diff --git "a/pgsql-performance.200508" "b/pgsql-performance.200508" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200508" @@ -0,0 +1,63994 @@ +From pgsql-performance-owner@postgresql.org Mon Aug 1 01:05:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3260352B7F + for ; + Mon, 1 Aug 2005 01:05:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63398-06 + for ; + Mon, 1 Aug 2005 04:04:55 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 812C052AC2 + for ; + Mon, 1 Aug 2005 01:04:53 -0300 (ADT) +Received: from ppp-66-143-176-222.dsl.austtx.swbell.net ([66.143.176.222] + helo=mail.herk.net) + by outbound.mailhop.org with esmtpsa (TLSv1:DES-CBC3-SHA:168) + (Exim 4.51) id 1DzRXn-000Bll-SZ + for pgsql-performance@postgresql.org; Mon, 01 Aug 2005 00:04:52 -0400 +Received: from localhost (localhost [127.0.0.1]) (uid 500) + by mail.herk.net with local; Sun, 31 Jul 2005 23:04:49 -0500 + id 00114186.42ED9F61.00001AB0 +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 66.143.176.222 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: parkerm +Date: Sun, 31 Jul 2005 23:04:49 -0500 +From: Michael Parker +To: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +Message-ID: <20050801040443.GA6527@mail.herk.net> +References: <42E80C28.2040608@aptalaska.net> + <1122532023.25574.1.camel@localhost.localdomain> + <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=_mail-6832-1122869089-0001-2" +Content-Disposition: inline +In-Reply-To: <27897.1122748133@sss.pgh.pa.us> +User-Agent: Mutt/1.5.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/1 +X-Sequence-Number: 13748 + +This is a MIME-formatted message. If you see this text it means that your +E-mail software does not support MIME-formatted messages. + +--=_mail-6832-1122869089-0001-2 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +Hi All, + +As a SpamAssassin developer, who by my own admission has real problem +getting PostgreSQL to work well, I must thank everyone for their +feedback on this issue. Believe me when I say what is in the tree now +is a far cry from what used to be there, orders of magnitude faster +for sure. I think there are several good ideas that have come out of +this thread and I've set about attempting to implement them. + +Here is a version of the stored procedure, based in large part by the +one written by Tom Lane, that accepts and array of tokens and loops +over them to either update or insert them into the database (I'm not +including the greatest_int/least_int procedures but you've all seen +them before): + +CREATE OR REPLACE FUNCTION put_tokens(inuserid INTEGER, + intokenary BYTEA[], + inspam_count INTEGER, + inham_count INTEGER, + inatime INTEGER) +RETURNS VOID AS '=20 +DECLARE + _token BYTEA; + new_tokens INTEGER :=3D 0; +BEGIN + for i in array_lower(intokenary, 1) .. array_upper(intokenary, 1) + LOOP + _token :=3D intokenary[i]; + UPDATE bayes_token + SET spam_count =3D greatest_int(spam_count + inspam_count, 0), + ham_count =3D greatest_int(ham_count + inham_count, 0), + atime =3D greatest_int(atime, inatime) + WHERE id =3D inuserid=20 + AND token =3D _token;=20 + IF NOT FOUND THEN=20 + -- we do not insert negative counts, just return true + IF NOT (inspam_count < 0 OR inham_count < 0) THEN + INSERT INTO bayes_token (id, token, spam_count, + ham_count, atime)=20 + VALUES (inuserid, _token, inspam_count, inham_count, inatime);=20 + IF FOUND THEN + new_tokens :=3D new_tokens + 1; + END IF; + END IF; + END IF; + END LOOP; + + UPDATE bayes_vars + SET token_count =3D token_count + new_tokens, + newest_token_age =3D greatest_int(newest_token_age, inatime), + oldest_token_age =3D least_int(oldest_token_age, inatime) + WHERE id =3D inuserid; + RETURN; +END;=20 +' LANGUAGE 'plpgsql';=20 + +This version is about 32x faster than the old version, with the +default fsync value and autovacuum running in the background. + +The next hurdle, and I've just posted to the DBD::Pg list, is +escaping/quoting the token strings. They are true binary strings, +substrings of SHA1 hashes, I don't think the original data set +provided puts them in the right context. They have proved to be +tricky. I'm unable to call the stored procedure from perl because I +keep getting a malformed array litteral error. + +Here is some example code that shows the issue: +#!/usr/bin/perl -w + +# from a new db, do this first +# INSERT INTO bayes_vars VALUES (1,'nobody',0,0,0,0,0,0,2147483647,0); + +use strict; +use DBI; +use DBD::Pg qw(:pg_types); +use Digest::SHA1 qw(sha1); + +my $dbh =3D DBI->connect("DBI:Pg:dbname=3Dspamassassin","postgres") || die; + +my @dataary; + +# Input is just a list of words (ie /usr/share/dict/words) stop after 150 +while(<>) { + chomp; + push(@dataary, substr(sha1($_), -5)); +# to see it work with normal string comment out above and uncomment below +# push(@dataary, $_); + last if scalar(@dataary) >=3D 150; +} + +my $datastring =3D join(",", map { '"' . bytea_esc($_) . '"' } +@dataary); +my $sql =3D "select put_tokens(1, '{$datastring}', 1, 1, 10000)"; +my $sth =3D $dbh->prepare($sql); +my $rc =3D $sth->execute(); +unless ($rc) { + print "Error: " . $dbh->errstr() . "\n"; +} +$sth->finish(); + +sub bytea_esc { + my ($str) =3D @_; + my $buf =3D ""; + foreach my $char (split(//,$str)) { + if (ord($char) =3D=3D 0) { $buf .=3D "\\\\000"; } + elsif (ord($char) =3D=3D 39) { $buf .=3D "\\\\047"; } + elsif (ord($char) =3D=3D 92) { $buf .=3D "\\\\134"; } + else { $buf .=3D $char; } + } + return $buf; +} + +Any ideas? or thoughts on the revised procedure? I'd greatly +appriciate them. + +Sorry for the length, but hopefully it give a good enough example. + +Thanks +Michael Parker + + +--=_mail-6832-1122869089-0001-2 +Content-Type: application/pgp-signature +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.0.7 (GNU/Linux) + +iD8DBQFC7Z9bG4km+uS4gOIRAklxAJ918GyBQKOnrblMY24M3GIsiVXjWQCfafn5 +K2WAqkOXTbmL9oLtY5UkchE= +=FGrI +-----END PGP SIGNATURE----- + +--=_mail-6832-1122869089-0001-2-- + +From pgsql-performance-owner@postgresql.org Mon Aug 1 01:42:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 315BC52A92 + for ; + Mon, 1 Aug 2005 01:42:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96541-07 + for ; + Mon, 1 Aug 2005 04:42:34 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A6EE052896 + for ; + Mon, 1 Aug 2005 01:42:33 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j714gUpc024579; + Mon, 1 Aug 2005 00:42:30 -0400 (EDT) +To: Michael Parker +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +In-reply-to: <20050801040443.GA6527@mail.herk.net> +References: <42E80C28.2040608@aptalaska.net> + <1122532023.25574.1.camel@localhost.localdomain> + <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <20050801040443.GA6527@mail.herk.net> +Comments: In-reply-to Michael Parker + message dated "Sun, 31 Jul 2005 23:04:49 -0500" +Date: Mon, 01 Aug 2005 00:42:30 -0400 +Message-ID: <24578.1122871350@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/2 +X-Sequence-Number: 13749 + +Michael Parker writes: +> The next hurdle, and I've just posted to the DBD::Pg list, is +> escaping/quoting the token strings. + +If you're trying to write a bytea[] literal, I think the most reliable +way to write the individual bytes is + \\\\nnn +where nnn is *octal*. The idea here is: + * string literal parser takes off one level of backslashing, + leaving \\nnn + * array input parser takes off another level, leaving \nnn + * bytea input parser knows about backslashed octal values + +Note it has to be 3 octal digits every time, no abbreviations. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 1 01:54:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7186752812 + for ; + Mon, 1 Aug 2005 01:54:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98576-09 + for ; + Mon, 1 Aug 2005 04:54:38 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A937D52AFC + for ; + Mon, 1 Aug 2005 01:54:37 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j714rMLp024658; + Mon, 1 Aug 2005 00:53:22 -0400 (EDT) +To: Michael Parker +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +In-reply-to: <20050801040443.GA6527@mail.herk.net> +References: <42E80C28.2040608@aptalaska.net> + <1122532023.25574.1.camel@localhost.localdomain> + <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <20050801040443.GA6527@mail.herk.net> +Comments: In-reply-to Michael Parker + message dated "Sun, 31 Jul 2005 23:04:49 -0500" +Date: Mon, 01 Aug 2005 00:53:22 -0400 +Message-ID: <24657.1122872002@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/3 +X-Sequence-Number: 13750 + +Michael Parker writes: +> sub bytea_esc { +> my ($str) = @_; +> my $buf = ""; +> foreach my $char (split(//,$str)) { +> if (ord($char) == 0) { $buf .= "\\\\000"; } +> elsif (ord($char) == 39) { $buf .= "\\\\047"; } +> elsif (ord($char) == 92) { $buf .= "\\\\134"; } +> else { $buf .= $char; } +> } +> return $buf; +> } + +Oh, I see the problem: you forgot to convert " to a backslash sequence. + +It would probably also be wise to convert anything >= 128 to a backslash +sequence, so as to avoid any possible problems with multibyte character +encodings. You wouldn't see this issue in a SQL_ASCII database, but I +suspect it would rise up to bite you with other encoding settings. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 1 13:34:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C2A2D52B53 + for ; + Mon, 1 Aug 2005 13:34:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47285-10 + for ; + Mon, 1 Aug 2005 16:34:07 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 47D8C52B3D + for ; + Mon, 1 Aug 2005 13:34:06 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j71GWYsQ010469; + Mon, 1 Aug 2005 12:32:34 -0400 (EDT) +To: "Luke Lonergan" +Cc: "Bruce Momjian" , "Mark Wong" , + "Joshua D. Drake" , + "Patrick Welche" , + pgsql-performance@postgresql.org, maryedie@osdl.org +Subject: Re: [PATCHES] COPY FROM performance improvements +In-reply-to: +References: +Comments: In-reply-to "Luke Lonergan" + message dated "Fri, 29 Jul 2005 10:54:08 -0700" +Date: Mon, 01 Aug 2005 12:32:34 -0400 +Message-ID: <10468.1122913954@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/4 +X-Sequence-Number: 13751 + +"Luke Lonergan" writes: +> On 7/29/05 5:37 AM, "Bruce Momjian" wrote: +>> Where is the most recent version of the COPY patch? + +> I've attached it here, sorry to the list owner for the patch inclusion / +> off-topic. + +This patch appears to reverse out the most recent committed changes in +copy.c. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 1 14:09:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F0CC052B6C + for ; + Mon, 1 Aug 2005 14:09:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57555-10 + for ; + Mon, 1 Aug 2005 17:09:19 +0000 (GMT) +Received: from larry.aptalaska.net (larry.aptalaska.net [64.186.96.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 61CF752B53 + for ; + Mon, 1 Aug 2005 14:09:18 -0300 (ADT) +Received: from [192.168.98.9] (rdbck-static-287.palmer.mtaonline.net + [64.4.232.33]) (authenticated bits=0) + by larry.aptalaska.net (8.13.4/8.13.4) with ESMTP id j71HMx7V014924 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Mon, 1 Aug 2005 09:23:00 -0800 +Message-ID: <42EE5720.2020306@aptalaska.net> +Date: Mon, 01 Aug 2005 09:08:48 -0800 +From: Matthew Schumacher +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Michael Parker , + pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E80C28.2040608@aptalaska.net> + <1122532023.25574.1.camel@localhost.localdomain> + <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <20050801040443.GA6527@mail.herk.net> + <24657.1122872002@sss.pgh.pa.us> +In-Reply-To: <24657.1122872002@sss.pgh.pa.us> +X-Enigmail-Version: 0.91.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Spam-Bayes: Learn: unavailable +X-Scanned-By: MIMEDefang 2.52 on 64.186.96.3 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/5 +X-Sequence-Number: 13752 + +Tom Lane wrote: +> Michael Parker writes: +> +>>sub bytea_esc { +>> my ($str) = @_; +>> my $buf = ""; +>> foreach my $char (split(//,$str)) { +>> if (ord($char) == 0) { $buf .= "\\\\000"; } +>> elsif (ord($char) == 39) { $buf .= "\\\\047"; } +>> elsif (ord($char) == 92) { $buf .= "\\\\134"; } +>> else { $buf .= $char; } +>> } +>> return $buf; +>>} +> +> +> Oh, I see the problem: you forgot to convert " to a backslash sequence. +> +> It would probably also be wise to convert anything >= 128 to a backslash +> sequence, so as to avoid any possible problems with multibyte character +> encodings. You wouldn't see this issue in a SQL_ASCII database, but I +> suspect it would rise up to bite you with other encoding settings. +> +> regards, tom lane + +Here is some code that applies Toms Suggestions: + +38c39,41 +< if (ord($char) == 0) { $buf .= "\\\\000"; } +--- +> if (ord($char) >= 128) { $buf .= "\\\\" . sprintf ("%lo", +ord($char)); } +> elsif (ord($char) == 0) { $buf .= "\\\\000"; } +> elsif (ord($char) == 34) { $buf .= "\\\\042"; } + +But this begs the question, why not escape everything? + +schu + +From pgsql-performance-owner@postgresql.org Mon Aug 1 16:48:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D9AD52B81 + for ; + Mon, 1 Aug 2005 16:48:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00978-05 + for ; + Mon, 1 Aug 2005 19:48:34 +0000 (GMT) +Received: from mail.Mi8.com (nycgw05.mi8.com [63.240.6.46]) + by svr1.postgresql.org (Postfix) with ESMTP id 667F8529B6 + for ; + Mon, 1 Aug 2005 16:48:33 -0300 (ADT) +Received: from 172.16.1.112 by mail.Mi8.com with ESMTP (- GW05 Welcome + to Mi8 Corporation www.Mi8.com); Mon, 01 Aug 2005 15:48:27 -0400 +X-Server-Uuid: E0C866E6-C6CD-48B5-AE61-E57E73CF3CC7 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Mon, 1 Aug 2005 + 15:48:26 -0400 +Received: from 141.156.39.156 ([141.156.39.156]) by MI8NYCMAIL06.Mi8.com + ([172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.104]) with Microsoft Exchange Server HTTP-DAV ; Mon, 1 Aug + 2005 15:48:26 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Mon, 01 Aug 2005 15:48:35 -0400 +Subject: Re: [PATCHES] COPY FROM performance improvements +From: "Alon Goldshuv" +To: pgsql-performance@postgresql.org +Cc: "Luke Lonergan" +Message-ID: +In-Reply-To: +MIME-Version: 1.0 +X-OriginalArrivalTime: 01 Aug 2005 19:48:26.0998 (UTC) + FILETIME=[FBFDE960:01C596D1] +X-WSS-ID: 6EF0A30126S57177-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.581 tagged_above=0 required=5 + tests=FORGED_RCVD_HELO, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200508/6 +X-Sequence-Number: 13753 + +Tom, + +>> I've attached it here, sorry to the list owner for the patch inclusion / +>> off-topic. +> +> This patch appears to reverse out the most recent committed changes in +> copy.c. + +Which changes do you refer to? I thought I accommodated all the recent +changes (I recall some changes to the tupletable/tupleslot interface, HEADER +in cvs, and hex escapes and maybe one or 2 more). What did I miss? + +Thanks. +Alon. + + + +From pgsql-performance-owner@postgresql.org Mon Aug 1 17:04:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F09952C26 + for ; + Mon, 1 Aug 2005 17:04:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17736-01 + for ; + Mon, 1 Aug 2005 20:04:22 +0000 (GMT) +Received: from larry.aptalaska.net (larry.aptalaska.net [64.186.96.3]) + by svr1.postgresql.org (Postfix) with ESMTP id ECD1252C3C + for ; + Mon, 1 Aug 2005 17:04:20 -0300 (ADT) +Received: from [192.168.98.9] (rdbck-static-287.palmer.mtaonline.net + [64.4.232.33]) (authenticated bits=0) + by larry.aptalaska.net (8.13.4/8.13.4) with ESMTP id j71KIWF6025299 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Mon, 1 Aug 2005 12:18:32 -0800 +Message-ID: <42EE8043.1050207@aptalaska.net> +Date: Mon, 01 Aug 2005 12:04:19 -0800 +From: Matthew Schumacher +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E80C28.2040608@aptalaska.net> + <1122532023.25574.1.camel@localhost.localdomain> + <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> +In-Reply-To: <27897.1122748133@sss.pgh.pa.us> +X-Enigmail-Version: 0.91.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Spam-Bayes: Learn: unavailable +X-Scanned-By: MIMEDefang 2.52 on 64.186.96.3 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/7 +X-Sequence-Number: 13754 + +Tom Lane wrote: +> +> Revised insertion procedure: +> +> +> CREATE or replace FUNCTION put_tokens (_id INTEGER, +> _tokens BYTEA[], +> _spam_count INTEGER, +> _ham_count INTEGER, +> _atime INTEGER) +> RETURNS VOID AS +> $$ +> declare _token bytea; +> new_tokens integer := 0; +> BEGIN +> for i in array_lower(_tokens,1) .. array_upper(_tokens,1) +> LOOP +> _token := _tokens[i]; +> UPDATE bayes_token +> SET spam_count = spam_count + _spam_count, +> ham_count = ham_count + _ham_count, +> atime = _atime +> WHERE id = _id +> AND token = _token; +> +> IF not found THEN +> INSERT INTO bayes_token VALUES (_id, _token, _spam_count, +> _ham_count, _atime); +> new_tokens := new_tokens + 1; +> END IF; +> END LOOP; +> if new_tokens > 0 THEN +> UPDATE bayes_vars SET token_count = token_count + new_tokens +> WHERE id = _id; +> IF NOT FOUND THEN +> RAISE EXCEPTION 'unable to update token_count in bayes_vars'; +> END IF; +> END IF; +> RETURN; +> END; +> $$ +> LANGUAGE plpgsql; +> + +Tom, thanks for all your help on this, I think we are fairly close to +having this done in a proc. The biggest problem we are running into now +is that the data gets inserted as an int. Even though your proc defines +_token as byeta, I get numbers in the table. For example: + +select put_tokens2(1, '{"\\246\\323\\061\\332\\277"}', 1, 1, 10000); + +produces this: + + id | token | spam_count | ham_count | atime +----+-----------------+------------+-----------+------- + 1 | 246323061332277 | 1 | 1 | 10000 + +I'm not sure why this is happening, perhaps the problem is obvious to you? + +Thanks, +schu + +From pgsql-performance-owner@postgresql.org Mon Aug 1 18:18:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E46352C00 + for ; + Mon, 1 Aug 2005 18:18:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68863-01 + for ; + Mon, 1 Aug 2005 21:18:25 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 271DF52B0E + for ; + Mon, 1 Aug 2005 18:18:23 -0300 (ADT) +Received: (qmail 26635 invoked from network); 1 Aug 2005 23:18:32 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 1 Aug 2005 23:18:32 +0200 +To: "Matthew Schumacher" , + "Tom Lane" +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E80C28.2040608@aptalaska.net> + <1122532023.25574.1.camel@localhost.localdomain> + <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> <42EE8043.1050207@aptalaska.net> +Message-ID: +Date: Mon, 01 Aug 2005 23:18:23 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <42EE8043.1050207@aptalaska.net> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/8 +X-Sequence-Number: 13755 + + + +> select put_tokens2(1, '{"\\246\\323\\061\\332\\277"}', 1, 1, 10000); + + Try adding more backslashes until it works (seems that you need \\\\ or +something). + Don't DBI convert the language types to postgres quoted forms on its own ? + + +From pgsql-performance-owner@postgresql.org Mon Aug 1 18:28:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3454752E31 + for ; + Mon, 1 Aug 2005 18:28:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63606-07 + for ; + Mon, 1 Aug 2005 21:28:30 +0000 (GMT) +Received: from larry.aptalaska.net (larry.aptalaska.net [64.186.96.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EAC252DF6 + for ; + Mon, 1 Aug 2005 18:28:29 -0300 (ADT) +Received: from [192.168.98.9] (rdbck-static-287.palmer.mtaonline.net + [64.4.232.33]) (authenticated bits=0) + by larry.aptalaska.net (8.13.4/8.13.4) with ESMTP id j71LgbQr011048 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Mon, 1 Aug 2005 13:42:38 -0800 +Message-ID: <42EE93F8.5010003@aptalaska.net> +Date: Mon, 01 Aug 2005 13:28:24 -0800 +From: Matthew Schumacher +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PFC +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E80C28.2040608@aptalaska.net> + <1122532023.25574.1.camel@localhost.localdomain> + <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> +In-Reply-To: +X-Enigmail-Version: 0.91.0.0 +Content-Type: text/plain; charset=ISO-8859-15 +Content-Transfer-Encoding: 7bit +X-Spam-Bayes: Learn: ham +X-Scanned-By: MIMEDefang 2.52 on 64.186.96.3 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/9 +X-Sequence-Number: 13756 + +PFC wrote: +> +> +>> select put_tokens2(1, '{"\\246\\323\\061\\332\\277"}', 1, 1, 10000); +> +> +> Try adding more backslashes until it works (seems that you need \\\\ +> or something). +> Don't DBI convert the language types to postgres quoted forms on its +> own ? +> + +Your right.... I am finding that the proc is not the problem as I +suspected, it works correctly when I am not calling it from perl, +something isn't escaped correctly.... + +schu + +From pgsql-performance-owner@postgresql.org Mon Aug 1 18:50:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2589952BA2 + for ; + Mon, 1 Aug 2005 18:49:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79715-06 + for ; + Mon, 1 Aug 2005 21:49:30 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DC0452BE0 + for ; + Mon, 1 Aug 2005 18:49:29 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id C41D015233; Mon, 1 Aug 2005 16:49:31 -0500 (CDT) +Date: Mon, 1 Aug 2005 16:49:31 -0500 +From: "Jim C. Nasby" +To: Matthew Schumacher +Cc: PFC , Tom Lane , + pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +Message-ID: <20050801214931.GF60019@decibel.org> +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <42EE93F8.5010003@aptalaska.net> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/10 +X-Sequence-Number: 13757 + +On Mon, Aug 01, 2005 at 01:28:24PM -0800, Matthew Schumacher wrote: +> PFC wrote: +> > +> > +> >> select put_tokens2(1, '{"\\246\\323\\061\\332\\277"}', 1, 1, 10000); +> > +> > +> > Try adding more backslashes until it works (seems that you need \\\\ +> > or something). +> > Don't DBI convert the language types to postgres quoted forms on its +> > own ? +> > +> +> Your right.... I am finding that the proc is not the problem as I +> suspected, it works correctly when I am not calling it from perl, +> something isn't escaped correctly.... + +I'm not sure who's responsible for DBI::Pg (Josh?), but would it make +sense to add better support for bytea to DBI::Pg? ISTM there should be a +better way of doing this than adding gobs of \'s. +-- +Jim C. Nasby, Database Consultant decibel@decibel.org +Give your computer some brain candy! www.distributed.net Team #1828 + +Windows: "Where do you want to go today?" +Linux: "Where do you want to go tomorrow?" +FreeBSD: "Are you guys coming, or what?" + +From pgsql-performance-owner@postgresql.org Mon Aug 1 19:09:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6337452C2F + for ; + Mon, 1 Aug 2005 19:09:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85765-03 + for ; + Mon, 1 Aug 2005 22:09:21 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C5E952BFA + for ; + Mon, 1 Aug 2005 19:09:20 -0300 (ADT) +Received: from ppp-66-143-176-222.dsl.austtx.swbell.net ([66.143.176.222] + helo=mail.herk.net) + by outbound.mailhop.org with esmtpsa (TLSv1:DES-CBC3-SHA:168) + (Exim 4.51) id 1DziTK-000A8w-7n + for pgsql-performance@postgresql.org; Mon, 01 Aug 2005 18:09:22 -0400 +Received: from [192.168.1.100] ([192.168.1.1]) (AUTH: LOGIN parker@herk.net) + by mail.herk.net with esmtp; Mon, 01 Aug 2005 17:09:20 -0500 + id 0011A3A1.42EE9D90.0000707B +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 66.143.176.222 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: parkerm +Message-ID: <42EE9D83.8000405@pobox.com> +Date: Mon, 01 Aug 2005 17:09:07 -0500 +From: Michael Parker +User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; + rv:1.7.6) Gecko/20050317 Thunderbird/1.0.2 Mnenhy/0.7.2.0 +X-Accept-Language: en-us, en +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=_mail-28795-1122934160-0001-2" +To: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> +In-Reply-To: <20050801214931.GF60019@decibel.org> +X-Enigmail-Version: 0.91.0.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/11 +X-Sequence-Number: 13758 + +This is a MIME-formatted message. If you see this text it means that your +E-mail software does not support MIME-formatted messages. + +--=_mail-28795-1122934160-0001-2 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Jim C. Nasby wrote: + +>I'm not sure who's responsible for DBI::Pg (Josh?), but would it make +>sense to add better support for bytea to DBI::Pg? ISTM there should be a +>better way of doing this than adding gobs of \'s. +> +> +It has support for binding a bytea parameter, but in this case we're +trying to build up an array and pass that into a stored procedure. The +$dbh->quote() method for DBD::Pg lacks the ability to quote bytea +types. There is actually a TODO note in the code about adding support +for quoting Pg specific types. Presumabliy the difficulties we are +having with this would be solved by that, once it has been implemented. +In the meantime, I believe it's just a matter of getting the right +escapes happen so that the procedure is inserting values that we can +later get via a select and using bind_param() with the PG_BYTEA type. + +Michael + +--=_mail-28795-1122934160-0001-2 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Transfer-Encoding: 7bit +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (Darwin) + +iD8DBQFC7p2HG4km+uS4gOIRAn9gAJwL+6XcJLjYloAjO3hOFKvlcTbzVwCeLwsy +RJPPQZDWRYPIer0eOcixutE= +=xv0t +-----END PGP SIGNATURE----- + +--=_mail-28795-1122934160-0001-2-- + +From pgsql-performance-owner@postgresql.org Mon Aug 1 19:19:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A24ED52E45 + for ; + Mon, 1 Aug 2005 19:19:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85345-06 + for ; + Mon, 1 Aug 2005 22:19:26 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 1246952931 + for ; + Mon, 1 Aug 2005 19:19:25 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i4so1100741wra + for ; + Mon, 01 Aug 2005 15:19:28 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type; + b=S1ulFd5kkedaClcKR43dRSSo6OxcSgQUPkE3lhBTmCCkvYm9UBUcQSYLW2NuGwvveXY3W9EPNabq1FS0/oniPjGkLUyjwoZ1MXi8wJzd+aZ437sznaga3sxqsLrtNad8cw22RDtk31ffq9JojMptw5B5d0a3Z3yJP8MeMczFpbg= +Received: by 10.54.8.60 with SMTP id 60mr3266886wrh; + Mon, 01 Aug 2005 15:19:28 -0700 (PDT) +Received: by 10.54.42.25 with HTTP; Mon, 1 Aug 2005 15:19:27 -0700 (PDT) +Message-ID: +Date: Tue, 2 Aug 2005 00:19:27 +0200 +From: Meetesh Karia +Reply-To: meetesh.karia@alumni.duke.edu +To: pgsql-performance@postgresql.org +Subject: Planner incorrectly choosing seq scan over index scan +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3517_6467213.1122934767947" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.231 tagged_above=0 required=5 tests=AWL, HTML_40_50, + HTML_MESSAGE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/12 +X-Sequence-Number: 13759 + +------=_Part_3517_6467213.1122934767947 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi all, + +We're using 8.0.3 and we're seeing a problem where the planner is choosing = +a=20 +seq scan and hash join over an index scan. If I set enable_hashjoin to off,= +=20 +then I get the plan I'm expecting and the query runs a lot faster. I've als= +o=20 +tried lowering the random page cost (even to 1) but the planner still=20 +chooses to use the hash join. + +Does anyone have any thoughts/suggestions? I saw that there was a thread=20 +recently in which the planner wasn't correctly estimating the cost for=20 +queries using LIMIT. Is it possible that something similar is happening her= +e=20 +(perhaps because of the sort) and that the patch Tom proposed would fix it? + +Thanks. Here are the various queries and plans: + +Normal settings +------------------------ +explain analyze +select +c.sourceId, +c.targetId, +abs(c.tr - c.sr ) as xmy, +(c.sr - s.ar ) * (c.tr - +t.ar) +as xy, +(c.sr - s.ar ) * (c.sr - +s.ar) +as x2, +(c.tr - t.ar ) * (c.tr - +t.ar) +as y2 +from +candidates617004 c, +lte_user s, +lte_user t +where +c.sourceId =3D s.user_id +and c.targetId =3D t.user_id +order by +c.sourceId, +c.targetId; + +QUERY PLAN +Sort (cost=3D13430.57..13439.24 rows=3D3467 width=3D48) (actual time=3D +1390.000..1390.000 rows=3D3467 loops=3D1) +Sort Key: c.sourceid, c.targetid +-> Merge Join (cost=3D9912.07..13226.72 rows=3D3467 width=3D48) (actual tim= +e=3D +1344.000..1375.000 rows=3D3467 loops=3D1) +Merge Cond: ("outer".user_id =3D "inner".sourceid) +-> Index Scan using lte_user_pkey on lte_user s +(cost=3D0.00..16837.71rows=3D279395 width=3D16) (actual time=3D +0.000..95.000 rows=3D50034 loops=3D1) +-> Sort (cost=3D9912.07..9920.73 rows=3D3467 width=3D40) (actual time=3D +1156.000..1156.000 rows=3D3467 loops=3D1) +Sort Key: c.sourceid +-> Hash Join (cost=3D8710.44..9708.21 rows=3D3467 width=3D40) (actual time= +=3D +1125.000..1156.000 rows=3D3467 loops=3D1) +Hash Cond: ("outer".targetid =3D "inner".user_id) +-> Seq Scan on candidates617004 c (cost=3D0.00..67.67 rows=3D3467 width=3D3= +2)=20 +(actual time=3D0.000..0.000 rows=3D3467 loops=3D1) +-> Hash (cost=3D8011.95..8011.95 rows=3D279395 width=3D16) (actual time=3D +1125.000..1125.000 rows=3D0 loops=3D1) +-> Seq Scan on lte_user t (cost=3D0.00..8011.95 rows=3D279395 width=3D16) (= +actual=20 +time=3D0.000..670.000 rows=3D279395 loops=3D1) +Total runtime: 1406.000 ms + +enable_hashjoin disabled +---------------------------------------- +QUERY PLAN +Sort (cost=3D14355.37..14364.03 rows=3D3467 width=3D48) (actual time=3D +391.000..391.000 rows=3D3467 loops=3D1) +Sort Key: c.sourceid, c.targetid +-> Nested Loop (cost=3D271.52..14151.51 rows=3D3467 width=3D48) (actual tim= +e=3D +203.000..359.000 rows=3D3467 loops=3D1) +-> Merge Join (cost=3D271.52..3490.83 rows=3D3467 width=3D40) (actual time= +=3D +203.000..218.000 rows=3D3467 loops=3D1) +Merge Cond: ("outer".user_id =3D "inner".sourceid) +-> Index Scan using lte_user_pkey on lte_user s +(cost=3D0.00..16837.71rows=3D279395 width=3D16) (actual time=3D +0.000..126.000 rows=3D50034 loops=3D1) +-> Sort (cost=3D271.52..280.19 rows=3D3467 width=3D32) (actual +time=3D15.000..30.000rows=3D3467 loops=3D1) +Sort Key: c.sourceid +-> Seq Scan on candidates617004 c (cost=3D0.00..67.67 rows=3D3467 width=3D3= +2)=20 +(actual time=3D0.000..0.000 rows=3D3467 loops=3D1) +-> Index Scan using lte_user_pkey on lte_user t (cost=3D0.00..3.03 rows=3D1= +=20 +width=3D16) (actual time=3D0.031..0.036 rows=3D1 loops=3D3467) +Index Cond: ("outer".targetid =3D t.user_id) +Total runtime: 406.000 ms + +random_page_cost set to 1.5 +---------------------------------------------- +QUERY PLAN +Sort (cost=3D12702.62..12711.29 rows=3D3467 width=3D48) (actual time=3D +1407.000..1407.000 rows=3D3467 loops=3D1) +Sort Key: c.sourceid, c.targetid +-> Merge Join (cost=3D9912.07..12498.77 rows=3D3467 width=3D48) (actual tim= +e=3D +1391.000..1407.000 rows=3D3467 loops=3D1) +Merge Cond: ("outer".user_id =3D "inner".sourceid) +-> Index Scan using lte_user_pkey on lte_user s +(cost=3D0.00..12807.34rows=3D279395 width=3D16) (actual time=3D +0.000..46.000 rows=3D50034 loops=3D1) +-> Sort (cost=3D9912.07..9920.73 rows=3D3467 width=3D40) (actual time=3D +1188.000..1188.000 rows=3D3467 loops=3D1) +Sort Key: c.sourceid +-> Hash Join (cost=3D8710.44..9708.21 rows=3D3467 width=3D40) (actual time= +=3D +1157.000..1188.000 rows=3D3467 loops=3D1) +Hash Cond: ("outer".targetid =3D "inner".user_id) +-> Seq Scan on candidates617004 c (cost=3D0.00..67.67 rows=3D3467 width=3D3= +2)=20 +(actual time=3D0.000..15.000 rows=3D3467 loops=3D1) +-> Hash (cost=3D8011.95..8011.95 rows=3D279395 width=3D16) (actual time=3D +1157.000..1157.000 rows=3D0 loops=3D1) +-> Seq Scan on lte_user t (cost=3D0.00..8011.95 rows=3D279395 width=3D16) (= +actual=20 +time=3D0.000..750.000 rows=3D279395 loops=3D1) +Total runtime: 1422.000 ms + +random_page_cost set to 1.5 and enable_hashjoin set to false +---------------------------------------------------------------------------= +----------------------- +QUERY PLAN +Sort (cost=3D13565.58..13574.25 rows=3D3467 width=3D48) (actual time=3D +390.000..390.000 rows=3D3467 loops=3D1) +Sort Key: c.sourceid, c.targetid +-> Nested Loop (cost=3D271.52..13361.73 rows=3D3467 width=3D48) (actual tim= +e=3D +203.000..360.000 rows=3D3467 loops=3D1) +-> Merge Join (cost=3D271.52..2762.88 rows=3D3467 width=3D40) (actual time= +=3D +203.000..250.000 rows=3D3467 loops=3D1) +Merge Cond: ("outer".user_id =3D "inner".sourceid) +-> Index Scan using lte_user_pkey on lte_user s +(cost=3D0.00..12807.34rows=3D279395 width=3D16) (actual time=3D +0.000..48.000 rows=3D50034 loops=3D1) +-> Sort (cost=3D271.52..280.19 rows=3D3467 width=3D32) (actual +time=3D15.000..31.000rows=3D3467 loops=3D1) +Sort Key: c.sourceid +-> Seq Scan on candidates617004 c (cost=3D0.00..67.67 rows=3D3467 width=3D3= +2)=20 +(actual time=3D0.000..15.000 rows=3D3467 loops=3D1) +-> Index Scan using lte_user_pkey on lte_user t (cost=3D0.00..3.02 rows=3D1= +=20 +width=3D16) (actual time=3D0.023..0.023 rows=3D1 loops=3D3467) +Index Cond: ("outer".targetid =3D t.user_id) +Total runtime: 406.000 ms + +Thanks, +Meetesh + +------=_Part_3517_6467213.1122934767947 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi all,
+
+We're using 8.0.3 and we're seeing a problem where the planner is +choosing a seq scan and hash join over an index scan.  If I set +enable_hashjoin to off, then I get the plan I'm expecting and the query +runs a lot faster.  I've also tried lowering the random page cost +(even to 1) but the planner still chooses to use the hash join.
+
+Does anyone have any thoughts/suggestions?  I saw that there was a +thread recently in which the planner wasn't correctly estimating the +cost for queries using LIMIT.  Is it possible that something +similar is happening here (perhaps because of the sort) and that the +patch Tom proposed would fix it?
+
+Thanks.  Here are the various queries and plans:
+
+Normal settings
+------------------------
+explain analyze
+    select
+        c.sourceId,
+        c.targetId,
+        abs(c.tr= + - c.sr) as xmy,
+        (c.sr - s.ar) * (c.tr -= + t.ar) as xy,
+        (c.sr - s.ar) * (c.sr -= + s.ar) as x2,
+        (c.tr - t.ar) * (c.tr -= + t.ar) as y2
+    from
+        candidates617004 c,
+        lte_user s,
+        lte_user t
+    where
+        c.sourceId =3D s.user_id
+        and c.targetId =3D t.user_id
+    order by
+        c.sourceId,
+        c.targetId;
+
+QUERY PLAN
+Sort  (cost=3D13430.57..13439.24 rows=3D3467 width=3D48) (actual time= +=3D1390.000..1390.000 rows=3D3467 loops=3D1)
+  Sort Key: c.sourceid, c.targetid
+  ->  Merge Join  (cost=3D9912.07..13226.72 rows=3D3467 +width=3D48) (actual time=3D1344.000..1375.000 rows=3D3467 loops=3D1)
+        Merge Cond: ("outer".u= +ser_id =3D "inner".sourceid)
+        ->  Index Scan using +lte_user_pkey on lte_user s  (cost=3D0.00..16837.71 rows=3D279395 +width=3D16) (actual time=3D0.000..95.000 rows=3D50034 loops=3D1)
+        ->  Sort  +(cost=3D9912.07..9920.73 rows=3D3467 width=3D40) (actual +time=3D1156.000..1156.000 rows=3D3467 loops=3D1)
+            &nb= +sp; Sort Key: c.sourceid
+            &nb= +sp; +->  Hash Join  (cost=3D8710.44..9708.21 rows=3D3467 width=3D40= +) +(actual time=3D1125.000..1156.000 rows=3D3467 loops=3D1)
+            &nb= +sp;       +Hash Cond: ("outer".targetid =3D "inner".user_id)
+            &nb= +sp;       +->  Seq Scan on candidates617004 c  (cost=3D0.00..67.67 +rows=3D3467 width=3D32) (actual time=3D0.000..0.000 rows=3D3467 loops=3D1)<= +br> +            &nb= +sp;       +->  Hash  (cost=3D8011.95..8011.95 rows=3D279395 width=3D16) +(actual time=3D1125.000..1125.000 rows=3D0 loops=3D1)
+            &nb= +sp;             +->  Seq Scan on lte_user t  (cost=3D0.00..8011.95 +rows=3D279395 width=3D16) (actual time=3D0.000..670.000 rows=3D279395 loops= +=3D1)
+Total runtime: 1406.000 ms
+
+enable_hashjoin disabled
+----------------------------------------
+QUERY PLAN
+Sort  (cost=3D14355.37..14364.03 rows=3D3467 width=3D48) (actual time= +=3D391.000..391.000 rows=3D3467 loops=3D1)
+  Sort Key: c.sourceid, c.targetid
+  ->  Nested Loop  (cost=3D271.52..14151.51 rows=3D3467 w= +idth=3D48) (actual time=3D203.000..359.000 rows=3D3467 loops=3D1)
+        ->  Merge Join  +(cost=3D271.52..3490.83 rows=3D3467 width=3D40) (actual time=3D203.000..218= +.000 +rows=3D3467 loops=3D1)
+            &nb= +sp; Merge Cond: ("outer".user_id =3D "inner".sourceid)<= +br> +            &nb= +sp; +->  Index Scan using lte_user_pkey on lte_user s  +(cost=3D0.00..16837.71 rows=3D279395 width=3D16) (actual time=3D0.000..126.= +000 +rows=3D50034 loops=3D1)
+            &nb= +sp; +->  Sort  (cost=3D271.52..280.19 rows=3D3467 width=3D32) (actu= +al +time=3D15.000..30.000 rows=3D3467 loops=3D1)
+            &nb= +sp;       +Sort Key: c.sourceid
+            &nb= +sp;       +->  Seq Scan on candidates617004 c  (cost=3D0.00..67.67 +rows=3D3467 width=3D32) (actual time=3D0.000..0.000 rows=3D3467 loops=3D1)<= +br> +        ->  Index Scan using +lte_user_pkey on lte_user t  (cost=3D0.00..3.03 rows=3D1 width=3D16) +(actual time=3D0.031..0.036 rows=3D1 loops=3D3467)
+            &nb= +sp; Index Cond: ("outer".targetid =3D t.user_id)
+Total runtime: 406.000 ms
+
+random_page_cost set to 1.5
+----------------------------------------------
+QUERY PLAN
+Sort  (cost=3D12702.62..12711.29 rows=3D3467 width=3D48) (actual time= +=3D1407.000..1407.000 rows=3D3467 loops=3D1)
+  Sort Key: c.sourceid, c.targetid
+  ->  Merge Join  (cost=3D9912.07..12498.77 rows=3D3467 +width=3D48) (actual time=3D1391.000..1407.000 rows=3D3467 loops=3D1)
+        Merge Cond: ("outer".u= +ser_id =3D "inner".sourceid)
+        ->  Index Scan using +lte_user_pkey on lte_user s  (cost=3D0.00..12807.34 rows=3D279395 +width=3D16) (actual time=3D0.000..46.000 rows=3D50034 loops=3D1)
+        ->  Sort  +(cost=3D9912.07..9920.73 rows=3D3467 width=3D40) (actual +time=3D1188.000..1188.000 rows=3D3467 loops=3D1)
+            &nb= +sp; Sort Key: c.sourceid
+            &nb= +sp; +->  Hash Join  (cost=3D8710.44..9708.21 rows=3D3467 width=3D40= +) +(actual time=3D1157.000..1188.000 rows=3D3467 loops=3D1)
+            &nb= +sp;       +Hash Cond: ("outer".targetid =3D "inner".user_id)
+            &nb= +sp;       +->  Seq Scan on candidates617004 c  (cost=3D0.00..67.67 +rows=3D3467 width=3D32) (actual time=3D0.000..15.000 rows=3D3467 loops=3D1)= +
+            &nb= +sp;       +->  Hash  (cost=3D8011.95..8011.95 rows=3D279395 width=3D16) +(actual time=3D1157.000..1157.000 rows=3D0 loops=3D1)
+            &nb= +sp;             +->  Seq Scan on lte_user t  (cost=3D0.00..8011.95 +rows=3D279395 width=3D16) (actual time=3D0.000..750.000 rows=3D279395 loops= +=3D1)
+Total runtime: 1422.000 ms
+
+random_page_cost set to 1.5 and enable_hashjoin set to false
+---------------------------------------------------------------------------= +-----------------------
+QUERY PLAN
+Sort  (cost=3D13565.58..13574.25 rows=3D3467 width=3D48) (actual time= +=3D390.000..390.000 rows=3D3467 loops=3D1)
+  Sort Key: c.sourceid, c.targetid
+  ->  Nested Loop  (cost=3D271.52..13361.73 rows=3D3467 w= +idth=3D48) (actual time=3D203.000..360.000 rows=3D3467 loops=3D1)
+        ->  Merge Join  +(cost=3D271.52..2762.88 rows=3D3467 width=3D40) (actual time=3D203.000..250= +.000 +rows=3D3467 loops=3D1)
+            &nb= +sp; Merge Cond: ("outer".user_id =3D "inner".sourceid)<= +br> +            &nb= +sp; +->  Index Scan using lte_user_pkey on lte_user s  +(cost=3D0.00..12807.34 rows=3D279395 width=3D16) (actual time=3D0.000..48.0= +00 +rows=3D50034 loops=3D1)
+            &nb= +sp; +->  Sort  (cost=3D271.52..280.19 rows=3D3467 width=3D32) (actu= +al +time=3D15.000..31.000 rows=3D3467 loops=3D1)
+            &nb= +sp;       +Sort Key: c.sourceid
+            &nb= +sp;       +->  Seq Scan on candidates617004 c  (cost=3D0.00..67.67 +rows=3D3467 width=3D32) (actual time=3D0.000..15.000 rows=3D3467 loops=3D1)= +
+        ->  Index Scan using +lte_user_pkey on lte_user t  (cost=3D0.00..3.02 rows=3D1 width=3D16) +(actual time=3D0.023..0.023 rows=3D1 loops=3D3467)
+            &nb= +sp; Index Cond: ("outer".targetid =3D t.user_id)
+Total runtime: 406.000 ms
+
+Thanks,
+Meetesh
+ +------=_Part_3517_6467213.1122934767947-- + +From pgsql-performance-owner@postgresql.org Mon Aug 1 19:37:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BC0FF52894 + for ; + Mon, 1 Aug 2005 19:37:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91710-06 + for ; + Mon, 1 Aug 2005 22:37:21 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id BE84652B4E + for ; + Mon, 1 Aug 2005 19:37:16 -0300 (ADT) +Received: from [84.48.51.94] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1DzisS-0003iy-QW; Tue, 02 Aug 2005 00:35:29 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id AE30FE003B; Tue, 2 Aug 2005 00:37:08 +0200 (CEST) +Date: Tue, 2 Aug 2005 00:37:08 +0200 +From: Tobias Brox +To: meetesh.karia@alumni.duke.edu +Cc: pgsql-performance@postgresql.org +Subject: Re: Planner incorrectly choosing seq scan over index scan +Message-ID: <20050801223708.GE17649@tobias.lan> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +Organization: Group Nordicbet +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/13 +X-Sequence-Number: 13760 + +[Meetesh Karia - Tue at 12:19:27AM +0200] +> We're using 8.0.3 and we're seeing a problem where the planner is choosing a +> seq scan and hash join over an index scan. If I set enable_hashjoin to off, +> then I get the plan I'm expecting and the query runs a lot faster. I've also +> tried lowering the random page cost (even to 1) but the planner still +> chooses to use the hash join. + +Have you tried increasing the statistics collection? + +-- +Tobias Brox, +47-91700050 +Nordicbet, IT dept + +From pgsql-performance-owner@postgresql.org Mon Aug 1 20:16:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3877152C2A + for ; + Mon, 1 Aug 2005 20:16:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99393-07 + for ; + Mon, 1 Aug 2005 23:16:38 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id D701B52C15 + for ; + Mon, 1 Aug 2005 20:16:34 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050801231636m9100g65e3e>; Mon, 1 Aug 2005 23:16:36 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id C3F565604F; Mon, 1 Aug 2005 18:16:35 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 6FDF355FD0; + Mon, 1 Aug 2005 18:16:30 -0500 (CDT) +Message-ID: <42EEAD4B.4010905@arbash-meinel.com> +Date: Mon, 01 Aug 2005 18:16:27 -0500 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: meetesh.karia@alumni.duke.edu +Cc: pgsql-performance@postgresql.org +Subject: Re: Planner incorrectly choosing seq scan over index scan +References: +In-Reply-To: +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig3CCABE5B81B1FDFC3904F657" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.046 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/14 +X-Sequence-Number: 13761 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig3CCABE5B81B1FDFC3904F657 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Meetesh Karia wrote: +> Hi all, +> +> We're using 8.0.3 and we're seeing a problem where the planner is +> choosing a seq scan and hash join over an index scan. If I set +> enable_hashjoin to off, then I get the plan I'm expecting and the query +> runs a lot faster. I've also tried lowering the random page cost (even +> to 1) but the planner still chooses to use the hash join. +> +> Does anyone have any thoughts/suggestions? I saw that there was a +> thread recently in which the planner wasn't correctly estimating the +> cost for queries using LIMIT. Is it possible that something similar is +> happening here (perhaps because of the sort) and that the patch Tom +> proposed would fix it? +> +> Thanks. Here are the various queries and plans: +> +> Normal settings + +... + +> QUERY PLAN +> Sort (cost=13430.57..13439.24 rows=3467 width=48) (actual +> time=1390.000..1390.000 rows=3467 loops=1) +> Sort Key: c.sourceid, c.targetid +> -> Merge Join (cost=9912.07..13226.72 rows=3467 width=48) (actual +> time=1344.000..1375.000 rows=3467 loops=1) +> Merge Cond: ("outer".user_id = "inner".sourceid) +> -> Index Scan using lte_user_pkey on lte_user s +> (cost=0.00..16837.71 rows=279395 width=16) (actual time=0.000..95.000 +> rows=50034 loops=1) + +This is where the planner is messing up, and mis-estimating the +selectivity. It is expecting to get 280k rows, but only needs to get 50k. +I assume lte_user is the bigger table, and that candidates617004 has +some subset. + +Has lte_user and candidates617004 been recently ANALYZEd? All estimates, +except for the expected number of rows from lte_user seem to be okay. + +Is user_id the primary key for lte_user? +I'm trying to figure out how you can get 50k rows, by searching a +primary key, against a 3.5k rows. Is user_id only part of the primary +key for lte_user? + +Can you give us the output of: +\d lte_user +\d candidates617004 + +So that we have the description of the tables, and what indexes you have +defined? + +Also, if you could describe the table layouts, that would help. + +John +=:-> + + +> -> Sort (cost=9912.07..9920.73 rows=3467 width=40) (actual +> time=1156.000..1156.000 rows=3467 loops=1) +> Sort Key: c.sourceid +> -> Hash Join (cost=8710.44..9708.21 rows=3467 width=40) +> (actual time=1125.000..1156.000 rows=3467 loops=1) +> Hash Cond: ("outer".targetid = "inner".user_id) +> -> Seq Scan on candidates617004 c +> (cost=0.00..67.67 rows=3467 width=32) (actual time=0.000..0.000 +> rows=3467 loops=1) +> -> Hash (cost=8011.95..8011.95 rows=279395 +> width=16) (actual time=1125.000..1125.000 rows=0 loops=1) +> -> Seq Scan on lte_user t +> (cost=0.00..8011.95 rows=279395 width=16) (actual time=0.000..670.000 +> rows=279395 loops=1) +> Total runtime: 1406.000 ms +> +> enable_hashjoin disabled +> ---------------------------------------- +> QUERY PLAN +> Sort (cost=14355.37..14364.03 rows=3467 width=48) (actual +> time=391.000..391.000 rows=3467 loops=1) +> Sort Key: c.sourceid, c.targetid +> -> Nested Loop (cost=271.52..14151.51 rows=3467 width=48) (actual +> time=203.000..359.000 rows=3467 loops=1) +> -> Merge Join (cost=271.52..3490.83 rows=3467 width=40) +> (actual time=203.000..218.000 rows=3467 loops=1) +> Merge Cond: ("outer".user_id = "inner".sourceid) +> -> Index Scan using lte_user_pkey on lte_user s +> (cost=0.00..16837.71 rows=279395 width=16) (actual time=0.000..126.000 +> rows=50034 loops=1) +> -> Sort (cost=271.52..280.19 rows=3467 width=32) (actual +> time=15.000..30.000 rows=3467 loops=1) +> Sort Key: c.sourceid +> -> Seq Scan on candidates617004 c +> (cost=0.00..67.67 rows=3467 width=32) (actual time=0.000..0.000 +> rows=3467 loops=1) +> -> Index Scan using lte_user_pkey on lte_user t +> (cost=0.00..3.03 rows=1 width=16) (actual time=0.031..0.036 rows=1 +> loops=3467) +> Index Cond: ("outer".targetid = t.user_id) +> Total runtime: 406.000 ms +> +> random_page_cost set to 1.5 +> ---------------------------------------------- +> QUERY PLAN +> Sort (cost=12702.62..12711.29 rows=3467 width=48) (actual +> time=1407.000..1407.000 rows=3467 loops=1) +> Sort Key: c.sourceid, c.targetid +> -> Merge Join (cost=9912.07..12498.77 rows=3467 width=48) (actual +> time=1391.000..1407.000 rows=3467 loops=1) +> Merge Cond: ("outer".user_id = "inner".sourceid) +> -> Index Scan using lte_user_pkey on lte_user s +> (cost=0.00..12807.34 rows=279395 width=16) (actual time=0.000..46.000 +> rows=50034 loops=1) +> -> Sort (cost=9912.07..9920.73 rows=3467 width=40) (actual +> time=1188.000..1188.000 rows=3467 loops=1) +> Sort Key: c.sourceid +> -> Hash Join (cost=8710.44..9708.21 rows=3467 width=40) +> (actual time=1157.000..1188.000 rows=3467 loops=1) +> Hash Cond: ("outer".targetid = "inner".user_id) +> -> Seq Scan on candidates617004 c +> (cost=0.00..67.67 rows=3467 width=32) (actual time=0.000..15.000 +> rows=3467 loops=1) +> -> Hash (cost=8011.95..8011.95 rows=279395 +> width=16) (actual time=1157.000..1157.000 rows=0 loops=1) +> -> Seq Scan on lte_user t +> (cost=0.00..8011.95 rows=279395 width=16) (actual time=0.000..750.000 +> rows=279395 loops=1) +> Total runtime: 1422.000 ms +> +> random_page_cost set to 1.5 and enable_hashjoin set to false +> -------------------------------------------------------------------------------------------------- +> QUERY PLAN +> Sort (cost=13565.58..13574.25 rows=3467 width=48) (actual +> time=390.000..390.000 rows=3467 loops=1) +> Sort Key: c.sourceid, c.targetid +> -> Nested Loop (cost=271.52..13361.73 rows=3467 width=48) (actual +> time=203.000..360.000 rows=3467 loops=1) +> -> Merge Join (cost=271.52..2762.88 rows=3467 width=40) +> (actual time=203.000..250.000 rows=3467 loops=1) +> Merge Cond: ("outer".user_id = "inner".sourceid) +> -> Index Scan using lte_user_pkey on lte_user s +> (cost=0.00..12807.34 rows=279395 width=16) (actual time=0.000..48.000 +> rows=50034 loops=1) +> -> Sort (cost=271.52..280.19 rows=3467 width=32) (actual +> time=15.000..31.000 rows=3467 loops=1) +> Sort Key: c.sourceid +> -> Seq Scan on candidates617004 c +> (cost=0.00..67.67 rows=3467 width=32) (actual time=0.000..15.000 +> rows=3467 loops=1) +> -> Index Scan using lte_user_pkey on lte_user t +> (cost=0.00..3.02 rows=1 width=16) (actual time=0.023..0.023 rows=1 +> loops=3467) +> Index Cond: ("outer".targetid = t.user_id) +> Total runtime: 406.000 ms +> +> Thanks, +> Meetesh + + +--------------enig3CCABE5B81B1FDFC3904F657 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC7q1OJdeBCYSNAAMRAkenAJ94Lfxat19qbFY9gaS+cXNfINK3RQCeP2eK +jEJ19FqiH59B9F75X/RRTAE= +=5VvY +-----END PGP SIGNATURE----- + +--------------enig3CCABE5B81B1FDFC3904F657-- + +From pgsql-performance-owner@postgresql.org Mon Aug 1 20:30:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D7AC152C2A + for ; + Mon, 1 Aug 2005 20:30:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00446-07 + for ; + Mon, 1 Aug 2005 23:30:24 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F80B529E1 + for ; + Mon, 1 Aug 2005 20:30:23 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i4so1110508wra + for ; + Mon, 01 Aug 2005 16:30:27 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=m4BqNLZ3iSOshYiEm5uKTke3ymmdGumSz2y8iZGcPJibEXrkHHNBwcaAN0qpJEYkIwpM77MHnfZ/IE+EX+f4wo8s8Uo1HO/qpEO44an0Bi+6tYVEDf2QMy3FVoN8PNc2H6eoiuZyG0RakgnHwOBVVyfjY2dU/322g43BmELMa9E= +Received: by 10.54.129.7 with SMTP id b7mr3320848wrd; + Mon, 01 Aug 2005 16:30:26 -0700 (PDT) +Received: by 10.54.42.25 with HTTP; Mon, 1 Aug 2005 16:30:26 -0700 (PDT) +Message-ID: +Date: Tue, 2 Aug 2005 01:30:26 +0200 +From: Meetesh Karia +Reply-To: meetesh.karia@alumni.duke.edu +To: Tobias Brox +Subject: Re: Planner incorrectly choosing seq scan over index scan +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20050801223708.GE17649@tobias.lan> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3553_30794248.1122939026870" +References: + <20050801223708.GE17649@tobias.lan> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.196 tagged_above=0 required=5 tests=AWL, HTML_30_40, + HTML_MESSAGE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/15 +X-Sequence-Number: 13762 + +------=_Part_3553_30794248.1122939026870 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Are you referring to the statistics gathering target for ANALYZE? Based on= +=20 +your email, I just tried the following and then re-ran the explain analyze= +=20 +but got the same "incorrect" plan: + +alter table candidates617004 +alter column sourceId set statistics 1000, +alter column targetId set statistics 1000; +analyze candidates617004; + +alter table lte_user +alter column user_id set statistics 1000; +analyze lte_user; + +Thanks for your suggestion, +Meetesh + +On 8/2/05, Tobias Brox wrote: +>=20 +> [Meetesh Karia - Tue at 12:19:27AM +0200] +> > We're using 8.0.3 and we're seeing a problem where the planner is=20 +> choosing a +> > seq scan and hash join over an index scan. If I set enable_hashjoin to= +=20 +> off, +> > then I get the plan I'm expecting and the query runs a lot faster. I've= +=20 +> also +> > tried lowering the random page cost (even to 1) but the planner still +> > chooses to use the hash join. +>=20 +> Have you tried increasing the statistics collection? +>=20 +> -- +> Tobias Brox, +47-91700050 +> Nordicbet, IT dept +> + +------=_Part_3553_30794248.1122939026870 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Are you referring to the statistics gathering target for ANALYZE?  +Based on your email, I just tried the following and then re-ran the +explain analyze but got the same "incorrect" plan:
+
+alter table candidates617004
+    alter column sourceId set statistics 1000,
+    alter column targetId set statistics 1000;
+analyze candidates617004;
+
+alter table lte_user
+    alter column user_id set statistics 1000;
+analyze lte_user;
+
Thanks for your suggestion,
+Meetesh
+
On 8/2/05, Tobias Brox <tobias@nordi= +cbet.com> wrote:
+[Meetesh Karia - Tue at 12:19:27AM +0200]
> We're using 8.0.3 and we'= +re seeing a problem where the planner is choosing a
> seq scan and ha= +sh join over an index scan. If I set enable_hashjoin to off,
> then I= + get the plan I'm expecting and the query runs a lot faster. I've also +
> tried lowering the random page cost (even to 1) but the planner st= +ill
> chooses to use the hash join.

Have you tried increasing = +the statistics collection?

--
Tobias Brox, +47-91700050
Nordic= +bet, IT dept +

+ +------=_Part_3553_30794248.1122939026870-- + +From pgsql-patches-owner@postgresql.org Mon Aug 1 20:51:18 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5859252BAB + for ; + Mon, 1 Aug 2005 20:51:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09155-04 + for ; + Mon, 1 Aug 2005 23:51:12 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A19652BA9 + for ; + Mon, 1 Aug 2005 20:51:11 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j71NpBIY026132; + Mon, 1 Aug 2005 19:51:11 -0400 (EDT) +To: "Alon Goldshuv" +Cc: pgsql-patches@postgresql.org, + "Luke Lonergan" +Subject: Re: [PERFORM] COPY FROM performance improvements +In-reply-to: +References: +Comments: In-reply-to "Alon Goldshuv" + message dated "Mon, 01 Aug 2005 15:48:35 -0400" +Date: Mon, 01 Aug 2005 19:51:10 -0400 +Message-ID: <26131.1122940270@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/25 +X-Sequence-Number: 16972 + +"Alon Goldshuv" writes: +>> This patch appears to reverse out the most recent committed changes in +>> copy.c. + +> Which changes do you refer to? I thought I accommodated all the recent +> changes (I recall some changes to the tupletable/tupleslot interface, HEADER +> in cvs, and hex escapes and maybe one or 2 more). What did I miss? + +The latest touch of copy.c, namely this patch: + +2005-07-10 17:13 tgl + + * doc/src/sgml/ref/create_type.sgml, src/backend/commands/copy.c, + src/backend/commands/typecmds.c, src/backend/tcop/fastpath.c, + src/backend/tcop/postgres.c, src/backend/utils/adt/arrayfuncs.c, + src/backend/utils/adt/date.c, src/backend/utils/adt/numeric.c, + src/backend/utils/adt/rowtypes.c, + src/backend/utils/adt/timestamp.c, src/backend/utils/adt/varbit.c, + src/backend/utils/adt/varchar.c, src/backend/utils/adt/varlena.c, + src/backend/utils/mb/mbutils.c, src/include/catalog/catversion.h, + src/include/catalog/pg_proc.h, + src/test/regress/expected/type_sanity.out, + src/test/regress/sql/type_sanity.sql: Change typreceive function + API so that receive functions get the same optional arguments as + text input functions, ie, typioparam OID and atttypmod. Make all + the datatypes that use typmod enforce it the same way in typreceive + as they do in typinput. This fixes a problem with failure to + enforce length restrictions during COPY FROM BINARY. + +It was rather obvious, given that the first chunk of the patch backed up +the file's CVS version stamp from 1.247 to 1.246 :-( + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 1 20:56:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6000252C36 + for ; + Mon, 1 Aug 2005 20:56:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07610-10 + for ; + Mon, 1 Aug 2005 23:56:10 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 04E3652975 + for ; + Mon, 1 Aug 2005 20:56:09 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i4so1113717wra + for ; + Mon, 01 Aug 2005 16:56:13 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=PeOiPrwWnSbHxFREi+8ocmiW59eoHLVtllcMi9DCleHsrDVXW2/+rF6sP/v1cZAjaRFmU4kqQAmx7Rmo7rexL6fLQn8tNbdhFJT9symG+tPAQf6Yyg0YSreHbajvUkdBJ3g3JUrCnskoBT+8hGMUNqs53eTxjvUJ6Ysj8wEbQNY= +Received: by 10.54.57.21 with SMTP id f21mr3130742wra; + Mon, 01 Aug 2005 16:56:13 -0700 (PDT) +Received: by 10.54.42.25 with HTTP; Mon, 1 Aug 2005 16:56:12 -0700 (PDT) +Message-ID: +Date: Tue, 2 Aug 2005 01:56:13 +0200 +From: Meetesh Karia +Reply-To: meetesh.karia@alumni.duke.edu +To: John Arbash Meinel +Subject: Re: Planner incorrectly choosing seq scan over index scan +Cc: pgsql-performance@postgresql.org +In-Reply-To: <42EEAD4B.4010905@arbash-meinel.com> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3573_25248839.1122940573051" +References: + <42EEAD4B.4010905@arbash-meinel.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.199 tagged_above=0 required=5 tests=AWL, HTML_50_60, + HTML_MESSAGE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/16 +X-Sequence-Number: 13763 + +------=_Part_3573_25248839.1122940573051 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Thanks John. I've answered your questions below: + +Has lte_user and candidates617004 been recently ANALYZEd? All estimates, +> except for the expected number of rows from lte_user seem to be okay. + + +I ANALYZEd both tables just before putting together my first email. And,=20 +unfortunately, modifying the statistics target didn't help either. + +Is user_id the primary key for lte_user? + + +Yes=20 + +I'm trying to figure out how you can get 50k rows, by searching a +> primary key, against a 3.5k rows. Is user_id only part of the primary +> key for lte_user? + + +Hmmm ... I missed that before. But, that surprises me too. Especially since= +=20 +sourceId in the candidates table has only 1 value. Also, user_id is the=20 +complete primary key for lte_user. + +Can you give us the output of: +> \d lte_user +> \d candidates617004 + + +Sure, here they are: + +lte=3D# \d lte_user +Table "public.lte_user" +Column | Type | Modifiers +---------------+-----------------------------+----------- +user_id | bigint | not null +firstname | character varying(255) | +lastname | character varying(255) | +address1 | character varying(255) | +address2 | character varying(255) | +city | character varying(255) | +state | character varying(255) | +zip | character varying(255) | +phone1 | character varying(255) | +phone2 | character varying(255) | +username | character varying(255) | +password | character varying(255) | +deleted | boolean | not null +ext_cust_id | character varying(255) | +aboutme | character varying(255) | +birthday | timestamp without time zone | +fm_id | bigint | +ar | double precision | +Indexes: +"lte_user_pkey" PRIMARY KEY, btree (user_id) +"idx_user_extid" btree (ext_cust_id) +"idx_user_username" btree (username) +Foreign-key constraints: +"fk_user_fm" FOREIGN KEY (fm_id) REFERENCES fm(fm_id) + +lte=3D# \d candidates617004 +Table "public.candidates617004" +Column | Type | Modifiers +--------------+------------------+----------- +fmid | bigint | +sourceid | bigint | +sr | double precision | +targetid | bigint | +tr | double precision |=20 + +Also, if you could describe the table layouts, that would help. + + +Sure. The lte_user table is just a collection of users. user_id is assigned= +=20 +uniquely using a sequence. During some processing, we create a candidates= +=20 +table (candidates617004 in our case). This table is usually a temp table.= +=20 +sourceid is a user_id (in this case it is always 617004) and targetid is=20 +also a user_id (2860 distinct values out of 3467). The rest of the=20 +information is either only used in the select clause or not used at all=20 +during this processing. + +Did I miss something in the table layout description that would be helpful? + +Thanks for your help! +Meetesh + +> -> Sort (cost=3D9912.07..9920.73 rows=3D3467 width=3D40) (actual +> > time=3D1156.000..1156.000 rows=3D3467 loops=3D1) +> > Sort Key: c.sourceid +> > -> Hash Join (cost=3D8710.44..9708.21 rows=3D3467 width=3D40) +> > (actual time=3D1125.000..1156.000 rows=3D3467 loops=3D1) +> > Hash Cond: ("outer".targetid =3D "inner".user_id) +> > -> Seq Scan on candidates617004 c +> > (cost=3D0.00..67.67 rows=3D3467 width=3D32) (actual time=3D0.000..0.000 +> > rows=3D3467 loops=3D1) +> > -> Hash (cost=3D8011.95..8011.95 rows=3D279395 +> > width=3D16) (actual time=3D1125.000..1125.000 rows=3D0 loops=3D1) +> > -> Seq Scan on lte_user t +> > (cost=3D0.00..8011.95 rows=3D279395 width=3D16) (actual time=3D0.000..6= +70.000 +> > rows=3D279395 loops=3D1) +> > Total runtime: 1406.000 ms +> > +> > enable_hashjoin disabled +> > ---------------------------------------- +> > QUERY PLAN +> > Sort (cost=3D14355.37..14364.03 rows=3D3467 width=3D48) (actual +> > time=3D391.000..391.000 rows=3D3467 loops=3D1) +> > Sort Key: c.sourceid, c.targetid +> > -> Nested Loop (cost=3D271.52..14151.51 rows=3D3467 width=3D48) (actual +> > time=3D203.000..359.000 rows=3D3467 loops=3D1) +> > -> Merge Join (cost=3D271.52..3490.83 rows=3D3467 width=3D40) +> > (actual time=3D203.000..218.000 rows=3D3467 loops=3D1) +> > Merge Cond: ("outer".user_id =3D "inner".sourceid) +> > -> Index Scan using lte_user_pkey on lte_user s +> > (cost=3D0.00..16837.71 rows=3D279395 width=3D16) (actual time=3D0.000..= +126.000 +> > rows=3D50034 loops=3D1) +> > -> Sort (cost=3D271.52..280.19 rows=3D3467 width=3D32) (actual +> > time=3D15.000..30.000 rows=3D3467 loops=3D1) +> > Sort Key: c.sourceid +> > -> Seq Scan on candidates617004 c +> > (cost=3D0.00..67.67 rows=3D3467 width=3D32) (actual time=3D0.000..0.000 +> > rows=3D3467 loops=3D1) +> > -> Index Scan using lte_user_pkey on lte_user t +> > (cost=3D0.00..3.03 rows=3D1 width=3D16) (actual time=3D0.031..0.036 row= +s=3D1 +> > loops=3D3467) +> > Index Cond: ("outer".targetid =3D t.user_id) +> > Total runtime: 406.000 ms +> > +> > random_page_cost set to 1.5 +> > ---------------------------------------------- +> > QUERY PLAN +> > Sort (cost=3D12702.62..12711.29 rows=3D3467 width=3D48) (actual +> > time=3D1407.000..1407.000 rows=3D3467 loops=3D1) +> > Sort Key: c.sourceid, c.targetid +> > -> Merge Join (cost=3D9912.07..12498.77 rows=3D3467 width=3D48) (actual +> > time=3D1391.000..1407.000 rows=3D3467 loops=3D1) +> > Merge Cond: ("outer".user_id =3D "inner".sourceid) +> > -> Index Scan using lte_user_pkey on lte_user s +> > (cost=3D0.00..12807.34 rows=3D279395 width=3D16) (actual time=3D0.000..= +46.000 +> > rows=3D50034 loops=3D1) +> > -> Sort (cost=3D9912.07..9920.73 rows=3D3467 width=3D40) (actual +> > time=3D1188.000..1188.000 rows=3D3467 loops=3D1) +> > Sort Key: c.sourceid +> > -> Hash Join (cost=3D8710.44..9708.21 rows=3D3467 width=3D40) +> > (actual time=3D1157.000..1188.000 rows=3D3467 loops=3D1) +> > Hash Cond: ("outer".targetid =3D "inner".user_id) +> > -> Seq Scan on candidates617004 c +> > (cost=3D0.00..67.67 rows=3D3467 width=3D32) (actual time=3D0.000..15.00= +0 +> > rows=3D3467 loops=3D1) +> > -> Hash (cost=3D8011.95..8011.95 rows=3D279395 +> > width=3D16) (actual time=3D1157.000..1157.000 rows=3D0 loops=3D1) +> > -> Seq Scan on lte_user t +> > (cost=3D0.00..8011.95 rows=3D279395 width=3D16) (actual time=3D0.000..7= +50.000 +> > rows=3D279395 loops=3D1) +> > Total runtime: 1422.000 ms +> > +> > random_page_cost set to 1.5 and enable_hashjoin set to false +> >=20 +> -------------------------------------------------------------------------= +------------------------- +> > QUERY PLAN +> > Sort (cost=3D13565.58..13574.25 rows=3D3467 width=3D48) (actual +> > time=3D390.000..390.000 rows=3D3467 loops=3D1) +> > Sort Key: c.sourceid, c.targetid +> > -> Nested Loop (cost=3D271.52..13361.73 rows=3D3467 width=3D48) (actual +> > time=3D203.000..360.000 rows=3D3467 loops=3D1) +> > -> Merge Join (cost=3D271.52..2762.88 rows=3D3467 width=3D40) +> > (actual time=3D203.000..250.000 rows=3D3467 loops=3D1) +> > Merge Cond: ("outer".user_id =3D "inner".sourceid) +> > -> Index Scan using lte_user_pkey on lte_user s +> > (cost=3D0.00..12807.34 rows=3D279395 width=3D16) (actual time=3D0.000..= +48.000 +> > rows=3D50034 loops=3D1) +> > -> Sort (cost=3D271.52..280.19 rows=3D3467 width=3D32) (actual +> > time=3D15.000..31.000 rows=3D3467 loops=3D1) +> > Sort Key: c.sourceid +> > -> Seq Scan on candidates617004 c +> > (cost=3D0.00..67.67 rows=3D3467 width=3D32) (actual time=3D0.000..15.00= +0 +> > rows=3D3467 loops=3D1) +> > -> Index Scan using lte_user_pkey on lte_user t +> > (cost=3D0.00..3.02 rows=3D1 width=3D16) (actual time=3D0.023..0.023 row= +s=3D1 +> > loops=3D3467) +> > Index Cond: ("outer".targetid =3D t.user_id) +> > Total runtime: 406.000 ms +> > +> > Thanks, +> > Meetesh +>=20 +>=20 +>=20 +> + +------=_Part_3573_25248839.1122940573051 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Thanks John.  I've answered your questions below:

+Has lte_user and candidates617004 been recently ANALYZEd? All estimates,except for the expected number of rows from lte_user seem to be okay.

+I ANALYZEd both tables just before putting together my first +email.  And, unfortunately, modifying the statistics target didn't +help either.
+

Is user= +_id the primary key for lte_user?

+Yes
+

I'm try= +ing to figure out how you can get 50k rows, by searching a
primary key, = +against a=20 +3.5k rows. Is user_id only part of the primary
key for lte_user?

+Hmmm ... I missed that before.  But, that surprises me too.  +Especially since sourceId in the candidates table has only 1 +value.  Also, user_id is the complete primary key for lte_user.
+

Can you= + give us the output of:
\d lte_user
\d candidates617004
+

+Sure, here they are:
+
+lte=3D# \d lte_user
+            &nb= +sp;    Table "public.lte_user"
+    Column     +|            +Type            = +; +| Modifiers
+---------------+-----------------------------+-----------
+ user_id       | +bigint           &nb= +sp;          +| not null
+ firstname     | character varying(255)  = +;    |
+ lastname      | character varying(255) = +     |
+ address1      | character varying(255) = +     |
+ address2      | character varying(255) = +     |
+ city          | characte= +r varying(255)      |
+ state         | character var= +ying(255)      |
+ zip           | cha= +racter varying(255)      |
+ phone1        | character varying(= +255)      |
+ phone2        | character varying(= +255)      |
+ username      | character varying(255) = +     |
+ password      | character varying(255) = +     |
+ deleted       | +boolean           &n= +bsp;         +| not null
+ ext_cust_id   | character varying(255)   &nb= +sp;  |
+ aboutme       | character varying(255)&= +nbsp;     |
+ birthday      | timestamp without time zone = +|
+ fm_id       | +bigint           &nb= +sp;          +|
+ ar            | double +precision            +|
+Indexes:
+    "lte_user_pkey" PRIMARY KEY, btree (user_id) +    "idx_user_extid" btree (ext_cust_id)
+    "idx_user_username" btree (username)
+Foreign-key constraints:
+    "fk_user_fm" FOREIGN KEY (fm_id) REFERENCES fm= +(fm_id)
+
+lte=3D# \d candidates617004
+       Table "public.candidates617004&qu= +ot;
+    Column    +|       +Type       | Modifiers
+--------------+------------------+-----------
+ fmid       | bigint   &n= +bsp;       |
+ sourceid     | bigint    &nbs= +p;      |
+ sr            | double precision |= +
+ targetid     | bigint    &nbs= +p;      |
+ tr           | double precision |
+

Also, i= +f you could describe the table layouts, that would help.
+
+Sure.  The lte_user table is just a collection of users.  +user_id is assigned uniquely using a sequence.  During some +processing, we create a candidates table (candidates617004 in our +case).  This table is usually a temp table.  sourceid is a +user_id (in this case it is always 617004) and targetid is also a +user_id (2860 distinct values out of 3467).  The rest of the +information is either only used in the select clause or not used at all +during this processing.
+
+Did I miss something in the table layout description that would be helpful?= +
+

+Thanks for your help!
+Meetesh
+
> &nb= +sp;       +->  Sort  (cost=3D9912.07..9920.73 rows=3D3467 +width=3D40) (actual
> time=3D1156.000..1156.000 rows=3D3467 loops=3D1= +)
>           = +    Sort Key: c.sourceid
>    &nbs= +p;          +->  Hash Join  (cost=3D8710.44..9708.21 rows=3D3467 +width=3D40)
> (actual time=3D1125.000..1156.000 rows=3D3467 loops=3D1= +)
>           = +          +Hash Cond: ("outer".targetid =3D "inner".user_id)
&g= +t;            &= +nbsp;        +->  Seq Scan on candidates617004 c
> (cost=3D0.00..67.67= + rows=3D3467 width=3D32) (actual time=3D0.000..0.000
> rows=3D3467 lo= +ops=3D1)
>          = +;           +->  Hash  (cost=3D8011.95..8011.95 rows=3D279395
= +> width=3D16) (actual time=3D1125.000..1125.000 rows=3D0 loops=3D1)
&= +gt;            = +            &nb= +sp;  +->  Seq Scan on lte_user t
> (cost=3D0.00..8011.95 rows= +=3D279395 width=3D16) (actual time=3D0.000..670.000
> rows=3D279395 l= +oops=3D1)
> Total runtime: 1406.000 ms
>
> enable_hashjoi= +n disabled
> ---------------------------------------- +
> QUERY PLAN
> Sort  (cost=3D14355.37..14364.03 rows= +=3D3467 width=3D48) (actual
> time=3D391.000..391.000 rows=3D3467 loo= +ps=3D1)
>   Sort Key: c.sourceid, c.targetid
> &= +nbsp; ->  Nested Loop  (cost=3D271.52..14151.51 + rows=3D3467 width=3D48) (actual
> time=3D203.000..359.000 rows=3D346= +7 loops=3D1)
>         +->  Merge Join  (cost=3D271.52..3490.83 rows=3D3467 +width=3D40)
> (actual time=3D203.000..218.000 rows=3D3467 loops=3D1)<= +br>>           &n= +bsp;   +Merge Cond: ("outer".user_id =3D "inner".sourceid)
&= +gt;            = +   +->  Index Scan using lte_user_pkey on lte_user s
> (cost= +=3D0.00..16837.71 rows=3D279395 width=3D16) (actual time=3D0.000..126.000> rows=3D50034 loops=3D1)
>      &= +nbsp;        +->  Sort  (cost=3D271.52..280.19 rows=3D3467 +width=3D32) (actual
> time=3D15.000..30.000 rows=3D3467 loops=3D1)>           &nbs= +p;         +Sort Key: c.sourceid
>        = +;             +->  Seq Scan on candidates617004 c
> (cost=3D0.00..67.67= + rows=3D3467 width=3D32) (actual time=3D0.000..0.000
> rows=3D3467 lo= +ops=3D1)
>         -> = +; Index Scan using lte_user_pkey on lte_user t
> (cost=3D0.00..3= +.03 + rows=3D1 width=3D16) (actual time=3D0.031..0.036 rows=3D1
> loops=3D= +3467)
>          &n= +bsp;    +Index Cond: ("outer".targetid =3D t.user_id)
> Total runtim= +e: 406.000 ms
>
> random_page_cost set to 1.5
> ---------= +-------------------------------------
> QUERY PLAN
> Sort = + (cost=3D +12702.62..12711.29 rows=3D3467 width=3D48) (actual
> time=3D1407.000.= +.1407.000 rows=3D3467 loops=3D1)
>   Sort Key: c.sourceid, = +c.targetid
>   ->  Merge Join  (cost= +=3D9912.07..12498.77 rows=3D3467 width=3D48) (actual +
> time=3D1391.000..1407.000 rows=3D3467 loops=3D1)
> &nbs= +p;       Merge Cond: ("outer".user_= +id =3D "inner".sourceid)
>     &nb= +sp;   ->  Index Scan using lte_user_pkey on lte_user= + s
> (cost=3D0.00..12807.34 + rows=3D279395 width=3D16) (actual time=3D0.000..46.000
> rows=3D5003= +4 loops=3D1)
>         +->  Sort  (cost=3D9912.07..9920.73 rows=3D3467 +width=3D40) (actual
> time=3D1188.000..1188.000 rows=3D3467 loops=3D1= +)
>           = +    Sort Key: c.sourceid
>    &nbs= +p;          +->  Hash Join  (cost=3D8710.44..9708.21 rows=3D3467 +width=3D40)
> (actual time=3D1157.000..1188.000 rows=3D3467 loops=3D1= +)
>           = +          +Hash Cond: ("outer".targetid =3D "inner".user_id)
&g= +t;            &= +nbsp;        +->  Seq Scan on candidates617004 c
> (cost=3D0.00..67.67= + rows=3D3467 width=3D32) (actual time=3D0.000..15.000
> rows=3D3467 l= +oops=3D1)
>         &nbs= +p;           +->  Hash  (cost=3D8011.95..8011.95 rows=3D279395
= +> width=3D16) (actual time=3D1157.000..1157.000 rows=3D0 loops=3D1)
&= +gt;            = +            &nb= +sp;  +->  Seq Scan on lte_user t
> (cost=3D0.00..8011.95 rows= +=3D279395 width=3D16) (actual time=3D0.000..750.000
> rows=3D279395 l= +oops=3D1)
> Total runtime: 1422.000 ms
>
> random_page_co= +st set to 1.5 and enable_hashjoin set to false +
> ------------------------------------------------------------------= +--------------------------------
> QUERY PLAN
> Sort  = +;(cost=3D13565.58..13574.25 rows=3D3467 width=3D48) (actual
> time=3D= +390.000..390.000 + rows=3D3467 loops=3D1)
>   Sort Key: c.sourceid, c.targeti= +d
>   ->  Nested Loop  (cost=3D271.5= +2..13361.73 rows=3D3467 width=3D48) (actual
> time=3D203.000..360.000= + rows=3D3467 loops=3D1)
>       &n= +bsp; +->  Merge Join  (cost=3D271.52..2762.88 rows=3D3467 +width=3D40)
> (actual time=3D203.000..250.000 rows=3D3467 loops=3D1)<= +br>>           &n= +bsp;   +Merge Cond: ("outer".user_id =3D "inner".sourceid)
&= +gt;            = +   +->  Index Scan using lte_user_pkey on lte_user s
> (cost= +=3D0.00..12807.34 rows=3D279395 width=3D16) (actual time=3D0.000..48.000> rows=3D50034 loops=3D1)
>      &n= +bsp;        +->  Sort  (cost=3D271.52..280.19 rows=3D3467 +width=3D32) (actual
> time=3D15.000..31.000 rows=3D3467 loops=3D1)>           &nbs= +p;         +Sort Key: c.sourceid
>        = +;             +->  Seq Scan on candidates617004 c
> (cost=3D0.00..67.67= + rows=3D3467 width=3D32) (actual time=3D0.000..15.000
> rows=3D3467 l= +oops=3D1)
>         ->&nbs= +p; Index Scan using lte_user_pkey on lte_user t
> (cost=3D +0.00..3.02 rows=3D1 width=3D16) (actual time=3D0.023..0.023 rows=3D1
>= +; loops=3D3467)
>        &nbs= +p;      +Index Cond: ("outer".targetid =3D t.user_id)
> Total runtim= +e: 406.000 ms
>
> Thanks,
> Meetesh




+ +------=_Part_3573_25248839.1122940573051-- + +From pgsql-performance-owner@postgresql.org Mon Aug 1 21:15:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 885C152BC3 + for ; + Mon, 1 Aug 2005 21:15:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12235-05 + for ; + Tue, 2 Aug 2005 00:15:26 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AB6F4529E1 + for ; + Mon, 1 Aug 2005 21:15:25 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j720FQaO026293; + Mon, 1 Aug 2005 20:15:26 -0400 (EDT) +To: meetesh.karia@alumni.duke.edu +Cc: John Arbash Meinel , + pgsql-performance@postgresql.org +Subject: Re: Planner incorrectly choosing seq scan over index scan +In-reply-to: +References: + <42EEAD4B.4010905@arbash-meinel.com> + +Comments: In-reply-to Meetesh Karia + message dated "Tue, 02 Aug 2005 01:56:13 +0200" +Date: Mon, 01 Aug 2005 20:15:26 -0400 +Message-ID: <26292.1122941726@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/17 +X-Sequence-Number: 13764 + +Meetesh Karia writes: +> Sure. The lte_user table is just a collection of users. user_id is assigned= +> uniquely using a sequence. During some processing, we create a candidates= +> table (candidates617004 in our case). This table is usually a temp table.= +> sourceid is a user_id (in this case it is always 617004) and targetid is=20 +> also a user_id (2860 distinct values out of 3467). The rest of the=20 +> information is either only used in the select clause or not used at all=20 +> during this processing. + +If you know that sourceid has only a single value, it'd probably be +helpful to call out that value in the query, ie, + where ... AND c.sourceId = 617004 ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 2 04:06:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B7C1752E97 + for ; + Tue, 2 Aug 2005 04:05:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12448-05 + for ; + Tue, 2 Aug 2005 07:05:50 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.198]) + by svr1.postgresql.org (Postfix) with ESMTP id 032AA52E96 + for ; + Tue, 2 Aug 2005 04:05:48 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i4so1162935wra + for ; + Tue, 02 Aug 2005 00:05:50 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=A6mAIeGuY5dNZIzyOJIpQxh/LfPDIZDEvq3UmrT3GMMr6qM4IF8pb6vdpcVcaxN4xeo5TNqb6r0XhfxO0u0LAErHlyjbORUtilr+Rkp1u3CVoiM5x10SqNczvE+yX9CWhtuBaivsZRkqlR+NUvbJwMARog3+wCHcblu9b1Z2hlg= +Received: by 10.54.2.57 with SMTP id 57mr3555676wrb; + Tue, 02 Aug 2005 00:05:50 -0700 (PDT) +Received: by 10.54.42.25 with HTTP; Tue, 2 Aug 2005 00:05:50 -0700 (PDT) +Message-ID: +Date: Tue, 2 Aug 2005 09:05:50 +0200 +From: Meetesh Karia +Reply-To: meetesh.karia@alumni.duke.edu +To: Tom Lane +Subject: Re: Planner incorrectly choosing seq scan over index scan +Cc: John Arbash Meinel , + pgsql-performance@postgresql.org +In-Reply-To: <26292.1122941726@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3703_21659964.1122966350462" +References: + <42EEAD4B.4010905@arbash-meinel.com> + + <26292.1122941726@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.185 tagged_above=0 required=5 tests=AWL, HTML_40_50, + HTML_MESSAGE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/18 +X-Sequence-Number: 13765 + +------=_Part_3703_21659964.1122966350462 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Thanks Tom, + +That modifies the query plan slightly, but the planner still decides to do = +a=20 +hash join for the lte_user table aliased 't'. Though, if I make this change= +=20 +and set enable_hashjoin to off, the query plan (and execution time) gets=20 +even better. + +enable_hashjoin =3D on +---------------------------------- +QUERY PLAN +Sort (cost=3D10113.35..10122.02 rows=3D3467 width=3D48) (actual time=3D +1203.000..1203.000 rows=3D3467 loops=3D1) +Sort Key: c.sourceid, c.targetid +-> Nested Loop (cost=3D8711.19..9909.50 rows=3D3467 width=3D48) (actual tim= +e=3D +1156.000..1203.000 rows=3D3467 loops=3D1) +-> Index Scan using lte_user_pkey on lte_user s (cost=3D0.00..3.02 rows=3D1= +=20 +width=3D16) (actual time=3D0.000..0.000 rows=3D1 loops=3D1) +Index Cond: (617004 =3D user_id) +-> Hash Join (cost=3D8711.19..9776.46 rows=3D3467 width=3D40) (actual time= +=3D +1156.000..1187.000 rows=3D3467 loops=3D1) +Hash Cond: ("outer".targetid =3D "inner".user_id) +-> Seq Scan on candidates617004 c (cost=3D0.00..76.34 rows=3D3467 width=3D3= +2)=20 +(actual time=3D0.000..16.000 rows=3D3467 loops=3D1) +Filter: (sourceid =3D 617004) +-> Hash (cost=3D8012.55..8012.55 rows=3D279455 width=3D16) (actual time=3D +1141.000..1141.000 rows=3D0 loops=3D1) +-> Seq Scan on lte_user t (cost=3D0.00..8012.55 rows=3D279455 width=3D16) (= +actual=20 +time=3D0.000..720.000 rows=3D279395 loops=3D1) +Total runtime: 1218.000 ms + +enable_hashjoin =3D off +----------------------------------- +QUERY PLAN +Sort (cost=3D10942.56..10951.22 rows=3D3467 width=3D48) (actual time=3D +188.000..188.000 rows=3D3467 loops=3D1) +Sort Key: c.sourceid, c.targetid +-> Nested Loop (cost=3D0.00..10738.71 rows=3D3467 width=3D48) (actual time= +=3D +0.000..188.000 rows=3D3467 loops=3D1) +-> Index Scan using lte_user_pkey on lte_user s (cost=3D0.00..3.02 rows=3D1= +=20 +width=3D16) (actual time=3D0.000..0.000 rows=3D1 loops=3D1) +Index Cond: (617004 =3D user_id) +-> Nested Loop (cost=3D0.00..10605.67 rows=3D3467 width=3D40) (actual time= +=3D +0.000..157.000 rows=3D3467 loops=3D1) +-> Seq Scan on candidates617004 c (cost=3D0.00..76.34 rows=3D3467 width=3D3= +2)=20 +(actual time=3D0.000..15.000 rows=3D3467 loops=3D1) +Filter: (sourceid =3D 617004) +-> Index Scan using lte_user_pkey on lte_user t (cost=3D0.00..3.02 rows=3D1= +=20 +width=3D16) (actual time=3D0.028..0.037 rows=3D1 loops=3D3467) +Index Cond: ("outer".targetid =3D t.user_id) +Total runtime: 188.000 ms + +Thanks, +Meetesh + +On 8/2/05, Tom Lane wrote: +>=20 +> Meetesh Karia writes: +> > Sure. The lte_user table is just a collection of users. user_id is=20 +> assigned=3D +> > uniquely using a sequence. During some processing, we create a=20 +> candidates=3D +> > table (candidates617004 in our case). This table is usually a temp=20 +> table.=3D +> > sourceid is a user_id (in this case it is always 617004) and targetid= +=20 +> is=3D20 +> > also a user_id (2860 distinct values out of 3467). The rest of the=3D20 +> > information is either only used in the select clause or not used at=20 +> all=3D20 +> > during this processing. +>=20 +> If you know that sourceid has only a single value, it'd probably be +> helpful to call out that value in the query, ie, +> where ... AND c.sourceId =3D 617004 ... +>=20 +> regards, tom lane +> + +------=_Part_3703_21659964.1122966350462 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Thanks Tom,
+
+That modifies the query plan slightly, but the planner still decides to +do a hash join for the lte_user table aliased 't'.  Though, if I +make this change and set enable_hashjoin to off, the query plan (and +execution time) gets even better.
+
+enable_hashjoin =3D on
+----------------------------------
+QUERY PLAN
+Sort  (cost=3D10113.35..10122.02 rows=3D3467 width=3D48) (actual time= +=3D1203.000..1203.000 rows=3D3467 loops=3D1)
+  Sort Key: c.sourceid, c.targetid
+  ->  Nested Loop  (cost=3D8711.19..9909.50 rows=3D3467 +width=3D48) (actual time=3D1156.000..1203.000 rows=3D3467 loops=3D1)
+        ->  Index Scan using +lte_user_pkey on lte_user s  (cost=3D0.00..3.02 rows=3D1 width=3D16) +(actual time=3D0.000..0.000 rows=3D1 loops=3D1)
+            &nb= +sp; Index Cond: (617004 =3D user_id)
+        ->  Hash Join  +(cost=3D8711.19..9776.46 rows=3D3467 width=3D40) (actual +time=3D1156.000..1187.000 rows=3D3467 loops=3D1)
+            &nb= +sp; Hash Cond: ("outer".targetid =3D "inner".user_id) +            &nb= +sp; +->  Seq Scan on candidates617004 c  (cost=3D0.00..76.34 +rows=3D3467 width=3D32) (actual time=3D0.000..16.000 rows=3D3467 loops=3D1)= +
+            &nb= +sp;       +Filter: (sourceid =3D 617004)
+            &nb= +sp; +->  Hash  (cost=3D8012.55..8012.55 rows=3D279455 width=3D16) +(actual time=3D1141.000..1141.000 rows=3D0 loops=3D1)
+            &nb= +sp;       +->  Seq Scan on lte_user t  (cost=3D0.00..8012.55 +rows=3D279455 width=3D16) (actual time=3D0.000..720.000 rows=3D279395 loops= +=3D1)
+Total runtime: 1218.000 ms
+
+enable_hashjoin =3D off
+-----------------------------------
+QUERY PLAN
+Sort  (cost=3D10942.56..10951.22 rows=3D3467 width=3D48) (actual time= +=3D188.000..188.000 rows=3D3467 loops=3D1)
+  Sort Key: c.sourceid, c.targetid
+  ->  Nested Loop  (cost=3D0.00..10738.71 rows=3D3467 wid= +th=3D48) (actual time=3D0.000..188.000 rows=3D3467 loops=3D1)
+        ->  Index Scan using +lte_user_pkey on lte_user s  (cost=3D0.00..3.02 rows=3D1 width=3D16) +(actual time=3D0.000..0.000 rows=3D1 loops=3D1)
+            &nb= +sp; Index Cond: (617004 =3D user_id)
+        ->  Nested +Loop  (cost=3D0.00..10605.67 rows=3D3467 width=3D40) (actual +time=3D0.000..157.000 rows=3D3467 loops=3D1)
+            &nb= +sp; +->  Seq Scan on candidates617004 c  (cost=3D0.00..76.34 +rows=3D3467 width=3D32) (actual time=3D0.000..15.000 rows=3D3467 loops=3D1)= +
+            &nb= +sp;       +Filter: (sourceid =3D 617004)
+            &nb= +sp; +->  Index Scan using lte_user_pkey on lte_user t  +(cost=3D0.00..3.02 rows=3D1 width=3D16) (actual time=3D0.028..0.037 rows=3D= +1 +loops=3D3467)
+            &nb= +sp;       +Index Cond: ("outer".targetid =3D t.user_id)
+Total runtime: 188.000 ms
+
+Thanks,
+Meetesh

On 8/2/05, Tom Lane <tgl@sss= +.pgh.pa.us> wrote:
+Meetesh Karia <meetesh.karia@= +gmail.com> writes:
> Sure. The lte_user table is just a collec= +tion of users. user_id is assigned=3D
> uniquely using a sequence. Du= +ring some processing, we create a candidates=3D +
> table (candidates617004 in our case). This table is usually a temp= + table.=3D
> sourceid is a user_id (in this case it is always 617004)= + and targetid is=3D20
> also a user_id (2860 distinct values out of 3= +467). The rest of the=3D20 +
> information is either only used in the select clause or not used a= +t all=3D20
> during this processing.

If you know that sourceid= + has only a single value, it'd probably be
helpful to call out that valu= +e in the query, ie, +
        where ... AND c.sourceI= +d =3D 617004 ...

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

+ +------=_Part_3703_21659964.1122966350462-- + +From pgsql-patches-owner@postgresql.org Tue Aug 2 12:00:17 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0908D52F18 + for ; + Tue, 2 Aug 2005 12:00:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25433-01 + for ; + Tue, 2 Aug 2005 15:00:02 +0000 (GMT) +Received: from mail.Mi8.com (nycgw01.mi8.com [63.240.6.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F9DA52F14 + for ; + Tue, 2 Aug 2005 11:59:56 -0300 (ADT) +Received: from 172.16.1.118 by mail.Mi8.com with ESMTP (- GW01 Welcome + to Mi8 Corporation www.Mi8.com); Tue, 02 Aug 2005 10:59:42 -0400 +X-Server-Uuid: F1A2E19A-84E4-48DD-8F48-B475613F58B2 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + d01smtp03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 2 Aug + 2005 10:59:42 -0400 +Received: from 141.156.39.156 ([141.156.39.156]) by MI8NYCMAIL06.Mi8.com + ([172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.104]) with Microsoft Exchange Server HTTP-DAV ; Tue, 2 Aug + 2005 10:59:39 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Tue, 02 Aug 2005 10:59:43 -0400 +Subject: Re: COPY FROM performance improvements +From: "Alon Goldshuv" +To: pgsql-patches@postgresql.org +Message-ID: +In-Reply-To: +MIME-Version: 1.0 +X-OriginalArrivalTime: 02 Aug 2005 14:59:42.0607 (UTC) + FILETIME=[D04361F0:01C59772] +X-WSS-ID: 6EF155D427K725273-01-01 +Content-Type: multipart/mixed; + boundary=B_3205825185_103175599 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.569 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200508/28 +X-Sequence-Number: 16975 + +> This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--B_3205825185_103175599 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit + +New patch attached. It includes very minor changes. These are changes that +were committed to CVS 3 weeks ago (copy.c 1.247) which I missed in the +previous patch. + +Alon. + + +--B_3205825185_103175599 +Content-Type: application/octet-stream; name=copy_parse_improvements_V16.patch +Content-Disposition: attachment; + filename=copy_parse_improvements_V16.patch +Content-Transfer-Encoding: base64 + +SW5kZXg6IHNyYy9iYWNrZW5kL2NvbW1hbmRzL2Nvc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lcnkoKTsKICAKICAJLyoKLS0tIDE1NDAsMTU0OCAtLS0tCiAgCQl9CiAgCX0KICAK +ISAJLyoKISAJICogUHJlcGFyZSB0byBjYXRjaCBBRlRFUiB0cmlnZ2Vycy4KISAJICovCiAg +CUFmdGVyVHJpZ2dlckJlZ2luUXVlcnkoKTsKICAKICAJLyoKKioqKioqKioqKioqKioqCioq +KiAxNjcxLDE2NzYgKioqKgotLS0gMTYwNiwxNjEyIC0tLS0KICAKICAJdmFsdWVzID0gKERh +dHVtICopIHBhbGxvYyhudW1fcGh5c19hdHRycyAqIHNpemVvZihEYXR1bSkpOwogIAludWxs +cyA9IChjaGFyICopIHBhbGxvYyhudW1fcGh5c19hdHRycyAqIHNpemVvZihjaGFyKSk7Cisg +CWF0dHJfb2Zmc2V0cyA9IChpbnQgKikgcGFsbG9jKG51bV9waHlzX2F0dHJzICogc2l6ZW9m +KGludCkpOwogIAogIAkvKiBNYWtlIHJvb20gZm9yIGEgUEFSQU1fRVhFQyB2YWx1ZSBmb3Ig +ZG9tYWluIGNvbnN0cmFpbnQgY2hlY2tzICovCiAgCWlmIChoYXNDb25zdHJhaW50cykKKioq +KioqKioqKioqKioqCioqKiAxNjkxLDE3MTIgKioqKgogIAllcnJjb250ZXh0LnByZXZpb3Vz +ID0gZXJyb3JfY29udGV4dF9zdGFjazsKICAJZXJyb3JfY29udGV4dF9zdGFjayA9ICZlcnJj +b250ZXh0OwogIAohIAkvKiBvbiBpbnB1dCBqdXN0IHRocm93IHRoZSBoZWFkZXIgbGluZSBh +d2F5ICovCiEgCWlmIChoZWFkZXJfbGluZSkKICAJewohIAkJY29weV9saW5lbm8rKzsKISAJ +CWRvbmUgPSBDb3B5UmVhZExpbmUocXVvdGUsIGVzY2FwZSkgOwogIAl9CiAgCiEgCXdoaWxl +ICghZG9uZSkKICAJewogIAkJYm9vbAkJc2tpcF90dXBsZTsKICAJCU9pZAkJCWxvYWRlZF9v +aWQgPSBJbnZhbGlkT2lkOwogIAogIAkJQ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yA8IHN0YXJ0ICsgbGVuOyBzKyspCisgCQk7CisgCQor +IAlyZXR1cm4gKCpzICE9ICdcMCcgPyAoY2hhciAqKSBzIDogTlVMTCk7CisgfQorIAorIAor +IAorIAorIAo= + +--B_3205825185_103175599-- + + +From pgsql-patches-owner@postgresql.org Tue Aug 2 12:03:57 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 760BB52C6D; + Tue, 2 Aug 2005 12:03:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20548-10; Tue, 2 Aug 2005 15:03:43 +0000 (GMT) +Received: from mail.Mi8.com (nycgw05.mi8.com [63.240.6.46]) + by svr1.postgresql.org (Postfix) with ESMTP id ADEBE52F23; + Tue, 2 Aug 2005 12:03:40 -0300 (ADT) +Received: from 172.16.1.110 by mail.Mi8.com with ESMTP (- GW05 Welcome + to Mi8 Corporation www.Mi8.com); Tue, 02 Aug 2005 11:03:35 -0400 +X-Server-Uuid: E0C866E6-C6CD-48B5-AE61-E57E73CF3CC7 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Tue, 2 Aug 2005 + 11:03:35 -0400 +Received: from 141.156.39.156 ([141.156.39.156]) by MI8NYCMAIL06.Mi8.com + ([172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.104]) with Microsoft Exchange Server HTTP-DAV ; Tue, 2 Aug + 2005 11:03:35 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Tue, 02 Aug 2005 11:03:44 -0400 +Subject: Re: [PERFORM] COPY FROM performance improvements +From: "Alon Goldshuv" +To: pgsql-patches@postgresql.org, + "pgsql-performance@postgresql.org" +Message-ID: +In-Reply-To: <26131.1122940270@sss.pgh.pa.us> +MIME-Version: 1.0 +X-OriginalArrivalTime: 02 Aug 2005 15:03:35.0747 (UTC) + FILETIME=[5B39B930:01C59773] +X-WSS-ID: 6EF154CD26S618902-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.569 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200508/29 +X-Sequence-Number: 16976 + +Tom, + +Thanks for pointing it out. I made the small required modifications to match +copy.c version 1.247 and sent it to -patches list. New patch is V16. + +Alon. + + +On 8/1/05 7:51 PM, "Tom Lane" wrote: + +> "Alon Goldshuv" writes: +>>> This patch appears to reverse out the most recent committed changes in +>>> copy.c. +> +>> Which changes do you refer to? I thought I accommodated all the recent +>> changes (I recall some changes to the tupletable/tupleslot interface, HEADER +>> in cvs, and hex escapes and maybe one or 2 more). What did I miss? +> +> The latest touch of copy.c, namely this patch: +> +> 2005-07-10 17:13 tgl +> +> * doc/src/sgml/ref/create_type.sgml, src/backend/commands/copy.c, +> src/backend/commands/typecmds.c, src/backend/tcop/fastpath.c, +> src/backend/tcop/postgres.c, src/backend/utils/adt/arrayfuncs.c, +> src/backend/utils/adt/date.c, src/backend/utils/adt/numeric.c, +> src/backend/utils/adt/rowtypes.c, +> src/backend/utils/adt/timestamp.c, src/backend/utils/adt/varbit.c, +> src/backend/utils/adt/varchar.c, src/backend/utils/adt/varlena.c, +> src/backend/utils/mb/mbutils.c, src/include/catalog/catversion.h, +> src/include/catalog/pg_proc.h, +> src/test/regress/expected/type_sanity.out, +> src/test/regress/sql/type_sanity.sql: Change typreceive function +> API so that receive functions get the same optional arguments as +> text input functions, ie, typioparam OID and atttypmod. Make all +> the datatypes that use typmod enforce it the same way in typreceive +> as they do in typinput. This fixes a problem with failure to +> enforce length restrictions during COPY FROM BINARY. +> +> It was rather obvious, given that the first chunk of the patch backed up +> the file's CVS version stamp from 1.247 to 1.246 :-( +> +> regards, tom lane +> + + + +From pgsql-performance-owner@postgresql.org Tue Aug 2 13:05:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1939D52C8A + for ; + Tue, 2 Aug 2005 13:04:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40098-02 + for ; + Tue, 2 Aug 2005 16:04:50 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B81552BE2 + for ; + Tue, 2 Aug 2005 13:04:48 -0300 (ADT) +Received: from [84.48.51.94] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1DzzE4-0004oe-Rn + for ; Tue, 02 Aug 2005 18:02:56 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id 06DA6E012E; Tue, 2 Aug 2005 18:04:34 +0200 (CEST) +Date: Tue, 2 Aug 2005 18:04:34 +0200 +From: Tobias Brox +To: pgsql-performance@postgresql.org +Subject: "nice"/low priority Query +Message-ID: <20050802160434.GD9278@tobias.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Organization: Group Nordicbet +User-Agent: Mutt/1.5.8i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/20 +X-Sequence-Number: 13767 + +The short question: + +Is there any ways to give postgresql a hint that a +particular SQL call should be run at lower priority? Since every db +connection has a pid, I can manually run "renice" to scheduele it by the OS +- but of course I can't do it manually all the time. + +The long story: + +We have a constantly growing database, and hence also a constantly growing +load on the database server. A hardware upgrade has for different reasons +been postponed, and it's still beeing postponed. + +We were hitting the first capacity problems in June, though so far I've +managed to keep the situation in check by tuning the configuration, adding +indices, optimizing queries, doing cacheing in the application, and at one +point in the code I'm even asking the database for "explain plan", grepping +out the estimated cost number, and referring the user to take contact with +the IT-dept if he really needs the report. But I digress. + +Still there are lots of CPU power available - normally the server runs with +50-80% of the CPUs idle, it's just the spikes that kills us. + +We basically have two kind of queries that are significant - an ever-ongoing +"critical" rush of simple queries, both reading and writing to the database, +plus some few heavy "non-critical" read-only queries that may cause +significant iowait. The problem comes when we are so unlucky that two or +three heavy queries are run simultaneously; we get congestion problems - +instead of the applications just running a bit slower, they run _much_ +slower. + +Ideally, if it was trivial to give priorities, it should be possible to keep +the CPUs running at 100% for hours without causing critical problems...? + +-- +Tobias Brox, +47-91700050 +Tromso, Norway + +From pgsql-performance-owner@postgresql.org Tue Aug 2 13:19:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EF7CE52C9F + for ; + Tue, 2 Aug 2005 13:19:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44138-01 + for ; + Tue, 2 Aug 2005 16:19:45 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 56F8E529D2 + for ; + Tue, 2 Aug 2005 13:19:44 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j72GJUYJ011485; + Tue, 2 Aug 2005 12:19:30 -0400 (EDT) +To: Tobias Brox +Cc: pgsql-performance@postgresql.org +Subject: Re: "nice"/low priority Query +In-reply-to: <20050802160434.GD9278@tobias.lan> +References: <20050802160434.GD9278@tobias.lan> +Comments: In-reply-to Tobias Brox + message dated "Tue, 02 Aug 2005 18:04:34 +0200" +Date: Tue, 02 Aug 2005 12:19:30 -0400 +Message-ID: <11484.1122999570@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/21 +X-Sequence-Number: 13768 + +Tobias Brox writes: +> Is there any ways to give postgresql a hint that a +> particular SQL call should be run at lower priority? Since every db +> connection has a pid, I can manually run "renice" to scheduele it by the OS +> - but of course I can't do it manually all the time. + +And it won't help you anyway, because renice only affects CPU priority +not I/O scheduling ... which, by your description, is the real problem. + +I think the only thing that's likely to help much is trying to arrange +that the "simple" queries only need to touch pages that are already in +memory. Some playing around with shared_buffer sizing might help. +Also, if you're not on PG 8.0.*, an update might help. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 2 14:00:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 57AC9529D2 + for ; + Tue, 2 Aug 2005 14:00:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53174-02 + for ; + Tue, 2 Aug 2005 17:00:34 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id F032452E8E + for ; + Tue, 2 Aug 2005 14:00:30 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id DC2B540C3C5; Tue, 2 Aug 2005 18:00:17 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 304D815EDA; + Tue, 2 Aug 2005 17:54:56 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 06583-10; Tue, 2 Aug 2005 17:54:53 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 1D39C15ED9; + Tue, 2 Aug 2005 17:54:53 +0100 (BST) +Message-ID: <42EFA55C.3080903@archonet.com> +Date: Tue, 02 Aug 2005 17:54:52 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: "nice"/low priority Query +References: <20050802160434.GD9278@tobias.lan> + <11484.1122999570@sss.pgh.pa.us> +In-Reply-To: <11484.1122999570@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/22 +X-Sequence-Number: 13769 + +Tom Lane wrote: +> Tobias Brox writes: +> +>>Is there any ways to give postgresql a hint that a +>>particular SQL call should be run at lower priority? Since every db +>>connection has a pid, I can manually run "renice" to scheduele it by the OS +>>- but of course I can't do it manually all the time. +> +> And it won't help you anyway, because renice only affects CPU priority +> not I/O scheduling ... which, by your description, is the real problem. +> +> I think the only thing that's likely to help much is trying to arrange +> that the "simple" queries only need to touch pages that are already in +> memory. Some playing around with shared_buffer sizing might help. +> Also, if you're not on PG 8.0.*, an update might help. + +Would it be useful to be able to re-use the vacuum_cost_xxx settings in +8.0 for this sort of thing? I'm thinking a long-running report query +isn't that different from a vacuum. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Aug 2 14:25:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0893A52E74 + for ; + Tue, 2 Aug 2005 14:25:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58127-06 + for ; + Tue, 2 Aug 2005 17:25:51 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 5280452CA7 + for ; + Tue, 2 Aug 2005 14:25:50 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 86CA715232; Tue, 2 Aug 2005 12:25:50 -0500 (CDT) +Date: Tue, 2 Aug 2005 12:25:50 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: "nice"/low priority Query +Message-ID: <20050802172550.GZ60019@decibel.org> +References: <20050802160434.GD9278@tobias.lan> + <11484.1122999570@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <11484.1122999570@sss.pgh.pa.us> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/23 +X-Sequence-Number: 13770 + +On Tue, Aug 02, 2005 at 12:19:30PM -0400, Tom Lane wrote: +> Tobias Brox writes: +> > Is there any ways to give postgresql a hint that a +> > particular SQL call should be run at lower priority? Since every db +> > connection has a pid, I can manually run "renice" to scheduele it by the OS +> > - but of course I can't do it manually all the time. +> +> And it won't help you anyway, because renice only affects CPU priority +> not I/O scheduling ... which, by your description, is the real problem. + +Actually, from what I've read 4.2BSD actually took priority into account +when scheduling I/O. I don't know if this behavior is still present in +FreeBSD or the like, though. So depending on the OS, priority could play +a role in determining I/O scheduling. +-- +Jim C. Nasby, Database Consultant decibel@decibel.org +Give your computer some brain candy! www.distributed.net Team #1828 + +Windows: "Where do you want to go today?" +Linux: "Where do you want to go tomorrow?" +FreeBSD: "Are you guys coming, or what?" + +From pgsql-performance-owner@postgresql.org Tue Aug 2 15:57:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EFBF45298A + for ; + Tue, 2 Aug 2005 15:57:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81274-02 + for ; + Tue, 2 Aug 2005 18:57:51 +0000 (GMT) +Received: from cdrsmtp01.yellowbook.com (unknown [64.199.226.83]) + by svr1.postgresql.org (Postfix) with ESMTP id 545C0528FC + for ; + Tue, 2 Aug 2005 15:57:49 -0300 (ADT) +Received: from ybcdrmta01.corp.ybusa.net ([10.5.17.170]) by + cdrsmtp01.yellowbook.com with Microsoft SMTPSVC(6.0.3790.0); + Tue, 2 Aug 2005 14:01:14 -0500 +Received: from YBCDREX01.corp.ybusa.net ([10.5.17.162]) by + ybcdrmta01.corp.ybusa.net with Microsoft SMTPSVC(6.0.3790.211); + Tue, 2 Aug 2005 13:57:49 -0500 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C59794.14BE874F" +Subject: pg_dump for table with bytea takes a long time +Date: Tue, 2 Aug 2005 13:57:50 -0500 +Message-ID: <3FB3AAE149F4AD4D8499E15EE8CF41A3460487@YBCDREX01.corp.ybusa.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: pg_dump for table with bytea takes a long time +Thread-Index: AcWXlBPdbGKJiWXZTU2vktSIqJrfAg== +From: "Sailer, Denis (YBUSA-CDR)" +To: +X-OriginalArrivalTime: 02 Aug 2005 18:57:49.0402 (UTC) + FILETIME=[13DB4BA0:01C59794] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.374 tagged_above=0 required=5 tests=AWL, + HTML_MESSAGE, HTML_TEXT_AFTER_BODY, HTML_TEXT_AFTER_HTML +X-Spam-Level: +X-Archive-Number: 200508/24 +X-Sequence-Number: 13771 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C59794.14BE874F +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Dumping a database which contains a table with a bytea column takes +approximately 25 hours and 45 minutes. The database has 26 tables in +it. The other 25 tables take less than 5 minutes to dump so almost all +time is spent dumping the bytea table. + +=20 + +prd1=3D# \d ybnet.ebook_master; + + Table "ybnet.ebook_master" + + Column | Type | Modifiers + +--------------+---------+----------- + + region_key | integer | not null + + book_key | integer | not null + + pub_sequence | integer | not null + + section_code | integer | not null + + pagenbr | integer | not null + + pdffile | bytea | + +Indexes: + + "ebook_master_pkey" PRIMARY KEY, btree (book_key, pub_sequence, +section_code, pagenbr, region_key) + +Foreign-key constraints: + + "FK1_book_year" FOREIGN KEY (book_key, pub_sequence, region_key) +REFERENCES ybnet.book_year(book_key, pub_sequence, region_key) + + "FK1_ebook_section" FOREIGN KEY (section_code) REFERENCES +ybnet.ebook_section(sectioncode) + +Tablespace: "ebook" + +=20 + +The tablespace ebook is 65504295 bytes in size and the ebook_master +table has 61-1GB files associated to it. + +=20 + +The command to dump the database is: + +=20 + +pg_dump --file=3D$DUMP_FILE --format=3Dc --data-only --verbose +--host=3Dybcdrdbp01 $DATABASE + +=20 + +I also perform a hot backup of this database using pg_start_backup(), +tar, and pg_stop_backup(). It takes only 20 minutes to create a tar +ball of the entire 62GB. I like the speed of this method, but it does +not allow me to restore 1 table at a time.=20 + +=20 + +The version of postgres is PostgreSQL 8.0.0 on i686-pc-linux-gnu, +compiled by GCC gcc (GCC) 3.2.2 + +=20 + +The machine has 4 Xeon 3.00 GHz processors with hyper-threading on and +4GB of memory. Postgres is supported by two file systems connected to +an EMC SAN disk array. One 2 GB one for the log files and a second 500 +GB one for the data and indexes. All output files for the backup files +are placed onto the 500 GB volume group and then backed up to an +external storage manager. + +=20 + +Portions of the config file are: + +=20 + +shared_buffers =3D 16384 + +work_mem =3D 8192 + +maintenance_work_mem =3D 16384 + +=20 + +max_fsm_pages =3D 512000 + +max_fsm_relations =3D 1000 + +fsync =3D true + +=20 + +# - Checkpoints - + +checkpoint_segments =3D 20 + +=20 + +# - Planner Cost Constants - + +effective_cache_size =3D 262144 + +random_page_cost =3D 3 + +=20 + +=20 + +I am looking for ideas for making the backup of the above table much +faster. + + +------_=_NextPart_001_01C59794.14BE874F +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + +
+ +

Dumping a database which contains a table with a = +bytea +column takes approximately 25 hours and 45 minutes.  The database = +has 26 +tables in it. The other 25 tables take less than 5 minutes to dump so = +almost +all time is spent dumping the bytea table.

+ +

 

+ +

prd1=3D# \d = +ybnet.ebook_master;

+ +

     +Table "ybnet.ebook_master"

+ +

    +Column    |  Type   | = +Modifiers

+ +

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

+ +

 region_key   +| integer | not null

+ +

 book_key     +| integer | not null

+ +

 pub_sequence = +| integer +| not null

+ +

 section_code = +| integer +| not null

+ +

 pagenbr      +| integer | not null

+ +

 pdffile      +| bytea   |

+ +

Indexes:

+ +

    = +"ebook_master_pkey" +PRIMARY KEY, btree (book_key, pub_sequence, section_code, pagenbr, = +region_key)

+ +

Foreign-key = +constraints:

+ +

    +"FK1_book_year" FOREIGN KEY (book_key, pub_sequence, = +region_key) +REFERENCES ybnet.book_year(book_key, pub_sequence, = +region_key)

+ +

    +"FK1_ebook_section" FOREIGN KEY (section_code) REFERENCES = +ybnet.ebook_section(sectioncode)

+ +

Tablespace: = +"ebook"

+ +

 

+ +

The tablespace ebook is 65504295 bytes in size and = +the ebook_master +table has 61-1GB files associated to it.

+ +

 

+ +

The command to dump the database = +is:

+ +

 

+ +

pg_dump --file=3D$DUMP_FILE --format=3Dc = +--data-only +--verbose -–host=3Dybcdrdbp01 $DATABASE

+ +

 

+ +

I also perform a hot backup of this database using = +pg_start_backup(), +tar, and pg_stop_backup().  It takes only 20 minutes to create a = +tar ball +of the entire 62GB.  I like the speed of this method, but it does = +not +allow me to restore 1 table at a time.

+ +

 

+ +

The version of postgres is PostgreSQL +8.0.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) = +3.2.2

+ +

 

+ +

The machine has 4 Xeon 3.00 GHz processors = +with +hyper-threading on and 4GB of memory.  Postgres is supported by two = +file +systems connected to an EMC SAN disk array.  One 2 GB one for the = +log +files and a second 500 GB one for the data and indexes.  All output = +files +for the backup files are placed onto the 500 GB volume group and then = +backed up +to an external storage manager.

+ +

 

+ +

Portions of the config file = +are:

+ +

 

+ +

shared_buffers =3D = +16384

+ +

work_mem =3D = +8192

+ +

maintenance_work_mem =3D = +16384

+ +

 

+ +

max_fsm_pages =3D = +512000

+ +

max_fsm_relations =3D 1000

+ +

fsync =3D = +true

+ +

 

+ +

# - Checkpoints = +-

+ +

checkpoint_segments =3D 20

+ +

 

+ +

# - Planner Cost = +Constants -

+ +

effective_cache_size =3D +262144

+ +

random_page_cost =3D 3

+ +

 

+ +

 

+ +

I am looking for ideas for making the backup of the = +above +table much faster.

+ +
+ + + + +=00 +------_=_NextPart_001_01C59794.14BE874F-- + +From pgsql-performance-owner@postgresql.org Tue Aug 2 16:59:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 67F1E528CC + for ; + Tue, 2 Aug 2005 16:59:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91341-07 + for ; + Tue, 2 Aug 2005 19:59:30 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 94A8B52A9E + for ; + Tue, 2 Aug 2005 16:59:28 -0300 (ADT) +Received: from [84.48.51.94] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1E02tD-0004eD-N5; Tue, 02 Aug 2005 21:57:38 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id 5085FE004E; Tue, 2 Aug 2005 21:59:16 +0200 (CEST) +Date: Tue, 2 Aug 2005 21:59:15 +0200 +From: Tobias Brox +To: Tobias Brox +Cc: pgsql-performance@postgresql.org +Subject: Re: "nice"/low priority Query +Message-ID: <20050802195915.GA9691@tobias.lan> +References: <20050802160434.GD9278@tobias.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050802160434.GD9278@tobias.lan> +Organization: Group Nordicbet +User-Agent: Mutt/1.5.8i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/25 +X-Sequence-Number: 13772 + +[Tobias Brox - Tue at 06:04:34PM +0200] +> (...) and at one +> point in the code I'm even asking the database for "explain plan", grepping +> out the estimated cost number, and referring the user to take contact with +> the IT-dept if he really needs the report. But I digress. + +I just came to think about some more "dirty" tricks I can do. I have turned +on stats collection in the configuration; now, if I do: + + select count(*) from pg_stat_activity where not current_query like '%'; + +or, eventually: + + select count(*) from pg_stat_activity + where not current_query like '%' and query_start+'1 second'; + Wed, 3 Aug 2005 06:02:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76751-05 + for ; + Wed, 3 Aug 2005 09:02:33 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B01052ABA + for ; + Wed, 3 Aug 2005 06:02:32 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id 5A2E140E099; Wed, 3 Aug 2005 10:02:29 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 3028515EDA; + Wed, 3 Aug 2005 09:53:33 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 10207-08; Wed, 3 Aug 2005 09:53:29 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id A281715ED9; + Wed, 3 Aug 2005 09:53:29 +0100 (BST) +Message-ID: <42F08609.5060709@archonet.com> +Date: Wed, 03 Aug 2005 09:53:29 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tobias Brox +Cc: pgsql-performance@postgresql.org +Subject: Re: "nice"/low priority Query +References: <20050802160434.GD9278@tobias.lan> + <20050802195915.GA9691@tobias.lan> +In-Reply-To: <20050802195915.GA9691@tobias.lan> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/26 +X-Sequence-Number: 13773 + +Tobias Brox wrote: +> [Tobias Brox - Tue at 06:04:34PM +0200] +> +>>(...) and at one +>>point in the code I'm even asking the database for "explain plan", grepping +>>out the estimated cost number, and referring the user to take contact with +>>the IT-dept if he really needs the report. But I digress. +> +> +> I just came to think about some more "dirty" tricks I can do. I have turned +> on stats collection in the configuration; now, if I do: +> +> select count(*) from pg_stat_activity where not current_query like '%'; +> +> or, eventually: +> +> select count(*) from pg_stat_activity +> where not current_query like '%' and query_start+'1 second' +> it will give a hint about how busy the database server is, thus I can +> eventually let the application sleep and retry if there are any other heavy +> queries in progress. + +Or - create a table with an estimated_cost column, when you start a new +"heavy" query, insert that query's cost, then sleep +SUM(estimated_cost)/100 secs or something. When the query ends, delete +the cost-row. + +Hmm - actually rather than dividing by 100, perhaps make it a tunable value. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Aug 3 09:48:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 78C2B52972 + for ; + Wed, 3 Aug 2005 09:48:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30383-05 + for ; + Wed, 3 Aug 2005 12:48:35 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.198]) + by svr1.postgresql.org (Postfix) with ESMTP id 2796F52808 + for ; + Wed, 3 Aug 2005 09:48:34 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i8so119919wra + for ; + Wed, 03 Aug 2005 05:48:38 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=UXXQJcEQJk0qKskeAO5hn53xadj7ZwXK1ofiFZXH/xu+0XM4qtEDL7Aca1Gd+hEd+BMqyvbKt0CYQJuHZJE8EteOuvyxYW/5TuSYmgAIj7RCgDaDEM6Q4EK6gVbrgXezwMyxJXUhD9Ti7+2vVsS4eStEw/vMPn+rALnTk3uEfPU= +Received: by 10.54.14.29 with SMTP id 29mr579846wrn; + Wed, 03 Aug 2005 05:48:38 -0700 (PDT) +Received: by 10.54.42.25 with HTTP; Wed, 3 Aug 2005 05:48:38 -0700 (PDT) +Message-ID: +Date: Wed, 3 Aug 2005 14:48:38 +0200 +From: Meetesh Karia +Reply-To: meetesh.karia@alumni.duke.edu +To: Tom Lane +Subject: Re: Planner incorrectly choosing seq scan over index scan +Cc: John Arbash Meinel , + pgsql-performance@postgresql.org +In-Reply-To: +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_247_16072047.1123073318453" +References: + <42EEAD4B.4010905@arbash-meinel.com> + + <26292.1122941726@sss.pgh.pa.us> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.177 tagged_above=0 required=5 tests=AWL, HTML_40_50, + HTML_MESSAGE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/27 +X-Sequence-Number: 13774 + +------=_Part_247_16072047.1123073318453 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Btw - I tried playing around with some of the other planner cost constants= +=20 +but I wasn't able to get the planner to choose the index scan. It seems lik= +e=20 +the issue is that the estimated cost for fetching one row from the index ( +3.02) is a little high in my case. Is there any way that I can adjust that= +=20 +cost estimate? Are there any side effects of doing that? Or is my best=20 +solution to simple set enable_hashjoin to off for this query? + +Thanks, +Meetesh + +On 8/2/05, Meetesh Karia wrote: +>=20 +> Thanks Tom, +>=20 +> That modifies the query plan slightly, but the planner still decides to d= +o=20 +> a hash join for the lte_user table aliased 't'. Though, if I make this=20 +> change and set enable_hashjoin to off, the query plan (and execution time= +)=20 +> gets even better. +>=20 +> enable_hashjoin =3D on +> ---------------------------------- +> QUERY PLAN +> Sort (cost=3D10113.35..10122.02 rows=3D3467 width=3D48) (actual time=3D +> 1203.000..1203.000 rows=3D3467 loops=3D1) +> Sort Key: c.sourceid, c.targetid +> -> Nested Loop (cost=3D8711.19..9909.50 rows=3D3467 width=3D48) (actual t= +ime=3D +> 1156.000..1203.000 rows=3D3467 loops=3D1) +> -> Index Scan using lte_user_pkey on lte_user s (cost=3D0.00..3.02 rows= +=3D1=20 +> width=3D16) (actual time=3D0.000..0.000 rows=3D1 loops=3D1) +> Index Cond: (617004 =3D user_id) +> -> Hash Join (cost=3D8711.19..9776.46 rows=3D3467 width=3D40) (actual tim= +e=3D +> 1156.000..1187.000 rows=3D3467 loops=3D1) +> Hash Cond: ("outer".targetid =3D "inner".user_id) +> -> Seq Scan on candidates617004 c (cost=3D0.00..76.34 rows=3D3467 width= +=3D32)=20 +> (actual time=3D0.000..16.000 rows=3D3467 loops=3D1) +> Filter: (sourceid =3D 617004) +> -> Hash (cost=3D8012.55..8012.55 rows=3D279455 width=3D16) (actual time= +=3D +> 1141.000..1141.000 rows=3D0 loops=3D1) +> -> Seq Scan on lte_user t (cost=3D0.00..8012.55 rows=3D279455 width=3D16)= +=20 +> (actual time=3D0.000..720.000 rows=3D279395 loops=3D1) +> Total runtime: 1218.000 ms +>=20 +> enable_hashjoin =3D off +> ----------------------------------- +> QUERY PLAN +> Sort (cost=3D10942.56..10951.22 rows=3D3467 width=3D48) (actual time=3D +> 188.000..188.000 rows=3D3467 loops=3D1) +> Sort Key: c.sourceid, c.targetid +> -> Nested Loop (cost=3D0.00..10738.71 rows=3D3467 width=3D48) (actual tim= +e=3D +> 0.000..188.000 rows=3D3467 loops=3D1) +> -> Index Scan using lte_user_pkey on lte_user s (cost=3D0.00..3.02 rows= +=3D1=20 +> width=3D16) (actual time=3D0.000..0.000 rows=3D1 loops=3D1) +> Index Cond: (617004 =3D user_id) +> -> Nested Loop (cost=3D0.00..10605.67 rows=3D3467 width=3D40) (actual tim= +e=3D +> 0.000..157.000 rows=3D3467 loops=3D1) +> -> Seq Scan on candidates617004 c (cost=3D0.00..76.34 rows=3D3467 width= +=3D32)=20 +> (actual time=3D0.000..15.000 rows=3D3467 loops=3D1) +> Filter: (sourceid =3D 617004) +> -> Index Scan using lte_user_pkey on lte_user t (cost=3D0.00..3.02 rows= +=3D1=20 +> width=3D16) (actual time=3D0.028..0.037 rows=3D1 loops=3D3467) +> Index Cond: ("outer".targetid =3D t.user_id) +> Total runtime: 188.000 ms +>=20 +> Thanks, +> Meetesh +>=20 +> On 8/2/05, Tom Lane wrote: +> >=20 +> > Meetesh Karia writes: +> > > Sure. The lte_user table is just a collection of users. user_id is=20 +> > assigned=3D +> > > uniquely using a sequence. During some processing, we create a=20 +> > candidates=3D=20 +> > > table (candidates617004 in our case). This table is usually a temp=20 +> > table.=3D +> > > sourceid is a user_id (in this case it is always 617004) and targetid= +=20 +> > is=3D20 +> > > also a user_id (2860 distinct values out of 3467). The rest of the=3D= +20=20 +> > > information is either only used in the select clause or not used at= +=20 +> > all=3D20 +> > > during this processing. +> >=20 +> > If you know that sourceid has only a single value, it'd probably be +> > helpful to call out that value in the query, ie,=20 +> > where ... AND c.sourceId =3D 617004 ... +> >=20 +> > regards, tom lane +> >=20 +>=20 +> + +------=_Part_247_16072047.1123073318453 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Btw - I tried playing around with some of the other planner cost +constants but I wasn't able to get the planner to choose the index +scan.  It seems like the issue is that the estimated cost for +fetching one row from the index (3.02) is a little high in my +case.  Is there any way that I can adjust that cost +estimate?  Are there any side effects of doing that?  Or is +my best solution to simple set enable_hashjoin to off for this query?
+
+Thanks,
+Meetesh

On 8/2/05, Meetesh Karia <meetesh.karia@gmail.com> wrote:
+Thanks Tom,
+
+That modifies the query plan slightly, but the planner still decides to +do a hash join for the lte_user table aliased 't'.  Though, if I +make this change and set enable_hashjoin to off, the query plan (and +execution time) gets even better.
+
+enable_hashjoin =3D on
+----------------------------------
+QUERY PLAN
+Sort  (cost=3D10113.35..10122.02 rows=3D3467 width=3D48) (actual time= +=3D1203.000..1203.000 rows=3D3467 loops=3D1)
+  Sort Key: c.sourceid, c.targetid
+  ->  Nested Loop  (cost=3D8711.19..9909.50 rows=3D3467 +width=3D48) (actual time=3D1156.000..1203.000 rows=3D3467 loops=3D1)
+        ->  Index Scan using +lte_user_pkey on lte_user s  (cost=3D0.00..3.02 rows=3D1 width=3D16) +(actual time=3D0.000..0.000 rows=3D1 loops=3D1)
+            &nb= +sp; Index Cond: (617004 =3D user_id)
+        ->  Hash Join  +(cost=3D8711.19..9776.46 rows=3D3467 width=3D40) (actual +time=3D1156.000..1187.000 rows=3D3467 loops=3D1)
+            &nb= +sp; Hash Cond: ("outer".targetid =3D "inner".user_id)
+            &nb= +sp; +->  Seq Scan on candidates617004 c  (cost=3D0.00..76.34 +rows=3D3467 width=3D32) (actual time=3D0.000..16.000 rows=3D3467 loops=3D1)= +
+            &nb= +sp;       +Filter: (sourceid =3D 617004)
+            &nb= +sp; +->  Hash  (cost=3D8012.55..8012.55 rows=3D279455 width=3D16) +(actual time=3D1141.000..1141.000 rows=3D0 loops=3D1)
+            &nb= +sp;       +->  Seq Scan on lte_user t  (cost=3D0.00..8012.55 +rows=3D279455 width=3D16) (actual time=3D0.000..720.000 rows=3D279395 loops= +=3D1)
+Total runtime: 1218.000 ms
+
+enable_hashjoin =3D off
+-----------------------------------
+QUERY PLAN
+Sort  (cost=3D10942.56..10951.22 rows=3D3467 width=3D48) (actual time= +=3D188.000..188.000 rows=3D3467 loops=3D1)
+  Sort Key: c.sourceid, c.targetid
+  ->  Nested Loop  (cost=3D0.00..10738.71 rows=3D3467 wid= +th=3D48) (actual time=3D0.000..188.000 rows=3D3467 loops=3D1)
+        ->  Index Scan using +lte_user_pkey on lte_user s  (cost=3D0.00..3.02 rows=3D1 width=3D16) +(actual time=3D0.000..0.000 rows=3D1 loops=3D1)
+            &nb= +sp; Index Cond: (617004 =3D user_id)
+        ->  Nested +Loop  (cost=3D0.00..10605.67 rows=3D3467 width=3D40) (actual +time=3D0.000..157.000 rows=3D3467 loops=3D1)
+            &nb= +sp; +->  Seq Scan on candidates617004 c  (cost=3D0.00..76.34 +rows=3D3467 width=3D32) (actual time=3D0.000..15.000 rows=3D3467 loops=3D1)= +
+            &nb= +sp;       +Filter: (sourceid =3D 617004)
+            &nb= +sp; +->  Index Scan using lte_user_pkey on lte_user t  +(cost=3D0.00..3.02 rows=3D1 width=3D16) (actual time=3D0.028..0.037 rows=3D= +1 +loops=3D3467)
+            &nb= +sp;       +Index Cond: ("outer".targetid =3D t.user_id)
+Total runtime: 188.000 ms
+
+Thanks,
+Meetesh


<= +div>On 8/2/05, To= +m Lane < +tgl@sss.pgh.pa.us> wrote:
+Meetesh Karia <meetesh.karia@= +gmail.com> writes:
> Sure. The lte_user table is just a collec= +tion of users. user_id is assigned=3D +
> uniquely using a sequence. During some processing, we create a can= +didates=3D +
> table (candidates617004 in our case). This table is usually a temp= + table.=3D
> sourceid is a user_id (in this case it is always 617004)= + and targetid is=3D20
> also a user_id (2860 distinct values out of 3= +467). The rest of the=3D20 +
> information is either only used in the select clause or not used a= +t all=3D20
> during this processing.

If you know that sourceid= + has only a single value, it'd probably be
helpful to call out that valu= +e in the query, ie, +
        where ... AND c.sourceI= +d =3D 617004 ...

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

+ +

+ +------=_Part_247_16072047.1123073318453-- + +From pgsql-performance-owner@postgresql.org Wed Aug 3 10:12:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 745E652851 + for ; + Wed, 3 Aug 2005 10:12:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37238-04 + for ; + Wed, 3 Aug 2005 13:12:04 +0000 (GMT) +Received: from TWMAIL.ESNCC.COM (static-66-173-159-28.t1.cavtel.net + [66.173.159.28]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C91352824 + for ; + Wed, 3 Aug 2005 10:12:02 -0300 (ADT) +Received: from spawar2i8uvlb9 ([150.125.117.63]) by TWMAIL.ESNCC.COM with + Microsoft SMTPSVC(5.0.2195.6713); Wed, 3 Aug 2005 09:12:05 -0400 +From: "Lane Van Ingen" +To: +Subject: Is There A Windows Version of Performance Tuning Documents? +Date: Wed, 3 Aug 2005 09:15:34 -0400 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 +Importance: Normal +X-OriginalArrivalTime: 03 Aug 2005 13:12:05.0409 (UTC) + FILETIME=[F1E2E910:01C5982C] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/28 +X-Sequence-Number: 13775 + +I have in my possession some performance tuning documents authored by Bruce +Momjian, Josh Berkus, and others. They give good information on utilities to +use (like ipcs, sar, vmstat, etc) to evaluate disk, memory, etc. performance +on Unix-based systems. + +Problem is, I have applications running on Windows 2003, and have worked +mostly on Unix before. Was wondering if anyone knows where there might be a +Windows performance document that tells what to use / where to look in +Windows for some of this data. I am thinking that I may not seeing what I +need +in perfmon or the Windows task manager. + +Want to answer questions like: + How much memory is being used for disk buffer cache? + How to I lock shared memory for PostgreSQL (if possible at all)? + How to determine if SWAP (esp. page-in) activity is hurting me? + Does Windows use a 'unified buffer cache' or not? + How do I determine how much space is required to do most of my sorts in +RAM? + + + +From pgsql-performance-owner@postgresql.org Wed Aug 3 12:08:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 29E1B528C2 + for ; + Wed, 3 Aug 2005 12:08:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83451-10 + for ; + Wed, 3 Aug 2005 15:08:05 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 308FB528B0 + for ; + Wed, 3 Aug 2005 12:08:03 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050803150800m9100g65v6e>; Wed, 3 Aug 2005 15:08:00 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 382C556051; Wed, 3 Aug 2005 10:07:58 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 8B65956016; + Wed, 3 Aug 2005 10:07:47 -0500 (CDT) +Message-ID: <42F0DDC3.9080707@arbash-meinel.com> +Date: Wed, 03 Aug 2005 10:07:47 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Lane Van Ingen , + Postgresql Performance +Subject: Re: Is There A Windows Version of Performance Tuning Documents? +References: +In-Reply-To: +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig6F8271126F508DC29657ACEF" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/29 +X-Sequence-Number: 13776 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig6F8271126F508DC29657ACEF +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Lane Van Ingen wrote: +> I have in my possession some performance tuning documents authored by Bruce +> Momjian, Josh Berkus, and others. They give good information on utilities to +> use (like ipcs, sar, vmstat, etc) to evaluate disk, memory, etc. performance +> on Unix-based systems. +> +> Problem is, I have applications running on Windows 2003, and have worked +> mostly on Unix before. Was wondering if anyone knows where there might be a +> Windows performance document that tells what to use / where to look in +> Windows for some of this data. I am thinking that I may not seeing what I +> need +> in perfmon or the Windows task manager. +> +> Want to answer questions like: +> How much memory is being used for disk buffer cache? +> How to I lock shared memory for PostgreSQL (if possible at all)? +> How to determine if SWAP (esp. page-in) activity is hurting me? +> Does Windows use a 'unified buffer cache' or not? +> How do I determine how much space is required to do most of my sorts in +> RAM? +> + +I don't know of any specific documentation. I would mention the +TaskManager as the first place I would look (Ctrl+Shift+Esc, or right +click on the task bar). +You can customize the columns that it shows in the process view, so you +can get an idea if something is paging, how much I/O it is using, etc. + +I'm sure there are other better tools, but this one is pretty easy to +get to, and shows quite a bit. + +John +=:-> + + +--------------enig6F8271126F508DC29657ACEF +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC8N3DJdeBCYSNAAMRAiVuAJ47FwYtwDCfkfVPiqkUf7YLH56zLwCePHMz +HYvS+fdAtzmqNRkCSjMtx4U= +=ffBB +-----END PGP SIGNATURE----- + +--------------enig6F8271126F508DC29657ACEF-- + +From pgsql-performance-owner@postgresql.org Thu Aug 4 05:14:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0534852840 + for ; + Thu, 4 Aug 2005 05:14:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63444-01 + for ; + Thu, 4 Aug 2005 08:14:04 +0000 (GMT) +Received: from larry.aptalaska.net (larry.aptalaska.net [64.186.96.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 7638252BB0 + for ; + Thu, 4 Aug 2005 05:14:01 -0300 (ADT) +Received: from [192.168.98.9] (rdbck-static-287.palmer.mtaonline.net + [64.4.232.33]) (authenticated bits=0) + by larry.aptalaska.net (8.13.4/8.13.4) with ESMTP id j748DwPo010731 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) + for ; Thu, 4 Aug 2005 00:13:59 -0800 +Message-ID: <42F1CE43.8040801@aptalaska.net> +Date: Thu, 04 Aug 2005 00:13:55 -0800 +From: Matthew Schumacher +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> <42EE9D83.8000405@pobox.com> +In-Reply-To: <42EE9D83.8000405@pobox.com> +X-Enigmail-Version: 0.91.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Spam-Bayes: Learn: ham +X-Scanned-By: MIMEDefang 2.52 on 64.186.96.3 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/30 +X-Sequence-Number: 13777 + +Okay, + +Here is the status of the SA updates and a question: + +Michael got SA changed to pass an array of tokens to the proc so right +there we gained a ton of performance due to connections and transactions +being grouped into one per email instead of one per token. + +Now I am working on making the proc even faster. Since we have all of +the tokens coming in as an array, it should be possible to get this down +to just a couple of queries. + +I have the proc using IN and NOT IN statements to update everything at +once from a temp table, but it progressively gets slower because the +temp table is growing between vacuums. At this point it's slightly +slower than the old update or else insert on every token. + +What I really want to do is have the token array available as a record +so that I can query against it, but not have it take up the resources of +a real table. If I could copy from an array into a record then I can +even get rid of the loop. Anyone have any thoughts on how to do this? + + +CREATE OR REPLACE FUNCTION put_tokens(inuserid INTEGER, + intokenary BYTEA[], + inspam_count INTEGER, + inham_count INTEGER, + inatime INTEGER) +RETURNS VOID AS ' +DECLARE + _token BYTEA; +BEGIN + + for i in array_lower(intokenary, 1) .. array_upper(intokenary, 1) + LOOP + _token := intokenary[i]; + INSERT INTO bayes_token_tmp VALUES (_token); + END LOOP; + + UPDATE + bayes_token + SET + spam_count = greatest_int(spam_count + inspam_count, 0), + ham_count = greatest_int(ham_count + inham_count , 0), + atime = greatest_int(atime, 1000) + WHERE + id = inuserid + AND + (token) IN (SELECT intoken FROM bayes_token_tmp); + + UPDATE + bayes_vars + SET + token_count = token_count + (SELECT count(intoken) FROM +bayes_token_tmp WHERE intoken NOT IN (SELECT token FROM bayes_token)), + newest_token_age = greatest_int(newest_token_age, inatime), + oldest_token_age = least_int(oldest_token_age, inatime) + WHERE + id = inuserid; + + INSERT INTO + bayes_token + SELECT + inuserid, + intoken, + inspam_count, + inham_count, + inatime + FROM + bayes_token_tmp + WHERE + (inspam_count > 0 OR inham_count > 0) + AND + (intoken) NOT IN (SELECT token FROM bayes_token); + + delete from bayes_token_tmp; + + RETURN; +END; +' LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION greatest_int (integer, integer) + RETURNS INTEGER + IMMUTABLE STRICT + AS 'SELECT CASE WHEN $1 < $2 THEN $2 ELSE $1 END;' + LANGUAGE SQL; + +CREATE OR REPLACE FUNCTION least_int (integer, integer) + RETURNS INTEGER + IMMUTABLE STRICT + AS 'SELECT CASE WHEN $1 < $2 THEN $1 ELSE $2 END;' + LANGUAGE SQL; + +From pgsql-performance-owner@postgresql.org Thu Aug 4 05:24:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F8A552BE8 + for ; + Thu, 4 Aug 2005 05:24:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62034-06 + for ; + Thu, 4 Aug 2005 08:24:33 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) + by svr1.postgresql.org (Postfix) with ESMTP id A49AC528D7 + for ; + Thu, 4 Aug 2005 05:24:30 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 70so79467wra + for ; + Thu, 04 Aug 2005 01:24:32 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type; + b=W7LoDuRvU8OEs7sYgpSMx0el88e9u/sOKm6XoBHa6Y100MNBiGMYWRWVmtCyJJ4hZXpXFy7B68pWub+po8+Go4adx8Q5bbcJTLwLQ5mDtR0BWntd5P7864J6lbzPJqKLC1s4sPLmXjmZIzjkuJs9GkyMJ6TEVwvFV9DfakjWK/o= +Received: by 10.54.7.21 with SMTP id 21mr1301386wrg; + Thu, 04 Aug 2005 01:24:32 -0700 (PDT) +Received: by 10.54.111.19 with HTTP; Thu, 4 Aug 2005 01:24:32 -0700 (PDT) +Message-ID: +Date: Thu, 4 Aug 2005 13:54:32 +0530 +From: prasanna s +Reply-To: prasanna s +To: postgres +Subject: Indexed views. +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3202_21493592.1123143872388" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.033 tagged_above=0 required=5 tests=HTML_10_20, + HTML_MESSAGE, HTML_SHORT_LENGTH, RCVD_BY_IP +X-Spam-Level: * +X-Archive-Number: 200508/31 +X-Sequence-Number: 13778 + +------=_Part_3202_21493592.1123143872388 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Does postgres support indexed views/materialised views that some of the=20 +other databases support? + +Thanks +Prasanna S + +------=_Part_3202_21493592.1123143872388 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Does postgres support indexed views/materialised views that some of the oth= +er databases support?
+
+Thanks
+Prasanna S
+ +------=_Part_3202_21493592.1123143872388-- + +From pgsql-performance-owner@postgresql.org Thu Aug 4 05:34:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B164252C8A + for ; + Thu, 4 Aug 2005 05:34:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67774-01 + for ; + Thu, 4 Aug 2005 08:34:30 +0000 (GMT) +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id CA21B52C86 + for ; + Thu, 4 Aug 2005 05:34:28 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 2978224FF1; + Thu, 4 Aug 2005 16:34:26 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id E81F024FE5; + Thu, 4 Aug 2005 16:34:22 +0800 (WST) +Message-ID: <42F1D3BA.1070107@familyhealth.com.au> +Date: Thu, 04 Aug 2005 16:37:14 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: prasanna s +Cc: postgres +Subject: Re: Indexed views. +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/32 +X-Sequence-Number: 13779 + +No, unless you use some custom triggers. + +prasanna s wrote: +> Does postgres support indexed views/materialised views that some of the +> other databases support? +> +> Thanks +> Prasanna S + + +From pgsql-performance-owner@postgresql.org Thu Aug 4 05:45:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DC4852BB0 + for ; + Thu, 4 Aug 2005 05:45:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67952-06 + for ; + Thu, 4 Aug 2005 08:45:42 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id BC5A052B01 + for ; + Thu, 4 Aug 2005 05:45:40 -0300 (ADT) +Received: (qmail 11009 invoked from network); 4 Aug 2005 10:45:51 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 4 Aug 2005 10:45:51 +0200 +To: "Matthew Schumacher" , + pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> +Message-ID: +Date: Thu, 04 Aug 2005 10:45:40 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <42F1CE43.8040801@aptalaska.net> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/33 +X-Sequence-Number: 13780 + + +> What I really want to do is have the token array available as a record +> so that I can query against it, but not have it take up the resources of +> a real table. If I could copy from an array into a record then I can +> even get rid of the loop. Anyone have any thoughts on how to do this? + + You could make a set-returning-function (about 3 lines) which RETURNs +NEXT every element in the array ; then you can use this SRF just like a +table and SELECT from it, join it with your other tables, etc. + +From pgsql-performance-owner@postgresql.org Thu Aug 4 05:52:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B4BBE52B04 + for ; + Thu, 4 Aug 2005 05:52:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68535-09 + for ; + Thu, 4 Aug 2005 08:52:35 +0000 (GMT) +Received: from epbsa003.epam.com (epbsa003.epam.com [195.56.119.212]) + by svr1.postgresql.org (Postfix) with ESMTP id D5A4552901 + for ; + Thu, 4 Aug 2005 05:52:33 -0300 (ADT) +Received: from [127.0.0.1] ([10.0.11.147]) by epbsa003.epam.com with Microsoft + SMTPSVC(6.0.3790.1830); Thu, 4 Aug 2005 10:52:33 +0200 +Message-ID: <42F1D739.2090309@forgeahead.hu> +Date: Thu, 04 Aug 2005 10:52:09 +0200 +From: Laszlo Hornyak +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Indexed views. +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 04 Aug 2005 08:52:33.0899 (UTC) + FILETIME=[DAF4CBB0:01C598D1] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/34 +X-Sequence-Number: 13781 + +prasanna s wrote: + +> Does postgres support indexed views/materialised views that some of +> the other databases support? +> +> Thanks +> Prasanna S + +Hi! + +It is not supported, but perhaps this will help you: +http://www.varlena.com/varlena/GeneralBits/Tidbits/matviews.html + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 4 11:10:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D61952C7D + for ; + Thu, 4 Aug 2005 11:10:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45969-03 + for ; + Thu, 4 Aug 2005 14:10:21 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id E0F0F52C92 + for ; + Thu, 4 Aug 2005 11:10:15 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050804141015m9100g5scfe>; Thu, 4 Aug 2005 14:10:19 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id C58CE56051; Thu, 4 Aug 2005 09:10:14 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 6BE7856016; + Thu, 4 Aug 2005 09:10:07 -0500 (CDT) +Message-ID: <42F221BB.5000702@arbash-meinel.com> +Date: Thu, 04 Aug 2005 09:10:03 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Matthew Schumacher +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> +In-Reply-To: <42F1CE43.8040801@aptalaska.net> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig2E83272BA840438B90498DA8" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/35 +X-Sequence-Number: 13782 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig2E83272BA840438B90498DA8 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Matthew Schumacher wrote: +> Okay, +> +> Here is the status of the SA updates and a question: +> +> Michael got SA changed to pass an array of tokens to the proc so right +> there we gained a ton of performance due to connections and transactions +> being grouped into one per email instead of one per token. +> +> Now I am working on making the proc even faster. Since we have all of +> the tokens coming in as an array, it should be possible to get this down +> to just a couple of queries. +> +> I have the proc using IN and NOT IN statements to update everything at +> once from a temp table, but it progressively gets slower because the +> temp table is growing between vacuums. At this point it's slightly +> slower than the old update or else insert on every token. + +I recommend that you drop and re-create the temp table. There is no +reason to have it around, considering you delete and re-add everything. +That means you never have to vacuum it, since it always only contains +the latest rows. + +> +> What I really want to do is have the token array available as a record +> so that I can query against it, but not have it take up the resources of +> a real table. If I could copy from an array into a record then I can +> even get rid of the loop. Anyone have any thoughts on how to do this? +> + +My one question here, is the inspam_count and inham_count *always* the +same for all tokens? I would have thought each token has it's own count. +Anyway, there are a few lines I would change: + +> +> CREATE OR REPLACE FUNCTION put_tokens(inuserid INTEGER, +> intokenary BYTEA[], +> inspam_count INTEGER, +> inham_count INTEGER, +> inatime INTEGER) +> RETURNS VOID AS ' +> DECLARE +> _token BYTEA; +> BEGIN +> + + -- create the table at the start of the procedure + CREATE TEMP TABLE bayes_token_tmp (intoken bytea); + -- You might also add primary key if you are going to be adding + -- *lots* of entries, but it sounds like you are going to have + -- less than 1 page, so it doesn't matter + +> for i in array_lower(intokenary, 1) .. array_upper(intokenary, 1) +> LOOP +> _token := intokenary[i]; +> INSERT INTO bayes_token_tmp VALUES (_token); +> END LOOP; +> +> UPDATE +> bayes_token +> SET +> spam_count = greatest_int(spam_count + inspam_count, 0), +> ham_count = greatest_int(ham_count + inham_count , 0), +> atime = greatest_int(atime, 1000) +> WHERE +> id = inuserid +> AND + +-- (token) IN (SELECT intoken FROM bayes_token_tmp); + EXISTS (SELECT token FROM bayes_token_tmp + WHERE intoken=token LIMIT 1); + +-- I would also avoid your intoken (NOT) IN (SELECT token FROM +-- bayes_token) There are a few possibilities, but to me +-- as your bayes_token table becomes big, this will start +-- to be the slow point + +-- Rather than doing 2 NOT IN queries, it *might* be faster to do + DELETE FROM bayes_token_tmp + WHERE NOT EXISTS (SELECT token FROM bayes_token + WHERE token=intoken); + + +> +> UPDATE +> bayes_vars +> SET + +-- token_count = token_count + (SELECT count(intoken) FROM +-- bayes_token_tmp WHERE intoken NOT IN (SELECT token FROM bayes_token)), + token_count = token_count + (SELECT count(intoken) + FROM bayes_token_tmp) + +-- You don't need the where NOT IN, since we already removed those rows + +> newest_token_age = greatest_int(newest_token_age, inatime), +> oldest_token_age = least_int(oldest_token_age, inatime) +> WHERE +> id = inuserid; +> +> INSERT INTO +> bayes_token +> SELECT +> inuserid, +> intoken, +> inspam_count, +> inham_count, +> inatime +> FROM +> bayes_token_tmp +> WHERE +> (inspam_count > 0 OR inham_count > 0) + +-- AND +-- (intoken) NOT IN (SELECT token FROM bayes_token); + +-- You don't need either of those lines, again because we already +-- filtered + +-- delete from bayes_token_tmp; +-- And rather than deleting all of the entries just + DROP TABLE bayes_token_tmp; + +> +> RETURN; +> END; +> ' LANGUAGE 'plpgsql'; +> +> CREATE OR REPLACE FUNCTION greatest_int (integer, integer) +> RETURNS INTEGER +> IMMUTABLE STRICT +> AS 'SELECT CASE WHEN $1 < $2 THEN $2 ELSE $1 END;' +> LANGUAGE SQL; +> +> CREATE OR REPLACE FUNCTION least_int (integer, integer) +> RETURNS INTEGER +> IMMUTABLE STRICT +> AS 'SELECT CASE WHEN $1 < $2 THEN $1 ELSE $2 END;' +> LANGUAGE SQL; +> + +So to clarify, here is my finished function: +------------------------------------ +CREATE OR REPLACE FUNCTION put_tokens(inuserid INTEGER, + intokenary BYTEA[], + inspam_count INTEGER, + inham_count INTEGER, + inatime INTEGER) +RETURNS VOID AS ' +DECLARE + _token BYTEA; +BEGIN + + CREATE TEMP TABLE bayes_token_tmp (intoken bytea); + for i in array_lower(intokenary, 1) .. array_upper(intokenary, 1) + LOOP + _token := intokenary[i]; + INSERT INTO bayes_token_tmp VALUES (_token); + END LOOP; + + UPDATE + bayes_token + SET + spam_count = greatest_int(spam_count + inspam_count, 0), + ham_count = greatest_int(ham_count + inham_count , 0), + atime = greatest_int(atime, 1000) + WHERE + id = inuserid + AND + EXISTS (SELECT token FROM bayes_token_tmp + WHERE intoken=token LIMIT 1); + + DELETE FROM bayes_token_tmp + WHERE NOT EXISTS (SELECT token FROM bayes_token + WHERE token=intoken); + + UPDATE + bayes_vars + SET + token_count = token_count + (SELECT count(intoken) + FROM bayes_token_tmp), + newest_token_age = greatest_int(newest_token_age, inatime), + oldest_token_age = least_int(oldest_token_age, inatime) + WHERE + id = inuserid; + + INSERT INTO + bayes_token + SELECT + inuserid, + intoken, + inspam_count, + inham_count, + inatime + FROM + bayes_token_tmp + WHERE + (inspam_count > 0 OR inham_count > 0) + + DROP TABLE bayes_token_tmp; + + RETURN; +END; +' LANGUAGE 'plpgsql'; + + +--------------enig2E83272BA840438B90498DA8 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC8iG+JdeBCYSNAAMRAuQpAJ9tr8Idt+akJTjmymh9QKw6ZRzr5QCglUC/ +Mm4izKm+0Gcl10WMNDY8Dmw= +=YH+y +-----END PGP SIGNATURE----- + +--------------enig2E83272BA840438B90498DA8-- + +From pgsql-performance-owner@postgresql.org Thu Aug 4 11:37:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D754552B17 + for ; + Thu, 4 Aug 2005 11:37:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51941-07 + for ; + Thu, 4 Aug 2005 14:37:02 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AC8765295A + for ; + Thu, 4 Aug 2005 11:37:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j74Eb362015611; + Thu, 4 Aug 2005 10:37:03 -0400 (EDT) +To: Matthew Schumacher +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +In-reply-to: <42F1CE43.8040801@aptalaska.net> +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> +Comments: In-reply-to Matthew Schumacher + message dated "Thu, 04 Aug 2005 00:13:55 -0800" +Date: Thu, 04 Aug 2005 10:37:02 -0400 +Message-ID: <15610.1123166222@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/36 +X-Sequence-Number: 13783 + +Matthew Schumacher writes: +> for i in array_lower(intokenary, 1) .. array_upper(intokenary, 1) +> LOOP +> _token := intokenary[i]; +> INSERT INTO bayes_token_tmp VALUES (_token); +> END LOOP; + +> UPDATE +> bayes_token +> SET +> spam_count = greatest_int(spam_count + inspam_count, 0), +> ham_count = greatest_int(ham_count + inham_count , 0), +> atime = greatest_int(atime, 1000) +> WHERE +> id = inuserid +> AND +> (token) IN (SELECT intoken FROM bayes_token_tmp); + +I don't really see why you think that this path is going to lead to +better performance than where you were before. Manipulation of the +temp table is never going to be free, and IN (sub-select) is always +inherently not fast, and NOT IN (sub-select) is always inherently +awful. Throwing a pile of simple queries at the problem is not +necessarily the wrong way ... especially when you are doing it in +plpgsql, because you've already eliminated the overhead of network +round trips and repeated planning of the queries. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Aug 4 12:08:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E46C0528C2 + for ; + Thu, 4 Aug 2005 12:08:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61577-10 + for ; + Thu, 4 Aug 2005 15:08:24 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id A04AA5295A + for ; + Thu, 4 Aug 2005 12:08:22 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050804150821m9200an2ave>; Thu, 4 Aug 2005 15:08:21 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 09A2C56051; Thu, 4 Aug 2005 10:08:21 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 9A76956016; + Thu, 4 Aug 2005 10:08:13 -0500 (CDT) +Message-ID: <42F22F59.7090901@arbash-meinel.com> +Date: Thu, 04 Aug 2005 10:08:09 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Matthew Schumacher , + pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> + <15610.1123166222@sss.pgh.pa.us> +In-Reply-To: <15610.1123166222@sss.pgh.pa.us> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig7354D6CDCD06455821ED204B" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/37 +X-Sequence-Number: 13784 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig7354D6CDCD06455821ED204B +Content-Type: multipart/mixed; + boundary="------------030100080708090409060609" + +This is a multi-part message in MIME format. +--------------030100080708090409060609 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: +> Matthew Schumacher writes: +> +>> for i in array_lower(intokenary, 1) .. array_upper(intokenary, 1) +>> LOOP +>> _token := intokenary[i]; +>> INSERT INTO bayes_token_tmp VALUES (_token); +>> END LOOP; +> +> +>> UPDATE +>> bayes_token +>> SET +>> spam_count = greatest_int(spam_count + inspam_count, 0), +>> ham_count = greatest_int(ham_count + inham_count , 0), +>> atime = greatest_int(atime, 1000) +>> WHERE +>> id = inuserid +>> AND +>> (token) IN (SELECT intoken FROM bayes_token_tmp); +> +> +> I don't really see why you think that this path is going to lead to +> better performance than where you were before. Manipulation of the +> temp table is never going to be free, and IN (sub-select) is always +> inherently not fast, and NOT IN (sub-select) is always inherently +> awful. Throwing a pile of simple queries at the problem is not +> necessarily the wrong way ... especially when you are doing it in +> plpgsql, because you've already eliminated the overhead of network +> round trips and repeated planning of the queries. + +So for an IN (sub-select), does it actually pull all of the rows from +the other table, or is the planner smart enough to stop once it finds +something? + +Is IN (sub-select) about the same as EXISTS (sub-select WHERE x=y)? + +What about NOT IN (sub-select) versus NOT EXISTS (sub-select WHERE x=y) + +I would guess that the EXISTS/NOT EXISTS would be faster, though it +probably would necessitate using a nested loop (at least that seems to +be the way the query is written). + +I did some tests on a database with 800k rows, versus a temp table with +2k rows. I did one sequential test (1-2000, with 66 rows missing), and +one sparse test (1-200, 100000-100200, 200000-200200, ... with 658 rows +missing). + +If found that NOT IN did indeed have to load the whole table. IN was +smart enough to do a nested loop. +EXISTS and NOT EXISTS did a sequential scan on my temp table, with a +SubPlan filter (which looks a whole lot like a Nested Loop). + +What I found was that IN performed about the same as EXISTS (since they +are both effectively doing a nested loop), but that NOT IN took 4,000ms +while NOT EXISTS was the same speed as EXISTS at around 166ms. + +Anyway, so it does seem like NOT IN is not a good choice, but IN seems +to be equivalent to EXISTS, and NOT EXISTS is also very fast. + +Is this generally true, or did I just get lucky on my data? + +John +=:-> + + + +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + +--------------030100080708090409060609 +Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; + name="random_exists.txt" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="random_exists.txt" + +mifar07=# EXPLAIN ANALYZE SELECT id FROM ids WHERE id IN (SELECT id FROM object_t); + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------- + Nested Loop IN Join (cost=0.00..9851.68 rows=2140 width=4) (actual time=0.085..183.889 rows=1351 loops=1) + -> Seq Scan on ids (cost=0.00..31.40 rows=2140 width=4) (actual time=0.014..24.032 rows=2009 loops=1) + -> Index Scan using object_t_pkey on object_t (cost=0.00..4.58 rows=1 width=4) (actual time=0.071..0.071 rows=1 loops=2009) + Index Cond: ("outer".id = object_t.id) + Total runtime: 184.823 ms +(5 rows) + +Time: 186.931 ms +mifar07=# EXPLAIN ANALYZE SELECT id FROM ids WHERE EXISTS (SELECT id FROM object_t o WHERE o.id = ids.id); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on ids (cost=0.00..9824.93 rows=1070 width=4) (actual time=0.086..165.053 rows=1351 loops=1) + Filter: (subplan) + SubPlan + -> Index Scan using object_t_pkey on object_t o (cost=0.00..4.58 rows=1 width=4) (actual time=0.025..0.025 rows=1 loops=2009) + Index Cond: (id = $0) + Total runtime: 165.995 ms +(6 rows) + +Time: 167.795 ms +mifar07=# EXPLAIN ANALYZE SELECT id FROM ids WHERE id NOT IN (SELECT id FROM object_t); + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------- + Seq Scan on ids (cost=36410.51..36447.26 rows=1070 width=4) (actual time=4168.247..4172.080 rows=658 loops=1) + Filter: (NOT (hashed subplan)) + SubPlan + -> Seq Scan on object_t (cost=0.00..34381.81 rows=811481 width=4) (actual time=0.044..2464.296 rows=811481 loops=1) + Total runtime: 4210.784 ms +(5 rows) + +Time: 4212.276 ms +mifar07=# EXPLAIN ANALYZE SELECT id FROM ids WHERE NOT EXISTS (SELECT id FROM object_t o WHERE o.id = ids.id); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on ids (cost=0.00..9824.93 rows=1070 width=4) (actual time=0.372..164.510 rows=658 loops=1) + Filter: (NOT (subplan)) + SubPlan + -> Index Scan using object_t_pkey on object_t o (cost=0.00..4.58 rows=1 width=4) (actual time=0.064..0.064 rows=1 loops=2009) + Index Cond: (id = $0) + Total runtime: 165.016 ms +(6 rows) + +Time: 166.786 ms + + +--------------030100080708090409060609 +Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; + name="sequential_exists_test.txt" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="sequential_exists_test.txt" + +mifar07=# EXPLAIN ANALYZE SELECT id FROM ids WHERE id IN (SELECT id FROM object_t); + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------- + Nested Loop IN Join (cost=0.00..9851.68 rows=2140 width=4) (actual time=0.069..97.567 rows=1934 loops=1) + -> Seq Scan on ids (cost=0.00..31.40 rows=2140 width=4) (actual time=0.012..1.868 rows=2000 loops=1) + -> Index Scan using object_t_pkey on object_t (cost=0.00..4.58 rows=1 width=4) (actual time=0.045..0.045 rows=1 loops=2000) + Index Cond: ("outer".id = object_t.id) + Total runtime: 98.236 ms +(5 rows) + +Time: 99.921 ms +mifar07=# EXPLAIN ANALYZE SELECT id FROM ids WHERE EXISTS (SELECT id FROM object_t o WHERE o.id = ids.id); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on ids (cost=0.00..9824.93 rows=1070 width=4) (actual time=0.071..74.158 rows=1934 loops=1) + Filter: (subplan) + SubPlan + -> Index Scan using object_t_pkey on object_t o (cost=0.00..4.58 rows=1 width=4) (actual time=0.013..0.013 rows=1 loops=2000) + Index Cond: (id = $0) + Total runtime: 74.798 ms +(6 rows) + +Time: 86.287 ms +mifar07=# EXPLAIN ANALYZE SELECT id FROM ids WHERE id NOT IN (SELECT id FROM object_t); + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------- + Seq Scan on ids (cost=36410.51..36447.26 rows=1070 width=4) (actual time=4024.613..4028.774 rows=66 loops=1) + Filter: (NOT (hashed subplan)) + SubPlan + -> Seq Scan on object_t (cost=0.00..34381.81 rows=811481 width=4) (actual time=0.040..2503.374 rows=811481 loops=1) + Total runtime: 4122.327 ms +(5 rows) + +Time: 4134.659 ms +mifar07=# EXPLAIN ANALYZE SELECT id FROM ids WHERE NOT EXISTS (SELECT id FROM object_t o WHERE o.id = ids.id); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on ids (cost=0.00..9824.93 rows=1070 width=4) (actual time=0.220..92.611 rows=66 loops=1) + Filter: (NOT (subplan)) + SubPlan + -> Index Scan using object_t_pkey on object_t o (cost=0.00..4.58 rows=1 width=4) (actual time=0.043..0.043 rows=1 loops=2000) + Index Cond: (id = $0) + Total runtime: 92.743 ms +(6 rows) + +Time: 94.190 ms +mifar07=# + + +--------------030100080708090409060609-- + +--------------enig7354D6CDCD06455821ED204B +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC8i9cJdeBCYSNAAMRAr5bAKCXMOelVjmGxp0O0x6BK9Orn0tYYwCeLGt6 +Q+6Co3FT9oCLnVyrtGxt/ec= +=CC8z +-----END PGP SIGNATURE----- + +--------------enig7354D6CDCD06455821ED204B-- + +From pgsql-performance-owner@postgresql.org Thu Aug 4 13:16:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 43E04529F6 + for ; + Thu, 4 Aug 2005 13:14:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78148-09 + for ; + Thu, 4 Aug 2005 16:14:14 +0000 (GMT) +Received: from larry.aptalaska.net (larry.aptalaska.net [64.186.96.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A7FB529D3 + for ; + Thu, 4 Aug 2005 13:14:13 -0300 (ADT) +Received: from [192.168.98.9] (rdbck-static-287.palmer.mtaonline.net + [64.4.232.33]) (authenticated bits=0) + by larry.aptalaska.net (8.13.4/8.13.4) with ESMTP id j74GDct8026452 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Thu, 4 Aug 2005 08:13:38 -0800 +Message-ID: <42F23EAF.2070603@aptalaska.net> +Date: Thu, 04 Aug 2005 08:13:35 -0800 +From: Matthew Schumacher +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John A Meinel +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> + <42F221BB.5000702@arbash-meinel.com> +In-Reply-To: <42F221BB.5000702@arbash-meinel.com> +X-Enigmail-Version: 0.91.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Spam-Bayes: Learn: ham +X-Scanned-By: MIMEDefang 2.52 on 64.186.96.3 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/38 +X-Sequence-Number: 13785 + +John A Meinel wrote: +> Matthew Schumacher wrote: +> + > I recommend that you drop and re-create the temp table. There is no +> reason to have it around, considering you delete and re-add everything. +> That means you never have to vacuum it, since it always only contains +> the latest rows. + +Whenever I have a create temp and drop statement I get these errors: + +select put_tokens(1, '{"\\\\000"}', 1, 1, 1000); +ERROR: relation with OID 582248 does not exist +CONTEXT: SQL statement "INSERT INTO bayes_token_tmp VALUES ( $1 )" +PL/pgSQL function "put_tokens" line 12 at SQL statement + + +> +> +> +> My one question here, is the inspam_count and inham_count *always* the +> same for all tokens? I would have thought each token has it's own count. +> Anyway, there are a few lines I would change: + +No, we get the userid, inspam, inham, and atime, and they are the same +for each token. If we have a different user we call the proc again. + +> -- create the table at the start of the procedure +> CREATE TEMP TABLE bayes_token_tmp (intoken bytea); +> -- You might also add primary key if you are going to be adding +> -- *lots* of entries, but it sounds like you are going to have +> -- less than 1 page, so it doesn't matter + +This causes errors, see above.... + +> -- (token) IN (SELECT intoken FROM bayes_token_tmp); +> EXISTS (SELECT token FROM bayes_token_tmp +> WHERE intoken=token LIMIT 1); +> +> -- I would also avoid your intoken (NOT) IN (SELECT token FROM +> -- bayes_token) There are a few possibilities, but to me +> -- as your bayes_token table becomes big, this will start +> -- to be the slow point +> +> -- Rather than doing 2 NOT IN queries, it *might* be faster to do +> DELETE FROM bayes_token_tmp +> WHERE NOT EXISTS (SELECT token FROM bayes_token +> WHERE token=intoken); +> +> + +I'll look into this. + + +thanks, + +schu + +From pgsql-performance-owner@postgresql.org Thu Aug 4 13:16:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37DAB529D3 + for ; + Thu, 4 Aug 2005 13:16:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79071-05 + for ; + Thu, 4 Aug 2005 16:16:17 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CC9452896 + for ; + Thu, 4 Aug 2005 13:16:16 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j74GGAX9016346; + Thu, 4 Aug 2005 12:16:10 -0400 (EDT) +To: John A Meinel +Cc: Matthew Schumacher , + pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +In-reply-to: <42F22F59.7090901@arbash-meinel.com> +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> + <15610.1123166222@sss.pgh.pa.us> + <42F22F59.7090901@arbash-meinel.com> +Comments: In-reply-to John A Meinel + message dated "Thu, 04 Aug 2005 10:08:09 -0500" +Date: Thu, 04 Aug 2005 12:16:10 -0400 +Message-ID: <16345.1123172170@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/39 +X-Sequence-Number: 13786 + +John A Meinel writes: +> Tom Lane wrote: +>> I don't really see why you think that this path is going to lead to +>> better performance than where you were before. + +> So for an IN (sub-select), does it actually pull all of the rows from +> the other table, or is the planner smart enough to stop once it finds +> something? + +It stops when it finds something --- but it's still a join operation +in essence. I don't see that putting the values one by one into a table +and then joining is going to be a win compared to just processing the +values one at a time against the main table. + +> Is IN (sub-select) about the same as EXISTS (sub-select WHERE x=y)? +> What about NOT IN (sub-select) versus NOT EXISTS (sub-select WHERE x=y) + +The EXISTS variants are actually worse, because we've not spent as much +time teaching the planner how to optimize them. There's effectively +only one decent plan for an EXISTS, which is that the subselect's "x" is +indexed and we do an indexscan probe using the outer "y" for each outer +row. IN and NOT IN can do that, or several alternative plans that might +be better depending on data statistics. + +However, that's cold comfort for Matthew's application -- the only way +he'd get any benefit from all those planner smarts is if he ANALYZEs +the temp table after loading it and then EXECUTEs the main query (so +that it gets re-planned every time). Plus, at least some of those +alternative plans would require an index on the temp table, which is +unlikely to be worth the cost of setting up. And finally, this +formulation requires separate IN and NOT IN tests that are necessarily +going to do a lot of redundant work. + +There's enough overhead here that I find it highly doubtful that it'll +be a win compared to the original approach of retail queries against the +main table. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Aug 4 13:32:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AC0852A76 + for ; + Thu, 4 Aug 2005 13:18:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78178-10 + for ; + Thu, 4 Aug 2005 16:18:05 +0000 (GMT) +Received: from larry.aptalaska.net (larry.aptalaska.net [64.186.96.3]) + by svr1.postgresql.org (Postfix) with ESMTP id E1BDF52A56 + for ; + Thu, 4 Aug 2005 13:18:04 -0300 (ADT) +Received: from [192.168.98.9] (rdbck-static-287.palmer.mtaonline.net + [64.4.232.33]) (authenticated bits=0) + by larry.aptalaska.net (8.13.4/8.13.4) with ESMTP id j74GI1Be027516 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Thu, 4 Aug 2005 08:18:02 -0800 +Message-ID: <42F23FB6.5010405@aptalaska.net> +Date: Thu, 04 Aug 2005 08:17:58 -0800 +From: Matthew Schumacher +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> + <15610.1123166222@sss.pgh.pa.us> +In-Reply-To: <15610.1123166222@sss.pgh.pa.us> +X-Enigmail-Version: 0.91.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Spam-Bayes: Learn: unavailable +X-Scanned-By: MIMEDefang 2.52 on 64.186.96.3 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/40 +X-Sequence-Number: 13787 + +Tom Lane wrote: + +> I don't really see why you think that this path is going to lead to +> better performance than where you were before. Manipulation of the +> temp table is never going to be free, and IN (sub-select) is always +> inherently not fast, and NOT IN (sub-select) is always inherently +> awful. Throwing a pile of simple queries at the problem is not +> necessarily the wrong way ... especially when you are doing it in +> plpgsql, because you've already eliminated the overhead of network +> round trips and repeated planning of the queries. +> +> regards, tom lane + +The reason why I think this may be faster is because I would avoid +running an update on data that needs to be inserted which saves +searching though the table for a matching token. + +Perhaps I should do the insert first, then drop those tokens from the +temp table, then do my updates in a loop. + +I'll have to do some benchmarking... + +schu + +From pgsql-performance-owner@postgresql.org Thu Aug 4 14:34:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 84E8B52A56 + for ; + Thu, 4 Aug 2005 14:34:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97153-06 + for ; + Thu, 4 Aug 2005 17:33:58 +0000 (GMT) +Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) + by svr1.postgresql.org (Postfix) with ESMTP id BD0AE5282F + for ; + Thu, 4 Aug 2005 14:33:55 -0300 (ADT) +Received: from localhost (mailbox.samurai.com [205.207.28.82]) + by mailbox.samurai.com (Postfix) with ESMTP id DB697239BEA; + Thu, 4 Aug 2005 13:33:55 -0400 (EDT) +Received: from mailbox.samurai.com ([205.207.28.82]) + by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, + port 10024) + with LMTP id 09013-01-2; Thu, 4 Aug 2005 13:33:25 -0400 (EDT) +Received: from [192.168.0.105] + (CPE3285f62f0d42-CM0011aec5ebbc.cpe.net.cable.rogers.com + [69.199.116.160]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mailbox.samurai.com (Postfix) with ESMTP id 38626239C3C; + Thu, 4 Aug 2005 13:32:40 -0400 (EDT) +Message-ID: <42F25137.4030107@samurai.com> +Date: Thu, 04 Aug 2005 13:32:39 -0400 +From: Neil Conway +User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Jim C. Nasby" +Cc: Tom Lane , Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: "nice"/low priority Query +References: <20050802160434.GD9278@tobias.lan> + <11484.1122999570@sss.pgh.pa.us> + <20050802172550.GZ60019@decibel.org> +In-Reply-To: <20050802172550.GZ60019@decibel.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/41 +X-Sequence-Number: 13788 + +Jim C. Nasby wrote: +> Actually, from what I've read 4.2BSD actually took priority into account +> when scheduling I/O. + +FWIW, you can set I/O priority in recent versions of the Linux kernel +using ionice, which is part of RML's schedutils package (which was +recently merged into util-linux). + +-Neil + +From pgsql-performance-owner@postgresql.org Thu Aug 4 14:36:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E115A52AB8 + for ; + Thu, 4 Aug 2005 14:35:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97627-09 + for ; + Thu, 4 Aug 2005 17:35:50 +0000 (GMT) +Received: from larry.aptalaska.net (larry.aptalaska.net [64.186.96.3]) + by svr1.postgresql.org (Postfix) with ESMTP id A52A352A97 + for ; + Thu, 4 Aug 2005 14:35:48 -0300 (ADT) +Received: from [192.168.98.9] (rdbck-static-287.palmer.mtaonline.net + [64.4.232.33]) (authenticated bits=0) + by larry.aptalaska.net (8.13.4/8.13.4) with ESMTP id j74HZiHp013869 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Thu, 4 Aug 2005 09:35:45 -0800 +Message-ID: <42F251F0.1070407@aptalaska.net> +Date: Thu, 04 Aug 2005 09:35:44 -0800 +From: Matthew Schumacher +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> + <15610.1123166222@sss.pgh.pa.us> <42F23FB6.5010405@aptalaska.net> +In-Reply-To: <42F23FB6.5010405@aptalaska.net> +X-Enigmail-Version: 0.91.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Spam-Bayes: Learn: ham +X-Scanned-By: MIMEDefang 2.52 on 64.186.96.3 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/42 +X-Sequence-Number: 13789 + +Matthew Schumacher wrote: +> Tom Lane wrote: +> +> +>>I don't really see why you think that this path is going to lead to +>>better performance than where you were before. Manipulation of the +>>temp table is never going to be free, and IN (sub-select) is always +>>inherently not fast, and NOT IN (sub-select) is always inherently +>>awful. Throwing a pile of simple queries at the problem is not +>>necessarily the wrong way ... especially when you are doing it in +>>plpgsql, because you've already eliminated the overhead of network +>>round trips and repeated planning of the queries. +>> +>> regards, tom lane +> +> +> The reason why I think this may be faster is because I would avoid +> running an update on data that needs to be inserted which saves +> searching though the table for a matching token. +> +> Perhaps I should do the insert first, then drop those tokens from the +> temp table, then do my updates in a loop. +> +> I'll have to do some benchmarking... +> +> schu + +Tom, I think your right, whenever I do a NOT IN it does a full table +scan against bayes_token and since that table is going to get very big +doing the simple query in a loop that uses an index seems a bit faster. + +John, thanks for your help, it was worth a try, but it looks like the +looping is just faster. + +Here is what I have so far in case anyone else has ideas before I +abandon it: + +CREATE OR REPLACE FUNCTION put_tokens(inuserid INTEGER, + intokenary BYTEA[], + inspam_count INTEGER, + inham_count INTEGER, + inatime INTEGER) +RETURNS VOID AS ' +DECLARE + _token BYTEA; +BEGIN + + UPDATE + bayes_token + SET + spam_count = greatest_int(spam_count + inspam_count, 0), + ham_count = greatest_int(ham_count + inham_count , 0), + atime = greatest_int(atime, inatime) + WHERE + id = inuserid + AND + (token) IN (SELECT bayes_token_tmp FROM bayes_token_tmp(intokenary)); + + UPDATE + bayes_vars + SET + token_count = token_count + ( + SELECT + count(bayes_token_tmp) + FROM + bayes_token_tmp(intokenary) + WHERE + bayes_token_tmp NOT IN (SELECT token FROM bayes_token)), + newest_token_age = greatest_int(newest_token_age, inatime), + oldest_token_age = least_int(oldest_token_age, inatime) + WHERE + id = inuserid; + + INSERT INTO + bayes_token + SELECT + inuserid, + bayes_token_tmp, + inspam_count, + inham_count, + inatime + FROM + bayes_token_tmp(intokenary) + WHERE + (inspam_count > 0 OR inham_count > 0) + AND + (bayes_token_tmp) NOT IN (SELECT token FROM bayes_token); + + RETURN; +END; +' LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION bayes_token_tmp(intokenary BYTEA[]) RETURNS +SETOF bytea AS +' +BEGIN + for i in array_lower(intokenary, 1) .. array_upper(intokenary, 1) + LOOP + return next intokenary[i]; + END LOOP; + RETURN; +end +' +language 'plpgsql'; + +CREATE OR REPLACE FUNCTION greatest_int (integer, integer) + RETURNS INTEGER + IMMUTABLE STRICT + AS 'SELECT CASE WHEN $1 < $2 THEN $2 ELSE $1 END;' + LANGUAGE SQL; + +CREATE OR REPLACE FUNCTION least_int (integer, integer) + RETURNS INTEGER + IMMUTABLE STRICT + AS 'SELECT CASE WHEN $1 < $2 THEN $1 ELSE $2 END;' + LANGUAGE SQL; + +From pgsql-performance-owner@postgresql.org Thu Aug 4 16:36:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FBD052A28 + for ; + Thu, 4 Aug 2005 16:36:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38890-09 + for ; + Thu, 4 Aug 2005 19:36:23 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id D129552A34 + for ; + Thu, 4 Aug 2005 16:36:21 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050804193622m92009hu98e>; Thu, 4 Aug 2005 19:36:22 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 98B2256051; Thu, 4 Aug 2005 14:36:21 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 8B73056016; + Thu, 4 Aug 2005 14:36:15 -0500 (CDT) +Message-ID: <42F26E2C.8010607@arbash-meinel.com> +Date: Thu, 04 Aug 2005 14:36:12 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Matthew Schumacher +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> + <15610.1123166222@sss.pgh.pa.us> <42F23FB6.5010405@aptalaska.net> + <42F251F0.1070407@aptalaska.net> +In-Reply-To: <42F251F0.1070407@aptalaska.net> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigE5BF5323050368A690114C1F" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/43 +X-Sequence-Number: 13790 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigE5BF5323050368A690114C1F +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Matthew Schumacher wrote: +> Matthew Schumacher wrote: +> +>>Tom Lane wrote: +>> +>> +>> +>>>I don't really see why you think that this path is going to lead to +>>>better performance than where you were before. Manipulation of the +>>>temp table is never going to be free, and IN (sub-select) is always +>>>inherently not fast, and NOT IN (sub-select) is always inherently +>>>awful. Throwing a pile of simple queries at the problem is not +>>>necessarily the wrong way ... especially when you are doing it in +>>>plpgsql, because you've already eliminated the overhead of network +>>>round trips and repeated planning of the queries. +>>> +>>> regards, tom lane +>> +>> +>>The reason why I think this may be faster is because I would avoid +>>running an update on data that needs to be inserted which saves +>>searching though the table for a matching token. +>> +>>Perhaps I should do the insert first, then drop those tokens from the +>>temp table, then do my updates in a loop. +>> +>>I'll have to do some benchmarking... +>> +>>schu +> +> +> Tom, I think your right, whenever I do a NOT IN it does a full table +> scan against bayes_token and since that table is going to get very big +> doing the simple query in a loop that uses an index seems a bit faster. +> +> John, thanks for your help, it was worth a try, but it looks like the +> looping is just faster. +> +> Here is what I have so far in case anyone else has ideas before I +> abandon it: + +Surely this isn't what you have. You have *no* loop here, and you have +stuff like: + AND + (bayes_token_tmp) NOT IN (SELECT token FROM bayes_token); + +I'm guessing this isn't your last version of the function. + +As far as putting the CREATE TEMP TABLE inside the function, I think the +problem is that the first time it runs, it compiles the function, and +when it gets to the UPDATE/INSERT with the temporary table name, at +compile time it hard-codes that table id. + +I tried getting around it by using "EXECUTE" which worked, but it made +the function horribly slow. So I don't recommend it. + +Anyway, if you want us to evaluate it, you really need to send us the +real final function. + +John +=:-> + + +> +> CREATE OR REPLACE FUNCTION put_tokens(inuserid INTEGER, +> intokenary BYTEA[], +> inspam_count INTEGER, +> inham_count INTEGER, +> inatime INTEGER) +> RETURNS VOID AS ' +> DECLARE +> _token BYTEA; +> BEGIN +> +> UPDATE +> bayes_token +> SET +> spam_count = greatest_int(spam_count + inspam_count, 0), +> ham_count = greatest_int(ham_count + inham_count , 0), +> atime = greatest_int(atime, inatime) +> WHERE +> id = inuserid +> AND +> (token) IN (SELECT bayes_token_tmp FROM bayes_token_tmp(intokenary)); +> +> UPDATE +> bayes_vars +> SET +> token_count = token_count + ( +> SELECT +> count(bayes_token_tmp) +> FROM +> bayes_token_tmp(intokenary) +> WHERE +> bayes_token_tmp NOT IN (SELECT token FROM bayes_token)), +> newest_token_age = greatest_int(newest_token_age, inatime), +> oldest_token_age = least_int(oldest_token_age, inatime) +> WHERE +> id = inuserid; +> +> INSERT INTO +> bayes_token +> SELECT +> inuserid, +> bayes_token_tmp, +> inspam_count, +> inham_count, +> inatime +> FROM +> bayes_token_tmp(intokenary) +> WHERE +> (inspam_count > 0 OR inham_count > 0) +> AND +> (bayes_token_tmp) NOT IN (SELECT token FROM bayes_token); +> +> RETURN; +> END; +> ' LANGUAGE 'plpgsql'; +> +> CREATE OR REPLACE FUNCTION bayes_token_tmp(intokenary BYTEA[]) RETURNS +> SETOF bytea AS +> ' +> BEGIN +> for i in array_lower(intokenary, 1) .. array_upper(intokenary, 1) +> LOOP +> return next intokenary[i]; +> END LOOP; +> RETURN; +> end +> ' +> language 'plpgsql'; +> +> CREATE OR REPLACE FUNCTION greatest_int (integer, integer) +> RETURNS INTEGER +> IMMUTABLE STRICT +> AS 'SELECT CASE WHEN $1 < $2 THEN $2 ELSE $1 END;' +> LANGUAGE SQL; +> +> CREATE OR REPLACE FUNCTION least_int (integer, integer) +> RETURNS INTEGER +> IMMUTABLE STRICT +> AS 'SELECT CASE WHEN $1 < $2 THEN $1 ELSE $2 END;' +> LANGUAGE SQL; +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + +--------------enigE5BF5323050368A690114C1F +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC8m4vJdeBCYSNAAMRAvw8AJ0dAsgk5dgc0itJcCipWyX9Hs2gUACfa3gZ +8Z7cmebXPoBQBQqjTDaF3nU= +=ahb7 +-----END PGP SIGNATURE----- + +--------------enigE5BF5323050368A690114C1F-- + +From pgsql-performance-owner@postgresql.org Thu Aug 4 19:38:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 825F55282F + for ; + Thu, 4 Aug 2005 19:38:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81498-09 + for ; + Thu, 4 Aug 2005 22:38:13 +0000 (GMT) +Received: from larry.aptalaska.net (larry.aptalaska.net [64.186.96.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E09452800 + for ; + Thu, 4 Aug 2005 19:38:12 -0300 (ADT) +Received: from [192.168.98.9] (rdbck-static-287.palmer.mtaonline.net + [64.4.232.33]) (authenticated bits=0) + by larry.aptalaska.net (8.13.4/8.13.4) with ESMTP id j74MbfVE015904 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Thu, 4 Aug 2005 14:37:42 -0800 +Message-ID: <42F298B5.5010405@aptalaska.net> +Date: Thu, 04 Aug 2005 14:37:41 -0800 +From: Matthew Schumacher +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John A Meinel +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> + <15610.1123166222@sss.pgh.pa.us> <42F23FB6.5010405@aptalaska.net> + <42F251F0.1070407@aptalaska.net> + <42F26E2C.8010607@arbash-meinel.com> +In-Reply-To: <42F26E2C.8010607@arbash-meinel.com> +X-Enigmail-Version: 0.91.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Spam-Bayes: Learn: unavailable +X-Scanned-By: MIMEDefang 2.52 on 64.186.96.3 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/44 +X-Sequence-Number: 13791 + +John A Meinel wrote: + +> Surely this isn't what you have. You have *no* loop here, and you have +> stuff like: +> AND +> (bayes_token_tmp) NOT IN (SELECT token FROM bayes_token); +> +> I'm guessing this isn't your last version of the function. +> +> As far as putting the CREATE TEMP TABLE inside the function, I think the +> problem is that the first time it runs, it compiles the function, and +> when it gets to the UPDATE/INSERT with the temporary table name, at +> compile time it hard-codes that table id. +> +> I tried getting around it by using "EXECUTE" which worked, but it made +> the function horribly slow. So I don't recommend it. +> +> Anyway, if you want us to evaluate it, you really need to send us the +> real final function. +> +> John +> =:-> + +It is the final function. It doesn't need a loop because of the +bayes_token_tmp function I added. The array is passed to it and it +returns a record set so I can work off of it like it's a table. So the +function works the same way it before, but instead of using SELECT +intoken from TEMPTABLE, you use SELECT bayes_token_tmp from +bayes_token_tmp(intokenary). + +I think this is more efficient than the create table overhead, +especially because the incoming record set won't be to big. + +Thanks, + +schu + + +From pgsql-performance-owner@postgresql.org Thu Aug 4 19:43:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B2362528B3 + for ; + Thu, 4 Aug 2005 19:43:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83408-08 + for ; + Thu, 4 Aug 2005 22:42:59 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 713F25282F + for ; + Thu, 4 Aug 2005 19:42:58 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050804224259m92009ipade>; Thu, 4 Aug 2005 22:42:59 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 26B8F56051; Thu, 4 Aug 2005 17:42:59 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 81F4F56016; + Thu, 4 Aug 2005 17:42:53 -0500 (CDT) +Message-ID: <42F299EC.8080809@arbash-meinel.com> +Date: Thu, 04 Aug 2005 17:42:52 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Matthew Schumacher +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems testing with Spamassassin 3.1.0 +References: <42E9749F.6000709@aptalaska.net> + <1122616211.5691.340.camel@lamb.mcmillan.net.nz> + <42EA6966.8090402@aptalaska.net> + <1122668371.5691.352.camel@lamb.mcmillan.net.nz> + <19405.1122670917@sss.pgh.pa.us> <42EAA410.9010700@aptalaska.net> + <27897.1122748133@sss.pgh.pa.us> + <42EE8043.1050207@aptalaska.net> + <42EE93F8.5010003@aptalaska.net> + <20050801214931.GF60019@decibel.org> + <42EE9D83.8000405@pobox.com> <42F1CE43.8040801@aptalaska.net> + <15610.1123166222@sss.pgh.pa.us> <42F23FB6.5010405@aptalaska.net> + <42F251F0.1070407@aptalaska.net> + <42F26E2C.8010607@arbash-meinel.com> + <42F298B5.5010405@aptalaska.net> +In-Reply-To: <42F298B5.5010405@aptalaska.net> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig30078318CC01CA21BF5E0E03" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/45 +X-Sequence-Number: 13792 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig30078318CC01CA21BF5E0E03 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Matthew Schumacher wrote: +> John A Meinel wrote: +> +> +>>Surely this isn't what you have. You have *no* loop here, and you have +>>stuff like: +>> AND +>> (bayes_token_tmp) NOT IN (SELECT token FROM bayes_token); +>> +>>I'm guessing this isn't your last version of the function. +>> +>>As far as putting the CREATE TEMP TABLE inside the function, I think the +>>problem is that the first time it runs, it compiles the function, and +>>when it gets to the UPDATE/INSERT with the temporary table name, at +>>compile time it hard-codes that table id. +>> +>>I tried getting around it by using "EXECUTE" which worked, but it made +>>the function horribly slow. So I don't recommend it. +>> +>>Anyway, if you want us to evaluate it, you really need to send us the +>>real final function. +>> +>>John +>>=:-> +> +> +> It is the final function. It doesn't need a loop because of the +> bayes_token_tmp function I added. The array is passed to it and it +> returns a record set so I can work off of it like it's a table. So the +> function works the same way it before, but instead of using SELECT +> intoken from TEMPTABLE, you use SELECT bayes_token_tmp from +> bayes_token_tmp(intokenary). +> +> I think this is more efficient than the create table overhead, +> especially because the incoming record set won't be to big. +> +> Thanks, +> +> schu +> +> + +Well, I would at least recommend that you change the "WHERE +bayes_token_tmp NOT IN (SELECT token FROM bayes_token)" +with a +"WHERE NOT EXISTS (SELECT toke FROM bayes_token WHERE +token=bayes_token_tmp)" + +You might try experimenting with the differences, but on my system the +NOT IN has to do a full sequential scan on bayes_token and load all +entries into a list, while NOT EXISTS can do effectively a nested loop. + +The nested loop requires that there is an index on bayes_token(token), +but I'm pretty sure there is anyway. + +Again, in my testing, it was a difference of 4200ms versus 180ms. (800k +rows in my big table, 2k in the temp one) + +John +=:-> + + +--------------enig30078318CC01CA21BF5E0E03 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC8pnsJdeBCYSNAAMRApkHAKCXHa4ddIXDqGJRk4y9CRLeeEVjOACfcIqh +FmYng0yOyadGlXkBQRAgH/E= +=mZVF +-----END PGP SIGNATURE----- + +--------------enig30078318CC01CA21BF5E0E03-- + +From pgsql-performance-owner@postgresql.org Fri Aug 5 08:11:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3658E52986 + for ; + Fri, 5 Aug 2005 08:11:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77920-07 + for ; + Fri, 5 Aug 2005 11:11:32 +0000 (GMT) +Received: from mail2.aeccom.com (port-212-202-101-158.static.qsc.de + [212.202.101.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 67AF8529BD + for ; + Fri, 5 Aug 2005 08:11:29 -0300 (ADT) +Received: from [192.168.2.12] (port-83-236-156-26.static.qsc.de + [83.236.156.26]) by mail2.aeccom.com (Postfix) with ESMTP + id E88E0108; Fri, 5 Aug 2005 13:11:31 +0200 (CEST) +Message-ID: <42F34963.5080403@aeccom.com> +Date: Fri, 05 Aug 2005 13:11:31 +0200 +From: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Organization: AEC/communications GmbH +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: Sven Geisler +Subject: Performance problems on 4-way AMD Opteron 875 (dual core) +Content-Type: multipart/alternative; + boundary="------------050707070801080103090606" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.232 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, HTML_10_20, HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: +X-Archive-Number: 200508/46 +X-Sequence-Number: 13793 + +This is a multi-part message in MIME format. +--------------050707070801080103090606 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +[[I'm posting this on behalf of my co-worker who cannot post to this +list at the moment]] + +Hi, + +I had installed PostgreSQL on a 4-way AMD Opteron 875 (dual core) and +the performance isn't on the expected level. + +Details: +The "old" server is a 4-way XEON MP 3.0 GHz with 4MB L3 cache, 32 GB RAM +(PC1600) and local FC-RAID 10. Hyper-Threading is off. (DL580) +The "old" server is using Red Hat Enterprise Linux 3 Update 5. +The "new" server is a 4-way Opteron 875 with 1 MB L2 cache, 32 GB RAM +(PC3200) and the same local FC-RAID 10. (HP DL585) +The "new" server is using Red Hat Enterprise Linux 4 (with the latest +x86_64 kernel from Red Hat - 2.6.9-11.ELsmp #1 SMP Fri May 20 18:25:30 +EDT 2005 x86_64) +I use PostgreSQL version 8.0.3. + +The issue is that the Opteron is slower as the XEON MP under high load. +I have created a test with parallel queries which are typical for my +application. The queries are in a range of small queries (0.1 seconds) +and larger queries using join (15 seconds). +The test starts parallel clients. Each clients runs the queries in a +random order. The test takes care that a client use always the same +random order to get valid results. + +Here are the number of queries which the server has finished in a fix +period of time. +I used PostgreSQL 8.1 snapshot from last week compiled as 64bit binary +for DL585-64bit. +I used PostgreSQL 8.0.3 compiled as 32bit binary for DL585-32bit and DL580. +During the tests everything which is needed is in the file cache. I +didn't have read activity. +Context switch spikes are over 50000 during the test on both server. My +feeling is that the XEON has a tick more context switches. + + + +PostgreSQL params: +max_locks_per_transaction = 256 +shared_buffers = 40000 +effective_cache_size = 3840000 +work_mem = 300000 +maintenance_work_mem = 512000 +wal_buffers = 32 +checkpoint_segments = 24 + + +I was expecting two times more queries on the DL585. The DL585 with +PostgreSQL 8.0.3 32bit does meltdown earlier as the XEON in production +use. Please compare 4 clients and 8 clients. With 4 clients the Opteron +is in front and with 8 clients the XEON doesn't meltdown that much as +the Opteron. + +I don't have any idea what cause this. Benchmarks like SAP's SD 2-tier +showing that the DL585 can handle nearly three times more load as the +DL580 with XEON 3.0. We choose the 4-way Opteron 875 based on such +benchmark to replace the 4-way XEON MP. + +Does anyone have comments or ideas on which I have to focus my work? + +I guess, the shared buffer cause the meltdown when to many clients are +accessing the same data. +I didn't understand why the 4-way XEON MP 3.0 can deal with this better +as the 4-way Opteron 875. +The system load on the Opteron is never over 3.0. The XEON MP has a load +up to 4.0. + +Should I try other settings for PostgreSQL in postgresql.conf? +Should I try other setting for the compilation? + +I will compile the latest PostgreSQL 8.1 snapshot for 32bit to evaluate +the new shared buffer code from Tom. +I think, the 64bit is slow because my queries are CPU intensive. + +Can someone provide a commercial support contact for this issue? + +Sven. + + +--------------050707070801080103090606 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + + +
[[I'm +posting this on behalf of my co-worker who cannot post to this list at +the moment]]
+
+Hi, +
+
+I had installed PostgreSQL on a 4-way AMD Opteron 875 (dual core) and +the performance isn't on the expected level. +
+
+Details: +
+The "old" server is a 4-way XEON MP 3.0 GHz with 4MB L3 cache, 32 GB +RAM (PC1600)  and local FC-RAID 10. Hyper-Threading is off. (DL580) +
+The "old" server is using Red Hat Enterprise Linux 3 Update 5. +
+The "new" server is a 4-way Opteron 875 with 1 MB L2 cache, 32 GB RAM +(PC3200) and the same local FC-RAID 10. (HP DL585) +
+The "new" server is using Red Hat Enterprise Linux 4 (with the latest +x86_64 kernel from Red Hat - 2.6.9-11.ELsmp #1 SMP Fri May 20 18:25:30 +EDT 2005 x86_64) +
+I use PostgreSQL version 8.0.3. +
+
+The issue is that the Opteron is slower as the XEON MP under high load. +I have created a test with parallel queries which are typical for my +application. The queries are in a range of small queries (0.1 seconds) +and larger queries using join (15 seconds). +
+The test starts parallel clients. Each clients runs the queries in a +random order. The test takes care that a client use always the same +random order to get valid results. +
+
+Here are the number of queries which the server has finished in a fix +period of time. +
+I used PostgreSQL 8.1 snapshot from last week compiled as 64bit binary +for DL585-64bit. +
+I used PostgreSQL 8.0.3 compiled as 32bit binary for DL585-32bit and +DL580. +
+During the tests everything which is needed is in the file cache. I +didn't have read activity. +
+Context switch  spikes are over 50000 during the test on both server. +My feeling is that the XEON has a tick more context switches. +
+
+
+

+
+PostgreSQL params: +
+max_locks_per_transaction = 256 +
+shared_buffers = 40000 +
+effective_cache_size = 3840000 +
+work_mem = 300000 +
+maintenance_work_mem = 512000 +
+wal_buffers = 32 +
+checkpoint_segments = 24 +
+
+
+I was expecting two times more queries on the DL585. The DL585 with +PostgreSQL 8.0.3 32bit does meltdown earlier as the XEON in production +use. Please compare 4 clients and 8 clients. With 4 clients the Opteron +is in front and with 8 clients the XEON doesn't meltdown that much as +the Opteron. +
+
+I don't have any idea what cause this. Benchmarks like SAP's SD 2-tier +showing that the DL585 can handle nearly three times more load as the +DL580 with XEON 3.0. We choose the 4-way Opteron 875 based on such +benchmark to replace the 4-way XEON MP. +
+
+Does anyone have comments or ideas on which I have to focus my work? +
+
+I guess, the shared buffer cause the meltdown when to many clients are +accessing the same data. +
+I didn't understand why the 4-way XEON MP 3.0 can deal with this better +as the 4-way Opteron 875. +
+The system load on the Opteron is never over 3.0. The XEON MP has a +load up to 4.0. +
+
+Should I try other settings for PostgreSQL in postgresql.conf? +
+Should I try other setting for the compilation? +
+
+I will compile the latest PostgreSQL 8.1 snapshot for 32bit to evaluate +the new shared buffer code from Tom. +
+I think, the 64bit is slow because my queries are CPU intensive. +
+
+Can someone provide a commercial support contact for this issue? +
+
+Sven. +
+

+
+ + + +--------------050707070801080103090606-- + +From pgsql-performance-owner@postgresql.org Fri Aug 5 09:27:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 20DE552BB7 + for ; + Fri, 5 Aug 2005 09:27:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96596-04 + for ; + Fri, 5 Aug 2005 12:27:18 +0000 (GMT) +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 58BFE52BC6 + for ; + Fri, 5 Aug 2005 09:27:17 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.53.154]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0IKR00GYS19KGZG0@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Fri, 05 Aug 2005 07:27:21 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 11A8C600498; Fri, + 05 Aug 2005 08:27:20 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 18342-02-6; Fri, 05 Aug 2005 08:27:19 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id D291C60048A; Fri, 05 Aug 2005 08:27:19 -0400 (EDT) +Date: Fri, 05 Aug 2005 08:27:19 -0400 +From: Michael Stone +Subject: Re: Performance problems on 4-way AMD Opteron 875 (dual core) +In-reply-to: <42F34963.5080403@aeccom.com> +To: Dirk =?iso-8859-1?Q?Lutzeb=E4ck?= +Cc: pgsql-performance@postgresql.org, + Sven Geisler +Mail-Followup-To: Dirk =?iso-8859-1?Q?Lutzeb=E4ck?= , + pgsql-performance@postgresql.org, Sven Geisler +Message-id: <20050805122719.GW19080@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=iso-8859-1; format=flowed +Content-transfer-encoding: 8BIT +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <42F34963.5080403@aeccom.com> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/47 +X-Sequence-Number: 13794 + +On Fri, Aug 05, 2005 at 01:11:31PM +0200, Dirk Lutzeb�ck wrote: +>I will compile the latest PostgreSQL 8.1 snapshot for 32bit to evaluate +>the new shared buffer code from Tom. +>I think, the 64bit is slow because my queries are CPU intensive. + +Have you actually tried it or are you guessing? If you're guessing, then +compile it as a 64 bit binary and benchmark that. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Fri Aug 5 09:56:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 84F4752836 + for ; + Fri, 5 Aug 2005 09:56:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01448-07 + for ; + Fri, 5 Aug 2005 12:56:20 +0000 (GMT) +Received: from mail2.aeccom.com (port-212-202-101-158.static.qsc.de + [212.202.101.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 98A1C5293F + for ; + Fri, 5 Aug 2005 09:56:19 -0300 (ADT) +Received: from [192.168.2.12] (port-83-236-156-26.static.qsc.de + [83.236.156.26]) by mail2.aeccom.com (Postfix) with ESMTP + id BC565108; Fri, 5 Aug 2005 14:56:23 +0200 (CEST) +Message-ID: <42F361F7.8070201@aeccom.com> +Date: Fri, 05 Aug 2005 14:56:23 +0200 +From: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Organization: AEC/communications GmbH +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Michael Stone +Cc: pgsql-performance@postgresql.org, + Sven Geisler +Subject: Re: Performance problems on 4-way AMD Opteron 875 (dual +References: <42F34963.5080403@aeccom.com> <20050805122719.GW19080@mathom.us> +In-Reply-To: <20050805122719.GW19080@mathom.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.077 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/48 +X-Sequence-Number: 13795 + + +Michael Stone wrote: + +> On Fri, Aug 05, 2005 at 01:11:31PM +0200, Dirk Lutzeb�ck wrote: +> +>> I will compile the latest PostgreSQL 8.1 snapshot for 32bit to +>> evaluate the new shared buffer code from Tom. +>> I think, the 64bit is slow because my queries are CPU intensive. +> +> +> Have you actually tried it or are you guessing? If you're guessing, then +> compile it as a 64 bit binary and benchmark that. +> +> Mike Stone + +We tried it. 64bit 8.1dev was slower than 32bit 8.0.3. + +Dirk + +From pgsql-performance-owner@postgresql.org Fri Aug 5 10:53:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 769BC529BA + for ; + Fri, 5 Aug 2005 10:53:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16749-07 + for ; + Fri, 5 Aug 2005 13:53:13 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DA67852909 + for ; + Fri, 5 Aug 2005 10:53:12 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j75DrEXI008259; + Fri, 5 Aug 2005 09:53:14 -0400 (EDT) +To: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= +Cc: pgsql-performance@postgresql.org, + Sven Geisler +Subject: Re: Performance problems on 4-way AMD Opteron 875 (dual core) +In-reply-to: <42F34963.5080403@aeccom.com> +References: <42F34963.5080403@aeccom.com> +Comments: In-reply-to =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= + message dated "Fri, 05 Aug 2005 13:11:31 +0200" +Date: Fri, 05 Aug 2005 09:53:14 -0400 +Message-ID: <8258.1123249994@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/49 +X-Sequence-Number: 13796 + +=?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= writes: +> Here are the number of queries which the server has finished in a fix +> period of time. + +Uh, you never actually supplied any numbers (or much of any other +specifics about what was tested, either). + +My first reaction is "don't vary more than one experimental parameter at +a time". There is no way to tell whether the discrepancy is due to the +different hardware, different Postgres version, or 32-bit vs 64-bit +build. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 5 15:35:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2630452848 + for ; + Fri, 5 Aug 2005 15:35:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18968-06 + for ; + Fri, 5 Aug 2005 18:35:03 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F6335286E + for ; + Fri, 5 Aug 2005 15:35:02 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i11so433141wra + for ; + Fri, 05 Aug 2005 11:35:03 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=R1QoxStqWrghhpk7TOc0/qoVi4LnLpOAqN2FwQ1OVbrYBD9b2o1CbmUi7zddcH3Y376XQY+yQOT3we4BGeYS52Qxbnth+2VK+Dk/UbhC903liHyF85MhyMDJ+edbUgTJzy7TZksuddd1m/g3Iucn4QoxDwhZKV3hZx8rQzlBoE8= +Received: by 10.54.34.54 with SMTP id h54mr2799504wrh; + Fri, 05 Aug 2005 11:35:03 -0700 (PDT) +Received: by 10.54.119.7 with HTTP; Fri, 5 Aug 2005 11:35:03 -0700 (PDT) +Message-ID: <41b0fe890508051135712a086b@mail.gmail.com> +Date: Fri, 5 Aug 2005 11:35:03 -0700 +From: Rhett Garber +Reply-To: Rhett Garber +To: pgsql-performance@postgresql.org +Subject: Why hash join instead of nested loop? +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/50 +X-Sequence-Number: 13797 + +I've got similiar queries that I think should be evaluated (as +displayed through 'explain') the same, but don't. +Hopefully this is the rigth place to send such a question and one of +you can help explain this to me. + +The Tables: + Connection - 1.2 million entries, about 60 megs, 3 integer fields +that link two tables together (i.e. an identifier and two foreign +keys). + has an index on the identifier and either of +the foreign keys. + rtmessagestate - very small, 5 entries + rtmessage - pretty big, 80,000 entries + + +The Queries: + =20 +select rtmessagestate.* from rtmessagestate, connection where +connection_registry_id =3D 40105 and obj1 =3D 73582 and obj2 =3D +rtmessagestate.id; + returns 1 in 13.7 ms + = +=20 +select rtmessage.id, subject from rtmessage, connection where +connection_registry_id =3D 40003 and obj1 =3D 4666 and obj2 =3D +rtmessage.id; + returns 12 in 2 ms + +Some more possibly important details: + entries in Connection with connection_registry_id =3D 40105: 30,000 + entries with this id and obj1 =3D 73582: 1 + entries in Connection with connection_registry_id =3D 40003: 6,000 + entries with this id and obj1 =3D 4666: 20 + =20 +but as I said before, there is an btree index on (connection_registry_id, o= +bj1) + +Explain: +The first query, breaks down as: +Hash Join (cost=3D5.96..7.04 rows=3D1 width=3D14) + Hash Cond: ("outer".id =3D "inner".obj2) + -> Seq Scan on rtmessagestate (cost=3D0.00..1.05 rows=3D5 width= +=3D14) + -> Hash (cost=3D5.96..5.96 rows=3D1 width=3D4) + -> Index Scan using connection_regid_obj1_index on +connection (cost=3D0.00..5.96 rows=3D1 width=3D4) + Index Cond: ((connection_registry_id =3D 40105) AND +(obj1 =3D 73582))(6 rows) + + +While the second query is: + Nested Loop (cost=3D0.00..11.62 rows=3D2 width=3D38) + -> Index Scan using connection_regid_obj1_index on connection=20 +(cost=3D0.00..5.96 rows=3D1 width=3D4) + Index Cond: ((connection_registry_id =3D 40003) AND (obj1 =3D = +4666)) + -> Index Scan using rtmessage_pkey on rtmessage=20 +(cost=3D0.00..5.65 rows=3D1 width=3D38) + Index Cond: ("outer".obj2 =3D rtmessage.id) + (5 rows) + +Actually running these queries shows that the second one (nested loop) +is much faster than the hash join, presumably because of hash startup +costs. Any ideas how I can make them both use the nested loop. I +assume that this would be the fastest for both. + +Oddly enough, running the 1st query (rtmessagestate) as two queries or +with a sub query is way faster than doing the join. + +And yes, I realize this schema may not be the most efficient for these +examples, but it seems to be the most flexible. I'm working on some +schema improvements also +but if I could understand why this is slow that woudl probably help also. + +Thanks for you help, + +Rhett + +From pgsql-performance-owner@postgresql.org Fri Aug 5 19:13:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 161D952836 + for ; + Fri, 5 Aug 2005 19:13:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63894-07 + for ; + Fri, 5 Aug 2005 22:13:51 +0000 (GMT) +Received: from viefep20-int.chello.at (viefep12-int.chello.at [213.46.255.25]) + by svr1.postgresql.org (Postfix) with ESMTP id C28035286E + for ; + Fri, 5 Aug 2005 19:13:49 -0300 (ADT) +Received: from OTTO ([213.222.172.216]) by viefep20-int.chello.at + (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with SMTP + id <20050805221350.KZHC25440.viefep20-int.chello.at@OTTO>; + Sat, 6 Aug 2005 00:13:50 +0200 +Message-ID: <001801c59a0a$f4be7480$9a00a8c0@OTTO> +From: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= +To: "Rhett Garber" , + +References: <41b0fe890508051135712a086b@mail.gmail.com> +Subject: Re: Why hash join instead of nested loop? +Date: Sat, 6 Aug 2005 00:13:49 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2527 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200508/51 +X-Sequence-Number: 13798 + +Rhett, + +Please post the explain analyze for both queries. From that we can see the +predicted and the actual costs of them. + +Regards, +Otto + + +----- Original Message ----- +From: "Rhett Garber" +To: +Sent: Friday, August 05, 2005 8:35 PM +Subject: [PERFORM] Why hash join instead of nested loop? + + +I've got similiar queries that I think should be evaluated (as +displayed through 'explain') the same, but don't. +Hopefully this is the rigth place to send such a question and one of +you can help explain this to me. + +The Tables: + Connection - 1.2 million entries, about 60 megs, 3 integer fields +that link two tables together (i.e. an identifier and two foreign +keys). + has an index on the identifier and either of +the foreign keys. + rtmessagestate - very small, 5 entries + rtmessage - pretty big, 80,000 entries + + +The Queries: + +select rtmessagestate.* from rtmessagestate, connection where +connection_registry_id = 40105 and obj1 = 73582 and obj2 = +rtmessagestate.id; + returns 1 in 13.7 ms + +select rtmessage.id, subject from rtmessage, connection where +connection_registry_id = 40003 and obj1 = 4666 and obj2 = +rtmessage.id; + returns 12 in 2 ms + +Some more possibly important details: + entries in Connection with connection_registry_id = 40105: 30,000 + entries with this id and obj1 = 73582: 1 + entries in Connection with connection_registry_id = 40003: 6,000 + entries with this id and obj1 = 4666: 20 + +but as I said before, there is an btree index on (connection_registry_id, +obj1) + +Explain: +The first query, breaks down as: +Hash Join (cost=5.96..7.04 rows=1 width=14) + Hash Cond: ("outer".id = "inner".obj2) + -> Seq Scan on rtmessagestate (cost=0.00..1.05 rows=5 width=14) + -> Hash (cost=5.96..5.96 rows=1 width=4) + -> Index Scan using connection_regid_obj1_index on +connection (cost=0.00..5.96 rows=1 width=4) + Index Cond: ((connection_registry_id = 40105) AND +(obj1 = 73582))(6 rows) + + +While the second query is: + Nested Loop (cost=0.00..11.62 rows=2 width=38) + -> Index Scan using connection_regid_obj1_index on connection +(cost=0.00..5.96 rows=1 width=4) + Index Cond: ((connection_registry_id = 40003) AND (obj1 = +4666)) + -> Index Scan using rtmessage_pkey on rtmessage +(cost=0.00..5.65 rows=1 width=38) + Index Cond: ("outer".obj2 = rtmessage.id) + (5 rows) + +Actually running these queries shows that the second one (nested loop) +is much faster than the hash join, presumably because of hash startup +costs. Any ideas how I can make them both use the nested loop. I +assume that this would be the fastest for both. + +Oddly enough, running the 1st query (rtmessagestate) as two queries or +with a sub query is way faster than doing the join. + +And yes, I realize this schema may not be the most efficient for these +examples, but it seems to be the most flexible. I'm working on some +schema improvements also +but if I could understand why this is slow that woudl probably help also. + +Thanks for you help, + +Rhett + +---------------------------(end of broadcast)--------------------------- +TIP 3: Have you checked our extensive FAQ? + + http://www.postgresql.org/docs/faq + + + + +From pgsql-performance-owner@postgresql.org Fri Aug 5 20:17:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 296D65286E + for ; + Fri, 5 Aug 2005 20:17:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77157-07 + for ; + Fri, 5 Aug 2005 23:16:51 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) + by svr1.postgresql.org (Postfix) with ESMTP id 78B9952A07 + for ; + Fri, 5 Aug 2005 20:16:50 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i8so670635wra + for ; + Fri, 05 Aug 2005 16:16:51 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=gaNGSJjfzitffKDFJqemxGJ7iBw1JZLXyiTg9M6rf7HYm+xa2Vm/Su+eQq2Uv0Psa4ceFUYNii91D94Ut4hdniuvuBX1eCYja/mZEVnh1JCyftRmp1aSto7kOYi8Hib7R7npjJz5NvQdJvzvuUG2W0QHEIXzsWh0Oct6S2AkxyQ= +Received: by 10.54.27.46 with SMTP id a46mr3029134wra; + Fri, 05 Aug 2005 16:16:51 -0700 (PDT) +Received: by 10.54.119.7 with HTTP; Fri, 5 Aug 2005 16:16:51 -0700 (PDT) +Message-ID: <41b0fe8905080516164464e04f@mail.gmail.com> +Date: Fri, 5 Aug 2005 16:16:51 -0700 +From: Rhett Garber +Reply-To: Rhett Garber +To: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= +Subject: Re: Why hash join instead of nested loop? +Cc: pgsql-performance@postgresql.org +In-Reply-To: <001801c59a0a$f4be7480$9a00a8c0@OTTO> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/52 +X-Sequence-Number: 13799 + +On 8/5/05, Havasv=F6lgyi Ott=F3 wrote: + +> Please post the explain analyze for both queries. From that we can see th= +e +> predicted and the actual costs of them. + + +> select rtmessagestate.* from rtmessagestate, connection where +> connection_registry_id =3D 40105 and obj1 =3D 73582 and obj2 =3D +> rtmessagestate.id; + +Hash Join (cost=3D5.96..7.04 rows=3D1 width=3D14) (actual +time=3D10.591..10.609 rows=3D1 loops=3D1) + Hash Cond: ("outer".id =3D "inner".obj2) + -> Seq Scan on rtmessagestate (cost=3D0.00..1.05 rows=3D5 width=3D14) +(actual time=3D0.011..0.022 rows=3D5 loops=3D1) + -> Hash (cost=3D5.96..5.96 rows=3D1 width=3D4) (actual +time=3D0.109..0.109 rows=3D0 loops=3D1) + -> Index Scan using connection_regid_obj1_index on +connection (cost=3D0.00..5.96 rows=3D1 width=3D4) (actual time=3D0.070..0.= +076 +rows=3D1 loops=3D1) + Index Cond: ((connection_registry_id =3D 40105) AND (obj1 +=3D 73582)) Total runtime: 11.536 ms +(7 rows) + +> select rtmessage.id, subject from rtmessage, connection where +> connection_registry_id =3D 40003 and obj1 =3D 4666 and obj2 =3D +> rtmessage.id; + +Nested Loop (cost=3D0.00..11.62 rows=3D2 width=3D38) (actual +time=3D0.186..0.970 rows=3D12 loops=3D1) + -> Index Scan using connection_regid_obj1_index on connection=20 +(cost=3D0.00..5.96 rows=3D1 width=3D4) (actual time=3D0.109..0.308 rows=3D1= +2 +loops=3D1) + Index Cond: ((connection_registry_id =3D 40003) AND (obj1 =3D 4666= +)) + -> Index Scan using rtmessage_pkey on rtmessage (cost=3D0.00..5.65 +rows=3D1 width=3D38) (actual time=3D0.032..0.039 rows=3D1 loops=3D12) + Index Cond: ("outer".obj2 =3D rtmessage.id) + Total runtime: 1.183 ms +(6 rows) + +Rhett + +From pgsql-performance-owner@postgresql.org Sat Aug 6 02:04:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AB1CE528B8 + for ; + Sat, 6 Aug 2005 02:04:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57096-05 + for ; + Sat, 6 Aug 2005 05:04:10 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 18A1E52A38 + for ; + Sat, 6 Aug 2005 02:04:09 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7653pPB015426; + Sat, 6 Aug 2005 01:03:51 -0400 (EDT) +To: Rhett Garber +Cc: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +Subject: Re: Why hash join instead of nested loop? +In-reply-to: <41b0fe8905080516164464e04f@mail.gmail.com> +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> +Comments: In-reply-to Rhett Garber + message dated "Fri, 05 Aug 2005 16:16:51 -0700" +Date: Sat, 06 Aug 2005 01:03:51 -0400 +Message-ID: <15425.1123304631@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/53 +X-Sequence-Number: 13800 + +Rhett Garber writes: +> Hash Join (cost=5.96..7.04 rows=1 width=14) (actual +> time=10.591..10.609 rows=1 loops=1) +> Hash Cond: ("outer".id = "inner".obj2) +> -> Seq Scan on rtmessagestate (cost=0.00..1.05 rows=5 width=14) +> (actual time=0.011..0.022 rows=5 loops=1) +> -> Hash (cost=5.96..5.96 rows=1 width=4) (actual +> time=0.109..0.109 rows=0 loops=1) +> -> Index Scan using connection_regid_obj1_index on +> connection (cost=0.00..5.96 rows=1 width=4) (actual time=0.070..0.076 +> rows=1 loops=1) +> Index Cond: ((connection_registry_id = 40105) AND (obj1 +> = 73582)) Total runtime: 11.536 ms +> (7 rows) + +[ scratches head... ] If the hash table build takes only 0.109 msec +and loads only one row into the hash table, and the scan of +rtmessagestate takes only 0.022 msec and produces only 5 rows, it is +real hard to see how the join takes 10.609 msec overall. Unless the id +and obj2 columns are of a datatype with an incredibly slow equality +function. What is the datatype involved here, anyway? And what PG +version are we speaking of? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Aug 6 10:16:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F0E9B52A81 + for ; + Sat, 6 Aug 2005 10:16:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59717-09 + for ; + Sat, 6 Aug 2005 13:16:03 +0000 (GMT) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C64F52A73 + for ; + Sat, 6 Aug 2005 10:16:02 -0300 (ADT) +Received: from [127.0.0.1] (c-24-4-66-2.hsd1.ca.comcast.net[24.4.66.2]) + by comcast.net (sccrmhc13) with ESMTP + id <2005080613160501300dkqnbe>; Sat, 6 Aug 2005 13:16:05 +0000 +Message-ID: <42F4B812.7070501@comcast.net> +Date: Sat, 06 Aug 2005 06:16:02 -0700 +From: Patrick Hatcher +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: Slow update statement +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.22 tagged_above=0 required=5 + tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, TO_ADDRESS_EQ_REAL +X-Spam-Level: ** +X-Archive-Number: 200508/54 +X-Sequence-Number: 13801 + +[Reposted from General section with updated information] +Pg 7.4.5 + +I'm running an update statement on about 12 million records using the +following query: + +Update table_A +set F1 = b.new_data +from table_B b +where b.keyfield = table_A.keyfield + +both keyfields are indexed, all other keys in table_A were dropped, yet this job has been running over 15 hours. Is +this normal? + +I stopped the process the first time after 3 hours of running due to excessive log rotation and reset the conf file to these settings: + + +wal_buffers = 64 # min 4, 8KB each + +# - Checkpoints - + +checkpoint_segments = 128 # in logfile segments, min 1, 16MB each +checkpoint_timeout = 1800 # 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 + + +Would it just be quicker to run a JOIN statement to a temp file and then reinsert? + +TIA +Patrick + + +From pgsql-performance-owner@postgresql.org Sat Aug 6 10:34:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 354A152A73 + for ; + Sat, 6 Aug 2005 10:34:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71348-03 + for ; + Sat, 6 Aug 2005 13:34:34 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 8369C52A71 + for ; + Sat, 6 Aug 2005 10:34:33 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050806133436m9100g6kqae>; Sat, 6 Aug 2005 13:34:36 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id D437656053; Sat, 6 Aug 2005 08:34:35 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id BEC3956016; + Sat, 6 Aug 2005 08:34:31 -0500 (CDT) +Message-ID: <42F4BC61.20102@arbash-meinel.com> +Date: Sat, 06 Aug 2005 08:34:25 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Patrick Hatcher +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Slow update statement +References: <42F4B812.7070501@comcast.net> +In-Reply-To: <42F4B812.7070501@comcast.net> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigB102F44065A4841D42023663" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/55 +X-Sequence-Number: 13802 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigB102F44065A4841D42023663 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Patrick Hatcher wrote: +> [Reposted from General section with updated information] +> Pg 7.4.5 +> +> I'm running an update statement on about 12 million records using the +> following query: +> +> Update table_A +> set F1 = b.new_data +> from table_B b +> where b.keyfield = table_A.keyfield +> +> both keyfields are indexed, all other keys in table_A were dropped, yet +> this job has been running over 15 hours. Is +> this normal? + +Can you do an EXPLAIN UPDATE so that we can have an idea what the +planner is trying to do? + +My personal concern is if it doing something like pulling in all rows +from b, and then one by one updating table_A, but as it is going, it +can't retire any dead rows, because you are still in a transaction. So +you are getting a lot of old rows, which it has to pull in to realize it +was old. + +How many rows are in table_B? + +I can see that possibly doing it in smaller chunks might be faster, as +would inserting into another table. But I would do more of a test and +see what happens. + +John +=:-> + +> +> I stopped the process the first time after 3 hours of running due to +> excessive log rotation and reset the conf file to these settings: +> +> +> wal_buffers = 64 # min 4, 8KB each +> +> # - Checkpoints - +> +> checkpoint_segments = 128 # in logfile segments, min 1, 16MB each +> checkpoint_timeout = 1800 # 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 +> +> +> Would it just be quicker to run a JOIN statement to a temp file and then +> reinsert? +> TIA Patrick +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + + +--------------enigB102F44065A4841D42023663 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC9LxlJdeBCYSNAAMRAtL9AJ98wz0ruVi1wics+ko476ylNgbT3QCffWN8 +arXwBSyM/BCE48I0BmunjUA= +=KQQn +-----END PGP SIGNATURE----- + +--------------enigB102F44065A4841D42023663-- + +From pgsql-performance-owner@postgresql.org Sat Aug 6 11:12:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E1B075292D + for ; + Sat, 6 Aug 2005 11:12:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78521-02 + for ; + Sat, 6 Aug 2005 14:12:39 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 26C4C52AB1 + for ; + Sat, 6 Aug 2005 11:12:38 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j76EChYV017917; + Sat, 6 Aug 2005 10:12:43 -0400 (EDT) +To: Patrick Hatcher +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Slow update statement +In-reply-to: <42F4B812.7070501@comcast.net> +References: <42F4B812.7070501@comcast.net> +Comments: In-reply-to Patrick Hatcher + message dated "Sat, 06 Aug 2005 06:16:02 -0700" +Date: Sat, 06 Aug 2005 10:12:43 -0400 +Message-ID: <17916.1123337563@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/56 +X-Sequence-Number: 13803 + +Patrick Hatcher writes: +> I'm running an update statement on about 12 million records using the +> following query: + +> Update table_A +> set F1 = b.new_data +> from table_B b +> where b.keyfield = table_A.keyfield + +What does EXPLAIN show for this? + +Do you have any foreign key references to table_A from elsewhere? + + regards, tom lane + +From pgsql-patches-owner@postgresql.org Sat Aug 6 18:05:05 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B585052B73 + for ; + Sat, 6 Aug 2005 18:05:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81449-03 + for ; + Sat, 6 Aug 2005 21:04:53 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4679D52B71 + for ; + Sat, 6 Aug 2005 18:04:52 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j76L4qVg026468; + Sat, 6 Aug 2005 17:04:53 -0400 (EDT) +To: "Alon Goldshuv" +Cc: pgsql-patches@postgresql.org +Subject: Re: COPY FROM performance improvements +In-reply-to: +References: +Comments: In-reply-to "Alon Goldshuv" + message dated "Tue, 02 Aug 2005 10:59:43 -0400" +Date: Sat, 06 Aug 2005 17:04:52 -0400 +Message-ID: <26467.1123362292@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/46 +X-Sequence-Number: 16993 + +"Alon Goldshuv" writes: +> New patch attached. It includes very minor changes. These are changes that +> were committed to CVS 3 weeks ago (copy.c 1.247) which I missed in the +> previous patch. + +I've applied this with (rather extensive) revisions. I didn't like what +you had done with the control structure --- loading the input buffer +only at the outermost loop level was a bad design choice IMHO. You had +sprinkled the code with an unreasonable number of special cases in order +to try to cope with the effects of that mistake, but there were lots +of problems still left. Some of the bugs I noticed: + +* Broke old-protocol COPY, since that has no provision for stopping at +the EOF marker except by parsing the data carefully to start with. The +backend would just hang up unless the total data size chanced to be a +multiple of 64K. + +* Subtle change in interpretation of \. EOF marker (the existing code +will recognize it even when not at start of line). + +* Seems to have thrown away detection of newline format discrepancies. + +* Fails for zero-column tables. + +* Broke display of column values during error context callback (would +always show the first column contents no matter which one is being +complained of). + +* DetectLineEnd mistakenly assumes CR mode if very last character of first +bufferload is CR; need to reserve judgment until next char is available. + +* DetectLineEnd fails to account for backslashed control characters, +so it will e.g. accept \ followed by \n as determining the newline +style. + +* Fails to apply encoding conversion if first line exceeds copy buf +size, because when DetectLineEnd fails the quick-exit path doesn't do +it. + +* There seem to be several bugs associated with the fact that input_buf[] +always has 64K of data in it even when EOF has been reached on the +input. One example: + echo -n 123 >zzz1 + psql> create temp table t1(f1 text); + psql> copy t1 from '/home/tgl/zzz1'; + psql> select * from t1; +hmm ... where'd that 64K of whitespace come from? + +I rewrote the patch in a way that retained most of the speedups without +changing the basic control structure (except for replacing multiple +CopyReadAttribute calls with one CopyReadAttributes call per line). + +I had some difficulty in generating test cases that weren't largely +I/O-bound, but AFAICT the patch as applied is about the same speed +as what you submitted. + + regards, tom lane + +From pgsql-patches-owner@postgresql.org Sat Aug 6 23:33:20 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 465D652B48 + for ; + Sat, 6 Aug 2005 23:33:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50369-10 + for ; + Sun, 7 Aug 2005 02:33:14 +0000 (GMT) +Received: from mail.Mi8.com (nycgw05.mi8.com [63.240.6.46]) + by svr1.postgresql.org (Postfix) with ESMTP id AA98252B2E + for ; + Sat, 6 Aug 2005 23:33:12 -0300 (ADT) +Received: from 172.16.1.118 by mail.Mi8.com with ESMTP (- GW05 Welcome + to Mi8 Corporation www.Mi8.com); Sat, 06 Aug 2005 22:33:08 -0400 +X-Server-Uuid: E0C866E6-C6CD-48B5-AE61-E57E73CF3CC7 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + d01smtp03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Sat, 6 Aug + 2005 22:33:08 -0400 +Received: from 24.5.173.15 ([24.5.173.15]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Sat, 6 Aug + 2005 22:33:07 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Sat, 06 Aug 2005 19:33:07 -0700 +Subject: Re: COPY FROM performance improvements +From: "Luke Lonergan" +To: "Tom Lane" , "Alon Goldshuv" +Cc: pgsql-patches@postgresql.org +Message-ID: +In-Reply-To: <26467.1123362292@sss.pgh.pa.us> +MIME-Version: 1.0 +X-OriginalArrivalTime: 07 Aug 2005 02:33:08.0216 (UTC) + FILETIME=[58CA7F80:01C59AF8] +X-WSS-ID: 6EEBAD6E26S3784053-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.594 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200508/47 +X-Sequence-Number: 16994 + +Tom, + +Thanks for finding the bugs and reworking things. + +> I had some difficulty in generating test cases that weren't largely +> I/O-bound, but AFAICT the patch as applied is about the same speed +> as what you submitted. + +You achieve the important objective of knocking the parsing stage down a +lot, but your parsing code is actually about 20% slower than Alon's. + +Before your patch: + Time: 14205.606 ms + +With your patch: + Time: 10565.374 ms + +With Alon's patch: + Time: 10289.845 ms + +The parsing part of the code in your version is slower, but as a percentage +of the total it's hidden. The loss of 0.3 seconds on 143MB means: + +- If parsing takes a total of 0.9 seconds, the parsing rate is 160MB/s +(143/0.9) + +- If we add another 0.3 seconds to parsing to bring it to 1.2, then the +parsing rate becomes 120MB/s + +When we improve the next stages of the processing (attribute conversion, +write-to disk), this will stand out a lot more. Our objective is to get the +COPY rate *much* faster than the current poky rate of 14MB/s (after this +patch). + +- Luke + +On 8/6/05 2:04 PM, "Tom Lane" wrote: + +> "Alon Goldshuv" writes: +>> New patch attached. It includes very minor changes. These are changes that +>> were committed to CVS 3 weeks ago (copy.c 1.247) which I missed in the +>> previous patch. +> +> I've applied this with (rather extensive) revisions. I didn't like what +> you had done with the control structure --- loading the input buffer +> only at the outermost loop level was a bad design choice IMHO. You had +> sprinkled the code with an unreasonable number of special cases in order +> to try to cope with the effects of that mistake, but there were lots +> of problems still left. Some of the bugs I noticed: +> +> * Broke old-protocol COPY, since that has no provision for stopping at +> the EOF marker except by parsing the data carefully to start with. The +> backend would just hang up unless the total data size chanced to be a +> multiple of 64K. +> +> * Subtle change in interpretation of \. EOF marker (the existing code +> will recognize it even when not at start of line). +> +> * Seems to have thrown away detection of newline format discrepancies. +> +> * Fails for zero-column tables. +> +> * Broke display of column values during error context callback (would +> always show the first column contents no matter which one is being +> complained of). +> +> * DetectLineEnd mistakenly assumes CR mode if very last character of first +> bufferload is CR; need to reserve judgment until next char is available. +> +> * DetectLineEnd fails to account for backslashed control characters, +> so it will e.g. accept \ followed by \n as determining the newline +> style. +> +> * Fails to apply encoding conversion if first line exceeds copy buf +> size, because when DetectLineEnd fails the quick-exit path doesn't do +> it. +> +> * There seem to be several bugs associated with the fact that input_buf[] +> always has 64K of data in it even when EOF has been reached on the +> input. One example: +> echo -n 123 >zzz1 +> psql> create temp table t1(f1 text); +> psql> copy t1 from '/home/tgl/zzz1'; +> psql> select * from t1; +> hmm ... where'd that 64K of whitespace come from? +> +> I rewrote the patch in a way that retained most of the speedups without +> changing the basic control structure (except for replacing multiple +> CopyReadAttribute calls with one CopyReadAttributes call per line). +> +> I had some difficulty in generating test cases that weren't largely +> I/O-bound, but AFAICT the patch as applied is about the same speed +> as what you submitted. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + + + +From pgsql-patches-owner@postgresql.org Sat Aug 6 23:54:26 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2717C52BBC + for ; + Sat, 6 Aug 2005 23:54:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49581-06 + for ; + Sun, 7 Aug 2005 02:54:10 +0000 (GMT) +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by svr1.postgresql.org (Postfix) with ESMTP id A144E52BC1 + for ; + Sat, 6 Aug 2005 23:54:08 -0300 (ADT) +Received: from 172.16.1.110 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Sat, 06 Aug 2005 22:54:05 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Sat, 6 Aug 2005 + 22:54:05 -0400 +Received: from 24.5.173.15 ([24.5.173.15]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Sat, 6 Aug + 2005 22:54:04 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Sat, 06 Aug 2005 19:54:04 -0700 +Subject: Re: COPY FROM performance improvements +From: "Luke Lonergan" +To: "Tom Lane" , "Alon Goldshuv" +Cc: pgsql-patches@postgresql.org +Message-ID: +In-Reply-To: <26467.1123362292@sss.pgh.pa.us> +MIME-Version: 1.0 +X-OriginalArrivalTime: 07 Aug 2005 02:54:05.0519 (UTC) + FILETIME=[4633B5F0:01C59AFB] +X-WSS-ID: 6EEBA8472X4762688-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.593 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200508/48 +X-Sequence-Number: 16995 + +Tom, + +The previous timings were for a table with 15 columns of mixed type. We +also test with 1 column to make the parsing overhead more apparent. In the +case of 1 text column with 145MB of input data: + +Your patch: + Time: 6612.599 ms + +Alon's patch: + Time: 6119.244 ms + + +Alon's patch is 7.5% faster here, where it was only 3% faster on the 15 +column case. This is consistent with a large difference in parsing speed +between your approach and Alon's. + +I'm pretty sure that the "mistake" you refer to is responsible for the speed +improvement, and was deliberately chosen to minimize memory copies, etc. +Given that we're looking ahead to getting much higher speeds, approaching +current high performance disk speeds, we've been looking more closely at the +parsing speed. It comes down to a tradeoff between elegant code and speed. + +We'll prove it in lab tests soon, where we measure the parsing rate +directly, but these experiments show it clearly, though indirectly. + +- Luke + + + +On 8/6/05 2:04 PM, "Tom Lane" wrote: + +> "Alon Goldshuv" writes: +>> New patch attached. It includes very minor changes. These are changes that +>> were committed to CVS 3 weeks ago (copy.c 1.247) which I missed in the +>> previous patch. +> +> I've applied this with (rather extensive) revisions. I didn't like what +> you had done with the control structure --- loading the input buffer +> only at the outermost loop level was a bad design choice IMHO. You had +> sprinkled the code with an unreasonable number of special cases in order +> to try to cope with the effects of that mistake, but there were lots +> of problems still left. Some of the bugs I noticed: +> +> * Broke old-protocol COPY, since that has no provision for stopping at +> the EOF marker except by parsing the data carefully to start with. The +> backend would just hang up unless the total data size chanced to be a +> multiple of 64K. +> +> * Subtle change in interpretation of \. EOF marker (the existing code +> will recognize it even when not at start of line). +> +> * Seems to have thrown away detection of newline format discrepancies. +> +> * Fails for zero-column tables. +> +> * Broke display of column values during error context callback (would +> always show the first column contents no matter which one is being +> complained of). +> +> * DetectLineEnd mistakenly assumes CR mode if very last character of first +> bufferload is CR; need to reserve judgment until next char is available. +> +> * DetectLineEnd fails to account for backslashed control characters, +> so it will e.g. accept \ followed by \n as determining the newline +> style. +> +> * Fails to apply encoding conversion if first line exceeds copy buf +> size, because when DetectLineEnd fails the quick-exit path doesn't do +> it. +> +> * There seem to be several bugs associated with the fact that input_buf[] +> always has 64K of data in it even when EOF has been reached on the +> input. One example: +> echo -n 123 >zzz1 +> psql> create temp table t1(f1 text); +> psql> copy t1 from '/home/tgl/zzz1'; +> psql> select * from t1; +> hmm ... where'd that 64K of whitespace come from? +> +> I rewrote the patch in a way that retained most of the speedups without +> changing the basic control structure (except for replacing multiple +> CopyReadAttribute calls with one CopyReadAttributes call per line). +> +> I had some difficulty in generating test cases that weren't largely +> I/O-bound, but AFAICT the patch as applied is about the same speed +> as what you submitted. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + + + +From pgsql-patches-owner@postgresql.org Sun Aug 7 00:25:48 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A0F2D5282E + for ; + Sun, 7 Aug 2005 00:25:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79905-03 + for ; + Sun, 7 Aug 2005 03:25:31 +0000 (GMT) +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 5676652AE0 + for ; + Sun, 7 Aug 2005 00:25:29 -0300 (ADT) +Received: from 172.16.1.110 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Sat, 06 Aug 2005 23:25:24 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Sat, 6 Aug 2005 + 23:25:24 -0400 +Received: from 24.5.173.15 ([24.5.173.15]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Sat, 6 Aug + 2005 23:25:24 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Sat, 06 Aug 2005 20:25:24 -0700 +Subject: Re: COPY FROM performance improvements +From: "Luke Lonergan" +To: "PostgreSQL-patches" +Message-ID: +In-Reply-To: <26467.1123362292@sss.pgh.pa.us> +MIME-Version: 1.0 +X-OriginalArrivalTime: 07 Aug 2005 03:25:24.0531 (UTC) + FILETIME=[A62E3030:01C59AFF] +X-WSS-ID: 6EEBA0AE2B414362915-01-01 +Content-Type: multipart/mixed; + boundary=B_3206204724_2604846 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.592 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200508/49 +X-Sequence-Number: 16996 + +> This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--B_3206204724_2604846 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit + +Tom, + +My direct e-mails to you are apparently blocked, so I'll send this to the +list. + +I've attached the case we use for load performance testing, with the data +generator modified to produce a single row version of the dataset. + +I do believe that you/we will need to invert the processing loop to get the +maximum parsing speed. We will be implementing much higher loading speeds +which require it to compete with Oracle, Netezza, Teradata, so we'll have to +work this out for the best interests of our users. + +- Luke + + +--B_3206204724_2604846 +Content-Type: application/octet-stream; + name=IVP.tgz +Content-Disposition: attachment; + filename=IVP.tgz +Content-Transfer-Encoding: base64 + +H4sIAJx59UIAA+w8aXfbxrX5KvyKG8aOSJkiCXCRTUVtFUlx2Go7kuLk1dZRQWBIjgViGAwg +imn939+9s4AgRcr2q+O+nhjHpoCZu83dZgV6r87rX/3OV6PRauy02/i30djptBb+musrt+Ht +tL2dVtNDONfzOs2voP17C0ZXJlM/AfgqikTMkqEfr4F7X/1/6dVD+wcJ81N2E/ZrcvR78Gi4 +jcfs32p5O2R/b6fTpkeEb7U9tH/j9xBm+fqD2/+br+t9Htf7vhw5DgtGYv4DVyMuAf/5MfRi +VFMU+SkXMbzyIx7q2/NEDBN/DAORwCFjk5cJY3FNo/dSmPIoAq5xwQfpjycRmwPCoZ/6yJoB +kkL1wtgPRjxmtYIQ+4OUJZCSKDJI+CSFJIvxPgsCJuUgi6JZFWYiAzkSWRTCyL9jyAqBYh4P +V/GK/TELNfFSOEyZTMN+qYos/FQRCrC9gYhjFqSQCsgk0UlHDAvHYz8OuwYXYCJ/jSAnURD6 +fwwZP5ICIuGHtumoNh8VkhZZP8ahVifsbULD4CyyKPUGC1oZ+DySJC+7Z0GWsiryFbfISxEe +cGT+poTRXovE8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w +ufWhLex+7DFsfv2hLTQ/tIWnH9rCdJemakC05mpsVpC6pMJ8NJVUmE/qYoUKUpe0MJ/UjzCG +ClKXtDCf1CUtzCd1SQsVpIbWy9VoVZC6pMJ8NJVUmE/qYoUKUpe0MJ/UjzCGClKXtDCf1CUt +zCd1SQsVpIZBkquxVUHqkgrz0VRSYT6pixUqSF3SwnxSP8IYKkhd0sJ8Upe0MJ/UJS1UzuqH +fI3tylldqFA1IwoVqmb1dIXKWV1ooWpW/+4xVM7qQgtVs7rQQtWsLrRQQWqY8bkaO1VmWbFC +hUlTrFBhlhUqVJllxRYqzLLfP4Yqs6zYQoVZVmyhwiwrtlBJ6n6+xm4lqQsVqtBUqFBF6ukK +laQutFBF6t89hkpSF1qoInWhhSpSF1qo0tXk/OZqfF2lq4sVKvRcsUKFri5UqNLVxRYqdPXv +H0OVri62UKGriy1U6OpiCxWkRlwiV+NpBalLKsxHU0mF+aQuVqggdUkL80n9CGOoIHVJC/NJ +XdLCfFKXtFBBaoSM3BrNjQpSl1SYj6aSCvNJXaxQQeqSFuaT+hHGUEHqkhbmk7qkhfmkLmmh +gtSI5uVqVEXLSirMR1NJhfmkLlaoIHVJC/NJ/QhjqCB1SQvzSV3SwnxSl7RQQWoEWnM1qqJl +JRXmo6mkwnxSFytUkLqkhfmkfoQxVJC6pIX5pC5pYT6pS1qY7tIfvQa3eBbP4lk8i2fxLJ7F +s3gWz+JZPItn8SyexbN4Fs/iWTyLZ/E89vN/0A4qNADwAAA= + +--B_3206204724_2604846-- + + +From pgsql-patches-owner@postgresql.org Sun Aug 7 01:08:28 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A34952A70 + for ; + Sun, 7 Aug 2005 01:08:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86158-06 + for ; + Sun, 7 Aug 2005 04:08:19 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 572FA52883 + for ; + Sun, 7 Aug 2005 01:08:18 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7748G4M029008; + Sun, 7 Aug 2005 00:08:16 -0400 (EDT) +To: "Luke Lonergan" +Cc: "Alon Goldshuv" , + pgsql-patches@postgresql.org +Subject: Re: COPY FROM performance improvements +In-reply-to: +References: +Comments: In-reply-to "Luke Lonergan" + message dated "Sat, 06 Aug 2005 19:33:07 -0700" +Date: Sun, 07 Aug 2005 00:08:16 -0400 +Message-ID: <29007.1123387696@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/50 +X-Sequence-Number: 16997 + +"Luke Lonergan" writes: +>> I had some difficulty in generating test cases that weren't largely +>> I/O-bound, but AFAICT the patch as applied is about the same speed +>> as what you submitted. + +> You achieve the important objective of knocking the parsing stage down a +> lot, but your parsing code is actually about 20% slower than Alon's. + +I would like to see the exact test case you are using to make this +claim; the tests I did suggested my code is the same speed or faster. +The particular test case I was using was the "tenk1" data from the +regression database, duplicated out to about 600K rows so as to run +long enough to measure with some degree of repeatability. + +As best I can tell, my version of CopyReadAttributes is significantly +quicker than Alon's, approximately balancing out the fact that my +version of CopyReadLine is slower. I did the latter first, and would +now be tempted to rewrite it in the same style as CopyReadAttributes, +ie one pass of memory-to-memory copy using pointers rather than buffer +indexes. + +BTW, late today I figured out a way to get fairly reproducible +non-I/O-bound numbers about COPY FROM: use a trigger that suppresses +the actual inserts, thus: + +create table foo ... +create function noway() returns trigger as +'begin return null; end' language plpgsql; +create trigger noway before insert on foo + for each row execute procedure noway(); +then repeat: +copy foo from '/tmp/foo.data'; + +If the source file is not too large to fit in kernel disk cache, then +after the first iteration there is no I/O at all. I got numbers +that were reproducible within less than 1%, as opposed to 5% or more +variation when the thing was partially I/O bound. Pretty useless in the +real world, of course, but great for timing COPY's data-pushing. + + regards, tom lane + +From pgsql-patches-owner@postgresql.org Sun Aug 7 02:22:23 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DEB652800 + for ; + Sun, 7 Aug 2005 02:22:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78644-03 + for ; + Sun, 7 Aug 2005 05:22:12 +0000 (GMT) +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 47B0A52903 + for ; + Sun, 7 Aug 2005 02:22:11 -0300 (ADT) +Received: from 172.16.1.112 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Sun, 07 Aug 2005 01:21:59 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Sun, 7 Aug 2005 + 01:21:05 -0400 +Received: from 24.5.173.15 ([24.5.173.15]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Sun, 7 Aug + 2005 01:21:04 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Sat, 06 Aug 2005 22:21:03 -0700 +Subject: Re: COPY FROM performance improvements +From: "Luke Lonergan" +To: "Tom Lane" +Cc: "Alon Goldshuv" , + pgsql-patches@postgresql.org +Message-ID: +In-Reply-To: <29007.1123387696@sss.pgh.pa.us> +MIME-Version: 1.0 +X-OriginalArrivalTime: 07 Aug 2005 05:21:05.0321 (UTC) + FILETIME=[CF36B190:01C59B0F] +X-WSS-ID: 6EEB45CB2B414402914-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.592 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200508/51 +X-Sequence-Number: 16998 + +Tom, + +On 8/6/05 9:08 PM, "Tom Lane" wrote: + +> "Luke Lonergan" writes: +>>> I had some difficulty in generating test cases that weren't largely +>>> I/O-bound, but AFAICT the patch as applied is about the same speed +>>> as what you submitted. +> +>> You achieve the important objective of knocking the parsing stage down a +>> lot, but your parsing code is actually about 20% slower than Alon's. +> +> I would like to see the exact test case you are using to make this +> claim; the tests I did suggested my code is the same speed or faster. + +I showed mine - you show yours :-) Apparently our e-mail crossed. + +> As best I can tell, my version of CopyReadAttributes is significantly +> quicker than Alon's, approximately balancing out the fact that my +> version of CopyReadLine is slower. I did the latter first, and would +> now be tempted to rewrite it in the same style as CopyReadAttributes, +> ie one pass of memory-to-memory copy using pointers rather than buffer +> indexes. + +See previous timings - looks like Alon's parsing is substantially faster. +However, I'd like him to confirm by running with the "shunt" placed at +different stages, in this case between parse and attribute conversion (not +attribute parse). + +> BTW, late today I figured out a way to get fairly reproducible +> non-I/O-bound numbers about COPY FROM: use a trigger that suppresses +> the actual inserts, thus: +> +> create table foo ... +> create function noway() returns trigger as +> 'begin return null; end' language plpgsql; +> create trigger noway before insert on foo +> for each row execute procedure noway(); +> then repeat: +> copy foo from '/tmp/foo.data'; + +Cool! That's a better way than hacking code and inserting shunts. + +Alon will likely hit this tomorrow. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Sun Aug 7 23:01:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7330A52C0F + for ; + Sun, 7 Aug 2005 23:01:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33156-07 + for ; + Mon, 8 Aug 2005 02:01:05 +0000 (GMT) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [63.240.76.28]) + by svr1.postgresql.org (Postfix) with ESMTP id D7C1352BBA + for ; + Sun, 7 Aug 2005 23:01:03 -0300 (ADT) +Received: from [127.0.0.1] (c-24-4-66-2.hsd1.ca.comcast.net[24.4.66.2]) + by comcast.net (sccrmhc13) with ESMTP + id <2005080802005501300dpesle>; Mon, 8 Aug 2005 02:00:55 +0000 +Message-ID: <42F6BCD3.4070600@comcast.net> +Date: Sun, 07 Aug 2005 19:00:51 -0700 +From: Patrick Hatcher +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John A Meinel +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Slow update statement +References: <42F4B812.7070501@comcast.net> <42F4BC61.20102@arbash-meinel.com> +In-Reply-To: <42F4BC61.20102@arbash-meinel.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.793 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS +X-Spam-Level: * +X-Archive-Number: 200508/57 +X-Sequence-Number: 13804 + +Sorry went out of town for the weekend. The update did occur, but I +have no idea when it finished. + +Here's the actual query and the explain Update: +cdm.bcp_ddw_ck_cus = 12.7 M +cdm.cdm_ddw_customer = 12.8M + +explain +update cdm.cdm_ddw_customer + set indiv_fkey = b.indiv_fkey + from cdm.bcp_ddw_ck_cus b + where +cdm.cdm_ddw_customer.cus_nbr = b.cus_num; + + + Hash Join (cost=1246688.42..4127248.31 rows=12702676 width=200) + Hash Cond: ("outer".cus_num = "inner".cus_nbr) + -> Seq Scan on bcp_ddw_ck_cus b (cost=0.00..195690.76 rows=12702676 +width=16) + -> Hash (cost=874854.34..874854.34 rows=12880834 width=192) + -> Seq Scan on cdm_ddw_customer (cost=0.00..874854.34 +rows=12880834 width=192) + + +John A Meinel wrote: + +>Patrick Hatcher wrote: +> +> +>>[Reposted from General section with updated information] +>>Pg 7.4.5 +>> +>>I'm running an update statement on about 12 million records using the +>>following query: +>> +>>Update table_A +>>set F1 = b.new_data +>>from table_B b +>>where b.keyfield = table_A.keyfield +>> +>>both keyfields are indexed, all other keys in table_A were dropped, yet +>>this job has been running over 15 hours. Is +>>this normal? +>> +>> +> +>Can you do an EXPLAIN UPDATE so that we can have an idea what the +>planner is trying to do? +> +>My personal concern is if it doing something like pulling in all rows +>from b, and then one by one updating table_A, but as it is going, it +>can't retire any dead rows, because you are still in a transaction. So +>you are getting a lot of old rows, which it has to pull in to realize it +>was old. +> +>How many rows are in table_B? +> +>I can see that possibly doing it in smaller chunks might be faster, as +>would inserting into another table. But I would do more of a test and +>see what happens. +> +>John +>=:-> +> +> +> +>>I stopped the process the first time after 3 hours of running due to +>>excessive log rotation and reset the conf file to these settings: +>> +>> +>>wal_buffers = 64 # min 4, 8KB each +>> +>># - Checkpoints - +>> +>>checkpoint_segments = 128 # in logfile segments, min 1, 16MB each +>>checkpoint_timeout = 1800 # 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 +>> +>> +>>Would it just be quicker to run a JOIN statement to a temp file and then +>>reinsert? +>>TIA Patrick +>> +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 9: In versions below 8.0, the planner will ignore your desire to +>> choose an index scan if your joining column's datatypes do not +>> match +>> +>> +>> +> +> +> + +From pgsql-performance-owner@postgresql.org Sun Aug 7 23:09:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BD76652C55 + for ; + Sun, 7 Aug 2005 23:09:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87512-05 + for ; + Mon, 8 Aug 2005 02:09:07 +0000 (GMT) +Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) + by svr1.postgresql.org (Postfix) with ESMTP id 6052152C47 + for ; + Sun, 7 Aug 2005 23:09:06 -0300 (ADT) +Received: from [127.0.0.1] (c-24-4-66-2.hsd1.ca.comcast.net[24.4.66.2]) + by comcast.net (sccrmhc11) with ESMTP + id <200508080209060110017uqse>; Mon, 8 Aug 2005 02:09:10 +0000 +Message-ID: <42F6BEC0.9090504@comcast.net> +Date: Sun, 07 Aug 2005 19:09:04 -0700 +From: Patrick Hatcher +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Slow update statement +References: <42F4B812.7070501@comcast.net> <17916.1123337563@sss.pgh.pa.us> +In-Reply-To: <17916.1123337563@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.943 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS +X-Spam-Level: * +X-Archive-Number: 200508/58 +X-Sequence-Number: 13805 + +Sorry went out of town for the weekend. The update did occur, but I +have no idea when it finished. + +Here's the actual query and the explain Update: +cdm.bcp_ddw_ck_cus = 12.7 M +cdm.cdm_ddw_customer = 12.8M + +explain +update cdm.cdm_ddw_customer + set indiv_fkey = b.indiv_fkey + from cdm.bcp_ddw_ck_cus b + where +cdm.cdm_ddw_customer.cus_nbr = b.cus_num; + + +Here's the table layout. It's the first time I noticed this, but there +is a PK on the cus_nbr and an index. Does really need to be both and +could this be causing the issue? I thought that if a primary key was +designated, it was automatically indexed.: + +CREATE TABLE cdm.cdm_ddw_customer +( + cus_nbr int8 NOT NULL, + ph_home int8, + ph_day int8, + email_adr varchar(255), + name_prefix varchar(5), + name_first varchar(20), + name_middle varchar(20), + name_last varchar(30), + name_suffix varchar(5), + addr1 varchar(40), + addr2 varchar(40), + addr3 varchar(40), + city varchar(25), + state varchar(7), + zip varchar(10), + country varchar(16), + gender varchar(1), + lst_dte date, + add_dte date, + reg_id int4, + indiv_fkey int8, + CONSTRAINT ddwcus_pk PRIMARY KEY (cus_nbr) +) +WITH OIDS; + +CREATE INDEX cdm_ddwcust_id_idx + ON cdm.cdm_ddw_customer + USING btree + (cus_nbr); + + +CREATE TABLE cdm.bcp_ddw_ck_cus +( + cus_num int8, + indiv_fkey int8 NOT NULL +) +WITHOUT OIDS; + +Tom Lane wrote: + +>Patrick Hatcher writes: +> +> +>>I'm running an update statement on about 12 million records using the +>>following query: +>> +>> +> +> +> +>>Update table_A +>>set F1 = b.new_data +>>from table_B b +>>where b.keyfield = table_A.keyfield +>> +>> +> +>What does EXPLAIN show for this? +> +>Do you have any foreign key references to table_A from elsewhere? +> +> regards, tom lane +> +> +> + +From pgsql-performance-owner@postgresql.org Mon Aug 8 00:48:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E40725288B + for ; + Mon, 8 Aug 2005 00:48:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59195-02 + for ; + Mon, 8 Aug 2005 03:48:31 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id EB77052967 + for ; + Mon, 8 Aug 2005 00:48:30 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j783mPn6020255; + Sun, 7 Aug 2005 23:48:27 -0400 (EDT) +To: Patrick Hatcher +Cc: John A Meinel , + "pgsql-performance@postgresql.org" +Subject: Re: Slow update statement +In-reply-to: <42F6BCD3.4070600@comcast.net> +References: <42F4B812.7070501@comcast.net> <42F4BC61.20102@arbash-meinel.com> + <42F6BCD3.4070600@comcast.net> +Comments: In-reply-to Patrick Hatcher + message dated "Sun, 07 Aug 2005 19:00:51 -0700" +Date: Sun, 07 Aug 2005 23:48:25 -0400 +Message-ID: <20254.1123472905@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/59 +X-Sequence-Number: 13806 + +Patrick Hatcher writes: +> Hash Join (cost=1246688.42..4127248.31 rows=12702676 width=200) +> Hash Cond: ("outer".cus_num = "inner".cus_nbr) +> -> Seq Scan on bcp_ddw_ck_cus b (cost=0.00..195690.76 rows=12702676 +> width=16) +> -> Hash (cost=874854.34..874854.34 rows=12880834 width=192) +> -> Seq Scan on cdm_ddw_customer (cost=0.00..874854.34 +> rows=12880834 width=192) + +Yipes, that's a bit of a large hash table, if the planner's estimates +are on-target. What do you have work_mem (sort_mem if pre 8.0) set to, +and how does that compare to actual available RAM? I'm thinking you +might have set work_mem too large and the thing is now swap-thrashing. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 8 01:38:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB36C52C28 + for ; + Mon, 8 Aug 2005 01:35:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66084-02 + for ; + Mon, 8 Aug 2005 04:35:43 +0000 (GMT) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id B7C7F52B73 + for ; + Mon, 8 Aug 2005 01:35:41 -0300 (ADT) +Received: from [127.0.0.1] (c-24-4-66-2.hsd1.ca.comcast.net[24.4.66.2]) + by comcast.net (sccrmhc13) with ESMTP + id <2005080804353901300dl953e>; Mon, 8 Aug 2005 04:35:39 +0000 +Message-ID: <42F6E118.20206@comcast.net> +Date: Sun, 07 Aug 2005 21:35:36 -0700 +From: Patrick Hatcher +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: John A Meinel , + "pgsql-performance@postgresql.org" +Subject: Re: Slow update statement +References: <42F4B812.7070501@comcast.net> <42F4BC61.20102@arbash-meinel.com> + <42F6BCD3.4070600@comcast.net> <20254.1123472905@sss.pgh.pa.us> +In-Reply-To: <20254.1123472905@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.719 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS +X-Spam-Level: * +X-Archive-Number: 200508/60 +X-Sequence-Number: 13807 + +At the time this was the only process running on the box so I set +sort_mem= 228000; +It's a 12G box. + +Tom Lane wrote: + +>Patrick Hatcher writes: +> +> +>> Hash Join (cost=1246688.42..4127248.31 rows=12702676 width=200) +>> Hash Cond: ("outer".cus_num = "inner".cus_nbr) +>> -> Seq Scan on bcp_ddw_ck_cus b (cost=0.00..195690.76 rows=12702676 +>>width=16) +>> -> Hash (cost=874854.34..874854.34 rows=12880834 width=192) +>> -> Seq Scan on cdm_ddw_customer (cost=0.00..874854.34 +>>rows=12880834 width=192) +>> +>> +> +>Yipes, that's a bit of a large hash table, if the planner's estimates +>are on-target. What do you have work_mem (sort_mem if pre 8.0) set to, +>and how does that compare to actual available RAM? I'm thinking you +>might have set work_mem too large and the thing is now swap-thrashing. +> +> regards, tom lane +> +> +> + +From pgsql-performance-owner@postgresql.org Mon Aug 8 09:05:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F1DA752A7B + for ; + Mon, 8 Aug 2005 09:05:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47716-08 + for ; + Mon, 8 Aug 2005 12:05:00 +0000 (GMT) +Received: from purple.bdb.fi (purple.bdb.fi [195.197.212.62]) + by svr1.postgresql.org (Postfix) with ESMTP id D8E7852C2D + for ; + Mon, 8 Aug 2005 09:04:58 -0300 (ADT) +Received: by purple.bdb.fi (Postfix, from userid 101) + id BE7FA3261; Mon, 8 Aug 2005 15:03:21 +0300 (EETDST) +Received: from localhost (localhost [127.0.0.1]) + by purple.bdb.fi (Postfix) with ESMTP id B50484972; + Mon, 8 Aug 2005 15:03:21 +0300 (EETDST) +Date: Mon, 8 Aug 2005 15:03:21 +0300 (EETDST) +From: Kari Lavikka +To: Luke Lonergan +Cc: pgsql-performance@postgresql.org +Subject: Re: Finding bottleneck +In-Reply-To: +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/61 +X-Sequence-Number: 13808 + + +Hi! + +Oprofile looks quite interesting. I'm not very familiar with postgresql +internals, but here's some report output: + +CPU: AMD64 processors, speed 2190.23 MHz (estimated) +Counted CPU_CLK_UNHALTED events (Cycles outside of halt state) with a unit +mask of 0x00 (No unit mask) count 100000 +samples % symbol name +13513390 16.0074 AtEOXact_CatCache +4492257 5.3213 StrategyGetBuffer +2279285 2.6999 AllocSetAlloc +2121509 2.5130 LWLockAcquire +2023574 2.3970 hash_seq_search +1971358 2.3352 nocachegetattr +1837168 2.1762 GetSnapshotData +1793693 2.1247 SearchCatCache +1777385 2.1054 hash_search +1460804 1.7304 ExecMakeFunctionResultNoSets +1360930 1.6121 _bt_compare +1344604 1.5928 yyparse +1318407 1.5617 LWLockRelease +1290814 1.5290 FunctionCall2 +1137544 1.3475 ExecEvalVar +1102236 1.3057 hash_any +912677 1.0811 OpernameGetCandidates +877993 1.0400 ReadBufferInternal +783908 0.9286 TransactionIdPrecedes +772886 0.9155 MemoryContextAllocZeroAligned +679768 0.8052 StrategyBufferLookup +609339 0.7218 equal +600584 0.7114 PGSemaphoreLock + +And btw, I tried to strace lingering queries under different loads. When +number of concurrent queries increases, lseek and read syscalls stay +within quite constant limits but number of semop calls quadruples. + +Are there some buffer locking issues? + + |\__/| + ( oo ) Kari Lavikka - tuner@bdb.fi - (050) 380 3808 +__ooO( )Ooo_______ _____ ___ _ _ _ _ _ _ _ + "" + +On Thu, 28 Jul 2005, Luke Lonergan wrote: + +> On 7/28/05 2:21 AM, "Kari Lavikka" wrote: +> +> There's a new profiling tool called oprofile: +> +> http://oprofile.sourceforge.net/download/ +> +> that can be run without instrumenting the binaries beforehand. To actually +> find out what the code is doing during these stalls, oprofile can show you +> in which routines the CPU is spending time when you start/stop the +> profiling. +> +> As an alternative to the "guess->change parameters->repeat" approach, this +> is the most direct way to find the exact nature of the problem. +> +> - Luke +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + +From pgsql-performance-owner@postgresql.org Mon Aug 8 11:39:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 404C052B49 + for ; + Mon, 8 Aug 2005 11:39:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52922-08 + for ; + Mon, 8 Aug 2005 14:39:12 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2976452B0B + for ; + Mon, 8 Aug 2005 11:39:11 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j78EdF7H028286; + Mon, 8 Aug 2005 10:39:15 -0400 (EDT) +To: Kari Lavikka +Cc: pgsql-performance@postgresql.org +Subject: Re: Finding bottleneck +In-reply-to: +References: + +Comments: In-reply-to Kari Lavikka + message dated "Mon, 08 Aug 2005 15:03:21 +0300" +Date: Mon, 08 Aug 2005 10:39:15 -0400 +Message-ID: <28285.1123511955@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/62 +X-Sequence-Number: 13809 + +Kari Lavikka writes: +> samples % symbol name +> 13513390 16.0074 AtEOXact_CatCache + +That seems quite odd --- I'm not used to seeing that function at the top +of a profile. What is the workload being profiled, exactly? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 8 12:19:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB03452DAD + for ; + Mon, 8 Aug 2005 12:19:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17017-05 + for ; + Mon, 8 Aug 2005 15:18:56 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 43FF552B53 + for ; + Mon, 8 Aug 2005 12:18:55 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j78FIsZB028598; + Mon, 8 Aug 2005 11:18:54 -0400 (EDT) +To: Patrick Hatcher +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Slow update statement +In-reply-to: <42F6BEC0.9090504@comcast.net> +References: <42F4B812.7070501@comcast.net> <17916.1123337563@sss.pgh.pa.us> + <42F6BEC0.9090504@comcast.net> +Comments: In-reply-to Patrick Hatcher + message dated "Sun, 07 Aug 2005 19:09:04 -0700" +Date: Mon, 08 Aug 2005 11:18:53 -0400 +Message-ID: <28597.1123514333@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/63 +X-Sequence-Number: 13810 + +Patrick Hatcher writes: +> Here's the table layout. It's the first time I noticed this, but there +> is a PK on the cus_nbr and an index. Does really need to be both and +> could this be causing the issue? I thought that if a primary key was +> designated, it was automatically indexed.: + +The duplicate index is certainly a waste, but it's no more expensive to +maintain than any other index would be; it doesn't seem likely that that +would account for any huge slowdown. + +A long-shot theory occurs to me upon noticing that your join keys are +int8: 7.4 had a pretty bad hash function for int8, to wit it took the +low order half of the integer and ignored the high order half. For +ordinary distributions of key values this made no difference, but I +recall seeing at least one real-world case where the information was +all in the high half of the key, and so the hash join degenerated to a +sequential search because all the entries went into the same hash +bucket. Were you assigning cus_nbrs nonsequentially by any chance? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 8 12:24:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 182DD528FA + for ; + Mon, 8 Aug 2005 12:24:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54979-01 + for ; + Mon, 8 Aug 2005 15:24:45 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 37FB1529BE + for ; + Mon, 8 Aug 2005 12:24:44 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Finding bottleneck +Date: Mon, 8 Aug 2005 11:24:42 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD026@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Finding bottleneck +Thread-Index: AcWcJ0fWQTl93s16T6yCKgBHt7uf3QABbjaw +From: "Merlin Moncure" +To: "Tom Lane" +Cc: , "Kari Lavikka" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.055 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/64 +X-Sequence-Number: 13811 + +> Kari Lavikka writes: +> > samples % symbol name +> > 13513390 16.0074 AtEOXact_CatCache +>=20 +> That seems quite odd --- I'm not used to seeing that function at the +top +> of a profile. What is the workload being profiled, exactly? + +He is running a commit_delay of 80000. Could that be playing a role? + +Merlin + +From pgsql-performance-owner@postgresql.org Mon Aug 8 12:37:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 01B755293B + for ; + Mon, 8 Aug 2005 12:37:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66243-10 + for ; + Mon, 8 Aug 2005 15:37:22 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DBDC8528CF + for ; + Mon, 8 Aug 2005 12:37:21 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j78FbKcc028802; + Mon, 8 Aug 2005 11:37:20 -0400 (EDT) +To: "Merlin Moncure" +Cc: pgsql-performance@postgresql.org, "Kari Lavikka" +Subject: Re: Finding bottleneck +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB3417DD026@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD026@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Mon, 08 Aug 2005 11:24:42 -0400" +Date: Mon, 08 Aug 2005 11:37:19 -0400 +Message-ID: <28801.1123515439@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/65 +X-Sequence-Number: 13812 + +"Merlin Moncure" writes: +>> Kari Lavikka writes: +>>> samples % symbol name +>>> 13513390 16.0074 AtEOXact_CatCache +>> +>> That seems quite odd --- I'm not used to seeing that function at the top +>> of a profile. What is the workload being profiled, exactly? + +> He is running a commit_delay of 80000. Could that be playing a role? + +It wouldn't cause AtEOXact_CatCache to suddenly get expensive. (I have +little or no faith in the value of nonzero commit_delay, though.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 8 13:21:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F142D52967 + for ; + Mon, 8 Aug 2005 13:21:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18584-01 + for ; + Mon, 8 Aug 2005 16:20:56 +0000 (GMT) +Received: from purple.bdb.fi (purple.bdb.fi [195.197.212.62]) + by svr1.postgresql.org (Postfix) with ESMTP id 9619B529BE + for ; + Mon, 8 Aug 2005 13:20:49 -0300 (ADT) +Received: by purple.bdb.fi (Postfix, from userid 101) + id 2915831AD; Mon, 8 Aug 2005 19:19:09 +0300 (EETDST) +Received: from localhost (localhost [127.0.0.1]) + by purple.bdb.fi (Postfix) with ESMTP id 1EB484972; + Mon, 8 Aug 2005 19:19:09 +0300 (EETDST) +Date: Mon, 8 Aug 2005 19:19:09 +0300 (EETDST) +From: Kari Lavikka +To: Merlin Moncure +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Finding bottleneck +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD026@Herge.rcsinc.local> +Message-ID: +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD026@Herge.rcsinc.local> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/66 +X-Sequence-Number: 13813 + + +Actually I modified postgresql.conf a bit and there isn't commit delay any +more. That didn't make noticeable difference though.. + +Workload is generated by a website with about 1000 dynamic page views a +second. Finland's biggest site among youths btw. + +Anyway, there are about 70 tables and here's some of the most important: + relname | reltuples +----------------------------------+------------- + comment | 1.00723e+08 + comment_archive | 9.12764e+07 + channel_comment | 6.93912e+06 + image | 5.80314e+06 + admin_event | 5.1936e+06 + user_channel | 3.36877e+06 + users | 325929 + channel | 252267 + +Queries to "comment" table are mostly IO-bound but are performing quite +well. Here's an example: + +(SELECT u.nick, c.comment, c.private, c.admin, c.visible, c.parsable, +c.uid_sender, to_char(c.stamp, 'DD.MM.YY HH24:MI') AS stamp, c.comment_id +FROM comment c INNER JOIN users u ON u.uid = c.uid_sender WHERE u.status = +'a' AND c.image_id = 15500900 AND c.uid_target = 780345 ORDER BY +uid_target DESC, image_id DESC, c.comment_id DESC) LIMIT 36 + +And explain analyze: + Limit (cost=0.00..6.81 rows=1 width=103) (actual time=0.263..17.522 rows=12 loops=1) + -> Nested Loop (cost=0.00..6.81 rows=1 width=103) (actual time=0.261..17.509 rows=12 loops=1) + -> Index Scan Backward using comment_uid_target_image_id_comment_id_20050527 on "comment" c (cost=0.00..3.39 rows=1 width=92) (actual time=0.129..16.213 rows=12 loops=1) + Index Cond: ((uid_target = 780345) AND (image_id = 15500900)) + -> Index Scan using users_pkey on users u (cost=0.00..3.40 rows=1 width=15) (actual time=0.084..0.085 rows=1 loops=12) + Index Cond: (u.uid = "outer".uid_sender) + Filter: (status = 'a'::bpchar) + Total runtime: 17.653 ms + + +We are having performance problems with some smaller tables and very +simple queries. For example: + +SELECT u.uid, u.nick, extract(epoch from uc.stamp) AS stamp FROM +user_channel uc INNER JOIN users u USING (uid) WHERE channel_id = 281321 +AND u.status = 'a' ORDER BY uc.channel_id, upper(uc.nick) + +And explain analyze: + Nested Loop (cost=0.00..200.85 rows=35 width=48) (actual time=0.414..38.128 rows=656 loops=1) + -> Index Scan using user_channel_channel_id_nick on user_channel uc (cost=0.00..40.18 rows=47 width=27) (actual time=0.090..0.866 rows=667 loops=1) + Index Cond: (channel_id = 281321) + -> Index Scan using users_pkey on users u (cost=0.00..3.40 rows=1 width=25) (actual time=0.048..0.051 rows=1 loops=667) + Index Cond: ("outer".uid = u.uid) + Filter: (status = 'a'::bpchar) + Total runtime: 38.753 ms + +Under heavy load these queries tend to take several minutes to execute +although there's plenty of free cpu available. There aren't any blocking +locks in pg_locks. + + |\__/| + ( oo ) Kari Lavikka - tuner@bdb.fi - (050) 380 3808 +__ooO( )Ooo_______ _____ ___ _ _ _ _ _ _ _ + "" + +On Mon, 8 Aug 2005, Merlin Moncure wrote: + +>> Kari Lavikka writes: +>>> samples % symbol name +>>> 13513390 16.0074 AtEOXact_CatCache +>> +>> That seems quite odd --- I'm not used to seeing that function at the +> top +>> of a profile. What is the workload being profiled, exactly? +> +> He is running a commit_delay of 80000. Could that be playing a role? +> +> Merlin +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + +From pgsql-performance-owner@postgresql.org Mon Aug 8 13:56:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D392D528CF + for ; + Mon, 8 Aug 2005 13:56:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15373-02 + for ; + Mon, 8 Aug 2005 16:56:42 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4061C5291E + for ; + Mon, 8 Aug 2005 13:56:41 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j78GueDg029385; + Mon, 8 Aug 2005 12:56:40 -0400 (EDT) +To: Kari Lavikka +Cc: Merlin Moncure , + pgsql-performance@postgresql.org +Subject: Re: Finding bottleneck +In-reply-to: +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD026@Herge.rcsinc.local> + +Comments: In-reply-to Kari Lavikka + message dated "Mon, 08 Aug 2005 19:19:09 +0300" +Date: Mon, 08 Aug 2005 12:56:40 -0400 +Message-ID: <29384.1123520200@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/67 +X-Sequence-Number: 13814 + +Kari Lavikka writes: +> We are having performance problems with some smaller tables and very +> simple queries. For example: + +> SELECT u.uid, u.nick, extract(epoch from uc.stamp) AS stamp FROM +> user_channel uc INNER JOIN users u USING (uid) WHERE channel_id = 281321 +> AND u.status = 'a' ORDER BY uc.channel_id, upper(uc.nick) + +> And explain analyze: +> Nested Loop (cost=0.00..200.85 rows=35 width=48) (actual time=0.414..38.128 rows=656 loops=1) +> -> Index Scan using user_channel_channel_id_nick on user_channel uc (cost=0.00..40.18 rows=47 width=27) (actual time=0.090..0.866 rows=667 loops=1) +> Index Cond: (channel_id = 281321) +> -> Index Scan using users_pkey on users u (cost=0.00..3.40 rows=1 width=25) (actual time=0.048..0.051 rows=1 loops=667) +> Index Cond: ("outer".uid = u.uid) +> Filter: (status = 'a'::bpchar) +> Total runtime: 38.753 ms + +> Under heavy load these queries tend to take several minutes to execute +> although there's plenty of free cpu available. + +What that sounds like to me is a machine with inadequate disk I/O bandwidth. +Your earlier comment that checkpoint drives the machine into the ground +fits right into that theory, too. You said there is "almost no IO-wait" +but are you sure you are measuring that correctly? + +Something else just struck me from your first post: + +> Queries accumulate and when checkpointing is over, there can be +> something like 400 queries running but over 50% of cpu is just idling. + +400 queries? Are you launching 400 separate backends to do that? +Some sort of connection pooling seems like a good idea, if you don't +have it in place already. If the system's effective behavior in the +face of heavy load is to start even more concurrent backends, that +could easily drive things into the ground. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 8 14:00:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 880095291E + for ; + Mon, 8 Aug 2005 14:00:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60101-01 + for ; + Mon, 8 Aug 2005 17:00:12 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.198]) + by svr1.postgresql.org (Postfix) with ESMTP id CEDB3528FA + for ; + Mon, 8 Aug 2005 14:00:08 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i5so820164wra + for ; + Mon, 08 Aug 2005 10:00:09 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=kIhXGdM880DrfcGjiVXAzVb3ra1nuikKkWzgOgV/N/i2AWfAJVH4z7Kr/egp25ybvDqvRouBhOOiL31s74OQJSi+qI4N9oA9CgL8V6Iy/Mj9QxheduQ934d2qou+EVa+vkH4ymVJ5VH/S24vniSbVtU2pHN9TfP8sXMYcTr2lXk= +Received: by 10.54.11.20 with SMTP id 20mr4996338wrk; + Mon, 08 Aug 2005 10:00:09 -0700 (PDT) +Received: by 10.54.119.7 with HTTP; Mon, 8 Aug 2005 10:00:08 -0700 (PDT) +Message-ID: <41b0fe89050808100021a2a4fc@mail.gmail.com> +Date: Mon, 8 Aug 2005 10:00:08 -0700 +From: Rhett Garber +Reply-To: Rhett Garber +To: Tom Lane +Subject: Re: Why hash join instead of nested loop? +Cc: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +In-Reply-To: <15425.1123304631@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/68 +X-Sequence-Number: 13815 + +This is postgres 7.4.1 + +All the rows involved are integers. + +Thanks, + +Rhett + +On 8/5/05, Tom Lane wrote: +> Rhett Garber writes: +> > Hash Join (cost=3D5.96..7.04 rows=3D1 width=3D14) (actual +> > time=3D10.591..10.609 rows=3D1 loops=3D1) +> > Hash Cond: ("outer".id =3D "inner".obj2) +> > -> Seq Scan on rtmessagestate (cost=3D0.00..1.05 rows=3D5 width=3D= +14) +> > (actual time=3D0.011..0.022 rows=3D5 loops=3D1) +> > -> Hash (cost=3D5.96..5.96 rows=3D1 width=3D4) (actual +> > time=3D0.109..0.109 rows=3D0 loops=3D1) +> > -> Index Scan using connection_regid_obj1_index on +> > connection (cost=3D0.00..5.96 rows=3D1 width=3D4) (actual time=3D0.070= +..0.076 +> > rows=3D1 loops=3D1) +> > Index Cond: ((connection_registry_id =3D 40105) AND (obj= +1 +> > =3D 73582)) Total runtime: 11.536 ms +> > (7 rows) +>=20 +> [ scratches head... ] If the hash table build takes only 0.109 msec +> and loads only one row into the hash table, and the scan of +> rtmessagestate takes only 0.022 msec and produces only 5 rows, it is +> real hard to see how the join takes 10.609 msec overall. Unless the id +> and obj2 columns are of a datatype with an incredibly slow equality +> function. What is the datatype involved here, anyway? And what PG +> version are we speaking of? +>=20 +> regards, tom lane +> + +From pgsql-performance-owner@postgresql.org Mon Aug 8 14:56:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B91D52E41 + for ; + Mon, 8 Aug 2005 14:56:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63551-07 + for ; + Mon, 8 Aug 2005 17:56:21 +0000 (GMT) +Received: from purple.bdb.fi (purple.bdb.fi [195.197.212.62]) + by svr1.postgresql.org (Postfix) with ESMTP id BE59E52E38 + for ; + Mon, 8 Aug 2005 14:56:17 -0300 (ADT) +Received: by purple.bdb.fi (Postfix, from userid 101) + id BE3013B1E; Mon, 8 Aug 2005 20:54:38 +0300 (EETDST) +Received: from localhost (localhost [127.0.0.1]) + by purple.bdb.fi (Postfix) with ESMTP id B6DBE4972; + Mon, 8 Aug 2005 20:54:38 +0300 (EETDST) +Date: Mon, 8 Aug 2005 20:54:38 +0300 (EETDST) +From: Kari Lavikka +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Finding bottleneck +In-Reply-To: <29384.1123520200@sss.pgh.pa.us> +Message-ID: +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD026@Herge.rcsinc.local> + + <29384.1123520200@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/69 +X-Sequence-Number: 13816 + +On Mon, 8 Aug 2005, Tom Lane wrote: +> What that sounds like to me is a machine with inadequate disk I/O bandwidth. +> Your earlier comment that checkpoint drives the machine into the ground +> fits right into that theory, too. You said there is "almost no IO-wait" +> but are you sure you are measuring that correctly? + +Currently there's some iowait caused by "fragmentation" of the comment +table. Periodic clustering helps a lot. + +Disk configurations looks something like this: + sda: data (10 spindles, raid10) + sdb: xlog & clog (2 spindles, raid1) + sdc: os and other stuff + +Usually iostat (2 second interval) says: + avg-cpu: %user %nice %sys %iowait %idle + 32.38 0.00 12.88 11.62 43.12 + + Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn + sda 202.00 1720.00 0.00 3440 0 + sdb 152.50 4.00 2724.00 8 5448 + sdc 0.00 0.00 0.00 0 0 + +And during checkpoint: + avg-cpu: %user %nice %sys %iowait %idle + 31.25 0.00 14.75 54.00 0.00 + + Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn + sda 3225.50 1562.00 35144.00 3124 70288 + sdb 104.50 10.00 2348.00 20 4696 + sdc 0.00 0.00 0.00 0 0 + +I think (insufficiency of) disk IO shouldn't cause those lingering queries +because dataset is rather small and it's continuously accessed. It should +fit into cache and stay there(?) + +> 400 queries? Are you launching 400 separate backends to do that? + +Well yes. That's the common problem with php and persistent connections. + +> Some sort of connection pooling seems like a good idea, if you don't +> have it in place already. + +pg_pool for example? I'm planning to give it a try. + +> regards, tom lane + + + |\__/| + ( oo ) Kari Lavikka - tuner@bdb.fi - (050) 380 3808 +__ooO( )Ooo_______ _____ ___ _ _ _ _ _ _ _ + "" + + +From pgsql-performance-owner@postgresql.org Mon Aug 8 16:27:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FBC7529B4 + for ; + Mon, 8 Aug 2005 16:27:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96590-04 + for ; + Mon, 8 Aug 2005 19:27:31 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B0995290F + for ; + Mon, 8 Aug 2005 16:27:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j78JRP9J008435; + Mon, 8 Aug 2005 15:27:25 -0400 (EDT) +To: Kari Lavikka +Cc: pgsql-performance@postgresql.org +Subject: Re: Finding bottleneck +In-reply-to: +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD026@Herge.rcsinc.local> + + <29384.1123520200@sss.pgh.pa.us> + +Comments: In-reply-to Kari Lavikka + message dated "Mon, 08 Aug 2005 20:54:38 +0300" +Date: Mon, 08 Aug 2005 15:27:25 -0400 +Message-ID: <8434.1123529245@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/70 +X-Sequence-Number: 13817 + +Kari Lavikka writes: +> Disk configurations looks something like this: +> sda: data (10 spindles, raid10) +> sdb: xlog & clog (2 spindles, raid1) +> sdc: os and other stuff + +That's definitely wrong. Put clog on the data disk. The entire point +of giving xlog its own spindle is that you don't ever want the disk +heads moving off the current xlog file. I'm not sure how much this is +hurting you, given that clog is relatively low volume, but if you're +going to go to the trouble of putting xlog on a separate spindle then +it should be a completely dedicated spindle. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 8 21:58:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D34852CBB + for ; + Mon, 8 Aug 2005 21:58:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06129-06 + for ; + Tue, 9 Aug 2005 00:58:32 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3703052803 + for ; + Mon, 8 Aug 2005 21:58:31 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j790wQPD010931; + Mon, 8 Aug 2005 20:58:26 -0400 (EDT) +To: Rhett Garber +Cc: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +Subject: Re: Why hash join instead of nested loop? +In-reply-to: <41b0fe89050808100021a2a4fc@mail.gmail.com> +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> +Comments: In-reply-to Rhett Garber + message dated "Mon, 08 Aug 2005 10:00:08 -0700" +Date: Mon, 08 Aug 2005 20:58:26 -0400 +Message-ID: <10930.1123549106@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/71 +X-Sequence-Number: 13818 + +Rhett Garber writes: +> This is postgres 7.4.1 +> All the rows involved are integers. + +Hmph. There is something really strange going on here. I tried to +duplicate your problem in 7.4.*, thus: + +regression=# create table rtmessagestate(id int, f1 char(6)); +CREATE TABLE +regression=# insert into rtmessagestate values(1,'z'); +INSERT 559399 1 +regression=# insert into rtmessagestate values(2,'z'); +INSERT 559400 1 +regression=# insert into rtmessagestate values(3,'z'); +INSERT 559401 1 +regression=# insert into rtmessagestate values(4,'z'); +INSERT 559402 1 +regression=# insert into rtmessagestate values(5,'z'); +INSERT 559403 1 +regression=# vacuum analyze rtmessagestate; +VACUUM +regression=# create table connection(connection_registry_id int, obj1 int, obj2 int); +CREATE TABLE +regression=# create index connection_regid_obj1_index on connection(connection_registry_id,obj1); +CREATE INDEX +regression=# insert into connection values(40105,73582,3); +INSERT 559407 1 +regression=# explain analyze select rtmessagestate.* from rtmessagestate,connection where (connection_registry_id = 40105) AND (obj1 = 73582) and id = obj2; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=4.83..5.91 rows=1 width=14) (actual time=0.498..0.544 rows=1 loops=1) + Hash Cond: ("outer".id = "inner".obj2) + -> Seq Scan on rtmessagestate (cost=0.00..1.05 rows=5 width=14) (actual time=0.030..0.072 rows=5 loops=1) + -> Hash (cost=4.83..4.83 rows=1 width=4) (actual time=0.305..0.305 rows=0 loops=1) + -> Index Scan using connection_regid_obj1_index on connection (cost=0.00..4.83 rows=1 width=4) (actual time=0.236..0.264 rows=1 loops=1) + Index Cond: ((connection_registry_id = 40105) AND (obj1 = 73582)) + Total runtime: 1.119 ms +(7 rows) + +This duplicates your example as to plan and row counts: + +> Hash Join (cost=5.96..7.04 rows=1 width=14) (actual +> time=10.591..10.609 rows=1 loops=1) +> Hash Cond: ("outer".id = "inner".obj2) +> -> Seq Scan on rtmessagestate (cost=0.00..1.05 rows=5 width=14) +> (actual time=0.011..0.022 rows=5 loops=1) +> -> Hash (cost=5.96..5.96 rows=1 width=4) (actual +> time=0.109..0.109 rows=0 loops=1) +> -> Index Scan using connection_regid_obj1_index on +> connection (cost=0.00..5.96 rows=1 width=4) (actual time=0.070..0.076 +> rows=1 loops=1) +> Index Cond: ((connection_registry_id = 40105) AND (obj1 +> = 73582)) Total runtime: 11.536 ms +> (7 rows) + +My machine is considerably slower than yours, to judge by the actual +elapsed times in the scan nodes ... so why is it beating the pants +off yours in the join step? + +Can you try the above script verbatim in a scratch database and see +what you get? (Note it's worth trying the explain two or three +times to be sure the values have settled out.) + +I'm testing a fairly recent 7.4-branch build (7.4.8 plus), so that's one +possible reason for the discrepancy between my results and yours, but I +do not see anything in the 7.4 CVS logs that looks like it's related to +hashjoin performance. + +I'd be interested to see results from other people using 7.4.* too. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 8 22:09:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 98E9452800 + for ; + Mon, 8 Aug 2005 22:09:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46006-03 + for ; + Tue, 9 Aug 2005 01:08:50 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 245B0528F6 + for ; + Mon, 8 Aug 2005 22:08:49 -0300 (ADT) +Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] + helo=trofast.sesse.net) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1E2Ibr-00069y-Cc + for pgsql-performance@postgresql.org; Tue, 09 Aug 2005 03:08:51 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1E2Ibq-00052V-00 + for ; Tue, 09 Aug 2005 03:08:50 +0200 +Date: Tue, 9 Aug 2005 03:08:50 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Why hash join instead of nested loop? +Message-ID: <20050809010850.GA18938@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <10930.1123549106@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.017 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/72 +X-Sequence-Number: 13819 + +On Mon, Aug 08, 2005 at 08:58:26PM -0400, Tom Lane wrote: +> Hmph. There is something really strange going on here. I tried to +> duplicate your problem in 7.4.*, thus: + +PostgreSQL 7.4.7 (Debian sarge): + + + +regression=# explain analyze select rtmessagestate.* from rtmessagestate,connection where (connection_registry_id = 40105) AND (obj1 = 73582) and id = obj2; + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=4.83..5.91 rows=1 width=14) (actual time=0.155..0.159 rows=1 loops=1) + Hash Cond: ("outer".id = "inner".obj2) + -> Seq Scan on rtmessagestate (cost=0.00..1.05 rows=5 width=14) (actual time=0.003..0.006 rows=5 loops=1) + -> Hash (cost=4.83..4.83 rows=1 width=4) (actual time=0.026..0.026 rows=0 loops=1) + -> Index Scan using connection_regid_obj1_index on connection (cost=0.00..4.83 rows=1 width=4) (actual time=0.011..0.012 rows=1 loops=1) + Index Cond: ((connection_registry_id = 40105) AND (obj1 = 73582)) + Total runtime: 0.215 ms +(7 rows) + +This is an Opteron (in 32-bit mode), though. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Tue Aug 9 01:33:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 844D3528DB + for ; + Tue, 9 Aug 2005 01:33:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35436-03 + for ; + Tue, 9 Aug 2005 04:33:18 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A9624528C1 + for ; + Tue, 9 Aug 2005 01:33:17 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 058DC30959; Tue, 9 Aug 2005 06:42:52 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: QRY seems not using indexes +Date: Tue, 9 Aug 2005 12:30:41 +0800 +Organization: Hub.Org Networking Services +Lines: 25 +Message-ID: +References: <1123071402.641229.314250@g43g2000cwa.googlegroups.com> +Reply-To: "Qingqing Zhou" +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.184 tagged_above=0 required=5 tests=AWL, + PRIORITY_NO_NAME +X-Spam-Level: * +X-Archive-Number: 200508/73 +X-Sequence-Number: 13820 + + + writes +> +> +> so, if I do a qry like "EXPLAIN ANALYZE select * from pridecdr where +> idsede=8977758488" it tooks a lot of time before i get back any result: +> +> Index Scan using prd_id_sede on pridecdr (cost=0.00..699079.90 +> rows=181850 width=138) (actual time=51.241..483068.255 rows=150511 +> loops=1) +> Index Cond: (idsede = 8977758488::bigint) +> Total runtime: 483355.325 ms +> + +The query plan looks ok. Try to do EXPLAIN ANALYZE twice and see if there is +any difference. This could reduce the IO time to read your index/data since +you got enough RAM. + +Also, if you haven't done VACUUM FULL for a long time, do so and compare the +difference. + +Regards, +Qingqing + + + +From pgsql-performance-owner@postgresql.org Tue Aug 9 02:05:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A016252930 + for ; + Tue, 9 Aug 2005 02:05:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33565-06 + for ; + Tue, 9 Aug 2005 05:05:44 +0000 (GMT) +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EACC52928 + for ; + Tue, 9 Aug 2005 02:05:43 -0300 (ADT) +Received: from smtp-3.paradise.net.nz (smtp-3a.paradise.net.nz [202.0.32.196]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0IKX00NR7VHI1I@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Tue, 09 Aug 2005 17:05:42 +1200 (NZST) +Received: from [192.168.1.11] (218-101-13-165.paradise.net.nz + [218.101.13.165]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id F35C5AE067; Tue, + 09 Aug 2005 17:05:41 +1200 (NZST) +Date: Tue, 09 Aug 2005 17:05:39 +1200 +From: Mark Kirkwood +Subject: Re: QRY seems not using indexes +In-reply-to: +To: morandell@gmail.com +Cc: Qingqing Zhou , + pgsql-performance@postgresql.org +Message-id: <42F839A3.2080501@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) +References: <1123071402.641229.314250@g43g2000cwa.googlegroups.com> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.152 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/74 +X-Sequence-Number: 13821 + +Qingqing Zhou wrote: +> writes +> +>> +>>so, if I do a qry like "EXPLAIN ANALYZE select * from pridecdr where +>>idsede=8977758488" it tooks a lot of time before i get back any result: +>> +>>Index Scan using prd_id_sede on pridecdr (cost=0.00..699079.90 +>>rows=181850 width=138) (actual time=51.241..483068.255 rows=150511 +>>loops=1) +>> Index Cond: (idsede = 8977758488::bigint) +>> Total runtime: 483355.325 ms +>> +> +> +> The query plan looks ok. Try to do EXPLAIN ANALYZE twice and see if there is +> any difference. This could reduce the IO time to read your index/data since +> you got enough RAM. +> +> Also, if you haven't done VACUUM FULL for a long time, do so and compare the +> difference. +> + +Could also be libpq buffering all 150000 rows before showing any. + +It might be worthwhile using a CURSOR and doing 1 FETCH. If that is +quick, then buffering is probably the issue. BTW - do you really want +all the rows? + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Tue Aug 9 02:12:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 99F9F528DB + for ; + Tue, 9 Aug 2005 02:12:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47510-10 + for ; + Tue, 9 Aug 2005 05:12:01 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 4249B5287F + for ; + Tue, 9 Aug 2005 02:12:00 -0300 (ADT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j795Bnnh044438 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Mon, 8 Aug 2005 23:11:52 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j795Bn6k085523; + Mon, 8 Aug 2005 23:11:49 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j795Bmmj085522; + Mon, 8 Aug 2005 23:11:48 -0600 (MDT) (envelope-from mfuhr) +Date: Mon, 8 Aug 2005 23:11:48 -0600 +From: Michael Fuhr +To: Tom Lane +Cc: Rhett Garber , + =?iso-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +Subject: Re: Why hash join instead of nested loop? +Message-ID: <20050809051148.GA85494@winnie.fuhr.org> +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <10930.1123549106@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/75 +X-Sequence-Number: 13822 + +On Mon, Aug 08, 2005 at 08:58:26PM -0400, Tom Lane wrote: +> I'd be interested to see results from other people using 7.4.* too. + +I just built 7.4.1 on FreeBSD 4.11-STABLE and ran your test: + +test=# explain analyze select rtmessagestate.* from rtmessagestate,connection where (connection_registry_id = 40105) AND (obj1 = 73582) and id = obj2; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=4.83..5.91 rows=1 width=14) (actual time=0.220..0.264 rows=1 loops=1) + Hash Cond: ("outer".id = "inner".obj2) + -> Seq Scan on rtmessagestate (cost=0.00..1.05 rows=5 width=14) (actual time=0.015..0.050 rows=5 loops=1) + -> Hash (cost=4.83..4.83 rows=1 width=4) (actual time=0.103..0.103 rows=0 loops=1) + -> Index Scan using connection_regid_obj1_index on connection (cost=0.00..4.83 rows=1 width=4) (actual time=0.070..0.081 rows=1 loops=1) + Index Cond: ((connection_registry_id = 40105) AND (obj1 = 73582)) + Total runtime: 0.495 ms +(7 rows) + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Tue Aug 9 09:16:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A09852A55 + for ; + Tue, 9 Aug 2005 09:16:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47906-04 + for ; + Tue, 9 Aug 2005 12:15:56 +0000 (GMT) +Received: from mailhost.intellivid.com (mailhost.intellivid.com + [64.32.200.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 32B3252A03 + for ; + Tue, 9 Aug 2005 09:15:53 -0300 (ADT) +Received: from [192.168.2.68] (spectre.intellivid.com [192.168.2.68]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by newmail.intellivid.com (Postfix) with ESMTP id 9F268F182AE; + Tue, 9 Aug 2005 08:15:56 -0400 (EDT) +Subject: Re: Why hash join instead of nested loop? +From: Ian Westmacott +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <10930.1123549106@sss.pgh.pa.us> +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Intellivid Corp. +Message-Id: <1123589756.15206.4.camel@spectre.intellivid.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 09 Aug 2005 08:15:56 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/76 +X-Sequence-Number: 13823 + +On Mon, 2005-08-08 at 20:58, Tom Lane wrote: +> I'd be interested to see results from other people using 7.4.* too. + +7.4.8: + +QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=4.83..5.91 rows=1 width=14) (actual time=0.122..0.126 +rows=1 loops=1) + Hash Cond: ("outer".id = "inner".obj2) + -> Seq Scan on rtmessagestate (cost=0.00..1.05 rows=5 width=14) +(actual time=0.003..0.006 rows=5 loops=1) + -> Hash (cost=4.83..4.83 rows=1 width=4) (actual time=0.021..0.021 +rows=0 loops=1) + -> Index Scan using connection_regid_obj1_index on connection +(cost=0.00..4.83 rows=1 width=4) (actual time=0.013..0.015 rows=1 +loops=1) + Index Cond: ((connection_registry_id = 40105) AND (obj1 = +73582)) + Total runtime: 0.198 ms + +7.4.2: + + +QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=4.83..5.91 rows=1 width=14) (actual time=0.577..0.600 +rows=1 loops=1) + Hash Cond: ("outer".id = "inner".obj2) + -> Seq Scan on rtmessagestate (cost=0.00..1.05 rows=5 width=14) +(actual time=0.006..0.023 rows=5 loops=1) + -> Hash (cost=4.83..4.83 rows=1 width=4) (actual time=0.032..0.032 +rows=0 loops=1) + -> Index Scan using connection_regid_obj1_index on connection +(cost=0.00..4.83 rows=1 width=4) (actual time=0.016..0.020 rows=1 +loops=1) + Index Cond: ((connection_registry_id = 40105) AND (obj1 = +73582)) + Total runtime: 0.697 ms + + + --Ian + + + +From pgsql-performance-owner@postgresql.org Tue Aug 9 11:36:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DEE752AE5 + for ; + Tue, 9 Aug 2005 11:33:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56198-06 + for ; + Tue, 9 Aug 2005 14:33:33 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 6923552A36 + for ; + Tue, 9 Aug 2005 11:33:32 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j79EXbji015882; + Tue, 9 Aug 2005 10:33:37 -0400 (EDT) +To: Ian Westmacott +Cc: pgsql-performance@postgresql.org +Subject: Re: Why hash join instead of nested loop? +In-reply-to: <1123589756.15206.4.camel@spectre.intellivid.com> +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> + <1123589756.15206.4.camel@spectre.intellivid.com> +Comments: In-reply-to Ian Westmacott + message dated "Tue, 09 Aug 2005 08:15:56 -0400" +Date: Tue, 09 Aug 2005 10:33:37 -0400 +Message-ID: <15881.1123598017@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/77 +X-Sequence-Number: 13824 + +Ian Westmacott writes: +> On Mon, 2005-08-08 at 20:58, Tom Lane wrote: +>> I'd be interested to see results from other people using 7.4.* too. + +> 7.4.8: +> Total runtime: 0.198 ms + +> 7.4.2: +> Total runtime: 0.697 ms + +Just to be clear: those are two different machines of different speeds, +right? I don't believe we put any factor-of-three speedups into 7.4.* +after release ;-) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 9 11:50:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 084F352806 + for ; + Tue, 9 Aug 2005 11:43:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97420-01 + for ; + Tue, 9 Aug 2005 14:43:30 +0000 (GMT) +Received: from mailhost.intellivid.com (mailhost.intellivid.com + [64.32.200.11]) + by svr1.postgresql.org (Postfix) with ESMTP id CAD3A5293D + for ; + Tue, 9 Aug 2005 11:43:28 -0300 (ADT) +Received: from [192.168.2.68] (spectre.intellivid.com [192.168.2.68]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by newmail.intellivid.com (Postfix) with ESMTP id BD829F182AF; + Tue, 9 Aug 2005 10:43:33 -0400 (EDT) +Subject: Re: Why hash join instead of nested loop? +From: Ian Westmacott +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <15881.1123598017@sss.pgh.pa.us> +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> + <1123589756.15206.4.camel@spectre.intellivid.com> + <15881.1123598017@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Intellivid Corp. +Message-Id: <1123598613.15206.17.camel@spectre.intellivid.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 09 Aug 2005 10:43:33 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/78 +X-Sequence-Number: 13825 + +Yes, sorry, two totally different machines. The 7.4.8 +run was on a dual P4 3.2GHz, and the 7.4.2 run was on +a dual hyperthreaded Xeon 2.4GHz. + + --Ian + + +On Tue, 2005-08-09 at 10:33, Tom Lane wrote: +> Ian Westmacott writes: +> > On Mon, 2005-08-08 at 20:58, Tom Lane wrote: +> >> I'd be interested to see results from other people using 7.4.* too. +> +> > 7.4.8: +> > Total runtime: 0.198 ms +> +> > 7.4.2: +> > Total runtime: 0.697 ms +> +> Just to be clear: those are two different machines of different speeds, +> right? I don't believe we put any factor-of-three speedups into 7.4.* +> after release ;-) +> +> regards, tom lane + + +From pgsql-performance-owner@postgresql.org Tue Aug 9 13:51:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 46BFF5291F + for ; + Tue, 9 Aug 2005 13:51:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42188-07 + for ; + Tue, 9 Aug 2005 16:51:52 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.202]) + by svr1.postgresql.org (Postfix) with ESMTP id C217A5288D + for ; + Tue, 9 Aug 2005 13:51:51 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 36so1239423wra + for ; + Tue, 09 Aug 2005 09:51:51 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=LzdUZh81WS8v66j92VyOpvduWrFrPEQRslzeS0eBEktjBUyupTqqXFrEemd0HD0chD7pNJPWIgSmaQOGiyHLSsC2gf4zP1PJIe9nDCG6CAuEBTDKjh3PwVfU4hCjjX0vxbu8gHUkQFfWnWxwjCxEG0nqJ1A5smamKzp06EAqYqs= +Received: by 10.54.14.29 with SMTP id 29mr687768wrn; + Tue, 09 Aug 2005 09:51:51 -0700 (PDT) +Received: by 10.54.119.7 with HTTP; Tue, 9 Aug 2005 09:51:51 -0700 (PDT) +Message-ID: <41b0fe890508090951546156f7@mail.gmail.com> +Date: Tue, 9 Aug 2005 09:51:51 -0700 +From: Rhett Garber +Reply-To: Rhett Garber +To: Tom Lane +Subject: Re: Why hash join instead of nested loop? +Cc: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +In-Reply-To: <10930.1123549106@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/79 +X-Sequence-Number: 13826 + +Duplicated your setup in a separate DB. + +At least its reproducable for me..... + +I tested this on a Xeon 2 Ghz, 1 Gig Ram. Its running on some shared +storage array that I'm not sure the details of. + +My production example also shows up on our production machine that is +almost the same hardware but has dual zeon and 6 gigs of ram. + +Rhett + +Hash Join (cost=3D4.83..5.91 rows=3D1 width=3D14) (actual time=3D7.148..7.= +159 +rows=3D1 loops=3D1) + Hash Cond: ("outer".id =3D "inner".obj2) + -> Seq Scan on rtmessagestate (cost=3D0.00..1.05 rows=3D5 width=3D14) +(actual time=3D0.007..0.015 rows=3D5 loops=3D1) + -> Hash (cost=3D4.83..4.83 rows=3D1 width=3D4) (actual +time=3D0.055..0.055 rows=3D0 loops=3D1) + -> Index Scan using connection_regid_obj1_index on +connection (cost=3D0.00..4.83 rows=3D1 width=3D4) (actual time=3D0.028..0.= +032 +rows=3D1 loops=3D1) + Index Cond: ((connection_registry_id =3D 40105) AND (obj1 +=3D 73582)) Total runtime: 7.693 ms +(7 rows) + + +On 8/8/05, Tom Lane wrote: +> Rhett Garber writes: +> > This is postgres 7.4.1 +> > All the rows involved are integers. +>=20 +> Hmph. There is something really strange going on here. I tried to +> duplicate your problem in 7.4.*, thus: +>=20 +> regression=3D# create table rtmessagestate(id int, f1 char(6)); +> CREATE TABLE +> regression=3D# insert into rtmessagestate values(1,'z'); +> INSERT 559399 1 +> regression=3D# insert into rtmessagestate values(2,'z'); +> INSERT 559400 1 +> regression=3D# insert into rtmessagestate values(3,'z'); +> INSERT 559401 1 +> regression=3D# insert into rtmessagestate values(4,'z'); +> INSERT 559402 1 +> regression=3D# insert into rtmessagestate values(5,'z'); +> INSERT 559403 1 +> regression=3D# vacuum analyze rtmessagestate; +> VACUUM +> regression=3D# create table connection(connection_registry_id int, obj1 i= +nt, obj2 int); +> CREATE TABLE +> regression=3D# create index connection_regid_obj1_index on connection(con= +nection_registry_id,obj1); +> CREATE INDEX +> regression=3D# insert into connection values(40105,73582,3); +> INSERT 559407 1 +> regression=3D# explain analyze select rtmessagestate.* from rtmessagestat= +e,connection where (connection_registry_id =3D 40105) AND (obj1 =3D 73582= +) and id =3D obj2; +> QUER= +Y PLAN +> -------------------------------------------------------------------------= +--------------------------------------------------------------------------- +> Hash Join (cost=3D4.83..5.91 rows=3D1 width=3D14) (actual time=3D0.498.= +.0.544 rows=3D1 loops=3D1) +> Hash Cond: ("outer".id =3D "inner".obj2) +> -> Seq Scan on rtmessagestate (cost=3D0.00..1.05 rows=3D5 width=3D14= +) (actual time=3D0.030..0.072 rows=3D5 loops=3D1) +> -> Hash (cost=3D4.83..4.83 rows=3D1 width=3D4) (actual time=3D0.305.= +.0.305 rows=3D0 loops=3D1) +> -> Index Scan using connection_regid_obj1_index on connection = +(cost=3D0.00..4.83 rows=3D1 width=3D4) (actual time=3D0.236..0.264 rows=3D1= + loops=3D1) +> Index Cond: ((connection_registry_id =3D 40105) AND (obj1 = +=3D 73582)) +> Total runtime: 1.119 ms +> (7 rows) +>=20 +> This duplicates your example as to plan and row counts: +>=20 +> > Hash Join (cost=3D5.96..7.04 rows=3D1 width=3D14) (actual +> > time=3D10.591..10.609 rows=3D1 loops=3D1) +> > Hash Cond: ("outer".id =3D "inner".obj2) +> > -> Seq Scan on rtmessagestate (cost=3D0.00..1.05 rows=3D5 width=3D14) +> > (actual time=3D0.011..0.022 rows=3D5 loops=3D1) +> > -> Hash (cost=3D5.96..5.96 rows=3D1 width=3D4) (actual +> > time=3D0.109..0.109 rows=3D0 loops=3D1) +> > -> Index Scan using connection_regid_obj1_index on +> > connection (cost=3D0.00..5.96 rows=3D1 width=3D4) (actual time=3D0.070= +..0.076 +> > rows=3D1 loops=3D1) +> > Index Cond: ((connection_registry_id =3D 40105) AND (obj1 +> > =3D 73582)) Total runtime: 11.536 ms +> > (7 rows) +>=20 +> My machine is considerably slower than yours, to judge by the actual +> elapsed times in the scan nodes ... so why is it beating the pants +> off yours in the join step? +>=20 +> Can you try the above script verbatim in a scratch database and see +> what you get? (Note it's worth trying the explain two or three +> times to be sure the values have settled out.) +>=20 +> I'm testing a fairly recent 7.4-branch build (7.4.8 plus), so that's one +> possible reason for the discrepancy between my results and yours, but I +> do not see anything in the 7.4 CVS logs that looks like it's related to +> hashjoin performance. +>=20 +> I'd be interested to see results from other people using 7.4.* too. +>=20 +> regards, tom lane +> + +From pgsql-performance-owner@postgresql.org Tue Aug 9 14:13:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D686E528BE + for ; + Tue, 9 Aug 2005 14:13:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19226-09 + for ; + Tue, 9 Aug 2005 17:13:09 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CA9C52A28 + for ; + Tue, 9 Aug 2005 14:13:06 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j79HCx8M017254; + Tue, 9 Aug 2005 13:13:00 -0400 (EDT) +To: Rhett Garber +Cc: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +Subject: Re: Why hash join instead of nested loop? +In-reply-to: <41b0fe890508090951546156f7@mail.gmail.com> +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> + <41b0fe890508090951546156f7@mail.gmail.com> +Comments: In-reply-to Rhett Garber + message dated "Tue, 09 Aug 2005 09:51:51 -0700" +Date: Tue, 09 Aug 2005 13:12:59 -0400 +Message-ID: <17253.1123607579@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/80 +X-Sequence-Number: 13827 + +Rhett Garber writes: +> Duplicated your setup in a separate DB. +> At least its reproducable for me..... + +Hmm. Well, we now have several data points but they seem to be on +wildly varying hardware. To try to normalize the results a little, +I computed the total actual time for the hash plan divided by the sum +of the actual times for the two scan nodes. Thus, for your example: + +> Hash Join (cost=4.83..5.91 rows=1 width=14) (actual time=7.148..7.159 +> rows=1 loops=1) +> Hash Cond: ("outer".id = "inner".obj2) +> -> Seq Scan on rtmessagestate (cost=0.00..1.05 rows=5 width=14) +> (actual time=0.007..0.015 rows=5 loops=1) +> -> Hash (cost=4.83..4.83 rows=1 width=4) (actual +> time=0.055..0.055 rows=0 loops=1) +> -> Index Scan using connection_regid_obj1_index on +> connection (cost=0.00..4.83 rows=1 width=4) (actual time=0.028..0.032 +> rows=1 loops=1) +> Index Cond: ((connection_registry_id = 40105) AND (obj1 +> = 73582)) Total runtime: 7.693 ms +> (7 rows) + +this would be 7.159 / (0.015 + 0.032). This is probably not an +enormously robust statistic but it at least focuses attention in the +right place. Here's what I get (rounded off to 4 digits which is surely +as much precision as we have in the numbers): + + Tom 7.4.8+ 1.619 + Ian 7.4.8 6.000 + Ian 7.4.2 13.95 + Steinar 7.4.7 8.833 + Rhett orig 108.3 + Rhett test 152.3 + Michael 7.4.1 2.015 + +My number seems to be a bit of an outlier to the low side, but yours are +way the heck to the high side. And Michael's test seems to rule out the +idea that it's something broken in 7.4.1 in particular. + +I'm now thinking you've got either a platform- or compiler-specific +problem. Exactly what is the hardware (the CPU not the disks)? How did +you build or come by the Postgres executables (compiler, configure +options, etc)? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 9 15:02:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B8DF529C0 + for ; + Tue, 9 Aug 2005 15:02:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77055-05 + for ; + Tue, 9 Aug 2005 18:01:59 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 28BC9529AD + for ; + Tue, 9 Aug 2005 15:01:53 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id E0AD7644111 + for ; + Tue, 9 Aug 2005 12:01:22 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 01641-01 for ; + Tue, 9 Aug 2005 12:01:20 -0600 (MDT) +Received: from [192.168.1.12] (c-24-9-24-35.hsd1.co.comcast.net [24.9.24.35]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id 490A564410F + for ; + Tue, 9 Aug 2005 12:01:19 -0600 (MDT) +Mime-Version: 1.0 (Apple Message framework v730) +Content-Transfer-Encoding: 7bit +Message-Id: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Dan Harris +Subject: Table locking problems? +Date: Tue, 9 Aug 2005 12:04:11 -0600 +X-Mailer: Apple Mail (2.730) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/81 +X-Sequence-Number: 13828 + +I thought I would send this to pg-performance since so many people +helped me with my speed issues recently. I was definitely IO- +bottlenecked. + +Since then, I have installed 2 RAID arrays with 7 15k drives in them +in RAID 0+1 as well as add a new controller card with 512MB of cache +on it. I also created this new partition on the RAID as XFS instead +of ext3. + +These changes have definitely improved performance, but I am now +finding some trouble with UPDATE or DELETE queries "hanging" and +never releasing their locks. As this happens, other statements queue +up behind it. It seems to occur at times of very high loads on the +box. Is my only option to kill the query ( which usually takes down +the whole postmaster with it! ouch ). + +Could these locking issues be related to the other changes I made? +I'm really scared that this is related to choosing XFS, but I sure +hope not. How should I go about troubleshooting the "problem" +queries? They don't seem to be specific to a single table or single +database. + +I'm running 8.0.1 on kernel 2.6.12-3 on 64-bit Opterons if that +matters.. + + +-Dan + +From pgsql-performance-owner@postgresql.org Tue Aug 9 15:10:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 73AF1529A5 + for ; + Tue, 9 Aug 2005 15:10:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87007-09 + for ; + Tue, 9 Aug 2005 18:10:36 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 52749528E1 + for ; + Tue, 9 Aug 2005 15:10:33 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i8so1269794wra + for ; + Tue, 09 Aug 2005 11:10:34 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=kkJWikFPbgJsk4oitvXDz3LOhmdQ1eSfhBQpUZDRFDst6oFUIFAz2caMk1NUTpe5PcHHbo1EfuQsCKt0p4/vH8UN+5bkWXAJIVzDWVEYehAvPeJJoNBGbNWkmU1FOigNNE0JY/XO+bgQqq7b6Wugq8PCNIgk+Vm8StLo3/nhF10= +Received: by 10.54.57.44 with SMTP id f44mr5757960wra; + Tue, 09 Aug 2005 11:10:34 -0700 (PDT) +Received: by 10.54.119.7 with HTTP; Tue, 9 Aug 2005 11:10:33 -0700 (PDT) +Message-ID: <41b0fe89050809111027e1d274@mail.gmail.com> +Date: Tue, 9 Aug 2005 11:10:33 -0700 +From: Rhett Garber +To: Tom Lane +Subject: Re: Why hash join instead of nested loop? +Cc: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +In-Reply-To: <17253.1123607579@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> + <41b0fe890508090951546156f7@mail.gmail.com> + <17253.1123607579@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/82 +X-Sequence-Number: 13829 + +> I'm now thinking you've got either a platform- or compiler-specific +> problem. Exactly what is the hardware (the CPU not the disks)? How did +> you build or come by the Postgres executables (compiler, configure +> options, etc)? + +I've tried it on two of our machines, both HP Proliant DL580: +Production: Intel(R) Xeon(TM) MP CPU 2.80GHz (I think there are 2 +physical CPUs with Hyperthreading, shows up as 4) + 6 gigs RAM +Development: Intel(R) XEON(TM) MP CPU 2.00GHz (I have vague +recollection of disabling hyperthreading on this chip because of some +other kernel issue) + 1 gig RAM + +They are both running SuSE 8, 2.4.21-128-smp kernel + +Compile instructions (I didn't do it myself) indicate we built from +source with nothing fancy: + +tar xpvf postgresql-7.4.1.tar.bz2 +cd postgresql-7.4.1 +./configure --prefix=3D/usr/local/postgresql-7.4.1 +make +make install +make install-all-headers + +If i run 'file' on /usr/local/postgresql-7.4.1/bin/postgres : +postgres: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), +dynamically linked (uses shared libs), not stripped + +Thanks for all your help guys, + +Rhett + +From pgsql-performance-owner@postgresql.org Tue Aug 9 15:31:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CA6C6529F1 + for ; + Tue, 9 Aug 2005 15:31:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92321-03 + for ; + Tue, 9 Aug 2005 18:31:34 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F038529D3 + for ; + Tue, 9 Aug 2005 15:31:34 -0300 (ADT) +Received: from [192.168.1.55] (fc1smp [66.93.38.87]) (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + j79IUVsG003359; Tue, 9 Aug 2005 11:30:31 -0700 +Message-ID: <42F8F717.6030106@commandprompt.com> +Date: Tue, 09 Aug 2005 11:33:59 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 1.0.6-1.1.fc4 (X11/20050720) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dan Harris +Cc: pgsql-performance@postgresql.org +Subject: Re: Table locking problems? +References: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> +In-Reply-To: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); + Tue, 09 Aug 2005 11:30:31 -0700 (PDT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/83 +X-Sequence-Number: 13830 + + +> Could these locking issues be related to the other changes I made? I'm +> really scared that this is related to choosing XFS, but I sure hope +> not. How should I go about troubleshooting the "problem" queries? +> They don't seem to be specific to a single table or single database. + +My experience is that when this type of thing happens it is typically +specific queries that cause the problem. If you turn on statement +logging you can get the exact queries and debug from there. + +Here are some things to look for: + +Is it a large table (and thus large indexes) that it is updating? +Is the query using indexes? +Is the query modifying ALOT of rows? + +Of course there is also the RTFM of are you analyzing and vacuuming? + +Sincerely, + +Joshua D. Drake + + +> +> I'm running 8.0.1 on kernel 2.6.12-3 on 64-bit Opterons if that matters.. +> +> +> -Dan +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match + + +-- +Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 +PostgreSQL Replication, Consulting, Custom Programming, 24x7 support +Managed Services, Shared and Dedicated Hosting +Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ + +From pgsql-performance-owner@postgresql.org Tue Aug 9 15:38:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CDC07529D2 + for ; + Tue, 9 Aug 2005 15:37:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54683-10 + for ; + Tue, 9 Aug 2005 18:37:30 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D981529D3 + for ; + Tue, 9 Aug 2005 15:37:29 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j79IbIfY017826; + Tue, 9 Aug 2005 14:37:18 -0400 (EDT) +To: Rhett Garber +Cc: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +Subject: Re: Why hash join instead of nested loop? +In-reply-to: <41b0fe89050809111027e1d274@mail.gmail.com> +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> + <41b0fe890508090951546156f7@mail.gmail.com> + <17253.1123607579@sss.pgh.pa.us> + <41b0fe89050809111027e1d274@mail.gmail.com> +Comments: In-reply-to Rhett Garber + message dated "Tue, 09 Aug 2005 11:10:33 -0700" +Date: Tue, 09 Aug 2005 14:37:18 -0400 +Message-ID: <17825.1123612638@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/84 +X-Sequence-Number: 13831 + +Rhett Garber writes: +> They are both running SuSE 8, 2.4.21-128-smp kernel + +> Compile instructions (I didn't do it myself) indicate we built from +> source with nothing fancy: + +You could double-check the configure options by running pg_config. +But probably the more interesting question is whether any nondefault +CFLAGS were used, and I don't think pg_config records that. +(Hmm, maybe it should.) + +In any case, there's no smoking gun there. I'm now wondering if maybe +there's something unusual about your runtime parameters. AFAIR you +didn't show us your postgresql.conf settings --- could we see any +nondefault entries there? + +(I looked quickly at the 7.4 hashjoin code, and I see that it uses a +hash table sized according to sort_mem even when the input is predicted +to be very small ... so an enormous sort_mem setting would account for +some plan startup overhead to initialize the table ...) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 9 15:52:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0072452A1D + for ; + Tue, 9 Aug 2005 15:51:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41563-05 + for ; + Tue, 9 Aug 2005 18:51:30 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 555BB52A00 + for ; + Tue, 9 Aug 2005 15:51:29 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 36so1268216wra + for ; + Tue, 09 Aug 2005 11:51:30 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=LVKv668pQGd+/jUq04gr5fEGOXlx0XbtQMIDOYY5tC7UswOxcAm9jbcTHKLYN1vluLDDVEKXuRMtAPYXl9dfIgje2IlLCCviVSL9Xs/ueIl3GjnS87HPHMUJjvV/gDK/YUbiCQFA4shLIDQbypWSiH62r/2ifixjnFYuUS/6Lyg= +Received: by 10.54.56.24 with SMTP id e24mr2871416wra; + Tue, 09 Aug 2005 11:51:30 -0700 (PDT) +Received: by 10.54.119.7 with HTTP; Tue, 9 Aug 2005 11:51:30 -0700 (PDT) +Message-ID: <41b0fe89050809115174ae1669@mail.gmail.com> +Date: Tue, 9 Aug 2005 11:51:30 -0700 +From: Rhett Garber +To: Tom Lane +Subject: Re: Why hash join instead of nested loop? +Cc: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +In-Reply-To: <17825.1123612638@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> + <41b0fe890508090951546156f7@mail.gmail.com> + <17253.1123607579@sss.pgh.pa.us> + <41b0fe89050809111027e1d274@mail.gmail.com> + <17825.1123612638@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/85 +X-Sequence-Number: 13832 + +Well that could be an issue, is this abnormally large: + +#shared_buffers =3D 1536 # min 16, at least max_connections*2, 8KB= + each +shared_buffers =3D 206440 +#sort_mem =3D 131072 # min 64, size in KB +sort_mem =3D 524288 # min 64, size in KB +vacuum_mem =3D 131072 # min 1024, size in K + +I actually had a lot of trouble finding example values for these... no +one wants to give real numbers in any postgres performance tuning +articles I saw. What would be appropriate for machines with 1 or 6 +gigs of RAM and wanting to maximize performance. + +Rhett + +On 8/9/05, Tom Lane wrote: +> Rhett Garber writes: +> > They are both running SuSE 8, 2.4.21-128-smp kernel +>=20 +> > Compile instructions (I didn't do it myself) indicate we built from +> > source with nothing fancy: +>=20 +> You could double-check the configure options by running pg_config. +> But probably the more interesting question is whether any nondefault +> CFLAGS were used, and I don't think pg_config records that. +> (Hmm, maybe it should.) +>=20 +> In any case, there's no smoking gun there. I'm now wondering if maybe +> there's something unusual about your runtime parameters. AFAIR you +> didn't show us your postgresql.conf settings --- could we see any +> nondefault entries there? +>=20 +> (I looked quickly at the 7.4 hashjoin code, and I see that it uses a +> hash table sized according to sort_mem even when the input is predicted +> to be very small ... so an enormous sort_mem setting would account for +> some plan startup overhead to initialize the table ...) +>=20 +> regards, tom lane +> + +From pgsql-performance-owner@postgresql.org Tue Aug 9 15:54:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6FE26529F1 + for ; + Tue, 9 Aug 2005 15:52:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12400-04 + for ; + Tue, 9 Aug 2005 18:52:12 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id CE5DB52A1D + for ; + Tue, 9 Aug 2005 15:52:08 -0300 (ADT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j79Iq1sJ045377 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Tue, 9 Aug 2005 12:52:03 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j79Iq1iZ025404; + Tue, 9 Aug 2005 12:52:01 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j79Iq1cN025403; + Tue, 9 Aug 2005 12:52:01 -0600 (MDT) (envelope-from mfuhr) +Date: Tue, 9 Aug 2005 12:52:01 -0600 +From: Michael Fuhr +To: Dan Harris +Cc: pgsql-performance@postgresql.org +Subject: Re: Table locking problems? +Message-ID: <20050809185201.GA25325@winnie.fuhr.org> +References: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/86 +X-Sequence-Number: 13833 + +On Tue, Aug 09, 2005 at 12:04:11PM -0600, Dan Harris wrote: +> These changes have definitely improved performance, but I am now +> finding some trouble with UPDATE or DELETE queries "hanging" and +> never releasing their locks. As this happens, other statements queue +> up behind it. + +Have you examined pg_locks to see if the UPDATE or DELETE is blocked +because of a lock another session holds? + +Are you using foreign keys? When updating referencing rows, released +versions of PostgreSQL acquire a lock on the referenced row that can +hurt concurrency or cause deadlock (this will be improved in 8.1). + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Tue Aug 9 16:02:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 844AC5288C + for ; + Tue, 9 Aug 2005 16:01:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73615-02 + for ; + Tue, 9 Aug 2005 19:01:12 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 81F6C5289C + for ; + Tue, 9 Aug 2005 16:01:10 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j79J0xm1018144; + Tue, 9 Aug 2005 15:00:59 -0400 (EDT) +To: Rhett Garber +Cc: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +Subject: Re: Why hash join instead of nested loop? +In-reply-to: <41b0fe89050809115174ae1669@mail.gmail.com> +References: <41b0fe890508051135712a086b@mail.gmail.com> + <001801c59a0a$f4be7480$9a00a8c0@OTTO> + <41b0fe8905080516164464e04f@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> + <41b0fe890508090951546156f7@mail.gmail.com> + <17253.1123607579@sss.pgh.pa.us> + <41b0fe89050809111027e1d274@mail.gmail.com> + <17825.1123612638@sss.pgh.pa.us> + <41b0fe89050809115174ae1669@mail.gmail.com> +Comments: In-reply-to Rhett Garber + message dated "Tue, 09 Aug 2005 11:51:30 -0700" +Date: Tue, 09 Aug 2005 15:00:59 -0400 +Message-ID: <18143.1123614059@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/87 +X-Sequence-Number: 13834 + +Rhett Garber writes: +> Well that could be an issue, is this abnormally large: +> #shared_buffers = 1536 # min 16, at least max_connections*2, 8KB each +> shared_buffers = 206440 +> #sort_mem = 131072 # min 64, size in KB +> sort_mem = 524288 # min 64, size in KB +> vacuum_mem = 131072 # min 1024, size in K + +The vacuum_mem number is OK I think, but both of the others seem +unreasonably large. Conventional wisdom about shared_buffers is that +the sweet spot is maybe 10000 or so buffers, rarely more than 50000. +(Particularly in pre-8.0 releases, there are code paths that grovel +through all the buffers linearly, so there is a significant cost to +making it too large.) Don't worry about it being too small to make +effective use of RAM --- we rely on the kernel's disk cache to do that. + +sort_mem is *per sort*, and so half a gig in a machine with only a +couple of gig is far too much except when you know you have only one +query running. A couple dozen backends each trying to use half a gig +will drive you into the ground in no time. Conventional wisdom here +is that the global setting should be conservatively small (perhaps +10Mb to 100Mb depending on how many concurrent backends you expect to +have), and then you can explicitly increase it locally with SET for +specific queries that need it. + +In terms of the problem at hand, try the test case with a few different +values of sort_mem (use SET to adjust it, you don't need to touch the +config file) and see what happens. I think the cost you're seeing is +just startup overhead to zero a hash table of a few hundred meg ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 9 16:38:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3DC095289C + for ; + Tue, 9 Aug 2005 16:08:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90449-02 + for ; + Tue, 9 Aug 2005 19:08:10 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A84252808 + for ; + Tue, 9 Aug 2005 16:08:07 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j79J867x018200; + Tue, 9 Aug 2005 15:08:06 -0400 (EDT) +To: "Joshua D. Drake" +Cc: Dan Harris , + pgsql-performance@postgresql.org +Subject: Re: Table locking problems? +In-reply-to: <42F8F717.6030106@commandprompt.com> +References: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> + <42F8F717.6030106@commandprompt.com> +Comments: In-reply-to "Joshua D. Drake" + message dated "Tue, 09 Aug 2005 11:33:59 -0700" +Date: Tue, 09 Aug 2005 15:08:06 -0400 +Message-ID: <18199.1123614486@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/90 +X-Sequence-Number: 13837 + +"Joshua D. Drake" writes: +> My experience is that when this type of thing happens it is typically +> specific queries that cause the problem. If you turn on statement +> logging you can get the exact queries and debug from there. + +> Here are some things to look for: + +> Is it a large table (and thus large indexes) that it is updating? +> Is the query using indexes? +> Is the query modifying ALOT of rows? + +Another thing to look at is foreign keys. Dan could be running into +problems with an update on one side of an FK being blocked by locks +on the associated rows on the other side. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 9 16:13:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 287B152AB6 + for ; + Tue, 9 Aug 2005 16:12:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74717-05 + for ; + Tue, 9 Aug 2005 19:11:52 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F9A052A7E + for ; + Tue, 9 Aug 2005 16:11:51 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i8so1284116wra + for ; + Tue, 09 Aug 2005 12:11:52 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=Bkc/M3YoCnjghDEkWifAhSya5hVGOHITTWmasJCoHlaNHUmlsLXSdcmLMb+mYCLcA5SqiTMdDZ6Prt3Y96487+sID5S5zn0N4oLjuWoi1RxYOjiFX1hbOYDy2GdOpNXw+4/aR/8PhnLsoE41g3pxkh2YoxLD4BZ+BXizP29goiE= +Received: by 10.54.53.62 with SMTP id b62mr5765154wra; + Tue, 09 Aug 2005 12:11:52 -0700 (PDT) +Received: by 10.54.119.7 with HTTP; Tue, 9 Aug 2005 12:11:52 -0700 (PDT) +Message-ID: <41b0fe8905080912113f381f84@mail.gmail.com> +Date: Tue, 9 Aug 2005 12:11:52 -0700 +From: Rhett Garber +To: Tom Lane +Subject: Re: Why hash join instead of nested loop? +Cc: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= , + pgsql-performance@postgresql.org +In-Reply-To: <18143.1123614059@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <41b0fe890508051135712a086b@mail.gmail.com> + <15425.1123304631@sss.pgh.pa.us> + <41b0fe89050808100021a2a4fc@mail.gmail.com> + <10930.1123549106@sss.pgh.pa.us> + <41b0fe890508090951546156f7@mail.gmail.com> + <17253.1123607579@sss.pgh.pa.us> + <41b0fe89050809111027e1d274@mail.gmail.com> + <17825.1123612638@sss.pgh.pa.us> + <41b0fe89050809115174ae1669@mail.gmail.com> + <18143.1123614059@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200508/88 +X-Sequence-Number: 13835 + +Bingo, the smaller the sort_mem, the faster that query is. + +Thanks a lot to everybody that helped, i'll tweak with these values +more when I get a chance now that I have some guidelines that make +sense. + +Rhett + +On 8/9/05, Tom Lane wrote: +> Rhett Garber writes: +> > Well that could be an issue, is this abnormally large: +> > #shared_buffers =3D 1536 # min 16, at least max_connections*2,= + 8KB each +> > shared_buffers =3D 206440 +> > #sort_mem =3D 131072 # min 64, size in KB +> > sort_mem =3D 524288 # min 64, size in KB +> > vacuum_mem =3D 131072 # min 1024, size in K +>=20 +> The vacuum_mem number is OK I think, but both of the others seem +> unreasonably large. Conventional wisdom about shared_buffers is that +> the sweet spot is maybe 10000 or so buffers, rarely more than 50000. +> (Particularly in pre-8.0 releases, there are code paths that grovel +> through all the buffers linearly, so there is a significant cost to +> making it too large.) Don't worry about it being too small to make +> effective use of RAM --- we rely on the kernel's disk cache to do that. +>=20 +> sort_mem is *per sort*, and so half a gig in a machine with only a +> couple of gig is far too much except when you know you have only one +> query running. A couple dozen backends each trying to use half a gig +> will drive you into the ground in no time. Conventional wisdom here +> is that the global setting should be conservatively small (perhaps +> 10Mb to 100Mb depending on how many concurrent backends you expect to +> have), and then you can explicitly increase it locally with SET for +> specific queries that need it. +>=20 +> In terms of the problem at hand, try the test case with a few different +> values of sort_mem (use SET to adjust it, you don't need to touch the +> config file) and see what happens. I think the cost you're seeing is +> just startup overhead to zero a hash table of a few hundred meg ... +>=20 +> regards, tom lane +> + +From pgsql-performance-owner@postgresql.org Tue Aug 9 17:43:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AE53252C68 + for ; + Tue, 9 Aug 2005 17:40:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23695-05 + for ; + Tue, 9 Aug 2005 20:40:34 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 153FD52C66 + for ; + Tue, 9 Aug 2005 17:40:33 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 8A5576440E0 + for ; + Tue, 9 Aug 2005 14:40:04 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 02670-08 for ; + Tue, 9 Aug 2005 14:40:02 -0600 (MDT) +Received: from [192.168.1.12] (c-24-9-24-35.hsd1.co.comcast.net [24.9.24.35]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id 23D5F6440C5 + for ; + Tue, 9 Aug 2005 14:40:02 -0600 (MDT) +Mime-Version: 1.0 (Apple Message framework v730) +In-Reply-To: <18199.1123614486@sss.pgh.pa.us> +References: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> + <42F8F717.6030106@commandprompt.com> + <18199.1123614486@sss.pgh.pa.us> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <36F56B3E-F6FC-491D-A8E2-B4961CC8AC16@drivefaster.net> +Content-Transfer-Encoding: 7bit +From: Dan Harris +Subject: Re: Table locking problems? +Date: Tue, 9 Aug 2005 14:42:57 -0600 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.730) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/91 +X-Sequence-Number: 13838 + + +On Aug 9, 2005, at 1:08 PM, Tom Lane wrote: + +> "Joshua D. Drake" writes: +> +>> My experience is that when this type of thing happens it is typically +>> specific queries that cause the problem. If you turn on statement +>> logging you can get the exact queries and debug from there. +>> +> +> +>> Here are some things to look for: +>> +> +> +>> Is it a large table (and thus large indexes) that it is updating? +>> Is the query using indexes? +>> Is the query modifying ALOT of rows? +>> +> +> Another thing to look at is foreign keys. Dan could be running into +> problems with an update on one side of an FK being blocked by locks +> on the associated rows on the other side. +> +> regards, tom lane +> + +Tom, Steve, Josh: + +Thank you for your ideas. The updates are only on a single table, no +joins. I had stats collection turned off. I have turned that on +again so that I can try and catch one while the problem is +occurring. The last table it did this on was about 3 million +records. 4 single-column indexes on it. + +The problem I had with statement logging is that if the query never +finishes, it doesn't get logged as far as I can tell. So everything +that did get logged was normal and would run with no isses in psql by +copy and pasting it. The rows updated will certainly vary by query. +I really need to "catch it in the act" with stats collection on so I +can get the query from pg_stat_activity. Once I get it, I will play +with explains and see if I can reproduce it outside the wild. + +Thanks again for your help. + +-Dan + + +From pgsql-performance-owner@postgresql.org Tue Aug 9 18:33:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B6BB52B05 + for ; + Tue, 9 Aug 2005 17:49:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40641-03 + for ; + Tue, 9 Aug 2005 20:48:54 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 04EE152A91 + for ; + Tue, 9 Aug 2005 17:48:53 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id C3AF06440E0 + for ; + Tue, 9 Aug 2005 14:48:25 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 02853-01 for ; + Tue, 9 Aug 2005 14:48:23 -0600 (MDT) +Received: from [192.168.1.12] (c-24-9-24-35.hsd1.co.comcast.net [24.9.24.35]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id 77D616440C5 + for ; + Tue, 9 Aug 2005 14:48:23 -0600 (MDT) +Mime-Version: 1.0 (Apple Message framework v730) +In-Reply-To: <1123656547.13362.43.camel@amd64-laptop-spoe> +References: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> + <1123656547.13362.43.camel@amd64-laptop-spoe> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <2764B744-4CDC-4F2C-99C4-2948D37A9D23@drivefaster.net> +Content-Transfer-Encoding: 7bit +From: Dan Harris +Subject: Re: Table locking problems? +Date: Tue, 9 Aug 2005 14:51:18 -0600 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.730) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/92 +X-Sequence-Number: 13839 + + +On Aug 10, 2005, at 12:49 AM, Steve Poe wrote: + +> Dan, +> +> Do you mean you did RAID 1 + 0 (RAID 10) or RAID 0 + 1? Just a +> clarification, since RAID 0 is still a single-point of failure even if +> RAID1 is on top of RAID0. + +Well, you tell me if I stated incorrectly. There are two raid +enclosures with 7 drives in each. Each is on its own bus on a dual- +channel controller. Each box has a stripe across its drives and the +enclosures are mirrors of each other. I understand the controller +could be a single point of failure, but I'm not sure I understand +your concern about the RAID structure itself. + +> +> How many users are connected when your update / delete queries are +> hanging? Have you done an analyze verbose on those queries? + +Most of the traffic is from programs we run to do analysis of the +data and managing changes. At the time I noticed it this morning, +there were 10 connections open to the database. That rarely goes +above 20 concurrent. As I said in my other response, I believe that +the log will only contain the query at the point the query finishes, +so if it never finishes... + +> +> Have you made changes to the postgresql.conf? kernel.vm settings? IO +> scheduler? + +I set shmmax appropriately for my shared_buffers setting, but that's +the only kernel tweak. + +> +> If you're not doing so already, you may consider running sar +> (iostat) to +> monitor when the hanging occurs if their is a memory / IO bottleneck +> somewhere. +> + +I will try that. Thanks + + + +From pgsql-performance-owner@postgresql.org Tue Aug 9 18:52:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D6BB5298E + for ; + Tue, 9 Aug 2005 18:51:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00804-02 + for ; + Tue, 9 Aug 2005 21:51:39 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F18552915 + for ; + Tue, 9 Aug 2005 18:51:33 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050809215131m92009juque>; Tue, 9 Aug 2005 21:51:31 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id C963955FF3; Tue, 9 Aug 2005 16:51:30 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 33E1355FCC; + Tue, 9 Aug 2005 16:51:24 -0500 (CDT) +Message-ID: <42F9255A.4080604@arbash-meinel.com> +Date: Tue, 09 Aug 2005 16:51:22 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dan Harris +Cc: pgsql-performance@postgresql.org +Subject: Re: Table locking problems? +References: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> + <1123656547.13362.43.camel@amd64-laptop-spoe> + <2764B744-4CDC-4F2C-99C4-2948D37A9D23@drivefaster.net> +In-Reply-To: <2764B744-4CDC-4F2C-99C4-2948D37A9D23@drivefaster.net> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig357C927C6DFAE6598CBC821E" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/93 +X-Sequence-Number: 13840 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig357C927C6DFAE6598CBC821E +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Dan Harris wrote: +> +> On Aug 10, 2005, at 12:49 AM, Steve Poe wrote: +> +>> Dan, +>> +>> Do you mean you did RAID 1 + 0 (RAID 10) or RAID 0 + 1? Just a +>> clarification, since RAID 0 is still a single-point of failure even if +>> RAID1 is on top of RAID0. +> +> +> Well, you tell me if I stated incorrectly. There are two raid +> enclosures with 7 drives in each. Each is on its own bus on a dual- +> channel controller. Each box has a stripe across its drives and the +> enclosures are mirrors of each other. I understand the controller +> could be a single point of failure, but I'm not sure I understand your +> concern about the RAID structure itself. + +In this configuration, if you have a drive fail on both controllers, the +entire RAID dies. Lets label them A1-7, B1-7, because you stripe within +a set, if a single one of A dies, and a single one of B dies, you have +lost your entire mirror. + +The correct way of doing it, is to have A1 be a mirror of B1, and then +stripe above that. Since you are using 2 7-disk enclosures, I'm not sure +how you can do it well, since it is not an even number of disks. Though +if you are using software RAID, there should be no problem. + +The difference is that in this scenario, *all* of the A drives can die, +and you haven't lost any data. The only thing you can't lose is a +matched pair (eg losing both A1 and B1 will cause complete data loss) + +I believe the correct notation for this last form is RAID 1 + 0 (RAID10) +since you have a set of RAID1 drives, with a RAID0 on-top of them. + +> +>> +>> How many users are connected when your update / delete queries are +>> hanging? Have you done an analyze verbose on those queries? +> +> +> Most of the traffic is from programs we run to do analysis of the data +> and managing changes. At the time I noticed it this morning, there +> were 10 connections open to the database. That rarely goes above 20 +> concurrent. As I said in my other response, I believe that the log +> will only contain the query at the point the query finishes, so if it +> never finishes... +> +>> +>> Have you made changes to the postgresql.conf? kernel.vm settings? IO +>> scheduler? +> +> +> I set shmmax appropriately for my shared_buffers setting, but that's +> the only kernel tweak. +> +>> +>> If you're not doing so already, you may consider running sar (iostat) to +>> monitor when the hanging occurs if their is a memory / IO bottleneck +>> somewhere. +>> +> +> I will try that. Thanks +> + +When you discover that an update is hanging, can you get into the +database, and see what locks currently exist? (SELECT * FROM pg_locks) + +That might help you figure out what is being locked and possibly +preventing your updates. + +It is also possible that your UPDATE query is trying to do something +funny (someone just recently was talking about an UPDATE that wanted to +do a hash join against 12M rows). Which probably meant that it had to +spill to disk, where a merge join would have worked better. + +John +=:-> + +--------------enig357C927C6DFAE6598CBC821E +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC+SVdJdeBCYSNAAMRAnwXAJ9aAP2hg377LNF0ib8RKKrB1j4anQCghKDG +Pl7DgEKhRiMBh//x4e0gJCA= +=/2aC +-----END PGP SIGNATURE----- + +--------------enig357C927C6DFAE6598CBC821E-- + +From pgsql-performance-owner@postgresql.org Tue Aug 9 19:03:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C0B9D5298F + for ; + Tue, 9 Aug 2005 19:03:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50121-02 + for ; + Tue, 9 Aug 2005 22:03:12 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F96252988 + for ; + Tue, 9 Aug 2005 19:03:08 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 6EFBE6440DC + for ; + Tue, 9 Aug 2005 16:02:41 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 03239-06 for ; + Tue, 9 Aug 2005 16:02:39 -0600 (MDT) +Received: from [192.168.1.12] (c-24-9-24-35.hsd1.co.comcast.net [24.9.24.35]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id 391856440BC + for ; + Tue, 9 Aug 2005 16:02:39 -0600 (MDT) +Mime-Version: 1.0 (Apple Message framework v730) +In-Reply-To: <42F9255A.4080604@arbash-meinel.com> +References: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> + <1123656547.13362.43.camel@amd64-laptop-spoe> + <2764B744-4CDC-4F2C-99C4-2948D37A9D23@drivefaster.net> + <42F9255A.4080604@arbash-meinel.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <17797211-4C5F-4410-B38E-53ECC10D0752@drivefaster.net> +Content-Transfer-Encoding: 7bit +From: Dan Harris +Subject: Re: Table locking problems? +Date: Tue, 9 Aug 2005 16:05:34 -0600 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.730) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/94 +X-Sequence-Number: 13841 + + +On Aug 9, 2005, at 3:51 PM, John A Meinel wrote: + +> Dan Harris wrote: +> +>> On Aug 10, 2005, at 12:49 AM, Steve Poe wrote: +>> +>>> Dan, +>>> +>>> Do you mean you did RAID 1 + 0 (RAID 10) or RAID 0 + 1? Just a +>>> clarification, since RAID 0 is still a single-point of failure +>>> even if +>>> RAID1 is on top of RAID0. +>>> +>> Well, you tell me if I stated incorrectly. There are two raid +>> enclosures with 7 drives in each. Each is on its own bus on a +>> dual- channel controller. Each box has a stripe across its drives +>> and the enclosures are mirrors of each other. I understand the +>> controller could be a single point of failure, but I'm not sure I +>> understand your concern about the RAID structure itself. +>> +> +> In this configuration, if you have a drive fail on both +> controllers, the entire RAID dies. Lets label them A1-7, B1-7, +> because you stripe within a set, if a single one of A dies, and a +> single one of B dies, you have lost your entire mirror. +> +> The correct way of doing it, is to have A1 be a mirror of B1, and +> then stripe above that. Since you are using 2 7-disk enclosures, +> I'm not sure how you can do it well, since it is not an even number +> of disks. Though if you are using software RAID, there should be no +> problem. +> +> The difference is that in this scenario, *all* of the A drives can +> die, and you haven't lost any data. The only thing you can't lose +> is a matched pair (eg losing both A1 and B1 will cause complete +> data loss) +> +> I believe the correct notation for this last form is RAID 1 + 0 +> (RAID10) since you have a set of RAID1 drives, with a RAID0 on-top +> of them. +> + +I have read up on the difference now. I don't understand why it's a +"single point of failure". Technically any array could be a "single +point" depending on your level of abstraction. In retrospect, I +probably should have gone 8 drives in each and used RAID 10 instead +for the better fault-tolerance, but it's online now and will require +some planning to see if I want to reconfigure that in the future. I +wish HP's engineer would have promoted that method instead of 0+1.. + +-Dan + + +From pgsql-performance-owner@postgresql.org Tue Aug 9 19:30:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 576285298E + for ; + Tue, 9 Aug 2005 19:30:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11724-05 + for ; + Tue, 9 Aug 2005 22:30:40 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E1B45291E + for ; + Tue, 9 Aug 2005 19:30:36 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050809223024m9100g5t0oe>; Tue, 9 Aug 2005 22:30:34 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 6EDC355FF3; Tue, 9 Aug 2005 17:30:21 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id CC65955FCC; + Tue, 9 Aug 2005 17:30:15 -0500 (CDT) +Message-ID: <42F92E79.5050905@arbash-meinel.com> +Date: Tue, 09 Aug 2005 17:30:17 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dan Harris +Cc: pgsql-performance@postgresql.org +Subject: Re: Table locking problems? +References: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> + <1123656547.13362.43.camel@amd64-laptop-spoe> + <2764B744-4CDC-4F2C-99C4-2948D37A9D23@drivefaster.net> + <42F9255A.4080604@arbash-meinel.com> + <17797211-4C5F-4410-B38E-53ECC10D0752@drivefaster.net> +In-Reply-To: <17797211-4C5F-4410-B38E-53ECC10D0752@drivefaster.net> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig54CE91A96C702C95B2C308BF" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/95 +X-Sequence-Number: 13842 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig54CE91A96C702C95B2C308BF +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Dan Harris wrote: +> +> On Aug 9, 2005, at 3:51 PM, John A Meinel wrote: +> +>> Dan Harris wrote: +>> +>>> On Aug 10, 2005, at 12:49 AM, Steve Poe wrote: +>>> +>>>> Dan, +>>>> +>>>> Do you mean you did RAID 1 + 0 (RAID 10) or RAID 0 + 1? Just a +>>>> clarification, since RAID 0 is still a single-point of failure even if +>>>> RAID1 is on top of RAID0. +>>>> +>>> Well, you tell me if I stated incorrectly. There are two raid +>>> enclosures with 7 drives in each. Each is on its own bus on a dual- +>>> channel controller. Each box has a stripe across its drives and +>>> the enclosures are mirrors of each other. I understand the +>>> controller could be a single point of failure, but I'm not sure I +>>> understand your concern about the RAID structure itself. +>>> +>> +>> In this configuration, if you have a drive fail on both controllers, +>> the entire RAID dies. Lets label them A1-7, B1-7, because you stripe +>> within a set, if a single one of A dies, and a single one of B dies, +>> you have lost your entire mirror. +>> +>> The correct way of doing it, is to have A1 be a mirror of B1, and +>> then stripe above that. Since you are using 2 7-disk enclosures, I'm +>> not sure how you can do it well, since it is not an even number of +>> disks. Though if you are using software RAID, there should be no +>> problem. +>> +>> The difference is that in this scenario, *all* of the A drives can +>> die, and you haven't lost any data. The only thing you can't lose is +>> a matched pair (eg losing both A1 and B1 will cause complete data loss) +>> +>> I believe the correct notation for this last form is RAID 1 + 0 +>> (RAID10) since you have a set of RAID1 drives, with a RAID0 on-top of +>> them. +>> +> +> I have read up on the difference now. I don't understand why it's a +> "single point of failure". Technically any array could be a "single +> point" depending on your level of abstraction. In retrospect, I +> probably should have gone 8 drives in each and used RAID 10 instead for +> the better fault-tolerance, but it's online now and will require some +> planning to see if I want to reconfigure that in the future. I wish +> HP's engineer would have promoted that method instead of 0+1.. + +I wouldn't say that it is a single point of failure, but I *can* say +that it is much more likely to fail. (2 drives rather than on average n +drives) + +If your devices will hold 8 drives, you could simply do 1 8-drive, and +one 6-drive. And then do RAID1 with pairs, and RAID0 across the +resultant 7 RAID1 sets. + +I'm really surprised that someone promoted RAID 0+1 over RAID10. I think +I've heard that there is a possible slight performance improvement, but +really the failure mode makes it a poor tradeoff. + +John +=:-> + +> +> -Dan +> + +--------------enig54CE91A96C702C95B2C308BF +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC+S55JdeBCYSNAAMRAsF5AJwMi+HzqgRohEH5XENK4+wJc3qOfACfSanr +n5bGniMEoSJuHjJNNHqgIHk= +=tXav +-----END PGP SIGNATURE----- + +--------------enig54CE91A96C702C95B2C308BF-- + +From pgsql-patches-owner@postgresql.org Tue Aug 9 21:41:35 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E30552927 + for ; + Tue, 9 Aug 2005 21:41:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47137-05 + for ; + Wed, 10 Aug 2005 00:41:23 +0000 (GMT) +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 3FB5B5295C + for ; + Tue, 9 Aug 2005 21:41:21 -0300 (ADT) +Received: from 172.16.1.110 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Tue, 09 Aug 2005 20:41:19 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Tue, 9 Aug 2005 + 20:41:18 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.104]) with Microsoft Exchange Server HTTP-DAV ; Tue, 9 Aug + 2005 20:41:18 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Tue, 09 Aug 2005 17:41:18 -0700 +Subject: Re: COPY FROM performance improvements +From: "Alon Goldshuv" +To: pgsql-patches@postgresql.org +Message-ID: +In-Reply-To: +MIME-Version: 1.0 +X-OriginalArrivalTime: 10 Aug 2005 00:41:18.0936 (UTC) + FILETIME=[38FCDD80:01C59D44] +X-WSS-ID: 6EE792A52B416104077-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.593 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200508/75 +X-Sequence-Number: 17022 + +I did some performance checks after the recent code commit. + +The good news is that the parsing speed of COPY is now MUCH faster, which is +great. It is about 5 times faster - about 100MB/sec on my machine +(previously 20MB/sec at best, usually less). + +The better news is that my original patch parsing speed reaches 120MB/sec, +about 20MB/sec faster than the code that's now in CVS. This can be +significant for the long scheme of things and for large data sets. Maybe we +can improve the current code a bit more to reach this number. + +I performed those measurement by executing *only the parsing logic* of the +COPY pipeline. All data conversion (functioncall3(string...)) and tuple +handling (form_heaptuple etc...) and insertion were manually disabled. So +the only code measured is reading from disk and parsing to the attribute +level. + +Cheers, +Alon. + + + + + +On 8/7/05 1:21 AM, "Luke Lonergan" wrote: + +> Tom, +> +> On 8/6/05 9:08 PM, "Tom Lane" wrote: +> +>> "Luke Lonergan" writes: +>>>> I had some difficulty in generating test cases that weren't largely +>>>> I/O-bound, but AFAICT the patch as applied is about the same speed +>>>> as what you submitted. +>> +>>> You achieve the important objective of knocking the parsing stage down a +>>> lot, but your parsing code is actually about 20% slower than Alon's. +>> +>> I would like to see the exact test case you are using to make this +>> claim; the tests I did suggested my code is the same speed or faster. +> +> I showed mine - you show yours :-) Apparently our e-mail crossed. +> +>> As best I can tell, my version of CopyReadAttributes is significantly +>> quicker than Alon's, approximately balancing out the fact that my +>> version of CopyReadLine is slower. I did the latter first, and would +>> now be tempted to rewrite it in the same style as CopyReadAttributes, +>> ie one pass of memory-to-memory copy using pointers rather than buffer +>> indexes. +> +> See previous timings - looks like Alon's parsing is substantially faster. +> However, I'd like him to confirm by running with the "shunt" placed at +> different stages, in this case between parse and attribute conversion (not +> attribute parse). +> +>> BTW, late today I figured out a way to get fairly reproducible +>> non-I/O-bound numbers about COPY FROM: use a trigger that suppresses +>> the actual inserts, thus: +>> +>> create table foo ... +>> create function noway() returns trigger as +>> 'begin return null; end' language plpgsql; +>> create trigger noway before insert on foo +>> for each row execute procedure noway(); +>> then repeat: +>> copy foo from '/tmp/foo.data'; +> +> Cool! That's a better way than hacking code and inserting shunts. +> +> Alon will likely hit this tomorrow. +> +> - Luke +> + + + +From pgsql-patches-owner@postgresql.org Tue Aug 9 22:01:45 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B189528EF + for ; + Tue, 9 Aug 2005 22:01:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32841-03 + for ; + Wed, 10 Aug 2005 01:01:42 +0000 (GMT) +Received: from trolak.mydnsbox2.com (ns1.mydnsbox2.com [207.44.142.118]) + by svr1.postgresql.org (Postfix) with ESMTP id 5BE7C528E1 + for ; + Tue, 9 Aug 2005 22:01:41 -0300 (ADT) +Received: from [192.168.1.103] (cpe-024-211-165-134.nc.res.rr.com + [24.211.165.134]) (authenticated (0 bits)) + by trolak.mydnsbox2.com (8.11.6/8.11.6) with ESMTP id j7A0GoK23122; + Tue, 9 Aug 2005 19:16:50 -0500 +Message-ID: <42F951F2.8010104@dunslane.net> +Date: Tue, 09 Aug 2005 21:01:38 -0400 +From: Andrew Dunstan +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.7.10) Gecko/20050719 Fedora/1.7.10-1.3.1 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alon Goldshuv +Cc: pgsql-patches@postgresql.org +Subject: Re: COPY FROM performance improvements +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/76 +X-Sequence-Number: 17023 + + + +Alon Goldshuv wrote: + +>I performed those measurement by executing *only the parsing logic* of the +>COPY pipeline. All data conversion (functioncall3(string...)) and tuple +>handling (form_heaptuple etc...) and insertion were manually disabled. So +>the only code measured is reading from disk and parsing to the attribute +>level. +> +> + +Arguably this might exaggerate the effect quite significantly. Users +will want to know the real time effect on a complete COPY. Depending on +how much the pasing is in the total time your 20% improvement in parsing +might only be a small fraction of 20% improvement in COPY. + +Like you, I'm happy we have seen a 5 times improvement in parsing. Is it +possible you can factor out something smallish from your patch that +might make up the balance? + +cheers + +andrew + +From pgsql-patches-owner@postgresql.org Wed Aug 10 01:40:17 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E26F852A1D + for ; + Wed, 10 Aug 2005 01:40:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97085-01 + for ; + Wed, 10 Aug 2005 04:40:12 +0000 (GMT) +Received: from mail.Mi8.com (nycgw01.mi8.com [63.240.6.42]) + by svr1.postgresql.org (Postfix) with ESMTP id A88E1528EF + for ; + Wed, 10 Aug 2005 01:40:10 -0300 (ADT) +Received: from 172.16.1.112 by mail.Mi8.com with ESMTP (- GW01 Welcome + to Mi8 Corporation www.Mi8.com); Wed, 10 Aug 2005 00:39:58 -0400 +X-Server-Uuid: F1A2E19A-84E4-48DD-8F48-B475613F58B2 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Wed, 10 Aug + 2005 00:39:58 -0400 +Received: from 24.5.173.15 ([24.5.173.15]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 10 Aug + 2005 00:39:58 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Tue, 09 Aug 2005 21:39:55 -0700 +Subject: Re: COPY FROM performance improvements +From: "Luke Lonergan" +To: "Andrew Dunstan" , + "Alon Goldshuv" +Cc: pgsql-patches@postgresql.org +Message-ID: +In-Reply-To: <42F951F2.8010104@dunslane.net> +MIME-Version: 1.0 +X-OriginalArrivalTime: 10 Aug 2005 04:39:58.0822 (UTC) + FILETIME=[904E1060:01C59D65] +X-WSS-ID: 6EE75A9427K5951281-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.591 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200508/80 +X-Sequence-Number: 17027 + +Andrew, + +> Arguably this might exaggerate the effect quite significantly. Users +> will want to know the real time effect on a complete COPY. Depending on +> how much the pasing is in the total time your 20% improvement in parsing +> might only be a small fraction of 20% improvement in COPY. + +Arguably has already been argued. We knew this because we profiled the +entire COPY process and came up with this approx. breakdown for a specific +case: +Parsing: 25% +Attribute Conversion: 40% +Data Insertion: 35% + +Net copy rate: 8 MB/s on a filesystem that does 240 MB/s + +So - if we speed up parsing by 500% or 450%, the end result is about a +20-30% speed increase in the overall process. + +Note that we're still a *long* way from getting anywhere near the limit of +the I/O subsystem at 12 MB/s. Oracle can probably get 5-8 times this data +rate, if not better. + +The attribute conversion logic is also very slow and needs similar +improvements. + +The reason we focused first on Parsing is that our MPP version of Bizgres +will reach data loading rates approaching the parsing speed, so we needed to +improve that part to get it out of the way. + +We will continue to improve COPY speed in Bizgres so that we can provide +comparable COPY performance to Oracle and MySQL. + +> Like you, I'm happy we have seen a 5 times improvement in parsing. Is it +> possible you can factor out something smallish from your patch that +> might make up the balance? + +That parsing was 25% of the workload was traceable to a 3 main things: +1) Per character acquisition from source instead of buffering +2) Frequent interruption of the parsing pipeline to handle attribute +conversion +3) Lack of micro-parallelism in the character finding logic + +Tom's patch took our contribution from (1) and (2) and his improvements, and +he rejected (3). The net result is that we lost performance from the lack +of (3) but gained performance from his improvements of (1) and (2). + +I believe that re-introducing (3) may bring us from 100 MB/s to 150 MB/s +parsing speed. + +- Luke + + + +From pgsql-patches-owner@postgresql.org Wed Aug 10 01:48:24 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D020A528EE + for ; + Wed, 10 Aug 2005 01:48:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73571-10 + for ; + Wed, 10 Aug 2005 04:48:14 +0000 (GMT) +Received: from mail.Mi8.com (nycgw01.mi8.com [63.240.6.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 49BC95282F + for ; + Wed, 10 Aug 2005 01:48:13 -0300 (ADT) +Received: from 172.16.1.118 by mail.Mi8.com with ESMTP (- GW01 Welcome + to Mi8 Corporation www.Mi8.com); Wed, 10 Aug 2005 00:48:08 -0400 +X-Server-Uuid: F1A2E19A-84E4-48DD-8F48-B475613F58B2 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + d01smtp03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 10 Aug + 2005 00:48:08 -0400 +Received: from 24.5.173.15 ([24.5.173.15]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 10 Aug + 2005 00:48:07 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Tue, 09 Aug 2005 21:48:02 -0700 +Subject: Re: COPY FROM performance improvements +From: "Luke Lonergan" +To: "Tom Lane" +Cc: "Alon Goldshuv" , + pgsql-patches@postgresql.org +Message-ID: +In-Reply-To: <29007.1123387696@sss.pgh.pa.us> +MIME-Version: 1.0 +X-OriginalArrivalTime: 10 Aug 2005 04:48:08.0352 (UTC) + FILETIME=[B4166A00:01C59D66] +X-WSS-ID: 6EE7588227K5953989-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.591 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200508/81 +X-Sequence-Number: 17028 + +Tom, + +> As best I can tell, my version of CopyReadAttributes is significantly +> quicker than Alon's, approximately balancing out the fact that my +> version of CopyReadLine is slower. I did the latter first, and would +> now be tempted to rewrite it in the same style as CopyReadAttributes, +> ie one pass of memory-to-memory copy using pointers rather than buffer +> indexes. + +I think you are right, with the exception that Alon's results prove out that +the net result of your patch is 20% slower than his. + +I think with your speedup of CopyReadAttributes and some additional work on +CopyReadLine the net result could be 50% faster than Alon's patch. + +The key thing that is missing is the lack of micro-parallelism in the +character processing in this version. By "inverting the loop", or putting +the characters into a buffer on the outside, then doing fast character +scanning inside with special "fix-up" cases, we exposed long runs of +pipeline-able code to the compiler. + +I think there is another way to accomplish the same thing and still preserve +the current structure, but it requires "strip mining" the character buffer +into chunks that can be processed with an explicit loop to check for the +different characters. While it may seem artificial (it is), it will provide +the compiler with the ability to pipeline the character finding logic over +long runs. The other necessary element will have to avoid pipeline stalls +from the "if" conditions as much as possible. + +Anyway, thanks for reviewing this code and improving it - it's important to +bring speed increases to our collective customer base. With Bizgres, we're +not satisfied with 12 MB/s, we won't stop until we saturate the I/O bus, so +we may get more extreme with the code than seems reasonable for the general +audience. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Tue Aug 9 16:14:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C048A529F6 + for ; + Tue, 9 Aug 2005 15:58:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99823-07 + for ; + Tue, 9 Aug 2005 18:58:40 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id 59927529F4 + for ; + Tue, 9 Aug 2005 15:58:39 -0300 (ADT) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Tue, 9 Aug 2005 12:02:24 -0700 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Tue, 9 Aug 2005 12:02:21 -0700 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005080912022128114 + for ; + Tue, 09 Aug 2005 12:02:21 -0700 +X-ASG-Debug-ID: 1123613917-1115-6-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail1 (mail1.hq.corp [192.168.160.5]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id 622B62014AF5 + for ; + Tue, 9 Aug 2005 11:58:37 -0700 (PDT) +Received: from amd64-laptop-spoe ([63.206.203.145]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.1830); Tue, 9 Aug 2005 12:02:20 -0700 +X-ASG-Orig-Subj: Re: [PERFORM] Table locking problems? +Subject: Re: Table locking problems? +From: Steve Poe +To: Dan Harris +Cc: pgsql-performance@postgresql.org +In-Reply-To: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> +References: <52CFA236-FC43-4018-B399-1854240110FF@drivefaster.net> +Content-Type: text/plain +Date: Wed, 10 Aug 2005 06:49:07 +0000 +Message-Id: <1123656547.13362.43.camel@amd64-laptop-spoe> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 09 Aug 2005 19:02:20.0428 (UTC) + FILETIME=[DE4AD4C0:01C59D14] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: 1.30 +X-Barracuda-Spam-Status: No, SCORE=1.30 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_50, + DATE_IN_FUTURE_06_12 +X-Barracuda-Spam-Report: Code version 3.02, rules version 3.0.3093 + Rule breakdown below pts rule name description + ---- ---------------------- + -------------------------------------------------- + 1.30 DATE_IN_FUTURE_06_12 Date: is 6 to 12 hours after Received: date + 0.00 BAYES_50 BODY: Bayesian spam probability is 40 to 60% + [score: 0.5985] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.75 tagged_above=0 required=5 tests=AWL, + DATE_IN_FUTURE_06_12, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/89 +X-Sequence-Number: 13836 + +Dan, + +Do you mean you did RAID 1 + 0 (RAID 10) or RAID 0 + 1? Just a +clarification, since RAID 0 is still a single-point of failure even if +RAID1 is on top of RAID0. + +How many users are connected when your update / delete queries are +hanging? Have you done an analyze verbose on those queries? + +Have you made changes to the postgresql.conf? kernel.vm settings? IO +scheduler? + +If you're not doing so already, you may consider running sar (iostat) to +monitor when the hanging occurs if their is a memory / IO bottleneck +somewhere. + +Good luck. + +Steve Poe + + +On Tue, 2005-08-09 at 12:04 -0600, Dan Harris wrote: +> I thought I would send this to pg-performance since so many people +> helped me with my speed issues recently. I was definitely IO- +> bottlenecked. +> +> Since then, I have installed 2 RAID arrays with 7 15k drives in them +> in RAID 0+1 as well as add a new controller card with 512MB of cache +> on it. I also created this new partition on the RAID as XFS instead +> of ext3. +> +> These changes have definitely improved performance, but I am now +> finding some trouble with UPDATE or DELETE queries "hanging" and +> never releasing their locks. As this happens, other statements queue +> up behind it. It seems to occur at times of very high loads on the +> box. Is my only option to kill the query ( which usually takes down +> the whole postmaster with it! ouch ). +> +> Could these locking issues be related to the other changes I made? +> I'm really scared that this is related to choosing XFS, but I sure +> hope not. How should I go about troubleshooting the "problem" +> queries? They don't seem to be specific to a single table or single +> database. +> +> I'm running 8.0.1 on kernel 2.6.12-3 on 64-bit Opterons if that +> matters.. +> +> +> -Dan +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match + + +From pgsql-patches-owner@postgresql.org Wed Aug 10 05:16:26 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EE0652ADB + for ; + Wed, 10 Aug 2005 05:16:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96362-04 + for ; + Wed, 10 Aug 2005 08:16:15 +0000 (GMT) +Received: from smtp1.freeserve.com (smtp1.wanadoo.co.uk [193.252.22.158]) + by svr1.postgresql.org (Postfix) with ESMTP id A040852C20 + for ; + Wed, 10 Aug 2005 05:16:14 -0300 (ADT) +Received: from me-wanadoo.net (nullmx.kyokofukada.net [127.0.0.1]) + by mwinf3004.me.freeserve.com (SMTP Server) with ESMTP id D6C971C001C4; + Wed, 10 Aug 2005 10:16:14 +0200 (CEST) +Received: from 192.168.0.102 (modem-951.lynx.dialup.pol.co.uk + [217.135.195.183]) + by mwinf3004.me.freeserve.com (SMTP Server) with ESMTP id 4F61B1C001C3; + Wed, 10 Aug 2005 10:16:14 +0200 (CEST) +X-ME-UUID: 20050810081614325.4F61B1C001C3@mwinf3004.me.freeserve.com +Subject: Re: COPY FROM performance improvements +From: Simon Riggs +To: Luke Lonergan +Cc: Tom Lane , + Alon Goldshuv , pgsql-patches@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Wed, 10 Aug 2005 09:15:00 +0100 +Message-Id: <1123661700.3670.621.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200508/85 +X-Sequence-Number: 17032 + +On Tue, 2005-08-09 at 21:48 -0700, Luke Lonergan wrote: + +> The key thing that is missing is the lack of micro-parallelism in the +> character processing in this version. By "inverting the loop", or putting +> the characters into a buffer on the outside, then doing fast character +> scanning inside with special "fix-up" cases, we exposed long runs of +> pipeline-able code to the compiler. +> +> I think there is another way to accomplish the same thing and still preserve +> the current structure, but it requires "strip mining" the character buffer +> into chunks that can be processed with an explicit loop to check for the +> different characters. While it may seem artificial (it is), it will provide +> the compiler with the ability to pipeline the character finding logic over +> long runs. The other necessary element will have to avoid pipeline stalls +> from the "if" conditions as much as possible. + +This is a key point, IMHO. + +That part of the code was specifically written to take advantage of +processing pipelines in the hardware, not because the actual theoretical +algorithm for that approach was itself faster. + +Nobody's said what compiler/hardware they have been using, so since both +Alon and Tom say their character finding logic is faster, it is likely +to be down to that? Name your platforms gentlemen, please. + +My feeling is that we may learn something here that applies more widely +across many parts of the code. + +Best Regards, Simon Riggs + + + +From pgsql-patches-owner@postgresql.org Wed Aug 10 12:30:06 2005 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F1016529F1 + for ; + Wed, 10 Aug 2005 12:30:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08043-04 + for ; + Wed, 10 Aug 2005 15:29:56 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 000365289C + for ; + Wed, 10 Aug 2005 12:29:55 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7AFTnha026483; + Wed, 10 Aug 2005 11:29:50 -0400 (EDT) +To: Simon Riggs +Cc: Luke Lonergan , + Alon Goldshuv , pgsql-patches@postgresql.org +Subject: Re: COPY FROM performance improvements +In-reply-to: <1123661700.3670.621.camel@localhost.localdomain> +References: + <1123661700.3670.621.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Wed, 10 Aug 2005 09:15:00 +0100" +Date: Wed, 10 Aug 2005 11:29:49 -0400 +Message-ID: <26482.1123687789@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/91 +X-Sequence-Number: 17038 + +Simon Riggs writes: +> Nobody's said what compiler/hardware they have been using, so since both +> Alon and Tom say their character finding logic is faster, it is likely +> to be down to that? Name your platforms gentlemen, please. + +I tested on HPPA with gcc 2.95.3 and on a Pentium 4 with gcc 3.4.3. +Got pretty much the same results on both. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 10 14:53:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FC6B52806 + for ; + Wed, 10 Aug 2005 14:52:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23587-10 + for ; + Wed, 10 Aug 2005 17:52:22 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id BD32252C3C + for ; + Wed, 10 Aug 2005 14:52:17 -0300 (ADT) +Received: from [84.48.51.94] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1E2uiM-0004XD-9f + for ; Wed, 10 Aug 2005 19:50:13 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id 7F3ABE14C2; Wed, 10 Aug 2005 19:52:08 +0200 (CEST) +Date: Wed, 10 Aug 2005 19:52:08 +0200 +From: Tobias Brox +To: pgsql-performance@postgresql.org +Subject: partial index regarded more expensive +Message-ID: <20050810175208.GD6141@tobias.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Organization: Group Nordicbet +User-Agent: Mutt/1.5.8i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/96 +X-Sequence-Number: 13843 + +So, I have a table game with a timestamp attribute 'game_end', ranging from +jan-2005 to present. The game table also have an attribute state, with live +games beeing in state 2, and ended games beeing in state 4 (so, +game_end+delta>now() usually means state=4). There are also an insignificant +number of games in states 1,3. + +This query puzzles me: + + select * from game where game_end>'2005-07-30' and state in (3,4); + +Now, one (at least me) should believe that the best index would be a partial +index, + + "resolved_game_by_date" btree (game_end) WHERE ((state = 3) OR (state = 4)) + +NBET=> explain analyze select * from game where game_end>'2005-07-30' and state in (3,4); + QUERY PLAN + +---------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using resolved_game_by_date on game (cost=0.00..7002.87 rows=7147 width=555) (actual time=0.220..86.234 rows=3852 loops=1) + Index Cond: (game_end > '2005-07-30 00:00:00'::timestamp without time zone) + Filter: ((state = 3) OR (state = 4)) + Total runtime: 90.568 ms +(4 rows) + +Since state has only two significant states, I wouldn't believe this index +to be any good: + + "game_by_state" btree (state) + + +...and it seems like I'm right: + +NBET=> explain analyze select * from game where game_end>'2005-07-30' and +state in (3,4); + QUERY +PLAN +------------------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using game_by_state, game_by_state on game (cost=0.00..4413.78 rows=7147 width=555) (actual time=0.074..451.771 rows=3851 loops=1) + Index Cond: ((state = 3) OR (state = 4)) + Filter: (game_end > '2005-07-30 00:00:00'::timestamp without time zone) + Total runtime: 457.132 ms +(4 rows) + +Now, how can the planner believe the game_by_state-index to be better? + +('vacuum analyze game' did not significantly impact the numbers, and I've +tried running the queries some times with and without the +game_by_state-index to rule out cacheing effects) + +-- +Tobias Brox +This signature has been virus scanned, and is probably safe to read. +This mail may contain confidential information, please keep your eyes closed. + +From pgsql-performance-owner@postgresql.org Wed Aug 10 15:15:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D6DD052939 + for ; + Wed, 10 Aug 2005 15:15:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92395-04 + for ; + Wed, 10 Aug 2005 18:15:15 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 6850552924 + for ; + Wed, 10 Aug 2005 15:15:14 -0300 (ADT) +Received: (qmail 22982 invoked from network); 10 Aug 2005 20:15:28 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 10 Aug 2005 20:15:28 +0200 +To: "Tobias Brox" , + pgsql-performance@postgresql.org +Subject: Re: partial index regarded more expensive +References: <20050810175208.GD6141@tobias.lan> +Message-ID: +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Date: Wed, 10 Aug 2005 20:15:13 +0200 +In-Reply-To: <20050810175208.GD6141@tobias.lan> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200508/97 +X-Sequence-Number: 13844 + + + why not simply create an index on (game_end, state) ? + +From pgsql-performance-owner@postgresql.org Wed Aug 10 15:32:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 21DA352991 + for ; + Wed, 10 Aug 2005 15:32:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19844-04 + for ; + Wed, 10 Aug 2005 18:31:54 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 94D5B5280D + for ; + Wed, 10 Aug 2005 15:31:53 -0300 (ADT) +Received: from [84.48.51.94] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1E2vKf-0006DA-8l; Wed, 10 Aug 2005 20:29:51 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id DB648CACF3; Wed, 10 Aug 2005 20:31:42 +0200 (CEST) +Date: Wed, 10 Aug 2005 20:31:42 +0200 +From: Tobias Brox +To: PFC +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: partial index regarded more expensive +Message-ID: <20050810183142.GG6141@tobias.lan> +References: <20050810175208.GD6141@tobias.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +Organization: Group Nordicbet +User-Agent: Mutt/1.5.8i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/98 +X-Sequence-Number: 13845 + +[PFC - Wed at 08:15:13PM +0200] +> why not simply create an index on (game_end, state) ? + +No, the planner prefers to use the partial index (I dropped the index on +game(state)). + +-- +Tobias Brox, Nordicbet IT dept +This signature has been virus scanned, and is probably safe to read. +This mail may contain confidential information, please keep your eyes closed. + +From pgsql-performance-owner@postgresql.org Wed Aug 10 18:04:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CC93A52A4B; + Wed, 10 Aug 2005 18:04:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92089-01; Wed, 10 Aug 2005 21:03:58 +0000 (GMT) +Received: from mailhost.intellivid.com (mailhost.intellivid.com + [64.32.200.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D35252A44; + Wed, 10 Aug 2005 18:03:52 -0300 (ADT) +Received: from [192.168.2.68] (spectre.intellivid.com [192.168.2.68]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by newmail.intellivid.com (Postfix) with ESMTP id C0CC8F182AF; + Wed, 10 Aug 2005 17:03:53 -0400 (EDT) +Subject: Re: Planner doesn't look at LIMIT? +From: Ian Westmacott +To: Tom Lane +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: <6440.1122049220@sss.pgh.pa.us> +References: <758d5e7f0507220210bfa4978@mail.gmail.com> + <29473.1122043197@sss.pgh.pa.us> <6440.1122049220@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Intellivid Corp. +Message-Id: <1123707833.17725.133.camel@spectre.intellivid.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 10 Aug 2005 17:03:53 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200508/99 +X-Sequence-Number: 13846 + +I have a case that I though was an example of this issue, +and that this patch would correct. I applied this patch +to an 8.0.3 source distribution, but it didn't seem to +solve my problem. + +In a nutshell, I have a LIMIT query where the planner +seems to favor a merge join over a nested loop. I've +simplified the query as much as possible: + + +itvtrackdata3=> \d tableA +Table "public.tableA" + Column | Type | Modifiers +--------+----------+----------- + foo | bigint | not null + bar | smallint | not null + bap | bigint | not null + bip | bigint | not null + bom | bigint | not null +Indexes: + "idx_tableA_bip" btree (bip) WHERE (bip = +9000000000000000000::bigint) + "idx_tableA_foo" btree (foo) + +itvtrackdata3=> \d tableB +Table "tableB" + Column | Type | Modifiers +---------+----------+----------- + bim | bigint | not null + bif | smallint | not null + baf | smallint | not null + bof | smallint | not null + buf | smallint | not null + foo | bigint | not null +Indexes: + "idx_tableB_bim" btree ("bim", foo) + +itvtrackdata3=> set default_statistics_target to 1000; +SET +Time: 0.448 ms +itvtrackdata3=> analyze tableA; +ANALYZE +Time: 4237.151 ms +itvtrackdata3=> analyze tableB; +ANALYZE +Time: 46672.939 ms +itvtrackdata3=> explain analyze SELECT * FROM tableB NATURAL JOIN tableA +WHERE bim>=72555896091359 AND bim<72555935412959 AND bim=bap ORDER BY +bim ASC LIMIT 1; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=149626.57..252987.71 rows=1 width=50) (actual +time=5684.013..5684.013 rows=1 loops=1) + -> Merge Join (cost=149626.57..252987.71 rows=1 width=50) (actual +time=5684.012..5684.012 rows=1 loops=1) + Merge Cond: (("outer"."bim" = "inner"."bap") AND ("outer".foo = +"inner".foo)) + -> Index Scan using idx_tableB_bim on tableB +(cost=0.00..97391.22 rows=55672 width=24) (actual time=0.017..0.059 +rows=29 loops=1) + Index Cond: (("bim" >= 72555896091359::bigint) AND ("bim" +< 72555935412959::bigint)) + -> Sort (cost=149626.57..151523.94 rows=758948 width=34) +(actual time=5099.300..5442.825 rows=560856 loops=1) + Sort Key: tableA."bap", tableA.foo + -> Seq Scan on tableA (cost=0.00..47351.48 rows=758948 +width=34) (actual time=0.021..1645.204 rows=758948 loops=1) + Total runtime: 5706.655 ms +(9 rows) + +Time: 5729.984 ms +itvtrackdata3=> set enable_mergejoin to false; +SET +Time: 0.373 ms +itvtrackdata3=> explain analyze SELECT * FROM tableB NATURAL JOIN tableA +WHERE bim>=72555896091359 AND bim<72555935412959 AND bim=bap ORDER BY +bim ASC LIMIT 1; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..432619.68 rows=1 width=50) (actual +time=11.149..11.150 rows=1 loops=1) + -> Nested Loop (cost=0.00..432619.68 rows=1 width=50) (actual +time=11.148..11.148 rows=1 loops=1) + Join Filter: ("outer"."bim" = "inner"."bap") + -> Index Scan using idx_tableB_bim on tableB +(cost=0.00..97391.22 rows=55672 width=24) (actual time=0.017..0.062 +rows=29 loops=1) + Index Cond: (("bim" >= 72555896091359::bigint) AND ("bim" +< 72555935412959::bigint)) + -> Index Scan using idx_tableA_foo on tableA (cost=0.00..6.01 +rows=1 width=34) (actual time=0.007..0.379 rows=1 loops=29) + Index Cond: ("outer".foo = tableA.foo) + Total runtime: 11.215 ms +(8 rows) + +Time: 32.007 ms + + +Have I just flubbed the patch, or is there something else +going on here? + +Thanks, + + --Ian + + +On Fri, 2005-07-22 at 12:20, Tom Lane wrote: +> I wrote: +> > Dawid Kuroczko writes: +> >> qnex=# EXPLAIN SELECT * FROM log NATURAL JOIN useragents LIMIT 1; +> +> >> Limit (cost=15912.20..15912.31 rows=1 width=272) +> >> -> Hash Join (cost=15912.20..5328368.96 rows=47044336 width=272) +> +> >> If I set enable_hashjoin=false: +> +> >> qnex=# EXPLAIN ANALYZE SELECT * FROM log NATURAL LEFT JOIN useragents LIMIT 1; +> +> >> Limit (cost=0.00..3.07 rows=1 width=272) (actual time=74.214..74.216 +> >> rows=1 loops=1) +> >> -> Nested Loop Left Join (cost=0.00..144295895.01 rows=47044336 +> >> width=272) (actual time=74.204..74.204 rows=1 loops=1) +> +> > This is quite strange. The nestloop plan definitely should be preferred +> > in the context of the LIMIT, considering that it has far lower estimated +> > cost. And it is preferred in simple tests for me. +> +> After a suitable period of contemplating my navel, I figured out +> what is going on here: the total costs involved are large enough that +> the still-fairly-high startup cost of the hash is disregarded by +> compare_fuzzy_path_costs(), and so the nestloop is discarded as not +> having any significant potential advantage in startup time. +> +> I think that this refutes the original scheme of using the same fuzz +> factor for both startup and total cost comparisons, and therefore +> propose the attached patch. +> +> Comments? +> +> regards, tom lane +> +> *** src/backend/optimizer/util/pathnode.c.orig Fri Jul 15 13:09:25 2005 +> --- src/backend/optimizer/util/pathnode.c Fri Jul 22 12:08:25 2005 +> *************** +> *** 98,157 **** +> static int +> compare_fuzzy_path_costs(Path *path1, Path *path2, CostSelector criterion) +> { +> - Cost fuzz; +> - +> /* +> ! * The fuzz factor is set at one percent of the smaller total_cost, +> ! * but not less than 0.01 cost units (just in case total cost is +> ! * zero). +> * +> * XXX does this percentage need to be user-configurable? +> */ +> - fuzz = Min(path1->total_cost, path2->total_cost) * 0.01; +> - fuzz = Max(fuzz, 0.01); +> - +> if (criterion == STARTUP_COST) +> { +> ! if (Abs(path1->startup_cost - path2->startup_cost) > fuzz) +> ! { +> ! if (path1->startup_cost < path2->startup_cost) +> ! return -1; +> ! else +> ! return +1; +> ! } +> +> /* +> * If paths have the same startup cost (not at all unlikely), +> * order them by total cost. +> */ +> ! if (Abs(path1->total_cost - path2->total_cost) > fuzz) +> ! { +> ! if (path1->total_cost < path2->total_cost) +> ! return -1; +> ! else +> ! return +1; +> ! } +> } +> else +> { +> ! if (Abs(path1->total_cost - path2->total_cost) > fuzz) +> ! { +> ! if (path1->total_cost < path2->total_cost) +> ! return -1; +> ! else +> ! return +1; +> ! } +> +> /* +> * If paths have the same total cost, order them by startup cost. +> */ +> ! if (Abs(path1->startup_cost - path2->startup_cost) > fuzz) +> ! { +> ! if (path1->startup_cost < path2->startup_cost) +> ! return -1; +> ! else +> ! return +1; +> ! } +> } +> return 0; +> } +> --- 98,138 ---- +> static int +> compare_fuzzy_path_costs(Path *path1, Path *path2, CostSelector criterion) +> { +> /* +> ! * We use a fuzz factor of 1% of the smaller cost. +> * +> * XXX does this percentage need to be user-configurable? +> */ +> if (criterion == STARTUP_COST) +> { +> ! if (path1->startup_cost > path2->startup_cost * 1.01) +> ! return +1; +> ! if (path2->startup_cost > path1->startup_cost * 1.01) +> ! return -1; +> +> /* +> * If paths have the same startup cost (not at all unlikely), +> * order them by total cost. +> */ +> ! if (path1->total_cost > path2->total_cost * 1.01) +> ! return +1; +> ! if (path2->total_cost > path1->total_cost * 1.01) +> ! return -1; +> } +> else +> { +> ! if (path1->total_cost > path2->total_cost * 1.01) +> ! return +1; +> ! if (path2->total_cost > path1->total_cost * 1.01) +> ! return -1; +> +> /* +> * If paths have the same total cost, order them by startup cost. +> */ +> ! if (path1->startup_cost > path2->startup_cost * 1.01) +> ! return +1; +> ! if (path2->startup_cost > path1->startup_cost * 1.01) +> ! return -1; +> } +> return 0; +> } +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + + +From pgsql-performance-owner@postgresql.org Wed Aug 10 19:55:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3ABF952922; + Wed, 10 Aug 2005 19:55:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17260-06; Wed, 10 Aug 2005 22:55:23 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DA9CB52CA9; + Wed, 10 Aug 2005 19:55:22 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7AMtOWq016041; + Wed, 10 Aug 2005 18:55:24 -0400 (EDT) +To: Ian Westmacott +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: Planner doesn't look at LIMIT? +In-reply-to: <1123707833.17725.133.camel@spectre.intellivid.com> +References: <758d5e7f0507220210bfa4978@mail.gmail.com> + <29473.1122043197@sss.pgh.pa.us> <6440.1122049220@sss.pgh.pa.us> + <1123707833.17725.133.camel@spectre.intellivid.com> +Comments: In-reply-to Ian Westmacott + message dated "Wed, 10 Aug 2005 17:03:53 -0400" +Date: Wed, 10 Aug 2005 18:55:24 -0400 +Message-ID: <16040.1123714524@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/100 +X-Sequence-Number: 13847 + +Ian Westmacott writes: +> In a nutshell, I have a LIMIT query where the planner +> seems to favor a merge join over a nested loop. + +The planner is already estimating only one row out of the join, and so +the LIMIT doesn't affect its cost estimates at all. + +It appears to me that the reason the nestloop plan is fast is just +chance: a suitable matching row is found very early in the scan of +tableB, so that the indexscan on it can stop after 29 rows, instead +of having to go through all 55000 rows in the given range of bim. +If it'd have had to go through, say, half of the rows to find a match, +the sort/merge plan would show up a lot better. + +If this wasn't chance, but was expected because there are many matching +rows and not only one, then there's a statistical problem. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 10 20:35:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D8E7452B89 + for ; + Wed, 10 Aug 2005 20:35:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13372-02 + for ; + Wed, 10 Aug 2005 23:35:19 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id EF41752AD8 + for ; + Wed, 10 Aug 2005 20:35:17 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 775336440A5 + for ; + Wed, 10 Aug 2005 17:34:49 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 13086-09 for ; + Wed, 10 Aug 2005 17:34:47 -0600 (MDT) +Received: from [192.168.1.12] (c-24-9-24-35.hsd1.co.comcast.net [24.9.24.35]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id 460076440F2 + for ; + Wed, 10 Aug 2005 17:34:47 -0600 (MDT) +Mime-Version: 1.0 (Apple Message framework v730) +Content-Transfer-Encoding: 7bit +Message-Id: <3E43C7D5-9DB8-4132-BF4F-607B000866E1@drivefaster.net> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Dan Harris +Subject: Speedier count(*) +Date: Wed, 10 Aug 2005 17:37:49 -0600 +X-Mailer: Apple Mail (2.730) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/101 +X-Sequence-Number: 13848 + +I have a web page for my customers that shows them count of records +and some min/max date ranges in each table of a database, as this is +how we bill them for service. They can log in and check the counts +at any time. I'd like for the counts to be as fresh as possible by +keeping this dynamic, but I will use a periodic 'snapshot'/cron job +if that is the only option to speed this up. I have thought about +using the table statistics, but the estimate error is probably +unacceptable because of the billing purposes. + +For some reason, the SQL Server we migrated the app from can return +count(*) in a split second on multi-million row tables, even though +it is a MUCH slower box hardware-wise, but it's now taking many +seconds to run. I have read in the archives the problems MVCC brings +into the count(*) dilemma forcing Pg to run a seq scan to get +counts. Does SQLServer not use MVCC or have they found another +approach for arriving at this number? Compounding all the min/max +and counts from other tables and all those queries take about a +minute to run. The tables will contain anywhere from 1 million to 40 +million rows. + +Also, I am using "select ... group by ... order by .. limit 1" to get +the min/max since I have already been bit by the issue of min() max() +being slower. + + +-Dan + + + +From pgsql-performance-owner@postgresql.org Wed Aug 10 21:23:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 27FAF52E73 + for ; + Wed, 10 Aug 2005 21:23:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35937-08 + for ; + Thu, 11 Aug 2005 00:23:32 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B2CF52E6F + for ; + Wed, 10 Aug 2005 21:23:32 -0300 (ADT) +Received: from [192.168.1.105] (clbb-248.saw.net [64.146.135.248]) + (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + j7B0MRef029344; Wed, 10 Aug 2005 17:22:27 -0700 +Message-ID: <42FA9A8B.1040400@commandprompt.com> +Date: Wed, 10 Aug 2005 17:23:39 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dan Harris +Cc: pgsql-performance@postgresql.org +Subject: Re: Speedier count(*) +References: <3E43C7D5-9DB8-4132-BF4F-607B000866E1@drivefaster.net> +In-Reply-To: <3E43C7D5-9DB8-4132-BF4F-607B000866E1@drivefaster.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); + Wed, 10 Aug 2005 17:22:28 -0700 (PDT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=[AWL=0.024] +X-Spam-Level: +X-Archive-Number: 200508/102 +X-Sequence-Number: 13849 + + +> Also, I am using "select ... group by ... order by .. limit 1" to get +> the min/max since I have already been bit by the issue of min() max() +> being slower. + +This specific instance is fixed in 8.1 + +Sincerely, + +Joshua D. Drake + + +> +> +> -Dan +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match + + +From pgsql-performance-owner@postgresql.org Wed Aug 10 21:36:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F04352E6F + for ; + Wed, 10 Aug 2005 21:36:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03660-02 + for ; + Thu, 11 Aug 2005 00:36:40 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 44DAD52E63 + for ; + Wed, 10 Aug 2005 21:36:40 -0300 (ADT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7B0aZSg047037 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Wed, 10 Aug 2005 18:36:37 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7B0aZgW069576; + Wed, 10 Aug 2005 18:36:35 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7B0aZIn069575; + Wed, 10 Aug 2005 18:36:35 -0600 (MDT) (envelope-from mfuhr) +Date: Wed, 10 Aug 2005 18:36:35 -0600 +From: Michael Fuhr +To: Dan Harris +Cc: pgsql-performance@postgresql.org +Subject: Re: Speedier count(*) +Message-ID: <20050811003635.GA69508@winnie.fuhr.org> +References: <3E43C7D5-9DB8-4132-BF4F-607B000866E1@drivefaster.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3E43C7D5-9DB8-4132-BF4F-607B000866E1@drivefaster.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/103 +X-Sequence-Number: 13850 + +On Wed, Aug 10, 2005 at 05:37:49PM -0600, Dan Harris wrote: +> Also, I am using "select ... group by ... order by .. limit 1" to get +> the min/max since I have already been bit by the issue of min() max() +> being slower. + +PostgreSQL 8.1 will have optimizations for certain MIN and MAX +queries. + +http://archives.postgresql.org/pgsql-committers/2005-04/msg00163.php +http://archives.postgresql.org/pgsql-committers/2005-04/msg00168.php + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Wed Aug 10 22:07:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C4B5252E84 + for ; + Wed, 10 Aug 2005 22:07:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62347-04 + for ; + Thu, 11 Aug 2005 01:07:53 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id BD28152E82 + for ; + Wed, 10 Aug 2005 22:07:51 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050811010754m92009iclke>; Thu, 11 Aug 2005 01:07:54 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id CA70256008; Wed, 10 Aug 2005 20:07:53 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id EE4C755FCC; + Wed, 10 Aug 2005 20:07:49 -0500 (CDT) +Message-ID: <42FAA4E6.5070703@arbash-meinel.com> +Date: Wed, 10 Aug 2005 20:07:50 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dan Harris +Cc: pgsql-performance@postgresql.org +Subject: Re: Speedier count(*) +References: <3E43C7D5-9DB8-4132-BF4F-607B000866E1@drivefaster.net> +In-Reply-To: <3E43C7D5-9DB8-4132-BF4F-607B000866E1@drivefaster.net> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig9CBF65940C3E69561ED666F5" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=[AWL=-0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/104 +X-Sequence-Number: 13851 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig9CBF65940C3E69561ED666F5 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Dan Harris wrote: +> I have a web page for my customers that shows them count of records and +> some min/max date ranges in each table of a database, as this is how we +> bill them for service. They can log in and check the counts at any +> time. I'd like for the counts to be as fresh as possible by keeping +> this dynamic, but I will use a periodic 'snapshot'/cron job if that is +> the only option to speed this up. I have thought about using the +> table statistics, but the estimate error is probably unacceptable +> because of the billing purposes. +> +> For some reason, the SQL Server we migrated the app from can return +> count(*) in a split second on multi-million row tables, even though it +> is a MUCH slower box hardware-wise, but it's now taking many seconds to +> run. I have read in the archives the problems MVCC brings into the +> count(*) dilemma forcing Pg to run a seq scan to get counts. Does +> SQLServer not use MVCC or have they found another approach for arriving +> at this number? Compounding all the min/max and counts from other +> tables and all those queries take about a minute to run. The tables +> will contain anywhere from 1 million to 40 million rows. + +I believe SQL Server doesn't use MVCC in the same way. At the very +least, it stores some row information in the index, so it can get some +info from just an index, without having to go to the actual page (MVCC +requires a main page visit to determine visibility.) + +Depending on how much it impacts performance, you can create an +INSERT/UPDATE trigger so that whenever a new entry is added, it +automatically updates a statistics table. It would be maintained as you +go, rather than periodically like a cron job. + +I would go Cron if things can be slightly out of date (like 1 hour at +least), and you need updates & inserts to not be slowed down. +Otherwise I think the trigger is nicer, since it doesn't do redundant +work, and means everything stays up-to-date. + + +> +> Also, I am using "select ... group by ... order by .. limit 1" to get +> the min/max since I have already been bit by the issue of min() max() +> being slower. +> +> +> -Dan + +John +=:-> + +--------------enig9CBF65940C3E69561ED666F5 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC+qTmJdeBCYSNAAMRAnFjAKCdP7B1WVO3pZtN1xlvJb3p6nbRVwCffPjY +60SZb50g1pbFtihFJ4AoZog= +=nZCQ +-----END PGP SIGNATURE----- + +--------------enig9CBF65940C3E69561ED666F5-- + +From pgsql-performance-owner@postgresql.org Thu Aug 11 00:15:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E299E52935 + for ; + Thu, 11 Aug 2005 00:15:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15238-08 + for ; + Thu, 11 Aug 2005 03:14:56 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D9D152BE5 + for ; + Thu, 11 Aug 2005 00:14:53 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7B3Eex3017715; + Wed, 10 Aug 2005 23:14:40 -0400 (EDT) +To: Tobias Brox +Cc: pgsql-performance@postgresql.org +Subject: Re: partial index regarded more expensive +In-reply-to: <20050810175208.GD6141@tobias.lan> +References: <20050810175208.GD6141@tobias.lan> +Comments: In-reply-to Tobias Brox + message dated "Wed, 10 Aug 2005 19:52:08 +0200" +Date: Wed, 10 Aug 2005 23:14:40 -0400 +Message-ID: <17714.1123730080@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/105 +X-Sequence-Number: 13852 + +Tobias Brox writes: +> This query puzzles me: +> select * from game where game_end>'2005-07-30' and state in (3,4); +> ... +> Now, how can the planner believe the game_by_state-index to be better? + +I suspect the problem has to do with lack of cross-column statistics. +The planner does not know that state=4 is correlated with game_end, +and it's probably coming up with some bogus guesses about the numbers +of index rows visited in each case. You haven't given enough info to +quantify this, though. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Aug 11 00:38:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D603452A06 + for ; + Thu, 11 Aug 2005 00:38:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30677-01 + for ; + Thu, 11 Aug 2005 03:37:58 +0000 (GMT) +Received: from smtp-gw.fnbs.net.my (smtp-gw.fnbs.net.my [202.9.108.191]) + by svr1.postgresql.org (Postfix) with ESMTP id E376352A92 + for ; + Thu, 11 Aug 2005 00:37:54 -0300 (ADT) +Received: from mail-std.fnbs.net.my (smtp-std.fnbs.net.my [202.9.108.197]) + by fnsrvlx9.fnbs.net.my (SMTP Mailer) with ESMTP id AA95752AD2 + for ; + Thu, 11 Aug 2005 11:37:51 +0800 (MYT) +Received: from Beh (unverified [203.106.54.162]) + by mail-std.fnbs.net.my (SurgeMail 3.0c2) with ESMTP id 17318585 + for ; + Thu, 11 Aug 2005 11:37:50 +0800 MYT +Message-ID: <002001c59e26$11bc5bf0$a279640a@Beh> +From: "Chun Yit(Chronos)" +To: +Subject: it is always delete temp table will slow down the postmaster? +Date: Thu, 11 Aug 2005 11:37:57 +0800 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_001D_01C59E69.1E7A1880" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.079 tagged_above=0 required=5 tests=[AWL=-0.007, + HTML_40_50=0.086, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/106 +X-Sequence-Number: 13853 + +This is a multi-part message in MIME format. + +------=_NextPart_000_001D_01C59E69.1E7A1880 +Content-Type: text/plain; + charset="gb2312" +Content-Transfer-Encoding: quoted-printable + +> +>hi, i got one situation here, i create one pl/pgsql function that using = +temp table to store temporary data. +>wherever i execute my function, i need to delete all the data inside = +the temp table, but this will slow down the=20 +>searching function if i conitnue to run the server because old tuples = +are not really clear if just using delete command. +>so i use drop table command and recreate the table. my question is, = +would it slow down the postmaster speed if i continue to=20 +>run this searching function more than 300 time per day?, cause the = +speed for execute searching function will graduatelly increase=20 +>after i test it for few day? anyway to test it is causing by the drop = +temp table and create temp table command? +> +>regards +>ivan +------=_NextPart_000_001D_01C59E69.1E7A1880 +Content-Type: text/html; + charset="gb2312" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
>
+
>hi, i got one situation here, i = +create one=20 +pl/pgsql function that using temp table to store temporary = +data.
+
>wherever i execute my function, i = +need to=20 +delete all the data inside the temp table, but this will slow down the=20 +
+
>searching function if i conitnue to = +run the=20 +server because old tuples are not really clear if just using delete=20 +command.
+
>so i use drop table command and = +recreate the=20 +table. my question is, would it slow down the postmaster speed if i = +continue to=20 +
+
>run this searching function more = +than 300 time=20 +per day?, cause the speed for execute searching function will = +graduatelly=20 +increase
+
>after i test it for few day? anyway = +to test it=20 +is causing by the drop temp table and create temp table = +command?
+
>
+
>regards
+
>ivan
+ +------=_NextPart_000_001D_01C59E69.1E7A1880-- + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 00:52:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 527DD52A90 + for ; + Thu, 11 Aug 2005 00:52:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30317-08 + for ; + Thu, 11 Aug 2005 03:52:18 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 9183752A2D + for ; + Thu, 11 Aug 2005 00:52:16 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j7B3q5KC032246; + Thu, 11 Aug 2005 13:52:05 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j7B3q4i6032243; Thu, 11 Aug 2005 13:52:05 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Thu, 11 Aug 2005 13:52:04 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Dan Harris +Cc: pgsql-performance@postgresql.org +Subject: Re: Speedier count(*) +In-Reply-To: <3E43C7D5-9DB8-4132-BF4F-607B000866E1@drivefaster.net> +Message-ID: +References: <3E43C7D5-9DB8-4132-BF4F-607B000866E1@drivefaster.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=[AWL=0.002] +X-Spam-Level: +X-Archive-Number: 200508/107 +X-Sequence-Number: 13854 + +Hi Dan, + +On Wed, 10 Aug 2005, Dan Harris wrote: + +> I have a web page for my customers that shows them count of records +> and some min/max date ranges in each table of a database, as this is +> how we bill them for service. They can log in and check the counts +> at any time. I'd like for the counts to be as fresh as possible by +> keeping this dynamic, but I will use a periodic 'snapshot'/cron job +> if that is the only option to speed this up. I have thought about +> using the table statistics, but the estimate error is probably +> unacceptable because of the billing purposes. +> +> For some reason, the SQL Server we migrated the app from can return +> count(*) in a split second on multi-million row tables, even though +> it is a MUCH slower box hardware-wise, but it's now taking many +> seconds to run. I have read in the archives the problems MVCC brings +> into the count(*) dilemma forcing Pg to run a seq scan to get +> counts. Does SQLServer not use MVCC or have they found another + +SQL Server probably jumps through a lot of hoops to do fast count(*)s. I'm +sure we could do something similar -- it's just a question of complexity, +resources, desirability, etc. The are other solutions, which makes the +idea of doing it less attractive still. + +> approach for arriving at this number? Compounding all the min/max +> and counts from other tables and all those queries take about a +> minute to run. The tables will contain anywhere from 1 million to 40 +> million rows. +> +> Also, I am using "select ... group by ... order by .. limit 1" to get +> the min/max since I have already been bit by the issue of min() max() +> being slower. + +I generally pre generate the results. There are two ways to do this: the +'snapshot'/cronjon you mentioned or using rules and triggers to maintain +'count' tables. The idea is that if data is added, modified or removed +from your table, you modify counters in these other tables. + +Alternatively, feel free to post your schema and sample queries with +explain analyze results to this list. Alternatively, jump on irc at +irc.freenode.net #postgresql and someone will be more than happy to look +through the problem in more detail. + +Thanks, + +Gavin + +From pgsql-performance-owner@postgresql.org Thu Aug 11 01:40:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A6DC52BA3 + for ; + Thu, 11 Aug 2005 01:40:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62552-07 + for ; + Thu, 11 Aug 2005 04:40:28 +0000 (GMT) +Received: from smtp012.mail.yahoo.com (smtp012.mail.yahoo.com + [216.136.173.32]) + by svr1.postgresql.org (Postfix) with SMTP id 8619352B8A + for ; + Thu, 11 Aug 2005 01:40:26 -0300 (ADT) +Received: (qmail 51100 invoked from network); 11 Aug 2005 04:40:26 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Received:User-Agent:Date:Subject:From:To:CC:Message-ID:In-Reply-To:Mime-version:Content-type:Content-transfer-encoding; + b=e6eQgLap2fiU6CVjlsiB7XM+zRLwnOq7Yp2xP5KPhtfQv8SsWP1bQjcwLNv6mZlBoJUhi0gvRSAqAzVQg/5YZVbugHx97sHG5K6P4E5/c1mhSUs1lmgUbnpgKSebH7vjmjFMqifBaHFZuvzStvYe+CAeV8x9hOipzf/PcLV6oKQ= + ; +Received: from unknown (HELO ?192.168.0.103?) (mcotner@66.56.49.200 with + login) + by smtp012.mail.yahoo.com with SMTP; 11 Aug 2005 04:40:25 -0000 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Thu, 11 Aug 2005 00:40:23 -0400 +Subject: Re: Speedier count(*) +From: Mark Cotner +To: Gavin Sherry , + Dan Harris +Cc: +Message-ID: +In-Reply-To: +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.374 tagged_above=0 required=5 + tests=[DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/108 +X-Sequence-Number: 13855 + +Here's a trigger I wrote to perform essentially the same purpose. The nice +thing about this is it keeps the number up to date for you, but you do incur +slight overhead. + +CREATE TABLE test (id serial primary key, name varchar(20)); + +CREATE TABLE rowcount (tablename varchar(50), rowcount bigint default 0); +CREATE INDEX rowcount_tablename ON rowcount(tablename); + +CREATE OR REPLACE FUNCTION del_rowcount() RETURNS trigger AS $$ +BEGIN + UPDATE rowcount SET rowcount = rowcount-1 WHERE tablename = TG_RELNAME; + RETURN OLD; +END; +$$ LANGUAGE PLPGSQL; + +CREATE OR REPLACE FUNCTION add_rowcount() RETURNS trigger AS $$ +BEGIN + UPDATE rowcount SET rowcount = rowcount+1 WHERE tablename = TG_RELNAME; + RETURN NEW; +END; +$$ LANGUAGE PLPGSQL; + +CREATE TRIGGER del_rowcount_tr BEFORE DELETE ON test FOR EACH ROW EXECUTE + PROCEDURE del_rowcount(); +CREATE TRIGGER add_rowcount_tr BEFORE INSERT ON test FOR EACH ROW EXECUTE + PROCEDURE add_rowcount(); + +INSERT INTO rowcount (tablename) VALUES ('test'); + +root=# select * from test; + id | name +----+------ +(0 rows) + +Time: 0.934 ms +root=# select * from rowcount; + tablename | rowcount +-----------+---------- + test | 0 +(1 row) + +Time: 0.630 ms +root=# insert into test (name) values ('blah'); +INSERT 1190671626 1 +Time: 3.278 ms +root=# select * from test; + id | name +----+------ + 5 | blah +(1 row) + +Time: 0.612 ms +root=# select * from rowcount; + tablename | rowcount +-----------+---------- + test | 1 +(1 row) + +Time: 0.640 ms +root=# insert into test (name) values ('blah'); +INSERT 1190671627 1 +Time: 1.677 ms +root=# select * from test; + id | name +----+------ + 5 | blah + 6 | blah +(2 rows) + +Time: 0.653 ms +root=# select * from rowcount; + tablename | rowcount +-----------+---------- + test | 2 +(1 row) + +Time: 0.660 ms +root=# delete from test where id = 6; +DELETE 1 +Time: 2.412 ms +root=# select * from test; + id | name +----+------ + 5 | blah +(1 row) + +Time: 0.631 ms +root=# select * from rowcount; + tablename | rowcount +-----------+---------- + test | 1 +(1 row) + +Time: 0.609 ms + +One thing to be mindful of . . . Truncate is NOT accounted for with this, +and unfortunately the rule system doesn't allow truncate operations so you +can't work around it that way. + +'njoy, +Mark + + +On 8/10/05 11:52 PM, "Gavin Sherry" wrote: + +> Hi Dan, +> +> On Wed, 10 Aug 2005, Dan Harris wrote: +> +>> I have a web page for my customers that shows them count of records +>> and some min/max date ranges in each table of a database, as this is +>> how we bill them for service. They can log in and check the counts +>> at any time. I'd like for the counts to be as fresh as possible by +>> keeping this dynamic, but I will use a periodic 'snapshot'/cron job +>> if that is the only option to speed this up. I have thought about +>> using the table statistics, but the estimate error is probably +>> unacceptable because of the billing purposes. +>> +>> For some reason, the SQL Server we migrated the app from can return +>> count(*) in a split second on multi-million row tables, even though +>> it is a MUCH slower box hardware-wise, but it's now taking many +>> seconds to run. I have read in the archives the problems MVCC brings +>> into the count(*) dilemma forcing Pg to run a seq scan to get +>> counts. Does SQLServer not use MVCC or have they found another +> +> SQL Server probably jumps through a lot of hoops to do fast count(*)s. I'm +> sure we could do something similar -- it's just a question of complexity, +> resources, desirability, etc. The are other solutions, which makes the +> idea of doing it less attractive still. +> +>> approach for arriving at this number? Compounding all the min/max +>> and counts from other tables and all those queries take about a +>> minute to run. The tables will contain anywhere from 1 million to 40 +>> million rows. +>> +>> Also, I am using "select ... group by ... order by .. limit 1" to get +>> the min/max since I have already been bit by the issue of min() max() +>> being slower. +> +> I generally pre generate the results. There are two ways to do this: the +> 'snapshot'/cronjon you mentioned or using rules and triggers to maintain +> 'count' tables. The idea is that if data is added, modified or removed +> from your table, you modify counters in these other tables. +> +> Alternatively, feel free to post your schema and sample queries with +> explain analyze results to this list. Alternatively, jump on irc at +> irc.freenode.net #postgresql and someone will be more than happy to look +> through the problem in more detail. +> +> Thanks, +> +> Gavin +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly + + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 03:39:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6056E52EB5 + for ; + Thu, 11 Aug 2005 03:39:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19197-09 + for ; + Thu, 11 Aug 2005 06:39:49 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EB75452EB2 + for ; + Thu, 11 Aug 2005 03:39:48 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 7C3663095A; Thu, 11 Aug 2005 08:49:47 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: it is always delete temp table will slow down the postmaster? +Date: Thu, 11 Aug 2005 14:37:20 +0800 +Organization: Hub.Org Networking Services +Lines: 17 +Message-ID: +References: <002001c59e26$11bc5bf0$a279640a@Beh> +Reply-To: "Qingqing Zhou" +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.185 tagged_above=0 required=5 tests=[AWL=-0.000, + PRIORITY_NO_NAME=1.185] +X-Spam-Level: * +X-Archive-Number: 200508/109 +X-Sequence-Number: 13856 + + +""Chun Yit(Chronos)"" writes +> +>hi, i got one situation here, i create one pl/pgsql function that using +temp table to store temporary data. +>wherever i execute my function, i need to delete all the data inside the +temp table, but this will slow down the +>searching function if i conitnue to run the server because old tuples are +not really clear if just using delete command. +>so i use drop table command and recreate the table. + +A better way to empty a table fast is "truncate table". + +Regards, +Qingqing + + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 04:03:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BB0FF52EAF + for ; + Thu, 11 Aug 2005 04:03:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88485-01 + for ; + Thu, 11 Aug 2005 07:03:28 +0000 (GMT) +Received: from smtp-gw.fnbs.net.my (smtp-gw.fnbs.net.my [202.9.108.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 0199252EAB + for ; + Thu, 11 Aug 2005 04:03:26 -0300 (ADT) +Received: from mail-std.fnbs.net.my (smtp-std.fnbs.net.my [202.9.108.197]) + by fnsrvlx9.fnbs.net.my (SMTP Mailer) with ESMTP id 5F8C252B51 + for ; + Thu, 11 Aug 2005 15:03:25 +0800 (MYT) +Received: from Beh (unverified [203.106.54.162]) + by mail-std.fnbs.net.my (SurgeMail 3.0c2) with ESMTP id 17330523 + for multiple; Thu, 11 Aug 2005 15:03:24 +0800 MYT +Message-ID: <001001c59e42$c9e9cca0$a279640a@Beh> +From: "Chun Yit(Chronos)" +To: "Qingqing Zhou" , + +References: <002001c59e26$11bc5bf0$a279640a@Beh> +Subject: Re: it is always delete temp table will slow down the postmaster? +Date: Thu, 11 Aug 2005 15:03:30 +0800 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.038 tagged_above=0 required=5 tests=[AWL=0.038] +X-Spam-Level: +X-Archive-Number: 200508/110 +X-Sequence-Number: 13857 + + +----- Original Message ----- +From: "Qingqing Zhou" +To: +Sent: Thursday, August 11, 2005 2:37 PM +Subject: Re: [PERFORM] it is always delete temp table will slow down the +postmaster? + + +> +> ""Chun Yit(Chronos)"" writes +>> +>>hi, i got one situation here, i create one pl/pgsql function that using +> temp table to store temporary data. +>>wherever i execute my function, i need to delete all the data inside the +> temp table, but this will slow down the +>>searching function if i conitnue to run the server because old tuples are +> not really clear if just using delete command. +>>so i use drop table command and recreate the table. +> +> A better way to empty a table fast is "truncate table". +> +> Regards, +> Qingqing +> + +>sorry, but truncate table cannot use inside function, any other way ? +>Regards +>ivan +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> +> +> -- +> No virus found in this incoming message. +> Checked by AVG Anti-Virus. +> Version: 7.0.338 / Virus Database: 267.10.5/68 - Release Date: 10/Aug/05 +> + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 04:24:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DFC6952EB3 + for ; + Thu, 11 Aug 2005 04:24:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19591-04 + for ; + Thu, 11 Aug 2005 07:24:17 +0000 (GMT) +Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) + by svr1.postgresql.org (Postfix) with ESMTP id 7546752EC0 + for ; + Thu, 11 Aug 2005 04:24:16 -0300 (ADT) +Received: from [192.168.178.99] (p548B2D2C.dip0.t-ipconnect.de [84.139.45.44]) + by service-web.de (Postfix) with ESMTP id 0078A200039; + Thu, 11 Aug 2005 09:24:16 +0200 (CEST) +Subject: Re: Speedier count(*) +From: Tino Wildenhain +To: Mark Cotner +Cc: Gavin Sherry , + Dan Harris , pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Date: Thu, 11 Aug 2005 09:24:08 +0200 +Message-Id: <1123745049.27613.1.camel@Andrea.peacock.de> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.234 tagged_above=0 required=5 tests=[AWL=-0.023, + FORGED_RCVD_HELO=0.05, UPPERCASE_25_50=0.207] +X-Spam-Level: +X-Archive-Number: 200508/111 +X-Sequence-Number: 13858 + +Am Donnerstag, den 11.08.2005, 00:40 -0400 schrieb Mark Cotner: +> Here's a trigger I wrote to perform essentially the same purpose. The nice +> thing about this is it keeps the number up to date for you, but you do incur +> slight overhead. +... +> +> CREATE TRIGGER del_rowcount_tr BEFORE DELETE ON test FOR EACH ROW EXECUTE +> PROCEDURE del_rowcount(); +> CREATE TRIGGER add_rowcount_tr BEFORE INSERT ON test FOR EACH ROW EXECUTE +> PROCEDURE add_rowcount(); +> +> INSERT INTO rowcount (tablename) VALUES ('test'); +... + +beware of problems with concurrency and even what happens +if transactions roll back. Maybe you can "fix" it a bit +by regulary correcting the count via cronjob or so. + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 07:37:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F040C52C7B + for ; + Thu, 11 Aug 2005 07:37:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48389-04 + for ; + Thu, 11 Aug 2005 10:37:13 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 9783D52C57 + for ; + Thu, 11 Aug 2005 07:37:11 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j7BAaxYu001724; + Thu, 11 Aug 2005 20:36:59 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j7BAawZg001721; Thu, 11 Aug 2005 20:36:58 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Thu, 11 Aug 2005 20:36:58 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Tino Wildenhain +Cc: Mark Cotner , + Dan Harris , pgsql-performance@postgresql.org +Subject: Re: Speedier count(*) +In-Reply-To: <1123745049.27613.1.camel@Andrea.peacock.de> +Message-ID: +References: + <1123745049.27613.1.camel@Andrea.peacock.de> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=[AWL=0.002] +X-Spam-Level: +X-Archive-Number: 200508/112 +X-Sequence-Number: 13859 + +On Thu, 11 Aug 2005, Tino Wildenhain wrote: + +> Am Donnerstag, den 11.08.2005, 00:40 -0400 schrieb Mark Cotner: +> > Here's a trigger I wrote to perform essentially the same purpose. The nice +> > thing about this is it keeps the number up to date for you, but you do incur +> > slight overhead. +> ... +> > +> > CREATE TRIGGER del_rowcount_tr BEFORE DELETE ON test FOR EACH ROW EXECUTE +> > PROCEDURE del_rowcount(); +> > CREATE TRIGGER add_rowcount_tr BEFORE INSERT ON test FOR EACH ROW EXECUTE +> > PROCEDURE add_rowcount(); +> > +> > INSERT INTO rowcount (tablename) VALUES ('test'); +> ... +> +> beware of problems with concurrency and even what happens +> if transactions roll back. Maybe you can "fix" it a bit +> by regulary correcting the count via cronjob or so. + +What problems? MVCC takes care of this. + +Gavin + +From pgsql-performance-owner@postgresql.org Thu Aug 11 07:52:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 33C9C52C7B + for ; + Thu, 11 Aug 2005 07:52:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23319-10 + for ; + Thu, 11 Aug 2005 10:52:16 +0000 (GMT) +Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F7FA52C57 + for ; + Thu, 11 Aug 2005 07:52:15 -0300 (ADT) +Received: from [192.168.178.99] (p548B2D2C.dip0.t-ipconnect.de [84.139.45.44]) + by service-web.de (Postfix) with ESMTP id BB354200039; + Thu, 11 Aug 2005 12:52:17 +0200 (CEST) +Subject: Re: Speedier count(*) +From: Tino Wildenhain +To: Gavin Sherry +Cc: Mark Cotner , + Dan Harris , pgsql-performance@postgresql.org +In-Reply-To: +References: + <1123745049.27613.1.camel@Andrea.peacock.de> + +Content-Type: text/plain +Date: Thu, 11 Aug 2005 12:52:16 +0200 +Message-Id: <1123757536.27613.10.camel@Andrea.peacock.de> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.106 tagged_above=0 required=5 tests=[AWL=0.056, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/113 +X-Sequence-Number: 13860 + +Am Donnerstag, den 11.08.2005, 20:36 +1000 schrieb Gavin Sherry: +> On Thu, 11 Aug 2005, Tino Wildenhain wrote: +> +> > Am Donnerstag, den 11.08.2005, 00:40 -0400 schrieb Mark Cotner: +> > > Here's a trigger I wrote to perform essentially the same purpose. The nice +> > > thing about this is it keeps the number up to date for you, but you do incur +> > > slight overhead. +> > ... +> > > +> > > CREATE TRIGGER del_rowcount_tr BEFORE DELETE ON test FOR EACH ROW EXECUTE +> > > PROCEDURE del_rowcount(); +> > > CREATE TRIGGER add_rowcount_tr BEFORE INSERT ON test FOR EACH ROW EXECUTE +> > > PROCEDURE add_rowcount(); +> > > +> > > INSERT INTO rowcount (tablename) VALUES ('test'); +> > ... +> > +> > beware of problems with concurrency and even what happens +> > if transactions roll back. Maybe you can "fix" it a bit +> > by regulary correcting the count via cronjob or so. +> +> What problems? MVCC takes care of this. + +Actually in this case MVCC works against you. +Just imagine some competing transactions to insert +end delete at will. + +You could lock the count table to prevent the problem +where 2 competing transactions do an insert, read the +start value and add 1 to it and then write the result +- which is n+1 rather then n+2 - so you are off by one. +Think of the same when one transaction inserts 100 +and the other 120. Then you could even be off by 100. + +But locking probably gets your worser performance then +simply count(*) all the time if you insert a lot. Also +prepare for the likeness of deadlocks. + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 08:33:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0762B52822 + for ; + Thu, 11 Aug 2005 08:33:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49088-10 + for ; + Thu, 11 Aug 2005 11:33:43 +0000 (GMT) +Received: from www.almabioinfo.com (www.almabioinfo.com [62.14.232.115]) + by svr1.postgresql.org (Postfix) with ESMTP id AFF7B52D1F + for ; + Thu, 11 Aug 2005 08:33:35 -0300 (ADT) +Received: from [192.168.1.60] (stargate.almabioinfo.com [62.14.232.114]) + by www.almabioinfo.com (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) with ESMTP + id j7BBXc830625 + for ; Thu, 11 Aug 2005 13:33:38 +0200 +Message-ID: <42FB3791.2060200@almabioinfo.com> +Date: Thu, 11 Aug 2005 13:33:37 +0200 +From: Luis Cornide Arce +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: es-es, es +MIME-Version: 1.0 +To: PGSL-PERFORMANCE LIST +Subject: Why is not using the index +Content-Type: multipart/alternative; + boundary="------------020405020706050801010200" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.073 tagged_above=0 required=5 + tests=[HTML_60_70=0.027, HTML_MESSAGE=0.001, HTML_TITLE_EMPTY=0.045] +X-Spam-Level: +X-Archive-Number: 200508/114 +X-Sequence-Number: 13861 + +This is a multi-part message in MIME format. +--------------020405020706050801010200 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Hi everyone, + +I have some problems with a quite long query and the plan postgreSQL is +choosing. The query joins 12 tables and in the WHERE clause I use a IN +expression with a lot of identifiers (up to 2000). The problem is that +the planner is proposing a seq_scan on two tables 2M rows each +(internalexpressionprofile and expressionprofile) + +I have just try this query (after doing a vacuum analyze), in the 'IN' +clause there are 1552 identifiers, and the query should return 14K rows. +I'm using a PostgreSQL 8.0.2 on a SuSE 8.1 with 1GB of RAM. + +explain analyze SELECT DISTINCT rset.replicatesetid, tra.value as value, +tra.expressionprofileid, rep.*, epg.expprogeneid, con.ordinal +FROM expprogene epg JOIN reporter rep ON +(epg.reporterid=rep.reporterid), expressionprofile epro, +transformedexpressionprofile tra, internalexpressionprofile int, +meanvalues mea, replicateset rset, replicateset_condition rsco, +condition con, +"CLUSTER" clu, clustertree tre, clusteranalysis an +WHERE epg.expprogeneid IN (80174,84567,...) AND +epg.expprogeneid=epro.expprogeneid +AND epro.expressionprofileid=tra.expressionprofileid AND +tra.expressionprofileid=int.expressionprofileid +AND int.meanvaluesid=mea.meanvaluesid AND +mea.replicatesetid=rset.replicatesetid +AND rset.replicatesetid=rsco.replicatesetid AND +rsco.conditionid=con.conditionid +AND tra.clusterid=clu.clusterid AND clu.clustertreeid=tre.clustertreeid +AND tre.clustertreeid=an.genetreeid +AND an.clusteranalysisid=1 AND con.clusteranalysisid = an.clusteranalysisid +ORDER BY epg.expprogeneid, con.ordinal; + +The plan... + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Unique (cost=129132.53..129132.59 rows=2 width=150) (actual +time=12637.224..12676.016 rows=13968 loops=1) + -> Sort (cost=129132.53..129132.54 rows=2 width=150) (actual +time=12637.217..12646.484 rows=13968 loops=1) + Sort Key: epg.expprogeneid, con.ordinal, rset.replicatesetid, +tra.value, tra.expressionprofileid, rep.reporterid, rep.name, +rep.anotation, rep.otherinfo, rep.incidences + -> Nested Loop (cost=62927.42..129132.52 rows=2 width=150) +(actual time=7112.942..12586.314 rows=13968 loops=1) + Join Filter: ("outer".genetreeid = "inner".clustertreeid) + -> Nested Loop (cost=62927.42..127893.86 rows=409 +width=162) (actual time=7112.864..11960.324 rows=41904 loops=1) + -> Nested Loop (cost=62927.42..125727.31 rows=369 +width=154) (actual time=7112.825..11500.645 rows=13968 loops=1) + -> Merge Join (cost=3.02..7.70 rows=1 +width=12) (actual time=0.057..0.073 rows=1 loops=1) + Merge Cond: ("outer".clustertreeid = +"inner".genetreeid) + -> Index Scan using clustertree_pk on +clustertree tre (cost=0.00..4.35 rows=123 width=4) (actual +time=0.017..0.024 rows=2 loops=1) + -> Sort (cost=3.02..3.03 rows=1 +width=8) (actual time=0.028..0.030 rows=1 loops=1) + Sort Key: an.genetreeid + -> Index Scan using +clusteranalysis_pk on clusteranalysis an (cost=0.00..3.01 rows=1 +width=8) (actual time=0.015..0.018 rows=1 loops=1) + Index Cond: +(clusteranalysisid = 1) + -> Hash Join (cost=62924.39..125715.53 +rows=408 width=150) (actual time=7112.758..11455.797 rows=13968 loops=1) + Hash Cond: ("outer".expressionprofileid += "inner".expressionprofileid) + -> Hash Join (cost=15413.58..78079.33 +rows=24339 width=134) (actual time=1489.347..5721.306 rows=41904 loops=1) + Hash Cond: ("outer".expprogeneid += "inner".expprogeneid) + -> Seq Scan on expressionprofile +epro (cost=0.00..48263.24 rows=2831824 width=8) (actual +time=0.039..3097.656 rows=2839676 loops=1) + -> Hash +(cost=15409.72..15409.72 rows=1546 width=130) (actual +time=43.365..43.365 rows=0 loops=1) + -> Nested Loop +(cost=0.00..15409.72 rows=1546 width=130) (actual time=0.056..40.637 +rows=1552 loops=1) + -> Index Scan using +expprogene_pk, expprogene_pk, [......] on expprogene epg +(cost=0.00..10698.83 rows=1546 width=8) (actual time=0.027..15.907 +rows=1552 loops=1) + Index Cond: +((expprogeneid = 80174) OR (expprogeneid = 84567) OR (expprogeneid = +83608) OR [OR ....]) + -> Index Scan using +reporter_pkey on reporter rep (cost=0.00..3.03 rows=1 width=126) +(actual time=0.009..0.010 rows=1 loops=1552) + Index Cond: +("outer".reporterid = rep.reporterid) + -> Hash (cost=47403.68..47403.68 +rows=42853 width=16) (actual time=5623.174..5623.174 rows=0 loops=1) + -> Hash Join +(cost=2369.91..47403.68 rows=42853 width=16) (actual +time=346.040..5538.571 rows=75816 loops=1) + Hash Cond: +("outer".meanvaluesid = "inner".meanvaluesid) + -> Seq Scan on +internalexpressionprofile "int" (cost=0.00..34506.16 rows=2019816 +width=8) (actual time=0.003..2231.427 rows=2019816 loops=1) + -> Hash +(cost=2262.78..2262.78 rows=42853 width=16) (actual +time=345.803..345.803 rows=0 loops=1) + -> Nested Loop +(cost=17.49..2262.78 rows=42853 width=16) (actual time=1.965..259.363 +rows=75816 loops=1) + -> Hash Join +(cost=17.49..28.42 rows=6 width=16) (actual time=1.881..2.387 rows=9 +loops=1) + Hash +Cond: ("outer".replicatesetid = "inner".replicatesetid) + -> Seq +Scan on replicateset rset (cost=0.00..9.58 rows=258 width=4) (actual +time=0.003..0.295 rows=258 loops=1) + -> Hash +(cost=17.47..17.47 rows=6 width=12) (actual time=1.575..1.575 rows=0 +loops=1) + -> +Hash Join (cost=3.17..17.47 rows=6 width=12) (actual time=0.315..1.557 +rows=9 loops=1) + +Hash Cond: ("outer".conditionid = "inner".conditionid) + +-> Seq Scan on replicateset_condition rsco (cost=0.00..10.83 rows=683 +width=8) (actual time=0.004..0.688 rows=683 loops=1) + +-> Hash (cost=3.14..3.14 rows=9 width=12) (actual time=0.059..0.059 +rows=0 loops=1) + +-> Index Scan using clustering_analysis_fk on condition con +(cost=0.00..3.14 rows=9 width=12) (actual time=0.019..0.039 rows=9 loops=1) + +Index Cond: (clusteranalysisid = 1) + -> Index Scan +using has_meanvalues_fk on meanvalues mea (cost=0.00..264.03 rows=8669 +width=8) (actual time=0.027..13.032 rows=8424 loops=9) + Index +Cond: ("outer".replicatesetid = mea.replicatesetid) + -> Index Scan using comes_from_raw_fk on +transformedexpressionprofile tra (cost=0.00..5.86 rows=1 width=16) +(actual time=0.010..0.018 rows=3 loops=13968) + Index Cond: (tra.expressionprofileid = +"outer".expressionprofileid) + -> Index Scan using _cluster__pk on "CLUSTER" clu +(cost=0.00..3.01 rows=1 width=8) (actual time=0.009..0.010 rows=1 +loops=41904) + Index Cond: ("outer".clusterid = clu.clusterid) + Total runtime: 12696.289 ms +(48 rows) + +I tried setting the enable_seq_scan to off and the query's runtime +returned by the explain analyze is 4000ms. +Why postgre is not using the indexes? +What is the real impact of having such a big 'IN' clause? + + +Thanks in advance, + +Luis Cornide + +--------------020405020706050801010200 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + + +Hi everyone,
+
+I have some problems with a quite long query and the plan postgreSQL is +choosing. The query joins 12 tables and in the WHERE clause I use a IN +expression with a lot of identifiers (up to 2000). The problem is that +the planner is proposing a seq_scan on two tables 2M rows each (
internalexpressionprofile and +expressionprofile)
+
+I have just try this query (after doing a vacuum analyze), in the 'IN' +clause there are 1552 identifiers, and the query should return 14K rows.
+I'm using a PostgreSQL 8.0.2 on a SuSE 8.1 with 1GB of RAM.
+
+explain analyze SELECT DISTINCT rset.replicatesetid, tra.value as +value, tra.expressionprofileid, rep.*, epg.expprogeneid,  con.ordinal
+FROM expprogene epg JOIN reporter rep ON  +(epg.reporterid=rep.reporterid), expressionprofile epro,
+transformedexpressionprofile tra, internalexpressionprofile int,
+meanvalues mea, replicateset rset, replicateset_condition rsco, +condition con,
+"CLUSTER" clu, clustertree tre, clusteranalysis an
+WHERE epg.expprogeneid IN (80174,84567,...) AND +epg.expprogeneid=epro.expprogeneid
+AND epro.expressionprofileid=tra.expressionprofileid AND +tra.expressionprofileid=int.expressionprofileid
+AND int.meanvaluesid=mea.meanvaluesid AND +mea.replicatesetid=rset.replicatesetid
+AND rset.replicatesetid=rsco.replicatesetid AND +rsco.conditionid=con.conditionid
+AND tra.clusterid=clu.clusterid AND clu.clustertreeid=tre.clustertreeid +AND tre.clustertreeid=an.genetreeid
+AND an.clusteranalysisid=1 AND con.clusteranalysisid = +an.clusteranalysisid
+ORDER BY epg.expprogeneid, con.ordinal;
+
+The plan...
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Unique  (cost=129132.53..129132.59 rows=2 width=150) (actual +time=12637.224..12676.016 rows=13968 loops=1)
+   ->  Sort  (cost=129132.53..129132.54 rows=2 width=150) (actual +time=12637.217..12646.484 rows=13968 loops=1)
+         Sort Key: epg.expprogeneid, con.ordinal, rset.replicatesetid, +tra.value, tra.expressionprofileid, rep.reporterid, rep.name, +rep.anotation, rep.otherinfo, rep.incidences
+         ->  Nested Loop  (cost=62927.42..129132.52 rows=2 +width=150) (actual time=7112.942..12586.314 rows=13968 loops=1)
+               Join Filter: ("outer".genetreeid = "inner".clustertreeid)
+               ->  Nested Loop  (cost=62927.42..127893.86 rows=409 +width=162) (actual time=7112.864..11960.324 rows=41904 loops=1)
+                     ->  Nested Loop  (cost=62927.42..125727.31 +rows=369 width=154) (actual time=7112.825..11500.645 rows=13968 loops=1)
+                           ->  Merge Join  (cost=3.02..7.70 rows=1 +width=12) (actual time=0.057..0.073 rows=1 loops=1)
+                                 Merge Cond: ("outer".clustertreeid = +"inner".genetreeid)
+                                 ->  Index Scan using clustertree_pk +on clustertree tre  (cost=0.00..4.35 rows=123 width=4) (actual +time=0.017..0.024 rows=2 loops=1)
+                                 ->  Sort  (cost=3.02..3.03 rows=1 +width=8) (actual time=0.028..0.030 rows=1 loops=1)
+                                       Sort Key: an.genetreeid
+                                       ->  Index Scan using +clusteranalysis_pk on clusteranalysis an  (cost=0.00..3.01 rows=1 +width=8) (actual time=0.015..0.018 rows=1 loops=1)
+                                             Index Cond: +(clusteranalysisid = 1)
+                           ->  Hash Join  (cost=62924.39..125715.53 +rows=408 width=150) (actual time=7112.758..11455.797 rows=13968 loops=1)
+                                 Hash Cond: +("outer".expressionprofileid = "inner".expressionprofileid)
+                                 ->  Hash Join  +(cost=15413.58..78079.33 rows=24339 width=134) (actual +time=1489.347..5721.306 rows=41904 loops=1)
+                                       Hash Cond: ("outer".expprogeneid += "inner".expprogeneid)
+                                       ->  Seq Scan on +expressionprofile epro  (cost=0.00..48263.24 rows=2831824 width=8) +(actual time=0.039..3097.656 rows=2839676 loops=1)
+                                       ->  Hash  +(cost=15409.72..15409.72 rows=1546 width=130) (actual +time=43.365..43.365 rows=0 loops=1)
+                                             ->  Nested Loop  +(cost=0.00..15409.72 rows=1546 width=130) (actual time=0.056..40.637 +rows=1552 loops=1)
+                                                   ->  Index Scan +using expprogene_pk, expprogene_pk, [......] on expprogene epg  +(cost=0.00..10698.83 rows=1546 width=8) (actual time=0.027..15.907 +rows=1552 loops=1)
+                                                         Index Cond: +((expprogeneid = 80174) OR (expprogeneid = 84567) OR (expprogeneid = +83608) OR [OR ....])
+                                                   ->  Index Scan +using reporter_pkey on reporter rep  (cost=0.00..3.03 rows=1 width=126) +(actual time=0.009..0.010 rows=1 loops=1552)
+                                                         Index Cond: +("outer".reporterid = rep.reporterid)
+                                 ->  Hash  (cost=47403.68..47403.68 +rows=42853 width=16) (actual time=5623.174..5623.174 rows=0 loops=1)
+                                       ->  Hash Join  +(cost=2369.91..47403.68 rows=42853 width=16) (actual +time=346.040..5538.571 rows=75816 loops=1)
+                                             Hash Cond: +("outer".meanvaluesid = "inner".meanvaluesid)
+                                             ->  Seq Scan on +internalexpressionprofile "int"  (cost=0.00..34506.16 rows=2019816 +width=8) (actual time=0.003..2231.427 rows=2019816 loops=1)
+                                             ->  Hash  +(cost=2262.78..2262.78 rows=42853 width=16) (actual +time=345.803..345.803 rows=0 loops=1)
+                                                   ->  Nested Loop  +(cost=17.49..2262.78 rows=42853 width=16) (actual time=1.965..259.363 +rows=75816 loops=1)
+                                                         ->  Hash +Join  (cost=17.49..28.42 rows=6 width=16) (actual time=1.881..2.387 +rows=9 loops=1)
+                                                               Hash +Cond: ("outer".replicatesetid = "inner".replicatesetid)
+                                                               ->  +Seq Scan on replicateset rset  (cost=0.00..9.58 rows=258 width=4) +(actual time=0.003..0.295 rows=258 loops=1)
+                                                               ->  +Hash  (cost=17.47..17.47 rows=6 width=12) (actual time=1.575..1.575 +rows=0 loops=1)
+                                                                     +->  Hash Join  (cost=3.17..17.47 rows=6 width=12) (actual +time=0.315..1.557 rows=9 loops=1)
+                                                                           +Hash Cond: ("outer".conditionid = "inner".conditionid)
+                                                                           +->  Seq Scan on replicateset_condition rsco  (cost=0.00..10.83 +rows=683 width=8) (actual time=0.004..0.688 rows=683 loops=1)
+                                                                           +->  Hash  (cost=3.14..3.14 rows=9 width=12) (actual +time=0.059..0.059 rows=0 loops=1)
+                                                                                 +->  Index Scan using clustering_analysis_fk on condition con  +(cost=0.00..3.14 rows=9 width=12) (actual time=0.019..0.039 rows=9 +loops=1)
+                                                                                       +Index Cond: (clusteranalysisid = 1)
+                                                         ->  Index +Scan using has_meanvalues_fk on meanvalues mea  (cost=0.00..264.03 +rows=8669 width=8) (actual time=0.027..13.032 rows=8424 loops=9)
+                                                               Index +Cond: ("outer".replicatesetid = mea.replicatesetid)
+                     ->  Index Scan using comes_from_raw_fk on +transformedexpressionprofile tra  (cost=0.00..5.86 rows=1 width=16) +(actual time=0.010..0.018 rows=3 loops=13968)
+                           Index Cond: (tra.expressionprofileid = +"outer".expressionprofileid)
+               ->  Index Scan using _cluster__pk on "CLUSTER" clu  +(cost=0.00..3.01 rows=1 width=8) (actual time=0.009..0.010 rows=1 +loops=41904)
+                     Index Cond: ("outer".clusterid = clu.clusterid)
+ Total runtime: 12696.289 ms
+(48 rows)
+
+I tried setting the enable_seq_scan to off and the query's runtime +returned by the explain analyze is 4000ms.
+Why postgre is not using the indexes?
+What is the real impact of having such a big 'IN' clause?
+
+
+Thanks in advance,
+
+Luis Cornide
+
+ + + +--------------020405020706050801010200-- + +From pgsql-performance-owner@postgresql.org Thu Aug 11 09:08:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E3935299C + for ; + Thu, 11 Aug 2005 09:08:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36300-02 + for ; + Thu, 11 Aug 2005 12:08:34 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 04E1052983 + for ; + Thu, 11 Aug 2005 09:08:32 -0300 (ADT) +Received: (qmail 18274 invoked from network); 11 Aug 2005 14:08:50 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 11 Aug 2005 14:08:50 +0200 +To: "Tino Wildenhain" , "Gavin Sherry" +Cc: "Mark Cotner" , + "Dan Harris" , pgsql-performance@postgresql.org +Subject: Re: Speedier count(*) +References: + <1123745049.27613.1.camel@Andrea.peacock.de> + + <1123757536.27613.10.camel@Andrea.peacock.de> +Message-ID: +Date: Thu, 11 Aug 2005 14:08:34 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <1123757536.27613.10.camel@Andrea.peacock.de> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/115 +X-Sequence-Number: 13862 + + + +> You could lock the count table to prevent the problem +> where 2 competing transactions do an insert, read the +> start value and add 1 to it and then write the result +> - which is n+1 rather then n+2 - so you are off by one. +> Think of the same when one transaction inserts 100 +> and the other 120. Then you could even be off by 100. + + Niet. + + If your trigger does UPDATE counts_cache SET cached_count = +cached_count+N WHERE ... + Then all locking is taken care of by Postgres. + Of course if you use 2 queries then you have locking issues. + + However the UPDATE counts_cache has a problem, ie. it locks this row FOR +UPDATE for the whole transaction, and all transactions which want to +update the same row must wait to see if the update commits or rollbacks, +so if you have one count cache row for the whole table you get MySQL style +scalability... + + To preserve scalability you could, instead of UPDATE, INSERT the delta of +rows inserted/deleted in a table (which has no concurrencies issues) and +compute the current count with the sum() of the deltas, then with a cron, +consolidate the deltas and update the count_cache table so that the deltas +table stays very small. + +From pgsql-performance-owner@postgresql.org Thu Aug 11 09:23:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BCF1752A19 + for ; + Thu, 11 Aug 2005 09:23:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74763-06 + for ; + Thu, 11 Aug 2005 12:23:20 +0000 (GMT) +Received: from lon-mail-2.gradwell.net (lon-mail-2.gradwell.net + [193.111.201.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 5166052A06 + for ; + Thu, 11 Aug 2005 09:23:19 -0300 (ADT) +Received: from www.gradwell.com ([193.111.200.100]) + by lon-mail-2.gradwell.net with smtp (Gradwell gwh-smtpd 1.190) id + 42fb4339.14d23.f; Thu, 11 Aug 2005 13:23:21 +0100 + (envelope-sender ) +Received: from 217.45.209.171 + (SquirrelMail authenticated user paul@pop3.oxton.com) + by www.gradwell.com with HTTP; Thu, 11 Aug 2005 13:23:21 +0100 (BST) +Message-ID: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> +Date: Thu, 11 Aug 2005 13:23:21 +0100 (BST) +Subject: PG8 Tuning +From: "Paul Johnson" +To: pgsql-performance@postgresql.org +Reply-To: paul@oxton.com +User-Agent: SquirrelMail/1.4.2 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200508/116 +X-Sequence-Number: 13863 + +Hi all, we're running PG8 on a Sun V250 with 8GB RAM and 2*1.3GHz SPARC +CPUs running Solaris 10. The DB cluster is on an external fibre-attached +Sun T3 array that has 9*36GB drives configured as a single RAID5 LUN. + +The system is for the sole use of a couple of data warehouse developers, +hence we are keen to use 'aggressive' tuning options to maximise +performance. + +So far we have made the following changes and measured the impact on our +test suite: + +1) Increase checkpoint_segments from 3 to 64. This made a 10x improvement +in some cases. + +2) Increase work_mem from 1,024 to 524,288. + +3) Increase shared_buffers from 1,000 to 262,143 (2 GB). This required +setting SHMMAX=4294967295 (4 GB) in /etc/system and re-booting the box. + +Question - can Postgres only use 2GB RAM, given that shared_buffers can +only be set as high as 262,143 (8K pages)? + +So far so good... + +4) Move /pg_xlog to an internal disk within the V250. This has had a +severe *negative* impact on performance. Copy job has gone from 2 mins to +12 mins, simple SQL job gone from 1 min to 7 mins. Not even run long SQL +jobs. + +I'm guessing that this is because pg_xlog has gone from a 9 spindle LUN to +a single spindle disk? + +In cases such as this, where an external storage array with a hardware +RAID controller is used, the normal advice to separate the data from the +pg_xlog seems to come unstuck, or are we missing something? + +Cheers, + +Paul Johnson. + +From pgsql-performance-owner@postgresql.org Thu Aug 11 09:34:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F30C52869 + for ; + Thu, 11 Aug 2005 09:34:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19364-06 + for ; + Thu, 11 Aug 2005 12:34:02 +0000 (GMT) +Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) + by svr1.postgresql.org (Postfix) with ESMTP id 14F125285A + for ; + Thu, 11 Aug 2005 09:33:59 -0300 (ADT) +Received: from [192.168.178.99] (p548B2D2C.dip0.t-ipconnect.de [84.139.45.44]) + by service-web.de (Postfix) with ESMTP id 479EC200039; + Thu, 11 Aug 2005 14:34:02 +0200 (CEST) +Subject: Re: Speedier count(*) +From: Tino Wildenhain +To: PFC +Cc: Gavin Sherry , + Mark Cotner , Dan Harris , + pgsql-performance@postgresql.org +In-Reply-To: +References: + <1123745049.27613.1.camel@Andrea.peacock.de> + + <1123757536.27613.10.camel@Andrea.peacock.de> + +Content-Type: text/plain +Date: Thu, 11 Aug 2005 14:34:00 +0200 +Message-Id: <1123763640.27613.18.camel@Andrea.peacock.de> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.098 tagged_above=0 required=5 tests=[AWL=0.048, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/117 +X-Sequence-Number: 13864 + +Am Donnerstag, den 11.08.2005, 14:08 +0200 schrieb PFC: +> +> > You could lock the count table to prevent the problem +> > where 2 competing transactions do an insert, read the +> > start value and add 1 to it and then write the result +> > - which is n+1 rather then n+2 - so you are off by one. +> > Think of the same when one transaction inserts 100 +> > and the other 120. Then you could even be off by 100. +> +> Niet. +> +> If your trigger does UPDATE counts_cache SET cached_count = +> cached_count+N WHERE ... +> Then all locking is taken care of by Postgres. +> Of course if you use 2 queries then you have locking issues. + +Yes, in the case you use just the UPDATE statement you are right. This +does the locking I was talking about. + +In either case I'd use an after trigger and not before to minimize +the impact. + +> However the UPDATE counts_cache has a problem, ie. it locks this row FOR +> UPDATE for the whole transaction, and all transactions which want to +> update the same row must wait to see if the update commits or rollbacks, +> so if you have one count cache row for the whole table you get MySQL style +> scalability... +> +> To preserve scalability you could, instead of UPDATE, INSERT the delta of +> rows inserted/deleted in a table (which has no concurrencies issues) and +> compute the current count with the sum() of the deltas, then with a cron, +> consolidate the deltas and update the count_cache table so that the deltas +> table stays very small. + +Yes, this is in fact a better approach to this problem. + +(All this provided you want an unqualified count() - as the + original poster) + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 10:01:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CDA3552A06 + for ; + Thu, 11 Aug 2005 10:01:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12761-05 + for ; + Thu, 11 Aug 2005 13:01:18 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 52F1E529F9 + for ; + Thu, 11 Aug 2005 10:01:18 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id D3DE040C066; Thu, 11 Aug 2005 14:01:08 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 799B915EDA; + Thu, 11 Aug 2005 13:49:15 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 30982-04; Thu, 11 Aug 2005 13:49:11 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 5B67615ED9; + Thu, 11 Aug 2005 13:49:11 +0100 (BST) +Message-ID: <42FB4946.6030105@archonet.com> +Date: Thu, 11 Aug 2005 13:49:10 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Luis Cornide Arce +Cc: PGSL-PERFORMANCE LIST +Subject: Re: Why is not using the index +References: <42FB3791.2060200@almabioinfo.com> +In-Reply-To: <42FB3791.2060200@almabioinfo.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/119 +X-Sequence-Number: 13866 + +Luis Cornide Arce wrote: +> Hi everyone, +> +> I have some problems with a quite long query and the plan postgreSQL is +> choosing. The query joins 12 tables and in the WHERE clause I use a IN +> expression with a lot of identifiers (up to 2000). The problem is that +> the planner is proposing a seq_scan on two tables 2M rows each +> (internalexpressionprofile and expressionprofile) +> +> I have just try this query (after doing a vacuum analyze), in the 'IN' +> clause there are 1552 identifiers, and the query should return 14K rows. +> I'm using a PostgreSQL 8.0.2 on a SuSE 8.1 with 1GB of RAM. + +> WHERE epg.expprogeneid IN (80174,84567,...) AND +> epg.expprogeneid=epro.expprogeneid + +-> Hash Join + (cost=15413.58..78079.33 rows=24339 width=134) + (actual time=1489.347..5721.306 rows=41904 loops=1) + Hash Cond: ("outer".expprogeneid = "inner".expprogeneid) + -> Seq Scan on expressionprofile epro + (cost=0.00..48263.24 rows=2831824 width=8) + (actual time=0.039..3097.656 rows=2839676 loops=1) + +-> Index Scan using +expprogene_pk, expprogene_pk, [......] on expprogene epg +(cost=0.00..10698.83 rows=1546 width=8) (actual time=0.027..15.907 +rows=1552 loops=1) + Index Cond: ((expprogeneid = 80174) OR (expprogeneid = 84567) + OR (expprogeneid = 83608) OR [OR ....]) + +OK - it looks like the "IN" clause is using your index. The fact that +it's using a Seq-scan on "expressionprofile epro" looks odd though, +especially since it expects 24339 matches (out of 2.8 million rows - +that should favour an index). + +Of course, I've not considered the context of the rest of the query, but +I'd expect the index to be used. + +Do you have any unusual config settings? +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Aug 11 10:01:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D21C52997 + for ; + Thu, 11 Aug 2005 10:01:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06248-08 + for ; + Thu, 11 Aug 2005 13:01:15 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 30E01529F5 + for ; + Thu, 11 Aug 2005 10:01:14 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id CC416414567; Thu, 11 Aug 2005 14:01:08 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id E9AA115EDB; + Thu, 11 Aug 2005 13:55:28 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 01250-01; Thu, 11 Aug 2005 13:55:24 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 58A0D15ED9; + Thu, 11 Aug 2005 13:55:24 +0100 (BST) +Message-ID: <42FB4ABB.1010305@archonet.com> +Date: Thu, 11 Aug 2005 13:55:23 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: paul@oxton.com +Cc: pgsql-performance@postgresql.org +Subject: Re: PG8 Tuning +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> +In-Reply-To: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/118 +X-Sequence-Number: 13865 + +Paul Johnson wrote: +> Hi all, we're running PG8 on a Sun V250 with 8GB RAM and 2*1.3GHz SPARC +> CPUs running Solaris 10. The DB cluster is on an external fibre-attached +> Sun T3 array that has 9*36GB drives configured as a single RAID5 LUN. +> +> The system is for the sole use of a couple of data warehouse developers, +> hence we are keen to use 'aggressive' tuning options to maximise +> performance. +> +> So far we have made the following changes and measured the impact on our +> test suite: +> +> 1) Increase checkpoint_segments from 3 to 64. This made a 10x improvement +> in some cases. + +OK + +> 2) Increase work_mem from 1,024 to 524,288. + +Don't forget you can use multiples of this in a single query. Might want +to reign it back a bit. I *think* you can set it per-query if you want +anyway. + +> 3) Increase shared_buffers from 1,000 to 262,143 (2 GB). This required +> setting SHMMAX=4294967295 (4 GB) in /etc/system and re-booting the box. +> +> Question - can Postgres only use 2GB RAM, given that shared_buffers can +> only be set as high as 262,143 (8K pages)? + +Well, normally you'd want to keep a fair bit for the O.S. to cache data. +One quarter of your RAM seems very high. Did you try 5000,10000,50000 +too or go straight to the top end? + +> So far so good... +> +> 4) Move /pg_xlog to an internal disk within the V250. This has had a +> severe *negative* impact on performance. Copy job has gone from 2 mins to +> 12 mins, simple SQL job gone from 1 min to 7 mins. Not even run long SQL +> jobs. +> +> I'm guessing that this is because pg_xlog has gone from a 9 spindle LUN to +> a single spindle disk? + +The key limitation will be one commit per rotation of the disk. Multiple +spindles, or better still with a battery-backed write-cache will give +you peak transactions. + +> In cases such as this, where an external storage array with a hardware +> RAID controller is used, the normal advice to separate the data from the +> pg_xlog seems to come unstuck, or are we missing something? + +Well, I think the advice then is actually "get 2 external arrays..." + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Sun Aug 14 19:56:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9124752A97 + for ; + Thu, 11 Aug 2005 10:19:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08161-01 + for ; + Thu, 11 Aug 2005 13:19:10 +0000 (GMT) +Received: from smtp4.wanadoo.fr (smtp4.wanadoo.fr [193.252.22.27]) + by svr1.postgresql.org (Postfix) with ESMTP id 114A952869 + for ; + Thu, 11 Aug 2005 10:19:08 -0300 (ADT) +Received: from me-wanadoo.net (unknown [127.0.0.1]) + by mwinf0401.wanadoo.fr (SMTP Server) with ESMTP id B5DCF1C002A5 + for ; + Thu, 11 Aug 2005 15:19:11 +0200 (CEST) +Received: from NEO (unknown [86.193.99.195]) + by mwinf0401.wanadoo.fr (SMTP Server) with ESMTP id 3175A1C0031B + for ; + Thu, 11 Aug 2005 15:19:11 +0200 (CEST) +X-ME-UUID: 20050811131911202.3175A1C0031B@mwinf0401.wanadoo.fr +From: =?iso-8859-1?Q?St=E9phane_COEZ?= +To: +Subject: Performance pb vs SQLServer. +Date: Thu, 11 Aug 2005 15:19:06 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +Thread-Index: AcWedz241y3YYG5NRWucxBfjaAmDhQ== +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-Id: <20050811131911.3175A1C0031B@mwinf0401.wanadoo.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/145 +X-Sequence-Number: 13892 + +Hi, + +I have a perfomance issue : + +I run PG (8.0.3) and SQLServer2000 on a Windows2000 Server (P4 1,5Ghz = +512Mo) +I have a table (3200000 rows) and I run this single query : + +select cod from mytable group by cod +I have an index on cod (char(4) - 88 different values) + +PG =3D ~ 20 sec. +SQLServer =3D < 8 sec + + +the explain is : + +HashAggregate (cost=3D64410.09..64410.09 rows=3D55 width=3D8) + -> Seq Scan on mytable (cost=3D0.00..56325.27 rows=3D3233927 = +width=3D8) + + +if I switch to "enable_hashagg =3D false" (just for a try...) +the planner will choose my index : + +Group (cost=3D0.00..76514.01 rows=3D55 width=3D8) + -> Index Scan using myindex on mytable (cost=3D0.00..68429.20 = +rows=3D3233927 +width=3D8) + +but performance will be comparable to previous test. + +So with or without using Index I have the same result. + + +Thanks for help. +=20 +St=E9phane COEZ + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 10:26:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 439E152AC9 + for ; + Thu, 11 Aug 2005 10:26:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98738-07 + for ; + Thu, 11 Aug 2005 13:26:35 +0000 (GMT) +Received: from mailhost.intellivid.com (mailhost.intellivid.com + [64.32.200.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 6312552A76 + for ; + Thu, 11 Aug 2005 10:26:34 -0300 (ADT) +Received: from [192.168.2.68] (spectre.intellivid.com [192.168.2.68]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by newmail.intellivid.com (Postfix) with ESMTP id 9C213F182B1; + Thu, 11 Aug 2005 09:26:37 -0400 (EDT) +Subject: Re: Planner doesn't look at LIMIT? +From: Ian Westmacott +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <16040.1123714524@sss.pgh.pa.us> +References: <758d5e7f0507220210bfa4978@mail.gmail.com> + <29473.1122043197@sss.pgh.pa.us> <6440.1122049220@sss.pgh.pa.us> + <1123707833.17725.133.camel@spectre.intellivid.com> + <16040.1123714524@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Intellivid Corp. +Message-Id: <1123766797.21162.93.camel@spectre.intellivid.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Thu, 11 Aug 2005 09:26:37 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/121 +X-Sequence-Number: 13868 + +On Wed, 2005-08-10 at 18:55, Tom Lane wrote: +> Ian Westmacott writes: +> > In a nutshell, I have a LIMIT query where the planner +> > seems to favor a merge join over a nested loop. +> +> The planner is already estimating only one row out of the join, and so +> the LIMIT doesn't affect its cost estimates at all. +> +> It appears to me that the reason the nestloop plan is fast is just +> chance: a suitable matching row is found very early in the scan of +> tableB, so that the indexscan on it can stop after 29 rows, instead +> of having to go through all 55000 rows in the given range of bim. +> If it'd have had to go through, say, half of the rows to find a match, +> the sort/merge plan would show up a lot better. + +Oh, I see. Thanks, that clears up some misconceptions I +had about the explain output. + +> If this wasn't chance, but was expected because there are many matching +> rows and not only one, then there's a statistical problem. + +Well, there are in fact almost 300 of them in this case. +So I guess what I need to do is give the planner more +information to correctly predict that. + +Thanks, + + --Ian + + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 10:59:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BDB92529D1 + for ; + Thu, 11 Aug 2005 10:59:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24144-04 + for ; + Thu, 11 Aug 2005 13:59:35 +0000 (GMT) +Received: from www.almabioinfo.com (www.almabioinfo.com [62.14.232.115]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BC3152986 + for ; + Thu, 11 Aug 2005 10:59:30 -0300 (ADT) +Received: from [192.168.1.60] (stargate.almabioinfo.com [62.14.232.114]) + by www.almabioinfo.com (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) with ESMTP + id j7BDxW831898 + for ; Thu, 11 Aug 2005 15:59:32 +0200 +Message-ID: <42FB59C3.5020809@almabioinfo.com> +Date: Thu, 11 Aug 2005 15:59:31 +0200 +From: Luis Cornide Arce +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: es-es, es +MIME-Version: 1.0 +Cc: PGSL-PERFORMANCE LIST +Subject: Re: Why is not using the index +References: <42FB3791.2060200@almabioinfo.com> <42FB4946.6030105@archonet.com> +In-Reply-To: <42FB4946.6030105@archonet.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.036 tagged_above=0 required=5 tests=[AWL=0.036] +X-Spam-Level: +X-Archive-Number: 200508/122 +X-Sequence-Number: 13869 + + +Well I have change the next setting in the postgresql.conf + +shared_buffers= 16384 +work_mem =32768 +maintenance_work_mem= 65536 +bgwriter_delay =800 +bgwriter_maxpages= 100 +wal_buffers =64 +efective_cache_size= 20000 + +The rest of the settings are the default. + +Thanks, + +Luis + +Richard Huxton escribi�: + +> Luis Cornide Arce wrote: +> +>> Hi everyone, +>> +>> I have some problems with a quite long query and the plan postgreSQL +>> is choosing. The query joins 12 tables and in the WHERE clause I use +>> a IN expression with a lot of identifiers (up to 2000). The problem +>> is that the planner is proposing a seq_scan on two tables 2M rows +>> each (internalexpressionprofile and expressionprofile) +>> +>> I have just try this query (after doing a vacuum analyze), in the +>> 'IN' clause there are 1552 identifiers, and the query should return +>> 14K rows. +>> I'm using a PostgreSQL 8.0.2 on a SuSE 8.1 with 1GB of RAM. +> +> +>> WHERE epg.expprogeneid IN (80174,84567,...) AND +>> epg.expprogeneid=epro.expprogeneid +> +> +> -> Hash Join +> (cost=15413.58..78079.33 rows=24339 width=134) +> (actual time=1489.347..5721.306 rows=41904 loops=1) +> Hash Cond: ("outer".expprogeneid = "inner".expprogeneid) +> -> Seq Scan on expressionprofile epro +> (cost=0.00..48263.24 rows=2831824 width=8) +> (actual time=0.039..3097.656 rows=2839676 loops=1) +> +> -> Index Scan using +> expprogene_pk, expprogene_pk, [......] on expprogene epg +> (cost=0.00..10698.83 rows=1546 width=8) (actual time=0.027..15.907 +> rows=1552 loops=1) +> Index Cond: ((expprogeneid = 80174) OR (expprogeneid = 84567) +> OR (expprogeneid = 83608) OR [OR ....]) +> +> OK - it looks like the "IN" clause is using your index. The fact that +> it's using a Seq-scan on "expressionprofile epro" looks odd though, +> especially since it expects 24339 matches (out of 2.8 million rows - +> that should favour an index). +> +> Of course, I've not considered the context of the rest of the query, +> but I'd expect the index to be used. +> +> Do you have any unusual config settings? + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 12:02:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A8C5529D1 + for ; + Thu, 11 Aug 2005 11:09:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29124-08 + for ; + Thu, 11 Aug 2005 14:09:46 +0000 (GMT) +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by svr1.postgresql.org (Postfix) with ESMTP id AD59652C12 + for ; + Thu, 11 Aug 2005 11:09:41 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.53.154]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0IL200HM59VT7C57@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Thu, 11 Aug 2005 09:07:06 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 2087D70882D for + ; + Thu, 11 Aug 2005 10:07:05 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 01836-01 for ; Thu, + 11 Aug 2005 10:07:04 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id E470B702202; Thu, 11 Aug 2005 10:07:04 -0400 (EDT) +Date: Thu, 11 Aug 2005 10:07:04 -0400 +From: Michael Stone +Subject: Re: PG8 Tuning +In-reply-to: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050811140704.GL19080@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=[AWL=0.007] +X-Spam-Level: +X-Archive-Number: 200508/123 +X-Sequence-Number: 13870 + +On Thu, Aug 11, 2005 at 01:23:21PM +0100, Paul Johnson wrote: +>I'm guessing that this is because pg_xlog has gone from a 9 spindle LUN to +>a single spindle disk? +> +>In cases such as this, where an external storage array with a hardware +>RAID controller is used, the normal advice to separate the data from the +>pg_xlog seems to come unstuck + +Yes. That's the downside to dogma. If you're writing pg_xlog to a +battery-backed ram buffer you'll see faster commits than you will with a +write to a disk, even if you've got a dedicated spindle, unless you've +got constant write activity. (Because once the buffer fills you're +limited to disk speed as you wait for buffer flushes.) If you've got a +lot of system RAM, a battery-backed disk buffer, an OS/filesystem than +effectively delays writes, and bursty transactional writes it's quite +possible you'll get better performance putting everything on one array +rather than breaking it up to follow the "rules". You might get a +performance boost by putting the transaction log on a seperate partition +or lun on the external array, depending on how the fs implements syncs +or whether you can optimize the filsystem choice for each partition. The +correct approach is to run comparative benchmarks of each configuration. +:-) + +Mike Stone + +From pgsql-performance-owner@postgresql.org Sun Aug 14 19:55:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E1B252AC0 + for ; + Thu, 11 Aug 2005 11:30:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49682-02 + for ; + Thu, 11 Aug 2005 14:30:14 +0000 (GMT) +Received: from brmea-mail-4.sun.com (brmea-mail-4.Sun.COM [192.18.98.36]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D6D9528D7 + for ; + Thu, 11 Aug 2005 11:30:13 -0300 (ADT) +Received: from phys-bur-1 ([129.148.9.72]) + by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id j7BEUDx9010848 + for ; + Thu, 11 Aug 2005 08:30:14 -0600 (MDT) +Received: from conversion-daemon.bur-mail1.east.sun.com by + bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0IL200801ATJW4@bur-mail1.east.sun.com> + (original mail from J.K.Shah@Sun.COM) for + pgsql-performance@postgresql.org; + Thu, 11 Aug 2005 10:30:13 -0400 (EDT) +Received: from bur-mail1.east.sun.com (phys-bur-1 [129.148.9.72]) + by bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTP id <0IL200AOPAYDEM@bur-mail1.east.sun.com>; Thu, + 11 Aug 2005 10:30:13 -0400 (EDT) +Received: from [129.148.168.2] by bur-mail1.east.sun.com (mshttpd); Thu, + 11 Aug 2005 10:30:13 -0400 +Date: Thu, 11 Aug 2005 10:30:13 -0400 +From: Jignesh Shah +Subject: Re: [Fwd: PG8 Tuning] +To: paul@oxton.com, pgsql-performance@postgresql.org +Cc: Robert Lor , Donald Courtney +Message-id: <7833474d78.74d7878334@bur-mail1.east.sun.com> +MIME-version: 1.0 +X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.24 (built Dec 19 2003) +Content-type: multipart/mixed; boundary="Boundary_(ID_EpePzI99TlR0Dh/+EexxvA)" +Content-language: en +X-Accept-Language: en +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/144 +X-Sequence-Number: 13891 + +This is a multi-part message in MIME format. + +--Boundary_(ID_EpePzI99TlR0Dh/+EexxvA) +Content-type: text/plain; charset=us-ascii +Content-transfer-encoding: 7BIT +Content-disposition: inline + +Hi Paul, + +I was passed your message... regarding DSS workload with Postgres on Solaris. (I am not in the alias). + +Performance is relative to your workload. Can you actually send us what you are doing in your queries, updates etc? + +I have been running few tests myself and here are my rules of thumbs, your mileage can vary.. + +http://blogs.sun.com/roller/page/jkshah?entry=tuning_postgresql_8_0_2 + +* Increasing checkpoint certainly helps. (I went as far as actually going to increase LOGFILE size from 16MB to 256MB and recompiling it and then using lower number of checkpoints (appropriately).. (file rotations also decreases performance) + +* Moving pg_xlog to a different file system and mounting that file system with "forcedirectio" also helps a lot (This increases the througput by another 2x to 5x or more.) (This can be done either by adding forcedirectio in your /etc/vfstab mount options or for existing mounts as follows: +mount -o remount,forcedirectio /filesystem +(Note: Database files should not be using forcedirectio otherwise file system cache will not be used for it) + +* I actually reduced the PG Bufferpool to 1G or less since it seemed to decrease performance as I increased its bufferpool size (depending on your workload) + +* If you are using SPARC then following etc commands will help.. + +set segmap_percent=60 +set ufs:freebehind=0 + + +This will allocate 60% of RAM for file system buffer (database files) and also cache all files (since PostgreSQL files are 1G by default) + +This will help your repeat queries significantly. + +Other things depends on what you queries you are running? If you send me few samples, I can send you appropriate DTrace scripts (Solaris 10 or higher) to run to figure out what's happening + +Regards, +Jignesh + + + +____________________________________________________ + +Jignesh K. Shah MTS Software Engineer +Sun Microsystems, Inc MDE-Horizontal Technologies +Email: J.K.Shah@sun.com Phone: (781) 442 3052 +http://blogs.sun.com/jkshah +____________________________________________________ + +----- Original Message ----- +>From Paul Johnson +Date Thu, 11 Aug 2005 13:23:21 +0100 (BST) +To pgsql-performance@postgresql.org +Subject [PERFORM] PG8 Tuning +Hi all, we're running PG8 on a Sun V250 with 8GB RAM and 2*1.3GHz SPARC +CPUs running Solaris 10. The DB cluster is on an external fibre-attached +Sun T3 array that has 9*36GB drives configured as a single RAID5 LUN. + +The system is for the sole use of a couple of data warehouse developers, +hence we are keen to use 'aggressive' tuning options to maximise +performance. + +So far we have made the following changes and measured the impact on our +test suite: + +1) Increase checkpoint_segments from 3 to 64. This made a 10x improvement +in some cases. + +2) Increase work_mem from 1,024 to 524,288. + +3) Increase shared_buffers from 1,000 to 262,143 (2 GB). This required +setting SHMMAX=4294967295 (4 GB) in /etc/system and re-booting the box. + +Question - can Postgres only use 2GB RAM, given that shared_buffers can +only be set as high as 262,143 (8K pages)? + +So far so good... + +4) Move /pg_xlog to an internal disk within the V250. This has had a +severe *negative* impact on performance. Copy job has gone from 2 mins to +12 mins, simple SQL job gone from 1 min to 7 mins. Not even run long SQL +jobs. + +I'm guessing that this is because pg_xlog has gone from a 9 spindle LUN to +a single spindle disk? + +In cases such as this, where an external storage array with a hardware +RAID controller is used, the normal advice to separate the data from the +pg_xlog seems to come unstuck, or are we missing something? + +Cheers, + +Paul Johnson. + + + +--Boundary_(ID_EpePzI99TlR0Dh/+EexxvA) +Content-type: message/rfc822; name="[PERFORM] PG8 Tuning" + +Return-path: +Received: from conversion-daemon.bur-mail1.east.sun.com by + bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0IL200C015ME3X@bur-mail1.east.sun.com> + (original mail from pgsql-performance-owner+M13863@postgresql.org) + for djc@bur-mail1.East.Sun.COM; Thu, 11 Aug 2005 08:38:53 -0400 (EDT) +Received: from eastmail2bur.East.Sun.COM + (eastmail2bur.East.Sun.COM [129.148.13.40]) by bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTP id <0IL200MH15STJS@bur-mail1.east.sun.com> for + djc@bur-mail1.East.Sun.COM (ORCPT donald.courtney@sun.com); Thu, + 11 Aug 2005 08:38:53 -0400 (EDT) +Received: from sunmail1brm.Central.Sun.COM + (sunmail1brm.Central.Sun.COM [129.147.62.17]) by + eastmail2bur.East.Sun.COM + (8.12.10+Sun/8.12.10/ENSMAIL,v2.2) with ESMTP id j7BCcrlM025431 for + ; Thu, 11 Aug 2005 08:38:53 -0400 (EDT) +Received: from nwkea-mail-2.sun.com (nwkea-mail-2.Sun.COM [192.18.42.14]) + by sunmail1brm.Central.Sun.COM (8.11.7p1+Sun/8.11.7/ENSMAIL,v2.2) + with ESMTP id j7BCcpb07056 for ; Thu, + 11 Aug 2005 06:38:52 -0600 (MDT) +Received: from relay23.sun.com + (relay23.sun.com [192.12.251.54] (may be forged)) by + nwkea-mail-2.sun.com + (8.12.10/8.12.9) with ESMTP id j7BCcp1d027727 for + ; Thu, 11 Aug 2005 05:38:51 -0700 (PDT) +Received: from mms21es.sun.com (mms21es.sun.com [150.143.232.14]) + by relay23.sun.com with ESMTP for donald.courtney@sun.com; Thu, + 11 Aug 2005 12:38:51 +0000 (Z) +Received: from relay21.sun.com (relay21.sun.com [192.12.251.14]) + by mms21es.sun.com with ESMTP for donald.courtney@sun.com; Thu, + 11 Aug 2005 12:38:50 +0000 (Z) +Received: from hosting.commandprompt.com ([207.173.200.128] [207.173.200.128]) + by relay21.sun.com with ESMTP for donald.courtney@sun.com; Thu, + 11 Aug 2005 12:38:50 +0000 (Z) +Received: from postgresql.org (svr1.postgresql.org [200.46.204.71]) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + j7BCPn0Q014340; Thu, 11 Aug 2005 05:26:04 -0700 +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BCF1752A19 for + ; Thu, + 11 Aug 2005 09:23:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74763-06 for + ; Thu, + 11 Aug 2005 12:23:20 +0000 (GMT) +Received: from lon-mail-2.gradwell.net + (lon-mail-2.gradwell.net [193.111.201.126]) by svr1.postgresql.org + (Postfix) + with ESMTP id 5166052A06 for ; Thu, + 11 Aug 2005 09:23:19 -0300 (ADT) +Received: from www.gradwell.com ([193.111.200.100]) by lon-mail-2.gradwell.net + with smtp (Gradwell gwh-smtpd 1.190) id 42fb4339.14d23.f; Thu, + 11 Aug 2005 13:23:21 +0100 (envelope-sender ) +Received: from 217.45.209.171 + (SquirrelMail authenticated user paul@pop3.oxton.com) + by www.gradwell.com with HTTP; Thu, 11 Aug 2005 13:23:21 +0100 (BST) +Date: Thu, 11 Aug 2005 13:23:21 +0100 (BST) +From: Paul Johnson +Subject: [PERFORM] PG8 Tuning +Sender: pgsql-performance-owner@postgresql.org +To: pgsql-performance@postgresql.org +Reply-to: paul@oxton.com +Message-id: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> +MIME-version: 1.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: 8BIT +Importance: Normal +X-Priority: 3 +Precedence: bulk +User-Agent: SquirrelMail/1.4.2 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Greylist: Sender IP whitelisted, + not delayed by milter-greylist-1.6 (hosting.commandprompt.com + [192.168.1.101]); Thu, 11 Aug 2005 05:26:08 -0700 (PDT) +X-Mailing-List: pgsql-performance +List-Owner: +List-Post: +List-Subscribe: +List-Unsubscribe: + +List-Archive: +List-Help: +List-Id: +Original-recipient: rfc822;donald.courtney@sun.com + +Hi all, we're running PG8 on a Sun V250 with 8GB RAM and 2*1.3GHz SPARC +CPUs running Solaris 10. The DB cluster is on an external fibre-attached +Sun T3 array that has 9*36GB drives configured as a single RAID5 LUN. + +The system is for the sole use of a couple of data warehouse developers, +hence we are keen to use 'aggressive' tuning options to maximise +performance. + +So far we have made the following changes and measured the impact on our +test suite: + +1) Increase checkpoint_segments from 3 to 64. This made a 10x improvement +in some cases. + +2) Increase work_mem from 1,024 to 524,288. + +3) Increase shared_buffers from 1,000 to 262,143 (2 GB). This required +setting SHMMAX=4294967295 (4 GB) in /etc/system and re-booting the box. + +Question - can Postgres only use 2GB RAM, given that shared_buffers can +only be set as high as 262,143 (8K pages)? + +So far so good... + +4) Move /pg_xlog to an internal disk within the V250. This has had a +severe *negative* impact on performance. Copy job has gone from 2 mins to +12 mins, simple SQL job gone from 1 min to 7 mins. Not even run long SQL +jobs. + +I'm guessing that this is because pg_xlog has gone from a 9 spindle LUN to +a single spindle disk? + +In cases such as this, where an external storage array with a hardware +RAID controller is used, the normal advice to separate the data from the +pg_xlog seems to come unstuck, or are we missing something? + +Cheers, + +Paul Johnson. + +---------------------------(end of broadcast)--------------------------- +TIP 4: Have you searched our list archives? + + http://archives.postgresql.org + +--Boundary_(ID_EpePzI99TlR0Dh/+EexxvA)-- + +From pgsql-performance-owner@postgresql.org Thu Aug 11 12:28:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 19B0752E95 + for ; + Thu, 11 Aug 2005 12:25:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95179-02 + for ; + Thu, 11 Aug 2005 15:25:31 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id E412652E8A + for ; + Thu, 11 Aug 2005 12:25:29 -0300 (ADT) +Received: from wren.rentec.com (wren.rentec.com [192.5.35.106]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j7BFPRfE020212 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) + for ; + Thu, 11 Aug 2005 11:25:28 -0400 (EDT) +X-Rentec: external +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by wren.rentec.com (8.13.1/8.12.1) with ESMTP id j7BFPRto023192 + for ; + Thu, 11 Aug 2005 11:25:27 -0400 (EDT) +Message-ID: <42FB6DE7.7060107@rentec.com> +Date: Thu, 11 Aug 2005 11:25:27 -0400 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 1.0+ (X11/20050712) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: BG writer question? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as j7BFPRfE020212 at Thu Aug 11 + 11:25:28 2005 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/124 +X-Sequence-Number: 13871 + +Hello all, + +I just was running strace in the writer process and I noticed this pattern: + +select(0, NULL, NULL, NULL, {0, 200000}) = 0 (Timeout) +getppid() = 4240 +time(NULL) = 1123773324 +mmap2(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, +0x81000) = 0x69ea3000 +semop(1409034, 0xffffc0bc, 1) = 0 +<...seeks and writes...> +munmap(0x69ea3000, 528384) = 0 +select(0, NULL, NULL, NULL, {0, 200000}) = 0 (Timeout) +getppid() = 4240 +time(NULL) = 1123773324 +mmap2(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, +0x81000) = 0x69ea3000 +semop(1605648, 0xffffc0bc, 1) = 0 +<...seeks and writes...> +munmap(0x69ea3000, 528384) = 0 +select(0, NULL, NULL, NULL, {0, 200000}) = 0 (Timeout) + + +why mmap and munmap each time? mmap and munmap are fairly expensive +operations (on some systems), especially on multi cpu machines. munmap +in particular generally needs to issue cross calls to the other cpus to +ensure any page mappings are invalidated. + +Just curious. + +Thanks! + +-- Alan + +From pgsql-performance-owner@postgresql.org Thu Aug 11 12:59:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A5EA152E94 + for ; + Thu, 11 Aug 2005 12:30:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96349-07 + for ; + Thu, 11 Aug 2005 15:30:29 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A7B152E72 + for ; + Thu, 11 Aug 2005 12:30:28 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id E55426440E6 + for ; + Thu, 11 Aug 2005 09:29:55 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 19615-05 for ; + Thu, 11 Aug 2005 09:29:54 -0600 (MDT) +Received: from [192.168.1.12] (c-24-9-24-35.hsd1.co.comcast.net [24.9.24.35]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id F03C16440B8 + for ; + Thu, 11 Aug 2005 09:29:53 -0600 (MDT) +Mime-Version: 1.0 (Apple Message framework v730) +In-Reply-To: <1123763640.27613.18.camel@Andrea.peacock.de> +References: + <1123745049.27613.1.camel@Andrea.peacock.de> + + <1123757536.27613.10.camel@Andrea.peacock.de> + + <1123763640.27613.18.camel@Andrea.peacock.de> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <40E2616B-1BCB-4B1D-9B00-9FE52DEBD85B@drivefaster.net> +Content-Transfer-Encoding: 7bit +From: Dan Harris +Subject: Re: Speedier count(*) +Date: Thu, 11 Aug 2005 09:33:00 -0600 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.730) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/125 +X-Sequence-Number: 13872 + +Thanks for all the great ideas. I have more options to evaluate now. + +-Dan + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 13:43:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D9B452FE3 + for ; + Thu, 11 Aug 2005 13:42:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37945-07 + for ; + Thu, 11 Aug 2005 16:42:49 +0000 (GMT) +Received: from alvh.no-ip.org (200-85-218-206.bk4-dsl.surnet.cl + [200.85.218.206]) + by svr1.postgresql.org (Postfix) with ESMTP id 5373052FF4 + for ; + Thu, 11 Aug 2005 13:42:48 -0300 (ADT) +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id B32CCC2D450; Thu, 11 Aug 2005 12:43:05 -0400 (CLT) +Date: Thu, 11 Aug 2005 12:43:05 -0400 +From: Alvaro Herrera +To: Alan Stange +Cc: pgsql-performance@postgresql.org +Subject: Re: BG writer question? +Message-ID: <20050811164305.GB20172@alvh.no-ip.org> +Mail-Followup-To: Alan Stange , + pgsql-performance@postgresql.org +References: <42FB6DE7.7060107@rentec.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <42FB6DE7.7060107@rentec.com> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.789 tagged_above=0 required=5 tests=[AWL=0.365, + DNS_FROM_RFC_ABUSE=0.374, FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/126 +X-Sequence-Number: 13873 + +On Thu, Aug 11, 2005 at 11:25:27AM -0400, Alan Stange wrote: + +> why mmap and munmap each time? mmap and munmap are fairly expensive +> operations (on some systems), especially on multi cpu machines. munmap +> in particular generally needs to issue cross calls to the other cpus to +> ensure any page mappings are invalidated. + +There are no mmap/munmap calls in our code. The problematic code is +probably somewhere in the libc. Maybe it'd be useful to figure out +where it's called and why, with an eye on working around that. + +-- +Alvaro Herrera () +"I love the Postgres community. It's all about doing things _properly_. :-)" +(David Garamond) + +From pgsql-performance-owner@postgresql.org Thu Aug 11 14:04:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AC9CF52C50 + for ; + Thu, 11 Aug 2005 14:01:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58442-06 + for ; + Thu, 11 Aug 2005 16:58:55 +0000 (GMT) +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 5412252936 + for ; + Thu, 11 Aug 2005 13:58:53 -0300 (ADT) +Received: from toonses.gghcwest.com (toonses.gghcwest.com [192.168.168.115]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id j7BGwhmd016814; + Thu, 11 Aug 2005 09:58:44 -0700 +Received: from jwb by toonses.gghcwest.com with local (Exim 4.50) + id 1E3GOC-0001l7-Df; Thu, 11 Aug 2005 09:58:44 -0700 +Subject: Re: [SPAM?] Re: PG8 Tuning +From: "Jeffrey W. Baker" +To: Steve Poe +Cc: paul@oxton.com, pgsql-performance@postgresql.org +In-Reply-To: <1123836428.19976.26.camel@amd64-laptop-spoe> +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Thu, 11 Aug 2005 09:58:44 -0700 +Message-Id: <1123779524.6664.1.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.3.6.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200508/127 +X-Sequence-Number: 13874 + +On Fri, 2005-08-12 at 08:47 +0000, Steve Poe wrote: +> Paul, +> +> Before I say anything else, one online document which may be of +> assistance to you is: +> http://www.powerpostgresql.com/PerfList/ +> +> Some thoughts I have: +> +> 3) You're shared RAM setting seems overkill to me. Part of the challenge +> is you're going from 1000 to 262K with no assessment in between. Each +> situation can be different, but try in the range of 10 - 50K. +> +> 4) pg_xlog: If you're pg_xlog is on a spindle is *only* for pg_xlog +> you're better off. + +Like Mr. Stone said earlier, this is pure dogma. In my experience, +xlogs on the same volume with data is much faster if both are on +battery-backed write-back RAID controller memory. Moving from this +situation to xlogs on a single normal disk is going to be much slower in +most cases. + +-jwb + +From pgsql-performance-owner@postgresql.org Thu Aug 11 16:04:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C6BD5303E + for ; + Thu, 11 Aug 2005 14:20:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68973-01 + for ; + Thu, 11 Aug 2005 17:20:14 +0000 (GMT) +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 581965301E + for ; + Thu, 11 Aug 2005 14:20:11 -0300 (ADT) +Received: from archimedes ([172.16.2.68]) by mir3-fs.mir3.com with Microsoft + SMTPSVC(5.0.2195.6713); Thu, 11 Aug 2005 10:21:42 -0700 +Subject: Re: PG8 Tuning +From: Mark Lewis +To: Steve Poe +Cc: paul@oxton.com, pgsql-performance@postgresql.org +In-Reply-To: <1123836428.19976.26.camel@amd64-laptop-spoe> +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> +Content-Type: text/plain +Organization: MIR3, Inc. +Date: Thu, 11 Aug 2005 10:18:44 -0700 +Message-Id: <1123780724.14573.108.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-16) +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 11 Aug 2005 17:21:42.0945 (UTC) + FILETIME=[247F8910:01C59E99] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/129 +X-Sequence-Number: 13876 + +(Musing, trying to think of a general-purpose performance-tuning rule +that applies here): + +Actually, it seems to me that with the addition of the WAL in PostgreSQL +and the subsequent decreased need to fsync the data files themselves +(only during checkpoints?), that the only time a battery-backed write +cache would make a really large performance difference would be on the +drive(s) hosting the WAL. + +So although it is in general good to have a dedicated spindle for the +WAL, for many workloads it is in fact significantly better to have the +WAL written to a battery-backed write cache. The exception would be for +applications with fewer, larger transactions, in which case you could +actually use the dedicated spindle. + +Hmmm, on second thought, now I think I understand the rationale behind +having a non-zero commit delay setting-- the problem with putting +pg_xlog on a single disk without a write cache is that frequent fsync() +calls might cause it to spend most of its time seeking instead of +writing (as seems to be happening to Paul here). Then again, the OS IO +scheduler should take care of this for you, making this a non-issue. +Perhaps Solaris 10 just has really poor IO scheduling performance with +this particular hardware and workload? + +Ah well. Thought myself in circles and have no real conclusions to show +for it. Posting anyway, maybe this will give somebody some ideas to +work with. + +-- Mark Lewis + +On Fri, 2005-08-12 at 08:47 +0000, Steve Poe wrote: +> Paul, +> +> Before I say anything else, one online document which may be of +> assistance to you is: +> http://www.powerpostgresql.com/PerfList/ +> +> Some thoughts I have: +> +> 3) You're shared RAM setting seems overkill to me. Part of the challenge +> is you're going from 1000 to 262K with no assessment in between. Each +> situation can be different, but try in the range of 10 - 50K. +> +> 4) pg_xlog: If you're pg_xlog is on a spindle is *only* for pg_xlog +> you're better off. If it is sharing with any other OS/DB resource, the +> performance will be impacted. +> +> >From what I have learned from others on this list, RAID5 is not the best +> choice for the database. RAID10 would be a better solution (using 8 of +> your disks) then take the remaining disk and do mirror with your pg_xlog +> if possible. +> +> Best of luck, +> +> Steve Poe +> +> On Thu, 2005-08-11 at 13:23 +0100, Paul Johnson wrote: +> > Hi all, we're running PG8 on a Sun V250 with 8GB RAM and 2*1.3GHz SPARC +> > CPUs running Solaris 10. The DB cluster is on an external fibre-attached +> > Sun T3 array that has 9*36GB drives configured as a single RAID5 LUN. +> > +> > The system is for the sole use of a couple of data warehouse developers, +> > hence we are keen to use 'aggressive' tuning options to maximise +> > performance. +> > +> > So far we have made the following changes and measured the impact on our +> > test suite: +> > +> > 1) Increase checkpoint_segments from 3 to 64. This made a 10x improvement +> > in some cases. +> > +> > 2) Increase work_mem from 1,024 to 524,288. +> > +> > 3) Increase shared_buffers from 1,000 to 262,143 (2 GB). This required +> > setting SHMMAX=4294967295 (4 GB) in /etc/system and re-booting the box. +> > +> > Question - can Postgres only use 2GB RAM, given that shared_buffers can +> > only be set as high as 262,143 (8K pages)? +> > +> > So far so good... +> > +> > 4) Move /pg_xlog to an internal disk within the V250. This has had a +> > severe *negative* impact on performance. Copy job has gone from 2 mins to +> > 12 mins, simple SQL job gone from 1 min to 7 mins. Not even run long SQL +> > jobs. +> > +> > I'm guessing that this is because pg_xlog has gone from a 9 spindle LUN to +> > a single spindle disk? +> > +> > In cases such as this, where an external storage array with a hardware +> > RAID controller is used, the normal advice to separate the data from the +> > pg_xlog seems to come unstuck, or are we missing something? +> > +> > Cheers, +> > +> > Paul Johnson. +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 4: Have you searched our list archives? +> > +> > http://archives.postgresql.org +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 15:21:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0EB2952F01 + for ; + Thu, 11 Aug 2005 15:00:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64033-08 + for ; + Thu, 11 Aug 2005 18:00:26 +0000 (GMT) +Received: from mail.jobflash.com (mail.jobflash.com [64.62.211.41]) + by svr1.postgresql.org (Postfix) with ESMTP id D0D4052E9C + for ; + Thu, 11 Aug 2005 15:00:25 -0300 (ADT) +Received: from [192.168.2.22] (user-38lc0mu.dialup.mindspring.com + [209.86.2.222]) + by mail.jobflash.com (Postfix) with ESMTP id 689DC420C1; + Thu, 11 Aug 2005 11:00:23 -0700 (PDT) +Message-ID: <42FB9235.4090505@jobflash.com> +Date: Thu, 11 Aug 2005 11:00:21 -0700 +From: Tom Arthurs +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Steve Poe +Cc: paul@oxton.com, pgsql-performance@postgresql.org +Subject: Re: [SPAM?] Re: PG8 Tuning +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> +In-Reply-To: <1123836428.19976.26.camel@amd64-laptop-spoe> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/128 +X-Sequence-Number: 13875 + +I think the T-3 RAID at least breaks some of these rules -- I've got 2 +T-3's, 1 configured as RAID-10 and the other as RAID5, and they both +seem to perform about the same. I use RAID5 with a hot spare, so it's +using 8 spindles. + +I got a lot of performance improvement out of mount the fs noatime and +turning journaling off. Of course it takes a *long* time to recover +from a crash. + +Steve Poe wrote: +> Paul, +> +> Before I say anything else, one online document which may be of +> assistance to you is: +> http://www.powerpostgresql.com/PerfList/ +> +> Some thoughts I have: +> +> 3) You're shared RAM setting seems overkill to me. Part of the challenge +> is you're going from 1000 to 262K with no assessment in between. Each +> situation can be different, but try in the range of 10 - 50K. +> +> 4) pg_xlog: If you're pg_xlog is on a spindle is *only* for pg_xlog +> you're better off. If it is sharing with any other OS/DB resource, the +> performance will be impacted. +> +>>From what I have learned from others on this list, RAID5 is not the best +> choice for the database. RAID10 would be a better solution (using 8 of +> your disks) then take the remaining disk and do mirror with your pg_xlog +> if possible. +> +> Best of luck, +> +> Steve Poe +> +> On Thu, 2005-08-11 at 13:23 +0100, Paul Johnson wrote: +> +>>Hi all, we're running PG8 on a Sun V250 with 8GB RAM and 2*1.3GHz SPARC +>>CPUs running Solaris 10. The DB cluster is on an external fibre-attached +>>Sun T3 array that has 9*36GB drives configured as a single RAID5 LUN. +>> +>>The system is for the sole use of a couple of data warehouse developers, +>>hence we are keen to use 'aggressive' tuning options to maximise +>>performance. +>> +>>So far we have made the following changes and measured the impact on our +>>test suite: +>> +>>1) Increase checkpoint_segments from 3 to 64. This made a 10x improvement +>>in some cases. +>> +>>2) Increase work_mem from 1,024 to 524,288. +>> +>>3) Increase shared_buffers from 1,000 to 262,143 (2 GB). This required +>>setting SHMMAX=4294967295 (4 GB) in /etc/system and re-booting the box. +>> +>>Question - can Postgres only use 2GB RAM, given that shared_buffers can +>>only be set as high as 262,143 (8K pages)? +>> +>>So far so good... +>> +>>4) Move /pg_xlog to an internal disk within the V250. This has had a +>>severe *negative* impact on performance. Copy job has gone from 2 mins to +>>12 mins, simple SQL job gone from 1 min to 7 mins. Not even run long SQL +>>jobs. +>> +>>I'm guessing that this is because pg_xlog has gone from a 9 spindle LUN to +>>a single spindle disk? +>> +>>In cases such as this, where an external storage array with a hardware +>>RAID controller is used, the normal advice to separate the data from the +>>pg_xlog seems to come unstuck, or are we missing something? +>> +>>Cheers, +>> +>>Paul Johnson. +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 4: Have you searched our list archives? +>> +>> http://archives.postgresql.org +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> +> +> + +From pgsql-performance-owner@postgresql.org Thu Aug 11 17:36:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9218752EBF + for ; + Thu, 11 Aug 2005 17:36:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14547-03 + for ; + Thu, 11 Aug 2005 20:36:42 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id D4E7352ECD + for ; + Thu, 11 Aug 2005 17:36:40 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050811203641m9100g6g0be>; Thu, 11 Aug 2005 20:36:41 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id B920E56008; Thu, 11 Aug 2005 15:36:40 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 003A955FCC + for ; + Thu, 11 Aug 2005 15:36:35 -0500 (CDT) +Message-ID: <42FBB6CF.6000404@arbash-meinel.com> +Date: Thu, 11 Aug 2005 15:36:31 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Postgresql Performance +Subject: Odd Locking Problem +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigE9A54294F5ECE755761E8BF4" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=[AWL=-0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/130 +X-Sequence-Number: 13877 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigE9A54294F5ECE755761E8BF4 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +I'm having an odd case where my system is locking such that if I insert +into a table during a transaction, if I start a new connection and +transaction, it blocks while trying to do a similar insert until the +first transaction is committed or rolled back. + +The schema is rather complex (currently 157 tables, 200 views), and I +still haven't been able to create a small test case. Everything I've +tried so far just works. + +The data is private, but the schema is open source, so I probably could +work with someone on it. When I look at the pg_locks table, I seem to be +blocked on: +SELECT * FROM pg_locks WHERE granted = false; + relation | database | transaction | pid | mode | granted +----------+----------+-------------+-------+------------------+--------- + | | 1525932 | 30175 | ShareLock | f +... + +Which if I understand correctly, means that the current transaction is +intentionally blocking waiting for the other transaction to finish. + +I'm currently running 8.0.3, but the database was first created under +7.4.? I confirmed this behavior on both systems. + +Under what circumstances would this occur? + +To try and outline the situation there is a main object table, which is +the root object. It contains a group column which is used for access +rights. There is a groupref table, which keeps track of the group rights +for each user. (Each user has specific insert,update,select rights per +group). + +The select rights are enforced by views (the tables are not publicly +accessible, the views join against the groupref table to check for +select permission). +Insert and update rights are validated by BEFORE INSERT triggers. + +Most tables references the object table. Basically it is OO, but doesn't +use the postgres inheritance (in our testing postgres inheritance didn't +scale well for deep inheritance, and wasn't able to enforce uniqueness +anyway.) The views present an OO appearance, and behind the scenes +direct table foreign keys maintain referential integrity. + +I have checked using RAISE NOTICE and the BEFORE INSERT trigger gets all +the way to the RETURN statement before things hang, so I haven't figured +out what is actually hanging. + +I have a bzip'd version of the schema and just enough data to be useful +available here: +http://www.arbash-meinel.com/extras/schema_and_data.sql.bz2 + +This is the commands to replicate the locking: + +-- Connect as postgres + +-- Required before any inserts, so that the TEMP env table is +-- created and filled out. +select mf_setup_env(); + +-- Begin a transaction and insert some data +BEGIN; +INSERT INTO object(vgroup,otype,oname) VALUES ('test',1,'test'); + +-- Start a new shell, and connect again and do exactly the same thing +-- as the above. +-- It should hang until you either do END/ROLLBACK in the first +-- connection. + +Thanks for any help, +John +=:-> + +--------------enigE9A54294F5ECE755761E8BF4 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC+7bTJdeBCYSNAAMRAoobAKCe4p+4YDnVkl63HS3HQjr6WH3/EgCeKo5Z +NbtuOQJIdn3+cWTbBC4glsc= +=BvPL +-----END PGP SIGNATURE----- + +--------------enigE9A54294F5ECE755761E8BF4-- + +From pgsql-performance-owner@postgresql.org Thu Aug 11 17:39:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 49BD65286F + for ; + Thu, 11 Aug 2005 17:38:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05208-06 + for ; + Thu, 11 Aug 2005 20:38:55 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 964625284E + for ; + Thu, 11 Aug 2005 17:38:52 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: PG8 Tuning +Date: Thu, 11 Aug 2005 16:38:53 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD095@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] PG8 Tuning +Thread-Index: AcWeqVEJJSwD/9NeSQGbxvRSDEigkgACZ18w +From: "Merlin Moncure" +To: "Mark Lewis" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/131 +X-Sequence-Number: 13878 + +> Actually, it seems to me that with the addition of the WAL in +PostgreSQL +> and the subsequent decreased need to fsync the data files themselves +> (only during checkpoints?), that the only time a battery-backed write +> cache would make a really large performance difference would be on the +> drive(s) hosting the WAL. + +It still helps. In my experience a good BBU Raid controller is only +slightly slower than fsync=3Dfalse. Fear the checkpoint storm if you +don't have some write caching. Beyond that I don't really care about +write delay. + +Another thing to watch out for is that some sync modes (varying by +platform) can do >1 seeks per sync. This will absolutely kill your +commit performance on the WAL without write caching. +=20 +> So although it is in general good to have a dedicated spindle for the +> WAL, for many workloads it is in fact significantly better to have the +> WAL written to a battery-backed write cache. The exception would be +for +> applications with fewer, larger transactions, in which case you could +> actually use the dedicated spindle. + +Exactly. + +=20 +> Hmmm, on second thought, now I think I understand the rationale behind +> having a non-zero commit delay setting-- the problem with putting + +I don't trust commit_delay. Get a good raid controller and make sure pg +is properly using it. Now, if you can't (or won't) do some type of +write caching bbu or no, your system has to be very carefully designed +to get any performance at all, especially with high transaction volumes. + + +Merlin + +From pgsql-performance-owner@postgresql.org Thu Aug 11 18:08:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D9A0E52EE4 + for ; + Thu, 11 Aug 2005 18:08:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16618-04 + for ; + Thu, 11 Aug 2005 21:08:24 +0000 (GMT) +Received: from alvh.no-ip.org (200-85-218-206.bk4-dsl.surnet.cl + [200.85.218.206]) + by svr1.postgresql.org (Postfix) with ESMTP id F160F52E8A + for ; + Thu, 11 Aug 2005 18:08:21 -0300 (ADT) +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id C46F6C2D450; Thu, 11 Aug 2005 17:08:42 -0400 (CLT) +Date: Thu, 11 Aug 2005 17:08:42 -0400 +From: Alvaro Herrera +To: John A Meinel +Cc: Postgresql Performance +Subject: Re: Odd Locking Problem +Message-ID: <20050811210842.GA28253@alvh.no-ip.org> +Mail-Followup-To: John A Meinel , + Postgresql Performance +References: <42FBB6CF.6000404@arbash-meinel.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <42FBB6CF.6000404@arbash-meinel.com> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.776 tagged_above=0 required=5 tests=[AWL=0.353, + DNS_FROM_RFC_ABUSE=0.374, FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/132 +X-Sequence-Number: 13879 + +On Thu, Aug 11, 2005 at 03:36:31PM -0500, John A Meinel wrote: +> I'm having an odd case where my system is locking such that if I insert +> into a table during a transaction, if I start a new connection and +> transaction, it blocks while trying to do a similar insert until the +> first transaction is committed or rolled back. + +Are there foreign keys here? I can duplicate the problem easily with +them: + +-- session 1 +create table a (a serial primary key); +create table b (a int references a); +insert into a values (1); + +begin; +insert into b values (1); + + +-- session 2 +insert into b values (1); +-- hangs + + +If I commit on session 1, session 2 is unlocked. + +This is a known problem, solved in 8.1. A workaround for previous +releases is to defer FK checks until commit: + +create table b (a int references a initially deferred); + +-- +Alvaro Herrera () +Dios hizo a Ad�n, pero fue Eva quien lo hizo hombre. + +From pgsql-performance-owner@postgresql.org Thu Aug 11 18:14:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BA08052EF5 + for ; + Thu, 11 Aug 2005 18:12:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85097-09 + for ; + Thu, 11 Aug 2005 21:12:07 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D5EF52EF4 + for ; + Thu, 11 Aug 2005 18:12:02 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050811211204m92009ij23e>; Thu, 11 Aug 2005 21:12:04 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 346F256008; Thu, 11 Aug 2005 16:12:04 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 3C7C655FCC; + Thu, 11 Aug 2005 16:11:59 -0500 (CDT) +Message-ID: <42FBBF1E.6040403@arbash-meinel.com> +Date: Thu, 11 Aug 2005 16:11:58 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alvaro Herrera +Cc: Postgresql Performance +Subject: Re: Odd Locking Problem +References: <42FBB6CF.6000404@arbash-meinel.com> + <20050811210842.GA28253@alvh.no-ip.org> +In-Reply-To: <20050811210842.GA28253@alvh.no-ip.org> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig85C8C97A4CA324ACA27CB4AC" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=[AWL=-0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/133 +X-Sequence-Number: 13880 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig85C8C97A4CA324ACA27CB4AC +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Alvaro Herrera wrote: +> On Thu, Aug 11, 2005 at 03:36:31PM -0500, John A Meinel wrote: +> +>>I'm having an odd case where my system is locking such that if I insert +>>into a table during a transaction, if I start a new connection and +>>transaction, it blocks while trying to do a similar insert until the +>>first transaction is committed or rolled back. +> +> +> Are there foreign keys here? I can duplicate the problem easily with +> them: +> +> -- session 1 +> create table a (a serial primary key); +> create table b (a int references a); +> insert into a values (1); +> +> begin; +> insert into b values (1); +> +> +> -- session 2 +> insert into b values (1); +> -- hangs +> + +Actually, there are but the insert is occurring into table 'a' not table +'b'. +'a' refers to other tables, but these should not be modified. + +> +> If I commit on session 1, session 2 is unlocked. +> +> This is a known problem, solved in 8.1. A workaround for previous +> releases is to defer FK checks until commit: +> +> create table b (a int references a initially deferred); + +I'll try one of the CVS entries and see if it happens there. Good to +hear there has been work done. + +John +=:-> + +> + + +--------------enig85C8C97A4CA324ACA27CB4AC +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC+78eJdeBCYSNAAMRAi8AAJ9N+E4aJXZvG+SadflT5Mml4DpX1ACcC4j1 +FLEvQdCoRCup3WTHkgg+dNk= +=dHX/ +-----END PGP SIGNATURE----- + +--------------enig85C8C97A4CA324ACA27CB4AC-- + +From pgsql-performance-owner@postgresql.org Thu Aug 11 19:21:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9035452983 + for ; + Thu, 11 Aug 2005 19:21:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37218-06 + for ; + Thu, 11 Aug 2005 22:21:42 +0000 (GMT) +Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) + by svr1.postgresql.org (Postfix) with ESMTP id E382D5301B + for ; + Thu, 11 Aug 2005 19:21:41 -0300 (ADT) +Received: from [192.168.1.52] + (c-24-60-119-214.hsd1.ma.comcast.net[24.60.119.214]) + by comcast.net (rwcrmhc11) with ESMTP + id <2005081122210201300ohcjhe>; Thu, 11 Aug 2005 22:21:02 +0000 +Message-ID: <42FBCF4D.6060002@comcast.net> +Date: Thu, 11 Aug 2005 18:21:01 -0400 +From: Jeffrey Tenny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Mostly read performance +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.544 tagged_above=0 required=5 tests=[AWL=-0.698, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, + DNS_FROM_RFC_WHOIS=0.492] +X-Spam-Level: * +X-Archive-Number: 200508/134 +X-Sequence-Number: 13881 + +I have a largely table-append-only application where most transactions +are read-intensive and many are read-only. The transactions may span +many tables, and in some cases might need to pull 70 MB of data out of a +couple of the larger tables. + + +In 7.3, I don't seem to see any file system or other caching that helps +with repeated reads of the 70MB of data. Secondary fetches are pretty +much as slow as the first fetch. (The 70MB in this example might take +place via 2000 calls to a parameterized statement via JDBC). + +Were there changes after 7.3 w.r.t. caching of data? I read this list +and see people saying that 8.0 will use the native file system cache to +good effect. Is this true? Is it supposed to work with 7.3? Is there +something I need to do to get postgresql to take advatage of large ram +systems? + +Thanks for any advice. + +From pgsql-performance-owner@postgresql.org Thu Aug 11 19:39:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 55A815284E + for ; + Thu, 11 Aug 2005 19:39:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89183-05 + for ; + Thu, 11 Aug 2005 22:38:57 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 832E952E7E + for ; + Thu, 11 Aug 2005 19:38:56 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050811223859m92009hurme>; Thu, 11 Aug 2005 22:38:59 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id A959E56008; Thu, 11 Aug 2005 17:38:56 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 6B1E755FCC; + Thu, 11 Aug 2005 17:38:50 -0500 (CDT) +Message-ID: <42FBD377.8040006@arbash-meinel.com> +Date: Thu, 11 Aug 2005 17:38:47 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeffrey Tenny +Cc: pgsql-performance@postgresql.org +Subject: Re: Mostly read performance +References: <42FBCF4D.6060002@comcast.net> +In-Reply-To: <42FBCF4D.6060002@comcast.net> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigA0AF2BF7B9B582267E8407E5" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=[AWL=-0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/135 +X-Sequence-Number: 13882 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigA0AF2BF7B9B582267E8407E5 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Jeffrey Tenny wrote: +> I have a largely table-append-only application where most transactions +> are read-intensive and many are read-only. The transactions may span +> many tables, and in some cases might need to pull 70 MB of data out of a +> couple of the larger tables. +> +> +> In 7.3, I don't seem to see any file system or other caching that helps +> with repeated reads of the 70MB of data. Secondary fetches are pretty +> much as slow as the first fetch. (The 70MB in this example might take +> place via 2000 calls to a parameterized statement via JDBC). +> +> Were there changes after 7.3 w.r.t. caching of data? I read this list +> and see people saying that 8.0 will use the native file system cache to +> good effect. Is this true? Is it supposed to work with 7.3? Is there +> something I need to do to get postgresql to take advatage of large ram +> systems? +> +> Thanks for any advice. +> + +Well, first off, the general recommendation is probably that 7.3 is +really old, and you should try to upgrade to at least 7.4, though +recommended to 8.0. + +The bigger questions: How much RAM do you have? How busy is your system? + +8.0 doesn't really do anything to do make the system cache the data. +What kernel are you using? + +Also, if your tables are small enough, and your RAM is big enough, you +might already have everything cached. + +One way to flush the caches, is to allocate a bunch of memory, and then +scan through it. Or maybe mmap a really big file, and access every byte. +But if your kernel is smart enough, it could certainly deallocate pages +after you stopped accessing them, so I can't say for sure that you can +flush the memory cache. Usually, I believe these methods are sufficient. + +John +=:-> + +--------------enigA0AF2BF7B9B582267E8407E5 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC+9N5JdeBCYSNAAMRAqWnAKCftXMEdupw2BcPfFF//U2sPrt8+ACgi1fz +ClIX7xWItItgq2NhnLskcQM= +=P+9r +-----END PGP SIGNATURE----- + +--------------enigA0AF2BF7B9B582267E8407E5-- + +From pgsql-performance-owner@postgresql.org Thu Aug 11 20:13:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C74D552F05 + for ; + Thu, 11 Aug 2005 20:13:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12193-08 + for ; + Thu, 11 Aug 2005 23:13:27 +0000 (GMT) +Received: from sccrmhc14.comcast.net (sccrmhc14.comcast.net [204.127.202.59]) + by svr1.postgresql.org (Postfix) with ESMTP id F307252F3C + for ; + Thu, 11 Aug 2005 20:13:25 -0300 (ADT) +Received: from [192.168.1.52] + (c-24-60-119-214.hsd1.ma.comcast.net[24.60.119.214]) + by comcast.net (sccrmhc14) with ESMTP + id <2005081123132801400k49ene>; Thu, 11 Aug 2005 23:13:28 +0000 +Message-ID: <42FBDB97.1010906@comcast.net> +Date: Thu, 11 Aug 2005 19:13:27 -0400 +From: Jeffrey Tenny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John A Meinel +Cc: pgsql-performance@postgresql.org +Subject: Re: Mostly read performance +References: <42FBCF4D.6060002@comcast.net> + <42FBD377.8040006@arbash-meinel.com> +In-Reply-To: <42FBD377.8040006@arbash-meinel.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.562 tagged_above=0 required=5 tests=[AWL=-0.680, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, + DNS_FROM_RFC_WHOIS=0.492] +X-Spam-Level: * +X-Archive-Number: 200508/136 +X-Sequence-Number: 13883 + +John A Meinel wrote: + > Well, first off, the general recommendation is probably that 7.3 is +> really old, and you should try to upgrade to at least 7.4, though +> recommended to 8.0. + +There have been issues with each release that led me to wait. +Even now I'm waiting for some things to settle in the 8.0 JDBC driver +(timezones), and 7.3 has behaved well for me. But yes, I'd like to upgrade. + +> +> The bigger questions: How much RAM do you have? How busy is your system? + +The system for testing was 512MB. I'm in the process of buying some +additional memory. However there was no swap activity on that system, +so I doubt memory was the limiting factor. + +> +> 8.0 doesn't really do anything to do make the system cache the data. +> What kernel are you using? + +2.4.X for various large x. (Multiple systems). Gonna try 2.6.x soon. + +> +> Also, if your tables are small enough, and your RAM is big enough, you +> might already have everything cached. + +Well, that's what you'd expect. But a first time 70MB fetch on a +freshly rebooted system took just as long as all secondary times. (Took +over a minute to fetch, which is too long for my needs, at least on +secondary attempts). + +> One way to flush the caches, is to allocate a bunch of memory, and then +> scan through it. Or maybe mmap a really big file, and access every byte. +> But if your kernel is smart enough, it could certainly deallocate pages +> after you stopped accessing them, so I can't say for sure that you can +> flush the memory cache. Usually, I believe these methods are sufficient. + +Not sure how that would really help. It doesn't seem like the database +or file system is caching the table content either way, which led me to +this inquiry. + +From pgsql-performance-owner@postgresql.org Thu Aug 11 20:30:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A84852B87 + for ; + Thu, 11 Aug 2005 20:30:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54180-07 + for ; + Thu, 11 Aug 2005 23:30:40 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id E6DE552822 + for ; + Thu, 11 Aug 2005 20:30:36 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050811233036m9100g7hq6e>; Thu, 11 Aug 2005 23:30:36 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 41E2056008; Thu, 11 Aug 2005 18:30:36 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id BFBF355FCC; + Thu, 11 Aug 2005 18:30:29 -0500 (CDT) +Message-ID: <42FBDF94.5060104@arbash-meinel.com> +Date: Thu, 11 Aug 2005 18:30:28 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alvaro Herrera +Cc: Postgresql Performance +Subject: Re: Odd Locking Problem +References: <42FBB6CF.6000404@arbash-meinel.com> + <20050811210842.GA28253@alvh.no-ip.org> +In-Reply-To: <20050811210842.GA28253@alvh.no-ip.org> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigA572A149154C7AAEB8BE044E" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=[AWL=-0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/137 +X-Sequence-Number: 13884 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigA572A149154C7AAEB8BE044E +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Alvaro Herrera wrote: +> On Thu, Aug 11, 2005 at 03:36:31PM -0500, John A Meinel wrote: +> + +... + +> +> This is a known problem, solved in 8.1. A workaround for previous +> releases is to defer FK checks until commit: + +So I don't know exactly what the fix was, but I just tested, and my +problem is indeed fixed with the latest CVS head. It no longer blocks. + +> +> create table b (a int references a initially deferred); +> + +John +=:-> + +--------------enigA572A149154C7AAEB8BE044E +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC+9+UJdeBCYSNAAMRAmrrAJ4xvUnHizNwntKnQvWdUeFoXJvsgACgrH3a +xypks5LPA/BuZ3T9h2oZlpo= +=b9YD +-----END PGP SIGNATURE----- + +--------------enigA572A149154C7AAEB8BE044E-- + +From pgsql-performance-owner@postgresql.org Thu Aug 11 20:54:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F04852ECA + for ; + Thu, 11 Aug 2005 20:54:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09410-10 + for ; + Thu, 11 Aug 2005 23:54:47 +0000 (GMT) +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by svr1.postgresql.org (Postfix) with ESMTP id DACD352EC7 + for ; + Thu, 11 Aug 2005 20:54:41 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.53.154]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0IL30088P1380PV1@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Thu, 11 Aug 2005 18:54:45 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 6861761C7F4 for + ; + Thu, 11 Aug 2005 19:54:44 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 27237-01-3 for ; Thu, + 11 Aug 2005 19:54:44 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 4C5346005C0; Thu, 11 Aug 2005 19:54:44 -0400 (EDT) +Date: Thu, 11 Aug 2005 19:54:44 -0400 +From: Michael Stone +Subject: Re: PG8 Tuning +In-reply-to: <1123780724.14573.108.camel@archimedes> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050811235444.GO19080@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> + <1123780724.14573.108.camel@archimedes> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/138 +X-Sequence-Number: 13885 + +On Thu, Aug 11, 2005 at 10:18:44AM -0700, Mark Lewis wrote: +>Actually, it seems to me that with the addition of the WAL in PostgreSQL +>and the subsequent decreased need to fsync the data files themselves +>(only during checkpoints?), that the only time a battery-backed write +>cache would make a really large performance difference would be on the +>drive(s) hosting the WAL. + +Write cache on a raid array helps in the general case too, because +it allows the controller to aggregate & reorder write requests. The OS +probably tries to do this to some degree, but it can't do as well as the +raid controller because it doesn't know the physical disk layout. + +>Hmmm, on second thought, now I think I understand the rationale behind +>having a non-zero commit delay setting-- the problem with putting +>pg_xlog on a single disk without a write cache is that frequent fsync() +>calls might cause it to spend most of its time seeking instead of +>writing (as seems to be happening to Paul here). Then again, the OS IO +>scheduler should take care of this for you, making this a non-issue. + +The OS can't do anything much in terms of IO scheduling for synchronous +writes. Either it handles them in suboptimal order or you get hideous +latency while requests are queued for reordering. Neither option is +really great. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Thu Aug 11 21:34:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 63EEC53051 + for ; + Thu, 11 Aug 2005 21:30:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20880-10 + for ; + Fri, 12 Aug 2005 00:30:30 +0000 (GMT) +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B2E352EBC + for ; + Thu, 11 Aug 2005 21:30:29 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.53.154]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0IL300BRX2QW7OZ5@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Thu, 11 Aug 2005 19:30:33 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 207CF6005E0 for + ; + Thu, 11 Aug 2005 20:30:32 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 27559-05-3 for ; Thu, + 11 Aug 2005 20:30:32 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 05DF16005C0; Thu, 11 Aug 2005 20:30:32 -0400 (EDT) +Date: Thu, 11 Aug 2005 20:30:31 -0400 +From: Michael Stone +Subject: Re: Mostly read performance +In-reply-to: <42FBDB97.1010906@comcast.net> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050812003031.GP19080@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <42FBCF4D.6060002@comcast.net> + <42FBD377.8040006@arbash-meinel.com> + <42FBDB97.1010906@comcast.net> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/139 +X-Sequence-Number: 13886 + +On Thu, Aug 11, 2005 at 07:13:27PM -0400, Jeffrey Tenny wrote: +>The system for testing was 512MB + +That's definately *not* a "large ram" system. If you're reading a subset +of data that totals 70MB I'm going to guess that your data set is larger +than or at least a large fraction of 512MB. + +>additional memory. However there was no swap activity on that system, +>so I doubt memory was the limiting factor. + +The system won't swap if your data set is larger than your memory, it +just won't cache the data. + +>Well, that's what you'd expect. But a first time 70MB fetch on a +>freshly rebooted system took just as long as all secondary times. (Took +>over a minute to fetch, which is too long for my needs, at least on +>secondary attempts). + +If the query involves a table scan and the data set is larger than your +available memory, you'll need a full scan every time. If you do a table +scan and the table fits in RAM, subsequent runs should be faster. If you +have an index and only need to look at a subset of the table, subsequent +runs should be faster. Without knowing more about your queries it's not +clear what your situation is. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Sun Aug 14 19:52:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ACBD853073 + for ; + Fri, 12 Aug 2005 03:53:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62983-08 + for ; + Fri, 12 Aug 2005 06:53:45 +0000 (GMT) +Received: from mailrelay1.nefonline.de (mailrelay1.nefonline.de + [212.114.153.196]) + by svr1.postgresql.org (Postfix) with ESMTP id 023D553069 + for ; + Fri, 12 Aug 2005 03:53:43 -0300 (ADT) +Received: from mail (mail.marekmicro.de [212.114.149.81]) + by mailrelay1.nefonline.de (NEFkom Mailservice) with ESMTP id + j7C6rgp24815 + for ; Fri, 12 Aug 2005 08:53:43 +0200 +Received: from [83.208.155.174] by mail.marekmicro.de (GMS + 11.00.3335/NY4279.00.ab72d4bc) with SMTP id pqmfzhaa for + pgsql-performance@postgresql.org; Fri, 12 Aug 2005 08:53:34 +0200 +Received: from 127.0.0.1 (AVG SMTP 7.0.338 [267.10.7]); + Fri, 12 Aug 2005 08:53:34 +0200 +Message-ID: <001a01c59f0a$8e8d9560$de01a8c0@kavan> +From: "Petr Kavan" +To: +Subject: How many views is ok? +Date: Fri, 12 Aug 2005 08:53:33 +0200 +Organization: MarekMicro +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Originating-IP: [83.208.155.174] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/143 +X-Sequence-Number: 13890 + +I have database of company data, and some of them is table of information +about employees. I need each employee to have access only to his own row. +Postgre cannot do this by system of privileges, because that can give +privileges only to whole tables. + +Possibility is to create a view for each employee that chooses only his data +and give employee privileges to this view. But I am not sure if such number +of views does not have some performance drawbacks or even if postgre can +support it (I expect i can). I would need several tables protected like this +and it can result in, say 1000 views in maximum. + +Because access to DB will go through PHP information system, other +possibility to protect data is to let IS connect as more privileged than +user really is, but let it retrieve only data for that user. + +View-approach seems far more clear than this, but im not sure if postgre can +handle it without problems. + +Thanks for any reply :-) + +----------------------------------------------------------- +Petr Kavan +Database Development + + + +From pgsql-performance-owner@postgresql.org Fri Aug 12 04:32:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B1FCD53061 + for ; + Fri, 12 Aug 2005 04:32:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02730-09 + for ; + Fri, 12 Aug 2005 07:32:45 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 13FFE53022 + for ; + Fri, 12 Aug 2005 04:32:44 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1E3U1t-00048Q-00; Fri, 12 Aug 2005 03:32:37 -0400 +To: Michael Stone +Cc: pgsql-performance@postgresql.org +Subject: Re: Mostly read performance +References: <42FBCF4D.6060002@comcast.net> + <42FBD377.8040006@arbash-meinel.com> <42FBDB97.1010906@comcast.net> + <20050812003031.GP19080@mathom.us> +In-Reply-To: <20050812003031.GP19080@mathom.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 12 Aug 2005 03:32:37 -0400 +Message-ID: <871x4za9uy.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 hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=[AWL=0.003] +X-Spam-Level: +X-Archive-Number: 200508/140 +X-Sequence-Number: 13887 + + +Michael Stone writes: + +> > Well, that's what you'd expect. But a first time 70MB fetch on a freshly +> > rebooted system took just as long as all secondary times. (Took over a +> > minute to fetch, which is too long for my needs, at least on secondary +> > attempts). + +That's not impressively fast even for the disk. You should get up to about +40Mbit/s or 5MByte/s from the disk. Add some overhead for postgres; so I would +expect a full table scan of 70MB to take more like 15-30s, not over a minute. + +What is your shared_buffers setting? Perhaps you have it set way too high or +way too low? + +Also, you probably should post the "explain analyze" output of the actual +query you're trying to optimize. Even if you're not looking for a better plan +having hard numbers is better than guessing. + +And the best way to tell if the data is cached is having a "vmstat 1" running +in another window. Start the query and look at the bi/bo columns. If you see +bi spike upwards then it's reading from disk. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Aug 11 10:19:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EC9552AFE + for ; + Thu, 11 Aug 2005 10:19:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99406-05 + for ; + Thu, 11 Aug 2005 13:19:25 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E93652AE5 + for ; + Thu, 11 Aug 2005 10:19:24 -0300 (ADT) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Thu, 11 Aug 2005 06:23:13 -0700 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Thu, 11 Aug 2005 06:23:09 -0700 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005081106230901800 + for ; + Thu, 11 Aug 2005 06:23:09 -0700 +X-ASG-Debug-ID: 1123766364-13015-0-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail1 (mail1.hq.corp [192.168.160.5]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id 1BD2D20171B3 + for ; + Thu, 11 Aug 2005 06:19:24 -0700 (PDT) +Received: from [192.168.0.100] ([63.206.203.145]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.1830); Thu, 11 Aug 2005 06:23:02 -0700 +X-ASG-Orig-Subj: Re: [PERFORM] PG8 Tuning +Subject: [SPAM?] Re: PG8 Tuning +From: Steve Poe +To: paul@oxton.com +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> +Content-Type: text/plain +Date: Fri, 12 Aug 2005 08:47:08 +0000 +Message-Id: <1123836428.19976.26.camel@amd64-laptop-spoe> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 11 Aug 2005 13:23:02.0302 (UTC) + FILETIME=[CCBAD3E0:01C59E77] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: 4.03 +X-Barracuda-Spam-Status: Yes, SCORE=4.03 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_60, + DATE_IN_FUTURE_12_24 +X-Barracuda-Spam-Report: Code version 3.02, rules version 3.0.3136 + Rule breakdown below pts rule name description + ---- ---------------------- + -------------------------------------------------- + 3.03 DATE_IN_FUTURE_12_24 Date: is 12 to 24 hours after Received: date + 1.00 BAYES_60 BODY: Bayesian spam probability is 60 to 80% + [score: 0.6148] +X-Priority: 5 (Lowest) +X-MSMail-Priority: Low +Importance: Low +X-Barracuda-Spam-Flag: YES +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.329 tagged_above=0 required=5 tests=[AWL=-1.050, + DATE_IN_FUTURE_12_24=2.329, FORGED_RCVD_HELO=0.05, MISSING_MIMEOLE=0] +X-Spam-Level: * +X-Archive-Number: 200508/120 +X-Sequence-Number: 13867 + +Paul, + +Before I say anything else, one online document which may be of +assistance to you is: +http://www.powerpostgresql.com/PerfList/ + +Some thoughts I have: + +3) You're shared RAM setting seems overkill to me. Part of the challenge +is you're going from 1000 to 262K with no assessment in between. Each +situation can be different, but try in the range of 10 - 50K. + +4) pg_xlog: If you're pg_xlog is on a spindle is *only* for pg_xlog +you're better off. If it is sharing with any other OS/DB resource, the +performance will be impacted. + +>From what I have learned from others on this list, RAID5 is not the best +choice for the database. RAID10 would be a better solution (using 8 of +your disks) then take the remaining disk and do mirror with your pg_xlog +if possible. + +Best of luck, + +Steve Poe + +On Thu, 2005-08-11 at 13:23 +0100, Paul Johnson wrote: +> Hi all, we're running PG8 on a Sun V250 with 8GB RAM and 2*1.3GHz SPARC +> CPUs running Solaris 10. The DB cluster is on an external fibre-attached +> Sun T3 array that has 9*36GB drives configured as a single RAID5 LUN. +> +> The system is for the sole use of a couple of data warehouse developers, +> hence we are keen to use 'aggressive' tuning options to maximise +> performance. +> +> So far we have made the following changes and measured the impact on our +> test suite: +> +> 1) Increase checkpoint_segments from 3 to 64. This made a 10x improvement +> in some cases. +> +> 2) Increase work_mem from 1,024 to 524,288. +> +> 3) Increase shared_buffers from 1,000 to 262,143 (2 GB). This required +> setting SHMMAX=4294967295 (4 GB) in /etc/system and re-booting the box. +> +> Question - can Postgres only use 2GB RAM, given that shared_buffers can +> only be set as high as 262,143 (8K pages)? +> +> So far so good... +> +> 4) Move /pg_xlog to an internal disk within the V250. This has had a +> severe *negative* impact on performance. Copy job has gone from 2 mins to +> 12 mins, simple SQL job gone from 1 min to 7 mins. Not even run long SQL +> jobs. +> +> I'm guessing that this is because pg_xlog has gone from a 9 spindle LUN to +> a single spindle disk? +> +> In cases such as this, where an external storage array with a hardware +> RAID controller is used, the normal advice to separate the data from the +> pg_xlog seems to come unstuck, or are we missing something? +> +> Cheers, +> +> Paul Johnson. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + + +From pgsql-performance-owner@postgresql.org Fri Aug 12 09:18:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C3ED52A9D + for ; + Fri, 12 Aug 2005 09:18:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62989-02 + for ; + Fri, 12 Aug 2005 12:18:28 +0000 (GMT) +Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 9317852A44 + for ; + Fri, 12 Aug 2005 09:18:27 -0300 (ADT) +Received: from jefftrout.com ([24.147.120.205]) + by comcast.net (rwcrmhc11) with SMTP + id <2005081212182901300oiarje>; Fri, 12 Aug 2005 12:18:29 +0000 +Received: (qmail 87675 invoked from network); 12 Aug 2005 12:19:12 -0000 +Received: from c-24-147-120-205.hsd1.ma.comcast.net (HELO ?192.168.0.106?) + (24.147.120.205) + by 192.168.0.109 with SMTP; 12 Aug 2005 12:19:12 -0000 +In-Reply-To: <1123779524.6664.1.camel@toonses.gghcwest.com> +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> + <1123779524.6664.1.camel@toonses.gghcwest.com> +Mime-Version: 1.0 (Apple Message framework v733) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: Steve Poe , paul@oxton.com, + pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Jeff Trout +Subject: Re: [SPAM?] Re: PG8 Tuning +Date: Fri, 12 Aug 2005 08:18:27 -0400 +To: Jeffrey W.Baker +X-Mailer: Apple Mail (2.733) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 + tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/141 +X-Sequence-Number: 13888 + + +On Aug 11, 2005, at 12:58 PM, Jeffrey W. Baker wrote: + +> Like Mr. Stone said earlier, this is pure dogma. In my experience, +> xlogs on the same volume with data is much faster if both are on +> battery-backed write-back RAID controller memory. Moving from this +> situation to xlogs on a single normal disk is going to be much +> slower in +> most cases. +> + +This does also point one important point about performance. Which is +a touch unfortunate (and expensive to test): Your milage may vary on +any of these improvements. Some people have 0 problems and +incredible performance with say, 1000 shared_bufs and the WAL on the +same disk.. Others need 10k shared bufs and wal split over a 900 +spindle raid with data spread across 18 SAN's... +Unfortunately there is no one true way :( + +The best bet (which is great if you can): Try out various settings.. +if you still run into problems look into some more hardware.. see if +you can borrow any or fabricate a "poor man"'s equivalent for testing. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + + +From pgsql-performance-owner@postgresql.org Fri Aug 12 19:54:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D10F52C54 + for ; + Fri, 12 Aug 2005 19:37:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64189-04 + for ; + Fri, 12 Aug 2005 22:37:47 +0000 (GMT) +Received: from rwcrmhc12.comcast.net (rwcrmhc13.comcast.net [216.148.227.118]) + by svr1.postgresql.org (Postfix) with ESMTP id C5FFB52C4B + for ; + Fri, 12 Aug 2005 19:37:45 -0300 (ADT) +Received: from [192.168.1.52] + (c-24-60-119-214.hsd1.ma.comcast.net[24.60.119.214]) + by comcast.net (rwcrmhc13) with ESMTP + id <20050812223747015004omnde>; Fri, 12 Aug 2005 22:37:48 +0000 +Message-ID: <42FD24B9.8080209@comcast.net> +Date: Fri, 12 Aug 2005 18:37:45 -0400 +From: Jeffrey Tenny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Mostly read performance (2 replies) +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.576 tagged_above=0 required=5 tests=[AWL=-0.666, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, + DNS_FROM_RFC_WHOIS=0.492] +X-Spam-Level: * +X-Archive-Number: 200508/142 +X-Sequence-Number: 13889 + +(Pardon my replying two two replies at once, I only get the digest and +this was easier). + +Michael Stone wrote: +[...] +>> Well, that's what you'd expect. But a first time 70MB fetch on a freshly rebooted system took just as long as all secondary times. (Took over a minute to fetch, which is too long for my needs, at least on secondary attempts). +> +> +> If the query involves a table scan and the data set is larger than your +> available memory, you'll need a full scan every time. If you do a table +> scan and the table fits in RAM, subsequent runs should be faster. If you +> have an index and only need to look at a subset of the table, subsequent +> runs should be faster. Without knowing more about your queries it's not +> clear what your situation is. + +I must amend my original statement. I'm not using a parameterized +statement. The system is effectively fetching file content stored in +the database for portions of one or more files. It attempts to batch +the records being fetched into as few non-parameterized queries as +possible, while balancing the rowset retrieval memory impact. + +Currently that means it will request up to 16K records in a query that +is assembled using a combination of IN (recids...) , BETWEEN ranges, and +UNION ALL for multiple file IDs. I do this to minimize the latency of +dbclient/dbserver requests, while at the same time capping the maximum +data returned by a DBIO to about 1.2MB per maximum retrieved record set. +(I'm trying not to pound the java app server via jdbc memory usage). +There's an ORDER BY on the file id column too. + +It sounds like a simple enough thing to do, but this "pieces of many +files in a database" problem is actually pretty hard to optimize. +Fetching all records for all files, even though I don't need all +records, is both inefficient and likely to use too much memory. +Fetching 1 file at a time is likely to result in too many queries +(latency overhead). So right now I err on the side of large but record +limited queries. That let's me process many files in one query, unless +the pieces of the files I need are substantial. +(I've been burned by trying to use setFetchSize so many times it isn't +funny, I never count on that any more). + +An index is in place to assist with record selection, I'll double check +that it's being used. It's a joint index on file-id and +record-id-within-the-file. I'll check to be sure it's being used. + +------------------------ + + +Greg Stark wrote: +[...] + +> What is your shared_buffers setting? Perhaps you have it set way too high or +> way too low? + +I generally run with the conservative installation default. I did some +experimenting with larger values but didn't see any improvement (and +yes, I restarted postmaster). This testing was done a while ago, I +don't have the numbers in memory any more so I can't tell you what they +were. + +> +> Also, you probably should post the "explain analyze" output of the actual +> query you're trying to optimize. Even if you're not looking for a better plan +> having hard numbers is better than guessing. + +A good suggestion. I'll look into it. + + +> And the best way to tell if the data is cached is having a "vmstat 1" running +> in another window. Start the query and look at the bi/bo columns. If you see +> bi spike upwards then it's reading from disk. + +Another good suggestion. + +I'll look into getting further data from the above suggestions. + +I'm also looking into getting a gig or two of ram to make sure that +isn't an issue. + +The basis of my post originally was to make sure that, all things being +equal, there's no reason those disk I/Os on behalf of the database +shouldn't be cached by the operating/file system so that repeated reads +might benefit from in-memory data. + + +From pgsql-performance-owner@postgresql.org Sun Aug 14 21:22:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6762A52B76 + for ; + Sun, 14 Aug 2005 21:22:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13700-07 + for ; + Mon, 15 Aug 2005 00:22:24 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id AC12D52B45 + for ; + Sun, 14 Aug 2005 21:22:22 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050815002225m9100g5h18e>; Mon, 15 Aug 2005 00:22:25 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id E8DDE55FBA; Sun, 14 Aug 2005 19:22:24 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 0EA0C55FAD; + Sun, 14 Aug 2005 19:22:17 -0500 (CDT) +Message-ID: <42FFE034.2020809@arbash-meinel.com> +Date: Sun, 14 Aug 2005 19:22:12 -0500 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Petr Kavan +Cc: pgsql-performance@postgresql.org +Subject: Re: How many views is ok? +References: <001a01c59f0a$8e8d9560$de01a8c0@kavan> +In-Reply-To: <001a01c59f0a$8e8d9560$de01a8c0@kavan> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig147DE0C9C9250FD6A8D13C72" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.044 required=5 tests=[AWL=-0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/146 +X-Sequence-Number: 13893 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig147DE0C9C9250FD6A8D13C72 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Petr Kavan wrote: + +> I have database of company data, and some of them is table of +> information about employees. I need each employee to have access only +> to his own row. Postgre cannot do this by system of privileges, +> because that can give privileges only to whole tables. +> +> Possibility is to create a view for each employee that chooses only +> his data and give employee privileges to this view. But I am not sure +> if such number of views does not have some performance drawbacks or +> even if postgre can support it (I expect i can). I would need several +> tables protected like this and it can result in, say 1000 views in +> maximum. +> +> Because access to DB will go through PHP information system, other +> possibility to protect data is to let IS connect as more privileged +> than user really is, but let it retrieve only data for that user. +> +> View-approach seems far more clear than this, but im not sure if +> postgre can handle it without problems. + +We do a similar thing tying user to per-row permissions. We have 1 view +per table, and it works fine. +I would recommend that you do something similar. Basically, just make +the view: + +CREATE VIEW just_me SECURITY DEFINER AS + SELECT * FROM user_table WHERE username=session_user; +REVOKE ALL FROM user_table; +GRANT SELECT TO just_me TO PUBLIC; + +security definer, means that the 'just_me' view will be executed as the +user who created the function (superuser). +The REVOKE ALL (my syntax might be wrong) prevents users from querying +the user tables directly. +The 'session_user' makes the view use the name of the actual connected +user (because of security definer, plain 'user' is the superuser) +This should allow a user to see only their own row in the database. +(Whichever rows that have username matching the connected name). + +Now, this only works if the php front end connects specifically as the +given user (our system is setup to do this). + +If you don't do it this way, you'll always be stuck with the IS layer +doing the restriction. Even if you create a view per user, if your PHP +layer has the right to look at other tables/views, it doesn't really help. + +Good luck, +John +=:-> + +> +> Thanks for any reply :-) +> +> ----------------------------------------------------------- +> Petr Kavan +> Database Development +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + +--------------enig147DE0C9C9250FD6A8D13C72 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC/+A4JdeBCYSNAAMRAmf1AJsHZghn/X3xlqi5TEbUnmQ+q3gH6wCfVbc/ +oYGPbncq79Eq/Y/Pgp3aB/g= +=BVAg +-----END PGP SIGNATURE----- + +--------------enig147DE0C9C9250FD6A8D13C72-- + +From pgsql-performance-owner@postgresql.org Sun Aug 14 21:27:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3275452DCC + for ; + Sun, 14 Aug 2005 21:27:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13076-04 + for ; + Mon, 15 Aug 2005 00:27:52 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id A700552DC4 + for ; + Sun, 14 Aug 2005 21:27:50 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050815002743m92009jakke>; Mon, 15 Aug 2005 00:27:53 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id F3CF455FBA; Sun, 14 Aug 2005 19:27:42 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 2F1F455FAD; + Sun, 14 Aug 2005 19:27:39 -0500 (CDT) +Message-ID: <42FFE17A.6010208@arbash-meinel.com> +Date: Sun, 14 Aug 2005 19:27:38 -0500 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-1?Q?St=E9phane_COEZ?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance pb vs SQLServer. +References: <20050811131911.3175A1C0031B@mwinf0401.wanadoo.fr> +In-Reply-To: <20050811131911.3175A1C0031B@mwinf0401.wanadoo.fr> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigD250D4B21DC4E3093825C750" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/147 +X-Sequence-Number: 13894 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigD250D4B21DC4E3093825C750 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable + +St=E9phane COEZ wrote: + +>Hi, +> +>I have a perfomance issue : +> +>I run PG (8.0.3) and SQLServer2000 on a Windows2000 Server (P4 1,5Ghz 51= +2Mo) +>I have a table (3200000 rows) and I run this single query : +> +>select cod from mytable group by cod +>I have an index on cod (char(4) - 88 different values) +> +>PG =3D ~ 20 sec. +>SQLServer =3D < 8 sec +> +> +>the explain is : +> +>HashAggregate (cost=3D64410.09..64410.09 rows=3D55 width=3D8) +> -> Seq Scan on mytable (cost=3D0.00..56325.27 rows=3D3233927 width=3D= +8) +> +> +>if I switch to "enable_hashagg =3D false" (just for a try...) +>the planner will choose my index : +> +>Group (cost=3D0.00..76514.01 rows=3D55 width=3D8) +> -> Index Scan using myindex on mytable (cost=3D0.00..68429.20 rows=3D= +3233927 +>width=3D8) +> +>but performance will be comparable to previous test. +> +>So with or without using Index I have the same result. +> =20 +> + +My guess is that this is part of a larger query. There isn't really much +you can do. If you want all 3.2M rows, then you have to wait for them to +be pulled in. + +What you generally can do for performance, is to restructure things, so +that you *don't* have to touch all 3.2M rows. +If you are just trying to determine what the unique entries are for cod, +you probably are better off doing some normalization, and keeping a +separate table of cod values. + +I'm guessing the reason your query is faster with SQLServer is because +of how postgres handles MVCC. Basically, it still has to fetch the main +page to determine if a row exists. While SQL server doesn't do MVCC, so +it can just look things up in the index. + +You might also try a different query, something like: + +SELECT DISTINCT cod FROM mytable ORDER BY cod GROUP BY cod; +(You may or may not want order by, or group by, try the different +combinations.) +It might be possible to have the planner realize that all you want is +unique rows, just doing a group by doesn't give you that. + +John +=3D:-> + +> +>Thanks for help. +>=20 +>St=E9phane COEZ +> +> +> +> +>---------------------------(end of broadcast)---------------------------= + +>TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> +> =20 +> + + + +--------------enigD250D4B21DC4E3093825C750 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC/+F6JdeBCYSNAAMRAjKFAJ9N79+cvK394sIPq4gIvwfFu8x2XgCaAwnm +QJu7OTqD6J+QWxIeIEj0jvk= +=I7DZ +-----END PGP SIGNATURE----- + +--------------enigD250D4B21DC4E3093825C750-- + +From pgsql-performance-owner@postgresql.org Sun Aug 14 21:38:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 68B8853186 + for ; + Sun, 14 Aug 2005 21:38:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11850-08 + for ; + Mon, 15 Aug 2005 00:38:00 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4BEF153180 + for ; + Sun, 14 Aug 2005 21:38:00 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7F0c0t3005060; + Sun, 14 Aug 2005 20:38:00 -0400 (EDT) +To: "Petr Kavan" +Cc: pgsql-performance@postgresql.org +Subject: Re: How many views is ok? +In-reply-to: <001a01c59f0a$8e8d9560$de01a8c0@kavan> +References: <001a01c59f0a$8e8d9560$de01a8c0@kavan> +Comments: In-reply-to "Petr Kavan" + message dated "Fri, 12 Aug 2005 08:53:33 +0200" +Date: Sun, 14 Aug 2005 20:38:00 -0400 +Message-ID: <5059.1124066280@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/148 +X-Sequence-Number: 13895 + +"Petr Kavan" writes: +> Possibility is to create a view for each employee that chooses only his data +> and give employee privileges to this view. But I am not sure if such number +> of views does not have some performance drawbacks or even if postgre can +> support it (I expect i can). + +Do you really need more than one view? I'd consider something like + + create view emp_view as select * from emp where name = current_user; + +This requires that your Postgres usernames match up with something in +the underlying table, of course. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 14 22:02:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 96B5552B08 + for ; + Sun, 14 Aug 2005 22:02:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20018-08 + for ; + Mon, 15 Aug 2005 01:02:01 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 06B2452B0A + for ; + Sun, 14 Aug 2005 22:01:59 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1E4TMW-0002cN-Md + for pgsql-performance@postgresql.org; Mon, 15 Aug 2005 03:02:02 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1E4TMV-0007Lx-00 + for ; Mon, 15 Aug 2005 03:01:59 +0200 +Date: Mon, 15 Aug 2005 03:01:59 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Performance pb vs SQLServer. +Message-ID: <20050815010159.GA27795@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050811131911.3175A1C0031B@mwinf0401.wanadoo.fr> + <42FFE17A.6010208@arbash-meinel.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <42FFE17A.6010208@arbash-meinel.com> +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.017 required=5 tests=[AWL=0.017] +X-Spam-Level: +X-Archive-Number: 200508/149 +X-Sequence-Number: 13896 + +On Sun, Aug 14, 2005 at 07:27:38PM -0500, John Arbash Meinel wrote: +> My guess is that this is part of a larger query. There isn't really much +> you can do. If you want all 3.2M rows, then you have to wait for them to +> be pulled in. + +To me, it looks like he'll get 88 rows, not 3.2M. Surely we must be able to +do something better than a full sequential scan in this case? + +test=# create table foo ( bar char(4) ); +CREATE TABLE +test=# insert into foo values ('0000'); +INSERT 24773320 1 +test=# insert into foo values ('0000'); +INSERT 24773321 1 +test=# insert into foo values ('1111'); +INSERT 24773322 1 +test=# select * from foo group by bar; + bar +------ + 1111 + 0000 +(2 rows) + +I considered doing some odd magic with generate_series() and subqueries with +LIMIT 1, but it was a bit too weird in the end :-) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sun Aug 14 22:04:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AC02B52B0A + for ; + Sun, 14 Aug 2005 22:04:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18411-07 + for ; + Mon, 15 Aug 2005 01:04:12 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 83B9852B08 + for ; + Sun, 14 Aug 2005 22:04:12 -0300 (ADT) +Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] + helo=trofast.sesse.net) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1E4TOh-0002cw-PO + for pgsql-performance@postgresql.org; Mon, 15 Aug 2005 03:04:16 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1E4TOh-0007QW-00 + for ; Mon, 15 Aug 2005 03:04:15 +0200 +Date: Mon, 15 Aug 2005 03:04:15 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Performance pb vs SQLServer. +Message-ID: <20050815010415.GB27795@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050811131911.3175A1C0031B@mwinf0401.wanadoo.fr> + <42FFE17A.6010208@arbash-meinel.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <42FFE17A.6010208@arbash-meinel.com> +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.017 required=5 tests=[AWL=0.017] +X-Spam-Level: +X-Archive-Number: 200508/150 +X-Sequence-Number: 13897 + +On Sun, Aug 14, 2005 at 07:27:38PM -0500, John Arbash Meinel wrote: +> If you are just trying to determine what the unique entries are for cod, +> you probably are better off doing some normalization, and keeping a +> separate table of cod values. + +Pah, I missed this part of the e-mail -- you can ignore most of my (other) +reply, then :-) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sun Aug 14 22:06:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D8CCA52EBF + for ; + Sun, 14 Aug 2005 22:06:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20648-06 + for ; + Mon, 15 Aug 2005 01:05:59 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A01352ABA + for ; + Sun, 14 Aug 2005 22:05:58 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050815010602m9100g6bcte>; Mon, 15 Aug 2005 01:06:02 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 25A1155FBA; Sun, 14 Aug 2005 20:06:02 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 07EFE55FAD; + Sun, 14 Aug 2005 20:05:59 -0500 (CDT) +Message-ID: <42FFEA76.6070109@arbash-meinel.com> +Date: Sun, 14 Aug 2005 20:05:58 -0500 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Steinar H. Gunderson" +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance pb vs SQLServer. +References: <20050811131911.3175A1C0031B@mwinf0401.wanadoo.fr> + <42FFE17A.6010208@arbash-meinel.com> + <20050815010159.GA27795@uio.no> +In-Reply-To: <20050815010159.GA27795@uio.no> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig600AA473DF119A810C53F557" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/151 +X-Sequence-Number: 13898 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig600AA473DF119A810C53F557 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Steinar H. Gunderson wrote: + +>On Sun, Aug 14, 2005 at 07:27:38PM -0500, John Arbash Meinel wrote: +> +> +>>My guess is that this is part of a larger query. There isn't really much +>>you can do. If you want all 3.2M rows, then you have to wait for them to +>>be pulled in. +>> +>> +> +>To me, it looks like he'll get 88 rows, not 3.2M. Surely we must be able to +>do something better than a full sequential scan in this case? +> +>test=# create table foo ( bar char(4) ); +>CREATE TABLE +>test=# insert into foo values ('0000'); +>INSERT 24773320 1 +>test=# insert into foo values ('0000'); +>INSERT 24773321 1 +>test=# insert into foo values ('1111'); +>INSERT 24773322 1 +>test=# select * from foo group by bar; +> bar +>------ +> 1111 +> 0000 +>(2 rows) +> +>I considered doing some odd magic with generate_series() and subqueries with +>LIMIT 1, but it was a bit too weird in the end :-) +> +>/* Steinar */ +> +> +I think a plain "GROUP BY" is not smart enough to detect it doesn't need +all rows (since it is generally used because you want to get aggregate +values of other columns). +I think you would want something like SELECT DISTINCT, possibly with an +ORDER BY rather than a GROUP BY (which was my final suggestion). + +John +=:-> + + +--------------enig600AA473DF119A810C53F557 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFC/+p2JdeBCYSNAAMRAnhQAJ4oOR2RxZyaLi4yJsrSCHJObxtfewCfQZIV +6mg+ebmDTj6dK5q4doe4hj4= +=6vR1 +-----END PGP SIGNATURE----- + +--------------enig600AA473DF119A810C53F557-- + +From pgsql-performance-owner@postgresql.org Sun Aug 14 22:18:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5138252B71 + for ; + Sun, 14 Aug 2005 22:18:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24135-01 + for ; + Mon, 15 Aug 2005 01:18:46 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 832AF52974 + for ; + Sun, 14 Aug 2005 22:18:44 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7F1IjgU014406; + Sun, 14 Aug 2005 21:18:45 -0400 (EDT) +To: "Steinar H. Gunderson" +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance pb vs SQLServer. +In-reply-to: <20050815010159.GA27795@uio.no> +References: <20050811131911.3175A1C0031B@mwinf0401.wanadoo.fr> + <42FFE17A.6010208@arbash-meinel.com> + <20050815010159.GA27795@uio.no> +Comments: In-reply-to "Steinar H. Gunderson" + message dated "Mon, 15 Aug 2005 03:01:59 +0200" +Date: Sun, 14 Aug 2005 21:18:45 -0400 +Message-ID: <14401.1124068725@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/152 +X-Sequence-Number: 13899 + +"Steinar H. Gunderson" writes: +> To me, it looks like he'll get 88 rows, not 3.2M. Surely we must be able to +> do something better than a full sequential scan in this case? + +Not really. There's been some speculation about implementing index +"skip search" --- once you've verified there's at least one visible +row of a given index value, tell the index to skip to the next different +value instead of handing back any of the remaining entries of the +current value. But it'd be a lot of work and AFAICS not useful for +very many kinds of queries besides this. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 14 22:37:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A05B35318D + for ; + Sun, 14 Aug 2005 22:37:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26437-04 + for ; + Mon, 15 Aug 2005 01:37:41 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id D9E8F53186 + for ; + Sun, 14 Aug 2005 22:37:40 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1E4Tv4-0002hi-AJ + for pgsql-performance@postgresql.org; Mon, 15 Aug 2005 03:37:43 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1E4Tv3-0008Vq-00 + for ; Mon, 15 Aug 2005 03:37:41 +0200 +Date: Mon, 15 Aug 2005 03:37:41 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Performance pb vs SQLServer. +Message-ID: <20050815013741.GA32106@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20050811131911.3175A1C0031B@mwinf0401.wanadoo.fr> + <42FFE17A.6010208@arbash-meinel.com> + <20050815010159.GA27795@uio.no> <14401.1124068725@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <14401.1124068725@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.016 required=5 tests=[AWL=0.016] +X-Spam-Level: +X-Archive-Number: 200508/153 +X-Sequence-Number: 13900 + +On Sun, Aug 14, 2005 at 09:18:45PM -0400, Tom Lane wrote: +> Not really. There's been some speculation about implementing index +> "skip search" --- once you've verified there's at least one visible +> row of a given index value, tell the index to skip to the next different +> value instead of handing back any of the remaining entries of the +> current value. But it'd be a lot of work and AFAICS not useful for +> very many kinds of queries besides this. + +This is probably a completely wrong way of handling it all, but could it be +done in a PL/PgSQL query like this? (Pseudo-code, sort of; I'm not very well +versed in the actual syntax, but I'd guess you get the idea.) + +x = ( SELECT foo FROM table ORDER BY foo LIMIT 1 ); +WHILE x IS NOT NULL + RETURN NEXT x; + x = ( SELECT foo FROM table WHERE foo > x ORDER BY foo LIMIT 1 ); +END; + +(Replace with max() and min() for 8.1, of course.) + +/* Steinar */ +- fond of horrible hacks :-) +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Mon Aug 15 02:23:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1810752A95 + for ; + Mon, 15 Aug 2005 02:23:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83171-07 + for ; + Mon, 15 Aug 2005 05:23:28 +0000 (GMT) +Received: from smtp.seznam.cz (smtp.seznam.cz [212.80.76.43]) + by svr1.postgresql.org (Postfix) with SMTP id 2413C528CC + for ; + Mon, 15 Aug 2005 02:23:25 -0300 (ADT) +Received: (qmail 15477 invoked from network); 15 Aug 2005 05:23:24 -0000 +Received: from unknown (HELO ?192.168.1.222?) (kavan.petr@83.208.155.174) + by cetus.go.seznam.cz with ESMTPA; 15 Aug 2005 05:23:24 -0000 +Received: from 127.0.0.1 (AVG SMTP 7.0.338 [267.10.9]); + Mon, 15 Aug 2005 07:23:24 +0200 +Message-ID: <005301c5a159$75a2ec20$de01a8c0@kavan> +From: "Petr Kavan" +To: "John Arbash Meinel" +Cc: +References: <001a01c59f0a$8e8d9560$de01a8c0@kavan> + <42FFE034.2020809@arbash-meinel.com> +Subject: Re: How many views is ok? +Date: Mon, 15 Aug 2005 07:23:23 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-Mimeole: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.376 required=5 tests=[DNS_FROM_RFC_POST=1.376] +X-Spam-Level: * +X-Archive-Number: 200508/155 +X-Sequence-Number: 13902 + +Hey, that trick with session_user is great! :-) Thank you all very much, +this will certainly help. + + +----------------------------------------------------------- +Petr Kavan +Database Development + + +----- Original Message ----- +From: "John Arbash Meinel" +To: "Petr Kavan" +Cc: +Sent: Monday, August 15, 2005 2:22 AM +Subject: Re: [PERFORM] How many views is ok? + + + +From pgsql-performance-owner@postgresql.org Mon Aug 15 01:54:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 438B2529B8 + for ; + Mon, 15 Aug 2005 01:54:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77139-10 + for ; + Mon, 15 Aug 2005 04:54:32 +0000 (GMT) +Received: from netbox.unitech.com.ar (unknown [200.32.92.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E28E5298F + for ; + Mon, 15 Aug 2005 01:54:29 -0300 (ADT) +Received: (from dariop@localhost) + by netbox.unitech.com.ar (8.11.6/8.11.6) id j7F5ptH26582; + Mon, 15 Aug 2005 01:51:55 -0400 +Date: Mon, 15 Aug 2005 01:51:55 -0400 +From: dario_d_s@unitech.com.ar +X-Authentication-Warning: netbox.unitech.com.ar: dariop set sender to + dario_d_s@unitech.com.ar using -f +Subject: Re: Performance pb vs SQLServer. +To: scoez@harrysoftware.com +Cc: pgsql-performance@postgresql.org +X-Originating-IP: 201.254.9.56 +X-Mailer: Usermin 1.110 +X-Priority: 4 +Message-Id: <1124085115.26580@netbox.unitech.com.ar> +MIME-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.154 required=5 tests=[AWL=-0.024, + NO_REAL_NAME=0.178] +X-Spam-Level: +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200508/154 +X-Sequence-Number: 13901 + +This is a multi-part message in MIME format. + +--bound1124085115 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 7bit + +One little thing. Did you shutdown sql2000 while testing postgresql? Remember that postgresql uses system cache. Sql2000 uses a large part of memory as buffer and it will not be available to operating system. I must say that, probably, results will be the same, but it will be a better test. + +> I'm guessing the reason your query is faster with SQLServer is because +> of how postgres handles MVCC. Basically, it still has to fetch the main +> page to determine if a row exists. While SQL server doesn't do MVCC, so +> it can just look things up in the index. + +Another thing [almost offtopic]: +I would like to add something to understand what does MVCC means and what are the consecuences. +MVCC: multiversion concurrency control. (ehhh...) + +Just do this. + +Open two psql sessions. Do this: +Session 1: + begin; + update any_table set any_column = 'value_a' where other_column = 'value_b' + -- do not commit +Session 2: + select any_table where other_column = 'value_b' + Watch the result. +Session 1: + commit; +Session 2: + select any_table where other_column = 'value_b' + Watch the result. + +Now open two session in query analyzer. Do the same thing: +Session 1: + begin tran + update any_table set any_column = 'value_a' where other_column = 'value_b' + -- do not commit +Session 2: + select any_table where other_column = 'value_b' + Wait for result. + Wait... wait... (Oh, a lock! Ok, when you get tired, go back to session 1.) +Session 1: + commit +Session 2: + Then watch the result. + +Which one was faster? + +["very, very offtopic"] +Ok. This comparition is just as useless as the other one, because it's comparing oranges with apples (It's funny anyway). I was just choosing an example in which you can see the best of postgresql against 'not so nice' behavior of mssql2000 (no service pack, it's my desktop system, I'll do the same test later with SP4 and different isolation levels and I'll check results). Furthermore, MSSQL2000 is 5 years old now. Does anybody has the same cellular phone, or computer? (I don't want to know :-) ). The big question is 'What do you need?'. No system can give you all. That's marketing 'sarasa'. + +Sorry for my english and the noise. [End of offtopic] + +Long life, little spam and prosperity. + +--bound1124085115-- + + +From pgsql-performance-owner@postgresql.org Mon Aug 15 05:18:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ABC23530C6 + for ; + Mon, 15 Aug 2005 05:18:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28805-02 + for ; + Mon, 15 Aug 2005 08:18:02 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 727C453021 + for ; + Mon, 15 Aug 2005 05:18:02 -0300 (ADT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id C1EC18F289; Mon, 15 Aug 2005 10:18:03 +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 +Subject: Re: Performance pb vs SQLServer. +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Date: Mon, 15 Aug 2005 10:18:03 +0200 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE6C789B@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Performance pb vs SQLServer. +Thread-Index: AcWedz241y3YYG5NRWucxBfjaAmDhQC+oSZA +From: "Magnus Hagander" +To: =?iso-8859-1?Q?St=E9phane_COEZ?= , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 required=5 tests=[AWL=0.011, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/156 +X-Sequence-Number: 13903 + +> Hi, +>=20 +> I have a perfomance issue : +>=20 +> I run PG (8.0.3) and SQLServer2000 on a Windows2000 Server=20 +> (P4 1,5Ghz 512Mo) I have a table (3200000 rows) and I run=20 +> this single query : +>=20 +> select cod from mytable group by cod +> I have an index on cod (char(4) - 88 different values) +>=20 +> PG =3D ~ 20 sec. +> SQLServer =3D < 8 sec +>=20 +>=20 +> the explain is : +>=20 +> HashAggregate (cost=3D64410.09..64410.09 rows=3D55 width=3D8) +> -> Seq Scan on mytable (cost=3D0.00..56325.27 rows=3D3233927 = +width=3D8) +>=20 +>=20 +> if I switch to "enable_hashagg =3D false" (just for a try...)=20 +> the planner will choose my index : +>=20 +> Group (cost=3D0.00..76514.01 rows=3D55 width=3D8) +> -> Index Scan using myindex on mytable =20 +> (cost=3D0.00..68429.20 rows=3D3233927 +> width=3D8) +>=20 +> but performance will be comparable to previous test. +>=20 +> So with or without using Index I have the same result. + +Out of curiosity, what plan do you get from SQLServer? I bet it's a = +clustered index scan... + + +//Magnus + +From pgsql-performance-owner@postgresql.org Mon Aug 15 05:25:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 800295311B + for ; + Mon, 15 Aug 2005 05:25:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23969-08 + for ; + Mon, 15 Aug 2005 08:25:46 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id D290D53115 + for ; + Mon, 15 Aug 2005 05:25:45 -0300 (ADT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 26F978F289; Mon, 15 Aug 2005 10:25:47 +0200 (CEST) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Performance pb vs SQLServer. +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Date: Mon, 15 Aug 2005 10:25:47 +0200 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE6C789C@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Performance pb vs SQLServer. +Thread-Index: AcWhV2CLRhRsDMJrSC6MdQEWvUnh7wAGpBzQ +From: "Magnus Hagander" +To: , +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 required=5 tests=[AWL=0.011, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/157 +X-Sequence-Number: 13904 + +> ["very, very offtopic"] +> Ok. This comparition is just as useless as the other one,=20 +> because it's comparing oranges with apples (It's funny=20 +> anyway). I was just choosing an example in which you can see=20 +> the best of postgresql against 'not so nice' behavior of=20 +> mssql2000 (no service pack, it's my desktop system, I'll do=20 +> the same test later with SP4 and different isolation levels=20 +> and I'll check results). + +There will be no difference in the service packs. +SQL 2005 has "MVCC" (they call it something different, of course, but +that's basicallyi what it is) + +> Furthermore, MSSQL2000 is 5 years=20 +> old now. Does anybody has the same cellular phone, or=20 +> computer? (I don't want to know :-) ). The big question is + +There is a big difference between your database and your cellphone. +There are a lot of systems out there running very solidly on older +products like MSSQL 7 (probably even some on 6.x), as well as Oracle 7,8 +and 9... +I'd say there is generally a huge difference in reliabilty in your +cellphone hw/sw than there is in your db hw/sw. I have yet to see a +cellphone that can run for a year without a reboot (or with a lot of +brands, complete replacement). +=20 +//Magnus + +From pgsql-performance-owner@postgresql.org Fri Aug 19 01:33:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2AF9353115 + for ; + Mon, 15 Aug 2005 06:05:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34799-08 + for ; + Mon, 15 Aug 2005 09:05:15 +0000 (GMT) +Received: from smtp7.wanadoo.fr (smtp7.wanadoo.fr [193.252.22.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DBFE530D7 + for ; + Mon, 15 Aug 2005 06:05:14 -0300 (ADT) +Received: from me-wanadoo.net (unknown [127.0.0.1]) + by mwinf0703.wanadoo.fr (SMTP Server) with ESMTP id 413831000099 + for ; + Mon, 15 Aug 2005 11:05:15 +0200 (CEST) +Received: from NEO (AToulon-151-1-27-207.w83-197.abo.wanadoo.fr + [83.197.78.207]) + by mwinf0703.wanadoo.fr (SMTP Server) with ESMTP id 0D75E100008F; + Mon, 15 Aug 2005 11:05:15 +0200 (CEST) +X-ME-UUID: 20050815090515552.0D75E100008F@mwinf0703.wanadoo.fr +From: =?iso-8859-1?Q?St=E9phane_COEZ?= +To: "'John Arbash Meinel'" +Cc: +Subject: Re: Performance pb vs SQLServer. +Date: Mon, 15 Aug 2005 11:05:11 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcWhMC+opyYYrHMVSf2/AMvq1xq1rAAR/teQ +In-Reply-To: <42FFE17A.6010208@arbash-meinel.com> +Message-Id: <20050815090515.0D75E100008F@mwinf0703.wanadoo.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/238 +X-Sequence-Number: 13985 + +John Arbash Meinel wrote :=20 +>=20 +> You might also try a different query, something like: +>=20 +> SELECT DISTINCT cod FROM mytable ORDER BY cod GROUP BY cod;=20 +> (You may or may not want order by, or group by, try the different +> combinations.) +> It might be possible to have the planner realize that all you=20 +> want is unique rows, just doing a group by doesn't give you that. +>=20 +> John +> =3D:-> +>=20 +Thanks John, but using SELECT DISTINCT with or without Order nor Group = +by is +worth... +30 sec (with index) - stopped at 200 sec without index... + +So Hash Aggregate is much better than index scan ... + + +> > +> >Thanks for help. +> >=20 +> >St=E9phane COEZ +> > +> > +> > +> > +> >---------------------------(end of=20 +> >broadcast)--------------------------- +> >TIP 9: In versions below 8.0, the planner will ignore your desire to +> > choose an index scan if your joining column's datatypes do not +> > match +> > +> > =20 +> > +>=20 +>=20 +>=20 + + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 01:37:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 903E653115 + for ; + Mon, 15 Aug 2005 06:08:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41087-02 + for ; + Mon, 15 Aug 2005 09:08:08 +0000 (GMT) +Received: from smtp7.wanadoo.fr (smtp7.wanadoo.fr [193.252.22.24]) + by svr1.postgresql.org (Postfix) with ESMTP id DE86B530D7 + for ; + Mon, 15 Aug 2005 06:08:07 -0300 (ADT) +Received: from me-wanadoo.net (localhost [127.0.0.1]) + by mwinf0709.wanadoo.fr (SMTP Server) with ESMTP id BFC8E1C000AA + for ; + Mon, 15 Aug 2005 11:08:09 +0200 (CEST) +Received: from NEO (AToulon-151-1-27-207.w83-197.abo.wanadoo.fr + [83.197.78.207]) + by mwinf0709.wanadoo.fr (SMTP Server) with ESMTP id 87D941C000A4; + Mon, 15 Aug 2005 11:08:09 +0200 (CEST) +X-ME-UUID: 20050815090809556.87D941C000A4@mwinf0709.wanadoo.fr +From: =?iso-8859-1?Q?St=E9phane_COEZ?= +To: +Cc: +Subject: Re: Performance pb vs SQLServer. +Date: Mon, 15 Aug 2005 11:08:06 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcWhVWPiS4kw4PktQu2478X/qr7OIAAIyOCg +In-Reply-To: <1124085115.26580@netbox.unitech.com.ar> +Message-Id: <20050815090809.87D941C000A4@mwinf0709.wanadoo.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/245 +X-Sequence-Number: 13992 + + +> +> One little thing. Did you shutdown sql2000 while testing +> postgresql? Remember that postgresql uses system cache. +> Sql2000 uses a large part of memory as buffer and it will not +> be available to operating system. I must say that, probably, +> results will be the same, but it will be a better test. +> + +Shutting done SQL2000 has no effect on PG performancies. + +Stephane. + + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 01:33:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 79FC6530E5 + for ; + Mon, 15 Aug 2005 06:08:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33767-07 + for ; + Mon, 15 Aug 2005 09:08:08 +0000 (GMT) +Received: from smtp7.wanadoo.fr (smtp7.wanadoo.fr [193.252.22.24]) + by svr1.postgresql.org (Postfix) with ESMTP id D66A252F3B + for ; + Mon, 15 Aug 2005 06:08:07 -0300 (ADT) +Received: from me-wanadoo.net (localhost [127.0.0.1]) + by mwinf0709.wanadoo.fr (SMTP Server) with ESMTP id 6C2951C000A5 + for ; + Mon, 15 Aug 2005 11:08:09 +0200 (CEST) +Received: from NEO (AToulon-151-1-27-207.w83-197.abo.wanadoo.fr + [83.197.78.207]) + by mwinf0709.wanadoo.fr (SMTP Server) with ESMTP id 3607E1C000A4; + Mon, 15 Aug 2005 11:08:09 +0200 (CEST) +X-ME-UUID: 20050815090809221.3607E1C000A4@mwinf0709.wanadoo.fr +From: =?iso-8859-1?Q?St=E9phane_COEZ?= +To: "'Magnus Hagander'" , + +Subject: Re: Performance pb vs SQLServer. +Date: Mon, 15 Aug 2005 11:08:06 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcWedz241y3YYG5NRWucxBfjaAmDhQC+oSZAAAG5cjA= +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCE6C789B@algol.sollentuna.se> +Message-Id: <20050815090809.3607E1C000A4@mwinf0709.wanadoo.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/239 +X-Sequence-Number: 13986 + +> De : Magnus Hagander [mailto:mha@sollentuna.net] +> Out of curiosity, what plan do you get from SQLServer? I bet +> it's a clustered index scan... +> +> +> //Magnus +> + +I have a Table scan and Hashaggregate... +Stephane + + + + + +From pgsql-performance-owner@postgresql.org Mon Aug 15 12:25:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EC1252AC9 + for ; + Mon, 15 Aug 2005 12:19:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35063-02 + for ; + Mon, 15 Aug 2005 15:19:34 +0000 (GMT) +Received: from email.aon.at (warsl404pip7.highway.telekom.at [195.3.96.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A36C52AC4 + for ; + Mon, 15 Aug 2005 12:19:32 -0300 (ADT) +Received: (qmail 8838 invoked from network); 15 Aug 2005 15:19:27 -0000 +Received: from m148p003.dipool.highway.telekom.at (HELO fermat.Koizar.inf) + ([62.46.8.99]) (envelope-sender ) + by smarthub73.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 15 Aug 2005 15:19:27 -0000 +From: Manfred Koizar +To: John A Meinel +Cc: Alvaro Herrera , + Postgresql Performance +Subject: Re: Odd Locking Problem +Date: Mon, 15 Aug 2005 17:19:44 +0200 +Message-ID: +References: <42FBB6CF.6000404@arbash-meinel.com> + <20050811210842.GA28253@alvh.no-ip.org> + <42FBBF1E.6040403@arbash-meinel.com> +In-Reply-To: <42FBBF1E.6040403@arbash-meinel.com> +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.217 required=5 tests=[AWL=0.167, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/158 +X-Sequence-Number: 13905 + +On Thu, 11 Aug 2005 16:11:58 -0500, John A Meinel + wrote: +>the insert is occurring into table 'a' not table 'b'. +>'a' refers to other tables, but these should not be modified. + +So your "a" is Alvaro's "b", and one of your referenced tables is +Alvaro's "a". This is further supported by the fact that the problem +doesn't occur with 8.1. + +Servus + Manfred + + +From pgsql-performance-owner@postgresql.org Mon Aug 15 13:22:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5EB9A52B42 + for ; + Mon, 15 Aug 2005 13:18:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51230-03 + for ; + Mon, 15 Aug 2005 16:18:35 +0000 (GMT) +Received: from alvh.no-ip.org (200-85-218-206.bk4-dsl.surnet.cl + [200.85.218.206]) + by svr1.postgresql.org (Postfix) with ESMTP id A872D52ADD + for ; + Mon, 15 Aug 2005 13:18:34 -0300 (ADT) +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 872A2C2DC09; Mon, 15 Aug 2005 12:18:59 -0400 (CLT) +Date: Mon, 15 Aug 2005 12:18:59 -0400 +From: Alvaro Herrera +To: Magnus Hagander +Cc: dario_d_s@unitech.com.ar, scoez@harrysoftware.com, + pgsql-performance@postgresql.org +Subject: Re: Performance pb vs SQLServer. +Message-ID: <20050815161859.GB22386@alvh.no-ip.org> +Mail-Followup-To: Magnus Hagander , + dario_d_s@unitech.com.ar, scoez@harrysoftware.com, + pgsql-performance@postgresql.org +References: <6BCB9D8A16AC4241919521715F4D8BCE6C789C@algol.sollentuna.se> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCE6C789C@algol.sollentuna.se> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.736 required=5 tests=[AWL=0.312, + DNS_FROM_RFC_ABUSE=0.374, FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/159 +X-Sequence-Number: 13906 + +On Mon, Aug 15, 2005 at 10:25:47AM +0200, Magnus Hagander wrote: + +> SQL 2005 has "MVCC" (they call it something different, of course, but +> that's basicallyi what it is) + +Interesting; do they use an overwriting storage manager like Oracle, or +a non-overwriting one like Postgres? + +-- +Alvaro Herrera () +"The Postgresql hackers have what I call a "NASA space shot" mentality. + Quite refreshing in a world of "weekend drag racer" developers." +(Scott Marlowe) + +From pgsql-performance-owner@postgresql.org Fri Aug 19 01:37:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E6940528E6 + for ; + Mon, 15 Aug 2005 13:25:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52821-03 + for ; + Mon, 15 Aug 2005 16:25:01 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id BDB06528CB + for ; + Mon, 15 Aug 2005 13:24:58 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7FGOv0j022541 + for ; Mon, 15 Aug 2005 11:24:57 -0500 +Subject: I'm configuraing a new system (Bigish) and need some advice. +From: Jeremiah Jahn +To: postgres performance +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-ZiOwI4AYpsu7FZjWOMAk" +Date: Mon, 15 Aug 2005 11:24:57 -0500 +Message-Id: <1124123097.27881.59.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Received-SPF: pass (penguin.goodinassociates.com: domain of + goodinassociates.com designates 206.80.71.242 as permitted + sender) client-ip=206.80.71.242; + envelope-from=jeremiah@goodinassociates.com; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1021/Mon Aug 15 02:05:53 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/246 +X-Sequence-Number: 13993 + + +--=-ZiOwI4AYpsu7FZjWOMAk +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +The system is a dual Xenon with 6Gig of ram and 14 73Gig 15K u320 scsi +drives. Plus 2 raid 1 system dives. + +RedHat EL ES4 is the OS.=20 + + +Any1 have any suggestions as to the configuration? The database is about +60 Gig's. Should jump to 120 here quite soon. Mus of the searches +involve people's names. Through a website. My current setup just doesn't +seem to have resulted in the performance kick I wanted. I don't know if +it's LVM or what. The strang thing is that My Memory usage stays very +LOW for some reason. While on my current production server it stays very +high. Also looking for ideas on stipe and extent size. The below is run +off of a RAID 10. I have not moved my WAL file yet, but there were no +incoming transactions at the time the query was run. My stats on the +identity table are set to 1000. + + + +> explain analyze select distinct case_category,identity_id,court.name,liti= +gant_details.case_id,case_year,date_of_birth,assigned_case_role,litigant_de= +tails.court_ori,full_name,litigant_details.actor_id,case_data.type_code,cas= +e_data.subtype_code,litigant_details.impound_litigant_data, to_number(trim(= +leading case_data.type_code from trim(leading case_data.case_year from case= +_data.case_id)),'999999') as seq from identity,court,litigant_details,case_= +data where identity.court_ori =3D litigant_details.court_ori and identity.c= +ase_id =3D litigant_details.case_id and identity.actor_id =3D litigant_deta= +ils.actor_id and court.id =3D identity.court_ori and identity.court_ori =3D= + case_data.court_ori and case_data.case_id =3D identity.case_id and identi= +ty.court_ori =3D 'IL081025J' and full_name like 'SMITH%' order by full_nam= +e; +> = + = + = + QUERY PLAN=20 +> -------------------------------------------------------------------------= +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +----------------------- +> Unique (cost=3D34042.46..34042.57 rows=3D3 width=3D173) (actual time=3D= +63696.896..63720.193 rows=3D8086 loops=3D1) +> -> Sort (cost=3D34042.46..34042.47 rows=3D3 width=3D173) (actual tim= +e=3D63696.892..63702.239 rows=3D8086 loops=3D1) +> Sort Key: identity.full_name, case_data.case_category, identity.= +identity_id, court.name, litigant_details.case_id, case_data.case_year, ide= +ntity.date_of_birth, litigant_details.assigned_case_role, litigant_details.= +court_ori, litigant_details.actor_id, case_data.type_code, case_data.subtyp= +e_code, litigant_details.impound_litigant_data, to_number(ltrim(ltrim((case= +_data.case_id)::text, (case_data.case_year)::text), (case_data.type_code)::= +text), '999999'::text) +> -> Nested Loop (cost=3D0.00..34042.43 rows=3D3 width=3D173) (a= +ctual time=3D135.498..63655.542 rows=3D8086 loops=3D1) +> -> Nested Loop (cost=3D0.00..34037.02 rows=3D1 width=3D1= +59) (actual time=3D95.760..34637.611 rows=3D8086 loops=3D1) +> -> Nested Loop (cost=3D0.00..34033.72 rows=3D1 wid= +th=3D138) (actual time=3D89.222..34095.763 rows=3D8086 loops=3D1) +> Join Filter: (("outer".case_id)::text =3D ("in= +ner".case_id)::text) +> -> Index Scan using name_speed on identity (= +cost=3D0.00..1708.26 rows=3D8152 width=3D82) (actual time=3D42.589..257.818= + rows=3D8092 loops=3D1) +> Index Cond: (((full_name)::text >=3D 'SM= +ITH'::character varying) AND ((full_name)::text < 'SMITI'::character varyin= +g)) +> Filter: (((court_ori)::text =3D 'IL08102= +5J'::text) AND ((full_name)::text ~~ 'SMITH%'::text)) +> -> Index Scan using lit_actor_speed on litiga= +nt_details (cost=3D0.00..3.95 rows=3D1 width=3D81) (actual time=3D4.157..4= +.170 rows=3D1 loops=3D8092) +> Index Cond: (("outer".actor_id)::text = +=3D (litigant_details.actor_id)::text) +> Filter: ('IL081025J'::text =3D (court_or= +i)::text) +> -> Seq Scan on court (cost=3D0.00..3.29 rows=3D1 w= +idth=3D33) (actual time=3D0.051..0.058 rows=3D1 loops=3D8086) +> Filter: ('IL081025J'::text =3D (id)::text) +> -> Index Scan using case_data_pkey on case_data (cost=3D= +0.00..5.36 rows=3D2 width=3D53) (actual time=3D3.569..3.572 rows=3D1 loops= +=3D8086) +> Index Cond: (('IL081025J'::text =3D (case_data.court= +_ori)::text) AND ((case_data.case_id)::text =3D ("outer".case_id)::text)) +> Total runtime: 63727.873 ms +>=20 +>=20 + + + +> tcpip_socket =3D true +> max_connections =3D 100 +> shared_buffers =3D 50000 # min 16, at least max_connections*2, 8= +KB each +> sort_mem =3D 2024000 # min 64, size in KB +> vacuum_mem =3D 819200 # min 1024, size in KB +> checkpoint_segments =3D 20 # in logfile segments, min 1, 16MB each +> effective_cache_size =3D 3600000 # typically 8KB each +> random_page_cost =3D 2 # units are one sequential page fetch c= +ost +> log_min_duration_statement =3D 10000 # Log all statements whose +> lc_messages =3D 'C' # locale for system error message strin= +gs +> lc_monetary =3D 'C' # locale for monetary formatting +> lc_numeric =3D 'C' # locale for number formatting +> lc_time =3D 'C' # locale for time formatting + + + + + +Ingrate, n.: A man who bites the hand that feeds him, and then complains +of indigestion. + +--=-ZiOwI4AYpsu7FZjWOMAk +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (GNU/Linux) + +iD8DBQBDAMHZ6caZY8jbHDkRAsGSAJ4q1QMU9LIsj3aaOQ/0jZFnGRStagCeLEDl +NYMEcN6rFLROJ+MF0riM0MY= +=FjzE +-----END PGP SIGNATURE----- + +--=-ZiOwI4AYpsu7FZjWOMAk-- + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 01:37:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3ED6E5293C + for ; + Mon, 15 Aug 2005 13:29:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51782-08 + for ; + Mon, 15 Aug 2005 16:29:05 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id E0B4052B48 + for ; + Mon, 15 Aug 2005 13:29:04 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7FGT4vW022635 + for ; Mon, 15 Aug 2005 11:29:04 -0500 +Subject: Re: I'm configuraing a new system (Bigish) and need some advice. +From: Jeremiah Jahn +To: postgres performance +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-Ay129qIYc2pXgE16W2hX" +Date: Mon, 15 Aug 2005 11:29:04 -0500 +Message-Id: <1124123344.27881.63.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Received-SPF: pass (penguin.goodinassociates.com: domain of + goodinassociates.com designates 206.80.71.242 as permitted + sender) client-ip=206.80.71.242; + envelope-from=jeremiah@goodinassociates.com; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1021/Mon Aug 15 02:05:53 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/244 +X-Sequence-Number: 13991 + + +--=-Ay129qIYc2pXgE16W2hX +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +7.4 is the pg version BTW....going to switch to 8 if it's worth it. + + +Ingrate, n.: A man who bites the hand that feeds him, and then complains +of indigestion. +--=20 +"Don't say yes until I finish talking." + -- Darryl F. Zanuck + +--=-Ay129qIYc2pXgE16W2hX +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (GNU/Linux) + +iD8DBQBDAMLQ6caZY8jbHDkRAj8jAJ4+aN0q3ZjnHNAbAuqlFg3mw6NClwCeK2eS +4SJtEpsubfDREI+LzDJpwJU= +=yRiq +-----END PGP SIGNATURE----- + +--=-Ay129qIYc2pXgE16W2hX-- + + +From pgsql-performance-owner@postgresql.org Mon Aug 15 13:29:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0900D52B48 + for ; + Mon, 15 Aug 2005 13:29:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53761-03 + for ; + Mon, 15 Aug 2005 16:29:24 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 33C2352B45 + for ; + Mon, 15 Aug 2005 13:29:24 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7FGTO3o022664 + for ; Mon, 15 Aug 2005 11:29:24 -0500 +Subject: Re: I'm configuraing a new system (Bigish) and need some advice. +From: Jeremiah Jahn +To: postgres performance +Content-Type: text/plain +Date: Mon, 15 Aug 2005 11:29:23 -0500 +Message-Id: <1124123363.27881.65.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1021/Mon Aug 15 02:05:53 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.027 required=5 tests=[AWL=-0.023, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/160 +X-Sequence-Number: 13907 + +7.4 is the pg version BTW....going to switch to 8 if it's worth it. + + +Ingrate, n.: A man who bites the hand that feeds him, and then complains +of indigestion. +-- +"Don't say yes until I finish talking." + -- Darryl F. Zanuck +-- +"Don't say yes until I finish talking." + -- Darryl F. Zanuck + + +From pgsql-performance-owner@postgresql.org Mon Aug 15 17:35:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ADE5E52C1A + for ; + Mon, 15 Aug 2005 17:35:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19831-02 + for ; + Mon, 15 Aug 2005 20:35:11 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.244]) + by svr1.postgresql.org (Postfix) with ESMTP id B225552AD8 + for ; + Mon, 15 Aug 2005 17:35:07 -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_01C5A1D8.D1E68745" +Subject: choosing RAID level for xlogs +Date: Mon, 15 Aug 2005 16:35:05 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BDF@vt-pe2550-001.VANTAGE.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: choosing RAID level for xlogs +Thread-Index: AcWh2NDgCbXrlD2dSvuZJkSyYWP7KA== +From: "Anjan Dave" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.034 required=5 tests=[AWL=0.033, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/161 +X-Sequence-Number: 13908 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5A1D8.D1E68745 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Hi, + +=20 + +One simple question. For 125 or more checkpoint segments +(checkpoint_timeout is 600 seconds, shared_buffers are at 21760 or +170MB) on a very busy database, what is more suitable, a separate 6 disk +RAID5 volume, or a RAID10 volume? Databases will be on separate +spindles. Disks are 36GB 15KRPM, 2Gb Fiber Channel. Performance is +paramount, but I don't want to use RAID0. + +=20 + +PG7.4.7 on RHAS 4.0 + +=20 + +I can provide more info if needed. + +=20 + +Appreciate some recommendations! + +=20 + +Thanks, + +Anjan + +=20 + +=20 +--- +This email message and any included attachments constitute confidential +and privileged information intended exclusively for the listed +addressee(s). If you are not the intended recipient, please notify +Vantage by immediately telephoning 215-579-8390, extension 1158. In +addition, please reply to this message confirming your receipt of the +same in error. A copy of your email reply can also be sent to +support@vantage.com. Please do not disclose, copy, distribute or take +any action in reliance on the contents of this information. Kindly +destroy all copies of this message and any attachments. Any other use of +this email is prohibited. Thank you for your cooperation. For more +information about Vantage, please visit our website at +http://www.vantage.com . +--- + +=20 + + +------_=_NextPart_001_01C5A1D8.D1E68745 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + +
+ +

Hi,

+ +

 

+ +

One simple question. For 125 or more checkpoint = +segments (checkpoint_timeout +is 600 seconds, shared_buffers are at 21760 or 170MB) on a very busy = +database, +what is more suitable, a separate 6 disk RAID5 volume, or a RAID10 = +volume? +Databases will be on separate spindles. Disks are 36GB 15KRPM, 2Gb Fiber +Channel. Performance is paramount, but I don’t want to use = +RAID0.

+ +

 

+ +

PG7.4.7 on RHAS 4.0

+ +

 

+ +

I can provide more info +if needed.

+ +

 

+ +

Appreciate some = +recommendations!

+ +

 

+ +

Thanks,

+ +

Anjan

+ +

 

+ +
 
---=
+
This =
+email message and any included attachments constitute confidential and =
+privileged information intended exclusively for the =
+listed addressee(s). If you are not the intended recipient, please =
+notify Vantage by immediately telephoning 215-579-8390, extension 1158. =
+In addition, please reply to this message confirming your receipt of the =
+same in error. A copy of your email reply can also be sent to =
+support@vantage.com. Please do not disclose, copy, distribute or take =
+any action in reliance on the contents of this information. Kindly destroy all copies of =
+this message and any attachments. Any other use of this email is =
+prohibited. Thank you for your cooperation. For more information about Vantage, please visit our =
+website at http://www.vantage.com.
---=
+
+ +

 

+ +
+ + + + + +------_=_NextPart_001_01C5A1D8.D1E68745-- + +From pgsql-performance-owner@postgresql.org Tue Aug 16 04:01:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DB3C5281F + for ; + Tue, 16 Aug 2005 04:01:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82895-04 + for ; + Tue, 16 Aug 2005 07:01:00 +0000 (GMT) +Received: from hotmail.com (bay18-f21.bay18.hotmail.com [65.54.187.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 68D1B52A78 + for ; + Tue, 16 Aug 2005 04:00:59 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 16 Aug 2005 00:01:00 -0700 +Message-ID: +Received: from 203.155.1.244 by by18fd.bay18.hotmail.msn.com with HTTP; + Tue, 16 Aug 2005 07:01:00 GMT +X-Originating-IP: [203.155.1.244] +X-Originating-Email: [maccran@hotmail.com] +X-Sender: maccran@hotmail.com +From: "wisan watcharinporn" +To: pgsql-performance@postgresql.org +Subject: database encoding with index search problem +Date: Tue, 16 Aug 2005 07:01:00 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +X-OriginalArrivalTime: 16 Aug 2005 07:01:00.0962 (UTC) + FILETIME=[429CA820:01C5A230] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.75 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374, + DNS_FROM_RFC_POST=1.376, MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: * +X-Archive-Number: 200508/162 +X-Sequence-Number: 13909 + +i have problem in database encoding with indexing + +case :1 +when i initdb -E win874 mydb and create database with createdb -E win874 +dbname +and create table emp with index in empname field + + +i can select sorting name correct in thai alphabet +such select empName from emp order by empName; +but in +select empName from emp where empname like 'xxx%' +it not using index scan , it use seq scan so it may slow in find name + +case :2 +when i initdb mydb (use default) and create database with createdb -E win874 +dbname +and create table emp with index in empname field + + +i can not select sorting name correct in thai alphabet +but in +select empName from emp where empname like 'xxx%' +it using index scan , very fast in find name + +problem: +how can i configure database that can correct in sorting name and using +index scan in like 'xxxx%' search + + +using FreeBSD 5.4 +postgreql 8.0. + +_________________________________________________________________ +Express yourself instantly with MSN Messenger! Download today it's FREE! +http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ + + +From pgsql-performance-owner@postgresql.org Tue Aug 16 04:29:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 85A2352A72 + for ; + Tue, 16 Aug 2005 04:29:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87417-06 + for ; + Tue, 16 Aug 2005 07:29:34 +0000 (GMT) +Received: from dd01.profihoster.net (dd01.profihoster.net [84.233.130.40]) + by svr1.postgresql.org (Postfix) with ESMTP id B4AEE52A3C + for ; + Tue, 16 Aug 2005 04:29:32 -0300 (ADT) +Received: from [192.168.54.114] (Iba10.i.pppool.de [85.73.186.16]) + by dd01.profihoster.net (Postfix) with ESMTP id C147A2380EF + for ; + Tue, 16 Aug 2005 09:29:28 +0200 (CEST) +Message-ID: <430195DC.70104@laliluna.de> +Date: Tue, 16 Aug 2005 09:29:32 +0200 +From: Sebastian Hennebrueder +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: postgres performance +Subject: Looking for a large database for testing +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/163 +X-Sequence-Number: 13910 + +Hello, + +I would like to test the performance of my Java/PostgreSQL applications +especially when making full text searches. +For this I am looking for a database with 50 to 300 MB having text fields. +e.g. A table with books with fields holding a comment, table of content +or example chapters +or what ever else. + +Does anybody have an idea where I can find a database like this or does +even have something like this? + +-- +Best Regards / Viele Gr��e + +Sebastian Hennebrueder + +---- + +http://www.laliluna.de + +Tutorials for JSP, JavaServer Faces, Struts, Hibernate and EJB + +Get support, education and consulting for these technologies - uncomplicated and cheap. + + +From pgsql-performance-owner@postgresql.org Tue Aug 16 05:08:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8DB1D52AAE + for ; + Tue, 16 Aug 2005 05:08:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02082-07 + for ; + Tue, 16 Aug 2005 08:08:08 +0000 (GMT) +Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E85D52862 + for ; + Tue, 16 Aug 2005 05:08:07 -0300 (ADT) +Received: from [193.97.247.16] (074-016-066-080.eggenet.de [80.66.16.74]) + by service-web.de (Postfix) with ESMTP id B125020003A; + Tue, 16 Aug 2005 10:08:08 +0200 (CEST) +Message-ID: <43019ED4.7070509@wildenhain.de> +Date: Tue, 16 Aug 2005 10:07:48 +0200 +From: Tino Wildenhain +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050802) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Sebastian Hennebrueder +Cc: postgres performance +Subject: Re: Looking for a large database for testing +References: <430195DC.70104@laliluna.de> +In-Reply-To: <430195DC.70104@laliluna.de> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.058 required=5 tests=[AWL=0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/164 +X-Sequence-Number: 13911 + +Sebastian Hennebrueder schrieb: +> Hello, +> +> I would like to test the performance of my Java/PostgreSQL applications +> especially when making full text searches. +> For this I am looking for a database with 50 to 300 MB having text fields. +> e.g. A table with books with fields holding a comment, table of content +> or example chapters +> or what ever else. +> +> Does anybody have an idea where I can find a database like this or does +> even have something like this? +> +You can download the wikipedia content. Just browse the wikimedia site. +Its some work to change the data to be able to import into postgres, +but at least you have a lot real world data - in many languages. + + + +From pgsql-performance-owner@postgresql.org Tue Aug 16 05:24:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D66052AAE + for ; + Tue, 16 Aug 2005 05:24:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05425-02 + for ; + Tue, 16 Aug 2005 08:23:56 +0000 (GMT) +Received: from dd01.profihoster.net (dd01.profihoster.net [84.233.130.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 73D9F52AAB + for ; + Tue, 16 Aug 2005 05:23:55 -0300 (ADT) +Received: from [192.168.54.114] (Iba10.i.pppool.de [85.73.186.16]) + by dd01.profihoster.net (Postfix) with ESMTP id 7A5822380EF + for ; + Tue, 16 Aug 2005 10:23:52 +0200 (CEST) +Message-ID: <4301A29C.9010003@laliluna.de> +Date: Tue, 16 Aug 2005 10:23:56 +0200 +From: Sebastian Hennebrueder +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Looking for a large database for testing +References: <430195DC.70104@laliluna.de> <43019ED4.7070509@wildenhain.de> +In-Reply-To: <43019ED4.7070509@wildenhain.de> +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/165 +X-Sequence-Number: 13912 + +Tino Wildenhain schrieb: + +> Sebastian Hennebrueder schrieb: +> +>> Hello, +>> +>> I would like to test the performance of my Java/PostgreSQL applications +>> especially when making full text searches. +>> For this I am looking for a database with 50 to 300 MB having text +>> fields. +>> e.g. A table with books with fields holding a comment, table of content +>> or example chapters +>> or what ever else. +>> +>> Does anybody have an idea where I can find a database like this or does +>> even have something like this? +>> +> You can download the wikipedia content. Just browse the wikimedia site. +> Its some work to change the data to be able to import into postgres, +> but at least you have a lot real world data - in many languages. + +I have just found it. Here there is a link +http://download.wikimedia.org/ +They have content in multiple languages and dumps up to 20 GB. + +-- +Best Regards / Viele Gr��e + +Sebastian Hennebrueder + +---- + +http://www.laliluna.de + +Tutorials for JSP, JavaServer Faces, Struts, Hibernate and EJB + +Get support, education and consulting for these technologies - +uncomplicated and cheap. + +From pgsql-performance-owner@postgresql.org Tue Aug 16 05:25:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 90F3F52AA3 + for ; + Tue, 16 Aug 2005 05:25:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05425-04 + for ; + Tue, 16 Aug 2005 08:25:22 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 67AE552AB6 + for ; + Tue, 16 Aug 2005 05:25:21 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id D4FDF4163D1; Tue, 16 Aug 2005 09:25:16 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id B8D3415EDA; + Tue, 16 Aug 2005 09:24:02 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 18203-07; Tue, 16 Aug 2005 09:24:00 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id C88D115ED9; + Tue, 16 Aug 2005 09:23:59 +0100 (BST) +Message-ID: <4301A29E.30703@archonet.com> +Date: Tue, 16 Aug 2005 09:23:58 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: wisan watcharinporn +Cc: pgsql-performance@postgresql.org +Subject: Re: database encoding with index search problem +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/166 +X-Sequence-Number: 13913 + +wisan watcharinporn wrote: +> problem: +> how can i configure database that can correct in sorting name and using +> index scan in like 'xxxx%' search + +I think you'll want to read the following then have a quick search of +the mailing list archives for "opclass" for some examples. + http://www.postgresql.org/docs/8.0/static/sql-createindex.html + http://www.postgresql.org/docs/8.0/static/indexes-opclass.html + +HTH +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Aug 16 05:39:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F39E52A36 + for ; + Tue, 16 Aug 2005 05:39:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08564-03 + for ; + Tue, 16 Aug 2005 08:39:26 +0000 (GMT) +Received: from heisenberg.zen.co.uk (heisenberg.zen.co.uk [212.23.3.141]) + by svr1.postgresql.org (Postfix) with ESMTP id 4476752A2F + for ; + Tue, 16 Aug 2005 05:39:25 -0300 (ADT) +Received: from [62.3.112.246] (helo=gweek.purplebat.com) + by heisenberg.zen.co.uk with esmtp (Exim 4.30) + id 1E4wyj-0003fP-JW; Tue, 16 Aug 2005 08:39:25 +0000 +Received: from mrae by gweek.purplebat.com with local (Exim 4.50) + id 1E4wyU-0008C9-Vd; Tue, 16 Aug 2005 09:39:10 +0100 +Date: Tue, 16 Aug 2005 09:39:10 +0100 +To: Sebastian Hennebrueder +Cc: postgres performance +Subject: Re: Looking for a large database for testing +Message-ID: <20050816083910.GA31460@purplebat.com> +References: <430195DC.70104@laliluna.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <430195DC.70104@laliluna.de> +User-Agent: Mutt/1.5.9i +From: Mark Rae +X-Originating-Heisenberg-IP: [62.3.112.246] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.033 required=5 tests=[AWL=-0.017, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/167 +X-Sequence-Number: 13914 + +On Tue, Aug 16, 2005 at 09:29:32AM +0200, Sebastian Hennebrueder wrote: +> I would like to test the performance of my Java/PostgreSQL applications +> especially when making full text searches. +> For this I am looking for a database with 50 to 300 MB having text fields. +> e.g. A table with books with fields holding a comment, table of content +> or example chapters +> or what ever else. + +You could try the OMIM database, which is currently 100M +It contains both journal references and large sections of +'plain' text. It also contains a large amount of technical +terms which will really test any kind of soundex matching +if you are using that. + +http://www.ncbi.nlm.nih.gov/Omim/omimfaq.html#download + +Unfortunately it only comes as a flat text file, but is +very easy to parse. + +And if you start reading it, you'll probably learn quite +a lot of things you really didn't want to know!! :-D + + -Mark + +From pgsql-performance-owner@postgresql.org Tue Aug 16 06:38:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BC1D65297B + for ; + Tue, 16 Aug 2005 06:38:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22542-06 + for ; + Tue, 16 Aug 2005 09:38:52 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E88252983 + for ; + Tue, 16 Aug 2005 06:38:42 -0300 (ADT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.13.4/8.13.4) with ESMTP id j7G9cf3d018056; + Tue, 16 Aug 2005 13:38:41 +0400 (MSD) +Date: Tue, 16 Aug 2005 13:38:41 +0400 (MSD) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Sebastian Hennebrueder +Cc: postgres performance +Subject: Re: Looking for a large database for testing +In-Reply-To: <430195DC.70104@laliluna.de> +Message-ID: +References: <430195DC.70104@laliluna.de> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.326 required=5 tests=[AWL=-0.048, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/168 +X-Sequence-Number: 13915 + +Sebastian, + +you can try document generator. I used +http://www.cs.rmit.edu.au/~jz/resources/finnegan.zip +yuo can play with freq. of words and document length distribution. +Also, I have SentenceGenerator.java which could be used for +generation of synthetic texts. + + Oleg +On Tue, 16 Aug 2005, Sebastian Hennebrueder wrote: + +> Hello, +> +> I would like to test the performance of my Java/PostgreSQL applications +> especially when making full text searches. +> For this I am looking for a database with 50 to 300 MB having text fields. +> e.g. A table with books with fields holding a comment, table of content +> or example chapters +> or what ever else. +> +> Does anybody have an idea where I can find a database like this or does +> even have something like this? +> +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Tue Aug 16 12:37:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4481552903 + for ; + Tue, 16 Aug 2005 12:37:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13965-07 + for ; + Tue, 16 Aug 2005 15:37:10 +0000 (GMT) +Received: from thor.netera.se (thor.netera.se [85.112.172.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 943F8528F0 + for ; + Tue, 16 Aug 2005 12:37:08 -0300 (ADT) +Received: from [192.168.2.240] (1-1-1-41a.o.sth.bostream.se [81.26.246.14]) + by thor.netera.se (Postfix) with ESMTP id A664713AC078 + for ; + Tue, 16 Aug 2005 17:37:07 +0200 (CEST) +Message-ID: <430208AE.7080100@relevanttraffic.se> +Date: Tue, 16 Aug 2005 17:39:26 +0200 +From: Ulrich Wisser +Organization: Relevant Traffic AB +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Need for speed +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/169 +X-Sequence-Number: 13916 + +Hello, + +one of our services is click counting for on line advertising. We do +this by importing Apache log files every five minutes. This results in a +lot of insert and delete statements. At the same time our customers +shall be able to do on line reporting. + +We have a box with +Linux Fedora Core 3, Postgres 7.4.2 +Intel(R) Pentium(R) 4 CPU 2.40GHz +2 scsi 76GB disks (15.000RPM, 2ms) + +I did put pg_xlog on another file system on other discs. + +Still when several users are on line the reporting gets very slow. +Queries can take more then 2 min. + +I need some ideas how to improve performance in some orders of +magnitude. I already thought of a box with the whole database on a ram +disc. So really any idea is welcome. + +Ulrich + + + +-- +Ulrich Wisser / System Developer + +RELEVANT TRAFFIC SWEDEN AB, Riddarg 17A, SE-114 57 Sthlm, Sweden +Direct (+46)86789755 || Cell (+46)704467893 || Fax (+46)86789769 +________________________________________________________________ +http://www.relevanttraffic.com + +From pgsql-performance-owner@postgresql.org Tue Aug 16 12:59:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AFE7C52800; + Tue, 16 Aug 2005 12:59:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19138-05; Tue, 16 Aug 2005 15:59:21 +0000 (GMT) +Received: from notes.beauchamp.loxane.fr (unknown [217.167.112.209]) + by svr1.postgresql.org (Postfix) with ESMTP id 551C352A07; + Tue, 16 Aug 2005 12:59:17 -0300 (ADT) +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org, + pgsql-performance-owner@postgresql.org +Subject: Re. : Need for speed +MIME-Version: 1.0 +X-Mailer: Lotus Notes Release 5.0.10 March 22, 2002 +Message-ID: + +From: bsimon@loxane.com +Date: Tue, 16 Aug 2005 18:02:53 +0200 +X-MIMETrack: Serialize by Router on notes/Loxane(Release 5.0.10 |March 22, + 2002) at 16/08/2005 18:02:58, + Serialize complete at 16/08/2005 18:02:58 +Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.21 required=5 tests=[AWL=0.032, NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/170 +X-Sequence-Number: 13917 + +Hi, + +How much Ram do you have ? +Could you give us your postgresql.conf ? (shared buffer parameter) + +If you do lots of deletes/inserts operations you HAVE to vacuum analyze=20 +your table (especially if you have indexes).=20 + +I'm not sure if vacuuming locks your table with pg 7.4.2 (it doesn't with=20 +8.0), you might consider upgrading your pg version.=20 +Anyway, your "SELECT" performance while vacuuming is going to be altered. = + + + +I don't know your application but I would certainly try to split your=20 +table. it would result in one table for inserts/vaccum and one for=20 +selects. You would have to switch from one to the other every five=20 +minutes. + +Benjamin. + + + + + +Ulrich Wisser +Envoy=E9 par : pgsql-performance-owner@postgresql.org +16/08/2005 17:39 + +=20 + Pour : pgsql-performance@postgresql.org + cc :=20 + Objet : [PERFORM] Need for speed + + +Hello, + +one of our services is click counting for on line advertising. We do=20 +this by importing Apache log files every five minutes. This results in a=20 +lot of insert and delete statements. At the same time our customers=20 +shall be able to do on line reporting. + +We have a box with +Linux Fedora Core 3, Postgres 7.4.2 +Intel(R) Pentium(R) 4 CPU 2.40GHz +2 scsi 76GB disks (15.000RPM, 2ms) + +I did put pg=5Fxlog on another file system on other discs. + +Still when several users are on line the reporting gets very slow.=20 +Queries can take more then 2 min. + +I need some ideas how to improve performance in some orders of=20 +magnitude. I already thought of a box with the whole database on a ram=20 +disc. So really any idea is welcome. + +Ulrich + + + +--=20 +Ulrich Wisser / System Developer + +RELEVANT TRAFFIC SWEDEN AB, Riddarg 17A, SE-114 57 Sthlm, Sweden +Direct (+46)86789755 || Cell (+46)704467893 || Fax (+46)86789769 +=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= +=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= +=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F +http://www.relevanttraffic.com + +---------------------------(end of broadcast)--------------------------- +TIP 1: if posting/reading through Usenet, please send an appropriate + subscribe-nomail command to majordomo@postgresql.org so that your + message can get through to the mailing list cleanly + + + + +From pgsql-performance-owner@postgresql.org Tue Aug 16 13:05:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 405E552A02 + for ; + Tue, 16 Aug 2005 13:05:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21148-06 + for ; + Tue, 16 Aug 2005 16:05:33 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id F30C952800 + for ; + Tue, 16 Aug 2005 13:05:32 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id B0C10417CD6; Tue, 16 Aug 2005 17:05:18 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id AA63715EDB; + Tue, 16 Aug 2005 17:03:58 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 04938-01; Tue, 16 Aug 2005 17:03:56 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 0EC0D15ED9; + Tue, 16 Aug 2005 17:03:56 +0100 (BST) +Message-ID: <43020E6B.9080607@archonet.com> +Date: Tue, 16 Aug 2005 17:03:55 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org +Subject: Re: Need for speed +References: <430208AE.7080100@relevanttraffic.se> +In-Reply-To: <430208AE.7080100@relevanttraffic.se> +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/171 +X-Sequence-Number: 13918 + +Ulrich Wisser wrote: +> Hello, +> +> one of our services is click counting for on line advertising. We do +> this by importing Apache log files every five minutes. This results in a +> lot of insert and delete statements. At the same time our customers +> shall be able to do on line reporting. + +> I need some ideas how to improve performance in some orders of +> magnitude. I already thought of a box with the whole database on a ram +> disc. So really any idea is welcome. + +So what's the problem - poor query plans? CPU saturated? I/O saturated? +Too much context-switching? + +What makes it worse - adding another reporting user, or importing +another logfile? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Aug 16 13:13:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1478C52A17 + for ; + Tue, 16 Aug 2005 13:12:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25765-02 + for ; + Tue, 16 Aug 2005 16:12:46 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 7482552A0E + for ; + Tue, 16 Aug 2005 13:12:45 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050816161244m92009jgjhe>; Tue, 16 Aug 2005 16:12:45 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 17E8355FBA; Tue, 16 Aug 2005 11:12:44 -0500 (CDT) +Received: from [192.168.1.119] (71-32-69-23.cdrr.qwest.net [71.32.69.23]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 5612255FAD; + Tue, 16 Aug 2005 11:12:29 -0500 (CDT) +Message-ID: <43021068.7080301@arbash-meinel.com> +Date: Tue, 16 Aug 2005 11:12:24 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org +Subject: Re: Need for speed +References: <430208AE.7080100@relevanttraffic.se> +In-Reply-To: <430208AE.7080100@relevanttraffic.se> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig6CD64640031BC136768E861A" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/173 +X-Sequence-Number: 13920 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig6CD64640031BC136768E861A +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Ulrich Wisser wrote: +> Hello, +> +> one of our services is click counting for on line advertising. We do +> this by importing Apache log files every five minutes. This results in a +> lot of insert and delete statements. At the same time our customers +> shall be able to do on line reporting. + +What are you deleting? I can see having a lot of updates and inserts, +but I'm trying to figure out what the deletes would be. + +Is it just that you completely refill the table based on the apache log, +rather than doing only appending? +Or are you deleting old rows? + +> +> We have a box with +> Linux Fedora Core 3, Postgres 7.4.2 +> Intel(R) Pentium(R) 4 CPU 2.40GHz +> 2 scsi 76GB disks (15.000RPM, 2ms) +> +> I did put pg_xlog on another file system on other discs. +> +> Still when several users are on line the reporting gets very slow. +> Queries can take more then 2 min. + +If it only gets slow when you have multiple clients it sounds like your +select speed is the issue, more than conflicting with your insert/deletes. + +> +> I need some ideas how to improve performance in some orders of +> magnitude. I already thought of a box with the whole database on a ram +> disc. So really any idea is welcome. + +How much ram do you have in the system? It sounds like you only have 1 +CPU, so there is a lot you can do to make the box scale. + +A dual Opteron (possibly a dual motherboard with dual core (but only +fill one for now)), with 16GB of ram, and an 8-drive RAID10 system would +perform quite a bit faster. + +How big is your database on disk? Obviously it isn't very large if you +are thinking to hold everything in RAM (and only have 76GB of disk +storage to put it in anyway). + +If your machine only has 512M, an easy solution would be to put in a +bunch more memory. + +In general, your hardware is pretty low in overall specs. So if you are +willing to throw money at the problem, there is a lot you can do. + +Alternatively, turn on statement logging, and then post the queries that +are slow. This mailing list is pretty good at fixing poor queries. + +One thing you are probably hitting is a lot of sequential scans on the +main table. + +If you are doing mostly inserting, make sure you are in a transaction, +and think about doing a COPY. + +There is a lot more that can be said, we just need to have more +information about what you want. + +John +=:-> + +> +> Ulrich +> +> +> + + +--------------enig6CD64640031BC136768E861A +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDAhBqJdeBCYSNAAMRAo/0AJ9Y8kXiQfm6BYbWa8enp7/7aqSCAwCeJ0p0 +PE1EpGW1XZMH+C7p5+nFTpg= +=9tf0 +-----END PGP SIGNATURE----- + +--------------enig6CD64640031BC136768E861A-- + +From pgsql-performance-owner@postgresql.org Tue Aug 16 13:11:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB02D52A0F + for ; + Tue, 16 Aug 2005 13:11:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21537-09 + for ; + Tue, 16 Aug 2005 16:11:31 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id A9A7552A72 + for ; + Tue, 16 Aug 2005 13:11:30 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7733922; Tue, 16 Aug 2005 09:13:47 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: [SPAM?] Re: PG8 Tuning +Date: Tue, 16 Aug 2005 09:12:31 -0700 +User-Agent: KMail/1.8 +Cc: "Jeffrey W. Baker" , Steve Poe , + paul@oxton.com +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> + <1123779524.6664.1.camel@toonses.gghcwest.com> +In-Reply-To: <1123779524.6664.1.camel@toonses.gghcwest.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200508160912.32263.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] +X-Spam-Level: +X-Archive-Number: 200508/172 +X-Sequence-Number: 13919 + +Jeff, + +> > 4) pg_xlog: If you're pg_xlog is on a spindle is *only* for pg_xlog +> > you're better off. +> +> Like Mr. Stone said earlier, this is pure dogma. =C2=A0In my experience, +> xlogs on the same volume with data is much faster if both are on +> battery-backed write-back RAID controller memory. =C2=A0Moving from this +> situation to xlogs on a single normal disk is going to be much slower in +> most cases. + +The advice on separate drives for xlog (as is all advice on that web page) = +is=20 +based on numerous, repeatable tests at OSDL. =20 + +However, you are absolutely correct in that it's *relative* advice, not=20 +absolute advice. If, for example, you're using a $100,000 EMC SAN as your= +=20 +storage you'll probably be better off giving it everything and letting its= +=20 +controller and cache handle disk allocation etc. On the other hand, if=20 +you're dealing with the 5 drives in a single Dell 6650, I've yet to encount= +er=20 +a case where a separate xlog disk did not benefit an OLTP application. + +=46or Solaris, the advantage of using a separate disk or partition is that = +the=20 +mount options you want for the xlog (including forcedirectio) are=20 +considerably different from what you'd use with the main database. + +=2D-=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 16 13:25:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B0E752888 + for ; + Tue, 16 Aug 2005 13:25:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27354-07 + for ; + Tue, 16 Aug 2005 16:24:59 +0000 (GMT) +Received: from alvh.no-ip.org (200-85-218-206.bk4-dsl.surnet.cl + [200.85.218.206]) + by svr1.postgresql.org (Postfix) with ESMTP id B03C05288E + for ; + Tue, 16 Aug 2005 13:24:56 -0300 (ADT) +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 310C4C2DC09; Tue, 16 Aug 2005 12:25:31 -0400 (CLT) +Date: Tue, 16 Aug 2005 12:25:31 -0400 +From: Alvaro Herrera +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, + "Jeffrey W. Baker" , Steve Poe , + paul@oxton.com +Subject: Re: [SPAM?] Re: PG8 Tuning +Message-ID: <20050816162531.GB32695@alvh.no-ip.org> +Mail-Followup-To: Josh Berkus , + pgsql-performance@postgresql.org, + "Jeffrey W. Baker" , Steve Poe , + paul@oxton.com +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> + <1123779524.6664.1.camel@toonses.gghcwest.com> + <200508160912.32263.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200508160912.32263.josh@agliodbs.com> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.725 required=5 tests=[AWL=0.301, + DNS_FROM_RFC_ABUSE=0.374, FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/174 +X-Sequence-Number: 13921 + +On Tue, Aug 16, 2005 at 09:12:31AM -0700, Josh Berkus wrote: + +> However, you are absolutely correct in that it's *relative* advice, not +> absolute advice. If, for example, you're using a $100,000 EMC SAN as your +> storage you'll probably be better off giving it everything and letting its +> controller and cache handle disk allocation etc. On the other hand, if +> you're dealing with the 5 drives in a single Dell 6650, I've yet to encounter +> a case where a separate xlog disk did not benefit an OLTP application. + +I've been asked this a couple of times and I don't know the answer: what +happens if you give XLog a single drive (unmirrored single spindle), and +that drive dies? So the question really is, should you be giving two +disks to XLog? + +-- +Alvaro Herrera () +"[PostgreSQL] is a great group; in my opinion it is THE best open source +development communities in existence anywhere." (Lamar Owen) + +From pgsql-performance-owner@postgresql.org Tue Aug 16 13:30:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 506305288A + for ; + Tue, 16 Aug 2005 13:29:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28351-09 + for ; + Tue, 16 Aug 2005 16:29:23 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 4126952888 + for ; + Tue, 16 Aug 2005 13:29:23 -0300 (ADT) +Received: from [192.168.1.55] (fc1smp [66.93.38.87]) (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + j7GGRd4c024499; Tue, 16 Aug 2005 09:27:39 -0700 +Message-ID: <430214F3.7010503@commandprompt.com> +Date: Tue, 16 Aug 2005 09:31:47 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 1.0.6-1.1.fc4 (X11/20050720) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alvaro Herrera +Cc: Josh Berkus , pgsql-performance@postgresql.org, + "Jeffrey W. Baker" , Steve Poe , + paul@oxton.com +Subject: Re: [SPAM?] Re: PG8 Tuning +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> + <1123779524.6664.1.camel@toonses.gghcwest.com> + <200508160912.32263.josh@agliodbs.com> + <20050816162531.GB32695@alvh.no-ip.org> +In-Reply-To: <20050816162531.GB32695@alvh.no-ip.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); + Tue, 16 Aug 2005 09:27:39 -0700 (PDT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 required=5 tests=[AWL=0.013] +X-Spam-Level: +X-Archive-Number: 200508/175 +X-Sequence-Number: 13922 + + +> I've been asked this a couple of times and I don't know the answer: what +> happens if you give XLog a single drive (unmirrored single spindle), and +> that drive dies? So the question really is, should you be giving two +> disks to XLog? + +If that drive dies your restoring from backup. You would need to run at +least RAID 1, preferrably RAID 10. + +Sincerely, + +Joshua D. Drkae + + +> + + +-- +Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 +PostgreSQL Replication, Consulting, Custom Programming, 24x7 support +Managed Services, Shared and Dedicated Hosting +Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ + +From pgsql-performance-owner@postgresql.org Tue Aug 16 13:46:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2725C52991 + for ; + Tue, 16 Aug 2005 13:34:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32349-01 + for ; + Tue, 16 Aug 2005 16:34:03 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id A971A52967 + for ; + Tue, 16 Aug 2005 13:33:58 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050816163352m92009jfg4e>; Tue, 16 Aug 2005 16:33:58 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 7525D55FBA; Tue, 16 Aug 2005 11:33:52 -0500 (CDT) +Received: from [192.168.1.119] (71-32-69-23.cdrr.qwest.net [71.32.69.23]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 8373A55FAD; + Tue, 16 Aug 2005 11:33:46 -0500 (CDT) +Message-ID: <43021567.1000101@arbash-meinel.com> +Date: Tue, 16 Aug 2005 11:33:43 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alvaro Herrera +Cc: Josh Berkus , pgsql-performance@postgresql.org, + "Jeffrey W. Baker" , Steve Poe , + paul@oxton.com +Subject: Re: PG8 Tuning +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> + <1123779524.6664.1.camel@toonses.gghcwest.com> + <200508160912.32263.josh@agliodbs.com> + <20050816162531.GB32695@alvh.no-ip.org> +In-Reply-To: <20050816162531.GB32695@alvh.no-ip.org> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigB40C2E18404ED09A81E307A1" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.038 required=5 tests=[AWL=-0.013, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/177 +X-Sequence-Number: 13924 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigB40C2E18404ED09A81E307A1 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Alvaro Herrera wrote: +> On Tue, Aug 16, 2005 at 09:12:31AM -0700, Josh Berkus wrote: +> +> +>>However, you are absolutely correct in that it's *relative* advice, not +>>absolute advice. If, for example, you're using a $100,000 EMC SAN as your +>>storage you'll probably be better off giving it everything and letting its +>>controller and cache handle disk allocation etc. On the other hand, if +>>you're dealing with the 5 drives in a single Dell 6650, I've yet to encounter +>>a case where a separate xlog disk did not benefit an OLTP application. +> +> +> I've been asked this a couple of times and I don't know the answer: what +> happens if you give XLog a single drive (unmirrored single spindle), and +> that drive dies? So the question really is, should you be giving two +> disks to XLog? +> + +I can propose a simple test. Create a test database. Run postgres, +insert a bunch of stuff. Stop postgres. Delete everything in the pg_xlog +directory. Start postgres again, what does it do? + +I suppose to simulate more of a failure mode, you could kill -9 the +postmaster (and all children processes) perhaps during an insert, and +then delete pg_xlog. + +But I would like to hear from the postgres folks what they *expect* +would happen if you ever lost pg_xlog. + +What about something like keeping pg_xlog on a ramdisk, and then +rsyncing it to a hard-disk every 5 minutes. If you die in the middle, +does it just restore back to the 5-minutes ago point, or does it get +more thoroughly messed up? +For some people, a 5-minute old restore would be okay, as long as you +still have transaction safety, so that you can figure out what needs to +be restored. + +John +=:-> + + +--------------enigB40C2E18404ED09A81E307A1 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDAhVnJdeBCYSNAAMRAsGuAKC2vFtT4mOyAH5nKLN4kggMF7hUeQCgyYRa +yN/jfacttQyc3tNPvQTK15o= +=XI9u +-----END PGP SIGNATURE----- + +--------------enigB40C2E18404ED09A81E307A1-- + +From pgsql-performance-owner@postgresql.org Tue Aug 16 13:46:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 65C0252BA7 + for ; + Tue, 16 Aug 2005 13:43:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34733-03 + for ; + Tue, 16 Aug 2005 16:43:06 +0000 (GMT) +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B41152B75 + for ; + Tue, 16 Aug 2005 13:43:04 -0300 (ADT) +Received: from toonses.gghcwest.com (toonses.gghcwest.com [192.168.168.115]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id j7GGh0md027531; + Tue, 16 Aug 2005 09:43:02 -0700 +Received: from jwb by toonses.gghcwest.com with local (Exim 4.50) + id 1E54Wj-00049f-TV; Tue, 16 Aug 2005 09:43:01 -0700 +Subject: Re: Need for speed +From: "Jeffrey W. Baker" +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org +In-Reply-To: <430208AE.7080100@relevanttraffic.se> +References: <430208AE.7080100@relevanttraffic.se> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Tue, 16 Aug 2005 09:43:01 -0700 +Message-Id: <1124210581.15880.10.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.3.6.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=-1.019 required=5 tests=[AWL=-1.069, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/176 +X-Sequence-Number: 13923 + +On Tue, 2005-08-16 at 17:39 +0200, Ulrich Wisser wrote: +> Hello, +> +> one of our services is click counting for on line advertising. We do +> this by importing Apache log files every five minutes. This results in a +> lot of insert and delete statements. At the same time our customers +> shall be able to do on line reporting. +> +> We have a box with +> Linux Fedora Core 3, Postgres 7.4.2 +> Intel(R) Pentium(R) 4 CPU 2.40GHz + +This is not a good CPU for this workload. Try an Opteron or Xeon. Also +of major importance is the amount of memory. If possible, you would +like to have memory larger than the size of your database. + +> 2 scsi 76GB disks (15.000RPM, 2ms) + +If you decide your application is I/O bound, here's an obvious place for +improvement. More disks == faster. + +> I did put pg_xlog on another file system on other discs. + +Did that have a beneficial effect? + +> Still when several users are on line the reporting gets very slow. +> Queries can take more then 2 min. + +Is this all the time or only during the insert? + +> I need some ideas how to improve performance in some orders of +> magnitude. I already thought of a box with the whole database on a ram +> disc. So really any idea is welcome. + +You don't need a RAM disk, just a lot of RAM. Your operating system +will cache disk contents in memory if possible. You have a very small +configuration, so more CPU, more memory, and especially more disks will +probably all yield improvements. + +From pgsql-performance-owner@postgresql.org Fri Aug 19 01:35:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 35F7852C86 + for ; + Tue, 16 Aug 2005 14:01:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42827-07 + for ; + Tue, 16 Aug 2005 17:01:20 +0000 (GMT) +Received: from sj1-exch-01.us.corp.kailea.com (mail.ragingnet.net + [209.249.149.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 013CE52C50 + for ; + Tue, 16 Aug 2005 14:01:14 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: base64 +Subject: Re: Need for speed +Date: Tue, 16 Aug 2005 10:01:14 -0700 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Need for speed +Thread-Index: AcWifb5K1mERc9seQ8KmxIu2FCJWUgABcK1Q +From: "Roger Hand" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/243 +X-Sequence-Number: 13990 + +PiBVbHJpY2ggV2lzc2VyIHdyb3RlOg0KPiA+DQo+ID4gb25lIG9mIG91ciBzZXJ2aWNlcyBpcyBj +bGljayBjb3VudGluZyBmb3Igb24gbGluZSBhZHZlcnRpc2luZy4gV2UgZG8NCj4gPiB0aGlzIGJ5 +IGltcG9ydGluZyBBcGFjaGUgbG9nIGZpbGVzIGV2ZXJ5IGZpdmUgbWludXRlcy4gVGhpcyByZXN1 +bHRzIGluIGENCj4gPiBsb3Qgb2YgaW5zZXJ0IGFuZCBkZWxldGUgc3RhdGVtZW50cy4gDQouLi4N +Cj4gSWYgeW91IGFyZSBkb2luZyBtb3N0bHkgaW5zZXJ0aW5nLCBtYWtlIHN1cmUgeW91IGFyZSBp +biBhIHRyYW5zYWN0aW9uLA0KDQpXZWxsLCB5ZXMsIGJ1dCB5b3UgbWF5IG5lZWQgdG8gbWFrZSBz +dXJlIHRoYXQgYSBzaW5nbGUgdHJhbnNhY3Rpb24gZG9lc24ndCBoYXZlIHRvbyBtYW55IGluc2Vy +dHMgaW4gaXQuDQpJIHdhcyBoYXZpbmcgYSBwZXJmb3JtYW5jZSBwcm9ibGVtIHdoZW4gZG9pbmcg +dHJhbnNhY3Rpb25zIHdpdGggYSBodWdlIG51bWJlciBvZiBpbnNlcnRzDQoodGVucyBvZiB0aG91 +c2FuZHMpLCBhbmQgSSBzb2x2ZWQgdGhlIHByb2JsZW0gYnkgcHV0dGluZyBhIHNpbXBsZSBjb3Vu +dGVyIGluIHRoZSBsb29wIChpbiB0aGUgSmF2YSBpbXBvcnQgY29kZSwgDQp0aGF0IGlzKSBhbmQg +ZG9pbmcgYSBjb21taXQgZXZlcnkgMTAwIG9yIHNvIGluc2VydHMuDQoNCi1Sb2dlcg0KDQo+IEpv +aG4NCj4NCj4gPiBVbHJpY2gNCg== + +From pgsql-performance-owner@postgresql.org Tue Aug 16 14:38:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 05B3552927 + for ; + Tue, 16 Aug 2005 14:38:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48386-10 + for ; + Tue, 16 Aug 2005 17:37:59 +0000 (GMT) +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by svr1.postgresql.org (Postfix) with ESMTP id B1FD65291A + for ; + Tue, 16 Aug 2005 14:37:58 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.53.154]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0ILB00BMGSNB0RD4@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Tue, 16 Aug 2005 12:30:49 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 76F896B811B for + ; + Tue, 16 Aug 2005 13:30:47 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 07205-01-2 for ; Tue, + 16 Aug 2005 13:30:47 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 5955E6B8118; Tue, 16 Aug 2005 13:30:47 -0400 (EDT) +Date: Tue, 16 Aug 2005 13:30:47 -0400 +From: Michael Stone +Subject: Re: [SPAM?] Re: PG8 Tuning +In-reply-to: <200508160912.32263.josh@agliodbs.com> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050816173047.GC19080@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> + <1123779524.6664.1.camel@toonses.gghcwest.com> + <200508160912.32263.josh@agliodbs.com> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/178 +X-Sequence-Number: 13925 + +On Tue, Aug 16, 2005 at 09:12:31AM -0700, Josh Berkus wrote: +>However, you are absolutely correct in that it's *relative* advice, not +>absolute advice. If, for example, you're using a $100,000 EMC SAN as your +>storage you'll probably be better off giving it everything and letting its +>controller and cache handle disk allocation etc. + +Well, you don't have to spend *quite* that much to get a decent storage +array. :) + +>On the other hand, if you're dealing with the 5 drives in a single Dell +>6650, I've yet to encounter a case where a separate xlog disk did not +>benefit an OLTP application. + +IIRC, that's an older raid controller that tops out at 128MB write +cache, and 5 spindles ain't a lot--so it makes sense that it would +benefit from a seperate spindle for xlog. Also note that I said the +write cache advice goes out the window if you have a workload that +involves constant writing (or if your xlog writes come in faster than +your write cache can drain) because at that point you essentially drop +back to raw disk speed; I assume the OLTP apps you mention are fairly +write-intensive. OTOH, in a reasonably safe configuration I suppose +you'd end up with a 3 disk raid5 / 2 disk raid1 or 2 raid 1 pairs on +that dell 6650; is that how you test? Once you're down to that small a +data set I'd expect the system's ram cache to be a much larger +percentage of the working set, which would tend to make the xlog just +about the *only* latency-critical i/o. That's a different creature from +a data mining app that might really benefit from having additional +spindles to accelerate read performance from indices much larger than +RAM. At any rate, this just underscores the need for testing a +particular workload on particular hardware. Things like the disk speed, +raid configuration, write cache size, transaction size, data set size, +working set size, concurrent transactions, read vs write emphasis, etc., +are each going to have a fairly large impact on performance. + +>For Solaris, the advantage of using a separate disk or partition is that the +>mount options you want for the xlog (including forcedirectio) are +>considerably different from what you'd use with the main database. + +Yeah, having a seperate partition is often good even if you do have +everything on the same disks. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Fri Aug 19 01:34:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB2FB5291A + for ; + Tue, 16 Aug 2005 14:46:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52752-07 + for ; + Tue, 16 Aug 2005 17:46:46 +0000 (GMT) +Received: from sj1-exch-01.us.corp.kailea.com (mail.ragingnet.net + [209.249.149.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 18D6652899 + for ; + Tue, 16 Aug 2005 14:46:45 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Query plan looks OK, but slow I/O - settings advice? +Date: Tue, 16 Aug 2005 10:46:46 -0700 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Query plan looks OK, but slow I/O - settings advice? +Thread-Index: AcWiiQlymkx6ErqSQZWErqyzbLeYrg== +From: "Roger Hand" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.054 required=5 tests=[AWL=0.003, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/241 +X-Sequence-Number: 13988 + +Summary +=3D=3D=3D=3D=3D=3D=3D +We are writing to the db pretty much 24 hours a day. +Recently the amount of data we write has increased, and the query speed, = +formerly okay, has taken a dive. +The query is using the indexes as expected, so I don't _think_ I have a = +query tuning issue, just an io problem.=20 +The first time a query is done it takes about 60 seconds. The second = +time it runs in about 6 seconds. +What I know I need advice on is io settings and various buffer settings. = + +I may also need advice on other things, but just don't know it yet! + +Below is ... +- an explain analyze +- details of the db setup and hardware +- some vmstat and iostat output showing the disks are very busy +- the SHOW ALL output for the db config. + +Details +=3D=3D=3D=3D=3D=3D=3D +Postgres 8.0.3 + +Below is a sample query. (This is actually implemented as a prepared = +statement. Here I fill in the '?'s with actual values.) + +electric=3D# EXPLAIN ANALYZE +electric-# SELECT datavalue, logfielddatatype, timestamp FROM = +logdata_recent=20 +electric-# WHERE (logfielddatatype =3D 70 OR logfielddatatype =3D 71 OR = +logfielddatatype =3D 69)=20 +electric-# AND graphtargetlog =3D 1327=20 +electric-# AND timestamp >=3D 1123052400 AND timestamp <=3D 1123138800=20 +electric-# ORDER BY timestamp; + = + = + QUERY PLAN = + = + = + =20 +-------------------------------------------------- + Sort (cost=3D82.48..82.50 rows=3D6 width=3D14) (actual = +time=3D60208.968..60211.232 rows=3D2625 loops=3D1) + Sort Key: public.logdata_recent."timestamp" + -> Result (cost=3D0.00..82.41 rows=3D6 width=3D14) (actual = +time=3D52.483..60200.868 rows=3D2625 loops=3D1) + -> Append (cost=3D0.00..82.41 rows=3D6 width=3D14) (actual = +time=3D52.476..60189.929 rows=3D2625 loops=3D1) + -> Seq Scan on logdata_recent (cost=3D0.00..46.25 = +rows=3D1 width=3D14) (actual time=3D0.003..0.003 rows=3D0 loops=3D1) + Filter: (((logfielddatatype =3D 70) OR = +(logfielddatatype =3D 71) OR (logfielddatatype =3D 69)) AND = +(graphtargetlog =3D 1327) AND ("timestamp" >=3D 1123052400) AND = +("timestamp" <=3D 1123138800)) + -> Index Scan using = +logdata_recent_1123085306_ix_t_fld_gtl, = +logdata_recent_1123085306_ix_t_fld_gtl, = +logdata_recent_1123085306_ix_t_fld_gtl on logdata_recent_stale = +logdata_recent (cost=3D0.00..18.08 rows=3D3 width=3D14) (actual = +time=3D52.465..60181.624 rows=3D2625 loops=3D1) + Index Cond: ((("timestamp" >=3D 1123052400) AND = +("timestamp" <=3D 1123138800) AND (logfielddatatype =3D 70) AND = +(graphtargetlog =3D 1327)) OR (("timestamp" >=3D 1123052400) AND = +("timestamp" <=3D 1123138800) AND (logfielddatatype =3D 71) AND = +(graphtargetlog =3D 1327)) OR (("timestamp" >=3D 1123052400) AND = +("timestamp" <=3D 1123138800) AND (logfielddatatype =3D 69) AND = +(graphtargetlog =3D 1327))) + Filter: (((logfielddatatype =3D 70) OR = +(logfielddatatype =3D 71) OR (logfielddatatype =3D 69)) AND = +(graphtargetlog =3D 1327) AND ("timestamp" >=3D 1123052400) AND = +("timestamp" <=3D 1123138800)) + -> Index Scan using = +logdata_recent_1123139634_ix_t_fld_gtl, = +logdata_recent_1123139634_ix_t_fld_gtl, = +logdata_recent_1123139634_ix_t_fld_gtl on logdata_recent_active = +logdata_recent (cost=3D0.00..18.08 rows=3D2 width=3D14) (actual = +time=3D0.178..0.178 rows=3D0 loops=3D1) + Index Cond: ((("timestamp" >=3D 1123052400) AND = +("timestamp" <=3D 1123138800) AND (logfielddatatype =3D 70) AND = +(graphtargetlog =3D 1327)) OR (("timestamp" >=3D 1123052400) AND = +("timestamp" <=3D 1123138800) AND (logfielddatatype =3D 71) AND = +(graphtargetlog =3D 1327)) OR (("timestamp" >=3D 1123052400) AND = +("timestamp" <=3D 1123138800) AND (logfielddatatype =3D 69) AND = +(graphtargetlog =3D 1327))) + Filter: (((logfielddatatype =3D 70) OR = +(logfielddatatype =3D 71) OR (logfielddatatype =3D 69)) AND = +(graphtargetlog =3D 1327) AND ("timestamp" >=3D 1123052400) AND = +("timestamp" <=3D 1123138800)) + Total runtime: 60214.545 ms +(13 rows) + +60 seconds is much longer than it used to be. I would guess it used to = +be under 10 seconds. The second time the above query is run we see the = +magic of caching as the time goes down to 6 seconds. + +logdata_recent_active and logdata_recent_stale are inherited tables of = +logdata_recent, which never has any data. (This is pseudo-partitioning = +in action!) +So the very quick seq_scan on the empty logdata_recent parent table is = +okay with me. + +The index is built on timestamp, logfielddatatype, graphtargetlog. I am = +curious as to why the same index shows up 3 times in the "using" clause, = +but can live without knowing the details as long as it doesn't indicate = +that something's wrong. + +The logdata_recent_stale table has 5 millions rows. The size of the = +table itself, on disk, is 324MB. The size of the index is 210MB. + +The disks are ext3 with journalling type of ordered, but this was later = +changed to writeback with no apparent change in speed. + +They're on a Dell poweredge 6650 with LSI raid card, setup as follows: +4 disks raid 10 for indexes (145GB) - sdc1 +6 disks raid 10 for data (220GB) - sdd1 +2 mirrored disks for logs - sdb1 + +stripe size is 32k +cache policy: cached io (am told the controller has bbu) +write policy: write-back +read policy: readahead + +The partition names do what they say ... +[root@rage-db2 /dbdata01]$ df +Filesystem 1K-blocks Used Available Use% Mounted on +/dev/sdb1 70430588 729324 66123592 2% /dblog01 +/dev/sdc1 140861236 19472588 114233300 15% /dbindex01 +/dev/sdd1 211299960 157159988 43406548 79% /dbdata01 +... + +Using iostat (the version from http://linux.inet.hr/) I saw at one point = +that the data disk was 100% busy. +I believe this was when running the above query, or similar, but in any = +case the system is always busy with both reads and (usually) writes. + +device mgr/s mgw/s r/s w/s kr/s kw/s size queue wait = +svc_t %b=20 +sdb1 0 61 0.1 15.5 0.4 305.7 19.6 0.1 5.8 = +4.9 8=20 +sdc1 21 22 20.6 17.7 164.6 158.6 8.4 1.1 28.3 = +6.2 24=20 +sdd1 1742 11 1904.7 6.6 14585.6 71.5 7.7 20.6 10.8 = +0.5 100=20 + +Another time, when I was running the query above, the index partition = +went to 90+% busy for 40 seconds: + +device mgr/s mgw/s r/s w/s kr/s kw/s size queue wait = +svc_t %b=20 +sdb1 0 0 0.0 0.2 0.0 0.8 4.0 0.0 20.0 = +15.0 0=20 +sdc1 366 53 687.0 66.1 4213.1 483.0 6.2 11.8 15.7 = +1.3 96=20 +sdd1 8 17 16.6 13.9 99.5 125.4 7.4 0.7 23.0 = +1.9 6=20 + +On another occasion (when the query took 24 seconds) I ran vmstat and = +iostat every 5 seconds +from just before the query until just after. About the first two outputs = +are before the query. +In this case the index disk is maxed. + +[root@rage-db2 ~]$ vmstat 5 16 +procs memory swap io system = + cpu + r b swpd free buff cache si so bi bo in cs us sy = +wa id + 0 0 92 1233500 225692 9578564 0 0 0 0 1 1 2 = +2 1 1 + 0 1 92 1218460 225748 9595136 0 0 3322 18 655 898 0 = +0 20 79 + 0 1 92 1202124 225780 9616140 0 0 4204 58 920 1291 0 = +1 24 76 + 0 1 92 1172876 225820 9645348 0 0 5847 120 1053 1482 0 = +1 23 76 + 1 0 92 1151712 225836 9666504 0 0 4234 7 847 1239 2 = +1 18 78 + 1 0 92 1140860 225844 9677436 0 0 2153 500 575 2027 13 = +2 11 73 + 1 0 92 1140852 225848 9677636 0 0 0 506 213 442 10 = +1 0 89 + +[root@rage-db2 ~]$ /usr/local/bin/iostat -Px 5 16 + +device mgr/s mgw/s r/s w/s kr/s kw/s size queue wait = +svc_t %b=20 +sdb1 1 243 0.1 105.5 2.7 37.6 0.4 0.0 0.2 = +0.1 1=20 +sdc1 6 111 3.7 75.9 38.3 769.3 10.1 0.0 0.3 = +0.2 1=20 +sdd1 255 107 85.2 37.6 4.9 581.0 4.8 0.0 0.1 = +0.0 1=20 + +device mgr/s mgw/s r/s w/s kr/s kw/s size queue wait = +svc_t %b=20 +sdb1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 = +0.0 0=20 +sdc1 273 0 414.0 0.4 2747.7 2.4 6.6 1.6 3.9 = +1.7 69=20 +sdd1 0 1 1.4 0.4 7.2 5.6 7.1 0.0 10.0 = +6.7 1=20 + +device mgr/s mgw/s r/s w/s kr/s kw/s size queue wait = +svc_t %b=20 +sdb1 0 0 0.0 0.4 0.0 1.6 4.0 0.0 10.0 = +5.0 0=20 +sdc1 225 4 777.1 4.6 4011.0 35.1 5.2 2.5 3.2 = +1.3 99=20 +sdd1 0 2 0.0 2.6 0.0 16.8 6.5 0.0 8.5 = +0.8 0=20 + +device mgr/s mgw/s r/s w/s kr/s kw/s size queue wait = +svc_t %b=20 +sdb1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 = +0.0 0=20 +sdc1 508 7 917.8 7.4 5703.0 58.3 6.2 2.2 2.4 = +1.1 98=20 +sdd1 0 4 0.0 6.8 0.0 44.7 6.6 0.1 15.6 = +0.6 0=20 + +device mgr/s mgw/s r/s w/s kr/s kw/s size queue wait = +svc_t %b=20 +sdb1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 = +0.0 0=20 +sdc1 361 0 737.5 0.4 4391.7 2.4 6.0 1.8 2.4 = +1.0 76=20 +sdd1 0 0 0.0 0.4 0.0 2.4 6.0 0.0 0.0 = +0.0 0=20 + +device mgr/s mgw/s r/s w/s kr/s kw/s size queue wait = +svc_t %b=20 +sdb1 0 87 0.0 17.8 0.0 418.3 23.6 0.0 1.3 = +1.2 2=20 +sdc1 216 2 489.5 0.4 2821.7 11.2 5.8 1.2 2.4 = +1.1 56=20 +sdd1 2 4 7.2 0.6 37.5 18.4 7.2 0.0 6.2 = +3.3 3=20 + +device mgr/s mgw/s r/s w/s kr/s kw/s size queue wait = +svc_t %b=20 +sdb1 0 89 0.0 22.4 0.0 446.3 20.0 0.0 1.1 = +0.8 2=20 +sdc1 0 4 0.0 1.0 0.0 18.4 18.4 0.0 0.0 = +0.0 0=20 +sdd1 0 6 0.0 1.0 0.0 27.1 27.2 0.0 0.0 = +0.0 0=20 + +device mgr/s mgw/s r/s w/s kr/s kw/s size queue wait = +svc_t %b=20 +sdb1 0 89 0.0 22.5 0.0 446.2 19.8 0.0 0.4 = +0.3 1=20 +sdc1 0 2 0.0 0.4 0.0 9.6 24.0 0.0 0.0 = +0.0 0=20 +sdd1 0 4 0.0 0.6 0.0 20.0 33.3 0.0 0.0 = +0.0 0=20 + + +Finally, here's a show all: + +add_missing_from | on +archive_command | unset +australian_timezones | off +authentication_timeout | 60 +bgwriter_delay | 200 +bgwriter_maxpages | 100 +bgwriter_percent | 1 +block_size | 8192 +check_function_bodies | on +checkpoint_segments | 20 +checkpoint_timeout | 300 +checkpoint_warning | 30 +client_encoding | UNICODE +client_min_messages | notice +commit_delay | 350 +commit_siblings | 5 +config_file | /dbdata01/pgdata/postgresql.conf +cpu_index_tuple_cost | 0.001 +cpu_operator_cost | 0.0025 +cpu_tuple_cost | 0.01 +custom_variable_classes | unset +data_directory | /dbdata01/pgdata +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 +debug_shared_buffers | 0 +default_statistics_target | 50 +default_tablespace | unset +default_transaction_isolation | read committed +default_transaction_read_only | off +default_with_oids | off +dynamic_library_path | $libdir +effective_cache_size | 48000 +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 +external_pid_file | unset +extra_float_digits | 0 +from_collapse_limit | 8 +fsync | on +geqo | on +geqo_effort | 5 +geqo_generations | 0 +geqo_pool_size | 0 +geqo_selection_bias | 2 +geqo_threshold | 12 +hba_file | /dbdata01/pgdata/pg_hba.conf +ident_file | /dbdata01/pgdata/pg_ident.conf +integer_datetimes | off +join_collapse_limit | 8 +krb_server_keyfile | unset +lc_collate | en_US.UTF-8 +lc_ctype | en_US.UTF-8 +lc_messages | en_US.UTF-8 +lc_monetary | en_US.UTF-8 +lc_numeric | en_US.UTF-8 +lc_time | en_US.UTF-8 +listen_addresses | * +log_connections | off +log_destination | stderr +log_directory | /dblog01 +log_disconnections | off +log_duration | off +log_error_verbosity | default +log_executor_stats | off +log_filename | postgresql-%Y-%m-%d_%H%M%S.log +log_hostname | off +log_line_prefix | unset +log_min_duration_statement | -1 +log_min_error_statement | panic +log_min_messages | notice +log_parser_stats | off +log_planner_stats | off +log_rotation_age | 1440 +log_rotation_size | 10240 +log_statement | none +log_statement_stats | off +log_truncate_on_rotation | off +maintenance_work_mem | 262144 +max_connections | 40 +max_files_per_process | 1000 +max_fsm_pages | 100000 +max_fsm_relations | 1000 +max_function_args | 32 +max_identifier_length | 63 +max_index_keys | 32 +max_locks_per_transaction | 64 +max_stack_depth | 2048 +password_encryption | on +port | 5432 +pre_auth_delay | 0 +preload_libraries | unset +random_page_cost | 4 +redirect_stderr | on +regex_flavor | advanced +rendezvous_name | unset +search_path | $user,public +server_encoding | UNICODE +server_version | 8.0.3 +shared_buffers | 10240 +silent_mode | off +sql_inheritance | on +ssl | off +statement_timeout | 0 +stats_block_level | off +stats_command_string | off +stats_reset_on_server_start | on +stats_row_level | on +stats_start_collector | on +superuser_reserved_connections | 2 +syslog_facility | LOCAL0 +syslog_ident | postgres +TimeZone | PST8PDT +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_cost_delay | 180 +vacuum_cost_limit | 200 +vacuum_cost_page_dirty | 20 +vacuum_cost_page_hit | 1 +vacuum_cost_page_miss | 10 +wal_buffers | 8 +wal_sync_method | fdatasync +work_mem | 98304 +zero_damaged_pages | off + +From pgsql-performance-owner@postgresql.org Tue Aug 16 14:59:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A93FF52862 + for ; + Tue, 16 Aug 2005 14:59:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54479-08 + for ; + Tue, 16 Aug 2005 17:59:54 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.200]) + by svr1.postgresql.org (Postfix) with ESMTP id E144E5282E + for ; + Tue, 16 Aug 2005 14:59:53 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i22so1232900wra + for ; + Tue, 16 Aug 2005 10:59:54 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=mHxzDy9dqCkijBt/ujQWiXMjEQeiB3ahk3mVaSeSOrBm1YdVKmlEjlZoVWSQQHJEo2XmdE6Wa4JF//3vwX2i65EFJanqxLmjNPenDT3Mqf2ZgLJf4HLSl0pmmBgPVb0rGkZ7Q7WEV79NYZuHXr+mXv7KJvYjy7Xac3NiDjNVKTs= +Received: by 10.54.144.9 with SMTP id r9mr4401173wrd; + Tue, 16 Aug 2005 10:59:54 -0700 (PDT) +Received: by 10.54.86.15 with HTTP; Tue, 16 Aug 2005 10:59:53 -0700 (PDT) +Message-ID: <33c6269f050816105957ae5d6f@mail.gmail.com> +Date: Tue, 16 Aug 2005 13:59:53 -0400 +From: Alex Turner +To: Ulrich Wisser +Subject: Re: Need for speed +Cc: pgsql-performance@postgresql.org +In-Reply-To: <430208AE.7080100@relevanttraffic.se> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <430208AE.7080100@relevanttraffic.se> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.106 required=5 tests=[AWL=0.082, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/179 +X-Sequence-Number: 13926 + +Are you calculating aggregates, and if so, how are you doing it (I ask +the question from experience of a similar application where I found +that my aggregating PGPLSQL triggers were bogging the system down, and +changed them so scheduled jobs instead). + +Alex Turner +NetEconomist + +On 8/16/05, Ulrich Wisser wrote: +> Hello, +>=20 +> one of our services is click counting for on line advertising. We do +> this by importing Apache log files every five minutes. This results in a +> lot of insert and delete statements. At the same time our customers +> shall be able to do on line reporting. +>=20 +> We have a box with +> Linux Fedora Core 3, Postgres 7.4.2 +> Intel(R) Pentium(R) 4 CPU 2.40GHz +> 2 scsi 76GB disks (15.000RPM, 2ms) +>=20 +> I did put pg_xlog on another file system on other discs. +>=20 +> Still when several users are on line the reporting gets very slow. +> Queries can take more then 2 min. +>=20 +> I need some ideas how to improve performance in some orders of +> magnitude. I already thought of a box with the whole database on a ram +> disc. So really any idea is welcome. +>=20 +> Ulrich +>=20 +>=20 +>=20 +> -- +> Ulrich Wisser / System Developer +>=20 +> RELEVANT TRAFFIC SWEDEN AB, Riddarg 17A, SE-114 57 Sthlm, Sweden +> Direct (+46)86789755 || Cell (+46)704467893 || Fax (+46)86789769 +> ________________________________________________________________ +> http://www.relevanttraffic.com +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + +From pgsql-performance-owner@postgresql.org Tue Aug 16 15:00:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB270528C6 + for ; + Tue, 16 Aug 2005 15:00:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58363-05 + for ; + Tue, 16 Aug 2005 18:00:09 +0000 (GMT) +Received: from mail0.rawbw.com (mail0.rawbw.com [198.144.192.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 941BA528B7 + for ; + Tue, 16 Aug 2005 15:00:08 -0300 (ADT) +Received: (from www@localhost) + by mail0.rawbw.com (8.11.6p2/8.11.6) id j7GI08k76560 + for pgsql-performance@postgresql.org; + Tue, 16 Aug 2005 11:00:08 -0700 (PDT) +Received: from cybs-gw.ic3.com (cybs-gw.ic3.com [66.185.177.10]) + by webmail.rawbw.com (IMP) with HTTP + for ; Tue, 16 Aug 2005 11:00:08 -0700 +Message-ID: <1124215208.430229a8a9cdd@webmail.rawbw.com> +Date: Tue, 16 Aug 2005 11:00:08 -0700 +From: mudfoot@rawbw.com +To: pgsql-performance@postgresql.org +Subject: Re: choosing RAID level for xlogs +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BDF@vt-pe2550-001.VANTAGE.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BDF@vt-pe2550-001.VANTAGE.vantage.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.1 +X-Originating-IP: 66.185.177.10 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/180 +X-Sequence-Number: 13927 + +Quoting Anjan Dave : + +> Hi, +> +> +> +> One simple question. For 125 or more checkpoint segments +> (checkpoint_timeout is 600 seconds, shared_buffers are at 21760 or +> 170MB) on a very busy database, what is more suitable, a separate 6 disk +> RAID5 volume, or a RAID10 volume? Databases will be on separate +> spindles. Disks are 36GB 15KRPM, 2Gb Fiber Channel. Performance is +> paramount, but I don't want to use RAID0. +> + +RAID10 -- no question. xlog activity is overwhelmingly sequential 8KB writes. +In order for RAID5 to perform a write, the host (or controller) needs to perform +extra calculations for parity. This turns into latency. RAID10 does not +perform those extra calculations. + +> +> +> PG7.4.7 on RHAS 4.0 +> +> +> +> I can provide more info if needed. +> +> +> +> Appreciate some recommendations! +> +> +> +> Thanks, +> +> Anjan +> +> +> +> +> --- +> This email message and any included attachments constitute confidential +> and privileged information intended exclusively for the listed +> addressee(s). If you are not the intended recipient, please notify +> Vantage by immediately telephoning 215-579-8390, extension 1158. In +> addition, please reply to this message confirming your receipt of the +> same in error. A copy of your email reply can also be sent to +> support@vantage.com. Please do not disclose, copy, distribute or take +> any action in reliance on the contents of this information. Kindly +> destroy all copies of this message and any attachments. Any other use of +> this email is prohibited. Thank you for your cooperation. For more +> information about Vantage, please visit our website at +> http://www.vantage.com . +> --- +> +> +> +> + + + +From pgsql-performance-owner@postgresql.org Tue Aug 16 15:38:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3618F52971 + for ; + Tue, 16 Aug 2005 15:38:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64908-07 + for ; + Tue, 16 Aug 2005 18:38:03 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.244]) + by svr1.postgresql.org (Postfix) with ESMTP id 86FBF52927 + for ; + Tue, 16 Aug 2005 15:37:57 -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="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: choosing RAID level for xlogs +Date: Tue, 16 Aug 2005 14:37:38 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE0@vt-pe2550-001.VANTAGE.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] choosing RAID level for xlogs +Thread-Index: AcWijK9TdlHgfGpnS/CevndAeVpYfgAAkMAQ +From: "Anjan Dave" +To: , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.033 required=5 tests=[AWL=0.033] +X-Spam-Level: +X-Archive-Number: 200508/181 +X-Sequence-Number: 13928 + +Yes, that's true, though, I am a bit confused because the Clariion array +document I am reading talks about how the write cache can eliminate the +RAID5 Write Penalty for sequential and large IOs...resulting in better +sequential write performance than RAID10. + +anjan + + +-----Original Message----- +From: mudfoot@rawbw.com [mailto:mudfoot@rawbw.com]=20 +Sent: Tuesday, August 16, 2005 2:00 PM +To: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] choosing RAID level for xlogs + +Quoting Anjan Dave : + +> Hi, +>=20 +> =20 +>=20 +> One simple question. For 125 or more checkpoint segments +> (checkpoint_timeout is 600 seconds, shared_buffers are at 21760 or +> 170MB) on a very busy database, what is more suitable, a separate 6 +disk +> RAID5 volume, or a RAID10 volume? Databases will be on separate +> spindles. Disks are 36GB 15KRPM, 2Gb Fiber Channel. Performance is +> paramount, but I don't want to use RAID0. +>=20 + +RAID10 -- no question. xlog activity is overwhelmingly sequential 8KB +writes.=20 +In order for RAID5 to perform a write, the host (or controller) needs to +perform +extra calculations for parity. This turns into latency. RAID10 does +not +perform those extra calculations. + +> =20 +>=20 +> PG7.4.7 on RHAS 4.0 +>=20 +> =20 +>=20 +> I can provide more info if needed. +>=20 +> =20 +>=20 +> Appreciate some recommendations! +>=20 +> =20 +>=20 +> Thanks, +>=20 +> Anjan +>=20 +> =20 +>=20 +> =20 +> --- +> This email message and any included attachments constitute +confidential +> and privileged information intended exclusively for the listed +> addressee(s). If you are not the intended recipient, please notify +> Vantage by immediately telephoning 215-579-8390, extension 1158. In +> addition, please reply to this message confirming your receipt of the +> same in error. A copy of your email reply can also be sent to +> support@vantage.com. Please do not disclose, copy, distribute or take +> any action in reliance on the contents of this information. Kindly +> destroy all copies of this message and any attachments. Any other use +of +> this email is prohibited. Thank you for your cooperation. For more +> information about Vantage, please visit our website at +> http://www.vantage.com . +> --- +>=20 +> =20 +>=20 +>=20 + + + +---------------------------(end of broadcast)--------------------------- +TIP 1: if posting/reading through Usenet, please send an appropriate + subscribe-nomail command to majordomo@postgresql.org so that your + message can get through to the mailing list cleanly + + +From pgsql-performance-owner@postgresql.org Tue Aug 16 15:48:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3A75529C4 + for ; + Tue, 16 Aug 2005 15:48:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66712-09 + for ; + Tue, 16 Aug 2005 18:47:59 +0000 (GMT) +Received: from zigo.dhs.org (ua-83-227-204-174.cust.bredbandsbolaget.se + [83.227.204.174]) + by svr1.postgresql.org (Postfix) with ESMTP id 5EC35529A9 + for ; + Tue, 16 Aug 2005 15:47:56 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 9C9138467; Tue, 16 Aug 2005 20:47:50 +0200 (CEST) +Date: Tue, 16 Aug 2005 20:47:50 +0200 (CEST) +From: Dennis Bjorklund +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org +Subject: Re: Need for speed +In-Reply-To: <430208AE.7080100@relevanttraffic.se> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.325 required=5 tests=[AWL=-0.099, + DNS_FROM_RFC_ABUSE=0.374, FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/182 +X-Sequence-Number: 13929 + +On Tue, 16 Aug 2005, Ulrich Wisser wrote: + +> Still when several users are on line the reporting gets very slow. +> Queries can take more then 2 min. + +Could you show an exampleof such a query and the output of EXPLAIN ANALYZE +on that query (preferably done when the database is slow). + +It's hard to say what is wrong without more information. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Tue Aug 16 16:04:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 67B6A52A14 + for ; + Tue, 16 Aug 2005 16:04:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74942-03 + for ; + Tue, 16 Aug 2005 19:04:19 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 33D5952A01 + for ; + Tue, 16 Aug 2005 16:04:18 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050816190418m9100g6rdhe>; Tue, 16 Aug 2005 19:04:18 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id F361B55FBA; Tue, 16 Aug 2005 14:04:17 -0500 (CDT) +Received: from [192.168.1.119] (71-32-69-23.cdrr.qwest.net [71.32.69.23]) + by juju.arbash-meinel.com (Postfix) with ESMTP id D6AE555FAD; + Tue, 16 Aug 2005 14:04:10 -0500 (CDT) +Message-ID: <430238A5.5000002@arbash-meinel.com> +Date: Tue, 16 Aug 2005 14:04:05 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Anjan Dave +Cc: mudfoot@rawbw.com, pgsql-performance@postgresql.org +Subject: Re: choosing RAID level for xlogs +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE0@vt-pe2550-001.VANTAGE.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE0@vt-pe2550-001.VANTAGE.vantage.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig8FC2F801ED54EF8FE7F18F89" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.038 required=5 tests=[AWL=-0.013, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/183 +X-Sequence-Number: 13930 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig8FC2F801ED54EF8FE7F18F89 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Anjan Dave wrote: +> Yes, that's true, though, I am a bit confused because the Clariion array +> document I am reading talks about how the write cache can eliminate the +> RAID5 Write Penalty for sequential and large IOs...resulting in better +> sequential write performance than RAID10. +> +> anjan +> + +Well, if your stripe size is 128k, and you have N disks in the RAID (N +must be even and > 4 for RAID10). + +With RAID5 you have a stripe across N-1 disks, and 1 parity entry. +With RAID10 you have a stripe across N/2 disks, replicated on the second +set. + +So if the average write size is >128k*N/2, then you will generally be +using all of the disks during a write, and you can expect a the maximum +scale up of about N/2 for RAID10. + +If your average write size is >128k*(N-1) then you can again write an +entire stripe at a time and even the parity since you already know all +of the information you don't have to do any reading. So you can get a +maximum speed up of N-1. + +If you are doing infrequent smallish writes, it can be buffered by the +write cache, and isn't disk limited at all. And the controller can write +it out when it feels like it. So it should be able to do more buffered +all-at-once writes. + +If you are writing a little bit more often (such that the cache fills +up), depending on your write pattern, it is possible that all of the +stripes are already in the cache, so again there is little penalty for +the parity stripe. + +I suppose the worst case is if you were writing lots of very small +chunks, all over the disk in random order. In which case each write +encounters a 2x read penalty for a smart controller, or a Nx read +penalty if you are going for more safety than speed. (You can read the +original value, and the parity, and re-compute the parity with the new +value (2x read penalty), but if there is corruption it would not be +detected, so you might want to read all of the stripes in the block, and +recompute the parity with the new data (Nx read penalty)). + +I think the issue for Postgres is that it writes 8k pages, which is +quite small relative to the stripe size. So you don't tend to build up +big buffers to write out the entire stripe at once. + +So if you aren't filling up your write buffer, RAID5 can do quite well +with bulk loads. +I also don't know about the penalties for a read followed immediately by +a write. Since you will be writing to the same location, you know that +you have to wait for the disk to spin back to the same location. At 10k +rpm that is a 6ms wait time. For 7200rpm disks, it is 8.3ms. + +Just to say that there are some specific extra penalties when you are +reading the location that you are going to write right away. Now a +really smart controller with lots of data to write could read the whole +circle on the disk, and then start writing out the entire circle, and +not have any spin delay. But you would have to know the size of the +circle, and that depends on what block you are on, and the heads +arrangement and everything else. +Though since hard-drives also have small caches in them, you could hide +some of the spin delay, but not a lot, since you have to leave the head +there until you are done writing, so while the current command would +finish quickly, the next command couldn't start until the first actually +finished. + +Writing large buffers hides all of these seek/spin based latencies, so +you can get really good throughput. But a lot of DB action is small +buffers randomly distributed, so you really do need low seek time, of +which RAID10 is probably better than RAID5. + +John +=:-> + +--------------enig8FC2F801ED54EF8FE7F18F89 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDAjioJdeBCYSNAAMRAmrxAJ0d/LOOzTPlN8aX0HhbpAD+U9JzBQCcChof +FBZU85r9+ojYJKWqBzGLAc0= +=d4vK +-----END PGP SIGNATURE----- + +--------------enig8FC2F801ED54EF8FE7F18F89-- + +From pgsql-performance-owner@postgresql.org Tue Aug 16 16:04:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2530D52883 + for ; + Tue, 16 Aug 2005 16:04:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73272-04 + for ; + Tue, 16 Aug 2005 19:04:36 +0000 (GMT) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DFBC5286E + for ; + Tue, 16 Aug 2005 16:04:30 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 05EA6B813 + for ; + Tue, 16 Aug 2005 15:04:24 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v733) +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE0@vt-pe2550-001.VANTAGE.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE0@vt-pe2550-001.VANTAGE.vantage.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <32D5016B-C7E3-4EEC-AA03-A924521F1DE8@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: choosing RAID level for xlogs +Date: Tue, 16 Aug 2005 15:04:23 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.733) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.019 required=5 tests=[AWL=0.019] +X-Spam-Level: +X-Archive-Number: 200508/184 +X-Sequence-Number: 13931 + + +On Aug 16, 2005, at 2:37 PM, Anjan Dave wrote: + +> Yes, that's true, though, I am a bit confused because the Clariion +> array +> document I am reading talks about how the write cache can eliminate +> the +> RAID5 Write Penalty for sequential and large IOs...resulting in better +> sequential write performance than RAID10. +> + +well, then run your own tests and find out :-) + +if I were using LSI MegaRAID controllers, I'd probalby go RAID10, but +I don't see why you need 6 disks for this... perhaps just 4 would be +enough? Or are your logs really that big? + + +Vivek Khera, Ph.D. ++1-301-869-4449 x806 + + + +From pgsql-performance-owner@postgresql.org Tue Aug 16 16:16:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B9DD52942 + for ; + Tue, 16 Aug 2005 16:16:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78044-01 + for ; + Tue, 16 Aug 2005 19:16:54 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CBD752903 + for ; + Tue, 16 Aug 2005 16:16:53 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050816191654m92009jj78e>; Tue, 16 Aug 2005 19:16:54 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 2947255FBA; Tue, 16 Aug 2005 14:16:54 -0500 (CDT) +Received: from [192.168.1.119] (71-32-69-23.cdrr.qwest.net [71.32.69.23]) + by juju.arbash-meinel.com (Postfix) with ESMTP id A7CB355FB6; + Tue, 16 Aug 2005 14:16:49 -0500 (CDT) +Message-ID: <43023BA0.5030608@arbash-meinel.com> +Date: Tue, 16 Aug 2005 14:16:48 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Anjan Dave +Cc: mudfoot@rawbw.com, pgsql-performance@postgresql.org +Subject: Re: choosing RAID level for xlogs +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE0@vt-pe2550-001.VANTAGE.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE0@vt-pe2550-001.VANTAGE.vantage.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig0BC0F093EED0FFC93551C378" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.037 required=5 tests=[AWL=-0.013, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/185 +X-Sequence-Number: 13932 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig0BC0F093EED0FFC93551C378 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Anjan Dave wrote: +> Yes, that's true, though, I am a bit confused because the Clariion array +> document I am reading talks about how the write cache can eliminate the +> RAID5 Write Penalty for sequential and large IOs...resulting in better +> sequential write performance than RAID10. +> +> anjan +> + +To give a shorter statement after my long one... +If you have enough cache that the controller can write out big chunks to +the disk at a time, you can get very good sequential RAID5 performance, +because the stripe size is large (so it can do a parallel write to all +disks). + +But for small chunk writes, you suffer the penalty of the read before +write, and possible multi-disk read (depends on what is in cache). + +RAID10 generally handles small writes better, and I would guess that +4disks would perform almost identically to 6disks, since you aren't +usually writing enough data to span multiple stripes. + +If your battery-backed cache is big enough that you don't fill it, they +probably perform about the same (superfast) since the cache hides the +latency of the disks. + +If you start filling up your cache, RAID5 probably can do better because +of the parallelization. + +But small writes followed by an fsync do favor RAID10 over RAID5. + +John +=:-> + +--------------enig0BC0F093EED0FFC93551C378 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDAjugJdeBCYSNAAMRAuRYAKDGHPWXaxLjCySei3LLZ+O/9DuTaQCeIVpM +sHxz9K3jdXGZb1lDVGjk7lk= +=+TkO +-----END PGP SIGNATURE----- + +--------------enig0BC0F093EED0FFC93551C378-- + +From pgsql-performance-owner@postgresql.org Tue Aug 16 16:21:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C75952A37 + for ; + Tue, 16 Aug 2005 16:21:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79279-01 + for ; + Tue, 16 Aug 2005 19:21:08 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) + by svr1.postgresql.org (Postfix) with ESMTP id 9248052A14 + for ; + Tue, 16 Aug 2005 16:21:07 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 71so14431wra + for ; + Tue, 16 Aug 2005 12:21:09 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=fAQ5ZmK0OTPRthgYzwyNmyEnwPEurvQdjERrm2DQ3AVAvwegCDwgnzTeawRuaJ3orYCEy9YOlEb2yCUG5RNACcY0W8BU8Uj8DRTtypCSek/pqG2cEQ/7ywHacxYHz/O+wj0weQAJh3bIik15ZoAe6ZcS0J4PHs/86TB4sUNcxUY= +Received: by 10.54.30.54 with SMTP id d54mr4462120wrd; + Tue, 16 Aug 2005 12:21:09 -0700 (PDT) +Received: by 10.54.86.15 with HTTP; Tue, 16 Aug 2005 12:21:09 -0700 (PDT) +Message-ID: <33c6269f0508161221703fc52d@mail.gmail.com> +Date: Tue, 16 Aug 2005 15:21:09 -0400 +From: Alex Turner +To: Anjan Dave +Subject: Re: choosing RAID level for xlogs +Cc: mudfoot@rawbw.com, pgsql-performance@postgresql.org +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE0@vt-pe2550-001.VANTAGE.vantage.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE0@vt-pe2550-001.VANTAGE.vantage.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.105 required=5 tests=[AWL=0.081, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/186 +X-Sequence-Number: 13933 + +Theoretically RAID 5 can perform better than RAID 10 over the same +number of drives (more members form the stripe in RAID 5 than in RAID +10). All you have to do is calculate parity faster than the drives +can write. Doesn't seem like a hard task really, although most RAID +controllers seem incapable of doing so, it is possible that Clariion +might be able to acheive it. The other factor is that for partial +block writes, the array has to first read the original block in order +to recalculate the parity, so small random writes are very slow. If +you are writing chunks that are larger than your stripe size*(n-1), +then in theory the controller doesn't have to re-read a block, and can +just overwrite the parity with the new info. + +Consider just four drives. in RAID 10, it is a stripe of two mirrors, +forming two independant units to write to. in RAID 5, it is a 3 drive +stripe with parity giving three independant units to write to.=20 +Theoretically the RAID 5 should be faster, but I've yet to benchmark a +controler where this holds to be true. + +Of course if you ever do have a drive failure, your array grinds to a +halt because rebuilding a raid 5 requires reading (n-1) blocks to +rebuild just one block where n is the number of drives in the array, +whereas a mirror only required to read from a single spindle of the +RAID. + +I would suggest running some benchmarks at RAID 5 and RAID 10 to see +what the _real_ performance actualy is, thats the only way to really +tell. + +Alex Turner +NetEconomist + +On 8/16/05, Anjan Dave wrote: +> Yes, that's true, though, I am a bit confused because the Clariion array +> document I am reading talks about how the write cache can eliminate the +> RAID5 Write Penalty for sequential and large IOs...resulting in better +> sequential write performance than RAID10. +>=20 +> anjan +>=20 +>=20 +> -----Original Message----- +> From: mudfoot@rawbw.com [mailto:mudfoot@rawbw.com] +> Sent: Tuesday, August 16, 2005 2:00 PM +> To: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] choosing RAID level for xlogs +>=20 +> Quoting Anjan Dave : +>=20 +> > Hi, +> > +> > +> > +> > One simple question. For 125 or more checkpoint segments +> > (checkpoint_timeout is 600 seconds, shared_buffers are at 21760 or +> > 170MB) on a very busy database, what is more suitable, a separate 6 +> disk +> > RAID5 volume, or a RAID10 volume? Databases will be on separate +> > spindles. Disks are 36GB 15KRPM, 2Gb Fiber Channel. Performance is +> > paramount, but I don't want to use RAID0. +> > +>=20 +> RAID10 -- no question. xlog activity is overwhelmingly sequential 8KB +> writes. +> In order for RAID5 to perform a write, the host (or controller) needs to +> perform +> extra calculations for parity. This turns into latency. RAID10 does +> not +> perform those extra calculations. +>=20 +> > +> > +> > PG7.4.7 on RHAS 4.0 +> > +> > +> > +> > I can provide more info if needed. +> > +> > +> > +> > Appreciate some recommendations! +> > +> > +> > +> > Thanks, +> > +> > Anjan +> > +> > +> > +> > +> > --- +> > This email message and any included attachments constitute +> confidential +> > and privileged information intended exclusively for the listed +> > addressee(s). If you are not the intended recipient, please notify +> > Vantage by immediately telephoning 215-579-8390, extension 1158. In +> > addition, please reply to this message confirming your receipt of the +> > same in error. A copy of your email reply can also be sent to +> > support@vantage.com. Please do not disclose, copy, distribute or take +> > any action in reliance on the contents of this information. Kindly +> > destroy all copies of this message and any attachments. Any other use +> of +> > this email is prohibited. Thank you for your cooperation. For more +> > information about Vantage, please visit our website at +> > http://www.vantage.com . +> > --- +> > +> > +> > +> > +>=20 +>=20 +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +>=20 +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +>=20 +> http://archives.postgresql.org +> + +From pgsql-performance-owner@postgresql.org Tue Aug 16 16:52:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D67E529C4 + for ; + Tue, 16 Aug 2005 16:52:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79971-10 + for ; + Tue, 16 Aug 2005 19:52:45 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) + by svr1.postgresql.org (Postfix) with ESMTP id F03E3529E5 + for ; + Tue, 16 Aug 2005 16:52:44 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 70so14956wra + for ; + Tue, 16 Aug 2005 12:52:45 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=PoUtsl1+zUyT13R5ETmzREg2wGQN2XBh27QvU8i+0BdquaEgwtsU69bMFYU5hW7Czf76uzXaZxAWOwlfIM3XPJmkBvbbOZ3JmLHnyayih5TKuphk7Xnl3/X1o21lL6y8Lf3lqGvEmnDQNrWC4ZU7dcnEWxBzD6bywsjB4tWZhNw= +Received: by 10.54.22.71 with SMTP id 71mr1092582wrv; + Tue, 16 Aug 2005 12:52:45 -0700 (PDT) +Received: by 10.54.86.15 with HTTP; Tue, 16 Aug 2005 12:52:45 -0700 (PDT) +Message-ID: <33c6269f050816125266a62d5d@mail.gmail.com> +Date: Tue, 16 Aug 2005 15:52:45 -0400 +From: Alex Turner +To: John A Meinel +Subject: Re: choosing RAID level for xlogs +Cc: Anjan Dave , mudfoot@rawbw.com, + pgsql-performance@postgresql.org +In-Reply-To: <43023BA0.5030608@arbash-meinel.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE0@vt-pe2550-001.VANTAGE.vantage.com> + <43023BA0.5030608@arbash-meinel.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.105 required=5 tests=[AWL=0.081, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/187 +X-Sequence-Number: 13934 + +Don't forget that often controlers don't obey fsyncs like a plain +drive does. thats the point of having a BBU ;) + +Alex Turner +NetEconomist + +On 8/16/05, John A Meinel wrote: +> Anjan Dave wrote: +> > Yes, that's true, though, I am a bit confused because the Clariion arra= +y +> > document I am reading talks about how the write cache can eliminate the +> > RAID5 Write Penalty for sequential and large IOs...resulting in better +> > sequential write performance than RAID10. +> > +> > anjan +> > +>=20 +> To give a shorter statement after my long one... +> If you have enough cache that the controller can write out big chunks to +> the disk at a time, you can get very good sequential RAID5 performance, +> because the stripe size is large (so it can do a parallel write to all +> disks). +>=20 +> But for small chunk writes, you suffer the penalty of the read before +> write, and possible multi-disk read (depends on what is in cache). +>=20 +> RAID10 generally handles small writes better, and I would guess that +> 4disks would perform almost identically to 6disks, since you aren't +> usually writing enough data to span multiple stripes. +>=20 +> If your battery-backed cache is big enough that you don't fill it, they +> probably perform about the same (superfast) since the cache hides the +> latency of the disks. +>=20 +> If you start filling up your cache, RAID5 probably can do better because +> of the parallelization. +>=20 +> But small writes followed by an fsync do favor RAID10 over RAID5. +>=20 +> John +> =3D:-> +>=20 +>=20 +> + +From pgsql-performance-owner@postgresql.org Tue Aug 16 19:04:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D9D60528C6 + for ; + Tue, 16 Aug 2005 18:59:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14829-08 + for ; + Tue, 16 Aug 2005 21:58:57 +0000 (GMT) +Received: from dd01.profihoster.net (dd01.profihoster.net [84.233.130.40]) + by svr1.postgresql.org (Postfix) with ESMTP id A445552896 + for ; + Tue, 16 Aug 2005 18:58:55 -0300 (ADT) +Received: from [192.168.54.114] (Iba10.i.pppool.de [85.73.186.16]) + by dd01.profihoster.net (Postfix) with ESMTP id 376002380EF + for ; + Tue, 16 Aug 2005 23:58:50 +0200 (CEST) +Message-ID: <430261A0.3040708@laliluna.de> +Date: Tue, 16 Aug 2005 23:58:56 +0200 +From: Sebastian Hennebrueder +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: postgres performance +Subject: Re: Looking for a large database for testing +References: <430195DC.70104@laliluna.de> <43019ED4.7070509@wildenhain.de> + <4301A29C.9010003@laliluna.de> +In-Reply-To: <4301A29C.9010003@laliluna.de> +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/188 +X-Sequence-Number: 13935 + +Sebastian Hennebrueder schrieb: + +>Tino Wildenhain schrieb: +> +> +> +> +>>You can download the wikipedia content. Just browse the wikimedia site. +>>Its some work to change the data to be able to import into postgres, +>>but at least you have a lot real world data - in many languages. +>> +>> +> +>I have just found it. Here there is a link +>http://download.wikimedia.org/ +>They have content in multiple languages and dumps up to 20 GB. +> +> +> +Just if anybody wants to import the wikipedia data. I had considerable +problems to get the proper encoding working. I downloaded the german +content from wikipedia, which is a dump of a unicode encoded database of +mysql (utf8) + +I used MySql 4.1 on Windows 2000 to read the dump and then copied the +data with a small application to postgreSQL +In +mysql.ini you should configure the setting +max_allowed_packet = 10M +I set it to 10, wich worked out. Else you can not import the dump into +mysql. The error message was something like lost connection .... +The default encoding of mysql was latin1 which worked. + +Then I imported the dump +mysql -uYourUserName -pPassword --default-character-set=utf8 database < +downloadedAndUnzippedFile +The default-character-set is very important + +Create table in postgres (not with all the columns) +CREATE TABLE content +( + cur_id int4 NOT NULL DEFAULT nextval('public.cur_cur_id_seq'::text), + cur_namespace int2 NOT NULL DEFAULT (0)::smallint, + cur_title varchar(255) NOT NULL DEFAULT ''::character varying, + cur_text text NOT NULL, + cur_comment text, + cur_user int4 NOT NULL DEFAULT 0, + cur_user_text varchar(255) NOT NULL DEFAULT ''::character varying, + cur_timestamp varchar(14) NOT NULL DEFAULT ''::character varying +) ; + +After this I copied the data from mySql to postgres with a small Java +application. The code is not beautiful. + + private void copyEntries() throws Exception { + Class.forName("org.postgresql.Driver"); + Class.forName("com.mysql.jdbc.Driver"); + Connection conMySQL = DriverManager.getConnection( + "jdbc:mysql://localhost/wikidb", "root", "mysql"); + Connection conPostgreSQL = DriverManager.getConnection( + "jdbc:postgresql://localhost/wiki", "postgres", "p"); + Statement selectStatement = conMySQL.createStatement(); + StringBuffer sqlQuery = new StringBuffer(); + sqlQuery.append("insert into content ("); + sqlQuery + .append("cur_id, cur_namespace, cur_title, cur_text, +cur_comment, cur_user, "); + sqlQuery.append("cur_user_text , cur_timestamp) "); + sqlQuery.append("values (?,?,?,?,?,?,?,?)"); + + PreparedStatement insertStatement = conPostgreSQL + .prepareStatement(sqlQuery.toString()); + + // get total rows + java.sql.ResultSet resultSet = selectStatement + .executeQuery("select count(*) from cur"); + resultSet.next(); + int iMax = resultSet.getInt(1); + + + int i = 0; + while (i < iMax) { + resultSet = selectStatement + .executeQuery("select * from cur limit "+i +", 2000"); + while (resultSet.next()) { + i++; + if (i % 100 == 0) + System.out.println("" + i + " von " + iMax); + insertStatement.setInt(1, resultSet.getInt(1)); + insertStatement.setInt(2, resultSet.getInt(2)); + insertStatement.setString(3, resultSet.getString(3)); + insertStatement.setString(4, resultSet.getString(4)); +// this blob field is utf-8 encoded + byte comment[] = resultSet.getBytes(5); + + insertStatement.setString(5, new String(comment, "UTF-8")); + insertStatement.setInt(6, resultSet.getInt(6)); + insertStatement.setString(7, resultSet.getString(7)); + insertStatement.setString(8, resultSet.getString(8)); + insertStatement.execute(); + } + } + } + +-- +Best Regards / Viele Gr��e + +Sebastian Hennebrueder + +---- + +http://www.laliluna.de + +Tutorials for JSP, JavaServer Faces, Struts, Hibernate and EJB + +Get support, education and consulting for these technologies. + + +From pgsql-performance-owner@postgresql.org Tue Aug 16 19:42:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 462F25283C + for ; + Tue, 16 Aug 2005 19:22:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23684-03 + for ; + Tue, 16 Aug 2005 22:22:56 +0000 (GMT) +Received: from loki.globexplorer.com (loki.globexplorer.com [208.35.14.101]) + by svr1.postgresql.org (Postfix) with ESMTP id 380655281E + for ; + Tue, 16 Aug 2005 19:22:55 -0300 (ADT) +X-MIMEOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: quoted-printable +Subject: Re: choosing RAID level for xlogs +Date: Tue, 16 Aug 2005 15:22:55 -0700 +Message-ID: + <71E37EF6B7DCC1499CEA0316A2568328024BB79D@loki.wc.globexplorer.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: choosing RAID level for xlogs +Thread-Index: AcWh2NDgCbXrlD2dSvuZJkSyYWP7KAA2AksO +From: "Gregory S. Williamson" +To: "Anjan Dave" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/189 +X-Sequence-Number: 13936 + +I would be very cautious about ever using RAID5, despite manufacturers' = +claims to the contrary. The link below is authored by a very = +knowledgable fellow whose posts I know (and trust) from Informix land. + + + +Greg Williamson +DBA +GlobeXplorer LLC + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org on behalf of Anjan Dave +Sent: Mon 8/15/2005 1:35 PM +To: pgsql-performance@postgresql.org +Cc:=09 +Subject: [PERFORM] choosing RAID level for xlogs +Hi, + +=20 + +One simple question. For 125 or more checkpoint segments +(checkpoint_timeout is 600 seconds, shared_buffers are at 21760 or +170MB) on a very busy database, what is more suitable, a separate 6 disk +RAID5 volume, or a RAID10 volume? Databases will be on separate +spindles. Disks are 36GB 15KRPM, 2Gb Fiber Channel. Performance is +paramount, but I don't want to use RAID0. + +=20 + +PG7.4.7 on RHAS 4.0 + +=20 + +I can provide more info if needed. + +=20 + +Appreciate some recommendations! + +=20 + +Thanks, + +Anjan + +=20 + +=20 +--- +This email message and any included attachments constitute confidential +and privileged information intended exclusively for the listed +addressee(s). If you are not the intended recipient, please notify +Vantage by immediately telephoning 215-579-8390, extension 1158. In +addition, please reply to this message confirming your receipt of the +same in error. A copy of your email reply can also be sent to +support@vantage.com. Please do not disclose, copy, distribute or take +any action in reliance on the contents of this information. Kindly +destroy all copies of this message and any attachments. Any other use of +this email is prohibited. Thank you for your cooperation. For more +information about Vantage, please visit our website at +http://www.vantage.com . +--- + +=20 + + + +!DSPAM:4300fd35105094125621296! + + + + +From pgsql-performance-owner@postgresql.org Tue Aug 16 19:52:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F18235283C + for ; + Tue, 16 Aug 2005 19:50:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32212-01 + for ; + Tue, 16 Aug 2005 22:50:21 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5716C529BC + for ; + Tue, 16 Aug 2005 19:50:19 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7GMnxXp007517; + Tue, 16 Aug 2005 18:49:59 -0400 (EDT) +To: John A Meinel +Cc: Alvaro Herrera , + Josh Berkus , pgsql-performance@postgresql.org, + "Jeffrey W. Baker" , Steve Poe , + paul@oxton.com +Subject: Re: PG8 Tuning +In-reply-to: <43021567.1000101@arbash-meinel.com> +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> + <1123779524.6664.1.camel@toonses.gghcwest.com> + <200508160912.32263.josh@agliodbs.com> + <20050816162531.GB32695@alvh.no-ip.org> + <43021567.1000101@arbash-meinel.com> +Comments: In-reply-to John A Meinel + message dated "Tue, 16 Aug 2005 11:33:43 -0500" +Date: Tue, 16 Aug 2005 18:49:59 -0400 +Message-ID: <7516.1124232599@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/190 +X-Sequence-Number: 13937 + +John A Meinel writes: +> Alvaro Herrera wrote: +>> I've been asked this a couple of times and I don't know the answer: what +>> happens if you give XLog a single drive (unmirrored single spindle), and +>> that drive dies? So the question really is, should you be giving two +>> disks to XLog? + +> I can propose a simple test. Create a test database. Run postgres, +> insert a bunch of stuff. Stop postgres. Delete everything in the pg_xlog +> directory. Start postgres again, what does it do? + +That test would really be completely unrelated to the problem. + +If you are able to shut down the database cleanly, then you do not need +pg_xlog anymore --- everything is on disk in the data area. You might +have to use pg_resetxlog to get going again, but you won't lose anything +by doing so. + +The question of importance is: if the xlog drive dies while the database +is running, are you going to be able to get the postmaster to shut down +cleanly? My suspicion is "no" --- if the kernel is reporting write +failures on WAL, that's going to prevent writes to the data drives (good +ol' WAL-before-data rule). You could imagine failure modes where the +drive is toast but isn't actually reporting any errors ... but one hopes +that's not a common scenario. + +In a scenario like this, it might be interesting to have a shutdown mode +that deliberately ignores writing to WAL and just does its best to get +all the dirty pages down onto the data drives. + +In the meantime ... use a mirrored drive for WAL. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 16 20:22:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7292D52870 + for ; + Tue, 16 Aug 2005 20:15:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36806-02 + for ; + Tue, 16 Aug 2005 23:15:00 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E235529E6 + for ; + Tue, 16 Aug 2005 20:14:58 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050816231500m9100g6eeae>; Tue, 16 Aug 2005 23:15:00 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id C048155FBA; Tue, 16 Aug 2005 18:14:59 -0500 (CDT) +Received: from [192.168.1.119] (71-32-69-23.cdrr.qwest.net [71.32.69.23]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 46D3755FAD; + Tue, 16 Aug 2005 18:14:45 -0500 (CDT) +Message-ID: <43027361.2070303@arbash-meinel.com> +Date: Tue, 16 Aug 2005 18:14:41 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane , + Postgresql Performance +Subject: Re: PG8 Tuning +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> + <1123779524.6664.1.camel@toonses.gghcwest.com> + <200508160912.32263.josh@agliodbs.com> + <20050816162531.GB32695@alvh.no-ip.org> + <43021567.1000101@arbash-meinel.com> + <7516.1124232599@sss.pgh.pa.us> +In-Reply-To: <7516.1124232599@sss.pgh.pa.us> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig5E2D1FE484D3F3971760F402" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.038 required=5 tests=[AWL=-0.013, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/191 +X-Sequence-Number: 13938 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig5E2D1FE484D3F3971760F402 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: +> John A Meinel writes: +> +>>Alvaro Herrera wrote: +>> +>>>I've been asked this a couple of times and I don't know the answer: what +>>>happens if you give XLog a single drive (unmirrored single spindle), and +>>>that drive dies? So the question really is, should you be giving two +>>>disks to XLog? +> +> +>>I can propose a simple test. Create a test database. Run postgres, +>>insert a bunch of stuff. Stop postgres. Delete everything in the pg_xlog +>>directory. Start postgres again, what does it do? +> +> +> That test would really be completely unrelated to the problem. +> +> If you are able to shut down the database cleanly, then you do not need +> pg_xlog anymore --- everything is on disk in the data area. You might +> have to use pg_resetxlog to get going again, but you won't lose anything +> by doing so. + +So pg_xlog is really only needed for a dirty shutdown. So what about the +idea of having pg_xlog on a ramdisk that is syncronized periodically to +a real disk. + +I'm guessing you would get corruption of the database, or at least you +don't know what is clean and what is dirty, since there would be no WAL +entry for some of the things that completed, but also no WAL entry for +things that were not completed. + +So what is actually written to the WAL? Is it something like: +"I am writing these pages, and when page X has a certain value, I am +finished" + +I'm just curious, because I don't believe you write to the WAL when you +complete the writing the data, you only make a note about what you are +going to do before you do it. So there needs to be a way to detect if +you actually finished (which would be in the actual data). + +John +=:-> + +> +> The question of importance is: if the xlog drive dies while the database +> is running, are you going to be able to get the postmaster to shut down +> cleanly? My suspicion is "no" --- if the kernel is reporting write +> failures on WAL, that's going to prevent writes to the data drives (good +> ol' WAL-before-data rule). You could imagine failure modes where the +> drive is toast but isn't actually reporting any errors ... but one hopes +> that's not a common scenario. +> +> In a scenario like this, it might be interesting to have a shutdown mode +> that deliberately ignores writing to WAL and just does its best to get +> all the dirty pages down onto the data drives. +> +> In the meantime ... use a mirrored drive for WAL. +> +> regards, tom lane +> + + +--------------enig5E2D1FE484D3F3971760F402 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDAnNkJdeBCYSNAAMRAvbYAJ4oWsYrHLDMpZwN54Hj0iar6SSsGACgx59f +9DeX5ViF+I9WodBxGD3/4lw= +=MeG4 +-----END PGP SIGNATURE----- + +--------------enig5E2D1FE484D3F3971760F402-- + +From pgsql-performance-owner@postgresql.org Tue Aug 16 22:12:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C99E5282E + for ; + Tue, 16 Aug 2005 22:12:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68348-01 + for ; + Wed, 17 Aug 2005 01:12:20 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.244]) + by svr1.postgresql.org (Postfix) with ESMTP id 809E45287D + for ; + Tue, 16 Aug 2005 22:12:15 -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="utf-8" +Content-Transfer-Encoding: base64 +Subject: Re: choosing RAID level for xlogs +Date: Tue, 16 Aug 2005 21:12:14 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE1@vt-pe2550-001.VANTAGE.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: choosing RAID level for xlogs +Thread-Index: AcWh2NDgCbXrlD2dSvuZJkSyYWP7KAA2AksOAASmv34= +From: "Anjan Dave" +To: "Gregory S. Williamson" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.032 required=5 tests=[AWL=0.032] +X-Spam-Level: +X-Archive-Number: 200508/192 +X-Sequence-Number: 13939 + +VGhhbmtzLCBldmVyeW9uZS4gSSBnb3Qgc29tZSBleGNlbGxlbnQgcmVwbGllcywgaW5jbHVkaW5n +IHNvbWUgbG9uZyBleHBsYW5hdGlvbnMuIEFwcHJlY2lhdGUgdGhlIHRpbWUgeW91IGd1eXMgdG9v +ayBvdXQgZm9yIHRoZSByZXNwb25zZXMuDQogDQpUaGUgZ2lzdCBvZiBpdCBpIHRha2UsIGlzIHRv +IHVzZSBSQUlEMTAuIEkgaGF2ZSA0MDBNQisgb2Ygd3JpdGUgY2FjaGUgb24gdGhlIGNvbnRyb2xs +ZXIocyksIHRoYXQgdGhlIFJBSUQ1IExVTihzKSBjb3VsZCBiZW5lZml0IGZyb20gYnkgZmlsbGlu +ZyBpdCB1cCBhbmQgd3JpdGluZyBvdXQgdGhlIGNvbXBsZXRlIHN0cmlwZSwgYnV0IGNvbWUgdG8g +dGhpbmsgb2YgaXQsIGl0J3Mgc2hhcmVkIGFtb25nIHRoZSB0d28gU3RvcmFnZSBQcm9jZXNzb3Jz +LCBhbGwgdGhlIExVTn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BIGNvcHkgb2YgeW91ciBlbWFpbCByZXBseSBjYW4gYWxzbyBi +ZSBzZW50IHRvIA0KCXN1cHBvcnRAdmFudGFnZS5jb20uIFBsZWFzZSBkbyBub3QgZGlzY2xvc2Us +IGNvcHksIGRpc3RyaWJ1dGUgb3IgdGFrZSANCglhbnkgYWN0aW9uIGluIHJlbGlhbmNlIG9uIHRo +ZSBjb250ZW50cyBvZiB0aGlzIGluZm9ybWF0aW9uLiBLaW5kbHkgDQoJZGVzdHJveSBhbGwgY29w +aWVzIG9mIHRoaXMgbWVzc2FnZSBhbmQgYW55IGF0dGFjaG1lbnRzLiBBbnkgb3RoZXIgdXNlIG9m +IA0KCXRoaXMgZW1haWwgaXMgcHJvaGliaXRlZC4gVGhhbmsgeW91IGZvciB5b3VyIGNvb3BlcmF0 +aW9uLiBGb3IgbW9yZSANCglpbmZvcm1hdGlvbiBhYm91dCBWYW50YWdlLCBwbGVhc2UgdmlzaXQg +b3VyIHdlYnNpdGUgYXQgDQoJaHR0cDovL3d3dy52YW50YWdlLmNvbSA8aHR0cDovL3d3dy52YW50 +YWdlLmNvbS8+IC4gDQoJLS0tIA0KDQoJDQoNCg0KDQoJIURTUEFNOjQzMDBmZDM1MTA1MDk0MTI1 +NjIxMjk2ISANCg0KDQoNCg== + +From pgsql-performance-owner@postgresql.org Tue Aug 16 23:28:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BC73B52A80 + for ; + Tue, 16 Aug 2005 23:27:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82224-09 + for ; + Wed, 17 Aug 2005 02:27:18 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 0337552AB9 + for ; + Tue, 16 Aug 2005 23:27:16 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7H2RKtN010093; + Tue, 16 Aug 2005 22:27:20 -0400 (EDT) +To: John A Meinel +Cc: Postgresql Performance +Subject: Re: PG8 Tuning +In-reply-to: <43027361.2070303@arbash-meinel.com> +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <1123836428.19976.26.camel@amd64-laptop-spoe> + <1123779524.6664.1.camel@toonses.gghcwest.com> + <200508160912.32263.josh@agliodbs.com> + <20050816162531.GB32695@alvh.no-ip.org> + <43021567.1000101@arbash-meinel.com> + <7516.1124232599@sss.pgh.pa.us> + <43027361.2070303@arbash-meinel.com> +Comments: In-reply-to John A Meinel + message dated "Tue, 16 Aug 2005 18:14:41 -0500" +Date: Tue, 16 Aug 2005 22:27:20 -0400 +Message-ID: <10092.1124245640@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/193 +X-Sequence-Number: 13940 + +John A Meinel writes: +> So pg_xlog is really only needed for a dirty shutdown. So what about the +> idea of having pg_xlog on a ramdisk that is syncronized periodically to +> a real disk. + +Well, if "periodically" means "at every transaction commit", that's +pretty much what we do now. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 17 00:15:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 54C4E52AD2 + for ; + Wed, 17 Aug 2005 00:10:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04050-02 + for ; + Wed, 17 Aug 2005 03:10:46 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EBB4528D4 + for ; + Wed, 17 Aug 2005 00:10:39 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i22so77519wra + for ; + Tue, 16 Aug 2005 20:10:39 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=Iy+Iwb6xoYEhyU8axm2jXwctLiAGr2jpzRmhUmeu/cCFSAUGYalFIH9NhVWcUB5LqEL0EVqdgSVIrM/rHE0WKxXbuS8/KBcAHZ91fbAY7pjqOzE4yKFX0czNiAoBEeoCKNTE8oq8VtTonQZwLPZROO30UbbgIvYw/Onv9lKVD2k= +Received: by 10.54.26.63 with SMTP id 63mr149251wrz; + Tue, 16 Aug 2005 20:10:38 -0700 (PDT) +Received: by 10.54.86.15 with HTTP; Tue, 16 Aug 2005 20:10:38 -0700 (PDT) +Message-ID: <33c6269f0508162010519a7f12@mail.gmail.com> +Date: Tue, 16 Aug 2005 23:10:38 -0400 +From: Alex Turner +To: Anjan Dave +Subject: Re: choosing RAID level for xlogs +Cc: "Gregory S. Williamson" , + pgsql-performance@postgresql.org +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE1@vt-pe2550-001.VANTAGE.vantage.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098BE1@vt-pe2550-001.VANTAGE.vantage.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.104 required=5 tests=[AWL=0.080, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/194 +X-Sequence-Number: 13941 + +The other point that is well made is that with enough drives you will +max out the PCI bus before you max out the drives. 64-bit 66Mhz can +do about 400MB/sec, which can be acheived by two 3 drive stripes (6 +drive in RAID 10). A true PCI-X card can do better, but can your +controller? Remember, U320 is only 320MB/channel... + +Alex Turner +NetEconomist + +On 8/16/05, Anjan Dave wrote: +> Thanks, everyone. I got some excellent replies, including some long expla= +nations. Appreciate the time you guys took out for the responses. +>=20 +> The gist of it i take, is to use RAID10. I have 400MB+ of write cache on = +the controller(s), that the RAID5 LUN(s) could benefit from by filling it u= +p and writing out the complete stripe, but come to think of it, it's shared= + among the two Storage Processors, all the LUNs, not just the ones holding = +the pg_xlog directory. The other thing (with Clariion) is the write cache m= +irroring. Write isn't signalled complete to the host until the cache conten= +t is mirrored across the other SP (and vice-versa), which is a good thing, = +but this operation could potentially become a bottleneck with very high loa= +d on the SPs. +>=20 +> Also, one would have to fully trust the controller/manufacturer's claim o= +n signalling the write completion. And, performance is a priority over the = +drive space lost in RAID10 for me. +>=20 +> I can use 4 drives instead of 6. +>=20 +> Thanks, +> Anjan +>=20 +> t-----Original Message----- +> From: Gregory S. Williamson [mailto:gsw@globexplorer.com] +> Sent: Tue 8/16/2005 6:22 PM +> To: Anjan Dave; pgsql-performance@postgresql.org +> Cc: +> Subject: RE: [PERFORM] choosing RAID level for xlogs +>=20 +>=20 +>=20 +> I would be very cautious about ever using RAID5, despite manufact= +urers' claims to the contrary. The link below is authored by a very knowled= +gable fellow whose posts I know (and trust) from Informix land. +>=20 +> +>=20 +> Greg Williamson +> DBA +> GlobeXplorer LLC +>=20 +>=20 +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org on behalf of Anjan= + Dave +> Sent: Mon 8/15/2005 1:35 PM +> To: pgsql-performance@postgresql.org +> Cc: +> Subject: [PERFORM] choosing RAID level for xlogs +> Hi, +>=20 +>=20 +>=20 +> One simple question. For 125 or more checkpoint segments +> (checkpoint_timeout is 600 seconds, shared_buffers are at 21760 o= +r +> 170MB) on a very busy database, what is more suitable, a separate= + 6 disk +> RAID5 volume, or a RAID10 volume? Databases will be on separate +> spindles. Disks are 36GB 15KRPM, 2Gb Fiber Channel. Performance i= +s +> paramount, but I don't want to use RAID0. +>=20 +>=20 +>=20 +> PG7.4.7 on RHAS 4.0 +>=20 +>=20 +>=20 +> I can provide more info if needed. +>=20 +>=20 +>=20 +> Appreciate some recommendations! +>=20 +>=20 +>=20 +> Thanks, +>=20 +> Anjan +>=20 +>=20 +>=20 +>=20 +> --- +> This email message and any included attachments constitute confid= +ential +> and privileged information intended exclusively for the listed +> addressee(s). If you are not the intended recipient, please notif= +y +> Vantage by immediately telephoning 215-579-8390, extension 1158. = +In +> addition, please reply to this message confirming your receipt of= + the +> same in error. A copy of your email reply can also be sent to +> support@vantage.com. Please do not disclose, copy, distribute or = +take +> any action in reliance on the contents of this information. Kindl= +y +> destroy all copies of this message and any attachments. Any other= + use of +> this email is prohibited. Thank you for your cooperation. For mor= +e +> information about Vantage, please visit our website at +> http://www.vantage.com . +> --- +>=20 +>=20 +>=20 +>=20 +>=20 +> !DSPAM:4300fd35105094125621296! +>=20 +>=20 +>=20 +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + +From pgsql-jdbc-owner@postgresql.org Wed Aug 17 01:42:39 2005 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4624252927; + Wed, 17 Aug 2005 01:42:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26067-01; Wed, 17 Aug 2005 04:42:33 +0000 (GMT) +Received: from NSNOVPS00411.nacio.xythos.com (212-59.84.64.master-link.com + [64.84.59.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 55B6552897; + Wed, 17 Aug 2005 01:42:30 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C5A2E6.133B18A8" +Subject: Performance problem using V3 protocol in jdbc driver +Date: Tue, 16 Aug 2005 21:42:29 -0700 +Message-ID: + <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Performance problem using V3 protocol in jdbc driver +Thread-Index: AcWi5hZNs712lLDwQT+PcpWjcgBCsQ== +From: "Barry Lind" +To: +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.074 required=5 tests=[AWL=-0.004, + FORGED_RCVD_HELO=0.05, HTML_60_70=0.027, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/108 +X-Sequence-Number: 13677 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5A2E6.133B18A8 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +We just moved a large production instance of ours from Oracle to +Postgres 8.0.3 on linux. When running on Oracle the machine hummed +along using about 5% of the CPU easily handling the fairly constant +load, after moving the data to Postgres the machine was pretty much +maxed out on CPU and could no longer keep up with the transaction +volume. On a hunch I switched the jdbc driver to using the V2 protocol +and the load on the machine dropped down to what it was when using +Oracle and everything was fine. + +=20 + +Now obviously I have found a work around for the performance problem, +but I really don't want to rely on using the V2 protocol forever, and +don't want to have to recommend to our customers that they need to run +with the V2 protocol. So I would like to resolve the problem and be +able to move back to a default configuration with the V3 protocol and +the benefits thereof. + +=20 + +The problem is that I don't really know where to begin to debug a +problem like this. In development environments and testing environments +we have not seen performance problems with the V3 protocol in the jdbc +driver. But they don't come close to approaching the transaction volume +of this production instance. + +=20 + +What I see when running the V3 protocol under 'top' is that the postgres +processes are routinely using 15% or more of the CPU each, when running +the V2 protocol they use more like 0.3%. + +=20 + +Does anyone have any suggestions on an approach to debug a problem like +this? + +=20 + +Thanks, + +--Barry + + +------_=_NextPart_001_01C5A2E6.133B18A8 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

We just moved a large production instance of ours = +from +Oracle to Postgres 8.0.3 on linux.  When running on Oracle the = +machine +hummed along using about 5% of the CPU easily handling the fairly = +constant load, +after moving the data to Postgres the machine was pretty much maxed out = +on CPU +and could no longer keep up with the transaction volume.  On a = +hunch I +switched the jdbc driver to using the V2 protocol and the load on the = +machine +dropped down to what it was when using Oracle and everything was = +fine.

+ +

 

+ +

Now obviously I have found a work around for the = +performance +problem, but I really don’t want to rely on using the V2 protocol +forever, and don’t want to have to recommend to our customers that = +they +need to run with the V2 protocol.  So I would like to resolve the = +problem +and be able to move back to a default configuration with the V3 protocol = +and +the benefits thereof.

+ +

 

+ +

The problem is that I don’t really know where = +to begin +to debug a problem like this.  In development environments and = +testing +environments we have not seen performance problems with the V3 protocol = +in the +jdbc driver.  But they don’t come close to approaching the +transaction volume of this production = +instance.

+ +

 

+ +

What I see when running the V3 protocol under = +‘top’ +is that the postgres processes are routinely using 15% or more of the = +CPU each, +when running the V2 protocol they use more like = +0.3%.

+ +

 

+ +

Does anyone have any suggestions on an approach to = +debug a +problem like this?

+ +

 

+ +

Thanks,

+ +

--Barry

+ +
+ + + + + +------_=_NextPart_001_01C5A2E6.133B18A8-- + +From pgsql-performance-owner@postgresql.org Wed Aug 17 01:49:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 147825297F + for ; + Wed, 17 Aug 2005 01:48:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27495-03 + for ; + Wed, 17 Aug 2005 04:48:29 +0000 (GMT) +Received: from smtpauth04.mail.atl.earthlink.net + (smtpauth04.mail.atl.earthlink.net [209.86.89.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 333B952956 + for ; + Wed, 17 Aug 2005 01:48:27 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=Q9qkzjv+vdZ9REwC0rN4tbIK6jhXxXcmmVLliM9zMl/0Bpojdx2VaB3q3bkERWy+; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth04.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E5Fqk-00019n-QJ; Wed, 17 Aug 2005 00:48:26 -0400 +Message-Id: <6.2.3.4.0.20050817001405.01fc3cd8@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Wed, 17 Aug 2005 00:48:26 -0400 +To: "Kari Lavikka" +From: Ron +Subject: Re: Finding bottleneck +Cc: pgsql-performance@postgresql.org +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc963dc7ab735b43a6dce1f6a9b0f1afd0350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.374 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/196 +X-Sequence-Number: 13943 + +I think I have a solution for you. + +You have posted that you presently have these RAID volumes and behaviors: + sda: data (10 spindles, raid10) + sdb: xlog & clog (2 spindles, raid1) + sdc: os and other stuff + +Usually iostat (2 second interval) says: +avg-cpu: %user %nice %sys %iowait %idle + 32.38 0.00 12.88 11.62 43.12 + +Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn + sda 202.00 1720.00 0.00 3440 0 + sdb 152.50 4.00 2724.00 8 5448 + sdc 0.00 0.00 0.00 0 0 + +And during checkpoint: +avg-cpu: %user %nice %sys %iowait %idle + 31.25 0.00 14.75 54.00 0.00 + +Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn +sda 3225.50 1562.00 35144.00 3124 70288 +sdb 104.50 10.00 2348.00 20 4696 +sdc 0.00 0.00 0.00 0 0 + + +During checkpoints sda is becoming saturated, essentially halting all +other DB activity involving sda. A lesser version of the porblem is +probably occurring every time multiple entities on sda are being +accessed simultaneously, particularly simultaneous writes. + +My Proposed Solution: +Put comment and its index on it's own dedicated RAID volume. +Put comment_archive and its index on its own dedicated RAID volume. +Put the rest of the tables currently part of "data" on their own +dedicated RAID volume. +Put the rest if the indexes to the tables currently part of "data" on +their own dedicated RAID volume. +Put xlog on its own dedicated RAID volume. + +The general idea here is to put any tables or indexes that tend to +require simultaneous access, particularly write access, on different +spindles. Like all things, there's a point of diminishing returns +that is dependent on the HW used and the DB load. + +If you must wring every last bit of IO out of the HD subsystem, a +more exact set of spindle assignments can be made by analyzing your +queries and then 1) make sure writes that tend to be simultaneous are +to different spindles, then (if you still need better IO) 2) make +sure reads that tend to be simultaneous are to different +spindles. At some point, your controller will become the +bottleneck. At some point beyond that, the IO channels on the +mainboard will become the bottleneck. + +My suggestion should get you to within 80-90% of optimal if I've +understood the implications of your posts correctly. + +The other suggestion I'd make is to bump your RAM from 16GB to 32GB +as soon as you can afford it and then tune your PostgreSQL parameters +to make best use of it. The more RAM resident your DB, the better. + +Hope this helps, +Ron Peacetree + + +===========Original Message Follows=========== +From: Kari Lavikka +To: Merlin Moncure +Subject: Re: Finding bottleneck +Date: Mon, 8 Aug 2005 19:19:09 +0300 (EETDST) + +---------- + +Actually I modified postgresql.conf a bit and there isn't commit +delay any more. That didn't make noticeable difference though.. + +Workload is generated by a website with about 1000 dynamic page views +a second. Finland's biggest site among youths btw. + + +Anyway, there are about 70 tables and here's some of the most important: + relname | reltuples +----------------------------------+------------- + comment | 1.00723e+08 + comment_archive | 9.12764e+07 + channel_comment | 6.93912e+06 + image | 5.80314e+06 + admin_event | 5.1936e+06 + user_channel | 3.36877e+06 + users | 325929 + channel | 252267 + +Queries to "comment" table are mostly IO-bound but are performing +quite well. Here's an example: +(SELECT u.nick, c.comment, c.private, c.admin, c.visible, c.parsable, +c.uid_sender, to_char(c.stamp, 'DD.MM.YY HH24:MI') AS stamp, +c.comment_id FROM comment c INNER JOIN users u ON u.uid = +c.uid_sender WHERE u.status = 'a' AND c.image_id = 15500900 AND +c.uid_target = 780345 ORDER BY uid_target DESC, image_id DESC, +c.comment_id DESC) LIMIT 36 + + +And explain analyze: + Limit (cost=0.00..6.81 rows=1 width=103) (actual +time=0.263..17.522 rows=12 loops=1) + -> Nested Loop (cost=0.00..6.81 rows=1 width=103) (actual +time=0.261..17.509 rows=12 loops=1) + -> Index Scan Backward using +comment_uid_target_image_id_comment_id_20050527 on "comment" +c (cost=0.00..3.39 rows=1 width=92) (actual time=0.129..16.213 +rows=12 loops=1) + Index Cond: ((uid_target = 780345) AND (image_id = 15500900)) + -> Index Scan using users_pkey on users +u (cost=0.00..3.40 rows=1 width=15) (actual time=0.084..0.085 rows=1 loops=12) + Index Cond: (u.uid = "outer".uid_sender) + Filter: (status = 'a'::bpchar) + Total runtime: 17.653 ms + + +We are having performance problems with some smaller tables and very +simple queries. For example: +SELECT u.uid, u.nick, extract(epoch from uc.stamp) AS stamp FROM +user_channel uc INNER JOIN users u USING (uid) WHERE channel_id = +281321 AND u.status = 'a' ORDER BY uc.channel_id, upper(uc.nick) + + +And explain analyze: + Nested Loop (cost=0.00..200.85 rows=35 width=48) (actual +time=0.414..38.128 rows=656 loops=1) + -> Index Scan using user_channel_channel_id_nick on user_channel +uc (cost=0.00..40.18 rows=47 width=27) (actual time=0.090..0.866 +rows=667 loops=1) + Index Cond: (channel_id = 281321) + -> Index Scan using users_pkey on users u (cost=0.00..3.40 +rows=1 width=25) (actual time=0.048..0.051 rows=1 loops=667) + Index Cond: ("outer".uid = u.uid) + Filter: (status = 'a'::bpchar) + Total runtime: 38.753 ms + +Under heavy load these queries tend to take several minutes to +execute although there's plenty of free cpu available. There aren't +any blocking locks in pg_locks. + + + |\__/| + ( oo ) Kari Lavikka - tuner ( at ) bdb ( dot ) fi - (050) 380 3808 +__ooO( )Ooo_______ _____ ___ _ _ _ _ _ _ _ + "" + + + + +From pgsql-jdbc-owner@postgresql.org Wed Aug 17 02:01:55 2005 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 43575529DA; + Wed, 17 Aug 2005 02:01:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32118-03; Wed, 17 Aug 2005 05:01:48 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C195529C6; + Wed, 17 Aug 2005 02:01:45 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7H51j41012038; + Wed, 17 Aug 2005 01:01:45 -0400 (EDT) +To: "Barry Lind" +Cc: pgsql-performance@postgresql.org, pgsql-jdbc@postgresql.org +Subject: Re: Performance problem using V3 protocol in jdbc driver +In-reply-to: + <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> +References: + <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> +Comments: In-reply-to "Barry Lind" + message dated "Tue, 16 Aug 2005 21:42:29 -0700" +Date: Wed, 17 Aug 2005 01:01:45 -0400 +Message-ID: <12037.1124254905@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/109 +X-Sequence-Number: 13678 + +"Barry Lind" writes: +> ... On a hunch I switched the jdbc driver to using the V2 protocol +> and the load on the machine dropped down to what it was when using +> Oracle and everything was fine. + +First knee-jerk reaction is that it's an optimization problem stemming +from V3 protocol feeding parameterized queries to the backend where V2 +did not, and the planner being unable to cope :-( + +Can you identify the specific queries causing the problem? + + regards, tom lane + +From pgsql-jdbc-owner@postgresql.org Wed Aug 17 02:43:48 2005 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8161D529EC; + Wed, 17 Aug 2005 02:43:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36727-09; Wed, 17 Aug 2005 05:43:43 +0000 (GMT) +Received: from NSNOVPS00411.nacio.xythos.com (212-59.84.64.master-link.com + [64.84.59.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 275EF529D6; + Wed, 17 Aug 2005 02:43:40 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Performance problem using V3 protocol in jdbc driver +Date: Tue, 16 Aug 2005 22:43:40 -0700 +Message-ID: + <03E7D3E231BB7B4A915A6581D4296CC6015D5352@NSNOVPS00411.nacio.xythos.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [JDBC] Performance problem using V3 protocol in jdbc driver +Thread-Index: AcWi6MdL6nw11NNHQ9q4dDVy3dz7XQAA4nBw +From: "Barry Lind" +To: "Tom Lane" +Cc: , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 required=5 tests=[AWL=0.011, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/110 +X-Sequence-Number: 13679 + +That was my suspicion as well, which is why I tried the V2 protocol. =20 + +I do not know of any specific queries that are causing the problem. As +I monitor 'top' I see processes utilizing a significant amount of CPU +running SELECT, UPDATE and DELETE, which would lead me to believe that +it isn't any one specific query. + +How does one identify on a live system specific queries that are running +slow, especially with the V3 protocol and when the system is executing +about a 100 queries a second (which makes turning on any sort of logging +very very verbose)? (I just subscribed to the performance list, so this +is probably something that has been answered many times before on this +list). + +I haven't tried to track down a performance problem like this before on +postgres. Since most of our large customers run Oracle that is where I +have the knowledge to figure something like this out. + +Thanks, +--Barry + + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Tuesday, August 16, 2005 10:02 PM +To: Barry Lind +Cc: pgsql-performance@postgresql.org; pgsql-jdbc@postgresql.org +Subject: Re: [JDBC] Performance problem using V3 protocol in jdbc driver + + +"Barry Lind" writes: +> ... On a hunch I switched the jdbc driver to using the V2 protocol +> and the load on the machine dropped down to what it was when using +> Oracle and everything was fine. + +First knee-jerk reaction is that it's an optimization problem stemming +from V3 protocol feeding parameterized queries to the backend where V2 +did not, and the planner being unable to cope :-( + +Can you identify the specific queries causing the problem? + + regards, tom lane + + +From pgsql-performance-owner@postgresql.org Wed Aug 17 05:16:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CA54652B1E + for ; + Wed, 17 Aug 2005 05:14:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91460-05 + for ; + Wed, 17 Aug 2005 08:14:25 +0000 (GMT) +Received: from mail0.rawbw.com (mail0.rawbw.com [198.144.192.41]) + by svr1.postgresql.org (Postfix) with ESMTP id BC77452B38 + for ; + Wed, 17 Aug 2005 05:14:23 -0300 (ADT) +Received: (from www@localhost) + by mail0.rawbw.com (8.11.6p2/8.11.6) id j7H8EPA52792 + for pgsql-performance@postgresql.org; + Wed, 17 Aug 2005 01:14:25 -0700 (PDT) +Received: from 198.144.203.173 ([198.144.203.173]) + by webmail.rawbw.com (IMP) with HTTP + for ; Wed, 17 Aug 2005 01:14:24 -0700 +Message-ID: <1124266464.4302f1e0d5d30@webmail.rawbw.com> +Date: Wed, 17 Aug 2005 01:14:24 -0700 +From: mudfoot@rawbw.com +To: pgsql-performance@postgresql.org +Subject: Re: Performance problem using V3 protocol in jdbc driver +References: + <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> +In-Reply-To: + <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.1 +X-Originating-IP: 198.144.203.173 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/199 +X-Sequence-Number: 13946 + +Quoting Barry Lind : + + +> +> +> What I see when running the V3 protocol under 'top' is that the postgres +> processes are routinely using 15% or more of the CPU each, when running +> the V2 protocol they use more like 0.3%. +> +> +> +> Does anyone have any suggestions on an approach to debug a problem like +> this? +> +> + +Tracing system calls is a good starting point--truss on Solaris, strace on Linux +(Redhat anyway), ktrace on BSD. The difference between 0.3% and 15% CPU +utilization under similar load will very likely (though not with complete +certainty) be showing very noticeably different system call activity. + +If you notice a difference in system call activity, then that would probably +provide a hint as to what's going on--where the inefficiency lies. It's +possible to spin the CPU up without any system calls, but system call tracing +can be done pretty quickly and you should be able to see any interesting +patterns emerge quite quickly. + +^ +| + +This method is a good starting point for troubleshooting just about any funny +process activity. And it comes with the added benefit of not having to know +ahead of time about the specific matter at hand (JDBC implementation, in this +case). :-) That's having your cake and eating it, too. + +> +> Thanks, +> +> --Barry +> +> + + + +From pgsql-performance-owner@postgresql.org Wed Aug 17 06:13:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5695252B42 + for ; + Wed, 17 Aug 2005 06:13:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15607-04 + for ; + Wed, 17 Aug 2005 09:13:20 +0000 (GMT) +Received: from thor.netera.se (thor.netera.se [85.112.172.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 7401452B48 + for ; + Wed, 17 Aug 2005 06:13:18 -0300 (ADT) +Received: from [192.168.2.240] (1-1-1-41a.o.sth.bostream.se [81.26.246.14]) + by thor.netera.se (Postfix) with ESMTP id 7E29313AC06F + for ; + Wed, 17 Aug 2005 11:13:19 +0200 (CEST) +Message-ID: <4303003B.3020407@relevanttraffic.se> +Date: Wed, 17 Aug 2005 11:15:39 +0200 +From: Ulrich Wisser +Organization: Relevant Traffic AB +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Need for speed +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/200 +X-Sequence-Number: 13947 + +Hello, + +thanks for all your suggestions. + +I can see that the Linux system is 90% waiting for disc io. At that time +all my queries are *very* slow. My scsi raid controller and disc are +already the fastest available. The query plan uses indexes and "vacuum +analyze" is run once a day. + +To avoid aggregating to many rows, I already made some aggregation +tables which will be updated after the import from the Apache logfiles. +That did help, but only to a certain level. + +I believe the biggest problem is disc io. Reports for very recent data +are quite fast, these are used very often and therefor already in the +cache. But reports can contain (and regulary do) very old data. In that +case the whole system slows down. To me this sounds like the recent data +is flushed out of the cache and now all data for all queries has to be +fetched from disc. + +My machine has 2GB memory, please find postgresql.conf below. + +Ulrich + + +#--------------------------------------------------------------------------- +# RESOURCE USAGE (except WAL) +#--------------------------------------------------------------------------- + +# - Memory - + +shared_buffers = 20000 # min 16, at least max_connections*2, +sort_mem = 4096 # min 64, size in KB +vacuum_mem = 8192 # min 1024, size in KB + +# - Free Space Map - + +max_fsm_pages = 50000 # min max_fsm_relations*16, 6 bytes each +max_fsm_relations = 3000 # min 100, ~50 bytes each + +# - Kernel Resource Usage - + +#max_files_per_process = 1000 # min 25 +#preload_libraries = '' + + +#--------------------------------------------------------------------------- +# WRITE AHEAD LOG +#--------------------------------------------------------------------------- + +# - Settings - + +fsync = false # turns forced synchronization on or off +#wal_sync_method = fsync # the default varies across platforms: +wal_buffers = 128 # min 4, 8KB each + +# - Checkpoints - + +checkpoint_segments = 16 # in logfile segments, min 1, 16MB each +#checkpoint_timeout = 300 # 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 + + +From pgsql-jdbc-owner@postgresql.org Wed Aug 17 06:31:12 2005 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D3EB52A43; + Wed, 17 Aug 2005 06:30:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20237-07; Wed, 17 Aug 2005 09:30:53 +0000 (GMT) +Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) + by svr1.postgresql.org (Postfix) with ESMTP id D0C8E529E6; + Wed, 17 Aug 2005 06:30:51 -0300 (ADT) +Received: from [192.168.1.110] (unknown [192.168.1.110]) + by mail.ecircle.de (READY) with ESMTP id CE0FF120567; + Wed, 17 Aug 2005 11:30:51 +0200 (CEST) +Subject: Re: Performance problem using V3 protocol in jdbc driver +From: Csaba Nagy +To: Barry Lind +Cc: pgsql-performance@postgresql.org, + Postgres JDBC +In-Reply-To: + <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> +References: + <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> +Content-Type: text/plain; charset=UTF-8 +Message-Id: <1124271051.24337.56.camel@coppola.muc.ecircle.de> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 17 Aug 2005 11:30:51 +0200 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 required=5 tests=[AWL=0.011] +X-Spam-Level: +X-Archive-Number: 200508/111 +X-Sequence-Number: 13680 + +Barry, + +I have made a similar experience, moving a big Oracle data base to +Postgres 8.03 on linux. +The first impact was similar, huge performance problems. +The main problem was bad planner choices. The cause in our case: bad +parameter types in the jdbc set methods (I guess you use Java). For +oracle we used the NUMERIC type to set primary keys, but the postgres id +type used was BIGINT, and it just refused to use the index in this case. +Imagine that kicking in on a 100 million rows table... a sequential scan +started a few times a second, now that made the DB unusable. +So we fixed the code that for oracle continues to use NUMERIC and for +postgres it uses BIGINT, and that is very important on setNull calls +too. + +One very useful tool was the following query: + +prepare ps as +SELECT procpid, substring(current_query for 97), +to_char((now()-query_start), 'HH24:MI:SS') as t +FROM pg_stat_activity +where current_query not like '% We just moved a large production instance of ours from Oracle to +> Postgres 8.0.3 on linux. When running on Oracle the machine hummed +> along using about 5% of the CPU easily handling the fairly constant +> load, after moving the data to Postgres the machine was pretty much +> maxed out on CPU and could no longer keep up with the transaction +> volume. On a hunch I switched the jdbc driver to using the V2 +> protocol and the load on the machine dropped down to what it was when +> using Oracle and everything was fine. +> +> +> +> Now obviously I have found a work around for the performance problem, +> but I really don’t want to rely on using the V2 protocol forever, and +> don’t want to have to recommend to our customers that they need to run +> with the V2 protocol. So I would like to resolve the problem and be +> able to move back to a default configuration with the V3 protocol and +> the benefits thereof. +> +> +> +> The problem is that I don’t really know where to begin to debug a +> problem like this. In development environments and testing +> environments we have not seen performance problems with the V3 +> protocol in the jdbc driver. But they don’t come close to approaching +> the transaction volume of this production instance. +> +> +> +> What I see when running the V3 protocol under ‘top’ is that the +> postgres processes are routinely using 15% or more of the CPU each, +> when running the V2 protocol they use more like 0.3%. +> +> +> +> Does anyone have any suggestions on an approach to debug a problem +> like this? +> +> +> +> Thanks, +> +> --Barry +> +> + + +From pgsql-jdbc-owner@postgresql.org Wed Aug 17 06:48:35 2005 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6490552956; + Wed, 17 Aug 2005 06:48:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24053-07; Wed, 17 Aug 2005 09:48:30 +0000 (GMT) +Received: from smtp.bizmail.net4india.com (smtp.bizmail.net4india.com + [202.71.129.102]) + by svr1.postgresql.org (Postfix) with ESMTP id 43A6C528F0; + Wed, 17 Aug 2005 06:48:26 -0300 (ADT) +Received: from [61.11.17.20] (helo=devp20) + by smtp.bizmail.net4india.com with smtp (Exim 3.36 #2) + id 1E5KbJ-0000Y3-00; Wed, 17 Aug 2005 15:22:50 +0530 +Message-ID: <009501c5a311$3706ef20$dd0aa8c0@codecindia.com> +From: "Mahesh Shinde" +To: +Cc: +Subject: Data Selection Slow From VB 6.0 +Date: Wed, 17 Aug 2005 02:50:45 -0700 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0092_01C5A2D6.771DF440" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 required=5 tests=[AWL=0.020, HTML_60_70=0.027, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/112 +X-Sequence-Number: 13681 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0092_01C5A2D6.771DF440 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi + I am using Postgres version=20 + *PostgreSQL 7.4.5 on i686-pc-linux-gnu, compiled by GCC gcc = +(GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5).*=20 + for an multy user desktop application using VB 6.0 as a front = +end toll. + + To connect To the PostgreSQL I am using *PostgreSQL Win32 ODBC and = +OLEDB client drivers 1.0.0.2*=20 + + The files included are=20 + Version 1.0 of the PGW32CLI Installer will install the following = +file versions. Files are installed in a separate PGW32CLI directory so = +should not conflict with existing applications. + libpq.dll 8.0.2.5098 (PostgreSQL library) + libintl-2.dll 0.11.5.1189 (GNU Text Utils) + libiconv-2.dll 1.8.1134.7927 (GNU Text Utils) + psqlodbc.dll 8.0.0.4 (PG ODBC) + pgoledb.dll 1.0.0.19 (PgOleDB) + libeay32.dll 0.9.7.f (OpenSSL) + ssleay32.dll 0.9.7.f (OpenSSL) + =20 +I have server configuration as=20 + P4 3 GHz HT Tech + 2 GB DDR RAM, + Intel Original 875 Chipset Motherboard, + 73 GB 10 K RPM SCSI HDD x 2 Nos. + Adp SCSI Controller, (You can do software RAID on it) + Server Class Cabinet + =20 + Since in the database I have one Major table that Debtor table which = +is master table and having around 55 lac records. I have set debtorId as = +a primary key having index on it.I am developing a search screen to = +search a specific debtor info using this table.=20 + +When I fire a query to search a debtor id, it took around 5 seconds to = +return an answer for a query whether entered debtor id is present in the = +database or not using ODBC. Where as when Explian the query on the = +database=20 + Index Scan using tbmstban_debtorid on tbmstbandetails = +(cost=3D0.00..6.01 rows=3D2 width=3D143) + Index Cond: ((debtorid)::text =3D '234'::text) + +Query for the search criteria is=20 + select * from tbmstdebtordetails where debtorid =3D'234'=20 + + Where as when I am using a like query to search a record starting with = +debtor id having a characters then it took around 10-15 sec to return a = +record set having records. +query is=20 +select * from tbmstdebtordetails where debtorid like '234%'=20 + +Explain output on the database + Index Scan using tbmstban_debtorid on tbmstbandetails = +(cost=3D0.00..6.01 rows=3D2 width=3D143) + Index Cond: ((debtorid)::text =3D '234%'::text) +Thanks & regards, +Mahesh Shinde +------------------------------------------------------------------ +Codec Communications (I) Pvt. Ltd. +PUNE (INDIA) +T # 91-20-24221460/70(Ext 43) +Desk No. 25143 +Email - mahesh.shinde@codecindia.com +------=_NextPart_000_0092_01C5A2D6.771DF440 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
Hi
+
    I am using Postgres = +version=20 +
+
       =20 +*PostgreSQL 7.4.5 on i686-pc-linux-gnu, compiled by GCC gcc = +(GCC) 3.2.2=20 +20030222 (Red Hat Linux 3.2.2-5).*
+
        = +for an multy=20 +user desktop application using VB 6.0 as a = +front end=20 +toll.
+
 
+
    To connect To the PostgreSQL I am using = +*PostgreSQL Win32=20 +ODBC and OLEDB client drivers 1.0.0.2*
+
 
+
    The files included = +are=20 +
+
    = +   =20 +Version 1.0 of the PGW32CLI Installer will install the following file = +versions.=20 +Files are installed in a separate PGW32CLI directory so should not = +conflict with=20 +existing            =20 +applications.
+
    = +   =20 +    libpq.dll 8.0.2.5098 = +(PostgreSQL=20 +library)
            = +libintl-2.dll=20 +0.11.5.1189 (GNU Text Utils)
            = +libiconv-2.dll=20 +1.8.1134.7927 (GNU Text Utils)
            = +psqlodbc.dll=20 +8.0.0.4 (PG ODBC)
            = +pgoledb.dll=20 +1.0.0.19 (PgOleDB)
            = +libeay32.dll=20 +0.9.7.f (OpenSSL)
            = +ssleay32.dll=20 +0.9.7.f (OpenSSL)
+
   =20 +
+
I have server configuration as = +
+
+
    = +   =20 +    P4 3 GHz HT = +Tech
+
   =20 +        2 GB DDR RAM,
+
   =20 +        Intel Original 875 Chipset=20 +Motherboard,
+
   =20 +        73 GB  10 K RPM SCSI HDD = +x =20 +2 Nos.
+
   =20 +        Adp SCSI Controller, (You can do = +software=20 +RAID on it)
+
   =20 +        Server Class = +Cabinet
+
   =20 +
+
    = +Since in the=20 +database I have one Major table that Debtor table which is master table = +and=20 +having around 55 lac records. I have set debtorId as a primary key = +having index=20 +on it.I am developing a search screen to search a specific debtor=20 +info using this table.
+
 
+
When I fire a query to = +search a=20 +debtor id,  it took around 5 seconds to return an answer for a = +query=20 +whether entered debtor id is present in the database or not using ODBC. = +Where as=20 +when Explian  the query on the database
+
 Index Scan using=20 +tbmstban_debtorid on tbmstbandetails  (cost=3D0.00..6.01 rows=3D2=20 +width=3D143)
   Index Cond: ((debtorid)::text =3D=20 +'234'::text)

Query for the=20 +search criteria is
+
+
 select * from = +tbmstdebtordetails=20 +where debtorid =3D'234'
+
 
+
 Where as when I = +am using a like=20 +query to search a record starting with debtor id having a characters = +then it=20 +took around 10-15 sec to return a record set having = +records.
+
query is 
+
select * from = +tbmstdebtordetails where=20 +debtorid like '234%'
+
 
+
Explain output on the = +database
+
 Index Scan=20 +using tbmstban_debtorid on tbmstbandetails  (cost=3D0.00..6.01 = +rows=3D2=20 +width=3D143)
   Index Cond: ((debtorid)::text =3D=20 +'234%'::text)
+
Thanks & regards,
Mahesh=20 +Shinde
---------------------------------------------------------------= +---
Codec=20 +Communications (I) Pvt. Ltd.
PUNE (INDIA)
T # = +91-20-24221460/70(Ext=20 +43)
Desk No. 25143
Email =96 mahesh.shinde@codecindia.com= +
+ +------=_NextPart_000_0092_01C5A2D6.771DF440-- + + +From pgsql-performance-owner@postgresql.org Wed Aug 17 07:29:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E6AEA52917 + for ; + Wed, 17 Aug 2005 07:29:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34451-06 + for ; + Wed, 17 Aug 2005 10:29:03 +0000 (GMT) +Received: from my.endian.it (unknown [62.146.87.34]) + by svr1.postgresql.org (Postfix) with ESMTP id F1989528F0 + for ; + Wed, 17 Aug 2005 07:29:00 -0300 (ADT) +Received: from dell.1006.org (host58-128.pool8251.interbusiness.it + [82.51.128.58]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id j7HAKZx06697; + Wed, 17 Aug 2005 12:20:35 +0200 +Subject: Re: Data Selection Slow From VB 6.0 +From: Chris Mair +To: Mahesh Shinde +Cc: pgsql-performance@postgresql.org +In-Reply-To: <009501c5a311$3706ef20$dd0aa8c0@codecindia.com> +References: <009501c5a311$3706ef20$dd0aa8c0@codecindia.com> +Content-Type: text/plain +Date: Wed, 17 Aug 2005 12:28:16 +0200 +Message-Id: <1124274496.2651.9.camel@dell.1006.org> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/202 +X-Sequence-Number: 13949 + + + +> When I fire a query to search a debtor id, it took around 5 seconds +> to return an answer for a query [...] + +Are you sure that time is actually spent in the database engine? +Maybe there are DNS resolving issues or something... + +Did you try to execute the queries directly on the server from +the psql shell? + +Bye, Chris. + + +> + + +From pgsql-jdbc-owner@postgresql.org Wed Aug 17 09:29:25 2005 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 443915288A; + Wed, 17 Aug 2005 09:29:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74393-04; Wed, 17 Aug 2005 12:29:14 +0000 (GMT) +Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) + by svr1.postgresql.org (Postfix) with ESMTP id B827B528B7; + Wed, 17 Aug 2005 09:29:09 -0300 (ADT) +Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] + helo=[192.168.0.21]) + by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) + (Exim 4.34) id 1E5N2e-0005ds-Lv; Thu, 18 Aug 2005 00:29:12 +1200 +Message-ID: <43032D99.9050606@opencloud.com> +Date: Wed, 17 Aug 2005 12:29:13 +0000 +From: Oliver Jowett +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mahesh Shinde +Cc: pgsql-performance@postgresql.org, pgsql-jdbc@postgresql.org +Subject: Re: Data Selection Slow From VB 6.0 +References: <009501c5a311$3706ef20$dd0aa8c0@codecindia.com> +In-Reply-To: <009501c5a311$3706ef20$dd0aa8c0@codecindia.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 required=5 tests=[AWL=0.009] +X-Spam-Level: +X-Archive-Number: 200508/113 +X-Sequence-Number: 13682 + +Mahesh Shinde wrote: +> Hi +> I am using Postgres version +> **PostgreSQL 7.4.5 on i686-pc-linux-gnu, compiled by GCC gcc +> (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5).* * +> for an multy user desktop application using VB 6.0 as a front +> end toll. +> +> To connect To the PostgreSQL I am using **PostgreSQL Win32 ODBC and +> OLEDB client drivers 1.0.0.2** + +pgsql-jdbc isn't relevant, then -- the JDBC driver is not involved. + +-O + +From pgsql-jdbc-owner@postgresql.org Wed Aug 17 10:00:20 2005 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DA06529DA + for ; + Wed, 17 Aug 2005 09:59:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76722-10 + for ; + Wed, 17 Aug 2005 12:59:30 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 1F1F3528DB + for ; Wed, 17 Aug 2005 09:59:28 -0300 (ADT) +Received: (qmail 9823 invoked from network); 17 Aug 2005 12:59:32 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 17 Aug 2005 12:59:32 -0000 +In-Reply-To: + <03E7D3E231BB7B4A915A6581D4296CC6015D5352@NSNOVPS00411.nacio.xythos.com> +References: + <03E7D3E231BB7B4A915A6581D4296CC6015D5352@NSNOVPS00411.nacio.xythos.com> +Mime-Version: 1.0 (Apple Message framework v733) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <76FC392F-3B3D-409E-A790-1D15B784C03E@fastcrypt.com> +Cc: "Tom Lane" , + , +Content-Transfer-Encoding: 7bit +From: Dave Cramer +Subject: Re: [PERFORM] Performance problem using V3 protocol in jdbc driver +Date: Wed, 17 Aug 2005 08:59:30 -0400 +To: Barry Lind +X-Mailer: Apple Mail (2.733) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 required=5 tests=[AWL=0.013] +X-Spam-Level: +X-Archive-Number: 200508/114 +X-Sequence-Number: 13683 + +Barry, + + +One way to do this is to turn logging on for calls over a certain +duration + + +log_duration in the config file. This will only log calls over n +milliseconds. + +There's a tool called iron eye SQL that monitors JDBC calls. + +http://www.irongrid.com/ + +unfortunately I am getting DNS errors from that site right now. I do +have a copy of their code if you need it. + +Dave + +On 17-Aug-05, at 1:43 AM, Barry Lind wrote: + +> That was my suspicion as well, which is why I tried the V2 protocol. +> +> I do not know of any specific queries that are causing the +> problem. As +> I monitor 'top' I see processes utilizing a significant amount of CPU +> running SELECT, UPDATE and DELETE, which would lead me to believe that +> it isn't any one specific query. +> +> How does one identify on a live system specific queries that are +> running +> slow, especially with the V3 protocol and when the system is executing +> about a 100 queries a second (which makes turning on any sort of +> logging +> very very verbose)? (I just subscribed to the performance list, so +> this +> is probably something that has been answered many times before on this +> list). +> +> I haven't tried to track down a performance problem like this +> before on +> postgres. Since most of our large customers run Oracle that is +> where I +> have the knowledge to figure something like this out. +> +> Thanks, +> --Barry +> +> +> -----Original Message----- +> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +> Sent: Tuesday, August 16, 2005 10:02 PM +> To: Barry Lind +> Cc: pgsql-performance@postgresql.org; pgsql-jdbc@postgresql.org +> Subject: Re: [JDBC] Performance problem using V3 protocol in jdbc +> driver +> +> +> "Barry Lind" writes: +> +>> ... On a hunch I switched the jdbc driver to using the V2 protocol +>> and the load on the machine dropped down to what it was when using +>> Oracle and everything was fine. +>> +> +> First knee-jerk reaction is that it's an optimization problem stemming +> from V3 protocol feeding parameterized queries to the backend where V2 +> did not, and the planner being unable to cope :-( +> +> Can you identify the specific queries causing the problem? +> +> regards, tom lane +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> +> + + +From pgsql-performance-owner@postgresql.org Wed Aug 17 11:52:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A783152938 + for ; + Wed, 17 Aug 2005 11:52:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15317-02 + for ; + Wed, 17 Aug 2005 14:52:45 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AEEB6528E6 + for ; + Wed, 17 Aug 2005 11:52:44 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7HEqmF4018976; + Wed, 17 Aug 2005 10:52:49 -0400 (EDT) +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org +Subject: Re: Need for speed +In-reply-to: <4303003B.3020407@relevanttraffic.se> +References: + <4303003B.3020407@relevanttraffic.se> +Comments: In-reply-to Ulrich Wisser + message dated "Wed, 17 Aug 2005 11:15:39 +0200" +Date: Wed, 17 Aug 2005 10:52:48 -0400 +Message-ID: <18975.1124290368@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/204 +X-Sequence-Number: 13951 + +Ulrich Wisser writes: +> My machine has 2GB memory, please find postgresql.conf below. + +> max_fsm_pages = 50000 # min max_fsm_relations*16, 6 bytes each + +FWIW, that index I've been groveling through in connection with your +other problem contains an astonishingly large amount of dead space --- +almost 50%. I suspect that you need a much larger max_fsm_pages +setting, and possibly more-frequent vacuuming, in order to keep a lid +on the amount of wasted space. + + regards, tom lane + +From pgsql-jdbc-owner@postgresql.org Wed Aug 17 12:27:20 2005 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A4FFF529AA; + Wed, 17 Aug 2005 12:18:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21041-05; Wed, 17 Aug 2005 15:18:56 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id BD111529D6; + Wed, 17 Aug 2005 12:18:54 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050817151852m92009ic8le>; Wed, 17 Aug 2005 15:18:52 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 0484255FBA; Wed, 17 Aug 2005 10:18:52 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id E303555FAD; + Wed, 17 Aug 2005 10:18:37 -0500 (CDT) +Message-ID: <4303554B.2020500@arbash-meinel.com> +Date: Wed, 17 Aug 2005 10:18:35 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mahesh Shinde +Cc: pgsql-performance@postgresql.org, pgsql-jdbc@postgresql.org +Subject: Re: [PERFORM] Data Selection Slow From VB 6.0 +References: <009501c5a311$3706ef20$dd0aa8c0@codecindia.com> +In-Reply-To: <009501c5a311$3706ef20$dd0aa8c0@codecindia.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig620020274E7B6ABB6664657C" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/115 +X-Sequence-Number: 13684 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig620020274E7B6ABB6664657C +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +Mahesh Shinde wrote: +> Hi +=2E.. + +> To connect To the PostgreSQL I am using **PostgreSQL Win32 ODBC and= + +> OLEDB client drivers 1.0.0.2** +> =20 + +=2E.. + +> Since in the database I have one Major table that Debtor table whic= +h +> is master table and having around 55 lac records. I have set debtorId a= +s +> a primary key having index on it.I am developing a search screen to +> search a specific debtor info using this table. +> =20 +> When I fire a query to search a debtor id, it took around 5 seconds to= + +> return an answer for a query whether entered debtor id is present in th= +e +> database or not using ODBC. Where as when Explian the query on the +> database +> Index Scan using tbmstban_debtorid on tbmstbandetails (cost=3D0.00..6= +=2E01 +> rows=3D2 width=3D143) +> Index Cond: ((debtorid)::text =3D '234'::text) + +Are you checking this from the VB App? Or just going onto the server and +running psql? (I'm guessing there is some way to run a flat query using +VB. In which case you can just have the query run EXPLAIN ANALYZE, the +return value is just the text, one line after another.) + +What I'm thinking is that it might be a locale/encoding issue. +What is the encoding of your database? And what is the default locale +and the locale that you are connecting as? + +Can you give us the "EXPLAIN ANALYZE" output so that we can see if the +planner is doing what it thinks it is? + +It certainly sounds like either it is always doing a sequential scan, or +something else is going on. 5 sec is a really long time for the type of +query you are doing. + +Oh, and can you run the win32 psql client to see if it might be ODBC +which is causing the problem? + +John +=3D:-> + + +>=20 +> Query for the search criteria is +> *select * from tbmstdebtordetails where debtorid =3D'234'* +> =20 +> Where as when I am using a like query to search a record starting with= + +> debtor id having a characters then it took around 10-15 sec to return a= + +> record set having records. +> query is=20 +> *select * from tbmstdebtordetails where debtorid like '234%'* +> =20 +> Explain output on the database +> Index Scan using tbmstban_debtorid on tbmstbandetails (cost=3D0.00..6= +=2E01 +> rows=3D2 width=3D143) +> Index Cond: ((debtorid)::text =3D '234%'::text) +> Thanks & regards, +> Mahesh Shinde +> ------------------------------------------------------------------ +> Codec Communications (I) Pvt. Ltd. +> PUNE (INDIA) +> T # 91-20-24221460/70(Ext 43) +> Desk No. 25143 +> Email =E2=80=93 mahesh.shinde@codecindia.com + + + +--------------enig620020274E7B6ABB6664657C +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDA1VLJdeBCYSNAAMRAswzAKCd7lERmivZb8CinkVh8ognvDjoqACdETdw +EY5dlmeNaDewSiibDeK+vFQ= +=hTR3 +-----END PGP SIGNATURE----- + +--------------enig620020274E7B6ABB6664657C-- + +From pgsql-performance-owner@postgresql.org Wed Aug 17 13:50:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B21E528DA + for ; + Wed, 17 Aug 2005 13:49:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52195-05 + for ; + Wed, 17 Aug 2005 16:49:34 +0000 (GMT) +Received: from mail24.sea5.speakeasy.net (mail24.sea5.speakeasy.net + [69.17.117.26]) + by svr1.postgresql.org (Postfix) with ESMTP id 227385288A + for ; + Wed, 17 Aug 2005 13:49:33 -0300 (ADT) +Received: (qmail 27532 invoked from network); 17 Aug 2005 16:49:33 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail24.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP + for ; 17 Aug 2005 16:49:33 -0000 +Subject: Re: Need for speed +From: "Jeffrey W. Baker" +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4303003B.3020407@relevanttraffic.se> +References: + <4303003B.3020407@relevanttraffic.se> +Content-Type: text/plain +Date: Wed, 17 Aug 2005 09:49:37 -0700 +Message-Id: <1124297377.423.2.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/206 +X-Sequence-Number: 13953 + +On Wed, 2005-08-17 at 11:15 +0200, Ulrich Wisser wrote: +> Hello, +> +> thanks for all your suggestions. +> +> I can see that the Linux system is 90% waiting for disc io. At that time +> all my queries are *very* slow. My scsi raid controller and disc are +> already the fastest available. + +What RAID controller? Initially you said you have only 2 disks, and +since you have your xlog on a separate spindle, I assume you have 1 disk +for the xlog and 1 for the data. Even so, if you have a RAID, I'm going +to further assume you are using RAID 1, since no sane person would use +RAID 0. In those cases you are getting the performance of a single +disk, which is never going to be very impressive. You need a RAID. + +Please be more precise when describing your system to this list. + +-jwb + + +From pgsql-performance-owner@postgresql.org Wed Aug 17 14:53:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EDB1C5288A + for ; + Wed, 17 Aug 2005 14:14:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54975-07 + for ; + Wed, 17 Aug 2005 17:14:32 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.197]) + by svr1.postgresql.org (Postfix) with ESMTP id 225325284B + for ; + Wed, 17 Aug 2005 14:14:30 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 8so143042nzo + for ; + Wed, 17 Aug 2005 10:14:30 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=le9asLzXXz7zEFvtRk44EHzPLW2cgBQvgngZgJxQ2X6HCLnEu/QzoH0orrM/3Tuq4kbKhtbibPWp6aSIh+YU3XLmI2xlguh1hvSiFrOah2RscgP1yPyR2KyPj2LWNOcRKjGX7rmo+Xvgr1F1acYF9t76rJiJ+hvu7C71w/lyp88= +Received: by 10.36.215.10 with SMTP id n10mr661285nzg; + Wed, 17 Aug 2005 10:14:30 -0700 (PDT) +Received: by 10.36.24.2 with HTTP; Wed, 17 Aug 2005 10:14:29 -0700 (PDT) +Message-ID: <1d219a6f05081710146acb9d40@mail.gmail.com> +Date: Wed, 17 Aug 2005 13:14:29 -0400 +From: Chris Hoover +To: pgsql-performance@postgresql.org +Subject: Tuning Effective Cache Question +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[AWL=-0.000, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/209 +X-Sequence-Number: 13956 + +I have some questions about tuning my effective_cache_size + +I have a RHEL 2.1 box running with dual Xeon (2.6 GHz I believe and +they have HT on). The box has 8GB memory. In my postgresql.conf, I +have set the effective_cache_size =3D 530505 (~4GB). + +However, I am noticing on this machine, top is telling me that I have +~3.5GB in the buff and only 3GB in cached. + +Here are the exact numbers: +Mem: 7720040K av, 7714364K used, 5676K free, 314816K shrd, 3737540K bu= +ff +Swap: 2096440K av, 119448K used, 1976992K free 3188192K ca= +ched + + +1. Is the configuration that linux is running in hurting PostgreSQL in any= + way? + +2. Is there a negative impact of the effective_cache_size being +larger than the actual cached memory? + +3. What effect postive or negative does the buff memory have on PostgreSQL= +.\ + +4. What exactly is this buff memory used for? We have had a time +trying to find a good explanation of what it means. + +Overall, this system appears to be running fine. However, I was taken +back when I saw the current memory configuration. We have been +walking a fine line performance wise, and can quickly become i/o +starved. So I want to make sure that I am not pushing the db towards +the i/o starved side. + +Thanks for any insight, + +Chris + +From pgsql-performance-owner@postgresql.org Wed Aug 17 14:52:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E51FA5288A + for ; + Wed, 17 Aug 2005 14:17:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60870-01 + for ; + Wed, 17 Aug 2005 17:17:35 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 55B5A52BD7 + for ; + Wed, 17 Aug 2005 14:17:34 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 8so143435nzo + for ; + Wed, 17 Aug 2005 10:17:34 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=biNdqOqNLbMTnuoY+edDq6gJ8kgNC++vypfQ1YlVt/c+URjP5uqdlLDeMfKRxy1D8iVfvgLK9dEs8fKv64b51ABxNMplkhGVhFDNXxn2e2w0eqPdU1Sk3vWNUyhlg44AJGMXvkThwX55ZzPf+63u2iBOH812gSMkTdby8g9ak0w= +Received: by 10.36.9.2 with SMTP id 2mr657392nzi; + Wed, 17 Aug 2005 10:17:34 -0700 (PDT) +Received: by 10.36.24.2 with HTTP; Wed, 17 Aug 2005 10:17:33 -0700 (PDT) +Message-ID: <1d219a6f050817101729be31a0@mail.gmail.com> +Date: Wed, 17 Aug 2005 13:17:33 -0400 +From: Chris Hoover +To: pgsql-performance@postgresql.org +Subject: Re: Tuning Effective Cache Question +In-Reply-To: <1d219a6f05081710146acb9d40@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <1d219a6f05081710146acb9d40@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/208 +X-Sequence-Number: 13955 + +Sorry, forgot to state that we are still on PG 7.3.4. + +On 8/17/05, Chris Hoover wrote: +> I have some questions about tuning my effective_cache_size +>=20 +> I have a RHEL 2.1 box running with dual Xeon (2.6 GHz I believe and +> they have HT on). The box has 8GB memory. In my postgresql.conf, I +> have set the effective_cache_size =3D 530505 (~4GB). +>=20 +> However, I am noticing on this machine, top is telling me that I have +> ~3.5GB in the buff and only 3GB in cached. +>=20 +> Here are the exact numbers: +> Mem: 7720040K av, 7714364K used, 5676K free, 314816K shrd, 3737540K = +buff +> Swap: 2096440K av, 119448K used, 1976992K free 3188192K = +cached +>=20 +>=20 +> 1. Is the configuration that linux is running in hurting PostgreSQL in a= +ny way? +>=20 +> 2. Is there a negative impact of the effective_cache_size being +> larger than the actual cached memory? +>=20 +> 3. What effect postive or negative does the buff memory have on PostgreS= +QL.\ +>=20 +> 4. What exactly is this buff memory used for? We have had a time +> trying to find a good explanation of what it means. +>=20 +> Overall, this system appears to be running fine. However, I was taken +> back when I saw the current memory configuration. We have been +> walking a fine line performance wise, and can quickly become i/o +> starved. So I want to make sure that I am not pushing the db towards +> the i/o starved side. +>=20 +> Thanks for any insight, +>=20 +> Chris +> + +From pgsql-performance-owner@postgresql.org Wed Aug 17 14:31:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E39152BDF + for ; + Wed, 17 Aug 2005 14:27:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62916-03 + for ; + Wed, 17 Aug 2005 17:27:05 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 8599752C09 + for ; + Wed, 17 Aug 2005 14:27:02 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7742017; Wed, 17 Aug 2005 10:29:18 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Need for speed +Date: Wed, 17 Aug 2005 10:28:04 -0700 +User-Agent: KMail/1.8 +Cc: Ulrich Wisser +References: + <4303003B.3020407@relevanttraffic.se> +In-Reply-To: <4303003B.3020407@relevanttraffic.se> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508171028.05028.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] +X-Spam-Level: +X-Archive-Number: 200508/207 +X-Sequence-Number: 13954 + +Ulrich, + +> I believe the biggest problem is disc io. Reports for very recent data +> are quite fast, these are used very often and therefor already in the +> cache. But reports can contain (and regulary do) very old data. In that +> case the whole system slows down. To me this sounds like the recent data +> is flushed out of the cache and now all data for all queries has to be +> fetched from disc. + +How large is the database on disk? + +> My machine has 2GB memory, please find postgresql.conf below. + +hmmmm ... +effective_cache_size? +random_page_cost? +cpu_tuple_cost? +etc. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Aug 17 15:37:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CC5EC528CD + for ; + Wed, 17 Aug 2005 15:00:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74095-04 + for ; + Wed, 17 Aug 2005 18:00:48 +0000 (GMT) +Received: from smtpauth01.mail.atl.earthlink.net + (smtpauth01.mail.atl.earthlink.net [209.86.89.61]) + by svr1.postgresql.org (Postfix) with ESMTP id CE74A528BB + for ; + Wed, 17 Aug 2005 15:00:47 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=WE8seZa9OEPVkg00hy6KujpVn4H4sMJhsIwypfw+53FFOFucg3IScwEl0xKexqsZ; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E5SDX-00020O-0I; Wed, 17 Aug 2005 14:00:47 -0400 +Message-Id: <6.2.3.4.0.20050817130842.05d31a40@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Wed, 17 Aug 2005 14:00:14 -0400 +To: Ulrich Wisser , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: Need for speed +In-Reply-To: <4303003B.3020407@relevanttraffic.se> +References: + <4303003B.3020407@relevanttraffic.se> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcb2c633390d1eadcf586367faf0372854350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.484 required=5 tests=[AWL=-1.298, BUY_DIRECT=1.779, + DNS_FROM_RFC_ABUSE=0.374, URIBL_SBL=0.629] +X-Spam-Level: * +X-Archive-Number: 200508/210 +X-Sequence-Number: 13957 + +At 05:15 AM 8/17/2005, Ulrich Wisser wrote: +>Hello, +> +>thanks for all your suggestions. +> +>I can see that the Linux system is 90% waiting for disc io. + +A clear indication that you need to improve your HD IO subsystem. + +>At that time all my queries are *very* slow. + +To be more precise, your server performance at that point is +essentially equal to your HD IO subsystem performance. + + +> My scsi raid controller and disc are already the fastest available. + +Oh, REALLY? This is the description of the system you gave us: + +"We have a box with +Linux Fedora Core 3, Postgres 7.4.2 +Intel(R) Pentium(R) 4 CPU 2.40GHz +2 scsi 76GB disks (15.000RPM, 2ms)" + +The is far, Far, FAR from the "the fastest available" in terms of SW, +OS, CPU host, _or_ HD subsystem. + +The "fastest available" means +1= you should be running 8.0.3 +2= you should be running the latest stable 2.6 based kernel +3= you should be running an Opteron based server +4= Fibre Channel HDs are higher performance than SCSI ones. +5= (and this is the big one) YOU NEED MORE SPINDLES AND A HIGHER END +RAID CONTROLLER. + +The absolute "top of the line" for RAID controllers is something +based on Fibre Channel from Xyratex (who make the RAID engines for +EMC and NetApps), Engino (the enterprise division of LSI Logic who +sell mostly to IBM. Apple has a server based on an Engino card), +dot-hill (who bought Chaparral among others). I suspect you can't +afford them even if they would do business with you. The ante for a +FC-based RAID subsystem in this class is in the ~$32K to ~$128K +range, even if you buy direct from the actual RAID HW manufacturer +rather than an OEM like + +In the retail commodity market, the current best RAID controllers are +probably the 16 and 24 port versions of the Areca cards ( +www.areca.us ). They come darn close to saturating the the Real +World Peak Bandwidth of a 64b 133MHz PCI-X bus. + +I did put pg_xlog on another file system on other discs. + +> The query plan uses indexes and "vacuum analyze" is run once a day. + +That + + +>To avoid aggregating to many rows, I already made some aggregation +>tables which will be updated after the import from the Apache +>logfiles. That did help, but only to a certain level. +> +>I believe the biggest problem is disc io. Reports for very recent +>data are quite fast, these are used very often and therefor already +>in the cache. But reports can contain (and regulary do) very old +>data. In that case the whole system slows down. To me this sounds +>like the recent data is flushed out of the cache and now all data +>for all queries has to be fetched from disc. +> +>My machine has 2GB memory, + + + + +From pgsql-performance-owner@postgresql.org Wed Aug 17 16:42:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB0B352968 + for ; + Wed, 17 Aug 2005 15:36:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83253-05 + for ; + Wed, 17 Aug 2005 18:36:51 +0000 (GMT) +Received: from smtpauth07.mail.atl.earthlink.net + (smtpauth07.mail.atl.earthlink.net [209.86.89.67]) + by svr1.postgresql.org (Postfix) with ESMTP id DA86252ABF + for ; + Wed, 17 Aug 2005 15:36:50 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=Emjj+fu/ul/LU/IpUZ9l9asLa9VX5Wq6zPi3KrFaG1aE47o5TPqV/xrqdgxhAtbb; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth07.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E5SmN-0005rx-LQ; Wed, 17 Aug 2005 14:36:47 -0400 +Message-Id: <6.2.3.4.0.20050817140116.05d317b0@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Wed, 17 Aug 2005 14:33:20 -0400 +To: Ulrich Wisser , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: Need for speed +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc9ef602ea55fa4e9e544bee205330bd47350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.917 required=5 tests=[AWL=-0.865, BUY_DIRECT=1.779, + DNS_FROM_RFC_ABUSE=0.374, URIBL_SBL=0.629] +X-Spam-Level: * +X-Archive-Number: 200508/211 +X-Sequence-Number: 13958 + +At 05:15 AM 8/17/2005, Ulrich Wisser wrote: +>Hello, +> +>thanks for all your suggestions. +> +>I can see that the Linux system is 90% waiting for disc io. + +A clear indication that you need to improve your HD IO subsystem if possible. + + +>At that time all my queries are *very* slow. + +To be more precise, your server performance at that point is +essentially equal to your HD IO subsystem performance. + + +> My scsi raid controller and disc are already the fastest available. + +Oh, REALLY? This is the description of the system you gave us: + +"We have a box with +Linux Fedora Core 3, Postgres 7.4.2 +Intel(R) Pentium(R) 4 CPU 2.40GHz +2 scsi 76GB disks (15.000RPM, 2ms)" + + +The is far, Far, FAR from the "the fastest available" in terms of SW, +OS, CPU host, _or_ HD subsystem. + +The "fastest available" means +1= you should be running PostgreSQL 8.0.3 +2= you should be running the latest stable 2.6 based kernel +3= you should be running an Opteron based server +4= Fibre Channel HDs are slightly higher performance than SCSI ones. +5= (and this is the big one) YOU NEED MORE SPINDLES AND A HIGHER END +RAID CONTROLLER. + +Your description of you workload was: +"one of our services is click counting for on line advertising. We do +this by importing Apache log files every five minutes. This results +in a lot of insert and delete statements. At the same time our +customers shall be able to do on line reporting." + +There are two issues here: +1= your primary usage is OLTP-like, but you are also expecting to do +reports against the same schema that is supporting your OLTP-like +usage. Bad Idea. Schemas that are optimized for reporting and other +data mining like operation are pessimal for OLTP-like applications +and vice versa. You need two schemas: one optimized for lots of +inserts and deletes (OLTP-like), and one optimized for reporting +(data-mining like). + +2= 2 spindles, even 15K rpm spindles, is minuscule. Real enterprise +class RAID subsystems have at least 10-20x that many spindles, +usually split into 6-12 sets dedicated to different groups of tables +in the DB. Putting xlog on its own dedicated spindles is just the +first step. + +The absolute "top of the line" for RAID controllers is something +based on Fibre Channel from Xyratex (who make the RAID engines for +EMC and NetApps), Engino (the enterprise division of LSI Logic who +sell mostly to IBM. Apple has a server based on an Engino card), or +dot-hill (who bought Chaparral among others). I suspect you can't +afford them even if they would do business with you. The ante for a +FC-based RAID subsystem in this class is in the ~$32K to ~$128K +range, even if you buy direct from the actual RAID HW manufacturer +rather than an OEM like EMC, IBM, or NetApp who will 2x or 4x the +price. OTOH, these subsystems will provide OLTP or OLTP-like DB apps +with performance that is head-and-shoulders better than anything else +to be found. Numbers like 50K-200K IOPS. You get what you pay for. + +In the retail commodity market where you are more realistically going +to be buying, the current best RAID controllers are probably the +Areca cards ( www.areca.us ). They come darn close to saturating the +Real World Peak Bandwidth of a 64b 133MHz PCI-X bus and have better +IOPS numbers than their commodity brethren. However, _none_ of the +commodity RAID cards have IOPS numbers anywhere near as high as those +mentioned above. + + +>To avoid aggregating to many rows, I already made some aggregation +>tables which will be updated after the import from the Apache +>logfiles. That did help, but only to a certain level. +> +>I believe the biggest problem is disc io. Reports for very recent +>data are quite fast, these are used very often and therefor already +>in the cache. But reports can contain (and regulary do) very old +>data. In that case the whole system slows down. To me this sounds +>like the recent data is flushed out of the cache and now all data +>for all queries has to be fetched from disc. + +I completely agree. Hopefully my above suggestions make sense and +are of use to you. + + +>My machine has 2GB memory, + +...and while we are at it, OLTP like apps benefit less from RAM than +data mining ones, but still 2GB of RAM is just not that much for a +real DB server... + + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Wed Aug 17 18:57:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DFC485288A + for ; + Wed, 17 Aug 2005 17:25:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39461-01 + for ; + Wed, 17 Aug 2005 20:25:32 +0000 (GMT) +Received: from email.aon.at (warsl404pip7.highway.telekom.at [195.3.96.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 42D47528CD + for ; + Wed, 17 Aug 2005 17:25:30 -0300 (ADT) +Received: (qmail 3258 invoked from network); 17 Aug 2005 20:25:29 -0000 +Received: from m160p019.dipool.highway.telekom.at (HELO fermat.Koizar.inf) + ([62.46.9.243]) (envelope-sender ) + by smarthub73.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 17 Aug 2005 20:25:29 -0000 +From: Manfred Koizar +To: Richard Huxton +Cc: Yves Vindevogel , + 'Postgresql Performance' +Subject: Re: Insert performance (OT?) +Date: Wed, 17 Aug 2005 22:25:09 +0200 +Message-ID: +References: + <42DCCA3B.8070100@archonet.com> + + <42DCDB47.3060009@archonet.com> +In-Reply-To: <42DCDB47.3060009@archonet.com> +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.317 required=5 tests=[AWL=0.060, + FORGED_RCVD_HELO=0.05, UPPERCASE_25_50=0.207] +X-Spam-Level: +X-Archive-Number: 200508/216 +X-Sequence-Number: 13963 + +On Tue, 19 Jul 2005 11:51:51 +0100, Richard Huxton +wrote: +>You could get away with one query if you converted them to left-joins: +>INSERT INTO ... +>SELECT * FROM upload LEFT JOIN ... WHERE f3 IS NULL +>UNION +>SELECT * FROM upload LEFT JOIN ... WHERE f4 IS NULL + +For the archives: This won't work. Each of the two SELECTs +eliminates rows violating one of the two constraints but includes rows +violating the other constraint. After the UNION you are back to +violating both constraints :-( + +Servus + Manfred + + +From pgsql-performance-owner@postgresql.org Wed Aug 17 18:40:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BDDD352802 + for ; + Wed, 17 Aug 2005 17:28:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30915-09 + for ; + Wed, 17 Aug 2005 20:28:31 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id D170E52968 + for ; + Wed, 17 Aug 2005 17:28:30 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7742974; Wed, 17 Aug 2005 13:30:47 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Tuning Effective Cache Question +Date: Wed, 17 Aug 2005 13:31:38 -0700 +User-Agent: KMail/1.8 +Cc: Chris Hoover +References: <1d219a6f05081710146acb9d40@mail.gmail.com> +In-Reply-To: <1d219a6f05081710146acb9d40@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508171331.38980.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.049 required=5 tests=[AWL=-0.001, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/215 +X-Sequence-Number: 13962 + +Chris, + +> I have a RHEL 2.1 box running with dual Xeon (2.6 GHz I believe and +> they have HT on). The box has 8GB memory. In my postgresql.conf, I +> have set the effective_cache_size = 530505 (~4GB). +> +> However, I am noticing on this machine, top is telling me that I have +> ~3.5GB in the buff and only 3GB in cached. + +effective_cache_size is just information for the query planner; it does not +affect the actually system file cache. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Aug 17 18:26:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37CE252AE9 + for ; + Wed, 17 Aug 2005 17:34:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44765-02 + for ; + Wed, 17 Aug 2005 20:33:56 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.198]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FA5052ABD + for ; + Wed, 17 Aug 2005 17:33:50 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i31so37428wxd + for ; + Wed, 17 Aug 2005 13:33:52 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=uFoByAS4pzqfRhu7po/hVPrlklTJx80+Sj8gBZlk5wJlaSHBn5md7AhSyD4SyyvGEKlt5aBn7WkIhsr6Qjnhv1AXRjEZVar707ptdgMEVHdpa+vF6fvwG3Kk2D+8L/kOnfjhRu/tkJQeJwFW6sw8DO1OTX+DszqmFp+KlGeksf0= +Received: by 10.70.73.8 with SMTP id v8mr5591wxa; + Wed, 17 Aug 2005 13:33:52 -0700 (PDT) +Received: by 10.70.128.19 with HTTP; Wed, 17 Aug 2005 13:33:52 -0700 (PDT) +Message-ID: +Date: Wed, 17 Aug 2005 15:33:52 -0500 +From: Matthew Nuzum +Reply-To: newz@bearfruit.org +To: pgsql-performance@postgresql.org +Subject: Re: Need for speed +Cc: Ulrich Wisser +In-Reply-To: <6.2.3.4.0.20050817140116.05d317b0@pop.earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <6.2.3.4.0.20050817140116.05d317b0@pop.earthlink.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/214 +X-Sequence-Number: 13961 + +On 8/17/05, Ron wrote: +> At 05:15 AM 8/17/2005, Ulrich Wisser wrote: +> >Hello, +> > +> >thanks for all your suggestions. +> > +> >I can see that the Linux system is 90% waiting for disc io. +... +> 1=3D your primary usage is OLTP-like, but you are also expecting to do +> reports against the same schema that is supporting your OLTP-like +> usage. Bad Idea. Schemas that are optimized for reporting and other +> data mining like operation are pessimal for OLTP-like applications +> and vice versa. You need two schemas: one optimized for lots of +> inserts and deletes (OLTP-like), and one optimized for reporting +> (data-mining like). + +Ulrich, + +If you meant that your disc/scsi system is already the fastest +available *with your current budget* then following Ron's advise I +quoted above will be a good step. + +I have some systems very similar to yours. What I do is import in +batches and then immediately pre-process the batch data into tables +optimized for quick queries. For example, if your reports frequenly +need to find the total number of views per hour for each customer, +create a table whose data contains just the totals for each customer +for each hour of the day. This will make it a tiny fraction of the +size, allowing it to fit largely in RAM for the query and making the +indexes more efficient. + +This is a tricky job, but if you do it right, your company will be a +big success and buy you more hardware to work with. Of course, they'll +also ask you to create dozens of new reports, but that's par for the +course. + +Even if you have the budget for more hardware, I feel that creating an +effective db structure is a much more elegant solution than to throw +more hardware. (I admit, sometimes its cheaper to throw more hardware) + +If you have particular queries that are too slow, posting the explain +analyze for each on the list should garner some help. + +--=20 +Matthew Nuzum +www.bearfruit.org + +From pgsql-performance-owner@postgresql.org Wed Aug 17 18:25:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E26695288A + for ; + Wed, 17 Aug 2005 17:36:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39818-07 + for ; + Wed, 17 Aug 2005 20:36:38 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E29752ACD + for ; + Wed, 17 Aug 2005 17:36:38 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7743019; Wed, 17 Aug 2005 13:38:55 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: PG8 Tuning +Date: Wed, 17 Aug 2005 13:39:47 -0700 +User-Agent: KMail/1.8 +Cc: Michael Stone +References: <1536.217.45.209.171.1123763001.squirrel@www.gradwell.com> + <200508160912.32263.josh@agliodbs.com> + <20050816173047.GC19080@mathom.us> +In-Reply-To: <20050816173047.GC19080@mathom.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508171339.47399.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.049 required=5 tests=[AWL=-0.001, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/213 +X-Sequence-Number: 13960 + +Michael, + +> Well, you don't have to spend *quite* that much to get a decent storage +> array. :) + +Yes, I'm just pointing out that it's only the extreme cases which are +clear-cut. Middle cases are a lot harder to define. For example, we've +found that on DBT2 running of a 14-drive JBOD, seperating off WAL boosts +performance about 8% to 14%. On DBT3 (DSS) seperate WAL (and seperate +tablespaces) helps considerably during data load,but not otherwise. So it +all depends. + +> That's a different creature from +> a data mining app that might really benefit from having additional +> spindles to accelerate read performance from indices much larger than +> RAM. + +Yes, although the data mining app benefits from the special xlog disk +during ETL. So it's a tradeoff. + +> At any rate, this just underscores the need for testing a +> particular workload on particular hardware + +Yes, absolutely. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Aug 17 18:09:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 135A0529E6; + Wed, 17 Aug 2005 17:40:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44884-08; Wed, 17 Aug 2005 20:40:37 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id CF9E5529C2; + Wed, 17 Aug 2005 17:40:34 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: bitmap scan issues 8.1 devel +Date: Wed, 17 Aug 2005 16:40:34 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD11C@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: bitmap scan issues 8.1 devel +Thread-Index: AcWja+mdyQz95+VbTreJShGw9lPYFg== +From: "Merlin Moncure" +To: +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/212 +X-Sequence-Number: 13959 + +Hello, +Doing some testing on upcoming 8.1 devel and am having serious issues +with new bitmap index scan feature. It is easy to work around (just +disable it) but IMO the planner is using it when a regular index scan +should be strongly favored. The performance of the bitmapscan in my +usage is actually quite a bit worse than a full sequential scan. + +here is a query which does this: +explain analyze execute +data1_read_next_product_structure_file_0('012241', '', '', '002', 1); + +Here is the 8.0/bitmap off plan: +Limit (cost=3D0.00..45805.23 rows=3D5722 width=3D288) (actual +time=3D0.070..0.072 rows=3D1 loops=3D1) + -> Index Scan using product_structure_file_pkey on +product_structure_file (cost=3D0.00..45805.23 rows=3D5722 width=3D288) +(actual time=3D0.063..0.063 row +s=3D1 loops=3D1) + Index Cond: ((ps_parent_code)::text >=3D ($1)::text) + Filter: ((((ps_parent_code)::text > ($1)::text) OR +(ps_group_code >=3D $2)) AND (((ps_parent_code)::text > ($1)::text) OR +(ps_group_code > $2) +OR ((ps_section_code)::text >=3D ($3)::text)) AND = +(((ps_parent_code)::text +> ($1)::text) OR (ps_group_code > $2) OR ((ps_section_code)::text > +($3)::tex +t) OR ((ps_seq_no)::smallint > $4))) + Total runtime: 0.185 ms + +Here is the 8.1 with bitamp on: +Limit (cost=3D3768.32..3782.63 rows=3D5722 width=3D288) (actual +time=3D2287.488..2287.490 rows=3D1 loops=3D1) + -> Sort (cost=3D3768.32..3782.63 rows=3D5722 width=3D288) (actual +time=3D2287.480..2287.480 rows=3D1 loops=3D1) + Sort Key: ps_parent_code, ps_group_code, ps_section_code, +ps_seq_no + -> Bitmap Heap Scan on product_structure_file +(cost=3D187.84..3411.20 rows=3D5722 width=3D288) (actual = +time=3D19.977..514.532 +rows=3D47355 loops=3D1) + Recheck Cond: ((ps_parent_code)::text >=3D ($1)::text) + Filter: ((((ps_parent_code)::text > ($1)::text) OR +(ps_group_code >=3D $2)) AND (((ps_parent_code)::text > ($1)::text) OR +(ps_group_code +> $2) OR ((ps_section_code)::text >=3D ($3)::text)) AND +(((ps_parent_code)::text > ($1)::text) OR (ps_group_code > $2) OR +((ps_section_code)::text > ($3 +)::text) OR ((ps_seq_no)::smallint > $4))) + -> Bitmap Index Scan on product_structure_file_pkey +(cost=3D0.00..187.84 rows=3D18239 width=3D0) (actual = +time=3D19.059..19.059 +rows=3D47356 loo +ps=3D1) + Index Cond: ((ps_parent_code)::text >=3D = +($1)::text) + Total runtime: 2664.034 ms + + +Here is the prepared statement definition: +prepare data1_read_next_product_structure_file_0 (character varying, +character, character varying, int4, int4) + as select 1::int4, * from data1.product_structure_file + where ps_parent_code >=3D $1 and=20 + (ps_parent_code > $1 or ps_group_code >=3D $2) and=20 + (ps_parent_code > $1 or ps_group_code > $2 or +ps_section_code >=3D $3) and=20 + (ps_parent_code > $1 or ps_group_code > $2 or +ps_section_code > $3 or ps_seq_no > $4)=20 + order by ps_parent_code, ps_group_code, ps_section_code, +ps_seq_no + limit $5 + +Aside: this is the long way of writing +select 1::int4, * from data1.product_structure_file where +(ps_parent_code, ps_group_code, ps_section_code, ps_seq_no) > ($1, $2, +$3, $4) limit %5 + +which is allowed in pg but returns the wrong answer. + +Merlin + +From pgsql-performance-owner@postgresql.org Wed Aug 17 20:09:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6553C52CBF; + Wed, 17 Aug 2005 18:30:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16068-02; Wed, 17 Aug 2005 21:30:08 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id AF9C452E46; + Wed, 17 Aug 2005 18:30:06 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7743300; Wed, 17 Aug 2005 14:32:24 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] bitmap scan issues 8.1 devel +Date: Wed, 17 Aug 2005 14:33:15 -0700 +User-Agent: KMail/1.8 +Cc: "Merlin Moncure" , + pgsql-performance@postgresql.org +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD11C@Herge.rcsinc.local> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD11C@Herge.rcsinc.local> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200508171433.15614.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.049 required=5 tests=[AWL=-0.001, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/219 +X-Sequence-Number: 13966 + +Merlin, + +> =A0 =A0-> =A0Index Scan using product_structure_file_pkey on +> product_structure_file =A0(cost=3D0.00..45805.23 rows=3D5722 width=3D288) +> (actual time=3D0.063..0.063 row +> s=3D1 loops=3D1) + +It appears that your DB is estimating the number of rows returned much too= +=20 +high (5722 instead of 1). Please raise the statistics on all columns to=20 +about 500, analyze, and try your test again. + +Thanks! + +=2D-=20 +=2D-Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Aug 17 19:46:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AED4A52AAE; + Wed, 17 Aug 2005 18:54:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77510-04; Wed, 17 Aug 2005 21:54:34 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 455E052A7E; + Wed, 17 Aug 2005 18:54:33 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7HLsa0t017375; + Wed, 17 Aug 2005 17:54:36 -0400 (EDT) +To: "Merlin Moncure" +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] bitmap scan issues 8.1 devel +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB3417DD11C@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD11C@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Wed, 17 Aug 2005 16:40:34 -0400" +Date: Wed, 17 Aug 2005 17:54:36 -0400 +Message-ID: <17374.1124315676@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/218 +X-Sequence-Number: 13965 + +"Merlin Moncure" writes: +> Doing some testing on upcoming 8.1 devel and am having serious issues +> with new bitmap index scan feature. It is easy to work around (just +> disable it) but IMO the planner is using it when a regular index scan +> should be strongly favored. + +I think blaming the bitmap code is the wrong response. What I see in +your example is that the planner doesn't know what the LIMIT value is, +and accordingly is favoring a plan that isn't going to get blown out of +the water if the LIMIT is large. I'd suggest not parameterizing the +LIMIT. + +(But hmm ... I wonder if we could use estimate_expression_value for +LIMIT items, instead of handling only simple Consts as the code does +now?) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 17 19:35:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 169F35285B + for ; + Wed, 17 Aug 2005 19:02:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84472-09 + for ; + Wed, 17 Aug 2005 22:02:38 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 04BC452B37 + for ; + Wed, 17 Aug 2005 19:02:34 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050817220235m9100g6hbue>; Wed, 17 Aug 2005 22:02:35 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 2133B55FBA; Wed, 17 Aug 2005 17:02:35 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 55F1C55FAD; + Wed, 17 Aug 2005 17:02:28 -0500 (CDT) +Message-ID: <4303B3F4.9010306@arbash-meinel.com> +Date: Wed, 17 Aug 2005 17:02:28 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Manfred Koizar , + Postgresql Performance +Subject: Re: Insert performance (OT?) +References: + <42DCCA3B.8070100@archonet.com> + + <42DCDB47.3060009@archonet.com> + +In-Reply-To: +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig314C86187A1349552BC0B1FC" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/217 +X-Sequence-Number: 13964 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig314C86187A1349552BC0B1FC +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Manfred Koizar wrote: +> On Tue, 19 Jul 2005 11:51:51 +0100, Richard Huxton +> wrote: +> +>>You could get away with one query if you converted them to left-joins: +>>INSERT INTO ... +>>SELECT * FROM upload LEFT JOIN ... WHERE f3 IS NULL +>>UNION +>>SELECT * FROM upload LEFT JOIN ... WHERE f4 IS NULL +> +> +> For the archives: This won't work. Each of the two SELECTs +> eliminates rows violating one of the two constraints but includes rows +> violating the other constraint. After the UNION you are back to +> violating both constraints :-( + +Couldn't you use "INTERSECT" then? To only get the rows that *both* +queries return? +John +=:-> + +> +> Servus +> Manfred +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + + +--------------enig314C86187A1349552BC0B1FC +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDA7P0JdeBCYSNAAMRAjhsAJ9pCTOStHkdEkOEV4uwj2RSuZm4+QCffk+7 +Y6mRPRvjR4RKPGu4R8sg/GY= +=F/S/ +-----END PGP SIGNATURE----- + +--------------enig314C86187A1349552BC0B1FC-- + +From pgsql-performance-owner@postgresql.org Wed Aug 17 23:02:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B3DE52848 + for ; + Wed, 17 Aug 2005 23:02:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79120-04 + for ; + Thu, 18 Aug 2005 02:02:17 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id E17F552802 + for ; + Wed, 17 Aug 2005 23:02:15 -0300 (ADT) +Received: from ram.rentec.com (mailhost [192.5.35.66]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j7I22HTs010784 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) + for ; + Wed, 17 Aug 2005 22:02:19 -0400 (EDT) +X-Rentec: external +Received: from [172.16.160.108] (stange-dhcp2.rentec.com [172.16.160.108]) + by ram.rentec.com (8.13.1/8.12.1) with ESMTP id j7I22Ge2022033 + for ; + Wed, 17 Aug 2005 22:02:16 -0400 (EDT) +Message-ID: <4303E704.4030200@rentec.com> +Date: Wed, 17 Aug 2005 21:40:20 -0400 +From: Alan Stange +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: limit number of concurrent callers to a stored proc? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as j7I22HTs010784 at Wed Aug 17 + 22:02:19 2005 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/220 +X-Sequence-Number: 13967 + +Hello all, + +is there a simple way to limit the number of concurrent callers to a +stored proc? + +The problem we have is about 50 clients come and perform the same +operation at nearly the same time. Typically, this query takes a few +seconds to run, but in the case of this thundering herd the query time +drops to 70 seconds or much more. The query can return up to 15MB of data. + +The machine is a dual opteron, 8 GB memory, lots of fiber channel disk, +Linux 2.6, etc. + +So, I'm thinking that a semaphore than will block more than N clients +from being in the core of the function at one time would be a good thing. + +Thanks! + +-- Alan + +From pgsql-performance-owner@postgresql.org Wed Aug 17 23:11:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DE68352848 + for ; + Wed, 17 Aug 2005 23:11:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00760-09 + for ; + Thu, 18 Aug 2005 02:11:46 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id D50165282E + for ; + Wed, 17 Aug 2005 23:11:45 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7I2BnVi004050 + for ; Wed, 17 Aug 2005 21:11:49 -0500 +Subject: extremly low memory usage +From: Jeremiah Jahn +To: postgres performance +Content-Type: text/plain +Date: Wed, 17 Aug 2005 21:11:48 -0500 +Message-Id: <1124331108.27881.96.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1027/Tue Aug 16 18:44:00 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.03 required=5 tests=[AWL=-0.020, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/221 +X-Sequence-Number: 13968 + +I just put together a system with 6GB of ram on a 14 disk raid 10 array. +When I run my usual big painful queries, I get very little to know +memory usage. My production box (raid 5 4GB ram) hovers at 3.9GB used +most of the time. the new devel box sits at around 250MB. + +I've switched to an 8.0 system on the new devel box, but the .conf +really didn't change. Index usage is the same. Something seems wrong and +I'm not sure why. + + +any thoughts, +-jj- + + +shared_buffers = 32768 # min 16, at least max_connections*2, 8KB each +work_mem = 2097151 # min 64, size in KB +maintenance_work_mem = 819200 # min 1024, size in KB +max_fsm_pages = 80000 # min max_fsm_relations*16, 6 bytes each +checkpoint_segments = 30 # in logfile segments, min 1, 16MB each +effective_cache_size = 3600000 <-----this is a little out of control, but would it have any real effect? +random_page_cost = 2 # units are one sequential page fetch cost +log_min_duration_statement = 10000 # -1 is disabled, in milliseconds. +lc_messages = 'C' # locale for system error message strings +lc_monetary = 'C' # locale for monetary formatting +lc_numeric = 'C' # locale for number formatting +lc_time = 'C' # locale for time formatting + + + +-- +"Now this is a totally brain damaged algorithm. Gag me with a +smurfette." + -- P. Buhr, Computer Science 354 + + +From pgsql-performance-owner@postgresql.org Wed Aug 17 23:23:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 05A8E52A14 + for ; + Wed, 17 Aug 2005 23:23:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06571-10 + for ; + Thu, 18 Aug 2005 02:23:25 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CFDD52A06 + for ; + Wed, 17 Aug 2005 23:23:24 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050818022327m92009id64e>; Thu, 18 Aug 2005 02:23:27 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 9A9E055FAD; Wed, 17 Aug 2005 21:23:26 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id C92CB55FAD; + Wed, 17 Aug 2005 21:21:09 -0500 (CDT) +Message-ID: <4303F090.40602@arbash-meinel.com> +Date: Wed, 17 Aug 2005 21:21:04 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> +In-Reply-To: <1124331108.27881.96.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig6476E14D6CEC3DB757D1CFC5" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/222 +X-Sequence-Number: 13969 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig6476E14D6CEC3DB757D1CFC5 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: +> I just put together a system with 6GB of ram on a 14 disk raid 10 array. +> When I run my usual big painful queries, I get very little to know +> memory usage. My production box (raid 5 4GB ram) hovers at 3.9GB used +> most of the time. the new devel box sits at around 250MB. +> +> I've switched to an 8.0 system on the new devel box, but the .conf +> really didn't change. Index usage is the same. Something seems wrong and +> I'm not sure why. +> + +How big is your actual database on disk? And how much of it is actually +touched by your queries? + +It seems that your tough queries might only be exercising a portion of +the database. If you really want to make memory usage increase try +something like: +find . -type f -print0 | xargs -0 cat >/dev/null +Which should read all the files. After doing that, does the memory usage +increase? + +> +> any thoughts, +> -jj- +> +> +> shared_buffers = 32768 # min 16, at least max_connections*2, 8KB each +> work_mem = 2097151 # min 64, size in KB + +This seems awfully high. 2GB Per sort? This might actually be flushing +some of your ram, since it would get allocated and filled, and then +freed when finished. Remember, depending on what you are doing, this +amount can get allocated more than once per query. + +> maintenance_work_mem = 819200 # min 1024, size in KB +> max_fsm_pages = 80000 # min max_fsm_relations*16, 6 bytes each +> checkpoint_segments = 30 # in logfile segments, min 1, 16MB each +> effective_cache_size = 3600000 <-----this is a little out of control, but would it have any real effect? + +It should just tell the planner that it is more likely to have buffers +in cache, so index scans are slightly cheaper than they would otherwise be. + +> random_page_cost = 2 # units are one sequential page fetch cost +> log_min_duration_statement = 10000 # -1 is disabled, in milliseconds. +> lc_messages = 'C' # locale for system error message strings +> lc_monetary = 'C' # locale for monetary formatting +> lc_numeric = 'C' # locale for number formatting +> lc_time = 'C' # locale for time formatting +> + +John +=:-> + +--------------enig6476E14D6CEC3DB757D1CFC5 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDA/CTJdeBCYSNAAMRAkkFAJ4mPFWO1cTQXZzSN8a3PYd8PbilvACgoRex +HWfH4vnvrPDt9COuwFW/y+8= +=0N+Z +-----END PGP SIGNATURE----- + +--------------enig6476E14D6CEC3DB757D1CFC5-- + +From pgsql-performance-owner@postgresql.org Wed Aug 17 23:30:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BAC85294D + for ; + Wed, 17 Aug 2005 23:30:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03288-01 + for ; + Thu, 18 Aug 2005 02:30:21 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 33B4C5282E + for ; + Wed, 17 Aug 2005 23:30:19 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j7I2UORY022238; + Thu, 18 Aug 2005 12:30:24 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j7I2UOqn022235; Thu, 18 Aug 2005 12:30:24 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Thu, 18 Aug 2005 12:30:24 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Alan Stange +Cc: pgsql-performance@postgresql.org +Subject: Re: limit number of concurrent callers to a stored proc? +In-Reply-To: <4303E704.4030200@rentec.com> +Message-ID: +References: <4303E704.4030200@rentec.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.002 required=5 tests=[AWL=0.002] +X-Spam-Level: +X-Archive-Number: 200508/223 +X-Sequence-Number: 13970 + +Hi Alan, + +On Wed, 17 Aug 2005, Alan Stange wrote: + +> Hello all, +> +> is there a simple way to limit the number of concurrent callers to a +> stored proc? +> +> The problem we have is about 50 clients come and perform the same +> operation at nearly the same time. Typically, this query takes a few +> seconds to run, but in the case of this thundering herd the query time +> drops to 70 seconds or much more. The query can return up to 15MB of data. +> +> The machine is a dual opteron, 8 GB memory, lots of fiber channel disk, +> Linux 2.6, etc. +> +> So, I'm thinking that a semaphore than will block more than N clients +> from being in the core of the function at one time would be a good thing. + +There is no PostgreSQL feature which will do this for you. It should be +possible to implement this yourself, without too much pain. If you're +using PL/PgSQL, write another function in C or one of the other more +sophisticated PLs to implement the logic for you. At the beginning of the +function, execute the function to increment the count; at the end, execute +a function to decrement it. + +If you're writing the function in C or one of those more sophisticated +PLs, it's even easier. + +As an aside, using semaphores might be a little painful. I'd just grab +some shared memory and keep a counter in it. If the counter is greater +than your desired number of concurrent executions, you sleep and try again +soon. + +That being said, did you want to give us a look at your function and data +and see if we can improve the performance at all? + +Thanks, + +Gavin + +From pgsql-performance-owner@postgresql.org Wed Aug 17 23:32:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 72CF45294D + for ; + Wed, 17 Aug 2005 23:32:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91406-02 + for ; + Thu, 18 Aug 2005 02:32:04 +0000 (GMT) +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id A4C4F52A14 + for ; + Wed, 17 Aug 2005 23:32:02 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 8CCBE24FF7; + Thu, 18 Aug 2005 10:32:04 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id A44A724FF1; + Thu, 18 Aug 2005 10:32:02 +0800 (WST) +Message-ID: <4303F417.3090307@familyhealth.com.au> +Date: Thu, 18 Aug 2005 10:36:07 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alan Stange +Cc: pgsql-performance@postgresql.org +Subject: Re: limit number of concurrent callers to a stored proc? +References: <4303E704.4030200@rentec.com> +In-Reply-To: <4303E704.4030200@rentec.com> +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.062 required=5 tests=[AWL=0.012, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/224 +X-Sequence-Number: 13971 + +You could use a 1 column/1 row table perhaps. Use some sort of locking +mechanism. + +Also, check out contrib/userlock + +Chris + +Alan Stange wrote: +> Hello all, +> +> is there a simple way to limit the number of concurrent callers to a +> stored proc? +> +> The problem we have is about 50 clients come and perform the same +> operation at nearly the same time. Typically, this query takes a few +> seconds to run, but in the case of this thundering herd the query time +> drops to 70 seconds or much more. The query can return up to 15MB of data. +> +> The machine is a dual opteron, 8 GB memory, lots of fiber channel disk, +> Linux 2.6, etc. +> +> So, I'm thinking that a semaphore than will block more than N clients +> from being in the core of the function at one time would be a good thing. +> Thanks! +> +> -- Alan +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + + +From pgsql-performance-owner@postgresql.org Thu Aug 18 00:21:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 82E3B528DA + for ; + Thu, 18 Aug 2005 00:19:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47452-05 + for ; + Thu, 18 Aug 2005 03:19:12 +0000 (GMT) +Received: from smtpauth07.mail.atl.earthlink.net + (smtpauth07.mail.atl.earthlink.net [209.86.89.67]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E86E528D4 + for ; + Thu, 18 Aug 2005 00:19:11 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=eYiuLLIWlc4fnricpidY+eXfUNn96MPKcPPUCYrCRm0sm+Q78nemMqJeMw0UQpuB; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth07.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E5avu-0006tW-Ew; Wed, 17 Aug 2005 23:19:10 -0400 +Message-Id: <6.2.3.4.0.20050817224934.05c09228@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Wed, 17 Aug 2005 23:19:04 -0400 +To: Alan Stange , pgsql-performance@postgresql.org +From: Ron +Subject: Re: limit number of concurrent callers to a stored +In-Reply-To: <4303E704.4030200@rentec.com> +References: <4303E704.4030200@rentec.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcdba9d9f157450d079aba40b5a5011883350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.083 required=5 tests=[AWL=0.709, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: * +X-Archive-Number: 200508/225 +X-Sequence-Number: 13972 + +At 09:40 PM 8/17/2005, Alan Stange wrote: + +>is there a simple way to limit the number of concurrent callers to a +>stored proc? +> +>The problem we have is about 50 clients come and perform the same +>operation at nearly the same time. Typically, this query takes a +>few seconds to run, but in the case of this thundering herd the +>query time drops to 70 seconds or much more. The query can return +>up to 15MB of data. + +I'm assuming there is some significant write activity going on at +some point as a result of the query, since MVCC should not care about +concurrent read activity? + +Is that "a few seconds each query" or "a few seconds total if we run +50 queries sequentially but 70+ seconds per query if we try to run 50 +queries concurrently"? + +A) If the former, "a few seconds" * 50 can easily be 70+ seconds, and +things are what you should expect. Getting higher performance in +that situation means reducing per query times, which may or may not +be easy. Looking at the stored procedure code with an eye towards +optimization would be a good place to start. + +B) If the later, then table access contention is driving performance +into the ground, and there are a few things you can try: +1= lock the table(s) under these circumstances so only one query of +the 50 can be acting on it at a time. If the table(s) is/are small +enough to be made RAM resident, this may be a particularly low-cost, +low-effort, reasonable solution. + +2= put a queue into place and only let some small number n of queries +run against the table(s) concurrently. Adjust n until you get best +performance. There are a few ways this could be done. + +3= Buy a SSD and put the table(s) in question on it. IIRC, 3.5" +format SSDs that can "drop in" replace HDs are available in up to +147GB capacities. + + +>The machine is a dual opteron, 8 GB memory, lots of fiber channel +>disk, Linux 2.6, etc. +> +>So, I'm thinking that a semaphore than will block more than N +>clients from being in the core of the function at one time would be +>a good thing. + +This will only help in case "B" above. If you go the "hard" route of +using systems programming, you will have a lot of details that must +be paid attention to correctly or Bad Things (tm) will +happen. Putting the semaphore in place is the tip of the iceberg. + + +Hope this helps, +Ron Peacetree + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 18 05:59:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4335D52AF7 + for ; + Thu, 18 Aug 2005 05:59:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46818-05 + for ; + Thu, 18 Aug 2005 08:59:16 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4107352ABF + for ; + Thu, 18 Aug 2005 05:59:15 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A75D930B42; Thu, 18 Aug 2005 11:10:30 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: Performance pb vs SQLServer. +Date: Thu, 18 Aug 2005 16:56:41 +0800 +Organization: Hub.Org Networking Services +Lines: 16 +Message-ID: +References: <6BCB9D8A16AC4241919521715F4D8BCE6C789C@algol.sollentuna.se> + <20050815161859.GB22386@alvh.no-ip.org> +Reply-To: "Qingqing Zhou" +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.185 required=5 tests=[AWL=-0.000, + PRIORITY_NO_NAME=1.185] +X-Spam-Level: * +X-Archive-Number: 200508/226 +X-Sequence-Number: 13973 + + +"Alvaro Herrera" writes +> +> Interesting; do they use an overwriting storage manager like Oracle, or +> a non-overwriting one like Postgres? +> + +They call this MVCC "RLV(row level versioning)". I think they use rollback +segment like Oracle (a.k.a "version store" or tempdb in SQL Server). Some +details are explained in their white paper:"Database concurrency and row +level versioning in SQL Server 2005". + +Regards, +Qingqing + + + +From pgsql-performance-owner@postgresql.org Thu Aug 18 10:00:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C542B529C6 + for ; + Thu, 18 Aug 2005 10:00:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81956-07 + for ; + Thu, 18 Aug 2005 13:00:38 +0000 (GMT) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [63.240.76.28]) + by svr1.postgresql.org (Postfix) with ESMTP id 66755528DC + for ; + Thu, 18 Aug 2005 10:00:36 -0300 (ADT) +Received: from jefftrout.com ([24.147.120.205]) + by comcast.net (sccrmhc13) with SMTP + id <2005081813003201300l7cmfe>; Thu, 18 Aug 2005 13:00:33 +0000 +Received: (qmail 74410 invoked from network); 18 Aug 2005 13:01:22 -0000 +Received: from c-24-147-120-205.hsd1.ma.comcast.net (HELO ?192.168.0.106?) + (24.147.120.205) + by 192.168.0.109 with SMTP; 18 Aug 2005 13:01:22 -0000 +In-Reply-To: <1124331108.27881.96.camel@bluejay.goodinassociates.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 (Apple Message framework v733) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: postgres performance +Content-Transfer-Encoding: 7bit +From: Jeff Trout +Subject: Re: extremly low memory usage +Date: Thu, 18 Aug 2005 09:00:31 -0400 +To: Jeremiah Jahn +X-Mailer: Apple Mail (2.733) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/227 +X-Sequence-Number: 13974 + + +On Aug 17, 2005, at 10:11 PM, Jeremiah Jahn wrote: + +> I just put together a system with 6GB of ram on a 14 disk raid 10 +> array. +> When I run my usual big painful queries, I get very little to know +> memory usage. My production box (raid 5 4GB ram) hovers at 3.9GB used +> most of the time. the new devel box sits at around 250MB. +> + +Is the system performing fine? Are you touching as much data as the +production box? + +If the system is performing fine don't worry about it. + +> work_mem = 2097151 # min 64, size in KB + +This is EXTREMELY high. You realize this is the amount of memory +that can be used per-sort and per-hash build in a query? You can end +up with multiples of this on a single query. If you have some big +queries that are run infrequently have them set it manually. + +> effective_cache_size = 3600000 <-----this is a little out of +> control, but would it have any real effect? + +This doesn't allocate anything - it is a hint to the planner about +how much data it can assume is cached. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + + +From pgsql-performance-owner@postgresql.org Thu Aug 18 11:47:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3677B52A98 + for ; + Thu, 18 Aug 2005 11:46:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19925-08 + for ; + Thu, 18 Aug 2005 14:46:53 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 43ABC52A6E + for ; + Thu, 18 Aug 2005 11:46:50 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050818144653m9100g61s9e>; Thu, 18 Aug 2005 14:46:53 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id C47D655FAD; Thu, 18 Aug 2005 09:46:52 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 3FC5855FAD; + Thu, 18 Aug 2005 09:44:39 -0500 (CDT) +Message-ID: <43049ED2.1080606@arbash-meinel.com> +Date: Thu, 18 Aug 2005 09:44:34 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Qingqing Zhou +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance pb vs SQLServer. +References: <6BCB9D8A16AC4241919521715F4D8BCE6C789C@algol.sollentuna.se> + <20050815161859.GB22386@alvh.no-ip.org> + +In-Reply-To: +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigC08C6AF0E589E59A3E6ACFBA" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/228 +X-Sequence-Number: 13975 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigC08C6AF0E589E59A3E6ACFBA +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Qingqing Zhou wrote: +> "Alvaro Herrera" writes +> +>>Interesting; do they use an overwriting storage manager like Oracle, or +>>a non-overwriting one like Postgres? +>> +> +> +> They call this MVCC "RLV(row level versioning)". I think they use rollback +> segment like Oracle (a.k.a "version store" or tempdb in SQL Server). Some +> details are explained in their white paper:"Database concurrency and row +> level versioning in SQL Server 2005". +> +> Regards, +> Qingqing +> + +I found the paper here: +http://www.microsoft.com/technet/prodtechnol/sql/2005/cncrrncy.mspx + +And it does sound like they are doing it the Oracle way: + +When a record in a table or index is updated, the new record is stamped +with the transaction sequence_number of the transaction that is doing +the update. The previous version of the record is stored in the version +store, and the new record contains a pointer to the old record in the +version store. Old records in the version store may contain pointers to +even older versions. All the old versions of a particular record are +chained in a linked list, and SQL Server may need to follow several +pointers in a list to reach the right version. Version records need to +be kept in the version store only as long as there are there are +operations that might require them. + +John +=:-> + +--------------enigC08C6AF0E589E59A3E6ACFBA +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDBJ7WJdeBCYSNAAMRAj+pAJ9sYAV896c6AjMlDUrVyhJldhNaFwCfUnMI +UZAct14ESLSKVMjdK9fGTQc= +=k73F +-----END PGP SIGNATURE----- + +--------------enigC08C6AF0E589E59A3E6ACFBA-- + +From pgsql-performance-owner@postgresql.org Thu Aug 18 12:01:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F95D529CC + for ; + Thu, 18 Aug 2005 12:01:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03401-02 + for ; + Thu, 18 Aug 2005 15:01:20 +0000 (GMT) +Received: from urano.datatransfer.com.ar (host202.200.80.31.ifxnw.com.ar + [200.80.31.202]) + by svr1.postgresql.org (Postfix) with ESMTP id D259B52984 + for ; + Thu, 18 Aug 2005 12:01:16 -0300 (ADT) +Content-Class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C5A405.B3701AEC" +Subject: FW: Tx forecast improving harware capabilities. +X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 +Date: Thu, 18 Aug 2005 12:01:24 -0300 +Message-ID: <722B1B9CFE0ECE488342E3EC2BA920B86CC443@mailserver> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Tx forecast improving harware capabilities. +thread-index: AcWjb2iCgsLuHIzSSjO5/yF8LaVzUQAiVH5AAAMSZgA= +From: "Sebastian Lallana" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.051 required=5 tests=[FORGED_RCVD_HELO=0.05, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/229 +X-Sequence-Number: 13976 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5A405.B3701AEC +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Hello: + +We are having serious performance problems using JBOSS and PGSQL. + +I'm sure the problem has to do with the application itself (and neither +with JBOSS nor PGSQL) but the fact is that we are using desktop +equipment to run both Jboss and Postgresql (An Athlon 2600, 1 Gb Ram, +IDE HDD with 60 Mb/sec Transfer Rate), and the answers arise: + +If we upgrade our hardware to a Dual Processor would the transactions +per second increase significantly? Would Postgresql take advantage from +SMP? Presumably yes, but can we do a forecast about the number of tps? +What we need is a paper with some figures showing the expected +performance in different environments. Some study about the "degree of +correlation" between TPS and Number of Processors, Cache, Frequency, +Word Size, Architecture, etc.=20 + +It exists something like this? Does anybody has experience about this +subject? + +=20 + +Thanks in advance and best regards. + +=20 + +P.S. I've been looking at www.tpc.org but I could't find anything +valuable. =20 + +=20 + + +------_=_NextPart_001_01C5A405.B3701AEC +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hello:

+ +

We are having serious performance problems = +using +JBOSS and PGSQL.

+ +

I’m sure the problem has to do with the +application itself (and neither with JBOSS nor PGSQL) but the fact is that we are using = +desktop equipment +to run both Jboss and Postgresql (An = +Athlon 2600, 1 +Gb Ram, IDE HDD with 60 Mb/sec Transfer Rate), and the answers = +arise:

+ +

If we upgrade our hardware to a Dual Processor = +would +the transactions per second increase significantly? Would Postgresql take advantage from SMP? = +Presumably yes, +but can we do a forecast about the number of tps? What we need is a = +paper with +some figures showing the expected performance in different environments. = +Some +study about the “degree of correlation” between TPS and = +Number of Processors, +Cache, Frequency, Word Size, Architecture, etc. = +

+ +

It exists = +something like +this? Does anybody has experience about this subject? + +

 = +

+ +

Thanks in +advance and best regards.

+ +

 = +

+ +

P.S. I’ve = +been +looking at www.tpc.org but I could’t find anything valuable.  = +

+ +

 = +

+ +
+ + + + + +------_=_NextPart_001_01C5A405.B3701AEC-- + +From pgsql-performance-owner@postgresql.org Thu Aug 18 13:29:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 66498529ED + for ; + Thu, 18 Aug 2005 13:29:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70624-07 + for ; + Thu, 18 Aug 2005 16:29:46 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B951529B8 + for ; + Thu, 18 Aug 2005 13:29:46 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7751994; Thu, 18 Aug 2005 09:32:01 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: FW: Tx forecast improving harware capabilities. +Date: Thu, 18 Aug 2005 09:30:47 -0700 +User-Agent: KMail/1.8 +Cc: "Sebastian Lallana" +References: <722B1B9CFE0ECE488342E3EC2BA920B86CC443@mailserver> +In-Reply-To: <722B1B9CFE0ECE488342E3EC2BA920B86CC443@mailserver> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508180930.48089.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] +X-Spam-Level: +X-Archive-Number: 200508/230 +X-Sequence-Number: 13977 + +Sebastian, + +> We are having serious performance problems using JBOSS and PGSQL. + +How about some information about your application? Performance tuning +approaches vary widely according to what you're doing with the database. + +Also, read this: +http://www.powerpostgresql.com/PerfList + +> I'm sure the problem has to do with the application itself (and neither +> with JBOSS nor PGSQL) but the fact is that we are using desktop +> equipment to run both Jboss and Postgresql (An Athlon 2600, 1 Gb Ram, +> IDE HDD with 60 Mb/sec Transfer Rate), and the answers arise: + +Well, first off, the IDE HDD is probably killing performance unless your +application is 95% read or greater. + +> If we upgrade our hardware to a Dual Processor would the transactions +> per second increase significantly? Would Postgresql take advantage from +> SMP? Presumably yes, but can we do a forecast about the number of tps? + +If this is an OLTP application, chance are that nothing is going to improve +performance until you get decent disk support. + +> What we need is a paper with some figures showing the expected +> performance in different environments. Some study about the "degree of +> correlation" between TPS and Number of Processors, Cache, Frequency, +> Word Size, Architecture, etc. + +I don't think such a thing exists even for Oracle. Hardware configuration +for maximum performance is almost entirely dependant on your application. + +If it helps, running DBT2 (an OLTP test devised by OSDL after TPC-C), I can +easily get 1700 new orders per minute (NOTPM) (about 3000 total +multiple-write transactions per minute) on a quad-pentium-III with 4GB RAM +and 14 drives, and 6500 notpm on a dual-Itanium machine. + +> P.S. I've been looking at www.tpc.org but I could't find anything +> valuable. + +Nor would you for any real-world situation even if we had a TPC benchmark +(which are involved and expensive, give us a couple of years). The TPC +benchmarks are more of a litmus test that your database system & platform are +"competitive"; they don't really relate to real-world performance (unless you +have budget for an 112-disk system!) + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Aug 18 13:35:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0639F52C05 + for ; + Thu, 18 Aug 2005 13:35:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85947-06 + for ; + Thu, 18 Aug 2005 16:35:18 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id C764452A7E + for ; + Thu, 18 Aug 2005 13:35:16 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7IGZCrc014488; Thu, 18 Aug 2005 11:35:14 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: John A Meinel +Cc: postgres performance +In-Reply-To: <4303F090.40602@arbash-meinel.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + <4303F090.40602@arbash-meinel.com> +Content-Type: text/plain +Date: Thu, 18 Aug 2005 11:35:11 -0500 +Message-Id: <1124382911.27881.113.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1030/Wed Aug 17 10:53:46 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.031 required=5 tests=[AWL=-0.019, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/231 +X-Sequence-Number: 13978 + +On Wed, 2005-08-17 at 21:21 -0500, John A Meinel wrote: +> Jeremiah Jahn wrote: +> > I just put together a system with 6GB of ram on a 14 disk raid 10 array. +> > When I run my usual big painful queries, I get very little to know +> > memory usage. My production box (raid 5 4GB ram) hovers at 3.9GB used +> > most of the time. the new devel box sits at around 250MB. +> > +> > I've switched to an 8.0 system on the new devel box, but the .conf +> > really didn't change. Index usage is the same. Something seems wrong and +> > I'm not sure why. +> > +> +> How big is your actual database on disk? And how much of it is actually +> touched by your queries? +The DB is about 60GB. About 10GB is actually used in real queries, +versus get me this single record with this ID. I have a large query that +finds court cases based on certain criteria that is name based. I get a +full seq scan on the name table in about 7 seconds, This table has about +6 million names (most being 'smith, something'). The index scan takes +much less time of course, once it's been cached (somewhere but not +apparently memory). The really query can take 60 seconds on a first run. +And 1.3 seconds on a second run. I'm very happy with the cached results, +just not really sure where that caching is happening since it doesn't +show up as memory usage. I do know that the caching that happens seems +to be independent of the DB. I can restart the DB and my speeds are +still the same as the cached second query. Is there some way to +pre-cache some of the tables/files on the file system? If I switch my +query to search for 'jones%' instead of 'smith%', I take a hit. But if I +then rerun the smith search, I still get cached speed. I only have two +tables essentially names and events that have to do any real work ie. +not very atomic data. I'd love to be able to force these two tables into +a cache somewhere. This is a linux system (RHEL ES4) by the way. +> +> It seems that your tough queries might only be exercising a portion of +> the database. If you really want to make memory usage increase try +> something like: +> find . -type f -print0 | xargs -0 cat >/dev/null +> Which should read all the files. After doing that, does the memory usage +> increase? +> +> > +> > any thoughts, +> > -jj- +> > +> > +> > shared_buffers = 32768 # min 16, at least max_connections*2, 8KB each +> > work_mem = 2097151 # min 64, size in KB +> +> This seems awfully high. 2GB Per sort? This might actually be flushing +> some of your ram, since it would get allocated and filled, and then +> freed when finished. Remember, depending on what you are doing, this +> amount can get allocated more than once per query. +What's a good way to determine the optimal size? + +> +> > maintenance_work_mem = 819200 # min 1024, size in KB +> > max_fsm_pages = 80000 # min max_fsm_relations*16, 6 bytes each +> > checkpoint_segments = 30 # in logfile segments, min 1, 16MB each +> > effective_cache_size = 3600000 <-----this is a little out of control, but would it have any real effect? +> +> It should just tell the planner that it is more likely to have buffers +> in cache, so index scans are slightly cheaper than they would otherwise be. +> +> > random_page_cost = 2 # units are one sequential page fetch cost +> > log_min_duration_statement = 10000 # -1 is disabled, in milliseconds. +> > lc_messages = 'C' # locale for system error message strings +> > lc_monetary = 'C' # locale for monetary formatting +> > lc_numeric = 'C' # locale for number formatting +> > lc_time = 'C' # locale for time formatting +> > +> +> John +> =:-> +-- +"Now this is a totally brain damaged algorithm. Gag me with a +smurfette." + -- P. Buhr, Computer Science 354 + + +From pgsql-performance-owner@postgresql.org Thu Aug 18 14:14:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EDED528D1 + for ; + Thu, 18 Aug 2005 14:14:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17681-01 + for ; + Thu, 18 Aug 2005 17:14:13 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DF44528CF + for ; + Thu, 18 Aug 2005 14:14:11 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050818171412m9100g65l2e>; Thu, 18 Aug 2005 17:14:12 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id AC60355FBA; Thu, 18 Aug 2005 12:14:11 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id A57FB55FAD; + Thu, 18 Aug 2005 12:14:05 -0500 (CDT) +Message-ID: <4304C1D9.40107@arbash-meinel.com> +Date: Thu, 18 Aug 2005 12:14:01 -0500 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + <4303F090.40602@arbash-meinel.com> + <1124382911.27881.113.camel@bluejay.goodinassociates.com> +In-Reply-To: <1124382911.27881.113.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig6C68D44715E31BBBCA7F4421" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/232 +X-Sequence-Number: 13979 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig6C68D44715E31BBBCA7F4421 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: + +>On Wed, 2005-08-17 at 21:21 -0500, John A Meinel wrote: +> +> +>>Jeremiah Jahn wrote: +>> +>> +>>>I just put together a system with 6GB of ram on a 14 disk raid 10 array. +>>>When I run my usual big painful queries, I get very little to know +>>>memory usage. My production box (raid 5 4GB ram) hovers at 3.9GB used +>>>most of the time. the new devel box sits at around 250MB. +>>> +>>>I've switched to an 8.0 system on the new devel box, but the .conf +>>>really didn't change. Index usage is the same. Something seems wrong and +>>>I'm not sure why. +>>> +>>> +>>> +>>How big is your actual database on disk? And how much of it is actually +>>touched by your queries? +>> +>> +>The DB is about 60GB. About 10GB is actually used in real queries, +>versus get me this single record with this ID. I have a large query that +>finds court cases based on certain criteria that is name based. I get a +>full seq scan on the name table in about 7 seconds, This table has about +>6 million names (most being 'smith, something'). The index scan takes +>much less time of course, once it's been cached (somewhere but not +>apparently memory). The really query can take 60 seconds on a first run. +>And 1.3 seconds on a second run. I'm very happy with the cached results, +>just not really sure where that caching is happening since it doesn't +>show up as memory usage. I do know that the caching that happens seems +>to be independent of the DB. I can restart the DB and my speeds are +>still the same as the cached second query. Is there some way to +>pre-cache some of the tables/files on the file system? If I switch my +>query to search for 'jones%' instead of 'smith%', I take a hit. But if I +>then rerun the smith search, I still get cached speed. I only have two +>tables essentially names and events that have to do any real work ie. +>not very atomic data. I'd love to be able to force these two tables into +>a cache somewhere. This is a linux system (RHEL ES4) by the way. +> +> +I think what is happening is that *some* of the index pages are being +cached, just not all of them. Most indexes (if you didn't specify +anything special) are btree, so that you load the root page, and then +determine what pages need to be loaded from there. So the "jones%" pages +aren't anywhere near the "smith%" pages. And don't need to be loaded if +you aren't accessing them. + +So the required memory usage might be smaller than you think. At least +until all of the index pages have been accessed. + +The reason it is DB independent is because the OS is caching a file +access (you read a file, it keeps the old pages in RAM in case you ask +for it again). + +Part of the trick, is that as you use the database, it will cache what +has been used. So you may not need to do anything. It should sort itself +out with time. +However, if you have to have cached performance as soon as your machine +reboots, you could figure out what files on disk represent your indexes +and tables, and then just "cat $files >/dev/null" +That should cause a read on those files, which should pull them into the +memory cache. *However* this will fail if the size of those files is +greater than available memory, so you may want to be a little bit stingy +about what you preload. +Alternatively, you could just write an SQL script which runs a bunch of +indexed queries to make sure all the pages get loaded. + +Something like: +FOR curname IN SELECT DISTINCT name FROM users LOOP + SELECT name FROM users WHERE name=curname; +END LOOP; + +That should make the database go through the entire table, and load the +index for every user. This is overkill, and will probably take a long +time to execute. But you could do it if you wanted. + +>>It seems that your tough queries might only be exercising a portion of +>>the database. If you really want to make memory usage increase try +>>something like: +>>find . -type f -print0 | xargs -0 cat >/dev/null +>>Which should read all the files. After doing that, does the memory usage +>>increase? +>> +>> +>> +>>>any thoughts, +>>>-jj- +>>> +>>> +>>>shared_buffers = 32768 # min 16, at least max_connections*2, 8KB each +>>>work_mem = 2097151 # min 64, size in KB +>>> +>>> +>>This seems awfully high. 2GB Per sort? This might actually be flushing +>>some of your ram, since it would get allocated and filled, and then +>>freed when finished. Remember, depending on what you are doing, this +>>amount can get allocated more than once per query. +>> +>> +>What's a good way to determine the optimal size? +> +> + +Practice. :) A few questions I guess... +How many concurrent connections are you expecting? How many joins does a +standard query have? How big are the joins? + +In general, I would tend to make this a smaller number, so that the os +has more room to cache tables, rather than having big buffers for joins. +If someone is requesting a join that requires a lot of rows, I would +rather *that* query be slower, than impacting everyone else. +I would put it more with a maximum in the 20-100MB range. + +John +=:-> + +> +> +>>>maintenance_work_mem = 819200 # min 1024, size in KB +>>>max_fsm_pages = 80000 # min max_fsm_relations*16, 6 bytes each +>>>checkpoint_segments = 30 # in logfile segments, min 1, 16MB each +>>>effective_cache_size = 3600000 <-----this is a little out of control, but would it have any real effect? +>>> +>>> +>>It should just tell the planner that it is more likely to have buffers +>>in cache, so index scans are slightly cheaper than they would otherwise be. +>> +>> +>> +>>>random_page_cost = 2 # units are one sequential page fetch cost +>>>log_min_duration_statement = 10000 # -1 is disabled, in milliseconds. +>>>lc_messages = 'C' # locale for system error message strings +>>>lc_monetary = 'C' # locale for monetary formatting +>>>lc_numeric = 'C' # locale for number formatting +>>>lc_time = 'C' # locale for time formatting +>>> +>>> +>>> +>>John +>>=:-> +>> +>> + + +--------------enig6C68D44715E31BBBCA7F4421 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDBMHdJdeBCYSNAAMRAjBbAJ47D8yVbYeYhjL6JHPmJKHrn5M4sgCgiAhT +MAh3/BrF05iFf9uGUe8CkQI= +=BksX +-----END PGP SIGNATURE----- + +--------------enig6C68D44715E31BBBCA7F4421-- + +From pgsql-performance-owner@postgresql.org Thu Aug 18 14:39:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CA34452BC5 + for ; + Thu, 18 Aug 2005 14:39:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78359-04 + for ; + Thu, 18 Aug 2005 17:39:23 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id CFA6352B98 + for ; + Thu, 18 Aug 2005 14:39:21 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7IHdMMx016018; Thu, 18 Aug 2005 12:39:22 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: Jeff Trout +Cc: postgres performance +In-Reply-To: +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + +Content-Type: text/plain +Date: Thu, 18 Aug 2005 12:39:21 -0500 +Message-Id: <1124386761.27881.119.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1030/Wed Aug 17 10:53:46 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.032 required=5 tests=[AWL=-0.018, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/233 +X-Sequence-Number: 13980 + +here's an example standard query. Ireally have to make the first hit go +faster. The table is clustered as well on full_name as well. 'Smith%' +took 87 seconds on the first hit. I wonder if I set up may array wrong. +I remeber see something about DMA access versus something else, and +choose DMA access. LVM maybe? + +explain analyze select distinct case_category,identity_id,court.name,litigant_details.case_id,case_year,date_of_birth,assigned_case_role,litigant_details.court_ori,full_name,litigant_details.actor_id,case_data.type_code,case_data.subtype_code,litigant_details.impound_litigant_data, to_number(trim(leading case_data.type_code from trim(leading case_data.case_year from case_data.case_id)),'999999') as seq from identity,court,litigant_details,case_data where identity.court_ori = litigant_details.court_ori and identity.case_id = litigant_details.case_id and identity.actor_id = litigant_details.actor_id and court.id = identity.court_ori and identity.court_ori = case_data.court_ori and case_data.case_id = identity.case_id and identity.court_ori = 'IL081025J' and full_name like 'MILLER%' order by full_name; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Unique (cost=20411.84..20411.91 rows=2 width=173) (actual time=38340.231..38355.120 rows=4906 loops=1) + -> Sort (cost=20411.84..20411.84 rows=2 width=173) (actual time=38340.227..38343.667 rows=4906 loops=1) + Sort Key: identity.full_name, case_data.case_category, identity.identity_id, court.name, litigant_details.case_id, case_data.case_year, identity.date_of_birth, litigant_details.assigned_case_role, litigant_details.court_ori, litigant_details.actor_id, case_data.type_code, case_data.subtype_code, litigant_details.impound_litigant_data, to_number(ltrim(ltrim((case_data.case_id)::text, (case_data.case_year)::text), (case_data.type_code)::text), '999999'::text) + -> Nested Loop (cost=0.00..20411.83 rows=2 width=173) (actual time=12.891..38317.017 rows=4906 loops=1) + -> Nested Loop (cost=0.00..20406.48 rows=1 width=159) (actual time=12.826..23232.106 rows=4906 loops=1) + -> Nested Loop (cost=0.00..20403.18 rows=1 width=138) (actual time=12.751..22885.439 rows=4906 loops=1) + Join Filter: (("outer".case_id)::text = ("inner".case_id)::text) + -> Index Scan using name_speed on identity (cost=0.00..1042.34 rows=4868 width=82) (actual time=0.142..52.538 rows=4915 loops=1) + Index Cond: (((full_name)::text >= 'MILLER'::character varying) AND ((full_name)::text < 'MILLES'::character varying)) + Filter: (((court_ori)::text = 'IL081025J'::text) AND ((full_name)::text ~~ 'MILLER%'::text)) + -> Index Scan using lit_actor_speed on litigant_details (cost=0.00..3.96 rows=1 width=81) (actual time=4.631..4.635 rows=1 loops=4915) + Index Cond: (("outer".actor_id)::text = (litigant_details.actor_id)::text) + Filter: ('IL081025J'::text = (court_ori)::text) + -> Seq Scan on court (cost=0.00..3.29 rows=1 width=33) (actual time=0.053..0.062 rows=1 loops=4906) + Filter: ('IL081025J'::text = (id)::text) + -> Index Scan using case_speed on case_data (cost=0.00..5.29 rows=3 width=53) (actual time=3.049..3.058 rows=1 loops=4906) + Index Cond: (('IL081025J'::text = (case_data.court_ori)::text) AND ((case_data.case_id)::text = ("outer".case_id)::text)) + Total runtime: 38359.722 ms +(18 rows) + +copa=> explain analyze select distinct case_category,identity_id,court.name,litigant_details.case_id,case_year,date_of_birth,assigned_case_role,litigant_details.court_ori,full_name,litigant_details.actor_id,case_data.type_code,case_data.subtype_code,litigant_details.impound_litigant_data, to_number(trim(leading case_data.type_code from trim(leading case_data.case_year from case_data.case_id)),'999999') as seq from identity,court,litigant_details,case_data where identity.court_ori = litigant_details.court_ori and identity.case_id = litigant_details.case_id and identity.actor_id = litigant_details.actor_id and court.id = identity.court_ori and identity.court_ori = case_data.court_ori and case_data.case_id = identity.case_id and identity.court_ori = 'IL081025J' and full_name like 'MILLER%' order by full_name; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Unique (cost=20411.84..20411.91 rows=2 width=173) (actual time=666.832..688.081 rows=4906 loops=1) + -> Sort (cost=20411.84..20411.84 rows=2 width=173) (actual time=666.825..671.833 rows=4906 loops=1) + Sort Key: identity.full_name, case_data.case_category, identity.identity_id, court.name, litigant_details.case_id, case_data.case_year, identity.date_of_birth, litigant_details.assigned_case_role, litigant_details.court_ori, litigant_details.actor_id, case_data.type_code, case_data.subtype_code, litigant_details.impound_litigant_data, to_number(ltrim(ltrim((case_data.case_id)::text, (case_data.case_year)::text), (case_data.type_code)::text), '999999'::text) + -> Nested Loop (cost=0.00..20411.83 rows=2 width=173) (actual time=0.216..641.366 rows=4906 loops=1) + -> Nested Loop (cost=0.00..20406.48 rows=1 width=159) (actual time=0.149..477.063 rows=4906 loops=1) + -> Nested Loop (cost=0.00..20403.18 rows=1 width=138) (actual time=0.084..161.045 rows=4906 loops=1) + Join Filter: (("outer".case_id)::text = ("inner".case_id)::text) + -> Index Scan using name_speed on identity (cost=0.00..1042.34 rows=4868 width=82) (actual time=0.047..37.898 rows=4915 loops=1) + Index Cond: (((full_name)::text >= 'MILLER'::character varying) AND ((full_name)::text < 'MILLES'::character varying)) + Filter: (((court_ori)::text = 'IL081025J'::text) AND ((full_name)::text ~~ 'MILLER%'::text)) + -> Index Scan using lit_actor_speed on litigant_details (cost=0.00..3.96 rows=1 width=81) (actual time=0.015..0.017 rows=1 loops=4915) + Index Cond: (("outer".actor_id)::text = (litigant_details.actor_id)::text) + Filter: ('IL081025J'::text = (court_ori)::text) + -> Seq Scan on court (cost=0.00..3.29 rows=1 width=33) (actual time=0.049..0.056 rows=1 loops=4906) + Filter: ('IL081025J'::text = (id)::text) + -> Index Scan using case_speed on case_data (cost=0.00..5.29 rows=3 width=53) (actual time=0.017..0.020 rows=1 loops=4906) + Index Cond: (('IL081025J'::text = (case_data.court_ori)::text) AND ((case_data.case_id)::text = ("outer".case_id)::text)) + Total runtime: 694.639 ms +(18 rows) + + + +On Thu, 2005-08-18 at 09:00 -0400, Jeff Trout wrote: +> On Aug 17, 2005, at 10:11 PM, Jeremiah Jahn wrote: +> +> > I just put together a system with 6GB of ram on a 14 disk raid 10 +> > array. +> > When I run my usual big painful queries, I get very little to know +> > memory usage. My production box (raid 5 4GB ram) hovers at 3.9GB used +> > most of the time. the new devel box sits at around 250MB. +> > +> +> Is the system performing fine? Are you touching as much data as the +> production box? +> +> If the system is performing fine don't worry about it. +> +> > work_mem = 2097151 # min 64, size in KB +> +> This is EXTREMELY high. You realize this is the amount of memory +> that can be used per-sort and per-hash build in a query? You can end +> up with multiples of this on a single query. If you have some big +> queries that are run infrequently have them set it manually. +> +> > effective_cache_size = 3600000 <-----this is a little out of +> > control, but would it have any real effect? +> +> This doesn't allocate anything - it is a hint to the planner about +> how much data it can assume is cached. +> +> -- +> Jeff Trout +> http://www.jefftrout.com/ +> http://www.stuarthamm.net/ +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +-- +"Now this is a totally brain damaged algorithm. Gag me with a +smurfette." + -- P. Buhr, Computer Science 354 + + +From pgsql-performance-owner@postgresql.org Thu Aug 18 14:55:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E39AB52C67 + for ; + Thu, 18 Aug 2005 14:55:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53635-01 + for ; + Thu, 18 Aug 2005 17:55:12 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E34252BE2 + for ; + Thu, 18 Aug 2005 14:55:10 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050818175508m92009jleke>; Thu, 18 Aug 2005 17:55:09 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 572B955FBA; Thu, 18 Aug 2005 12:55:08 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id B882E55FAD; + Thu, 18 Aug 2005 12:55:03 -0500 (CDT) +Message-ID: <4304CB77.4070403@arbash-meinel.com> +Date: Thu, 18 Aug 2005 12:55:03 -0500 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: Jeff Trout , + postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> +In-Reply-To: <1124386761.27881.119.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigEB715DABC17B44CB3B41A889" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/234 +X-Sequence-Number: 13981 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigEB715DABC17B44CB3B41A889 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: + +>here's an example standard query. Ireally have to make the first hit go +>faster. The table is clustered as well on full_name as well. 'Smith%' +>took 87 seconds on the first hit. I wonder if I set up may array wrong. +>I remeber see something about DMA access versus something else, and +>choose DMA access. LVM maybe? +> +> +It would be nice if you would format your queries to be a little bit +easier to read before posting them. +However, I believe I am reading it correctly, to say that the index scan +on identity is not your slow point. In fact, as near as I can tell, it +only takes 52ms to complete. + +The expensive parts are the 4915 lookups into the litigant_details (each +one takes approx 4ms for a total of ~20s). +And then you do it again on case_data (average 3ms each * 4906 loops = +~15s). + +So there is no need for preloading your indexes on the identity table. +It is definitely not the bottleneck. + +So a few design bits, which may help your database. +Why is "actor_id" a text field instead of a number? +You could try creating an index on "litigant_details (actor_id, +count_ori)" so that it can do just an index lookup, rather than an index ++ filter. + +More importantly, though, the planner seems to think the join of +identity to litigant_details will only return 1 row, not 5000. +Do you regularly vacuum analyze your tables? +Just as a test, try running: +set enable_nested_loop to off; +And then run EXPLAIN ANALYZE again, just to see if it is faster. + +You probably need to increase some statistics targets, so that the +planner can design better plans. + +> -> Nested Loop (cost=0.00..20411.83 rows=2 width=173) +> (actual time=12.891..38317.017 rows=4906 loops=1) +> -> Nested Loop (cost=0.00..20406.48 rows=1 width=159) +> (actual time=12.826..23232.106 rows=4906 loops=1) +> -> Nested Loop (cost=0.00..20403.18 rows=1 +> width=138) (actual time=12.751..22885.439 rows=4906 loops=1) +> Join Filter: (("outer".case_id)::text = +> ("inner".case_id)::text) +> -> Index Scan using name_speed on +> identity (cost=0.00..1042.34 rows=4868 width=82) (actual +> time=0.142..52.538 rows=4915 loops=1) +> Index Cond: (((full_name)::text >= +> 'MILLER'::character varying) AND ((full_name)::text < +> 'MILLES'::character varying)) +> Filter: (((court_ori)::text = +> 'IL081025J'::text) AND ((full_name)::text ~~ 'MILLER%'::text)) +> -> Index Scan using lit_actor_speed on +> litigant_details (cost=0.00..3.96 rows=1 width=81) (actual +> time=4.631..4.635 rows=1 loops=4915) +> Index Cond: (("outer".actor_id)::text +> = (litigant_details.actor_id)::text) +> Filter: ('IL081025J'::text = +> (court_ori)::text) +> -> Seq Scan on court (cost=0.00..3.29 rows=1 +> width=33) (actual time=0.053..0.062 rows=1 loops=4906) +> Filter: ('IL081025J'::text = (id)::text) +> -> Index Scan using case_speed on case_data +> (cost=0.00..5.29 rows=3 width=53) (actual time=3.049..3.058 rows=1 +> loops=4906) +> Index Cond: (('IL081025J'::text = +> (case_data.court_ori)::text) AND ((case_data.case_id)::text = +> ("outer".case_id)::text)) + + +John +=:-> + + +--------------enigEB715DABC17B44CB3B41A889 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDBMt3JdeBCYSNAAMRAj33AJ9qq96tbNdUfwLtoN5YdV8t8mRgmQCgp/rk +mZgsruuYF/yOK8Smgkk+XQE= +=CRGt +-----END PGP SIGNATURE----- + +--------------enigEB715DABC17B44CB3B41A889-- + +From pgsql-performance-owner@postgresql.org Thu Aug 18 16:23:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1064352B28 + for ; + Thu, 18 Aug 2005 16:22:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34278-02 + for ; + Thu, 18 Aug 2005 19:22:48 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 9147C52AB8 + for ; + Thu, 18 Aug 2005 16:22:46 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: limit number of concurrent callers to a stored proc? +Date: Thu, 18 Aug 2005 15:22:46 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD147@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] limit number of concurrent callers to a stored proc? +Thread-Index: AcWjnWbJ7u0/UiC6RFm84YoIU7CBagAi8AjA +From: "Merlin Moncure" +To: "Christopher Kings-Lynne" +Cc: , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/235 +X-Sequence-Number: 13982 + +Christopher +> You could use a 1 column/1 row table perhaps. Use some sort of +locking +> mechanism. +>=20 +> Also, check out contrib/userlock + +userlock is definitely the way to go for this type of problem. =20 + +The are really the only way to provide locking facilities that live +outside transactions. + +You are provided with 48 bits of lock space in the form of offset/block +in 32 bit field and a 16 bit field. The 16 bit field could be the pid +of the locker and the 32 bit field the oid of the function. + +Unfortunately, userlocks are not really easy to query via the pg_locks() +view. However this has been addressed for 8.1. In 8.1, it will be +trivial to create a function which checked the number of lockers on the +function oid and acquire a lock if less than a certain amount. + +Merlin + +From pgsql-performance-owner@postgresql.org Thu Aug 18 16:57:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EFDB352A71 + for ; + Thu, 18 Aug 2005 16:57:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01995-09 + for ; + Thu, 18 Aug 2005 19:57:02 +0000 (GMT) +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by svr1.postgresql.org (Postfix) with ESMTP id 44A4052A44 + for ; + Thu, 18 Aug 2005 16:57:00 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=sylsv3mtKhWcyFo9YODu3cbtw8zheltuLTFbrPQ0QgC+3r/BALJVpx/IIA/Uuq18; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E5qVX-0006nl-SX; Thu, 18 Aug 2005 15:57:00 -0400 +Message-Id: <6.2.3.4.0.20050818141059.05c2fac0@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Thu, 18 Aug 2005 15:56:53 -0400 +To: Jeremiah Jahn +From: Ron +Subject: Re: extremly low memory usage +Cc: postgres performance +In-Reply-To: <4304CB77.4070403@arbash-meinel.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc6a30abf5fc3b1b4640a4a4551cdf78ba350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.882 required=5 tests=[AWL=0.508, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/236 +X-Sequence-Number: 13983 + +At 01:55 PM 8/18/2005, John Arbash Meinel wrote: +>Jeremiah Jahn wrote: +> +> >here's an example standard query. Ireally have to make the first hit go +> >faster. The table is clustered as well on full_name as well. 'Smith%' +> >took 87 seconds on the first hit. I wonder if I set up may array wrong. +> >I remeber see something about DMA access versus something else, and +> >choose DMA access. LVM maybe? +> > +> > +>It would be nice if you would format your queries to be a little bit +>easier to read before posting them. +>However, I believe I am reading it correctly, to say that the index scan +>on identity is not your slow point. In fact, as near as I can tell, it +>only takes 52ms to complete. +> +>The expensive parts are the 4915 lookups into the litigant_details (each +>one takes approx 4ms for a total of ~20s). +>And then you do it again on case_data (average 3ms each * 4906 loops = +>~15s). + +How big are litigant_details and case_data? If they can fit in RAM, +preload them using methods like the "cat to /dev/null" trick and +those table lookups will be ~100-1000x faster. If they won't fit +into RAM but the machine can be expanded to hold enough RAM to fit +the tables, it's well worth the ~$75-$150/GB to upgrade the server so +that the tables will fit into RAM. + +If they can't be made to fit into RAM as atomic entities, you have a +few choices: +A= Put the data tables and indexes on separate dedicated spindles and +put litigant_details and case_data each on their own dedicated +spindles. This will lower seek conflicts. Again it this requires +buying some more HDs, it's well worth it. + +B= Break litigant_details and case_data into a set of smaller tables +(based on something sane like the first n characters of the primary key) +such that the smaller tables easily fit into RAM. Given that you've +said only 10GB/60GB is "hot", this could work very well. Combine it +with "A" above (put all the litigant_details sub tables on one +dedicated spindle set and all the case_data sub tables on another +spindle set) for added oomph. + +C= Buy a SSD big enough to hold litigant_details and case_data and +put them there. Again, this can be combined with "A" and "B" above +to lessen the size of the SSD needed. + + +>So there is no need for preloading your indexes on the identity +>table. It is definitely not the bottleneck. +> +>So a few design bits, which may help your database. Why is +>"actor_id" a text field instead of a number? +>You could try creating an index on "litigant_details (actor_id, +>count_ori)" so that it can do just an index lookup, rather than an +>index+ filter. + +Yes, that certainly sounds like it would be more efficient. + + +>More importantly, though, the planner seems to think the join of +>identity to litigant_details will only return 1 row, not 5000. +>Do you regularly vacuum analyze your tables? +>Just as a test, try running: +>set enable_nested_loop to off; +>And then run EXPLAIN ANALYZE again, just to see if it is faster. +> +>You probably need to increase some statistics targets, so that the +>planner can design better plans. +> +> > -> Nested Loop (cost=0.00..20411.83 rows=2 width=173) (actual +> time=12.891..38317.017 rows=4906 loops=1) +> > -> Nested Loop (cost=0.00..20406.48 rows=1 width=159)(actual +> time=12.826..23232.106 rows=4906 loops=1) +> > -> Nested Loop (cost=0.00..20403.18 rows=1 width=138) +> (actual time=12.751..22885.439 rows=4906 loops=1) +> > Join Filter: (("outer".case_id)::text = +> ("inner".case_id)::text) +> > -> Index Scan using name_speed on +> identity (cost=0.00..1042.34 rows=4868 width=82) (actual time=0.142..52.538 +> > rows=4915 loops=1) +> > Index Cond: (((full_name)::text >= +> 'MILLER'::character varying) AND ((full_name)::text < +> 'MILLES'::character varying)) +> > Filter: (((court_ori)::text = +> 'IL081025J'::text) AND ((full_name)::text ~~ 'MILLER%'::text)) +> > -> Index Scan using lit_actor_speed on +> litigant_details (cost=0.00..3.96 rows=1 width=81) (actual +> > time=4.631..4.635 rows=1 loops=4915) +> > Index Cond: (("outer".actor_id)::text = +> (litigant_details.actor_id)::text) +> > Filter: ('IL081025J'::text = (court_ori)::text) +> > -> Seq Scan on court (cost=0.00..3.29 +> rows=1 width=33) (actual time=0.053..0.062 rows=1 loops=4906) +> > Filter: ('IL081025J'::text = (id)::text) +> > -> Index Scan using case_speed on +> case_data (cost=0.00..5.29 rows=3 width=53) (actual time=3.049..3.058 +> > rows=1 loops=4906) +> > Index Cond: (('IL081025J'::text +> = (case_data.court_ori)::text) AND ((case_data.case_id)::text = +> > ("outer".case_id)::text)) + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 18 19:08:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 495AF528C3 + for ; + Thu, 18 Aug 2005 19:08:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43853-02 + for ; + Thu, 18 Aug 2005 22:08:50 +0000 (GMT) +Received: from dns.deep-purple.com (dns.deep-purple.com [209.61.158.121]) + by svr1.postgresql.org (Postfix) with ESMTP id AEE5652BFA + for ; + Thu, 18 Aug 2005 19:08:46 -0300 (ADT) +Received: from [192.168.5.2] (195-112-29-123.dyn.gotadsl.co.uk + [195.112.29.123]) (authenticated) + by dns.deep-purple.com (8.11.6/8.11.6) with ESMTP id j7IM8ZT07600; + Thu, 18 Aug 2005 17:08:35 -0500 +In-Reply-To: <722B1B9CFE0ECE488342E3EC2BA920B86CC443@mailserver> +References: <722B1B9CFE0ECE488342E3EC2BA920B86CC443@mailserver> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <701BBF0B-1E25-4BC0-BF7C-0D53EAD2784D@hodgkinson.org> +Cc: +Content-Transfer-Encoding: 7bit +From: David Hodgkinson +Subject: Re: FW: Tx forecast improving harware capabilities. +Date: Thu, 18 Aug 2005 23:08:29 +0100 +To: Sebastian Lallana +X-Mailer: Apple Mail (2.734) +X-RIF3-MailScanner-Information: Please contact the ISP for more information +X-RIF3-MailScanner: Found to be clean +X-RIF3-MailScanner-SpamCheck: not spam, SpamAssassin (score=-4.871, + required 5, autolearn=not spam, AWL 0.03, BAYES_00 -4.90) +X-MailScanner-From: daveh@hodgkinson.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/237 +X-Sequence-Number: 13984 + + +On 18 Aug 2005, at 16:01, Sebastian Lallana wrote: + + +> It exists something like this? Does anybody has experience about +> this subject? + +I've just been through this with a client with both a badly tuned Pg and +an application being less than optimal. + +First, find a benchmark. Just something you can hold on to. For us, it +was the generation time of the site's home page. In this case, 7 +seconds. +We looked hard at postgresql.conf, planned the memory usage, sort_memory +and all that. That was a boost. Then we looked at the queries that were +being thrown at the database. Over 200 to build one page! So, a layer +of caching was built into the web server layer. Finally, some frequently +occurring combinations of queries were pushed down into stored procs. +We got the page gen time down to 1.5 seconds AND the server being stable +under extreme stress. So, a fair win. + +Thanks to cms for several clues. + +So, without understanding your application and were it's taking the +time, +you can't begin to estimate hardware usage. + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 03:56:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7009052D18 + for ; + Fri, 19 Aug 2005 03:55:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87395-08 + for ; + Fri, 19 Aug 2005 06:55:21 +0000 (GMT) +Received: from mail23.sea5.speakeasy.net (mail23.sea5.speakeasy.net + [69.17.117.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 15F8352DE8 + for ; + Fri, 19 Aug 2005 03:55:18 -0300 (ADT) +Received: (qmail 5497 invoked from network); 19 Aug 2005 06:55:18 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail23.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 19 Aug 2005 06:55:18 -0000 +Subject: Re: Query plan looks OK, but slow I/O - settings advice? +From: "Jeffrey W. Baker" +To: Roger Hand +Cc: pgsql-performance@postgresql.org +In-Reply-To: + +References: + +Content-Type: text/plain +Date: Thu, 18 Aug 2005 23:55:35 -0700 +Message-Id: <1124434535.3257.7.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/247 +X-Sequence-Number: 13994 + +On Tue, 2005-08-16 at 10:46 -0700, Roger Hand wrote: +> The disks are ext3 with journalling type of ordered, but this was later changed to writeback with no apparent change in speed. +> +> They're on a Dell poweredge 6650 with LSI raid card, setup as follows: +> 4 disks raid 10 for indexes (145GB) - sdc1 +> 6 disks raid 10 for data (220GB) - sdd1 +> 2 mirrored disks for logs - sdb1 +> +> stripe size is 32k +> cache policy: cached io (am told the controller has bbu) +> write policy: write-back +> read policy: readahead + +I assume you are using Linux 2.6. Have you considered booting your +machine with elevator=deadline? You can also change this at runtime +using sysfs. + +These read speeds are not too impressive. Perhaps this is a slow +controller. Alternately you might need bigger CPUs. + +There's a lot of possibilities, obviously :) I'd start with the +elevator, since that's easily tested. + +-jwb + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 04:18:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CF4152CEA + for ; + Fri, 19 Aug 2005 04:18:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45563-10 + for ; + Fri, 19 Aug 2005 07:17:59 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 71FEE52CBB + for ; + Fri, 19 Aug 2005 04:17:56 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j7J7HlIO031072; + Fri, 19 Aug 2005 17:17:48 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j7J7HjEF031069; Fri, 19 Aug 2005 17:17:47 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Fri, 19 Aug 2005 17:17:45 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Roger Hand +Cc: pgsql-performance@postgresql.org +Subject: Re: Query plan looks OK, but slow I/O - settings advice? +In-Reply-To: + +Message-ID: +References: + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.002 required=5 tests=[AWL=0.002] +X-Spam-Level: +X-Archive-Number: 200508/248 +X-Sequence-Number: 13995 + +The query plan does *not* look okay. + +> electric=# EXPLAIN ANALYZE +> electric-# SELECT datavalue, logfielddatatype, timestamp FROM logdata_recent +> electric-# WHERE (logfielddatatype = 70 OR logfielddatatype = 71 OR logfielddatatype = 69) +> electric-# AND graphtargetlog = 1327 +> electric-# AND timestamp >= 1123052400 AND timestamp <= 1123138800 +> electric-# ORDER BY timestamp; +> QUERY PLAN +> -------------------------------------------------- +> Sort (cost=82.48..82.50 rows=6 width=14) (actual time=60208.968..60211.232 rows=2625 loops=1) +> Sort Key: public.logdata_recent."timestamp" +> -> Result (cost=0.00..82.41 rows=6 width=14) (actual time=52.483..60200.868 rows=2625 loops=1) +> -> Append (cost=0.00..82.41 rows=6 width=14) (actual time=52.476..60189.929 rows=2625 loops=1) +> -> Seq Scan on logdata_recent (cost=0.00..46.25 rows=1 width=14) (actual time=0.003..0.003 rows=0 loops=1) +> Filter: (((logfielddatatype = 70) OR (logfielddatatype = 71) OR (logfielddatatype = 69)) AND (graphtargetlog = 1327) AND ("timestamp" >= 1123052400) AND ("timestamp" <= 1123138800)) +> -> Index Scan using logdata_recent_1123085306_ix_t_fld_gtl, logdata_recent_1123085306_ix_t_fld_gtl, logdata_recent_1123085306_ix_t_fld_gtl on logdata_recent_stale logdata_recent (cost=0.00..18.08 rows=3 width=14) (actual time=52.465..60181.624 rows=2625 loops=1) + +Notice here that expected rows is 3, but actual rows is a hell of a lot +higher. Try increasing stats collections for the columns on which +logdata_recent_1123085306_ix_t_fld_gtl is declared. + +Also, the actual index scan is taking a long time. How recently have you +vacuum full'd? + +Thanks, + +Gavin + +From pgsql-performance-owner@postgresql.org Fri Aug 19 04:35:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E1BE52DD0 + for ; + Fri, 19 Aug 2005 04:35:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91837-09 + for ; + Fri, 19 Aug 2005 07:35:25 +0000 (GMT) +Received: from sj1-exch-01.us.corp.kailea.com (mail.ragingnet.net + [209.249.149.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CBE252DFC + for ; + Fri, 19 Aug 2005 04:35:22 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Query plan looks OK, but slow I/O - settings advice? +Date: Fri, 19 Aug 2005 00:35:23 -0700 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Query plan looks OK, but slow I/O - settings advice? +Thread-Index: AcWkiviNpjnrx5NjS8eZ5LEY435vXgAA/ycw +From: "Roger Hand" +To: "Jeffrey W. Baker" +Cc: , + "Leszek Kotzian" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.344 required=5 tests=[AWL=-0.292, + FORGED_RCVD_HELO=0.05, HOT_NASTY=0.586] +X-Spam-Level: +X-Archive-Number: 200508/249 +X-Sequence-Number: 13996 + +Jeffrey W. Baker wrote: +> On Tue, 2005-08-16 at 10:46 -0700, Roger Hand wrote: +>> The disks are ext3 with journalling type of ordered, but this was = +later changed to writeback with no apparent change in speed. +>>=20 +>> They're on a Dell poweredge 6650 with LSI raid card, setup as = +follows: +>> 4 disks raid 10 for indexes (145GB) - sdc1 +>> 6 disks raid 10 for data (220GB) - sdd1 +>> 2 mirrored disks for logs - sdb1 +>>=20 +>> stripe size is 32k +>> cache policy: cached io (am told the controller has bbu) +>> write policy: write-back +>> read policy: readahead +>=20 +> I assume you are using Linux 2.6. =20 + +Oops, sorry I left that out. Nope, we're on 2.4: + +[root@rage-db2 ~]$ uname -a +Linux xxx.xxx.xxx 2.4.21-27.0.2.ELsmp #1 SMP Wed Jan 12 23:35:44 EST = +2005 i686 i686 i386 GNU/Linux + +It's RedHat Enterprise AS3.0 Fri Nov 5 17:55:14 PST 2004 + +> Have you considered booting your +> machine with elevator=3Ddeadline?=20 + +I just did a little Googling and see that the 2.4 kernel didn't have a = +decent elevator tuning system, and that was fixed in 2.6. Hmmm .... + +Thanks for the ideas ... + +-Roger + +From pgsql-performance-owner@postgresql.org Fri Aug 19 05:24:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EA32B52D58 + for ; + Fri, 19 Aug 2005 05:24:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29025-05 + for ; + Fri, 19 Aug 2005 08:24:04 +0000 (GMT) +Received: from web32915.mail.mud.yahoo.com (web32915.mail.mud.yahoo.com + [68.142.206.62]) + by svr1.postgresql.org (Postfix) with SMTP id A39C352CEA + for ; + Fri, 19 Aug 2005 05:24:02 -0300 (ADT) +Received: (qmail 53753 invoked by uid 60001); 19 Aug 2005 08:24:04 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=QEFBL9/jqKbUl/eHyZ2CWh/w//9L6anHWaJUkX/5A9UHFP9xuUFfIPQF22XtubMz6C+UUk08f3Lq3crR+DP0V2Jtuw++n1iTzgQDh8V37Gvtf4+n35KAoxvN9T5uZQZSYL4sWAA3Ibwf7u9lPsRM/TULTmjSj+ta2lISmxoVHCk= + ; +Message-ID: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> +Received: from [66.56.49.200] by web32915.mail.mud.yahoo.com via HTTP; + Fri, 19 Aug 2005 01:24:04 PDT +Date: Fri, 19 Aug 2005 01:24:04 -0700 (PDT) +From: Mark Cotner +Subject: sustained update load of 1-2k/sec +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.28 required=5 tests=[AWL=-0.093, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/250 +X-Sequence-Number: 13997 + +Hi all, +I bet you get tired of the same ole questions over and +over. + +I'm currently working on an application that will poll +thousands of cable modems per minute and I would like +to use PostgreSQL to maintain state between polls of +each device. This requires a very heavy amount of +updates in place on a reasonably large table(100k-500k +rows, ~7 columns mostly integers/bigint). Each row +will be refreshed every 15 minutes, or at least that's +how fast I can poll via SNMP. I hope I can tune the +DB to keep up. + +The app is threaded and will likely have well over 100 +concurrent db connections. Temp tables for storage +aren't a preferred option since this is designed to be +a shared nothing approach and I will likely have +several polling processes. + +Here are some of my assumptions so far . . . + +HUGE WAL +Vacuum hourly if not more often + +I'm getting 1700tx/sec from MySQL and I would REALLY +prefer to use PG. I don't need to match the number, +just get close. + +Is there a global temp table option? In memory tables +would be very beneficial in this case. I could just +flush it to disk occasionally with an insert into blah +select from memory table. + +Any help or creative alternatives would be greatly +appreciated. :) + +'njoy, +Mark + + +-- +Writing software requires an intelligent person, +creating functional art requires an artist. +-- Unknown + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 06:09:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2477C52C59 + for ; + Fri, 19 Aug 2005 06:09:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46670-05 + for ; + Fri, 19 Aug 2005 09:09:37 +0000 (GMT) +Received: from redivi.com (redivi.com [64.207.133.54]) + by svr1.postgresql.org (Postfix) with ESMTP id E885C52B52 + for ; + Fri, 19 Aug 2005 06:09:35 -0300 (ADT) +Received: from [64.203.23.17] (helo=[192.168.0.8]) + by redivi.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.43) + id 1E62sa-0001E6-6n; Fri, 19 Aug 2005 02:09:37 -0700 +In-Reply-To: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> +Mime-Version: 1.0 (Apple Message framework v733) +Message-Id: <67788A4A-4011-49AB-B329-683FD9532661@redivi.com> +Cc: pgsql-performance@postgresql.org +From: Bob Ippolito +Date: Thu, 18 Aug 2005 23:09:27 -1000 +To: Mark Cotner +X-Mailer: Apple Mail (2.733) +X-SA-Exim-Connect-IP: 64.203.23.17 +X-SA-Exim-Mail-From: bob@redivi.com +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Content-Transfer-Encoding: 7bit +Subject: Re: sustained update load of 1-2k/sec +X-SA-Exim-Version: 4.1+cvs (built Mon, 23 Aug 2004 08:44:05 -0700) +X-SA-Exim-Scanned: Yes (on redivi.com) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/251 +X-Sequence-Number: 13998 + + +On Aug 18, 2005, at 10:24 PM, Mark Cotner wrote: + +> I'm currently working on an application that will poll +> thousands of cable modems per minute and I would like +> to use PostgreSQL to maintain state between polls of +> each device. This requires a very heavy amount of +> updates in place on a reasonably large table(100k-500k +> rows, ~7 columns mostly integers/bigint). Each row +> will be refreshed every 15 minutes, or at least that's +> how fast I can poll via SNMP. I hope I can tune the +> DB to keep up. +> +> The app is threaded and will likely have well over 100 +> concurrent db connections. Temp tables for storage +> aren't a preferred option since this is designed to be +> a shared nothing approach and I will likely have +> several polling processes. + +Somewhat OT, but.. + +The easiest way to speed that up is to use less threads. You're +adding a whole TON of overhead with that many threads that you just +don't want or need. You should probably be using something event- +driven to solve this problem, with just a few database threads to +store all that state. Less is definitely more in this case. See + (and there's plenty of other +literature out there saying that event driven is an extremely good +way to do this sort of thing). + +Here are some frameworks to look at for this kind of network code: +(Python) Twisted - +(Perl) POE - +(Java) java.nio (not familiar enough with the Java thing to know +whether or not there's a high-level wrapper) +(C++) ACE - +(Ruby) IO::Reactor - +(C) libevent - + +.. and of course, you have select/poll/kqueue/WaitNextEvent/whatever +that you could use directly, if you wanted to roll your own solution, +but don't do that. + +If you don't want to optimize the whole application, I'd at least +just push the DB operations down to a very small number of +connections (*one* might even be optimal!), waiting on some kind of +thread-safe queue for updates from the rest of the system. This way +you can easily batch those updates into transactions and you won't be +putting so much unnecessary synchronization overhead into your +application and the database. + +Generally, once you have more worker threads (or processes) than +CPUs, you're going to get diminishing returns in a bad way, assuming +those threads are making good use of their time. + +-bob + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 07:15:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D7545291A + for ; + Fri, 19 Aug 2005 07:14:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07604-01 + for ; + Fri, 19 Aug 2005 10:14:55 +0000 (GMT) +Received: from smtp106.mail.sc5.yahoo.com (smtp106.mail.sc5.yahoo.com + [66.163.169.226]) + by svr1.postgresql.org (Postfix) with SMTP id A5150528C3 + for ; + Fri, 19 Aug 2005 07:14:53 -0300 (ADT) +Received: (qmail 2178 invoked from network); 19 Aug 2005 10:14:56 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Received:User-Agent:Date:Subject:From:To:CC:Message-ID:In-Reply-To:Mime-version:Content-type:Content-transfer-encoding; + b=lyv/h+YDXeUfE66KEq88++EvoTA4z3Ep96c+jUOoujdvTuJXRREDskLQyFb9wotC68frqppIejCjs8PS9xDdB0HzLgqfxm0bAVo3vIvjuGcoLG21yKo6Uy/MJgu3WL7au3faEefHlmqDSGLf+k7uh/efgQltKn2jdRmCTa6hZwk= + ; +Received: from unknown (HELO ?192.168.0.103?) (mcotner@66.56.49.200 with + login) + by smtp106.mail.sc5.yahoo.com with SMTP; 19 Aug 2005 10:14:55 -0000 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Fri, 19 Aug 2005 06:14:54 -0400 +Subject: Re: sustained update load of 1-2k/sec +From: Mark Cotner +To: Bob Ippolito +Cc: +Message-ID: +In-Reply-To: <67788A4A-4011-49AB-B329-683FD9532661@redivi.com> +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.28 required=5 tests=[AWL=-0.093, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/252 +X-Sequence-Number: 13999 + +Excellent feedback. Thank you. Please do keep in mind I'm storing the +results of SNMP queries. The majority of the time each thread is in a wait +state, listening on a UDP port for return packet. The number of threads is +high because in order to sustain poll speed I need to minimize the impact of +timeouts and all this waiting for return packets. + +I had intended to have a fallback plan which would build a thread safe queue +for db stuffs, but the application isn't currently architected that way. +It's not completely built yet so now is the time for change. I hadn't +thought of building up a batch of queries and creating a transaction from +them. + +I've been looking into memcached as a persistent object store as well and +hadn't seen the reactor pattern yet. Still trying to get my puny brain +around that one. + +Again, thanks for the help. + +'njoy, +Mark + + +On 8/19/05 5:09 AM, "Bob Ippolito" wrote: + +> +> On Aug 18, 2005, at 10:24 PM, Mark Cotner wrote: +> +>> I'm currently working on an application that will poll +>> thousands of cable modems per minute and I would like +>> to use PostgreSQL to maintain state between polls of +>> each device. This requires a very heavy amount of +>> updates in place on a reasonably large table(100k-500k +>> rows, ~7 columns mostly integers/bigint). Each row +>> will be refreshed every 15 minutes, or at least that's +>> how fast I can poll via SNMP. I hope I can tune the +>> DB to keep up. +>> +>> The app is threaded and will likely have well over 100 +>> concurrent db connections. Temp tables for storage +>> aren't a preferred option since this is designed to be +>> a shared nothing approach and I will likely have +>> several polling processes. +> +> Somewhat OT, but.. +> +> The easiest way to speed that up is to use less threads. You're +> adding a whole TON of overhead with that many threads that you just +> don't want or need. You should probably be using something event- +> driven to solve this problem, with just a few database threads to +> store all that state. Less is definitely more in this case. See +> (and there's plenty of other +> literature out there saying that event driven is an extremely good +> way to do this sort of thing). +> +> Here are some frameworks to look at for this kind of network code: +> (Python) Twisted - +> (Perl) POE - +> (Java) java.nio (not familiar enough with the Java thing to know +> whether or not there's a high-level wrapper) +> (C++) ACE - +> (Ruby) IO::Reactor - +> (C) libevent - +> +> .. and of course, you have select/poll/kqueue/WaitNextEvent/whatever +> that you could use directly, if you wanted to roll your own solution, +> but don't do that. +> +> If you don't want to optimize the whole application, I'd at least +> just push the DB operations down to a very small number of +> connections (*one* might even be optimal!), waiting on some kind of +> thread-safe queue for updates from the rest of the system. This way +> you can easily batch those updates into transactions and you won't be +> putting so much unnecessary synchronization overhead into your +> application and the database. +> +> Generally, once you have more worker threads (or processes) than +> CPUs, you're going to get diminishing returns in a bad way, assuming +> those threads are making good use of their time. +> +> -bob +> + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 08:28:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A4E8A529EF + for ; + Fri, 19 Aug 2005 08:28:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76808-07 + for ; + Fri, 19 Aug 2005 11:28:27 +0000 (GMT) +Received: from redivi.com (redivi.com [64.207.133.54]) + by svr1.postgresql.org (Postfix) with ESMTP id A516C529EE + for ; + Fri, 19 Aug 2005 08:28:27 -0300 (ADT) +Received: from [64.203.23.17] (helo=[192.168.0.8]) + by redivi.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.43) + id 1E652x-0001el-CE; Fri, 19 Aug 2005 04:28:30 -0700 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v733) +Message-Id: <9852B15E-8F9D-46F5-B4B4-9EAAE26F1AF7@redivi.com> +Cc: +From: Bob Ippolito +Date: Fri, 19 Aug 2005 01:28:07 -1000 +To: Mark Cotner +X-Mailer: Apple Mail (2.733) +X-SA-Exim-Connect-IP: 64.203.23.17 +X-SA-Exim-Mail-From: bob@redivi.com +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Content-Transfer-Encoding: 7bit +Subject: Re: sustained update load of 1-2k/sec +X-SA-Exim-Version: 4.1+cvs (built Mon, 23 Aug 2004 08:44:05 -0700) +X-SA-Exim-Scanned: Yes (on redivi.com) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/253 +X-Sequence-Number: 14000 + + +On Aug 19, 2005, at 12:14 AM, Mark Cotner wrote: + +> Excellent feedback. Thank you. Please do keep in mind I'm storing +> the +> results of SNMP queries. The majority of the time each thread is +> in a wait +> state, listening on a UDP port for return packet. The number of +> threads is +> high because in order to sustain poll speed I need to minimize the +> impact of +> timeouts and all this waiting for return packets. + +Asynchronous IO via select/poll/etc. basically says: "given these 100 +sockets, wake me up when any of them has something to tell me, or +wake me up anyway in N milliseconds". From one thread, you can +usually deal with thousands of connections without breaking a sweat, +where with thread-per-connection you have so much overhead just for +the threads that you probably run out of RAM before your network is +throttled. The reactor pattern basically just abstracts this a bit +so that you worry about what do to when the sockets have something to +say, and also allow you to schedule timed events, rather than having +to worry about how to implement that correctly *and* write your +application. + +With 100 threads you are basically invoking a special-case of the +same mechanism that only looks at one socket, but this makes for 100 +different data structures that end up in both userspace and kernel +space, plus the thread stacks (which can easily be a few megs each) +and context switching when any of them wakes up.. You're throwing a +lot of RAM and CPU cycles out the window by using this design. + +Also, preemptive threads are hard. + +> I had intended to have a fallback plan which would build a thread +> safe queue +> for db stuffs, but the application isn't currently architected that +> way. +> It's not completely built yet so now is the time for change. I hadn't +> thought of building up a batch of queries and creating a +> transaction from +> them. + +It should be *really* easy to just swap out the implementation of +your "change this record" function with one that simply puts its +arguments on a queue, with another thread that gets them from the +queue and actually does the work. + +> I've been looking into memcached as a persistent object store as +> well and +> hadn't seen the reactor pattern yet. Still trying to get my puny +> brain +> around that one. + +memcached is RAM based, it's not persistent at all... unless you are +sure all of your nodes will be up at all times and will never go +down. IIRC, it also just starts throwing away data once you hit its +size limit. If course, this isn't really any different than MySQL's +MyISAM tables if you hit the row limit, but I think that memcached +might not even give you an error when this happens. Also, memcached +is just key/value pairs over a network, not much of a database going +on there. + +If you can fit all this data in RAM and you don't care so much about +the integrity, you might not benefit much from a RDBMS at all. +However, I don't really know what you're doing with the data once you +have it so I might be very wrong here... + +-bob + +> +> Again, thanks for the help. +> +> 'njoy, +> Mark +> +> +> On 8/19/05 5:09 AM, "Bob Ippolito" wrote: +> +> +>> +>> On Aug 18, 2005, at 10:24 PM, Mark Cotner wrote: +>> +>> +>>> I'm currently working on an application that will poll +>>> thousands of cable modems per minute and I would like +>>> to use PostgreSQL to maintain state between polls of +>>> each device. This requires a very heavy amount of +>>> updates in place on a reasonably large table(100k-500k +>>> rows, ~7 columns mostly integers/bigint). Each row +>>> will be refreshed every 15 minutes, or at least that's +>>> how fast I can poll via SNMP. I hope I can tune the +>>> DB to keep up. +>>> +>>> The app is threaded and will likely have well over 100 +>>> concurrent db connections. Temp tables for storage +>>> aren't a preferred option since this is designed to be +>>> a shared nothing approach and I will likely have +>>> several polling processes. +>>> +>> +>> Somewhat OT, but.. +>> +>> The easiest way to speed that up is to use less threads. You're +>> adding a whole TON of overhead with that many threads that you just +>> don't want or need. You should probably be using something event- +>> driven to solve this problem, with just a few database threads to +>> store all that state. Less is definitely more in this case. See +>> (and there's plenty of other +>> literature out there saying that event driven is an extremely good +>> way to do this sort of thing). +>> +>> Here are some frameworks to look at for this kind of network code: +>> (Python) Twisted - +>> (Perl) POE - +>> (Java) java.nio (not familiar enough with the Java thing to know +>> whether or not there's a high-level wrapper) +>> (C++) ACE - +>> (Ruby) IO::Reactor - +>> (C) libevent - +>> +>> .. and of course, you have select/poll/kqueue/WaitNextEvent/whatever +>> that you could use directly, if you wanted to roll your own solution, +>> but don't do that. +>> +>> If you don't want to optimize the whole application, I'd at least +>> just push the DB operations down to a very small number of +>> connections (*one* might even be optimal!), waiting on some kind of +>> thread-safe queue for updates from the rest of the system. This way +>> you can easily batch those updates into transactions and you won't be +>> putting so much unnecessary synchronization overhead into your +>> application and the database. +>> +>> Generally, once you have more worker threads (or processes) than +>> CPUs, you're going to get diminishing returns in a bad way, assuming +>> those threads are making good use of their time. +>> +>> -bob +>> +>> +> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 08:36:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E826529F5 + for ; + Fri, 19 Aug 2005 08:36:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95556-10 + for ; + Fri, 19 Aug 2005 11:36:42 +0000 (GMT) +Received: from purple.bdb.fi (purple.bdb.fi [195.197.212.62]) + by svr1.postgresql.org (Postfix) with ESMTP id C77F452899 + for ; + Fri, 19 Aug 2005 08:36:38 -0300 (ADT) +Received: by purple.bdb.fi (Postfix, from userid 101) + id 58CDE31D2; Fri, 19 Aug 2005 14:34:47 +0300 (EETDST) +Received: from localhost (localhost [127.0.0.1]) + by purple.bdb.fi (Postfix) with ESMTP id 4D2A1292D; + Fri, 19 Aug 2005 14:34:47 +0300 (EETDST) +Date: Fri, 19 Aug 2005 14:34:47 +0300 (EETDST) +From: Kari Lavikka +To: Tom Lane +Cc: pgsql-performance@postgresql.org, rjpeace@earthlink.net +Subject: Re: Finding bottleneck +In-Reply-To: <29384.1123520200@sss.pgh.pa.us> +Message-ID: +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD026@Herge.rcsinc.local> + + <29384.1123520200@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/254 +X-Sequence-Number: 14001 + +On Mon, 8 Aug 2005, Tom Lane wrote: +> What that sounds like to me is a machine with inadequate disk I/O bandwidth. +> Your earlier comment that checkpoint drives the machine into the ground +> fits right into that theory, too. You said there is "almost no IO-wait" +> but are you sure you are measuring that correctly? + +Reducing checkpoint_timeout to 600 seconds had a positive effect. Previous +value was 1800 seconds. + +We have a spare disk array from the old server and I'm planning to use it +as a tablespace for the comment table (the 100M+ rows one) as Ron +suggested. + +>> Queries accumulate and when checkpointing is over, there can be +>> something like 400 queries running but over 50% of cpu is just idling. +> +> 400 queries? Are you launching 400 separate backends to do that? +> Some sort of connection pooling seems like a good idea, if you don't +> have it in place already. If the system's effective behavior in the +> face of heavy load is to start even more concurrent backends, that +> could easily drive things into the ground. + +Ok, I implemented connection pooling using pgpool and it increased +performance a lot! We are now delivering about 1500 dynamic pages a second +without problems. Each of the eight single-cpu webservers are running a +pgpool instance with 20 connections. + +However, those configuration changes didn't have significant effect to +oprofile results. AtEOXact_CatCache consumes even more cycles. This isn't +a problem right now but it may be in the future... + +CPU: AMD64 processors, speed 2190.23 MHz (estimated) +Counted CPU_CLK_UNHALTED events (Cycles outside of halt state) with a unit mask of 0x00 (No unit mask) count 100000 +samples % symbol name +1147870 21.1602 AtEOXact_CatCache +187466 3.4558 hash_seq_search +174357 3.2142 AllocSetAlloc +170896 3.1504 nocachegetattr +131724 2.4282 ExecMakeFunctionResultNoSets +125292 2.3097 SearchCatCache +117264 2.1617 StrategyDirtyBufferList +105741 1.9493 hash_search +98245 1.8111 FunctionCall2 +97878 1.8043 yyparse +90932 1.6763 LWLockAcquire +83555 1.5403 LWLockRelease +81045 1.4940 _bt_compare +... and so on ... + +----->8 Signigicant rows from current postgresql.conf 8<----- + +max_connections = 768 # unnecessarily large with connection +pooling +shared_buffers = 15000 +work_mem = 2048 +maintenance_work_mem = 32768 +max_fsm_pages = 1000000 +max_fsm_relations = 5000 +bgwriter_percent = 2 +fsync = true +wal_buffers = 512 +checkpoint_segments = 200 # less would probably be enuff with 600sec +timeout +checkpoint_timeout = 600 +effective_cache_size = 500000 +random_page_cost = 1.5 +default_statistics_target = 150 +stats_start_collector = true +stats_command_string = true + + + |\__/| + ( oo ) Kari Lavikka - tuner@bdb.fi - (050) 380 3808 +__ooO( )Ooo_______ _____ ___ _ _ _ _ _ _ _ + "" + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 09:50:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B81CA52C1F + for ; + Fri, 19 Aug 2005 09:50:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80161-04 + for ; + Fri, 19 Aug 2005 12:50:03 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C1E8952B3D + for ; + Fri, 19 Aug 2005 09:50:02 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 85A9530B42; Fri, 19 Aug 2005 15:01:30 +0200 (MET DST) +From: Christopher Browne +X-Newsgroups: pgsql.performance +Subject: Re: Need for speed +Date: Fri, 19 Aug 2005 08:00:26 -0400 +Organization: cbbrowne Computing Inc +Lines: 33 +Message-ID: +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, + berkeley-unix) +Cancel-Lock: sha1:2WATvvUFlUBNDukomBEVrYVzI0c= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.116 required=5 tests=[AWL=0.116] +X-Spam-Level: +X-Archive-Number: 200508/256 +X-Sequence-Number: 14003 + +>> Ulrich Wisser wrote: +>> > +>> > one of our services is click counting for on line advertising. We do +>> > this by importing Apache log files every five minutes. This results in a +>> > lot of insert and delete statements. +> ... +>> If you are doing mostly inserting, make sure you are in a transaction, +> +> Well, yes, but you may need to make sure that a single transaction +> doesn't have too many inserts in it. I was having a performance +> problem when doing transactions with a huge number of inserts (tens +> of thousands), and I solved the problem by putting a simple counter +> in the loop (in the Java import code, that is) and doing a commit +> every 100 or so inserts. + +Are you sure that was an issue with PostgreSQL? + +I have certainly observed that issue with Oracle, but NOT with +PostgreSQL. + +I have commonly done data loads where they loaded 50K rows at a time, +the reason for COMMITting at that point being "programming paranoia" +at the possibility that some data might fail to load and need to be +retried, and I'd rather have less fail... + +It would seem more likely that the issue would be on the Java side; it +might well be that the data being loaded might bloat JVM memory usage, +and that the actions taken at COMMIT time might keep the size of the +Java-side memory footprint down. +-- +(reverse (concatenate 'string "moc.liamg" "@" "enworbbc")) +http://cbbrowne.com/info/ +If we were meant to fly, we wouldn't keep losing our luggage. + +From pgsql-performance-owner@postgresql.org Fri Aug 19 09:41:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A14C552BCA + for ; + Fri, 19 Aug 2005 09:40:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66529-05 + for ; + Fri, 19 Aug 2005 12:40:46 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) + by svr1.postgresql.org (Postfix) with ESMTP id A4BFB52E45 + for ; + Fri, 19 Aug 2005 09:40:38 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i22so507916wra + for ; + Fri, 19 Aug 2005 05:40:39 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=akHVlRYJ02H0PDPuDv/e84h115C5Zk6FwUE3USQDOkBsM4YcNMf88fIhmrd2Zvhoz9maRWiLsqbwx2/CMcITT2t7sp8wDx/A61nCNtwTbf+Wxc/gTNgnxZDMSNwRYZvk1Kn/qR43yl03/X1YCwt6y9Rw4PjEnCG8IPiEj0Io8L0= +Received: by 10.54.32.60 with SMTP id f60mr1248568wrf; + Fri, 19 Aug 2005 05:40:39 -0700 (PDT) +Received: by 10.54.86.15 with HTTP; Fri, 19 Aug 2005 05:40:39 -0700 (PDT) +Message-ID: <33c6269f050819054038af9886@mail.gmail.com> +Date: Fri, 19 Aug 2005 08:40:39 -0400 +From: Alex Turner +To: Mark Cotner +Subject: Re: sustained update load of 1-2k/sec +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.104 required=5 tests=[AWL=0.080, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/255 +X-Sequence-Number: 14002 + +I have managed tx speeds that high from postgresql going even as high +as 2500/sec for small tables, but it does require a good RAID +controler card (yes I'm even running with fsync on). I'm using 3ware +9500S-8MI with Raptor drives in multiple RAID 10s. The box wasn't too +$$$ at just around $7k. I have two independant controlers on two +independant PCI buses to give max throughput. on with a 6 drive RAID +10 and the other with two 4 drive RAID 10s. + +Alex Turner +NetEconomist + +On 8/19/05, Mark Cotner wrote: +> Hi all, +> I bet you get tired of the same ole questions over and +> over. +>=20 +> I'm currently working on an application that will poll +> thousands of cable modems per minute and I would like +> to use PostgreSQL to maintain state between polls of +> each device. This requires a very heavy amount of +> updates in place on a reasonably large table(100k-500k +> rows, ~7 columns mostly integers/bigint). Each row +> will be refreshed every 15 minutes, or at least that's +> how fast I can poll via SNMP. I hope I can tune the +> DB to keep up. +>=20 +> The app is threaded and will likely have well over 100 +> concurrent db connections. Temp tables for storage +> aren't a preferred option since this is designed to be +> a shared nothing approach and I will likely have +> several polling processes. +>=20 +> Here are some of my assumptions so far . . . +>=20 +> HUGE WAL +> Vacuum hourly if not more often +>=20 +> I'm getting 1700tx/sec from MySQL and I would REALLY +> prefer to use PG. I don't need to match the number, +> just get close. +>=20 +> Is there a global temp table option? In memory tables +> would be very beneficial in this case. I could just +> flush it to disk occasionally with an insert into blah +> select from memory table. +>=20 +> Any help or creative alternatives would be greatly +> appreciated. :) +>=20 +> 'njoy, +> Mark +>=20 +>=20 +> -- +> Writing software requires an intelligent person, +> creating functional art requires an artist. +> -- Unknown +>=20 +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +>=20 +> http://www.postgresql.org/docs/faq +> + +From pgsql-performance-owner@postgresql.org Fri Aug 19 10:06:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BC10752E60 + for ; + Fri, 19 Aug 2005 10:05:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24697-07 + for ; + Fri, 19 Aug 2005 13:05:46 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 12D4552E65 + for ; + Fri, 19 Aug 2005 10:05:45 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7JD5loZ017465; + Fri, 19 Aug 2005 09:05:48 -0400 (EDT) +To: Kari Lavikka +Cc: pgsql-performance@postgresql.org, rjpeace@earthlink.net +Subject: Re: Finding bottleneck +In-reply-to: +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD026@Herge.rcsinc.local> + + <29384.1123520200@sss.pgh.pa.us> + +Comments: In-reply-to Kari Lavikka + message dated "Fri, 19 Aug 2005 14:34:47 +0300" +Date: Fri, 19 Aug 2005 09:05:47 -0400 +Message-ID: <17464.1124456747@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/257 +X-Sequence-Number: 14004 + +Kari Lavikka writes: +> However, those configuration changes didn't have significant effect to +> oprofile results. AtEOXact_CatCache consumes even more cycles. + +I believe I've fixed that for 8.1. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 19 10:37:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B76BE52E68 + for ; + Fri, 19 Aug 2005 10:35:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77688-07 + for ; + Fri, 19 Aug 2005 13:35:51 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 92E7B52E1E + for ; + Fri, 19 Aug 2005 10:35:49 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7JDZro9017691; + Fri, 19 Aug 2005 09:35:53 -0400 (EDT) +To: Bob Ippolito +Cc: Mark Cotner , pgsql-performance@postgresql.org +Subject: Re: sustained update load of 1-2k/sec +In-reply-to: <67788A4A-4011-49AB-B329-683FD9532661@redivi.com> +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> + <67788A4A-4011-49AB-B329-683FD9532661@redivi.com> +Comments: In-reply-to Bob Ippolito + message dated "Thu, 18 Aug 2005 23:09:27 -1000" +Date: Fri, 19 Aug 2005 09:35:53 -0400 +Message-ID: <17690.1124458553@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/258 +X-Sequence-Number: 14005 + +Bob Ippolito writes: +> If you don't want to optimize the whole application, I'd at least +> just push the DB operations down to a very small number of +> connections (*one* might even be optimal!), waiting on some kind of +> thread-safe queue for updates from the rest of the system. + +While I agree that hundreds of threads seems like overkill, I think the +above advice might be going too far in the other direction. The problem +with single-threaded operation is that any delay affects the whole +system --- eg, if you're blocked waiting for disk I/O, the CPU doesn't +get anything done either. You want enough DB connections doing things +in parallel to make sure that there's always something else useful to do +for each major component. This is particularly important for Postgres, +which doesn't do any internal query parallelization (not that it would +help much anyway for the sorts of trivial queries you are worried about). +If you have, say, a 4-way CPU you want at least 4 active connections to +make good use of the CPUs. + +I'd suggest trying to build the system so that it uses a dozen or two +active database connections. If that doesn't match up to the number of +polling activities you want to have in flight at any instant, then you +can do something like what Bob suggested on the client side to bridge +the gap. + +As far as the question "can PG do 1-2k xact/sec", the answer is "yes +if you throw enough hardware at it". Spending enough money on the +disk subsystem is the key ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 19 10:37:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C21FE52E14 + for ; + Fri, 19 Aug 2005 10:37:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82454-05 + for ; + Fri, 19 Aug 2005 13:37:22 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 029E152E07 + for ; + Fri, 19 Aug 2005 10:37:16 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Finding bottleneck +Date: Fri, 19 Aug 2005 09:37:19 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD150@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Finding bottleneck +Thread-Index: AcWkvxCeRZU6M6WETVCl/asOphrnNwAAjKuw +From: "Merlin Moncure" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/259 +X-Sequence-Number: 14006 + +> Kari Lavikka writes: +> > However, those configuration changes didn't have significant effect +to +> > oprofile results. AtEOXact_CatCache consumes even more cycles. +>=20 +> I believe I've fixed that for 8.1. + +Relative to 8.0, I am seeing a dramatic, almost miraculous reduction in +CPU load times in 8.1devel. This is for ISAM style access patterns over +the parse/bind interface. (IOW one record at a time, 90% read, 10% +write). + +Relative to commercial dedicated ISAM storage engines, pg holds up very +well except in cpu load, but 8.1 is a huge step towards addressing that. + +So far, except for one minor (and completely understandable) issue with +bitmap issues, 8.1 has been a stellar performer. Also great is the +expansion of pg_locks view (which I didn't see mentioned in Bruce's TODO +list, just FYI). + +Merlin + +From pgsql-performance-owner@postgresql.org Fri Aug 19 10:58:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E19152C34 + for ; + Fri, 19 Aug 2005 10:58:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18998-05 + for ; + Fri, 19 Aug 2005 13:58:37 +0000 (GMT) +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.188]) + by svr1.postgresql.org (Postfix) with ESMTP id C64FD52C1F + for ; + Fri, 19 Aug 2005 10:58:35 -0300 (ADT) +Received: from p548F1B85.dip0.t-ipconnect.de [84.143.27.133] + (helo=pse.dyndns.org) + by mrelayeu.kundenserver.de with ESMTP (Nemesis), + id 0MKwh2-1E67OH3mTv-00034N; Fri, 19 Aug 2005 15:58:37 +0200 +Received: from p548f1e1e.dip0.t-ipconnect.de ([84.143.30.30] + helo=[10.10.11.120]) + by pse.dyndns.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.44) + id 1E67OF-0000dE-Ht; Fri, 19 Aug 2005 15:58:36 +0200 +Message-ID: <4305E57E.1010604@pse-consulting.de> +Date: Fri, 19 Aug 2005 15:58:22 +0200 +From: Andreas Pflug +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Bob Ippolito , Mark Cotner , + pgsql-performance@postgresql.org +Subject: Re: sustained update load of 1-2k/sec +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> + <67788A4A-4011-49AB-B329-683FD9532661@redivi.com> + <17690.1124458553@sss.pgh.pa.us> +In-Reply-To: <17690.1124458553@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:0ce7ee5c3478b8d72edd8e05ccd40b70 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.073 required=5 tests=[AWL=-0.769, + FORGED_RCVD_HELO=0.05, RCVD_IN_NJABL_DUL=1.655, RCVD_IN_SORBS_DUL=0.137] +X-Spam-Level: * +X-Archive-Number: 200508/260 +X-Sequence-Number: 14007 + +Tom Lane wrote: + +>Bob Ippolito writes: +> +> +>>If you don't want to optimize the whole application, I'd at least +>>just push the DB operations down to a very small number of +>>connections (*one* might even be optimal!), waiting on some kind of +>>thread-safe queue for updates from the rest of the system. +>> +>> +> +>While I agree that hundreds of threads seems like overkill, I think the +>above advice might be going too far in the other direction. The problem +>with single-threaded operation is that any delay affects the whole +>system --- eg, if you're blocked waiting for disk I/O, the CPU doesn't +>get anything done either. You want enough DB connections doing things +>in parallel to make sure that there's always something else useful to do +>for each major component. This is particularly important for Postgres, +>which doesn't do any internal query parallelization (not that it would +>help much anyway for the sorts of trivial queries you are worried about). +>If you have, say, a 4-way CPU you want at least 4 active connections to +>make good use of the CPUs. +> +>I'd suggest trying to build the system so that it uses a dozen or two +>active database connections. If that doesn't match up to the number of +>polling activities you want to have in flight at any instant, then you +>can do something like what Bob suggested on the client side to bridge +>the gap. +> +>As far as the question "can PG do 1-2k xact/sec", the answer is "yes +>if you throw enough hardware at it". Spending enough money on the +>disk subsystem is the key ... +> +> +The 1-2k xact/sec for MySQL seems suspicious, sounds very much like +write-back cached, not write-through, esp. considering that heavy +concurrent write access isn't said to be MySQLs strength... + +I wonder if preserving the database after a fatal crash is really +necessary, since the data stored sounds quite volatile; in this case, +fsync=false might be sufficient. + +Regards, +Andreas + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 11:03:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 08F0F52C19 + for ; + Fri, 19 Aug 2005 11:03:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38325-01 + for ; + Fri, 19 Aug 2005 14:03:09 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A901A52BE2 + for ; + Fri, 19 Aug 2005 11:03:08 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7JE3D3K017940; + Fri, 19 Aug 2005 10:03:13 -0400 (EDT) +To: "Merlin Moncure" +Cc: pgsql-performance@postgresql.org +Subject: Re: Finding bottleneck +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB3417DD150@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD150@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Fri, 19 Aug 2005 09:37:19 -0400" +Date: Fri, 19 Aug 2005 10:03:12 -0400 +Message-ID: <17939.1124460192@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/261 +X-Sequence-Number: 14008 + +"Merlin Moncure" writes: +> Relative to 8.0, I am seeing a dramatic, almost miraculous reduction in +> CPU load times in 8.1devel. This is for ISAM style access patterns over +> the parse/bind interface. (IOW one record at a time, 90% read, 10% +> write). + +> Relative to commercial dedicated ISAM storage engines, pg holds up very +> well except in cpu load, but 8.1 is a huge step towards addressing that. + +Cool --- we've done a fair amount of work on squeezing out internal +inefficiencies during this devel cycle, but it's always hard to predict +just how much anyone will notice in the real world. + +Care to do some oprofile or gprof profiles to see where it's still bad? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 19 11:09:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 89D3352BCE + for ; + Fri, 19 Aug 2005 11:09:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40276-04 + for ; + Fri, 19 Aug 2005 14:09:03 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 681E252AD6 + for ; + Fri, 19 Aug 2005 11:09:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7JE96GO018001; + Fri, 19 Aug 2005 10:09:06 -0400 (EDT) +To: Andreas Pflug +Cc: Bob Ippolito , Mark Cotner , + pgsql-performance@postgresql.org +Subject: Re: sustained update load of 1-2k/sec +In-reply-to: <4305E57E.1010604@pse-consulting.de> +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> + <67788A4A-4011-49AB-B329-683FD9532661@redivi.com> + <17690.1124458553@sss.pgh.pa.us> + <4305E57E.1010604@pse-consulting.de> +Comments: In-reply-to Andreas Pflug + message dated "Fri, 19 Aug 2005 15:58:22 +0200" +Date: Fri, 19 Aug 2005 10:09:05 -0400 +Message-ID: <18000.1124460545@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/262 +X-Sequence-Number: 14009 + +Andreas Pflug writes: +> Tom Lane wrote: +>> As far as the question "can PG do 1-2k xact/sec", the answer is "yes +>> if you throw enough hardware at it". Spending enough money on the +>> disk subsystem is the key ... +>> +> The 1-2k xact/sec for MySQL seems suspicious, sounds very much like +> write-back cached, not write-through, esp. considering that heavy +> concurrent write access isn't said to be MySQLs strength... + +> I wonder if preserving the database after a fatal crash is really +> necessary, since the data stored sounds quite volatile; in this case, +> fsync=false might be sufficient. + +Yeah, that's something to think about. If you do need full transaction +safety, then you *must* have a decent battery-backed-write-cache setup, +else your transaction commit rate will be limited by disk rotation +speed --- for instance, a single connection can commit at most 250 xacts +per second if the WAL log is on a 15000RPM drive. (You can improve this +to the extent that you can spread activity across multiple connections, +but I'm not sure you can expect to reliably have 8 or more connections +ready to commit each time the disk goes 'round.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 19 11:55:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E20752E0C + for ; + Fri, 19 Aug 2005 11:55:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31597-04 + for ; + Fri, 19 Aug 2005 14:54:58 +0000 (GMT) +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F99652A2B + for ; + Fri, 19 Aug 2005 11:54:57 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=FqVgtOHasABKey78n2Y8/jE2SspFW36HGI69f1rJDsyfgMUGA+lFzJZ/BOEqDf45; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E68Gs-0005PC-0O; Fri, 19 Aug 2005 10:55:02 -0400 +Message-Id: <6.2.3.4.0.20050819093011.05c1b9d8@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Fri, 19 Aug 2005 10:54:57 -0400 +To: postgres performance +From: Ron +Subject: Re: sustained update load of 1-2k/sec +In-Reply-To: <33c6269f050819054038af9886@mail.gmail.com> +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> + <33c6269f050819054038af9886@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc8e05e127e111a9d4886337fbf3f87140350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.762 required=5 tests=[AWL=0.388, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/263 +X-Sequence-Number: 14010 + +Alex mentions a nice setup, but I'm pretty sure I know how to beat +that IO subsystems HW's performance by at least 1.5x or 2x. Possibly +more. (No, I do NOT work for any vendor I'm about to discuss.) + +Start by replacing the WD Raptors with Maxtor Atlas 15K II's. +At 5.5ms average access, 97.4MB/s outer track throughput, 85.9MB/s +average, and 74.4 MB/s inner track throughput, they have the best +performance characteristics of any tested shipping HDs I know +of. (Supposedly the new SAS versions will _sustain_ ~98MB/s, but +I'll believe that only if I see it under independent testing). +In comparison, the numbers on the WD740GD are 8.1ms average access, +71.8, 62.9, and 53.9 MB/s outer, average and inner track throughputs +respectively. + +Be prepared to use as many of them as possible (read: as many you can +afford) if you want to maximize transaction rates, particularly for +small transactions like this application seems to be mentioning. + +Next, use a better RAID card. The TOL enterprise stuff (Xyratex, +Engino, Dot-hill) is probably too expensive, but in the commodity +market benchmarks indicate that that Areca's 1GB buffer RAID cards +currently outperform all the other commodity RAID stuff. + +9 Atlas II's per card in a RAID 5 set, or 16 per card in a RAID 10 +set, should max the RAID card's throughput and come very close to, if +not attaining, the real world peak bandwidth of the 64b 133MHz PCI-X +bus they are plugged into. Say somewhere in the 700-800MB/s range. + +Repeat the above for as many independent PCI-X buses as you have for +a very fast commodity RAID IO subsystem. + +Two such configured cards used in the dame manner as mentioned by +Alex should easily attain 1.5x - 2x the transaction numbers mentioned +by Alex unless there's a bottleneck somewhere else in the system design. + +Hope this helps, +Ron Peacetree + +At 08:40 AM 8/19/2005, Alex Turner wrote: +>I have managed tx speeds that high from postgresql going even as high +>as 2500/sec for small tables, but it does require a good RAID +>controler card (yes I'm even running with fsync on). I'm using 3ware +>9500S-8MI with Raptor drives in multiple RAID 10s. The box wasn't too +>$$$ at just around $7k. I have two independant controlers on two +>independant PCI buses to give max throughput. on with a 6 drive RAID +>10 and the other with two 4 drive RAID 10s. +> +>Alex Turner +>NetEconomist +> +>On 8/19/05, Mark Cotner wrote: +> > Hi all, +> > I bet you get tired of the same ole questions over and +> > over. +> > +> > I'm currently working on an application that will poll +> > thousands of cable modems per minute and I would like +> > to use PostgreSQL to maintain state between polls of +> > each device. This requires a very heavy amount of +> > updates in place on a reasonably large table(100k-500k +> > rows, ~7 columns mostly integers/bigint). Each row +> > will be refreshed every 15 minutes, or at least that's +> > how fast I can poll via SNMP. I hope I can tune the +> > DB to keep up. +> > +> > The app is threaded and will likely have well over 100 +> > concurrent db connections. Temp tables for storage +> > aren't a preferred option since this is designed to be +> > a shared nothing approach and I will likely have +> > several polling processes. +> > +> > Here are some of my assumptions so far . . . +> > +> > HUGE WAL +> > Vacuum hourly if not more often +> > +> > I'm getting 1700tx/sec from MySQL and I would REALLY +> > prefer to use PG. I don't need to match the number, +> > just get close. +> > +> > Is there a global temp table option? In memory tables +> > would be very beneficial in this case. I could just +> > flush it to disk occasionally with an insert into blah +> > select from memory table. +> > +> > Any help or creative alternatives would be greatly +> > appreciated. :) +> > +> > 'njoy, +> > Mark +> > +> > +> > -- +> > Writing software requires an intelligent person, +> > creating functional art requires an artist. +> > -- Unknown +> > +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 3: Have you checked our extensive FAQ? +> > +> > http://www.postgresql.org/docs/faq +> > +> +>---------------------------(end of broadcast)--------------------------- +>TIP 2: Don't 'kill -9' the postmaster + + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 12:04:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3FB752E2E + for ; + Fri, 19 Aug 2005 12:04:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44686-08 + for ; + Fri, 19 Aug 2005 15:04:00 +0000 (GMT) +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B81A52E2D + for ; + Fri, 19 Aug 2005 12:04:00 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=qpS1QwNjCFcGxob02hmALGmzcUbRGYopOoj7fhKy88feLFPT77pYxEN6YamwYhVq; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E68PX-0003y9-9r; Fri, 19 Aug 2005 11:03:59 -0400 +Message-Id: <6.2.3.4.0.20050819105751.05c1a760@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Fri, 19 Aug 2005 11:03:54 -0400 +To: Andreas Pflug +From: Ron +Subject: Re: sustained update load of 1-2k/sec +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4305E57E.1010604@pse-consulting.de> +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> + <67788A4A-4011-49AB-B329-683FD9532661@redivi.com> + <17690.1124458553@sss.pgh.pa.us> + <4305E57E.1010604@pse-consulting.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc1a6d27d7b2cbdd61554e775236ab66aa350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.682 required=5 tests=[AWL=0.308, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/264 +X-Sequence-Number: 14011 + +At 09:58 AM 8/19/2005, Andreas Pflug wrote: + +>The 1-2k xact/sec for MySQL seems suspicious, sounds very much like +>write-back cached, not write-through, esp. considering that heavy +>concurrent write access isn't said to be MySQLs strength... + +Don't be suspicious. + +I haven't seen the code under discussion, but I have seen mySQL +easily achieve these kinds of numbers using the myISAM storage engine +in write-through cache +mode. + +myISAM can be =FAST=. Particularly when decent HW is thrown at it. + +Ron + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 12:27:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F136152C3A + for ; + Fri, 19 Aug 2005 12:22:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81433-02 + for ; + Fri, 19 Aug 2005 15:22:49 +0000 (GMT) +Received: from birao.terra.com.br (birao.terra.com.br [200.176.10.197]) + by svr1.postgresql.org (Postfix) with ESMTP id 62A1B52ACB + for ; + Fri, 19 Aug 2005 12:22:48 -0300 (ADT) +Received: from donga.terra.com.br (donga.terra.com.br [200.176.10.10]) + by birao.terra.com.br (Postfix) with ESMTP id 22BA0108C0AD + for ; + Fri, 19 Aug 2005 12:22:47 -0300 (BRT) +X-Terra-Karma: -2% +X-Terra-Hash: 4cf10e32f89f4380a51ac919858cb02c +Received-SPF: none (donga.terra.com.br: 200.176.10.10 is neither permitted nor + denied by domain of sistemica.info) client-ip=200.176.10.10; + envelope-from=diego@sistemica.info; helo=modem.sistemica; +Received: from modem.sistemica + (201-25-44-253.paemt704.dsl.brasiltelecom.net.br + [201.25.44.253]) (authenticated user sistemic) + by donga.terra.com.br (Postfix) with ESMTP id 952BF9C4071 + for ; + Fri, 19 Aug 2005 12:22:46 -0300 (BRT) +Received: from diretoria02 (unknown [192.168.200.61]) + by modem.sistemica (Postfix) with SMTP id 0FA2813F610 + for ; + Fri, 19 Aug 2005 12:24:00 -0300 (BRT) +Message-ID: <002a01c5a4d1$d36f6420$3dc8a8c0@diretoria02> +Reply-To: "Diego de Lima" +From: "Diego de Lima" +To: +Subject: LEFT JOIN ON vs. LEFT JOIN USING performance +Date: Fri, 19 Aug 2005 12:22:35 -0300 +Organization: Sistemica.info +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0027_01C5A4B8.AE118A50" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.146 required=5 tests=[FORGED_RCVD_HELO=0.05, + HTML_50_60=0.095, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/266 +X-Sequence-Number: 14013 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0027_01C5A4B8.AE118A50 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi list, + +I=B4m using Pg 8.0.3 on Linux FC2. + +This question may have a very simple answer (I hope), but I=B4m having = +lots of trouble solving it, and I counldn=B4t find any other post about = +it or anything in the pg docs. + +I have some very complex select statements on 4 million rows tables. = +When using LEFT JOIN ON, some select statements takes about 2 minutes. = +When I write exactly the same statement but with LEFT JOIN USING, it = +takes only 1 minute. Comparing to Oracle, the same statement takes 1 = +minute also, but with LEFT JOIN ON. + +Sometimes tables have the same column names and I can use LEFT JOIN = +USING, but in some other cases I MUST use LEFT JOIN ON, because the = +tables have different column names. + +So my question is: is there a way to make LEFT JOIN ON uses the same = +plan of LEFT JOIN USING? + +Thanks, + +Diego de Lima + + +------=_NextPart_000_0027_01C5A4B8.AE118A50 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi list,
+
 
+
I=B4m using Pg 8.0.3 on Linux = +FC2.
+
 
+
This question may have a very simple = +answer (I=20 +hope), but I=B4m having lots of trouble solving it, and I counldn=B4t = +find any other=20 +post about it or anything in the pg docs.
+
 
+
I have some very complex select = +statements on 4=20 +million rows tables. When using LEFT JOIN ON, some select = +statements=20 +takes about 2 minutes. When I write exactly the same statement but with = +LEFT=20 +JOIN USING, it takes only 1 minute. Comparing to Oracle, the same = +statement=20 +takes 1 minute also, but with LEFT JOIN ON.
+
 
+
Sometimes tables have the = +same column=20 +names and I can use LEFT JOIN USING, but in some other cases I MUST use = +LEFT=20 +JOIN ON, because the tables have different column names.
+
 
+
So my question is: is there a way to = +make LEFT JOIN=20 +ON uses the same plan of LEFT JOIN USING?
+
 
+
Thanks,
+
 
+
Diego de Lima
+
 
+
 
+ +------=_NextPart_000_0027_01C5A4B8.AE118A50-- + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 12:27:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DA0852969 + for ; + Fri, 19 Aug 2005 12:26:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81896-07 + for ; + Fri, 19 Aug 2005 15:26:30 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 26B0D5288E + for ; + Fri, 19 Aug 2005 12:26:29 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7JFQQEU031777 + for ; Fri, 19 Aug 2005 10:26:28 -0500 +Subject: Re: I'm configuraing a new system (Bigish) and need some +From: Jeremiah Jahn +To: postgres performance +In-Reply-To: <1124123097.27881.59.camel@bluejay.goodinassociates.com> +References: <1124123097.27881.59.camel@bluejay.goodinassociates.com> +Content-Type: text/plain +Date: Fri, 19 Aug 2005 10:26:25 -0500 +Message-Id: <1124465185.27881.127.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1034/Thu Aug 18 15:07:58 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.033 required=5 tests=[AWL=-0.018, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/265 +X-Sequence-Number: 14012 + +that took a little while to get through the system didn't it. Please +ignore. + + +> Ingrate, n.: A man who bites the hand that feeds him, and then complains +> of indigestion. +-- +A free society is one where it is safe to be unpopular. + -- Adlai Stevenson + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 12:44:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EABF652EC7 + for ; + Fri, 19 Aug 2005 12:41:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05428-05 + for ; + Fri, 19 Aug 2005 15:41:17 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 428B352DD0 + for ; + Fri, 19 Aug 2005 12:40:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7JFeneQ025397; + Fri, 19 Aug 2005 11:40:50 -0400 (EDT) +To: "Diego de Lima" +Cc: pgsql-performance@postgresql.org +Subject: Re: LEFT JOIN ON vs. LEFT JOIN USING performance +In-reply-to: <002a01c5a4d1$d36f6420$3dc8a8c0@diretoria02> +References: <002a01c5a4d1$d36f6420$3dc8a8c0@diretoria02> +Comments: In-reply-to "Diego de Lima" + message dated "Fri, 19 Aug 2005 12:22:35 -0300" +Date: Fri, 19 Aug 2005 11:40:49 -0400 +Message-ID: <25396.1124466049@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.246 required=5 tests=[AWL=-0.235, INFO_TLD=0.481] +X-Spam-Level: +X-Archive-Number: 200508/268 +X-Sequence-Number: 14015 + +"Diego de Lima" writes: +> I have some very complex select statements on 4 million rows tables. = +> When using LEFT JOIN ON, some select statements takes about 2 minutes. = +> When I write exactly the same statement but with LEFT JOIN USING, it = +> takes only 1 minute. + +Could we see details please? Like the table schemas, the query itself, +and EXPLAIN ANALYZE results for both cases. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 19 12:44:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C7FFB52BD8 + for ; + Fri, 19 Aug 2005 12:41:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11714-04 + for ; + Fri, 19 Aug 2005 15:41:24 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 5464D52B54 + for ; + Fri, 19 Aug 2005 12:41:06 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050819154105m92009i8pue>; Fri, 19 Aug 2005 15:41:05 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id CA2FB55FBA; Fri, 19 Aug 2005 10:41:04 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 1527655FAD; + Fri, 19 Aug 2005 10:41:00 -0500 (CDT) +Message-ID: <4305FD8B.9090803@arbash-meinel.com> +Date: Fri, 19 Aug 2005 10:40:59 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Diego de Lima +Cc: pgsql-performance@postgresql.org +Subject: Re: LEFT JOIN ON vs. LEFT JOIN USING performance +References: <002a01c5a4d1$d36f6420$3dc8a8c0@diretoria02> +In-Reply-To: <002a01c5a4d1$d36f6420$3dc8a8c0@diretoria02> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigF91D8A06A6C8BD5262A8C6FA" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=-0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/267 +X-Sequence-Number: 14014 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigF91D8A06A6C8BD5262A8C6FA +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +Diego de Lima wrote: +> Hi list, +> =20 +> I=C2=B4m using Pg 8.0.3 on Linux FC2. +> =20 +> This question may have a very simple answer (I hope), but I=C2=B4m havi= +ng +> lots of trouble solving it, and I counldn=C2=B4t find any other post ab= +out it +> or anything in the pg docs. +> =20 +> I have some very complex select statements on 4 million rows +> tables. When using LEFT JOIN ON, some select statements takes about 2 +> minutes. When I write exactly the same statement but with LEFT JOIN +> USING, it takes only 1 minute. Comparing to Oracle, the same statement +> takes 1 minute also, but with LEFT JOIN ON. +> =20 +> Sometimes tables have the same column names and I can use LEFT JOIN +> USING, but in some other cases I MUST use LEFT JOIN ON, because the +> tables have different column names. +> =20 +> So my question is: is there a way to make LEFT JOIN ON uses the same +> plan of LEFT JOIN USING? +> =20 +> Thanks, +> =20 +> Diego de Lima +> =20 +> =20 + +I'm guessing that ON/USING isn't the specific problem. It's probably +more an issue of how the planner is deciding to do the joins (merge +join, hash join, nested loop, etc.) + +Can you send the results of EXPLAIN ANALYZE ? + +Also, any sort of join where you have to join against millions of rows +is going to be slow. I don't know your specific design, but likely you +could change the design to be more selective at an earlier level, which +means that you can cut the size of the join by a lot. If you post you +query, a lot of times people here can help optimize your query. (But +make sure to explain what you are trying to do, so the optimizations +make sense.) + +John +=3D:-> + + + +--------------enigF91D8A06A6C8BD5262A8C6FA +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDBf2LJdeBCYSNAAMRArdNAJ4msAEWqcEZRGvoYoGanRvDpL8YiACguaIY +oA3YYom0rtxPpTetl5SXeMM= +=vuUc +-----END PGP SIGNATURE----- + +--------------enigF91D8A06A6C8BD5262A8C6FA-- + +From pgsql-performance-owner@postgresql.org Fri Aug 19 13:34:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C681D52A06 + for ; + Fri, 19 Aug 2005 13:34:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76579-06 + for ; + Fri, 19 Aug 2005 16:34:50 +0000 (GMT) +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 121C952990 + for ; + Fri, 19 Aug 2005 13:34:48 -0300 (ADT) +Received: from toonses.gghcwest.com (toonses.gghcwest.com [192.168.168.115]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id j7JGYimd027052; + Fri, 19 Aug 2005 09:34:44 -0700 +Received: from jwb by toonses.gghcwest.com with local (Exim 4.50) + id 1E69pN-0007nY-4t; Fri, 19 Aug 2005 09:34:45 -0700 +Subject: Re: sustained update load of 1-2k/sec +From: "Jeffrey W. Baker" +To: Ron +Cc: pgsql-performance@postgresql.org +In-Reply-To: <6.2.3.4.0.20050819093011.05c1b9d8@pop.earthlink.net> +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> + <33c6269f050819054038af9886@mail.gmail.com> + <6.2.3.4.0.20050819093011.05c1b9d8@pop.earthlink.net> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Fri, 19 Aug 2005 09:34:44 -0700 +Message-Id: <1124469284.29778.4.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.3.6.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=-0.841 required=5 tests=[AWL=-0.891, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/269 +X-Sequence-Number: 14016 + +On Fri, 2005-08-19 at 10:54 -0400, Ron wrote: +> Maxtor Atlas 15K II's. + +> Areca's 1GB buffer RAID cards + +The former are SCSI disks and the latter is an SATA controller. The +combination would have a transaction rate of approximately 0. + +I can vouch for the Areca controllers, however. You can certainly +achieve pgbench transaction rates in the hundreds per second even with +only 5 7200RPM disks and 128MB cache. + +Don't forget to buy the battery. + +-jwb + +From pgsql-performance-owner@postgresql.org Fri Aug 19 13:48:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D987052869 + for ; + Fri, 19 Aug 2005 13:48:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99034-04 + for ; + Fri, 19 Aug 2005 16:48:34 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 93DFB5281F + for ; + Fri, 19 Aug 2005 13:48:32 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7JGmUlN001513; Fri, 19 Aug 2005 11:48:30 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: John Arbash Meinel +Cc: Jeff Trout , + postgres performance +In-Reply-To: <4304CB77.4070403@arbash-meinel.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> +Content-Type: text/plain +Date: Fri, 19 Aug 2005 11:48:29 -0500 +Message-Id: <1124470109.27881.152.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1034/Thu Aug 18 15:07:58 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.033 required=5 tests=[AWL=-0.017, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/270 +X-Sequence-Number: 14017 + +Sorry about the formatting. + +On Thu, 2005-08-18 at 12:55 -0500, John Arbash Meinel wrote: +> Jeremiah Jahn wrote: +> +> >here's an example standard query. Ireally have to make the first hit go +> >faster. The table is clustered as well on full_name as well. 'Smith%' +> >took 87 seconds on the first hit. I wonder if I set up may array wrong. +> >I remeber see something about DMA access versus something else, and +> >choose DMA access. LVM maybe? +> > +> > +> It would be nice if you would format your queries to be a little bit +> easier to read before posting them. +> However, I believe I am reading it correctly, to say that the index scan +> on identity is not your slow point. In fact, as near as I can tell, it +> only takes 52ms to complete. +> +> The expensive parts are the 4915 lookups into the litigant_details (each +> one takes approx 4ms for a total of ~20s). +> And then you do it again on case_data (average 3ms each * 4906 loops = +> ~15s). +Is there some way to avoid this? + + +> +> So there is no need for preloading your indexes on the identity table. +> It is definitely not the bottleneck. +> +> So a few design bits, which may help your database. +> Why is "actor_id" a text field instead of a number? +This is simply due to the nature of the data. + +> You could try creating an index on "litigant_details (actor_id, +> count_ori)" so that it can do just an index lookup, rather than an index +> + filter. +I have one, but it doesn't seem to like to use it. Don't really need it +though, I can just drop the court_id out of the query. It's redundant, +since each actor_id is also unique in litigant details. I had run vac +full and analyze but I ran them again anyway and the planning improved. +However, my 14 disk raid 10 array is still slower than my 3 disk raid 5 +on my production box. 46sec vs 30sec (with live traffic on the +production) One of the strange things is that when I run the cat command +on my index and tables that are "HOT" it has no effect on memory usage. +Right now I'm running ext3 on LVM. I'm still in a position to redo the +file system and everything. Is this a good way to do it or should I +switch to something else? What about stripe and extent sizes...? kernel +parameters to change? + + + +---------------devel box:----------------------- + +copa=# EXPLAIN ANALYZE select full_name,identity_id,identity.case_id,court.id,date_of_birth,assigned_case_role,litigant_details.impound_litigant_data +copa-# from identity +copa-# join litigant_details on identity.actor_id = litigant_details.actor_id +copa-# join case_data on litigant_details.case_id = case_data.case_id and litigant_details.court_ori = case_data.court_ori +copa-# join court on identity.court_ori = court.id +copa-# where identity.court_ori = 'IL081025J' and full_name like 'JONES%' order by full_name; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=3.29..29482.22 rows=3930 width=86) (actual time=114.060..46001.480 rows=5052 loops=1) + -> Nested Loop (cost=3.29..16193.27 rows=3820 width=112) (actual time=93.038..24584.275 rows=5052 loops=1) + -> Nested Loop (cost=0.00..16113.58 rows=3820 width=113) (actual time=85.778..24536.489 rows=5052 loops=1) + -> Index Scan using name_speed on identity (cost=0.00..824.72 rows=3849 width=82) (actual time=50.284..150.133 rows=5057 loops=1) + Index Cond: (((full_name)::text >= 'JONES'::character varying) AND ((full_name)::text < 'JONET'::character varying)) + Filter: (((court_ori)::text = 'IL081025J'::text) AND ((full_name)::text ~~ 'JONES%'::text)) + -> Index Scan using lit_actor_speed on litigant_details (cost=0.00..3.96 rows=1 width=81) (actual time=4.788..4.812 rows=1 loops=5057) + Index Cond: (("outer".actor_id)::text = (litigant_details.actor_id)::text) + -> Materialize (cost=3.29..3.30 rows=1 width=12) (actual time=0.002..0.003 rows=1 loops=5052) + -> Seq Scan on court (cost=0.00..3.29 rows=1 width=12) (actual time=7.248..7.257 rows=1 loops=1) + Filter: ('IL081025J'::text = (id)::text) + -> Index Scan using case_speed on case_data (cost=0.00..3.46 rows=1 width=26) (actual time=4.222..4.230 rows=1 loops=5052) + Index Cond: ((("outer".court_ori)::text = (case_data.court_ori)::text) AND (("outer".case_id)::text = (case_data.case_id)::text)) + Total runtime: 46005.994 ms + + + +> +> More importantly, though, the planner seems to think the join of +> identity to litigant_details will only return 1 row, not 5000. +> Do you regularly vacuum analyze your tables? +> Just as a test, try running: +> set enable_nested_loop to off; +not quite acceptable +Total runtime: 221486.149 ms + +> And then run EXPLAIN ANALYZE again, just to see if it is faster. +> +> You probably need to increase some statistics targets, so that the +> planner can design better plans. + +---------------------this is the output from the production box------------------ +LOG: duration: 27213.068 ms statement: EXPLAIN ANALYZE select full_name,identity_id,identity.case_id,court.id,date_of_birth,assigned_case_role,litigant_details.impound_litigant_data + from identity + join litigant_details on identity.actor_id = litigant_details.actor_id + join case_data on litigant_details.case_id = case_data.case_id and litigant_details.court_ori = case_data.court_ori + join court on identity.court_ori = court.id + where identity.court_ori = 'IL081025J' and full_name like 'JONES%' order by full_name; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=3.29..43498.76 rows=2648 width=86) (actual time=17.106..27192.000 rows=5052 loops=1) + -> Nested Loop (cost=0.00..43442.53 rows=2647 width=87) (actual time=16.947..27120.619 rows=5052 loops=1) + -> Nested Loop (cost=0.00..23061.79 rows=3827 width=113) (actual time=16.801..17390.682 rows=5052 loops=1) + -> Index Scan using name_speed on identity (cost=0.00..1277.39 rows=3858 width=82) (actual time=9.842..213.424 rows=5057 loops=1) + Index Cond: (((full_name)::text >= 'JONES'::character varying) AND ((full_name)::text < 'JONET'::character varying)) + Filter: (((court_ori)::text = 'IL081025J'::text) AND ((full_name)::text ~~ 'JONES%'::text)) + -> Index Scan using lit_actor_speed on litigant_details (cost=0.00..5.63 rows=1 width=81) (actual time=3.355..3.364 rows=1 loops=5057) + Index Cond: (("outer".actor_id)::text = (litigant_details.actor_id)::text) + -> Index Scan using case_data_pkey on case_data (cost=0.00..5.31 rows=1 width=26) (actual time=1.897..1.904 rows=1 loops=5052) + Index Cond: ((("outer".court_ori)::text = (case_data.court_ori)::text) AND (("outer".case_id)::text = (case_data.case_id)::text)) + -> Materialize (cost=3.29..3.30 rows=1 width=12) (actual time=0.002..0.003 rows=1 loops=5052) + -> Seq Scan on court (cost=0.00..3.29 rows=1 width=12) (actual time=0.142..0.165 rows=1 loops=1) + Filter: ('IL081025J'::text = (id)::text) + Total runtime: 27205.060 ms + +> +> +> John +> =:-> +> +-- +"I didn't know it was impossible when I did it." + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 14:12:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 542CA5288B + for ; + Fri, 19 Aug 2005 14:12:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14926-08 + for ; + Fri, 19 Aug 2005 17:12:47 +0000 (GMT) +Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) + by svr1.postgresql.org (Postfix) with ESMTP id D365A5288E + for ; + Fri, 19 Aug 2005 14:12:43 -0300 (ADT) +Received: from [65.87.16.98] (HELO [10.0.0.221]) + by mx1.neopolitan.us (CommuniGate Pro SMTP 4.2.10) + with ESMTP id 10387635; Fri, 19 Aug 2005 10:12:43 -0700 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Fri, 19 Aug 2005 10:12:42 -0700 +Subject: Re: sustained update load of 1-2k/sec +From: "J. Andrew Rogers" +To: Mark Cotner , + +Message-ID: +In-Reply-To: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.312 required=5 tests=[AWL=-0.438, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376] +X-Spam-Level: * +X-Archive-Number: 200508/271 +X-Sequence-Number: 14018 + +On 8/19/05 1:24 AM, "Mark Cotner" wrote: +> I'm currently working on an application that will poll +> thousands of cable modems per minute and I would like +> to use PostgreSQL to maintain state between polls of +> each device. This requires a very heavy amount of +> updates in place on a reasonably large table(100k-500k +> rows, ~7 columns mostly integers/bigint). Each row +> will be refreshed every 15 minutes, or at least that's +> how fast I can poll via SNMP. I hope I can tune the +> DB to keep up. +> +> The app is threaded and will likely have well over 100 +> concurrent db connections. Temp tables for storage +> aren't a preferred option since this is designed to be +> a shared nothing approach and I will likely have +> several polling processes. + + +Mark, + +We have PostgreSQL databases on modest hardware doing exactly what you are +attempting to (massive scalable SNMP monitoring system). The monitoring +volume for a single database server appears to exceed what you are trying to +do by a few orders of magnitude with no scaling or performance issues, so I +can state without reservation that PostgreSQL can easily handle your +application in theory. + +However, that is predicated on having a well-architected system that +minimizes resource contention and unnecessary blocking, and based on your +description you may be going about it a bit wrong. + +The biggest obvious bottleneck is the use of threads and massive +process-level parallelization. As others have pointed out, async queues are +your friends, as is partitioning the workload horizontally rather than +vertically through the app stack. A very scalable high-throughput engine +for SNMP polling only requires two or three threads handling different parts +of the workload to saturate the network, and by choosing what each thread +does carefully you can all but eliminate blocking when there is work to be +done. + +We only use a single database connection to insert all the data into +PostgreSQL, and that process/thread receives its data from a work queue. +Depending on how you design your system, you can batch many records in your +queue as a single transaction. In our case, we also use very few updates, +mostly just inserts, which is probably advantageous in terms of throughput +if you have the disk for it. The insert I/O load is easily handled, and our +disk array is a modest 10k SCSI rig. The only thing that really hammers the +server is when multiple reporting processes are running, which frequently +touch several million rows each (the database is much larger than the system +memory), and even this is manageable with clever database design. + + +In short, what you are trying to do is easily doable on PostgreSQL in +theory. However, restrictions on design choices may pose significant +hurdles. We did not start out with an ideal system either; it took a fair +amount of re-engineering to solve all the bottlenecks and problems that pop +up. + +Good luck, + +J. Andrew Rogers +jrogers@neopolitan.com + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 14:24:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 215665288B + for ; + Fri, 19 Aug 2005 14:18:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23083-04 + for ; + Fri, 19 Aug 2005 17:18:52 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id D027A52BB8 + for ; + Fri, 19 Aug 2005 14:18:50 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050819171849m92009j6cke>; Fri, 19 Aug 2005 17:18:50 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 251F955FBA; Fri, 19 Aug 2005 12:18:49 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id A9DE955FAD; + Fri, 19 Aug 2005 12:18:42 -0500 (CDT) +Message-ID: <43061472.2080201@arbash-meinel.com> +Date: Fri, 19 Aug 2005 12:18:42 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: Jeff Trout , + postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> +In-Reply-To: <1124470109.27881.152.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig5193DC20985C1AA5C3A20100" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/273 +X-Sequence-Number: 14020 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig5193DC20985C1AA5C3A20100 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: +> Sorry about the formatting. +> +> On Thu, 2005-08-18 at 12:55 -0500, John Arbash Meinel wrote: +> +>>Jeremiah Jahn wrote: +>> +>> + +... + +>>The expensive parts are the 4915 lookups into the litigant_details (each +>>one takes approx 4ms for a total of ~20s). +>>And then you do it again on case_data (average 3ms each * 4906 loops = +>>~15s). +> +> Is there some way to avoid this? +> + +Well, in general, 3ms for a single lookup seems really long. Maybe your +index is bloated by not vacuuming often enough. Do you tend to get a lot +of updates to litigant_details? + +There are a couple possibilities at this point. First, you can REINDEX +the appropriate index, and see if that helps. However, if this is a test +box, it sounds like you just did a dump and reload, which wouldn't have +bloat in an index. + +Another possibility. Is this the column that you usually use when +pulling information out of litigant_details? If so, you can CLUSTER +litigant_details on the appropriate index. This will help things be +close together that should be, which decreases the index lookup costs. + +However, if this is not the common column, then you probably will slow +down whatever other accesses you may have on this table. + +After CLUSTER, the current data will stay clustered, but new data will +not, so you have to continually CLUSTER, the same way that you might +VACUUM. *However*, IIRC CLUSTER grabs an Exclusive lock, so it is as +expensive as a VACUUM FULL. Be aware of this, but it might vastly +improve your performance, so it would be worth it. + +> +> +>>So there is no need for preloading your indexes on the identity table. +>>It is definitely not the bottleneck. +>> +>>So a few design bits, which may help your database. +>>Why is "actor_id" a text field instead of a number? +> +> This is simply due to the nature of the data. +> + +I'm just wondering if changing into a number, and using a number->name +lookup would be faster for you. It may not be. In general, I prefer to +use numbers for references. I may be over paranoid, but I know that some +locales are bad with string -> string comparisons. And since the data in +your database is stored as UNICODE, I'm not sure if it has to do any +translating or not. Again, something to consider, it may not make any +difference. + + +> +>>You could try creating an index on "litigant_details (actor_id, +>>count_ori)" so that it can do just an index lookup, rather than an index +>>+ filter. +> +> I have one, but it doesn't seem to like to use it. Don't really need it +> though, I can just drop the court_id out of the query. It's redundant, +> since each actor_id is also unique in litigant details. I had run vac +> full and analyze but I ran them again anyway and the planning improved. +> However, my 14 disk raid 10 array is still slower than my 3 disk raid 5 +> on my production box. 46sec vs 30sec (with live traffic on the +> production) One of the strange things is that when I run the cat command +> on my index and tables that are "HOT" it has no effect on memory usage. +> Right now I'm running ext3 on LVM. I'm still in a position to redo the +> file system and everything. Is this a good way to do it or should I +> switch to something else? What about stripe and extent sizes...? kernel +> parameters to change? + +Well, the plans are virtually identical. There is one small difference +as to whether it joins against case_data or court first. But 'court' is +very tiny (small enough to use a seqscan instead of index scan) I'm a +little surprised with court being this small that it doesn't do +something like a hash aggregation, but court takes no time anyway. + +The real problem is that your nested loop index time is *much* slower. + +Devel: +-> Index Scan using lit_actor_speed on litigant_details + (cost=0.00..3.96 rows=1 width=81) + (actual time=4.788..4.812 rows=1 loops=5057) + +Production: +-> Index Scan using lit_actor_speed on litigant_details + (cost=0.00..5.63 rows=1 width=81) + (actual time=3.355..3.364 rows=1 loops=5057) + +Devel: +-> Index Scan using case_speed on case_data + (cost=0.00..3.46 rows=1 width=26) + (actual time=4.222..4.230 rows=1 loops=5052) + +Production: +-> Index Scan using case_data_pkey on case_data + (cost=0.00..5.31 rows=1 width=26) + (actual time=1.897..1.904 rows=1 loops=5052) + +Notice that the actual per-row cost is as much as 1/2 less than on your +devel box. + +As a test, can you do "time cat $index_file >/dev/null" a couple of +times. And then determine the MB/s. +Alternatively run vmstat in another shell. If the read/s doesn't change, +then you know the "cat" is being served from RAM, and thus it really is +cached. + +I can point you to REINDEX and CLUSTER, but if it is caching in ram, I +honestly can't say why the per loop would be that much slower. +Are both systems running the same postgres version? It sounds like it is +different (since you say something about switching to 8.0). +I doubt it, but you might try an 8.1devel version. + +... + +>>Do you regularly vacuum analyze your tables? +>>Just as a test, try running: +>>set enable_nested_loop to off; +> +> not quite acceptable +> Total runtime: 221486.149 ms +> + +Well, the estimates are now at least closer (3k vs 5k instead of 1), and +it is still choosing nested loops. So they probably are faster. +I would still be interested in the actual EXPLAIN ANALYZE with nested +loops disabled. It is possible that *some* of the nested loops are +performing worse than they have to. +But really, you have worse index speed, and that needs to be figured out. + +John +=:-> + +--------------enig5193DC20985C1AA5C3A20100 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDBhRyJdeBCYSNAAMRAnHPAKDURdzSBGw7mBWHd/tSfQn0N2xvRACgry6Z +gXkO0btpFCO0AoY/gH79tyY= +=5qCi +-----END PGP SIGNATURE----- + +--------------enig5193DC20985C1AA5C3A20100-- + +From pgsql-performance-owner@postgresql.org Fri Aug 19 14:24:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C0E1152C60 + for ; + Fri, 19 Aug 2005 14:20:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23451-05 + for ; + Fri, 19 Aug 2005 17:20:50 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id F179B52BA7 + for ; + Fri, 19 Aug 2005 14:20:49 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Finding bottleneck +Date: Fri, 19 Aug 2005 13:20:49 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD153@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Finding bottleneck +Thread-Index: AcWkxr5EndVUITMSSs6KP/tRXihkJAAF32MA +From: "Merlin Moncure" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/272 +X-Sequence-Number: 14019 + +> Cool --- we've done a fair amount of work on squeezing out internal +> inefficiencies during this devel cycle, but it's always hard to +predict +> just how much anyone will notice in the real world. +>=20 +> Care to do some oprofile or gprof profiles to see where it's still +bad? +>=20 + +Since release of 8.0, we are a strictly windows shop :). I tried +building pg with -pg flag and got errors in some of the satellite +libraries. I think this is solvable though at some point I'll spend +more time on it. Anyways, just so you know the #s that I'm seein, I've +run several benchmarks of various programs that access pg via our ISAM +bridge. The results are as consistent as they are good. These tests +are on the same box using the same .conf on the same freshly loaded +data. The disk doesn't play a major role in these tests. All data +access is through ExecPrepared libpq C interface. Benchmark is run from +a separate box on a LAN. + +Bill of Materials Traversal ( ~ 62k records). + + ISAM* pg 8.0 pg 8.1 devel delta 8.0->8.1 +running time 63 sec 90 secs 71 secs 21% +cpu load 17% 45% 32% 29% =20 +loadsecs** 10.71 40.5 22.72 44% +recs/sec 984 688 873 +recs/loadsec 5882 1530 2728 + +*ISAM is an anonymous commercial ISAM library in an optimized server +architecture (pg smokes the non-optimized flat file version). +**Loadsecs being seconds of CPU at 100% load. =20 + + +IOW cpu load drop is around 44%. Amazing! + +Merlin + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 14:58:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B284452A2F + for ; + Fri, 19 Aug 2005 14:58:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56198-03 + for ; + Fri, 19 Aug 2005 17:58:02 +0000 (GMT) +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by svr1.postgresql.org (Postfix) with ESMTP id AA77C528DC + for ; + Fri, 19 Aug 2005 14:57:56 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=M2/N7rt7vzYLvcvQXdvkzrN143YkQfUJ2LYIBdPOQ4HwyadmXh3l51+Mc5N1WEM2; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E6B7o-0000SA-Uk; Fri, 19 Aug 2005 13:57:53 -0400 +Message-Id: <6.2.3.4.0.20050819124201.05c15e40@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Fri, 19 Aug 2005 13:57:46 -0400 +To: "Jeffrey W. Baker" +From: Ron +Subject: Re: sustained update load of 1-2k/sec +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1124469284.29778.4.camel@toonses.gghcwest.com> +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> + <33c6269f050819054038af9886@mail.gmail.com> + <6.2.3.4.0.20050819093011.05c1b9d8@pop.earthlink.net> + <1124469284.29778.4.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc240ef543a1a701d2484258297a4c1a65350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.625 required=5 tests=[AWL=0.251, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/274 +X-Sequence-Number: 14021 + +At 12:34 PM 8/19/2005, Jeffrey W. Baker wrote: +>On Fri, 2005-08-19 at 10:54 -0400, Ron wrote: +> > Maxtor Atlas 15K II's. +> +> > Areca's 1GB buffer RAID cards +> +>The former are SCSI disks and the latter is an SATA controller. The +>combination would have a transaction rate of approximately 0. + +You are evidently thinking of the Areca ARC-11xx controllers (and you +are certainly right for that HW combination ;-) ). Those are not the +only product Areca makes that can be upgraded to a 1GB cache. + +Until SAS infrastructure is good enough, U320 SCSI and FC HD's remain +the top performing HD's realistically available. At the most +fundamental, your DBMS is only as good as your HD IO subsystem, and +your HD IO subsystem is only as good as your HDs. As others have +said here, skimping on your HDs is _not_ a good design choice where +DBMSs are concerned. + +As an aside, the Atlas 15K II's are now available in SAS: +http://www.maxtor.com/portal/site/Maxtor/menuitem.ba88f6d7cf664718376049b291346068/?channelpath=/en_us/Products/SCSI%20Hard%20Drives/Atlas%2015K%20Family/Atlas%2015K%20II%20SAS + +I haven't seen independent benches on them, so I explicitly +referenced the U320 Atlas 15K II's known performance numbers +instead. As I said, Maxtor is claiming even better for the SAS +version of the Atlas 15K II. + +None of the SAS <-> PCI-X or PCI-E RAID cards I know of are ready for +mass market yet, although a few are in beta.. + + +>I can vouch for the Areca controllers, however. You can certainly +>achieve pgbench transaction rates in the hundreds per second even with +>only 5 7200RPM disks and 128MB cache. +> +>Don't forget to buy the battery. + +Agreed. + +Hope this is helpful, +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 15:12:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7159352BE2 + for ; + Fri, 19 Aug 2005 15:12:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64054-07 + for ; + Fri, 19 Aug 2005 18:11:57 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F21752B87 + for ; + Fri, 19 Aug 2005 15:11:55 -0300 (ADT) +Received: (qmail 5869 invoked from network); 19 Aug 2005 20:12:15 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 19 Aug 2005 20:12:15 +0200 +Date: Fri, 19 Aug 2005 20:11:54 +0200 +To: "Tom Lane" , "Bob Ippolito" +Subject: Re: sustained update load of 1-2k/sec +Cc: "Mark Cotner" , + pgsql-performance@postgresql.org +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> + <67788A4A-4011-49AB-B329-683FD9532661@redivi.com> + <17690.1124458553@sss.pgh.pa.us> +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <17690.1124458553@sss.pgh.pa.us> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/275 +X-Sequence-Number: 14022 + + +> While I agree that hundreds of threads seems like overkill, I think the +> above advice might be going too far in the other direction. The problem +> with single-threaded operation is that any delay affects the whole +> system --- eg, if you're blocked waiting for disk I/O, the CPU doesn't + + You use UDP which is a connectionless protocol... then why use threads ? + + I'd advise this : + + Use asynchronous network code (one thread) to do your network stuff. This +will lower the CPU used by this code immensely. + Every minute, dump a file contianing everything to insert into the table. + Use another thread to COPY it into the DB, in a temporary table if you +wish, and then INSERT INTO ... SELECT. + This should be well adapted to your requirements. + +From pgsql-performance-owner@postgresql.org Fri Aug 19 15:43:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F256F52E4D + for ; + Fri, 19 Aug 2005 15:42:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88795-05 + for ; + Fri, 19 Aug 2005 18:42:52 +0000 (GMT) +Received: from smtpauth06.mail.atl.earthlink.net + (smtpauth06.mail.atl.earthlink.net [209.86.89.66]) + by svr1.postgresql.org (Postfix) with ESMTP id B5FA052C17 + for ; + Fri, 19 Aug 2005 15:42:50 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=Vy/G/MIfCVF79yAHkmLlW+/SYCIs8lezgttlbB9lPn4IWmdTLxUEiAF0FK8zbhtZ; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth06.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E6BpJ-0000Pm-1m; Fri, 19 Aug 2005 14:42:49 -0400 +Message-Id: <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Fri, 19 Aug 2005 14:42:43 -0400 +To: Jeremiah Jahn +From: Ron +Subject: Re: extremly low memory usage +Cc: postgres performance +In-Reply-To: <43061472.2080201@arbash-meinel.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcadf749b503341dcf81cdd621d335eccc350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.582 required=5 tests=[AWL=0.208, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/276 +X-Sequence-Number: 14023 + +At 01:18 PM 8/19/2005, John A Meinel wrote: +>Jeremiah Jahn wrote: +> > Sorry about the formatting. +> > +> > On Thu, 2005-08-18 at 12:55 -0500, John Arbash Meinel wrote: +> > +> >>Jeremiah Jahn wrote: +> >> +> >> +> +>... +> +> >>The expensive parts are the 4915 lookups into the litigant_details (each +> >>one takes approx 4ms for a total of ~20s). +> >>And then you do it again on case_data (average 3ms each * 4906 loops = +> >>~15s). +> > +> > Is there some way to avoid this? +> > +> +>Well, in general, 3ms for a single lookup seems really long. Maybe your +>index is bloated by not vacuuming often enough. Do you tend to get a lot +>of updates to litigant_details? + +Given that the average access time for a 15Krpm HD is in the 5.5-6ms +range (7.5-8ms for a 10Krpm HD), having an average of 3ms for a +single lookup implies that ~1/2 (the 15Krpm case) or ~1/3 (the 10Krpm +case) table accesses is requiring a seek. + +This implies a poor match between physical layout and access pattern. + +If I understand correctly, the table should not be very fragmented +given that this is a reasonably freshly loaded DB? That implies that +the fields being looked up are not well sorted in the table compared +to the query pattern. + +If the entire table could fit in RAM, this would be far less of a +consideration. Failing that, the physical HD layout has to be +improved or the query pattern has to be changed to reduce seeks. + + +>There are a couple possibilities at this point. First, you can REINDEX +>the appropriate index, and see if that helps. However, if this is a test +>box, it sounds like you just did a dump and reload, which wouldn't have +>bloat in an index. +> +>Another possibility. Is this the column that you usually use when +>pulling information out of litigant_details? If so, you can CLUSTER +>litigant_details on the appropriate index. This will help things be +>close together that should be, which decreases the index lookup costs. +> +>However, if this is not the common column, then you probably will slow +>down whatever other accesses you may have on this table. +> +>After CLUSTER, the current data will stay clustered, but new data will +>not, so you have to continually CLUSTER, the same way that you might +>VACUUM. *However*, IIRC CLUSTER grabs an Exclusive lock, so it is as +>expensive as a VACUUM FULL. Be aware of this, but it might vastly +>improve your performance, so it would be worth it. + +CLUSTER can be a very large maintenance overhead/problem if the +table(s) in question actually need to be "continually" re CLUSTER ed. + +If there is no better solution available, then you do what you have +to, but it feels like there should be a better answer here. + +Perhaps the DB schema needs examining to see if it matches up well +with its real usage? + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 16:23:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8645C52873 + for ; + Fri, 19 Aug 2005 16:23:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16256-06 + for ; + Fri, 19 Aug 2005 19:23:08 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id CE6045285B + for ; + Fri, 19 Aug 2005 16:23:06 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050819192307m92009htcne>; Fri, 19 Aug 2005 19:23:07 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 0925755FBA; Fri, 19 Aug 2005 14:23:07 -0500 (CDT) +Received: from [192.168.1.12] (Jigglypuff.arbash-meinel.com [192.168.1.12]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 5B4AA55FAD; + Fri, 19 Aug 2005 14:23:02 -0500 (CDT) +Message-ID: <43063196.9000001@arbash-meinel.com> +Date: Fri, 19 Aug 2005 14:23:02 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ron +Cc: Jeremiah Jahn , + postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> +In-Reply-To: <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig83629B4E59FE3046462F8DEF" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/277 +X-Sequence-Number: 14024 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig83629B4E59FE3046462F8DEF +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Ron wrote: +> At 01:18 PM 8/19/2005, John A Meinel wrote: +> +>> Jeremiah Jahn wrote: +>> > Sorry about the formatting. +>> > +>> > On Thu, 2005-08-18 at 12:55 -0500, John Arbash Meinel wrote: +>> > +>> >>Jeremiah Jahn wrote: +>> >> +>> >> +>> +>> ... +>> +>> >>The expensive parts are the 4915 lookups into the litigant_details +>> (each +>> >>one takes approx 4ms for a total of ~20s). +>> >>And then you do it again on case_data (average 3ms each * 4906 loops = +>> >>~15s). +>> > +>> > Is there some way to avoid this? +>> > +>> +>> Well, in general, 3ms for a single lookup seems really long. Maybe your +>> index is bloated by not vacuuming often enough. Do you tend to get a lot +>> of updates to litigant_details? +> +> +> Given that the average access time for a 15Krpm HD is in the 5.5-6ms +> range (7.5-8ms for a 10Krpm HD), having an average of 3ms for a single +> lookup implies that ~1/2 (the 15Krpm case) or ~1/3 (the 10Krpm case) +> table accesses is requiring a seek. +> + + +Well, from what he has said, the total indexes are < 1GB and he has 6GB +of ram. So everything should fit. Not to mention he is only accessing +5000/several million rows. + + +> This implies a poor match between physical layout and access pattern. + +This seems to be the case. But since this is not the only query, it may +be that other access patterns are more important to optimize for. + +> +> If I understand correctly, the table should not be very fragmented given +> that this is a reasonably freshly loaded DB? That implies that the +> fields being looked up are not well sorted in the table compared to the +> query pattern. +> +> If the entire table could fit in RAM, this would be far less of a +> consideration. Failing that, the physical HD layout has to be improved +> or the query pattern has to be changed to reduce seeks. +> +> + +... + +>> After CLUSTER, the current data will stay clustered, but new data will +>> not, so you have to continually CLUSTER, the same way that you might +>> VACUUM. *However*, IIRC CLUSTER grabs an Exclusive lock, so it is as +>> expensive as a VACUUM FULL. Be aware of this, but it might vastly +>> improve your performance, so it would be worth it. +> +> +> CLUSTER can be a very large maintenance overhead/problem if the table(s) +> in question actually need to be "continually" re CLUSTER ed. +> +> If there is no better solution available, then you do what you have to, +> but it feels like there should be a better answer here. +> +> Perhaps the DB schema needs examining to see if it matches up well with +> its real usage? +> +> Ron Peacetree +> + +I certainly agree that CLUSTER is expensive, and is an on-going +maintenance issue. If it is the normal access pattern, though, it may be +worth it. + +I also wonder, though, if his table is properly normalized. Which, as +you mentioned, might lead to improved access patterns. + +John +=:-> + +--------------enig83629B4E59FE3046462F8DEF +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDBjGWJdeBCYSNAAMRAsisAKDMPTuigYc5k2BjdPS3vsBPcxJ3DwCgjE0f +6hzEvFAReO5GlSMzwbZeUf0= +=ARWA +-----END PGP SIGNATURE----- + +--------------enig83629B4E59FE3046462F8DEF-- + +From pgsql-performance-owner@postgresql.org Fri Aug 19 16:32:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A3FC52A16 + for ; + Fri, 19 Aug 2005 16:32:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23242-05 + for ; + Fri, 19 Aug 2005 19:32:12 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.202]) + by svr1.postgresql.org (Postfix) with ESMTP id A40DF52A80 + for ; + Fri, 19 Aug 2005 16:32:09 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i27so556008wra + for ; + Fri, 19 Aug 2005 12:31:58 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=SrTQn70CE1NPLM2hyk61e9tHpd5kT368hdaOtlJKBSxX+x4NyH1p1ZeFS2+MtSjvnc67BVgsk8pFmAMW/nmWSi/c0TlbgMPq7yeCEd51AGQIM0ZCqAWHjiWU9ELOJbc44qsJKcfFFmC9dAcvw0UAeJ8AE0BgxkuWotxFlMQugyk= +Received: by 10.54.153.7 with SMTP id a7mr2038071wre; + Fri, 19 Aug 2005 12:31:58 -0700 (PDT) +Received: by 10.54.86.15 with HTTP; Fri, 19 Aug 2005 12:31:58 -0700 (PDT) +Message-ID: <33c6269f0508191231b12f5b@mail.gmail.com> +Date: Fri, 19 Aug 2005 15:31:58 -0400 +From: Alex Turner +To: Ron +Subject: Re: sustained update load of 1-2k/sec +Cc: postgres performance +In-Reply-To: <6.2.3.4.0.20050819093011.05c1b9d8@pop.earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> + <33c6269f050819054038af9886@mail.gmail.com> + <6.2.3.4.0.20050819093011.05c1b9d8@pop.earthlink.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.103 required=5 tests=[AWL=0.079, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/278 +X-Sequence-Number: 14025 + +Don't forget that Ultra 320 is the speed of the bus, not each drive.=20 +No matter how many honking 15k disks you put on a 320MB bus, you can +only get 320MB/sec! and have so many outstanding IO/s on the bus. + +Not so with SATA! Each drive is on it's own bus, and you are only +limited by the speed of your PCI-X Bus, which can be as high as +800MB/sec at 133Mhz/64bit. + +It's cheap and it's fast - all you have to do is pay for the +enclosure, which can be a bit pricey, but there are some nice 24bay +and even 40bay enclosures out there for SATA. + +Yes a 15k RPM drive will give you better seek time and better peak +through put, but put them all on a single U320 bus and you won't see +much return past a stripe size of 3 or 4. + +If it's raw transactions per second data warehouse style, it's all +about the xlog baby which is sequential writes, and all about large +block reads, which is sequential reads. + +Alex Turner +NetEconomist +P.S. Sorry if i'm a bit punchy, I've been up since yestarday with +server upgrade nightmares that continue ;) + +On 8/19/05, Ron wrote: +> Alex mentions a nice setup, but I'm pretty sure I know how to beat +> that IO subsystems HW's performance by at least 1.5x or 2x. Possibly +> more. (No, I do NOT work for any vendor I'm about to discuss.) +>=20 +> Start by replacing the WD Raptors with Maxtor Atlas 15K II's. +> At 5.5ms average access, 97.4MB/s outer track throughput, 85.9MB/s +> average, and 74.4 MB/s inner track throughput, they have the best +> performance characteristics of any tested shipping HDs I know +> of. (Supposedly the new SAS versions will _sustain_ ~98MB/s, but +> I'll believe that only if I see it under independent testing). +> In comparison, the numbers on the WD740GD are 8.1ms average access, +> 71.8, 62.9, and 53.9 MB/s outer, average and inner track throughputs +> respectively. +>=20 +> Be prepared to use as many of them as possible (read: as many you can +> afford) if you want to maximize transaction rates, particularly for +> small transactions like this application seems to be mentioning. +>=20 +> Next, use a better RAID card. The TOL enterprise stuff (Xyratex, +> Engino, Dot-hill) is probably too expensive, but in the commodity +> market benchmarks indicate that that Areca's 1GB buffer RAID cards +> currently outperform all the other commodity RAID stuff. +>=20 +> 9 Atlas II's per card in a RAID 5 set, or 16 per card in a RAID 10 +> set, should max the RAID card's throughput and come very close to, if +> not attaining, the real world peak bandwidth of the 64b 133MHz PCI-X +> bus they are plugged into. Say somewhere in the 700-800MB/s range. +>=20 +> Repeat the above for as many independent PCI-X buses as you have for +> a very fast commodity RAID IO subsystem. +>=20 +> Two such configured cards used in the dame manner as mentioned by +> Alex should easily attain 1.5x - 2x the transaction numbers mentioned +> by Alex unless there's a bottleneck somewhere else in the system design. +>=20 +> Hope this helps, +> Ron Peacetree +>=20 +> At 08:40 AM 8/19/2005, Alex Turner wrote: +> >I have managed tx speeds that high from postgresql going even as high +> >as 2500/sec for small tables, but it does require a good RAID +> >controler card (yes I'm even running with fsync on). I'm using 3ware +> >9500S-8MI with Raptor drives in multiple RAID 10s. The box wasn't too +> >$$$ at just around $7k. I have two independant controlers on two +> >independant PCI buses to give max throughput. on with a 6 drive RAID +> >10 and the other with two 4 drive RAID 10s. +> > +> >Alex Turner +> >NetEconomist +> > +> >On 8/19/05, Mark Cotner wrote: +> > > Hi all, +> > > I bet you get tired of the same ole questions over and +> > > over. +> > > +> > > I'm currently working on an application that will poll +> > > thousands of cable modems per minute and I would like +> > > to use PostgreSQL to maintain state between polls of +> > > each device. This requires a very heavy amount of +> > > updates in place on a reasonably large table(100k-500k +> > > rows, ~7 columns mostly integers/bigint). Each row +> > > will be refreshed every 15 minutes, or at least that's +> > > how fast I can poll via SNMP. I hope I can tune the +> > > DB to keep up. +> > > +> > > The app is threaded and will likely have well over 100 +> > > concurrent db connections. Temp tables for storage +> > > aren't a preferred option since this is designed to be +> > > a shared nothing approach and I will likely have +> > > several polling processes. +> > > +> > > Here are some of my assumptions so far . . . +> > > +> > > HUGE WAL +> > > Vacuum hourly if not more often +> > > +> > > I'm getting 1700tx/sec from MySQL and I would REALLY +> > > prefer to use PG. I don't need to match the number, +> > > just get close. +> > > +> > > Is there a global temp table option? In memory tables +> > > would be very beneficial in this case. I could just +> > > flush it to disk occasionally with an insert into blah +> > > select from memory table. +> > > +> > > Any help or creative alternatives would be greatly +> > > appreciated. :) +> > > +> > > 'njoy, +> > > Mark +> > > +> > > +> > > -- +> > > Writing software requires an intelligent person, +> > > creating functional art requires an artist. +> > > -- Unknown +> > > +> > > +> > > ---------------------------(end of broadcast)------------------------= +--- +> > > TIP 3: Have you checked our extensive FAQ? +> > > +> > > http://www.postgresql.org/docs/faq +> > > +> > +> >---------------------------(end of broadcast)--------------------------- +> >TIP 2: Don't 'kill -9' the postmaster +>=20 +>=20 +>=20 +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + +From pgsql-performance-owner@postgresql.org Fri Aug 19 16:57:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E37C152A72 + for ; + Fri, 19 Aug 2005 16:56:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42580-07 + for ; + Fri, 19 Aug 2005 19:56:31 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 7ED2E52858 + for ; + Fri, 19 Aug 2005 16:56:29 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7JJuRVs005330; Fri, 19 Aug 2005 14:56:29 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: John A Meinel +Cc: Jeff Trout , + postgres performance +In-Reply-To: <43061472.2080201@arbash-meinel.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> +Content-Type: text/plain +Date: Fri, 19 Aug 2005 14:56:26 -0500 +Message-Id: <1124481386.27881.167.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1034/Thu Aug 18 15:07:58 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.033 required=5 tests=[AWL=-0.017, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/279 +X-Sequence-Number: 14026 + +On Fri, 2005-08-19 at 12:18 -0500, John A Meinel wrote: +> Jeremiah Jahn wrote: +> > Sorry about the formatting. +> > +> > On Thu, 2005-08-18 at 12:55 -0500, John Arbash Meinel wrote: +> > +> >>Jeremiah Jahn wrote: +> >> +> >> +> +> ... +> +> >>The expensive parts are the 4915 lookups into the litigant_details (each +> >>one takes approx 4ms for a total of ~20s). +> >>And then you do it again on case_data (average 3ms each * 4906 loops = +> >>~15s). +> > +> > Is there some way to avoid this? +> > +> +> Well, in general, 3ms for a single lookup seems really long. Maybe your +> index is bloated by not vacuuming often enough. Do you tend to get a lot +> of updates to litigant_details? +I have vacuumed this already. I get lots of updates, but this data is +mostly unchanging. + +> +> There are a couple possibilities at this point. First, you can REINDEX +> the appropriate index, and see if that helps. However, if this is a test +> box, it sounds like you just did a dump and reload, which wouldn't have +> bloat in an index. + +I loaded it using slony + +> +> Another possibility. Is this the column that you usually use when +> pulling information out of litigant_details? If so, you can CLUSTER +> litigant_details on the appropriate index. This will help things be +> close together that should be, which decreases the index lookup costs. +clustering on this right now. Most of the other things are already +clustered. name and case_data + +> +> However, if this is not the common column, then you probably will slow +> down whatever other accesses you may have on this table. +> +> After CLUSTER, the current data will stay clustered, but new data will +> not, so you have to continually CLUSTER, the same way that you might +> VACUUM. *However*, IIRC CLUSTER grabs an Exclusive lock, so it is as +> expensive as a VACUUM FULL. Be aware of this, but it might vastly +> improve your performance, so it would be worth it. +I generally re-cluster once a week. +> +> > +> > +> >>So there is no need for preloading your indexes on the identity table. +> >>It is definitely not the bottleneck. +> >> +> >>So a few design bits, which may help your database. +> >>Why is "actor_id" a text field instead of a number? +> > +> > This is simply due to the nature of the data. +> > +> +> I'm just wondering if changing into a number, and using a number->name +> lookup would be faster for you. It may not be. In general, I prefer to +> use numbers for references. I may be over paranoid, but I know that some +> locales are bad with string -> string comparisons. And since the data in +> your database is stored as UNICODE, I'm not sure if it has to do any +> translating or not. Again, something to consider, it may not make any +> difference. +I don't believe so. I initialze the DB as 'lang=C'. I used to have the +problem where things were being inited as en_US. this would prevent any +text based index from working. This doesn't seem to be the case here, so +I'm not worried about it. + + +> +> +> > +> >>You could try creating an index on "litigant_details (actor_id, +> >>count_ori)" so that it can do just an index lookup, rather than an index +> >>+ filter. +> > +> > I have one, but it doesn't seem to like to use it. Don't really need it +> > though, I can just drop the court_id out of the query. It's redundant, +> > since each actor_id is also unique in litigant details. I had run vac +> > full and analyze but I ran them again anyway and the planning improved. +> > However, my 14 disk raid 10 array is still slower than my 3 disk raid 5 +> > on my production box. 46sec vs 30sec (with live traffic on the +> > production) One of the strange things is that when I run the cat command +> > on my index and tables that are "HOT" it has no effect on memory usage. +> > Right now I'm running ext3 on LVM. I'm still in a position to redo the +> > file system and everything. Is this a good way to do it or should I +> > switch to something else? What about stripe and extent sizes...? kernel +> > parameters to change? +> +> Well, the plans are virtually identical. There is one small difference +> as to whether it joins against case_data or court first. But 'court' is +> very tiny (small enough to use a seqscan instead of index scan) I'm a +> little surprised with court being this small that it doesn't do +> something like a hash aggregation, but court takes no time anyway. +> +> The real problem is that your nested loop index time is *much* slower. +> +> Devel: +> -> Index Scan using lit_actor_speed on litigant_details +> (cost=0.00..3.96 rows=1 width=81) +> (actual time=4.788..4.812 rows=1 loops=5057) +> +> Production: +> -> Index Scan using lit_actor_speed on litigant_details +> (cost=0.00..5.63 rows=1 width=81) +> (actual time=3.355..3.364 rows=1 loops=5057) +> +> Devel: +> -> Index Scan using case_speed on case_data +> (cost=0.00..3.46 rows=1 width=26) +> (actual time=4.222..4.230 rows=1 loops=5052) +> +> Production: +> -> Index Scan using case_data_pkey on case_data +> (cost=0.00..5.31 rows=1 width=26) +> (actual time=1.897..1.904 rows=1 loops=5052) +> +> Notice that the actual per-row cost is as much as 1/2 less than on your +> devel box. +> +> As a test, can you do "time cat $index_file >/dev/null" a couple of +> times. And then determine the MB/s. +> Alternatively run vmstat in another shell. If the read/s doesn't change, +> then you know the "cat" is being served from RAM, and thus it really is +> cached. +it's cached alright. I'm getting a read rate of about 150MB/sec. I would +have thought is would be faster with my raid setup. I think I'm going to +scrap the whole thing and get rid of LVM. I'll just do a straight ext3 +system. Maybe that will help. Still trying to get suggestions for a +stripe size. + +> +> I can point you to REINDEX and CLUSTER, but if it is caching in ram, I +> honestly can't say why the per loop would be that much slower. +> Are both systems running the same postgres version? It sounds like it is +> different (since you say something about switching to 8.0). +These had little or no effect. +The production machine is running 7.4 while the devel machine is running +8.0 + +> I doubt it, but you might try an 8.1devel version. +> +> ... +> +> >>Do you regularly vacuum analyze your tables? +> >>Just as a test, try running: +> >>set enable_nested_loop to off; +> > +> > not quite acceptable +> > Total runtime: 221486.149 ms +> > +> +> Well, the estimates are now at least closer (3k vs 5k instead of 1), and +> it is still choosing nested loops. So they probably are faster. +> I would still be interested in the actual EXPLAIN ANALYZE with nested +> loops disabled. It is possible that *some* of the nested loops are +> performing worse than they have to. + +this is a cached version. + +> copa=> explain analyze select full_name,identity_id,identity.case_id,court.id,date_of_birth,assigned_case_role,litigant_details.impound_litigant_data +> copa-> from identity +> copa-> join litigant_details on identity.actor_id = litigant_details.actor_id +> copa-> join case_data on litigant_details.case_id = case_data.case_id and litigant_details.court_ori = case_data.court_ori +> copa-> join court on identity.court_ori = court.id +> copa-> where identity.court_ori = 'IL081025J' and full_name like 'SMITH%' order by full_name; +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +> Sort (cost=100502560.72..100502583.47 rows=9099 width=86) (actual time=17843.876..17849.401 rows=8094 loops=1) +> Sort Key: identity.full_name +> -> Merge Join (cost=100311378.72..100501962.40 rows=9099 width=86) (actual time=15195.816..17817.847 rows=8094 loops=1) +> Merge Cond: ((("outer".court_ori)::text = "inner"."?column10?") AND (("outer".case_id)::text = "inner"."?column11?")) +> -> Index Scan using case_speed on case_data (cost=0.00..170424.73 rows=3999943 width=26) (actual time=0.015..4540.525 rows=3018284 loops=1) +> -> Sort (cost=100311378.72..100311400.82 rows=8839 width=112) (actual time=9594.985..9601.174 rows=8094 loops=1) +> Sort Key: (litigant_details.court_ori)::text, (litigant_details.case_id)::text +> -> Nested Loop (cost=100002491.43..100310799.34 rows=8839 width=112) (actual time=6892.755..9555.828 rows=8094 loops=1) +> -> Seq Scan on court (cost=0.00..3.29 rows=1 width=12) (actual time=0.085..0.096 rows=1 loops=1) +> Filter: ('IL081025J'::text = (id)::text) +> -> Merge Join (cost=2491.43..310707.66 rows=8839 width=113) (actual time=6892.656..9519.680 rows=8094 loops=1) +> Merge Cond: (("outer".actor_id)::text = "inner"."?column7?") +> -> Index Scan using lit_actor_speed on litigant_details (cost=0.00..295722.00 rows=4956820 width=81) (actual time=0.027..5613.814 rows=3736703 loops=1) +> -> Sort (cost=2491.43..2513.71 rows=8913 width=82) (actual time=116.071..122.272 rows=8100 loops=1) +> Sort Key: (identity.actor_id)::text +> -> Index Scan using name_speed on identity (cost=0.00..1906.66 rows=8913 width=82) (actual time=0.133..81.104 rows=8100 loops=1) +> Index Cond: (((full_name)::text >= 'SMITH'::character varying) AND ((full_name)::text < 'SMITI'::character varying)) +> Filter: (((court_ori)::text = 'IL081025J'::text) AND ((full_name)::text ~~ 'SMITH%'::text)) +> Total runtime: 17859.917 ms + +> But really, you have worse index speed, and that needs to be figured out. +> +> John +> =:-> +-- +Speak softly and carry a +6 two-handed sword. + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 17:11:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DC9C152858 + for ; + Fri, 19 Aug 2005 17:11:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53255-07 + for ; + Fri, 19 Aug 2005 20:11:32 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id BFC8552869 + for ; + Fri, 19 Aug 2005 17:11:29 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7JKBSis005565; Fri, 19 Aug 2005 15:11:28 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: John A Meinel +Cc: Ron , + postgres performance +In-Reply-To: <43063196.9000001@arbash-meinel.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> +Content-Type: text/plain +Date: Fri, 19 Aug 2005 15:11:28 -0500 +Message-Id: <1124482288.27881.182.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1034/Thu Aug 18 15:07:58 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.034 required=5 tests=[AWL=-0.016, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/280 +X-Sequence-Number: 14027 + +On Fri, 2005-08-19 at 14:23 -0500, John A Meinel wrote: +> Ron wrote: +> > At 01:18 PM 8/19/2005, John A Meinel wrote: +> > +> >> Jeremiah Jahn wrote: +> >> > Sorry about the formatting. +> >> > +> >> > On Thu, 2005-08-18 at 12:55 -0500, John Arbash Meinel wrote: +> >> > +> >> >>Jeremiah Jahn wrote: +> >> >> +> >> >> +> >> +> >> ... +> >> +> >> >>The expensive parts are the 4915 lookups into the litigant_details +> >> (each +> >> >>one takes approx 4ms for a total of ~20s). +> >> >>And then you do it again on case_data (average 3ms each * 4906 loops = +> >> >>~15s). +> >> > +> >> > Is there some way to avoid this? +> >> > +> >> +> >> Well, in general, 3ms for a single lookup seems really long. Maybe your +> >> index is bloated by not vacuuming often enough. Do you tend to get a lot +> >> of updates to litigant_details? +> > +> > +> > Given that the average access time for a 15Krpm HD is in the 5.5-6ms +> > range (7.5-8ms for a 10Krpm HD), having an average of 3ms for a single +> > lookup implies that ~1/2 (the 15Krpm case) or ~1/3 (the 10Krpm case) +> > table accesses is requiring a seek. +> > +I think LVM may be a problem, since it also seems to break things up on +the file system. My access time on the seek should be around 1/7th the +15Krpm I believe since it's a 14 disk raid 10 array. And no other +traffic at the moment. + + + +> +> +> Well, from what he has said, the total indexes are < 1GB and he has 6GB +> of ram. So everything should fit. Not to mention he is only accessing +> 5000/several million rows. +I table spaced some of the indexes and they are around 211066880 bytes +for the name_speed index and 149825330 for the lit_actor_speed index +tables seem to be about a gig. + +> +> +> > This implies a poor match between physical layout and access pattern. +> +> This seems to be the case. But since this is not the only query, it may +> be that other access patterns are more important to optimize for. +> +> > +> > If I understand correctly, the table should not be very fragmented given +> > that this is a reasonably freshly loaded DB? That implies that the +> > fields being looked up are not well sorted in the table compared to the +> > query pattern. +> > +> > If the entire table could fit in RAM, this would be far less of a +> > consideration. Failing that, the physical HD layout has to be improved +> > or the query pattern has to be changed to reduce seeks. +> > +> > +> +> ... +> +> >> After CLUSTER, the current data will stay clustered, but new data will +> >> not, so you have to continually CLUSTER, the same way that you might +> >> VACUUM. *However*, IIRC CLUSTER grabs an Exclusive lock, so it is as +> >> expensive as a VACUUM FULL. Be aware of this, but it might vastly +> >> improve your performance, so it would be worth it. +> > +> > +> > CLUSTER can be a very large maintenance overhead/problem if the table(s) +> > in question actually need to be "continually" re CLUSTER ed. +> > +> > If there is no better solution available, then you do what you have to, +> > but it feels like there should be a better answer here. +> > +> > Perhaps the DB schema needs examining to see if it matches up well with +> > its real usage? +> > +> > Ron Peacetree +> > +> +> I certainly agree that CLUSTER is expensive, and is an on-going +> maintenance issue. If it is the normal access pattern, though, it may be +> worth it. + +The query I've sent you is one of the most common I get just change the +name. I handle about 180K of them a day mostly between 8 and 5. The +clustering has never really been a problem. Like I said before I do it +about once a week. I handle about 3000 update an hour consisting of +about 1000-3000 statement per update. ie about 2.5 million updates per +hour. In the last few months or so I've filtered these down to about +400K update/delete/insert statements per hour. + +> +> I also wonder, though, if his table is properly normalized. Which, as +> you mentioned, might lead to improved access patterns. +The system is about as normalized as I can get it. In general the layout +is the following: +courts have cases, cases have litigant_details. Actors have identities +and litigant_details. + +> +> John +> =:-> +-- +Speak softly and carry a +6 two-handed sword. + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 18:06:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CAF8E52C17 + for ; + Fri, 19 Aug 2005 18:01:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13616-01 + for ; + Fri, 19 Aug 2005 21:01:43 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CC9E52BF3 + for ; + Fri, 19 Aug 2005 18:01:42 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7JL1etb006646; Fri, 19 Aug 2005 16:01:40 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: John A Meinel +Cc: Ron , + postgres performance +In-Reply-To: <43063196.9000001@arbash-meinel.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> +Content-Type: text/plain +Date: Fri, 19 Aug 2005 16:01:39 -0500 +Message-Id: <1124485299.27881.192.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1034/Thu Aug 18 15:07:58 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.034 required=5 tests=[AWL=-0.016, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/281 +X-Sequence-Number: 14028 + +Rebuild in progress with just ext3 on the raid array...will see if this +helps the access times. If it doesn't I'll mess with the stripe size. I +have REINDEXED, CLUSTERED, tablespaced and cached with 'cat table/index +> /dev/null' none of this seems to have helped, or even increased my +memory usage. argh! The only thing about this new system that I'm +unfamiliar with is the array setup and LVM, which is why I think that's +where the issue is. clustering and indexing as well as vacuum etc are +things that I do and have been aware of for sometime. Perhaps slony is a +factor, but I really don't see it causing problems on index read speed +esp. when it's not running. + +thanx for your help, I really appreciate it. +-jj- + + + + +On Fri, 2005-08-19 at 14:23 -0500, John A Meinel wrote: +> Ron wrote: +> > At 01:18 PM 8/19/2005, John A Meinel wrote: +> > +> >> Jeremiah Jahn wrote: +> >> > Sorry about the formatting. +> >> > +> >> > On Thu, 2005-08-18 at 12:55 -0500, John Arbash Meinel wrote: +> >> > +> >> >>Jeremiah Jahn wrote: +> >> >> +> >> >> +> >> +> >> ... +> >> +> >> >>The expensive parts are the 4915 lookups into the litigant_details +> >> (each +> >> >>one takes approx 4ms for a total of ~20s). +> >> >>And then you do it again on case_data (average 3ms each * 4906 loops = +> >> >>~15s). +> >> > +> >> > Is there some way to avoid this? +> >> > +> >> +> >> Well, in general, 3ms for a single lookup seems really long. Maybe your +> >> index is bloated by not vacuuming often enough. Do you tend to get a lot +> >> of updates to litigant_details? +> > +> > +> > Given that the average access time for a 15Krpm HD is in the 5.5-6ms +> > range (7.5-8ms for a 10Krpm HD), having an average of 3ms for a single +> > lookup implies that ~1/2 (the 15Krpm case) or ~1/3 (the 10Krpm case) +> > table accesses is requiring a seek. +> > +> +> +> Well, from what he has said, the total indexes are < 1GB and he has 6GB +> of ram. So everything should fit. Not to mention he is only accessing +> 5000/several million rows. +> +> +> > This implies a poor match between physical layout and access pattern. +> +> This seems to be the case. But since this is not the only query, it may +> be that other access patterns are more important to optimize for. +> +> > +> > If I understand correctly, the table should not be very fragmented given +> > that this is a reasonably freshly loaded DB? That implies that the +> > fields being looked up are not well sorted in the table compared to the +> > query pattern. +> > +> > If the entire table could fit in RAM, this would be far less of a +> > consideration. Failing that, the physical HD layout has to be improved +> > or the query pattern has to be changed to reduce seeks. +> > +> > +> +> ... +> +> >> After CLUSTER, the current data will stay clustered, but new data will +> >> not, so you have to continually CLUSTER, the same way that you might +> >> VACUUM. *However*, IIRC CLUSTER grabs an Exclusive lock, so it is as +> >> expensive as a VACUUM FULL. Be aware of this, but it might vastly +> >> improve your performance, so it would be worth it. +> > +> > +> > CLUSTER can be a very large maintenance overhead/problem if the table(s) +> > in question actually need to be "continually" re CLUSTER ed. +> > +> > If there is no better solution available, then you do what you have to, +> > but it feels like there should be a better answer here. +> > +> > Perhaps the DB schema needs examining to see if it matches up well with +> > its real usage? +> > +> > Ron Peacetree +> > +> +> I certainly agree that CLUSTER is expensive, and is an on-going +> maintenance issue. If it is the normal access pattern, though, it may be +> worth it. +> +> I also wonder, though, if his table is properly normalized. Which, as +> you mentioned, might lead to improved access patterns. +> +> John +> =:-> +-- +Speak softly and carry a +6 two-handed sword. + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 18:06:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69D1452B9D + for ; + Fri, 19 Aug 2005 18:03:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00678-09 + for ; + Fri, 19 Aug 2005 21:03:18 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id C248052B98 + for ; + Fri, 19 Aug 2005 18:03:16 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050819210318m92009jnkpe>; Fri, 19 Aug 2005 21:03:18 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 0F23255FBA; Fri, 19 Aug 2005 16:03:18 -0500 (CDT) +Received: from [192.168.1.103] (63-230-159-164.cdrr.qwest.net + [63.230.159.164]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 55CA255FAD; + Fri, 19 Aug 2005 16:03:07 -0500 (CDT) +Message-ID: <43064908.7010505@arbash-meinel.com> +Date: Fri, 19 Aug 2005 16:03:04 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: Jeff Trout , + postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <1124481386.27881.167.camel@bluejay.goodinassociates.com> +In-Reply-To: <1124481386.27881.167.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigE5E6EAB78A66B0E023BE7ECF" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.025 required=5 tests=[AWL=-0.025, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/282 +X-Sequence-Number: 14029 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigE5E6EAB78A66B0E023BE7ECF +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: +> On Fri, 2005-08-19 at 12:18 -0500, John A Meinel wrote: +> +>>Jeremiah Jahn wrote: +>> + + +... + +>> +>>Well, in general, 3ms for a single lookup seems really long. Maybe your +>>index is bloated by not vacuuming often enough. Do you tend to get a lot +>>of updates to litigant_details? +> +> I have vacuumed this already. I get lots of updates, but this data is +> mostly unchanging. +> +> +>>There are a couple possibilities at this point. First, you can REINDEX +>>the appropriate index, and see if that helps. However, if this is a test +>>box, it sounds like you just did a dump and reload, which wouldn't have +>>bloat in an index. +> +> +> I loaded it using slony + +I don't know that slony versus pg_dump/pg_restore really matters. The +big thing is that Updates wouldn't be trashing your index. +But if you are saying that you cluster once/wk your index can't be that +messed up anyway. (Unless CLUSTER messes up the non-clustered indexes, +but that would make cluster much less useful, so I would have guessed +this was not the case) + +> +> +>>Another possibility. Is this the column that you usually use when +>>pulling information out of litigant_details? If so, you can CLUSTER +>>litigant_details on the appropriate index. This will help things be +>>close together that should be, which decreases the index lookup costs. +> +> clustering on this right now. Most of the other things are already +> clustered. name and case_data + +Just as a reality check, they are clustered on the columns in question, +right? (I don't know if this column is a primary key or not, but any +index can be used for clustering). + +> +> +>>However, if this is not the common column, then you probably will slow +>>down whatever other accesses you may have on this table. +>> +>>After CLUSTER, the current data will stay clustered, but new data will +>>not, so you have to continually CLUSTER, the same way that you might +>>VACUUM. *However*, IIRC CLUSTER grabs an Exclusive lock, so it is as +>>expensive as a VACUUM FULL. Be aware of this, but it might vastly +>>improve your performance, so it would be worth it. +> +> I generally re-cluster once a week. +> +>>> +>>>>So there is no need for preloading your indexes on the identity table. +>>>>It is definitely not the bottleneck. +>>>> +>>>>So a few design bits, which may help your database. +>>>>Why is "actor_id" a text field instead of a number? +>>> +>>>This is simply due to the nature of the data. +>>> +>> +>>I'm just wondering if changing into a number, and using a number->name +>>lookup would be faster for you. It may not be. In general, I prefer to +>>use numbers for references. I may be over paranoid, but I know that some +>>locales are bad with string -> string comparisons. And since the data in +>>your database is stored as UNICODE, I'm not sure if it has to do any +>>translating or not. Again, something to consider, it may not make any +>>difference. +> +> I don't believe so. I initialze the DB as 'lang=C'. I used to have the +> problem where things were being inited as en_US. this would prevent any +> text based index from working. This doesn't seem to be the case here, so +> I'm not worried about it. +> + +Sorry, I think I was confusing you with someone else who posted SHOW ALL. + +> +> +>> + +... + +> it's cached alright. I'm getting a read rate of about 150MB/sec. I would +> have thought is would be faster with my raid setup. I think I'm going to +> scrap the whole thing and get rid of LVM. I'll just do a straight ext3 +> system. Maybe that will help. Still trying to get suggestions for a +> stripe size. +> + +I don't think 150MB/s is out of the realm for a 14 drive array. +How fast is +time dd if=/dev/zero of=testfile bs=8192 count=1000000 +(That should create a 8GB file, which is too big to cache everything) +And then how fast is: +time dd if=testfile of=/dev/null bs=8192 count=1000000 + +That should give you a semi-decent way of measuring how fast the RAID +system is, since it should be too big to cache in ram. + +> +>>I can point you to REINDEX and CLUSTER, but if it is caching in ram, I +>>honestly can't say why the per loop would be that much slower. +>>Are both systems running the same postgres version? It sounds like it is +>>different (since you say something about switching to 8.0). +> +> These had little or no effect. +> The production machine is running 7.4 while the devel machine is running +> 8.0 +> + +Well, my concern is that maybe some portion of the 8.0 code actually +slowed things down for you. You could try reverting to 7.4 on the devel +box, though I think playing with upgrading to 8.1 might be more worthwhile. + +... + +> +> this is a cached version. +> + +I assume that you mean this is the second run of the query. I can't +compare it too much, since this is "smith" rather than "jones". But this +one is 17s rather than the other one being 46s. + +And that includes having 8k rows instead of having 5k rows. + +Have you tried other values with disabled nested loops? Because this +query (at least in cached form) seems to be *way* faster than with +nested loops. +I know that you somehow managed to get 200s in your testing, but it +might just be that whatever needed to be loaded is now loaded, and you +would get better performance. +If this is true, it means you might need to tweak some settings, and +make sure your statistics are decent, so that postgres can actually pick +the optimal plan. + +> +>>copa=> explain analyze select full_name,identity_id,identity.case_id,court.id,date_of_birth,assigned_case_role,litigant_details.impound_litigant_data +>>copa-> from identity +>>copa-> join litigant_details on identity.actor_id = litigant_details.actor_id +>>copa-> join case_data on litigant_details.case_id = case_data.case_id and litigant_details.court_ori = case_data.court_ori +>>copa-> join court on identity.court_ori = court.id +>>copa-> where identity.court_ori = 'IL081025J' and full_name like 'SMITH%' order by full_name; +>> QUERY PLAN +>>------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +>> Sort (cost=100502560.72..100502583.47 rows=9099 width=86) (actual time=17843.876..17849.401 rows=8094 loops=1) +>> Sort Key: identity.full_name +>> -> Merge Join (cost=100311378.72..100501962.40 rows=9099 width=86) (actual time=15195.816..17817.847 rows=8094 loops=1) +>> Merge Cond: ((("outer".court_ori)::text = "inner"."?column10?") AND (("outer".case_id)::text = "inner"."?column11?")) +>> -> Index Scan using case_speed on case_data (cost=0.00..170424.73 rows=3999943 width=26) (actual time=0.015..4540.525 rows=3018284 loops=1) +>> -> Sort (cost=100311378.72..100311400.82 rows=8839 width=112) (actual time=9594.985..9601.174 rows=8094 loops=1) +>> Sort Key: (litigant_details.court_ori)::text, (litigant_details.case_id)::text +>> -> Nested Loop (cost=100002491.43..100310799.34 rows=8839 width=112) (actual time=6892.755..9555.828 rows=8094 loops=1) +>> -> Seq Scan on court (cost=0.00..3.29 rows=1 width=12) (actual time=0.085..0.096 rows=1 loops=1) +>> Filter: ('IL081025J'::text = (id)::text) + +What I don't really understand is the next part. It seems to be doing an +index scan on 3.7M rows, and getting very decent performance (5s), and +then merging against a table which returns only 8k rows. +Why is it having to look through all of those rows? +I may be missing something, but this says it is able to do 600 index +lookups / millisecond. Which seems superfast. (Compared to your earlier +4ms / lookup) + +Something fishy is going on here. + + +>> -> Merge Join (cost=2491.43..310707.66 rows=8839 width=113) (actual time=6892.656..9519.680 rows=8094 loops=1) +>> Merge Cond: (("outer".actor_id)::text = "inner"."?column7?") +>> -> Index Scan using lit_actor_speed on litigant_details (cost=0.00..295722.00 rows=4956820 width=81) (actual time=0.027..5613.814 rows=3736703 loops=1) +>> -> Sort (cost=2491.43..2513.71 rows=8913 width=82) (actual time=116.071..122.272 rows=8100 loops=1) +>> Sort Key: (identity.actor_id)::text +>> -> Index Scan using name_speed on identity (cost=0.00..1906.66 rows=8913 width=82) (actual time=0.133..81.104 rows=8100 loops=1) +>> Index Cond: (((full_name)::text >= 'SMITH'::character varying) AND ((full_name)::text < 'SMITI'::character varying)) +>> Filter: (((court_ori)::text = 'IL081025J'::text) AND ((full_name)::text ~~ 'SMITH%'::text)) +>> Total runtime: 17859.917 ms +> +> +>>But really, you have worse index speed, and that needs to be figured out. +>> +>>John +>>=:-> + +I'm assuming your data is private (since it looks like legal stuff). +Unless maybe that makes it part of the public record. +Anyway, I'm not able to, but sometimes someone like Tom can profile +stuff to see what is going on. + +I might just be messing up my ability to read the explain output. But +somehow things don't seem to be lining up with the cost of a single +index lookup. +On my crappy Celeron 450 box, an index lookup is 0.06ms once things are +cached in ram. + +John +=:-> + + + +--------------enigE5E6EAB78A66B0E023BE7ECF +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDBkkIJdeBCYSNAAMRAvkXAKDT8tRVb2b85F6RjhGvMorKv39YfQCaA4HD +uFJc5g6grmnac0RjuIt1vp4= +=3LUc +-----END PGP SIGNATURE----- + +--------------enigE5E6EAB78A66B0E023BE7ECF-- + +From pgsql-performance-owner@postgresql.org Fri Aug 19 18:12:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D639552E04 + for ; + Fri, 19 Aug 2005 18:07:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07214-09 + for ; + Fri, 19 Aug 2005 21:07:24 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id E7B3352C61 + for ; + Fri, 19 Aug 2005 18:07:23 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050819210724m9100g7aoge>; Fri, 19 Aug 2005 21:07:24 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 54A0355FBA; Fri, 19 Aug 2005 16:07:24 -0500 (CDT) +Received: from [192.168.1.103] (63-230-159-164.cdrr.qwest.net + [63.230.159.164]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 37DCA55FAD; + Fri, 19 Aug 2005 16:07:20 -0500 (CDT) +Message-ID: <43064A06.8020102@arbash-meinel.com> +Date: Fri, 19 Aug 2005 16:07:18 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: Ron , + postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124485299.27881.192.camel@bluejay.goodinassociates.com> +In-Reply-To: <1124485299.27881.192.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig0B481C51B574C85D434A19BC" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.027 required=5 tests=[AWL=-0.023, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/283 +X-Sequence-Number: 14030 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig0B481C51B574C85D434A19BC +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: +> Rebuild in progress with just ext3 on the raid array...will see if this +> helps the access times. If it doesn't I'll mess with the stripe size. I +> have REINDEXED, CLUSTERED, tablespaced and cached with 'cat table/index +> +>>/dev/null' none of this seems to have helped, or even increased my +> +> memory usage. argh! The only thing about this new system that I'm +> unfamiliar with is the array setup and LVM, which is why I think that's +> where the issue is. clustering and indexing as well as vacuum etc are +> things that I do and have been aware of for sometime. Perhaps slony is a +> factor, but I really don't see it causing problems on index read speed +> esp. when it's not running. +> +> thanx for your help, I really appreciate it. +> -jj- +> + +By the way, how are you measuring memory usage? Can you give the output +of that command, just to make sure you are reading it correctly. + +John +=:-> + + +--------------enig0B481C51B574C85D434A19BC +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDBkoGJdeBCYSNAAMRAkUiAKCAOu6b6h8oee4Tv/WB0VDtVOF2OACfaDp3 +Cx9Hw+sPlGNxaw1/tZ8Mxv4= +=IxL1 +-----END PGP SIGNATURE----- + +--------------enig0B481C51B574C85D434A19BC-- + +From pgsql-performance-owner@postgresql.org Fri Aug 19 18:21:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A50CD52B9D + for ; + Fri, 19 Aug 2005 18:19:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26812-05 + for ; + Fri, 19 Aug 2005 21:19:04 +0000 (GMT) +Received: from smtpauth07.mail.atl.earthlink.net + (smtpauth07.mail.atl.earthlink.net [209.86.89.67]) + by svr1.postgresql.org (Postfix) with ESMTP id 144C152B6D + for ; + Fri, 19 Aug 2005 18:19:03 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=oqD3jsLMocgjvyXVw03LXiQNwxXiPl6I2cw0zve2vXW22gUwyIHeNjE9/+vrMzeP; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth07.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E6EGX-000856-0z; Fri, 19 Aug 2005 17:19:05 -0400 +Message-Id: <6.2.3.4.0.20050819163215.05ba0a98@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Fri, 19 Aug 2005 17:19:00 -0400 +To: Alex Turner +From: Ron +Subject: Re: sustained update load of 1-2k/sec +Cc: postgres performance +In-Reply-To: <33c6269f0508191231b12f5b@mail.gmail.com> +References: <20050819082404.53751.qmail@web32915.mail.mud.yahoo.com> + <33c6269f050819054038af9886@mail.gmail.com> + <6.2.3.4.0.20050819093011.05c1b9d8@pop.earthlink.net> + <33c6269f0508191231b12f5b@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc8b6ab3b984c581f56246ba50e4529136350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.548 required=5 tests=[AWL=0.174, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/284 +X-Sequence-Number: 14031 + +At 03:31 PM 8/19/2005, Alex Turner wrote: +>Don't forget that Ultra 320 is the speed of the bus, not each drive. +>No matter how many honking 15k disks you put on a 320MB bus, you can +>only get 320MB/sec! and have so many outstanding IO/s on the bus. + +Of course. This is exactly why multi-channel SCSI and multichannel +Fibre Channel cards exist; and why external RAID enclosures usually +have multiple such cards in them... + +Even moderately acceptable U320 SCSI cards are dual channel at this +point (think Adaptec dual channel AHAxxxx's), and Quad channel ones +are just as common. The Quads will, of course, saturate a 64b 133MHz +PCI-X bus. _IF_ the chipset on them can keep up. + +The current kings of RAID card performance are all Fibre Channel +based, and all the ones I know of are theoretically capable of +saturating a 64b 133MHz PCI-X bus. Again, _IF_ the chipset on them +can keep up. + +Most commodity RAID card have neither adequate CPU nor enough +buffer. Regardless of the peripheral IO technology they use. + + +>Not so with SATA! Each drive is on it's own bus, and you are only +>limited by the speed of your PCI-X Bus, which can be as high as +>800MB/sec at 133Mhz/64bit. + +That's the Theory anyway, and latency should be lower as well. OTOH, +as my wife likes to say "In theory, Theory and Practice are the +same. In practice, they almost never are." + +You are only getting the performance you mention as long as your card +can keep up with multiplexing N IO streams, crunching RAID 5 XORs +(assuming you are using RAID 5), etc, etc. As I'm sure you know, +"The chain is only as strong as its weakest link.". + +Most commodity SATA RAID cards brag about being able to pump 300MB/s +(they were all over LW SF bragging about this!?), which in this +context is woefully unimpressive. Sigh. + +I'm impressed with the Areca cards because they usually have CPUs +that actually can come close to pushing the theoretical IO limit of +the bus they are plugged into; and they can be upgraded to (barely) +acceptable buffer amounts (come on, manufacturers! 4GB of DDR +PC3200 is only -2- DIMMs, and shortly that will be enough to hold 8GB +of DDR PC3200. Give us more buffer!). + + +>It's cheap and it's fast - all you have to do is pay for the +>enclosure, which can be a bit pricey, but there are some nice 24bay +>and even 40bay enclosures out there for SATA. + +I've even seen 48 bay ones. However, good enclosures, particularly +for larger numbers of HDs, are examples of non-trivial engineering +and priced accordingly. Too many times I see people buy "bargain" +enclosures and set themselves and their organizations up for some +_very_ unpleasant times that could easily have been avoided by being +careful to buy quality products. "Pay when you buy or pay much more later." + + +>Yes a 15k RPM drive will give you better seek time and better peak +>through put, but put them all on a single U320 bus and you won't see +>much return past a stripe size of 3 or 4 + +Agreed. Same holds for 2Gbps FC. Haven't tested 4Gbps FC personally +yet, but I'm told the limit is higher in the manner you'd expect. + + +>If it's raw transactions per second data warehouse style, it's all +>about the xlog baby which is sequential writes, and all about large +>block reads, which is sequential reads. +> +>Alex Turner +>NetEconomist +>P.S. Sorry if i'm a bit punchy, I've been up since yestarday with +>server upgrade nightmares that continue ;) + +My condolences and sympathies. I've definitely been there and done that. + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Fri Aug 19 20:02:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C2DE952CB2 + for ; + Fri, 19 Aug 2005 20:02:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05681-09 + for ; + Fri, 19 Aug 2005 23:02:36 +0000 (GMT) +Received: from smtp106.mail.sc5.yahoo.com (smtp106.mail.sc5.yahoo.com + [66.163.169.226]) + by svr1.postgresql.org (Postfix) with SMTP id 7C89952B6D + for ; + Fri, 19 Aug 2005 20:02:35 -0300 (ADT) +Received: (qmail 86809 invoked from network); 19 Aug 2005 23:02:37 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Received:User-Agent:Date:Subject:From:To:CC:Message-ID:In-Reply-To:Mime-version:Content-type:Content-transfer-encoding; + b=1OToURhp9PxWy6HIdRVIavt+C59i+wcyRtNCFkXeA3GBrqajs+NcNQkPc5WoHrEYBhMYsOvQ+df5uJRtiAbGp/R3r85PBggLlTJ1J3pLMDCRLWcEPrfrqp7R8SoAFansDwd1yH7JGGY7BCyuIzYqXC91s00EtkHmK0VsKSr13r4= + ; +Received: from unknown (HELO ?10.3.101.47?) (mcotner@24.248.72.254 with login) + by smtp106.mail.sc5.yahoo.com with SMTP; 19 Aug 2005 23:02:37 -0000 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Fri, 19 Aug 2005 19:02:35 -0400 +Subject: Re: sustained update load of 1-2k/sec +From: Mark Cotner +To: PFC , Tom Lane , + Bob Ippolito +Cc: +Message-ID: +In-Reply-To: +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.374 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/285 +X-Sequence-Number: 14032 + +:) Most of the ppl on this list are systems programmers, however I am not. +The tool of choice for this app is Ruby and the libraries don't support +async SNMP at the moment. + +I've done a good deal of async snmp and the libraries that actually pull it +off generally aren't that good(Net-SNMP and Perl's Net::SNMP). Granted, UDP +is connectionless to an extent, but you still have to send the PDU, and bind +to the return socket and wait. If you batch the outgoing PDUs then you can +get away with sending them out synchronously and listening on the returning +socket synchronously, but it would require that your libraries support this. +I understand the concepts well enough, maybe I'll put together a patch. It +would be much lower overhead than managing all those threads. Looks like +it's gonna be a fun weekend. + +Thanks again for all the great feedback. + +'njoy, +Mark + + +On 8/19/05 2:11 PM, "PFC" wrote: + +> +>> While I agree that hundreds of threads seems like overkill, I think the +>> above advice might be going too far in the other direction. The problem +>> with single-threaded operation is that any delay affects the whole +>> system --- eg, if you're blocked waiting for disk I/O, the CPU doesn't +> +> You use UDP which is a connectionless protocol... then why use threads ? +> +> I'd advise this : +> +> Use asynchronous network code (one thread) to do your network stuff. This +> will lower the CPU used by this code immensely. +> Every minute, dump a file contianing everything to insert into the table. +> Use another thread to COPY it into the DB, in a temporary table if you +> wish, and then INSERT INTO ... SELECT. +> This should be well adapted to your requirements. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster + + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 03:52:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F67B52E31 + for ; + Sat, 20 Aug 2005 03:52:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92759-05 + for ; + Sat, 20 Aug 2005 06:52:13 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 2960B52A04 + for ; + Sat, 20 Aug 2005 03:52:10 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 338B464413E + for ; + Sat, 20 Aug 2005 00:51:38 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 12088-02 for ; + Sat, 20 Aug 2005 00:51:36 -0600 (MDT) +Received: from [192.168.1.12] (c-24-9-24-35.hsd1.co.comcast.net [24.9.24.35]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id 192C164411F + for ; + Sat, 20 Aug 2005 00:51:36 -0600 (MDT) +Mime-Version: 1.0 (Apple Message framework v733) +In-Reply-To: <1124434535.3257.7.camel@noodles> +References: + + <1124434535.3257.7.camel@noodles> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Dan Harris +Subject: Re: Query plan looks OK, but slow I/O - settings advice? +Date: Sat, 20 Aug 2005 00:52:08 -0600 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.733) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/286 +X-Sequence-Number: 14033 + + +On Aug 19, 2005, at 12:55 AM, Jeffrey W. Baker wrote: + +> On Tue, 2005-08-16 at 10:46 -0700, Roger Hand wrote: +> Have you considered booting your +> machine with elevator=deadline? + +Although I'm not the OP for this problem, I thought I'd try it out. +WOW.. this should be in a Pg tuning guide somewhere. I added this to +my server tonight just for kicks and saw a pronounced improvement in +IO performance. Thank you very much for mentioning this on the list. + +I didn't have a long enough maintenance window to do solid +benchmarking, but I can say for certain that the change was +noticeable, especially in VACUUM operations. + +Specs for the server: + +PG 8.0.1 +Linux 2.6.12-3 kernel +4xOpteron 2.2 +12GB RAM +16-drive RAID 10 +XFS mounted with noatime +pg_xlog on separate RAID controller + +-Dan + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 04:12:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B50D52E4E + for ; + Sat, 20 Aug 2005 04:12:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54839-06 + for ; + Sat, 20 Aug 2005 07:12:17 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 838DB52E4A + for ; + Sat, 20 Aug 2005 04:12:16 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 5A28664413E + for ; + Sat, 20 Aug 2005 01:11:45 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 12088-04 for ; + Sat, 20 Aug 2005 01:11:43 -0600 (MDT) +Received: from [192.168.1.12] (c-24-9-24-35.hsd1.co.comcast.net [24.9.24.35]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id 45A7E64411F + for ; + Sat, 20 Aug 2005 01:11:43 -0600 (MDT) +Mime-Version: 1.0 (Apple Message framework v733) +In-Reply-To: <1124485299.27881.192.camel@bluejay.goodinassociates.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124485299.27881.192.camel@bluejay.goodinassociates.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Dan Harris +Subject: Re: extremly low memory usage +Date: Sat, 20 Aug 2005 01:12:15 -0600 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.733) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/287 +X-Sequence-Number: 14034 + + +On Aug 19, 2005, at 3:01 PM, Jeremiah Jahn wrote: + +> Rebuild in progress with just ext3 on the raid array...will see if +> this +> helps the access times. + + From my recent experiences, I can say ext3 is probably not a great +choice for Pg databases. If you check the archives you'll see +there's a lot of discussion about various journalling filesystems and +ext3 usually(always?) comes up on the bottom as far as performance +goes. If you insist on using it, I would at least recommend the +noatime option in fstab and using data=writeback to get the faster of +the journal modes. + +XFS seems to be a trusted choice, followed by Reiser and JFS both +with the occasional controversy when the comparisons pop up. + +-Dan + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 08:18:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 76CCB52DEF + for ; + Sat, 20 Aug 2005 08:18:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75198-07 + for ; + Sat, 20 Aug 2005 11:18:00 +0000 (GMT) +Received: from fep32-app.kolumbus.fi (fep32-0.kolumbus.fi [193.229.0.63]) + by svr1.postgresql.org (Postfix) with ESMTP id 60CCE52DE2 + for ; + Sat, 20 Aug 2005 08:17:56 -0300 (ADT) +Received: from [192.168.1.101] (really [80.186.78.229]) + by fep32-app.kolumbus.fi with ESMTP + id <20050820111758.QSZF27630.fep32-app.kolumbus.fi@[192.168.1.101]> + for ; + Sat, 20 Aug 2005 14:17:58 +0300 +Message-ID: <43071162.6050405@kolumbus.fi> +Date: Sat, 20 Aug 2005 14:17:54 +0300 +From: Marko Ristola +User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +Cc: pgsql-performance@postgresql.org +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124485299.27881.192.camel@bluejay.goodinassociates.com> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.128 required=5 tests=[AWL=0.078, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/288 +X-Sequence-Number: 14035 + +Dan Harris wrote: + +> From my recent experiences, I can say ext3 is probably not a great +> choice for Pg databases. If you check the archives you'll see +> there's a lot of discussion about various journalling filesystems and +> ext3 usually(always?) comes up on the bottom as far as performance +> goes. If you insist on using it, I would at least recommend the +> noatime option in fstab and using data=writeback to get the faster + + +Based on my knoledge, Ext3 is good with keeping filesystem integrity AND +data integrity while +pressing the reset button. +However, by selecting data=writeback, you gain more speed, but you risk the +data integrity during a crash: Ext3 garantees only filesystem integrity. + +This means with database transaction logs: The last transactions are not +guaranteed to be written into the hard drives during a hardware reset, +meaning of a loss of some committed transactions. + +Reiserfs is known to do things this false way also. +Is there a way with a Reiserfs filesystem to fulfill both +filesystem AND data integrity requirements nowadays? + +See for example "man mount" to see the effects of data=journal, +data=ordered(default) and +data=writeback for Ext3. Only the writeback risks data integrity. + +Ext3 is the only journaled filesystem, that I know that fulfills +these fundamental data integrity guarantees. Personally I like about +such filesystems, even though it means less speed. + +Marko Ristola + + + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 09:15:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4594C52AE9 + for ; + Sat, 20 Aug 2005 09:15:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77442-02 + for ; + Sat, 20 Aug 2005 12:15:05 +0000 (GMT) +Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A53052A38 + for ; + Sat, 20 Aug 2005 09:15:02 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.53.154]) + by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0ILI00F9BSP59W47@vms048.mailsrvcs.net> for + pgsql-performance@postgresql.org; Sat, 20 Aug 2005 07:15:06 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 1C09E6050CD; Sat, + 20 Aug 2005 08:15:05 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 27694-04; Sat, 20 Aug 2005 08:15:04 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id DCD24600498; Sat, 20 Aug 2005 08:15:04 -0400 (EDT) +Date: Sat, 20 Aug 2005 08:15:04 -0400 +From: Michael Stone +Subject: Re: Query plan looks OK, but slow I/O - settings advice? +In-reply-to: +To: Dan Harris +Cc: pgsql-performance@postgresql.org +Mail-Followup-To: Dan Harris , + pgsql-performance@postgresql.org +Message-id: <20050820121504.GL19080@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: + + <1124434535.3257.7.camel@noodles> + +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/289 +X-Sequence-Number: 14036 + +On Sat, Aug 20, 2005 at 12:52:08AM -0600, Dan Harris wrote: +>On Aug 19, 2005, at 12:55 AM, Jeffrey W. Baker wrote: +>> Have you considered booting your +>>machine with elevator=deadline? +> +>Although I'm not the OP for this problem, I thought I'd try it out. +>WOW.. this should be in a Pg tuning guide somewhere. +[snip] +>16-drive RAID 10 + +Yeah, the default scheduler tries to optimize disk access patterns for a +single-spindle setup, and actually makes things worse if you have a +device with multiple spindles. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Sat Aug 20 09:18:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D71A5299B + for ; + Sat, 20 Aug 2005 09:18:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77264-09 + for ; + Sat, 20 Aug 2005 12:18:30 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2871052936 + for ; + Sat, 20 Aug 2005 09:18:29 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 5244130B42; Sat, 20 Aug 2005 14:30:08 +0200 (MET DST) +From: ohp@pyrenet.fr +X-Newsgroups: pgsql.performance +Subject: index as large as table +Date: Sat, 20 Aug 2005 14:18:29 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 26 +Message-ID: +Reply-To: ohp@pyrenet.fr +Mime-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Complaints-To: abuse@pyrenet.fr +X-X-Sender: ohp@sun.pyrenet +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/291 +X-Sequence-Number: 14038 + +Hi, + +While testing 8.1dev I came to this: + +CREATE TABLE t ( +a int, +b int +PRIMARY KEY (a,b)); + +In that case, the index is as big as the table. + +My question is is it worthwhile to have such index peformance wise. +I understand I'd loose uniqness buthas such an index any chance to be used +against seq scan. + +Is there any chance we have a "btree table" in the future for that case? + +Regards, + +-- +Olivier PRENANT Tel: +33-5-61-50-97-00 (Work) +15, Chemin des Monges +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 Sat Aug 20 09:18:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F76A52996 + for ; + Sat, 20 Aug 2005 09:18:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89706-04 + for ; + Sat, 20 Aug 2005 12:18:31 +0000 (GMT) +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by svr1.postgresql.org (Postfix) with ESMTP id 08C6952945 + for ; + Sat, 20 Aug 2005 09:18:30 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.53.154]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0ILI00BC7SUX0QII@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Sat, 20 Aug 2005 07:18:34 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 604036050CD for + ; + Sat, 20 Aug 2005 08:18:33 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 27878-03-2 for ; Sat, + 20 Aug 2005 08:18:33 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 360D8600498; Sat, 20 Aug 2005 08:18:33 -0400 (EDT) +Date: Sat, 20 Aug 2005 08:18:33 -0400 +From: Michael Stone +Subject: Re: extremly low memory usage +In-reply-to: +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050820121833.GM19080@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124485299.27881.192.camel@bluejay.goodinassociates.com> + +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/290 +X-Sequence-Number: 14037 + +On Sat, Aug 20, 2005 at 01:12:15AM -0600, Dan Harris wrote: +>XFS seems to be a trusted choice, followed by Reiser and JFS both +>with the occasional controversy when the comparisons pop up. + +And don't put the xlog on a journaled filesystem. There is no advantage +to doing so, and it will slow things down. (Assuming a sane seperate xlog +partition configuration, sized reasonably.) + +Mike Stone + +From pgsql-performance-owner@postgresql.org Sat Aug 20 09:23:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 519C2528E7 + for ; + Sat, 20 Aug 2005 09:23:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90582-06 + for ; + Sat, 20 Aug 2005 12:23:03 +0000 (GMT) +Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) + by svr1.postgresql.org (Postfix) with ESMTP id ACB5452849 + for ; + Sat, 20 Aug 2005 09:23:02 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.53.154]) + by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0ILI0044IT2H0RD6@vms046.mailsrvcs.net> for + pgsql-performance@postgresql.org; Sat, 20 Aug 2005 07:23:06 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 91A3B6050CD for + ; + Sat, 20 Aug 2005 08:23:05 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 27694-05 for ; Sat, + 20 Aug 2005 08:23:05 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 5F459600498; Sat, 20 Aug 2005 08:23:05 -0400 (EDT) +Date: Sat, 20 Aug 2005 08:23:05 -0400 +From: Michael Stone +Subject: Re: extremly low memory usage +In-reply-to: <43071162.6050405@kolumbus.fi> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050820122305.GN19080@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124485299.27881.192.camel@bluejay.goodinassociates.com> + + <43071162.6050405@kolumbus.fi> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/292 +X-Sequence-Number: 14039 + +On Sat, Aug 20, 2005 at 02:17:54PM +0300, Marko Ristola wrote: +>Based on my knoledge, Ext3 is good with keeping filesystem integrity +>AND data integrity while pressing the reset button. However, by +>selecting data=writeback, you gain more speed, but you risk the data +>integrity during a crash: Ext3 garantees only filesystem integrity. + +That's why postgres keeps its own transaction log. Any of these +filesystems guarantee data integrity for data that's been synced to +disk, and postgres keeps track of what data has and has not been +committed so it can recover gracefully from a failure. That's why most +filesystems are designed the way they are; the application can determine +what things need better data integrity and which need better performance +on a case-by-case basis. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Sat Aug 20 10:08:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E637A529C7 + for ; + Sat, 20 Aug 2005 10:08:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24690-05 + for ; + Sat, 20 Aug 2005 13:08:14 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id BE0ED5299B + for ; + Sat, 20 Aug 2005 10:08:10 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j7KD8ES8004254; + Sat, 20 Aug 2005 23:08:14 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j7KD8D3q004251; Sat, 20 Aug 2005 23:08:13 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Sat, 20 Aug 2005 23:08:13 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: ohp@pyrenet.fr +Cc: pgsql-performance@postgresql.org +Subject: Re: index as large as table +In-Reply-To: +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.002 required=5 tests=[AWL=0.002] +X-Spam-Level: +X-Archive-Number: 200508/293 +X-Sequence-Number: 14040 + +On Sat, 20 Aug 2005 ohp@pyrenet.fr wrote: + +> Hi, +> +> While testing 8.1dev I came to this: +> +> CREATE TABLE t ( +> a int, +> b int +> PRIMARY KEY (a,b)); +> +> In that case, the index is as big as the table. + +Right. Think about it: the index must store a, b, a reference to the data +in the table itself and index meta data. If an index is defined across all +columns of the table, it must be bigger than the table itself. (In +PostgreSQL, when the table is small, the index will be smaller still. This +is because of each entry in the table itself has meta data. But the amount +of data per row of a table remains constant, whereas, the amount of +metadata in an index grows.) + +> My question is is it worthwhile to have such index peformance wise. +> I understand I'd loose uniqness buthas such an index any chance to be used +> against seq scan. + +Of course. The idea is that, generally speaking, you're only interested in +a small portion of the data stored in the table. Indexes store extra data +so that they can locate the portion you're interested in faster. + +Gavin + +From pgsql-performance-owner@postgresql.org Sat Aug 20 11:41:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2484252E20 + for ; + Sat, 20 Aug 2005 11:40:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90422-07 + for ; + Sat, 20 Aug 2005 14:40:41 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E0C9352C63 + for ; + Sat, 20 Aug 2005 11:40:39 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7KEef86023045; + Sat, 20 Aug 2005 10:40:44 -0400 (EDT) +To: Michael Stone +Cc: pgsql-performance@postgresql.org +Subject: Re: extremly low memory usage +In-reply-to: <20050820122305.GN19080@mathom.us> +References: + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124485299.27881.192.camel@bluejay.goodinassociates.com> + + <43071162.6050405@kolumbus.fi> <20050820122305.GN19080@mathom.us> +Comments: In-reply-to Michael Stone + message dated "Sat, 20 Aug 2005 08:23:05 -0400" +Date: Sat, 20 Aug 2005 10:40:41 -0400 +Message-ID: <23044.1124548841@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/294 +X-Sequence-Number: 14041 + +Michael Stone writes: +> On Sat, Aug 20, 2005 at 02:17:54PM +0300, Marko Ristola wrote: +>> Based on my knoledge, Ext3 is good with keeping filesystem integrity +>> AND data integrity while pressing the reset button. However, by +>> selecting data=writeback, you gain more speed, but you risk the data +>> integrity during a crash: Ext3 garantees only filesystem integrity. + +> That's why postgres keeps its own transaction log. Any of these +> filesystems guarantee data integrity for data that's been synced to +> disk, and postgres keeps track of what data has and has not been +> committed so it can recover gracefully from a failure. + +Right. I think the optimal setting for a Postgres data directory is +journaled metadata, non-journaled file content. Postgres can take care +of the data integrity for itself, but it does assume that the filesystem +stays structurally sane (eg, data blocks don't get reassigned to the +wrong file), so you need a filesystem guarantee about the metadata. + +WAL files are handled in a much more conservative way (created, filled +with zeroes, and fsync'd before we ever put any valuable data in 'em). +If you have WAL on its own drive then I think Mike's recommendation of +no filesystem journalling at all for that drive is probably OK. Or +you can do same as above (journal metadata only) if you want a little +extra protection. + +And of course all this reasoning depends on the assumption that the +drive tells the truth about write-completion. If the drive does write +caching it had better be able to complete all its accepted writes before +dying in a power failure. (Hence, battery-backed write cache is OK, any +other kind is evil.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Aug 20 12:11:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DE1052F0F + for ; + Sat, 20 Aug 2005 12:10:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70818-04 + for ; + Sat, 20 Aug 2005 15:10:31 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 5230D52DC1 + for ; + Sat, 20 Aug 2005 12:10:29 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1E6UzK-00036J-Bt + for pgsql-performance@postgresql.org; Sat, 20 Aug 2005 17:10:27 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1E6UzJ-0003Zr-00 + for ; Sat, 20 Aug 2005 17:10:25 +0200 +Date: Sat, 20 Aug 2005 17:10:25 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: index as large as table +Message-ID: <20050820151025.GA12890@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.016 required=5 tests=[AWL=0.016] +X-Spam-Level: +X-Archive-Number: 200508/295 +X-Sequence-Number: 14042 + +On Sat, Aug 20, 2005 at 11:08:13PM +1000, Gavin Sherry wrote: +> Of course. The idea is that, generally speaking, you're only interested in +> a small portion of the data stored in the table. Indexes store extra data +> so that they can locate the portion you're interested in faster. + +I think his question was more why you needed the data in itself, when you had +everything you needed in the index anyway. (Actually, you don't -- indexes +don't carry MVCC information, but I guess that's a bit beside the point.) + +There has been discussion on "heap tables" or whatever you'd want to call +them (ie. tables that are organized as a B+-tree on some index) here before; +I guess the archives would be a reasonable place to start looking. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sat Aug 20 12:59:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB7B952C91 + for ; + Sat, 20 Aug 2005 12:59:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84932-07 + for ; + Sat, 20 Aug 2005 15:59:47 +0000 (GMT) +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by svr1.postgresql.org (Postfix) with ESMTP id 07F8B52C17 + for ; + Sat, 20 Aug 2005 12:59:45 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=RdLPRkFJX3Pw0igNikvZ0LZeJGMM2ClgT2bxDZYtgUFK6lCF4MgQph6NNBxA1kFD; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E6Vku-0007IP-L5; Sat, 20 Aug 2005 11:59:36 -0400 +Message-Id: <6.2.3.4.0.20050819233655.05c993a0@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Sat, 20 Aug 2005 11:59:32 -0400 +To: Jeremiah Jahn +From: Ron +Subject: Re: extremly low memory usage +Cc: postgres performance +In-Reply-To: <1124482288.27881.182.camel@bluejay.goodinassociates.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124482288.27881.182.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc076e50b2875ad8579b2fef1c8c724c89350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.521 required=5 tests=[AWL=0.147, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/296 +X-Sequence-Number: 14043 + +At 04:11 PM 8/19/2005, Jeremiah Jahn wrote: +>On Fri, 2005-08-19 at 14:23 -0500, John A Meinel wrote: +> > Ron wrote: +> > > At 01:18 PM 8/19/2005, John A Meinel wrote: +> > > +> > >> Jeremiah Jahn wrote: +> > >> > Sorry about the formatting. +> > >> > +> > >> > On Thu, 2005-08-18 at 12:55 -0500, John Arbash Meinel wrote: +> > >> > +> > >> >>Jeremiah Jahn wrote: +> > >> >> +> > >> >> +> > >> +> > >> ... +> > >> +> > >> >>The expensive parts are the 4915 lookups into the litigant_details +> > >> (each +> > >> >>one takes approx 4ms for a total of ~20s). +> > >> >>And then you do it again on case_data (average 3ms each * 4906 loops = +> > >> >>~15s). +> > >> > +> > >> > Is there some way to avoid this? +> > >> > +> > >> +> > >> Well, in general, 3ms for a single lookup seems really long. Maybe your +> > >> index is bloated by not vacuuming often enough. Do you tend to get a lot +> > >> of updates to litigant_details? +> > > +> > > +> > > Given that the average access time for a 15Krpm HD is in the 5.5-6ms +> > > range (7.5-8ms for a 10Krpm HD), having an average of 3ms for a single +> > > lookup implies that ~1/2 (the 15Krpm case) or ~1/3 (the 10Krpm case) +> > > table accesses is requiring a seek. +> > > +>I think LVM may be a problem, since it also seems to break things up on +>the file system. My access time on the seek should be around 1/7th the +>15Krpm I believe since it's a 14 disk raid 10 array. And no other +>traffic at the moment. + +Oops. There's a misconception here. RAID arrays increase +_throughput_ AKA _bandwidth_ through parallel access to HDs. OTOH, +access time is _latency_, and that is not changed. Access time for a +RAID set is equal to that of the slowest access time, AKA highest +latency, HD in the RAID set. + +> > Well, from what he has said, the total indexes are < 1GB and he has 6GB +> > of ram. So everything should fit. Not to mention he is only accessing +> > 5000/several million rows. +>I table spaced some of the indexes and they are around 211066880 bytes +>for the name_speed index and 149825330 for the lit_actor_speed index +>tables seem to be about a gig. + +Hmm. And you think you are only using 250MB out of your 6GB of +RAM? Something doesn't seem to add up here. From what's been +posted, I'd expect much more RAM to be in use. + + +> > > This implies a poor match between physical layout and access pattern. +> > +> > This seems to be the case. But since this is not the only query, it may +> > be that other access patterns are more important to optimize for. +> > +> > > +> > > If I understand correctly, the table should not be very fragmented given +> > > that this is a reasonably freshly loaded DB? That implies that the +> > > fields being looked up are not well sorted in the table compared to the +> > > query pattern. +> > > +> > > If the entire table could fit in RAM, this would be far less of a +> > > consideration. Failing that, the physical HD layout has to be improved +> > > or the query pattern has to be changed to reduce seeks. +> > > +> > > +> > +> > ... +> > +> > >> After CLUSTER, the current data will stay clustered, but new data will +> > >> not, so you have to continually CLUSTER, the same way that you might +> > >> VACUUM. *However*, IIRC CLUSTER grabs an Exclusive lock, so it is as +> > >> expensive as a VACUUM FULL. Be aware of this, but it might vastly +> > >> improve your performance, so it would be worth it. +> > > +> > > +> > > CLUSTER can be a very large maintenance overhead/problem if the table(s) +> > > in question actually need to be "continually" re CLUSTER ed. +> > > +> > > If there is no better solution available, then you do what you have to, +> > > but it feels like there should be a better answer here. +> > > +> > > Perhaps the DB schema needs examining to see if it matches up well with +> > > its real usage? +> > > +> > > Ron Peacetree +> > > +> > +> > I certainly agree that CLUSTER is expensive, and is an on-going +> > maintenance issue. If it is the normal access pattern, though, it may be +> > worth it. +> +>The query I've sent you is one of the most common I get just change the +>name. I handle about 180K of them a day mostly between 8 and 5. The +>clustering has never really been a problem. Like I said before I do it +>about once a week. I handle about 3000 update an hour consisting of +>about 1000-3000 statement per update. ie about 2.5 million updates per +>hour. In the last few months or so I've filtered these down to about +>400K update/delete/insert statements per hour. + +2.5M updates per hour = ~695 updates per second. 400K per hour = +~112 updates per sec. These should be well within the capabilities +of a RAID 10 subsystem based on 14 15Krpm HDs assuming a decent RAID +card. What is the exact HW of the RAID subsystem involved and how is +it configured? You shouldn't be having a performance problem AFAICT... + +> > I also wonder, though, if his table is properly normalized. +> Which, as you mentioned, might lead to improved access patterns. +>The system is about as normalized as I can get it. In general the +>layout is the following: +>courts have cases, cases have litigant_details. Actors have +>identities and litigant_details. + +Hmmm. Can you tell us more about the actual schema, I may have an idea... + +> > +> > John +> > =:-> +>-- +>Speak softly and carry a +6 two-handed sword. + +Nah. A wand of 25th level automatic Magic Missile Fire ;-) + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 15:16:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DE65852AB0 + for ; + Sat, 20 Aug 2005 15:16:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44105-09 + for ; + Sat, 20 Aug 2005 18:16:17 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 76CBC52F06 + for ; + Sat, 20 Aug 2005 15:16:13 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7KIGA1D017691; Sat, 20 Aug 2005 13:16:10 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: John A Meinel +Cc: Ron , + postgres performance +In-Reply-To: <43064A06.8020102@arbash-meinel.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124485299.27881.192.camel@bluejay.goodinassociates.com> + <43064A06.8020102@arbash-meinel.com> +Content-Type: text/plain +Date: Sat, 20 Aug 2005 13:16:09 -0500 +Message-Id: <1124561769.27881.200.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1034/Thu Aug 18 15:07:58 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.034 required=5 tests=[AWL=-0.016, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/297 +X-Sequence-Number: 14044 + +I'm just watching gnome-system-monoitor. Which after careful +consideration.....and looking at dstat means I'm on CRACK....GSM isn't +showing cached memory usage....I asume that the cache memory usage is +where data off of the disks would be cached...? + + + +memory output from dstat is this for a few seconds: + +---procs--- ------memory-usage----- ---paging-- --disk/sda----disk/sdb- ----swap--- ----total-cpu-usage---- +run blk new|_used _buff _cach _free|__in_ _out_|_read write:_read write|_used _free|usr sys idl wai hiq siq + 0 0 0|1336M 10M 4603M 17M| 490B 833B|3823B 3503k:1607k 4285k| 160k 2048M| 4 1 89 7 0 0 + 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 : 0 464k| 160k 2048M| 25 0 75 0 0 0 + 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 : 0 0 | 160k 2048M| 25 0 75 0 0 0 + 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 48k: 0 0 | 160k 2048M| 25 0 75 0 0 0 + 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 : 0 0 | 160k 2048M| 25 0 75 0 0 0 + 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 132k: 0 0 | 160k 2048M| 25 0 75 0 0 0 + 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 36k: 0 0 | 160k 2048M| 25 0 75 0 0 0 + 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 : 0 0 | 160k 2048M| 25 0 75 0 0 0 + 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 12k: 0 0 | 160k 2048M| 25 0 75 0 0 0 + 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 : 0 0 | 160k 2048M| 25 0 75 0 0 0 + 2 0 0|1353M 10M 4585M 18M| 0 0 | 0 0 : 0 0 | 160k 2048M| 25 1 75 0 0 0 + 1 0 0|1321M 10M 4616M 19M| 0 0 | 0 0 : 0 0 | 160k 2048M| 18 8 74 0 0 0 + 1 0 0|1326M 10M 4614M 17M| 0 0 | 0 0 :4096B 0 | 160k 2048M| 16 10 74 1 0 0 + 1 0 0|1330M 10M 4609M 17M| 0 0 | 0 12k:4096B 0 | 160k 2048M| 17 9 74 0 0 0 + 0 1 0|1343M 10M 4596M 17M| 0 0 | 0 0 : 0 316M| 160k 2048M| 5 10 74 11 0 1 + 0 1 0|1339M 10M 4596M 21M| 0 0 | 0 0 : 0 0 | 160k 2048M| 0 0 74 25 0 1 + 0 2 0|1334M 10M 4596M 25M| 0 0 | 0 4096B: 0 0 | 160k 2048M| 0 0 54 44 0 1 + 1 0 0|1326M 10M 4596M 34M| 0 0 | 0 0 : 0 364k| 160k 2048M| 4 1 60 34 0 1 + 1 0 0|1290M 10M 4596M 70M| 0 0 | 0 12k: 0 0 | 160k 2048M| 24 1 75 0 0 0 + 1 0 0|1301M 10M 4596M 59M| 0 0 | 0 20k: 0 0 | 160k 2048M| 21 4 75 0 0 0 + 1 0 0|1312M 10M 4596M 48M| 0 0 | 0 0 : 0 0 | 160k 2048M| 22 4 75 0 0 0 + 1 0 0|1323M 10M 4596M 37M| 0 0 | 0 0 : 0 24k| 160k 2048M| 21 4 75 0 0 0 + 1 0 0|1334M 10M 4596M 25M| 0 0 | 0 0 : 0 56k| 160k 2048M| 21 4 75 0 0 0 + + + +On Fri, 2005-08-19 at 16:07 -0500, John A Meinel wrote: +> Jeremiah Jahn wrote: +> > Rebuild in progress with just ext3 on the raid array...will see if this +> > helps the access times. If it doesn't I'll mess with the stripe size. I +> > have REINDEXED, CLUSTERED, tablespaced and cached with 'cat table/index +> > +> >>/dev/null' none of this seems to have helped, or even increased my +> > +> > memory usage. argh! The only thing about this new system that I'm +> > unfamiliar with is the array setup and LVM, which is why I think that's +> > where the issue is. clustering and indexing as well as vacuum etc are +> > things that I do and have been aware of for sometime. Perhaps slony is a +> > factor, but I really don't see it causing problems on index read speed +> > esp. when it's not running. +> > +> > thanx for your help, I really appreciate it. +> > -jj- +> > +> +> By the way, how are you measuring memory usage? Can you give the output +> of that command, just to make sure you are reading it correctly. +> +> John +> =:-> +> +-- +Speak softly and carry a +6 two-handed sword. + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 15:31:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A324352E07 + for ; + Sat, 20 Aug 2005 15:31:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04910-02 + for ; + Sat, 20 Aug 2005 18:31:17 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 6750052D5A + for ; + Sat, 20 Aug 2005 15:31:15 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7KIVFhh017780; Sat, 20 Aug 2005 13:31:15 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: Ron +Cc: postgres performance +In-Reply-To: <6.2.3.4.0.20050819233655.05c993a0@pop.earthlink.net> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124482288.27881.182.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050819233655.05c993a0@pop.earthlink.net> +Content-Type: text/plain +Date: Sat, 20 Aug 2005 13:31:15 -0500 +Message-Id: <1124562675.27881.215.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1034/Thu Aug 18 15:07:58 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.034 required=5 tests=[AWL=-0.016, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/298 +X-Sequence-Number: 14045 + +On Sat, 2005-08-20 at 11:59 -0400, Ron wrote: +> At 04:11 PM 8/19/2005, Jeremiah Jahn wrote: +> >On Fri, 2005-08-19 at 14:23 -0500, John A Meinel wrote: +> > > Ron wrote: +> > > > At 01:18 PM 8/19/2005, John A Meinel wrote: +> > > > +> > > >> Jeremiah Jahn wrote: +> > > >> > Sorry about the formatting. +> > > >> > +> > > >> > On Thu, 2005-08-18 at 12:55 -0500, John Arbash Meinel wrote: +> > > >> > +> > > >> >>Jeremiah Jahn wrote: +> > > >> >> +> > > >> >> +> > > >> +> > > >> ... +> > > >> +> > > >> >>The expensive parts are the 4915 lookups into the litigant_details +> > > >> (each +> > > >> >>one takes approx 4ms for a total of ~20s). +> > > >> >>And then you do it again on case_data (average 3ms each * 4906 loops = +> > > >> >>~15s). +> > > >> > +> > > >> > Is there some way to avoid this? +> > > >> > +> > > >> +> > > >> Well, in general, 3ms for a single lookup seems really long. Maybe your +> > > >> index is bloated by not vacuuming often enough. Do you tend to get a lot +> > > >> of updates to litigant_details? +> > > > +> > > > +> > > > Given that the average access time for a 15Krpm HD is in the 5.5-6ms +> > > > range (7.5-8ms for a 10Krpm HD), having an average of 3ms for a single +> > > > lookup implies that ~1/2 (the 15Krpm case) or ~1/3 (the 10Krpm case) +> > > > table accesses is requiring a seek. +> > > > +> >I think LVM may be a problem, since it also seems to break things up on +> >the file system. My access time on the seek should be around 1/7th the +> >15Krpm I believe since it's a 14 disk raid 10 array. And no other +> >traffic at the moment. +> +> Oops. There's a misconception here. RAID arrays increase +> _throughput_ AKA _bandwidth_ through parallel access to HDs. OTOH, +> access time is _latency_, and that is not changed. Access time for a +> RAID set is equal to that of the slowest access time, AKA highest +> latency, HD in the RAID set. + +so I will max out at the 5.5-6ms rang for access time? + + +> +> > > Well, from what he has said, the total indexes are < 1GB and he has 6GB +> > > of ram. So everything should fit. Not to mention he is only accessing +> > > 5000/several million rows. +> >I table spaced some of the indexes and they are around 211066880 bytes +> >for the name_speed index and 149825330 for the lit_actor_speed index +> >tables seem to be about a gig. +> +> Hmm. And you think you are only using 250MB out of your 6GB of +> RAM? Something doesn't seem to add up here. From what's been +> posted, I'd expect much more RAM to be in use. + +the cached memory usage is complete using up the rest of the memory. + +> +> +> > > > This implies a poor match between physical layout and access pattern. +> > > +> > > This seems to be the case. But since this is not the only query, it may +> > > be that other access patterns are more important to optimize for. +> > > +> > > > +> > > > If I understand correctly, the table should not be very fragmented given +> > > > that this is a reasonably freshly loaded DB? That implies that the +> > > > fields being looked up are not well sorted in the table compared to the +> > > > query pattern. +> > > > +> > > > If the entire table could fit in RAM, this would be far less of a +> > > > consideration. Failing that, the physical HD layout has to be improved +> > > > or the query pattern has to be changed to reduce seeks. +> > > > +> > > > +> > > +> > > ... +> > > +> > > >> After CLUSTER, the current data will stay clustered, but new data will +> > > >> not, so you have to continually CLUSTER, the same way that you might +> > > >> VACUUM. *However*, IIRC CLUSTER grabs an Exclusive lock, so it is as +> > > >> expensive as a VACUUM FULL. Be aware of this, but it might vastly +> > > >> improve your performance, so it would be worth it. +> > > > +> > > > +> > > > CLUSTER can be a very large maintenance overhead/problem if the table(s) +> > > > in question actually need to be "continually" re CLUSTER ed. +> > > > +> > > > If there is no better solution available, then you do what you have to, +> > > > but it feels like there should be a better answer here. +> > > > +> > > > Perhaps the DB schema needs examining to see if it matches up well with +> > > > its real usage? +> > > > +> > > > Ron Peacetree +> > > > +> > > +> > > I certainly agree that CLUSTER is expensive, and is an on-going +> > > maintenance issue. If it is the normal access pattern, though, it may be +> > > worth it. +> > +> >The query I've sent you is one of the most common I get just change the +> >name. I handle about 180K of them a day mostly between 8 and 5. The +> >clustering has never really been a problem. Like I said before I do it +> >about once a week. I handle about 3000 update an hour consisting of +> >about 1000-3000 statement per update. ie about 2.5 million updates per +> >hour. In the last few months or so I've filtered these down to about +> >400K update/delete/insert statements per hour. +> +> 2.5M updates per hour = ~695 updates per second. 400K per hour = +> ~112 updates per sec. These should be well within the capabilities +> of a RAID 10 subsystem based on 14 15Krpm HDs assuming a decent RAID +> card. What is the exact HW of the RAID subsystem involved and how is +> it configured? You shouldn't be having a performance problem AFAICT... + +dell perc4 with 14 drives and the each pair is raid 1 with spanning +enabled across all of the pairs. It doesn't say raid 10...But it seem to +be it. What else would you like to know? + +> +> > > I also wonder, though, if his table is properly normalized. +> > Which, as you mentioned, might lead to improved access patterns. +> >The system is about as normalized as I can get it. In general the +> >layout is the following: +> >courts have cases, cases have litigant_details. Actors have +> >identities and litigant_details. +> +> Hmmm. Can you tell us more about the actual schema, I may have an idea... +In what format would you like it. What kind of things would you like to +know..? I've probably missed a few things, but this is what running on +the production box. There are no foreign keys. Cascading delete were far +too slow. And having to determine the order of deletes was a pain in the +but. + + + +CREATE TABLE actor ( + actor_id character varying(50) NOT NULL, + case_id character varying(50) DEFAULT '0'::character varying NOT NULL, + court_ori character varying(18) NOT NULL, + role_class_code character varying(50) NOT NULL +); + + + +CREATE TABLE identity ( + identity_id character varying(50) NOT NULL, + actor_id character varying(50) NOT NULL, + case_id character varying(50) DEFAULT '0'::character varying NOT NULL, + court_ori character varying(18) NOT NULL, + identity_type character varying(10) NOT NULL, + entity_type character varying(50), + full_name character varying(60) NOT NULL, + entity_acronym character varying(50), + name_prefix character varying(50), + first_name character varying(50), + middle_name character varying(50), + last_name character varying(50), + name_suffix character varying(50), + gender_code character varying(50), + date_of_birth date, + place_of_birth character varying(50), + height character varying(50), + height_unit character varying(50), + weight character varying(50), + weight_unit character varying(50), + religion character varying(50), + ethnicity character varying(50), + citizenship_country character varying(50), + hair_color character varying(50), + eye_color character varying(50), + scars_marks_tatto character varying(255), + marital_status character varying(50) +); +ALTER TABLE ONLY identity ALTER COLUMN full_name SET STATISTICS 1000; + + + +CREATE TABLE case_data ( + case_id character varying(50) NOT NULL, + court_ori character varying(18) NOT NULL, + type_code character varying(50), + subtype_code character varying(50), + case_category character varying(50), + case_title character varying(100), + type_subtype_text character varying(255), + case_year integer, + extraction_datetime character varying(15) NOT NULL, + update_date date NOT NULL, + case_dom oid, + data bytea +); + + + +CREATE TABLE litigant_details ( + actor_id character varying(50) NOT NULL, + case_id character varying(50) NOT NULL, + court_ori character varying(18) NOT NULL, + assigned_case_role character varying(50) NOT NULL, + initial_file_date date, + initial_close_date date, + reopen_date date, + reclose_date date, + physical_file_location character varying(50), + impound_litigant_data character varying(50), + impound_litigant_minutes character varying(50), + actor_type character varying(50) NOT NULL, + conviction character varying(3) +); + + + +CREATE TABLE actor_identifier ( + identity_id character varying(50) NOT NULL, + actor_id character varying(50) NOT NULL, + case_id character varying(50) DEFAULT '0'::character varying NOT NULL, + court_ori character varying(18) NOT NULL, + actor_identifier_type_code character varying(50) NOT NULL, + actor_identifier_id character varying(50) NOT NULL +); + + + +CREATE TABLE actor_relationship ( + litigant_actor_id character varying(50) NOT NULL, + related_actor_id character varying(50) NOT NULL, + case_id character varying(50) NOT NULL, + court_ori character varying(18) NOT NULL, + relationship_type character varying(50) NOT NULL +); + +CREATE INDEX lit_actor_speed ON litigant_details USING btree (actor_id); + +CREATE INDEX name_speed ON identity USING btree (full_name); +ALTER TABLE identity CLUSTER ON name_speed; + +CREATE INDEX case_speed ON case_data USING btree (court_ori, case_id); +ALTER TABLE case_data CLUSTER ON case_speed; + + +ALTER TABLE ONLY actor + ADD CONSTRAINT actor_pkey PRIMARY KEY (court_ori, case_id, actor_id); +ALTER TABLE ONLY identity + ADD CONSTRAINT identity_pkey PRIMARY KEY (court_ori, case_id, identity_id, actor_id); +ALTER TABLE ONLY case_data + ADD CONSTRAINT case_data_pkey PRIMARY KEY (court_ori, case_id); +ALTER TABLE ONLY litigant_details + ADD CONSTRAINT litigant_details_pkey PRIMARY KEY (actor_id, case_id, court_ori); + + + +> +> > > +> > > John +> > > =:-> +> >-- +> >Speak softly and carry a +6 two-handed sword. +> +> Nah. A wand of 25th level automatic Magic Missile Fire ;-) +> +> Ron Peacetree +> +-- +Speak softly and carry a +6 two-handed sword. + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 15:53:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 64B96528BE + for ; + Sat, 20 Aug 2005 15:53:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49344-01 + for ; + Sat, 20 Aug 2005 18:53:25 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id DBDFB52834 + for ; + Sat, 20 Aug 2005 15:53:24 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7KIrOrJ017902; Sat, 20 Aug 2005 13:53:24 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: John A Meinel +Cc: Jeff Trout , + postgres performance +In-Reply-To: <43064908.7010505@arbash-meinel.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <1124481386.27881.167.camel@bluejay.goodinassociates.com> + <43064908.7010505@arbash-meinel.com> +Content-Type: text/plain +Date: Sat, 20 Aug 2005 13:53:23 -0500 +Message-Id: <1124564003.27881.229.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1034/Thu Aug 18 15:07:58 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.035 required=5 tests=[AWL=-0.015, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/299 +X-Sequence-Number: 14046 + +On Fri, 2005-08-19 at 16:03 -0500, John A Meinel wrote: +> Jeremiah Jahn wrote: +> > On Fri, 2005-08-19 at 12:18 -0500, John A Meinel wrote: +> > +> >>Jeremiah Jahn wrote: +> >> +> +> +> ... +> +> >> +> >>Well, in general, 3ms for a single lookup seems really long. Maybe your +> >>index is bloated by not vacuuming often enough. Do you tend to get a lot +> >>of updates to litigant_details? +> > +> > I have vacuumed this already. I get lots of updates, but this data is +> > mostly unchanging. +> > +> > +> >>There are a couple possibilities at this point. First, you can REINDEX +> >>the appropriate index, and see if that helps. However, if this is a test +> >>box, it sounds like you just did a dump and reload, which wouldn't have +> >>bloat in an index. +> > +> > +> > I loaded it using slony +> +> I don't know that slony versus pg_dump/pg_restore really matters. The +> big thing is that Updates wouldn't be trashing your index. +> But if you are saying that you cluster once/wk your index can't be that +> messed up anyway. (Unless CLUSTER messes up the non-clustered indexes, +> but that would make cluster much less useful, so I would have guessed +> this was not the case) +> +> > +> > +> >>Another possibility. Is this the column that you usually use when +> >>pulling information out of litigant_details? If so, you can CLUSTER +> >>litigant_details on the appropriate index. This will help things be +> >>close together that should be, which decreases the index lookup costs. +> > +> > clustering on this right now. Most of the other things are already +> > clustered. name and case_data +> +> Just as a reality check, they are clustered on the columns in question, +> right? (I don't know if this column is a primary key or not, but any +> index can be used for clustering). +> +> > +> > +> >>However, if this is not the common column, then you probably will slow +> >>down whatever other accesses you may have on this table. +> >> +> >>After CLUSTER, the current data will stay clustered, but new data will +> >>not, so you have to continually CLUSTER, the same way that you might +> >>VACUUM. *However*, IIRC CLUSTER grabs an Exclusive lock, so it is as +> >>expensive as a VACUUM FULL. Be aware of this, but it might vastly +> >>improve your performance, so it would be worth it. +> > +> > I generally re-cluster once a week. +> > +> >>> +> >>>>So there is no need for preloading your indexes on the identity table. +> >>>>It is definitely not the bottleneck. +> >>>> +> >>>>So a few design bits, which may help your database. +> >>>>Why is "actor_id" a text field instead of a number? +> >>> +> >>>This is simply due to the nature of the data. +> >>> +> >> +> >>I'm just wondering if changing into a number, and using a number->name +> >>lookup would be faster for you. It may not be. In general, I prefer to +> >>use numbers for references. I may be over paranoid, but I know that some +> >>locales are bad with string -> string comparisons. And since the data in +> >>your database is stored as UNICODE, I'm not sure if it has to do any +> >>translating or not. Again, something to consider, it may not make any +> >>difference. +> > +> > I don't believe so. I initialze the DB as 'lang=C'. I used to have the +> > problem where things were being inited as en_US. this would prevent any +> > text based index from working. This doesn't seem to be the case here, so +> > I'm not worried about it. +> > +> +> Sorry, I think I was confusing you with someone else who posted SHOW ALL. +> +> > +> > +> >> +> +> ... +> +> > it's cached alright. I'm getting a read rate of about 150MB/sec. I would +> > have thought is would be faster with my raid setup. I think I'm going to +> > scrap the whole thing and get rid of LVM. I'll just do a straight ext3 +> > system. Maybe that will help. Still trying to get suggestions for a +> > stripe size. +> > +> +> I don't think 150MB/s is out of the realm for a 14 drive array. +> How fast is +> time dd if=/dev/zero of=testfile bs=8192 count=1000000 +time dd if=/dev/zero of=testfile bs=8192 count=1000000 +1000000+0 records in +1000000+0 records out + +real 1m24.248s +user 0m0.381s +sys 0m33.028s + + +> (That should create a 8GB file, which is too big to cache everything) +> And then how fast is: +> time dd if=testfile of=/dev/null bs=8192 count=1000000 + +time dd if=testfile of=/dev/null bs=8192 count=1000000 +1000000+0 records in +1000000+0 records out + +real 0m54.139s +user 0m0.326s +sys 0m8.916s + + +and on a second run: + +real 0m55.667s +user 0m0.341s +sys 0m9.013s + + +> +> That should give you a semi-decent way of measuring how fast the RAID +> system is, since it should be too big to cache in ram. + +about 150MB/Sec. Is there no better way to make this go faster...? + +> +> > +> >>I can point you to REINDEX and CLUSTER, but if it is caching in ram, I +> >>honestly can't say why the per loop would be that much slower. +> >>Are both systems running the same postgres version? It sounds like it is +> >>different (since you say something about switching to 8.0). +> > +> > These had little or no effect. +> > The production machine is running 7.4 while the devel machine is running +> > 8.0 +> > +> +> Well, my concern is that maybe some portion of the 8.0 code actually +> slowed things down for you. You could try reverting to 7.4 on the devel +> box, though I think playing with upgrading to 8.1 might be more worthwhile. +And the level of stability for 8.1? I started with 7.4 and it didn't +really feel as fast as it should either. + +> +> ... +> +> > +> > this is a cached version. +> > +> +> I assume that you mean this is the second run of the query. I can't +> compare it too much, since this is "smith" rather than "jones". But this +> one is 17s rather than the other one being 46s. +> +> And that includes having 8k rows instead of having 5k rows. +> +> Have you tried other values with disabled nested loops? Because this +> query (at least in cached form) seems to be *way* faster than with +> nested loops. +> I know that you somehow managed to get 200s in your testing, but it +> might just be that whatever needed to be loaded is now loaded, and you +> would get better performance. +> If this is true, it means you might need to tweak some settings, and +> make sure your statistics are decent, so that postgres can actually pick +> the optimal plan. +> +> > +> >>copa=> explain analyze select full_name,identity_id,identity.case_id,court.id,date_of_birth,assigned_case_role,litigant_details.impound_litigant_data +> >>copa-> from identity +> >>copa-> join litigant_details on identity.actor_id = litigant_details.actor_id +> >>copa-> join case_data on litigant_details.case_id = case_data.case_id and litigant_details.court_ori = case_data.court_ori +> >>copa-> join court on identity.court_ori = court.id +> >>copa-> where identity.court_ori = 'IL081025J' and full_name like 'SMITH%' order by full_name; +> >> QUERY PLAN +> >>------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +> >> Sort (cost=100502560.72..100502583.47 rows=9099 width=86) (actual time=17843.876..17849.401 rows=8094 loops=1) +> >> Sort Key: identity.full_name +> >> -> Merge Join (cost=100311378.72..100501962.40 rows=9099 width=86) (actual time=15195.816..17817.847 rows=8094 loops=1) +> >> Merge Cond: ((("outer".court_ori)::text = "inner"."?column10?") AND (("outer".case_id)::text = "inner"."?column11?")) +> >> -> Index Scan using case_speed on case_data (cost=0.00..170424.73 rows=3999943 width=26) (actual time=0.015..4540.525 rows=3018284 loops=1) +> >> -> Sort (cost=100311378.72..100311400.82 rows=8839 width=112) (actual time=9594.985..9601.174 rows=8094 loops=1) +> >> Sort Key: (litigant_details.court_ori)::text, (litigant_details.case_id)::text +> >> -> Nested Loop (cost=100002491.43..100310799.34 rows=8839 width=112) (actual time=6892.755..9555.828 rows=8094 loops=1) +> >> -> Seq Scan on court (cost=0.00..3.29 rows=1 width=12) (actual time=0.085..0.096 rows=1 loops=1) +> >> Filter: ('IL081025J'::text = (id)::text) +> +> What I don't really understand is the next part. It seems to be doing an +> index scan on 3.7M rows, and getting very decent performance (5s), and +> then merging against a table which returns only 8k rows. +> Why is it having to look through all of those rows? +> I may be missing something, but this says it is able to do 600 index +> lookups / millisecond. Which seems superfast. (Compared to your earlier +> 4ms / lookup) +> +Makes me a little confused myself... + +> Something fishy is going on here. +> +> +> >> -> Merge Join (cost=2491.43..310707.66 rows=8839 width=113) (actual time=6892.656..9519.680 rows=8094 loops=1) +> >> Merge Cond: (("outer".actor_id)::text = "inner"."?column7?") +> >> -> Index Scan using lit_actor_speed on litigant_details (cost=0.00..295722.00 rows=4956820 width=81) (actual time=0.027..5613.814 rows=3736703 loops=1) +> >> -> Sort (cost=2491.43..2513.71 rows=8913 width=82) (actual time=116.071..122.272 rows=8100 loops=1) +> >> Sort Key: (identity.actor_id)::text +> >> -> Index Scan using name_speed on identity (cost=0.00..1906.66 rows=8913 width=82) (actual time=0.133..81.104 rows=8100 loops=1) +> >> Index Cond: (((full_name)::text >= 'SMITH'::character varying) AND ((full_name)::text < 'SMITI'::character varying)) +> >> Filter: (((court_ori)::text = 'IL081025J'::text) AND ((full_name)::text ~~ 'SMITH%'::text)) +> >> Total runtime: 17859.917 ms +> > +> > +> >>But really, you have worse index speed, and that needs to be figured out. +> >> +> >>John +> >>=:-> +> +> I'm assuming your data is private (since it looks like legal stuff). +> Unless maybe that makes it part of the public record. +> Anyway, I'm not able to, but sometimes someone like Tom can profile +> stuff to see what is going on. +I've had tom on here before..:) not my devel box, but my production box +a couple of years ago. + + +> +> I might just be messing up my ability to read the explain output. But +> somehow things don't seem to be lining up with the cost of a single +> index lookup. +> On my crappy Celeron 450 box, an index lookup is 0.06ms once things are +> cached in ram. +> +> John +> =:-> +> +> +-- +Speak softly and carry a +6 two-handed sword. + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 18:02:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 573BE52CFE + for ; + Sat, 20 Aug 2005 18:02:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00233-09 + for ; + Sat, 20 Aug 2005 21:01:59 +0000 (GMT) +Received: from smtpauth04.mail.atl.earthlink.net + (smtpauth04.mail.atl.earthlink.net [209.86.89.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 2AE6752C3F + for ; + Sat, 20 Aug 2005 18:01:58 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=bSSjAVD1BTl3ktwpPexOryQEADQutNOpxYBKGYwWyKtKneNsiAKqVr/1bgnMePXd; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth04.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E6aTV-0006Dy-TP; Sat, 20 Aug 2005 17:01:58 -0400 +Message-Id: <6.2.3.4.0.20050820154422.06021150@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Sat, 20 Aug 2005 17:01:53 -0400 +To: Jeremiah Jahn +From: Ron +Subject: Re: extremly low memory usage +Cc: postgres performance +In-Reply-To: <1124564003.27881.229.camel@bluejay.goodinassociates.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <1124481386.27881.167.camel@bluejay.goodinassociates.com> + <43064908.7010505@arbash-meinel.com> + <1124564003.27881.229.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcba2b3f2007ee6fd7b8a17eb3b763a96c350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.499 required=5 tests=[AWL=0.125, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/300 +X-Sequence-Number: 14047 + +At 02:53 PM 8/20/2005, Jeremiah Jahn wrote: +>On Fri, 2005-08-19 at 16:03 -0500, John A Meinel wrote: +> > Jeremiah Jahn wrote: +> > > On Fri, 2005-08-19 at 12:18 -0500, John A Meinel wrote: +> > > +> +> > +> > > it's cached alright. I'm getting a read rate of about 150MB/sec. I would +> > > have thought is would be faster with my raid setup. I think I'm going to +> > > scrap the whole thing and get rid of LVM. I'll just do a straight ext3 +> > > system. Maybe that will help. Still trying to get suggestions for a +> > > stripe size. +> > > +> > +> > I don't think 150MB/s is out of the realm for a 14 drive array. +> > How fast is time dd if=/dev/zero of=testfile bs=8192 count=1000000 +> > +>time dd if=/dev/zero of=testfile bs=8192 count=1000000 +>1000000+0 records in +>1000000+0 records out +> +>real 1m24.248s +>user 0m0.381s +>sys 0m33.028s +> +> +> > (That should create a 8GB file, which is too big to cache everything) +> > And then how fast is: +> > time dd if=testfile of=/dev/null bs=8192 count=1000000 +> +>time dd if=testfile of=/dev/null bs=8192 count=1000000 +>1000000+0 records in +>1000000+0 records out +> +>real 0m54.139s +>user 0m0.326s +>sys 0m8.916s +> +> +>and on a second run: +> +>real 0m55.667s +>user 0m0.341s +>sys 0m9.013s +> +> +> > +> > That should give you a semi-decent way of measuring how fast the RAID +> > system is, since it should be too big to cache in ram. +> +>about 150MB/Sec. Is there no better way to make this go faster...? +Assuming these are U320 15Krpm 147GB HDs, a RAID 10 array of 14 of +them doing raw sequential IO like this should be capable of at + ~7*75MB/s= 525MB/s using Seagate Cheetah 15K.4's, ~7*79MB/s= +553MB/s if using Fujitsu MAU's, and ~7*86MB/s= 602MB/s if using +Maxtor Atlas 15K II's to devices external to the RAID array. + +_IF_ the controller setup is high powered enough to keep that kind of +IO rate up. This will require a controller or controllers providing +dual channel U320 bandwidth externally and quad channel U320 +bandwidth internally. IOW, it needs a controller or controllers +talking 64b 133MHz PCI-X, reasonably fast DSP/CPU units, and probably +a decent sized IO buffer as well. + +AFAICT, the Dell PERC4 controllers use various flavors of the LSI +Logic MegaRAID controllers. What I don't know is which exact one +yours is, nor do I know if it (or any of the MegaRAID controllers) +are high powered enough. + +Talk to your HW supplier to make sure you have controllers adequate +to your HD's. + +...and yes, your average access time will be in the 5.5ms - 6ms range +when doing a physical seek. +Even with RAID, you want to minimize seeks and maximize sequential IO +when accessing them. +Best to not go to HD at all ;-) + +Hope this helps, +Ron Peacetree + + + + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 18:13:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A95E52BC3 + for ; + Sat, 20 Aug 2005 18:12:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19145-07 + for ; + Sat, 20 Aug 2005 21:12:12 +0000 (GMT) +Received: from smtpauth01.mail.atl.earthlink.net + (smtpauth01.mail.atl.earthlink.net [209.86.89.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AB4152996 + for ; + Sat, 20 Aug 2005 18:12:11 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=M9Lfp7ba3cPwkPIpq5bnsQXW7H2e1utk9NpNf3ftslAGrtOxHPcT4j80Oc1iUPff; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E6adP-0002X8-JQ; Sat, 20 Aug 2005 17:12:11 -0400 +Message-Id: <6.2.3.4.0.20050820170952.05bcedb8@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Sat, 20 Aug 2005 17:12:07 -0400 +To: Jeremiah Jahn +From: Ron +Subject: Re: extremly low memory usage +Cc: postgres performance +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcb32ade9d7d69f805dbe7f19d5ba55cbd350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.481 required=5 tests=[AWL=0.107, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/301 +X-Sequence-Number: 14048 + +I'm reposting this because my mailer hiccuped when I sent it the +first time. If this results in a double post, I apologize. + +At 02:53 PM 8/20/2005, Jeremiah Jahn wrote: +>On Fri, 2005-08-19 at 16:03 -0500, John A Meinel wrote: +> > Jeremiah Jahn wrote: +> > > On Fri, 2005-08-19 at 12:18 -0500, John A Meinel wrote: +> > > +> +> > +> > > it's cached alright. I'm getting a read rate of about 150MB/sec. I would +> > > have thought is would be faster with my raid setup. I think I'm going to +> > > scrap the whole thing and get rid of LVM. I'll just do a straight ext3 +> > > system. Maybe that will help. Still trying to get suggestions for a +> > > stripe size. +> > > +> > +> > I don't think 150MB/s is out of the realm for a 14 drive array. +> > How fast is time dd if=/dev/zero of=testfile bs=8192 count=1000000 +> > +>time dd if=/dev/zero of=testfile bs=8192 count=1000000 +>1000000+0 records in +>1000000+0 records out +> +>real 1m24.248s +>user 0m0.381s +>sys 0m33.028s +> +> +> > (That should create a 8GB file, which is too big to cache everything) +> > And then how fast is: +> > time dd if=testfile of=/dev/null bs=8192 count=1000000 +> +>time dd if=testfile of=/dev/null bs=8192 count=1000000 +>1000000+0 records in +>1000000+0 records out +> +>real 0m54.139s +>user 0m0.326s +>sys 0m8.916s +> +> +>and on a second run: +> +>real 0m55.667s +>user 0m0.341s +>sys 0m9.013s +> +> +> > +> > That should give you a semi-decent way of measuring how fast the RAID +> > system is, since it should be too big to cache in ram. +> +>about 150MB/Sec. Is there no better way to make this go faster...? +Assuming these are U320 15Krpm 147GB HDs, a RAID 10 array of 14 of +them doing raw sequential IO like this should be capable of at + ~7*75MB/s= 525MB/s using Seagate Cheetah 15K.4's, ~7*79MB/s= +553MB/s if using Fujitsu MAU's, and ~7*86MB/s= 602MB/s if using +Maxtor Atlas 15K II's to devices external to the RAID array. + +_IF_ the controller setup is high powered enough to keep that kind of +IO rate up. This will require a controller or controllers providing +dual channel U320 bandwidth externally and quad channel U320 +bandwidth internally. IOW, it needs a controller or controllers +talking 64b 133MHz PCI-X, reasonably fast DSP/CPU units, and probably +a decent sized IO buffer as well. + +AFAICT, the Dell PERC4 controllers use various flavors of the LSI +Logic MegaRAID controllers. What I don't know is which exact one +yours is, nor do I know if it (or any of the MegaRAID controllers) +are high powered enough. + +Talk to your HW supplier to make sure you have controllers adequate +to your HD's. + +...and yes, your average access time will be in the 5.5ms - 6ms range +when doing a physical seek. +Even with RAID, you want to minimize seeks and maximize sequential IO +when accessing them. +Best to not go to HD at all ;-) + +Hope this helps, +Ron Peacetree + + + + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 18:25:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B97252B3E + for ; + Sat, 20 Aug 2005 18:23:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61258-07 + for ; + Sat, 20 Aug 2005 21:23:29 +0000 (GMT) +Received: from smtpauth01.mail.atl.earthlink.net + (smtpauth01.mail.atl.earthlink.net [209.86.89.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 976FB52A88 + for ; + Sat, 20 Aug 2005 18:23:28 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=YuSmJZJhL5Sw4Ak1nBNwsCkWWigVf80zB8Vxx2k/7SeQvEhCUvfSO2tYc3naK9g2; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E6aoM-000847-P8; Sat, 20 Aug 2005 17:23:30 -0400 +Message-Id: <6.2.3.4.0.20050820171521.05bd0a38@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Sat, 20 Aug 2005 17:23:25 -0400 +To: Jeremiah Jahn +From: Ron +Subject: Re: extremly low memory usage +Cc: postgres performance +In-Reply-To: <1124561769.27881.200.camel@bluejay.goodinassociates.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124485299.27881.192.camel@bluejay.goodinassociates.com> + <43064A06.8020102@arbash-meinel.com> + <1124561769.27881.200.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcd8796ffd4a735881ffc8faabeffd2923350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.466 required=5 tests=[AWL=0.092, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/302 +X-Sequence-Number: 14049 + +At 02:16 PM 8/20/2005, Jeremiah Jahn wrote: +>I'm just watching gnome-system-monoitor. Which after careful +>consideration.....and looking at dstat means I'm on CRACK....GSM isn't +>showing cached memory usage....I asume that the cache memory usage +>is where data off of the disks would be cached...? +> +>memory output from dstat is this for a few seconds: +> +>---procs--- ------memory-usage----- ---paging-- +>--disk/sda----disk/sdb- ----swap--- ----total-cpu-usage---- +>run blk new|_used _buff _cach _free|__in_ _out_|_read write:_read +>write|_used _free|usr sys idl wai hiq siq +> 0 0 0|1336M 10M 4603M 17M| 490B 833B|3823B 3503k:1607k +> 4285k| 160k 2048M| 4 1 89 7 0 0 +> 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 +> : 0 464k| 160k 2048M| 25 0 75 0 0 0 +> +> 1 0 0|1334M 10M 4596M 25M| 0 0 | 0 0 +> : 0 56k| 160k 2048M| 21 4 75 0 0 0 + +Then the "low memory usage" was a chimera. Excellent! + +Given the evidence in this thread, IMO you should upgrade your box to +16GB of RAM ASAP. That should be enough to cache most, if not all, +of the 10GB of the "hot" part of your DB; thereby dedicating your HD +subsystem as much as possible to writes (which is unavoidable HD +IO). As I've posted before, at $75-$150/GB, it's well worth the +investment whenever you can prove it will help as we have here. + +Hope this helps, +Ron Peacetree + + + + +From pgsql-performance-owner@postgresql.org Sat Aug 20 23:29:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 92A1B52D9A + for ; + Sat, 20 Aug 2005 23:28:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42777-05 + for ; + Sun, 21 Aug 2005 02:28:31 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 9420652D96 + for ; + Sat, 20 Aug 2005 23:28:29 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050821022614m92009j2ufe>; Sun, 21 Aug 2005 02:28:33 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 59B9955FE1; Sat, 20 Aug 2005 21:26:13 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 37E3455FAD; + Sat, 20 Aug 2005 21:26:07 -0500 (CDT) +Message-ID: <4307E63C.7050408@arbash-meinel.com> +Date: Sat, 20 Aug 2005 21:26:04 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: Ron , + postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124485299.27881.192.camel@bluejay.goodinassociates.com> + <43064A06.8020102@arbash-meinel.com> + <1124561769.27881.200.camel@bluejay.goodinassociates.com> +In-Reply-To: <1124561769.27881.200.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigB4CB00E9C4E22B57E9612252" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/303 +X-Sequence-Number: 14050 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigB4CB00E9C4E22B57E9612252 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: +> I'm just watching gnome-system-monoitor. Which after careful +> consideration.....and looking at dstat means I'm on CRACK....GSM isn't +> showing cached memory usage....I asume that the cache memory usage is +> where data off of the disks would be cached...? +> + +Well a simple "free" also tells you how much has been cached. +I believe by reading the _cach line, it looks like you have 4.6G cached. +So you are indeed using memory. + +I'm still concerned why it seems to be taking 3-4ms per index lookup, +when things should already be cached in RAM. +Now, I may be wrong about whether the indexes are cached, but I sure +would expect them to be. +What is the time for a cached query on your system (with normal nested +loops)? (give the EXPLAIN ANALYZE for the *second* run, or maybe the +fourth). + +I'm glad that we aren't seeing something weird with your kernel, at least. + +John +=:-> + + +> +> +> memory output from dstat is this for a few seconds: +> +> ---procs--- ------memory-usage----- ---paging-- --disk/sda----disk/sdb- ----swap--- ----total-cpu-usage---- +> run blk new|_used _buff _cach _free|__in_ _out_|_read write:_read write|_used _free|usr sys idl wai hiq siq +> 0 0 0|1336M 10M 4603M 17M| 490B 833B|3823B 3503k:1607k 4285k| 160k 2048M| 4 1 89 7 0 0 +> 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 : 0 464k| 160k 2048M| 25 0 75 0 0 0 +> 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 : 0 0 | 160k 2048M| 25 0 75 0 0 0 +> 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 48k: 0 0 | 160k 2048M| 25 0 75 0 0 0 +> 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 : 0 0 | 160k 2048M| 25 0 75 0 0 0 +> 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 132k: 0 0 | 160k 2048M| 25 0 75 0 0 0 +> 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 36k: 0 0 | 160k 2048M| 25 0 75 0 0 0 +> 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 : 0 0 | 160k 2048M| 25 0 75 0 0 0 +> 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 12k: 0 0 | 160k 2048M| 25 0 75 0 0 0 +> 1 0 0|1337M 10M 4600M 18M| 0 0 | 0 0 : 0 0 | 160k 2048M| 25 0 75 0 0 0 +> 2 0 0|1353M 10M 4585M 18M| 0 0 | 0 0 : 0 0 | 160k 2048M| 25 1 75 0 0 0 +> 1 0 0|1321M 10M 4616M 19M| 0 0 | 0 0 : 0 0 | 160k 2048M| 18 8 74 0 0 0 +> 1 0 0|1326M 10M 4614M 17M| 0 0 | 0 0 :4096B 0 | 160k 2048M| 16 10 74 1 0 0 +> 1 0 0|1330M 10M 4609M 17M| 0 0 | 0 12k:4096B 0 | 160k 2048M| 17 9 74 0 0 0 +> 0 1 0|1343M 10M 4596M 17M| 0 0 | 0 0 : 0 316M| 160k 2048M| 5 10 74 11 0 1 +> 0 1 0|1339M 10M 4596M 21M| 0 0 | 0 0 : 0 0 | 160k 2048M| 0 0 74 25 0 1 +> 0 2 0|1334M 10M 4596M 25M| 0 0 | 0 4096B: 0 0 | 160k 2048M| 0 0 54 44 0 1 +> 1 0 0|1326M 10M 4596M 34M| 0 0 | 0 0 : 0 364k| 160k 2048M| 4 1 60 34 0 1 +> 1 0 0|1290M 10M 4596M 70M| 0 0 | 0 12k: 0 0 | 160k 2048M| 24 1 75 0 0 0 +> 1 0 0|1301M 10M 4596M 59M| 0 0 | 0 20k: 0 0 | 160k 2048M| 21 4 75 0 0 0 +> 1 0 0|1312M 10M 4596M 48M| 0 0 | 0 0 : 0 0 | 160k 2048M| 22 4 75 0 0 0 +> 1 0 0|1323M 10M 4596M 37M| 0 0 | 0 0 : 0 24k| 160k 2048M| 21 4 75 0 0 0 +> 1 0 0|1334M 10M 4596M 25M| 0 0 | 0 0 : 0 56k| 160k 2048M| 21 4 75 0 0 0 +> +> +> +> On Fri, 2005-08-19 at 16:07 -0500, John A Meinel wrote: +> +>>Jeremiah Jahn wrote: +>> +>>>Rebuild in progress with just ext3 on the raid array...will see if this +>>>helps the access times. If it doesn't I'll mess with the stripe size. I +>>>have REINDEXED, CLUSTERED, tablespaced and cached with 'cat table/index +>>> +>>> +>>>>/dev/null' none of this seems to have helped, or even increased my +>>> +>>>memory usage. argh! The only thing about this new system that I'm +>>>unfamiliar with is the array setup and LVM, which is why I think that's +>>>where the issue is. clustering and indexing as well as vacuum etc are +>>>things that I do and have been aware of for sometime. Perhaps slony is a +>>>factor, but I really don't see it causing problems on index read speed +>>>esp. when it's not running. +>>> +>>>thanx for your help, I really appreciate it. +>>>-jj- +>>> +>> +>>By the way, how are you measuring memory usage? Can you give the output +>>of that command, just to make sure you are reading it correctly. +>> +>>John +>>=:-> +>> + + +--------------enigB4CB00E9C4E22B57E9612252 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDB+Y+JdeBCYSNAAMRAigBAKC1f3abT+2b+rCkhszkHOPwnY7cRQCfTg/K +HNROGvXqnQyBg/Scof5BCao= +=vL6A +-----END PGP SIGNATURE----- + +--------------enigB4CB00E9C4E22B57E9612252-- + +From pgsql-performance-owner@postgresql.org Sat Aug 20 23:36:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37F6352DEA + for ; + Sat, 20 Aug 2005 23:34:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55941-03 + for ; + Sun, 21 Aug 2005 02:34:23 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id E2EAD52DC1 + for ; + Sat, 20 Aug 2005 23:34:21 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050821023210m9100g5klfe>; Sun, 21 Aug 2005 02:34:26 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 437A855FE1; Sat, 20 Aug 2005 21:32:10 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 744C855FAD; + Sat, 20 Aug 2005 21:32:04 -0500 (CDT) +Message-ID: <4307E7A4.7090300@arbash-meinel.com> +Date: Sat, 20 Aug 2005 21:32:04 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ron +Cc: Jeremiah Jahn , + postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <1124481386.27881.167.camel@bluejay.goodinassociates.com> + <43064908.7010505@arbash-meinel.com> + <1124564003.27881.229.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050820154422.06021150@pop.earthlink.net> +In-Reply-To: <6.2.3.4.0.20050820154422.06021150@pop.earthlink.net> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig6CF0AF8208E4B7FC20509C12" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/304 +X-Sequence-Number: 14051 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig6CF0AF8208E4B7FC20509C12 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Ron wrote: +> At 02:53 PM 8/20/2005, Jeremiah Jahn wrote: +> +>> On Fri, 2005-08-19 at 16:03 -0500, John A Meinel wrote: +>> > Jeremiah Jahn wrote: +>> > > On Fri, 2005-08-19 at 12:18 -0500, John A Meinel wrote: +>> > > +>> +>> > +>> > > it's cached alright. I'm getting a read rate of about 150MB/sec. I +>> would +>> > > have thought is would be faster with my raid setup. I think I'm +>> going to +>> > > scrap the whole thing and get rid of LVM. I'll just do a straight +>> ext3 +>> > > system. Maybe that will help. Still trying to get suggestions for a +>> > > stripe size. +>> > > + +Well, since you can get a read of the RAID at 150MB/s, that means that +it is actual I/O speed. It may not be cached in RAM. Perhaps you could +try the same test, only using say 1G, which should be cached. + +>> > +>> > I don't think 150MB/s is out of the realm for a 14 drive array. +>> > How fast is time dd if=/dev/zero of=testfile bs=8192 count=1000000 +>> > +>> time dd if=/dev/zero of=testfile bs=8192 count=1000000 +>> 1000000+0 records in +>> 1000000+0 records out +>> +>> real 1m24.248s +>> user 0m0.381s +>> sys 0m33.028s +>> +>> +>> > (That should create a 8GB file, which is too big to cache everything) +>> > And then how fast is: +>> > time dd if=testfile of=/dev/null bs=8192 count=1000000 +>> +>> time dd if=testfile of=/dev/null bs=8192 count=1000000 +>> 1000000+0 records in +>> 1000000+0 records out +>> +>> real 0m54.139s +>> user 0m0.326s +>> sys 0m8.916s +>> +>> +>> and on a second run: +>> +>> real 0m55.667s +>> user 0m0.341s +>> sys 0m9.013s +>> +>> +>> > +>> > That should give you a semi-decent way of measuring how fast the RAID +>> > system is, since it should be too big to cache in ram. +>> +>> about 150MB/Sec. Is there no better way to make this go faster...? + +I'm actually curious about PCI bus saturation at this point. Old 32-bit +33MHz pci could only push 1Gbit = 100MB/s. Now, I'm guessing that this +is a higher performance system. But I'm really surprised that your write +speed is that close to your read speed. (100MB/s write, 150MB/s read). + +> +> Assuming these are U320 15Krpm 147GB HDs, a RAID 10 array of 14 of them +> doing raw sequential IO like this should be capable of at +> ~7*75MB/s= 525MB/s using Seagate Cheetah 15K.4's, ~7*79MB/s= 553MB/s +> if using Fujitsu MAU's, and ~7*86MB/s= 602MB/s if using Maxtor Atlas 15K +> II's to devices external to the RAID array. + +I know I thought these were SATA drives, over 2 controllers. I could be +completely wrong, though. + +> +> _IF_ the controller setup is high powered enough to keep that kind of IO +> rate up. This will require a controller or controllers providing dual +> channel U320 bandwidth externally and quad channel U320 bandwidth +> internally. IOW, it needs a controller or controllers talking 64b +> 133MHz PCI-X, reasonably fast DSP/CPU units, and probably a decent sized +> IO buffer as well. +> +> AFAICT, the Dell PERC4 controllers use various flavors of the LSI Logic +> MegaRAID controllers. What I don't know is which exact one yours is, +> nor do I know if it (or any of the MegaRAID controllers) are high +> powered enough. +> +> Talk to your HW supplier to make sure you have controllers adequate to +> your HD's. +> +> ...and yes, your average access time will be in the 5.5ms - 6ms range +> when doing a physical seek. +> Even with RAID, you want to minimize seeks and maximize sequential IO +> when accessing them. +> Best to not go to HD at all ;-) + +Well, certainly, if you can get more into RAM, you're always better off. +For writing, a battery-backed write cache, and for reading lots of +system RAM. + +> +> Hope this helps, +> Ron Peacetree +> + +John +=:-> + +--------------enig6CF0AF8208E4B7FC20509C12 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDB+ekJdeBCYSNAAMRAlbBAKCPJZ4Ox/4u9nFiD5u0fZT9zpTDpwCferGG +CmQ+DrIWO1Rw86QSK9rrRfw= +=PICd +-----END PGP SIGNATURE----- + +--------------enig6CF0AF8208E4B7FC20509C12-- + +From pgsql-performance-owner@postgresql.org Sun Aug 21 00:49:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AA01852EF7 + for ; + Sun, 21 Aug 2005 00:45:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30938-08 + for ; + Sun, 21 Aug 2005 03:45:30 +0000 (GMT) +Received: from calvin.surfutopia.net (calvin.surfutopia.net [67.120.245.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BE4952DC4 + for ; + Sun, 21 Aug 2005 00:45:28 -0300 (ADT) +Received: by calvin.surfutopia.net (Postfix, from userid 1000) + id 32191F22A; Sat, 20 Aug 2005 20:48:41 -0700 (PDT) +Date: Sat, 20 Aug 2005 20:48:41 -0700 +From: John Mendenhall +To: pgsql-performance list +Subject: complex query performance assistance request +Message-ID: <20050821034841.GA28968@calvin.surfutopia.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/305 +X-Sequence-Number: 14052 + +I need to improve the performance for the following +query. + +Soon after I reboot my server, the following query takes +20 seconds the first time I run it. +When I run it after that, it takes approximately 2 seconds. +I understand the caching taking place (at the os or db +level, it doesn't matter here). + +Here are the results of the explain analyze run: + +----- +LOG: duration: 6259.632 ms statement: explain analyze +SELECT +c.id AS contact_id, +sr.id AS sales_rep_id, +LTRIM(RTRIM(sr.firstname || ' ' || sr.lastname)) AS sales_rep_name, +p.id AS partner_id, +p.company AS partner_company, +coalesce(LTRIM(RTRIM(c.company)), LTRIM(RTRIM(c.firstname || ' ' || c.lastname))) +AS contact_company, +LTRIM(RTRIM(c.city || ' ' || c.state || ' ' || c.postalcode || ' ' || c.country)) +AS contact_location, +c.phone AS contact_phone, +c.email AS contact_email, +co.name AS contact_country, +TO_CHAR(c.request_status_last_modified, 'mm/dd/yy hh12:mi pm') +AS request_status_last_modified, +TO_CHAR(c.request_status_last_modified, 'yyyymmddhh24miss') +AS rqst_stat_last_mdfd_sortable, +c.token_id, +c.master_key_token AS token +FROM +sales_reps sr +JOIN partners p ON (sr.id = p.sales_rep_id) +JOIN contacts c ON (p.id = c.partner_id) +JOIN countries co ON (LOWER(c.country) = LOWER(co.code)) +JOIN partner_classification pc ON (p.classification_id = pc.id AND pc.classification != 'Sales Rep') +WHERE +c.lead_deleted IS NULL +AND EXISTS +( +SELECT +lr.id +FROM +lead_requests lr, +lead_request_status lrs +WHERE +c.id = lr.contact_id AND +lr.status_id = lrs.id AND +lrs.is_closed = 0 +) +ORDER BY +contact_company, contact_id; + QUERY PLAN + +-------------------------------------------------------------------------------------------------------------------------------- +---------------------------------------------------------- + Sort (cost=39093.16..39102.80 rows=3856 width=238) (actual time=6220.481..6221.188 rows=1071 loops=1) + Sort Key: COALESCE(ltrim(rtrim((c.company)::text)), ltrim(rtrim((((c.firstname)::text || ' '::text) || (c.lastname)::text)))), c.id + -> Merge Join (cost=38580.89..38863.48 rows=3856 width=238) (actual time=6015.751..6184.199 rows=1071 loops=1) + Merge Cond: ("outer"."?column3?" = "inner"."?column19?") + -> Sort (cost=14.00..14.61 rows=242 width=19) (actual time=9.250..9.500 rows=240 loops=1) + Sort Key: lower((co.code)::text) + -> Seq Scan on countries co (cost=0.00..4.42 rows=242 width=19) (actual time=0.132..4.498 rows=242 loops=1) + -> Sort (cost=38566.89..38574.86 rows=3186 width=225) (actual time=6005.644..6006.954 rows=1071 loops=1) + Sort Key: lower((c.country)::text) + -> Merge Join (cost=75.65..38381.50 rows=3186 width=225) (actual time=58.086..5979.287 rows=1071 loops=1) + Merge Cond: ("outer".partner_id = "inner".id) + -> Index Scan using contacts_partner_id_idx on contacts c (cost=0.00..160907.39 rows=20106 width=171) (actual time=2.569..5816.985 rows=1547 loops=1) + Filter: ((lead_deleted IS NULL) AND (subplan)) + SubPlan + -> Nested Loop (cost=1.16..6.56 rows=2 width=10) (actual time=0.119..0.119 rows=0 loops=40261) + Join Filter: ("outer".status_id = "inner".id) + -> Index Scan using lead_requests_contact_id_idx on lead_requests lr (cost=0.00..4.86 rows=3 width=20) (actual time=0.079..0.083 rows=0 loops=40261) + Index Cond: ($0 = contact_id) + -> Materialize (cost=1.16..1.24 rows=8 width=10) (actual time=0.002..0.011 rows=6 loops=12592) + -> Seq Scan on lead_request_status lrs (cost=0.00..1.16 rows=8 width=10) (actual time=0.083..0.270 rows=7 loops=1) + Filter: (is_closed = 0::numeric) + -> Sort (cost=75.65..76.37 rows=290 width=64) (actual time=55.073..56.990 rows=1334 loops=1) + Sort Key: p.id + -> Merge Join (cost=59.24..63.79 rows=290 width=64) (actual time=31.720..41.096 rows=395 loops=1) + Merge Cond: ("outer".id = "inner".sales_rep_id) + -> Sort (cost=2.42..2.52 rows=39 width=31) (actual time=1.565..1.616 rows=39 loops=1) + Sort Key: sr.id + -> Seq Scan on sales_reps sr (cost=0.00..1.39 rows=39 width=31) (actual time=0.043..0.581 rows=39 loops=1) + -> Sort (cost=56.82..57.55 rows=290 width=43) (actual time=29.921..30.310 rows=395 loops=1) + Sort Key: p.sales_rep_id + -> Nested Loop (cost=24.35..44.96 rows=290 width=43) (actual time=0.169..22.566 rows=395 loops=1) + Join Filter: ("inner".classification_id = "outer".id) + -> Seq Scan on partner_classification pc (cost=0.00..1.04 rows=2 width=10) (actual time=0.059..0.102 rows=2 loops=1) + Filter: ((classification)::text <> 'Sales Rep'::text) + -> Materialize (cost=24.35..28.70 rows=435 width=53) (actual time=0.023..5.880 rows=435 loops=2) + -> Seq Scan on partners p (cost=0.00..24.35 rows=435 width=53) (actual time=0.034..8.937 rows=435 loops=1) + Total runtime: 6225.791 ms +(37 rows) + +----- + +My first question is, what is the Materialize query plan element? +It happens twice, and usually when I see it, my query is slow. + +My second and more important question is, does anyone have +any ideas or suggestions as to how I can increase the speed +for this query? + +Things I have already done are, modify the joins and conditions +so it starts with smaller tables, thus the join set is smaller, +modify the configuration of the server to ensure index scans +are used as they should be, ran vacuumdb and analyze on the +database. + +Thank you very much in advance for any pointers for additional +places I can look. + +Thanks. + +JohnM + +-- +John Mendenhall +john@surfutopia.net +surf utopia +internet services + +From pgsql-performance-owner@postgresql.org Sun Aug 21 06:52:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 067211FEF168 + for ; + Sun, 21 Aug 2005 06:52:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51611-01 + for ; + Sun, 21 Aug 2005 09:52:10 +0000 (GMT) +Received: from fep01-app.kolumbus.fi (fep01-0.kolumbus.fi [193.229.0.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 302DF1FEF167 + for ; + Sun, 21 Aug 2005 06:52:09 -0300 (ADT) +Received: from [192.168.1.101] (really [80.186.78.229]) + by fep01-app.kolumbus.fi with ESMTP + id <20050821095208.SQKB23558.fep01-app.kolumbus.fi@[192.168.1.101]>; + Sun, 21 Aug 2005 12:52:08 +0300 +Message-ID: <43084EC4.4070906@kolumbus.fi> +Date: Sun, 21 Aug 2005 12:52:04 +0300 +From: Marko Ristola +User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Michael Stone , + pgsql-performance@postgresql.org, jeremiah@cs.earlham.edu +Subject: Re: extremly low memory usage +References: + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <6.2.3.4.0.20050819140714.05c181e8@pop.earthlink.net> + <43063196.9000001@arbash-meinel.com> + <1124485299.27881.192.camel@bluejay.goodinassociates.com> + + <43071162.6050405@kolumbus.fi> <20050820122305.GN19080@mathom.us> + <23044.1124548841@sss.pgh.pa.us> +In-Reply-To: <23044.1124548841@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.124 required=5 tests=[AWL=0.074, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/306 +X-Sequence-Number: 14053 + + +I'm Sorry, +that I wrote that the option would risk the LOG +persistency with PostgreSQL. + +I should have asked instead, that how you have taken this into account. + +Tom Lane's email below convinces me, that you have taken the metadata +only journalling into account and still fulfill the persistency +of committed transactions. + +This means, that Ext3 with data=writeback is safe with PostgreSQL even with +a hardware reset button. Metadata only journalling is faster, when it +can be used. + +I didn't know, that any database can keep the database guarantees +with the metadata only journalling option. + +I looked at your problem. +One of the problems is that you need to keep the certain data +cached in memory all the time. + +That could be solved by doing +SELECT COUNT(*) from to_be_cached; +as a cron job. It loads the whole table into the Linux Kernel memory cache. + + +Marko Ristola + +Tom Lane wrote: + +>Right. I think the optimal setting for a Postgres data directory is +>journaled metadata, non-journaled file content. Postgres can take care +>of the data integrity for itself, but it does assume that the filesystem +>stays structurally sane (eg, data blocks don't get reassigned to the +>wrong file), so you need a filesystem guarantee about the metadata. +> +>WAL files are handled in a much more conservative way (created, filled +>with zeroes, and fsync'd before we ever put any valuable data in 'em). +>If you have WAL on its own drive then I think Mike's recommendation of +>no filesystem journalling at all for that drive is probably OK. Or +>you can do same as above (journal metadata only) if you want a little +>extra protection. +> +>And of course all this reasoning depends on the assumption that the +>drive tells the truth about write-completion. If the drive does write +>caching it had better be able to complete all its accepted writes before +>dying in a power failure. (Hence, battery-backed write cache is OK, any +>other kind is evil.) +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 2: Don't 'kill -9' the postmaster +> +> + + +From pgsql-performance-owner@postgresql.org Sun Aug 21 12:01:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C3C501FEE591 + for ; + Sun, 21 Aug 2005 11:54:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98444-10 + for ; + Sun, 21 Aug 2005 14:54:29 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 463361FEE588 + for ; + Sun, 21 Aug 2005 11:54:29 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7LEsQbd020366; Sun, 21 Aug 2005 09:54:27 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: John A Meinel +Cc: Ron , + postgres performance +In-Reply-To: <4307E7A4.7090300@arbash-meinel.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <1124481386.27881.167.camel@bluejay.goodinassociates.com> + <43064908.7010505@arbash-meinel.com> + <1124564003.27881.229.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050820154422.06021150@pop.earthlink.net> + <4307E7A4.7090300@arbash-meinel.com> +Content-Type: text/plain +Date: Sun, 21 Aug 2005 09:54:26 -0500 +Message-Id: <1124636066.27881.238.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1034/Thu Aug 18 15:07:58 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 required=5 tests=[AWL=0.010] +X-Spam-Level: +X-Archive-Number: 200508/307 +X-Sequence-Number: 14054 + +On Sat, 2005-08-20 at 21:32 -0500, John A Meinel wrote: +> Ron wrote: +> > At 02:53 PM 8/20/2005, Jeremiah Jahn wrote: +> > +> >> On Fri, 2005-08-19 at 16:03 -0500, John A Meinel wrote: +> >> > Jeremiah Jahn wrote: +> >> > > On Fri, 2005-08-19 at 12:18 -0500, John A Meinel wrote: +> >> > > +> >> +> >> > +> >> > > it's cached alright. I'm getting a read rate of about 150MB/sec. I +> >> would +> >> > > have thought is would be faster with my raid setup. I think I'm +> >> going to +> >> > > scrap the whole thing and get rid of LVM. I'll just do a straight +> >> ext3 +> >> > > system. Maybe that will help. Still trying to get suggestions for a +> >> > > stripe size. +> >> > > +> +> Well, since you can get a read of the RAID at 150MB/s, that means that +> it is actual I/O speed. It may not be cached in RAM. Perhaps you could +> try the same test, only using say 1G, which should be cached. + +[root@io pgsql]# time dd if=/dev/zero of=testfile bs=1024 count=1000000 +1000000+0 records in +1000000+0 records out + +real 0m8.885s +user 0m0.299s +sys 0m6.998s +[root@io pgsql]# time dd of=/dev/null if=testfile bs=1024 count=1000000 +1000000+0 records in +1000000+0 records out + +real 0m1.654s +user 0m0.232s +sys 0m1.415s + + +> +> >> > +> >> > I don't think 150MB/s is out of the realm for a 14 drive array. +> >> > How fast is time dd if=/dev/zero of=testfile bs=8192 count=1000000 +> >> > +> >> time dd if=/dev/zero of=testfile bs=8192 count=1000000 +> >> 1000000+0 records in +> >> 1000000+0 records out +> >> +> >> real 1m24.248s +> >> user 0m0.381s +> >> sys 0m33.028s +> >> +> >> +> >> > (That should create a 8GB file, which is too big to cache everything) +> >> > And then how fast is: +> >> > time dd if=testfile of=/dev/null bs=8192 count=1000000 +> >> +> >> time dd if=testfile of=/dev/null bs=8192 count=1000000 +> >> 1000000+0 records in +> >> 1000000+0 records out +> >> +> >> real 0m54.139s +> >> user 0m0.326s +> >> sys 0m8.916s +> >> +> >> +> >> and on a second run: +> >> +> >> real 0m55.667s +> >> user 0m0.341s +> >> sys 0m9.013s +> >> +> >> +> >> > +> >> > That should give you a semi-decent way of measuring how fast the RAID +> >> > system is, since it should be too big to cache in ram. +> >> +> >> about 150MB/Sec. Is there no better way to make this go faster...? +> +> I'm actually curious about PCI bus saturation at this point. Old 32-bit +> 33MHz pci could only push 1Gbit = 100MB/s. Now, I'm guessing that this +> is a higher performance system. But I'm really surprised that your write +> speed is that close to your read speed. (100MB/s write, 150MB/s read). + +The raid array I have is currently set up to use a single channel. But I +have dual controllers In the array. And dual external slots on the card. +The machine is brand new and has pci-e backplane. + + + +> +> > +> > Assuming these are U320 15Krpm 147GB HDs, a RAID 10 array of 14 of them +> > doing raw sequential IO like this should be capable of at +> > ~7*75MB/s= 525MB/s using Seagate Cheetah 15K.4's, ~7*79MB/s= 553MB/s +BTW I'm using Seagate Cheetah 15K.4's + +> > if using Fujitsu MAU's, and ~7*86MB/s= 602MB/s if using Maxtor Atlas 15K +> > II's to devices external to the RAID array. +> +> I know I thought these were SATA drives, over 2 controllers. I could be +> completely wrong, though. +> +> > +> > _IF_ the controller setup is high powered enough to keep that kind of IO +> > rate up. This will require a controller or controllers providing dual +> > channel U320 bandwidth externally and quad channel U320 bandwidth +> > internally. IOW, it needs a controller or controllers talking 64b +> > 133MHz PCI-X, reasonably fast DSP/CPU units, and probably a decent sized +> > IO buffer as well. +> > +> > AFAICT, the Dell PERC4 controllers use various flavors of the LSI Logic +> > MegaRAID controllers. What I don't know is which exact one yours is, +> > nor do I know if it (or any of the MegaRAID controllers) are high +> > powered enough. + +PERC4eDC-PCI Express, 128MB Cache, 2-External Channels + +> > +> > Talk to your HW supplier to make sure you have controllers adequate to +> > your HD's. +> > +> > ...and yes, your average access time will be in the 5.5ms - 6ms range +> > when doing a physical seek. +> > Even with RAID, you want to minimize seeks and maximize sequential IO +> > when accessing them. +> > Best to not go to HD at all ;-) +> +> Well, certainly, if you can get more into RAM, you're always better off. +> For writing, a battery-backed write cache, and for reading lots of +> system RAM. + +I'm not really worried about the writing, it's the reading the reading +that needs to be faster. + +> +> > +> > Hope this helps, +> > Ron Peacetree +> > +> +> John +> =:-> +-- +Speak softly and carry a +6 two-handed sword. + + +From pgsql-performance-owner@postgresql.org Sun Aug 21 12:56:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D93A1FEE930 + for ; + Sun, 21 Aug 2005 12:52:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32559-06 + for ; + Sun, 21 Aug 2005 15:52:05 +0000 (GMT) +Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 9193C1FEE927 + for ; + Sun, 21 Aug 2005 12:51:57 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc92.asp.att.net (sccmmhc92) with ESMTP + id <20050821155156m92009hsc4e>; Sun, 21 Aug 2005 15:51:56 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 0797855F80; Sun, 21 Aug 2005 10:51:56 -0500 (CDT) +Received: from [192.168.1.11] (liliana.arbash-meinel.com [192.168.1.11]) + by juju.arbash-meinel.com (Postfix) with ESMTP id E223F55F7A; + Sun, 21 Aug 2005 10:51:52 -0500 (CDT) +Message-ID: <4308A318.1040106@arbash-meinel.com> +Date: Sun, 21 Aug 2005 10:51:52 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: Ron , + postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <1124481386.27881.167.camel@bluejay.goodinassociates.com> + <43064908.7010505@arbash-meinel.com> + <1124564003.27881.229.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050820154422.06021150@pop.earthlink.net> + <4307E7A4.7090300@arbash-meinel.com> + <1124636066.27881.238.camel@bluejay.goodinassociates.com> +In-Reply-To: <1124636066.27881.238.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig8D5A08ABEE109B148706B224" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/308 +X-Sequence-Number: 14055 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig8D5A08ABEE109B148706B224 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: +> On Sat, 2005-08-20 at 21:32 -0500, John A Meinel wrote: +> +>>Ron wrote: +>> +>>>At 02:53 PM 8/20/2005, Jeremiah Jahn wrote: +>> +>>Well, since you can get a read of the RAID at 150MB/s, that means that +>>it is actual I/O speed. It may not be cached in RAM. Perhaps you could +>>try the same test, only using say 1G, which should be cached. +> +> +> [root@io pgsql]# time dd if=/dev/zero of=testfile bs=1024 count=1000000 +> 1000000+0 records in +> 1000000+0 records out +> +> real 0m8.885s +> user 0m0.299s +> sys 0m6.998s +> [root@io pgsql]# time dd of=/dev/null if=testfile bs=1024 count=1000000 +> 1000000+0 records in +> 1000000+0 records out +> +> real 0m1.654s +> user 0m0.232s +> sys 0m1.415s +> + +The write time seems about the same (but you only have 128MB of write +cache), but your read jumped up to 620MB/s. So you drives do seem to be +giving you 150MB/s. + +> + +... + +>>I'm actually curious about PCI bus saturation at this point. Old 32-bit +>>33MHz pci could only push 1Gbit = 100MB/s. Now, I'm guessing that this +>>is a higher performance system. But I'm really surprised that your write +>>speed is that close to your read speed. (100MB/s write, 150MB/s read). +> +> +> The raid array I have is currently set up to use a single channel. But I +> have dual controllers In the array. And dual external slots on the card. +> The machine is brand new and has pci-e backplane. +> +> +> +> +>>>Assuming these are U320 15Krpm 147GB HDs, a RAID 10 array of 14 of them +>>>doing raw sequential IO like this should be capable of at +>>> ~7*75MB/s= 525MB/s using Seagate Cheetah 15K.4's, ~7*79MB/s= 553MB/s +> +> BTW I'm using Seagate Cheetah 15K.4's +> + +Now, are the numbers that Ron is quoting in megabytes or megabits? I'm +guessing he knows what he is talking about, and is doing megabytes. +80MB/s sustained seems rather high for a hard-disk. + +Though this page: +http://www.storagereview.com/articles/200411/20041116ST3146754LW_2.html + +Does seem to agree with that statement. (Between 56 and 93MB/s) + +And since U320 is a 320MB/s bus, it doesn't seem like anything there +should be saturating. So why the low performance???? + +>> +>>>_IF_ the controller setup is high powered enough to keep that kind of IO +>>>rate up. This will require a controller or controllers providing dual +>>>channel U320 bandwidth externally and quad channel U320 bandwidth +>>>internally. IOW, it needs a controller or controllers talking 64b +>>>133MHz PCI-X, reasonably fast DSP/CPU units, and probably a decent sized +>>>IO buffer as well. +>>> +>>>AFAICT, the Dell PERC4 controllers use various flavors of the LSI Logic +>>>MegaRAID controllers. What I don't know is which exact one yours is, +>>>nor do I know if it (or any of the MegaRAID controllers) are high +>>>powered enough. +> +> +> PERC4eDC-PCI Express, 128MB Cache, 2-External Channels + +Do you know which card it is? Does it look like this one: +http://www.lsilogic.com/products/megaraid/megaraid_320_2e.html + +Judging by the 320 speed, and 2 external controllers, that is my guess. +They at least claim a theoretical max of 2GB/s. + +Which makes you wonder why reading from RAM is only able to get +throughput of 600MB/s. Did you run it multiple times? On my windows +system, I get just under 550MB/s for what should be cached, copying from +/dev/zero to /dev/null I get 2.4GB/s (though that might be a no-op). + +On a similar linux machine, I'm able to get 1200MB/s for a cached file. +(And 3GB/s for a zero=>null copy). + +John +=:-> + +> +> +>>>Talk to your HW supplier to make sure you have controllers adequate to +>>>your HD's. +>>> +>>>...and yes, your average access time will be in the 5.5ms - 6ms range +>>>when doing a physical seek. +>>>Even with RAID, you want to minimize seeks and maximize sequential IO +>>>when accessing them. +>>>Best to not go to HD at all ;-) +>> +>>Well, certainly, if you can get more into RAM, you're always better off. +>>For writing, a battery-backed write cache, and for reading lots of +>>system RAM. +> +> +> I'm not really worried about the writing, it's the reading the reading +> that needs to be faster. +> +> +>>>Hope this helps, +>>>Ron Peacetree +>>> +>> +>>John +>>=:-> + + +--------------enig8D5A08ABEE109B148706B224 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDCKMYJdeBCYSNAAMRAqnOAJ9D7H2TzoMHAgZYfZo8DfaWPusXfACfd69d +lnoanPccpm+iqovJ7p5Vt3o= +=45DT +-----END PGP SIGNATURE----- + +--------------enig8D5A08ABEE109B148706B224-- + +From pgsql-performance-owner@postgresql.org Sun Aug 21 15:32:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DC0F91FEE955 + for ; + Sun, 21 Aug 2005 15:32:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89561-07 + for ; + Sun, 21 Aug 2005 18:32:37 +0000 (GMT) +Received: from apate.telenet-ops.be (apate.telenet-ops.be [195.130.132.57]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DBA21FEE954 + for ; + Sun, 21 Aug 2005 15:32:36 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by apate.telenet-ops.be (Postfix) with SMTP id 5073138315 + for ; + Sun, 21 Aug 2005 20:32:34 +0200 (CEST) +Received: from [10.0.1.2] (d5152B1F3.access.telenet.be [81.82.177.243]) + by apate.telenet-ops.be (Postfix) with ESMTP id CCD5D382DB + for ; + Sun, 21 Aug 2005 20:32:33 +0200 (CEST) +Mime-Version: 1.0 (Apple Message framework v622) +To: pgsql-performance@postgresql.org +Message-Id: +Content-Type: multipart/mixed; boundary=Apple-Mail-1-313063916 +From: Yves Vindevogel +Subject: (Re)-indexing on updates +Date: Sun, 21 Aug 2005 20:32:31 +0200 +X-Mailer: Apple Mail (2.622) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/309 +X-Sequence-Number: 14056 + + +--Apple-Mail-1-313063916 +Content-Type: multipart/alternative; + boundary=Apple-Mail-2-313063917 + + +--Apple-Mail-2-313063917 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/plain; + charset=ISO-8859-1; + format=flowed + +Hi, + +Say I have a table with column A, B, C, D +A has a unique index on it (primary key) +B and C have a normal index on it +D has no index + +If I perform a query like update tbl set D =3D 'whatever' ; +that should make no difference on the indexes on the other columns,=20 +right ? + +Or is there some kind of mechanism that does create a sort of new=20 +record, thus makes the indexes go wild. + +Met vriendelijke groeten, +Bien =E0 vous, +Kind regards, + +Yves Vindevogel +Implements + + +--Apple-Mail-2-313063917 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/enriched; + charset=ISO-8859-1 + +Hi, + + +Say I have a table with column A, B, C, D + +A has a unique index on it (primary key) + +B and C have a normal index on it + +D has no index + + +If I perform a query like update tbl set D =3D 'whatever' ; + +that should make no difference on the indexes on the other columns, +right ? + + +Or is there some kind of mechanism that does create a sort of new +record, thus makes the indexes go wild. + + +Met vriendelijke groeten, + +Bien =E0 vous, + +Kind regards, + + +Yves Vindevogel + +Implements + + + += + +--Apple-Mail-2-313063917-- + +--Apple-Mail-1-313063916 +Content-Transfer-Encoding: base64 +Content-Type: image/tiff; + x-unix-mode=0666; + name="Pasted Graphic 2.tiff" +Content-Disposition: inline; + filename="Pasted Graphic 2.tiff" + +TU0AKgAAFciAP6BP5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GeFU/3G4Xa/0MfVY/1or2bQlbRUiiVpJpQ/y+U0jEYggzzOSkRUM/0KfJqfzop3+p1Aw3+53I7 +n+UCJWak3m26H+OxYdX+Xiij6leVRY3+YKheaks1Yy3+VCPBEIe5zM5qOxbdICAADgEAAAMAAAAB +ADgAAAEBAAMAAAABAEAAAAECAAMAAAAEAAAWdgEDAAMAAAABAAUAAAEGAAMAAAABAAIAAAERAAQA +AAABAAAACAEVAAMAAAABAAQAAAEWAAQAAAABAAAAkgEXAAQAAAABAAAVwAEaAAUAAAABAAAWfgEb +AAUAAAABAAAWhgEcAAMAAAABAAEAAAEoAAMAAAABAAIAAAFSAAMAAAABAAEAAAAAAAAACAAIAAgA +CAAK/IAAACcQAAr8gAAAJxA= + +--Apple-Mail-1-313063916 +Content-Type: multipart/alternative; + boundary=Apple-Mail-3-313063918 + + +--Apple-Mail-3-313063918 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + format=flowed + + + +Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 + +Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 + +Web: http://www.implements.be + +First they ignore you. Then they laugh at you. Then they fight you. +Then you win. +Mahatma Ghandi. +--Apple-Mail-3-313063918 +Content-Transfer-Encoding: 7bit +Content-Type: text/enriched; + charset=US-ASCII + + + + +Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 + + +Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 + + +Web: http://www.implements.be + + + +First they ignore you. Then they laugh at you. Then they fight you. +Then you win. + +Mahatma Ghandi. +--Apple-Mail-3-313063918-- + +--Apple-Mail-1-313063916-- + + +From pgsql-performance-owner@postgresql.org Sun Aug 21 17:37:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 19D19D729B + for ; + Sun, 21 Aug 2005 17:37:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24581-05 + for ; + Sun, 21 Aug 2005 20:37:38 +0000 (GMT) +Received: from mail28.sea5.speakeasy.net (mail28.sea5.speakeasy.net + [69.17.117.30]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D6E71FEE071 + for ; + Sun, 21 Aug 2005 16:05:28 -0300 (ADT) +Received: (qmail 5954 invoked from network); 21 Aug 2005 19:05:28 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail28.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 21 Aug 2005 19:05:28 -0000 +Subject: Re: (Re)-indexing on updates +From: "Jeffrey W. Baker" +To: Yves Vindevogel +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Date: Sun, 21 Aug 2005 12:06:05 -0700 +Message-Id: <1124651165.5990.1.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/312 +X-Sequence-Number: 14059 + +On Sun, 2005-08-21 at 20:32 +0200, Yves Vindevogel wrote: +> +> +> ______________________________________________________________________ +> +> Hi, +> +> Say I have a table with column A, B, C, D +> A has a unique index on it (primary key) +> B and C have a normal index on it +> D has no index +> +> If I perform a query like update tbl set D = 'whatever' ; +> that should make no difference on the indexes on the other columns, +> right ? + +What postgresql does on update is to make a new record, so there will be +two records in your table and two records in your index. You would need +to vacuum the table to mark the space for the old record free, and you +would need to reindex the table to shrink the index. + +> +> Or is there some kind of mechanism that does create a sort of new +> record, thus makes the indexes go wild. + +Yes. + +-jwb + + +From pgsql-performance-owner@postgresql.org Sun Aug 21 16:36:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A788B1FEF0F4 + for ; + Sun, 21 Aug 2005 16:36:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12767-04 + for ; + Sun, 21 Aug 2005 19:36:08 +0000 (GMT) +Received: from asia.telenet-ops.be (asia.telenet-ops.be [195.130.132.59]) + by svr1.postgresql.org (Postfix) with ESMTP id 737871FEF0E1 + for ; + Sun, 21 Aug 2005 16:36:07 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by asia.telenet-ops.be (Postfix) with SMTP id CD1272241EE + for ; + Sun, 21 Aug 2005 21:36:06 +0200 (MEST) +Received: from [10.0.1.2] (d5152B1F3.access.telenet.be [81.82.177.243]) + by asia.telenet-ops.be (Postfix) with ESMTP id C22652241C6 + for ; + Sun, 21 Aug 2005 21:36:05 +0200 (MEST) +Mime-Version: 1.0 (Apple Message framework v622) +To: pgsql-performance@postgresql.org +Message-Id: <7d4e3af17fe3d48a741969cea5f462e3@implements.be> +Content-Type: multipart/mixed; boundary=Apple-Mail-11-316875059 +From: Yves Vindevogel +Subject: Fwd: (Re)-indexing on updates +Date: Sun, 21 Aug 2005 21:36:03 +0200 +X-Mailer: Apple Mail (2.622) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/310 +X-Sequence-Number: 14057 + + +--Apple-Mail-11-316875059 +Content-Type: multipart/alternative; + boundary=Apple-Mail-12-316875060 + + +--Apple-Mail-12-316875060 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/plain; + charset=ISO-8859-1; + delsp=yes; + format=flowed + +I always forget that this goes to the writer itself and not to the =20 +group. +> +> +> Ok, this is a major setback in some of my procedures. +> =46rom time to time, I must update one field in about 10% of the = +records. +> So this will take time. +> +> How can I work around that ? +> +> Some personal opinions ... +> 1) Drop indexes, run update, create indexes, vacuum +> 2) Move the field to another table and use joins ? I could delete the = +=20 +> records when needed and add them again +> +> +> This mechanism, of inserting a new record and marking the old one, is =20= + +> that data kept somewhere where I can "see" it ? +> I need for one app a trace of all my changes in the database. I have =20= + +> a set of triggers to do that for the moment on each table. +> Could I use that mechanism somehow to avoid my triggers ? +> Any documentation on that mechanism (hacker stuff like what tables are = +=20 +> used) ? +> Any good books on stuff like this ? I love to read and know how the =20= + +> inside mechanics work. +> +> Tnx +> +> +> +> On 21 Aug 2005, at 21:06, Jeffrey W. Baker wrote: +> +>> On Sun, 2005-08-21 at 20:32 +0200, Yves Vindevogel wrote: +>>> +>>> +>>> = +_____________________________________________________________________=20 +>>> _ +>>> +>>> Hi, +>>> +>>> Say I have a table with column A, B, C, D +>>> A has a unique index on it (primary key) +>>> B and C have a normal index on it +>>> D has no index +>>> +>>> If I perform a query like update tbl set D =3D 'whatever' ; +>>> that should make no difference on the indexes on the other columns, +>>> right ? +>> +>> What postgresql does on update is to make a new record, so there will = +=20 +>> be +>> two records in your table and two records in your index. You would =20= + +>> need +>> to vacuum the table to mark the space for the old record free, and = +you +>> would need to reindex the table to shrink the index. +>> +>>> +>>> Or is there some kind of mechanism that does create a sort of new +>>> record, thus makes the indexes go wild. +>> +>> Yes. +>> +>> -jwb +>> +>> +>> +> Met vriendelijke groeten, +> Bien =E0 vous, +> Kind regards, +> +> Yves Vindevogel +> Implements +> + +--Apple-Mail-12-316875060 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/enriched; + charset=ISO-8859-1 + +I always forget that this goes to the writer itself and not to the +group. + + + + + +Ok, this is a major setback in some of my procedures. + +=46rom time to time, I must update one field in about 10% of the = +records. + +So this will take time. + + +How can I work around that ? + + +Some personal opinions ... + +1) Drop indexes, run update, create indexes, vacuum + +2) Move the field to another table and use joins ? I could delete the +records when needed and add them again=20 + + + +This mechanism, of inserting a new record and marking the old one, is +that data kept somewhere where I can "see" it ? + +I need for one app a trace of all my changes in the database. I have +a set of triggers to do that for the moment on each table. + +Could I use that mechanism somehow to avoid my triggers ? + +Any documentation on that mechanism (hacker stuff like what tables are +used) ? + +Any good books on stuff like this ? I love to read and know how the +inside mechanics work. + + +Tnx + + + + +On 21 Aug 2005, at 21:06, Jeffrey W. Baker wrote: + + +On Sun, 2005-08-21 at 20:32 +0200, Yves Vindevogel wrote: + + + + +______________________________________________________________________ + + +Hi, + + +Say I have a table with column A, B, C, D + +A has a unique index on it (primary key) + +B and C have a normal index on it + +D has no index + + +If I perform a query like update tbl set D =3D 'whatever' ; + +that should make no difference on the indexes on the other columns, + +right ? + + + +What postgresql does on update is to make a new record, so there will +be + +two records in your table and two records in your index. You would +need + +to vacuum the table to mark the space for the old record free, and you + +would need to reindex the table to shrink the index. + + + + +Or is there some kind of mechanism that does create a sort of new + +record, thus makes the indexes go wild. + + + +Yes. + + +-jwb + + + + +Met vriendelijke groeten, + +Bien =E0 vous, + +Kind regards, + + +Yves Vindevogel + +Implements + + + += + +--Apple-Mail-12-316875060-- + +--Apple-Mail-11-316875059 +Content-Transfer-Encoding: base64 +Content-Type: image/tiff; + x-unix-mode=0666; + name="Pasted Graphic 2.tiff" +Content-Disposition: inline; + filename="Pasted Graphic 2.tiff" + +TU0AKgAAFciAP6BP5/wWDQeEQmFQuGQ2HQ+FP5+v9rOh5P9IMBuP8zK9tP8fJNlP8QoNjP8FndhP +8MnyVjJHSMrqFnv9BL1vP9ett2v98PuJxChUOiUWGQOCUalUujOV4PZ/qBluR/mdVtJ/jVHst/ho +9MF/g08WABHJfv8AWa0WoAHFfWuzgg6sB/hY9ysUohjv8qqVqv9LMZxv9ouV40zEYmHUjFY2HPx+ +RNtOl4Rhftt/phiRs6LC/iA5LewnJeWg46W22+02cAHOwa26bC0HPY7TZ7G2G9dv8EHFdP8Om9YP +8rKJov9UtFzv9Dzh/sRvu5/vZ9PzHdeF4zsUqgQRlO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AAAABAAIAAAFSAAMAAAABAAEAAAAAAAAACAAIAAgA +CAAK/IAAACcQAAr8gAAAJxA= + +--Apple-Mail-11-316875059 +Content-Type: multipart/alternative; + boundary=Apple-Mail-13-316875061 + + +--Apple-Mail-13-316875061 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/plain; + charset=ISO-8859-1; + format=flowed + +> +> +> Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 +> +> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 +> +> Web: http://www.implements.be +> +> First they ignore you. Then they laugh at you. Then they fight you. =20= + +> Then you win. +> Mahatma Ghandi. +> +Met vriendelijke groeten, +Bien =E0 vous, +Kind regards, + +Yves Vindevogel +Implements + + +--Apple-Mail-13-316875061 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/enriched; + charset=ISO-8859-1 + + + + +Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 + + +Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 + + +Web: http://www.implements.be + + + +First they ignore you. Then they laugh at you. Then they fight you.=20 +Then you win. + +Mahatma Ghandi. + + +Met vriendelijke groeten, + +Bien =E0 vous, + +Kind regards, + + +Yves Vindevogel + +Implements + + + += + +--Apple-Mail-13-316875061-- + +--Apple-Mail-11-316875059 +Content-Transfer-Encoding: base64 +Content-Type: image/tiff; + x-unix-mode=0666; + name="Pasted Graphic 2.tiff" +Content-Disposition: inline; + filename="Pasted Graphic 2.tiff" + +TU0AKgAAFciAP6BP5/wWDQeEQmFQuGQ2HQ+FP5+v9rOh5P9IMBuP8zK9tP8fJNlP8QoNjP8FndhP +8MnyVjJHSMrqFnv9BL1vP9ett2v98PuJxChUOiUWGQOCUalUujOV4PZ/qBluR/mdVtJ/jVHst/ho +9MF/g08WABHJfv8AWa0WoAHFfWuzgg6sB/hY9ysUohjv8qqVqv9LMZxv9ouV40zEYmHUjFY2HPx+ +RNtOl4Rhftt/phiR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AAACAEVAAMAAAABAAQAAAEWAAQAAAABAAAAkgEXAAQAAAABAAAVwAEaAAUAAAABAAAWfgEb +AAUAAAABAAAWhgEcAAMAAAABAAEAAAEoAAMAAAABAAIAAAFSAAMAAAABAAEAAAAAAAAACAAIAAgA +CAAK/IAAACcQAAr8gAAAJxA= + +--Apple-Mail-11-316875059 +Content-Type: multipart/alternative; + boundary=Apple-Mail-14-316875063 + + +--Apple-Mail-14-316875063 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + format=flowed + + + +Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 + +Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 + +Web: http://www.implements.be + +First they ignore you. Then they laugh at you. Then they fight you. +Then you win. +Mahatma Ghandi. + +--Apple-Mail-14-316875063 +Content-Transfer-Encoding: 7bit +Content-Type: text/enriched; + charset=US-ASCII + + + + +Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 + + +Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 + + +Web: http://www.implements.be + + + +First they ignore you. Then they laugh at you. Then they fight you. +Then you win. + +Mahatma Ghandi. + + +--Apple-Mail-14-316875063-- + +--Apple-Mail-11-316875059-- + + +From pgsql-performance-owner@postgresql.org Sun Aug 21 17:00:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 21B891FEEC4B + for ; + Sun, 21 Aug 2005 16:59:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20569-01 + for ; + Sun, 21 Aug 2005 19:59:47 +0000 (GMT) +Received: from asia.telenet-ops.be (asia.telenet-ops.be [195.130.132.59]) + by svr1.postgresql.org (Postfix) with ESMTP id 442951FEEC43 + for ; + Sun, 21 Aug 2005 16:59:16 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by asia.telenet-ops.be (Postfix) with SMTP id CD7FB224037 + for ; + Sun, 21 Aug 2005 21:59:15 +0200 (MEST) +Received: from [10.0.1.2] (d5152B1F3.access.telenet.be [81.82.177.243]) + by asia.telenet-ops.be (Postfix) with ESMTP id DDEE8224099 + for ; + Sun, 21 Aug 2005 21:59:14 +0200 (MEST) +Mime-Version: 1.0 (Apple Message framework v622) +To: pgsql-performance@postgresql.org +Message-Id: +Content-Type: multipart/mixed; boundary=Apple-Mail-18-318263928 +From: Yves Vindevogel +Subject: Fwd: (Re)-indexing on updates +Date: Sun, 21 Aug 2005 21:59:11 +0200 +X-Mailer: Apple Mail (2.622) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/311 +X-Sequence-Number: 14058 + + +--Apple-Mail-18-318263928 +Content-Type: multipart/alternative; + boundary=Apple-Mail-19-318263928 + + +--Apple-Mail-19-318263928 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/plain; + charset=ISO-8859-1; + format=flowed + +My DB is quite simple. It holds data about printjobs that come from=20 +the windows eventlog. +The data is shown on a website. I have one main table: tblPrintjobs. +We add some extra data to it. Like the applicationtype, based on rules=20= + +we define in other tables. + +When a rule changes, the updates take place (and take so long). +Also, when new records are added, this takes place. + +For instance, rule 1 and rule 2 are changing positions in importance.=20 +(1 was before 2, now 2 before 1) +The records that hold reference to rule 1 are reset to null (one field) +Rule 2 is assigned, then rule 1 is assigned. + +What I could do is also: +delete all from tblRefRules where rule is 1 +insert all from tblPrintjobs that are not yet in RefRules for Rule2,=20 +then insert all for rule2 + +That would be a workaround for the MVCC. Not ? + +BTW: The good rule is: drop index, update, vacuum, create index ? +I think I mistook the purpose of vacuum. +If I index before the vacuum, my marked records will still be in the=20 +index ? Even if all transactions are finished ? + + +Begin forwarded message: + +> From: "Jeffrey W. Baker" +> Date: Sun 21 Aug 2005 21:36:16 CEST +> To: Yves Vindevogel +> Subject: Re: [PERFORM] (Re)-indexing on updates +> +> On Sun, 2005-08-21 at 21:18 +0200, Yves Vindevogel wrote: +>> +>> +>> = +______________________________________________________________________ +>> +>> Ok, this is a major setback in some of my procedures. +>> =46rom time to time, I must update one field in about 10% of the +>> records. +>> So this will take time. +>> +>> How can I work around that ? +>> +>> Some personal opinions ... +>> 1) Drop indexes, run update, create indexes, vacuum +> +> Drop index, update, vacuum, create index +> +> -or- +> +> update, vacuum, reindex +> +>> 2) Move the field to another table and use joins ? I could delete = +the +>> records when needed and add them again +> +> I'm not familiar with your application, but you could try it and tell=20= + +> us +> if this works :) +> +>> +>> This mechanism, of inserting a new record and marking the old one, is +>> that data kept somewhere where I can "see" it ? +> +> This is MVCC: multi-version cuncurrency. The old record is kept=20 +> because +> there could be an old transaction that can still see it, and cannot = +yet +> see the updated record. And no other transaction can see your record +> until you commit. The old row isn't removed until you vacuum. +> +>> I need for one app a trace of all my changes in the database. I have +>> a set of triggers to do that for the moment on each table. +>> Could I use that mechanism somehow to avoid my triggers ? +>> Any documentation on that mechanism (hacker stuff like what tables = +are +>> used) ? +> +> You could search the postgresql documentation (or the web) for MVCC. +> +> Regards, +> jwb +> +> +> +Met vriendelijke groeten, +Bien =E0 vous, +Kind regards, + +Yves Vindevogel +Implements + + +--Apple-Mail-19-318263928 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/enriched; + charset=ISO-8859-1 + +My DB is quite simple. It holds data about printjobs that come from +the windows eventlog. + +The data is shown on a website. I have one main table: tblPrintjobs. + +We add some extra data to it. Like the applicationtype, based on +rules we define in other tables. + + +When a rule changes, the updates take place (and take so long). + +Also, when new records are added, this takes place. + + +For instance, rule 1 and rule 2 are changing positions in importance. +(1 was before 2, now 2 before 1) + +The records that hold reference to rule 1 are reset to null (one field) + +Rule 2 is assigned, then rule 1 is assigned. + + +What I could do is also: + +delete all from tblRefRules where rule is 1 + +insert all from tblPrintjobs that are not yet in RefRules for Rule2, +then insert all for rule2 + + +That would be a workaround for the MVCC. Not ? + + +BTW: The good rule is: drop index, update, vacuum, create index ? + +I think I mistook the purpose of vacuum. + +If I index before the vacuum, my marked records will still be in the +index ? Even if all transactions are finished ? + + + +Begin forwarded message: + + +0000,0000,0000From: +"Jeffrey W. Baker" < + +0000,0000,0000Date: Sun 21 +Aug 2005 21:36:16 CEST + +0000,0000,0000To: Yves +Vindevogel < + +0000,0000,0000Subject: Re: +[PERFORM] (Re)-indexing on updates + + + +On Sun, 2005-08-21 at 21:18 +0200, Yves Vindevogel wrote: + + + + +______________________________________________________________________ + + +Ok, this is a major setback in some of my procedures. + +=46rom time to time, I must update one field in about 10% of the + +records. + +So this will take time. + + +How can I work around that ? + + +Some personal opinions ... + +1) Drop indexes, run update, create indexes, vacuum + + + +Drop index, update, vacuum, create index + + +-or- + + +update, vacuum, reindex + + +2) Move the field to another table and use joins ? I could +delete the + +records when needed and add them again=20 + + + +I'm not familiar with your application, but you could try it and tell +us + +if this works :) + + + + +This mechanism, of inserting a new record and marking the old one, is + +that data kept somewhere where I can "see" it ? + + + +This is MVCC: multi-version cuncurrency. The old record is kept +because + +there could be an old transaction that can still see it, and cannot yet + +see the updated record. And no other transaction can see your record + +until you commit. The old row isn't removed until you vacuum. + + +I need for one app a trace of all my changes in the database.=20= + +I have + +a set of triggers to do that for the moment on each table. + +Could I use that mechanism somehow to avoid my triggers ? + +Any documentation on that mechanism (hacker stuff like what tables are + +used) ? + + + +You could search the postgresql documentation (or the web) for MVCC. + + +Regards, + +jwb + + + + +Met vriendelijke groeten, + +Bien =E0 vous, + +Kind regards, + + +Yves Vindevogel + +Implements + + + += + +--Apple-Mail-19-318263928-- + +--Apple-Mail-18-318263928 +Content-Transfer-Encoding: base64 +Content-Type: image/tiff; + x-unix-mode=0666; + name="Pasted Graphic 2.tiff" +Content-Disposition: inline; + filename="Pasted Graphic 2.tiff" + +TU0AKgAAFciAP6BP5/wWDQeEQmFQuGQ2HQ+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2bQlbRUiiVpJpQ/y+U0jEYggzzOSkRUM/0KfJqfzop3+p1Aw3+53I7 +n+UCJWak3m26H+OxYdX+Xiij6leVRY3+YKheaks1Yy3+VCPBEIe5zM5qOxbdICAADgEAAAMAAAAB +ADgAAAEBAAMAAAABAEAAAAECAAMAAAAEAAAWdgEDAAMAAAABAAUAAAEGAAMAAAABAAIAAAERAAQA +AAABAAAACAEVAAMAAAABAAQAAAEWAAQAAAABAAAAkgEXAAQAAAABAAAVwAEaAAUAAAABAAAWfgEb +AAUAAAABAAAWhgEcAAMAAAABAAEAAAEoAAMAAAABAAIAAAFSAAMAAAABAAEAAAAAAAAACAAIAAgA +CAAK/IAAACcQAAr8gAAAJxA= + +--Apple-Mail-18-318263928 +Content-Type: multipart/alternative; + boundary=Apple-Mail-20-318263930 + + +--Apple-Mail-20-318263930 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + format=flowed + + + +Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 + +Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 + +Web: http://www.implements.be + +First they ignore you. Then they laugh at you. Then they fight you. +Then you win. +Mahatma Ghandi. + +--Apple-Mail-20-318263930 +Content-Transfer-Encoding: 7bit +Content-Type: text/enriched; + charset=US-ASCII + + + + +Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 + + +Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 + + +Web: http://www.implements.be + + + +First they ignore you. Then they laugh at you. Then they fight you. +Then you win. + +Mahatma Ghandi. + + +--Apple-Mail-20-318263930-- + +--Apple-Mail-18-318263928-- + + +From pgsql-performance-owner@postgresql.org Sun Aug 21 20:37:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 59EB4D76CF + for ; + Sun, 21 Aug 2005 20:35:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92394-01 + for ; + Sun, 21 Aug 2005 23:35:49 +0000 (GMT) +Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) + by svr1.postgresql.org (Postfix) with ESMTP id A59F2D77B1 + for ; + Sun, 21 Aug 2005 20:33:33 -0300 (ADT) +Received: from smtpauth09.mail.atl.earthlink.net + (smtpauth09.mail.atl.earthlink.net [209.86.89.69]) + by svr2.postgresql.org (Postfix) with ESMTP id 922BDF10A6 + for ; + Sun, 21 Aug 2005 21:13:46 +0100 (BST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=nJ/bH4nQrkilcDUBB5f59PqXYtr/+F0IGnjnhXi9uGu4ef8rMGa4wqUIF7VBhAUC; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Cc:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth09.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E6wGJ-0007a0-10; Sun, 21 Aug 2005 16:17:47 -0400 +Message-Id: <6.2.3.4.0.20050821112849.01f79860@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Sun, 21 Aug 2005 16:13:17 -0400 +To: Jeremiah Jahn +From: Ron +Subject: Re: extremly low memory usage +Cc: postgres performance +In-Reply-To: <1124636066.27881.238.camel@bluejay.goodinassociates.com> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <1124481386.27881.167.camel@bluejay.goodinassociates.com> + <43064908.7010505@arbash-meinel.com> + <1124564003.27881.229.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050820154422.06021150@pop.earthlink.net> + <4307E7A4.7090300@arbash-meinel.com> + <1124636066.27881.238.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcd077a119f968650f22b316183a24595f350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.441 required=5 tests=[AWL=0.067, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/314 +X-Sequence-Number: 14061 + +At 10:54 AM 8/21/2005, Jeremiah Jahn wrote: +>On Sat, 2005-08-20 at 21:32 -0500, John A Meinel wrote: +> > Ron wrote: +> > +> > Well, since you can get a read of the RAID at 150MB/s, that means that +> > it is actual I/O speed. It may not be cached in RAM. Perhaps you could +> > try the same test, only using say 1G, which should be cached. +> +>[root@io pgsql]# time dd if=/dev/zero of=testfile bs=1024 count=1000000 +>1000000+0 records in +>1000000+0 records out +> +>real 0m8.885s +>user 0m0.299s +>sys 0m6.998s + +This is abysmally slow. + + +>[root@io pgsql]# time dd of=/dev/null if=testfile bs=1024 count=1000000 +>1000000+0 records in +>1000000+0 records out +> +>real 0m1.654s +>user 0m0.232s +>sys 0m1.415s + +This transfer rate is the only one out of the 4 you have posted that +is in the vicinity of where it should be. + + +>The raid array I have is currently set up to use a single channel. But I +>have dual controllers in the array. And dual external slots on the card. +>The machine is brand new and has pci-e backplane. +> +So you have 2 controllers each with 2 external slots? But you are +currently only using 1 controller and only one external slot on that +controller? + + +> > > Assuming these are U320 15Krpm 147GB HDs, a RAID 10 array of 14 of them +> > > doing raw sequential IO like this should be capable of at +> > > ~7*75MB/s= 525MB/s using Seagate Cheetah 15K.4's +>BTW I'm using Seagate Cheetah 15K.4's + +OK, now we have that nailed down. + + +> > > AFAICT, the Dell PERC4 controllers use various flavors of the LSI Logic +> > > MegaRAID controllers. What I don't know is which exact one yours is, +> > > nor do I know if it (or any of the MegaRAID controllers) are high +> > > powered enough. +> +>PERC4eDC-PCI Express, 128MB Cache, 2-External Channels + +Looks like they are using the LSI Logic MegaRAID SCSI 320-2E +controller. IIUC, you have 2 of these, each with 2 external channels? + +The specs on these appear a bit strange. They are listed as being a +PCI-Ex8 card, which means they should have a max bandwidth of 20Gb/s= +2GB/s, yet they are also listed as only supporting dual channel U320= +640MB/s when they could easily support quad channel U320= +1.28GB/s. Why bother building a PCI-Ex8 card when only a PCI-Ex4 +card (which is a more standard physical format) would've been +enough? Or if you are going to build a PCI-Ex8 card, why not support +quad channel U320? This smells like there's a problem with LSI's design. + +The 128MB buffer also looks suspiciously small, and I do not see any +upgrade path for it on LSI Logic's site. "Serious" RAID controllers +from companies like Xyratex, Engino, and Dot-hill can have up to +1-2GB of buffer, and there's sound technical reasons for it. See if +there's a buffer upgrade available or if you can get controllers that +have larger buffer capabilities. + +Regardless of the above, each of these controllers should still be +good for about 80-85% of 640MB/s, or ~510-540 MB/s apiece when doing +raw sequential IO if you plug 3-4 fast enough HD's into each SCSI +channel. Cheetah 15K.4's certainly are fast enough. Optimal setup +is probably to split each RAID 1 pair so that one HD is on each of +the SCSI channels, and then RAID 0 those pairs. That will also +protect you from losing the entire disk subsystem if one of the SCSI +channels dies. + +That 128MB of buffer cache may very well be too small to keep the IO +rate up, and/or there may be a more subtle problem with the LSI card, +and/or you may have a configuration problem, but _something(s)_ need +fixing since you are only getting raw sequential IO of ~100-150MB/s +when it should be above 500MB/s. + +This will make the most difference for initial reads (first time you +load a table, first time you make a given query, etc) and for any writes. + +Your HW provider should be able to help you, even if some of the HW +in question needs to be changed. You paid for a solution. As long +as this stuff is performing at so much less then what it is supposed +to, you have not received the solution you paid for. + +BTW, on the subject of RAID stripes IME the sweet spot tends to be in +the 64KB to 256KB range (very large, very read heavy data mines can +want larger RAID stripes.). Only experimentation will tell you what +results in the best performance for your application. + + +>I'm not really worried about the writing, it's the reading the reading +>that needs to be faster. + +Initial reads are only going to be as fast as your HD subsystem, so +there's a reason for making the HD subsystem faster even if all you +care about is reads. In addition, I'll repeat my previous advice +that upgrading to 16GB of RAM would be well worth it for you. + +Hope this helps, +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Sun Aug 21 19:59:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C4903D6D84 + for ; + Sun, 21 Aug 2005 19:59:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74781-09 + for ; + Sun, 21 Aug 2005 22:59:18 +0000 (GMT) +Received: from smtpauth01.mail.atl.earthlink.net + (smtpauth01.mail.atl.earthlink.net [209.86.89.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A9E0D6D83 + for ; + Sun, 21 Aug 2005 19:59:16 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=BnlOVH8co24DmRuCFfRnR+J4eSD9eWQgiJZTqu3jZgFKaMtivQ9ZfzDfgQuI0hbD; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E6ymd-0002lZ-K7; Sun, 21 Aug 2005 18:59:19 -0400 +Message-Id: <6.2.3.4.0.20050821185759.01f7c720@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Sun, 21 Aug 2005 18:59:15 -0400 +To: Jeremiah Jahn , + postgres performance +From: Ron +Subject: Re: extremly low memory usage +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc830015ee01ac8153963bc8f9c0569fda350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.453 required=5 tests=[AWL=0.079, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/313 +X-Sequence-Number: 14060 + +I'm resending this as it appears not to have made it to the list. + +At 10:54 AM 8/21/2005, Jeremiah Jahn wrote: +>On Sat, 2005-08-20 at 21:32 -0500, John A Meinel wrote: +> > Ron wrote: +> > +> > Well, since you can get a read of the RAID at 150MB/s, that means that +> > it is actual I/O speed. It may not be cached in RAM. Perhaps you could +> > try the same test, only using say 1G, which should be cached. +> +>[root@io pgsql]# time dd if=/dev/zero of=testfile bs=1024 count=1000000 +>1000000+0 records in +>1000000+0 records out +> +>real 0m8.885s +>user 0m0.299s +>sys 0m6.998s + +This is abysmally slow. + + +>[root@io pgsql]# time dd of=/dev/null if=testfile bs=1024 count=1000000 +>1000000+0 records in +>1000000+0 records out +> +>real 0m1.654s +>user 0m0.232s +>sys 0m1.415s + +This transfer rate is the only one out of the 4 you have posted that +is in the vicinity of where it should be. + + +>The raid array I have is currently set up to use a single channel. But I +>have dual controllers in the array. And dual external slots on the card. +>The machine is brand new and has pci-e backplane. +> +So you have 2 controllers each with 2 external slots? But you are +currently only using 1 controller and only one external slot on that +controller? + + +> > > Assuming these are U320 15Krpm 147GB HDs, a RAID 10 array of 14 of them +> > > doing raw sequential IO like this should be capable of at +> > > ~7*75MB/s= 525MB/s using Seagate Cheetah 15K.4's +>BTW I'm using Seagate Cheetah 15K.4's + +OK, now we have that nailed down. + + +> > > AFAICT, the Dell PERC4 controllers use various flavors of the LSI Logic +> > > MegaRAID controllers. What I don't know is which exact one yours is, +> > > nor do I know if it (or any of the MegaRAID controllers) are high +> > > powered enough. +> +>PERC4eDC-PCI Express, 128MB Cache, 2-External Channels + +Looks like they are using the LSI Logic MegaRAID SCSI 320-2E +controller. IIUC, you have 2 of these, each with 2 external channels? + +The specs on these appear a bit strange. They are listed as being a +PCI-Ex8 card, which means they should have a max bandwidth of 20Gb/s= +2GB/s, yet they are also listed as only supporting dual channel U320= +640MB/s when they could easily support quad channel U320= +1.28GB/s. Why bother building a PCI-Ex8 card when only a PCI-Ex4 +card (which is a more standard physical format) would've been +enough? Or if you are going to build a PCI-Ex8 card, why not support +quad channel U320? This smells like there's a problem with LSI's design. + +The 128MB buffer also looks suspiciously small, and I do not see any +upgrade path for it on LSI Logic's site. "Serious" RAID controllers +from companies like Xyratex, Engino, and Dot-hill can have up to +1-2GB of buffer, and there's sound technical reasons for it. See if +there's a buffer upgrade available or if you can get controllers that +have larger buffer capabilities. + +Regardless of the above, each of these controllers should still be +good for about 80-85% of 640MB/s, or ~510-540 MB/s apiece when doing +raw sequential IO if you plug 3-4 fast enough HD's into each SCSI +channel. Cheetah 15K.4's certainly are fast enough. Optimal setup +is probably to split each RAID 1 pair so that one HD is on each of +the SCSI channels, and then RAID 0 those pairs. That will also +protect you from losing the entire disk subsystem if one of the SCSI +channels dies. + +That 128MB of buffer cache may very well be too small to keep the IO +rate up, and/or there may be a more subtle problem with the LSI card, +and/or you may have a configuration problem, but _something(s)_ need +fixing since you are only getting raw sequential IO of ~100-150MB/s +when it should be above 500MB/s. + +This will make the most difference for initial reads (first time you +load a table, first time you make a given query, etc) and for any writes. + +Your HW provider should be able to help you, even if some of the HW +in question needs to be changed. You paid for a solution. As long +as this stuff is performing at so much less then what it is supposed +to, you have not received the solution you paid for. + +BTW, on the subject of RAID stripes IME the sweet spot tends to be in +the 64KB to 256KB range (very large, very read heavy data mines can +want larger RAID stripes.). Only experimentation will tell you what +results in the best performance for your application. + + +>I'm not really worried about the writing, it's the reading the reading +>that needs to be faster. + +Initial reads are only going to be as fast as your HD subsystem, so +there's a reason for making the HD subsystem faster even if all you +care about is reads. In addition, I'll repeat my previous advice +that upgrading to 16GB of RAM would be well worth it for you. + +Hope this helps, +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Mon Aug 22 06:11:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BEFAD6E91 + for ; + Mon, 22 Aug 2005 06:11:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17642-07 + for ; + Mon, 22 Aug 2005 09:11:39 +0000 (GMT) +Received: from apate.telenet-ops.be (apate.telenet-ops.be [195.130.132.57]) + by svr1.postgresql.org (Postfix) with ESMTP id 628DCD6E7F + for ; + Mon, 22 Aug 2005 06:11:33 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by apate.telenet-ops.be (Postfix) with SMTP + id 8462238189; Mon, 22 Aug 2005 11:11:26 +0200 (CEST) +Received: from [10.0.1.2] (d5152B1F3.access.telenet.be [81.82.177.243]) + by apate.telenet-ops.be (Postfix) with ESMTP + id DE1783828E; Mon, 22 Aug 2005 11:11:25 +0200 (CEST) +In-Reply-To: <1124651165.5990.1.camel@noodles> +References: + <1124651165.5990.1.camel@noodles> +Mime-Version: 1.0 (Apple Message framework v622) +Content-Type: multipart/mixed; boundary=Apple-Mail-46-365797590 +Message-Id: <72e7fd0cfc36da6420ba0e92a390b561@implements.be> +Cc: pgsql-performance@postgresql.org +From: Yves Vindevogel +Subject: Re: (Re)-indexing on updates +Date: Mon, 22 Aug 2005 11:11:25 +0200 +To: "Jeffrey W. Baker" +X-Mailer: Apple Mail (2.622) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/315 +X-Sequence-Number: 14062 + + +--Apple-Mail-46-365797590 +Content-Type: multipart/alternative; + boundary=Apple-Mail-47-365797590 + + +--Apple-Mail-47-365797590 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/plain; + charset=ISO-8859-1; + format=flowed + +The option with + +T1: A B C and T2 A D (to avoid the updates) +works very well with a simple query + +Insert into T2 (A, D) +select A, functionToGetD from T1 left join T2 on T1.A =3D T2.A +where T2.A is null + +The above gives me the new records for those where D was not filled yet. +Since they are all new records, I have no trouble with the MVCC + +On 21 Aug 2005, at 21:06, Jeffrey W. Baker wrote: + +> On Sun, 2005-08-21 at 20:32 +0200, Yves Vindevogel wrote: +>> +>> +>> = +______________________________________________________________________ +>> +>> Hi, +>> +>> Say I have a table with column A, B, C, D +>> A has a unique index on it (primary key) +>> B and C have a normal index on it +>> D has no index +>> +>> If I perform a query like update tbl set D =3D 'whatever' ; +>> that should make no difference on the indexes on the other columns, +>> right ? +> +> What postgresql does on update is to make a new record, so there will=20= + +> be +> two records in your table and two records in your index. You would=20 +> need +> to vacuum the table to mark the space for the old record free, and you +> would need to reindex the table to shrink the index. +> +>> +>> Or is there some kind of mechanism that does create a sort of new +>> record, thus makes the indexes go wild. +> +> Yes. +> +> -jwb +> +> +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> +> +Met vriendelijke groeten, +Bien =E0 vous, +Kind regards, + +Yves Vindevogel +Implements + + +--Apple-Mail-47-365797590 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/enriched; + charset=ISO-8859-1 + +The option with=20 + + +T1: A B C and T2 A D (to avoid the updates) + +works very well with a simple query + + +Insert into T2 (A, D) + +select A, functionToGetD from T1 left join T2 on T1.A =3D T2.A=20 + +where T2.A is null + + +The above gives me the new records for those where D was not filled +yet. + +Since they are all new records, I have no trouble with the MVCC + + +On 21 Aug 2005, at 21:06, Jeffrey W. Baker wrote: + + +On Sun, 2005-08-21 at 20:32 +0200, Yves Vindevogel wrote: + + + + +______________________________________________________________________ + + +Hi, + + +Say I have a table with column A, B, C, D + +A has a unique index on it (primary key) + +B and C have a normal index on it + +D has no index + + +If I perform a query like update tbl set D =3D 'whatever' ; + +that should make no difference on the indexes on the other columns, + +right ? + + + +What postgresql does on update is to make a new record, so there will +be + +two records in your table and two records in your index. You would +need + +to vacuum the table to mark the space for the old record free, and you + +would need to reindex the table to shrink the index. + + + + +Or is there some kind of mechanism that does create a sort of new + +record, thus makes the indexes go wild. + + + +Yes. + + +-jwb + + + +---------------------------(end of +broadcast)--------------------------- + +TIP 9: In versions below 8.0, the planner will ignore your desire to + + choose an index scan if your joining column's datatypes do not + + match + + + +Met vriendelijke groeten, + +Bien =E0 vous, + +Kind regards, + + +Yves Vindevogel + +Implements + + + += + +--Apple-Mail-47-365797590-- + +--Apple-Mail-46-365797590 +Content-Transfer-Encoding: base64 +Content-Type: image/tiff; + x-unix-mode=0666; + name="Pasted Graphic 2.tiff" +Content-Disposition: inline; + filename="Pasted Graphic 2.tiff" + +TU0AKgAAFciAP6BP5/wWDQeEQmFQuGQ2HQ+FP5+v9rOh5P9IMBuP8zK9tP8fJNlP8QoNjP8FndhP +8MnyVjJHSMrqFnv9BL1vP9ett2v98PuJxChUOiUWGQOCUalUujOV4PZ/qBluR/mdVtJ/jVHst/ho +9MF/g08WABHJfv8AWa0WoAHFfWuzgg6sB/hY9ysUohjv8qqVqv9LMZxv9ouV40zEYmHUjFY2HPx+ +RNtOl4Rhftt/phiRs6LC/iA5LewnJeWg46W22+02cAHOwa26bC0HPY7TZ7G2G9dv8EHFdP8Om9YP +8rKJov9UtFzv9Dzh/sRvu5/vZ9PzHdeF4zsUqgQRlOR5v9DMBwv8uqe/jZIVwNHu6B0/WAKHvWGr +RAA1ra0G1c/vfgANrdraXrTQIAA6JW2TUrQNz/ja0oAjO4YAjSWS0DOWawjys4RkIk4Lj2sAWEUZ +B/ieUJqH+PZdnAf5aG06R5nsfLtqW7UaoWZJwukwLyi4VRsn+F5HGYf8QJWBQ7JWAI5tYti2Dm1T +bQHAq0De1Q2FwtA1Fof4Aj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0RSz2KgCABjdACSB4ED3V3YH+C8CjbCFAEwLP006EG8 +G2X35LbnK6B/5iH+GcGSs8FoFehCC0CYEavXAT5WRSDyDdxACKBtvwFwFkJqHEHAUVxeLACSB3HZ +2GNKEyEgP6EsEaNEKQCn3MH+DuDZEgIOEUEAZMDuDbxB7jFL5zbCDQC2Et2cC/zwIP8AH+BoBKDf +1iCxEEC4CfFgEqEYNFCeU4BWA2DSXIGgXGIWu+XmCQB35r2R0EEgEOQyIWEOD88GECDvVmCyCZIs +DACpGaE0EkN+DP8GIQEGDyFUH/3LFL0Ue+HkHh18IMHPwoCqCRe54ILoCMBvEKC6Cl8CC18IIWFa +FKL2DGCtEEIXE0MH2+H+EKD4fZ10fZ374Z7h7l7p7sIMEF9eRd6d1p1t4H4L/ohCDECsEkIQIAVC +MiX+dTUoH++n0/X++4W/4hEHe7Xo/xQGTO/zQXEu/0Cd1S/0Yglg/3g73q/yWPUE/zsa1C/0IeVW +/0GeFU/3G4Xa/0MfVY/1or2bQlbRUiiVpJpQ/y+U0jEYggzzOSkRUM/0KfJqfzop3+p1Aw3+53I7 +n+UCJWak3m26H+OxYdX+Xiij6leVRY3+YKheaks1Yy3+VCPBEIe5zM5qOxbdICAADgEAAAMAAAAB +ADgAAAEBAAMAAAABAEAAAAECAAMAAAAEAAAWdgEDAAMAAAABAAUAAAEGAAMAAAABAAIAAAERAAQA +AAABAAAACAEVAAMAAAABAAQAAAEWAAQAAAABAAAAkgEXAAQAAAABAAAVwAEaAAUAAAABAAAWfgEb +AAUAAAABAAAWhgEcAAMAAAABAAEAAAEoAAMAAAABAAIAAAFSAAMAAAABAAEAAAAAAAAACAAIAAgA +CAAK/IAAACcQAAr8gAAAJxA= + +--Apple-Mail-46-365797590 +Content-Type: multipart/alternative; + boundary=Apple-Mail-48-365797592 + + +--Apple-Mail-48-365797592 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + format=flowed + + + +Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 + +Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 + +Web: http://www.implements.be + +First they ignore you. Then they laugh at you. Then they fight you. +Then you win. +Mahatma Ghandi. + +--Apple-Mail-48-365797592 +Content-Transfer-Encoding: 7bit +Content-Type: text/enriched; + charset=US-ASCII + + + + +Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 + + +Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 + + +Web: http://www.implements.be + + + +First they ignore you. Then they laugh at you. Then they fight you. +Then you win. + +Mahatma Ghandi. + + +--Apple-Mail-48-365797592-- + +--Apple-Mail-46-365797590-- + + +From pgsql-performance-owner@postgresql.org Mon Aug 22 06:29:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9ED92D6E50 + for ; + Mon, 22 Aug 2005 06:29:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62122-01 + for ; + Mon, 22 Aug 2005 09:29:17 +0000 (GMT) +Received: from smtp104.mail.sc5.yahoo.com (smtp104.mail.sc5.yahoo.com + [66.163.169.223]) + by svr1.postgresql.org (Postfix) with SMTP id B66DFD6E3E + for ; + Mon, 22 Aug 2005 06:29:15 -0300 (ADT) +Received: (qmail 43782 invoked from network); 22 Aug 2005 09:29:13 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Received:User-Agent:Date:Subject:From:To:Message-ID:In-Reply-To:Mime-version:Content-type:Content-transfer-encoding; + b=jWMuYO6I1MB8y7tsC64ummRCWCTYVb6bPFdocmn64Yt7n8YiKUuYoKLRzUe/w/pAvGSVLFHOeTZW9WYjMVO/J0rJb6WQ7Oy065wrHXd0EmnhkzjHl6GtEl30rnpnE+/LcaTnbTNzehC+rxMiYQbPCmrPx2pGE38ABniRrNjcOK4= + ; +Received: from unknown (HELO ?192.168.0.103?) (mcotner@66.56.49.200 with + login) + by smtp104.mail.sc5.yahoo.com with SMTP; 22 Aug 2005 09:29:13 -0000 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Mon, 22 Aug 2005 05:29:12 -0400 +Subject: Re: sustained update load of 1-2k/sec +From: Mark Cotner +To: "J. Andrew Rogers" , + +Message-ID: +In-Reply-To: +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.28 required=5 tests=[AWL=-0.094, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/316 +X-Sequence-Number: 14063 + +Thanks again everyone for the excellent suggestions. + +I looked into IO::Reactor, but after a few hours of fiddling decided I was +getting the kind of performance I wanted from using a slightly more than +modest number of threads and decided(due to dev timelines) to come back to +patching the SNMP libraries for Ruby to do async using Reactor later. + +I am unfortunately stuck with updates, but I think(with you're suggestions) +I've made it work for me. + +MySQL = 1500 updates/sec +PostgreSQL w/10k tx per commit using single thread = 1400 updates/sec +Given the update heavy nature of this table I felt it was necessary to test +during a vacuum. Turns out the hit wasn't that bad . . . +PostgreSQL w/10k tx per commit using a single thread during a vacuum = 1300 +updates/sec + +100-200 updates/sec is a small price to pay for mature stored procedures, +more stored procedure language options, acid compliance, mvcc, very few if +any corrupt tables(get about 2 a week from MySQL on the 40 DBs I manage), +more crash resistant db(crash about once a month on one of my 40 MySQL dbs), +and replication that actually works for more than a day before quitting for +no apparent reason ;) [/flame off] + +For those of you with Cox Communications cable modems look forward to better +customer service and cable plant management. :) + +And if anyone's curious here's the app I'm rebuilding/updating +http://www.mysql.com/customers/customer.php?id=16 +We won runner up behind Saabre airline reservation system for MySQL app of +the year. Needless to say they weren't too happy when they heard we might +be switching DBs. + +'njoy, +Mark + +On 8/19/05 1:12 PM, "J. Andrew Rogers" wrote: + +> On 8/19/05 1:24 AM, "Mark Cotner" wrote: +>> I'm currently working on an application that will poll +>> thousands of cable modems per minute and I would like +>> to use PostgreSQL to maintain state between polls of +>> each device. This requires a very heavy amount of +>> updates in place on a reasonably large table(100k-500k +>> rows, ~7 columns mostly integers/bigint). Each row +>> will be refreshed every 15 minutes, or at least that's +>> how fast I can poll via SNMP. I hope I can tune the +>> DB to keep up. +>> +>> The app is threaded and will likely have well over 100 +>> concurrent db connections. Temp tables for storage +>> aren't a preferred option since this is designed to be +>> a shared nothing approach and I will likely have +>> several polling processes. +> +> +> Mark, +> +> We have PostgreSQL databases on modest hardware doing exactly what you are +> attempting to (massive scalable SNMP monitoring system). The monitoring +> volume for a single database server appears to exceed what you are trying to +> do by a few orders of magnitude with no scaling or performance issues, so I +> can state without reservation that PostgreSQL can easily handle your +> application in theory. +> +> However, that is predicated on having a well-architected system that +> minimizes resource contention and unnecessary blocking, and based on your +> description you may be going about it a bit wrong. +> +> The biggest obvious bottleneck is the use of threads and massive +> process-level parallelization. As others have pointed out, async queues are +> your friends, as is partitioning the workload horizontally rather than +> vertically through the app stack. A very scalable high-throughput engine +> for SNMP polling only requires two or three threads handling different parts +> of the workload to saturate the network, and by choosing what each thread +> does carefully you can all but eliminate blocking when there is work to be +> done. +> +> We only use a single database connection to insert all the data into +> PostgreSQL, and that process/thread receives its data from a work queue. +> Depending on how you design your system, you can batch many records in your +> queue as a single transaction. In our case, we also use very few updates, +> mostly just inserts, which is probably advantageous in terms of throughput +> if you have the disk for it. The insert I/O load is easily handled, and our +> disk array is a modest 10k SCSI rig. The only thing that really hammers the +> server is when multiple reporting processes are running, which frequently +> touch several million rows each (the database is much larger than the system +> memory), and even this is manageable with clever database design. +> +> +> In short, what you are trying to do is easily doable on PostgreSQL in +> theory. However, restrictions on design choices may pose significant +> hurdles. We did not start out with an ideal system either; it took a fair +> amount of re-engineering to solve all the bottlenecks and problems that pop +> up. +> +> Good luck, +> +> J. Andrew Rogers +> jrogers@neopolitan.com +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + + + +From pgsql-performance-owner@postgresql.org Mon Aug 22 10:28:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EB976D6EA7 + for ; + Mon, 22 Aug 2005 10:15:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28144-01 + for ; + Mon, 22 Aug 2005 13:15:08 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id D71B9D6E91 + for ; + Mon, 22 Aug 2005 10:15:06 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Finding bottleneck +Date: Mon, 22 Aug 2005 09:15:10 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD15D@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Finding bottleneck +Thread-Index: AcWkxr5EndVUITMSSs6KP/tRXihkJAAF32MAAI8Vy3A= +From: "Merlin Moncure" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/317 +X-Sequence-Number: 14064 + +> Bill of Materials Traversal ( ~ 62k records). +>=20 +> ISAM* pg 8.0 pg 8.1 devel delta 8.0->8.1 +> running time 63 sec 90 secs 71 secs 21% +> cpu load 17% 45% 32% 29% +> loadsecs** 10.71 40.5 22.72 44% +> recs/sec 984 688 873 +> recs/loadsec 5882 1530 2728 +>=20 +> *ISAM is an anonymous commercial ISAM library in an optimized server +> architecture (pg smokes the non-optimized flat file version). +> **Loadsecs being seconds of CPU at 100% load. + +One thing that might interest you is that the penalty in 8.1 for +stats_command_string=3Dtrue in this type of access pattern is very high: = +I +was experimenting to see if the new cpu efficiency gave me enough of a +budget to start using this. This more than doubled the cpu load to +around 70% with a runtime of 82 seconds. This is actually worse than +8.0 :(. + +This *might* be a somewhat win32 specific issue. I've had issues with +the stats collector before. Anyways, the feature is a frill so it's not +a big deal. + +Merlin + + + +From pgsql-performance-owner@postgresql.org Mon Aug 22 11:06:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 55327D6E69 + for ; + Mon, 22 Aug 2005 10:47:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27253-01 + for ; + Mon, 22 Aug 2005 13:47:35 +0000 (GMT) +Received: from hotmail.com (bay101-f3.bay101.hotmail.com [64.4.56.13]) + by svr1.postgresql.org (Postfix) with ESMTP id 17564D6E5B + for ; + Mon, 22 Aug 2005 10:47:34 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 22 Aug 2005 06:47:38 -0700 +Message-ID: +Received: from 64.4.56.200 by by101fd.bay101.hotmail.msn.com with HTTP; + Mon, 22 Aug 2005 13:47:38 GMT +X-Originating-IP: [64.4.56.200] +X-Originating-Email: [jigneshk@hotmail.com] +X-Sender: jigneshk@hotmail.com +From: "Jignesh Shah" +To: pgsql-performance@postgresql.org +Subject: MemoryContextSwitchTo during table scan? +Date: Mon, 22 Aug 2005 09:47:38 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +X-OriginalArrivalTime: 22 Aug 2005 13:47:38.0983 (UTC) + FILETIME=[0F71B770:01C5A720] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=3.582 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374, + DNS_FROM_RFC_POST=1.376, MSGID_FROM_MTA_HEADER=0, + RCVD_IN_BL_SPAMCOP_NET=1.832] +X-Spam-Level: *** +X-Archive-Number: 200508/318 +X-Sequence-Number: 14065 + + +Hello, + +I am running PostgreSQL 8.0.x on Solaris 10 AMD64. My Tablesize for this +test is about 80G. When I run a query on a column which is not indexed, I +get a full table scan query and that's what I am testing right now. (I am +artificially creating that scenario to improve that corner case). Aparently +I find that the full query is running much slower compared to what hardware +can support and hence dug into DTrace to figure out where it is spending +most of its time. + +Running a script (available on my blog) I find the following top 5 functions +where it spends most time during a 10 second run of the script +
+                                                    Time in (millisec)       
+    Call Count
+MemoryContextSwitchTo                   775                           106564
+LockBuffer                                        707                        
+    109367
+LWLockAcquire                                 440                            
+  58888
+ExecEvalConst                                  418                           
+    53282
+ResourceOwnerRememberBuffer      400                              54684
+TransactionIdFollowsOrEquals           392                              
+53281
+
+
+ +While the times look pretty small (0.775 second out of 10seconds which is +about 7.75%), it still represents significant time since the table is pretty +big and the entire scan takes about 30 minute (about 80G big table). +Considering it is a single threaded single process scan all the hits of the +function calls itself can delay the performance. + +MemoryContextSwitchTo and LockBuffer itself takes 15% of the total time of +the query. I was expecting "read" to be the slowest part (biggest component) +but it was way down in the 0.4% level. + +Now the question is why there are so many calls to MemoryContextSwitchTo in +a single SELECT query command? Can it be minimized? + +Also is there any way to optimize LockBuffer? + +Is there anything else that can minimize the time spent in these calls +itself? (Of course it is the first iteration but something else will be the +bottleneck... but that's the goal). + +If there are any hackers interested in tackling this problem let me know. + +Thanks. +Regards, +Jignesh + + + +From pgsql-performance-owner@postgresql.org Mon Aug 22 11:50:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 52BCBD7019 + for ; + Mon, 22 Aug 2005 11:17:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93421-03 + for ; + Mon, 22 Aug 2005 14:17:50 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B7BAD7016 + for ; + Mon, 22 Aug 2005 11:17:48 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7MEHrLp015639; + Mon, 22 Aug 2005 10:17:53 -0400 (EDT) +To: "Merlin Moncure" +Cc: pgsql-performance@postgresql.org +Subject: Re: Finding bottleneck +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB3417DD15D@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD15D@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Mon, 22 Aug 2005 09:15:10 -0400" +Date: Mon, 22 Aug 2005 10:17:53 -0400 +Message-ID: <15638.1124720273@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/319 +X-Sequence-Number: 14066 + +"Merlin Moncure" writes: +> One thing that might interest you is that the penalty in 8.1 for +> stats_command_string=true in this type of access pattern is very high: I +> was experimenting to see if the new cpu efficiency gave me enough of a +> budget to start using this. This more than doubled the cpu load to +> around 70% with a runtime of 82 seconds. This is actually worse than +> 8.0 :(. + +That seems quite peculiar; AFAICS the pgstat code shouldn't be any +slower than before. At first I thought it might be because we'd +increased PGSTAT_ACTIVITY_SIZE, but actually that happened before +8.0 release, so it shouldn't be a factor in this comparison. + +Can anyone else confirm a larger penalty for stats_command_string in +HEAD than in 8.0? A self-contained test case would be nice too. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 22 13:18:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BB59D6EC0 + for ; + Mon, 22 Aug 2005 11:42:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60424-03 + for ; + Mon, 22 Aug 2005 14:42:42 +0000 (GMT) +Received: from penguin.goodinassociates.com (unknown [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id E10FED6E7E + for ; + Mon, 22 Aug 2005 11:42:41 -0300 (ADT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.13.1/8.12.11) with ESMTP id + j7MEgixx032272; Mon, 22 Aug 2005 09:42:44 -0500 +Subject: Re: extremly low memory usage +From: Jeremiah Jahn +To: Ron +Cc: postgres performance +In-Reply-To: <6.2.3.4.0.20050821112849.01f79860@pop.earthlink.net> +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <1124481386.27881.167.camel@bluejay.goodinassociates.com> + <43064908.7010505@arbash-meinel.com> + <1124564003.27881.229.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050820154422.06021150@pop.earthlink.net> + <4307E7A4.7090300@arbash-meinel.com> + <1124636066.27881.238.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050821112849.01f79860@pop.earthlink.net> +Content-Type: text/plain +Date: Mon, 22 Aug 2005 09:42:43 -0500 +Message-Id: <1124721763.27881.250.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.2 (2.2.2-5) +Content-Transfer-Encoding: 7bit +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: ClamAV 0.86.1/1034/Thu Aug 18 15:07:58 2005 on + penguin.goodinassociates.com +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.034 required=5 tests=[AWL=-0.016, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/321 +X-Sequence-Number: 14068 + +On Sun, 2005-08-21 at 16:13 -0400, Ron wrote: +> At 10:54 AM 8/21/2005, Jeremiah Jahn wrote: +> >On Sat, 2005-08-20 at 21:32 -0500, John A Meinel wrote: +> > > Ron wrote: +> > > +> > > Well, since you can get a read of the RAID at 150MB/s, that means that +> > > it is actual I/O speed. It may not be cached in RAM. Perhaps you could +> > > try the same test, only using say 1G, which should be cached. +> > +> >[root@io pgsql]# time dd if=/dev/zero of=testfile bs=1024 count=1000000 +> >1000000+0 records in +> >1000000+0 records out +> > +> >real 0m8.885s +> >user 0m0.299s +> >sys 0m6.998s +> +> This is abysmally slow. +> +> +> >[root@io pgsql]# time dd of=/dev/null if=testfile bs=1024 count=1000000 +> >1000000+0 records in +> >1000000+0 records out +> > +> >real 0m1.654s +> >user 0m0.232s +> >sys 0m1.415s +> +> This transfer rate is the only one out of the 4 you have posted that +> is in the vicinity of where it should be. +> +> +> >The raid array I have is currently set up to use a single channel. But I +> >have dual controllers in the array. And dual external slots on the card. +> >The machine is brand new and has pci-e backplane. +> > +> So you have 2 controllers each with 2 external slots? But you are +> currently only using 1 controller and only one external slot on that +> controller? + +Sorry, no. I have one dual channel card in the system and two +controllers on the array. Dell PowerVault 220S w/ PERC4eDC-PCI Express + +> +> +> > > > Assuming these are U320 15Krpm 147GB HDs, a RAID 10 array of 14 of them +> > > > doing raw sequential IO like this should be capable of at +> > > > ~7*75MB/s= 525MB/s using Seagate Cheetah 15K.4's +> >BTW I'm using Seagate Cheetah 15K.4's +> +> OK, now we have that nailed down. +> +> +> > > > AFAICT, the Dell PERC4 controllers use various flavors of the LSI Logic +> > > > MegaRAID controllers. What I don't know is which exact one yours is, +> > > > nor do I know if it (or any of the MegaRAID controllers) are high +> > > > powered enough. +> > +> >PERC4eDC-PCI Express, 128MB Cache, 2-External Channels +> +> Looks like they are using the LSI Logic MegaRAID SCSI 320-2E +> controller. IIUC, you have 2 of these, each with 2 external channels? +> +> The specs on these appear a bit strange. They are listed as being a +> PCI-Ex8 card, which means they should have a max bandwidth of 20Gb/s= +> 2GB/s, yet they are also listed as only supporting dual channel U320= +> 640MB/s when they could easily support quad channel U320= +> 1.28GB/s. Why bother building a PCI-Ex8 card when only a PCI-Ex4 +> card (which is a more standard physical format) would've been +> enough? Or if you are going to build a PCI-Ex8 card, why not support +> quad channel U320? This smells like there's a problem with LSI's design. +> +> The 128MB buffer also looks suspiciously small, and I do not see any +> upgrade path for it on LSI Logic's site. "Serious" RAID controllers +> from companies like Xyratex, Engino, and Dot-hill can have up to +> 1-2GB of buffer, and there's sound technical reasons for it. See if +> there's a buffer upgrade available or if you can get controllers that +> have larger buffer capabilities. +> +> Regardless of the above, each of these controllers should still be +> good for about 80-85% of 640MB/s, or ~510-540 MB/s apiece when doing +> raw sequential IO if you plug 3-4 fast enough HD's into each SCSI +> channel. Cheetah 15K.4's certainly are fast enough. Optimal setup +> is probably to split each RAID 1 pair so that one HD is on each of +> the SCSI channels, and then RAID 0 those pairs. That will also +> protect you from losing the entire disk subsystem if one of the SCSI +> channels dies. +I like this idea, but how exactly does one bond the two channels +together? Won't this cause me to have both an /dev/sdb and an /dev/sdc? + + +> +> That 128MB of buffer cache may very well be too small to keep the IO +> rate up, and/or there may be a more subtle problem with the LSI card, +> and/or you may have a configuration problem, but _something(s)_ need +> fixing since you are only getting raw sequential IO of ~100-150MB/s +> when it should be above 500MB/s. + +It looks like there's a way to add more memory to it. + +> +> This will make the most difference for initial reads (first time you +> load a table, first time you make a given query, etc) and for any writes. +> +> Your HW provider should be able to help you, even if some of the HW +> in question needs to be changed. You paid for a solution. As long +> as this stuff is performing at so much less then what it is supposed +> to, you have not received the solution you paid for. +> +> BTW, on the subject of RAID stripes IME the sweet spot tends to be in +> the 64KB to 256KB range (very large, very read heavy data mines can +> want larger RAID stripes.). Only experimentation will tell you what +> results in the best performance for your application. +I think I have them very small at the moment. + +> +> +> >I'm not really worried about the writing, it's the reading the reading +> >that needs to be faster. +> +> Initial reads are only going to be as fast as your HD subsystem, so +> there's a reason for making the HD subsystem faster even if all you +> care about is reads. In addition, I'll repeat my previous advice +> that upgrading to 16GB of RAM would be well worth it for you. + +12GB is my max. I may run with it for a while and see. + +> +> Hope this helps, +> Ron Peacetree +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +-- +Speak softly and carry a +6 two-handed sword. + + +From pgsql-performance-owner@postgresql.org Mon Aug 22 12:33:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A70C4D6EC0 + for ; + Mon, 22 Aug 2005 12:07:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83816-09 + for ; + Mon, 22 Aug 2005 15:07:50 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B71AD6D71 + for ; + Mon, 22 Aug 2005 12:07:49 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id DCDB330B42; Mon, 22 Aug 2005 17:19:42 +0200 (MET DST) +From: William Yu +X-Newsgroups: pgsql.performance +Subject: Re: extremly low memory usage +Date: Mon, 22 Aug 2005 08:07:36 -0700 +Organization: Hub.Org Networking Services +Lines: 89 +Message-ID: +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <1124481386.27881.167.camel@bluejay.goodinassociates.com> + <43064908.7010505@arbash-meinel.com> + <1124564003.27881.229.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050820154422.06021150@pop.earthlink.net> + <4307E7A4.7090300@arbash-meinel.com> + <1124636066.27881.238.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050821112849.01f79860@pop.earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +In-Reply-To: <6.2.3.4.0.20050821112849.01f79860@pop.earthlink.net> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.017 required=5 tests=[AWL=0.017] +X-Spam-Level: +X-Archive-Number: 200508/320 +X-Sequence-Number: 14067 + +Ron wrote: +>> PERC4eDC-PCI Express, 128MB Cache, 2-External Channels +> +> Looks like they are using the LSI Logic MegaRAID SCSI 320-2E +> controller. IIUC, you have 2 of these, each with 2 external channels? + +A lot of people have mentioned Dell's versions of the LSI cards can be +WAY slower than the ones you buy from LSI. Why this is the case? Nobody +knows for sure. + +Here's a guess on my part. A while back, I was doing some googling. And +instead of typing "LSI MegaRAID xxx", I just typed "MegaRAID xxx". Going +beyond the initial pages, I saw Tekram -- a company that supposedly +produces their own controllers -- listing products with the exact model +numbers and photos as cards from LSI and Areca. Seemed puzzling until I +read a review about SATA RAID cards where it mentioned Tekram produces +the Areca cards under their own name but using slower components to +avoid competing at the highend with them. + +So what may be happening is that the logic circuitry on the Dell PERCs +are the same as the source LSI cards, the speed of the RAID +processor/RAM/internal buffers/etc is not as fast so Dell can shave off +a few bucks for every server. That would mean while a true LSI card has +the processing power to do the RAID calculates for X drives, the Dell +version probably can only do X*0.6 drives or so. + + +> The 128MB buffer also looks suspiciously small, and I do not see any +> upgrade path for it on LSI Logic's site. "Serious" RAID controllers +> from companies like Xyratex, Engino, and Dot-hill can have up to 1-2GB + +The card is upgradable. If you look at the pic of the card, it shows a +SDRAM DIMM versus integrated RAM chips. I've also read reviews a while +back comparing benchmarks of the 320-2 w/ 128K versus 512K onboard RAM. +Their product literature is just nebulous on the RAM upgrade part. I'm +sure if you opened up the PDF manuals, you could find the exact info + + +> That 128MB of buffer cache may very well be too small to keep the IO +> rate up, and/or there may be a more subtle problem with the LSI card, +> and/or you may have a configuration problem, but _something(s)_ need +> fixing since you are only getting raw sequential IO of ~100-150MB/s when +> it should be above 500MB/s. + +I think it just might be the Dell hardware or the lack of 64-bit IOMMU +on Xeon's. Here's my numbers on 320-1 w/ 128K paired up with Opterons +compared to Jeremiah's. + + >> # time dd if=/dev/zero of=testfile bs=1024 count=1000000 + >> 1000000+0 records in + >> 1000000+0 records out + >> + >> real 0m8.885s + >> user 0m0.299s + >> sys 0m6.998s + +2x15K RAID1 +real 0m14.493s +user 0m0.255s +sys 0m11.712s + +6x15K RAID10 (2x 320-1) +real 0m9.986s +user 0m0.200s +sys 0m8.634s + + + >> # time dd of=/dev/null if=testfile bs=1024 count=1000000 + >> 1000000+0 records in + >> 1000000+0 records out + >> + >> real 0m1.654s + >> user 0m0.232s + >> sys 0m1.415s + +2x15K RAID1 +real 0m3.383s +user 0m0.176s +sys 0m3.207s + +6x15K RAID10 (2x 320-1) +real 0m2.427s +user 0m0.178s +sys 0m2.250s + +If all 14 HDs are arranged in a RAID10 array, I'd say there's definitely +something wrong with Jeremiah's hardware. + + + +From pgsql-performance-owner@postgresql.org Mon Aug 22 14:26:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 96BE9D6D71 + for ; + Mon, 22 Aug 2005 12:43:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69655-02 + for ; + Mon, 22 Aug 2005 15:42:58 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 17292D70A5 + for ; + Mon, 22 Aug 2005 12:42:57 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7MFfeCY016260; + Mon, 22 Aug 2005 11:41:40 -0400 (EDT) +To: "Jignesh Shah" +Cc: pgsql-performance@postgresql.org +Subject: Re: MemoryContextSwitchTo during table scan? +In-reply-to: +References: +Comments: In-reply-to "Jignesh Shah" + message dated "Mon, 22 Aug 2005 09:47:38 -0400" +Date: Mon, 22 Aug 2005 11:41:40 -0400 +Message-ID: <16259.1124725300@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/322 +X-Sequence-Number: 14069 + +"Jignesh Shah" writes: +> Running a script (available on my blog) I find the following top 5 functions +> where it spends most time during a 10 second run of the script + +It's pretty risky to draw conclusions from only 10 seconds' worth of +gprof data --- that's only 1000 samples total at the common sampling +rate of 100/sec. If there's one function eating 90% of the runtime, +you'll find out, but you don't have enough data to believe that you +know what is happening with resolution of a percent or so. I generally +try to accumulate several minutes worth of CPU time in a gprof run. + +> MemoryContextSwitchTo and LockBuffer itself takes 15% of the total time of +> the query. I was expecting "read" to be the slowest part (biggest component) +> but it was way down in the 0.4% level. + +You do know that gprof counts only CPU time, and only user-space CPU +time at that? read() isn't going to show up at all. It's fairly likely +that your test case is I/O bound and that worrying about CPU efficiency +for it is a waste of time anyway. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 22 15:19:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 96989D701C + for ; + Mon, 22 Aug 2005 14:18:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77125-01 + for ; + Mon, 22 Aug 2005 17:18:30 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FAB3D70E7 + for ; + Mon, 22 Aug 2005 14:18:29 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Finding bottleneck +Date: Mon, 22 Aug 2005 13:18:28 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD167@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Finding bottleneck +Thread-Index: AcWnJEqjyZRHA1Q8SpqfQYHxLxmIfAAFyH0g +From: "Merlin Moncure" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/324 +X-Sequence-Number: 14071 + +> That seems quite peculiar; AFAICS the pgstat code shouldn't be any +> slower than before. At first I thought it might be because we'd +> increased PGSTAT_ACTIVITY_SIZE, but actually that happened before +> 8.0 release, so it shouldn't be a factor in this comparison. + +Just FYI the last time I looked at stats was in the 8.0 beta period. +=20 +> Can anyone else confirm a larger penalty for stats_command_string in +> HEAD than in 8.0? A self-contained test case would be nice too. + +looking into it. + +Merlin + + + +From pgsql-performance-owner@postgresql.org Mon Aug 22 15:03:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DBC4D70A9 + for ; + Mon, 22 Aug 2005 14:46:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15349-05 + for ; + Mon, 22 Aug 2005 17:46:46 +0000 (GMT) +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F32DD70A8 + for ; + Mon, 22 Aug 2005 14:46:44 -0300 (ADT) +Received: from 172.16.1.118 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Mon, 22 Aug 2005 13:46:35 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.174]) by + d01smtp03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 22 Aug + 2005 13:46:34 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.104]) with Microsoft Exchange Server HTTP-DAV ; Mon, 22 Aug + 2005 13:46:33 -0500 +User-Agent: Microsoft-Entourage/11.1.0.040913 +Date: Mon, 22 Aug 2005 10:46:33 -0700 +Subject: Re: MemoryContextSwitchTo during table scan? +From: "Luke Lonergan" +To: "Tom Lane" , + "Jignesh Shah" +Cc: pgsql-performance@postgresql.org +Message-ID: +In-Reply-To: <16259.1124725300@sss.pgh.pa.us> +MIME-Version: 1.0 +X-OriginalArrivalTime: 22 Aug 2005 17:46:34.0048 (UTC) + FILETIME=[6FCF0C00:01C5A741] +X-WSS-ID: 6F14D0F12TG9840475-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.575 required=5 tests=[AWL=-0.006, + FORGED_RCVD_HELO=0.05, RCVD_NUMERIC_HELO=1.531] +X-Spam-Level: * +X-Archive-Number: 200508/323 +X-Sequence-Number: 14070 + +Tom, + +On 8/22/05 8:41 AM, "Tom Lane" wrote: + +>> MemoryContextSwitchTo and LockBuffer itself takes 15% of the total time of +>> the query. I was expecting "read" to be the slowest part (biggest component) +>> but it was way down in the 0.4% level. +> +> You do know that gprof counts only CPU time, and only user-space CPU +> time at that? read() isn't going to show up at all. It's fairly likely +> that your test case is I/O bound and that worrying about CPU efficiency +> for it is a waste of time anyway. + +He's running DTRACE, a CPU profiler that uses hardware performance +registers, not gprof. BTW, if you statically link your app, you get +profiling information for system calls with gprof. + +Jignesh has been analyzing PG for quite a while, there are definite issues +with CPU consuming functions in the data path IMO. This result he reported +is one of them on Solaris 10, and possibly on other platforms. + +We are limited to about 130MB/s of I/O throughput for sequential scan on +platforms that can do 240MB/s of sequential 8k block I/O. Though I haven't +profiled seqscan, I'd look at Jignesh's results carefully because they +correlate with our experience. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Mon Aug 22 15:58:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C4145D7231 + for ; + Mon, 22 Aug 2005 15:21:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86567-06 + for ; + Mon, 22 Aug 2005 18:21:42 +0000 (GMT) +Received: from calvin.surfutopia.net (calvin.surfutopia.net [67.120.245.34]) + by svr1.postgresql.org (Postfix) with ESMTP id EF04FD727F + for ; + Mon, 22 Aug 2005 15:21:40 -0300 (ADT) +Received: by calvin.surfutopia.net (Postfix, from userid 1000) + id 83B08F237; Mon, 22 Aug 2005 11:21:38 -0700 (PDT) +Date: Mon, 22 Aug 2005 11:21:38 -0700 +From: John Mendenhall +To: pgsql-performance list +Subject: Re: complex query performance assistance request +Message-ID: <20050822182138.GA30818@calvin.surfutopia.net> +References: <20050821034841.GA28968@calvin.surfutopia.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050821034841.GA28968@calvin.surfutopia.net> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/325 +X-Sequence-Number: 14072 + +On Sat, 20 Aug 2005, John Mendenhall wrote: + +> I need to improve the performance for the following +> query. + +I have run the same query in the same database under +different schemas. Each schema is pretty much the same +tables and indices. One has an extra backup table and +an extra index which are not used in either of the explain +analyze plans. + +The first schema is a development schema, which I used +to performance tune the server so everything was great. + +Here are the current results of the sql run in the development +environment: + +----- +LOG: duration: 852.275 ms statement: explain analyze +SELECT + c.id AS contact_id, + sr.id AS sales_rep_id, + p.id AS partner_id, + coalesce(LTRIM(RTRIM(c.company)), LTRIM(RTRIM(c.firstname || ' ' || c.lastname))) AS contact_company, + co.name AS contact_country, + c.master_key_token +FROM + sales_reps sr + JOIN partners p ON (sr.id = p.sales_rep_id) + JOIN contacts c ON (p.id = c.partner_id) + JOIN countries co ON (LOWER(c.country) = LOWER(co.code)) + JOIN partner_classification pc ON (p.classification_id = pc.id AND pc.classification != 'Sales Rep') +WHERE + c.lead_deleted IS NULL + AND EXISTS + ( + SELECT + lr.id + FROM + lead_requests lr, + lead_request_status lrs + WHERE + c.id = lr.contact_id AND + lr.status_id = lrs.id AND + lrs.is_closed = 0 + ) +ORDER BY + contact_company, contact_id + QUERY PLAN + +-------------------------------------------------------------------------------------------------------------------------------- +--------------------------------------------------------------------------------- + Sort (cost=18238.25..18238.27 rows=11 width=102) (actual time=823.721..823.915 rows=247 loops=1) + Sort Key: COALESCE(ltrim(rtrim((c.company)::text)), ltrim(rtrim((((c.firstname)::text || ' '::text) || (c.lastname)::text)))), c.id + -> Hash Join (cost=18230.34..18238.06 rows=11 width=102) (actual time=808.042..818.427 rows=247 loops=1) + Hash Cond: (lower(("outer".code)::text) = lower(("inner".country)::text)) + -> Seq Scan on countries co (cost=0.00..4.42 rows=242 width=19) (actual time=0.032..1.208 rows=242 loops=1) + -> Hash (cost=18230.31..18230.31 rows=9 width=95) (actual time=807.554..807.554 rows=0 loops=1) + -> Merge Join (cost=18229.98..18230.31 rows=9 width=95) (actual time=794.413..804.855 rows=247 loops=1) + Merge Cond: ("outer".sales_rep_id = "inner".id) + -> Sort (cost=18227.56..18227.59 rows=9 width=95) (actual time=793.132..793.502 rows=250 loops=1) + Sort Key: p.sales_rep_id + -> Merge Join (cost=18227.26..18227.42 rows=9 width=95) (actual time=782.832..789.205 rows=250 loops=1) + Merge Cond: ("outer".id = "inner".classification_id) + -> Sort (cost=1.05..1.05 rows=2 width=10) (actual time=0.189..0.194 rows=2 loops=1) + Sort Key: pc.id + -> Seq Scan on partner_classification pc (cost=0.00..1.04 rows=2 width=10) (actual time=0.089..0.127 rows=2 loops=1) + Filter: ((classification)::text <> 'Sales Rep'::text) + -> Sort (cost=18226.21..18226.24 rows=13 width=105) (actual time=782.525..782.818 rows=251 loops=1) + Sort Key: p.classification_id + -> Merge Join (cost=0.00..18225.97 rows=13 width=105) (actual time=54.135..776.299 rows=449 loops=1) + Merge Cond: ("outer".id = "inner".partner_id) + -> Index Scan using partners_pkey on partners p (cost=0.00..30.80 rows=395 width=30) (actual time=0.073..6.873 rows=395 loops=1) + -> Index Scan using contacts_partner_id_idx on contacts c (cost=0.00..130157.20 rows=93 width=85) (actual time=0.366..739.783 rows=453 loops=1) + Filter: ((lead_deleted IS NULL) AND (subplan)) + SubPlan + -> Nested Loop (cost=0.00..6.75 rows=2 width=10) (actual time=0.103..0.103 rows=0 loops=5576) + Join Filter: ("outer".status_id = "inner".id) + -> Index Scan using lead_requests_contact_id_idx on lead_requests lr (cost=0.00..4.23 rows=2 width=20) (actual time=0.075..0.075 rows=0 loops=5576) + Index Cond: ($0 = contact_id) + -> Seq Scan on lead_request_status lrs (cost=0.00..1.16 rows=8 width=10) (actual time=0.028..0.098 rows=4 loops=522) + Filter: (is_closed = 0::numeric) + -> Sort (cost=2.42..2.52 rows=39 width=10) (actual time=1.183..1.569 rows=268 loops=1) + Sort Key: sr.id + -> Seq Scan on sales_reps sr (cost=0.00..1.39 rows=39 width=10) (actual time=0.056..0.353 rows=39 loops=1) + Total runtime: 826.425 ms +(34 rows) +----- + +Here is the current run in the production environment, +which I need to figure out how to get to the performance +level of the development environment: + +----- +LOG: duration: 6447.934 ms statement: explain analyze +SELECT + c.id AS contact_id, + sr.id AS sales_rep_id, + p.id AS partner_id, + coalesce(LTRIM(RTRIM(c.company)), LTRIM(RTRIM(c.firstname || ' ' || c.lastname))) AS contact_company, + co.name AS contact_country, + c.master_key_token +FROM + sales_reps sr + JOIN partners p ON (sr.id = p.sales_rep_id) + JOIN contacts c ON (p.id = c.partner_id) + JOIN countries co ON (LOWER(c.country) = LOWER(co.code)) + JOIN partner_classification pc ON (p.classification_id = pc.id AND pc.classification != 'Sales Rep') +WHERE + c.lead_deleted IS NULL + AND EXISTS + ( + SELECT + lr.id + FROM + lead_requests lr, + lead_request_status lrs + WHERE + c.id = lr.contact_id AND + lr.status_id = lrs.id AND + lrs.is_closed = 0 + ) +ORDER BY + contact_company, contact_id + QUERY PLAN + +-------------------------------------------------------------------------------------------------------------------------------- +---------------------------------------------------------- + Sort (cost=40838.98..40849.08 rows=4042 width=102) (actual time=6418.732..6419.536 rows=1071 loops=1) + Sort Key: COALESCE(ltrim(rtrim((c.company)::text)), ltrim(rtrim((((c.firstname)::text || ' '::text) || (c.lastname)::text)))), c.id + -> Merge Join (cost=40442.25..40596.85 rows=4042 width=102) (actual time=6357.161..6389.616 rows=1071 loops=1) + Merge Cond: ("outer"."?column3?" = "inner"."?column9?") + -> Sort (cost=14.00..14.61 rows=242 width=19) (actual time=9.753..10.018 rows=240 loops=1) + Sort Key: lower((co.code)::text) + -> Seq Scan on countries co (cost=0.00..4.42 rows=242 width=19) (actual time=0.126..3.950 rows=242 loops=1) + -> Sort (cost=40428.24..40436.59 rows=3340 width=95) (actual time=6347.154..6348.429 rows=1071 loops=1) + Sort Key: lower((c.country)::text) + -> Merge Join (cost=75.65..40232.76 rows=3340 width=95) (actual time=60.308..6331.266 rows=1071 loops=1) + Merge Cond: ("outer".partner_id = "inner".id) + -> Index Scan using contacts_partner_id_idx on contacts c (cost=0.00..161018.18 rows=20120 width=85) (actual time=2.769..6188.886 rows=1548 loops=1) + Filter: ((lead_deleted IS NULL) AND (subplan)) + SubPlan + -> Nested Loop (cost=1.16..6.57 rows=2 width=10) (actual time=0.129..0.129 rows=0 loops=40262) + Join Filter: ("outer".status_id = "inner".id) + -> Index Scan using lead_requests_contact_id_idx on lead_requests lr (cost=0.00..4.86 rows=3 width=20) (actual time=0.086..0.092 rows=0 loops=40262) + Index Cond: ($0 = contact_id) + -> Materialize (cost=1.16..1.24 rows=8 width=10) (actual time=0.002..0.013 rows=6 loops=12593) + -> Seq Scan on lead_request_status lrs (cost=0.00..1.16 rows=8 width=10) (actual time=0.078..0.243 rows=7 loops=1) + Filter: (is_closed = 0::numeric) + -> Sort (cost=75.65..76.37 rows=290 width=20) (actual time=57.243..59.574 rows=1334 loops=1) + Sort Key: p.id + -> Merge Join (cost=59.24..63.79 rows=290 width=20) (actual time=33.975..42.215 rows=395 loops=1) + Merge Cond: ("outer".id = "inner".sales_rep_id) + -> Sort (cost=2.42..2.52 rows=39 width=10) (actual time=1.206..1.285 rows=39 loops=1) + Sort Key: sr.id + -> Seq Scan on sales_reps sr (cost=0.00..1.39 rows=39 width=10) (actual time=0.028..0.365 rows=39 loops=1) + -> Sort (cost=56.82..57.55 rows=290 width=20) (actual time=32.566..33.254 rows=395 loops=1) + Sort Key: p.sales_rep_id + -> Nested Loop (cost=24.35..44.96 rows=290 width=20) (actual time=0.158..25.227 rows=395 loops=1) + Join Filter: ("inner".classification_id = "outer".id) + -> Seq Scan on partner_classification pc (cost=0.00..1.04 rows=2 width=10) (actual time=0.050..0.096 rows=2 loops=1) + Filter: ((classification)::text <> 'Sales Rep'::text) + -> Materialize (cost=24.35..28.70 rows=435 width=30) (actual time=0.028..6.617 rows=435 loops=2) + -> Seq Scan on partners p (cost=0.00..24.35 rows=435 width=30) (actual time=0.042..9.941 rows=435 loops=1) + Total runtime: 6423.683 ms +(37 rows) +----- + +The SQL is exactly the same. + +The issue is the query plan is different, and thus, +not up to the performance we need. + +We have 256meg in the machine. Would it help if +we threw some more memory in? + +Please let me know if you have *any* pointers as to +the reason for the difference. + +Thank you very much in advance for any pointers or +suggestions. + +JohnM + +-- +John Mendenhall +john@surfutopia.net +surf utopia +internet services + +From pgsql-performance-owner@postgresql.org Mon Aug 22 16:11:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AE64DD7253 + for ; + Mon, 22 Aug 2005 16:09:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47884-09 + for ; + Mon, 22 Aug 2005 19:09:46 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C922D70A8 + for ; + Mon, 22 Aug 2005 16:09:45 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [67.103.45.218] (account josh@agliodbs.com HELO [10.0.0.38]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7907752; Mon, 22 Aug 2005 12:12:02 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: MemoryContextSwitchTo during table scan? +Date: Mon, 22 Aug 2005 12:12:56 -0700 +User-Agent: KMail/1.8 +Cc: "Jignesh Shah" +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508221212.57047.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[AWL=0.000] +X-Spam-Level: +X-Archive-Number: 200508/326 +X-Sequence-Number: 14073 + +Jignesh, + +> Also is there any way to optimize LockBuffer? + +Yes, test on 8.1. The buffer manager was re-written for 8.1. You should +see a decrease in both LockBuffer and context switch activity. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Aug 22 18:13:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D0F62D7021 + for ; + Mon, 22 Aug 2005 17:15:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97803-06 + for ; + Mon, 22 Aug 2005 20:15:18 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C21C3D7761 + for ; + Mon, 22 Aug 2005 17:15:17 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7MKFICA020831; + Mon, 22 Aug 2005 16:15:18 -0400 (EDT) +To: John Mendenhall +Cc: pgsql-performance list +Subject: Re: complex query performance assistance request +In-reply-to: <20050822182138.GA30818@calvin.surfutopia.net> +References: <20050821034841.GA28968@calvin.surfutopia.net> + <20050822182138.GA30818@calvin.surfutopia.net> +Comments: In-reply-to John Mendenhall + message dated "Mon, 22 Aug 2005 11:21:38 -0700" +Date: Mon, 22 Aug 2005 16:15:18 -0400 +Message-ID: <20830.1124741718@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/327 +X-Sequence-Number: 14074 + +John Mendenhall writes: +> The issue is the query plan is different, and thus, +> not up to the performance we need. + +No, the issue is that you've got eight times as much data in the +production server; so it's hardly surprising that it takes about +eight times longer. + +The production query is spending most of its time on the subplan +attached to the contacts table: + +> -> Index Scan using contacts_partner_id_idx on contacts c (cost=0.00..161018.18 rows=20120 width=85) (actual time=2.769..6188.886 rows=1548 loops=1) +> Filter: ((lead_deleted IS NULL) AND (subplan)) +> SubPlan +> -> Nested Loop (cost=1.16..6.57 rows=2 width=10) (actual time=0.129..0.129 rows=0 loops=40262) + +0.129 * 40262 = 5193.798, so about five seconds in the subplan and +another one second in the indexscan proper. The problem is that the +subplan (the EXISTS clause) is iterated for each of 40262 rows of +contacts --- basically, every contacts row that has null lead_deleted. + +On the dev server the same scan shows these numbers: + +> -> Index Scan using contacts_partner_id_idx on contacts c (cost=0.00..130157.20 rows=93 width=85) (actual time=0.366..739.783 rows=453 loops=1) +> Filter: ((lead_deleted IS NULL) AND (subplan)) +> SubPlan +> -> Nested Loop (cost=0.00..6.75 rows=2 width=10) (actual time=0.103..0.103 rows=0 loops=5576) + +Here the subplan is iterated only 5576 times for 574 total msec. It's +still the bulk of the runtime though; the fact that the upper levels +of the plan are a bit different has got little to do with where the time +is going. + +I'd suggest trying to get rid of the EXISTS clause --- can you refactor +that into something that joins at the top query level? + +Or, if this is 7.4 or later (and you should ALWAYS mention which version +you are using in a performance question, because it matters), try to +convert the EXISTS into an IN. "x IN (subselect)" is planned much better +than "EXISTS(subselect-using-x)" these days. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 22 18:55:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69F91D7025 + for ; + Mon, 22 Aug 2005 18:08:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23027-05 + for ; + Mon, 22 Aug 2005 21:07:56 +0000 (GMT) +Received: from calvin.surfutopia.net (calvin.surfutopia.net [67.120.245.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 458ABD7018 + for ; + Mon, 22 Aug 2005 18:07:54 -0300 (ADT) +Received: by calvin.surfutopia.net (Postfix, from userid 1000) + id 71C7CF23B; Mon, 22 Aug 2005 14:07:51 -0700 (PDT) +Date: Mon, 22 Aug 2005 14:07:51 -0700 +From: John Mendenhall +To: Tom Lane +Cc: pgsql-performance list +Subject: Re: complex query performance assistance request +Message-ID: <20050822210751.GA32479@calvin.surfutopia.net> +References: <20050821034841.GA28968@calvin.surfutopia.net> + <20050822182138.GA30818@calvin.surfutopia.net> + <20830.1124741718@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20830.1124741718@sss.pgh.pa.us> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/328 +X-Sequence-Number: 14075 + +Tom, + +> No, the issue is that you've got eight times as much data in the +> production server; so it's hardly surprising that it takes about +> eight times longer. +> +> The production query is spending most of its time on the subplan +> attached to the contacts table: +> +> > -> Index Scan using contacts_partner_id_idx on contacts c (cost=0.00..161018.18 rows=20120 width=85) (actual time=2.769..6188.886 rows=1548 loops=1) +> > Filter: ((lead_deleted IS NULL) AND (subplan)) +> > SubPlan +> > -> Nested Loop (cost=1.16..6.57 rows=2 width=10) (actual time=0.129..0.129 rows=0 loops=40262) +> +> 0.129 * 40262 = 5193.798, so about five seconds in the subplan and +> another one second in the indexscan proper. The problem is that the +> subplan (the EXISTS clause) is iterated for each of 40262 rows of +> contacts --- basically, every contacts row that has null lead_deleted. +> +> On the dev server the same scan shows these numbers: +> +> > -> Index Scan using contacts_partner_id_idx on contacts c (cost=0.00..130157.20 rows=93 width=85) (actual time=0.366..739.783 rows=453 loops=1) +> > Filter: ((lead_deleted IS NULL) AND (subplan)) +> > SubPlan +> > -> Nested Loop (cost=0.00..6.75 rows=2 width=10) (actual time=0.103..0.103 rows=0 loops=5576) +> +> I'd suggest trying to get rid of the EXISTS clause --- can you refactor +> that into something that joins at the top query level? +> +> Or, if this is 7.4 or later (and you should ALWAYS mention which version +> you are using in a performance question, because it matters), try to +> convert the EXISTS into an IN. "x IN (subselect)" is planned much better +> than "EXISTS(subselect-using-x)" these days. + +We are using version 7.4.6. + +The number of contacts in the dev env is 37080. +The number of contacts in the production env is 40307. +The amount of data is statistically about the same. + +However, the number of lead_requests are much different. +The dev env has 1438 lead_requests, the production env +has 15554 lead_requests. Each contacts row can have +multiple lead_requests, each lead_requests entry can +have an open or closed status. We are trying to select +the contacts with an open lead_request. + +Would it be best to attempt to rewrite it for IN? +Or, should we try to tie it in with a join? I would +probably need to GROUP so I can just get a count of those +contacts with open lead_requests. Unless you know of a +better way? + +Thanks for your assistance. This is helping a lot. +BTW, what does the Materialize query plan element mean? + +Thanks again. + +JohnM + +-- +John Mendenhall +john@surfutopia.net +surf utopia +internet services + +From pgsql-performance-owner@postgresql.org Mon Aug 22 19:37:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BCE7FD6FEC + for ; + Mon, 22 Aug 2005 19:37:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70495-07 + for ; + Mon, 22 Aug 2005 22:37:24 +0000 (GMT) +Received: from hotmail.com (bay101-f22.bay101.hotmail.com [64.4.56.32]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E912D6D78 + for ; + Mon, 22 Aug 2005 19:37:22 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 22 Aug 2005 15:37:21 -0700 +Message-ID: +Received: from 64.4.56.205 by by101fd.bay101.hotmail.msn.com with HTTP; + Mon, 22 Aug 2005 22:37:21 GMT +X-Originating-IP: [64.4.56.205] +X-Originating-Email: [jigneshk@hotmail.com] +X-Sender: jigneshk@hotmail.com +In-Reply-To: <16259.1124725300@sss.pgh.pa.us> +From: "Jignesh Shah" +To: tgl@sss.pgh.pa.us +Cc: pgsql-performance@postgresql.org +Subject: Re: MemoryContextSwitchTo during table scan? +Date: Mon, 22 Aug 2005 18:37:21 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +X-OriginalArrivalTime: 22 Aug 2005 22:37:21.0434 (UTC) + FILETIME=[0F42DFA0:01C5A76A] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.228 required=5 tests=[AWL=0.478, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, + MSGID_FROM_MTA_HEADER=0] +X-Spam-Level: ** +X-Archive-Number: 200508/329 +X-Sequence-Number: 14076 + + +Hi Tom, + +Like I mentioned I am using DTrace on Solaris 10 x64 and not gprof. +DTrace is not based on sampling but actual entry/exit point. Ofcourse my 10 +second profile is just a sample that I can assure you is representative of +the query since it is a very simple query that does simple table scan. (I am +taken profiles at different times of the queries all giving similar outputs) + +In case of DTrace I am actually measuring "wall clock" for leaf functions. + +For more information on DTrace please refer to: +http://docs.sun.com/app/docs/doc/817-6223/6mlkidlf1?a=view + +Regards, +Jignesh + + +----Original Message Follows---- +From: Tom Lane +To: "Jignesh Shah" +CC: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] MemoryContextSwitchTo during table scan? +Date: Mon, 22 Aug 2005 11:41:40 -0400 + +"Jignesh Shah" writes: + > Running a script (available on my blog) I find the following top 5 +functions + > where it spends most time during a 10 second run of the script + +It's pretty risky to draw conclusions from only 10 seconds' worth of +gprof data --- that's only 1000 samples total at the common sampling +rate of 100/sec. If there's one function eating 90% of the runtime, +you'll find out, but you don't have enough data to believe that you +know what is happening with resolution of a percent or so. I generally +try to accumulate several minutes worth of CPU time in a gprof run. + + > MemoryContextSwitchTo and LockBuffer itself takes 15% of the total time +of + > the query. I was expecting "read" to be the slowest part (biggest +component) + > but it was way down in the 0.4% level. + +You do know that gprof counts only CPU time, and only user-space CPU +time at that? read() isn't going to show up at all. It's fairly likely +that your test case is I/O bound and that worrying about CPU efficiency +for it is a waste of time anyway. + + regards, tom lane + + + +From pgsql-performance-owner@postgresql.org Mon Aug 22 21:10:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E749AD6D78 + for ; + Mon, 22 Aug 2005 19:48:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78049-09 + for ; + Mon, 22 Aug 2005 22:48:21 +0000 (GMT) +Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 55F7BD70B4 + for ; + Mon, 22 Aug 2005 19:48:19 -0300 (ADT) +Received: from localhost (mailbox.samurai.com [205.207.28.82]) + by mailbox.samurai.com (Postfix) with ESMTP id 592332395A6; + Mon, 22 Aug 2005 18:48:22 -0400 (EDT) +Received: from mailbox.samurai.com ([205.207.28.82]) + by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, + port 10024) + with LMTP id 50302-01-8; Mon, 22 Aug 2005 18:48:20 -0400 (EDT) +Received: from [192.168.0.105] + (CPE3285f62f0d42-CM0011aec5ebbc.cpe.net.cable.rogers.com + [69.199.116.160]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mailbox.samurai.com (Postfix) with ESMTP id B24AC2395B6; + Mon, 22 Aug 2005 18:48:20 -0400 (EDT) +Message-ID: <430A5632.10701@samurai.com> +Date: Mon, 22 Aug 2005 18:48:18 -0400 +From: Neil Conway +User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jignesh Shah +Cc: pgsql-performance@postgresql.org +Subject: Re: MemoryContextSwitchTo during table scan? +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/330 +X-Sequence-Number: 14077 + +Jignesh Shah wrote: +> Now the question is why there are so many calls to MemoryContextSwitchTo +> in a single SELECT query command? Can it be minimized? + +I agree with Tom -- if profiling indicates that MemoryContextSwitchTo() +is the bottleneck, I would be suspicious that your profiling setup is +misconfigured. MemoryContextSwitchTo() is essentially a function call, +two pointer assignments, and a function return. Try rerunning the test +with current sources -- MemoryContextSwitchTo() is now inlined when +using GCC, which should just leave the assignments. + +-Neil + +From pgsql-performance-owner@postgresql.org Mon Aug 22 21:43:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BCF2D7245 + for ; + Mon, 22 Aug 2005 21:43:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56040-07 + for ; + Tue, 23 Aug 2005 00:43:33 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 87111D7201 + for ; + Mon, 22 Aug 2005 21:43:32 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 09AE91529B; Mon, 22 Aug 2005 19:43:35 -0500 (CDT) +Date: Mon, 22 Aug 2005 19:43:35 -0500 +From: "Jim C. Nasby" +To: Sebastian Hennebrueder +Cc: postgres performance +Subject: Re: Looking for a large database for testing +Message-ID: <20050823004335.GG17203@pervasive.com> +References: <430195DC.70104@laliluna.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <430195DC.70104@laliluna.de> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/331 +X-Sequence-Number: 14078 + +On Tue, Aug 16, 2005 at 09:29:32AM +0200, Sebastian Hennebrueder wrote: +> Hello, +> +> I would like to test the performance of my Java/PostgreSQL applications +> especially when making full text searches. +> For this I am looking for a database with 50 to 300 MB having text fields. +> e.g. A table with books with fields holding a comment, table of content +> or example chapters +> or what ever else. +> +> Does anybody have an idea where I can find a database like this or does +> even have something like this? + +Most benchmarks (such as dbt* and pgbench) have data generators you +could use. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon Aug 22 21:48:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 820EBD7289 + for ; + Mon, 22 Aug 2005 21:48:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72103-03 + for ; + Tue, 23 Aug 2005 00:48:54 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 70F57D6D78 + for ; + Mon, 22 Aug 2005 21:48:52 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 1242D152AE; Mon, 22 Aug 2005 19:48:56 -0500 (CDT) +Date: Mon, 22 Aug 2005 19:48:56 -0500 +From: "Jim C. Nasby" +To: Alex Turner +Cc: Ulrich Wisser , + pgsql-performance@postgresql.org +Subject: Re: Need for speed +Message-ID: <20050823004856.GH17203@pervasive.com> +References: <430208AE.7080100@relevanttraffic.se> + <33c6269f050816105957ae5d6f@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <33c6269f050816105957ae5d6f@mail.gmail.com> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/332 +X-Sequence-Number: 14079 + +RRS (http://rrs.decibel.org) might be of use in this case. + +On Tue, Aug 16, 2005 at 01:59:53PM -0400, Alex Turner wrote: +> Are you calculating aggregates, and if so, how are you doing it (I ask +> the question from experience of a similar application where I found +> that my aggregating PGPLSQL triggers were bogging the system down, and +> changed them so scheduled jobs instead). +> +> Alex Turner +> NetEconomist +> +> On 8/16/05, Ulrich Wisser wrote: +> > Hello, +> > +> > one of our services is click counting for on line advertising. We do +> > this by importing Apache log files every five minutes. This results in a +> > lot of insert and delete statements. At the same time our customers +> > shall be able to do on line reporting. +> > +> > We have a box with +> > Linux Fedora Core 3, Postgres 7.4.2 +> > Intel(R) Pentium(R) 4 CPU 2.40GHz +> > 2 scsi 76GB disks (15.000RPM, 2ms) +> > +> > I did put pg_xlog on another file system on other discs. +> > +> > Still when several users are on line the reporting gets very slow. +> > Queries can take more then 2 min. +> > +> > I need some ideas how to improve performance in some orders of +> > magnitude. I already thought of a box with the whole database on a ram +> > disc. So really any idea is welcome. +> > +> > Ulrich +> > +> > +> > +> > -- +> > Ulrich Wisser / System Developer +> > +> > RELEVANT TRAFFIC SWEDEN AB, Riddarg 17A, SE-114 57 Sthlm, Sweden +> > Direct (+46)86789755 || Cell (+46)704467893 || Fax (+46)86789769 +> > ________________________________________________________________ +> > http://www.relevanttraffic.com +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 1: if posting/reading through Usenet, please send an appropriate +> > subscribe-nomail command to majordomo@postgresql.org so that your +> > message can get through to the mailing list cleanly +> > +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon Aug 22 21:54:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2ED9ED6D8C + for ; + Mon, 22 Aug 2005 21:54:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64584-09 + for ; + Tue, 23 Aug 2005 00:54:28 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B71CD6D78 + for ; + Mon, 22 Aug 2005 21:54:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7N0sUlM026870; + Mon, 22 Aug 2005 20:54:31 -0400 (EDT) +To: John Mendenhall +Cc: pgsql-performance list +Subject: Re: complex query performance assistance request +In-reply-to: <20050822210751.GA32479@calvin.surfutopia.net> +References: <20050821034841.GA28968@calvin.surfutopia.net> + <20050822182138.GA30818@calvin.surfutopia.net> + <20830.1124741718@sss.pgh.pa.us> + <20050822210751.GA32479@calvin.surfutopia.net> +Comments: In-reply-to John Mendenhall + message dated "Mon, 22 Aug 2005 14:07:51 -0700" +Date: Mon, 22 Aug 2005 20:54:30 -0400 +Message-ID: <26869.1124758470@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/333 +X-Sequence-Number: 14080 + +John Mendenhall writes: +> Would it be best to attempt to rewrite it for IN? +> Or, should we try to tie it in with a join? + +Couldn't say without a deeper understanding of what you're trying to +accomplish. + +> BTW, what does the Materialize query plan element mean? + +Means "run the contained subplan once, and save the results aside in a +buffer; on subsequent loops, just pass back the buffer contents instead +of re-running the subplan". + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 22 22:19:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E8996D7201 + for ; + Mon, 22 Aug 2005 22:19:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12645-09 + for ; + Tue, 23 Aug 2005 01:19:25 +0000 (GMT) +Received: from smtpsig-4.ig.com.br (smtpsig-4.ig.com.br [200.226.132.141]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E9D1D6E31 + for ; + Mon, 22 Aug 2005 22:19:23 -0300 (ADT) +Received: (qmail 17131 invoked from network); 23 Aug 2005 01:19:23 -0000 +Received: from 200164168141.user.veloxzone.com.br (HELO [192.168.1.223]) + (Usuario_autenticado:netsuporte@superig.com.br@[200.164.168.141]) + (envelope-sender ) + by smtpsig-4.ig.com.br (qmail-ldap-1.03) with SMTP + for ; 23 Aug 2005 01:19:23 -0000 +Message-ID: <430A78B2.8080803@superig.com.br> +Date: Mon, 22 Aug 2005 22:15:30 -0300 +From: Philip Pinkerton +User-Agent: Debian Thunderbird 1.0.6 (X11/20050802) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance list +Subject: pgbench +X-Enigmail-Version: 0.86.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/334 +X-Sequence-Number: 14081 + +I am looking for the latest pgbench and documentation. + +If someone know where I can locate them it would save a lot of search time. + +Thanks + +Philip Pinkerton +TPC-C Benchmarks Sybase +Independant Consultant +Rio de Janeiro, RJ, Brazil 22031-010 + + + +From pgsql-performance-owner@postgresql.org Tue Aug 23 00:13:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BDA42D7766 + for ; + Tue, 23 Aug 2005 00:13:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28422-02 + for ; + Tue, 23 Aug 2005 03:13:17 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 55534D7764 + for ; + Tue, 23 Aug 2005 00:13:15 -0300 (ADT) +Received: from wren.rentec.com (wren.rentec.com [192.5.35.106]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j7N3CWWr015715 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) + for ; + Mon, 22 Aug 2005 23:12:34 -0400 (EDT) +X-Rentec: external +Received: from [172.16.160.108] (stange-dhcp2.rentec.com [172.16.160.108]) + by wren.rentec.com (8.13.1/8.12.1) with ESMTP id j7N3CV7g023672 + for ; + Mon, 22 Aug 2005 23:12:31 -0400 (EDT) +Message-ID: <430A8F30.7050706@rentec.com> +Date: Mon, 22 Aug 2005 22:51:28 -0400 +From: Alan Stange +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: unused item pointers? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as j7N3CWWr015715 at Mon Aug 22 + 23:12:34 2005 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/335 +X-Sequence-Number: 14082 + +Hello all, + +what are unused item pointers and how do I get rid of them? + +We have a fairly large table which is vacuumed daily and reindexed every +weekend. + +NFO: vacuuming "public.tbltimeseries" +INFO: index "idx_timeseries" now contains 26165807 row versions in +151713 pages +DETAIL: 8610108 index row versions were removed. +58576 index pages have been deleted, 36223 are currently reusable. +CPU 6.36s/18.46u sec elapsed 263.75 sec. +INFO: "tbltimeseries": removed 8610108 row versions in 500766 pages +DETAIL: CPU 37.07s/29.76u sec elapsed 826.82 sec. +INFO: "tbltimeseries": found 8610108 removable, 26165807 nonremovable +row versions in 5744789 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 235555635 unused item pointers. +0 pages are entirely empty. +CPU 119.13s/61.09u sec elapsed 2854.22 sec. +INFO: vacuuming "pg_toast.pg_toast_2361976783" +INFO: index "pg_toast_2361976783_index" now contains 24749150 row +versions in 108975 pages +DETAIL: 5857243 index row versions were removed. +33592 index pages have been deleted, 16007 are currently reusable. +CPU 4.15s/13.53u sec elapsed 78.56 sec. +INFO: "pg_toast_2361976783": removed 5857243 row versions in 1125801 pages +DETAIL: CPU 82.62s/69.48u sec elapsed 1571.43 sec. +INFO: "pg_toast_2361976783": found 5857243 removable, 24749150 +nonremovable row versions in 10791766 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 33395357 unused item pointers. +0 pages are entirely empty. +CPU 235.46s/105.91u sec elapsed 4458.31 sec. +INFO: "pg_toast_2361976783": truncated 10791766 to 10778290 pages +DETAIL: CPU 0.21s/0.07u sec elapsed 7.09 sec. +INFO: analyzing "public.tbltimeseries" +INFO: "tbltimeseries": scanned 150000 of 5744789 pages, containing +691250 live rows and 0 dead rows; 150000 rows in sample, 26473903 +estimated total rows + +as you can see we have 235M unused item pointers in the main table and a +few 10's of millions more in other associated tables. + +Please note that the advice "vacuum more often" is a non-starter as the +total time here is already about 3 hours and this is just one table. +This is a fairly active table to which about 20M rows are added and +removed daily. + +The free space map is set at 11M pages and just today we popped up over +that amount in the vacuum output. I don't think this is an issue here +though as the large number of unused item pointers has been present for +a while. + +Thanks! + +-- Alan + +From pgsql-performance-owner@postgresql.org Sat Aug 27 02:04:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C1715D7240 + for ; + Tue, 23 Aug 2005 00:41:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59464-06 + for ; + Tue, 23 Aug 2005 03:41:44 +0000 (GMT) +Received: from tierw.net.avaya.com (tierw.net.avaya.com [198.152.13.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 90C3CD7210 + for ; + Tue, 23 Aug 2005 00:41:43 -0300 (ADT) +Received: from tierw.net.avaya.com (localhost [127.0.0.1]) + by tierw.net.avaya.com (Switch-3.1.2/Switch-3.1.0) with ESMTP id + j7N3Sivl003840 for ; + Mon, 22 Aug 2005 23:28:44 -0400 (EDT) +Received: from au3010avexu1.global.avaya.com (h135-27-64-251.avaya.com + [135.27.64.251]) + by tierw.net.avaya.com (Switch-3.1.2/Switch-3.1.0) with ESMTP id + j7N3Scvl003625 for ; + Mon, 22 Aug 2005 23:28:39 -0400 (EDT) +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C5A794.8DEF9C8B" +Subject: Need indexes on empty tables for good performance ? +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +Date: Tue, 23 Aug 2005 13:41:32 +1000 +Message-ID: + <2773CAC687FD5F4689F526998C7E4E5F43F392@au3010avexu1.global.avaya.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Need indexes on empty tables for good performance ? +Thread-Index: AcWnlI2d7/66JAMCQSi8he+aZQ5/jg== +From: "Lenard, Rohan (Rohan)" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 required=5 tests=[AWL=-0.014, HTML_60_70=0.027, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/470 +X-Sequence-Number: 14217 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5A794.8DEF9C8B +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +I've read that indexes aren't used for COUNT(*) and I've noticed (7.3.x) +with EXPLAIN that indexes never seem to be used on empty tables - is +there any reason to have indexes on empty tables, or will postgresql +never use them. +=20 +This is not as silly as it sounds - with table inheritance you might +have table children with the data and a parent that is empty. It'd be +nice to make sure postgresql knows to never really look at the parent - +especially is you don't know the names of all the children .. +=20 +Thoughts ? +=20 +thx, + Rohan + +------_=_NextPart_001_01C5A794.8DEF9C8B +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + +
I've = +read that=20 +indexes aren't used for COUNT(*) and I've noticed (7.3.x) with EXPLAIN = +that=20 +indexes never seem to be used on empty tables - is there any reason to = +have=20 +indexes on empty tables, or will postgresql never use = +them.
+
 
+
This = +is not as silly=20 +as it sounds - with table inheritance you might have table children with = +the=20 +data and a parent that is empty.  It'd be nice to make sure = +postgresql=20 +knows to never really look at the parent - especially is you don't know = +the=20 +names of all the children ..
+
 
+
Thoughts=20 +?
+
 
+
thx,
+
  = + +Rohan
+ +------_=_NextPart_001_01C5A794.8DEF9C8B-- + +From pgsql-performance-owner@postgresql.org Tue Aug 23 01:42:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 86746D6D8F + for ; + Tue, 23 Aug 2005 01:42:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66035-02 + for ; + Tue, 23 Aug 2005 04:42:14 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 08375D6D78 + for ; + Tue, 23 Aug 2005 01:42:09 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7N4g9RQ028372; + Tue, 23 Aug 2005 00:42:09 -0400 (EDT) +To: Alan Stange +Cc: pgsql-performance@postgresql.org +Subject: Re: unused item pointers? +In-reply-to: <430A8F30.7050706@rentec.com> +References: <430A8F30.7050706@rentec.com> +Comments: In-reply-to Alan Stange + message dated "Mon, 22 Aug 2005 22:51:28 -0400" +Date: Tue, 23 Aug 2005 00:42:09 -0400 +Message-ID: <28371.1124772129@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/336 +X-Sequence-Number: 14083 + +Alan Stange writes: +> INFO: "tbltimeseries": found 8610108 removable, 26165807 nonremovable +> row versions in 5744789 pages +> DETAIL: 0 dead row versions cannot be removed yet. +> There were 235555635 unused item pointers. +> 0 pages are entirely empty. + +The item pointers themselves are not very interesting --- at 4 bytes +apiece, they're only accounting for 2% of the table space. However +the fact that there are nearly 10x more unused than used ones suggests +that this table is suffering a pretty serious bloat problem. Assuming +constant-width rows in the table, that implies something like 90% of +the space in the table is unused. (contrib/pgstattuple might be useful +to confirm this estimate.) + +VACUUM FULL, or perhaps better CLUSTER, would get you out of that. And +yes, you will need to vacuum more often afterwards if you want to keep +the bloat under control. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 23 02:00:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C663D7791 + for ; + Tue, 23 Aug 2005 02:00:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73734-07 + for ; + Tue, 23 Aug 2005 05:00:36 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 3DFA8D77D4 + for ; + Tue, 23 Aug 2005 02:00:34 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7912501; Mon, 22 Aug 2005 22:02:50 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: pgbench +Date: Mon, 22 Aug 2005 22:01:37 -0700 +User-Agent: KMail/1.8 +Cc: Philip Pinkerton +References: <430A78B2.8080803@superig.com.br> +In-Reply-To: <430A78B2.8080803@superig.com.br> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508222201.38131.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] +X-Spam-Level: +X-Archive-Number: 200508/337 +X-Sequence-Number: 14084 + +Phillip, + +> I am looking for the latest pgbench and documentation. + +Currently they are packaged with the PostgreSQL source code. + +However, if you're looking for a serious benchmark, may I suggest OSDL's DBT2? +It's substantially similar to TPC-C. +http://sourceforge.net/projects/osdldbt + +What's your interest in benchmarking PostgreSQL, BTW? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 23 02:14:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 622CFD77FC + for ; + Tue, 23 Aug 2005 02:14:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01445-07 + for ; + Tue, 23 Aug 2005 05:14:20 +0000 (GMT) +Received: from mail27.sea5.speakeasy.net (mail27.sea5.speakeasy.net + [69.17.117.29]) + by svr1.postgresql.org (Postfix) with ESMTP id 714B2D77D9 + for ; + Tue, 23 Aug 2005 02:14:19 -0300 (ADT) +Received: (qmail 18387 invoked from network); 23 Aug 2005 05:14:18 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail27.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 23 Aug 2005 05:14:18 -0000 +Subject: Re: unused item pointers? +From: "Jeffrey W. Baker" +To: Alan Stange +Cc: pgsql-performance@postgresql.org +In-Reply-To: <430A8F30.7050706@rentec.com> +References: <430A8F30.7050706@rentec.com> +Content-Type: text/plain +Date: Mon, 22 Aug 2005 22:15:08 -0700 +Message-Id: <1124774108.6978.7.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/338 +X-Sequence-Number: 14085 + +On Mon, 2005-08-22 at 22:51 -0400, Alan Stange wrote: +> Hello all, +> +> what are unused item pointers and how do I get rid of them? +> +> We have a fairly large table which is vacuumed daily and reindexed every +> weekend. + +> as you can see we have 235M unused item pointers in the main table and a +> few 10's of millions more in other associated tables. +> +> Please note that the advice "vacuum more often" is a non-starter as the +> total time here is already about 3 hours and this is just one table. +> This is a fairly active table to which about 20M rows are added and +> removed daily. + +That may be so, but the answer is still to VACUUM more often. Try the +autovacuum. If it takes 3 hours with 90% wasted records, it would only +take 20 minutes when running properly. + +You might be able to change your application to avoid generating so many +dead rows. For example, test before insert so you don't make a dead +tuple on duplicate insert. + +To repair this table, you can try VACUUM FULL but this is likely to take +longer than you find reasonable. I would recommend dump and reload. + +-jwb + + +From pgsql-performance-owner@postgresql.org Tue Aug 23 06:48:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 265D1D6EEF + for ; + Tue, 23 Aug 2005 06:48:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88320-03 + for ; + Tue, 23 Aug 2005 09:48:33 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id AC976D6ED2 + for ; + Tue, 23 Aug 2005 06:48:30 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050823094829m9100g5ta8e>; Tue, 23 Aug 2005 09:48:29 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 4844C55FA6; Tue, 23 Aug 2005 04:48:29 -0500 (CDT) +Received: from [10.10.0.94] (host35-174.pool82188.interbusiness.it + [82.188.174.35]) + by juju.arbash-meinel.com (Postfix) with ESMTP id D6EB055F9C; + Tue, 23 Aug 2005 04:48:22 -0500 (CDT) +Message-ID: <430AF0E4.3050205@arbash-meinel.com> +Date: Tue, 23 Aug 2005 04:48:20 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: Ron , + postgres performance +Subject: Re: extremly low memory usage +References: <1124331108.27881.96.camel@bluejay.goodinassociates.com> + + <1124386761.27881.119.camel@bluejay.goodinassociates.com> + <4304CB77.4070403@arbash-meinel.com> + <1124470109.27881.152.camel@bluejay.goodinassociates.com> + <43061472.2080201@arbash-meinel.com> + <1124481386.27881.167.camel@bluejay.goodinassociates.com> + <43064908.7010505@arbash-meinel.com> + <1124564003.27881.229.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050820154422.06021150@pop.earthlink.net> + <4307E7A4.7090300@arbash-meinel.com> + <1124636066.27881.238.camel@bluejay.goodinassociates.com> + <6.2.3.4.0.20050821112849.01f79860@pop.earthlink.net> + <1124721763.27881.250.camel@bluejay.goodinassociates.com> +In-Reply-To: <1124721763.27881.250.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig70D3342FFE24F9008453FCB0" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/339 +X-Sequence-Number: 14086 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig70D3342FFE24F9008453FCB0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: +> On Sun, 2005-08-21 at 16:13 -0400, Ron wrote: +> +>>At 10:54 AM 8/21/2005, Jeremiah Jahn wrote: +>> + +... + +>>So you have 2 controllers each with 2 external slots? But you are +>>currently only using 1 controller and only one external slot on that +>>controller? +> +> +> Sorry, no. I have one dual channel card in the system and two +> controllers on the array. Dell PowerVault 220S w/ PERC4eDC-PCI Express +> +> + +... + +>>Regardless of the above, each of these controllers should still be +>>good for about 80-85% of 640MB/s, or ~510-540 MB/s apiece when doing +>>raw sequential IO if you plug 3-4 fast enough HD's into each SCSI +>>channel. Cheetah 15K.4's certainly are fast enough. Optimal setup +>>is probably to split each RAID 1 pair so that one HD is on each of +>>the SCSI channels, and then RAID 0 those pairs. That will also +>>protect you from losing the entire disk subsystem if one of the SCSI +>>channels dies. +> +> I like this idea, but how exactly does one bond the two channels +> together? Won't this cause me to have both an /dev/sdb and an /dev/sdc? +> + +Well, even if you did, you could always either use software raid, or lvm +to turn it into a single volume. + +It also depends what the controller card bios would let you get away +with. Some cards would let you setup 4 RAID1's (one drive from each +channel), and then create a RAID0 of those pairs. Software raid should +do this without any problem. And can even be done such that it can be +grown in the future, as well as work across multiple cards (though the +latter is supported by some cards as well). + +> +> +>>That 128MB of buffer cache may very well be too small to keep the IO +>>rate up, and/or there may be a more subtle problem with the LSI card, +>>and/or you may have a configuration problem, but _something(s)_ need +>>fixing since you are only getting raw sequential IO of ~100-150MB/s +>>when it should be above 500MB/s. +> +> +> It looks like there's a way to add more memory to it. + +This memory probably helps more in writing than reading. If you are +reading the same area over and over, it might end up being a little bit +of extra cache for that (but it should already be cached in system RAM, +so you don't really get anything). + +... + +>>Initial reads are only going to be as fast as your HD subsystem, so +>>there's a reason for making the HD subsystem faster even if all you +>>care about is reads. In addition, I'll repeat my previous advice +>>that upgrading to 16GB of RAM would be well worth it for you. +> +> +> 12GB is my max. I may run with it for a while and see. + +If your working set truly is 10GB, then you can get a massive +performance increase even at 12GB. If your working set is 10GB and you +have 6GB of RAM, it probably is always swapping out what it just read +for the new stuff, even though you will read that same thing again in a +few seconds. So rather than just paying for the 4GB that can't be +cached, you pay for the whole 10. + +John +=:-> + +> +> +>>Hope this helps, +>>Ron Peacetree +>> +>> +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 9: In versions below 8.0, the planner will ignore your desire to +>> choose an index scan if your joining column's datatypes do not +>> match + + +--------------enig70D3342FFE24F9008453FCB0 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDCvDkJdeBCYSNAAMRAoHFAJ9BcZLQHppIRddenaUCQscU92321wCgpoYF +vp7zmFoS9+22qOuILwy9U88= +=lZuP +-----END PGP SIGNATURE----- + +--------------enig70D3342FFE24F9008453FCB0-- + +From pgsql-performance-owner@postgresql.org Sat Aug 27 02:02:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 65065D7729 + for ; + Tue, 23 Aug 2005 09:14:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09337-07 + for ; + Tue, 23 Aug 2005 12:14:30 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 16991D7726 + for ; + Tue, 23 Aug 2005 09:14:28 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 6CBDF30B42; Tue, 23 Aug 2005 14:26:38 +0200 (MET DST) +From: "tobbe" +X-Newsgroups: pgsql.performance +Subject: Performance for relative large DB +Date: 23 Aug 2005 05:14:24 -0700 +Organization: http://groups.google.com +Lines: 27 +Message-ID: <1124799264.282119.167760@g47g2000cwa.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +User-Agent: G2/0.2 +Complaints-To: groups-abuse@google.com +Injection-Info: g47g2000cwa.googlegroups.com; posting-host=212.209.39.154; + posting-account=6PgMzAwAAAAyhWPJdwnKqBSRj5_iJFf6 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/469 +X-Sequence-Number: 14216 + +Hi. + +The company that I'm working for are surveying the djungle of DBMS +since we are due to implement the next generation of our system. + +The companys buissnes is utilizing the DBMS to store data that are +accessed trough the web at daytime (only SELECTs, sometimes with joins, +etc). The data is a collection of bjects that are for sale. The data +consists of basic text information about theese togheter with some +group information, etc. + +The data is updated once every night. + +There are about 4 M posts in the database (one table) and is expected +to grow with atleast 50% during a reasonable long time. + +How well would PostgreSQL fit our needs? + +We are using Pervasive SQL today and suspect that it is much to small. +We have some problems with latency. Esp. when updating information, +complicated conditions in selects and on concurrent usage. + + +Best Regards +Robert Bengtsson +Project Manager + + +From pgsql-performance-owner@postgresql.org Tue Aug 23 10:52:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 27A89D6F1D + for ; + Tue, 23 Aug 2005 10:52:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53180-06 + for ; + Tue, 23 Aug 2005 13:52:51 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id 9D320D6EC7 + for ; + Tue, 23 Aug 2005 10:52:49 -0300 (ADT) +Received: (qmail 4699 invoked from network); 23 Aug 2005 13:52:51 -0000 +Received: from 12-215-178-50.client.mchsi.com (HELO ?192.168.1.120?) + (12.215.178.50) by 0 with SMTP; 23 Aug 2005 13:52:51 -0000 +In-Reply-To: <430A78B2.8080803@superig.com.br> +References: <430A78B2.8080803@superig.com.br> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed +Message-Id: +Cc: pgsql-performance list +Content-Transfer-Encoding: quoted-printable +From: "Thomas F. O'Connell" +Subject: Re: pgbench +Date: Tue, 23 Aug 2005 08:52:46 -0500 +To: Philip Pinkerton +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/340 +X-Sequence-Number: 14087 + +pgbench is located in the contrib directory of any source tarball, =20 +along with a README that serves as documentation. + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC + +Strategic Open Source: Open Your i=99 + +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-469-5150 +615-469-5151 (fax) + +On Aug 22, 2005, at 8:15 PM, Philip Pinkerton wrote: + +> I am looking for the latest pgbench and documentation. +> +> If someone know where I can locate them it would save a lot of =20 +> search time. +> +> Thanks +> +> Philip Pinkerton +> TPC-C Benchmarks Sybase +> Independant Consultant +> Rio de Janeiro, RJ, Brazil 22031-010 + +From pgsql-performance-owner@postgresql.org Tue Aug 23 11:50:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 92E7AD6F5A + for ; + Tue, 23 Aug 2005 11:50:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63309-09 + for ; + Tue, 23 Aug 2005 14:50:22 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.201]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E0C9D6F14 + for ; + Tue, 23 Aug 2005 11:50:20 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i17so5174wra + for ; + Tue, 23 Aug 2005 07:50:26 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:content-type:content-transfer-encoding; + b=CVW45rnpQE2pqFKdgY/vgpoQXsFk1EMiydRAtnvdJTy4s/vXQxjJ81xza4IrC5pj/cYnOlvb2647Xh4g3/rWuPzyZQw/RKTlm2gBBNH1PmrwSP3UCj+W/x8JKErpdeKDm9KCWvQFu+WIK+FIgHchYMsFJIUVj5fmQoBk+b4a/Fo= +Received: by 10.54.27.6 with SMTP id a6mr3806653wra; + Tue, 23 Aug 2005 07:50:26 -0700 (PDT) +Received: from ?192.168.3.4? ([81.182.248.121]) + by mx.gmail.com with ESMTP id g9sm11154106wra.2005.08.23.07.50.24; + Tue, 23 Aug 2005 07:50:26 -0700 (PDT) +Message-ID: <430B379A.7090204@gmail.com> +Date: Tue, 23 Aug 2005 16:50:02 +0200 +From: =?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: hu-hu, hu, en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: fake condition causes far better plan +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.447 required=5 tests=[AWL=-0.047, RCVD_BY_IP=0.024, + TO_ADDRESS_EQ_REAL=0.47] +X-Spam-Level: +X-Archive-Number: 200508/341 +X-Sequence-Number: 14088 + +Dear Gurus, + +System: Debian "Woody" 2.4.28 +Version: PostgreSQL 7.4.8 + +I have a join which causes a better hash if I provide a "trivial" condition: +WHERE m.nap > '1900-01-01'::date +This is a date field with a minimum of '2005-06-21'. However, if I omit this +condition from the WHERE clause, I get a far worse plan. There's also +something not quite right in the cost tuning part of the config file, but I +*think* it shouldn't cause such a bad plan. + +Explain analyze times: +With fake condition: 1104 msec +Without it: 11653 msec +Without, mergejoin disabled: 5776 msec + +For full query and plans, see below. The operator "!=@" is the nonequity +operator extended so that it treats NULL as a one-element equivalence class, +thus never returning NULL. (NULL !=@ NULL is false, NULL !=@ "anything else" +is true) + +1. What may be the cause that this "obvious" condition causes a far better +hash plan than the one without it, even while mergejoin is disabled? + +2. What may be the cause that the planner favors mergejoin to hashjoin? +usually a sign of too high/too low random page cost, for example? I'm +willing to provide config options if it helps. + +TIA, + +-- +G. + +-------------- the query with fake condition (m.nap>=...) -------------- +explain analyze +SELECT DISTINCT + mv.az, mv.vonalkod, mv.idopont, mv.muszakhely as mvhely, + mv.muszaknap as mvnap, mv.muszakkod as mvmkod, + m.hely, m.nap, m.muszakkod as mkod, m.tol, m.ig +FROM muvelet_vonalkod mv + left join olvaso_hely oh on (oh.olvaso_nev = mv.olvaso_nev + and oh.tol <= mv.idopont and mv.idopont < oh.ig) + left join muszak m on (oh.hely = m.hely + and m.tol <= mv.idopont and mv.idopont < m.ig) + , muvelet_vonalkod_ny ny +where mv.az = ny.muvelet_vonalkod + and ny.idopont >= now()-1 + and m.nap >= '1900-01-01'::date + and (mv.muszakhely!=@m.hely or mv.muszaknap!=@m.nap + or mv.muszakkod!=@m.muszakkod); + + +-------------- best plan with fake condition -------------- + Unique (cost=6484.22..6826.73 rows=11417 width=75) (actual +time=1103.870..1103.872 rows=1 loops=1) + -> Sort (cost=6484.22..6512.76 rows=11417 width=75) (actual +time=1103.867..1103.868 rows=1 loops=1) + Sort Key: mv.az, mv.vonalkod, mv.idopont, mv.muszakhely, +mv.muszaknap, mv.muszakkod, m.hely, m.nap, m.muszakkod, m.tol, m.ig + -> Hash Join (cost=1169.78..5434.78 rows=11417 width=75) (actual +time=1075.836..1103.835 rows=1 loops=1) + Hash Cond: ("outer".hely = "inner".hely) + Join Filter: (("inner".tol <= "outer".idopont) AND +("outer".idopont < "inner".ig) AND (CASE WHEN (("outer".muszakhely IS NULL) +AND ("inner".hely IS NULL)) THEN false ELSE CASE WHEN (("outer".muszakhely +IS NULL) AND ("inner".hely IS NOT NULL)) THEN true ELSE CASE WHEN +(("outer".muszakhely IS NOT NULL) AND ("inner".hely IS NULL)) THEN true ELSE +("outer".muszakhely <> "inner".hely) END END END OR CASE WHEN +(("outer".muszaknap IS NULL) AND ("inner".nap IS NULL)) THEN false ELSE CASE +WHEN (("outer".muszaknap IS NULL) AND ("inner".nap IS NOT NULL)) THEN true +ELSE CASE WHEN (("outer".muszaknap IS NOT NULL) AND ("inner".nap IS NULL)) +THEN true ELSE ("outer".muszaknap <> "inner".nap) END END END OR CASE WHEN +(("outer".muszakkod IS NULL) AND ("inner".muszakkod IS NULL)) THEN false +ELSE CASE WHEN (("outer".muszakkod IS NULL) AND ("inner".muszakkod IS NOT +NULL)) THEN true ELSE CASE WHEN (("outer".muszakkod IS NOT NULL) AND +("inner".muszakkod IS NULL)) THEN true ELSE ("outer".muszakkod <> +"inner".muszakkod) END END END)) + -> Hash Join (cost=1167.65..2860.48 rows=1370 width=51) +(actual time=533.035..741.211 rows=3943 loops=1) + Hash Cond: ("outer".muvelet_vonalkod = "inner".az) + -> Index Scan using muvelet_vonalkod_ny_idopont on +muvelet_vonalkod_ny ny (cost=0.00..1351.88 rows=24649 width=4) (actual +time=0.161..10.735 rows=3943 loops=1) + Index Cond: (idopont >= (now() - +('00:00:00'::interval + ('1 days'::text)::interval))) + -> Hash (cost=1124.61..1124.61 rows=3618 width=51) +(actual time=532.703..532.703 rows=0 loops=1) + -> Nested Loop (cost=0.00..1124.61 rows=3618 +width=51) (actual time=0.209..443.765 rows=61418 loops=1) + -> Seq Scan on olvaso_hely oh +(cost=0.00..1.01 rows=1 width=28) (actual time=0.031..0.036 rows=1 loops=1) + -> Index Scan using muvelet_vonalkod_pk2 +on muvelet_vonalkod mv (cost=0.00..1060.30 rows=3617 width=55) (actual +time=0.162..244.158 rows=61418 loops=1) + Index Cond: +((("outer".olvaso_nev)::text = (mv.olvaso_nev)::text) AND ("outer".tol <= +mv.idopont) AND (mv.idopont < "outer".ig)) + -> Hash (cost=1.94..1.94 rows=75 width=28) (actual +time=0.333..0.333 rows=0 loops=1) + -> Seq Scan on muszak m (cost=0.00..1.94 rows=75 +width=28) (actual time=0.070..0.230 rows=73 loops=1) + Filter: (nap >= '2001-01-01'::date) + Total runtime: 1104.244 ms +(19 rows) + + +-------------- mergejoin disabled, no fake condition -------------- + + Unique (cost=256601.12..262763.39 rows=205409 width=75) (actual +time=5776.476..5776.479 rows=1 loops=1) + -> Sort (cost=256601.12..257114.64 rows=205409 width=75) (actual +time=5776.472..5776.472 rows=1 loops=1) + Sort Key: mv.az, mv.vonalkod, mv.idopont, mv.muszakhely, +mv.muszaknap, mv.muszakkod, m.hely, m.nap, m.muszakkod, m.tol, m.ig + -> Hash Join (cost=132547.25..228451.03 rows=205409 width=75) +(actual time=5733.661..5776.428 rows=1 loops=1) + Hash Cond: ("outer".muvelet_vonalkod = "inner".az) + -> Index Scan using muvelet_vonalkod_ny_idopont on +muvelet_vonalkod_ny ny (cost=0.00..1351.88 rows=24649 width=4) (actual +time=0.179..8.578 rows=3940 loops=1) + Index Cond: (idopont >= (now() - ('00:00:00'::interval ++ ('1 days'::text)::interval))) + -> Hash (cost=124566.75..124566.75 rows=542600 width=75) +(actual time=5697.192..5697.192 rows=0 loops=1) + -> Hash Left Join (cost=2.95..124566.75 rows=542600 +width=75) (actual time=33.430..5689.636 rows=484 loops=1) + Hash Cond: ("outer".hely = "inner".hely) + Join Filter: (("inner".tol <= "outer".idopont) +AND ("outer".idopont < "inner".ig)) + Filter: (CASE WHEN (("outer".muszakhely IS NULL) +AND ("inner".hely IS NULL)) THEN false ELSE CASE WHEN (("outer".muszakhely +IS NULL) AND ("inner".hely IS NOT NULL)) THEN true ELSE CASE WHEN +(("outer".muszakhely IS NOT NULL) AND ("inner".hely IS NULL)) THEN true ELSE +("outer".muszakhely <> "inner".hely) END END END OR CASE WHEN +(("outer".muszaknap IS NULL) AND ("inner".nap IS NULL)) THEN false ELSE CASE +WHEN (("outer".muszaknap IS NULL) AND ("inner".nap IS NOT NULL)) THEN true +ELSE CASE WHEN (("outer".muszaknap IS NOT NULL) AND ("inner".nap IS NULL)) +THEN true ELSE ("outer".muszaknap <> "inner".nap) END END END OR CASE WHEN +(("outer".muszakkod IS NULL) AND ("inner".muszakkod IS NULL)) THEN false +ELSE CASE WHEN (("outer".muszakkod IS NULL) AND ("inner".muszakkod IS NOT +NULL)) THEN true ELSE CASE WHEN (("outer".muszakkod IS NOT NULL) AND +("inner".muszakkod IS NULL)) THEN true ELSE ("outer".muszakkod <> +"inner".muszakkod) END END END) + -> Hash Left Join (cost=1.01..2317.03 +rows=65112 width=51) (actual time=0.462..542.361 rows=61465 loops=1) + Hash Cond: (("outer".olvaso_nev)::text = +("inner".olvaso_nev)::text) + Join Filter: (("inner".tol <= +"outer".idopont) AND ("outer".idopont < "inner".ig)) + -> Seq Scan on muvelet_vonalkod mv +(cost=0.00..1502.12 rows=65112 width=55) (actual time=0.028..123.649 +rows=61465 loops=1) + -> Hash (cost=1.01..1.01 rows=1 +width=28) (actual time=0.045..0.045 rows=0 loops=1) + -> Seq Scan on olvaso_hely oh +(cost=0.00..1.01 rows=1 width=28) (actual time=0.031..0.033 rows=1 loops=1) + -> Hash (cost=1.75..1.75 rows=75 width=28) +(actual time=0.319..0.319 rows=0 loops=1) + -> Seq Scan on muszak m (cost=0.00..1.75 +rows=75 width=28) (actual time=0.067..0.215 rows=73 loops=1) + Total runtime: 5776.778 ms +(21 rows) + + +-------------- mergejoin enabled, no fake condition -------------- + + Unique (cost=210234.71..216396.98 rows=205409 width=75) (actual +time=11652.868..11652.870 rows=1 loops=1) + -> Sort (cost=210234.71..210748.24 rows=205409 width=75) (actual +time=11652.865..11652.865 rows=1 loops=1) + Sort Key: mv.az, mv.vonalkod, mv.idopont, mv.muszakhely, +mv.muszaknap, mv.muszakkod, m.hely, m.nap, m.muszakkod, m.tol, m.ig + -> Merge Join (cost=3152.69..182084.63 rows=205409 width=75) +(actual time=11408.433..11652.836 rows=1 loops=1) + Merge Cond: ("outer".az = "inner".muvelet_vonalkod) + -> Nested Loop Left Join (cost=2.76..174499.23 rows=542600 +width=75) (actual time=1.506..11632.727 rows=484 loops=1) + Join Filter: (("outer".hely = "inner".hely) AND +("inner".tol <= "outer".idopont) AND ("outer".idopont < "inner".ig)) + Filter: (CASE WHEN (("outer".muszakhely IS NULL) AND +("inner".hely IS NULL)) THEN false ELSE CASE WHEN (("outer".muszakhely IS +NULL) AND ("inner".hely IS NOT NULL)) THEN true ELSE CASE WHEN +(("outer".muszakhely IS NOT NULL) AND ("inner".hely IS NULL)) THEN true ELSE +("outer".muszakhely <> "inner".hely) END END END OR CASE WHEN +(("outer".muszaknap IS NULL) AND ("inner".nap IS NULL)) THEN false ELSE CASE +WHEN (("outer".muszaknap IS NULL) AND ("inner".nap IS NOT NULL)) THEN true +ELSE CASE WHEN (("outer".muszaknap IS NOT NULL) AND ("inner".nap IS NULL)) +THEN true ELSE ("outer".muszaknap <> "inner".nap) END END END OR CASE WHEN +(("outer".muszakkod IS NULL) AND ("inner".muszakkod IS NULL)) THEN false +ELSE CASE WHEN (("outer".muszakkod IS NULL) AND ("inner".muszakkod IS NOT +NULL)) THEN true ELSE CASE WHEN (("outer".muszakkod IS NOT NULL) AND +("inner".muszakkod IS NULL)) THEN true ELSE ("outer".muszakkod <> +"inner".muszakkod) END END END) + -> Nested Loop Left Join (cost=1.01..3578.48 +rows=65112 width=51) (actual time=0.140..757.392 rows=61461 loops=1) + Join Filter: ((("inner".olvaso_nev)::text = +("outer".olvaso_nev)::text) AND ("inner".tol <= "outer".idopont) AND +("outer".idopont < "inner".ig)) + -> Index Scan using muvelet_vonalkod_pkey on +muvelet_vonalkod mv (cost=0.00..1786.89 rows=65112 width=55) (actual +time=0.103..144.516 rows=61461 loops=1) + -> Materialize (cost=1.01..1.02 rows=1 +width=28) (actual time=0.001..0.002 rows=1 loops=61461) + -> Seq Scan on olvaso_hely oh +(cost=0.00..1.01 rows=1 width=28) (actual time=0.005..0.007 rows=1 loops=1) + -> Materialize (cost=1.75..2.50 rows=75 width=28) +(actual time=0.001..0.054 rows=73 loops=61461) + -> Seq Scan on muszak m (cost=0.00..1.75 +rows=75 width=28) (actual time=0.012..0.179 rows=73 loops=1) + -> Sort (cost=3149.93..3211.55 rows=24649 width=4) (actual +time=15.420..17.108 rows=2356 loops=1) + Sort Key: ny.muvelet_vonalkod + -> Index Scan using muvelet_vonalkod_ny_idopont on +muvelet_vonalkod_ny ny (cost=0.00..1351.88 rows=24649 width=4) (actual +time=0.048..9.502 rows=3942 loops=1) + Index Cond: (idopont >= (now() - +('00:00:00'::interval + ('1 days'::text)::interval))) + Total runtime: 11653.429 ms +(20 rows) + +From pgsql-performance-owner@postgresql.org Tue Aug 23 13:16:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B8F49D702D + for ; + Tue, 23 Aug 2005 13:04:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66522-09 + for ; + Tue, 23 Aug 2005 16:04:07 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A8164D702B + for ; + Tue, 23 Aug 2005 13:04:05 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id ACF4A30B42; Tue, 23 Aug 2005 18:16:13 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Performance for relative large DB +Date: Tue, 23 Aug 2005 11:12:51 -0400 +Organization: cbbrowne Computing Inc +Lines: 51 +Message-ID: <60wtmcptzg.fsf@dba2.int.libertyrms.com> +References: <1124799264.282119.167760@g47g2000cwa.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:RcRQTv8EtD3YOVl9Uf0wrl1M3nI= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.116 required=5 tests=[AWL=0.116] +X-Spam-Level: +X-Archive-Number: 200508/343 +X-Sequence-Number: 14090 + +"tobbe" writes: +> The company that I'm working for are surveying the djungle of DBMS +> since we are due to implement the next generation of our system. +> +> The companys buissnes is utilizing the DBMS to store data that are +> accessed trough the web at daytime (only SELECTs, sometimes with joins, +> etc). The data is a collection of bjects that are for sale. The data +> consists of basic text information about theese togheter with some +> group information, etc. +> +> The data is updated once every night. + +How much data is updated per night? The whole 4M "posts"? Or just +some subset? + +> There are about 4 M posts in the database (one table) and is +> expected to grow with atleast 50% during a reasonable long time. + +So you're expecting to have ~6M entries in the 'posts' table? + +> How well would PostgreSQL fit our needs? +> +> We are using Pervasive SQL today and suspect that it is much to small. +> We have some problems with latency. Esp. when updating information, +> complicated conditions in selects and on concurrent usage. + +If you're truly updating all 4M/6M rows each night, *that* would turn +out to be something of a bottleneck, as every time you update a tuple, +this creates a new copy, leaving the old one to be later cleaned away +via VACUUM. + +That strikes me as unlikely: I expect instead that you update a few +thousand or a few tens of thousands of entries per day, in which case +the "vacuum pathology" won't be a problem. + +I wouldn't expect PostgreSQL to be "too small;" it can and does cope +well with complex queries. + +And the use of MVCC allows there to be a relatively minimal amount of +locking done even though there may be a lot of concurrent users, the +particular merit there being that you can essentially eliminate most +read locks. That is, you can get consistent reports without having to +lock rows or tables. + +One table with millions of rows isn't that complex a scenario :-). +-- +output = ("cbbrowne" "@" "cbbrowne.com") +http://cbbrowne.com/info/spiritual.html +Appendium to the Rules of the Evil Overlord #1: "I will not build +excessively integrated security-and-HVAC systems. They may be Really +Cool, but are far too vulnerable to breakdowns." + +From pgsql-performance-owner@postgresql.org Tue Aug 23 12:18:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E7D5D6F74 + for ; + Tue, 23 Aug 2005 12:14:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45705-05 + for ; + Tue, 23 Aug 2005 15:14:30 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B1D7D6F63 + for ; + Tue, 23 Aug 2005 12:14:28 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7NFEKD3002639; + Tue, 23 Aug 2005 11:14:22 -0400 (EDT) +To: =?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= +Cc: "pgsql-performance@postgresql.org" +Subject: Re: fake condition causes far better plan +In-reply-to: <430B379A.7090204@gmail.com> +References: <430B379A.7090204@gmail.com> +Comments: In-reply-to =?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= + message dated "Tue, 23 Aug 2005 16:50:02 +0200" +Date: Tue, 23 Aug 2005 11:14:19 -0400 +Message-ID: <2638.1124810059@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/342 +X-Sequence-Number: 14089 + +=?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= writes: +> [ bad query plan ] + +Most of the problem is here: + +> -> Index Scan using muvelet_vonalkod_ny_idopont on +> muvelet_vonalkod_ny ny (cost=0.00..1351.88 rows=24649 width=4) (actual +> time=0.161..10.735 rows=3943 loops=1) +> Index Cond: (idopont >= (now() - +> ('00:00:00'::interval + ('1 days'::text)::interval))) + +(BTW, you lied about the query, because this index condition doesn't +match anything in the given query text.) + +Pre-8.0 releases aren't capable of making useful statistical estimates +for conditions involving nonconstant subexpressions, so you get a +badly-mistaken row count estimate that leads to a poor choice of plan. + +If you can't update to 8.0, the best answer is to do the date arithmetic +on the client side. Another way is to create an allegedly-immutable +function along the lines of "ago(interval) returns timestamptz" to hide +the now() call --- this is dangerous but sometimes it's the easiest answer. +See the archives. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 23 14:10:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E5AF5D6E2A + for ; + Tue, 23 Aug 2005 14:10:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97915-03 + for ; + Tue, 23 Aug 2005 17:10:51 +0000 (GMT) +Received: from web51309.mail.yahoo.com (web51309.mail.yahoo.com + [206.190.38.175]) + by svr1.postgresql.org (Postfix) with SMTP id 3BA7BD6F66 + for ; + Tue, 23 Aug 2005 14:10:50 -0300 (ADT) +Received: (qmail 12114 invoked by uid 60001); 23 Aug 2005 17:10:45 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=33YFblMUk98I7sGSUJpwxrKEzFiJMgx0e6RcryMIhrQb46CucudvgCBTh90sT/zwlBG+fLp7/zFc1SeLrhO3lOJoLghE/4WG9B4j+iJ/CsoP5WHEBfkQTr6MoV0XkuX2EYuSwM6TrpkQzRBnRHXYGJQ5RGX39MBCVnckv61BLFM= + ; +Message-ID: <20050823171045.12112.qmail@web51309.mail.yahoo.com> +Received: from [203.101.103.131] by web51309.mail.yahoo.com via HTTP; + Tue, 23 Aug 2005 10:10:45 PDT +Date: Tue, 23 Aug 2005 10:10:45 -0700 (PDT) +From: gokulnathbabu manoharan +Subject: Caching by Postgres +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.374 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/344 +X-Sequence-Number: 14091 + +Hi all, + +I like to know the caching policies of Postgresql. +What parameter in the postgresql.conf affects the +cache size used by the Postgresql? As far as I have +searched my knowledge of the parameters are + +1. shared_buffers - Sets the limit on the amount of +shared memory used. If I take this is as the cache +size then my performance should increase with the +increase in the size of shared_buffers. But it seems +it is not the case and my performance actually +decreases with the increase in the shared_buffers. I +have a RAM size of 32 GB. The table which I use more +frequently has around 68 million rows. Can I cache +this entire table in RAM? + +2. work_mem - It is the amount of memory used by an +operation. My guess is once the operation is complete +this is freed and hence has nothing to do with the +caching. + +3. effective_cache_size - The parameter used by the +query planner and has nothing to do with the actual +caching. + +So kindly help me in pointing me to the correct +parameter to set. + +It will be great if you can point me to the docs that +explains the implementation of caching in Postgresql +which will help me in understanding things much +clearly. + +Thanks in advance. +Gokul. + + +__________________________________________________ +Do You Yahoo!? +Tired of spam? Yahoo! Mail has the best spam protection around +http://mail.yahoo.com + +From pgsql-performance-owner@postgresql.org Tue Aug 23 14:26:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F364D704F + for ; + Tue, 23 Aug 2005 14:26:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01799-05 + for ; + Tue, 23 Aug 2005 17:26:18 +0000 (GMT) +Received: from sccmmhc91.asp.att.net (sccmmhc91.asp.att.net [204.127.203.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 96673D6F66 + for ; + Tue, 23 Aug 2005 14:26:14 -0300 (ADT) +Received: from juju.arbash-meinel.com ([12.214.18.81]) + by sccmmhc91.asp.att.net (sccmmhc91) with ESMTP + id <20050823172613m9100g70one>; Tue, 23 Aug 2005 17:26:13 +0000 +Received: by juju.arbash-meinel.com (Postfix, from userid 505) + id 75C5B55FA6; Tue, 23 Aug 2005 12:26:13 -0500 (CDT) +Received: from [10.10.0.181] (unknown [85.20.238.130]) + by juju.arbash-meinel.com (Postfix) with ESMTP id 9B9CC55F9C; + Tue, 23 Aug 2005 12:26:01 -0500 (CDT) +Message-ID: <430B5C27.9030007@arbash-meinel.com> +Date: Tue, 23 Aug 2005 12:25:59 -0500 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: gokulnathbabu manoharan +Cc: pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> +In-Reply-To: <20050823171045.12112.qmail@web51309.mail.yahoo.com> +X-Enigmail-Version: 0.92.0.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig6B9A2DFC2643B98ED6BD6B74" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/345 +X-Sequence-Number: 14092 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig6B9A2DFC2643B98ED6BD6B74 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +gokulnathbabu manoharan wrote: +> Hi all, +> +> I like to know the caching policies of Postgresql. +> What parameter in the postgresql.conf affects the +> cache size used by the Postgresql? As far as I have +> searched my knowledge of the parameters are + +In general, you don't. The OS handles caching based on file usage. +So if you are using the files, the OS should cache them. Just like it +does with any other program. + +> +> 1. shared_buffers - Sets the limit on the amount of +> shared memory used. If I take this is as the cache +> size then my performance should increase with the +> increase in the size of shared_buffers. But it seems +> it is not the case and my performance actually +> decreases with the increase in the shared_buffers. I +> have a RAM size of 32 GB. The table which I use more +> frequently has around 68 million rows. Can I cache +> this entire table in RAM? + +There is a portion of this which is used for caching. But I believe +before 8.1 there was code that went linearly through all of the +shared_buffers and checked for dirty/clean pages. So there was a +tradeoff that the bigger you make it, the longer that search goes. So +you got diminishing returns, generally around 10k shared buffers. +I think it is better in 8.1, but if the OS is going to cache it anyway +(since it does), then having a Postgres cache is just wasting memory, +and not letting cache as much. + +So I'm guessing that with 8.1 there would be 2 sweet spots. Low +shared_buffers (<= 10k), and really high shared buffers (like all of +available ram). +But because postgres has been tuned for the former I would stick with it +(I don't think shared_buffers can go >2GB, but that might just be +work_mem/maintenance_work_mem). + +> +> 2. work_mem - It is the amount of memory used by an +> operation. My guess is once the operation is complete +> this is freed and hence has nothing to do with the +> caching. +> +> 3. effective_cache_size - The parameter used by the +> query planner and has nothing to do with the actual +> caching. + +This is important from a planner issue. Because the planner can then +expect that the OS is doing its job and caching the tables, so index +scans are cheaper than they would be otherwise. + +John +=:-> + +> +> So kindly help me in pointing me to the correct +> parameter to set. +> +> It will be great if you can point me to the docs that +> explains the implementation of caching in Postgresql +> which will help me in understanding things much +> clearly. +> +> Thanks in advance. +> Gokul. +> + + +--------------enig6B9A2DFC2643B98ED6BD6B74 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFDC1woJdeBCYSNAAMRAo5oAKDK1553m7IjY7NssS5Ot/I7lDwKjQCfW21x +1B1z4H/JdL58uUMxS1ma3Ac= +=QG/Q +-----END PGP SIGNATURE----- + +--------------enig6B9A2DFC2643B98ED6BD6B74-- + +From pgsql-performance-owner@postgresql.org Tue Aug 23 14:41:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB981D6F66 + for ; + Tue, 23 Aug 2005 14:41:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03546-07 + for ; + Tue, 23 Aug 2005 17:41:40 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.197.194]) + by svr1.postgresql.org (Postfix) with SMTP id 3CC02D6ED5 + for ; + Tue, 23 Aug 2005 14:41:39 -0300 (ADT) +Received: (qmail 23428 invoked by uid 500); 23 Aug 2005 17:41:08 -0000 +Date: Tue, 23 Aug 2005 12:41:08 -0500 +From: Bruno Wolff III +To: gokulnathbabu manoharan +Cc: pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +Message-ID: <20050823174108.GD19586@wolff.to> +Mail-Followup-To: Bruno Wolff III , + gokulnathbabu manoharan , + pgsql-performance@postgresql.org +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050823171045.12112.qmail@web51309.mail.yahoo.com> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/346 +X-Sequence-Number: 14093 + +On Tue, Aug 23, 2005 at 10:10:45 -0700, + gokulnathbabu manoharan wrote: +> Hi all, +> +> I like to know the caching policies of Postgresql. +> What parameter in the postgresql.conf affects the +> cache size used by the Postgresql? As far as I have +> searched my knowledge of the parameters are + +The main policy is to let the OS do most of the caching. + +> 1. shared_buffers - Sets the limit on the amount of +> shared memory used. If I take this is as the cache +> size then my performance should increase with the +> increase in the size of shared_buffers. But it seems +> it is not the case and my performance actually +> decreases with the increase in the shared_buffers. I +> have a RAM size of 32 GB. The table which I use more +> frequently has around 68 million rows. Can I cache +> this entire table in RAM? + +Using extermely large values for shared buffers is known to be a performance +loss for Postgres. Some improvements were made for 8.0 and more for 8.1. + +The OS will cache frequently used data from files for you. So if you are using +that table a lot and the rows aren't too wide, it should mostly be cached +for you by the OS. + +> 2. work_mem - It is the amount of memory used by an +> operation. My guess is once the operation is complete +> this is freed and hence has nothing to do with the +> caching. + +This is used for sorts and some other things. + +> 3. effective_cache_size - The parameter used by the +> query planner and has nothing to do with the actual +> caching. + +You are supposed to use this to give the planner an idea about how much +space the OS will using for caching on behalf of Posgres. + +> So kindly help me in pointing me to the correct +> parameter to set. +> +> It will be great if you can point me to the docs that +> explains the implementation of caching in Postgresql +> which will help me in understanding things much +> clearly. + +You probably want to read the following: +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +From pgsql-performance-owner@postgresql.org Tue Aug 23 14:43:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CC667D6F5D + for ; + Tue, 23 Aug 2005 14:42:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03180-03 + for ; + Tue, 23 Aug 2005 17:42:47 +0000 (GMT) +Received: from frank.wiles.org (frank.wiles.org [24.124.39.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B176D6ED5 + for ; + Tue, 23 Aug 2005 14:42:46 -0300 (ADT) +Received: from kungfu (frank.wiles.org [127.0.0.1]) + by frank.wiles.org (8.13.1/8.13.1) with SMTP id j7NGpQiA008440; + Tue, 23 Aug 2005 11:51:27 -0500 +Date: Tue, 23 Aug 2005 12:43:23 -0500 +From: Frank Wiles +To: gokulnathbabu manoharan +Cc: pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +Message-Id: <20050823124323.710a9dd3.frank@wiles.org> +In-Reply-To: <20050823171045.12112.qmail@web51309.mail.yahoo.com> +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> +X-Mailer: Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-redhat-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/347 +X-Sequence-Number: 14094 + +On Tue, 23 Aug 2005 10:10:45 -0700 (PDT) +gokulnathbabu manoharan wrote: + +> Hi all, +> +> I like to know the caching policies of Postgresql. +> What parameter in the postgresql.conf affects the +> cache size used by the Postgresql? As far as I have +> searched my knowledge of the parameters are +> +> 1. shared_buffers - Sets the limit on the amount of +> shared memory used. If I take this is as the cache +> size then my performance should increase with the +> increase in the size of shared_buffers. But it seems +> it is not the case and my performance actually +> decreases with the increase in the shared_buffers. I +> have a RAM size of 32 GB. The table which I use more +> frequently has around 68 million rows. Can I cache +> this entire table in RAM? + + increasing shared_buffers to a point helps, but after + a certain threshold it can actually degree performance. + +> 2. work_mem - It is the amount of memory used by an +> operation. My guess is once the operation is complete +> this is freed and hence has nothing to do with the +> caching. + + This is the amount of memory used for things like sorts and + order bys on a per backend process basis. + +> 3. effective_cache_size - The parameter used by the +> query planner and has nothing to do with the actual +> caching. + + The instructs the query planner on how large the operating + system's disk cache is. There isn't a built in cache, PostgreSQL + relies on the operating system to cache the on disk information + based on how often it is used. In most cases this is probably + more accurate anyway. + + I wrote an article on PostgreSQL performance tuning that has + links to several other related sites, you can find it here: + + http://www.revsys.com/writings/postgresql-performance.html + + --------------------------------- + Frank Wiles + http://www.wiles.org + --------------------------------- + + +From pgsql-performance-owner@postgresql.org Tue Aug 23 14:54:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D9A1D70AB + for ; + Tue, 23 Aug 2005 14:54:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06851-10 + for ; + Tue, 23 Aug 2005 17:53:57 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id DD2BCD6F9F + for ; + Tue, 23 Aug 2005 14:53:56 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7915661; Tue, 23 Aug 2005 10:56:14 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +Date: Tue, 23 Aug 2005 10:57:09 -0700 +User-Agent: KMail/1.8 +Cc: John A Meinel , + gokulnathbabu manoharan +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <430B5C27.9030007@arbash-meinel.com> +In-Reply-To: <430B5C27.9030007@arbash-meinel.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508231057.09885.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 required=5 tests=[AWL=-0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/348 +X-Sequence-Number: 14095 + +John, + +> So I'm guessing that with 8.1 there would be 2 sweet spots. Low +> shared_buffers (<= 10k), and really high shared buffers (like all of +> available ram). +> But because postgres has been tuned for the former I would stick with it +> (I don't think shared_buffers can go >2GB, but that might just be +> work_mem/maintenance_work_mem). + +I'll be testing this as soon as we get some issues with the 64bit +shared_buffer patch worked out. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 23 15:50:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9726DD710E + for ; + Tue, 23 Aug 2005 15:45:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17023-08 + for ; + Tue, 23 Aug 2005 18:45:45 +0000 (GMT) +Received: from nwkea-mail-1.sun.com (nwkea-mail-1.sun.com [192.18.42.13]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CDB7D7106 + for ; + Tue, 23 Aug 2005 15:45:44 -0300 (ADT) +Received: from phys-bur-1 ([129.148.9.72]) + by nwkea-mail-1.sun.com (8.12.10/8.12.9) with ESMTP id j7NIjj2B018077 + for ; + Tue, 23 Aug 2005 11:45:45 -0700 (PDT) +Received: from conversion-daemon.bur-mail1.east.sun.com by + bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0ILO00M01UMBEL@bur-mail1.east.sun.com> + (original mail from Donald.Courtney@Sun.COM) + for pgsql-performance@postgresql.org; + Tue, 23 Aug 2005 14:45:45 -0400 (EDT) +Received: from [129.148.184.34] (gyama.East.Sun.COM [129.148.184.34]) + by bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTPA id <0ILO007CYUS82G@bur-mail1.east.sun.com>; Tue, + 23 Aug 2005 14:45:45 -0400 (EDT) +Date: Tue, 23 Aug 2005 14:41:39 -0400 +From: Donald Courtney +Subject: Re: Caching by Postgres +In-reply-to: <20050823124323.710a9dd3.frank@wiles.org> +To: pgsql-performance@postgresql.org +Cc: Frank Wiles , + gokulnathbabu manoharan +Message-id: <430B6DE3.6040109@sun.com> +Organization: Sun Microsystems +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7) Gecko/20041221 +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/349 +X-Sequence-Number: 14096 + + +I mean well with this comment - +This whole issue of data caching is a troubling issue with postreSQL +in that even if you ran postgreSQL on a 64 bit address space +with larger number of CPUs you won't see much of a scale up +and possibly even a drop. I am not alone in having the *expectation* +that a database should have some cache size parameter and +the option to skip the file system. If I use oracle, sybase, mysql +and maxdb they all have the ability to size a data cache and move +to 64 bits. + +Is this a crazy idea - that a project be started to get this adopted? +Is it +too big and structural to contemplate? + + From one who likes postgreSQL +dc + +Frank Wiles wrote: + +>On Tue, 23 Aug 2005 10:10:45 -0700 (PDT) +>gokulnathbabu manoharan wrote: +> +> +> +>>Hi all, +>> +>>I like to know the caching policies of Postgresql. +>>What parameter in the postgresql.conf affects the +>>cache size used by the Postgresql? As far as I have +>>searched my knowledge of the parameters are +>> +>>1. shared_buffers - Sets the limit on the amount of +>>shared memory used. If I take this is as the cache +>>size then my performance should increase with the +>>increase in the size of shared_buffers. But it seems +>>it is not the case and my performance actually +>>decreases with the increase in the shared_buffers. I +>>have a RAM size of 32 GB. The table which I use more +>>frequently has around 68 million rows. Can I cache +>>this entire table in RAM? +>> +>> +> +> increasing shared_buffers to a point helps, but after +> a certain threshold it can actually degree performance. +> +> +> +>>2. work_mem - It is the amount of memory used by an +>>operation. My guess is once the operation is complete +>>this is freed and hence has nothing to do with the +>>caching. +>> +>> +> +> This is the amount of memory used for things like sorts and +> order bys on a per backend process basis. +> +> +> +>>3. effective_cache_size - The parameter used by the +>>query planner and has nothing to do with the actual +>>caching. +>> +>> +> +> The instructs the query planner on how large the operating +> system's disk cache is. There isn't a built in cache, PostgreSQL +> relies on the operating system to cache the on disk information +> based on how often it is used. In most cases this is probably +> more accurate anyway. +> +> I wrote an article on PostgreSQL performance tuning that has +> links to several other related sites, you can find it here: +> +> http://www.revsys.com/writings/postgresql-performance.html +> +> --------------------------------- +> Frank Wiles +> http://www.wiles.org +> --------------------------------- +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> +> + + +From pgsql-performance-owner@postgresql.org Tue Aug 23 16:05:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A76B0D708A + for ; + Tue, 23 Aug 2005 16:05:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34820-03 + for ; + Tue, 23 Aug 2005 19:05:31 +0000 (GMT) +Received: from calvin.surfutopia.net (calvin.surfutopia.net [67.120.245.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E611D70AD + for ; + Tue, 23 Aug 2005 16:05:27 -0300 (ADT) +Received: by calvin.surfutopia.net (Postfix, from userid 1000) + id 8AA1FF22F; Tue, 23 Aug 2005 12:05:25 -0700 (PDT) +Date: Tue, 23 Aug 2005 12:05:25 -0700 +From: John Mendenhall +To: Tom Lane +Cc: pgsql-performance list +Subject: Re: complex query performance assistance request +Message-ID: <20050823190525.GA27623@calvin.surfutopia.net> +References: <20050821034841.GA28968@calvin.surfutopia.net> + <20050822182138.GA30818@calvin.surfutopia.net> + <20830.1124741718@sss.pgh.pa.us> + <20050822210751.GA32479@calvin.surfutopia.net> + <26869.1124758470@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <26869.1124758470@sss.pgh.pa.us> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/350 +X-Sequence-Number: 14097 + +Tom, + +> > Would it be best to attempt to rewrite it for IN? +> > Or, should we try to tie it in with a join? +> +> Couldn't say without a deeper understanding of what you're trying to +> accomplish. + +Here are the results of each SQL rewrite. + +The first pass, I rewrote it as c.id IN (): +----- +LOG: duration: 2669.682 ms statement: explain analyze +SELECT + c.id AS contact_id, + sr.id AS sales_rep_id, + p.id AS partner_id, + coalesce(LTRIM(RTRIM(c.company)), LTRIM(RTRIM(c.firstname || ' ' || c.lastname))) AS contact_company, + co.name AS contact_country, + c.master_key_token +FROM + sales_reps sr + JOIN partners p ON (sr.id = p.sales_rep_id) + JOIN contacts c ON (p.id = c.partner_id) + JOIN countries co ON (LOWER(c.country) = LOWER(co.code)) + JOIN partner_classification pc ON (p.classification_id = pc.id AND pc.classification != 'Sales Rep') +WHERE + c.lead_deleted IS NULL + AND c.id IN + ( + SELECT + lr.contact_id + FROM + lead_requests lr, + lead_request_status lrs + WHERE + lr.status_id = lrs.id AND + lrs.is_closed = 0 + ) +ORDER BY + contact_company, contact_id +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=4413.35..4416.16 rows=1123 width=102) (actual time=2617.069..2617.719 rows=1071 loops=1) + Sort Key: COALESCE(ltrim(rtrim((c.company)::text)), ltrim(rtrim((((c.firstname)::text || ' '::text) || (c.lastname)::text)))), c.id + -> Merge Join (cost=4311.31..4356.45 rows=1123 width=102) (actual time=2549.717..2589.398 rows=1071 loops=1) + Merge Cond: ("outer"."?column3?" = "inner"."?column9?") + -> Sort (cost=14.00..14.61 rows=242 width=19) (actual time=9.765..9.966 rows=240 loops=1) + Sort Key: lower((co.code)::text) + -> Seq Scan on countries co (cost=0.00..4.42 rows=242 width=19) (actual time=0.142..5.118 rows=242 loops=1) + -> Sort (cost=4297.31..4299.63 rows=928 width=95) (actual time=2539.685..2540.913 rows=1071 loops=1) + Sort Key: lower((c.country)::text) + -> Merge IN Join (cost=4163.02..4251.57 rows=928 width=95) (actual time=2377.539..2524.844 rows=1071 loops=1) + Merge Cond: ("outer".id = "inner".contact_id) + -> Sort (cost=1835.53..1851.27 rows=6296 width=95) (actual time=1843.866..1853.193 rows=6349 loops=1) + Sort Key: c.id + -> Merge Join (cost=75.65..1438.24 rows=6296 width=95) (actual time=51.713..1505.633 rows=6349 loops=1) + Merge Cond: ("outer".partner_id = "inner".id) + -> Index Scan using contacts_partner_id_idx on contacts c (cost=0.00..5303.84 rows=40243 width=85) (actual time=0.077..584.736 rows=40267 loops=1) + Filter: (lead_deleted IS NULL) + -> Sort (cost=75.65..76.37 rows=290 width=20) (actual time=51.508..62.288 rows=6462 loops=1) + Sort Key: p.id + -> Merge Join (cost=59.24..63.79 rows=290 width=20) (actual time=30.152..38.281 rows=395 loops=1) + Merge Cond: ("outer".id = "inner".sales_rep_id) + -> Sort (cost=2.42..2.52 rows=39 width=10) (actual time=1.390..1.505 rows=39 loops=1) + Sort Key: sr.id + -> Seq Scan on sales_reps sr (cost=0.00..1.39 rows=39 width=10) (actual time=0.026..0.380 rows=39 loops=1) + -> Sort (cost=56.82..57.55 rows=290 width=20) (actual time=28.558..29.120 rows=395 loops=1) + Sort Key: p.sales_rep_id + -> Nested Loop (cost=24.35..44.96 rows=290 width=20) (actual time=0.191..21.408 rows=395 loops=1) + Join Filter: ("inner".classification_id = "outer".id) + -> Seq Scan on partner_classification pc (cost=0.00..1.04 rows=2 width=10) (actual time=0.068..0.121 rows=2 loops=1) + Filter: ((classification)::text <> 'Sales Rep'::text) + -> Materialize (cost=24.35..28.70 rows=435 width=30) (actual time=0.029..5.380 rows=435 loops=2) + -> Seq Scan on partners p (cost=0.00..24.35 rows=435 width=30) (actual time=0.038..8.161 rows=435 loops=1) + -> Sort (cost=2327.50..2351.43 rows=9573 width=11) (actual time=533.508..535.629 rows=1742 loops=1) + Sort Key: lr.contact_id + -> Merge Join (cost=1520.94..1694.49 rows=9573 width=11) (actual time=302.932..461.644 rows=1745 loops=1) + Merge Cond: ("outer".id = "inner".status_id) + -> Sort (cost=1.28..1.30 rows=8 width=10) (actual time=0.392..0.404 rows=7 loops=1) + Sort Key: lrs.id + -> Seq Scan on lead_request_status lrs (cost=0.00..1.16 rows=8 width=10) (actual time=0.117..0.280 rows=7 loops=1) + Filter: (is_closed = 0::numeric) + -> Sort (cost=1519.66..1558.55 rows=15556 width=21) (actual time=302.423..321.939 rows=15387 loops=1) + Sort Key: lr.status_id + -> Seq Scan on lead_requests lr (cost=0.00..436.56 rows=15556 width=21) (actual time=0.029..164.708 rows=15559 loops=1) + Total runtime: 2632.987 ms +(44 rows) +----- + +The second pass, I rewrote it to tie in with a JOIN, adding +a DISTINCT at the top to get rid of the duplicates: +----- +LOG: duration: 3285.645 ms statement: explain analyze +SELECT DISTINCT + c.id AS contact_id, + sr.id AS sales_rep_id, + p.id AS partner_id, + coalesce(LTRIM(RTRIM(c.company)), LTRIM(RTRIM(c.firstname || ' ' || c.lastname))) AS contact_company, + co.name AS contact_country, + c.master_key_token +FROM + sales_reps sr + JOIN partners p ON (sr.id = p.sales_rep_id) + JOIN contacts c ON (p.id = c.partner_id) + JOIN countries co ON (LOWER(c.country) = LOWER(co.code)) + JOIN partner_classification pc ON (p.classification_id = pc.id AND pc.classification != 'Sales Rep') + JOIN lead_requests lr ON (c.id = lr.contact_id) + JOIN lead_request_status lrs ON (lr.status_id = lrs.id AND lrs.is_closed = 0) +WHERE + c.lead_deleted IS NULL +ORDER BY + contact_company, contact_id +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------- + Unique (cost=3039.78..3071.46 rows=1810 width=102) (actual time=3219.707..3228.637 rows=1071 loops=1) + -> Sort (cost=3039.78..3044.31 rows=1810 width=102) (actual time=3219.695..3220.560 rows=1118 loops=1) + Sort Key: COALESCE(ltrim(rtrim((c.company)::text)), ltrim(rtrim((((c.firstname)::text || ' '::text) || (c.lastname)::text)))), c.id, sr.id, p.id, co.name, c.master_key_token + -> Merge Join (cost=2870.92..2941.85 rows=1810 width=102) (actual time=3156.788..3188.338 rows=1118 loops=1) + Merge Cond: ("outer"."?column3?" = "inner"."?column9?") + -> Sort (cost=14.00..14.61 rows=242 width=19) (actual time=9.196..9.445 rows=240 loops=1) + Sort Key: lower((co.code)::text) + -> Seq Scan on countries co (cost=0.00..4.42 rows=242 width=19) (actual time=0.128..3.914 rows=242 loops=1) + -> Sort (cost=2856.92..2860.66 rows=1496 width=95) (actual time=3147.340..3148.477 rows=1118 loops=1) + Sort Key: lower((c.country)::text) + -> Merge Join (cost=2750.88..2778.03 rows=1496 width=95) (actual time=3008.933..3132.122 rows=1118 loops=1) + Merge Cond: ("outer".id = "inner".status_id) + -> Sort (cost=1.28..1.30 rows=8 width=10) (actual time=0.366..0.379 rows=7 loops=1) + Sort Key: lrs.id + -> Seq Scan on lead_request_status lrs (cost=0.00..1.16 rows=8 width=10) (actual time=0.094..0.254 rows=7 loops=1) + Filter: (is_closed = 0::numeric) + -> Sort (cost=2749.60..2755.67 rows=2430 width=105) (actual time=3008.396..3023.502 rows=9992 loops=1) + Sort Key: lr.status_id + -> Merge Join (cost=1835.53..2612.95 rows=2430 width=105) (actual time=1975.714..2912.632 rows=10089 loops=1) + Merge Cond: ("outer".contact_id = "inner".id) + -> Index Scan using lead_requests_contact_id_idx on lead_requests lr (cost=0.00..683.87 rows=15556 width=21) (actual time=0.073..247.148 rows=15556 loops=1) + -> Sort (cost=1835.53..1851.27 rows=6296 width=95) (actual time=1975.273..1988.664 rows=10089 loops=1) + Sort Key: c.id + -> Merge Join (cost=75.65..1438.24 rows=6296 width=95) (actual time=56.107..1625.186 rows=6349 loops=1) + Merge Cond: ("outer".partner_id = "inner".id) + -> Index Scan using contacts_partner_id_idx on contacts c (cost=0.00..5303.84 rows=40243 width=85) (actual time=0.047..580.311 rows=40267 loops=1) + Filter: (lead_deleted IS NULL) + -> Sort (cost=75.65..76.37 rows=290 width=20) (actual time=55.935..65.502 rows=6462 loops=1) + Sort Key: p.id + -> Merge Join (cost=59.24..63.79 rows=290 width=20) (actual time=31.765..39.925 rows=395 loops=1) + Merge Cond: ("outer".id = "inner".sales_rep_id) + -> Sort (cost=2.42..2.52 rows=39 width=10) (actual time=1.072..1.117 rows=39 loops=1) + Sort Key: sr.id + -> Seq Scan on sales_reps sr (cost=0.00..1.39 rows=39 width=10) (actual time=0.022..0.312 rows=39 loops=1) + -> Sort (cost=56.82..57.55 rows=290 width=20) (actual time=30.489..30.893 rows=395 loops=1) + Sort Key: p.sales_rep_id + -> Nested Loop (cost=24.35..44.96 rows=290 width=20) (actual time=0.159..23.356 rows=395 loops=1) + Join Filter: ("inner".classification_id = "outer".id) + -> Seq Scan on partner_classification pc (cost=0.00..1.04 rows=2 width=10) (actual time=0.047..0.086 rows=2 loops=1) + Filter: ((classification)::text <> 'Sales Rep'::text) + -> Materialize (cost=24.35..28.70 rows=435 width=30) (actual time=0.028..6.124 rows=435 loops=2) + -> Seq Scan on partners p (cost=0.00..24.35 rows=435 width=30) (actual time=0.039..9.383 rows=435 loops=1) + Total runtime: 3241.139 ms +(43 rows) +----- + +The DISTINCT ON condition was about the same amount of time, +statistically. Removing the DISTINCT entirely only gave a +very slight improvement in performance. + +So, the bottom line is, unless there are other ideas to +improve the performance, I will most likely rewrite our +application to use the c.id IN () option. + +Thank you very much for your input and suggestions. + +JohnM + +-- +John Mendenhall +john@surfutopia.net +surf utopia +internet services + +From pgsql-performance-owner@postgresql.org Tue Aug 23 16:23:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D4D29D70F9 + for ; + Tue, 23 Aug 2005 16:23:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45934-04 + for ; + Tue, 23 Aug 2005 19:23:47 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F429D70B1 + for ; + Tue, 23 Aug 2005 16:23:46 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7NJNipF004588; + Tue, 23 Aug 2005 15:23:44 -0400 (EDT) +To: Donald Courtney +Cc: pgsql-performance@postgresql.org, Frank Wiles , + gokulnathbabu manoharan +Subject: Re: Caching by Postgres +In-reply-to: <430B6DE3.6040109@sun.com> +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> +Comments: In-reply-to Donald Courtney + message dated "Tue, 23 Aug 2005 14:41:39 -0400" +Date: Tue, 23 Aug 2005 15:23:43 -0400 +Message-ID: <4587.1124825023@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/351 +X-Sequence-Number: 14098 + +Donald Courtney writes: +> I am not alone in having the *expectation* that a database should have +> some cache size parameter and the option to skip the file system. If +> I use oracle, sybase, mysql and maxdb they all have the ability to +> size a data cache and move to 64 bits. + +And you're not alone in holding that opinion despite having no shred +of evidence that it's worthwhile expanding the cache that far. + +However, since we've gotten tired of hearing this FUD over and over, +8.1 will have the ability to set shared_buffers as high as you want. +I expect next we'll be hearing from people complaining that they +set shared_buffers to use all of RAM and performance went into the +tank ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 23 16:34:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BF3CD7121 + for ; + Tue, 23 Aug 2005 16:34:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61644-02 + for ; + Tue, 23 Aug 2005 19:34:51 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F34AD711A + for ; + Tue, 23 Aug 2005 16:34:50 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7916342; Tue, 23 Aug 2005 12:37:09 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +Date: Tue, 23 Aug 2005 12:38:04 -0700 +User-Agent: KMail/1.8 +Cc: Donald Courtney , Frank Wiles , + gokulnathbabu manoharan +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> +In-Reply-To: <430B6DE3.6040109@sun.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508231238.04844.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 required=5 tests=[AWL=-0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/352 +X-Sequence-Number: 14099 + +Donald, + +> This whole issue of data caching is a troubling issue with postreSQL +> in that even if you ran postgreSQL on a 64 bit address space +> with larger number of CPUs you won't see much of a scale up +> and possibly even a drop. + +Since when? Barring the context switch bug, you're not going to get a +drop with more processors/more RAM. + +You may fail to get any gain, though. If your database is only 100MB in +size, having 11G of cache space isn't going to help you much over having +only 1G. + +> I am not alone in having the *expectation* +> that a database should have some cache size parameter and +> the option to skip the file system. + +Sure, because that's the conventional wisdom, as writ by Oracle. However, +this comes with substantial code maintenance costs and portability +limitations which have to be measured against any gain in performance. + +> If I use oracle, sybase, mysql +> and maxdb they all have the ability to size a data cache and move +> to 64 bits. + +And yet, we regularly outperform Sybase and MySQL on heavy OLTP loads on +commodity x86 hardware. So apparently DB caching isn't everything. ;-) + +I'm not saying that it's not worth testing larger database caches -- even +taking over most of RAM -- on high-speed systems. In fact, I'm working +on doing that kind of test now. However, barring test results, we can't +assume that taking over RAM and the FS cache would have a substantial +performance benefit; that remains to be shown. + +The other thing is that we've had, and continue to have, low-hanging fruit +which have a clear and measurable effect on performance and are fixable +without bloating the PG code. Some of these issues (COPY path, context +switching, locks, GiST concurrency, some aggregates) have been addressed +in the 8.1 code; some remain to be addressed (sorts, disk spill, 64-bit +sort mem, other aggregates, index-only access, etc.). Why tackle a huge, +250-hour project which could fail when a 20-hour patch is more likely to +provide the same performance benefit? + +We have the same discussion (annually) about mmap. Using mmap *might* +provide us with a huge performance boost. However, it would *definitely* +require 300hours (or more) of programmer time to test properly, and might +not benefit us at all. + +Of course, if *you* want to work on large database cache improvements, be +my guest ... it's an open source project! Submit your patches! I'll be +happy to test them. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 23 17:18:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3DC9D7133 + for ; + Tue, 23 Aug 2005 17:13:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74871-09 + for ; + Tue, 23 Aug 2005 20:13:10 +0000 (GMT) +Received: from mail.envyfinancial.com (unknown [206.248.142.186]) + by svr1.postgresql.org (Postfix) with ESMTP id AF829D7116 + for ; + Tue, 23 Aug 2005 17:13:08 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envyfinancial.com (Postfix) with ESMTP id 21B801D062; + Tue, 23 Aug 2005 16:03:43 -0400 (EDT) +Received: from mail.envyfinancial.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 18870-05; Tue, 23 Aug 2005 16:03:42 -0400 (EDT) +Received: by mail.envyfinancial.com (Postfix, from userid 500) + id DD1241D069; Tue, 23 Aug 2005 16:03:42 -0400 (EDT) +Date: Tue, 23 Aug 2005 16:03:42 -0400 +From: mark@mark.mielke.cc +To: Donald Courtney +Cc: pgsql-performance@postgresql.org, Frank Wiles , + gokulnathbabu manoharan +Subject: Re: Caching by Postgres +Message-ID: <20050823200342.GA18891@mark.mielke.cc> +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <430B6DE3.6040109@sun.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envyfinancial.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.18 required=5 tests=[AWL=0.002, NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/353 +X-Sequence-Number: 14100 + +On Tue, Aug 23, 2005 at 02:41:39PM -0400, Donald Courtney wrote: +> I mean well with this comment - +> This whole issue of data caching is a troubling issue with postreSQL +> in that even if you ran postgreSQL on a 64 bit address space +> with larger number of CPUs you won't see much of a scale up +> and possibly even a drop. I am not alone in having the *expectation* +> that a database should have some cache size parameter and +> the option to skip the file system. If I use oracle, sybase, mysql +> and maxdb they all have the ability to size a data cache and move +> to 64 bits. +> Is this a crazy idea - that a project be started to get this adopted? +> Is it +> too big and structural to contemplate? +> From one who likes postgreSQL + +Hey Donald. :-) + +This is an operating system issue, not a PostgreSQL issue. If you have +more physical memory than fits in 32-bit addresses, and your operating +system isn't using this extra memory to cache files (or anything +else), than your OS is what I would consider to be broken (or at the +very least, not designed for a 64-bit host). + +The only questions that can be asked here is - 1) can PostgreSQL do a +better job than the OS at best utilizing system RAM, and 2) if so, is +the net gain worth the added complexity to PostgreSQL? + +I happen to think that yes, PostgreSQL can do a better job than most +OS's, as it has better information to make decisions as to which pages +are worth keeping, and which are not, but no, it isn't worth the +effort until PostgreSQL developers start running out of things to do. + +Buy your 64-bit platforms - but if page caching is your concern, 1) +ensure that you really have more physical memory than can fit in 32 +bits, and 2) ensure that your operating system is comfortable caching +data pages from files above the 32-bit mark. + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Tue Aug 23 17:37:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 49DD2D70FF + for ; + Tue, 23 Aug 2005 17:29:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91328-06 + for ; + Tue, 23 Aug 2005 20:29:34 +0000 (GMT) +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by svr1.postgresql.org (Postfix) with ESMTP id D9389D6FD9 + for ; + Tue, 23 Aug 2005 17:29:32 -0300 (ADT) +Received: from osgiliath.mathom.us ([151.200.14.55]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0ILO00DQIZL92XE1@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Tue, 23 Aug 2005 15:29:34 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 2B048602638; Tue, + 23 Aug 2005 16:29:33 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 04490-02; Tue, 23 Aug 2005 16:29:32 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id D9B07600162; Tue, 23 Aug 2005 16:29:32 -0400 (EDT) +Date: Tue, 23 Aug 2005 16:29:32 -0400 +From: Michael Stone +Subject: Re: Caching by Postgres +In-reply-to: <200508231238.04844.josh@agliodbs.com> +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Mail-Followup-To: Josh Berkus , + pgsql-performance@postgresql.org +Message-id: <20050823202932.GK8667@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> <430B6DE3.6040109@sun.com> + <200508231238.04844.josh@agliodbs.com> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/354 +X-Sequence-Number: 14101 + +On Tue, Aug 23, 2005 at 12:38:04PM -0700, Josh Berkus wrote: +>which have a clear and measurable effect on performance and are fixable +>without bloating the PG code. Some of these issues (COPY path, context +>switching + +Does that include increasing the size of read/write blocks? I've noticed +that with a large enough table it takes a while to do a sequential scan, +even if it's cached; I wonder if the fact that it takes a million +read(2) calls to get through an 8G table is part of that. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Tue Aug 23 17:42:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 82FF7D6FD7 + for ; + Tue, 23 Aug 2005 17:42:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05351-04 + for ; + Tue, 23 Aug 2005 20:42:18 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2637BD6FD5 + for ; + Tue, 23 Aug 2005 17:42:17 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 7CE7130B42; Tue, 23 Aug 2005 22:54:30 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Caching by Postgres +Date: Tue, 23 Aug 2005 16:41:33 -0400 +Organization: cbbrowne Computing Inc +Lines: 29 +Message-ID: <60slx0perm.fsf@dba2.int.libertyrms.com> +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:Z88FuvlZon01WvzFSgLpygDCH2g= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.115 required=5 tests=[AWL=0.115] +X-Spam-Level: +X-Archive-Number: 200508/355 +X-Sequence-Number: 14102 + +Donald.Courtney@Sun.COM (Donald Courtney) writes: +> I mean well with this comment - +> This whole issue of data caching is a troubling issue with postreSQL +> in that even if you ran postgreSQL on a 64 bit address space +> with larger number of CPUs you won't see much of a scale up +> and possibly even a drop. I am not alone in having the *expectation* +> that a database should have some cache size parameter and +> the option to skip the file system. If I use oracle, sybase, mysql +> and maxdb they all have the ability to size a data cache and move +> to 64 bits. +> +> Is this a crazy idea - that a project be started to get this +> adopted? Is it too big and structural to contemplate? + +This project amounts to "Implement Your Own Operating System," because +it requires that the DBMS take over the things that operating systems +normally do, like: + a) Managing access to filesystems and + b) Managing memory + +The world is already sufficiently filled up with numerous variations +of Linux, BSD 4.4 Lite, and UNIX System V; I can't see justification for +reinventing this wheel still again. +-- +(format nil "~S@~S" "cbbrowne" "acm.org") +http://cbbrowne.com/info/multiplexor.html +Rules of the Evil Overlord #196. "I will hire an expert marksman to +stand by the entrance to my fortress. His job will be to shoot anyone +who rides up to challenge me." + +From pgsql-performance-owner@postgresql.org Tue Aug 23 18:19:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EEDABD7093 + for ; + Tue, 23 Aug 2005 18:19:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28189-01 + for ; + Tue, 23 Aug 2005 21:19:51 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F2C9D7087 + for ; + Tue, 23 Aug 2005 18:19:49 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id B5A6E30B42; Tue, 23 Aug 2005 23:32:03 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Caching by Postgres +Date: Tue, 23 Aug 2005 17:17:42 -0400 +Organization: cbbrowne Computing Inc +Lines: 24 +Message-ID: <60oe7opd3d.fsf@dba2.int.libertyrms.com> +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> <200508231238.04844.josh@agliodbs.com> + <20050823202932.GK8667@mathom.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:RQHjE2QF6M4vONlqAnZ1A7VO1ho= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.114 required=5 tests=[AWL=0.114] +X-Spam-Level: +X-Archive-Number: 200508/356 +X-Sequence-Number: 14103 + +mstone+postgres@mathom.us (Michael Stone) writes: +> On Tue, Aug 23, 2005 at 12:38:04PM -0700, Josh Berkus wrote: +>> which have a clear and measurable effect on performance and are +>> fixable without bloating the PG code. Some of these issues (COPY +>> path, context switching +> +> Does that include increasing the size of read/write blocks? I've +> noticed that with a large enough table it takes a while to do a +> sequential scan, even if it's cached; I wonder if the fact that it +> takes a million read(2) calls to get through an 8G table is part of +> that. + +But behind the scenes, the OS is still going to have to evaluate the +"is this in cache?" question for each and every one of those pages. +(Assuming the kernel's page size is 8K; if it's smaller, the number of +evaluations will be even higher...) + +Grouping the read(2) calls together isn't going to have any impact on +_that_ evaluation. +-- +let name="cbbrowne" and tld="ntlug.org" in name ^ "@" ^ tld;; +http://www3.sympatico.ca/cbbrowne/finances.html +"People who don't use computers are more sociable, reasonable, and ... +less twisted" -- Arthur Norman + +From pgsql-performance-owner@postgresql.org Tue Aug 23 18:34:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C4FFD7087 + for ; + Tue, 23 Aug 2005 18:29:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30277-03 + for ; + Tue, 23 Aug 2005 21:29:02 +0000 (GMT) +Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34]) + by svr1.postgresql.org (Postfix) with ESMTP id B11A1D704D + for ; + Tue, 23 Aug 2005 18:29:00 -0300 (ADT) +Received: from phys-bur-1 ([129.148.9.72]) + by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id j7NLT2WV012413 + for ; + Tue, 23 Aug 2005 15:29:02 -0600 (MDT) +Received: from conversion-daemon.bur-mail1.east.sun.com by + bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0ILP00M012AL63@bur-mail1.east.sun.com> + (original mail from J.K.Shah@Sun.COM) for + pgsql-performance@postgresql.org; + Tue, 23 Aug 2005 17:29:02 -0400 (EDT) +Received: from bur-mail1.east.sun.com (phys-bur-1 [129.148.9.72]) + by bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTP id <0ILP00BW22CDYO@bur-mail1.east.sun.com>; Tue, + 23 Aug 2005 17:29:01 -0400 (EDT) +Received: from [129.148.168.2] by bur-mail1.east.sun.com (mshttpd); Tue, + 23 Aug 2005 17:29:01 -0400 +Date: Tue, 23 Aug 2005 17:29:01 -0400 +From: Jignesh Shah +Subject: Re: Read/Write block sizes (Was: Caching by Postgres) +To: Michael Stone +Cc: Josh Berkus , pgsql-performance@postgresql.org +Message-id: +MIME-version: 1.0 +X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.24 (built Dec 19 2003) +Content-type: text/plain; charset=us-ascii +Content-language: en +Content-transfer-encoding: 7BIT +Content-disposition: inline +X-Accept-Language: en +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/357 +X-Sequence-Number: 14104 + +> Does that include increasing the size of read/write blocks? I've +> noticedthat with a large enough table it takes a while to do a +> sequential scan, +> even if it's cached; I wonder if the fact that it takes a million +> read(2) calls to get through an 8G table is part of that. +> + + +Actually some of that readaheads,etc the OS does already if it does some sort of throttling/clubbing of reads/writes. But its not enough for such types of workloads. + +Here is what I think will help: + +* Support for different Blocksize TABLESPACE without recompiling the code.. (Atlease support for a different Blocksize for the whole database without recompiling the code) + +* Support for bigger sizes of WAL files instead of 16MB files WITHOUT recompiling the code.. Should be a tuneable if you ask me (with checkpoint_segments at 256.. you have too many 16MB files in the log directory) (This will help OLTP benchmarks more since now they don't spend time rotating log files) + +* Introduce a multiblock or extent tunable variable where you can define a multiple of 8K (or BlockSize tuneable) to read a bigger chunk and store it in the bufferpool.. (Maybe writes too) (Most devices now support upto 1MB chunks for reads and writes) + +*There should be a way to preallocate files for TABLES in TABLESPACES otherwise with multiple table writes in the same filesystem ends with fragmented files which causes poor "READS" from the files. + +* With 64bit 1GB file chunks is also moot.. Maybe it should be tuneable too like 100GB without recompiling the code. + + +Why recompiling is bad? Most companies that will support Postgres will support their own binaries and they won't prefer different versions of binaries for different blocksizes, different WAL file sizes, etc... and hence more function using the same set of binaries is more desirable in enterprise environments + + +Regards, +Jignesh + + + +From pgsql-performance-owner@postgresql.org Tue Aug 23 19:00:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 87428D7247 + for ; + Tue, 23 Aug 2005 19:00:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36467-07 + for ; + Tue, 23 Aug 2005 21:59:51 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 69A21D70CA + for ; + Tue, 23 Aug 2005 18:59:49 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id C599730B42; Wed, 24 Aug 2005 00:12:04 +0200 (MET DST) +From: William Yu +X-Newsgroups: pgsql.performance +Subject: Re: Caching by Postgres +Date: Tue, 23 Aug 2005 14:59:42 -0700 +Organization: Hub.Org Networking Services +Lines: 27 +Message-ID: +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +In-Reply-To: <430B6DE3.6040109@sun.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.016 required=5 tests=[AWL=0.016] +X-Spam-Level: +X-Archive-Number: 200508/358 +X-Sequence-Number: 14105 + +Donald Courtney wrote: +> in that even if you ran postgreSQL on a 64 bit address space +> with larger number of CPUs you won't see much of a scale up +> and possibly even a drop. I am not alone in having the *expectation* + +What's your basis for believing this is the case? Why would PostgreSQL's +dependence on the OS's caching/filesystem limit scalability? I know when +I went from 32bit to 64bit Linux, I got *HUGE* increases in performance +using the same amount of memory. And when I went from 2x1P to 2xDC, my +average cpu usage % dropped almost in half. + +> that a database should have some cache size parameter and +> the option to skip the file system. If I use oracle, sybase, mysql +> and maxdb they all have the ability to size a data cache and move +> to 64 bits. + +Josh Berkus has already mentioned this as conventional wisdom as written +by Oracle. This may also be legacy wisdom. Oracle/Sybase/etc has been +around for a long time; it was probably a clear performance win way back +when. Nowadays with how far open-source OS's have advanced, I'd take it +with a grain of salt and do my own performance analysis. I suspect the +big vendors wouldn't change their stance even if they knew it was no +longer true due to the support hassles. + +My personal experience with PostgreSQL. Dropping shared buffers from 2GB +to 750MB improved performance on my OLTP DB a good 25%. Going down from +750MB to 150MB was another +10%. + +From pgsql-performance-owner@postgresql.org Tue Aug 23 20:04:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E367FD722D + for ; + Tue, 23 Aug 2005 20:04:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46512-09 + for ; + Tue, 23 Aug 2005 23:04:03 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B147DD714E + for ; + Tue, 23 Aug 2005 20:04:01 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A1EF330B42; Wed, 24 Aug 2005 01:16:16 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Read/Write block sizes +Date: Tue, 23 Aug 2005 18:09:09 -0400 +Organization: cbbrowne Computing Inc +Lines: 75 +Message-ID: <60k6icpapm.fsf@dba2.int.libertyrms.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:FglkrWkAo9E+UnKEe6okIBqwugA= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.114 required=5 tests=[AWL=0.114] +X-Spam-Level: +X-Archive-Number: 200508/359 +X-Sequence-Number: 14106 + +J.K.Shah@Sun.COM (Jignesh Shah) writes: +>> Does that include increasing the size of read/write blocks? I've +>> noticedthat with a large enough table it takes a while to do a +>> sequential scan, even if it's cached; I wonder if the fact that it +>> takes a million read(2) calls to get through an 8G table is part of +>> that. +> +> Actually some of that readaheads,etc the OS does already if it does +> some sort of throttling/clubbing of reads/writes. But its not enough +> for such types of workloads. +> +> Here is what I think will help: +> +> * Support for different Blocksize TABLESPACE without recompiling the +> code.. (Atlease support for a different Blocksize for the whole +> database without recompiling the code) +> +> * Support for bigger sizes of WAL files instead of 16MB files +> WITHOUT recompiling the code.. Should be a tuneable if you ask me +> (with checkpoint_segments at 256.. you have too many 16MB files in +> the log directory) (This will help OLTP benchmarks more since now +> they don't spend time rotating log files) +> +> * Introduce a multiblock or extent tunable variable where you can +> define a multiple of 8K (or BlockSize tuneable) to read a bigger +> chunk and store it in the bufferpool.. (Maybe writes too) (Most +> devices now support upto 1MB chunks for reads and writes) +> +> *There should be a way to preallocate files for TABLES in +> TABLESPACES otherwise with multiple table writes in the same +> filesystem ends with fragmented files which causes poor "READS" from +> the files. +> +> * With 64bit 1GB file chunks is also moot.. Maybe it should be +> tuneable too like 100GB without recompiling the code. +> +> Why recompiling is bad? Most companies that will support Postgres +> will support their own binaries and they won't prefer different +> versions of binaries for different blocksizes, different WAL file +> sizes, etc... and hence more function using the same set of binaries +> is more desirable in enterprise environments + +Every single one of these still begs the question of whether the +changes will have a *material* impact on performance. + +What we have been finding, as RAID controllers get smarter, is that it +is getting increasingly futile to try to attach knobs to 'disk stuff;' +it is *way* more effective to add a few more spindles to an array than +it is to fiddle with which disks are to be allocated to what database +'objects.' + +The above suggested 'knobs' are all going to add to complexity and it +is NOT evident that any of them will forcibly help. + +I could be wrong; code contributions combined with Actual Benchmarking +would be the actual proof of the merits of the ideas. + +But it also suggests another question, namely... + + Will these represent more worthwhile improvements to speed than + working on other optimizations that are on the TODO list? + +If someone spends 100h working on one of these items, and gets a 2% +performance improvement, that's almost certain to be less desirable +than spending 50h on something else that gets a 4% improvement. + +And we might discover that memory management improvements in Linux +2.6.16 or FreeBSD 5.5 allow some OS kernels to provide some such +improvements "for free" behind our backs without *any* need to write +database code. :-) +-- +let name="cbbrowne" and tld="ntlug.org" in name ^ "@" ^ tld;; +http://www3.sympatico.ca/cbbrowne/postgresql.html +Wiener's Law of Libraries: + There are no answers, only cross references. + +From pgsql-performance-owner@postgresql.org Tue Aug 23 20:18:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A70AD71EC + for ; + Tue, 23 Aug 2005 20:18:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54190-02 + for ; + Tue, 23 Aug 2005 23:18:31 +0000 (GMT) +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by svr1.postgresql.org (Postfix) with ESMTP id 39959D70F9 + for ; + Tue, 23 Aug 2005 20:18:30 -0300 (ADT) +Received: from osgiliath.mathom.us ([151.200.14.55]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0ILP00DO57523IO1@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Tue, 23 Aug 2005 18:12:39 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id B1A87602638; Tue, + 23 Aug 2005 19:12:38 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 07218-04-8; Tue, 23 Aug 2005 19:12:38 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 86F56600162; Tue, 23 Aug 2005 19:12:38 -0400 (EDT) +Date: Tue, 23 Aug 2005 19:12:38 -0400 +From: Michael Stone +Subject: Re: Read/Write block sizes (Was: Caching by Postgres) +In-reply-to: +To: Jignesh Shah +Cc: pgsql-performance@postgresql.org +Mail-Followup-To: Jignesh Shah , + pgsql-performance@postgresql.org +Message-id: <20050823231238.GL8667@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.044 required=5 tests=[AWL=-0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/360 +X-Sequence-Number: 14107 + +On Tue, Aug 23, 2005 at 05:29:01PM -0400, Jignesh Shah wrote: +>Actually some of that readaheads,etc the OS does already if it does +>some sort of throttling/clubbing of reads/writes. + +Note that I specified the fully cached case--even with the workload in +RAM the system still has to process a heck of a lot of read calls. + +>* Introduce a multiblock or extent tunable variable where you can +>define a multiple of 8K (or BlockSize tuneable) to read a bigger chunk +>and store it in the bufferpool.. (Maybe writes too) (Most devices now +>support upto 1MB chunks for reads and writes) + +Yeah. The problem with relying on OS readahead is that the OS doesn't +know whether you're doing a sequential scan or an index scan; if you +have the OS agressively readahead you'll kill your seek performance. +OTOH, if you don't do readaheads you'll kill your sequential scan +performance. At the app level you know which makes sense for each +operation. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Tue Aug 23 20:24:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AED61D70DC + for ; + Tue, 23 Aug 2005 20:24:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56228-03 + for ; + Tue, 23 Aug 2005 23:24:27 +0000 (GMT) +Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) + by svr1.postgresql.org (Postfix) with ESMTP id 56816D702B + for ; + Tue, 23 Aug 2005 20:24:26 -0300 (ADT) +Received: from osgiliath.mathom.us ([151.200.14.55]) + by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0ILP00F4C7OO1K72@vms048.mailsrvcs.net> for + pgsql-performance@postgresql.org; Tue, 23 Aug 2005 18:24:25 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id A546E60067A; Tue, + 23 Aug 2005 19:24:24 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 07726-01-7; Tue, 23 Aug 2005 19:24:24 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 83C5D600162; Tue, 23 Aug 2005 19:24:24 -0400 (EDT) +Date: Tue, 23 Aug 2005 19:24:24 -0400 +From: Michael Stone +Subject: Re: Read/Write block sizes +In-reply-to: <60k6icpapm.fsf@dba2.int.libertyrms.com> +To: Chris Browne +Cc: pgsql-performance@postgresql.org +Mail-Followup-To: Chris Browne , + pgsql-performance@postgresql.org +Message-id: <20050823232424.GM8667@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/361 +X-Sequence-Number: 14108 + +On Tue, Aug 23, 2005 at 06:09:09PM -0400, Chris Browne wrote: +>What we have been finding, as RAID controllers get smarter, is that it +>is getting increasingly futile to try to attach knobs to 'disk stuff;' +>it is *way* more effective to add a few more spindles to an array than +>it is to fiddle with which disks are to be allocated to what database +>'objects.' + +That statement doesn't say anything about trying to maximize performance +to or from a disk array. Yes, controllers are getting smarter--but they +aren't omnicient. IME an I/O bound sequential table scan doesn't get +data moving off the disk nearly as fast as say, a dd with a big ibs. +Why? There's obviously a lot of factors at work, but one of those +factors is that the raid controller can optimize "grab this meg" a lot +more than it can optimize "grab this 8k". + +Mike Stone + +From pgsql-performance-owner@postgresql.org Tue Aug 23 20:29:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 79A8DD7217 + for ; + Tue, 23 Aug 2005 20:29:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53111-09 + for ; + Tue, 23 Aug 2005 23:29:43 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 70334D714A + for ; + Tue, 23 Aug 2005 20:29:41 -0300 (ADT) +Received: (qmail 32007 invoked from network); 24 Aug 2005 01:30:07 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 24 Aug 2005 01:30:07 +0200 +Date: Wed, 24 Aug 2005 01:29:42 +0200 +To: "William Yu" , pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/362 +X-Sequence-Number: 14109 + + +> Josh Berkus has already mentioned this as conventional wisdom as written +> by Oracle. This may also be legacy wisdom. Oracle/Sybase/etc has been +> around for a long time; it was probably a clear performance win way back +> when. Nowadays with how far open-source OS's have advanced, I'd take it +> with a grain of salt and do my own performance analysis. I suspect the +> big vendors wouldn't change their stance even if they knew it was no +> longer true due to the support hassles. + + Reinvent a filesystem... that would be suicidal. + + Now, Hans Reiser has expressed interest on the ReiserFS list in tweaking +his Reiser4 especially for Postgres. In his own words, he wants a "Killer +app for reiser4". Reiser4 will offser transactional semantics via a +special reiser4 syscall, so it might be possible, with a minimum of +changes to postgres (ie maybe just another sync mode besides fsync, +fdatasync et al) to use this. Other interesting details were exposed on +the reiser list, too (ie. a transactional filesystems can give ACID +guarantees to postgres without the need for fsync()). + + Very interesting. + +From pgsql-performance-owner@postgresql.org Tue Aug 23 20:36:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C4B0D6FFB + for ; + Tue, 23 Aug 2005 20:36:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56748-05 + for ; + Tue, 23 Aug 2005 23:36:20 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EF96D7157 + for ; + Tue, 23 Aug 2005 20:36:18 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id DD23E15289; Tue, 23 Aug 2005 18:36:08 -0500 (CDT) +Date: Tue, 23 Aug 2005 18:36:08 -0500 +From: "Jim C. Nasby" +To: Chris Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: Read/Write block sizes +Message-ID: <20050823233608.GA94425@pervasive.com> +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <60k6icpapm.fsf@dba2.int.libertyrms.com> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/363 +X-Sequence-Number: 14110 + +On Tue, Aug 23, 2005 at 06:09:09PM -0400, Chris Browne wrote: +> J.K.Shah@Sun.COM (Jignesh Shah) writes: +> >> Does that include increasing the size of read/write blocks? I've +> >> noticedthat with a large enough table it takes a while to do a +> >> sequential scan, even if it's cached; I wonder if the fact that it +> >> takes a million read(2) calls to get through an 8G table is part of +> >> that. +> > +> > Actually some of that readaheads,etc the OS does already if it does +> > some sort of throttling/clubbing of reads/writes. But its not enough +> > for such types of workloads. +> > +> > Here is what I think will help: +> > +> > * Support for different Blocksize TABLESPACE without recompiling the +> > code.. (Atlease support for a different Blocksize for the whole +> > database without recompiling the code) +> > +> > * Support for bigger sizes of WAL files instead of 16MB files +> > WITHOUT recompiling the code.. Should be a tuneable if you ask me +> > (with checkpoint_segments at 256.. you have too many 16MB files in +> > the log directory) (This will help OLTP benchmarks more since now +> > they don't spend time rotating log files) +> > +> > * Introduce a multiblock or extent tunable variable where you can +> > define a multiple of 8K (or BlockSize tuneable) to read a bigger +> > chunk and store it in the bufferpool.. (Maybe writes too) (Most +> > devices now support upto 1MB chunks for reads and writes) +> > +> > *There should be a way to preallocate files for TABLES in +> > TABLESPACES otherwise with multiple table writes in the same +> > filesystem ends with fragmented files which causes poor "READS" from +> > the files. +> > +> > * With 64bit 1GB file chunks is also moot.. Maybe it should be +> > tuneable too like 100GB without recompiling the code. +> > +> > Why recompiling is bad? Most companies that will support Postgres +> > will support their own binaries and they won't prefer different +> > versions of binaries for different blocksizes, different WAL file +> > sizes, etc... and hence more function using the same set of binaries +> > is more desirable in enterprise environments +> +> Every single one of these still begs the question of whether the +> changes will have a *material* impact on performance. + +How many of these things are currently easy to change with a recompile? +I should be able to start testing some of these ideas in the near +future, if they only require minor code or configure changes. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Aug 23 20:44:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 63494D71EC + for ; + Tue, 23 Aug 2005 20:44:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59901-03 + for ; + Tue, 23 Aug 2005 23:44:15 +0000 (GMT) +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 80621D714E + for ; + Tue, 23 Aug 2005 20:44:13 -0300 (ADT) +Received: from toonses.gghcwest.com (toonses.gghcwest.com [192.168.168.115]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id j7NNi8md020032; + Tue, 23 Aug 2005 16:44:09 -0700 +Received: from jwb by toonses.gghcwest.com with local (Exim 4.50) + id 1E7iR8-00044n-RC; Tue, 23 Aug 2005 16:44:10 -0700 +Subject: Re: Read/Write block sizes (Was: Caching by Postgres) +From: "Jeffrey W. Baker" +To: Michael Stone +Cc: Jignesh Shah , pgsql-performance@postgresql.org +In-Reply-To: <20050823231238.GL8667@mathom.us> +References: + <20050823231238.GL8667@mathom.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Tue, 23 Aug 2005 16:44:10 -0700 +Message-Id: <1124840650.12932.1.camel@toonses.gghcwest.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.3.6.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=-0.714 required=5 tests=[AWL=-0.764, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/365 +X-Sequence-Number: 14112 + +On Tue, 2005-08-23 at 19:12 -0400, Michael Stone wrote: +> On Tue, Aug 23, 2005 at 05:29:01PM -0400, Jignesh Shah wrote: +> >Actually some of that readaheads,etc the OS does already if it does +> >some sort of throttling/clubbing of reads/writes. +> +> Note that I specified the fully cached case--even with the workload in +> RAM the system still has to process a heck of a lot of read calls. +> +> >* Introduce a multiblock or extent tunable variable where you can +> >define a multiple of 8K (or BlockSize tuneable) to read a bigger chunk +> >and store it in the bufferpool.. (Maybe writes too) (Most devices now +> >support upto 1MB chunks for reads and writes) +> +> Yeah. The problem with relying on OS readahead is that the OS doesn't +> know whether you're doing a sequential scan or an index scan; if you +> have the OS agressively readahead you'll kill your seek performance. +> OTOH, if you don't do readaheads you'll kill your sequential scan +> performance. At the app level you know which makes sense for each +> operation. + +This is why we have MADVISE_RANDOM and MADVISE_SEQUENTIAL. + +-jwb + +From pgsql-performance-owner@postgresql.org Tue Aug 23 20:40:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 746D4D7261 + for ; + Tue, 23 Aug 2005 20:39:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59110-01 + for ; + Tue, 23 Aug 2005 23:39:06 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id 418FBD722D + for ; + Tue, 23 Aug 2005 20:39:05 -0300 (ADT) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Tue, 23 Aug 2005 16:42:56 -0700 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Tue, 23 Aug 2005 16:42:52 -0700 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005082316425204244 + for ; + Tue, 23 Aug 2005 16:42:52 -0700 +X-ASG-Debug-ID: 1124840343-17072-0-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail1 (mail1.hq.corp [192.168.160.5]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id 435AC20362F7 + for ; + Tue, 23 Aug 2005 16:39:03 -0700 (PDT) +Received: from amd64-laptop-spoe ([63.206.203.145]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.1830); Tue, 23 Aug 2005 16:42:49 -0700 +X-ASG-Orig-Subj: Re: [PERFORM] Read/Write block sizes +Subject: Re: Read/Write block sizes +From: Steve Poe +To: Chris Browne +Cc: pgsql-performance@postgresql.org +In-Reply-To: <60k6icpapm.fsf@dba2.int.libertyrms.com> +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> +Content-Type: text/plain +Date: Wed, 24 Aug 2005 01:25:43 +0000 +Message-Id: <1124846743.12045.94.camel@amd64-laptop-spoe> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 23 Aug 2005 23:42:49.0984 (UTC) + FILETIME=[5F45C800:01C5A83C] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: 2.00 +X-Barracuda-Spam-Status: No, SCORE=2.00 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_80 +X-Barracuda-Spam-Report: Code version 3.02, rules version 3.0.3434 + Rule breakdown below pts rule name description + ---- ---------------------- + -------------------------------------------------- + 2.00 BAYES_80 BODY: Bayesian spam probability is 80 to 95% + [score: 0.8081] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.205 required=5 tests=[AWL=0.155, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/364 +X-Sequence-Number: 14111 + +Chris, + +Unless I am wrong, you're making the assumpting the amount of time spent +and ROI is known. Maybe those who've been down this path know how to get +that additional 2-4% in 30 minutes or less? + +While each person and business' performance gains (or not) could vary, +someone spending the 50-100h to gain 2-4% over a course of a month for a +24x7 operation would seem worth the investment? + +I would assume that dbt2 with STP helps minimize the amount of hours +someone has to invest to determine performance gains with configurable +options? + +Steve Poe + +> If someone spends 100h working on one of these items, and gets a 2% +> performance improvement, that's almost certain to be less desirable +> than spending 50h on something else that gets a 4% improvement. +> +> And we might discover that memory management improvements in Linux +> 2.6.16 or FreeBSD 5.5 allow some OS kernels to provide some such +> improvements "for free" behind our backs without *any* need to write +> database code. :-) + + +From pgsql-performance-owner@postgresql.org Tue Aug 23 23:11:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 207F1D725F + for ; + Tue, 23 Aug 2005 23:10:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02461-02 + for ; + Wed, 24 Aug 2005 02:10:56 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id D6914D71FC + for ; + Tue, 23 Aug 2005 23:10:49 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7919635; Tue, 23 Aug 2005 19:13:11 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +Date: Tue, 23 Aug 2005 19:11:58 -0700 +User-Agent: KMail/1.8 +Cc: PFC , "William Yu" +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200508231911.59100.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 required=5 tests=[AWL=0.011] +X-Spam-Level: +X-Archive-Number: 200508/366 +X-Sequence-Number: 14113 + +PFC, + +> =A0=A0=A0=A0=A0=A0=A0=A0Now, Hans Reiser has expressed interest on the Re= +iserFS list in +> tweaking =A0 his Reiser4 especially for Postgres. In his own words, he wa= +nts +> a "Killer app for reiser4". Reiser4 will offser transactional semantics v= +ia +> a special reiser4 syscall, so it might be possible, with a minimum of +> changes to postgres (ie maybe just another sync mode besides fsync, +> fdatasync et al) to use this. Other interesting details were exposed on t= +he +> reiser list, too (ie. a transactional filesystems can give ACID guarantees +> to postgres without the need for fsync()). + +Really? Cool, I'd like to see that. Could you follow up with Hans? Or g= +ive=20 +me his e-mail? + +=2D-=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 23 23:26:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A14A2D70DC + for ; + Tue, 23 Aug 2005 23:25:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09234-09 + for ; + Wed, 24 Aug 2005 02:25:56 +0000 (GMT) +Received: from brmea-mail-4.sun.com (brmea-mail-4.Sun.COM [192.18.98.36]) + by svr1.postgresql.org (Postfix) with ESMTP id C82D2D70CF + for ; + Tue, 23 Aug 2005 23:25:54 -0300 (ADT) +Received: from phys-bur-1 ([129.148.9.72]) + by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id j7O2PwTa016676 + for ; + Tue, 23 Aug 2005 20:25:59 -0600 (MDT) +Received: from conversion-daemon.bur-mail1.east.sun.com by + bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0ILP00H01G2OKS@bur-mail1.east.sun.com> + (original mail from J.K.Shah@Sun.COM) for + pgsql-performance@postgresql.org; + Tue, 23 Aug 2005 22:25:58 -0400 (EDT) +Received: from [129.150.32.236] + (vpn-129-150-32-236.Central.Sun.COM [129.150.32.236]) + by bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTPA id <0ILP0092LG3910@bur-mail1.east.sun.com>; Tue, + 23 Aug 2005 22:25:58 -0400 (EDT) +Date: Tue, 23 Aug 2005 22:22:04 -0400 +From: "Jignesh K. Shah" +Subject: Re: Read/Write block sizes +In-reply-to: <20050823233608.GA94425@pervasive.com> +To: "Jim C. Nasby" +Cc: Chris Browne , pgsql-performance@postgresql.org +Message-id: <430BD9CC.3030306@sun.com> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <20050823233608.GA94425@pervasive.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/367 +X-Sequence-Number: 14114 + +Hi Jim, + +| How many of these things are currently easy to change with a recompile? +| I should be able to start testing some of these ideas in the near +| future, if they only require minor code or configure changes. + + +The following +* Data File Size 1GB +* WAL File Size of 16MB +* Block Size of 8K + +Are very easy to change with a recompile.. A Tunable will be greatly +prefered as it will allow one binary for different tunings + +* MultiBlock read/write + +Is not available but will greatly help in reducing the number of system +calls which will only increase as the size of the database increases if +something is not done about i. + +* Pregrown files... maybe not important at this point since TABLESPACE +can currently work around it a bit (Just need to create a different file +system for each tablespace + +But if you really think hardware & OS is the answer for all small +things...... I think we should now start to look on how to make Postgres +Multi-threaded or multi-processed for each connection. With the influx +of "Dual-Core" or "Multi-Core" being the fad.... Postgres can have the +cutting edge if somehow exploiting cores is designed. + +Somebody mentioned that adding CPU to Postgres workload halved the +average CPU usage... +YEAH... PostgreSQL uses only 1 CPU per connection (assuming 100% +usage) so if you add another CPU it is idle anyway and the system will +report only 50% :-) BUT the importing to measure is.. whether the query +time was cut down or not? ( No flames I am sure you were talking about +multi-connection multi-user environment :-) ) But my point is then this +approach is worth the ROI and the time and effort spent to solve this +problem. + +I actually vote for a multi-threaded solution for each connection while +still maintaining seperate process for each connections... This way the +fundamental architecture of Postgres doesn't change, however a +multi-threaded connection can then start to exploit different cores.. +(Maybe have tunables for number of threads to read data files who +knows.. If somebody is interested in actually working a design .. +contact me and I will be interested in assisting this work. + +Regards, +Jignesh + + +Jim C. Nasby wrote: + +>On Tue, Aug 23, 2005 at 06:09:09PM -0400, Chris Browne wrote: +> +> +>>J.K.Shah@Sun.COM (Jignesh Shah) writes: +>> +>> +>>>>Does that include increasing the size of read/write blocks? I've +>>>>noticedthat with a large enough table it takes a while to do a +>>>>sequential scan, even if it's cached; I wonder if the fact that it +>>>>takes a million read(2) calls to get through an 8G table is part of +>>>>that. +>>>> +>>>> +>>>Actually some of that readaheads,etc the OS does already if it does +>>>some sort of throttling/clubbing of reads/writes. But its not enough +>>>for such types of workloads. +>>> +>>>Here is what I think will help: +>>> +>>>* Support for different Blocksize TABLESPACE without recompiling the +>>>code.. (Atlease support for a different Blocksize for the whole +>>>database without recompiling the code) +>>> +>>>* Support for bigger sizes of WAL files instead of 16MB files +>>>WITHOUT recompiling the code.. Should be a tuneable if you ask me +>>>(with checkpoint_segments at 256.. you have too many 16MB files in +>>>the log directory) (This will help OLTP benchmarks more since now +>>>they don't spend time rotating log files) +>>> +>>>* Introduce a multiblock or extent tunable variable where you can +>>>define a multiple of 8K (or BlockSize tuneable) to read a bigger +>>>chunk and store it in the bufferpool.. (Maybe writes too) (Most +>>>devices now support upto 1MB chunks for reads and writes) +>>> +>>>*There should be a way to preallocate files for TABLES in +>>>TABLESPACES otherwise with multiple table writes in the same +>>>filesystem ends with fragmented files which causes poor "READS" from +>>>the files. +>>> +>>>* With 64bit 1GB file chunks is also moot.. Maybe it should be +>>>tuneable too like 100GB without recompiling the code. +>>> +>>>Why recompiling is bad? Most companies that will support Postgres +>>>will support their own binaries and they won't prefer different +>>>versions of binaries for different blocksizes, different WAL file +>>>sizes, etc... and hence more function using the same set of binaries +>>>is more desirable in enterprise environments +>>> +>>> +>>Every single one of these still begs the question of whether the +>>changes will have a *material* impact on performance. +>> +>> + + +From pgsql-performance-owner@postgresql.org Tue Aug 23 23:31:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D1DB9D71F9 + for ; + Tue, 23 Aug 2005 23:30:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41174-03 + for ; + Wed, 24 Aug 2005 02:30:21 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 1309DD70DC + for ; + Tue, 23 Aug 2005 23:30:20 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7919862; Tue, 23 Aug 2005 19:32:42 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Read/Write block sizes +Date: Tue, 23 Aug 2005 19:31:29 -0700 +User-Agent: KMail/1.8 +Cc: Steve Poe , Chris Browne +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> +In-Reply-To: <1124846743.12045.94.camel@amd64-laptop-spoe> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508231931.29682.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 required=5 tests=[AWL=0.011] +X-Spam-Level: +X-Archive-Number: 200508/368 +X-Sequence-Number: 14115 + +Steve, + +> I would assume that dbt2 with STP helps minimize the amount of hours +> someone has to invest to determine performance gains with configurable +> options? + +Actually, these I/O operation issues show up mainly with DW workloads, so the +STP isn't much use there. If I can ever get some of these machines back +from the build people, I'd like to start testing some stuff. + +One issue with testing this is that currently PostgreSQL doesn't support block +sizes above 128K. We've already done testing on that (well, Mark has) and +the performance gains aren't even worth the hassle of remembering you're on a +different block size (like, +4%). + +What the Sun people have done with other DB systems is show that substantial +performance gains are possible on large databases (>100G) using block sizes +of 1MB. I believe that's possible (and that it probably makes more of a +difference on Solaris than on BSD) but we can't test it without some hackery +first. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Aug 24 01:44:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 258C8D7267 + for ; + Wed, 24 Aug 2005 01:44:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83728-08 + for ; + Wed, 24 Aug 2005 04:44:07 +0000 (GMT) +Received: from mail21.sea5.speakeasy.net (mail21.sea5.speakeasy.net + [69.17.117.23]) + by svr1.postgresql.org (Postfix) with ESMTP id 811B0D7012 + for ; + Wed, 24 Aug 2005 00:06:42 -0300 (ADT) +Received: (qmail 23271 invoked from network); 24 Aug 2005 03:06:37 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail21.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 24 Aug 2005 03:06:37 -0000 +Subject: Re: Read/Write block sizes +From: "Jeffrey W. Baker" +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, Steve Poe , + Chris Browne +In-Reply-To: <200508231931.29682.josh@agliodbs.com> +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> + <200508231931.29682.josh@agliodbs.com> +Content-Type: text/plain +Date: Tue, 23 Aug 2005 20:07:34 -0700 +Message-Id: <1124852854.11147.5.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/371 +X-Sequence-Number: 14118 + +On Tue, 2005-08-23 at 19:31 -0700, Josh Berkus wrote: +> Steve, +> +> > I would assume that dbt2 with STP helps minimize the amount of hours +> > someone has to invest to determine performance gains with configurable +> > options? +> +> Actually, these I/O operation issues show up mainly with DW workloads, so the +> STP isn't much use there. If I can ever get some of these machines back +> from the build people, I'd like to start testing some stuff. +> +> One issue with testing this is that currently PostgreSQL doesn't support block +> sizes above 128K. We've already done testing on that (well, Mark has) and +> the performance gains aren't even worth the hassle of remembering you're on a +> different block size (like, +4%). +> +> What the Sun people have done with other DB systems is show that substantial +> performance gains are possible on large databases (>100G) using block sizes +> of 1MB. I believe that's possible (and that it probably makes more of a +> difference on Solaris than on BSD) but we can't test it without some hackery +> first. + +To get decent I/O you need 1MB fundamental units all the way down the +stack. You need a filesystem that can take a 1MB write well, and you +need an I/O scheduler that will keep it together, and you need a storage +controller that can eat a 1MB request at once. Ideally you'd like an +architecture with a 1MB page (Itanium has this, and AMD64 Linux will +soon have this.) The Lustre people have done some work in this area, +opening up the datapaths in the kernel so they can keep the hardware +really working. They even modified the QLogic SCSI/FC driver so it +supports such large transfers. Their work has shown that you can get +significant perf boost on Linux just by thinking in terms of larger +transfers. + +Unfortunately I'm really afraid that this conversation is about trees +when the forest is the problem. PostgreSQL doesn't even have an async +reader, which is the sort of thing that could double or triple its +performance. You're talking about block sizes and such, but the kinds +of improvements you can get there are in the tens of percents at most. + +-jwb + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 01:22:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 71784D70DC + for ; + Wed, 24 Aug 2005 01:22:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31461-10 + for ; + Wed, 24 Aug 2005 04:22:30 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id C598DD710D + for ; + Wed, 24 Aug 2005 01:22:28 -0300 (ADT) +Received: from wren.rentec.com (wren.rentec.com [192.5.35.106]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j7O4LLYC017574 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Wed, 24 Aug 2005 00:21:22 -0400 (EDT) +X-Rentec: external +Received: from [172.16.160.108] (stange-dhcp2.rentec.com [172.16.160.108]) + by wren.rentec.com (8.13.1/8.12.1) with ESMTP id j7O4LIla011044; + Wed, 24 Aug 2005 00:21:18 -0400 (EDT) +Message-ID: <430BF0DA.5010002@rentec.com> +Date: Wed, 24 Aug 2005 00:00:26 -0400 +From: Alan Stange +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, Steve Poe , + Chris Browne +Subject: Re: Read/Write block sizes +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> + <200508231931.29682.josh@agliodbs.com> +In-Reply-To: <200508231931.29682.josh@agliodbs.com> +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as j7O4LLYC017574 at Wed Aug 24 + 00:21:22 2005 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/369 +X-Sequence-Number: 14116 + +Josh Berkus wrote: + +>Steve, +> +> +> +>>I would assume that dbt2 with STP helps minimize the amount of hours +>>someone has to invest to determine performance gains with configurable +>>options? +>> +>> +> +>Actually, these I/O operation issues show up mainly with DW workloads, so the +>STP isn't much use there. If I can ever get some of these machines back +>from the build people, I'd like to start testing some stuff. +> +>One issue with testing this is that currently PostgreSQL doesn't support block +>sizes above 128K. We've already done testing on that (well, Mark has) and +>the performance gains aren't even worth the hassle of remembering you're on a +>different block size (like, +4%). +> +> +What size database was this on? + +>What the Sun people have done with other DB systems is show that substantial +>performance gains are possible on large databases (>100G) using block sizes +>of 1MB. I believe that's possible (and that it probably makes more of a +>difference on Solaris than on BSD) but we can't test it without some hackery +>first. +> +We're running on a 100+GB database, with long streams of 8KB reads with +the occasional _llseek(). I've been thinking about running with a +larger blocksize with the expectation that we'd see fewer system calls +and a bit more throughput. + +read() calls are a very expensive way to get 8KB of memory (that we know +is already resident) during scans. One has to trap into the kernel, do +the usual process state accounting, find the block, copy the memory to +userspace, return back from the kernel to user space reversing all the +process accounting, pick out the bytes one needs, and repeat all over +again. That's quite a few sacrificial cache lines for 8KB. Yeah, +sure, Linux syscalls are fast, but they aren't that fast, and other +operating systems (windows and solaris) have a bit more overhead on +syscalls. + +Regarding large blocks sizes on Solaris: the Solaris folks can also use +large memory pages and avoid a lot of the TLB overhead from the VM +system. The various trapstat and cpustat commands can be quite +interesting to look at when running any large application on a Solaris +system. + +It should be noted that having a large shared memory segment can be a +performance looser just from the standpoint of TLB thrashing. O(GB) +memory access patterns can take a huge performance hit in user space +with 4K pages compared to the kernel which would be mapping the "segmap" +(in Solaris parlance) with 4MB pages. + +Anyway, I guess my point is that the balance between kernel managed vs. +postgresql managed buffer isn't obvious at all. + +-- Alan + +From pgsql-performance-owner@postgresql.org Wed Aug 24 01:38:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A9573D7279 + for ; + Wed, 24 Aug 2005 01:38:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82631-05 + for ; + Wed, 24 Aug 2005 04:38:15 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id BDD83D7116 + for ; + Wed, 24 Aug 2005 01:38:12 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j7O4c3Aj005242; + Wed, 24 Aug 2005 14:38:04 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j7O4c2Ef005239; Wed, 24 Aug 2005 14:38:03 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Wed, 24 Aug 2005 14:38:02 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: PFC +Cc: William Yu , pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +In-Reply-To: +Message-ID: +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> <430B6DE3.6040109@sun.com> + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.002 required=5 tests=[AWL=0.002] +X-Spam-Level: +X-Archive-Number: 200508/370 +X-Sequence-Number: 14117 + +On Wed, 24 Aug 2005, PFC wrote: + +> +> > Josh Berkus has already mentioned this as conventional wisdom as written +> > by Oracle. This may also be legacy wisdom. Oracle/Sybase/etc has been +> > around for a long time; it was probably a clear performance win way back +> > when. Nowadays with how far open-source OS's have advanced, I'd take it +> > with a grain of salt and do my own performance analysis. I suspect the +> > big vendors wouldn't change their stance even if they knew it was no +> > longer true due to the support hassles. +> +> Reinvent a filesystem... that would be suicidal. +> +> Now, Hans Reiser has expressed interest on the ReiserFS list in tweaking +> his Reiser4 especially for Postgres. In his own words, he wants a "Killer +> app for reiser4". Reiser4 will offser transactional semantics via a +> special reiser4 syscall, so it might be possible, with a minimum of +> changes to postgres (ie maybe just another sync mode besides fsync, +> fdatasync et al) to use this. Other interesting details were exposed on +> the reiser list, too (ie. a transactional filesystems can give ACID +> guarantees to postgres without the need for fsync()). +> +> Very interesting. + +Ummm... I don't see anything here which will be a win for Postgres. The +transactional semantics we're interested in are fairly complex: + +1) Modifications to multiple objects can become visible to the system +atomically +2) On error, a series of modifications which had been grouped together +within a transaction can be rolled back +3) Using object version information, determine which version of which +object is visible to a given session +4) Using version information and locking, detect and resolve read/write +and write/write conflicts + +Now, I can see a file system offering (1) and (2). But a file system that +can allow people to do (3) and (4) would require that we make *major* +modifications to how postgresql is implemented. More over, it would be for +no gain, since we've already written a system which can do it. + +A filesystem could, in theory, help us by providing an API which allows us +to tell the file system either: the way we'd like it to read ahead, the +fact that we don't want it to read ahead or the way we'd like it to cache +(or not cache) data. The thing is, most OSes provide interfaces to do this +already and we make only little use of them (I'm think of +madv_sequential(), madv_random(), POSIX fadvise(), the various flags to +open() which AIX, HPUX, Solaris provide). + +Gavin + +From pgsql-performance-owner@postgresql.org Wed Aug 24 02:07:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C7DA3D7012 + for ; + Wed, 24 Aug 2005 02:07:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33799-04 + for ; + Wed, 24 Aug 2005 05:07:34 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C1D4ED6DC2 + for ; + Wed, 24 Aug 2005 02:07:32 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7O57Mw2021393; + Wed, 24 Aug 2005 01:07:22 -0400 (EDT) +To: Gavin Sherry +Cc: PFC , William Yu , + pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +In-reply-to: +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + + +Comments: In-reply-to Gavin Sherry + message dated "Wed, 24 Aug 2005 14:38:02 +1000" +Date: Wed, 24 Aug 2005 01:07:22 -0400 +Message-ID: <21392.1124860042@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/372 +X-Sequence-Number: 14119 + +Gavin Sherry writes: +> A filesystem could, in theory, help us by providing an API which allows us +> to tell the file system either: the way we'd like it to read ahead, the +> fact that we don't want it to read ahead or the way we'd like it to cache +> (or not cache) data. The thing is, most OSes provide interfaces to do this +> already and we make only little use of them (I'm think of +> madv_sequential(), madv_random(), POSIX fadvise(), the various flags to +> open() which AIX, HPUX, Solaris provide). + +Yeah ... the main reason we've not spent too much time on that sort of +stuff is that *it's not portable*. And with all due respect to Hans, +special tweaks for one filesystem are even less interesting than special +tweaks for one OS. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 24 02:13:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E7963D7319 + for ; + Wed, 24 Aug 2005 02:10:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33871-08 + for ; + Wed, 24 Aug 2005 05:10:28 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D8EDAD731E + for ; + Wed, 24 Aug 2005 02:10:27 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7O5AKam021416; + Wed, 24 Aug 2005 01:10:20 -0400 (EDT) +To: "Jeffrey W. Baker" +Cc: Josh Berkus , + pgsql-performance@postgresql.org, Steve Poe , + Chris Browne +Subject: Re: Read/Write block sizes +In-reply-to: <1124852854.11147.5.camel@noodles> +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> + <200508231931.29682.josh@agliodbs.com> + <1124852854.11147.5.camel@noodles> +Comments: In-reply-to "Jeffrey W. Baker" + message dated "Tue, 23 Aug 2005 20:07:34 -0700" +Date: Wed, 24 Aug 2005 01:10:20 -0400 +Message-ID: <21415.1124860220@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/373 +X-Sequence-Number: 14120 + +"Jeffrey W. Baker" writes: +> To get decent I/O you need 1MB fundamental units all the way down the +> stack. + +It would also be a good idea to have an application that isn't likely +to change a single bit in a 1MB range and then expect you to record +that change. This pretty much lets Postgres out of the picture. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 24 02:20:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F0D24D6F0F + for ; + Wed, 24 Aug 2005 02:20:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50726-08 + for ; + Wed, 24 Aug 2005 05:20:35 +0000 (GMT) +Received: from serv-0.esphion.com (serv-0.esphion.com [202.55.97.148]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B240D6EA5 + for ; + Wed, 24 Aug 2005 02:20:29 -0300 (ADT) +Received: from conker.alb-nz.esphion.com ([10.0.1.137] + helo=conker.esphion.com) + by serv-0.esphion.com with smtp (Exim 4.50) + id 1E7ngW-0000K9-1g; Wed, 24 Aug 2005 17:20:24 +1200 +Received: (nullmailer pid 1553 invoked by uid 10001); + Wed, 24 Aug 2005 05:20:24 -0000 +Date: Wed, 24 Aug 2005 17:20:23 +1200 +From: Guy Thornley +To: "Jeffrey W. Baker" +Cc: Josh Berkus , + pgsql-performance@postgresql.org, Steve Poe , + Chris Browne +Subject: Re: Read/Write block sizes +Message-ID: <20050824052023.GB31806@conker.esphion.com> +Reply-To: Guy Thornley +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> + <200508231931.29682.josh@agliodbs.com> + <1124852854.11147.5.camel@noodles> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1124852854.11147.5.camel@noodles> +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/374 +X-Sequence-Number: 14121 + +> Unfortunately I'm really afraid that this conversation is about trees +> when the forest is the problem. PostgreSQL doesn't even have an async +> reader, which is the sort of thing that could double or triple its +> performance. You're talking about block sizes and such, but the kinds +> of improvements you can get there are in the tens of percents at most. + +Not 100% sure, but I'm fairly cirtain we were seeing significant performance +degradation by too much _scheduled_ I/O activity + +ie: too much work being submitted to the kernel, due to excessive +parallelism already!! + +The classic example of this is a seqscan being interleved by a index scan, +and the disks end up doing nothing but seek activity + +Out of all the stuff talked about on this thread so far, only tweaking the +block size (and the madvise() stuff) makes any real-world sense, as its the +only thing talked about that increases the _work_per_seek_. + +As for the async IO, sure you might think 'oh async IO would be so cool!!' +and I did, once, too. But then I sat down and _thought_ about it, and +decided well, no, actually, theres _very_ few areas it could actually help, +and in most cases it just make it easier to drive your box into lseek() +induced IO collapse. + +Dont forget that already in postgres, you have a process per connection, and +all the processes take care of their own I/O. + +Somebody mentioned having threaded backends too, but the only benefit would +be reduced memory footprint (a backend consumes 1-2MB of RAM, which is +almost enough to be a concern for largish systems with a lot of backends) +but personally I _know_ the complixities introduced through threading are +usually not worth it. + + +IMVVHO (naive experience) what is needed is a complete architecture change +(probably infeasible and only useful as a thought experiment), where: + +* a network I/O process deals with client connections +* a limited pool of worker processes deal with statements (perhaps related + to number of spindles somehow) + +so when a client issues a statement, the net-IO process simply forwards the +connection state to a worker process and says 'deal with this'. +(Clearly the state object needs to contain all user and transaction state +the connection is involved in). + +- Guy Thornley + +From pgsql-performance-owner@postgresql.org Wed Aug 24 02:24:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 55C5DD710D + for ; + Wed, 24 Aug 2005 02:24:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64207-08 + for ; + Wed, 24 Aug 2005 05:24:15 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id BFD1BD7093 + for ; + Wed, 24 Aug 2005 02:24:13 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j7O5O7Ja005621; + Wed, 24 Aug 2005 15:24:07 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + j7O5O75h005618; Wed, 24 Aug 2005 15:24:07 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Wed, 24 Aug 2005 15:24:07 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Tom Lane +Cc: PFC , William Yu , + pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +In-Reply-To: <21392.1124860042@sss.pgh.pa.us> +Message-ID: +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> <430B6DE3.6040109@sun.com> + + + <21392.1124860042@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.002 required=5 tests=[AWL=0.002] +X-Spam-Level: +X-Archive-Number: 200508/375 +X-Sequence-Number: 14122 + +On Wed, 24 Aug 2005, Tom Lane wrote: + +> Gavin Sherry writes: +> > A filesystem could, in theory, help us by providing an API which allows us +> > to tell the file system either: the way we'd like it to read ahead, the +> > fact that we don't want it to read ahead or the way we'd like it to cache +> > (or not cache) data. The thing is, most OSes provide interfaces to do this +> > already and we make only little use of them (I'm think of +> > madv_sequential(), madv_random(), POSIX fadvise(), the various flags to +> > open() which AIX, HPUX, Solaris provide). +> +> Yeah ... the main reason we've not spent too much time on that sort of +> stuff is that *it's not portable*. And with all due respect to Hans, +> special tweaks for one filesystem are even less interesting than special +> tweaks for one OS. + +Right. + +As an aside, it seems to me that if there is merit in all this low level +interaction with the file system (not to mention the other platform +specific microoptimisations which come up regularly on the lists) then the +companies currently producing niche commercial releases of PostgreSQL +should be taking advantage of them: if it increases performance, then +there's a reason to buy as opposed to just downloading the OSS version. + +Gavin + +From pgsql-performance-owner@postgresql.org Wed Aug 24 02:24:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AFA38D7215 + for ; + Wed, 24 Aug 2005 02:24:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77847-05 + for ; + Wed, 24 Aug 2005 05:24:25 +0000 (GMT) +Received: from mail28.sea5.speakeasy.net (mail28.sea5.speakeasy.net + [69.17.117.30]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A990D7268 + for ; + Wed, 24 Aug 2005 02:24:23 -0300 (ADT) +Received: (qmail 5444 invoked from network); 24 Aug 2005 05:24:23 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail28.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 24 Aug 2005 05:24:23 -0000 +Subject: Re: Read/Write block sizes +From: "Jeffrey W. Baker" +To: Guy Thornley +Cc: Josh Berkus , + pgsql-performance@postgresql.org, Steve Poe , + Chris Browne +In-Reply-To: <20050824052023.GB31806@conker.esphion.com> +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> + <200508231931.29682.josh@agliodbs.com> + <1124852854.11147.5.camel@noodles> + <20050824052023.GB31806@conker.esphion.com> +Content-Type: text/plain +Date: Tue, 23 Aug 2005 22:25:21 -0700 +Message-Id: <1124861121.11270.1.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/376 +X-Sequence-Number: 14123 + +On Wed, 2005-08-24 at 17:20 +1200, Guy Thornley wrote: +> As for the async IO, sure you might think 'oh async IO would be so cool!!' +> and I did, once, too. But then I sat down and _thought_ about it, and +> decided well, no, actually, theres _very_ few areas it could actually help, +> and in most cases it just make it easier to drive your box into lseek() +> induced IO collapse. +> +> Dont forget that already in postgres, you have a process per connection, and +> all the processes take care of their own I/O. + +That's the problem. Instead you want 1 or 4 or 10 i/o slaves +coordinating the I/O of all the backends optimally. For instance, with +synchronous scanning. + +-jwb + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 02:57:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D91E0D725B + for ; + Wed, 24 Aug 2005 02:57:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22522-05 + for ; + Wed, 24 Aug 2005 05:57:29 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F235D7233 + for ; + Wed, 24 Aug 2005 02:57:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7O5ui65021701; + Wed, 24 Aug 2005 01:56:44 -0400 (EDT) +To: "Jeffrey W. Baker" +Cc: Guy Thornley , Josh Berkus , + pgsql-performance@postgresql.org, Steve Poe , + Chris Browne +Subject: Re: Read/Write block sizes +In-reply-to: <1124861121.11270.1.camel@noodles> +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> + <200508231931.29682.josh@agliodbs.com> + <1124852854.11147.5.camel@noodles> + <20050824052023.GB31806@conker.esphion.com> + <1124861121.11270.1.camel@noodles> +Comments: In-reply-to "Jeffrey W. Baker" + message dated "Tue, 23 Aug 2005 22:25:21 -0700" +Date: Wed, 24 Aug 2005 01:56:44 -0400 +Message-ID: <21700.1124863004@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/377 +X-Sequence-Number: 14124 + +"Jeffrey W. Baker" writes: +> On Wed, 2005-08-24 at 17:20 +1200, Guy Thornley wrote: +>> Dont forget that already in postgres, you have a process per connection, and +>> all the processes take care of their own I/O. + +> That's the problem. Instead you want 1 or 4 or 10 i/o slaves +> coordinating the I/O of all the backends optimally. For instance, with +> synchronous scanning. + +And why exactly are we going to do a better job of I/O scheduling than +the OS itself can do? + +There's a fairly basic disconnect in viewpoint involved here. The +old-school viewpoint (as embodied in Oracle and a few other DBMSes) +is that the OS is too stupid to be worth anything, and the DB should +bypass the OS to the greatest extent possible, doing its own caching, +disk space layout, I/O scheduling, yadda yadda. That might have been +defensible twenty-odd years ago when Oracle was designed. Postgres +prefers to lay off to the OS anything that the OS can do well --- and +that definitely includes caching and I/O scheduling. There are a whole +lot of smart people working on those problems at the OS level. Maybe we +could make marginal improvements on their results after spending a lot +of effort reinventing the wheel ... but our time will be repaid much +more if we work at levels that the OS cannot have knowledge of, such as +join planning and data statistics. + +There are some things we could do to reduce the impedance between us and +the OS --- for instance, the upthread criticism that a seqscan asks the +OS for only 8K at a time is fair enough. But that doesn't translate +to a conclusion that we should schedule the I/O instead of the OS. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 24 03:22:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 02CB1D6FBF + for ; + Wed, 24 Aug 2005 03:22:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84569-05 + for ; + Wed, 24 Aug 2005 06:22:00 +0000 (GMT) +Received: from mail28.sea5.speakeasy.net (mail28.sea5.speakeasy.net + [69.17.117.30]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D59FD6E30 + for ; + Wed, 24 Aug 2005 03:21:54 -0300 (ADT) +Received: (qmail 10794 invoked from network); 24 Aug 2005 06:21:54 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail28.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 24 Aug 2005 06:21:54 -0000 +Subject: Re: Read/Write block sizes +From: "Jeffrey W. Baker" +To: Tom Lane +Cc: Guy Thornley , Josh Berkus , + pgsql-performance@postgresql.org, Steve Poe , + Chris Browne +In-Reply-To: <21700.1124863004@sss.pgh.pa.us> +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> + <200508231931.29682.josh@agliodbs.com> + <1124852854.11147.5.camel@noodles> + <20050824052023.GB31806@conker.esphion.com> + <1124861121.11270.1.camel@noodles> <21700.1124863004@sss.pgh.pa.us> +Content-Type: text/plain +Date: Tue, 23 Aug 2005 23:22:52 -0700 +Message-Id: <1124864572.11270.16.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/378 +X-Sequence-Number: 14125 + +On Wed, 2005-08-24 at 01:56 -0400, Tom Lane wrote: +> "Jeffrey W. Baker" writes: +> > On Wed, 2005-08-24 at 17:20 +1200, Guy Thornley wrote: +> >> Dont forget that already in postgres, you have a process per connection, and +> >> all the processes take care of their own I/O. +> +> > That's the problem. Instead you want 1 or 4 or 10 i/o slaves +> > coordinating the I/O of all the backends optimally. For instance, with +> > synchronous scanning. +> +> And why exactly are we going to do a better job of I/O scheduling than +> the OS itself can do? +... +> There are some things we could do to reduce the impedance between us and +> the OS --- for instance, the upthread criticism that a seqscan asks the +> OS for only 8K at a time is fair enough. But that doesn't translate +> to a conclusion that we should schedule the I/O instead of the OS. + +Synchronous scanning is a fairly huge and obvious win. If you have two +processes 180 degrees out-of-phase in a linear read, neither process is +going to get anywhere near the throughput they would get from a single +scan. + +I think you're being deliberately obtuse with regards to file I/O and +the operating system. The OS isn't magical. It has to strike a balance +between a reasonable read latency and a reasonable throughput. As far +as the kernel is concerned, a busy postgresql server is +indistinguishable from 100 unrelated activities. All backends will be +served equally, even if in this case "equally" means "quite badly all +around." + +An I/O slave process could be a big win in Postgres for many kinds of +reads. Instead of opening and reading files the backends would connect +to the I/O slave and request the file be read. If a scan of that file +were already underway, the new backends would be attached. Otherwise a +new scan would commence. In either case, the slave process can issue +(sometimes non-dependant) reads well ahead of the needs of the backend. +You may think the OS can do this for you but it can't. On postgres +knows that it needs the whole file from beginning to end. The OS can +only guess. + +Ask me sometime about my replacement for GNU sort. It uses the same +sorting algorithm, but it's an order of magnitude faster due to better +I/O strategy. Someday, in my infinite spare time, I hope to demonstrate +that kind of improvement with a patch to pg. + +-jwb + + +From pgsql-performance-owner@postgresql.org Sat Aug 27 02:11:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 59A72D728E + for ; + Wed, 24 Aug 2005 03:25:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70091-09 + for ; + Wed, 24 Aug 2005 06:25:14 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EA6BBD72AC + for ; + Wed, 24 Aug 2005 03:25:12 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 3991630B42; Wed, 24 Aug 2005 08:37:28 +0200 (MET DST) +From: "tobbe" +X-Newsgroups: pgsql.performance +Subject: Re: Performance for relative large DB +Date: 23 Aug 2005 23:25:02 -0700 +Organization: http://groups.google.com +Lines: 27 +Message-ID: <1124864702.822522.64410@g49g2000cwa.googlegroups.com> +References: <1124799264.282119.167760@g47g2000cwa.googlegroups.com> + <60wtmcptzg.fsf@dba2.int.libertyrms.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +User-Agent: G2/0.2 +Complaints-To: groups-abuse@google.com +Injection-Info: g49g2000cwa.googlegroups.com; posting-host=212.209.39.154; + posting-account=6PgMzAwAAAAyhWPJdwnKqBSRj5_iJFf6 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/471 +X-Sequence-Number: 14218 + +Hi Chris. + +Thanks for the answer. +Sorry that i was a bit unclear. + +1) We update around 20.000 posts per night. + +2) What i meant was that we suspect that the DBMS called PervasiveSQL +that we are using today is much to small. That's why we're looking for +alternatives. + +Today we base our solution much on using querry-specific tables created +at night, so instead of doing querrys direct on the "post" table (with +4-6M rows) at daytime, we have the data pre-aligned in several much +smaller tables. This is just to make the current DBMS coop with our +amount of data. + +What I am particulary interested in is if we can expect to run all our +select querrys directly from the "post" table with PostgreSQL. + +3) How well does postgres work with load balancing environments. Is it +built-in? + +Best Regards +Robert Bengtsson +Project Manager + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 07:35:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B856D71FA + for ; + Wed, 24 Aug 2005 07:35:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87077-08 + for ; + Wed, 24 Aug 2005 10:35:09 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CACFD7164 + for ; + Wed, 24 Aug 2005 07:35:07 -0300 (ADT) +Received: (qmail 7628 invoked from network); 24 Aug 2005 12:35:33 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 24 Aug 2005 12:35:33 +0200 +Date: Wed, 24 Aug 2005 12:35:08 +0200 +To: "Tom Lane" , + "Jeffrey W. Baker" +Subject: Re: Read/Write block sizes +Cc: "Guy Thornley" , + "Josh Berkus" , pgsql-performance@postgresql.org, + "Steve Poe" , "Chris Browne" +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> + <200508231931.29682.josh@agliodbs.com> + <1124852854.11147.5.camel@noodles> + <20050824052023.GB31806@conker.esphion.com> + <1124861121.11270.1.camel@noodles> <21700.1124863004@sss.pgh.pa.us> +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <21700.1124863004@sss.pgh.pa.us> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/379 +X-Sequence-Number: 14126 + + +> of effort reinventing the wheel ... but our time will be repaid much +> more if we work at levels that the OS cannot have knowledge of, such as +> join planning and data statistics. + + Considering a global budget of man-hours which is the best ? + +1- Spend it on reimplementing half of VFS in postgres, half of Windows in +postgres, half of FreeBSD in postgres, half of Solaris in Postgres, only +to discover you gain a meagre speed increase and a million and a half bugs, + +2- Spending 5% of that time lowering the impedance between the OS and +Postgres, and another 5% annoying Kernel people and helping them tweaking +stuff for database use, and the rest on useful features that give useful +speedups, like bitmap indexes, skip scans, and other features that enhance +power and usability ? + +If you're Oracle and have almost unlimited resources, maybe. But even +Microsoft opted for option 2 : they implemented ReadFileGather and +WriteFileScatter to lower the syscall overhead and that's it. + +And point 2 will benefit to many other apps, wether 1 would benefit only +postgres, and then only in certain cases. + +I do believe there is something ineresting to uncover with reiser4 though +(it definitely fits point 2). + +I'm happy that the pg team chose point 2 and that new versions keep coming +with new features at an unbelievable rate these times. Do you guys sleep ? + +From pgsql-performance-owner@postgresql.org Wed Aug 24 10:27:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 051E9D7243 + for ; + Wed, 24 Aug 2005 10:25:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18184-07 + for ; + Wed, 24 Aug 2005 13:25:15 +0000 (GMT) +Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FB65D7166 + for ; + Wed, 24 Aug 2005 10:25:14 -0300 (ADT) +Received: from phys-bur-1 ([129.148.9.72]) + by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id j7ODPIWR027571 + for ; + Wed, 24 Aug 2005 07:25:18 -0600 (MDT) +Received: from conversion-daemon.bur-mail1.east.sun.com by + bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0ILQ00F01AIXYF@bur-mail1.east.sun.com> + (original mail from Donald.Courtney@Sun.COM) + for pgsql-performance@postgresql.org; + Wed, 24 Aug 2005 09:25:18 -0400 (EDT) +Received: from [129.148.184.34] (gyama.East.Sun.COM [129.148.184.34]) + by bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTPA id <0ILQ009QTAM6OB@bur-mail1.east.sun.com>; Wed, + 24 Aug 2005 09:25:18 -0400 (EDT) +Date: Wed, 24 Aug 2005 09:21:12 -0400 +From: Donald Courtney +Subject: Re: Caching by Postgres +In-reply-to: +To: William Yu +Cc: pgsql-performance@postgresql.org +Message-id: <430C7448.7030103@sun.com> +Organization: Sun Microsystems +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7) Gecko/20041221 +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> <430B6DE3.6040109@sun.com> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/380 +X-Sequence-Number: 14127 + + + +Great discussion and illuminating for those of us who are still +learning the subtleties of postGres. + +William + +To be clear - +I built postgreSQL 8.1 64K bit on solaris 10 a few months ago +and side by side with the 32 bit postgreSQL build saw no improvement. +In fact the 64 bit result was slightly lower. + +I used the *same 64 bit S10 OS* for both versions. I think your +experience makes sense since your change was from 32 to 64 bit Linux. + From my experiment I am surmising that there will not be any +file/os/buffer-cache +scale up effect on the same OS with postgreSQL 64. + +I was testing on a 4 core system in both cases. + + + +William Yu wrote: + +> Donald Courtney wrote: +> +>> in that even if you ran postgreSQL on a 64 bit address space +>> with larger number of CPUs you won't see much of a scale up +>> and possibly even a drop. I am not alone in having the *expectation* +> +> +> What's your basis for believing this is the case? Why would +> PostgreSQL's dependence on the OS's caching/filesystem limit +> scalability? I know when I went from 32bit to 64bit Linux, I got +> *HUGE* increases in performance using the same amount of memory. And +> when I went from 2x1P to 2xDC, my average cpu usage % dropped almost +> in half. +> +>> that a database should have some cache size parameter and +>> the option to skip the file system. If I use oracle, sybase, mysql +>> and maxdb they all have the ability to size a data cache and move +>> to 64 bits. +> +> +> Josh Berkus has already mentioned this as conventional wisdom as +> written by Oracle. This may also be legacy wisdom. Oracle/Sybase/etc +> has been around for a long time; it was probably a clear performance +> win way back when. Nowadays with how far open-source OS's have +> advanced, I'd take it with a grain of salt and do my own performance +> analysis. I suspect the big vendors wouldn't change their stance even +> if they knew it was no longer true due to the support hassles. +> +> My personal experience with PostgreSQL. Dropping shared buffers from +> 2GB to 750MB improved performance on my OLTP DB a good 25%. Going down +> from 750MB to 150MB was another +10%. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly + + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 10:52:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B3C7D6D8A + for ; + Wed, 24 Aug 2005 10:52:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00146-01 + for ; + Wed, 24 Aug 2005 13:52:28 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) + by svr1.postgresql.org (Postfix) with ESMTP id A3B3CD6E53 + for ; + Wed, 24 Aug 2005 10:52:26 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id j7ODqRU08395; + Wed, 24 Aug 2005 09:52:27 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200508241352.j7ODqRU08395@candle.pha.pa.us> +Subject: Re: Read/Write block sizes +In-Reply-To: <430BD9CC.3030306@sun.com> +To: "Jignesh K. Shah" +Date: Wed, 24 Aug 2005 09:52:27 -0400 (EDT) +Cc: "Jim C. Nasby" , + Chris Browne , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 required=5 tests=[AWL=0.009] +X-Spam-Level: +X-Archive-Number: 200508/381 +X-Sequence-Number: 14128 + + +This thread covers several performance ideas. First is the idea that +more parameters should be configurable. While this seems like a noble +goal, we try to make parameters auto-tuning, or if users have to +configure it, the parameter should be useful for a significant number of +users. + +In the commercial software world, if you can convince your boss that a +feature/knob is useful, it usually gets into the product. +Unfortunately, this leads to the golden doorknob on a shack, where some +features are out of sync with the rest of the product in terms of +usefulness and utility. With open source, if a feature can not be +auto-tuned, or has significant overhead, the features has to be +implemented and then proven to be a benefit. + +In terms of adding async I/O, threading, and other things, it might make +sense to explore how these could be implemented in a way that fits the +above criteria. + +--------------------------------------------------------------------------- + +Jignesh K. Shah wrote: +> Hi Jim, +> +> | How many of these things are currently easy to change with a recompile? +> | I should be able to start testing some of these ideas in the near +> | future, if they only require minor code or configure changes. +> +> +> The following +> * Data File Size 1GB +> * WAL File Size of 16MB +> * Block Size of 8K +> +> Are very easy to change with a recompile.. A Tunable will be greatly +> prefered as it will allow one binary for different tunings +> +> * MultiBlock read/write +> +> Is not available but will greatly help in reducing the number of system +> calls which will only increase as the size of the database increases if +> something is not done about i. +> +> * Pregrown files... maybe not important at this point since TABLESPACE +> can currently work around it a bit (Just need to create a different file +> system for each tablespace +> +> But if you really think hardware & OS is the answer for all small +> things...... I think we should now start to look on how to make Postgres +> Multi-threaded or multi-processed for each connection. With the influx +> of "Dual-Core" or "Multi-Core" being the fad.... Postgres can have the +> cutting edge if somehow exploiting cores is designed. +> +> Somebody mentioned that adding CPU to Postgres workload halved the +> average CPU usage... +> YEAH... PostgreSQL uses only 1 CPU per connection (assuming 100% +> usage) so if you add another CPU it is idle anyway and the system will +> report only 50% :-) BUT the importing to measure is.. whether the query +> time was cut down or not? ( No flames I am sure you were talking about +> multi-connection multi-user environment :-) ) But my point is then this +> approach is worth the ROI and the time and effort spent to solve this +> problem. +> +> I actually vote for a multi-threaded solution for each connection while +> still maintaining seperate process for each connections... This way the +> fundamental architecture of Postgres doesn't change, however a +> multi-threaded connection can then start to exploit different cores.. +> (Maybe have tunables for number of threads to read data files who +> knows.. If somebody is interested in actually working a design .. +> contact me and I will be interested in assisting this work. +> +> Regards, +> Jignesh +> +> +> Jim C. Nasby wrote: +> +> >On Tue, Aug 23, 2005 at 06:09:09PM -0400, Chris Browne wrote: +> > +> > +> >>J.K.Shah@Sun.COM (Jignesh Shah) writes: +> >> +> >> +> >>>>Does that include increasing the size of read/write blocks? I've +> >>>>noticedthat with a large enough table it takes a while to do a +> >>>>sequential scan, even if it's cached; I wonder if the fact that it +> >>>>takes a million read(2) calls to get through an 8G table is part of +> >>>>that. +> >>>> +> >>>> +> >>>Actually some of that readaheads,etc the OS does already if it does +> >>>some sort of throttling/clubbing of reads/writes. But its not enough +> >>>for such types of workloads. +> >>> +> >>>Here is what I think will help: +> >>> +> >>>* Support for different Blocksize TABLESPACE without recompiling the +> >>>code.. (Atlease support for a different Blocksize for the whole +> >>>database without recompiling the code) +> >>> +> >>>* Support for bigger sizes of WAL files instead of 16MB files +> >>>WITHOUT recompiling the code.. Should be a tuneable if you ask me +> >>>(with checkpoint_segments at 256.. you have too many 16MB files in +> >>>the log directory) (This will help OLTP benchmarks more since now +> >>>they don't spend time rotating log files) +> >>> +> >>>* Introduce a multiblock or extent tunable variable where you can +> >>>define a multiple of 8K (or BlockSize tuneable) to read a bigger +> >>>chunk and store it in the bufferpool.. (Maybe writes too) (Most +> >>>devices now support upto 1MB chunks for reads and writes) +> >>> +> >>>*There should be a way to preallocate files for TABLES in +> >>>TABLESPACES otherwise with multiple table writes in the same +> >>>filesystem ends with fragmented files which causes poor "READS" from +> >>>the files. +> >>> +> >>>* With 64bit 1GB file chunks is also moot.. Maybe it should be +> >>>tuneable too like 100GB without recompiling the code. +> >>> +> >>>Why recompiling is bad? Most companies that will support Postgres +> >>>will support their own binaries and they won't prefer different +> >>>versions of binaries for different blocksizes, different WAL file +> >>>sizes, etc... and hence more function using the same set of binaries +> >>>is more desirable in enterprise environments +> >>> +> >>> +> >>Every single one of these still begs the question of whether the +> >>changes will have a *material* impact on performance. +> >> +> >> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + +-- + 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 Aug 24 12:37:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C099D7826 + for ; + Wed, 24 Aug 2005 11:51:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83934-08 + for ; + Wed, 24 Aug 2005 14:51:36 +0000 (GMT) +Received: from postfix.vectorx.com.br (fire.vectorx.com.br [200.247.35.133]) + by svr1.postgresql.org (Postfix) with ESMTP id 75DECD77FD + for ; + Wed, 24 Aug 2005 11:51:34 -0300 (ADT) +Received: from localhost (mail [127.0.0.1]) + by postfix.vectorx.com.br (Postfix) with ESMTP id F30CDE06F + for ; + Wed, 24 Aug 2005 11:47:02 -0400 (EDT) +Received: from postfix.vectorx.com.br ([127.0.0.1]) + by localhost (vectorx.com.br [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 05812-08 for ; + Wed, 24 Aug 2005 11:46:58 -0400 (EDT) +Received: from [192.168.16.7] (unknown [192.168.16.7]) + by postfix.vectorx.com.br (Postfix) with ESMTP id D1B34E04F + for ; + Wed, 24 Aug 2005 11:46:56 -0400 (EDT) +Message-ID: <430C8779.9080500@vectorx.com.br> +Date: Wed, 24 Aug 2005 11:43:05 -0300 +From: Alexandre Barros +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.11) Gecko/20050731 +X-Accept-Language: pt-br, en-us, en +MIME-Version: 1.0 +To: postgres performance +Subject: performance drop on RAID5 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: amavisd-new at vectorx.com.br +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.025 required=5 tests=[AWL=0.025] +X-Spam-Level: +X-Archive-Number: 200508/383 +X-Sequence-Number: 14130 + +Hello, +i have a pg-8.0.3 running on Linux kernel 2.6.8, CPU Sempron 2600+, +1Gb RAM on IDE HD ( which could be called a "heavy desktop" ), measuring +this performance with pgbench ( found on /contrib ) it gave me an +average ( after several runs ) of 170 transactions per second; + +for the sake of experimentation ( actually, i'm scared this IDE drive +could fail at any time, hence i'm looking for an alternative, more +"robust", machine ), i've installed on an aging Compaq Proliant server ( +freshly compiled SMP kernel 2.6.12.5 with preemption ), dual Pentium +III Xeon 500Mhz, 512Mb RAM, (older) SCSI-2 80pin drives, and re-tested, +when the database was on a single SCSI drive, pgbench gave me an average +of 90 transactions per second, but, and that scared me most, when the +database was on a RAID-5 array ( four 9Gb disks, using linux software +RAID mdadm and LVM2, with the default filesystem cluster size of 32Kb ), +the performance dropped to about 55 transactions per second. + +Despite the amount of RAM difference, none machine seems to be swapping. +All filesystems ( on both machines ) are Reiserfs. +Both pg-8.0.3 were compiled with CFLAGS -O3 and -mtune for their +respective architectures... and "gmake -j2" on the server. +Both machines have an original ( except by the pg and the kernel ) +Mandrake 10.1 install. + +I've googled a little, and maybe the cluster size might be one problem, +but despite that, the performance dropping when running on +"server-class" hardware with RAID-5 SCSI-2 drives was way above my most +delirious expectations... i need some help to figure out what is **so** +wrong... + +i wouldn't be so stunned if the newer machine was ( say ) twice faster +than the older server, but over three times faster is disturbing. + +the postgresql.conf of both machines is here: + +max_connections = 50 +shared_buffers = 1000 # min 16, at least max_connections*2, +8KB each +debug_print_parse = false +debug_print_rewritten = false +debug_print_plan = false +debug_pretty_print = false +log_statement = 'all' +log_parser_stats = false +log_planner_stats = false +log_executor_stats = false +log_statement_stats = false +lc_messages = 'en_US' # locale for system error message strings +lc_monetary = 'en_US' # locale for monetary formatting +lc_numeric = 'en_US' # locale for number formatting +lc_time = 'en_US' # locale for time formatting + +many thanks in advance ! + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 12:32:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B2F43D7842 + for ; + Wed, 24 Aug 2005 11:55:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91406-09 + for ; + Wed, 24 Aug 2005 14:55:10 +0000 (GMT) +Received: from ns.snowman.net (ns.snowman.net [66.92.160.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 97D37D7805 + for ; + Wed, 24 Aug 2005 11:55:08 -0300 (ADT) +Received: by ns.snowman.net (Postfix, from userid 1000) + id C2A2817B11; Wed, 24 Aug 2005 10:55:33 -0400 (EDT) +Date: Wed, 24 Aug 2005 10:55:33 -0400 +From: Stephen Frost +To: Donald Courtney +Cc: William Yu , pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +Message-ID: <20050824145533.GN6026@ns.snowman.net> +Mail-Followup-To: Donald Courtney , + William Yu , pgsql-performance@postgresql.org +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="BU7+kJFeeDlNltZg" +Content-Disposition: inline +In-Reply-To: <430C7448.7030103@sun.com> +X-Editor: Vim http://www.vim.org/ +X-Info: http://www.snowman.net +X-Operating-System: Linux/2.4.24ns.3.0 (i686) +X-Uptime: 10:48:33 up 74 days, 7:06, 6 users, load average: 0.05, 0.13, 0.09 +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 required=5 tests=[AWL=0.004] +X-Spam-Level: +X-Archive-Number: 200508/382 +X-Sequence-Number: 14129 + + +--BU7+kJFeeDlNltZg +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +* Donald Courtney (Donald.Courtney@sun.com) wrote: +> To be clear - +> I built postgreSQL 8.1 64K bit on solaris 10 a few months ago +> and side by side with the 32 bit postgreSQL build saw no improvement.=20 +> In fact the 64 bit result was slightly lower. + +That makes some sense actually. It really depends on what you're doing +alot of the time. On a Sparc system you're not likely to get much of a +speed improvment by going to 64bit (unless, maybe, you're doing lots of +intensive 64bit math ops). You'll have larger pointers and whatnot +though. + +> I used the *same 64 bit S10 OS* for both versions. I think your +> experience makes sense since your change was from 32 to 64 bit Linux. + +32bit to 64bit Linux on a Sparc platform really shouldn't affect +performance all that much (I'd expect it to be similar to 32bit to 64bit +under Solaris actually, at least in terms of the performance +difference). 32bit to 64bit Linux on an amd64 platform is another +matter entirely though, but not because of the number of bits involved. + +Under amd64, 32bit is limited to 32bit on i386 which has a limited +number of registers and whatnot. Under amd64/64bit you get more +registers (and I think some other niceities) which will improve +performance. That's not a 32bit vs. 64bit thing, that's i386 vs. native +amd64. It's really mainly an oddity of the platform. On a mips system +I'd expect the same kind of performance difference between 32bit and +64bit as you'd see on a sparc platform. + + Enjoy, + + Stephen + +--BU7+kJFeeDlNltZg +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (GNU/Linux) + +iD8DBQFDDIplrzgMPqB3kigRAgdZAJ9qbWNbxrPc6bSy7foIPir/sPv0RwCfWhVT +9IKq1E6qwm6VW6vw3arTAhc= +=pqT1 +-----END PGP SIGNATURE----- + +--BU7+kJFeeDlNltZg-- + +From pgsql-performance-owner@postgresql.org Wed Aug 24 13:18:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB0D9D6FBB + for ; + Wed, 24 Aug 2005 12:36:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73999-08 + for ; + Wed, 24 Aug 2005 15:36:40 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 5810DD6E00 + for ; + Wed, 24 Aug 2005 12:36:38 -0300 (ADT) +Received: (qmail 21623 invoked from network); 24 Aug 2005 17:37:01 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 24 Aug 2005 17:37:01 +0200 +To: "Josh Berkus" , + pgsql-performance@postgresql.org +Cc: "William Yu" +Subject: Re: Caching by Postgres +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + + <200508231911.59100.josh@agliodbs.com> +Message-ID: +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Date: Wed, 24 Aug 2005 17:36:35 +0200 +In-Reply-To: <200508231911.59100.josh@agliodbs.com> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/385 +X-Sequence-Number: 14132 + + +> Really? Cool, I'd like to see that. Could you follow up with Hans? +> Or give +> me his e-mail? + + You can subscribe to the Reiser mailinglist on namesys.com or : + reiser@namesys.com + +From pgsql-performance-owner@postgresql.org Wed Aug 24 12:54:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B64B7D726E + for ; + Wed, 24 Aug 2005 12:52:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11324-06 + for ; + Wed, 24 Aug 2005 15:52:07 +0000 (GMT) +Received: from frank.wiles.org (frank.wiles.org [24.124.39.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A1BFD7166 + for ; + Wed, 24 Aug 2005 12:52:06 -0300 (ADT) +Received: from kungfu (frank.wiles.org [127.0.0.1]) + by frank.wiles.org (8.13.1/8.13.1) with SMTP id j7OF0ljd015554; + Wed, 24 Aug 2005 10:00:47 -0500 +Date: Wed, 24 Aug 2005 10:52:43 -0500 +From: Frank Wiles +To: Alexandre Barros +Cc: pgsql-performance@postgresql.org +Subject: Re: performance drop on RAID5 +Message-Id: <20050824105243.067f0ae5.frank@wiles.org> +In-Reply-To: <430C8779.9080500@vectorx.com.br> +References: <430C8779.9080500@vectorx.com.br> +X-Mailer: Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-redhat-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/384 +X-Sequence-Number: 14131 + +On Wed, 24 Aug 2005 11:43:05 -0300 +Alexandre Barros wrote: + +> I've googled a little, and maybe the cluster size might be one +> problem, but despite that, the performance dropping when running on +> "server-class" hardware with RAID-5 SCSI-2 drives was way above my +> most delirious expectations... i need some help to figure out what is +> **so** wrong... + + RAID-5 isn't great for databases in general. What would be better + would be to mirror the disks to redundancy or do RAID 1+0. + + You could probably also increase your shared_buffers some, but + that alone most likely won't make up your speed difference. + + --------------------------------- + Frank Wiles + http://www.wiles.org + --------------------------------- + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 14:04:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 11E93D7266 + for ; + Wed, 24 Aug 2005 13:02:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42195-07 + for ; + Wed, 24 Aug 2005 16:02:53 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BFEED70BF + for ; + Wed, 24 Aug 2005 13:02:51 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: performance drop on RAID5 +Date: Wed, 24 Aug 2005 12:02:51 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD1A3@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] performance drop on RAID5 +Thread-Index: AcWowgLuh0xdZeDaSZuHRbYhqWtA8gAAgmlw +From: "Merlin Moncure" +To: "Alexandre Barros" +Cc: "postgres performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/392 +X-Sequence-Number: 14139 + +> Hello, +> i have a pg-8.0.3 running on Linux kernel 2.6.8, CPU Sempron +2600+, +> 1Gb RAM on IDE HD ( which could be called a "heavy desktop" ), +measuring +> this performance with pgbench ( found on /contrib ) it gave me an +> average ( after several runs ) of 170 transactions per second; + +170 tps is not plausible no a single platter IDE disk without using +write caching of some kind. For a 7200 rpm drive any result much over +100 tps is a little suspicious. (my 10k sata raptor can do about 120). +=20 +> for the sake of experimentation ( actually, i'm scared this IDE drive +> could fail at any time, hence i'm looking for an alternative, more +> "robust", machine ), i've installed on an aging Compaq Proliant server +( +> freshly compiled SMP kernel 2.6.12.5 with preemption ), dual Pentium +> III Xeon 500Mhz, 512Mb RAM, (older) SCSI-2 80pin drives, and +re-tested, +> when the database was on a single SCSI drive, pgbench gave me an +average +> of 90 transactions per second, but, and that scared me most, when the +> database was on a RAID-5 array ( four 9Gb disks, using linux software +> RAID mdadm and LVM2, with the default filesystem cluster size of 32Kb +), +> the performance dropped to about 55 transactions per second. + +Is natural to see a slight to moderate drop in write performance moving +to RAID 5. The only raid levels that are faster than single disk levels +for writing are the ones with '0' in it or caching raid controllers. +Even for 0+1, expect modest gains in tps vs. single disk if not using +write caching. + +Merlin + +From pgsql-performance-owner@postgresql.org Wed Aug 24 13:43:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 878DCD77F7 + for ; + Wed, 24 Aug 2005 13:36:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22547-04 + for ; + Wed, 24 Aug 2005 16:36:14 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C60CD7336 + for ; + Wed, 24 Aug 2005 13:36:13 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 3693A30B42; Wed, 24 Aug 2005 18:48:30 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Read/Write block sizes +Date: Wed, 24 Aug 2005 12:12:22 -0400 +Organization: cbbrowne Computing Inc +Lines: 63 +Message-ID: <60br3npb4p.fsf@dba2.int.libertyrms.com> +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:mK8J5RkNPPi1vcmSWCFrL193fzI= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.114 required=5 tests=[AWL=0.114] +X-Spam-Level: +X-Archive-Number: 200508/387 +X-Sequence-Number: 14134 + +spoe@sfnet.cc (Steve Poe) writes: +> Chris, +> +> Unless I am wrong, you're making the assumpting the amount of time spent +> and ROI is known. Maybe those who've been down this path know how to get +> that additional 2-4% in 30 minutes or less? +> +> While each person and business' performance gains (or not) could vary, +> someone spending the 50-100h to gain 2-4% over a course of a month for a +> 24x7 operation would seem worth the investment? + +What we *do* know is that adding these "knobs" would involve a +significant amount of effort, as the values are widely used throughout +the database engine. Making them dynamic (e.g. - so they could be +tuned on a tablespace-by-tablespace basis) would undoubtedly require +rather a lot of development effort. They are definitely NOT 30 minute +changes. + +Moreover, knowing how to adjust them is almost certainly also NOT a 30 +minute configuration change; significant benchmarking effort for the +individual application is almost sure to be needed. + +It's not much different from the reason why PostgreSQL doesn't use +threading... + +The problem with using threading is that introducing it to the code +base would require a pretty enormous amount of effort (I'll bet +multiple person-years), and it wouldn't provide *any* benefit until +you get rather a long ways down the road. + +Everyone involved in development seems to me to have a reasonably keen +understanding as to what the potential benefits of threading are; the +value is that there fall out plenty of opportunities to parallelize +the evaluation of portions of queries. Alas, it wouldn't be until +*after* all the effort goes in that we would get any idea as to what +kinds of speedups this would provide. + +In effect, there has to be a year invested in *breaking* PostgreSQL +(because this would initially break a lot, since thread programming is +a really tough skill) where you don't actually see any benefits. + +> I would assume that dbt2 with STP helps minimize the amount of hours +> someone has to invest to determine performance gains with +> configurable options? + +That's going to help in constructing a "default" knob value. And if +we find an "optimal default," that encourages sticking with the +current approach, of using #define to apply that value... + +>> If someone spends 100h working on one of these items, and gets a 2% +>> performance improvement, that's almost certain to be less desirable +>> than spending 50h on something else that gets a 4% improvement. +>> +>> And we might discover that memory management improvements in Linux +>> 2.6.16 or FreeBSD 5.5 allow some OS kernels to provide some such +>> improvements "for free" behind our backs without *any* need to write +>> database code. :-) +-- +let name="cbbrowne" and tld="ntlug.org" in String.concat "@" [name;tld];; +http://www.ntlug.org/~cbbrowne/lisp.html +"For those of you who are into writing programs that are as obscure +and complicated as possible, there are opportunities for... real fun +here" -- Arthur Norman + +From pgsql-performance-owner@postgresql.org Wed Aug 24 13:54:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B4302D7844 + for ; + Wed, 24 Aug 2005 13:16:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84853-02 + for ; + Wed, 24 Aug 2005 16:16:25 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CE39D7803 + for ; + Wed, 24 Aug 2005 13:16:22 -0300 (ADT) +Received: from [192.168.1.100] (clbb-248.saw.net [64.146.135.248]) + (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + j7OGEGBe025056; Wed, 24 Aug 2005 09:14:17 -0700 +Message-ID: <430C9DA6.2080801@commandprompt.com> +Date: Wed, 24 Aug 2005 09:17:42 -0700 +From: "Joshua D. Drake" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alexandre Barros +Cc: postgres performance +Subject: Re: performance drop on RAID5 +References: <430C8779.9080500@vectorx.com.br> +In-Reply-To: <430C8779.9080500@vectorx.com.br> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); + Wed, 24 Aug 2005 09:14:18 -0700 (PDT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.022 required=5 tests=[AWL=0.022] +X-Spam-Level: +X-Archive-Number: 200508/391 +X-Sequence-Number: 14138 + +Alexandre Barros wrote: + +> Hello, +> i have a pg-8.0.3 running on Linux kernel 2.6.8, CPU Sempron +> 2600+, 1Gb RAM on IDE HD ( which could be called a "heavy desktop" ), +> measuring this performance with pgbench ( found on /contrib ) it gave +> me an average ( after several runs ) of 170 transactions per second; + +That is going to be because IDE drives LIE about write times because of +the large cache. + +> for the sake of experimentation ( actually, i'm scared this IDE drive +> could fail at any time, hence i'm looking for an alternative, more +> "robust", machine ), i've installed on an aging Compaq Proliant server +> ( freshly compiled SMP kernel 2.6.12.5 with preemption ), dual +> Pentium III Xeon 500Mhz, 512Mb RAM, (older) SCSI-2 80pin drives, and +> re-tested, when the database was on a single SCSI drive, pgbench gave +> me an average of 90 transactions per second, but, and that scared me +> most, when the database was on a RAID-5 array ( four 9Gb disks, using +> linux software RAID mdadm and LVM2, with the default filesystem +> cluster size of 32Kb ), the performance dropped to about 55 +> transactions per second. + + +That seems more reasonable and probably truthful. I would be curious +what type of performance you would get with the exact same +setup EXCEPT remove LVM2. Just have the software RAID. In fact, since +you have 4 drives you could do RAID 10. + +> +> i wouldn't be so stunned if the newer machine was ( say ) twice faster +> than the older server, but over three times faster is disturbing. +> +> the postgresql.conf of both machines is here: +> +> max_connections = 50 +> shared_buffers = 1000 # min 16, at least max_connections*2, +> 8KB each + +You should look at the annotated conf: + +http://www.powerpostgresql.com/Downloads/annotated_conf_80.html + +Sincerely, + +Joshua D. Drake + + + +> debug_print_parse = false +> debug_print_rewritten = false +> debug_print_plan = false +> debug_pretty_print = false +> log_statement = 'all' +> log_parser_stats = false +> log_planner_stats = false +> log_executor_stats = false +> log_statement_stats = false +> lc_messages = 'en_US' # locale for system error message strings +> lc_monetary = 'en_US' # locale for monetary formatting +> lc_numeric = 'en_US' # locale for number formatting +> lc_time = 'en_US' # locale for time formatting +> +> many thanks in advance ! +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 13:50:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6592AD768A + for ; + Wed, 24 Aug 2005 13:25:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76142-06 + for ; + Wed, 24 Aug 2005 16:25:36 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 22105D72C6 + for ; + Wed, 24 Aug 2005 13:25:35 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7926794; Wed, 24 Aug 2005 09:27:52 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane +Subject: Re: Read/Write block sizes +Date: Wed, 24 Aug 2005 09:26:39 -0700 +User-Agent: KMail/1.8 +Cc: "Jeffrey W. Baker" , + pgsql-performance@postgresql.org, Steve Poe , + Chris Browne +References: + <1124852854.11147.5.camel@noodles> <21415.1124860220@sss.pgh.pa.us> +In-Reply-To: <21415.1124860220@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508240926.39885.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 required=5 tests=[AWL=0.011] +X-Spam-Level: +X-Archive-Number: 200508/390 +X-Sequence-Number: 14137 + +Tom, Gavin, + + +> > To get decent I/O you need 1MB fundamental units all the way down the +> > stack. +> +> It would also be a good idea to have an application that isn't likely +> to change a single bit in a 1MB range and then expect you to record +> that change. This pretty much lets Postgres out of the picture. + +We're looking at this pretty much just for data warehousing, where you +constantly have gigabytes of data which don't change from month to month or +even year to year. I agree that it would *not* be an optimization for OLTP +systems. Which is why a build-time option would be fine. + +> Ummm... I don't see anything here which will be a win for Postgres. The +> transactional semantics we're interested in are fairly complex: +> +> 1) Modifications to multiple objects can become visible to the system +> atomically +> 2) On error, a series of modifications which had been grouped together +> within a transaction can be rolled back +> 3) Using object version information, determine which version of which +> object is visible to a given session +> 4) Using version information and locking, detect and resolve read/write +> and write/write conflicts + +I wasn't thinking of database transactions. I was thinking specifically of +using Reiser4 transactions (and other transactional filesytems) to do things +like eliminate the need for full page writes in the WAL. Filesystems are +low-level things which should take care of low-level needs, like making sure +an 8K page got written to disk even in the event of a system failure. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Aug 24 13:32:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A838D7849 + for ; + Wed, 24 Aug 2005 13:32:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05121-07 + for ; + Wed, 24 Aug 2005 16:32:26 +0000 (GMT) +Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AA99D7858 + for ; + Wed, 24 Aug 2005 13:32:25 -0300 (ADT) +Received: from [10.0.0.2] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) + by olive.qinip.net (Postfix) with ESMTP + id 81325180FB; Wed, 24 Aug 2005 18:32:17 +0200 (MEST) +Message-ID: <430CA115.8030006@tweakers.net> +Date: Wed, 24 Aug 2005 18:32:21 +0200 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alexandre Barros +Cc: postgres performance +Subject: Re: performance drop on RAID5 +References: <430C8779.9080500@vectorx.com.br> +In-Reply-To: <430C8779.9080500@vectorx.com.br> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/386 +X-Sequence-Number: 14133 + +On 24-8-2005 16:43, Alexandre Barros wrote: +> Hello, +> i have a pg-8.0.3 running on Linux kernel 2.6.8, CPU Sempron 2600+, +> 1Gb RAM on IDE HD ( which could be called a "heavy desktop" ), measuring +> this performance with pgbench ( found on /contrib ) it gave me an +> average ( after several runs ) of 170 transactions per second; + +Nowadays you can call that a "light desktop", although the amount of RAM +is a bit more than normal. ;) + +> for the sake of experimentation ( actually, i'm scared this IDE drive +> could fail at any time, hence i'm looking for an alternative, more +> "robust", machine ), i've installed on an aging Compaq Proliant server ( +> freshly compiled SMP kernel 2.6.12.5 with preemption ), dual Pentium + +Preemption is afaik counter-productive for a server. + +> III Xeon 500Mhz, 512Mb RAM, (older) SCSI-2 80pin drives, and re-tested, +> when the database was on a single SCSI drive, pgbench gave me an average +> of 90 transactions per second, but, and that scared me most, when the +> database was on a RAID-5 array ( four 9Gb disks, using linux software +> RAID mdadm and LVM2, with the default filesystem cluster size of 32Kb ), +> the performance dropped to about 55 transactions per second. + +The default disk io scheduler of the 2.6-series is designed for disks or +controllers that have no command queueing (like most standaard +IDE-disks). Try changing your default "anticipatory" scheduler on the +test-device to "deadline" or "cfq" (see the two *-iosched.txt files in +/usr/src/linux/Documentation/block/ for more information). +Changing is simple with a 2.6.11+ kernel, just do "echo 'deadline' > +/sys/block/*devicename*/queue/scheduler" at runtime. + +> Despite the amount of RAM difference, none machine seems to be swapping. + +But there is a 512MB extra amount of file-cache. Which can make a +significant difference. + +> All filesystems ( on both machines ) are Reiserfs. +> Both pg-8.0.3 were compiled with CFLAGS -O3 and -mtune for their +> respective architectures... and "gmake -j2" on the server. +> Both machines have an original ( except by the pg and the kernel ) +> Mandrake 10.1 install. +> +> I've googled a little, and maybe the cluster size might be one problem, +> but despite that, the performance dropping when running on +> "server-class" hardware with RAID-5 SCSI-2 drives was way above my most +> delirious expectations... i need some help to figure out what is **so** +> wrong... + +Did you consider you're overestimating the raid's performance and usage? +If the benchmark was mostly run from the memory, you're not going to see +much gain in performance from a faster disk. +But even worse is that for sequential reads and writes, the performance +of current (large) IDE drives is very good. It may actually outperform +your RAID on that one. +Random access will probably still be slower, but may not be that much +slower. And if the database resides in memory, that doesn't matter much +anyway. + +> i wouldn't be so stunned if the newer machine was ( say ) twice faster +> than the older server, but over three times faster is disturbing. + +I'm actually not surprised. Old scsi disks are not faster than new ones +anymore, although they still may be a bit faster on random access issues +or under (very) high load. + +Especially if: +- you only ran it with 1 client +- the database mostly or entirely fits in the desktop's memory +- the database did not fit entirely in the server's memory. + +Even worse would be if the database does fit entirely in the desktop's +memory, but not in the server's! + +Please don't forget your server probably has much slower memory-access, +it will likely have 133Mhz SDR Ram instead of your current DDR2700 orso. +The latter is much faster (in theory more than twice). +Your desktop cpu will very likely, even when multiple processes exist, +be faster especially with the faster memory accesses. The Xeon's +probably only beat it on the amount of cache. + +So please check if pgbench actually makes much use of the disk, if it +does check how large the test databases will be, etc, etc. + +Btw, if you'd prefer to use your desktop, but are afraid of the +IDE-drive dying on you, buy a "server class" SATA disk. Most +manufacturers have those, Western Digital even has "scsi like" sata +disks (the Raptor drives), they generally have 3 to 5 years warranty and +higher class components. + +Best regards, + +Arjen + +From pgsql-performance-owner@postgresql.org Wed Aug 24 13:43:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F8B0D77F4 + for ; + Wed, 24 Aug 2005 13:36:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22537-05 + for ; + Wed, 24 Aug 2005 16:36:14 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BDDED732F + for ; + Wed, 24 Aug 2005 13:36:11 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id D295B30B43; Wed, 24 Aug 2005 18:48:30 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Performance for relative large DB +Date: Wed, 24 Aug 2005 12:34:51 -0400 +Organization: cbbrowne Computing Inc +Lines: 80 +Message-ID: <607jebpa38.fsf@dba2.int.libertyrms.com> +References: <1124799264.282119.167760@g47g2000cwa.googlegroups.com> + <60wtmcptzg.fsf@dba2.int.libertyrms.com> + <1124864702.822522.64410@g49g2000cwa.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:dfPIkB8Ya3TN84LEbPwiDeFwbS4= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.115 required=5 tests=[AWL=0.115] +X-Spam-Level: +X-Archive-Number: 200508/388 +X-Sequence-Number: 14135 + +"tobbe" writes: +> Hi Chris. +> +> Thanks for the answer. +> Sorry that i was a bit unclear. +> +> 1) We update around 20.000 posts per night. + +No surprise there; I would have been surprised to see 100/nite or +6M/nite... + +> 2) What i meant was that we suspect that the DBMS called PervasiveSQL +> that we are using today is much to small. That's why we're looking for +> alternatives. +> +> Today we base our solution much on using querry-specific tables created +> at night, so instead of doing querrys direct on the "post" table (with +> 4-6M rows) at daytime, we have the data pre-aligned in several much +> smaller tables. This is just to make the current DBMS coop with our +> amount of data. +> +> What I am particulary interested in is if we can expect to run all our +> select querrys directly from the "post" table with PostgreSQL. + +Given a decent set of indices, I'd expect that to work OK... Whether +4M or 6M rows, that's pretty moderate in size. + +If there are specific states that rows are in which are "of interest," +then you can get big wins out of having partial indices... Consider... + +create index partial_post_status on posts where status in ('Active', 'Pending', 'Locked'); +-- When processing of postings are completely finished, they wind up with 'Closed' status + +We have some 'stateful' tables in our environment where the +interesting states are 'P' (where work is "pending") and 'C' (where +all the work has been completed and the records are never of interest +again except as ancient history); the partial index "where status = +'P'" winds up being incredibly helpful. + +It's worth your while to dump data out from Pervasive and load it into +a PostgreSQL instance and to do some typical sorts of queries on the +PostgreSQL side. + +Do "EXPLAIN ANALYZE [some select statement];" and you'll get a feel +for how PostgreSQL is running the queries. + +Fiddling with indices to see how that affects things will also be a +big help. + +You may find there are columns with large cardinalities (quite a lot +of unique values) where you want to improve the stats analysis via... + + alter posts alter column [whatever] set statistics 100; + -- Default is 10 bins + analyze posts; + -- then run ANALYZE to update statistics + +> 3) How well does postgres work with load balancing environments. Is +> it built-in? + +Load balancing means too many things. Can you be more specific about +what you consider it to mean? + +For Internet registry operations, we use replication (Slony-I) to +create replicas used to take particular sorts of load off the "master" +systems. + +But you might be referring to something else... + +For instance, connection pools, whether implemented inside +applications (everyone doing Java has one or more favorite Java +connection pool implementations) or in web servers (Apache has a DB +connection pool manager) or in an outside application (pgpool, a +C-based connection pool manager) are also sometimes used for load +balancing. +-- +(reverse (concatenate 'string "gro.mca" "@" "enworbbc")) +http://www3.sympatico.ca/cbbrowne/postgresql.html +In case you weren't aware, "ad homineum" is not latin for "the user of +this technique is a fine debater." -- Thomas F. Burdick + +From pgsql-performance-owner@postgresql.org Wed Aug 24 13:47:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 23B19D78B7 + for ; + Wed, 24 Aug 2005 13:35:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92951-07 + for ; + Wed, 24 Aug 2005 16:35:03 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.200]) + by svr1.postgresql.org (Postfix) with ESMTP id 37124D7897 + for ; + Wed, 24 Aug 2005 13:35:02 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i22so132067wra + for ; + Wed, 24 Aug 2005 09:35:01 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=b0N2msU1qLDiAm9q/iyXDo63t1Y8GDD9kVYQX8Fl2+PfWQHNHaiIpnVAY8fe0f34IBLM6/MBL3TLn3xHMh6cjnh2pIbdpxCrkPoiBb/G9CI6PV55k/6MgBmMLig9+2xwWBfncoEoNwTBUJBAQYstyQ5PCiJhp0FakRYSkY06ww4= +Received: by 10.54.111.11 with SMTP id j11mr839076wrc; + Wed, 24 Aug 2005 09:35:01 -0700 (PDT) +Received: by 10.54.96.7 with HTTP; Wed, 24 Aug 2005 09:35:01 -0700 (PDT) +Message-ID: <37d451f70508240935315add63@mail.gmail.com> +Date: Wed, 24 Aug 2005 11:35:01 -0500 +From: Rosser Schwarz +To: Alexandre Barros +Subject: Re: performance drop on RAID5 +Cc: postgres performance +In-Reply-To: <430C8779.9080500@vectorx.com.br> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <430C8779.9080500@vectorx.com.br> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.089 required=5 tests=[AWL=0.065, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/389 +X-Sequence-Number: 14136 + +On 8/24/05, Alexandre Barros wrote: + +> i wouldn't be so stunned if the newer machine was ( say ) twice faster +> than the older server, but over three times faster is disturbing. + +RAID5 on so few spindles is a known losing case for PostgreSQL. You'd +be far, far better off doing a pair of RAID1 sets or a single RAID10 +set. + +/rls + +--=20 +:wq + +From pgsql-performance-owner@postgresql.org Wed Aug 24 14:36:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 085BFD78F8 + for ; + Wed, 24 Aug 2005 13:57:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62000-06 + for ; + Wed, 24 Aug 2005 16:56:55 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 50CC7D7833 + for ; + Wed, 24 Aug 2005 13:56:54 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 8so85104nzo + for ; + Wed, 24 Aug 2005 09:56:54 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=gMKjZvIOlGpCuVmiCnaTfbNwP5PX+4gVkP14bo3lpZWWoblAYpM2CGLD2oKtKPVnod7P8oJ5yQKGbwT9Ox6fVAzsbPreHYq2h0xvoWnhuzCJJUDLPmXZexHGZ8ZOe4PM4KDNeum/g7sSxewke70xbUT9H3KKGy6qiexSEevpxek= +Received: by 10.36.74.13 with SMTP id w13mr3206721nza; + Wed, 24 Aug 2005 09:56:54 -0700 (PDT) +Received: by 10.36.24.2 with HTTP; Wed, 24 Aug 2005 09:56:54 -0700 (PDT) +Message-ID: <1d219a6f05082409563775a8a7@mail.gmail.com> +Date: Wed, 24 Aug 2005 12:56:54 -0400 +From: Chris Hoover +To: pgsql-performance@postgresql.org +Subject: Some ideas for comment +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/393 +X-Sequence-Number: 14140 + +Ok, there is always a lot of talk about tuning PostgreSQL on linux and +how PostgreSQL uses the linux kernel cache to cache the tables and +indexes. + +My question is, is there anyway to see what files linux is caching at +this moment? + +My reasoning behind this question is: + +I have several database systems each with 1 PostgreSQL cluster.=20 +However, each cluster has a large number of identical databases on +it. Since there can be a great amount of size disparity between the +databases, I am wondering if some of slowness we see might be caused +by the kernel cache having to reload a lot of data that keeps getting +swapped out. (most systems have at least 100GB of data/indexes on them +with 8 or 12GB ram). + +If this is the case, what sort of symptoms would you expect? + +To help mitigate this potential, I have been researching the +following, and am thinking of proposing it to management. Any +comments would be appreciated. + +1. Implement a partition type layout using views and rules - This +will allow me to have one table in each view with the "active" data, +and the inactive data stored by year in other tables. + +So I would have the following (for each major table): + +Table View as +select * from active_table +union all=20 +select * from table_2005 +union all +select * from table_2004 +etc. + +Each table would have identical indexes, however only the +"active_table" would have data that is actively being worked. The +rules and a nightly job can keep the data correctly stored. + +I am thinking that with this setup, the active table indexes should +almost always be in memory. And, if they do happen to be pushed out, +they are much smaller than the indexes I have today (where all data is +in one table), so they should load faster with less i/o pressure. + + From the testing I have done so far, I believe I can implement this +system with out having to ask for developer time. This is a "Good +Thing". + +Also, the database is not normalized and is very ugly, by using the +view to partition and abstract the actual data, I will be in a better +position to start normalizing some of the tables w/o developer time +(once again, a "Good Thing") + + +2. I am also thinking of recommending we collapse all databases in a +cluster into one "mega" database. I can then use schema's and views +to control database access and ensure that no customer can see another +customers data. + +This would mean that there are only one set of indexes being loaded +into the cache. While they would be larger, I think in combination +with the partition from idea 1, we would be ahead of the ball game.=20 +Since there would only be one set of indexes, everyone would be +sharing them so they should always be in memory. + +I don't have real numbers to give you, but we know that our systems +are hurting i/o wise and we are growing by about 2GB+ per week (net).=20 +We actually grow by about 5GB/week/server. However, when I run my +weekly maintenance of vacuum full, reindex, and the vacuum analyze, we +end up getting about 3GB back. Unfortunately, I do not have the i/o +bandwidth to vacuum during the day as it causes major slowdowns on our +system. Each night, I do run a vacuum analyze across all db's to try +and help. I also have my fsm parameters set high (8000000 fsm pages, +and 5000 fsm relations) to try and compensate. + +I believe this is only hurting us as any queries that choose to +tablescan are only getting slower and slower. Also, obviously, our +indexes are continually growing. The partitioning should help as the +actual number of records being worked on each table is a very small +percentage ( a site may have 1 million records, but only load and work +a few thousand each day). The archive tables would be doing the most +growing while the active tables should stay small. Most of the +queries that are tablescanning can not be fixed as the database +clusters have been initialized with a non-C locale and won't use +indexes on our queries that are using like with a wild card. + + +Right now, we are still on 7.3.4. However, these ideas would be +implemented as part of an upgrade to 8.x (plus, we'll initialize the +new clusters with a C locale). + +Anyway, I hope this makes since, and any comments, ideas, and/or +suggestions would be appreciated. + +Thanks, + +Chris + +From pgsql-performance-owner@postgresql.org Wed Aug 24 15:04:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CC8ECD769F + for ; + Wed, 24 Aug 2005 14:39:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12039-09 + for ; + Wed, 24 Aug 2005 17:39:21 +0000 (GMT) +Received: from mail.envyfinancial.com (unknown [206.248.142.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AE3BD78AC + for ; + Wed, 24 Aug 2005 14:39:17 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envyfinancial.com (Postfix) with ESMTP id 603DD1B7F8; + Wed, 24 Aug 2005 13:30:56 -0400 (EDT) +Received: from mail.envyfinancial.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 12034-02; Wed, 24 Aug 2005 13:30:56 -0400 (EDT) +Received: by mail.envyfinancial.com (Postfix, from userid 500) + id 2108F1B802; Wed, 24 Aug 2005 13:30:56 -0400 (EDT) +Date: Wed, 24 Aug 2005 13:30:56 -0400 +From: mark@mark.mielke.cc +To: Donald Courtney +Cc: William Yu , pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +Message-ID: <20050824173055.GA11788@mark.mielke.cc> +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <430C7448.7030103@sun.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envyfinancial.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.18 required=5 tests=[AWL=0.002, NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/394 +X-Sequence-Number: 14141 + +On Wed, Aug 24, 2005 at 09:21:12AM -0400, Donald Courtney wrote: +> I built postgreSQL 8.1 64K bit on solaris 10 a few months ago +> and side by side with the 32 bit postgreSQL build saw no improvement. +> In fact the 64 bit result was slightly lower. + +I've had this sort of argument with a friend of mine who works at a +retail computer sales company who always tries to pitch 64-bit +platforms to me (I don't have one yet). + +There are a few issues in here that are hard to properly detach to +allow for a fair comparison. + +The first, to always remember - is that the move from 64-bits to +32-bits doesn't come for free. In a real 64-bit system with a +64-bit operating system, and 64-bit applications, pointers are +now double their 32-bit size. This means more bytes to copy around +memory, and in an extreme case, has the potential to approach +halfing both the memory latency to access many such pointers from +RAM, and half the effective amount of RAM. In real world cases, +not everything is a pointer, so this sort of performance degradation +is doubtful - but it is something to keep in mind. + +In response to this, it appears that, at least on the Intel/AMD side +of things, they've increased the bandwidth on the motherboard, and +allowed for faster memory to be connected to the motherboard. They've +increased the complexity of the chip, to allow 64-bit register +operations to be equivalent in speed to 32-bit register operations. +I have no idea what else they've done... :-) + +So, it may be difficult to properly compare a 32-bit system to a +64-bit system. Even if the Ghz on the chip appears equal, it isn't +the same chip, and unless it is the exact same make, product and +version of the motherboard, it may not be a fair compairson. Turning +support for 32-bit on or off, and using a kernel that is only 32-bit +may give good comparisons - but with the above explanation, I would +expect the 32-bit application + kernel to out-perform the 64-bit +application. + +So then we move on to what 64-bit is really useful for. Obviously, +there is the arithmetic. If you were previously doing 64-bit +arithmetic through software, you will notice an immediate speed +improvement when doing it through hardware instead. If you have +a program that is scanning memory in any way, it may benefit from +64-bit instructions (for example - copying data 64-bit words at +a time instead of 32-bit words at a time). PostgreSQL might benefit +slightly from either of these, slightly balancing the performance +degradation of using more memory to store the pointers, and more +memory bandwidth the access the pointers. + +The real benefit of 64-bit is address space. From the kernel +perspective, it means that more programs, or bigger programs can run +at once. From the application perspective, it means your application +can use more than 32-bits of address space. For programs that make +extensive use of mmap(), this can be a necessity. They are mapping +very large files into their own address space. This isn't a +performance boost, as much as it is a 'you can't do it', if the +files mmap()'ed at the same time, will not fit within 32-bits of +address space. This also becomes, potentially, a performance +degradation, as the system is now having to manage applications +that have very large page tables. Page faults may become +expensive. + +PostgreSQL uses read(), instead of mmap(), and uses <2 Gbyte files. +PostgreSQL doesn't require the additional address space for normal +operation. + +If, however, you happen to have a very large amount of physical memory +- more memory than is supported by a 32-bit system, but is supported +by your 64-bit system, then the operating system should be able to use +this additional physical memory to cache file system data pages, which +will benefit PostgreSQL if used with tables that are larger than the +memory supported by your 32-bit system, and which have queries which +require more pages than the memory supported by your 32-bit system to +be frequently accessed. If you have a huge database, with many clients +accessing the data, this would be a definate yes. With anything less, +it is a maybe, or a probably not. + +I've been looking at switching to 64-bit, mostly to benefit from the +better motherboard bandwidth, and just to play around. I'm not +expecting to require the 64-bit instructions. + +Hope this helps, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 16:25:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A5E50D72B3 + for ; + Wed, 24 Aug 2005 15:47:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61138-09 + for ; + Wed, 24 Aug 2005 18:47:20 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id B18E1D79B7 + for ; + Wed, 24 Aug 2005 15:47:18 -0300 (ADT) +Received: from wren.rentec.com (wren.rentec.com [192.5.35.106]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j7OIl9GK020673 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Wed, 24 Aug 2005 14:47:10 -0400 (EDT) +X-Rentec: external +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by wren.rentec.com (8.13.1/8.12.1) with ESMTP id j7OIl9ds022058; + Wed, 24 Aug 2005 14:47:09 -0400 (EDT) +Message-ID: <430CC0AD.5040400@rentec.com> +Date: Wed, 24 Aug 2005 14:47:09 -0400 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 1.0+ (X11/20050712) +MIME-Version: 1.0 +To: mark@mark.mielke.cc +Cc: Donald Courtney , + William Yu , pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> <20050824173055.GA11788@mark.mielke.cc> +In-Reply-To: <20050824173055.GA11788@mark.mielke.cc> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as j7OIl9GK020673 at Wed Aug 24 + 14:47:10 2005 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.02 required=5 tests=[AWL=0.020] +X-Spam-Level: +X-Archive-Number: 200508/397 +X-Sequence-Number: 14144 + +mark@mark.mielke.cc wrote: +> So then we move on to what 64-bit is really useful for. Obviously, +> there is the arithmetic. If you were previously doing 64-bit +> arithmetic through software, you will notice an immediate speed +> improvement when doing it through hardware instead. If you have +> a program that is scanning memory in any way, it may benefit from +> 64-bit instructions (for example - copying data 64-bit words at +> a time instead of 32-bit words at a time). PostgreSQL might benefit +> slightly from either of these, slightly balancing the performance +> degradation of using more memory to store the pointers, and more +> memory bandwidth the access the pointers. +> +At least on Sparc processors, v8 and newer, any double precision math +(including longs) is performed with a single instruction, just like for +a 32 bit datum. Loads and stores of 8 byte datums are also handled via +a single instruction. The urban myth that 64bit math is +different/better on a 64 bit processor is just that; yes, some lower +end processors would emulate/trap those instructions but that an +implementation detail, not architecture. I believe that this is all +true for other RISC processors as well. + +The 64bit API on UltraSparcs does bring along some extra FP registers IIRC. + +> If, however, you happen to have a very large amount of physical memory +> - more memory than is supported by a 32-bit system, but is supported +> by your 64-bit system, then the operating system should be able to use +> this additional physical memory to cache file system data pages, which +> will benefit PostgreSQL if used with tables that are larger than the +> memory supported by your 32-bit system, and which have queries which +> require more pages than the memory supported by your 32-bit system to +> be frequently accessed. If you have a huge database, with many clients +> accessing the data, this would be a definate yes. With anything less, +> it is a maybe, or a probably not. +> +Solaris, at least, provided support for far more than 4GB of physical +memory on 32 bit kernels. A newer 64 bit kernel might be more +efficient, but that's just because the time was taken to support large +page sizes and more efficient data structures. It's nothing intrinsic +to a 32 vs 64 bit kernel. + +-- Alan + +From pgsql-performance-owner@postgresql.org Wed Aug 24 16:06:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B701D7903 + for ; + Wed, 24 Aug 2005 16:01:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94524-03 + for ; + Wed, 24 Aug 2005 19:01:08 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 11354D7771 + for ; + Wed, 24 Aug 2005 16:01:08 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.13.1/8.13.1) with ESMTP id j7OJ18BN005228 + for ; Wed, 24 Aug 2005 19:01:08 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.13.1/8.13.1/Submit) id j7OIsmFU093991 + for pgsql-performance@postgresql.org; Wed, 24 Aug 2005 18:54:48 GMT + (envelope-from news) +From: William Yu +X-Newsgroups: pgsql.performance +Subject: Re: Caching by Postgres +Date: Wed, 24 Aug 2005 11:54:42 -0700 +Organization: Hub.Org Networking Services +Lines: 21 +Message-ID: +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +In-Reply-To: <430C7448.7030103@sun.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=-2.641 required=5 tests=[ALL_TRUSTED=-2.82, AWL=0.179] +X-Spam-Level: +X-Archive-Number: 200508/395 +X-Sequence-Number: 14142 + +Donald Courtney wrote: +> I built postgreSQL 8.1 64K bit on solaris 10 a few months ago +> and side by side with the 32 bit postgreSQL build saw no improvement. In +> fact the 64 bit result was slightly lower. + +I'm not surprised 32-bit binaries running on a 64-bit OS would be faster +than 64-bit/64-bit. 64-bit isn't some magical wand you wave and it's all +ok. Programs compiled as 64-bit will only run faster if (1) you need +64-bit address space and you've been using ugly hacks like PAE to get +access to memory > 2GB or (2) you need native 64-bit data types and +you've been using ugly hacks to piece 32-bit ints together (example, +encryption/compression). In most cases, 64-bit will run slightly slower +due to extra overhead of using larger datatypes. + +Since PostgreSQL hands off the majority of memory management/data +caching to the OS, only the OS needs to be 64-bit to reap the benefits +of better memory management. Since Postgres *ALREADY* reaps the 64-bit +benefit, I'm not sure how the argument moving caching/mm/fs into +Postgres would apply. Yes there's the point about possibly implementing +better/smarter/more appropriate caching algorithms but that has nothing +to do with 64-bit. + +From pgsql-performance-owner@postgresql.org Wed Aug 24 16:17:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A4050D72B3 + for ; + Wed, 24 Aug 2005 15:59:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75965-08 + for ; + Wed, 24 Aug 2005 18:59:14 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id C0D51D7A01 + for ; + Wed, 24 Aug 2005 15:59:12 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Some ideas for comment +Date: Wed, 24 Aug 2005 14:59:12 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD1AB@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Some ideas for comment +Thread-Index: AcWo0rYU7GIt7hM2Qe2fSAtg0O/haAACZp4Q +From: "Merlin Moncure" +To: "Chris Hoover" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/396 +X-Sequence-Number: 14143 + +> Ok, there is always a lot of talk about tuning PostgreSQL on linux and +> how PostgreSQL uses the linux kernel cache to cache the tables and +> indexes. +[...] +>=20 +> 1. Implement a partition type layout using views and rules - This +> will allow me to have one table in each view with the "active" data, +> and the inactive data stored by year in other tables. +>=20 +> So I would have the following (for each major table): +>=20 +> Table View as +> select * from active_table +> union all +> select * from table_2005 +> union all +> select * from table_2004 +> etc. + +Linux does a pretty good job of deciding what to cache. I don't think +this will help much. You can always look at partial indexes too. + +> 2. I am also thinking of recommending we collapse all databases in a +> cluster into one "mega" database. I can then use schema's and views +> to control database access and ensure that no customer can see another +> customers data. + +hm. keep in mind views are tightly bound to the tables they are created +with (views can't 'float' over tables in different schemas). pl/pgsql +functions can, though. This is a more efficient use of server +resources, IMO, but not a windfall. +=20 +> This would mean that there are only one set of indexes being loaded +> into the cache. While they would be larger, I think in combination +> with the partition from idea 1, we would be ahead of the ball game. +> Since there would only be one set of indexes, everyone would be +> sharing them so they should always be in memory. + +I would strongly consider adding more memory :). +=20 +> I don't have real numbers to give you, but we know that our systems +> are hurting i/o wise and we are growing by about 2GB+ per week (net). +> We actually grow by about 5GB/week/server. However, when I run my +> weekly maintenance of vacuum full, reindex, and the vacuum analyze, we +> end up getting about 3GB back. Unfortunately, I do not have the i/o +> bandwidth to vacuum during the day as it causes major slowdowns on our +> system. Each night, I do run a vacuum analyze across all db's to try +> and help. I also have my fsm parameters set high (8000000 fsm pages, +> and 5000 fsm relations) to try and compensate. + +Generally, you can reduce data turnover for the same workload by +normalizing your database. IOW, try and make your database more +efficient in the way it stores data. + +> Right now, we are still on 7.3.4. However, these ideas would be +> implemented as part of an upgrade to 8.x (plus, we'll initialize the +> new clusters with a C locale). + +yes, do this! + +Merlin + +From pgsql-performance-owner@postgresql.org Wed Aug 24 17:08:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B6BA5D7803 + for ; + Wed, 24 Aug 2005 16:43:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54356-08 + for ; + Wed, 24 Aug 2005 19:42:59 +0000 (GMT) +Received: from mail.envyfinancial.com (unknown [206.248.142.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B354D6F72 + for ; + Wed, 24 Aug 2005 16:42:58 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envyfinancial.com (Postfix) with ESMTP id 9A9911BB55; + Wed, 24 Aug 2005 15:34:41 -0400 (EDT) +Received: from mail.envyfinancial.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 13987-01; Wed, 24 Aug 2005 15:34:41 -0400 (EDT) +Received: by mail.envyfinancial.com (Postfix, from userid 500) + id 2C9791BB58; Wed, 24 Aug 2005 15:34:41 -0400 (EDT) +Date: Wed, 24 Aug 2005 15:34:41 -0400 +From: mark@mark.mielke.cc +To: Alan Stange +Cc: Donald Courtney , + William Yu , pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +Message-ID: <20050824193441.GA13772@mark.mielke.cc> +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> <20050824173055.GA11788@mark.mielke.cc> + <430CC0AD.5040400@rentec.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <430CC0AD.5040400@rentec.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envyfinancial.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.22 required=5 tests=[AWL=0.042, NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/400 +X-Sequence-Number: 14147 + +On Wed, Aug 24, 2005 at 02:47:09PM -0400, Alan Stange wrote: +> At least on Sparc processors, v8 and newer, any double precision math +> (including longs) is performed with a single instruction, just like for +> a 32 bit datum. Loads and stores of 8 byte datums are also handled via +> a single instruction. The urban myth that 64bit math is +> different/better on a 64 bit processor is just that; yes, some lower +> end processors would emulate/trap those instructions but that an +> implementation detail, not architecture. + +It isn't an urban myth that 64-bit math on a 64-bit processor is +faster, at least if done using registers. It definately is faster. + +It may be an urban myth, though, that most applications perform +a sufficient amount of 64-bit arithmetic to warrant the upgrade. +The benefit may be lost in the noise for an application such as +PostgreSQL. It takes, effectively, infinately longer to access +a disk page, than to increment a 64-bit integer in software. + +For the lower end processors that emulate/trap these instructions, +they are being performed in software, along with the overhead of a +trap, and are therefore not a single instruction any more. We are +coming at this from different sides (which is good - perspective is +always good :-) ). From the Intel/AMD side of things, ALL non 64-bit +platforms are 'lower end processors', and don't emulate/trap the +instructions as they didn't exist (at least not yet - who knows what +clever and sufficiently motivated people will do :-) ). + +> >If, however, you happen to have a very large amount of physical memory +> >- more memory than is supported by a 32-bit system, but is supported +> >by your 64-bit system, then the operating system should be able to use +> >this additional physical memory to cache file system data pages, which +> >will benefit PostgreSQL if used with tables that are larger than the +> >memory supported by your 32-bit system, and which have queries which +> >require more pages than the memory supported by your 32-bit system to +> >be frequently accessed. If you have a huge database, with many clients +> >accessing the data, this would be a definate yes. With anything less, +> >it is a maybe, or a probably not. +> Solaris, at least, provided support for far more than 4GB of physical +> memory on 32 bit kernels. A newer 64 bit kernel might be more +> efficient, but that's just because the time was taken to support large +> page sizes and more efficient data structures. It's nothing intrinsic +> to a 32 vs 64 bit kernel. + +Hehe. That's why I was so careful to qualify my statements. :-) + +But yeah, I agree. It's a lot of hype, for not much gain (and some +loss, depending on what it is being used for). I only want one because +they're built better, and because I want to play around. + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 16:51:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 143BFD7832 + for ; + Wed, 24 Aug 2005 16:51:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75508-09 + for ; + Wed, 24 Aug 2005 19:51:40 +0000 (GMT) +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by svr1.postgresql.org (Postfix) with ESMTP id C71C9D77E5 + for ; + Wed, 24 Aug 2005 16:51:37 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) (216.155.73.164) + by mx2.surnet.cl with ESMTP; 24 Aug 2005 16:51:16 -0400 +X-IronPort-AV: i="3.96,138,1122868800"; d="scan'208"; a="2531923:sNHT94544510" +Received: from alvh.no-ip.org (216.155.78.140) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 42B3EF600094A550; Wed, 24 Aug 2005 15:51:38 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 2E120C2DC2A; Wed, 24 Aug 2005 15:51:43 -0400 (CLT) +Date: Wed, 24 Aug 2005 15:51:43 -0400 +From: Alvaro Herrera +To: Chris Hoover +Cc: pgsql-performance@postgresql.org +Subject: Re: Some ideas for comment +Message-ID: <20050824195143.GE17609@surnet.cl> +Mail-Followup-To: Chris Hoover , + pgsql-performance@postgresql.org +References: <1d219a6f05082409563775a8a7@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1d219a6f05082409563775a8a7@mail.gmail.com> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.069 required=5 tests=[AWL=-0.707, + DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, + RCVD_IN_NJABL_PROXY=1.026] +X-Spam-Level: ** +X-Archive-Number: 200508/398 +X-Sequence-Number: 14145 + +On Wed, Aug 24, 2005 at 12:56:54PM -0400, Chris Hoover wrote: + +> I don't have real numbers to give you, but we know that our systems +> are hurting i/o wise and we are growing by about 2GB+ per week (net). +> We actually grow by about 5GB/week/server. However, when I run my +> weekly maintenance of vacuum full, reindex, and the vacuum analyze, we +> end up getting about 3GB back. Unfortunately, I do not have the i/o +> bandwidth to vacuum during the day as it causes major slowdowns on our +> system. Each night, I do run a vacuum analyze across all db's to try +> and help. I also have my fsm parameters set high (8000000 fsm pages, +> and 5000 fsm relations) to try and compensate. + +[...] + +> Right now, we are still on 7.3.4. However, these ideas would be +> implemented as part of an upgrade to 8.x (plus, we'll initialize the +> new clusters with a C locale). + +If you were on a newer version, I'd suggest that you use the cost-based +vacuum delay, and vacuum at least some of the tables more often. This +way you can reduce the continual growth of the data files without +affecting day-to-day performance, because you allow the VACUUM-inflicted +I/O to be interleaved by normal query execution. + +Sadly (for you), I think the cost-based vacuum delay feature was only +introduced in 8.0. + +-- +Alvaro Herrera () +Officer Krupke, what are we to do? +Gee, officer Krupke, Krup you! (West Side Story, "Gee, Officer Krupke") + +From pgsql-performance-owner@postgresql.org Wed Aug 24 17:03:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C457FD7974 + for ; + Wed, 24 Aug 2005 17:00:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91731-06 + for ; + Wed, 24 Aug 2005 20:00:49 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CA1E3D76B7 + for ; + Wed, 24 Aug 2005 17:00:46 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7OK0jjW008482; + Wed, 24 Aug 2005 16:00:45 -0400 (EDT) +To: "Merlin Moncure" +Cc: "Chris Hoover" , + pgsql-performance@postgresql.org +Subject: Re: Some ideas for comment +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB3417DD1AB@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD1AB@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Wed, 24 Aug 2005 14:59:12 -0400" +Date: Wed, 24 Aug 2005 16:00:45 -0400 +Message-ID: <8481.1124913645@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/399 +X-Sequence-Number: 14146 + +"Merlin Moncure" writes: +>> Right now, we are still on 7.3.4. However, these ideas would be +>> implemented as part of an upgrade to 8.x (plus, we'll initialize the +>> new clusters with a C locale). + +> yes, do this! + +Moving from 7.3 to 8.0 is alone likely to give you a noticeable +performance boost. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 24 18:37:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 91BC8D79DE + for ; + Wed, 24 Aug 2005 17:03:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85114-06 + for ; + Wed, 24 Aug 2005 20:03:47 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 0EBB4D79CD + for ; + Wed, 24 Aug 2005 17:03:45 -0300 (ADT) +Received: (qmail 1694 invoked from network); 24 Aug 2005 22:04:08 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 24 Aug 2005 22:04:08 +0200 +Date: Wed, 24 Aug 2005 22:03:43 +0200 +To: stange@rentec.com, mark@mark.mielke.cc +Subject: Re: Caching by Postgres +Cc: "Donald Courtney" , + "William Yu" , pgsql-performance@postgresql.org +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> <20050824173055.GA11788@mark.mielke.cc> + <430CC0AD.5040400@rentec.com> +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <430CC0AD.5040400@rentec.com> +User-Agent: Opera M2/8.0 (Linux, build 1095) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/405 +X-Sequence-Number: 14152 + + + +> At least on Sparc processors, v8 and newer, any double precision math +> (including longs) is performed with a single instruction, just like for +> a 32 bit datum. Loads and stores of 8 byte datums are also handled via +> a single instruction. The urban myth that 64bit math is +> different/better on a 64 bit processor is just that; yes, some lower +> end processors would emulate/trap those instructions but that an +> implementation detail, not architecture. I believe that this is all +> true for other RISC processors as well. +> +> The 64bit API on UltraSparcs does bring along some extra FP registers +> IIRC. + + It's very different on x86. + 64-bit x86 like the Opteron has more registers, which are very scarce on +the base x86 (8 I think). This alone is very important. There are other +factors as well. + +> Solaris, at least, provided support for far more than 4GB of physical +> memory on 32 bit kernels. A newer 64 bit kernel might be more +> efficient, but that's just because the time was taken to support large +> page sizes and more efficient data structures. It's nothing intrinsic +> to a 32 vs 64 bit kernel. + + Well, on a large working set, a processor which can directly address more +than 4GB of memory will be a lot faster than one which can't, and has to +play with the MMU and paging units ! + +From pgsql-performance-owner@postgresql.org Wed Aug 24 18:28:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A707D77CC + for ; + Wed, 24 Aug 2005 17:10:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05573-01 + for ; + Wed, 24 Aug 2005 20:10:44 +0000 (GMT) +Received: from ausimss.pervasive.com (ausimss.pervasive.com [66.45.103.246]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C761D76B7 + for ; + Wed, 24 Aug 2005 17:10:39 -0300 (ADT) +Received: from ausbayes2.aus.pervasive.com ([172.16.8.8]) by + ausimss.pervasive.com with InterScan Messaging Security Suite; + Wed, 24 Aug 2005 15:10:38 -0500 +Received: from ausbayes1.aus.pervasive.com ([172.16.8.6]) by + ausbayes2.aus.pervasive.com with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 24 Aug 2005 15:10:38 -0500 +Received: from ausmailowa.aus.pervasive.com ([172.16.4.8]) by + ausbayes1.aus.pervasive.com with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 24 Aug 2005 15:10:38 -0500 +Received: from ausmail2k2.aus.pervasive.com ([172.16.4.9]) by + ausmailowa.aus.pervasive.com with Microsoft SMTPSVC(6.0.3790.1830); + Wed, 24 Aug 2005 15:10:37 -0500 +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: Read/Write block sizes +Date: Wed, 24 Aug 2005 15:10:37 -0500 +Message-ID: + <072BDB2B234F3840B0AC03411084C9AF869911@ausmail2k2.aus.pervasive.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Read/Write block sizes +Thread-Index: AcWo5+SGCG6LxAh9SkKyyvvry40Dug== +From: "Lance Obermeyer" +To: "Bruce Momjian" , + "Jignesh K. Shah" +Cc: "Jim Nasby" , + "Chris Browne" , +X-OriginalArrivalTime: 24 Aug 2005 20:10:37.0777 (UTC) + FILETIME=[E4B2EC10:01C5A8E7] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/404 +X-Sequence-Number: 14151 + +Since Bruce referred to the "corporate software world" I'll chime in... + +It has been a while since adding knobs and dials has been considered a = +good idea. Customers are almost always bad at tuning their systems, = +which decreases customer satisfaction. While many people assume the = +corporate types don't care, that is actually far from the truth. Well = +run commercial software companies regularly commission (expensive) = +customer satisfaction surveys. These numbers are the second most = +important numbers in all of the enterprise, trailing only revenue in = +importance. Results are sliced and diced in every way imaginable. + +The commercial world is trying to auto-tune their systems just as much. = +Examples are the work that many of the big boys are doing towards = +"autonomic" computing. While it is driven by naked self interest of = +wanting to sell version upgrades, those efforts increase customer = +satisfaction and decrease support costs. Works well for everyone... + + + +-----Original Message----- +From: Bruce Momjian [mailto:pgman@candle.pha.pa.us] +Sent: Wednesday, August 24, 2005 8:52 AM +To: Jignesh K. Shah +Cc: Jim Nasby; Chris Browne; pgsql-performance@postgresql.org +Subject: Re: Read/Write block sizes + + + +This thread covers several performance ideas. First is the idea that +more parameters should be configurable. While this seems like a noble +goal, we try to make parameters auto-tuning, or if users have to +configure it, the parameter should be useful for a significant number of +users. + +In the commercial software world, if you can convince your boss that a +feature/knob is useful, it usually gets into the product.=20 +Unfortunately, this leads to the golden doorknob on a shack, where some +features are out of sync with the rest of the product in terms of +usefulness and utility. With open source, if a feature can not be +auto-tuned, or has significant overhead, the features has to be +implemented and then proven to be a benefit. + +In terms of adding async I/O, threading, and other things, it might make +sense to explore how these could be implemented in a way that fits the +above criteria. + +-------------------------------------------------------------------------= +-- + +Jignesh K. Shah wrote: +> Hi Jim, +>=20 +> | How many of these things are currently easy to change with a = +recompile? +> | I should be able to start testing some of these ideas in the near +> | future, if they only require minor code or configure changes. +>=20 +>=20 +> The following +> * Data File Size 1GB +> * WAL File Size of 16MB +> * Block Size of 8K +>=20 +> Are very easy to change with a recompile.. A Tunable will be greatly=20 +> prefered as it will allow one binary for different tunings +>=20 +> * MultiBlock read/write +>=20 +> Is not available but will greatly help in reducing the number of = +system=20 +> calls which will only increase as the size of the database increases = +if=20 +> something is not done about i. +>=20 +> * Pregrown files... maybe not important at this point since TABLESPACE = + +> can currently work around it a bit (Just need to create a different = +file=20 +> system for each tablespace +>=20 +> But if you really think hardware & OS is the answer for all small=20 +> things...... I think we should now start to look on how to make = +Postgres=20 +> Multi-threaded or multi-processed for each connection. With the influx = + +> of "Dual-Core" or "Multi-Core" being the fad.... Postgres can have = +the=20 +> cutting edge if somehow exploiting cores is designed. +>=20 +> Somebody mentioned that adding CPU to Postgres workload halved the=20 +> average CPU usage... +> YEAH... PostgreSQL uses only 1 CPU per connection (assuming 100%=20 +> usage) so if you add another CPU it is idle anyway and the system = +will=20 +> report only 50% :-) BUT the importing to measure is.. whether the = +query=20 +> time was cut down or not? ( No flames I am sure you were talking about = + +> multi-connection multi-user environment :-) ) But my point is then = +this=20 +> approach is worth the ROI and the time and effort spent to solve this=20 +> problem. +>=20 +> I actually vote for a multi-threaded solution for each connection = +while=20 +> still maintaining seperate process for each connections... This way = +the=20 +> fundamental architecture of Postgres doesn't change, however a=20 +> multi-threaded connection can then start to exploit different cores..=20 +> (Maybe have tunables for number of threads to read data files who=20 +> knows.. If somebody is interested in actually working a design ..=20 +> contact me and I will be interested in assisting this work. +>=20 +> Regards, +> Jignesh +>=20 +>=20 +> Jim C. Nasby wrote: +>=20 +> >On Tue, Aug 23, 2005 at 06:09:09PM -0400, Chris Browne wrote: +> > =20 +> > +> >>J.K.Shah@Sun.COM (Jignesh Shah) writes: +> >> =20 +> >> +> >>>>Does that include increasing the size of read/write blocks? I've +> >>>>noticedthat with a large enough table it takes a while to do a +> >>>>sequential scan, even if it's cached; I wonder if the fact that it +> >>>>takes a million read(2) calls to get through an 8G table is part = +of +> >>>>that. +> >>>> =20 +> >>>> +> >>>Actually some of that readaheads,etc the OS does already if it does +> >>>some sort of throttling/clubbing of reads/writes. But its not = +enough +> >>>for such types of workloads. +> >>> +> >>>Here is what I think will help: +> >>> +> >>>* Support for different Blocksize TABLESPACE without recompiling = +the +> >>>code.. (Atlease support for a different Blocksize for the whole +> >>>database without recompiling the code) +> >>> +> >>>* Support for bigger sizes of WAL files instead of 16MB files +> >>>WITHOUT recompiling the code.. Should be a tuneable if you ask me +> >>>(with checkpoint_segments at 256.. you have too many 16MB files in +> >>>the log directory) (This will help OLTP benchmarks more since now +> >>>they don't spend time rotating log files) +> >>> +> >>>* Introduce a multiblock or extent tunable variable where you can +> >>>define a multiple of 8K (or BlockSize tuneable) to read a bigger +> >>>chunk and store it in the bufferpool.. (Maybe writes too) (Most +> >>>devices now support upto 1MB chunks for reads and writes) +> >>> +> >>>*There should be a way to preallocate files for TABLES in +> >>>TABLESPACES otherwise with multiple table writes in the same +> >>>filesystem ends with fragmented files which causes poor "READS" = +from +> >>>the files. +> >>> +> >>>* With 64bit 1GB file chunks is also moot.. Maybe it should be +> >>>tuneable too like 100GB without recompiling the code. +> >>> +> >>>Why recompiling is bad? Most companies that will support Postgres +> >>>will support their own binaries and they won't prefer different +> >>>versions of binaries for different blocksizes, different WAL file +> >>>sizes, etc... and hence more function using the same set of = +binaries +> >>>is more desirable in enterprise environments +> >>> =20 +> >>> +> >>Every single one of these still begs the question of whether the +> >>changes will have a *material* impact on performance. +> >> =20 +> >> +>=20 +>=20 +> ---------------------------(end of = +broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +>=20 +> http://www.postgresql.org/docs/faq +>=20 + +--=20 + 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 Aug 24 18:19:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 61578D79A1 + for ; + Wed, 24 Aug 2005 17:20:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04768-07 + for ; + Wed, 24 Aug 2005 20:20:37 +0000 (GMT) +Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34]) + by svr1.postgresql.org (Postfix) with ESMTP id EE41DD78D3 + for ; + Wed, 24 Aug 2005 17:20:33 -0300 (ADT) +Received: from phys-bur-1 ([129.148.9.72]) + by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id j7OKKYWZ000041 + for ; + Wed, 24 Aug 2005 14:20:35 -0600 (MDT) +Received: from conversion-daemon.bur-mail1.east.sun.com by + bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0ILQ00F01TU0ZC@bur-mail1.east.sun.com> + (original mail from J.K.Shah@Sun.COM) for + pgsql-performance@postgresql.org; + Wed, 24 Aug 2005 16:20:34 -0400 (EDT) +Received: from bur-mail1.east.sun.com (phys-bur-1 [129.148.9.72]) + by bur-mail1.east.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTP id <0ILQ00E43TUAD8@bur-mail1.east.sun.com>; Wed, + 24 Aug 2005 16:20:34 -0400 (EDT) +Received: from [129.148.168.2] by bur-mail1.east.sun.com (mshttpd); Wed, + 24 Aug 2005 16:20:34 -0400 +Date: Wed, 24 Aug 2005 16:20:34 -0400 +From: Jignesh Shah +Subject: Re: Read/Write block sizes +To: Lance Obermeyer +Cc: Bruce Momjian , + Jim Nasby , Chris Browne , + pgsql-performance@postgresql.org +Message-id: +MIME-version: 1.0 +X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.24 (built Dec 19 2003) +Content-type: text/plain; charset=us-ascii +Content-language: en +Content-transfer-encoding: 7BIT +Content-disposition: inline +X-Accept-Language: en +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/403 +X-Sequence-Number: 14150 + +Agreed!!! + +But the knowledge to Auto-tune your application comes from years of understanding of how users are using the so-called "knobs".. But if the "knobs" are not there in the first place.. how do you know what people are using? + +The "so-called" big boys are also using their knowledge base of what works for the customer in their autonomic self healers and its based on the experience of all the settings possible and based on service requests on what had failed that they get the knowledge about avoiding what fails and tuning what works. + +Remember "recompiling" is a risk with upteem number of variables which not every production release engineer is happy about. + +Its easy to change back the knob to the previous value rather than trying to figure out how do I get my old binaries back. + + +-Jignesh + + +----- Original Message ----- +From: Lance Obermeyer +Date: Wednesday, August 24, 2005 4:10 pm +Subject: RE: Read/Write block sizes + +> Since Bruce referred to the "corporate software world" I'll chime +> in... +> It has been a while since adding knobs and dials has been +> considered a good idea. Customers are almost always bad at tuning +> their systems, which decreases customer satisfaction. While many +> people assume the corporate types don't care, that is actually far +> from the truth. Well run commercial software companies regularly +> commission (expensive) customer satisfaction surveys. These +> numbers are the second most important numbers in all of the +> enterprise, trailing only revenue in importance. Results are +> sliced and diced in every way imaginable. +> +> The commercial world is trying to auto-tune their systems just as +> much. Examples are the work that many of the big boys are doing +> towards "autonomic" computing. While it is driven by naked self +> interest of wanting to sell version upgrades, those efforts +> increase customer satisfaction and decrease support costs. Works +> well for everyone... +> +> +> +> -----Original Message----- +> From: Bruce Momjian [pgman@candle.pha.pa.us] +> Sent: Wednesday, August 24, 2005 8:52 AM +> To: Jignesh K. Shah +> Cc: Jim Nasby; Chris Browne; pgsql-performance@postgresql.org +> Subject: Re: Read/Write block sizes +> +> +> +> This thread covers several performance ideas. First is the idea that +> more parameters should be configurable. While this seems like a +> noblegoal, we try to make parameters auto-tuning, or if users have to +> configure it, the parameter should be useful for a significant +> number of +> users. +> +> In the commercial software world, if you can convince your boss +> that a +> feature/knob is useful, it usually gets into the product. +> Unfortunately, this leads to the golden doorknob on a shack, where +> somefeatures are out of sync with the rest of the product in terms of +> usefulness and utility. With open source, if a feature can not be +> auto-tuned, or has significant overhead, the features has to be +> implemented and then proven to be a benefit. +> +> In terms of adding async I/O, threading, and other things, it might +> makesense to explore how these could be implemented in a way that +> fits the +> above criteria. +> +> -------------------------------------------------------------------- +> ------- +> +> Jignesh K. Shah wrote: +> > Hi Jim, +> > +> > | How many of these things are currently easy to change with a +> recompile?> | I should be able to start testing some of these ideas +> in the near +> > | future, if they only require minor code or configure changes. +> > +> > +> > The following +> > * Data File Size 1GB +> > * WAL File Size of 16MB +> > * Block Size of 8K +> > +> > Are very easy to change with a recompile.. A Tunable will be +> greatly +> > prefered as it will allow one binary for different tunings +> > +> > * MultiBlock read/write +> > +> > Is not available but will greatly help in reducing the number of +> system +> > calls which will only increase as the size of the database +> increases if +> > something is not done about i. +> > +> > * Pregrown files... maybe not important at this point since +> TABLESPACE +> > can currently work around it a bit (Just need to create a +> different file +> > system for each tablespace +> > +> > But if you really think hardware & OS is the answer for all +> small +> > things...... I think we should now start to look on how to make +> Postgres +> > Multi-threaded or multi-processed for each connection. With the +> influx +> > of "Dual-Core" or "Multi-Core" being the fad.... Postgres can +> have the +> > cutting edge if somehow exploiting cores is designed. +> > +> > Somebody mentioned that adding CPU to Postgres workload halved +> the +> > average CPU usage... +> > YEAH... PostgreSQL uses only 1 CPU per connection (assuming 100% +> > usage) so if you add another CPU it is idle anyway and the +> system will +> > report only 50% :-) BUT the importing to measure is.. whether +> the query +> > time was cut down or not? ( No flames I am sure you were talking +> about +> > multi-connection multi-user environment :-) ) But my point is +> then this +> > approach is worth the ROI and the time and effort spent to solve +> this +> > problem. +> > +> > I actually vote for a multi-threaded solution for each connection +> while +> > still maintaining seperate process for each connections... This +> way the +> > fundamental architecture of Postgres doesn't change, however a +> > multi-threaded connection can then start to exploit different +> cores.. +> > (Maybe have tunables for number of threads to read data files who +> > knows.. If somebody is interested in actually working a design .. +> > contact me and I will be interested in assisting this work. +> > +> > Regards, +> > Jignesh +> > +> > +> > Jim C. Nasby wrote: +> > +> > >On Tue, Aug 23, 2005 at 06:09:09PM -0400, Chris Browne wrote: +> > > +> > > +> > >>J.K.Shah@Sun.COM (Jignesh Shah) writes: +> > >> +> > >> +> > >>>>Does that include increasing the size of read/write blocks? I've +> > >>>>noticedthat with a large enough table it takes a while to do a +> > >>>>sequential scan, even if it's cached; I wonder if the fact +> that it +> > >>>>takes a million read(2) calls to get through an 8G table is +> part of +> > >>>>that. +> > >>>> +> > >>>> +> > >>>Actually some of that readaheads,etc the OS does already if it +> does> >>>some sort of throttling/clubbing of reads/writes. But its +> not enough +> > >>>for such types of workloads. +> > >>> +> > >>>Here is what I think will help: +> > >>> +> > >>>* Support for different Blocksize TABLESPACE without +> recompiling the +> > >>>code.. (Atlease support for a different Blocksize for the whole +> > >>>database without recompiling the code) +> > >>> +> > >>>* Support for bigger sizes of WAL files instead of 16MB files +> > >>>WITHOUT recompiling the code.. Should be a tuneable if you ask me +> > >>>(with checkpoint_segments at 256.. you have too many 16MB +> files in +> > >>>the log directory) (This will help OLTP benchmarks more since now +> > >>>they don't spend time rotating log files) +> > >>> +> > >>>* Introduce a multiblock or extent tunable variable where you can +> > >>>define a multiple of 8K (or BlockSize tuneable) to read a bigger +> > >>>chunk and store it in the bufferpool.. (Maybe writes too) (Most +> > >>>devices now support upto 1MB chunks for reads and writes) +> > >>> +> > >>>*There should be a way to preallocate files for TABLES in +> > >>>TABLESPACES otherwise with multiple table writes in the same +> > >>>filesystem ends with fragmented files which causes poor +> "READS" from +> > >>>the files. +> > >>> +> > >>>* With 64bit 1GB file chunks is also moot.. Maybe it should be +> > >>>tuneable too like 100GB without recompiling the code. +> > >>> +> > >>>Why recompiling is bad? Most companies that will support Postgres +> > >>>will support their own binaries and they won't prefer different +> > >>>versions of binaries for different blocksizes, different WAL file +> > >>>sizes, etc... and hence more function using the same set of +> binaries> >>>is more desirable in enterprise environments +> > >>> +> > >>> +> > >>Every single one of these still begs the question of whether the +> > >>changes will have a *material* impact on performance. +> > >> +> > >> +> > +> > +> > ---------------------------(end of broadcast)--------------------- +> ------ +> > TIP 3: Have you checked our extensive FAQ? +> > +> > http://www.postgresql.org/docs/faq +> > +> +> -- +> 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 Aug 24 18:14:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BCB61D7A51 + for ; + Wed, 24 Aug 2005 17:26:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04229-10 + for ; + Wed, 24 Aug 2005 20:26:41 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 767A6D7A44 + for ; + Wed, 24 Aug 2005 17:26:39 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 8so111568nzo + for ; + Wed, 24 Aug 2005 13:26:41 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=E90xCPGHHNzOfIFscQm1vVxK7ta4PedI01UeMIfAugZMm4fFzPG+raPwF0G47oi5/9+0L0HTrPw9P+9OcPdziYgBoOHGCuXBWd58o+MjpwgGN/W71sKQyq2nQZXDSErZIayi3hhTaEr/TkfUFMtAF58yXzTXdBaO0pkREy5vtLo= +Received: by 10.36.10.20 with SMTP id 20mr3304159nzj; + Wed, 24 Aug 2005 13:26:40 -0700 (PDT) +Received: by 10.36.24.2 with HTTP; Wed, 24 Aug 2005 13:26:40 -0700 (PDT) +Message-ID: <1d219a6f05082413265e872134@mail.gmail.com> +Date: Wed, 24 Aug 2005 16:26:40 -0400 +From: Chris Hoover +To: Merlin Moncure +Subject: Re: Some ideas for comment +Cc: pgsql-performance@postgresql.org +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD1AB@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD1AB@Herge.rcsinc.local> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[AWL=-0.000, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/402 +X-Sequence-Number: 14149 + +On 8/24/05, Merlin Moncure wrote: +> > Ok, there is always a lot of talk about tuning PostgreSQL on linux and +> > how PostgreSQL uses the linux kernel cache to cache the tables and +> > indexes. +> [...] +> > +> > 1. Implement a partition type layout using views and rules - This +> > will allow me to have one table in each view with the "active" data, +> > and the inactive data stored by year in other tables. +> > +> > So I would have the following (for each major table): +> > +> > Table View as +> > select * from active_table +> > union all +> > select * from table_2005 +> > union all +> > select * from table_2004 +> > etc. +>=20 +> Linux does a pretty good job of deciding what to cache. I don't think +> this will help much. You can always look at partial indexes too. +>=20 +Yes, but won't this help create the need to store less? If I have +1,000.000 rows in a table, but only 4,000 are active, if I move those +4 to another table and link the tables via a view, should that not +help keep the 9,996,000 rows out of the kernel cache (the majority of +the time at least)? + +This would mean I have more room for other objects and hopefully less +turn over in the cache, and less disk i/o. + +Yes? +[...] +> I would strongly consider adding more memory :). +Unfortunately, it looks like 12GB is all our Dell servers can handle. :( + +>=20 +> > I don't have real numbers to give you, but we know that our systems +> > are hurting i/o wise and we are growing by about 2GB+ per week (net). +> > We actually grow by about 5GB/week/server. However, when I run my +> > weekly maintenance of vacuum full, reindex, and the vacuum analyze, we +> > end up getting about 3GB back. Unfortunately, I do not have the i/o +> > bandwidth to vacuum during the day as it causes major slowdowns on our +> > system. Each night, I do run a vacuum analyze across all db's to try +> > and help. I also have my fsm parameters set high (8000000 fsm pages, +> > and 5000 fsm relations) to try and compensate. +>=20 +> Generally, you can reduce data turnover for the same workload by +> normalizing your database. IOW, try and make your database more +> efficient in the way it stores data. +>=20 +That's the ultimate goal, but this database structure was developed +and released into production before I started work here. I'm trying +to slowly change it into a better db, but it is a slow process.=20 +Normalization does not make it at the top of the priority list, +unfortunately. + +> > Right now, we are still on 7.3.4. However, these ideas would be +> > implemented as part of an upgrade to 8.x (plus, we'll initialize the +> > new clusters with a C locale). +> > > 2. I am also thinking of recommending we collapse all databases in a +> > cluster into one "mega" database. I can then use schema's and views +> > to control database access and ensure that no customer can see another +> > customers data. +>=20 +> hm. keep in mind views are tightly bound to the tables they are created +> with (views can't 'float' over tables in different schemas). pl/pgsql +> functions can, though. This is a more efficient use of server +> resources, IMO, but not a windfall. + +This I know. Each schema would have to have a "custom" set of views +replacing the tables with the view programmed to only return that +customers data. + +I was thinking all of the tables in schema my_tables and the views all +querying the tables stored in the my_tables schema. I would add an +identifying column to each table so that I can differentiate the data. + +Chris + +From pgsql-performance-owner@postgresql.org Wed Aug 24 17:52:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D0CCD7A1E + for ; + Wed, 24 Aug 2005 17:43:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82006-08 + for ; + Wed, 24 Aug 2005 20:43:50 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.196]) + by svr1.postgresql.org (Postfix) with ESMTP id 45064D7A12 + for ; + Wed, 24 Aug 2005 17:43:49 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 8so113823nzo + for ; + Wed, 24 Aug 2005 13:43:51 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=O11vR1UMsMxWbs+ugX+la4+iLi+numSsTJc+ZIQzTnMVSBGm4MEcQBuUmrFBBuXdXVhuhMyJv5Dy+5UWwWpLIIqiiMsp1Wo4qsl2+MOmTWk8WWMdc7S66kGLqc/5o22zPTi18hOg6bh62XS8MG9nqasi1lrdpHFlm/d6N/Uq9rs= +Received: by 10.37.2.4 with SMTP id e4mr3022nzi; + Wed, 24 Aug 2005 13:43:51 -0700 (PDT) +Received: by 10.36.158.7 with HTTP; Wed, 24 Aug 2005 13:43:51 -0700 (PDT) +Message-ID: +Date: Wed, 24 Aug 2005 14:43:51 -0600 +From: Mark Fox +To: pgsql-performance@postgresql.org +Subject: Performance indexing of a simple query +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.177 required=5 tests=[AWL=0.153, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/401 +X-Sequence-Number: 14148 + +I have a table called 'jobs' with several million rows, and the only +columns that are important to this discussion are 'start_time' and +'completion_time'. + +The sort of queries I want to execute (among others) are like: + +SELECT * FROM jobs +WHERE completion_time > SOMEDATE AND start_time < SOMEDATE; + +In plain english: All the jobs that were running at SOMEDATE. The +result of the query is on the order of 500 rows. + +I've got seperate indexes on 'start_time' and 'completion_time'. + +Now, if SOMEDATE is such that the number of rows with completion_time +> SOMEDATE is small (say 10s of thousands), the query uses index scans +and executes quickly. If not, the query uses sequential scans and is +unacceptably slow (a couple of minutes). I've used EXPLAIN and +EXPLAIN ANALYZE to confirm this. This makes perfect sense to me. + +I've played with some of the memory settings for PostgreSQL, but none +has had a significant impact. + +Any ideas on how to structure the query or add/change indexes in such +a way to improve its performance? In desperation, I tried using a +subquery, but unsurprisingly it made no (positive) difference. I feel +like there might be a way of using an index on both 'completion_time' +and 'start_time', but can't put a temporal lobe on the details. + + +Mark + +From pgsql-performance-owner@postgresql.org Wed Aug 24 19:57:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 54ED0D78DF + for ; + Wed, 24 Aug 2005 17:57:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95843-01 + for ; + Wed, 24 Aug 2005 20:57:46 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id AF010D7832 + for ; + Wed, 24 Aug 2005 17:57:44 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id B8E5C15255; Wed, 24 Aug 2005 15:57:44 -0500 (CDT) +Date: Wed, 24 Aug 2005 15:57:44 -0500 +From: "Jim C. Nasby" +To: Chris Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: Read/Write block sizes +Message-ID: <20050824205744.GX96732@pervasive.com> +References: + <60k6icpapm.fsf@dba2.int.libertyrms.com> + <1124846743.12045.94.camel@amd64-laptop-spoe> + <60br3npb4p.fsf@dba2.int.libertyrms.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <60br3npb4p.fsf@dba2.int.libertyrms.com> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 required=5 tests=[AWL=0.010] +X-Spam-Level: +X-Archive-Number: 200508/409 +X-Sequence-Number: 14156 + +On Wed, Aug 24, 2005 at 12:12:22PM -0400, Chris Browne wrote: +> Everyone involved in development seems to me to have a reasonably keen +> understanding as to what the potential benefits of threading are; the +> value is that there fall out plenty of opportunities to parallelize +> the evaluation of portions of queries. Alas, it wouldn't be until +> *after* all the effort goes in that we would get any idea as to what +> kinds of speedups this would provide. + +My understanding is that the original suggestion was to use threads +within individual backends to allow for parallel query execution, not +swiching to a completely thread-based model. + +In any case, there are other ways to enable parallelism without using +threads, such as handing actual query execution off to a set of +processes. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Aug 24 19:45:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E9B7FD7A59 + for ; + Wed, 24 Aug 2005 18:10:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64704-10 + for ; + Wed, 24 Aug 2005 21:10:24 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id F39C2D7A19 + for ; + Wed, 24 Aug 2005 18:10:23 -0300 (ADT) +Received: from ram.rentec.com (mailhost [192.5.35.66]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j7OL959w025968 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Wed, 24 Aug 2005 17:09:06 -0400 (EDT) +X-Rentec: external +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by ram.rentec.com (8.13.1/8.12.1) with ESMTP id j7OL949a019445; + Wed, 24 Aug 2005 17:09:05 -0400 (EDT) +Message-ID: <430CE1F0.3080205@rentec.com> +Date: Wed, 24 Aug 2005 17:09:04 -0400 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 1.0+ (X11/20050712) +MIME-Version: 1.0 +To: mark@mark.mielke.cc +Cc: Donald Courtney , + pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> <20050824173055.GA11788@mark.mielke.cc> + <430CC0AD.5040400@rentec.com> + <20050824193441.GA13772@mark.mielke.cc> +In-Reply-To: <20050824193441.GA13772@mark.mielke.cc> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as j7OL959w025968 at Wed Aug 24 + 17:09:06 2005 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.019 required=5 tests=[AWL=0.019] +X-Spam-Level: +X-Archive-Number: 200508/407 +X-Sequence-Number: 14154 + +mark@mark.mielke.cc wrote: +> On Wed, Aug 24, 2005 at 02:47:09PM -0400, Alan Stange wrote: +> +>> At least on Sparc processors, v8 and newer, any double precision math +>> (including longs) is performed with a single instruction, just like for +>> a 32 bit datum. Loads and stores of 8 byte datums are also handled via +>> a single instruction. The urban myth that 64bit math is +>> different/better on a 64 bit processor is just that; yes, some lower +>> end processors would emulate/trap those instructions but that an +>> implementation detail, not architecture. +>> +> +> It isn't an urban myth that 64-bit math on a 64-bit processor is +> faster, at least if done using registers. It definately is faster. +> +The older 32bit RISC processors do have 64 bit registers, ALUs and +datapaths, and they are marketed toward high end scientific computing, +and you're claiming that such a processor is slower than one which has +the addition of 64 bit pointers added to it? + +As an example, an UltraSparc running a 32 bit kernel+application will +have the same double precision floating point performance as one +running a 64bit kernel+application (except for the additional FP +registers in the 64bit API). For a function like daxpy, it's the exact +same hardware running the exact same instructions! So why do you think +the performance would be different? + +I believe the IBM Power processors also upped everything to double +precision internally because of some details of the "multiply-add fused" +instructions. It's been a few years since I taught H&P to CS +undergrads, but I'm fairly sure the details are all the same for MIPS +processors as well. + +-- Alan + + + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 19:49:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 95FB0D79B8 + for ; + Wed, 24 Aug 2005 18:09:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94582-07 + for ; + Wed, 24 Aug 2005 21:09:16 +0000 (GMT) +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by svr1.postgresql.org (Postfix) with ESMTP id C551AD78C3 + for ; + Wed, 24 Aug 2005 18:09:12 -0300 (ADT) +Received: from osgiliath.mathom.us ([151.200.14.55]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix + 0.04 (built Dec 24 2004)) with ESMTPA id + <0ILQ009HTW3950E1@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 24 Aug 2005 16:09:11 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 861F060263C for + ; + Wed, 24 Aug 2005 17:09:09 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 29379-02-8 for ; Wed, + 24 Aug 2005 17:09:09 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 6A627602638; Wed, 24 Aug 2005 17:09:09 -0400 (EDT) +Date: Wed, 24 Aug 2005 17:09:09 -0400 +From: Michael Stone +Subject: Re: Caching by Postgres +In-reply-to: <20050824193441.GA13772@mark.mielke.cc> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050824210909.GN8667@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> + <20050824173055.GA11788@mark.mielke.cc> <430CC0AD.5040400@rentec.com> + <20050824193441.GA13772@mark.mielke.cc> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.041 required=5 tests=[AWL=-0.009, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/408 +X-Sequence-Number: 14155 + +On Wed, Aug 24, 2005 at 03:34:41PM -0400, mark@mark.mielke.cc wrote: +>It isn't an urban myth that 64-bit math on a 64-bit processor is +>faster, at least if done using registers. It definately is faster. +>It may be an urban myth, though, that most applications perform +>a sufficient amount of 64-bit arithmetic to warrant the upgrade. + +The mjor problem is that the definition of "64bit processor" is fuzzy. +The major slowdown of "64bitness" is the necessity of carting around +64 bit pointers. It's not, however, necessary to do 64bit pointers to +get 64bit registers & fast 64 bit ops. E.g., sgi has "n32" & "n64" abi's +which can access exactly the same instruction set & registers, the +difference between them is the size of pointers and whether a "long" is +the same as a "long long". Any discussion of "64 bit processors" is +doomed from the start because people tend to start making implementation +assumptions on top of an already vague concept. Current & future +discussions are tinged by the fact that amd64 *doubles* the number +of registers in 64 bit mode, potentially providing a major speedup--but +one that doesn't really have anything to do with being "64bit". +Pretty much any discussion of 64 bit mode really needs to be a +discussion of a particular abi on a particular processor; talking about +"64 bit processors" abstractly is a waste of time. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Wed Aug 24 19:21:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6321BD6FF5 + for ; + Wed, 24 Aug 2005 18:22:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75415-02 + for ; + Wed, 24 Aug 2005 21:22:34 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A75CD7A64 + for ; + Wed, 24 Aug 2005 18:22:32 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id DD02A1527C; Wed, 24 Aug 2005 16:22:34 -0500 (CDT) +Date: Wed, 24 Aug 2005 16:22:34 -0500 +From: "Jim C. Nasby" +To: Mark Fox +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance indexing of a simple query +Message-ID: <20050824212234.GZ96732@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 required=5 tests=[AWL=0.009] +X-Spam-Level: +X-Archive-Number: 200508/406 +X-Sequence-Number: 14153 + +Try + +CREATE INDEX start_complete ON jobs( start_time, completion_time ); + +Try also completion_time, start_time. One might work better than the +other. Or, depending on your data, you might want to keep both. + +In 8.1 you'll be able to do bitmap-based index combination, which might +allow making use of the seperate indexes. + +On Wed, Aug 24, 2005 at 02:43:51PM -0600, Mark Fox wrote: +> I have a table called 'jobs' with several million rows, and the only +> columns that are important to this discussion are 'start_time' and +> 'completion_time'. +> +> The sort of queries I want to execute (among others) are like: +> +> SELECT * FROM jobs +> WHERE completion_time > SOMEDATE AND start_time < SOMEDATE; +> +> In plain english: All the jobs that were running at SOMEDATE. The +> result of the query is on the order of 500 rows. +> +> I've got seperate indexes on 'start_time' and 'completion_time'. +> +> Now, if SOMEDATE is such that the number of rows with completion_time +> > SOMEDATE is small (say 10s of thousands), the query uses index scans +> and executes quickly. If not, the query uses sequential scans and is +> unacceptably slow (a couple of minutes). I've used EXPLAIN and +> EXPLAIN ANALYZE to confirm this. This makes perfect sense to me. +> +> I've played with some of the memory settings for PostgreSQL, but none +> has had a significant impact. +> +> Any ideas on how to structure the query or add/change indexes in such +> a way to improve its performance? In desperation, I tried using a +> subquery, but unsurprisingly it made no (positive) difference. I feel +> like there might be a way of using an index on both 'completion_time' +> and 'start_time', but can't put a temporal lobe on the details. +> +> +> Mark +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Aug 24 21:31:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DF3CD7AA1 + for ; + Wed, 24 Aug 2005 20:42:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34651-02 + for ; + Wed, 24 Aug 2005 23:42:00 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 651FFD78D3 + for ; + Wed, 24 Aug 2005 20:41:58 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7ONg0oU016555; + Wed, 24 Aug 2005 19:42:00 -0400 (EDT) +To: Mark Fox +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance indexing of a simple query +In-reply-to: +References: +Comments: In-reply-to Mark Fox + message dated "Wed, 24 Aug 2005 14:43:51 -0600" +Date: Wed, 24 Aug 2005 19:42:00 -0400 +Message-ID: <16554.1124926920@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/412 +X-Sequence-Number: 14159 + +Mark Fox writes: +> The sort of queries I want to execute (among others) are like: +> SELECT * FROM jobs +> WHERE completion_time > SOMEDATE AND start_time < SOMEDATE; +> In plain english: All the jobs that were running at SOMEDATE. + +AFAIK there is no good way to do this with btree indexes; the problem +is that it's fundamentally a 2-dimensional query and btrees are +1-dimensional. There are various hacks you can try if you're willing +to constrain the problem (eg, if you can assume some not-very-large +maximum on the running time of jobs) but in full generality btrees are +just the Wrong Thing. + +So what you want to look at is a non-btree index, ie, rtree or gist. +For example, the contrib/seg data type could pretty directly be adapted +to solve this problem, since it can index searches for overlapping +line segments. + +The main drawback of these index types in existing releases is that they +are bad on concurrent updates and don't have WAL support. Both those +things are (allegedly) fixed for GIST in 8.1 ... are you interested in +trying out 8.1beta? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 24 21:30:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D3DF8D7B01 + for ; + Wed, 24 Aug 2005 21:22:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47444-03 + for ; + Thu, 25 Aug 2005 00:22:54 +0000 (GMT) +Received: from mail.envyfinancial.com (unknown [206.248.142.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F924D7B1A + for ; + Wed, 24 Aug 2005 21:22:52 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envyfinancial.com (Postfix) with ESMTP id 5DDB01BD2D; + Wed, 24 Aug 2005 20:13:20 -0400 (EDT) +Received: from mail.envyfinancial.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 18226-05; Wed, 24 Aug 2005 20:13:20 -0400 (EDT) +Received: by mail.envyfinancial.com (Postfix, from userid 500) + id 235881BD2E; Wed, 24 Aug 2005 20:13:20 -0400 (EDT) +Date: Wed, 24 Aug 2005 20:13:20 -0400 +From: mark@mark.mielke.cc +To: Alan Stange +Cc: Donald Courtney , + pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +Message-ID: <20050825001320.GA18300@mark.mielke.cc> +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> <20050824173055.GA11788@mark.mielke.cc> + <430CC0AD.5040400@rentec.com> + <20050824193441.GA13772@mark.mielke.cc> + <430CE1F0.3080205@rentec.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <430CE1F0.3080205@rentec.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envyfinancial.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.215 required=5 tests=[AWL=0.037, NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/410 +X-Sequence-Number: 14157 + +On Wed, Aug 24, 2005 at 05:09:04PM -0400, Alan Stange wrote: +> The older 32bit RISC processors do have 64 bit registers, ALUs and +> datapaths, and they are marketed toward high end scientific computing, +> and you're claiming that such a processor is slower than one which has +> the addition of 64 bit pointers added to it? + +No. I'm claiming that you are talking about a hybrid 64/32 processor, +and that this isn't fair to declare that 64-bit arithmetic units don't +provide benefit for 64-bit math. :-) + +> As an example, an UltraSparc running a 32 bit kernel+application will +> have the same double precision floating point performance as one +> running a 64bit kernel+application (except for the additional FP +> registers in the 64bit API). For a function like daxpy, it's the exact +> same hardware running the exact same instructions! So why do you think +> the performance would be different? + +Double precision floating point isn't 64-bit integer arithmetic. I think +this is all a little besides the point. If you point is that the SPARC +was designed well - I agree with you. + +I won't agree that a SPARC with 64-bit registers should be considered +a 32-bit machine. The AMD 64-bit machines come in two forms as well - +the ones that allow you to use the 64-bit integer registers (not +floating point! those are already 80-bit!), and the ones that allow +you to address more memory. I wouldn't consider either to be a 32-bit +CPU, although they will allow 32-bit applications to run fine. + +> I believe the IBM Power processors also upped everything to double +> precision internally because of some details of the "multiply-add fused" +> instructions. It's been a few years since I taught H&P to CS +> undergrads, but I'm fairly sure the details are all the same for MIPS +> processors as well. + +Smart design, that obscures the difference - but doesn't make the +difference a myth. If it's already there, then it's already there, +and we can't talk as if it isn't. + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Wed Aug 24 21:31:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 13567D7A97 + for ; + Wed, 24 Aug 2005 21:17:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46913-02 + for ; + Thu, 25 Aug 2005 00:16:58 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 347AFD76D1 + for ; + Wed, 24 Aug 2005 21:16:57 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 599071529A; Wed, 24 Aug 2005 19:17:01 -0500 (CDT) +Date: Wed, 24 Aug 2005 19:17:01 -0500 +From: "Jim C. Nasby" +To: pgsql-performance@postgresql.org +Subject: RAID arrays (and vendors) +Message-ID: <20050825001701.GD56081@pervasive.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 required=5 tests=[AWL=0.009] +X-Spam-Level: +X-Archive-Number: 200508/411 +X-Sequence-Number: 14158 + +I'm looking for an external RAID array (with external controller); +either ~8 15kRPM SCSI drives or something with more SATA drives. This +will be used in a test environment and could get moved between machines, +so I'd like something with it's own RAID controller. Support for a broad +range of OSes is important. + +Can anyone recommend hardware as well as vendors? Feel free to reply +off-list. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Aug 24 22:35:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 23645D730C + for ; + Wed, 24 Aug 2005 21:30:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49604-02 + for ; + Thu, 25 Aug 2005 00:30:38 +0000 (GMT) +Received: from mail.envyfinancial.com (unknown [206.248.142.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E831D7300 + for ; + Wed, 24 Aug 2005 21:30:37 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envyfinancial.com (Postfix) with ESMTP id 1BCCF1B6AA + for ; + Wed, 24 Aug 2005 20:21:06 -0400 (EDT) +Received: from mail.envyfinancial.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 18249-04 for ; + Wed, 24 Aug 2005 20:21:05 -0400 (EDT) +Received: by mail.envyfinancial.com (Postfix, from userid 500) + id C58761B8F0; Wed, 24 Aug 2005 20:21:05 -0400 (EDT) +Date: Wed, 24 Aug 2005 20:21:05 -0400 +From: mark@mark.mielke.cc +To: pgsql-performance@postgresql.org +Subject: Re: Caching by Postgres +Message-ID: <20050825002105.GB18300@mark.mielke.cc> +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> <20050824173055.GA11788@mark.mielke.cc> + <430CC0AD.5040400@rentec.com> + <20050824193441.GA13772@mark.mielke.cc> + <20050824210909.GN8667@mathom.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050824210909.GN8667@mathom.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envyfinancial.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.214 required=5 tests=[AWL=0.036, NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/413 +X-Sequence-Number: 14160 + +On Wed, Aug 24, 2005 at 05:09:09PM -0400, Michael Stone wrote: +> On Wed, Aug 24, 2005 at 03:34:41PM -0400, mark@mark.mielke.cc wrote: +> >It isn't an urban myth that 64-bit math on a 64-bit processor is +> >faster, at least if done using registers. It definately is faster. +> >It may be an urban myth, though, that most applications perform +> >a sufficient amount of 64-bit arithmetic to warrant the upgrade. +> The mjor problem is that the definition of "64bit processor" is fuzzy. +> The major slowdown of "64bitness" is the necessity of carting around +> 64 bit pointers. It's not, however, necessary to do 64bit pointers to +> get 64bit registers & fast 64 bit ops. E.g., sgi has "n32" & "n64" abi's +> which can access exactly the same instruction set & registers, the +> difference between them is the size of pointers and whether a "long" is +> the same as a "long long". Any discussion of "64 bit processors" is +> doomed from the start because people tend to start making implementation +> assumptions on top of an already vague concept. Current & future +> discussions are tinged by the fact that amd64 *doubles* the number +> of registers in 64 bit mode, potentially providing a major speedup--but +> one that doesn't really have anything to do with being "64bit". +> Pretty much any discussion of 64 bit mode really needs to be a +> discussion of a particular abi on a particular processor; talking about +> "64 bit processors" abstractly is a waste of time. + +Agree. :-) + +As this very thread has shown! Hehe... + +There is no way the manufacturers would release two machines, side by +side that could easily show that the 64-bit version is slower for +regular application loads. They added these other things specifically +to mask this... :-) + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Thu Aug 25 04:08:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F8CBD7B5B + for ; + Thu, 25 Aug 2005 04:08:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63249-02 + for ; + Thu, 25 Aug 2005 07:08:28 +0000 (GMT) +Received: from thor.netera.se (thor.netera.se [85.112.172.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 33C35D7B09 + for ; + Thu, 25 Aug 2005 04:08:23 -0300 (ADT) +Received: from [192.168.2.240] (1-1-1-41a.o.sth.bostream.se [81.26.246.14]) + by thor.netera.se (Postfix) with ESMTP id 3BFD613AC04F + for ; + Thu, 25 Aug 2005 09:08:19 +0200 (CEST) +Message-ID: <430D6EED.10603@relevanttraffic.se> +Date: Thu, 25 Aug 2005 09:10:37 +0200 +From: Ulrich Wisser +Organization: Relevant Traffic AB +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Need for speed 2 +References: <6.2.3.4.0.20050817140116.05d317b0@pop.earthlink.net> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] +X-Spam-Level: +X-Archive-Number: 200508/414 +X-Sequence-Number: 14161 + +Hello, + +I realize I need to be much more specific. Here is a more detailed +description of my hardware and system design. + + +Pentium 4 2.4GHz +Memory 4x DIMM DDR 1GB PC3200 400MHZ CAS3, KVR +Motherboard chipset 'I865G', two IDE channels on board +2x SEAGATE BARRACUDA 7200.7 80GB 7200RPM ATA/100 +(software raid 1, system, swap, pg_xlog) +ADAPTEC SCSI RAID 2100S ULTRA160 32MB 1-CHANNEL +2x SEAGATE CHEETAH 15K.3 73GB ULTRA320 68-PIN WIDE +(raid 1, /var/lib/pgsql) + +Database size on disc is 22GB. (without pg_xlog) + +Please find my postgresql.conf below. + +Putting pg_xlog on the IDE drives gave about 10% performance +improvement. Would faster disks give more performance? + +What my application does: + +Every five minutes a new logfile will be imported. Depending on the +source of the request it will be imported in one of three "raw click" +tables. (data from two months back, to be able to verify customer complains) +For reporting I have a set of tables. These contain data from the last +two years. My app deletes all entries from today and reinserts updated +data calculated from the raw data tables. + +The queries contain no joins only aggregates. I have several indexes to +speed different kinds of queries. + +My problems occur when one users does a report that contains to much old +data. In that case all cache mechanisms will fail and disc io is the +limiting factor. + +If one query contains so much data, that a full table scan is needed, I +do not care if it takes two minutes to answer. But all other queries +with less data (at the same time) still have to be fast. + +I can not stop users doing that kind of reporting. :( + +I need more speed in orders of magnitude. Will more disks / more memory +do that trick? + +Money is of course a limiting factor but it doesn't have to be real cheap. + +Ulrich + + + + + +# ----------------------------- +# PostgreSQL configuration file +# ----------------------------- +#--------------------------------------------------------------------------- +# CONNECTIONS AND AUTHENTICATION +#--------------------------------------------------------------------------- + +# - Connection Settings - + +tcpip_socket = true +max_connections = 100 + # note: increasing max_connections costs about 500 bytes of shared + # memory per connection slot, in addition to costs from +shared_buffers + # and max_locks_per_transaction. +#superuser_reserved_connections = 2 +#port = 5432 +#unix_socket_directory = '' +#unix_socket_group = '' +#unix_socket_permissions = 0777 # octal +#virtual_host = '' # what interface to listen on; defaults +to any +#rendezvous_name = '' # defaults to the computer name + +# - Security & Authentication - + +#authentication_timeout = 60 # 1-600, in seconds +#ssl = false +#password_encryption = true +#krb_server_keyfile = '' +#db_user_namespace = false + + +#--------------------------------------------------------------------------- +# RESOURCE USAGE (except WAL) +#--------------------------------------------------------------------------- + +# - Memory - + +shared_buffers = 20000 # min 16, at least max_connections*2, +8KB each +sort_mem = 4096 # min 64, size in KB +vacuum_mem = 8192 # min 1024, size in KB + +# - Free Space Map - + +max_fsm_pages = 200000 # min max_fsm_relations*16, 6 bytes each +max_fsm_relations = 10000 # min 100, ~50 bytes each + +# - Kernel Resource Usage - + +#max_files_per_process = 1000 # min 25 +#preload_libraries = '' + + +#--------------------------------------------------------------------------- +# WRITE AHEAD LOG +#--------------------------------------------------------------------------- + +# - Settings - + +fsync = false # turns forced synchronization on or off +#wal_sync_method = fsync # the default varies across platforms: + # fsync, fdatasync, open_sync, or +open_datasync +wal_buffers = 128 # min 4, 8KB each + +# - Checkpoints - + +checkpoint_segments = 16 # in logfile segments, min 1, 16MB each +#checkpoint_timeout = 300 # 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 + + +#--------------------------------------------------------------------------- +# QUERY TUNING +#--------------------------------------------------------------------------- + +# - Planner Method Enabling - + +#enable_hashagg = true +#enable_hashjoin = true +#enable_indexscan = true +#enable_mergejoin = true +#enable_nestloop = true +#enable_seqscan = true +#enable_sort = true +#enable_tidscan = true + +# - Planner Cost Constants - + +#effective_cache_size = 1000 # typically 8KB each +#random_page_cost = 4 # units are one sequential page fetch cost +#cpu_tuple_cost = 0.01 # (same) +#cpu_index_tuple_cost = 0.001 # (same) +#cpu_operator_cost = 0.0025 # (same) + +# - Genetic Query Optimizer - + +#geqo = true +#geqo_threshold = 11 +#geqo_effort = 1 +#geqo_generations = 0 +#geqo_pool_size = 0 # default based on tables in statement, + # range 128-1024 +#geqo_selection_bias = 2.0 # range 1.5-2.0 + +# - Other Planner Options - + +#default_statistics_target = 10 # range 1-1000 +#from_collapse_limit = 8 +#join_collapse_limit = 8 # 1 disables collapsing of explicit JOINs + + +#--------------------------------------------------------------------------- +# ERROR REPORTING AND LOGGING +#--------------------------------------------------------------------------- + +# - Syslog - + +syslog = 2 # range 0-2; 0=stdout; 1=both; 2=syslog +syslog_facility = 'LOCAL0' +syslog_ident = 'postgres' + +# - When to Log - + +client_min_messages = info # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # log, info, notice, warning, error + +log_min_messages = info # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # info, notice, warning, error, log, +fatal, + # panic + +log_error_verbosity = verbose # terse, default, or verbose messages + +log_min_error_statement = info # Values in order of increasing severity: + # debug5, debug4, debug3, debug2, +debug1, + # info, notice, warning, error, +panic(off) + +log_min_duration_statement = 1000 # Log all statements whose + # execution time exceeds the value, in + # milliseconds. Zero prints all queries. + # Minus-one disables. + +silent_mode = false # DO NOT USE without Syslog! + +# - What to Log - + +#debug_print_parse = false +#debug_print_rewritten = false +#debug_print_plan = false +#debug_pretty_print = false +log_connections = true +#log_duration = false +#log_pid = false +#log_statement = false +#log_timestamp = false +#log_hostname = false +#log_source_port = false + + +#--------------------------------------------------------------------------- +# RUNTIME STATISTICS +#--------------------------------------------------------------------------- + +# - Statistics Monitoring - + +#log_parser_stats = false +#log_planner_stats = false +#log_executor_stats = false +#log_statement_stats = false + +# - Query/Index Statistics Collector - + +#stats_start_collector = true +#stats_command_string = false +#stats_block_level = false +#stats_row_level = false +#stats_reset_on_server_start = true + + +#--------------------------------------------------------------------------- +# CLIENT CONNECTION DEFAULTS +#--------------------------------------------------------------------------- + +# - Statement Behavior - + +#search_path = '$user,public' # schema names +#check_function_bodies = true +#default_transaction_isolation = 'read committed' +#default_transaction_read_only = false +#statement_timeout = 0 # 0 is disabled, in milliseconds + +# - Locale and Formatting - + +#datestyle = 'iso, mdy' +#timezone = unknown # actually, defaults to TZ environment +setting +#australian_timezones = false +#extra_float_digits = 0 # min -15, max 2 +#client_encoding = sql_ascii # actually, defaults to database encoding + +# These settings are initialized by initdb -- they may be changed +lc_messages = 'en_US' # locale for system error message strings +lc_monetary = 'en_US' # locale for monetary formatting +lc_numeric = 'en_US' # locale for number formatting +lc_time = 'en_US' # locale for time formatting + +# - Other Defaults - + +#explain_pretty_print = true +#dynamic_library_path = '$libdir' +#max_expr_depth = 10000 # min 10 + + +#--------------------------------------------------------------------------- +# LOCK MANAGEMENT +#--------------------------------------------------------------------------- + +#deadlock_timeout = 1000 # in milliseconds +#max_locks_per_transaction = 64 # min 10, ~260*max_connections bytes each + + +#--------------------------------------------------------------------------- +# VERSION/PLATFORM COMPATIBILITY +#--------------------------------------------------------------------------- + +# - Previous Postgres Versions - + +#add_missing_from = true +#regex_flavor = advanced # advanced, extended, or basic +#sql_inheritance = true + +# - Other Platforms & Clients - + +#transform_null_equals = false + + + +From pgsql-performance-owner@postgresql.org Thu Aug 25 04:18:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5530BD7A57 + for ; + Thu, 25 Aug 2005 04:18:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62383-06 + for ; + Thu, 25 Aug 2005 07:18:29 +0000 (GMT) +Received: from smtp1.asco.de (smtp1.asco.de [217.13.70.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 57407D78AD + for ; + Thu, 25 Aug 2005 04:18:24 -0300 (ADT) +Received: from [192.168.1.72] (pitr.asco.de [192.168.1.72]) + (envelope-sender: ) + (authenticated j_schicke CRAM-MD5 bits=0) + by smtp1.asco.de (8.13.4/8.13.4/Debian-3) with ESMTP id j7P7IMvM032388 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Thu, 25 Aug 2005 09:18:22 +0200 +Date: Thu, 25 Aug 2005 09:18:22 +0200 +From: Jens-Wolfhard Schicke +Reply-To: Jens-Wolfhard Schicke +To: Chris Hoover +Cc: pgsql-performance@postgresql.org +Subject: Re: Some ideas for comment +Message-ID: <489BA31DB80A2298E8BC1C52@[192.168.1.72]> +In-Reply-To: <1d219a6f05082413265e872134@mail.gmail.com> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD1AB@Herge.rcsinc.local> + <1d219a6f05082413265e872134@mail.gmail.com> +X-Mailer: Mulberry/3.1.6 (Linux/x86) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/415 +X-Sequence-Number: 14162 + +--On Mittwoch, August 24, 2005 16:26:40 -0400 Chris Hoover=20 + wrote: + +> On 8/24/05, Merlin Moncure wrote: +>> Linux does a pretty good job of deciding what to cache. I don't think +>> this will help much. You can always look at partial indexes too. +>> +> Yes, but won't this help create the need to store less? If I have +> 1,000.000 rows in a table, but only 4,000 are active, if I move those +> 4 to another table and link the tables via a view, should that not +> help keep the 9,996,000 rows out of the kernel cache (the majority of +> the time at least)? +The kernel caches per page, not per file. It is likely linux only caches=20 +those pages which contain active rows, as long as no statement does a=20 +seq-scan on that table. + +To optimize the thing, you could consider to cluster by some index which=20 +sorts by the "activity" of the rows first. That way pages with active rows=20 +are likely to contain more than only 1 active row and so the cache is=20 +utilized better. + +Cluster is rather slow however and tables need to be reclustered from time=20 +to time. + + +Mit freundlichem Gru=DF +Jens Schicke +--=20 +Jens Schicke j.schicke@asco.de +asco GmbH http://www.asco.de +Mittelweg 7 Tel 0531/3906-127 +38106 Braunschweig Fax 0531/3906-400 + +From pgsql-performance-owner@postgresql.org Sat Aug 27 01:58:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AD00AD7F18 + for ; + Thu, 25 Aug 2005 09:28:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55518-10 + for ; + Thu, 25 Aug 2005 12:28:10 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A817D7F16 + for ; + Thu, 25 Aug 2005 09:28:08 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id E839130B42; Thu, 25 Aug 2005 14:40:41 +0200 (MET DST) +From: Thomas Ganss + +X-Newsgroups: pgsql.performance +Subject: Re: Caching by Postgres +Date: Thu, 25 Aug 2005 14:23:49 +0100 +Organization: T-Online +Lines: 18 +Message-ID: +References: <20050823171045.12112.qmail@web51309.mail.yahoo.com> + <20050823124323.710a9dd3.frank@wiles.org> + <430B6DE3.6040109@sun.com> + <430C7448.7030103@sun.com> <20050824173055.GA11788@mark.mielke.cc> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet-abuse@t-online.de +X-ID: Eqk63QZT8eXFIO1vXj4+shE4YiLPu+9v2BbtCVQlwLs4QKHH+vvogW +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: de-DE, de, en-us, en +In-Reply-To: <20050824173055.GA11788@mark.mielke.cc> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.174 required=5 tests=[FORGED_YAHOO_RCVD=2.174] +X-Spam-Level: ** +X-Archive-Number: 200508/468 +X-Sequence-Number: 14215 + + +> The first, to always remember - is that the move from 64-bits to +> 32-bits doesn't come for free. In a real 64-bit system with a +> 64-bit operating system, and 64-bit applications, pointers are +> now double their 32-bit size. This means more bytes to copy around +> memory, and in an extreme case, has the potential to approach +> halfing both the memory latency to access many such pointers from +> RAM, and half the effective amount of RAM. In real world cases, +> not everything is a pointer, so this sort of performance degradation +> is doubtful - but it is something to keep in mind. +> +In addition to the above it lessens the effects of the CPU cache, so be +sure to take the larger cached versions if you have structures needing +to fit into the cache... + +my 0.02 EUR + +thomas + +From pgsql-performance-owner@postgresql.org Thu Aug 25 10:46:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 13A39D8034 + for ; + Thu, 25 Aug 2005 10:46:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81557-05 + for ; + Thu, 25 Aug 2005 13:46:33 +0000 (GMT) +Received: from frank.wiles.org (frank.wiles.org [24.124.39.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E9EDD6F4D + for ; + Thu, 25 Aug 2005 10:46:29 -0300 (ADT) +Received: from kungfu (frank.wiles.org [127.0.0.1]) + by frank.wiles.org (8.13.1/8.13.1) with SMTP id j7PDkVHA018413; + Thu, 25 Aug 2005 08:46:32 -0500 +Date: Thu, 25 Aug 2005 08:47:11 -0500 +From: Frank Wiles +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org +Subject: Re: Need for speed 2 +Message-Id: <20050825084711.2b08f485.frank@wiles.org> +In-Reply-To: <430D6EED.10603@relevanttraffic.se> +References: <6.2.3.4.0.20050817140116.05d317b0@pop.earthlink.net> + + <430D6EED.10603@relevanttraffic.se> +X-Mailer: Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-redhat-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.02 required=5 tests=[AWL=0.020] +X-Spam-Level: +X-Archive-Number: 200508/416 +X-Sequence-Number: 14163 + +On Thu, 25 Aug 2005 09:10:37 +0200 +Ulrich Wisser wrote: + +> Pentium 4 2.4GHz +> Memory 4x DIMM DDR 1GB PC3200 400MHZ CAS3, KVR +> Motherboard chipset 'I865G', two IDE channels on board +> 2x SEAGATE BARRACUDA 7200.7 80GB 7200RPM ATA/100 +> (software raid 1, system, swap, pg_xlog) +> ADAPTEC SCSI RAID 2100S ULTRA160 32MB 1-CHANNEL +> 2x SEAGATE CHEETAH 15K.3 73GB ULTRA320 68-PIN WIDE +> (raid 1, /var/lib/pgsql) +> +> Database size on disc is 22GB. (without pg_xlog) +> +> Please find my postgresql.conf below. +> +> Putting pg_xlog on the IDE drives gave about 10% performance +> improvement. Would faster disks give more performance? + + Faster as in RPM on your pg_xlog partition probably won't make + much of a difference. However, if you can get a drive with better + overall write performance then it would be a benefit. + + Another thing to consider on this setup is whether or not you're + hitting swap often and/or logging to that same IDE RAID set. For + optimal insertion benefit you want the heads of your disks to + essentially be only used for pg_xlog. If you're having to jump + around the disk in the following manner: + + write to pg_xlog + read from swap + write syslog data + write to pg_xlog + ... + ... + + You probably aren't getting anywhere near the benefit you could. One + thing you could easily try is to break your IDE RAID set and put + OS/swap on one disk and pg_xlog on the other. + +> If one query contains so much data, that a full table scan is needed, +> I do not care if it takes two minutes to answer. But all other +> queries with less data (at the same time) still have to be fast. +> +> I can not stop users doing that kind of reporting. :( +> +> I need more speed in orders of magnitude. Will more disks / more +> memory do that trick? + + More disk and more memory always helps out. Since you say these + queries are mostly on not-often-used data I would lean toward more + disks in your SCSI RAID-1 setup than maxing out available RAM based + on the size of your database. + + --------------------------------- + Frank Wiles + http://www.wiles.org + --------------------------------- + + +From pgsql-performance-owner@postgresql.org Thu Aug 25 16:28:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 889FDD6E77 + for ; + Thu, 25 Aug 2005 16:28:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74262-02 + for ; + Thu, 25 Aug 2005 19:28:04 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id F0A02D6E67 + for ; + Thu, 25 Aug 2005 16:28:03 -0300 (ADT) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Thu, 25 Aug 2005 12:31:54 -0700 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Thu, 25 Aug 2005 12:31:48 -0700 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005082512314710024 + for ; + Thu, 25 Aug 2005 12:31:47 -0700 +X-ASG-Debug-ID: 1124998078-3388-3-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail1 (mail1.hq.corp [192.168.160.5]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id 1BAB120206D1 + for ; + Thu, 25 Aug 2005 12:27:58 -0700 (PDT) +Received: from [10.0.0.250] ([63.193.127.22]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.1830); Thu, 25 Aug 2005 12:31:44 -0700 +X-ASG-Orig-Subj: Re: [PERFORM] What *_mem to increase when running CLUSTER +Subject: Re: What *_mem to increase when running CLUSTER +From: Steve Poe +To: andrew@pillette.com +Cc: pgsql-performance@postgresql.org +In-Reply-To: <430E1AF6.9030803@pillette.com> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD1D2@Herge.rcsinc.local> + <430E1AF6.9030803@pillette.com> +Content-Type: text/plain +Date: Thu, 25 Aug 2005 13:56:11 +0000 +Message-Id: <1124978171.11102.12.camel@amd64-laptop-spoe> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 25 Aug 2005 19:31:44.0159 (UTC) + FILETIME=[A02AD2F0:01C5A9AB] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: 2.00 +X-Barracuda-Spam-Status: No, SCORE=2.00 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_80 +X-Barracuda-Spam-Report: Code version 3.02, rules version 3.0.3477 + Rule breakdown below pts rule name description + ---- ---------------------- + -------------------------------------------------- + 2.00 BAYES_80 BODY: Bayesian spam probability is 80 to 95% + [score: 0.9434] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/421 +X-Sequence-Number: 14168 + +Andrew, + +On Thu, 2005-08-25 at 12:24 -0700, Andrew Lazarus wrote: +> Should I temporarily increase sort_mem, vacuum_mem, neither, or both +> when doing a CLUSTER on a large (100 million row) table where as many as +> half of the tuples are deadwood from UPDATEs or DELETEs? I have large +> batch (10 million row) inserts, updates, and deletes so I'm not sure +> frequent vacuuming would help. + +You may need to experiment with both. What version of Postgres? What is +the size of your database? How many concurrent users? If you're seeing +half of the tuples are dead, I look at checking your max_fsm_pages and +max_fsm_relations after a full vacuum analyze before doing too much with +sort mem. + +Your mileage may vary. + +Best of luck. + +Steve Poe + + +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Thu Aug 25 12:16:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DECED6E6D + for ; + Thu, 25 Aug 2005 12:16:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07269-04 + for ; + Thu, 25 Aug 2005 15:16:43 +0000 (GMT) +Received: from smtpauth09.mail.atl.earthlink.net + (smtpauth09.mail.atl.earthlink.net [209.86.89.69]) + by svr1.postgresql.org (Postfix) with ESMTP id 99EE5D8314 + for ; + Thu, 25 Aug 2005 12:16:42 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=nQG0LCn/5XfBlwGCQzJJzfwrtVZ/g6NZ3Kr/a8Eh7v9YGRHY0ZQgB1TLw/I+mRnw; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth09.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E8JT6-00057l-5P; Thu, 25 Aug 2005 11:16:40 -0400 +Message-Id: <6.2.3.4.0.20050825094630.05e6b160@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Thu, 25 Aug 2005 11:16:33 -0400 +To: Ulrich Wisser , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: Need for speed 2 +In-Reply-To: <430D6EED.10603@relevanttraffic.se> +References: <6.2.3.4.0.20050817140116.05d317b0@pop.earthlink.net> + + <430D6EED.10603@relevanttraffic.se> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcbc02d0e36cde4f55982224a72df9e4b3350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.431 required=5 tests=[AWL=0.057, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/417 +X-Sequence-Number: 14164 + +At 03:10 AM 8/25/2005, Ulrich Wisser wrote: + +>I realize I need to be much more specific. Here is a more detailed +>description of my hardware and system design. +> +> +>Pentium 4 2.4GHz +>Memory 4x DIMM DDR 1GB PC3200 400MHZ CAS3, KVR +>Motherboard chipset 'I865G', two IDE channels on board + +First suggestion: Get better server HW. AMD Opteron based dual +processor board is the current best in terms of price/performance +ratio, _particularly_ for DB applications like the one you have +described. Such mainboards cost ~$400-$500. RAM will cost about +$75-$150/GB. Opteron 2xx are ~$200-$700 apiece. So a 2P AMD system +can be had for as little as ~$850 + the cost of the RAM you need. In +the worst case where you need 24GB of RAM (~$3600), the total comes +in at ~$4450. As you can see from the numbers, buying only what RAM +you actually need can save you a great deal on money. + +Given what little you said about how much of your DB is frequently +accessed, I'd suggest buying a server based around the 2P 16 DIMM +slot IWill DK88 mainboard (Tyan has announced a 16 DIMM slot +mainboard, but I do not think it is actually being sold yet.). Then +fill it with the minimum amount of RAM that will allow the "working +set" of the DB to be cached in RAM. In the worst case where DB +access is essentially uniform and essentially random, you will need +24GB of RAM to hold the 22GB DB + OS + etc. That worst case is +_rare_. Usually DB's have a working set that is smaller than the +entire DB. You want to keep that working set in RAM. If you can't +identify the working set, buy enough RAM to hold the entire DB. + +In particular, you want to make sure that any frequently accessed +read only tables or indexes are kept in RAM. The "read only" part is +very important. Tables (and their indexes) that are frequently +written to _have_ to access HD. Therefore you get much less out of +having them in RAM. Read only tables and their indexes can be loaded +into tmpfs at boot time thereby keeping out of the way of the file +system buffer cache. tmpfs does not save data if the host goes down +so it is very important that you ONLY use this trick with read only +tables. The other half of the trick is to make sure that the file +system buffer cache does _not_ cache whatever you have loaded into tmpfs. + + +>2x SEAGATE BARRACUDA 7200.7 80GB 7200RPM ATA/100 +>(software raid 1, system, swap, pg_xlog) +>ADAPTEC SCSI RAID 2100S ULTRA160 32MB 1-CHANNEL +>2x SEAGATE CHEETAH 15K.3 73GB ULTRA320 68-PIN WIDE +>(raid 1, /var/lib/pgsql) + +Second suggestion: you need a MUCH better IO subsystem. In fact, +given that you have described this system as being primarily OLTP +like, this is more important that the above server HW. Best would be +to upgrade everything, but if you are strapped for cash, upgrade the +IO subsystem first. + +You need many more spindles and a decent RAID card or cards. You +want 15Krpm (best) or 10Krpm HDs. As long as all of the HD's are at +least 10Krpm, more spindles is more important than faster +spindles. If it's a choice between more 10Krpm discs or fewer 15Krpm +discs, buy the 10Krpm discs. Get the spindle count as high as you +RAID cards can handle. + +Whatever RAID cards you get should have as much battery backed write +buffer as possible. In the commodity market, presently the highest +performance RAID cards I know of, and the ones that support the +largest battery backed write buffer, are made by Areca. + + +>Database size on disc is 22GB. (without pg_xlog) + +Find out what the working set, ie the most frequently accessed +portion, of this 22GB is and you will know how much RAM is worth +having. 4GB is definitely too little! + + +>Please find my postgresql.conf below. + +Third suggestion: make sure you are running a 2.6 based kernel and +at least PG 8.0.3. Helping beta test PG 8.1 might be an option for +you as well. + + +>Putting pg_xlog on the IDE drives gave about 10% performance +>improvement. Would faster disks give more performance? +> +>What my application does: +> +>Every five minutes a new logfile will be imported. Depending on the +>source of the request it will be imported in one of three "raw click" +>tables. (data from two months back, to be able to verify customer +>complains) For reporting I have a set of tables. These contain data +>from the last two years. My app deletes all entries from today and +>reinserts updated data calculated from the raw data tables. + +The raw data tables seem to be read only? If so, you should buy +enough RAM to load them into tmpfs at boot time and have them be +completely RAM resident in addition to having enough RAM for the OS +to cache an appropriate amount of the rest of the DB. + + +>The queries contain no joins only aggregates. I have several indexes +>to speed different kinds of queries. +> +>My problems occur when one users does a report that contains too +>much old data. In that case all cache mechanisms will fail and disc +>io is the limiting factor. +> +>If one query contains so much data, that a full table scan is +>needed, I do not care if it takes two minutes to answer. But all +>other queries with less data (at the same time) still have to be fast. + +HDs can only do one thing at once. If they are in the middle of a +full table scan, everything else that requires HD access is going to +wait until it is done. + +At some point, looking at your DB schema and queries will be worth it +for optimization purposes. Right now, you HW is so underpowered +compared to the demands you are placing on it that there's little +point to SW tuning. + +>I can not stop users doing that kind of reporting. :( +> +>I need more speed in orders of magnitude. Will more disks / more +>memory do that trick? + +If you do the right things with them ;) + +>Money is of course a limiting factor but it doesn't have to be real cheap. +> +>Ulrich +> +> +> +> +> +># ----------------------------- +># PostgreSQL configuration file +># ----------------------------- +>#--------------------------------------------------------------------------- +># CONNECTIONS AND AUTHENTICATION +>#--------------------------------------------------------------------------- +> +># - Connection Settings - +> +>tcpip_socket = true +>max_connections = 100 +> # note: increasing max_connections costs about 500 bytes of shared +> # memory per connection slot, in addition to costs from +> shared_buffers +> # and max_locks_per_transaction. +>#superuser_reserved_connections = 2 +>#port = 5432 +>#unix_socket_directory = '' +>#unix_socket_group = '' +>#unix_socket_permissions = 0777 # octal +>#virtual_host = '' # what interface to listen on; defaults to any +>#rendezvous_name = '' # defaults to the computer name +> +># - Security & Authentication - +> +>#authentication_timeout = 60 # 1-600, in seconds +>#ssl = false +>#password_encryption = true +>#krb_server_keyfile = '' +>#db_user_namespace = false +> +> +>#--------------------------------------------------------------------------- +># RESOURCE USAGE (except WAL) +>#--------------------------------------------------------------------------- +> +># - Memory - +> +>shared_buffers = 20000 # min 16, at least max_connections*2, 8KB each +>sort_mem = 4096 # min 64, size in KB + +4MB seems small. Find out how much memory you usually need for a +sort, and how many sorts you are usually doing at once to set this to +a sane size. + + +>vacuum_mem = 8192 # min 1024, size in KB +> +># - Free Space Map - +> +>max_fsm_pages = 200000 # min max_fsm_relations*16, 6 bytes each +>max_fsm_relations = 10000 # min 100, ~50 bytes each +> +># - Kernel Resource Usage - +> +>#max_files_per_process = 1000 # min 25 +>#preload_libraries = '' +> +> +>#--------------------------------------------------------------------------- +># WRITE AHEAD LOG +>#--------------------------------------------------------------------------- +> +># - Settings - +> +>fsync = false # turns forced synchronization on or off +>#wal_sync_method = fsync # the default varies across platforms: +> # fsync, fdatasync, open_sync, or + +I hope you have a battery backed write buffer! + +>open_datasync +>wal_buffers = 128 # min 4, 8KB each + +There might be a better value for you to use. + +I'll hold off on looking at the rest of this... + +># - Checkpoints - +> +>checkpoint_segments = 16 # in logfile segments, min 1, 16MB each +>#checkpoint_timeout = 300 # 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 +> +> +>#--------------------------------------------------------------------------- +># QUERY TUNING +>#--------------------------------------------------------------------------- +> +># - Planner Method Enabling - +> +>#enable_hashagg = true +>#enable_hashjoin = true +>#enable_indexscan = true +>#enable_mergejoin = true +>#enable_nestloop = true +>#enable_seqscan = true +>#enable_sort = true +>#enable_tidscan = true +> +># - Planner Cost Constants - +> +>#effective_cache_size = 1000 # typically 8KB each +>#random_page_cost = 4 # units are one sequential page fetch cost +>#cpu_tuple_cost = 0.01 # (same) +>#cpu_index_tuple_cost = 0.001 # (same) +>#cpu_operator_cost = 0.0025 # (same) +> +># - Genetic Query Optimizer - +> +>#geqo = true +>#geqo_threshold = 11 +>#geqo_effort = 1 +>#geqo_generations = 0 +>#geqo_pool_size = 0 # default based on tables in statement, +> # range 128-1024 +>#geqo_selection_bias = 2.0 # range 1.5-2.0 +> +># - Other Planner Options - +> +>#default_statistics_target = 10 # range 1-1000 +>#from_collapse_limit = 8 +>#join_collapse_limit = 8 # 1 disables collapsing of explicit JOINs +> +> +>#--------------------------------------------------------------------------- +># ERROR REPORTING AND LOGGING +>#--------------------------------------------------------------------------- +> +># - Syslog - +> +>syslog = 2 # range 0-2; 0=stdout; 1=both; 2=syslog +>syslog_facility = 'LOCAL0' +>syslog_ident = 'postgres' +> +># - When to Log - +> +>client_min_messages = info # Values, in order of decreasing detail: +> # debug5, debug4, debug3, debug2, debug1, +> # log, info, notice, warning, error +> +>log_min_messages = info # Values, in order of decreasing detail: +> # debug5, debug4, debug3, debug2, debug1, +> # info, notice, warning, error, log, +>fatal, +> # panic +> +>log_error_verbosity = verbose # terse, default, or verbose messages +> +>log_min_error_statement = info # Values in order of increasing severity: +> # debug5, debug4, debug3, debug2, +>debug1, +> # info, notice, warning, error, +>panic(off) +> +>log_min_duration_statement = 1000 # Log all statements whose +> # execution time exceeds the value, in +> # milliseconds. Zero prints all queries. +> # Minus-one disables. +> +>silent_mode = false # DO NOT USE without Syslog! +> +># - What to Log - +> +>#debug_print_parse = false +>#debug_print_rewritten = false +>#debug_print_plan = false +>#debug_pretty_print = false +>log_connections = true +>#log_duration = false +>#log_pid = false +>#log_statement = false +>#log_timestamp = false +>#log_hostname = false +>#log_source_port = false +> +> +>#--------------------------------------------------------------------------- +># RUNTIME STATISTICS +>#--------------------------------------------------------------------------- +> +># - Statistics Monitoring - +> +>#log_parser_stats = false +>#log_planner_stats = false +>#log_executor_stats = false +>#log_statement_stats = false +> +># - Query/Index Statistics Collector - +> +>#stats_start_collector = true +>#stats_command_string = false +>#stats_block_level = false +>#stats_row_level = false +>#stats_reset_on_server_start = true +> +> +>#--------------------------------------------------------------------------- +># CLIENT CONNECTION DEFAULTS +>#--------------------------------------------------------------------------- +> +># - Statement Behavior - +> +>#search_path = '$user,public' # schema names +>#check_function_bodies = true +>#default_transaction_isolation = 'read committed' +>#default_transaction_read_only = false +>#statement_timeout = 0 # 0 is disabled, in milliseconds +> +># - Locale and Formatting - +> +>#datestyle = 'iso, mdy' +>#timezone = unknown # actually, defaults to TZ environment +>setting +>#australian_timezones = false +>#extra_float_digits = 0 # min -15, max 2 +>#client_encoding = sql_ascii # actually, defaults to database encoding +> +># These settings are initialized by initdb -- they may be changed +>lc_messages = 'en_US' # locale for system error message strings +>lc_monetary = 'en_US' # locale for monetary formatting +>lc_numeric = 'en_US' # locale for number formatting +>lc_time = 'en_US' # locale for time formatting +> +># - Other Defaults - +> +>#explain_pretty_print = true +>#dynamic_library_path = '$libdir' +>#max_expr_depth = 10000 # min 10 +> +> +>#--------------------------------------------------------------------------- +># LOCK MANAGEMENT +>#--------------------------------------------------------------------------- +> +>#deadlock_timeout = 1000 # in milliseconds +>#max_locks_per_transaction = 64 # min 10, ~260*max_connections bytes each +> +> +>#--------------------------------------------------------------------------- +># VERSION/PLATFORM COMPATIBILITY +>#--------------------------------------------------------------------------- +> +># - Previous Postgres Versions - +> +>#add_missing_from = true +>#regex_flavor = advanced # advanced, extended, or basic +>#sql_inheritance = true +> +># - Other Platforms & Clients - +> +>#transform_null_equals = false +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 2: Don't 'kill -9' the postmaster + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 25 14:30:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AA64D6E67 + for ; + Thu, 25 Aug 2005 14:30:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46485-02 + for ; + Thu, 25 Aug 2005 17:30:49 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 8913AD6DF8 + for ; + Thu, 25 Aug 2005 14:30:48 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Need for speed 2 +Date: Thu, 25 Aug 2005 13:30:48 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD1D2@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Need for speed 2 +Thread-Index: AcWpRE73bCrrIw0sQFWp+cqC7CzJygAVHOOw +From: "Merlin Moncure" +To: "Ulrich Wisser" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/418 +X-Sequence-Number: 14165 + +> Putting pg_xlog on the IDE drives gave about 10% performance +> improvement. Would faster disks give more performance? +>=20 +> What my application does: +>=20 +> Every five minutes a new logfile will be imported. Depending on the +> source of the request it will be imported in one of three "raw click" +> tables. (data from two months back, to be able to verify customer +> complains) +> For reporting I have a set of tables. These contain data from the last +> two years. My app deletes all entries from today and reinserts updated +> data calculated from the raw data tables. +>=20 +> The queries contain no joins only aggregates. I have several indexes +to +> speed different kinds of queries. +>=20 +> My problems occur when one users does a report that contains to much +old +> data. In that case all cache mechanisms will fail and disc io is the +> limiting factor. + +It seems like you are pushing limit of what server can handle. This +means: 1. expensive server upgrade. or=20 +2. make software more efficient. + +Since you sound I/O bound, you can tackle 1. by a. adding more memory or +b. increasing i/o throughput. =20 + +Unfortunately, you already have a pretty decent server (for x86) so 1. +means 64 bit platform and 2. means more expensive hard drives. The +archives is full of information about this... + +Is your data well normalized? You can do tricks like: +if table has fields a,b,c,d,e,f with a is primary key, and d,e,f not +frequently queried or missing, move d,e,f to seprate table. + +well normalized structures are always more cache efficient. Do you have +lots of repeating and/or empty data values in your tables? + +Make your indexes and data as small as possible to reduce pressure on +the cache, here are just a few tricks: +1. use int2/int4 instead of numeric +2. know when to use char and varchar=20 +3. use functional indexes to reduce index expression complexity. This +can give extreme benefits if you can, for example, reduce double field +index to Boolean. + +Merlin + +From pgsql-performance-owner@postgresql.org Thu Aug 25 16:00:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B15CD768F + for ; + Thu, 25 Aug 2005 16:00:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67926-03 + for ; + Thu, 25 Aug 2005 19:00:23 +0000 (GMT) +Received: from tbmail.tradebot.com + (Tradebot-Systems-1096753.cust-rtr.swbell.net [68.90.170.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 48D44D768E + for ; + Thu, 25 Aug 2005 16:00:22 -0300 (ADT) +Received: from 192.168.200.29 ([192.168.200.29]) by tbmail.tradebot.com + ([192.168.1.50]) with Microsoft Exchange Server HTTP-DAV ; + Thu, 25 Aug 2005 19:00:22 +0000 +Received: from krb06 by TBMAIL; 25 Aug 2005 14:00:22 -0500 +Subject: Re: Need for speed 2 +From: Kelly Burkhart +To: Ron +Cc: pgsql-performance@postgresql.org +In-Reply-To: <6.2.3.4.0.20050825094630.05e6b160@pop.earthlink.net> +References: <6.2.3.4.0.20050817140116.05d317b0@pop.earthlink.net> + + <430D6EED.10603@relevanttraffic.se> + <6.2.3.4.0.20050825094630.05e6b160@pop.earthlink.net> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Thu, 25 Aug 2005 14:00:22 -0500 +Message-Id: <1124996422.6969.47.camel@krb06.tradebot.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/419 +X-Sequence-Number: 14166 + +On Thu, 2005-08-25 at 11:16 -0400, Ron wrote: +> ># - Settings - +> > +> >fsync = false # turns forced synchronization on or off +> >#wal_sync_method = fsync # the default varies across platforms: +> > # fsync, fdatasync, open_sync, or +> +> I hope you have a battery backed write buffer! + +Battery backed write buffer will do nothing here, because the OS is +taking it's sweet time flushing to the controller's battery backed write +buffer! + +Isn't the reason for batter backed controller cache to make fsync()s +fast? + +-K + +From pgsql-performance-owner@postgresql.org Thu Aug 25 16:13:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B310CD710A + for ; + Thu, 25 Aug 2005 16:13:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71816-03 + for ; + Thu, 25 Aug 2005 19:13:17 +0000 (GMT) +Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net + [67.119.5.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C304D7142 + for ; + Thu, 25 Aug 2005 16:13:15 -0300 (ADT) +Received: from [192.168.1.213] (dhcp213.pillette.com [192.168.1.213] (may be + forged)) by pillette.com (8.11.6/8.11.6) with ESMTP id j7PJDFu21089 + for ; Thu, 25 Aug 2005 12:13:15 -0700 +Message-ID: <430E1AF6.9030803@pillette.com> +Date: Thu, 25 Aug 2005 12:24:38 -0700 +From: Andrew Lazarus +Reply-To: andrew@pillette.com +Organization: Pillette Investment Management +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: What *_mem to increase when running CLUSTER +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD1D2@Herge.rcsinc.local> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD1D2@Herge.rcsinc.local> +Content-Type: multipart/mixed; boundary="------------050003000907070802050103" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.112 required=5 tests=[AWL=0.062, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/420 +X-Sequence-Number: 14167 + +This is a multi-part message in MIME format. +--------------050003000907070802050103 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Should I temporarily increase sort_mem, vacuum_mem, neither, or both +when doing a CLUSTER on a large (100 million row) table where as many as +half of the tuples are deadwood from UPDATEs or DELETEs? I have large +batch (10 million row) inserts, updates, and deletes so I'm not sure +frequent vacuuming would help. + + +--------------050003000907070802050103 +Content-Type: text/x-vcard; charset=utf-8; + name="andrew.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="andrew.vcf" + +begin:vcard +fn:Andrew Lazarus +n:Lazarus;Andrew +org:Pillette Investment Management;Research and Development +adr;dom:;;3028 Fillmore;San Francisco;CA;94123 +email;internet:andrew@pillette.com +title:Director +tel;work:800-366-0688 +tel;fax:415-440-4093 +url:http://www.pillette.com +version:2.1 +end:vcard + + +--------------050003000907070802050103-- + +From pgsql-performance-owner@postgresql.org Thu Aug 25 16:42:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 939B9D7244 + for ; + Thu, 25 Aug 2005 16:41:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77678-02 + for ; + Thu, 25 Aug 2005 19:41:44 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id B3F06D71EA + for ; + Thu, 25 Aug 2005 16:41:43 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7939593; Thu, 25 Aug 2005 12:44:00 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Read/Write block sizes +Date: Thu, 25 Aug 2005 12:45:03 -0700 +User-Agent: KMail/1.8 +Cc: "Jeffrey W. Baker" , + Tom Lane , Guy Thornley , + Steve Poe , Chris Browne +References: + <21700.1124863004@sss.pgh.pa.us> + <1124864572.11270.16.camel@noodles> +In-Reply-To: <1124864572.11270.16.camel@noodles> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200508251245.03473.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 required=5 tests=[AWL=-0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/422 +X-Sequence-Number: 14169 + +Jeff, + +> Ask me sometime about my replacement for GNU sort. =C2=A0It uses the same +> sorting algorithm, but it's an order of magnitude faster due to better +> I/O strategy. =C2=A0Someday, in my infinite spare time, I hope to demonst= +rate +> that kind of improvement with a patch to pg. + +Since we desperately need some improvements in sort performance, I do hope= +=20 +you follow up on this. + +=2D-=20 +=2D-Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Aug 25 17:19:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8546FD76C2 + for ; + Thu, 25 Aug 2005 17:19:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83907-08 + for ; + Thu, 25 Aug 2005 20:19:51 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 68704D7682 + for ; + Thu, 25 Aug 2005 17:19:49 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7PKJovh014787; + Thu, 25 Aug 2005 16:19:50 -0400 (EDT) +To: andrew@pillette.com +Cc: pgsql-performance@postgresql.org +Subject: Re: What *_mem to increase when running CLUSTER +In-reply-to: <430E1AF6.9030803@pillette.com> +References: <6EE64EF3AB31D5448D0007DD34EEB3417DD1D2@Herge.rcsinc.local> + <430E1AF6.9030803@pillette.com> +Comments: In-reply-to Andrew Lazarus + message dated "Thu, 25 Aug 2005 12:24:38 -0700" +Date: Thu, 25 Aug 2005 16:19:50 -0400 +Message-ID: <14786.1125001190@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/423 +X-Sequence-Number: 14170 + +Andrew Lazarus writes: +> Should I temporarily increase sort_mem, vacuum_mem, neither, or both +> when doing a CLUSTER on a large (100 million row) table + +The only part of that job that can use lots of memory is the index +rebuilds. In recent PG versions maintenance_work_mem is the thing +to increase for an index build; previously sort_mem controlled it. +I forget when the changeover was; maybe 8.0. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Aug 25 17:26:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DE9F9D76D6 + for ; + Thu, 25 Aug 2005 17:26:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86419-09 + for ; + Thu, 25 Aug 2005 20:26:38 +0000 (GMT) +Received: from smtpauth01.mail.atl.earthlink.net + (smtpauth01.mail.atl.earthlink.net [209.86.89.61]) + by svr1.postgresql.org (Postfix) with ESMTP id D68C0D76C2 + for ; + Thu, 25 Aug 2005 17:26:37 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=NqoHMEt4GyPZWq99tKj9cQgjBtyrABeNbkE4ue8UXNpLJgAWAOQV0437FNyDgsTW; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:Content-Transfer-Encoding:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E8OJ4-0003ZP-LX; Thu, 25 Aug 2005 16:26:38 -0400 +Message-Id: <6.2.3.4.0.20050825162308.05dbf298@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Thu, 25 Aug 2005 16:26:34 -0400 +To: josh@agliodbs.com, pgsql-performance@postgresql.org +From: Ron +Subject: Re: Read/Write block sizes +In-Reply-To: <200508251245.03473.josh@agliodbs.com> +References: + <21700.1124863004@sss.pgh.pa.us> + <1124864572.11270.16.camel@noodles> + <200508251245.03473.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1"; format=flowed +Content-Transfer-Encoding: quoted-printable +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcaa3d4fb93db5250a4c66d5258db04eb7350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.442 required=5 tests=[AWL=0.068, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/424 +X-Sequence-Number: 14171 + +At 03:45 PM 8/25/2005, Josh Berkus wrote: +>Jeff, +> +> > Ask me sometime about my replacement for GNU sort. =C2 It uses the same +> > sorting algorithm, but it's an order of magnitude faster due to better +> > I/O strategy. =C2 Someday, in my infinite spare time, I hope to= + demonstrate +> > that kind of improvement with a patch to pg. +> +>Since we desperately need some improvements in sort performance, I do hope +>you follow up on this. +> +>-- +>--Josh + +I'll generalize that. IMO we desperately need=20 +any and all improvements in IO performance. Even=20 +more so than we need improvements in sorting or sorting IO performance. + +Ron + + + +From pgsql-performance-owner@postgresql.org Thu Aug 25 17:49:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BAA0AD7712 + for ; + Thu, 25 Aug 2005 17:49:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93231-01 + for ; + Thu, 25 Aug 2005 20:49:37 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 819F9D76C8 + for ; + Thu, 25 Aug 2005 17:49:35 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 2124E31F50; Thu, 25 Aug 2005 23:02:09 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Read/Write block sizes +Date: Thu, 25 Aug 2005 16:49:26 -0400 +Organization: cbbrowne Computing Inc +Lines: 41 +Message-ID: <604q9doi7d.fsf@dba2.int.libertyrms.com> +References: + <21700.1124863004@sss.pgh.pa.us> + <1124864572.11270.16.camel@noodles> + <200508251245.03473.josh@agliodbs.com> + <6.2.3.4.0.20050825162308.05dbf298@pop.earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:ySqOwaJz/b3BL3ibyrYi6KhtleU= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.109 required=5 tests=[AWL=0.109] +X-Spam-Level: +X-Archive-Number: 200508/425 +X-Sequence-Number: 14172 + +rjpeace@earthlink.net (Ron) writes: +> At 03:45 PM 8/25/2005, Josh Berkus wrote: +>> > Ask me sometime about my replacement for GNU sort. � It uses the +>> > same sorting algorithm, but it's an order of magnitude faster due +>> > to better I/O strategy. � Someday, in my infinite spare time, I +>> > hope to demonstrate that kind of improvement with a patch to pg. +>> +>>Since we desperately need some improvements in sort performance, I +>>do hope you follow up on this. +> +> I'll generalize that. IMO we desperately need any and all +> improvements in IO performance. Even more so than we need +> improvements in sorting or sorting IO performance. + +That's frankly a step backwards. + +Feel free to "specialise" that instead. + +A patch that improves some specific aspect of performance is a +thousand times better than any sort of "desperate desire for any and +all improvements in I/O performance." + +The latter is unlikely to provide any usable result. + +The "specialized patch" is also pointedly better in that a +*confidently submitted* patch is likely to be way better than any sort +of "desperate clutching at whatever may come to hand." + +Far too often, I see people trying to address performance problems via +the "desperate clutching at whatever seems near to hand," and that +generally turns out very badly as a particular result of the whole +"desperate clutching" part. + +If you can get a sort improvement submitted, that's a concrete +improvement... +-- +select 'cbbrowne' || '@' || 'ntlug.org'; +http://www3.sympatico.ca/cbbrowne/lisp.html +Appendium to the Rules of the Evil Overlord #1: "I will not build +excessively integrated security-and-HVAC systems. They may be Really +Cool, but are far too vulnerable to breakdowns." + +From pgsql-performance-owner@postgresql.org Thu Aug 25 20:47:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BCCED78D0 + for ; + Thu, 25 Aug 2005 20:46:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37751-09 + for ; + Thu, 25 Aug 2005 23:46:54 +0000 (GMT) +Received: from smtpauth05.mail.atl.earthlink.net + (smtpauth05.mail.atl.earthlink.net [209.86.89.65]) + by svr1.postgresql.org (Postfix) with ESMTP id AB486D789C + for ; + Thu, 25 Aug 2005 20:46:52 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=tGouZISx5acGbjd110zxz8F1ASDWQ2nto6247G5c+DVO9G9Q8xetSVyLymjV1k4x; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:Content-Transfer-Encoding:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth05.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E8RQu-0002ky-6U; Thu, 25 Aug 2005 19:46:56 -0400 +Message-Id: <6.2.3.4.0.20050825185441.05e63ef0@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Thu, 25 Aug 2005 19:46:51 -0400 +To: Chris Browne , pgsql-performance@postgresql.org +From: Ron +Subject: Re: Read/Write block sizes +In-Reply-To: <604q9doi7d.fsf@dba2.int.libertyrms.com> +References: + <21700.1124863004@sss.pgh.pa.us> + <1124864572.11270.16.camel@noodles> + <200508251245.03473.josh@agliodbs.com> + <6.2.3.4.0.20050825162308.05dbf298@pop.earthlink.net> + <604q9doi7d.fsf@dba2.int.libertyrms.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1"; format=flowed +Content-Transfer-Encoding: quoted-printable +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc2469d0c2931e1f8d42fb3ee955c9969c350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.433 required=5 tests=[AWL=0.059, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/426 +X-Sequence-Number: 14173 + +At 04:49 PM 8/25/2005, Chris Browne wrote: +>rjpeace@earthlink.net (Ron) writes: +> > At 03:45 PM 8/25/2005, Josh Berkus wrote: +> >> > Ask me sometime about my replacement for GNU sort. =C2 It uses the +> >> > same sorting algorithm, but it's an order of magnitude faster due +> >> > to better I/O strategy. =C2 Someday, in my infinite spare time, I +> >> > hope to demonstrate that kind of improvement with a patch to pg. +> >> +> >>Since we desperately need some improvements in sort performance, I +> >>do hope you follow up on this. +> > +> > I'll generalize that. IMO we desperately need any and all +> > improvements in IO performance. Even more so than we need +> > improvements in sorting or sorting IO performance. +> +>That's frankly a step backwards. Feel free to "specialise" that instead. + +We can agree to disagree, I'm cool with that. + +I'm well aware that a Systems Approach to SW=20 +Architecture is not always popular in the Open=20 +Source world. Nonetheless, my POV is that if we=20 +want to be taken seriously and beat "the big=20 +boys", we have to do everything smarter and=20 +faster, as well as cheaper, than they do. You=20 +are not likely to be able to do that consistently=20 +without using some of the "icky" stuff one is=20 +required to study as part of formal training in=20 +the Comp Sci and SW Engineering fields. + + +>A patch that improves some specific aspect of=20 +>performance is a thousand times better than any=20 +>sort of "desperate desire for any and +>all improvements in I/O performance." + +minor twisting of my words: substituting "desire"=20 +for "need". The need is provable. Just put "the=20 +big 5" (SQL Server, Oracle, DB2, mySQL, and=20 +PostgreSQL) into some realistic benches to see that. + +Major twisting of my words: the apparent=20 +implication by you that I don't appreciate=20 +improvements in the IO behavior of specific=20 +things like sorting as much as I'd appreciate=20 +more "general" IO performance=20 +improvements. Performance optimization is best=20 +done as an iterative improvement process that=20 +starts with measuring where the need is greatest,=20 +then improving that greatest need by the most you=20 +can, then repeating the whole cycle. _Every_=20 +improvement in such a process is a specific=20 +improvement, even if the improvement is a=20 +decision to re-architect the entire product to=20 +solve the current biggest issue. Improving=20 +sorting IO is cool. OTOH, if pg's biggest IO=20 +problems are elsewhere, then the amount of=20 +overall benefit we will get from improving=20 +sorting IO is going to be minimized until we=20 +improve the bigger problem(s). Amdahl's Law. + + +>The "specialized patch" is also pointedly better=20 +>in that a *confidently submitted* patch is=20 +>likely to be way better than any sort of=20 +>"desperate clutching at whatever may come to hand." + +Another distortion of my statement and POV. I=20 +never suggested nor implied any sort of=20 +"desperate clutching...". We have _measurable_=20 +IO issues that need to be addressed in order for=20 +pg to be a better competitor in the=20 +marketplace. Just as we do with sorting performance. + + +>Far too often, I see people trying to address=20 +>performance problems via the "desperate=20 +>clutching at whatever seems near to hand," and that +>generally turns out very badly as a particular=20 +>result of the whole "desperate clutching" part. +> +>If you can get a sort improvement submitted, that's a concrete= + improvement... + +As I said, I'm all in favor of concrete,=20 +measurable improvement. I do not think I ever=20 +stated I was in favor of anything else. + +You evidently are mildly ranting because you've=20 +seen some examples of poor SW Engineering=20 +Discipline/Practice by people with perhaps=20 +inadequate skills for the issues they were trying=20 +to address. We all have. "90% of everything is=20 +Jreck (eg of too low a quality)." + +OTOH, I do not think I've given you any reason to=20 +think I lack such Clue, nor do I think my post was advocating such= + thrashing. + +My post was intended to say that we need an=20 +Overall Systems Approach to pg optimization=20 +rather than just applying what compiler writer's=20 +call "peephole optimizations" to pg. No more, no less. + +I apologize if I somehow misled you, +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Thu Aug 25 21:27:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 00651D70D1 + for ; + Thu, 25 Aug 2005 21:27:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52378-03 + for ; + Fri, 26 Aug 2005 00:27:26 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E647D703F + for ; + Thu, 25 Aug 2005 21:27:24 -0300 (ADT) +Received: from [80.203.125.83] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1E8S1Y-00017T-Mf + for ; Fri, 26 Aug 2005 02:24:59 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id 938E6DECFD; Fri, 26 Aug 2005 02:27:09 +0200 (CEST) +Date: Fri, 26 Aug 2005 02:27:09 +0200 +From: Tobias Brox +To: pgsql-performance@postgresql.org +Subject: Limit + group + join +Message-ID: <20050826002709.GK10328@tobias.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Organization: Group Nordicbet +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/427 +X-Sequence-Number: 14174 + +Consider this setup - which is a gross simplification of parts of our +production system ;-) + + create table c (id integer primary key); + create table b (id integer primary key, c_id integer); + create index b_on_c on b(c_id) + + insert into c (select ... lots of IDs ...); + insert into b (select id, id from c); /* keep it simple :-) */ + +Now, I'm just interessted in some few rows. + +All those gives good plans: + +explain select c.id from c order by c.id limit 1; +explain select c.id from c group by c.id order by c.id limit 1; +explain select c.id from c join b on c_id=c.id order by c.id limit 1; + +... BUT ... combining join, group and limit makes havoc: + +explain select c.id from c join b on c_id=c.id group by c.id order by c.id +desc limit 5; + QUERY PLAN +------------------------------------------------------------------------------------- + Limit (cost=3809.65..3809.67 rows=5 width=4) + -> Group (cost=3809.65..3940.59 rows=26187 width=4) + -> Sort (cost=3809.65..3875.12 rows=26188 width=4) + Sort Key: c.id + -> Hash Join (cost=559.34..1887.89 rows=26188 width=4) + Hash Cond: ("outer".id = "inner".c_id) + -> Seq Scan on c (cost=0.00..403.87 rows=26187 width=4) + -> Hash (cost=403.87..403.87 rows=26187 width=4) + -> Seq Scan on b (cost=0.00..403.87 rows=26187 width=4) +(9 rows) + +I get the same behaviour on pg 7.4.7 and pg 8.0.2. Of course, I can +probably use subqueries instead of join - though, I would have wished the +planner could do better ;-) + +-- +Notice of Confidentiality: This information may be confidential, and +blah-blah-blah - so please keep your eyes closed. Please delete and destroy +this email. Failure to comply will cause my lawyer to yawn. + +From pgsql-performance-owner@postgresql.org Thu Aug 25 22:56:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A5519D7908 + for ; + Thu, 25 Aug 2005 22:55:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81172-04 + for ; + Fri, 26 Aug 2005 01:55:43 +0000 (GMT) +Received: from mail27.sea5.speakeasy.net (mail27.sea5.speakeasy.net + [69.17.117.29]) + by svr1.postgresql.org (Postfix) with ESMTP id EF9C9D7911 + for ; + Thu, 25 Aug 2005 22:55:42 -0300 (ADT) +Received: (qmail 25321 invoked from network); 26 Aug 2005 01:55:46 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail27.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 26 Aug 2005 01:55:46 -0000 +Subject: Re: Limit + group + join +From: "Jeffrey W. Baker" +To: Tobias Brox +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20050826002709.GK10328@tobias.lan> +References: <20050826002709.GK10328@tobias.lan> +Content-Type: text/plain +Date: Thu, 25 Aug 2005 18:56:59 -0700 +Message-Id: <1125021419.16451.0.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 required=5 tests=[AWL=0.043] +X-Spam-Level: +X-Archive-Number: 200508/428 +X-Sequence-Number: 14175 + +On Fri, 2005-08-26 at 02:27 +0200, Tobias Brox wrote: +> Consider this setup - which is a gross simplification of parts of our +> production system ;-) +> +> create table c (id integer primary key); +> create table b (id integer primary key, c_id integer); +> create index b_on_c on b(c_id) +> +> insert into c (select ... lots of IDs ...); +> insert into b (select id, id from c); /* keep it simple :-) */ +> +> Now, I'm just interessted in some few rows. +> +> All those gives good plans: +> +> explain select c.id from c order by c.id limit 1; +> explain select c.id from c group by c.id order by c.id limit 1; +> explain select c.id from c join b on c_id=c.id order by c.id limit 1; +> +> ... BUT ... combining join, group and limit makes havoc: +> +> explain select c.id from c join b on c_id=c.id group by c.id order by c.id +> desc limit 5; + +Where's b in this join clause? It looks like a cartesian product to me. + +-jwb + + +From pgsql-performance-owner@postgresql.org Thu Aug 25 23:07:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1331BD6E53 + for ; + Thu, 25 Aug 2005 23:07:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86805-03 + for ; + Fri, 26 Aug 2005 02:06:52 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9569AD791D + for ; + Thu, 25 Aug 2005 23:06:49 -0300 (ADT) +Received: from [80.203.125.83] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1E8TZl-0006IO-Ly; Fri, 26 Aug 2005 04:04:23 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id 90C47DECFD; Fri, 26 Aug 2005 04:06:35 +0200 (CEST) +Date: Fri, 26 Aug 2005 04:06:35 +0200 +From: Tobias Brox +To: "Jeffrey W. Baker" +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: Limit + group + join +Message-ID: <20050826020635.GM10328@tobias.lan> +References: <20050826002709.GK10328@tobias.lan> + <1125021419.16451.0.camel@noodles> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1125021419.16451.0.camel@noodles> +Organization: Group Nordicbet +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/429 +X-Sequence-Number: 14176 + +[Jeffrey W. Baker - Thu at 06:56:59PM -0700] +> > explain select c.id from c join b on c_id=c.id group by c.id order by c.id +> > desc limit 5; +> +> Where's b in this join clause? + +"join b on c_id=c.id" + +It just a funny way of writing: + +select c.id from c,b where c_id=c.id group by c.id order by c.id desc limit 5; + +> It looks like a cartesian product to me. + +No. The query will return exactly the same as the simplest query: + + select c.id from c order by c.id desc limit 5; + +As said, this is a gross oversimplification of the production envorinment. +In the production environment, I really need to use both join, group and +limit. I tested a bit with subqueries, it was not a good solution +(selecting really a lot of rows and aggregates from many of the tables). + +The next idea is to hack it up by manually finding out where the "limit" +will cut, and place a restriction in the where-part of the query. + +-- +Notice of Confidentiality: This information may be confidential, and +blah-blah-blah - so please keep your eyes closed. Please delete and destroy +this email. Failure to comply will cause my lawyer to yawn. + +From pgsql-performance-owner@postgresql.org Thu Aug 25 23:33:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CFE0CD7930 + for ; + Thu, 25 Aug 2005 23:30:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96597-05 + for ; + Fri, 26 Aug 2005 02:30:11 +0000 (GMT) +Received: from mail23.sea5.speakeasy.net (mail23.sea5.speakeasy.net + [69.17.117.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 0611BD78E3 + for ; + Thu, 25 Aug 2005 23:30:04 -0300 (ADT) +Received: (qmail 12130 invoked from network); 26 Aug 2005 02:30:07 -0000 +Received: from dsl081-060-184.sfo1.dsl.speakeasy.net (HELO noodles) + ([64.81.60.184]) (envelope-sender ) + by mail23.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted + SMTP for ; 26 Aug 2005 02:30:07 -0000 +Subject: Re: Limit + group + join +From: "Jeffrey W. Baker" +To: Tobias Brox +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1125021419.16451.0.camel@noodles> +References: <20050826002709.GK10328@tobias.lan> + <1125021419.16451.0.camel@noodles> +Content-Type: text/plain +Date: Thu, 25 Aug 2005 19:31:20 -0700 +Message-Id: <1125023480.16451.2.camel@noodles> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.038 required=5 tests=[AWL=0.038] +X-Spam-Level: +X-Archive-Number: 200508/430 +X-Sequence-Number: 14177 + +On Thu, 2005-08-25 at 18:56 -0700, Jeffrey W. Baker wrote: +> On Fri, 2005-08-26 at 02:27 +0200, Tobias Brox wrote: +> > Consider this setup - which is a gross simplification of parts of our +> > production system ;-) +> > +> > create table c (id integer primary key); +> > create table b (id integer primary key, c_id integer); +> > create index b_on_c on b(c_id) +> > +> > insert into c (select ... lots of IDs ...); +> > insert into b (select id, id from c); /* keep it simple :-) */ +> > +> > Now, I'm just interessted in some few rows. +> > +> > All those gives good plans: +> > +> > explain select c.id from c order by c.id limit 1; +> > explain select c.id from c group by c.id order by c.id limit 1; +> > explain select c.id from c join b on c_id=c.id order by c.id limit 1; +> > +> > ... BUT ... combining join, group and limit makes havoc: +> > +> > explain select c.id from c join b on c_id=c.id group by c.id order by c.id +> > desc limit 5; +> +> Where's b in this join clause? It looks like a cartesian product to me. + +Nevermind. I read c_id as c.id. + +-jwb + + +From pgsql-performance-owner@postgresql.org Fri Aug 26 00:44:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F411FD6FC7 + for ; + Fri, 26 Aug 2005 00:17:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17829-03 + for ; + Fri, 26 Aug 2005 03:17:52 +0000 (GMT) +Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz [202.0.58.22]) + by svr1.postgresql.org (Postfix) with ESMTP id 08BFAD6FDD + for ; + Fri, 26 Aug 2005 00:17:51 -0300 (ADT) +Received: from smtp-1.paradise.net.nz (smtp-1a.paradise.net.nz [202.0.32.194]) + by linda-3.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0ILT00KK77TO3C@linda-3.paradise.net.nz> for + pgsql-performance@postgresql.org; Fri, 26 Aug 2005 15:17:50 +1200 (NZST) +Received: from [192.168.1.11] (218-101-14-16.paradise.net.nz [218.101.14.16]) + by smtp-1.paradise.net.nz (Postfix) with ESMTP id 9C26E831B2; Fri, + 26 Aug 2005 15:01:03 +1200 (NZST) +Date: Fri, 26 Aug 2005 15:01:01 +1200 +From: Mark Kirkwood +Subject: Re: Limit + group + join +In-reply-to: <20050826002709.GK10328@tobias.lan> +To: Tobias Brox +Cc: pgsql-performance@postgresql.org +Message-id: <430E85ED.60109@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) +References: <20050826002709.GK10328@tobias.lan> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.653 required=5 tests=[AWL=-0.373, + RCVD_IN_NJABL_PROXY=1.026] +X-Spam-Level: +X-Archive-Number: 200508/431 +X-Sequence-Number: 14178 + +Tobias, +Interesting example: + +The 'desc' seems to be the guy triggering the sort, e.g: + +explain select c.id from c join b on c_id=c.id group by c.id order by +c.id limit 5; + QUERY PLAN + +----------------------------------------------------------------------------------------- + Limit (cost=0.00..0.28 rows=5 width=4) + -> Group (cost=0.00..4476.00 rows=80000 width=4) + -> Merge Join (cost=0.00..4276.00 rows=80000 width=4) + Merge Cond: ("outer".id = "inner".c_id) + -> Index Scan using c_pkey on c (cost=0.00..1518.00 +rows=80000 width=4) + -> Index Scan using b_on_c on b (cost=0.00..1558.00 +rows=80000 width=4) +(6 rows) + +Whereas with it back in again: + +explain select c.id from c join b on c_id=c.id group by c.id order by +c.id desc limit 5; + QUERY PLAN + +-------------------------------------------------------------------------------------- + Limit (cost=10741.08..10741.11 rows=5 width=4) + -> Group (cost=10741.08..11141.08 rows=80000 width=4) + -> Sort (cost=10741.08..10941.08 rows=80000 width=4) + Sort Key: c.id + -> Hash Join (cost=1393.00..4226.00 rows=80000 width=4) + Hash Cond: ("outer".c_id = "inner".id) + -> Seq Scan on b (cost=0.00..1233.00 rows=80000 +width=4) + -> Hash (cost=1193.00..1193.00 rows=80000 width=4) + -> Seq Scan on c (cost=0.00..1193.00 +rows=80000 width=4) +(9 rows) + + +However being a bit brutal: + +set enable_mergejoin=false; +set enable_hashjoin=false; + +explain select c.id from c join b on c_id=c.id group by c.id order by +c.id desc limit 5; + QUERY PLAN + +-------------------------------------------------------------------------------------------------- + Limit (cost=0.00..15.24 rows=5 width=4) + -> Group (cost=0.00..243798.00 rows=80000 width=4) + -> Nested Loop (cost=0.00..243598.00 rows=80000 width=4) + -> Index Scan Backward using c_pkey on c +(cost=0.00..1518.00 rows=80000 width=4) + -> Index Scan using b_on_c on b (cost=0.00..3.01 +rows=1 width=4) + Index Cond: (b.c_id = "outer".id) +(6 rows) + +What is interesting is why this plan is being rejected... + +Cheers + +Mark + +Tobias Brox wrote: +> Consider this setup - which is a gross simplification of parts of our +> production system ;-) +> +> create table c (id integer primary key); +> create table b (id integer primary key, c_id integer); +> create index b_on_c on b(c_id) +> +> insert into c (select ... lots of IDs ...); +> insert into b (select id, id from c); /* keep it simple :-) */ +> +> Now, I'm just interessted in some few rows. +> +> All those gives good plans: +> +> explain select c.id from c order by c.id limit 1; +> explain select c.id from c group by c.id order by c.id limit 1; +> explain select c.id from c join b on c_id=c.id order by c.id limit 1; +> +> ... BUT ... combining join, group and limit makes havoc: +> +> explain select c.id from c join b on c_id=c.id group by c.id order by c.id +> desc limit 5; +> + +From pgsql-performance-owner@postgresql.org Fri Aug 26 03:08:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A222D6F75 + for ; + Fri, 26 Aug 2005 03:08:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60615-09 + for ; + Fri, 26 Aug 2005 06:08:41 +0000 (GMT) +Received: from smtp-gw.fnbs.net.my (smtp-gw.fnbs.net.my [202.9.108.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 0AF9FD6E40 + for ; + Fri, 26 Aug 2005 03:08:39 -0300 (ADT) +Received: from mail-std.fnbs.net.my (smtp-std.fnbs.net.my [202.9.108.197]) + by fnsrvlx9.fnbs.net.my (SMTP Mailer) with ESMTP id 786E152AB7 + for ; + Fri, 26 Aug 2005 14:08:37 +0800 (MYT) +Received: from Beh (unverified [203.106.54.162]) + by mail-std.fnbs.net.my (SurgeMail 3.0c2) with ESMTP id 18087424 + for ; + Fri, 26 Aug 2005 14:08:37 +0800 MYT +Message-ID: <000b01c5aa04$a1ba0100$a279640a@Beh> +From: "Chun Yit(Chronos)" +To: +Subject: postmaster memory keep going up???? +Date: Fri, 26 Aug 2005 14:08:51 +0800 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0008_01C5AA47.AF9CDCA0" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.077 required=5 tests=[AWL=-0.019, HTML_50_60=0.095, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/432 +X-Sequence-Number: 14179 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0008_01C5AA47.AF9CDCA0 +Content-Type: text/plain; + charset="gb2312" +Content-Transfer-Encoding: quoted-printable + +>I have a pl/pgsql function that using temp table to perform searching = +logic, +>we have one server running on 512MB, Red Hat 9.0, postgresql-7.4.5. +>the problem is the pl/pgsql function that i created will increase = +postmaster memory when calling to function +>become more frequent, i did a test by getting out all the logic inside = +the function and what left only +>create temporary table and drop the temporary table statement (at the = +end if this function), i monitor the %mem for postmaster +>using linux command, ps -eo pid,comm,user,%mem | grep postmaster. +>when i start the postmaster, the %mem show only 2.0 something, but = +after i run the function for more that 1000 time, then +>the %mem will go up until 10.0 something. +>my question is,it is postmaster have memory leaking problem? +>hope someone can give me some help and best is how to identify the = +problem it is come from postgresql? +> +>thanks +>regards +>ivan +------=_NextPart_000_0008_01C5AA47.AF9CDCA0 +Content-Type: text/html; + charset="gb2312" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
>I have a pl/pgsql function that = +using temp=20 +table to perform searching logic,
+
>we have one=20 +server running on 512MB, Red Hat 9.0, postgresql-7.4.5.
+
>the problem is the pl/pgsql = +function that i=20 +created will increase postmaster memory when calling to = +function
+
>become more frequent, i did a test = +by getting=20 +out all the logic inside the function and what left only
+
>create temporary table and drop the = +temporary=20 +table statement (at the end if this function), i monitor the %mem for=20 +postmaster
+
>using linux command, ps -eo = +pid,comm,user,%mem=20 +| grep postmaster.
+
>when i start the postmaster, the = +%mem show only=20 +2.0 something, but after i run the function for more that 1000 time,=20 +then
+
>the %mem will go up until 10.0=20 +something.
+
>my question is,it is postmaster = +have memory=20 +leaking problem?
+
>hope someone can give me some help = +and best is=20 +how to identify the problem it is come from postgresql?
+
>
+
>thanks
+
>regards
+
>ivan
+ +------=_NextPart_000_0008_01C5AA47.AF9CDCA0-- + + +From pgsql-performance-owner@postgresql.org Fri Aug 26 03:21:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 94794D7859 + for ; + Fri, 26 Aug 2005 03:21:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67689-06 + for ; + Fri, 26 Aug 2005 06:21:11 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 60568D7838 + for ; + Fri, 26 Aug 2005 03:21:09 -0300 (ADT) +Received: from [80.203.125.83] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1E8XXp-0006yn-GO; Fri, 26 Aug 2005 08:18:39 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id 8FB69DECFD; Fri, 26 Aug 2005 08:20:51 +0200 (CEST) +Date: Fri, 26 Aug 2005 08:20:51 +0200 +From: Tobias Brox +To: Mark Kirkwood +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: Limit + group + join +Message-ID: <20050826062051.GN10328@tobias.lan> +References: <20050826002709.GK10328@tobias.lan> + <430E85ED.60109@paradise.net.nz> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <430E85ED.60109@paradise.net.nz> +Organization: Group Nordicbet +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/433 +X-Sequence-Number: 14180 + +[Mark Kirkwood - Fri at 03:01:01PM +1200] +> Tobias, +> Interesting example: +> +> The 'desc' seems to be the guy triggering the sort, e.g: + +Oh; really an accident that I didn't notice myself, I was actually going to +remove all instances of "desc" in my simplification, but seems like I forgot. + +> However being a bit brutal: +> +> set enable_mergejoin=false; +> set enable_hashjoin=false; + +:-) maybe I can use that in production. I'll check. + +-- +Notice of Confidentiality: This information may be confidential, and +blah-blah-blah - so please keep your eyes closed. Please delete and destroy +this email. Failure to comply will cause my lawyer to yawn. + +From pgsql-performance-owner@postgresql.org Fri Aug 26 05:35:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C8D8ED7C5F + for ; + Fri, 26 Aug 2005 05:35:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03987-08 + for ; + Fri, 26 Aug 2005 08:35:34 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 124CFD7C70 + for ; + Fri, 26 Aug 2005 05:35:31 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id 2A54B417C49; Fri, 26 Aug 2005 09:35:27 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 45ABC15EDB; + Fri, 26 Aug 2005 09:34:34 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 31733-01; Fri, 26 Aug 2005 09:34:32 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id E8FFE15ED9; + Fri, 26 Aug 2005 09:34:31 +0100 (BST) +Message-ID: <430ED417.2050601@archonet.com> +Date: Fri, 26 Aug 2005 09:34:31 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Chun Yit(Chronos)" +Cc: pgsql-performance@postgresql.org +Subject: Re: postmaster memory keep going up???? +References: <000b01c5aa04$a1ba0100$a279640a@Beh> +In-Reply-To: <000b01c5aa04$a1ba0100$a279640a@Beh> +Content-Type: text/plain; charset=GB2312 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/434 +X-Sequence-Number: 14181 + +Chun Yit(Chronos) wrote: +>>I have a pl/pgsql function that using temp table to perform searching logic, + +>>my question is,it is postmaster have memory leaking problem? + +First step - upgrade to the latest 7.4.x release. + +Second step - read the "release notes" section of the manuals for 7.4.x +and 8.0.x and see what it says about memory and plpgsql. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Aug 26 08:09:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D215FD6FC6 + for ; + Fri, 26 Aug 2005 08:09:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42421-07 + for ; + Fri, 26 Aug 2005 11:09:32 +0000 (GMT) +Received: from gollum.cambrium.nl (mx1.cambrium.nl [217.19.16.130]) + by svr1.postgresql.org (Postfix) with SMTP id 7B3B4D6D7B + for ; + Fri, 26 Aug 2005 08:09:28 -0300 (ADT) +Received: (qmail 7482 invoked from network); 26 Aug 2005 11:09:28 -0000 +Received: from office.tweakers.net (HELO ?10.0.0.157?) (84.245.2.46) + by gollum.cambrium.nl with SMTP; 26 Aug 2005 11:09:28 -0000 +Message-ID: <430EF844.70905@tweakers.net> +Date: Fri, 26 Aug 2005 13:08:52 +0200 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 1.0+ (Windows/20050711) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Inefficient queryplan for query with intersectable subselects/joins +Content-Type: multipart/mixed; boundary="------------050607070007070009010202" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/435 +X-Sequence-Number: 14182 + +This is a multi-part message in MIME format. +--------------050607070007070009010202 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Hi list, + +I'm writing an application that will aggregate records with a few +million records into averages/sums/minimums etc grouped per day. + +Clients can add filters and do lots of customization on what they want +to see. And I've to translate that to one or more queries. Basically, I +append each filter as either an extra and-in-the-where or joined with +the clauses as ON-clause. The application now uses 8.1devel but I think +the basic plans are similar to 8.0. At least for this first query. + +I noticed a query taking over 25 seconds to execute: + +SELECT "make a timestamp" grouper, chart_2.Prijs as field_2_0 +FROM + pwprijs as chart_2 + JOIN pwprodukten t_0 ON chart_2.ProduktID = t_0.ID AND t_0.Cat2 IN + (SELECT 545 UNION SELECT ID FROM cat WHERE ParentID = 545) + JOIN pwprijs t_1 ON chart_2.ProduktID = t_1.ProduktID + AND t_1.LeverancierID = 938 AND t_1.recordtimestamp >= "last +timestamp" +WHERE + chart_2.Prijs > 0 + +It yields quite a long plan, so I've send that as an attachment along. +Basically it combines two tables against an original to fetch "all +prices (of all suppliers) for products of a certain category that are +sold by a certain supplier". + +I was wondering how rewriting it to subselects would improve +performance, but that wasn't a very clear winner. It shaved of about 5 +seconds. So I took the subselects and used INTERSECT to unite them and +have only one IN-clause in the query. That made it go down to around 13 +seconds. + +I noticed it was doing a seq scan on the largest table to get the "Prijs + > 0"-condition. But since there are only 947 of the 7692207 with prijs += 0 and none with < 0, it shouldn't be the main thing to look for. +Dropping the clause made a minor improvement in performance for the queries. + +But disabling sequential scans allowed an improvement to only 660 ms +compared to the 13 seconds earlier! Row-estimates seem to be quite a bit +off, so I already set the statistics target to 1000 and re-analyzed. +Btw, adding the prijs-clause again would make it choose another index +and thus resulted in much longer operation. + +The final query, only taking 650ms, would be: + +SELECT + "make a timestamp" as grouper, + chart_2.Prijs as field_2_0 +FROM + pwprijs as chart_2 +WHERE + chart_2.ProduktID IN (SELECT ID FROM pwprodukten WHERE Cat2 IN +(SELECT 545 UNION SELECT ID FROM cat WHERE ParentID = 545) + INTERSECT + SELECT produktid FROM pwprijs WHERE LeverancierID = 938 +AND recordtimestamp >= "last timestamp") + +So I'm wondering: how can I make postgres decide to use the (correct) +index without having to disable seq scans and how can I still add the +prijs-clause without dropping the index for it (since it should be used +for other filters). And for ease of use in my application I'd prefer to +use the first query or the version with two seperate IN-clauses. + +Is that possible? + +I left all the configuration-stuff to the defaults since changing values +didn't seem to impact much. Apart from the buffers and effective cache, +increasing those made the performance worse. + +Best regards, + +Arjen + +--------------050607070007070009010202 +Content-Type: text/plain; + name="query-plans.txt" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="query-plans.txt" + + Table "public.pwprijs" + Column | Type | Modifiers +-----------------+---------+----------- + produktid | integer | not null + leverancierid | integer | not null + prijs | real | not null + Time | bigint | not null + recordtimestamp | bigint | not null +Indexes: + "pwprijs_levid_idx" btree (leverancierid), tablespace "raptor" + "pwprijs_levid_pid_idx" btree (leverancierid, produktid), tablespace "raptor" + "pwprijs_levid_rects_idx" btree (leverancierid, recordtimestamp), tablespace "raptor" + "pwprijs_produktid_timestamp_idx" btree (produktid, recordtimestamp), tablespace "raptor" + "pwprijs_rec_levid_pid" btree (recordtimestamp, leverancierid, produktid), tablespace "raptor" + "pwprijs_recordtimestamp_idx" btree (recordtimestamp), tablespace "raptor" + "pwprijs_recordtimestamp_produktid_prijs_idx" btree (recordtimestamp, produktid, prijs), tablespace "raptor" +Tablespace: "raptor" + + Table "public.pwprodukten" + Column | Type | Modifiers +-----------------+-----------------------+------------------------------ + id | integer | not null + naam | character varying(80) | not null + cat2 | smallint | not null + recordtimestamp | bigint | not null +Indexes: + "pwprodukten_pkey" PRIMARY KEY, btree (id) + "pwprodukten_cat_idx" btree (cat2) + + + +SELECT + CAST('epoch'::timestamp + (chart_2.RecordTimestamp - (chart_2.RecordTimestamp % 86400)) * interval '1 second' as date) as grouper, + chart_2.Prijs as field_2_0 +FROM + pwprijs as chart_2 + JOIN pwprodukten t_0 ON chart_2.ProduktID = t_0.ID + AND t_0.Cat2 IN (SELECT 545 UNION SELECT ID FROM cat WHERE ParentID = 545) + JOIN pwprijs t_1 ON chart_2.ProduktID = t_1.ProduktID AND + t_1.LeverancierID = 938 AND t_1.recordtimestamp >= + (SELECT max_date - 60 FROM last_dates WHERE table_name = 'pricetracker') +WHERE + chart_2.Prijs > 0 + + Hash Join (cost=72062.34..940100.37 rows=22901407 width=12) (actual time=746.520..29655.748 rows=58065 loops=1) + Hash Cond: ("outer".produktid = "inner".id) + InitPlan + -> Seq Scan on last_dates (cost=0.00..1.06 rows=1 width=8) (actual time=0.041..0.045 rows=1 loops=1) + Filter: ((table_name)::text = 'pricetracker'::text) + -> Seq Scan on pwprijs chart_2 (cost=0.00..156721.59 rows=7691800 width=16) (actual time=8.457..14713.939 rows=7691260 loops=1) + Filter: (prijs > 0::double precision) + -> Hash (cost=71769.47..71769.47 rows=42319 width=8) (actual time=606.996..606.996 rows=103 loops=1) + -> Hash Join (cost=4329.24..71769.47 rows=42319 width=8) (actual time=599.771..606.782 rows=103 loops=1) + Hash Cond: ("outer".produktid = "inner".id) + -> Bitmap Heap Scan on pwprijs t_1 (cost=787.84..65786.28 rows=84640 width=4) (actual time=36.049..40.618 rows=4405 loops=1) + Recheck Cond: ((leverancierid = 938) AND (recordtimestamp >= $1)) + -> Bitmap Index Scan on pwprijs_levid_rects_idx (cost=0.00..787.84 rows=84640 width=0) (actual time=36.004..36.004 rows=4405 loops=1) + Index Cond: ((leverancierid = 938) AND (recordtimestamp >= $1)) + -> Hash (cost=3399.01..3399.01 rows=22156 width=4) (actual time=561.313..561.313 rows=1458 loops=1) + -> Seq Scan on pwprodukten t_0 (cost=10.45..3399.01 rows=22156 width=4) (actual time=60.957..559.595 rows=1458 loops=1) + Filter: (subplan) + SubPlan + -> Materialize (cost=10.45..10.53 rows=8 width=2) (actual time=0.002..0.006 rows=8 loops=44313) + -> Unique (cost=10.40..10.44 rows=8 width=2) (actual time=44.831..44.846 rows=8 loops=1) + -> Sort (cost=10.40..10.42 rows=8 width=2) (actual time=44.829..44.834 rows=8 loops=1) + Sort Key: "?column?" + -> Append (cost=0.00..10.28 rows=8 width=2) (actual time=0.006..44.754 rows=8 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..0.02 rows=1 width=0) (actual time=0.004..0.006 rows=1 loops=1) + -> Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.002..0.003 rows=1 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=2.02..10.26 rows=7 width=2) (actual time=44.723..44.738 rows=7 loops=1) + -> Bitmap Heap Scan on cat (cost=2.02..10.19 rows=7 width=2) (actual time=44.719..44.726 rows=7 loops=1) + Recheck Cond: (parentid = 545) + -> Bitmap Index Scan on cat_parentid_idx (cost=0.00..2.02 rows=7 width=0) (actual time=44.704..44.704 rows=7 loops=1) + Index Cond: (parentid = 545) + Total runtime: 29688.736 ms + + + + +SELECT + CAST('epoch'::timestamp + (chart_2.RecordTimestamp - (chart_2.RecordTimestamp % 86400)) * interval '1 second' as date) as grouper, + chart_2.Prijs as field_2_0 +FROM + pwprijs as chart_2 +WHERE + chart_2.ProduktID IN (SELECT ID FROM pwprodukten WHERE Cat2 IN (SELECT 545 UNION SELECT ID FROM cat WHERE ParentID = 545)) +AND + chart_2.ProduktID IN (SELECT produktid FROM pwprijs WHERE LeverancierID = 938 AND recordtimestamp >= + (SELECT max_date - 60 FROM last_dates WHERE table_name = 'pricetracker')) +AND + chart_2.Prijs > 0 + + Nested Loop IN Join (cost=2850.25..230556.55 rows=1699 width=12) (actual time=482.862..24419.848 rows=58065 loops=1) + InitPlan + -> Seq Scan on last_dates (cost=0.00..1.06 rows=1 width=8) (actual time=0.022..0.025 rows=1 loops=1) + Filter: ((table_name)::text = 'pricetracker'::text) + -> Hash IN Join (cost=2849.18..200109.24 rows=207947 width=20) (actual time=360.511..15450.592 rows=190487 loops=1) + Hash Cond: ("outer".produktid = "inner".id) + -> Seq Scan on pwprijs chart_2 (cost=0.00..156721.59 rows=7691800 width=16) (actual time=11.587..10137.642 rows=7691260 loops=1) + Filter: (prijs > 0::double precision) + -> Hash (cost=2846.19..2846.19 rows=1198 width=4) (actual time=244.576..244.576 rows=1458 loops=1) + -> Nested Loop (cost=12.93..2846.19 rows=1198 width=4) (actual time=48.646..243.239 rows=1458 loops=1) + -> Unique (cost=10.40..10.44 rows=8 width=2) (actual time=19.552..19.580 rows=8 loops=1) + -> Sort (cost=10.40..10.42 rows=8 width=2) (actual time=19.550..19.559 rows=8 loops=1) + Sort Key: "?column?" + -> Append (cost=0.00..10.28 rows=8 width=2) (actual time=0.005..19.532 rows=8 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..0.02 rows=1 width=0) (actual time=0.005..0.007 rows=1 loops=1) + -> Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.003..0.003 rows=1 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=2.02..10.26 rows=7 width=2) (actual time=19.501..19.518 rows=7 loops=1) + -> Bitmap Heap Scan on cat (cost=2.02..10.19 rows=7 width=2) (actual time=19.499..19.506 rows=7 loops=1) + Recheck Cond: (parentid = 545) + -> Bitmap Index Scan on cat_parentid_idx (cost=0.00..2.02 rows=7 width=0) (actual time=19.493..19.493 rows=7 loops=1) + Index Cond: (parentid = 545) + -> Bitmap Heap Scan on pwprodukten (cost=2.52..352.58 rows=150 width=6) (actual time=3.717..27.732 rows=182 loops=8) + Recheck Cond: (pwprodukten.cat2 = "outer"."?column?") + -> Bitmap Index Scan on pwprodukten_cat_idx (cost=0.00..2.52 rows=150 width=0) (actual time=1.510..1.510 rows=182 loops=8) + Index Cond: (pwprodukten.cat2 = "outer"."?column?") + -> Index Scan using pwprijs_levid_pid_idx on pwprijs (cost=0.00..34.16 rows=3 width=4) (actual time=0.044..0.044 rows=0 loops=190487) + Index Cond: ((pwprijs.leverancierid = 938) AND ("outer".produktid = pwprijs.produktid)) + Filter: (recordtimestamp >= $0) + Total runtime: 24466.560 ms + + + + +SELECT + CAST('epoch'::timestamp + (chart_2.RecordTimestamp - (chart_2.RecordTimestamp % 86400)) * interval '1 second' as date) as grouper, + chart_2.Prijs as field_2_0 +FROM + pwprijs as chart_2 +WHERE + chart_2.ProduktID IN (SELECT ID FROM pwprodukten WHERE Cat2 IN (SELECT 545 UNION SELECT ID FROM cat WHERE ParentID = 545) + INTERSECT + SELECT produktid FROM pwprijs WHERE LeverancierID = 938 AND recordtimestamp >= + (SELECT max_date - 60 FROM last_dates WHERE table_name = 'pricetracker')) +AND + chart_2.Prijs > 0 + + + Hash Join (cost=77791.44..457846.83 rows=2010732 width=12) (actual time=409.838..13202.566 rows=58065 loops=1) + Hash Cond: ("outer".produktid = "inner".id) + -> Seq Scan on pwprijs chart_2 (cost=0.00..156721.59 rows=7691800 width=16) (actual time=7.896..8253.585 rows=7691260 loops=1) + Filter: (prijs > 0::double precision) + -> Hash (cost=77769.98..77769.98 rows=8584 width=4) (actual time=325.008..325.008 rows=103 loops=1) + -> SetOp Intersect (cost=77254.95..77684.14 rows=8584 width=4) (actual time=317.384..324.932 rows=103 loops=1) + -> Sort (cost=77254.95..77469.55 rows=85838 width=4) (actual time=317.361..320.519 rows=5863 loops=1) + Sort Key: id + -> Append (cost=12.93..69491.92 rows=85838 width=4) (actual time=38.765..308.837 rows=5863 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=12.93..2858.17 rows=1198 width=4) (actual time=38.763..256.795 rows=1458 loops=1) + -> Nested Loop (cost=12.93..2846.19 rows=1198 width=4) (actual time=38.761..254.989 rows=1458 loops=1) + -> Unique (cost=10.40..10.44 rows=8 width=2) (actual time=8.994..9.027 rows=8 loops=1) + -> Sort (cost=10.40..10.42 rows=8 width=2) (actual time=8.993..9.000 rows=8 loops=1) + Sort Key: "?column?" + -> Append (cost=0.00..10.28 rows=8 width=2) (actual time=0.003..8.978 rows=8 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..0.02 rows=1 width=0) (actual time=0.003..0.005 rows=1 loops=1) + -> Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=2.02..10.26 rows=7 width=2) (actual time=8.949..8.963 rows=7 loops=1) + -> Bitmap Heap Scan on cat (cost=2.02..10.19 rows=7 width=2) (actual time=8.945..8.952 rows=7 loops=1) + Recheck Cond: (parentid = 545) + -> Bitmap Index Scan on cat_parentid_idx (cost=0.00..2.02 rows=7 width=0) (actual time=8.940..8.940 rows=7 loops=1) + Index Cond: (parentid = 545) + -> Bitmap Heap Scan on pwprodukten (cost=2.52..352.58 rows=150 width=6) (actual time=3.847..30.522 rows=182 loops=8) + Recheck Cond: (pwprodukten.cat2 = "outer"."?column?") + -> Bitmap Index Scan on pwprodukten_cat_idx (cost=0.00..2.52 rows=150 width=0) (actual time=1.583..1.583 rows=182 loops=8) + Index Cond: (pwprodukten.cat2 = "outer"."?column?") + -> Subquery Scan "*SELECT* 2" (cost=788.90..66633.75 rows=84640 width=4) (actual time=36.653..46.266 rows=4405 loops=1) + -> Bitmap Heap Scan on pwprijs (cost=788.90..65787.35 rows=84640 width=4) (actual time=36.651..41.326 rows=4405 loops=1) + Recheck Cond: ((leverancierid = 938) AND (recordtimestamp >= $0)) + InitPlan + -> Seq Scan on last_dates (cost=0.00..1.06 rows=1 width=8) (actual time=0.025..0.029 rows=1 loops=1) + Filter: ((table_name)::text = 'pricetracker'::text) + -> Bitmap Index Scan on pwprijs_levid_rects_idx (cost=0.00..787.84 rows=84640 width=0) (actual time=36.614..36.614 rows=4405 loops=1) + Index Cond: ((leverancierid = 938) AND (recordtimestamp >= $0)) + Total runtime: 13234.570 ms + + +set enable_seqscan = false; + + +without prijs-clause: + + Nested Loop (cost=77299.32..7858118.21 rows=2013780 width=12) (actual time=33.964..634.359 rows=58065 loops=1) + -> SetOp Intersect (cost=77296.51..77727.66 rows=8623 width=4) (actual time=33.632..42.356 rows=103 loops=1) + -> Sort (cost=77296.51..77512.08 rows=86231 width=4) (actual time=33.616..36.979 rows=5863 loops=1) + Sort Key: id + -> Append (cost=12.93..69495.92 rows=86231 width=4) (actual time=0.214..25.380 rows=5863 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=12.93..2858.17 rows=1198 width=4) (actual time=0.213..8.779 rows=1458 loops=1) + -> Nested Loop (cost=12.93..2846.19 rows=1198 width=4) (actual time=0.211..7.065 rows=1458 loops=1) + -> Unique (cost=10.40..10.44 rows=8 width=2) (actual time=0.095..0.122 rows=8 loops=1) + -> Sort (cost=10.40..10.42 rows=8 width=2) (actual time=0.093..0.099 rows=8 loops=1) + Sort Key: "?column?" + -> Append (cost=0.00..10.28 rows=8 width=2) (actual time=0.003..0.079 rows=8 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..0.02 rows=1 width=0) (actual time=0.003..0.005 rows=1 loops=1) + -> Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=2.02..10.26 rows=7 width=2) (actual time=0.050..0.065 rows=7 loops=1) + -> Bitmap Heap Scan on cat (cost=2.02..10.19 rows=7 width=2) (actual time=0.048..0.054 rows=7 loops=1) + Recheck Cond: (parentid = 545) + -> Bitmap Index Scan on cat_parentid_idx (cost=0.00..2.02 rows=7 width=0) (actual time=0.040..0.040 rows=7 loops=1) + Index Cond: (parentid = 545) + -> Bitmap Heap Scan on pwprodukten (cost=2.52..352.58 rows=150 width=6) (actual time=0.076..0.658 rows=182 loops=8) + Recheck Cond: (pwprodukten.cat2 = "outer"."?column?") + -> Bitmap Index Scan on pwprodukten_cat_idx (cost=0.00..2.52 rows=150 width=0) (actual time=0.056..0.056 rows=182 loops=8) + Index Cond: (pwprodukten.cat2 = "outer"."?column?") + -> Subquery Scan "*SELECT* 2" (cost=794.53..66637.75 rows=85033 width=4) (actual time=1.064..10.785 rows=4405 loops=1) + -> Bitmap Heap Scan on pwprijs (cost=794.53..65787.42 rows=85033 width=4) (actual time=1.062..5.792 rows=4405 loops=1) + Recheck Cond: ((leverancierid = 938) AND (recordtimestamp >= $0)) + InitPlan + -> Index Scan using last_dates_pkey on last_dates (cost=0.00..3.33 rows=1 width=8) (actual time=0.042..0.044 rows=1 loops=1) + Index Cond: ((table_name)::text = 'pricetracker'::text) + -> Bitmap Index Scan on pwprijs_levid_rects_idx (cost=0.00..791.20 rows=85033 width=0) (actual time=1.027..1.027 rows=4405 loops=1) + Index Cond: ((leverancierid = 938) AND (recordtimestamp >= $0)) + -> Bitmap Heap Scan on pwprijs chart_2 (cost=2.82..895.85 rows=234 width=16) (actual time=0.363..3.980 rows=564 loops=103) + Recheck Cond: (chart_2.produktid = "outer".id) + -> Bitmap Index Scan on pwprijs_produktid_timestamp_idx (cost=0.00..2.82 rows=234 width=0) (actual time=0.206..0.206 rows=564 loops=103) + Index Cond: (chart_2.produktid = "outer".id) + Total runtime: 665.335 ms + + +with prijs-clause: + + + Hash Join (cost=134379.17..514503.02 rows=2013674 width=12) (actual time=3089.037..15063.409 rows=58065 loops=1) + Hash Cond: ("outer".produktid = "inner".id) + -> Bitmap Heap Scan on pwprijs chart_2 (cost=56543.72..213260.22 rows=7691800 width=16) (actual time=2972.869..10299.608 rows=7691260 loops=1) + Recheck Cond: (prijs > 0::double precision) + -> Bitmap Index Scan on pwprijs_recordtimestamp_produktid_prijs_idx (cost=0.00..56543.72 rows=7691800 width=0) (actual time=2962.018..2962.018 rows=7691260 loops=1) + Index Cond: (prijs > 0::double precision) + -> Hash (cost=77813.89..77813.89 rows=8623 width=4) (actual time=41.373..41.373 rows=103 loops=1) + -> SetOp Intersect (cost=77296.51..77727.66 rows=8623 width=4) (actual time=33.770..41.297 rows=103 loops=1) + -> Sort (cost=77296.51..77512.08 rows=86231 width=4) (actual time=33.756..36.971 rows=5863 loops=1) + Sort Key: id + -> Append (cost=12.93..69495.92 rows=86231 width=4) (actual time=0.247..25.379 rows=5863 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=12.93..2858.17 rows=1198 width=4) (actual time=0.246..8.816 rows=1458 loops=1) + -> Nested Loop (cost=12.93..2846.19 rows=1198 width=4) (actual time=0.243..7.092 rows=1458 loops=1) + -> Unique (cost=10.40..10.44 rows=8 width=2) (actual time=0.110..0.135 rows=8 loops=1) + -> Sort (cost=10.40..10.42 rows=8 width=2) (actual time=0.108..0.115 rows=8 loops=1) + Sort Key: "?column?" + -> Append (cost=0.00..10.28 rows=8 width=2) (actual time=0.004..0.092 rows=8 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..0.02 rows=1 width=0) (actual time=0.004..0.006 rows=1 loops=1) + -> Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.002..0.003 rows=1 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=2.02..10.26 rows=7 width=2) (actual time=0.062..0.077 rows=7 loops=1) + -> Bitmap Heap Scan on cat (cost=2.02..10.19 rows=7 width=2) (actual time=0.059..0.066 rows=7 loops=1) + Recheck Cond: (parentid = 545) + -> Bitmap Index Scan on cat_parentid_idx (cost=0.00..2.02 rows=7 width=0) (actual time=0.042..0.042 rows=7 loops=1) + Index Cond: (parentid = 545) + -> Bitmap Heap Scan on pwprodukten (cost=2.52..352.58 rows=150 width=6) (actual time=0.078..0.658 rows=182 loops=8) + Recheck Cond: (pwprodukten.cat2 = "outer"."?column?") + -> Bitmap Index Scan on pwprodukten_cat_idx (cost=0.00..2.52 rows=150 width=0) (actual time=0.058..0.058 rows=182 loops=8) + Index Cond: (pwprodukten.cat2 = "outer"."?column?") + -> Subquery Scan "*SELECT* 2" (cost=794.53..66637.75 rows=85033 width=4) (actual time=1.075..10.724 rows=4405 loops=1) + -> Bitmap Heap Scan on pwprijs (cost=794.53..65787.42 rows=85033 width=4) (actual time=1.072..5.846 rows=4405 loops=1) + Recheck Cond: ((leverancierid = 938) AND (recordtimestamp >= $0)) + InitPlan + -> Index Scan using last_dates_pkey on last_dates (cost=0.00..3.33 rows=1 width=8) (actual time=0.045..0.047 rows=1 loops=1) + Index Cond: ((table_name)::text = 'pricetracker'::text) + -> Bitmap Index Scan on pwprijs_levid_rects_idx (cost=0.00..791.20 rows=85033 width=0) (actual time=1.037..1.037 rows=4405 loops=1) + Index Cond: ((leverancierid = 938) AND (recordtimestamp >= $0)) + Total runtime: 15095.402 ms + +--------------050607070007070009010202-- + +From pgsql-performance-owner@postgresql.org Fri Aug 26 10:10:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 839FFD7066 + for ; + Fri, 26 Aug 2005 10:10:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81936-01 + for ; + Fri, 26 Aug 2005 13:10:18 +0000 (GMT) +Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 314B1D6FEF + for ; + Fri, 26 Aug 2005 10:10:16 -0300 (ADT) +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP + id B87C440DCD2; Fri, 26 Aug 2005 14:10:11 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mainbox.archonet.com (Postfix) with ESMTP id 991FC15EDA; + Fri, 26 Aug 2005 14:05:56 +0100 (BST) +Received: from mainbox.archonet.com ([127.0.0.1]) + by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 06572-01; Fri, 26 Aug 2005 14:05:53 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 0497D15EDE; + Fri, 26 Aug 2005 14:05:24 +0100 (BST) +Message-ID: <430F1393.5040704@archonet.com> +Date: Fri, 26 Aug 2005 14:05:23 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Arjen van der Meijden +Cc: pgsql-performance@postgresql.org +Subject: Re: Inefficient queryplan for query with intersectable +References: <430EF844.70905@tweakers.net> +In-Reply-To: <430EF844.70905@tweakers.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/436 +X-Sequence-Number: 14183 + +Arjen van der Meijden wrote: +> +> I left all the configuration-stuff to the defaults since changing values +> didn't seem to impact much. Apart from the buffers and effective cache, +> increasing those made the performance worse. + +I've not looked at the rest of your problem in detail, but using the +default configuration values is certainly not going to help things. In +particular effective_cache is supposed to tell PG how much memory your +OS is using to cache data. + +Read this through and make sure your configuration settings are sane, +then it might be worthwhile looking in detail at this particular query. + http://www.powerpostgresql.com/PerfList + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Aug 26 11:18:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CCE2D705A + for ; + Fri, 26 Aug 2005 11:18:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91898-09 + for ; + Fri, 26 Aug 2005 14:18:33 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id DA05FD6F0C + for ; + Fri, 26 Aug 2005 11:18:32 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id F334435485; Fri, 26 Aug 2005 07:18:34 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id DAAC63547A; Fri, 26 Aug 2005 07:18:34 -0700 (PDT) +Date: Fri, 26 Aug 2005 07:18:30 -0700 (PDT) +From: Stephan Szabo +To: Mark Kirkwood +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: Limit + group + join +In-Reply-To: <430E85ED.60109@paradise.net.nz> +Message-ID: <20050826071621.P12124@megazone.bigpanda.com> +References: <20050826002709.GK10328@tobias.lan> + <430E85ED.60109@paradise.net.nz> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/437 +X-Sequence-Number: 14184 + +On Fri, 26 Aug 2005, Mark Kirkwood wrote: + +> However being a bit brutal: +> +> set enable_mergejoin=false; +> set enable_hashjoin=false; +> +> explain select c.id from c join b on c_id=c.id group by c.id order by +> c.id desc limit 5; +> QUERY PLAN +> +> -------------------------------------------------------------------------------------------------- +> Limit (cost=0.00..15.24 rows=5 width=4) +> -> Group (cost=0.00..243798.00 rows=80000 width=4) +> -> Nested Loop (cost=0.00..243598.00 rows=80000 width=4) +> -> Index Scan Backward using c_pkey on c +> (cost=0.00..1518.00 rows=80000 width=4) +> -> Index Scan using b_on_c on b (cost=0.00..3.01 +> rows=1 width=4) +> Index Cond: (b.c_id = "outer".id) +> (6 rows) +> +> What is interesting is why this plan is being rejected... + +Well, it expects 80000 probles into b_on_c to be more expensive than the +hash join and sort. I wonder what explain analyze shows for the original +and the version with the enables changed. + +From pgsql-performance-owner@postgresql.org Fri Aug 26 11:49:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B116D79F9 + for ; + Fri, 26 Aug 2005 11:45:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08460-01 + for ; + Fri, 26 Aug 2005 14:45:11 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 64683D79C0 + for ; + Fri, 26 Aug 2005 11:45:06 -0300 (ADT) +Received: from wren.rentec.com (wren.rentec.com [192.5.35.106]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j7QEj72t013241 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) + for ; + Fri, 26 Aug 2005 10:45:09 -0400 (EDT) +X-Rentec: external +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by wren.rentec.com (8.13.1/8.12.1) with ESMTP id j7QEj7wf029455 + for ; + Fri, 26 Aug 2005 10:45:07 -0400 (EDT) +Message-ID: <430F2AF3.1080704@rentec.com> +Date: Fri, 26 Aug 2005 10:45:07 -0400 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 1.0+ (X11/20050712) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: difference in plan between 8.0 and 8.1? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as j7QEj72t013241 at Fri Aug 26 + 10:45:09 2005 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.018 required=5 tests=[AWL=0.018] +X-Spam-Level: +X-Archive-Number: 200508/438 +X-Sequence-Number: 14185 + +Hello all, + +I was hoping someone could explain the plan for a statement. + +We have a table with a column of longs being used as an index. The +query plan in 8.0 was like this: + +# explain select distinct timeseriesid from tbltimeseries where +timeseriesid > 0 order by timeseriesid; +SET + QUERY PLAN +------------------------------------------------------------------------------------------------------- + Unique (cost=0.00..15065908.60 rows=10854026 width=8) + -> Index Scan using idx_timeseris on tbltimeseries +(cost=0.00..15038773.53 rows=10854026 width=8) + Index Cond: (timeseriesid > 0) +(3 rows) + + + +In 8.1, (using the same database after a dump+restore+vacuum+analyze) I +get the following: +# explain select distinct timeseriesid from tbltimeseries where +timeseriesid > 0 order by timeseriesid; + QUERY PLAN +--------------------------------------------------------------------------------------------------- + Unique (cost=2717137.08..2771407.21 rows=10854026 width=8) + -> Sort (cost=2717137.08..2744272.14 rows=10854026 width=8) + Sort Key: timeseriesid + -> Bitmap Heap Scan on tbltimeseries +(cost=48714.09..1331000.42 rows=10854026 width=8) + Recheck Cond: (timeseriesid > 0) + -> Bitmap Index Scan on idx_timeseris +(cost=0.00..48714.09 rows=10854026 width=0) + Index Cond: (timeseriesid > 0) +(7 rows) + + +I'm hoping someone can explain the new query plan (as I'm not sure I +understand what it is doing). + +Thanks! + +-- Alan + +From pgsql-performance-owner@postgresql.org Fri Aug 26 12:03:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A7E7D6F0C + for ; + Fri, 26 Aug 2005 11:49:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08438-05 + for ; + Fri, 26 Aug 2005 14:49:19 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FA62D7B54 + for ; + Fri, 26 Aug 2005 11:49:18 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Limit + group + join +Date: Fri, 26 Aug 2005 10:49:23 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD1F1@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Limit + group + join +Thread-Index: AcWqBqTCoYy6uEvNSTuYW78DFcX66gARl6pQ +From: "Merlin Moncure" +To: "Tobias Brox" +Cc: , + "Mark Kirkwood" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/439 +X-Sequence-Number: 14186 + +Mark Kirkwood +> > The 'desc' seems to be the guy triggering the sort, e.g: +>=20 +> Oh; really an accident that I didn't notice myself, I was actually +going +> to +> remove all instances of "desc" in my simplification, but seems like I +> forgot. + +If desc is the problem you can push the query into a subquery without +sorting and sort the result. This is called an inline view. Sometimes +you can pull a couple of tricks to force the view to materialize before +it is sorted. + +aka=20 +select q.* +from +( + some_complex_query=09 +) q order by ...; + +Merlin + +From pgsql-performance-owner@postgresql.org Fri Aug 26 12:46:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DE24D79CA + for ; + Fri, 26 Aug 2005 12:12:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13630-09 + for ; + Fri, 26 Aug 2005 15:12:50 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 6443DD7971 + for ; + Fri, 26 Aug 2005 12:12:49 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: difference in plan between 8.0 and 8.1? +Date: Fri, 26 Aug 2005 11:12:48 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD1F3@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] difference in plan between 8.0 and 8.1? +Thread-Index: AcWqTbsvXjeYODI0SE2PjPG4tWTjAgAAk4pg +From: "Merlin Moncure" +To: +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/443 +X-Sequence-Number: 14190 + +> Hello all, +>=20 +> I was hoping someone could explain the plan for a statement. +>=20 +> We have a table with a column of longs being used as an index. The +> query plan in 8.0 was like this: +>=20 +> # explain select distinct timeseriesid from tbltimeseries where +> timeseriesid > 0 order by timeseriesid; + +I had the same problem. You probably already have seq scan turned off, +or the server would be using that. You may have to turn bitmap off or +rework you query such that the server will use the index. (between?). + +Anyways, distinct is code word for 'bad performance' :). Consider +laying out tables such that it not necessary, for example set up table +with RI link. Then you can do this in zero time. + +Good luck! + +Merlin + +From pgsql-performance-owner@postgresql.org Fri Aug 26 12:41:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F1227D7BB8 + for ; + Fri, 26 Aug 2005 12:16:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14515-10 + for ; + Fri, 26 Aug 2005 15:16:15 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id A4C36D7A74 + for ; + Fri, 26 Aug 2005 12:16:13 -0300 (ADT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7QFG8WJ019211 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Fri, 26 Aug 2005 09:16:11 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7QFG8kP016969; + Fri, 26 Aug 2005 09:16:08 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7QFG8Td016968; + Fri, 26 Aug 2005 09:16:08 -0600 (MDT) (envelope-from mfuhr) +Date: Fri, 26 Aug 2005 09:16:08 -0600 +From: Michael Fuhr +To: Alan Stange +Cc: pgsql-performance@postgresql.org +Subject: Re: difference in plan between 8.0 and 8.1? +Message-ID: <20050826151608.GA16945@winnie.fuhr.org> +References: <430F2AF3.1080704@rentec.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <430F2AF3.1080704@rentec.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/441 +X-Sequence-Number: 14188 + +On Fri, Aug 26, 2005 at 10:45:07AM -0400, Alan Stange wrote: +> -> Bitmap Heap Scan on tbltimeseries (cost=48714.09..1331000.42 rows=10854026 width=8) +> Recheck Cond: (timeseriesid > 0) +> -> Bitmap Index Scan on idx_timeseris (cost=0.00..48714.09 rows=10854026 width=0) +> Index Cond: (timeseriesid > 0) +> +> I'm hoping someone can explain the new query plan (as I'm not sure I +> understand what it is doing). + +Search for "bitmap" in the 8.1 Release Notes: + +http://developer.postgresql.org/docs/postgres/release.html#RELEASE-8-1 + +You could probably find more detailed discussion in the pgsql-hackers +archives. + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Fri Aug 26 12:40:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CBCDED79BC + for ; + Fri, 26 Aug 2005 12:17:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16234-03 + for ; + Fri, 26 Aug 2005 15:16:59 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A3115D7108 + for ; + Fri, 26 Aug 2005 12:16:55 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7QFGtGH009249; + Fri, 26 Aug 2005 11:16:55 -0400 (EDT) +To: stange@rentec.com +Cc: pgsql-performance@postgresql.org +Subject: Re: difference in plan between 8.0 and 8.1? +In-reply-to: <430F2AF3.1080704@rentec.com> +References: <430F2AF3.1080704@rentec.com> +Comments: In-reply-to Alan Stange + message dated "Fri, 26 Aug 2005 10:45:07 -0400" +Date: Fri, 26 Aug 2005 11:16:55 -0400 +Message-ID: <9248.1125069415@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/440 +X-Sequence-Number: 14187 + +Alan Stange writes: +> Unique (cost=2717137.08..2771407.21 rows=10854026 width=8) +> -> Sort (cost=2717137.08..2744272.14 rows=10854026 width=8) +> Sort Key: timeseriesid +> -> Bitmap Heap Scan on tbltimeseries +> (cost=48714.09..1331000.42 rows=10854026 width=8) +> Recheck Cond: (timeseriesid > 0) +> -> Bitmap Index Scan on idx_timeseris +> (cost=0.00..48714.09 rows=10854026 width=0) +> Index Cond: (timeseriesid > 0) +> (7 rows) + +> I'm hoping someone can explain the new query plan (as I'm not sure I +> understand what it is doing). + +The index scan is reading the index to find out which heap tuple IDs +(TIDs) the index says meet the condition. It returns a bitmap of the +tuple locations (actually, an array of per-page bitmaps). The heap +scan goes and fetches the tuples from the table, working in TID order +to avoid re-reading the same page many times, as can happen for ordinary +index scans. Since the result isn't sorted, we have to do a sort to get +it into the correct order for the Unique step. + +Because it avoids random access to the heap, this plan can be a lot +faster than a regular index scan. I'm not sure at all that 8.1 is +doing good relative cost estimation yet, though. It would be +interesting to see EXPLAIN ANALYZE results for both ways. (You can +use enable_bitmapscan and enable_indexscan to force the planner to pick +the plan it thinks is slower.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 26 12:43:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BD77D7822 + for ; + Fri, 26 Aug 2005 12:14:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15622-03 + for ; + Fri, 26 Aug 2005 15:14:15 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C018D7BAE + for ; + Fri, 26 Aug 2005 12:14:11 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 55so157146wri + for ; + Fri, 26 Aug 2005 08:14:11 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:date:from:to:subject:message-id:reply-to:mime-version:content-type:content-disposition:user-agent; + b=OjPL+4xlPi1NInDxjEedtv92kRT1jQBt4djtwtrAESZNIn3CP44vEAJI7HxPmqNRpZBcBSLHZJZpvjaym7lyVFRkoVYEWW1dSE7hss3by6+Ezv03zrN1ypGeqnRhe4AaZEpLjL2SCege2lyS98y/BS0x2uBKMKuWJEeWmEGIXMM= +Received: by 10.54.43.24 with SMTP id q24mr3448803wrq; + Fri, 26 Aug 2005 08:14:09 -0700 (PDT) +Received: from localhost ( [61.246.59.42]) + by mx.gmail.com with ESMTP id 43sm2981017wri.2005.08.26.08.14.04; + Fri, 26 Aug 2005 08:14:09 -0700 (PDT) +Date: Fri, 26 Aug 2005 20:54:09 +0530 +From: Ligesh +To: pgsql-performance@postgresql.org +Subject: Sending a select to multiple servers. +Message-ID: <20050826152409.GA22060@lxlabs.com> +Reply-To: gxlists@gmail.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/442 +X-Sequence-Number: 14189 + + + I would like to know if the following kind of database client exists: I need a 'select' query to be sent to say 10 db servers simultaneously in parallel (using threading), the results should be re-sorted and returned. For example I have a query: 'select * from table where parent_clname = 'parent' order by name limit 10'. Now this query has to be sent to 10 servers, and the maximum number of results would be 100. Now this 100 result set has to be re-sorted, out of which 90 has to be discarded, and the 10 has to be returned. + + Does such a solution exist now. To me this appears to be in entirety of what should constitute a database cluster. Only the search needs to be done on all the servers simultaneously at the low level. Once you get the results, the writing can be determined by the upper level logic (which can even be in a scripting language). But the search across many servers has to be done using proper threading, and the re-sorting also needs to be done fast. + + Thanks a lot in advance. + + +-- +:: Ligesh :: http://ligesh.com + + + +From pgsql-performance-owner@postgresql.org Fri Aug 26 12:49:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 29751D79CA + for ; + Fri, 26 Aug 2005 12:47:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21828-05 + for ; + Fri, 26 Aug 2005 15:46:57 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AADCFD79BC + for ; + Fri, 26 Aug 2005 12:46:55 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7QFkX2B009502; + Fri, 26 Aug 2005 11:46:33 -0400 (EDT) +To: Mark Kirkwood +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: Limit + group + join +In-reply-to: <430E85ED.60109@paradise.net.nz> +References: <20050826002709.GK10328@tobias.lan> + <430E85ED.60109@paradise.net.nz> +Comments: In-reply-to Mark Kirkwood + message dated "Fri, 26 Aug 2005 15:01:01 +1200" +Date: Fri, 26 Aug 2005 11:46:33 -0400 +Message-ID: <9501.1125071193@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/444 +X-Sequence-Number: 14191 + +Mark Kirkwood writes: +> What is interesting is why this plan is being rejected... + +Which PG version are you using exactly? That mistake looks like an +artifact of the 8.0 "fuzzy plan cost" patch, which we fixed recently: +http://archives.postgresql.org/pgsql-committers/2005-07/msg00474.php + +But Tobias wasn't happy with 7.4 either, so I'm not sure that the fuzzy +cost issue explains his results. + +As far as the "desc" point goes, the problem is that mergejoins aren't +capable of dealing with backward sort order, so a merge plan isn't +considered for that case (or at least, it would have to have a sort +after it, which pretty much defeats the point for a fast-start plan). +I have some ideas about fixing this but it won't happen before 8.2. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 26 13:06:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 150FBD7B30 + for ; + Fri, 26 Aug 2005 13:04:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25173-10 + for ; + Fri, 26 Aug 2005 16:04:22 +0000 (GMT) +Received: from frank.wiles.org (frank.wiles.org [24.124.39.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B0A8D7B06 + for ; + Fri, 26 Aug 2005 13:04:21 -0300 (ADT) +Received: from kungfu (frank.wiles.org [127.0.0.1]) + by frank.wiles.org (8.13.1/8.13.1) with SMTP id j7QG4HPW004397; + Fri, 26 Aug 2005 11:04:17 -0500 +Date: Fri, 26 Aug 2005 11:04:59 -0500 +From: Frank Wiles +To: gxlists@gmail.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Sending a select to multiple servers. +Message-Id: <20050826110459.03cce4d9.frank@wiles.org> +In-Reply-To: <20050826152409.GA22060@lxlabs.com> +References: <20050826152409.GA22060@lxlabs.com> +X-Mailer: Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-redhat-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.019 required=5 tests=[AWL=0.019] +X-Spam-Level: +X-Archive-Number: 200508/445 +X-Sequence-Number: 14192 + +On Fri, 26 Aug 2005 20:54:09 +0530 +Ligesh wrote: + +> +> I would like to know if the following kind of database client exists: +> I need a 'select' query to be sent to say 10 db servers +> simultaneously in parallel (using threading), the results should be +> re-sorted and returned. For example I have a query: 'select * from +> table where parent_clname = 'parent' order by name limit 10'. Now +> this query has to be sent to 10 servers, and the maximum number of +> results would be 100. Now this 100 result set has to be re-sorted, +> out of which 90 has to be discarded, and the 10 has to be returned. +> +> Does such a solution exist now. To me this appears to be in entirety +> of what should constitute a database cluster. Only the search needs +> to be done on all the servers simultaneously at the low level. Once +> you get the results, the writing can be determined by the upper level +> logic (which can even be in a scripting language). But the search +> across many servers has to be done using proper threading, and the +> re-sorting also needs to be done fast. + + This is typically handled by the application layer, not a standard + client. Mostly because every situation is different, you may have + 10 servers and need 10 rows of results, others may need something + entirely different. + + This isn't really a "cluster" either. In a clustered environment + you would send the one query to any of the 10 servers and it would + return the proper results. + + But like I said this type of application is fairly trivial to write + in most scripting or higher level languages. + + --------------------------------- + Frank Wiles + http://www.wiles.org + --------------------------------- + + +From pgsql-performance-owner@postgresql.org Fri Aug 26 13:12:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CCF36D79D2 + for ; + Fri, 26 Aug 2005 13:11:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29863-02 + for ; + Fri, 26 Aug 2005 16:11:21 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id AD0D7D79BC + for ; + Fri, 26 Aug 2005 13:11:19 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Sending a select to multiple servers. +Date: Fri, 26 Aug 2005 12:11:18 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD1F8@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Sending a select to multiple servers. +Thread-Index: AcWqVXd3ATuMkienQpK/MSZ5pFjdQAAAmLrw +From: "Merlin Moncure" +To: +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/446 +X-Sequence-Number: 14193 + +> Does such a solution exist now. To me this appears to be in entirety +of +> what should constitute a database cluster. Only the search needs to be +> done on all the servers simultaneously at the low level. Once you get +the +> results, the writing can be determined by the upper level logic (which +can +> even be in a scripting language). But the search across many servers +has +> to be done using proper threading, and the re-sorting also needs to be +> done fast. + +Well the fastest way would be to write a libpq wrapper, personally I +would choose C++ for extreme performance. STL bring super fast sorting +to the table and will make dealing with ExecParams/ExecPrepared a little +bit easier. To make available from scripting languages you need to make +C wrappers for interface functions and build in a shared library. + +You could use any of a number of high level scripting languages but +performance will not be as good. YMMV. + +Antother interesting take on this problem would be to use dblink +contrib. module. Check that out and see if it can meet your needs. + +Merlin + +From pgsql-performance-owner@postgresql.org Fri Aug 26 13:28:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B9DDDD791C + for ; + Fri, 26 Aug 2005 13:28:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32381-04 + for ; + Fri, 26 Aug 2005 16:28:04 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id BC865D7745 + for ; + Fri, 26 Aug 2005 13:28:02 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 7133B1529A; Fri, 26 Aug 2005 11:28:02 -0500 (CDT) +Date: Fri, 26 Aug 2005 11:28:02 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Mark Fox , pgsql-performance@postgresql.org +Subject: Re: Performance indexing of a simple query +Message-ID: <20050826162801.GF11282@pervasive.com> +References: + <16554.1124926920@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <16554.1124926920@sss.pgh.pa.us> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] +X-Spam-Level: +X-Archive-Number: 200508/447 +X-Sequence-Number: 14194 + +On Wed, Aug 24, 2005 at 07:42:00PM -0400, Tom Lane wrote: +> Mark Fox writes: +> > The sort of queries I want to execute (among others) are like: +> > SELECT * FROM jobs +> > WHERE completion_time > SOMEDATE AND start_time < SOMEDATE; +> > In plain english: All the jobs that were running at SOMEDATE. + +Uh, the plain english and the SQL don't match. That query will find +every job that was NOT running at the time you said. + +> AFAIK there is no good way to do this with btree indexes; the problem +> is that it's fundamentally a 2-dimensional query and btrees are +> 1-dimensional. There are various hacks you can try if you're willing +> to constrain the problem (eg, if you can assume some not-very-large +> maximum on the running time of jobs) but in full generality btrees are +> just the Wrong Thing. + +Ignoring the SQL and doing what the author actually wanted, wouldn't a +bitmap combination of indexes work here? + +Or with an index on (start_time, completion_time), start an index scan +at start_time = SOMEDATE and only include rows where completion_time < +SOMEDATE. Of course if SOMEDATE is near the beginning of the table that +wouldn't help. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri Aug 26 15:12:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 02277D7738 + for ; + Fri, 26 Aug 2005 15:12:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52406-10 + for ; + Fri, 26 Aug 2005 18:12:51 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B5EBD6FEF + for ; + Fri, 26 Aug 2005 13:42:45 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7QGgf4t009942; + Fri, 26 Aug 2005 12:42:41 -0400 (EDT) +To: "Jim C. Nasby" +Cc: Mark Fox , pgsql-performance@postgresql.org +Subject: Re: Performance indexing of a simple query +In-reply-to: <20050826162801.GF11282@pervasive.com> +References: + <16554.1124926920@sss.pgh.pa.us> + <20050826162801.GF11282@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Fri, 26 Aug 2005 11:28:02 -0500" +Date: Fri, 26 Aug 2005 12:42:41 -0400 +Message-ID: <9941.1125074561@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/448 +X-Sequence-Number: 14195 + +"Jim C. Nasby" writes: +> Uh, the plain english and the SQL don't match. That query will find +> every job that was NOT running at the time you said. + +No, I think it was right. But anyway it was just an example. + +> On Wed, Aug 24, 2005 at 07:42:00PM -0400, Tom Lane wrote: +>> AFAIK there is no good way to do this with btree indexes; the problem +>> is that it's fundamentally a 2-dimensional query and btrees are +>> 1-dimensional. There are various hacks you can try if you're willing +>> to constrain the problem (eg, if you can assume some not-very-large +>> maximum on the running time of jobs) but in full generality btrees are +>> just the Wrong Thing. + +> Ignoring the SQL and doing what the author actually wanted, wouldn't a +> bitmap combination of indexes work here? + +> Or with an index on (start_time, completion_time), start an index scan +> at start_time = SOMEDATE and only include rows where completion_time < +> SOMEDATE. Of course if SOMEDATE is near the beginning of the table that +> wouldn't help. + +The trouble with either of those is that you have to scan very large +fractions of the index (if not indeed *all* of it) in order to get your +answer; certainly you hit much more of the index than just the region +containing matching rows. Btree just doesn't have a good way to answer +this type of query. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 26 15:58:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 286B8D7A57 + for ; + Fri, 26 Aug 2005 15:58:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64213-09 + for ; + Fri, 26 Aug 2005 18:58:20 +0000 (GMT) +Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) + by svr1.postgresql.org (Postfix) with ESMTP id 080C2D799D + for ; + Fri, 26 Aug 2005 15:58:18 -0300 (ADT) +Received: from jefftrout.com ([24.147.120.205]) + by comcast.net (sccrmhc11) with SMTP + id <2005082618581801100ljhn4e>; Fri, 26 Aug 2005 18:58:19 +0000 +Received: (qmail 87348 invoked from network); 26 Aug 2005 18:59:14 -0000 +Received: from c-24-147-120-205.hsd1.ma.comcast.net (HELO ?192.168.0.106?) + (24.147.120.205) + by 192.168.0.109 with SMTP; 26 Aug 2005 18:59:14 -0000 +Mime-Version: 1.0 (Apple Message framework v733) +Content-Transfer-Encoding: 7bit +Message-Id: +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: postgres performance +From: Jeff Trout +Subject: OSX & Performance +Date: Fri, 26 Aug 2005 14:58:17 -0400 +X-Mailer: Apple Mail (2.733) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/449 +X-Sequence-Number: 14196 + +Well folks, I've been trying to track down why this Athlon 2800 +(2.1ghz) has been handing my 2.5ghz G5 its cake. I have a query that +(makes no io - the dataset can live in ram easily) takes about 700ms +on the athlon and about 10 seconds on the G5. + +Tracking ti down a bit timestamp_cmp_internal (The btree was made of +a timestamp & and int) was taking a large amount of time - +specifically all the calls it makes to isnan(x). 14.1% in __isnand +(which is the libSystem function & guts, which according to the +darwin source copies the double to memory and accesses it as 2 ints +looking for a specific pattern). (For reference, the other top +functions are _bt_checkkeys at 30%, FunctionCall2 at 15.8% , _bt_step +at 9% and _bt_first at 7%) . + +Talking to some of the mac super guru's on irc they said the problem +is how the Mach-O ABI works, basically you get kicked in the nuts for +accessing global or static data (like those constants __isnand +uses). (You can read http://www.unsanity.org/archives/000044.php for +a touch of info on it). + +I think given the function-call-rich arch of PG may make its +performance on OSX always lower than other counterparts. Especially +things like that __isnand. + +I'm going to be doing a couple experiments: 1. making an inline +version of isnan to see how that improves performance 2. Trying it +out on linux ppc to see how it runs. It may be worth noting these +in the docs or faq somewhere. + +Also, two things to note, one of which is quite important: On tiger +(10.4) PG compiles with NO OPTIMIZATION. Probably a template file +needs to be updated. +Panther seems to compile with -O2 though. + +If you want to profile PG on Tiger do not use gprof - it seems to be +broken. I get func call #s, but no timing data. Instead you can do +something even better - compile PG normally and attach to it with +Shark (Comes with the CHUD tools) and check out its profile. Quite +slick actually :) + +I'll keep people updated on my progress, but I just wanted to get +these issues out in the air. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + + +From pgsql-performance-owner@postgresql.org Fri Aug 26 16:02:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BE3AD7C75 + for ; + Fri, 26 Aug 2005 16:02:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67688-01 + for ; + Fri, 26 Aug 2005 19:02:02 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 79ADAD7C19 + for ; + Fri, 26 Aug 2005 16:02:00 -0300 (ADT) +Received: from wren.rentec.com (wren.rentec.com [192.5.35.106]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j7QJ1tEv022223 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Fri, 26 Aug 2005 15:01:58 -0400 (EDT) +X-Rentec: external +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by wren.rentec.com (8.13.1/8.12.1) with ESMTP id j7QJ1tPg017724; + Fri, 26 Aug 2005 15:01:55 -0400 (EDT) +Message-ID: <430F6723.5050505@rentec.com> +Date: Fri, 26 Aug 2005 15:01:55 -0400 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 1.0+ (X11/20050712) +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: difference in plan between 8.0 and 8.1? +References: <430F2AF3.1080704@rentec.com> <9248.1125069415@sss.pgh.pa.us> +In-Reply-To: <9248.1125069415@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as j7QJ1tEv022223 at Fri Aug 26 + 15:01:58 2005 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.017 required=5 tests=[AWL=0.017] +X-Spam-Level: +X-Archive-Number: 200508/450 +X-Sequence-Number: 14197 + +Tom Lane wrote: +> Alan Stange writes: +> +>> Unique (cost=2717137.08..2771407.21 rows=10854026 width=8) +>> -> Sort (cost=2717137.08..2744272.14 rows=10854026 width=8) +>> Sort Key: timeseriesid +>> -> Bitmap Heap Scan on tbltimeseries +>> (cost=48714.09..1331000.42 rows=10854026 width=8) +>> Recheck Cond: (timeseriesid > 0) +>> -> Bitmap Index Scan on idx_timeseris +>> (cost=0.00..48714.09 rows=10854026 width=0) +>> Index Cond: (timeseriesid > 0) +>> (7 rows) +>> +> +> +>> I'm hoping someone can explain the new query plan (as I'm not sure I +>> understand what it is doing). +>> +> +> The index scan is reading the index to find out which heap tuple IDs +> (TIDs) the index says meet the condition. It returns a bitmap of the +> tuple locations (actually, an array of per-page bitmaps). The heap +> scan goes and fetches the tuples from the table, working in TID order +> to avoid re-reading the same page many times, as can happen for ordinary +> index scans. Since the result isn't sorted, we have to do a sort to get +> it into the correct order for the Unique step. +> +> Because it avoids random access to the heap, this plan can be a lot +> faster than a regular index scan. I'm not sure at all that 8.1 is +> doing good relative cost estimation yet, though. It would be +> interesting to see EXPLAIN ANALYZE results for both ways. (You can +> use enable_bitmapscan and enable_indexscan to force the planner to pick +> the plan it thinks is slower.) +Just to be clear. The index is on the timeseriesid column. Also, We +usually have the where clause with some non-zero number. + +Anyway, here's the basic query, with variations added on belowe: + +fiasco=# explain analyze select timeseriesid from tbltimeseries where +timeseriesid > 0; + QUERY +PLAN +------------------------------------------------------------------------------------------------------------------------------------------------ + Bitmap Heap Scan on tbltimeseries (cost=48906.82..1332935.19 +rows=10905949 width=8) (actual time=16476.337..787480.979 rows=10907853 +loops=1) + Recheck Cond: (timeseriesid > 0) + -> Bitmap Index Scan on idx_timeseris (cost=0.00..48906.82 +rows=10905949 width=0) (actual time=16443.585..16443.585 rows=10907853 +loops=1) + Index Cond: (timeseriesid > 0) + Total runtime: 791340.341 ms +(5 rows) + + + +Now add the order: + +fiasco=# explain analyze select timeseriesid from tbltimeseries where +timeseriesid > 0 order by timeseriesid; + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------ + Sort (cost=2726087.93..2753352.81 rows=10905949 width=8) (actual +time=821090.666..826353.054 rows=10913868 loops=1) + Sort Key: timeseriesid + -> Bitmap Heap Scan on tbltimeseries (cost=48912.82..1332941.19 +rows=10905949 width=8) (actual time=16353.921..757075.349 rows=10913868 +loops=1) + Recheck Cond: (timeseriesid > 0) + -> Bitmap Index Scan on idx_timeseris (cost=0.00..48912.82 +rows=10905949 width=0) (actual time=16335.239..16335.239 rows=10913868 +loops=1) + Index Cond: (timeseriesid > 0) + Total runtime: 830829.145 ms +(7 rows) + + + + +and the distinct: + +fiasco=# explain analyze select distinct timeseriesid from tbltimeseries +where timeseriesid > 0 order by timeseriesid; + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------ + Unique (cost=2726087.93..2780617.68 rows=10905949 width=8) (actual +time=816938.970..831119.423 rows=10913868 loops=1) + -> Sort (cost=2726087.93..2753352.81 rows=10905949 width=8) (actual +time=816938.967..822298.802 rows=10913868 loops=1) + Sort Key: timeseriesid + -> Bitmap Heap Scan on tbltimeseries +(cost=48912.82..1332941.19 rows=10905949 width=8) (actual +time=15866.736..752851.006 rows=10913868 loops=1) + Recheck Cond: (timeseriesid > 0) + -> Bitmap Index Scan on idx_timeseris +(cost=0.00..48912.82 rows=10905949 width=0) (actual +time=15852.652..15852.652 rows=10913868 loops=1) + Index Cond: (timeseriesid > 0) + Total runtime: 835558.312 ms +(8 rows) + + + + +Now the usual query from 8.0: + +fiasco=# set enable_bitmapscan=false; explain analyze select distinct +timeseriesid from tbltimeseries where timeseriesid > 0 order by +timeseriesid; +SET + +QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------------- + Unique (cost=0.00..14971276.10 rows=10905949 width=8) (actual +time=24.930..999645.638 rows=10913868 loops=1) + -> Index Scan using idx_timeseris on tbltimeseries +(cost=0.00..14944011.22 rows=10905949 width=8) (actual +time=24.926..989117.882 rows=10913868 loops=1) + Index Cond: (timeseriesid > 0) + Total runtime: 1003549.067 ms +(4 rows) + + + + +And now a sequential scan of the table itself: + +fiasco=# set enable_bitmapscan=false; set enable_indexscan=false; +explain analyze select distinct timeseriesid from tbltimeseries where +timeseriesid > 0 order by timeseriesid; +SET +SET + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------ + Unique (cost=102677188.75..102731718.49 rows=10905949 width=8) (actual +time=956783.989..971036.657 rows=10919883 loops=1) + -> Sort (cost=102677188.75..102704453.62 rows=10905949 width=8) +(actual time=956783.985..962115.616 rows=10919883 loops=1) + Sort Key: timeseriesid + -> Seq Scan on tbltimeseries (cost=100000000.00..101284042.00 +rows=10905949 width=8) (actual time=7.314..893267.030 rows=10919883 loops=1) + Filter: (timeseriesid > 0) + Total runtime: 975393.678 ms +(6 rows) + + +For us, the query is best served by the index scan as the ordering comes +for free and results can be streamed to a client immediately. So, while +the whole query is a bit slower, the client can begin processing the +results immediately. The client has three threads which stream in two +sets of id's and emit delete statements in smaller batches. It can be +done as one statement, but on our production system that statement can +run for 10 hours and delete 20M rows...which conflicts with the vacuum +process. This version can be throttled, stopped and restarted at any +time and no work is lost compared to a single long running query. + +From pgsql-performance-owner@postgresql.org Fri Aug 26 17:15:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 09F8ED7CC7 + for ; + Fri, 26 Aug 2005 17:14:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83212-01 + for ; + Fri, 26 Aug 2005 20:14:18 +0000 (GMT) +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.201]) + by svr1.postgresql.org (Postfix) with ESMTP id C1342D7CC5 + for ; + Fri, 26 Aug 2005 17:14:17 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 8so371206nzo + for ; + Fri, 26 Aug 2005 13:14:18 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=r2aY7OCC0toXKqqtLEzpZOItKZN991cIl7ZU/NdOkrAhE/+1zU3VrgCDWXtE8WwPoIHb20B8sfr6rRWwO7u7ZqEvi5M5HvWRfaQBFchUpY5tR4v6siKNVxFhdrL+97L2ZEtXOpLPRsh87AAMyVAesOoW2JodGXcNm2KcFJisPJY= +Received: by 10.36.250.44 with SMTP id x44mr300895nzh; + Fri, 26 Aug 2005 13:14:18 -0700 (PDT) +Received: by 10.36.24.2 with HTTP; Fri, 26 Aug 2005 13:14:18 -0700 (PDT) +Message-ID: <1d219a6f0508261314516fdb0@mail.gmail.com> +Date: Fri, 26 Aug 2005 16:14:18 -0400 +From: Chris Hoover +To: pgsql-performance@postgresql.org +Subject: How does the planner execute unions? +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/451 +X-Sequence-Number: 14198 + +Hopefully a quick question. + +In 7.3.4, how does the planner execute a query with union alls in it? + +Does it execute the unions serially, or does it launch a "thread" for +each union (or maybe something else entirely). + +Thanks, + +Chris + +Here is an explain from the view I'm thinking about, how does postgres +run this query? +hmd=3D# explain select count(1) from clmhdr where hdr_user_id =3D 'user_id'= +; + QUERY PLAN +---------------------------------------------------------------------------= +------------------------------------------------------------- + Aggregate (cost=3D42.48..42.48 rows=3D1 width=3D924) + -> Subquery Scan clmhdr (cost=3D0.00..42.41 rows=3D30 width=3D924) + -> Append (cost=3D0.00..42.41 rows=3D30 width=3D924) + -> Subquery Scan "*SELECT* 1" (cost=3D0.00..7.07 rows=3D5 +width=3D924) + -> Index Scan using +clmhdr_live_hdr_user_id_hdr_clm_status_idx on clmhdr_live=20 +(cost=3D0.00..7.07 rows=3D5 width=3D924) + Index Cond: (hdr_user_id =3D +'user_id'::character varying) + -> Subquery Scan "*SELECT* 2" (cost=3D0.00..7.07 rows=3D5 +width=3D924) + -> Index Scan using +clmhdr_2003_hdr_user_id_hdr_clm_status_idx on clmhdr_2003=20 +(cost=3D0.00..7.07 rows=3D5 width=3D924) + Index Cond: (hdr_user_id =3D +'user_id'::character varying) + -> Subquery Scan "*SELECT* 3" (cost=3D0.00..7.07 rows=3D5 +width=3D924) + -> Index Scan using +clmhdr_2004_hdr_user_id_hdr_clm_status_idx on clmhdr_2004=20 +(cost=3D0.00..7.07 rows=3D5 width=3D924) + Index Cond: (hdr_user_id =3D +'user_id'::character varying) + -> Subquery Scan "*SELECT* 4" (cost=3D0.00..7.07 rows=3D5 +width=3D924) + -> Index Scan using +clmhdr_2005_hdr_user_id_hdr_clm_status_idx on clmhdr_2005=20 +(cost=3D0.00..7.07 rows=3D5 width=3D924) + Index Cond: (hdr_user_id =3D +'user_id'::character varying) + -> Subquery Scan "*SELECT* 5" (cost=3D0.00..7.07 rows=3D5 +width=3D924) + -> Index Scan using +clmhdr_2006_hdr_user_id_hdr_clm_status_idx on clmhdr_2006=20 +(cost=3D0.00..7.07 rows=3D5 width=3D924) + Index Cond: (hdr_user_id =3D +'user_id'::character varying) + -> Subquery Scan "*SELECT* 6" (cost=3D0.00..7.07 rows=3D5 +width=3D924) + -> Index Scan using +clmhdr_2007_hdr_user_id_hdr_clm_status_idx on clmhdr_2007=20 +(cost=3D0.00..7.07 rows=3D5 width=3D924) + Index Cond: (hdr_user_id =3D +'user_id'::character varying) +(21 rows) + +hmd=3D# + +From pgsql-performance-owner@postgresql.org Fri Aug 26 17:46:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ECB61D6FEB + for ; + Fri, 26 Aug 2005 17:46:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86282-07 + for ; + Fri, 26 Aug 2005 20:46:16 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.197.194]) + by svr1.postgresql.org (Postfix) with SMTP id CA87ED7CF0 + for ; + Fri, 26 Aug 2005 17:46:15 -0300 (ADT) +Received: (qmail 11667 invoked by uid 500); 26 Aug 2005 20:45:54 -0000 +Date: Fri, 26 Aug 2005 15:45:54 -0500 +From: Bruno Wolff III +To: Chris Hoover +Cc: pgsql-performance@postgresql.org +Subject: Re: How does the planner execute unions? +Message-ID: <20050826204554.GB11078@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Chris Hoover , pgsql-performance@postgresql.org +References: <1d219a6f0508261314516fdb0@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1d219a6f0508261314516fdb0@mail.gmail.com> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/452 +X-Sequence-Number: 14199 + +On Fri, Aug 26, 2005 at 16:14:18 -0400, + Chris Hoover wrote: +> Hopefully a quick question. +> +> In 7.3.4, how does the planner execute a query with union alls in it? +> +> Does it execute the unions serially, or does it launch a "thread" for +> each union (or maybe something else entirely). + +Postgres doesn't have parallel execution of parts of queries. So it is +going to do one part followed by the other part. + +From pgsql-performance-owner@postgresql.org Fri Aug 26 18:19:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D91D5D7A18 + for ; + Fri, 26 Aug 2005 18:16:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95746-03 + for ; + Fri, 26 Aug 2005 21:16:09 +0000 (GMT) +Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) + by svr1.postgresql.org (Postfix) with ESMTP id F19F4D79C5 + for ; + Fri, 26 Aug 2005 18:16:08 -0300 (ADT) +Received: from [10.0.0.2] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) + by olive.qinip.net (Postfix) with ESMTP + id 77DC918153; Fri, 26 Aug 2005 23:16:06 +0200 (MEST) +Message-ID: <430F8699.3030400@tweakers.net> +Date: Fri, 26 Aug 2005 23:16:09 +0200 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: pgsql-performance@postgresql.org +Subject: Re: Inefficient queryplan for query with intersectable +References: <430EF844.70905@tweakers.net> <430F1393.5040704@archonet.com> +In-Reply-To: <430F1393.5040704@archonet.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/453 +X-Sequence-Number: 14200 + +On 26-8-2005 15:05, Richard Huxton wrote: +> Arjen van der Meijden wrote: +> +>> +>> I left all the configuration-stuff to the defaults since changing +>> values didn't seem to impact much. Apart from the buffers and +>> effective cache, increasing those made the performance worse. +> +> +> I've not looked at the rest of your problem in detail, but using the +> default configuration values is certainly not going to help things. In +> particular effective_cache is supposed to tell PG how much memory your +> OS is using to cache data. +> +> Read this through and make sure your configuration settings are sane, +> then it might be worthwhile looking in detail at this particular query. +> http://www.powerpostgresql.com/PerfList + +Thanks for the advice. But as said, I tried such things. Adjusting +shared buffers to 5000, 10000 or 15000 made minor improvements. +But adjusting the effective_cache was indeed very dramatic, to make +matters worse! +Changing the random_page_cost to 2.0 also made it choose another plan, +but still not the fast plan. + +The machine has 1GB of memory, so I tested for effective cache size +10000, 20000, 40000, 60000 and 80000. The "600ms"-plan I'm talking about +will not come up with an effective cache set to 60000 or above and for +the lower values there was no improvement in performance over that +already very fast plan. +As said, it chooses sequential scans or "the wrong index plans" over a +perfectly good plan that is just not selected when the parameters are +"too well tuned" or sequential scanning of the table is allowed. + +So I'm still looking for a way to get it to use the fast plan, instead +of the slower ones that appear when I tend to tune the database... + + +From pgsql-performance-owner@postgresql.org Fri Aug 26 19:04:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A3504D7D2A + for ; + Fri, 26 Aug 2005 19:04:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05914-03 + for ; + Fri, 26 Aug 2005 22:04:27 +0000 (GMT) +Received: from kartal.liqia.com (unknown [65.254.45.184]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B875D7D30 + for ; + Fri, 26 Aug 2005 19:04:24 -0300 (ADT) +Received: from [81.215.232.82] (helo=[10.0.0.201]) + by kartal.liqia.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1E8mJC-0007WZ-R2 + for ; Sat, 27 Aug 2005 01:04:25 +0300 +Subject: Weird performance drop after VACUUM +From: =?ISO-8859-1?Q?=DCmit_=D6ztosun?= +To: pgsql-performance@postgresql.org +Content-Type: multipart/mixed; boundary="=-MRyV2tcUtXWirnwXOIJ6" +Date: Sat, 27 Aug 2005 01:04:19 +0300 +Message-Id: <1125093859.9329.30.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/454 +X-Sequence-Number: 14201 + + +--=-MRyV2tcUtXWirnwXOIJ6 +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +Hello, + +We are using PostgreSQL for our business application. Recently, during +testing of our application with large volumes of data, we faced a weird +problem. Our query performance dropped *dramatically* after "VACUUM FULL +ANALYZE" command. We have encountered a similar problem listed on +mailing list archives, but the submitter solved his problem by rewriting +his query, which is unfortunatelly very hard for us. + +I am attaching two EXPLAIN ANALYZE outputs, first one is just before the +VACUUM FULL ANALYZE command and the other is the one after. Also +attached is the SQL query, which is simplified to clearify the problem. +In the example query time increases from 1.8 second to > 4.0 secons. The +difference for the complete query is much bigger, query time increases +from 7.8 seconds to > 110 seconds. + +Any help is appreciated, we were unable to identify what causes the +query planner to choose a different/poor performing plan. + +Notes: +Our production platform is Ubuntu Linux Hoary on i386, PostgreSQL 8.0.3, +compiled from sources. Same tests were carried on Windows XP +Professional and PostgreSQL 8.0.1 with similar results. The queries use +little IO, high CPU. The largest table involved in the sample query has +about 10000 rows. Indexes are used intensively, some tables use > 4 +indexes. + +Best regards, +Umit Oztosun + + +--=-MRyV2tcUtXWirnwXOIJ6 +Content-Disposition: attachment; filename=query.sql +Content-Type: text/x-sql; name=query.sql; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +SELECT * FROM ( + SELECT + COALESCE ( + (SELECT COALESCE (sum(irskal.anamiktar), 0) + * (SELECT + birim.fiyat2 * (SELECT kur1 + FROM sis_doviz_kuru kur + WHERE birim._key_sis_doviz2 = kur._key_sis_doviz + ORDER BY tarih desc + LIMIT 1) + FROM scf_stokkart_birimleri birim + WHERE _key_scf_stokkart = stok._key + AND anabirim = '1' + ) + FROM scf_irsaliye irs, scf_irsaliye_kalemi irskal + WHERE irskal._key_kalemturu = stok._key + AND irskal._key_scf_irsaliye = irs._key + AND irs.karsifirma = 'KENDI' + AND (irs.turu='MAI' OR irs.turu='KGI' OR irs.turu='PS' OR irs.turu='TS' OR irs.turu='KC' OR irs.turu='KCO') + AND ( irs._key_sis_depo_dest = '$$$$0000003l$1$$' OR irs._key_sis_depo_dest = '$$$$00000048$1$$' OR irs._key_sis_depo_dest = '$$$$0000004b$1$$' OR irs._key_sis_depo_dest = '$$$$0000004d$1$$' ) + AND ((irskal._key LIKE '0000%' OR irskal._key LIKE '0101%' OR irskal._key LIKE '$$%')) + AND irs.tarih <= '2005-08-26' + ), 0 + ) as arti_fiili_irs_karsifirma, + stok.* + FROM scf_stokkart stok +) AS _SWT WHERE (_key LIKE '00%' OR _key LIKE '01%' OR _key LIKE '$$%') ORDER BY _key desc + +--=-MRyV2tcUtXWirnwXOIJ6 +Content-Disposition: attachment; filename=before_vacuum.txt +Content-Type: text/plain; name=before_vacuum.txt; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Before VACUUM FULL ANALYZE - Short Query +--------------------------------------- +Sort (cost=9094.31..9094.40 rows=37 width=817) (actual time=1852.799..1877.738 rows=10000 loops=1) + Sort Key: stok._key + -> Seq Scan on scf_stokkart stok (cost=0.00..9093.34 rows=37 width=817) (actual time=8.670..1575.586 rows=10000 loops=1) + Filter: (((_key)::text ~~ '00%'::text) OR ((_key)::text ~~ '01%'::text) OR ((_key)::text ~~ '$$%'::text)) + SubPlan + -> Aggregate (cost=237.29..237.29 rows=1 width=16) (actual time=0.136..0.138 rows=1 loops=10000) + InitPlan + -> Index Scan using scf_stokkart_birimleri_key_scf_stokkart_idx on scf_stokkart_birimleri birim (cost=0.00..209.59 rows=1 width=58) (actual time=0.088..0.093 rows=1 loops=10000) + Index Cond: ((_key_scf_stokkart)::text = ($1)::text) + Filter: (anabirim = '1'::bpchar) + SubPlan + -> Limit (cost=9.31..9.31 rows=1 width=17) (actual time=0.046..0.048 rows=1 loops=10000) + -> Sort (cost=9.31..9.31 rows=2 width=17) (actual time=0.041..0.041 rows=1 loops=10000) + Sort Key: tarih + -> Index Scan using sis_doviz_kuru_key_sis_doviz_idx on sis_doviz_kuru kur (cost=0.00..9.30 rows=2 width=17) (actual time=0.018..0.029 rows=2 loops=10000) + Index Cond: (($0)::text = (_key_sis_doviz)::text) + -> Nested Loop (cost=0.00..27.69 rows=1 width=16) (actual time=0.033..0.033 rows=0 loops=10000) + -> Index Scan using scf_irsaliye_kalemi_key_kalemturu_idx on scf_irsaliye_kalemi irskal (cost=0.00..21.75 rows=1 width=58) (actual time=0.017..0.020 rows=0 loops=10000) + Index Cond: ((_key_kalemturu)::text = ($1)::text) + Filter: (((_key)::text ~~ '0000%'::text) OR ((_key)::text ~~ '0101%'::text) OR ((_key)::text ~~ '$$%'::text)) + -> Index Scan using scf_irsaliye_pkey on scf_irsaliye irs (cost=0.00..5.94 rows=1 width=42) (actual time=0.021..0.021 rows=0 loops=3000) + Index Cond: (("outer"._key_scf_irsaliye)::text = (irs._key)::text) + Filter: (((karsifirma)::text = 'KENDI'::text) AND (((turu)::text = 'MAI'::text) OR ((turu)::text = 'KGI'::text) OR ((turu)::text = 'PS'::text) OR ((turu)::text = 'TS'::text) OR ((turu)::text = 'KC'::text) OR ((turu)::text = 'KCO'::text)) AND (((_key_sis_depo_dest)::text = '$$$$0000003l$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$00000048$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$0000004b$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$0000004d$1$$'::text)) AND (tarih <= '2005-08-26'::date)) +Total runtime: 1899.533 ms + +--=-MRyV2tcUtXWirnwXOIJ6 +Content-Disposition: attachment; filename=after_vacuum.txt +Content-Type: text/plain; name=after_vacuum.txt; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +After VACUUM FULL ANALYZE - Short Query +--------------------------------------- +Index Scan Backward using scf_stokkart_pkey on scf_stokkart stok (cost=0.00..392045.63 rows=9998 width=166) (actual time=0.661..4431.568 rows=10000 loops=1) + Filter: (((_key)::text ~~ '00%'::text) OR ((_key)::text ~~ '01%'::text) OR ((_key)::text ~~ '$$%'::text)) + SubPlan + -> Aggregate (cost=39.16..39.16 rows=1 width=10) (actual time=0.416..0.418 rows=1 loops=10000) + InitPlan + -> Index Scan using scf_stokkart_birimleri_key_scf_stokkart_idx on scf_stokkart_birimleri birim (cost=0.00..5.25 rows=2 width=28) (actual time=0.101..0.105 rows=1 loops=10000) + Index Cond: ((_key_scf_stokkart)::text = ($1)::text) + Filter: (anabirim = '1'::bpchar) + SubPlan + -> Limit (cost=1.08..1.09 rows=1 width=15) (actual time=0.048..0.050 rows=1 loops=10000) + -> Sort (cost=1.08..1.09 rows=2 width=15) (actual time=0.043..0.043 rows=1 loops=10000) + Sort Key: tarih + -> Seq Scan on sis_doviz_kuru kur (cost=0.00..1.07 rows=2 width=15) (actual time=0.009..0.026 rows=2 loops=10000) + Filter: (($0)::text = (_key_sis_doviz)::text) + -> Nested Loop (cost=0.00..33.90 rows=1 width=10) (actual time=0.295..0.295 rows=0 loops=10000) + -> Seq Scan on scf_irsaliye irs (cost=0.00..30.00 rows=1 width=20) (actual time=0.290..0.290 rows=0 loops=10000) + Filter: (((karsifirma)::text = 'KENDI'::text) AND (((turu)::text = 'MAI'::text) OR ((turu)::text = 'KGI'::text) OR ((turu)::text = 'PS'::text) OR ((turu)::text = 'TS'::text) OR ((turu)::text = 'KC'::text) OR ((turu)::text = 'KCO'::text)) AND (((_key_sis_depo_dest)::text = '$$$$0000003l$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$00000048$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$0000004b$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$0000004d$1$$'::text)) AND (tarih <= '2005-08-26'::date)) + -> Index Scan using scf_irsaliye_kalemi_key_scf_irsaliye_idx on scf_irsaliye_kalemi irskal (cost=0.00..3.89 rows=1 width=30) (never executed) + Index Cond: ((irskal._key_scf_irsaliye)::text = ("outer"._key)::text) + Filter: (((_key_kalemturu)::text = ($1)::text) AND (((_key)::text ~~ '0000%'::text) OR ((_key)::text ~~ '0101%'::text) OR ((_key)::text ~~ '$$%'::text))) +Total runtime: 4456.895 ms + +--=-MRyV2tcUtXWirnwXOIJ6-- + + +From pgsql-performance-owner@postgresql.org Fri Aug 26 19:35:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F3F58D7D2F + for ; + Fri, 26 Aug 2005 19:35:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11841-08 + for ; + Fri, 26 Aug 2005 22:35:40 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.197]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B611D7D2B + for ; + Fri, 26 Aug 2005 19:35:39 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i21so295550wra + for ; + Fri, 26 Aug 2005 15:35:42 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:date:from:to:cc:subject:message-id:reply-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; + b=nl1D+2AeOgBzCkmkbbMvMQyFQScsF8O6c1VvG724bHpQxQjFFyte9/f50BgPdIhDxgb0ADXKclrs2NBt8x+wENPW+VZG6vLrOoBtz5aXWqzte7+QuFb5ShgyMauPKzT0uDSI64l3Z4+FcGcefmtrT24fgxu2iOyi/qi0Dqf8sv4= +Received: by 10.54.32.62 with SMTP id f62mr1536730wrf; + Fri, 26 Aug 2005 15:35:42 -0700 (PDT) +Received: from localhost ( [61.246.59.42]) + by mx.gmail.com with ESMTP id 27sm5524422wrl.2005.08.26.15.35.37; + Fri, 26 Aug 2005 15:35:42 -0700 (PDT) +Date: Sat, 27 Aug 2005 04:15:40 +0530 +From: Ligesh +To: Frank Wiles +Cc: pgsql-performance@postgresql.org +Subject: Re: Sending a select to multiple servers. +Message-ID: <20050826224540.GA24476@lxlabs.com> +Reply-To: gxlists@gmail.com +References: <20050826152409.GA22060@lxlabs.com> + <20050826110459.03cce4d9.frank@wiles.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050826110459.03cce4d9.frank@wiles.org> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[AWL=-0.000, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/455 +X-Sequence-Number: 14202 + +On Fri, Aug 26, 2005 at 11:04:59AM -0500, Frank Wiles wrote: +> On Fri, 26 Aug 2005 20:54:09 +0530 +> This is typically handled by the application layer, not a standard +> client. Mostly because every situation is different, you may have +> 10 servers and need 10 rows of results, others may need something +> entirely different. +> +> This isn't really a "cluster" either. In a clustered environment +> you would send the one query to any of the 10 servers and it would +> return the proper results. +> +> But like I said this type of application is fairly trivial to write +> in most scripting or higher level languages. +> + + The cluster logic is sort of implemented by this client library. If you write this at higher level the scalability becomes an issue. For 10 servers it is alright. If you want to retrieve 100 rows, and there are 100 servers, you will have a total result set of 10,000, which should be re-sorted and the 9900 of them should be droped, and only the 100 should be returned. + + Anyway, what I want to know is, if there is such a functionality offered by some C library. + + Thanks. + +-- +:: Ligesh :: http://ligesh.com + +From pgsql-performance-owner@postgresql.org Fri Aug 26 19:50:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 17CD4D7CD1 + for ; + Fri, 26 Aug 2005 19:41:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13471-05 + for ; + Fri, 26 Aug 2005 22:41:22 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 06A90D736E + for ; + Fri, 26 Aug 2005 19:41:20 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i11so44827wra + for ; + Fri, 26 Aug 2005 15:41:21 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:date:from:to:cc:subject:message-id:reply-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; + b=t/gbpOpgY+8BuMOZ9ius3PSF8+sLSzR/UuEsecLttNe3+LjI0mSaN1IOzUGFvoT9x8OR935DS5Ohit8byYELAZNDB548HM520IFxJAbDK5or/1zYV8z09Vvd7Yn9cSJbD9e+kvmSg6Vpf4O4LLdgPHVVdR8bXcfthOkVRdw9iRg= +Received: by 10.54.14.70 with SMTP id 70mr3994410wrn; + Fri, 26 Aug 2005 15:41:21 -0700 (PDT) +Received: from localhost ( [61.246.59.42]) + by mx.gmail.com with ESMTP id 12sm15089wrl.2005.08.26.15.41.17; + Fri, 26 Aug 2005 15:41:21 -0700 (PDT) +Date: Sat, 27 Aug 2005 04:21:23 +0530 +From: Ligesh +To: Frank Wiles +Cc: pgsql-performance@postgresql.org +Subject: Re: Sending a select to multiple servers. +Message-ID: <20050826225123.GB24476@lxlabs.com> +Reply-To: gxlists@gmail.com +References: <20050826152409.GA22060@lxlabs.com> + <20050826110459.03cce4d9.frank@wiles.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050826110459.03cce4d9.frank@wiles.org> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/456 +X-Sequence-Number: 14203 + +On Fri, Aug 26, 2005 at 11:04:59AM -0500, Frank Wiles wrote: +> On Fri, 26 Aug 2005 20:54:09 +0530 +> Ligesh wrote: + + +> Mostly because every situation is different, you may have +> 10 servers and need 10 rows of results, others may need something +> entirely different. +> + + No. I have say 'm' number of servers, and I need 'n' rows. To get the results, you need to run the query against all the 'm' servers, which will return 'm x n' results, then you have to re-sort it and drop the 'm x n - n' rows and return only the 'n'. So this is like retrieving the 'n' rows amongst ALL the servers, that satisfy your search criteria. + + Once you retrieve the data, you will know which server each row belongs to, and you can do the writes yourself at the higher level. + + Thanks. + +-- +:: Ligesh :: http://ligesh.com + + + +From pgsql-performance-owner@postgresql.org Fri Aug 26 19:55:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 43902D7D5E + for ; + Fri, 26 Aug 2005 19:52:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16560-03 + for ; + Fri, 26 Aug 2005 22:52:24 +0000 (GMT) +Received: from web35212.mail.mud.yahoo.com (web35212.mail.mud.yahoo.com + [66.163.179.91]) + by svr1.postgresql.org (Postfix) with SMTP id DE5E8D7D50 + for ; + Fri, 26 Aug 2005 19:52:23 -0300 (ADT) +Received: (qmail 27639 invoked by uid 60001); 26 Aug 2005 22:52:24 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=l+6JkIlfeYWsHytkmJ8V5JSIZErK3VS/NqPQeWyrVqWb0JFLfgEI2Pm93KO3OrgTE+mVXDQmsuz1t/lmtKjL+DHLnmh5dXWdz0FSl2DNtX8Xp6CFDfsGX3y4HT6WJWOgLkj9S/jzZ0lk7B5D4g76gNfWUKyn6lALvycHynXk7w0= + ; +Message-ID: <20050826225224.27637.qmail@web35212.mail.mud.yahoo.com> +Received: from [65.218.233.130] by web35212.mail.mud.yahoo.com via HTTP; + Fri, 26 Aug 2005 15:52:24 PDT +Date: Fri, 26 Aug 2005 15:52:24 -0700 (PDT) +From: asif ali +Subject: Re: Weird performance drop after VACUUM +To: pgsql-performance@postgresql.org +In-Reply-To: <1125093859.9329.30.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.374 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/457 +X-Sequence-Number: 14204 + +Hi, +I have the same issue. After doing "VACCUME ANALYZE" +performance of the query dropped. + +Here is the query +explain select * from conversion_table c where +c.conversion_date BETWEEN '2005-06-07' and +'2005-08-17' + +Before "VACCUME ANALYZE" + +"Index Scan using conversion_table_pk on +keyword_conversion_table c (cost=0.00..18599.25 +rows=4986 width=95)" +" Index Cond: ((conversion_date >= +'2005-06-07'::date) AND (conversion_date <= +'2005-08-17'::date))" + + +After "VACCUME ANALYZE" + + +"Seq Scan on conversion_table c (cost=0.00..29990.83 +rows=1094820 width=66)" +" Filter: ((conversion_date >= '2005-06-07'::date) +AND (conversion_date <= '2005-08-17'::date))" + + +I dont know why system is doing "Seq scan" now. + +Thanks + +asif ali + + + + + + + +--- �mit �ztosun wrote: + +> Hello, +> +> We are using PostgreSQL for our business +> application. Recently, during +> testing of our application with large volumes of +> data, we faced a weird +> problem. Our query performance dropped +> *dramatically* after "VACUUM FULL +> ANALYZE" command. We have encountered a similar +> problem listed on +> mailing list archives, but the submitter solved his +> problem by rewriting +> his query, which is unfortunatelly very hard for us. +> +> I am attaching two EXPLAIN ANALYZE outputs, first +> one is just before the +> VACUUM FULL ANALYZE command and the other is the one +> after. Also +> attached is the SQL query, which is simplified to +> clearify the problem. +> In the example query time increases from 1.8 second +> to > 4.0 secons. The +> difference for the complete query is much bigger, +> query time increases +> from 7.8 seconds to > 110 seconds. +> +> Any help is appreciated, we were unable to identify +> what causes the +> query planner to choose a different/poor performing +> plan. +> +> Notes: +> Our production platform is Ubuntu Linux Hoary on +> i386, PostgreSQL 8.0.3, +> compiled from sources. Same tests were carried on +> Windows XP +> Professional and PostgreSQL 8.0.1 with similar +> results. The queries use +> little IO, high CPU. The largest table involved in +> the sample query has +> about 10000 rows. Indexes are used intensively, some +> tables use > 4 +> indexes. +> +> Best regards, +> Umit Oztosun +> +> > SELECT * FROM ( +> SELECT +> COALESCE ( +> (SELECT COALESCE (sum(irskal.anamiktar), +> 0) +> * (SELECT +> birim.fiyat2 * (SELECT kur1 +> FROM +> sis_doviz_kuru kur +> WHERE +> birim._key_sis_doviz2 = kur._key_sis_doviz +> ORDER BY tarih +> desc +> LIMIT 1) +> FROM scf_stokkart_birimleri +> birim +> WHERE _key_scf_stokkart = +> stok._key +> AND anabirim = '1' +> ) +> FROM scf_irsaliye irs, +> scf_irsaliye_kalemi irskal +> WHERE irskal._key_kalemturu = +> stok._key +> AND irskal._key_scf_irsaliye = +> irs._key +> AND irs.karsifirma = 'KENDI' +> AND (irs.turu='MAI' OR +> irs.turu='KGI' OR irs.turu='PS' OR irs.turu='TS' OR +> irs.turu='KC' OR irs.turu='KCO') +> AND ( irs._key_sis_depo_dest = +> '$$$$0000003l$1$$' OR irs._key_sis_depo_dest = +> '$$$$00000048$1$$' OR irs._key_sis_depo_dest = +> '$$$$0000004b$1$$' OR irs._key_sis_depo_dest = +> '$$$$0000004d$1$$' ) +> AND ((irskal._key LIKE '0000%' OR +> irskal._key LIKE '0101%' OR irskal._key LIKE '$$%')) +> AND irs.tarih <= '2005-08-26' +> ), 0 +> ) as arti_fiili_irs_karsifirma, +> stok.* +> FROM scf_stokkart stok +> ) AS _SWT WHERE (_key LIKE '00%' OR _key LIKE '01%' +> OR _key LIKE '$$%') ORDER BY _key desc +> > Before VACUUM FULL ANALYZE - Short Query +> --------------------------------------- +> Sort (cost=9094.31..9094.40 rows=37 width=817) +> (actual time=1852.799..1877.738 rows=10000 loops=1) +> Sort Key: stok._key +> -> Seq Scan on scf_stokkart stok +> (cost=0.00..9093.34 rows=37 width=817) (actual +> time=8.670..1575.586 rows=10000 loops=1) +> Filter: (((_key)::text ~~ '00%'::text) OR +> ((_key)::text ~~ '01%'::text) OR ((_key)::text ~~ +> '$$%'::text)) +> SubPlan +> -> Aggregate (cost=237.29..237.29 rows=1 +> width=16) (actual time=0.136..0.138 rows=1 +> loops=10000) +> InitPlan +> -> Index Scan using +> scf_stokkart_birimleri_key_scf_stokkart_idx on +> scf_stokkart_birimleri birim (cost=0.00..209.59 +> rows=1 width=58) (actual time=0.088..0.093 rows=1 +> loops=10000) +> Index Cond: +> ((_key_scf_stokkart)::text = ($1)::text) +> Filter: (anabirim = +> '1'::bpchar) +> SubPlan +> -> Limit +> (cost=9.31..9.31 rows=1 width=17) (actual +> time=0.046..0.048 rows=1 loops=10000) +> -> Sort +> (cost=9.31..9.31 rows=2 width=17) (actual +> time=0.041..0.041 rows=1 loops=10000) +> Sort Key: +> tarih +> -> Index Scan +> using sis_doviz_kuru_key_sis_doviz_idx on +> sis_doviz_kuru kur (cost=0.00..9.30 rows=2 +> width=17) (actual time=0.018..0.029 rows=2 +> loops=10000) +> Index +> Cond: (($0)::text = (_key_sis_doviz)::text) +> -> Nested Loop (cost=0.00..27.69 +> rows=1 width=16) (actual time=0.033..0.033 rows=0 +> loops=10000) +> -> Index Scan using +> scf_irsaliye_kalemi_key_kalemturu_idx on +> scf_irsaliye_kalemi irskal (cost=0.00..21.75 rows=1 +> width=58) (actual time=0.017..0.020 rows=0 +> loops=10000) +> Index Cond: +> ((_key_kalemturu)::text = ($1)::text) +> Filter: (((_key)::text +> ~~ '0000%'::text) OR ((_key)::text ~~ '0101%'::text) +> OR ((_key)::text ~~ '$$%'::text)) +> -> Index Scan using +> scf_irsaliye_pkey on scf_irsaliye irs +> (cost=0.00..5.94 rows=1 width=42) (actual +> time=0.021..0.021 rows=0 loops=3000) +> Index Cond: +> (("outer"._key_scf_irsaliye)::text = +> (irs._key)::text) +> Filter: +> (((karsifirma)::text = 'KENDI'::text) AND +> (((turu)::text = 'MAI'::text) OR ((turu)::text = +> 'KGI'::text) OR ((turu)::text = 'PS'::text) OR +> ((turu)::text = 'TS'::text) OR ((turu)::text = +> 'KC'::text) OR ((turu)::text = 'KCO'::text)) AND +> (((_key_sis_depo_dest)::text = +> '$$$$0000003l$1$$'::text) OR +> ((_key_sis_depo_dest)::text = +> '$$$$00000048$1$$'::text) OR +> ((_key_sis_depo_dest)::text = +> '$$$$0000004b$1$$'::text) OR +> ((_key_sis_depo_dest)::text = +> '$$$$0000004d$1$$'::text)) AND (tarih <= +> '2005-08-26'::date)) +> Total runtime: 1899.533 ms +> > After VACUUM FULL ANALYZE - Short Query +> --------------------------------------- +> Index Scan Backward using scf_stokkart_pkey on +> scf_stokkart stok (cost=0.00..392045.63 rows=9998 +> width=166) (actual time=0.661..4431.568 rows=10000 +> loops=1) +> Filter: (((_key)::text ~~ '00%'::text) OR +> ((_key)::text ~~ '01%'::text) OR ((_key)::text ~~ +> '$$%'::text)) +> SubPlan +> -> Aggregate (cost=39.16..39.16 rows=1 +> width=10) (actual time=0.416..0.418 rows=1 +> loops=10000) +> InitPlan +> -> Index Scan using +> scf_stokkart_birimleri_key_scf_stokkart_idx on +> scf_stokkart_birimleri birim (cost=0.00..5.25 +> rows=2 width=28) (actual time=0.101..0.105 rows=1 +> loops=10000) +> Index Cond: +> ((_key_scf_stokkart)::text = ($1)::text) +> Filter: (anabirim = '1'::bpchar) +> SubPlan +> -> Limit (cost=1.08..1.09 +> rows=1 width=15) (actual time=0.048..0.050 rows=1 +> loops=10000) +> -> Sort (cost=1.08..1.09 +> rows=2 width=15) (actual time=0.043..0.043 rows=1 +> loops=10000) +> Sort Key: tarih +> -> Seq Scan on +> sis_doviz_kuru kur (cost=0.00..1.07 rows=2 +> width=15) (actual time=0.009..0.026 rows=2 +> loops=10000) +> Filter: +> (($0)::text = (_key_sis_doviz)::text) +> -> Nested Loop (cost=0.00..33.90 rows=1 +> width=10) (actual time=0.295..0.295 rows=0 +> loops=10000) +> -> Seq Scan on scf_irsaliye irs +> (cost=0.00..30.00 rows=1 width=20) (actual +> time=0.290..0.290 rows=0 loops=10000) +> Filter: (((karsifirma)::text = +> 'KENDI'::text) AND (((turu)::text = 'MAI'::text) OR +> ((turu)::text = 'KGI'::text) OR ((turu)::text = +> 'PS'::text) OR ((turu)::text = 'TS'::text) OR +> ((turu)::text = 'KC'::text) OR ((turu)::text = +> 'KCO'::text)) AND (((_key_sis_depo_dest)::text = +> '$$$$0000003l$1$$'::text) OR +> ((_key_sis_depo_dest)::text = +> '$$$$00000048$1$$'::text) OR +> ((_key_sis_depo_dest)::text = +> '$$$$0000004b$1$$'::text) OR +> ((_key_sis_depo_dest)::text = +> '$$$$0000004d$1$$'::text)) AND (tarih <= +> '2005-08-26'::date)) +> -> Index Scan using +> scf_irsaliye_kalemi_key_scf_irsaliye_idx on +> scf_irsaliye_kalemi irskal (cost=0.00..3.89 rows=1 +> width=30) (never executed) +> Index Cond: +> ((irskal._key_scf_irsaliye)::text = +> ("outer"._key)::text) +> Filter: +> (((_key_kalemturu)::text = ($1)::text) AND +> (((_key)::text ~~ '0000%'::text) OR ((_key)::text ~~ +> '0101%'::text) OR ((_key)::text ~~ '$$%'::text))) +> Total runtime: 4456.895 ms +> > +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please +> send an appropriate +> subscribe-nomail command to +> majordomo@postgresql.org so that your +> message can get through to the mailing list +> cleanly +> + + + + +__________________________________ +Yahoo! Mail for Mobile +Take Yahoo! Mail with you! Check email on your mobile phone. +http://mobile.yahoo.com/learn/mail + +From pgsql-performance-owner@postgresql.org Fri Aug 26 20:07:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C8214D7D3B + for ; + Fri, 26 Aug 2005 19:56:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15707-09 + for ; + Fri, 26 Aug 2005 22:56:17 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B994AD7B46 + for ; + Fri, 26 Aug 2005 19:56:16 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7QMuGjX026437; + Fri, 26 Aug 2005 18:56:16 -0400 (EDT) +To: Arjen van der Meijden +Cc: Richard Huxton , + pgsql-performance@postgresql.org +Subject: Re: Inefficient queryplan for query with intersectable +In-reply-to: <430F8699.3030400@tweakers.net> +References: <430EF844.70905@tweakers.net> <430F1393.5040704@archonet.com> + <430F8699.3030400@tweakers.net> +Comments: In-reply-to Arjen van der Meijden + message dated "Fri, 26 Aug 2005 23:16:09 +0200" +Date: Fri, 26 Aug 2005 18:56:16 -0400 +Message-ID: <26436.1125096976@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/458 +X-Sequence-Number: 14205 + +Arjen van der Meijden writes: +> As said, it chooses sequential scans or "the wrong index plans" over a +> perfectly good plan that is just not selected when the parameters are +> "too well tuned" or sequential scanning of the table is allowed. + +I think some part of the problem comes from using inconsistent +datatypes. For instance, it seems very odd that the thing is not +using a hash or something to handle + + t_0.Cat2 IN (SELECT 545 UNION SELECT ID FROM cat WHERE ParentID = 545) + +seeing that it correctly guesses there are only going to be about 8 rows +in the union. Part of the reason is that cat2 is smallint, whereas the +output of the union must be at least int, maybe wider depending on the +datatype of cat.id (which you did not show us); so the comparison isn't +hashable. Even a smallint vs int comparison would be mergejoinable, +though, so I'm really wondering what cat.id is. + +Another big part of the problem comes from poor result size estimation. +I'm not sure you can eliminate that entirely given the multiple +conditions on different columns (which'd require cross-column statistics +to really do well, which we do not have). But you could avoid +constructs like + + WHERE ... t_1.recordtimestamp >= + (SELECT max_date - 60 FROM last_dates WHERE table_name = 'pricetracker') + +The planner is basically going to throw up its hands and make a default +guess on the selectivity of this; it's not smart enough to decide that +the sub-select probably represents a constant. What I'd do with this +is to define a function marked STABLE for the sub-select result, perhaps +something like + +create function get_last_date(tabname text, offsetdays int) +returns timestamp as $$ +SELECT max_date - $2 FROM last_dates WHERE table_name = $1 +$$ language sql strict stable; + +(I'm guessing as to datatypes and the amount of parameterization you +need.) Then write the query like + + WHERE ... t_1.recordtimestamp >= get_last_date('pricetracker', 60) + +In this formulation the planner will be able to make a reasonable guess +about how many rows will match ... at least if your statistics are up +to date ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 26 20:15:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E5ECAD7CF3 + for ; + Fri, 26 Aug 2005 20:14:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21118-05 + for ; + Fri, 26 Aug 2005 23:14:01 +0000 (GMT) +Received: from zhonka1.zhonka.net (zhonka1.zhonka.net [66.228.195.5]) + by svr1.postgresql.org (Postfix) with ESMTP id 16071D7CD9 + for ; + Fri, 26 Aug 2005 20:14:00 -0300 (ADT) +Received: from wolf.pjkh.com ([66.228.196.74]) by zhonka1.zhonka.net + (Post.Office MTA v3.5.3 release 223 ID# 0-58414U4500L450S0V35) + with ESMTP id net; Fri, 26 Aug 2005 16:14:03 -0700 +Received: from localhost (localhost [127.0.0.1]) + by wolf.pjkh.com (Postfix) with ESMTP id 8CDA8584D; + Fri, 26 Aug 2005 16:13:56 -0700 (PDT) +Received: from wolf.pjkh.com ([127.0.0.1]) + by localhost (wolf.pjkh.com [127.0.0.1]) (amavisd-new, + port 10024) with ESMTP + id 21985-09; Fri, 26 Aug 2005 16:13:56 -0700 (PDT) +Received: by wolf.pjkh.com (Postfix, from userid 1000) + id 550AF584B; Fri, 26 Aug 2005 16:13:56 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by wolf.pjkh.com (Postfix) with ESMTP id 50FD05773; + Fri, 26 Aug 2005 16:13:56 -0700 (PDT) +Date: Fri, 26 Aug 2005 16:13:56 -0700 (PDT) +From: Philip Hallstrom +To: asif ali +Cc: pgsql-performance@postgresql.org +Subject: Re: Weird performance drop after VACUUM +In-Reply-To: <20050826225224.27637.qmail@web35212.mail.mud.yahoo.com> +Message-ID: <20050826161119.P22700@wolf.pjkh.com> +References: <20050826225224.27637.qmail@web35212.mail.mud.yahoo.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at pjkh.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=-0.056 required=5 tests=[AWL=-0.056] +X-Spam-Level: +X-Archive-Number: 200508/459 +X-Sequence-Number: 14206 + +> Hi, +> I have the same issue. After doing "VACCUME ANALYZE" +> performance of the query dropped. +> +> Here is the query +> explain select * from conversion_table c where +> c.conversion_date BETWEEN '2005-06-07' and +> '2005-08-17' +> +> Before "VACCUME ANALYZE" +> +> "Index Scan using conversion_table_pk on +> keyword_conversion_table c (cost=0.00..18599.25 +> rows=4986 width=95)" +> " Index Cond: ((conversion_date >= +> '2005-06-07'::date) AND (conversion_date <= +> '2005-08-17'::date))" +> +> +> After "VACCUME ANALYZE" +> +> +> "Seq Scan on conversion_table c (cost=0.00..29990.83 +> rows=1094820 width=66)" +> " Filter: ((conversion_date >= '2005-06-07'::date) +> AND (conversion_date <= '2005-08-17'::date))" +> +> +> I dont know why system is doing "Seq scan" now. + +I could be wrong as I'm definitely no expert on reading the output of +EXPLAIN, but it seems to say that prior to VACUUM it was expecting to +retrieve 4986 rows and afterwards expecting to retrieve 1094820 rows. + +Which is a pretty big difference. + +So maybe the statistics were just really really off prior to vacuuming and +once it did vacuum it realized there would be a lot more matches and since +there were a lot more matches the planner decided to do a seq scan since +it would be quicker overall... + +Maybe? Seems I've heard Tom Lane say something to that affect, although +much more eloquently :-) + +-philip + +From pgsql-performance-owner@postgresql.org Fri Aug 26 20:28:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 13C73D7686 + for ; + Fri, 26 Aug 2005 20:26:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22405-09 + for ; + Fri, 26 Aug 2005 23:26:43 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E944D736E + for ; + Fri, 26 Aug 2005 20:26:41 -0300 (ADT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7QNQgCm019593 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Fri, 26 Aug 2005 17:26:44 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7QNQfrB019672; + Fri, 26 Aug 2005 17:26:41 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7QNQfUM019671; + Fri, 26 Aug 2005 17:26:41 -0600 (MDT) (envelope-from mfuhr) +Date: Fri, 26 Aug 2005 17:26:41 -0600 +From: Michael Fuhr +To: asif ali +Cc: pgsql-performance@postgresql.org +Subject: Re: Weird performance drop after VACUUM +Message-ID: <20050826232641.GA19583@winnie.fuhr.org> +References: <1125093859.9329.30.camel@localhost.localdomain> + <20050826225224.27637.qmail@web35212.mail.mud.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050826225224.27637.qmail@web35212.mail.mud.yahoo.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/460 +X-Sequence-Number: 14207 + +On Fri, Aug 26, 2005 at 03:52:24PM -0700, asif ali wrote: +> I have the same issue. After doing "VACCUME ANALYZE" +> performance of the query dropped. + +Your EXPLAIN output doesn't show the actual query times -- could +you post the EXPLAIN ANALYZE output? That'll also show how accurate +the planner's row count estimates are. + +> Before "VACCUME ANALYZE" +> +> "Index Scan using conversion_table_pk on +> keyword_conversion_table c (cost=0.00..18599.25 +> rows=4986 width=95)" +> " Index Cond: ((conversion_date >= +> '2005-06-07'::date) AND (conversion_date <= +> '2005-08-17'::date))" +> +> After "VACCUME ANALYZE" +> +> "Seq Scan on conversion_table c (cost=0.00..29990.83 +> rows=1094820 width=66)" +> " Filter: ((conversion_date >= '2005-06-07'::date) +> AND (conversion_date <= '2005-08-17'::date))" +> +> I dont know why system is doing "Seq scan" now. + +Notice the row count estimates: 4986 in the "before" query and +1094820 in the "after" query. In the latter, the planner thinks +it has to fetch so much of the table that a sequential scan would +be faster than an index scan. You can see whether that guess is +correct by disabling enable_seqscan to force an index scan. It +might be useful to see the output of the following: + +SET enable_seqscan TO on; +SET enable_indexscan TO off; +EXPLAIN ANALYZE SELECT ...; + +SET enable_seqscan TO off; +SET enable_indexscan TO on; +EXPLAIN ANALYZE SELECT ...; + +You might also experiment with planner variables like effective_cache_size +and random_page_cost to see how changing them affects the query +plan. However, be careful of tuning the system based on one query: +make sure adjustments result in reasonable plans for many different +queries. + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Fri Aug 26 20:33:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 92B71D7CF5 + for ; + Fri, 26 Aug 2005 20:31:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23093-09 + for ; + Fri, 26 Aug 2005 23:31:11 +0000 (GMT) +Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz [202.0.58.23]) + by svr1.postgresql.org (Postfix) with ESMTP id 05398D7CD9 + for ; + Fri, 26 Aug 2005 20:31:10 -0300 (ADT) +Received: from smtp-1.paradise.net.nz (smtp-1a.paradise.net.nz [202.0.32.194]) + by linda-4.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0ILU00KG2RWEZ8@linda-4.paradise.net.nz> for + pgsql-performance@postgresql.org; Sat, 27 Aug 2005 11:29:02 +1200 (NZST) +Received: from [192.168.1.11] (218-101-14-104.paradise.net.nz + [218.101.14.104]) + by smtp-1.paradise.net.nz (Postfix) with ESMTP id 5F34E82B87; Sat, + 27 Aug 2005 11:29:02 +1200 (NZST) +Date: Sat, 27 Aug 2005 11:29:01 +1200 +From: Mark Kirkwood +Subject: Re: Limit + group + join +In-reply-to: <9501.1125071193@sss.pgh.pa.us> +To: Tom Lane +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Message-id: <430FA5BD.2070407@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) +References: <20050826002709.GK10328@tobias.lan> + <430E85ED.60109@paradise.net.nz> <9501.1125071193@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.147 required=5 tests=[AWL=0.147] +X-Spam-Level: +X-Archive-Number: 200508/462 +X-Sequence-Number: 14209 + +Tom Lane wrote: +> Mark Kirkwood writes: +> +>>What is interesting is why this plan is being rejected... +> +> +> Which PG version are you using exactly? That mistake looks like an +> artifact of the 8.0 "fuzzy plan cost" patch, which we fixed recently: +> http://archives.postgresql.org/pgsql-committers/2005-07/msg00474.php +> + +Right on - 8.0.3 (I might look at how CVS tip handles this, could be +interesting). + +> But Tobias wasn't happy with 7.4 either, so I'm not sure that the fuzzy +> cost issue explains his results. +> +> As far as the "desc" point goes, the problem is that mergejoins aren't +> capable of dealing with backward sort order, so a merge plan isn't +> considered for that case (or at least, it would have to have a sort +> after it, which pretty much defeats the point for a fast-start plan). +> I have some ideas about fixing this but it won't happen before 8.2. + +That doesn't explain why the nested loop is being kicked tho', or have I +missed something obvious? - it's been known to happen :-)... + +Cheers + +Mark + + +From pgsql-performance-owner@postgresql.org Fri Aug 26 20:32:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B5A8D7A5E + for ; + Fri, 26 Aug 2005 20:31:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24101-04 + for ; + Fri, 26 Aug 2005 23:31:50 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 993EFD7705 + for ; + Fri, 26 Aug 2005 20:31:49 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7QNVpGB026746; + Fri, 26 Aug 2005 19:31:51 -0400 (EDT) +To: =?ISO-8859-1?Q?=DCmit_=D6ztosun?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Weird performance drop after VACUUM +In-reply-to: <1125093859.9329.30.camel@localhost.localdomain> +References: <1125093859.9329.30.camel@localhost.localdomain> +Comments: In-reply-to =?ISO-8859-1?Q?=DCmit_=D6ztosun?= + + message dated "Sat, 27 Aug 2005 01:04:19 +0300" +Date: Fri, 26 Aug 2005 19:31:51 -0400 +Message-ID: <26745.1125099111@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/461 +X-Sequence-Number: 14208 + +=?ISO-8859-1?Q?=DCmit_=D6ztosun?= writes: +> We are using PostgreSQL for our business application. Recently, during +> testing of our application with large volumes of data, we faced a weird +> problem. Our query performance dropped *dramatically* after "VACUUM FULL +> ANALYZE" command. + +I think the problem is that the planner is underestimating the cost of +evaluating this complicated filter condition: + +> -> Seq Scan on scf_irsaliye irs (cost=0.00..30.00 rows=1 width=20) (actual time=0.290..0.290 rows=0 loops=10000) +> Filter: (((karsifirma)::text = 'KENDI'::text) AND (((turu)::text = 'MAI'::text) OR ((turu)::text = 'KGI'::text) OR ((turu)::text = 'PS'::text) OR ((turu)::text = 'TS'::text) OR ((turu)::text = 'KC'::text) OR ((turu)::text = 'KCO'::text)) AND (((_key_sis_depo_dest)::text = '$$$$0000003l$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$00000048$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$0000004b$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$0000004d$1$$'::text)) AND (tarih <= '2005-08-26'::date)) + +While you could attack that by raising the cpu_operator_cost parameter, +it would also be worth inquiring *why* the condition is so expensive to +evaluate. I am suspicious that you are running the database in a locale +in which strcoll() is really slow. Can you run it in C locale instead, +or do you really need locale-aware behavior? Can you switch to a +different database encoding? (A single-byte encoding such as Latin1 +might be faster than UTF8, for example.) + +Another possibility is to take a hard look at whether you can't simplify +the filter condition, but that'd require more knowledge of your +application than I have. + +Or you could just play with the order of the filter conditions ... for +example, the date condition at the end is probably far cheaper to test +than the text comparisons, so if that's fairly selective it'd be worth +putting it first. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 26 20:48:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D852D7D75 + for ; + Fri, 26 Aug 2005 20:48:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22863-10 + for ; + Fri, 26 Aug 2005 23:48:17 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 623C5D7D72 + for ; + Fri, 26 Aug 2005 20:48:15 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7QNm5Zx026875; + Fri, 26 Aug 2005 19:48:05 -0400 (EDT) +To: Mark Kirkwood +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: Limit + group + join +In-reply-to: <430FA5BD.2070407@paradise.net.nz> +References: <20050826002709.GK10328@tobias.lan> + <430E85ED.60109@paradise.net.nz> <9501.1125071193@sss.pgh.pa.us> + <430FA5BD.2070407@paradise.net.nz> +Comments: In-reply-to Mark Kirkwood + message dated "Sat, 27 Aug 2005 11:29:01 +1200" +Date: Fri, 26 Aug 2005 19:48:05 -0400 +Message-ID: <26874.1125100085@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/463 +X-Sequence-Number: 14210 + +Mark Kirkwood writes: +> That doesn't explain why the nested loop is being kicked tho', + +No, but I think the fuzzy-cost bug does. There are two different issues +here. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 26 21:10:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EDDE7D7705 + for ; + Fri, 26 Aug 2005 21:10:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31418-10 + for ; + Sat, 27 Aug 2005 00:10:47 +0000 (GMT) +Received: from web35210.mail.mud.yahoo.com (web35210.mail.mud.yahoo.com + [66.163.179.89]) + by svr1.postgresql.org (Postfix) with SMTP id BBA3ED736E + for ; + Fri, 26 Aug 2005 21:10:45 -0300 (ADT) +Received: (qmail 58961 invoked by uid 60001); 27 Aug 2005 00:10:49 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=P7dsyrW1AuZ5qo9mOCrfFeNwY6D2KAGORCVLijqlE6PtMA/xMq3bUKzpNz5ni2nEwdF+Zhok+ZsDNQe3UwjVxWzgtFl08TkSaoW75j+zrjr7o3YHsJ84PYmWpLtmOg7dsEzGJoy/FKw/PuztpReEZQWXWN3VY69cGeLkmWUntyM= + ; +Message-ID: <20050827001049.58959.qmail@web35210.mail.mud.yahoo.com> +Received: from [65.218.233.130] by web35210.mail.mud.yahoo.com via HTTP; + Fri, 26 Aug 2005 17:10:49 PDT +Date: Fri, 26 Aug 2005 17:10:49 -0700 (PDT) +From: asif ali +Subject: Re: Weird performance drop after VACUUM +To: Michael Fuhr +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20050826232641.GA19583@winnie.fuhr.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.28 required=5 tests=[AWL=-0.093, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/464 +X-Sequence-Number: 14211 + +Thanks Michael For your reply. + +Here is performance on the database on which i did +VACUUM ANALYZE + +explain analyze +select keyword_id + ,sum(daily_impressions) as daily_impressions + ,sum(daily_actions)as daily_actions + from conversion_table c where c.conversion_date +BETWEEN '2005-06-07' and '2005-08-17' + group by keyword_Id + +"GroupAggregate (cost=195623.66..206672.52 rows=20132 +width=16) (actual time=8205.283..10139.369 rows=55291 +loops=1)" +" -> Sort (cost=195623.66..198360.71 rows=1094820 +width=16) (actual time=8205.114..9029.501 rows=863883 +loops=1)" +" Sort Key: keyword_id" +" -> Seq Scan on keyword_conversion_table c +(cost=0.00..29990.83 rows=1094820 width=16) (actual +time=0.057..1422.319 rows=863883 loops=1)" +" Filter: ((conversion_date >= +'2005-06-07'::date) AND (conversion_date <= +'2005-08-17'::date))" +"Total runtime: 14683.617 ms" + + +Now see if am changing the query and commenting one +column. + +explain analyze +select keyword_id + ,sum(daily_impressions) as daily_impressions +-- ,sum(daily_actions)as daily_actions + from conversion_table c where c.conversion_date +BETWEEN '2005-06-07' and '2005-08-17' + group by keyword_Id + + +"HashAggregate (cost=27373.51..27373.52 rows=2 +width=16) (actual time=3030.386..3127.073 rows=55717 +loops=1)" +" -> Seq Scan on conversion_table c +(cost=0.00..27336.12 rows=4986 width=16) (actual +time=0.050..1357.164 rows=885493 loops=1)" +" Filter: ((conversion_date >= +'2005-06-07'::date) AND (conversion_date <= +'2005-08-17'::date))" +"Total runtime: 3159.162 ms" + + +I noticed "GroupAggregate" changes to "HashAggregate" +and performance from 14 sec to 3 sec. + + +On the other hand I have another database which I did +not do "VACUUM ANALYZE" working fine. + + +explain analyze +select keyword_id + ,sum(daily_impressions) as daily_impressions + ,sum(daily_actions)as daily_actions + from conversion_table c where c.conversion_date +BETWEEN '2005-06-07' and '2005-08-17' + group by keyword_Id + + +"HashAggregate (cost=27373.51..27373.52 rows=2 +width=16) (actual time=3024.289..3120.324 rows=55717 +loops=1)" +" -> Seq Scan on conversion_table c +(cost=0.00..27336.12 rows=4986 width=16) (actual +time=0.047..1352.212 rows=885493 loops=1)" +" Filter: ((conversion_date >= +'2005-06-07'::date) AND (conversion_date <= +'2005-08-17'::date))" +"Total runtime: 3152.437 ms" + + +I am new to postgres. Thanks in advance. + + +asif ali + + + + + + +--- Michael Fuhr wrote: + +> On Fri, Aug 26, 2005 at 03:52:24PM -0700, asif ali +> wrote: +> > I have the same issue. After doing "VACCUME +> ANALYZE" +> > performance of the query dropped. +> +> Your EXPLAIN output doesn't show the actual query +> times -- could +> you post the EXPLAIN ANALYZE output? That'll also +> show how accurate +> the planner's row count estimates are. +> +> > Before "VACCUME ANALYZE" +> > +> > "Index Scan using conversion_table_pk on +> > keyword_conversion_table c (cost=0.00..18599.25 +> > rows=4986 width=95)" +> > " Index Cond: ((conversion_date >= +> > '2005-06-07'::date) AND (conversion_date <= +> > '2005-08-17'::date))" +> > +> > After "VACCUME ANALYZE" +> > +> > "Seq Scan on conversion_table c +> (cost=0.00..29990.83 +> > rows=1094820 width=66)" +> > " Filter: ((conversion_date >= +> '2005-06-07'::date) +> > AND (conversion_date <= '2005-08-17'::date))" +> > +> > I dont know why system is doing "Seq scan" now. +> +> Notice the row count estimates: 4986 in the "before" +> query and +> 1094820 in the "after" query. In the latter, the +> planner thinks +> it has to fetch so much of the table that a +> sequential scan would +> be faster than an index scan. You can see whether +> that guess is +> correct by disabling enable_seqscan to force an +> index scan. It +> might be useful to see the output of the following: +> +> SET enable_seqscan TO on; +> SET enable_indexscan TO off; +> EXPLAIN ANALYZE SELECT ...; +> +> SET enable_seqscan TO off; +> SET enable_indexscan TO on; +> EXPLAIN ANALYZE SELECT ...; +> +> You might also experiment with planner variables +> like effective_cache_size +> and random_page_cost to see how changing them +> affects the query +> plan. However, be careful of tuning the system +> based on one query: +> make sure adjustments result in reasonable plans for +> many different +> queries. +> +> -- +> Michael Fuhr +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + + + +____________________________________________________ +Start your day with Yahoo! - make it your home page +http://www.yahoo.com/r/hs + + +From pgsql-performance-owner@postgresql.org Fri Aug 26 22:41:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D7CFD7E0D + for ; + Fri, 26 Aug 2005 22:41:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53392-02 + for ; + Sat, 27 Aug 2005 01:41:28 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 61445D7E0F + for ; + Fri, 26 Aug 2005 22:41:26 -0300 (ADT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7R1fRE1019691 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Fri, 26 Aug 2005 19:41:29 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7R1fRG4033726; + Fri, 26 Aug 2005 19:41:27 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7R1fQEn033725; + Fri, 26 Aug 2005 19:41:26 -0600 (MDT) (envelope-from mfuhr) +Date: Fri, 26 Aug 2005 19:41:26 -0600 +From: Michael Fuhr +To: asif ali +Cc: pgsql-performance@postgresql.org +Subject: Re: Weird performance drop after VACUUM +Message-ID: <20050827014126.GA33637@winnie.fuhr.org> +References: <20050826232641.GA19583@winnie.fuhr.org> + <20050827001049.58959.qmail@web35210.mail.mud.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050827001049.58959.qmail@web35210.mail.mud.yahoo.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/465 +X-Sequence-Number: 14212 + +On Fri, Aug 26, 2005 at 05:10:49PM -0700, asif ali wrote: +> "GroupAggregate (cost=195623.66..206672.52 rows=20132 +> width=16) (actual time=8205.283..10139.369 rows=55291 +> loops=1)" +> " -> Sort (cost=195623.66..198360.71 rows=1094820 +> width=16) (actual time=8205.114..9029.501 rows=863883 +> loops=1)" +> " Sort Key: keyword_id" +> " -> Seq Scan on keyword_conversion_table c +> (cost=0.00..29990.83 rows=1094820 width=16) (actual +> time=0.057..1422.319 rows=863883 loops=1)" +> " Filter: ((conversion_date >= +> '2005-06-07'::date) AND (conversion_date <= +> '2005-08-17'::date))" +> "Total runtime: 14683.617 ms" + +What are your effective_cache_size and work_mem (8.x) or sort_mem (7.x) +settings? How much RAM does the machine have? If you have enough +memory then raising those variables should result in better plans; +you might also want to experiment with random_page_cost. Be careful +not to set work_mem/sort_mem too high, though. See "Run-time +Configuration" in the "Server Run-time Environment" chapter of the +documentation for more information about these variables. + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Fri Aug 26 23:55:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9506CD7D7D + for ; + Fri, 26 Aug 2005 23:55:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66784-06 + for ; + Sat, 27 Aug 2005 02:55:21 +0000 (GMT) +Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz [202.0.58.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 84A0AD7D5F + for ; + Fri, 26 Aug 2005 23:55:19 -0300 (ADT) +Received: from smtp-1.paradise.net.nz (smtp-1a.paradise.net.nz [202.0.32.194]) + by linda-5.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0ILV00LFU1GBSJ@linda-5.paradise.net.nz> for + pgsql-performance@postgresql.org; Sat, 27 Aug 2005 14:55:24 +1200 (NZST) +Received: from [192.168.1.11] (218-101-14-104.paradise.net.nz + [218.101.14.104]) + by smtp-1.paradise.net.nz (Postfix) with ESMTP id 7411A82B27; Sat, + 27 Aug 2005 14:55:23 +1200 (NZST) +Date: Sat, 27 Aug 2005 14:55:22 +1200 +From: Mark Kirkwood +Subject: Re: Limit + group + join +In-reply-to: <9501.1125071193@sss.pgh.pa.us> +To: Tom Lane +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Message-id: <430FD61A.3020902@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) +References: <20050826002709.GK10328@tobias.lan> + <430E85ED.60109@paradise.net.nz> <9501.1125071193@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.145 required=5 tests=[AWL=0.145] +X-Spam-Level: +X-Archive-Number: 200508/466 +X-Sequence-Number: 14213 + +Interestingly enough, 7.4.8 and 8.1devel-2005-08-23 all behave the same +as 8.0.3 for me (tables freshly ANALYZEd): + +joinlimit=# SELECT version(); + version + +------------------------------------------------------------------------------------------------- + PostgreSQL 7.4.8 on i386-unknown-freebsd5.4, compiled by GCC gcc (GCC) +3.4.2 [FreeBSD] 20040728 +(1 row) + +joinlimit=# EXPLAIN SELECT c.id FROM c JOIN b ON c_id=c.id GROUP BY +c.id ORDER BY c.id DESC LIMIT 5; + QUERY PLAN + +----------------------------------------------------------------------------------------------- + Limit (cost=10591.36..10591.39 rows=5 width=4) + -> Group (cost=10591.36..10992.02 rows=80131 width=4) + -> Sort (cost=10591.36..10791.69 rows=80131 width=4) + Sort Key: c.id + -> Merge Join (cost=0.00..4064.66 rows=80131 width=4) + Merge Cond: ("outer".id = "inner".c_id) + -> Index Scan using c_pkey on c +(cost=0.00..1411.31 rows=80131 width=4) + -> Index Scan using b_on_c on b +(cost=0.00..1451.72 rows=80172 width=4) +(8 rows) + +joinlimit=# EXPLAIN SELECT c.id FROM c JOIN b ON c_id=c.id GROUP BY +c.id ORDER BY c.id LIMIT 5; + QUERY PLAN + +----------------------------------------------------------------------------------------- + Limit (cost=0.00..0.27 rows=5 width=4) + -> Group (cost=0.00..4264.99 rows=80131 width=4) + -> Merge Join (cost=0.00..4064.66 rows=80131 width=4) + Merge Cond: ("outer".id = "inner".c_id) + -> Index Scan using c_pkey on c (cost=0.00..1411.31 +rows=80131 width=4) + -> Index Scan using b_on_c on b (cost=0.00..1451.72 +rows=80172 width=4) +(6 rows) + + +joinlimit=# SELECT version(); + version + +---------------------------------------------------------------------------------------------------- + PostgreSQL 8.1devel on i386-unknown-freebsd5.4, compiled by GCC gcc +(GCC) 3.4.2 [FreeBSD] 20040728 +(1 row) + +joinlimit=# EXPLAIN SELECT c.id FROM c JOIN b ON c_id=c.id GROUP BY +c.id ORDER BY c.id DESC LIMIT 5; + QUERY PLAN + +----------------------------------------------------------------------------------------------- + Limit (cost=10654.53..10654.55 rows=5 width=4) + -> Group (cost=10654.53..11054.53 rows=80000 width=4) + -> Sort (cost=10654.53..10854.53 rows=80000 width=4) + Sort Key: c.id + -> Merge Join (cost=0.00..4139.44 rows=80000 width=4) + Merge Cond: ("outer".id = "inner".c_id) + -> Index Scan using c_pkey on c +(cost=0.00..1450.00 rows=80000 width=4) + -> Index Scan using b_on_c on b +(cost=0.00..1490.00 rows=80000 width=4) +(8 rows) + +joinlimit=# EXPLAIN SELECT c.id FROM c JOIN b ON c_id=c.id GROUP BY +c.id ORDER BY c.id LIMIT 5; + QUERY PLAN + +----------------------------------------------------------------------------------------- + Limit (cost=0.00..0.27 rows=5 width=4) + -> Group (cost=0.00..4339.44 rows=80000 width=4) + -> Merge Join (cost=0.00..4139.44 rows=80000 width=4) + Merge Cond: ("outer".id = "inner".c_id) + -> Index Scan using c_pkey on c (cost=0.00..1450.00 +rows=80000 width=4) + -> Index Scan using b_on_c on b (cost=0.00..1490.00 +rows=80000 width=4) +(6 rows) + +The non default server params of relevance are: + +shared_buffers = 12000 +effective_cache_size = 100000 +work_mem/sort_mem = 20480 + +I did wonder if the highish sort_mem might be a factor, but no, with it + set to 1024 I get the same behaviour (just higher sort cost estimates). + +Cheers + +Mark + +Tom Lane wrote: +> +> +> Which PG version are you using exactly? That mistake looks like an +> artifact of the 8.0 "fuzzy plan cost" patch, which we fixed recently: +> http://archives.postgresql.org/pgsql-committers/2005-07/msg00474.php +> +> But Tobias wasn't happy with 7.4 either, so I'm not sure that the fuzzy +> cost issue explains his results. +> +> As far as the "desc" point goes, the problem is that mergejoins aren't +> capable of dealing with backward sort order, so a merge plan isn't +> considered for that case (or at least, it would have to have a sort +> after it, which pretty much defeats the point for a fast-start plan). +> I have some ideas about fixing this but it won't happen before 8.2. +> + +From pgsql-performance-owner@postgresql.org Sat Aug 27 00:03:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 551F7D7E0D + for ; + Sat, 27 Aug 2005 00:03:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98219-03 + for ; + Sat, 27 Aug 2005 03:03:48 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 67074D7E08 + for ; + Sat, 27 Aug 2005 00:03:47 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1E8qyg-0006zX-00; Fri, 26 Aug 2005 23:03:30 -0400 +To: Tom Lane +Cc: Mark Kirkwood , + Tobias Brox , pgsql-performance@postgresql.org +Subject: Re: Limit + group + join +References: <20050826002709.GK10328@tobias.lan> + <430E85ED.60109@paradise.net.nz> <9501.1125071193@sss.pgh.pa.us> +In-Reply-To: <9501.1125071193@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 26 Aug 2005 23:03:30 -0400 +Message-ID: <87mzn484jh.fsf@stark.xeocode.com> +Lines: 14 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/467 +X-Sequence-Number: 14214 + + +Tom Lane writes: + +> As far as the "desc" point goes, the problem is that mergejoins aren't +> capable of dealing with backward sort order, so a merge plan isn't +> considered for that case (or at least, it would have to have a sort +> after it, which pretty much defeats the point for a fast-start plan). +> I have some ideas about fixing this but it won't happen before 8.2. + +Of course in this case assuming "id" is an integer column you can just sort by +-id instead. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sat Aug 27 03:20:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C83FD7E91 + for ; + Sat, 27 Aug 2005 03:20:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44540-03 + for ; + Sat, 27 Aug 2005 06:20:13 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.197.194]) + by svr1.postgresql.org (Postfix) with SMTP id 5B517D7E62 + for ; + Sat, 27 Aug 2005 03:20:11 -0300 (ADT) +Received: (qmail 28325 invoked by uid 500); 27 Aug 2005 06:19:49 -0000 +Date: Sat, 27 Aug 2005 01:19:49 -0500 +From: Bruno Wolff III +To: "Lenard, Rohan (Rohan)" +Cc: pgsql-performance@postgresql.org +Subject: Re: Need indexes on empty tables for good performance ? +Message-ID: <20050827061949.GB27248@wolff.to> +Mail-Followup-To: Bruno Wolff III , + "Lenard, Rohan (Rohan)" , + pgsql-performance@postgresql.org +References: + <2773CAC687FD5F4689F526998C7E4E5F43F392@au3010avexu1.global.avaya.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: + <2773CAC687FD5F4689F526998C7E4E5F43F392@au3010avexu1.global.avaya.com> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/472 +X-Sequence-Number: 14219 + +On Tue, Aug 23, 2005 at 13:41:32 +1000, + "Lenard, Rohan (Rohan)" wrote: +> I've read that indexes aren't used for COUNT(*) and I've noticed (7.3.x) +> with EXPLAIN that indexes never seem to be used on empty tables - is +> there any reason to have indexes on empty tables, or will postgresql +> never use them. + +count will use indexes if appropiate. The counts themselves are NOT in the +indexes, so counts of significant fractions of a table (in particular +of the whole table) won't benefit from indexes. + +You aren't going to get query speed ups by putting indexes on empty tables. +However, they may be required if you have unique or primary keys declared +in the table. You may want them to enforce some kinds of constraints. + +From pgsql-performance-owner@postgresql.org Sat Aug 27 03:30:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C9F73D7EC7 + for ; + Sat, 27 Aug 2005 03:30:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45327-07 + for ; + Sat, 27 Aug 2005 06:30:10 +0000 (GMT) +Received: from mail.travelamericas.com (unknown [206.130.134.147]) + by svr1.postgresql.org (Postfix) with SMTP id 9A9ADD7EC6 + for ; + Sat, 27 Aug 2005 03:30:08 -0300 (ADT) +Received: (qmail 12839 invoked from network); 27 Aug 2005 06:30:08 -0000 +Received: from unknown (HELO ?10.0.0.253?) (10.0.0.253) + by verkiel.travelamericas.com with SMTP; 27 Aug 2005 06:30:08 -0000 +Message-ID: <43100870.8070406@travelamericas.com> +Date: Fri, 26 Aug 2005 23:30:08 -0700 +From: Chris Travers +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: tobbe +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance for relative large DB +References: <1124799264.282119.167760@g47g2000cwa.googlegroups.com> + <60wtmcptzg.fsf@dba2.int.libertyrms.com> + <1124864702.822522.64410@g49g2000cwa.googlegroups.com> +In-Reply-To: <1124864702.822522.64410@g49g2000cwa.googlegroups.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/473 +X-Sequence-Number: 14220 + +tobbe wrote: + +>Hi Chris. +> +>Thanks for the answer. +>Sorry that i was a bit unclear. +> +>1) We update around 20.000 posts per night. +> +>2) What i meant was that we suspect that the DBMS called PervasiveSQL +>that we are using today is much to small. That's why we're looking for +>alternatives. +> +>Today we base our solution much on using querry-specific tables created +>at night, so instead of doing querrys direct on the "post" table (with +>4-6M rows) at daytime, we have the data pre-aligned in several much +>smaller tables. This is just to make the current DBMS coop with our +>amount of data. +> +>What I am particulary interested in is if we can expect to run all our +>select querrys directly from the "post" table with PostgreSQL. +> +> +20k transactions per day? Doesn't seem too bad. That amounts to how +many transactions per second during peak times? Personally I don't +think it will be a problem, but you might want to clarify what sort of +load you are expecting during its peak time. + +>3) How well does postgres work with load balancing environments. Is it +>built-in? +> +> +There is no load balancing "built in." You would need to use Slony-I +and possibly Pg-Pool for that. I don't know about Pg-Pool, but Slony-I +was written in large part by member(s?) of the core development team so +even if it is not "built in" it is not as if it is a team of outsiders +who wrote it. + +If you need something proprietary, there are similar solutions with +replication built in which are based on PostgreSQL and licensed under +proprietary licenses. + +Best Wishes, +Chris Travers +Metatron Technology Consulting + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:03:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8595FD7EB2 + for ; + Sat, 27 Aug 2005 03:34:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45167-06 + for ; + Sat, 27 Aug 2005 06:34:24 +0000 (GMT) +Received: from mail.travelamericas.com (unknown [206.130.134.147]) + by svr1.postgresql.org (Postfix) with SMTP id 69056D7ED8 + for ; + Sat, 27 Aug 2005 03:34:22 -0300 (ADT) +Received: (qmail 12882 invoked from network); 27 Aug 2005 06:34:23 -0000 +Received: from unknown (HELO ?10.0.0.253?) (10.0.0.253) + by verkiel.travelamericas.com with SMTP; 27 Aug 2005 06:34:23 -0000 +Message-ID: <4310096F.3020805@metatrontech.com> +Date: Fri, 26 Aug 2005 23:34:23 -0700 +From: Chris Travers +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Lenard, Rohan (Rohan)" +Cc: pgsql-performance@postgresql.org +Subject: Re: Need indexes on empty tables for good performance ? +References: + <2773CAC687FD5F4689F526998C7E4E5F43F392@au3010avexu1.global.avaya.com> +In-Reply-To: + <2773CAC687FD5F4689F526998C7E4E5F43F392@au3010avexu1.global.avaya.com> +Content-Type: multipart/mixed; boundary="------------060901010708010604050506" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[AWL=-0.000, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/519 +X-Sequence-Number: 14266 + +This is a multi-part message in MIME format. +--------------060901010708010604050506 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Lenard, Rohan (Rohan) wrote: + +> I've read that indexes aren't used for COUNT(*) and I've noticed +> (7.3.x) with EXPLAIN that indexes never seem to be used on empty +> tables - is there any reason to have indexes on empty tables, or will +> postgresql never use them. + +You could add a row, vacuum analyze, delete the row, etc.... Then you +are fine until you vacuum analyze again ;-) + +This is a feature designed to prevent really bad plans when you are +loading tables with data. However, you are right. It can create bad +plans sometimes. + +Any chance one can eventually come up with a way to tell the planner +that an empty table is expected not to grow? Otherwise, I can see +nightmares in a data warehouse environment where you have an empty +parent table... + +Best Wishes, +Chris Travers +Metatron Technology Consulting + +--------------060901010708010604050506 +Content-Type: text/x-vcard; charset=utf-8; + name="chris.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="chris.vcf" + +begin:vcard +fn:Chris Travers +n:Travers;Chris +email;internet:chris@metatrontech.com +x-mozilla-html:FALSE +version:2.1 +end:vcard + + +--------------060901010708010604050506-- + +From pgsql-performance-owner@postgresql.org Sat Aug 27 06:31:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A2CA9D6E06 + for ; + Sat, 27 Aug 2005 06:31:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83280-08 + for ; + Sat, 27 Aug 2005 09:31:18 +0000 (GMT) +Received: from kartal.liqia.com (unknown [65.254.45.184]) + by svr1.postgresql.org (Postfix) with ESMTP id C035BD6D88 + for ; + Sat, 27 Aug 2005 06:31:17 -0300 (ADT) +Received: from [81.215.232.82] (helo=[10.0.0.201]) + by kartal.liqia.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1E8x1v-00018K-Tq; Sat, 27 Aug 2005 12:31:17 +0300 +Subject: Re: Weird performance drop after VACUUM +From: Umit Oztosun +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <26745.1125099111@sss.pgh.pa.us> +References: <1125093859.9329.30.camel@localhost.localdomain> + <26745.1125099111@sss.pgh.pa.us> +Content-Type: text/plain +Date: Sat, 27 Aug 2005 12:31:13 +0300 +Message-Id: <1125135073.8001.21.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.1.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/474 +X-Sequence-Number: 14221 + +On Cum, 2005-08-26 at 19:31 -0400, Tom Lane wrote: +> I think the problem is that the planner is underestimating the cost of +> evaluating this complicated filter condition: +> +> > -> Seq Scan on scf_irsaliye irs (cost=0.00..30.00 rows=1 width=20) (actual time=0.290..0.290 rows=0 loops=10000) +> > Filter: (((karsifirma)::text = 'KENDI'::text) AND (((turu)::text = 'MAI'::text) OR ((turu)::text = 'KGI'::text) OR ((turu)::text = 'PS'::text) OR ((turu)::text = 'TS'::text) OR ((turu)::text = 'KC'::text) OR ((turu)::text = 'KCO'::text)) AND (((_key_sis_depo_dest)::text = '$$$$0000003l$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$00000048$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$0000004b$1$$'::text) OR ((_key_sis_depo_dest)::text = '$$$$0000004d$1$$'::text)) AND (tarih <= '2005-08-26'::date)) +> +> While you could attack that by raising the cpu_operator_cost parameter, +> it would also be worth inquiring *why* the condition is so expensive to +> evaluate. I am suspicious that you are running the database in a locale +> in which strcoll() is really slow. Can you run it in C locale instead, +> or do you really need locale-aware behavior? Can you switch to a +> different database encoding? (A single-byte encoding such as Latin1 +> might be faster than UTF8, for example.) + +Yes, you are perfectly right. We are using UTF8 and tr_TR.UTF8 locale. +However, I tried the same tests with latin1 and C locale, it is surely +faster, but not dramatically. i.e.: + + Before Vacuum After Vacuum +UTF8 and tr_TR.UTF8: ~8 s ~110 s +latin1 and C: ~7 s ~65 s + +I also played with cpu_operator_cost parameter and it dramatically +reduced query times, but not to the level before vacuum: + + Before Vacuum After Vacuum +UTF8 and tr_TR.UTF8: ~8 s ~11 s +latin1 and C: ~7 s ~9 s + +These values are much better but I really wonder if I can reach the +performance levels before vacuum. I am also worried about the +side-effects that may be caused by the non-default cpu_operator_cost +parameter. + +> Another possibility is to take a hard look at whether you can't simplify +> the filter condition, but that'd require more knowledge of your +> application than I have. + +Yes that is another option, we are even considering schema changes to +use less character types, but these are really costly and error-prone +operations at the moment. + +> Or you could just play with the order of the filter conditions ... for +> example, the date condition at the end is probably far cheaper to test +> than the text comparisons, so if that's fairly selective it'd be worth +> putting it first. + +We are experimenting on this. + +Thanks your help! + +Best Regards, +Umit Oztosun + + +From pgsql-performance-owner@postgresql.org Sat Aug 27 07:19:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 348DCD79B1 + for ; + Sat, 27 Aug 2005 07:19:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96278-01 + for ; + Sat, 27 Aug 2005 10:19:48 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id C3539D7078 + for ; + Sat, 27 Aug 2005 07:19:46 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1E8xms-000247-A3 + for pgsql-performance@postgresql.org; Sat, 27 Aug 2005 12:19:47 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1E8xmr-0004vm-00 + for ; Sat, 27 Aug 2005 12:19:45 +0200 +Date: Sat, 27 Aug 2005 12:19:45 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Weird performance drop after VACUUM +Message-ID: <20050827101945.GA18155@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <1125093859.9329.30.camel@localhost.localdomain> + <26745.1125099111@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <26745.1125099111@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 required=5 tests=[AWL=0.015] +X-Spam-Level: +X-Archive-Number: 200508/475 +X-Sequence-Number: 14222 + +On Fri, Aug 26, 2005 at 07:31:51PM -0400, Tom Lane wrote: +> Or you could just play with the order of the filter conditions ... for +> example, the date condition at the end is probably far cheaper to test +> than the text comparisons, so if that's fairly selective it'd be worth +> putting it first. + +That's an interesting approach -- could the planner do such things itself? + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sat Aug 27 07:50:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1990ED6E1F + for ; + Sat, 27 Aug 2005 07:50:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00832-04 + for ; + Sat, 27 Aug 2005 10:50:21 +0000 (GMT) +Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 37377D6E11 + for ; + Sat, 27 Aug 2005 07:50:20 -0300 (ADT) +Received: from [10.0.0.2] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) + by olive.qinip.net (Postfix) with ESMTP + id D811C18156; Sat, 27 Aug 2005 12:50:19 +0200 (MEST) +Message-ID: <4310456F.8040303@tweakers.net> +Date: Sat, 27 Aug 2005 12:50:23 +0200 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Inefficient queryplan for query with intersectable +References: <430EF844.70905@tweakers.net> <430F1393.5040704@archonet.com> + <430F8699.3030400@tweakers.net> <26436.1125096976@sss.pgh.pa.us> +In-Reply-To: <26436.1125096976@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/476 +X-Sequence-Number: 14223 + + + +On 27-8-2005 0:56, Tom Lane wrote: +> Arjen van der Meijden writes: +> +>>As said, it chooses sequential scans or "the wrong index plans" over a +>>perfectly good plan that is just not selected when the parameters are +>>"too well tuned" or sequential scanning of the table is allowed. +> +> +> I think some part of the problem comes from using inconsistent +> datatypes. For instance, it seems very odd that the thing is not +> using a hash or something to handle +> +> t_0.Cat2 IN (SELECT 545 UNION SELECT ID FROM cat WHERE ParentID = 545) +> +> seeing that it correctly guesses there are only going to be about 8 rows +> in the union. Part of the reason is that cat2 is smallint, whereas the +> output of the union must be at least int, maybe wider depending on the +> datatype of cat.id (which you did not show us); so the comparison isn't +> hashable. Even a smallint vs int comparison would be mergejoinable, +> though, so I'm really wondering what cat.id is. + +cat.id is a smallint. I replaced that subquery with these two: +t_0.Cat2 IN (SELECT '545'::smallint UNION SELECT ID FROM cat WHERE +ParentID = '545'::smallint) + +t_0.Cat2 IN (SELECT '545' UNION SELECT ID FROM cat WHERE ParentID = '545') + +But appareantly there is a bug in the explain mechanism of the 8.1devel +I'm using (I downloaded a nightly 25 august somewhere in the morning +(CEST)), since it returned: +ERROR: bogus varno: 9 + +So I can't see whether the plan changed, execution times didn't change +much. I also replaced the subselect with the result of that query (like +('545', '546', ...) ) but that didn't seem to make much difference in +the execution time as well. The plan did change of course, it used a +BitmapOr of 8 Bitmap Index Scans over the pwprodukten. + +By the way, as far as I know, this is the only datatype mismatch in the +query. + +> Another big part of the problem comes from poor result size estimation. +> I'm not sure you can eliminate that entirely given the multiple +> conditions on different columns (which'd require cross-column statistics +> to really do well, which we do not have). But you could avoid +> constructs like +> +> WHERE ... t_1.recordtimestamp >= +> (SELECT max_date - 60 FROM last_dates WHERE table_name = 'pricetracker') +> +> The planner is basically going to throw up its hands and make a default +> guess on the selectivity of this; it's not smart enough to decide that +> the sub-select probably represents a constant. What I'd do with this +> is to define a function marked STABLE for the sub-select result, perhaps +> something like +[...] +> need.) Then write the query like +> +> WHERE ... t_1.recordtimestamp >= get_last_date('pricetracker', 60) +> +> In this formulation the planner will be able to make a reasonable guess +> about how many rows will match ... at least if your statistics are up +> to date ... + +I tried such a function and also tried replacing it with the fixed +outcome of that suquery itself. Although it has a considerable more +accurate estimate of the rows returned, it doesn't seem to impact the +basic plan much. It does make the sub-query itself use another index +(the one on the recordtimestamp alone, rather than the combined index on +leverancierid and recordtimestamp). +With that changed subquery it estimates about 4173 rows over 4405 real rows. + +Actually with the adjusted or original query, it seems to favor the hash +join over a nested loop, but the rest of the plan (for the subqueries) +seems to be exactly the same. + +Here is the first part of the explain analyze when it can do any trick +it wants: + Hash Join (cost=7367.43..186630.19 rows=132426 width=12) (actual +time=191.726..11072.025 rows=58065 loops=1) + Hash Cond: ("outer".produktid = "inner".id) + -> Seq Scan on pwprijs chart_2 (cost=0.00..137491.07 rows=7692207 +width=16) (actual time=0.018..6267.744 rows=7692207 loops=1) + -> Hash (cost=7366.02..7366.02 rows=565 width=4) (actual +time=123.265..123.265 rows=103 loops=1) + -> SetOp Intersect (cost=7332.10..7360.37 rows=565 width=4) +(actual time=115.760..123.192 rows=103 loops=1) +[snip] + +And here is the first (and last) part when I disable hash joins or seq +scans: + Nested Loop (cost=7334.92..517159.39 rows=132426 width=12) (actual +time=111.905..512.575 rows=58065 loops=1) + -> SetOp Intersect (cost=7332.10..7360.37 rows=565 width=4) +(actual time=111.588..120.035 rows=103 loops=1) +[snip] + -> Bitmap Heap Scan on pwprijs chart_2 (cost=2.82..895.85 rows=234 +width=16) (actual time=0.344..2.149 rows=564 loops=103) + Recheck Cond: (chart_2.produktid = "outer".id) + -> Bitmap Index Scan on pwprijs_produktid_idx +(cost=0.00..2.82 rows=234 width=0) (actual time=0.189..0.189 rows=564 +loops=103) + Index Cond: (chart_2.produktid = "outer".id) + +Is a nested loop normally so much (3x) more costly than a hash join? Or +is it just this query that gets estimated wronly? + +Best regards, + +Arjen + +From pgsql-performance-owner@postgresql.org Sat Aug 27 11:27:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B947D7D0A + for ; + Sat, 27 Aug 2005 11:26:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45407-09 + for ; + Sat, 27 Aug 2005 14:26:58 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 96F8DD7D04 + for ; + Sat, 27 Aug 2005 11:26:56 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7RER19s001117; + Sat, 27 Aug 2005 10:27:01 -0400 (EDT) +To: Arjen van der Meijden +Cc: pgsql-performance@postgresql.org +Subject: Re: Inefficient queryplan for query with intersectable +In-reply-to: <4310456F.8040303@tweakers.net> +References: <430EF844.70905@tweakers.net> <430F1393.5040704@archonet.com> + <430F8699.3030400@tweakers.net> <26436.1125096976@sss.pgh.pa.us> + <4310456F.8040303@tweakers.net> +Comments: In-reply-to Arjen van der Meijden + message dated "Sat, 27 Aug 2005 12:50:23 +0200" +Date: Sat, 27 Aug 2005 10:27:01 -0400 +Message-ID: <1116.1125152821@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/477 +X-Sequence-Number: 14224 + +Arjen van der Meijden writes: +> But appareantly there is a bug in the explain mechanism of the 8.1devel +> I'm using (I downloaded a nightly 25 august somewhere in the morning +> (CEST)), since it returned: +> ERROR: bogus varno: 9 + +Yeah, someone else sent in a test case for this failure (or at least one +with a similar symptom) yesterday. I'll try to fix it today. + +> Is a nested loop normally so much (3x) more costly than a hash join? Or +> is it just this query that gets estimated wronly? + +There's been some discussion that we are overestimating the cost of +nestloops in general, because we don't take into account that successive +scans of the inner relation are likely to find many pages already in +cache from the earlier scans. So far no one's come up with a good cost +model to use for this, though. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Aug 27 13:42:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 021EFD7D64 + for ; + Sat, 27 Aug 2005 13:42:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70429-05 + for ; + Sat, 27 Aug 2005 16:42:49 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C4982D7DD6 + for ; + Sat, 27 Aug 2005 12:05:08 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7RF51gh001405; + Sat, 27 Aug 2005 11:05:01 -0400 (EDT) +To: "Steinar H. Gunderson" +Cc: pgsql-performance@postgresql.org +Subject: Re: Weird performance drop after VACUUM +In-reply-to: <20050827101945.GA18155@uio.no> +References: <1125093859.9329.30.camel@localhost.localdomain> + <26745.1125099111@sss.pgh.pa.us> <20050827101945.GA18155@uio.no> +Comments: In-reply-to "Steinar H. Gunderson" + message dated "Sat, 27 Aug 2005 12:19:45 +0200" +Date: Sat, 27 Aug 2005 11:05:01 -0400 +Message-ID: <1404.1125155101@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/481 +X-Sequence-Number: 14228 + +"Steinar H. Gunderson" writes: +> On Fri, Aug 26, 2005 at 07:31:51PM -0400, Tom Lane wrote: +>> Or you could just play with the order of the filter conditions ... for +>> example, the date condition at the end is probably far cheaper to test +>> than the text comparisons, so if that's fairly selective it'd be worth +>> putting it first. + +> That's an interesting approach -- could the planner do such things itself? + +It could, but it doesn't really have enough information. We don't +currently have any model that some operators are more expensive than +others. IIRC the only sort of reordering the current code will do +in a filter condition list is to push clauses involving sub-SELECTs +to the end. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Aug 27 12:11:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37942D6E2C + for ; + Sat, 27 Aug 2005 12:10:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53989-06 + for ; + Sat, 27 Aug 2005 15:10:56 +0000 (GMT) +Received: from smtpauth09.mail.atl.earthlink.net + (smtpauth09.mail.atl.earthlink.net [209.86.89.69]) + by svr1.postgresql.org (Postfix) with ESMTP id 25AA8D7C5B + for ; + Sat, 27 Aug 2005 12:10:55 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=ZYgVoeWoDS6VPD3ahdSv1VFqkTXz8uxTbZDthNscQr1xuo4+Tsi7qyWoWQ8HahTo; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth09.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1E92Kc-0006nQ-HO; Sat, 27 Aug 2005 11:10:54 -0400 +Message-Id: <6.2.3.4.0.20050827104222.05e36150@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Sat, 27 Aug 2005 11:07:37 -0400 +To: Tom Lane , pgsql-performance@postgresql.org +From: Ron +Subject: Re: Inefficient queryplan for query with +In-Reply-To: <1116.1125152821@sss.pgh.pa.us> +References: <430EF844.70905@tweakers.net> <430F1393.5040704@archonet.com> + <430F8699.3030400@tweakers.net> <26436.1125096976@sss.pgh.pa.us> + <4310456F.8040303@tweakers.net> <1116.1125152821@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc714bbc61b37f6eea4fc0fe41ee64c9e8350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.425 required=5 tests=[AWL=0.051, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/478 +X-Sequence-Number: 14225 + +At 10:27 AM 8/27/2005, Tom Lane wrote: +>Arjen van der Meijden writes: +> > But appareantly there is a bug in the explain mechanism of the 8.1devel +> > I'm using (I downloaded a nightly 25 august somewhere in the morning +> > (CEST)), since it returned: +> > ERROR: bogus varno: 9 +> +>Yeah, someone else sent in a test case for this failure (or at least one +>with a similar symptom) yesterday. I'll try to fix it today. +> +> > Is a nested loop normally so much (3x) more costly than a hash join? Or +> > is it just this query that gets estimated wronly? +> +>There's been some discussion that we are overestimating the cost of +>nestloops in general, because we don't take into account that successive +>scans of the inner relation are likely to find many pages already in +>cache from the earlier scans. So far no one's come up with a good cost +>model to use for this, though. +> +> regards, tom lane +It certainly seems common in the EXPLAIN ANALYZE output I see that +the (estimated) cost of Nested Loop is far higher than the actual +time measured. + +What happened when someone tried the naive approach of telling the +planner to estimate the cost of a nested loop based on fitting +whatever entities are involved in the nested loop in RAM as much as +possible? When there are multiple such mappings, use whichever one +results in the lowest cost for the NL in question. + +Clearly, this should lead to an underestimate of the cost of the +constant of operation involved, but since nested loops have the only +polynomial growth function of the planner's choices, NL's should +still have a decent chance of being more expensive than other choices +under most circumstances. + +In addition, if those costs are based on actual measurements of how +long it takes to do such scans then the estimated cost has a decent +chance of being fairly accurate under such circumstances. + +It might not work well, but it seems like a reasonable first attempt +at a solution? +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Sat Aug 27 12:26:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A8FFD790E + for ; + Sat, 27 Aug 2005 12:26:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58452-02 + for ; + Sat, 27 Aug 2005 15:26:09 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 67424D795F + for ; + Sat, 27 Aug 2005 12:26:06 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1E92ZI-00065v-Hm + for pgsql-performance@postgresql.org; Sat, 27 Aug 2005 17:26:04 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1E92ZH-0006Pr-00 + for ; Sat, 27 Aug 2005 17:26:03 +0200 +Date: Sat, 27 Aug 2005 17:26:03 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Weird performance drop after VACUUM +Message-ID: <20050827152603.GF17097@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <1125093859.9329.30.camel@localhost.localdomain> + <26745.1125099111@sss.pgh.pa.us> + <20050827101945.GA18155@uio.no> <1404.1125155101@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <1404.1125155101@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.11.8 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 required=5 tests=[AWL=0.015] +X-Spam-Level: +X-Archive-Number: 200508/479 +X-Sequence-Number: 14226 + +On Sat, Aug 27, 2005 at 11:05:01AM -0400, Tom Lane wrote: +> It could, but it doesn't really have enough information. We don't +> currently have any model that some operators are more expensive than +> others. IIRC the only sort of reordering the current code will do +> in a filter condition list is to push clauses involving sub-SELECTs +> to the end. + +I was more thinking along the lines of reordering "a AND/OR b" to "b AND/OR +a" if b has lower selectivity than a. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sat Aug 27 12:40:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 84733D7C46 + for ; + Sat, 27 Aug 2005 12:40:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61700-02 + for ; + Sat, 27 Aug 2005 15:40:46 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A3B65D795F + for ; + Sat, 27 Aug 2005 12:40:45 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7RFeg2O001639; + Sat, 27 Aug 2005 11:40:42 -0400 (EDT) +To: "Steinar H. Gunderson" +Cc: pgsql-performance@postgresql.org +Subject: Re: Weird performance drop after VACUUM +In-reply-to: <20050827152603.GF17097@uio.no> +References: <1125093859.9329.30.camel@localhost.localdomain> + <26745.1125099111@sss.pgh.pa.us> + <20050827101945.GA18155@uio.no> <1404.1125155101@sss.pgh.pa.us> + <20050827152603.GF17097@uio.no> +Comments: In-reply-to "Steinar H. Gunderson" + message dated "Sat, 27 Aug 2005 17:26:03 +0200" +Date: Sat, 27 Aug 2005 11:40:42 -0400 +Message-ID: <1638.1125157242@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/480 +X-Sequence-Number: 14227 + +"Steinar H. Gunderson" writes: +> On Sat, Aug 27, 2005 at 11:05:01AM -0400, Tom Lane wrote: +>> It could, but it doesn't really have enough information. We don't +>> currently have any model that some operators are more expensive than +>> others. IIRC the only sort of reordering the current code will do +>> in a filter condition list is to push clauses involving sub-SELECTs +>> to the end. + +> I was more thinking along the lines of reordering "a AND/OR b" to "b AND/OR +> a" if b has lower selectivity than a. + +Yeah, but if b is considerably more expensive to evaluate than a, that +could still be a net loss. To do it correctly you really need to trade +off cost of evaluation against selectivity, and the planner currently +only knows something about the latter (and all too often, not enough :-(). + +I'd like to do this someday, but until we get some cost info in there +I think it'd be a mistake to do much re-ordering of conditions. +Currently the SQL programmer can determine what happens by writing his +query carefully --- if we reorder based on selectivity only, we could +make things worse, and there'd be no way to override it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:04:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 54FE5D79A5 + for ; + Sat, 27 Aug 2005 13:03:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65600-04 + for ; + Sat, 27 Aug 2005 16:03:06 +0000 (GMT) +Received: from mailserv.pune.wibhu.com (unknown [210.212.168.94]) + by svr1.postgresql.org (Postfix) with ESMTP id 142E4D6F81 + for ; + Sat, 27 Aug 2005 13:03:03 -0300 (ADT) +Received: from mailserv.pune.wibhu.com (localhost.localdomain [127.0.0.1]) + by mailserv.pune.wibhu.com (8.12.8/8.12.5) with ESMTP id j7RFwwrw018599 + for ; Sat, 27 Aug 2005 21:28:59 +0530 +Received: (from apache@localhost) + by mailserv.pune.wibhu.com (8.12.8/8.12.8/Submit) id j7RFwvQj018597; + Sat, 27 Aug 2005 21:28:57 +0530 +X-Authentication-Warning: mailserv.pune.wibhu.com: apache set sender to + akshay@airtightnetworks.net using -f +Received: from 192.168.1.175 (SquirrelMail authenticated user akshay) + by mailserv with HTTP; Sat, 27 Aug 2005 21:28:57 +0530 (IST) +Message-ID: <2527.192.168.1.175.1125158337.squirrel@mailserv> +Date: Sat, 27 Aug 2005 21:28:57 +0530 (IST) +Subject: Observation about db response time +From: +To: +X-Priority: 3 +Importance: Normal +X-Mailer: SquirrelMail (version 1.2.10) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/521 +X-Sequence-Number: 14268 + +Hello Friends, +We were having a database in pgsql7.4. The database was responding very +slowly even after full vacuum (select +count(*) from some_table_having_18000_records was taking 18 Sec). + +We took a backup of that db and restored it back. Now the same db on +same PC is responding fast (same query is taking 18 ms). + +But we can't do the same as a solution of slow response. Do anybody has +faced similar problem? Is this due to any internal problem of pgsql? Is +there any clue to fasteen the database? + +Regards, + +akshay + + + + +From pgsql-performance-owner@postgresql.org Sat Aug 27 19:18:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 80560D7F1B + for ; + Sat, 27 Aug 2005 19:18:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63588-03 + for ; + Sat, 27 Aug 2005 22:18:03 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 206EED7F0A + for ; + Sat, 27 Aug 2005 19:18:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7RMHpaX010923; + Sat, 27 Aug 2005 18:17:52 -0400 (EDT) +To: Mark Kirkwood +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: Limit + group + join +In-reply-to: <430FD61A.3020902@paradise.net.nz> +References: <20050826002709.GK10328@tobias.lan> + <430E85ED.60109@paradise.net.nz> <9501.1125071193@sss.pgh.pa.us> + <430FD61A.3020902@paradise.net.nz> +Comments: In-reply-to Mark Kirkwood + message dated "Sat, 27 Aug 2005 14:55:22 +1200" +Date: Sat, 27 Aug 2005 18:17:51 -0400 +Message-ID: <10922.1125181071@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/482 +X-Sequence-Number: 14229 + +Mark Kirkwood writes: +> joinlimit=# EXPLAIN SELECT c.id FROM c JOIN b ON c_id=c.id GROUP BY +> c.id ORDER BY c.id DESC LIMIT 5; +> [ fails to pick an available index-scan-backward plan ] + +I looked into this and found that indeed the desirable join plan was +getting generated, but it wasn't picked because query_planner didn't +have an accurate idea of how much of the join needed to be scanned to +satisfy the GROUP BY step. I've committed some changes that hopefully +will let 8.1 be smarter about GROUP BY ... LIMIT queries. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Aug 27 21:49:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A79B8D7FB3 + for ; + Sat, 27 Aug 2005 21:49:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98036-04 + for ; + Sun, 28 Aug 2005 00:49:00 +0000 (GMT) +Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz [202.0.58.22]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EF57D7F8B + for ; + Sat, 27 Aug 2005 21:48:58 -0300 (ADT) +Received: from smtp-3.paradise.net.nz (smtp-3a.paradise.net.nz [202.0.32.196]) + by linda-3.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0ILW00E5IQ9P82@linda-3.paradise.net.nz> for + pgsql-performance@postgresql.org; Sun, 28 Aug 2005 12:49:02 +1200 (NZST) +Received: from [192.168.1.11] (218-101-45-94.paradise.net.nz [218.101.45.94]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id 467C7AE927; Sun, + 28 Aug 2005 12:49:01 +1200 (NZST) +Date: Sun, 28 Aug 2005 12:48:59 +1200 +From: Mark Kirkwood +Subject: Re: Limit + group + join +In-reply-to: <10922.1125181071@sss.pgh.pa.us> +To: Tom Lane +Cc: Tobias Brox , + pgsql-performance@postgresql.org +Message-id: <431109FB.6000505@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) +References: <20050826002709.GK10328@tobias.lan> + <430E85ED.60109@paradise.net.nz> <9501.1125071193@sss.pgh.pa.us> + <430FD61A.3020902@paradise.net.nz> <10922.1125181071@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.142 required=5 tests=[AWL=0.142] +X-Spam-Level: +X-Archive-Number: 200508/483 +X-Sequence-Number: 14230 + +Tom Lane wrote: +> +> I looked into this and found that indeed the desirable join plan was +> getting generated, but it wasn't picked because query_planner didn't +> have an accurate idea of how much of the join needed to be scanned to +> satisfy the GROUP BY step. I've committed some changes that hopefully +> will let 8.1 be smarter about GROUP BY ... LIMIT queries. +> + +Very nice :-) + +joinlimit=# EXPLAIN SELECT c.id FROM c JOIN b ON c_id=c.id GROUP BY +c.id ORDER BY c.id DESC LIMIT 5; + QUERY PLAN + +-------------------------------------------------------------------------------------------------- + Limit (cost=0.00..15.23 rows=5 width=4) + -> Group (cost=0.00..243730.00 rows=80000 width=4) + -> Nested Loop (cost=0.00..243530.00 rows=80000 width=4) + -> Index Scan Backward using c_pkey on c +(cost=0.00..1450.00 rows=80000 width=4) + -> Index Scan using b_on_c on b (cost=0.00..3.01 +rows=1 width=4) + Index Cond: (b.c_id = "outer".id) +(6 rows) + +This is 8.1devel from today. + +regards + +Mark + +From pgsql-performance-owner@postgresql.org Sat Aug 27 22:43:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C467D7F1B + for ; + Sat, 27 Aug 2005 22:43:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10635-05 + for ; + Sun, 28 Aug 2005 01:42:58 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E7ADDD78B5 + for ; + Sat, 27 Aug 2005 22:42:55 -0300 (ADT) +Received: from [80.203.125.83] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1E9C9g-0005f1-Ao; Sun, 28 Aug 2005 03:40:24 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id 25EA0E169B; Sun, 28 Aug 2005 03:42:41 +0200 (CEST) +Date: Sun, 28 Aug 2005 03:42:40 +0200 +From: Tobias Brox +To: Mark Kirkwood +Cc: Tom Lane , Tobias Brox , + pgsql-performance@postgresql.org +Subject: Re: Limit + group + join +Message-ID: <20050828014240.GB5736@tobias.lan> +References: <20050826002709.GK10328@tobias.lan> + <430E85ED.60109@paradise.net.nz> <9501.1125071193@sss.pgh.pa.us> + <430FD61A.3020902@paradise.net.nz> <10922.1125181071@sss.pgh.pa.us> + <431109FB.6000505@paradise.net.nz> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <431109FB.6000505@paradise.net.nz> +Organization: Group Nordicbet +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/484 +X-Sequence-Number: 14231 + +[Tom Lane] +> I looked into this and (...) I've committed some changes that hopefully will +> let 8.1 be smarter about GROUP BY ... LIMIT queries. + +[Mark Kirkwood] +> Very nice :-) +(...) +> This is 8.1devel from today. + +Splendid :-) Unfortunately we will not be upgrading for some monthes still, +but anyway I'm happy. This provides yet another good argument for upgrading +sooner. I'm also happy to see such a perfect match: + + - A problem that can be reduced from beeing complex and + production-specific, to simple and easily reproducible. + + - Enthusiastic people testing it and pinpointing even more precisely what + conditions will cause the condition + + - Programmers actually fixing the issue + + - Testers verifying that it was fixed + +Long live postgresql! :-) + +-- +Notice of Confidentiality: This email is sent unencrypted over the network, +and may be stored on several email servers; it can be read by third parties +as easy as a postcard. Do not rely on email for confidential information. + +From pgsql-performance-owner@postgresql.org Sun Aug 28 11:44:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DD7CCD7DB1 + for ; + Sun, 28 Aug 2005 11:44:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97976-07 + for ; + Sun, 28 Aug 2005 14:44:32 +0000 (GMT) +Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C78DD7D9F + for ; + Sun, 28 Aug 2005 11:44:31 -0300 (ADT) +Received: from [10.0.0.2] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) + by olive.qinip.net (Postfix) with ESMTP + id 5B420180DA; Sun, 28 Aug 2005 16:44:33 +0200 (MEST) +Message-ID: <4311CDD5.8060508@tweakers.net> +Date: Sun, 28 Aug 2005 16:44:37 +0200 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Inefficient queryplan for query with intersectable +References: <430EF844.70905@tweakers.net> <430F1393.5040704@archonet.com> + <430F8699.3030400@tweakers.net> <26436.1125096976@sss.pgh.pa.us> + <4310456F.8040303@tweakers.net> <1116.1125152821@sss.pgh.pa.us> +In-Reply-To: <1116.1125152821@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/485 +X-Sequence-Number: 14232 + +On 27-8-2005 16:27, Tom Lane wrote: +> Arjen van der Meijden writes: +> +>>Is a nested loop normally so much (3x) more costly than a hash join? Or +>>is it just this query that gets estimated wronly? +> +> There's been some discussion that we are overestimating the cost of +> nestloops in general, because we don't take into account that successive +> scans of the inner relation are likely to find many pages already in +> cache from the earlier scans. So far no one's come up with a good cost +> model to use for this, though. + +Ah, that explains. I take it, there already is an estimation for the +cost of "the amount of pages that will be loaded for this operation". +For indexed lookups this will probably be something like "the amount of +expected pages to fetch * the random page cost"? + +And appareantly for the nested loop its something like "iterations * +amount of pages per iteration * random page cost" ? +The naive approach seems to me, is to just calculate the probable amount +of pages to fetch from disk rather than from cache. + +In this case there are 7692207 rows in 60569 pages and on average 234 +rows per product (per nested loop) in the estimation. It estimates that +it'll have to do 565 iterations. +In worst case for the first 234 rows, no pages are already cached and +the rows are all in a seperate page. So thats 234 pages to fetch. +In the second iteration, you know already 234 pages are fetched and +that's about 0.386% of the total pages. So the expected amount of pages +for the next 234 pages expected to be in cache is 234 * 0.00386 = 1. +After that you'll have 234 + 233 pages in cache, etc, etc. +Following that approach, the 565th iteration only has to pull in about +27 new pages in the worst case of all records being perfectly scattered +over the pages, not 234. + +Of course this has to be adjusted for the amount of available buffers +and cache and the expected amount of pages to fetch for the iterations, +which may be less than 234. + +When a fetch of a random page costs 4 and one from cache 0.01, there is +quite a large difference: 565 * (234 * 4) = 530535 vs 215864,93 + +Actually the likeliness of a page being in cache is a bit higher, since +the expectation increases for each newly fetched page, not for batches +of 234. I didn't use that in my calculation here. + +Anyway, this is probably been thought over already and there may be many +flaws in it. If not, please think it over. + +Best regards, + +Arjen + +From pgsql-performance-owner@postgresql.org Sun Aug 28 17:00:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B4DB0D80BF + for ; + Sun, 28 Aug 2005 17:00:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70984-10 + for ; + Sun, 28 Aug 2005 20:00:50 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CA10D80A3 + for ; + Sun, 28 Aug 2005 17:00:47 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7SK0nVu026477; + Sun, 28 Aug 2005 16:00:49 -0400 (EDT) +To: Jeff Trout +Cc: postgres performance +Subject: Re: OSX & Performance +In-reply-to: +References: +Comments: In-reply-to Jeff Trout + message dated "Fri, 26 Aug 2005 14:58:17 -0400" +Date: Sun, 28 Aug 2005 16:00:49 -0400 +Message-ID: <26476.1125259249@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/486 +X-Sequence-Number: 14233 + +Jeff Trout writes: +> Tracking ti down a bit timestamp_cmp_internal (The btree was made of +> a timestamp & and int) was taking a large amount of time - +> specifically all the calls it makes to isnan(x). 14.1% in __isnand + +Hmm, can you provide a test case for other people to poke at? + +> Also, two things to note, one of which is quite important: On tiger +> (10.4) PG compiles with NO OPTIMIZATION. Probably a template file +> needs to be updated. +> Panther seems to compile with -O2 though. + +I see -O2 when building PG (CVS tip) on a fully up-to-date 10.4.2 +machine. Maybe something odd in your environment, like a preset +CFLAGS setting? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 28 17:41:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7864DD7F54 + for ; + Sun, 28 Aug 2005 17:41:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84281-02 + for ; + Sun, 28 Aug 2005 20:41:28 +0000 (GMT) +Received: from Apachihuilliztli.mtu.ru (apachihuilliztli.mtu.ru + [195.34.32.124]) + by svr1.postgresql.org (Postfix) with ESMTP id 40413D7E3D + for ; + Sun, 28 Aug 2005 17:41:26 -0300 (ADT) +Received: from umail.ru (umail.mtu.ru [195.34.32.101]) + by Apachihuilliztli.mtu.ru (Postfix) with ESMTP id 8A08C20A6F6 + for ; + Mon, 29 Aug 2005 00:41:25 +0400 (MSD) + (envelope-from ilia@obnovlenie.ru) +Received: from [85.140.125.21] (HELO ilia) + by umail.ru (CommuniGate Pro SMTP 4.2b6) + with ESMTP id 558490720 for pgsql-performance@postgresql.org; + Mon, 29 Aug 2005 00:41:24 +0400 +From: "Ilia Kantor" +To: +Subject: intarray is broken ? (8.1b1) +Date: Mon, 29 Aug 2005 00:41:18 +0400 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0017_01C5AC32.5E9A9B20" +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcWsENc/4YuF/s7KSymYIzUiy/y9EA== +Message-ID: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.192 required=5 tests=[AWL=0.141, + FORGED_RCVD_HELO=0.05, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/487 +X-Sequence-Number: 14234 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0017_01C5AC32.5E9A9B20 +Content-Type: text/plain; + charset="koi8-r" +Content-Transfer-Encoding: 7bit + +I tried to use intarray on 8.1 . It seems to give same estimates for +anything I ask: + + + +explain analyze select * from objects_hier where tg && array[10001] + +explain analyze select * from objects_hier where tg && array[0] + +explain analyze select * from objects_hier where tg @ array[10001] + +explain analyze select * from objects_hier where tg ~ array[0] + + + +Some of queries cover whole table, some cover none, but all give same +estimated number of rows: + + + +Bitmap Heap Scan on objects_hier (cost=2.10..102.75 rows=30 width=337) +(actual time=0.028..0.028 rows=0 loops=1) + + Recheck Cond: (tg && '{0}'::integer[]) + + -> Bitmap Index Scan on gistbla2 (cost=0.00..2.10 rows= !! 30 !! +width=0) (actual time=0.024..0.024 rows=0 loops=1) + + Index Cond: (tg && '{0}'::integer[]) + + + +See the number of estimated rows is 30 is all cases. + +But actually it varies from whole table (30000 rows) to 0. + + + +Looks like GIST indexes for intarray give no statistic at all. + + + +It makes them much much less useless than they could be.. Because planner +can't plan them well and makes horrible mistakes. + + + +For example, puts nested loops in order when for each of 30k rows it makes +an index scan within 5 rows => that leads to 30k nested scans, while it +should for each of 5 rows perform single index scan among those 30k. + + + + + +Yes, I have all necessary indexes on tables. + +And yes, I run VACUUM FULL ANALYZE just before the tests. + + + +The lack of estimation is not documented anywhere so I just hope this is a +bug and can be fixed fast :-) + + + + + + +------=_NextPart_000_0017_01C5AC32.5E9A9B20 +Content-Type: text/html; + charset="koi8-r" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

I tried to use intarray on 8.1 . It seems to = +give +same estimates for anything I ask:

+ +

 

+ +

explain analyze select * from objects_hier = +where tg && +array[10001]

+ +

explain analyze select * from objects_hier = +where tg && +array[0]

+ +

explain analyze select * from objects_hier = +where tg @ +array[10001]

+ +

explain analyze select * from objects_hier = +where tg ~ +array[0]

+ +

 

+ +

Some of queries cover whole table, some cover = +none, +but all give same estimated number of rows:

+ +

 

+ +

Bitmap Heap Scan on objects_hier=9A = +(cost=3D2.10..102.75 +rows=3D30 width=3D337) (actual time=3D0.028..0.028 rows=3D0 = +loops=3D1)

+ +

=9A=9A Recheck Cond: (tg && = +'{0}'::integer[])

+ +

=9A=9A ->=9A Bitmap Index Scan on = +gistbla2=9A +(cost=3D0.00..2.10 rows=3D !! 30 !! width=3D0) (actual = +time=3D0.024..0.024 rows=3D0 +loops=3D1)

+ +

=9A=9A=9A=9A=9A=9A=9A=9A Index Cond: (tg = +&& '{0}'::integer[])

+ +

 

+ +

See the number of estimated rows is 30 is all = +cases.

+ +

But actually it varies from whole table (30000 = +rows) to +0.

+ +

 

+ +

Looks like GIST indexes for intarray give no +statistic at all.

+ +

 

+ +

It makes them much much less useless than they = +could +be.. Because planner can’t plan them well and makes horrible = +mistakes.

+ +

 

+ +

For example, puts nested loops in order when = +for each +of 30k rows it makes an index scan within 5 rows =3D> that leads to = +30k nested +scans, while it should for each of 5 rows perform single index scan = +among those +30k.

+ +

 

+ +

 

+ +

Yes, I have all necessary indexes on = +tables.

+ +

And yes, I run VACUUM FULL ANALYZE just before = +the +tests.

+ +

 

+ +

The lack of estimation is not documented = +anywhere so +I just hope this is a bug and can be fixed fast J + +

 

+ +

 

+ +
+ + + + + +------=_NextPart_000_0017_01C5AC32.5E9A9B20-- + + +From pgsql-performance-owner@postgresql.org Sun Aug 28 17:48:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E00DD809C + for ; + Sun, 28 Aug 2005 17:48:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86573-01 + for ; + Sun, 28 Aug 2005 20:48:47 +0000 (GMT) +Received: from Apachihuilliztli.mtu.ru (apachihuilliztli.mtu.ru + [195.34.32.124]) + by svr1.postgresql.org (Postfix) with ESMTP id 22A3AD8100 + for ; + Sun, 28 Aug 2005 17:48:45 -0300 (ADT) +Received: from umail.ru (umail.mtu.ru [195.34.32.101]) + by Apachihuilliztli.mtu.ru (Postfix) with ESMTP id A985820A626 + for ; + Mon, 29 Aug 2005 00:48:47 +0400 (MSD) + (envelope-from ilia@obnovlenie.ru) +Received: from [85.140.125.21] (HELO ilia) + by umail.ru (CommuniGate Pro SMTP 4.2b6) + with ESMTP id 558491990 for pgsql-performance@postgresql.org; + Mon, 29 Aug 2005 00:48:47 +0400 +From: "Ilia Kantor" +To: +Subject: Bitmap scan when it is not needed +Date: Mon, 29 Aug 2005 00:48:40 +0400 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_001E_01C5AC33.6672B430" +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcWsEd8vVV8k6GFwS/uc4O6Py5kyLw== +Message-ID: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.156 required=5 tests=[AWL=0.105, + FORGED_RCVD_HELO=0.05, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/488 +X-Sequence-Number: 14235 + +This is a multi-part message in MIME format. + +------=_NextPart_000_001E_01C5AC33.6672B430 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +explain analyze select * from objects_hier where tg && array[0] and id +<10000; + + + +Bitmap Heap Scan on objects_hier (cost=4.79..8.80 rows=1 width=337) (actual +time=0.110..0.110 rows=0 loops=1) + + Recheck Cond: ((tg && '{0}'::integer[]) AND (id < 10000)) + + -> BitmapAnd (cost=4.79..4.79 rows=1 width=0) (actual time=0.106..0.106 +rows=0 loops=1) + + -> Bitmap Index Scan on gistbla2 (cost=0.00..2.10 rows=30 +width=0) (actual time=0.042..0.042 rows=0 loops=1) + + Index Cond: (tg && '{0}'::integer[]) + + -> Bitmap Index Scan on ohid (cost=0.00..2.44 rows=1240 width=0) +(actual time=0.058..0.058 rows=1255 loops=1) + + Index Cond: (id < 10000) + + + +I see, Bitmap is going to AND my indexes.. It read one with less number of +rows estimated the first (right).. + +It found 0 records at gistbla2 index. + + + +Then why is it reading ohid ? + + + +Maybe a quickfix is possible for cases when 0 records is found to stop +reading other AND elements.. + + + + +------=_NextPart_000_001E_01C5AC33.6672B430 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

explain analyze select * from objects_hier = +where tg +&& array[0] and id <10000;

+ +

 

+ +

Bitmap Heap Scan on objects_hier  +(cost=3D4.79..8.80 rows=3D1 width=3D337) (actual time=3D0.110..0.110 = +rows=3D0 loops=3D1)

+ +

   Recheck Cond: ((tg && +'{0}'::integer[]) AND (id < 10000))

+ +

   ->  BitmapAnd  +(cost=3D4.79..4.79 rows=3D1 width=3D0) (actual time=3D0.106..0.106 = +rows=3D0 loops=3D1)

+ +

        = +; +->  Bitmap Index Scan on gistbla2  (cost=3D0.00..2.10 = +rows=3D30 +width=3D0) (actual time=3D0.042..0.042 rows=3D0 = +loops=3D1)

+ +

        = +;       +Index Cond: (tg && = +'{0}'::integer[])

+ +

        = +; +->  Bitmap Index Scan on ohid  (cost=3D0.00..2.44 = +rows=3D1240 width=3D0) +(actual time=3D0.058..0.058 rows=3D1255 = +loops=3D1)

+ +

        = +;       +Index Cond: (id < 10000)

+ +

 

+ +

I see, Bitmap is going to AND my indexes.. It = +read +one with less number of rows estimated the first = +(right)..

+ +

It found 0 records at gistbla2 = +index…

+ +

 

+ +

Then why is it reading ohid ?  = +

+ +

 

+ +

Maybe a quickfix is possible for cases when 0 = +records +is found to stop reading other AND = +elements..

+ +

 

+ +
+ + + + + +------=_NextPart_000_001E_01C5AC33.6672B430-- + + +From pgsql-performance-owner@postgresql.org Sun Aug 28 17:59:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C06DD809C + for ; + Sun, 28 Aug 2005 17:59:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88311-05 + for ; + Sun, 28 Aug 2005 20:59:40 +0000 (GMT) +Received: from Apachihuilliztli.mtu.ru (apachihuilliztli.mtu.ru + [195.34.32.124]) + by svr1.postgresql.org (Postfix) with ESMTP id A8059D7F54 + for ; + Sun, 28 Aug 2005 17:59:38 -0300 (ADT) +Received: from umail.ru (umail.mtu.ru [195.34.32.101]) + by Apachihuilliztli.mtu.ru (Postfix) with ESMTP id 5ECC520A61B + for ; + Mon, 29 Aug 2005 00:59:40 +0400 (MSD) + (envelope-from ilia@obnovlenie.ru) +Received: from [85.140.125.21] (HELO ilia) + by umail.ru (CommuniGate Pro SMTP 4.2b6) + with ESMTP id 558493797 for pgsql-performance@postgresql.org; + Mon, 29 Aug 2005 00:59:39 +0400 +From: "Ilia Kantor" +To: +Subject: Planner improvement suggestion +Date: Mon, 29 Aug 2005 00:59:33 +0400 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0022_01C5AC34.EB419DB0" +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcWsE2QHh/PeY0pPRG29Y8huSDcQOw== +Message-ID: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.135 required=5 tests=[AWL=0.084, + FORGED_RCVD_HELO=0.05, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/489 +X-Sequence-Number: 14236 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0022_01C5AC34.EB419DB0 +Content-Type: text/plain; + charset="koi8-r" +Content-Transfer-Encoding: 7bit + +I have a query: + + + +SELECT oh.id +FROM objects_hier oh +where +oh.id < 2000 (!) +and +oh.id in ( + SELECT id as id FROM objects_access oa + WHERE + oa.master IN (1,2,10001) + AND + oa.id < 2000 (!) + +) + + + +The sense of the query is simple: I choose ids from objects_hier where +access has necessary masters. + + + +The problem is: I have duplicate conditions for id here. They are marked +with '!'. + + + +I just can't remove any of them, because planner needs to estimate both +outer and inner selects to calculate the order + +Of nested loop or choose a join. If I remove one of duplicate conditions - +planner can't estimate well. + + + +It's obvious that condition on oh.id can be put inside or outside "oh.id in +( .. )" statement with same result. + + + +So I just suggest that the planner should take this into account and +"propagate" the condition outside or inside for planning if needed. + + + +P.S + +Is there a way to fix this particular query? Usually oh.id condition is not +like <2000, but an inner join. + + + + + + + + + + + + + + +------=_NextPart_000_0022_01C5AC34.EB419DB0 +Content-Type: text/html; + charset="koi8-r" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

I have a query:

+ +

 

+ +
SELECT =
+oh.id
FROM =
+objects_hier oh
where
oh.id =
+< 2000 (!)
and
oh.id =
+in (
=9A=9A=9A=9A=9A SELECT id as id FROM =
+objects_access oa
=9A=9A=9A=9A=9A =
+WHERE
=9A=9A=9A=9A=9A oa.master IN =
+(1,2,10001)
=9A=9A=9A=9A=9A =
+AND
=9A=9A=9A=9A=9A oa.id < 2000 =
+(!)
+ +

)

+ +

 

+ +

The sense of the query is simple: I choose = +ids from +objects_hier where access has necessary = +masters.

+ +

 

+ +

The problem is: I have duplicate conditions = +for id +here. They are marked with ‘!’.

+ +

 

+ +

I just can’t remove any of them, = +because planner +needs to estimate both outer and inner selects to calculate the = +order

+ +

Of nested loop or choose a join. If I remove = +one of duplicate +conditions – planner can’t estimate = +well.

+ +

 

+ +

It’s obvious that condition on oh.id = +can be put +inside or outside “oh.id in ( .. )” statement with same = +result.

+ +

 

+ +

So I just suggest that the planner should = +take this +into account and “propagate” the condition outside or inside = +for +planning if needed.

+ +

 

+ +

P.S

+ +

Is there a way to fix this particular query? = +Usually +oh.id condition is not like <2000, but an inner = +join.

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +
+ + + + + +------=_NextPart_000_0022_01C5AC34.EB419DB0-- + + +From pgsql-performance-owner@postgresql.org Sun Aug 28 18:25:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 36AE9D712A + for ; + Sun, 28 Aug 2005 18:25:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95360-01 + for ; + Sun, 28 Aug 2005 21:25:05 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B9C6D6E11 + for ; + Sun, 28 Aug 2005 18:25:04 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7SLOvH5026889; + Sun, 28 Aug 2005 17:24:57 -0400 (EDT) +To: "Ilia Kantor" +Cc: pgsql-performance@postgresql.org +Subject: Re: intarray is broken ? (8.1b1) +In-reply-to: +References: +Comments: In-reply-to "Ilia Kantor" + message dated "Mon, 29 Aug 2005 00:41:18 +0400" +Date: Sun, 28 Aug 2005 17:24:57 -0400 +Message-ID: <26888.1125264297@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/490 +X-Sequence-Number: 14237 + +"Ilia Kantor" writes: +> Looks like GIST indexes for intarray give no statistic at all. + +Feel free to contribute some stats routines that aren't stubs ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 28 18:30:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 550B8D8097 + for ; + Sun, 28 Aug 2005 18:30:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94778-06 + for ; + Sun, 28 Aug 2005 21:30:50 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A0B7D809A + for ; + Sun, 28 Aug 2005 18:30:49 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7SLUmHF026928; + Sun, 28 Aug 2005 17:30:50 -0400 (EDT) +To: "Ilia Kantor" +Cc: pgsql-performance@postgresql.org +Subject: Re: Planner improvement suggestion +In-reply-to: +References: +Comments: In-reply-to "Ilia Kantor" + message dated "Mon, 29 Aug 2005 00:59:33 +0400" +Date: Sun, 28 Aug 2005 17:30:48 -0400 +Message-ID: <26927.1125264648@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/491 +X-Sequence-Number: 14238 + +"Ilia Kantor" writes: +> So I just suggest that the planner should take this into account and +> "propagate" the condition outside or inside for planning if needed. + +I believe it does this already for equality conditions, but not for +inequalities. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 28 19:49:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A733BD6ECD + for ; + Sun, 28 Aug 2005 19:49:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16343-03 + for ; + Sun, 28 Aug 2005 22:49:08 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 346E8D6EA0 + for ; + Sun, 28 Aug 2005 19:49:07 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7SMn7MZ028245; + Sun, 28 Aug 2005 18:49:08 -0400 (EDT) +To: "Ilia Kantor" +Cc: pgsql-performance@postgresql.org +Subject: Re: Bitmap scan when it is not needed +In-reply-to: +References: +Comments: In-reply-to "Ilia Kantor" + message dated "Mon, 29 Aug 2005 00:48:40 +0400" +Date: Sun, 28 Aug 2005 18:49:07 -0400 +Message-ID: <28244.1125269347@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/492 +X-Sequence-Number: 14239 + +"Ilia Kantor" writes: +> Maybe a quickfix is possible for cases when 0 records is found to stop +> reading other AND elements.. + +Not sure how useful this will be in practice (since the planner tends +not to bother ANDing unselective indexes at all), but it's easy enough +to do ... so I did it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:03:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E8F6ED7AA4 + for ; + Mon, 29 Aug 2005 10:42:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75114-10 + for ; + Mon, 29 Aug 2005 13:42:49 +0000 (GMT) +Received: from iad2.emailsrvr.com (iad2.emailsrvr.com [207.97.227.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 271C1D79F5 + for ; + Mon, 29 Aug 2005 10:42:46 -0300 (ADT) +Received: from [10.10.20.22] (unknown [216.94.157.147]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + (Authenticated sender: remyb@medrium.com) + by relay3.r3.iad.emailsrvr.com (SMTP Server) with ESMTP id 55FC344C2A3; + Mon, 29 Aug 2005 09:42:39 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v622) +Message-Id: +Content-Type: multipart/alternative; boundary=Apple-Mail-1-986878859 +To: pgsql-performance@postgresql.org +Subject: High load and iowait but no disk access +From: =?ISO-8859-1?Q?R=E9my_Beaumont?= +Date: Mon, 29 Aug 2005 09:42:46 -0400 +X-Mailer: Apple Mail (2.622) +X-Virus-Scanned: OK +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/520 +X-Sequence-Number: 14267 + + +--Apple-Mail-1-986878859 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/plain; + charset=ISO-8859-1; + format=flowed + +We have been trying to pinpoint what originally seem to be a I/O=20 +bottleneck but which now seems to be an issue with either Postgresql or=20= + +RHES 3. + +We have the following test environment on which we can reproduce the=20 +problem: + +1) Test System A +Dell 6650 Quad Xeon Pentium 4 +8 Gig of RAM +OS: RHES 3 update 2 +Storage: NetApp FAS270 connected using an FC card using 10 disks + +2) Test System B +Dell Dual Xeon Pentium III +2 Gig o RAM +OS: RHES 3 update 2 +Storage: NetApp FAS920 connected using an FC card using 28 disks + +Our Database size is around 30G. + +The behavior we see is that when running queries that do random reads=20 +on disk, IOWAIT goes over 80% and actual disk IO falls to a crawl at a=20= + +throughput bellow 3000kB/s (We usually average 40000 kB/s to 80000 kB/s=20= + +on sequential read operations on the netapps) + +The stats of the NetApp do confirm that it is sitting idle. Doing an=20 +strace on the Postgresql process shows that is it doing seeks and=20 +reads. + +So my question is where is this iowait time spent ? +Is there a way to pinpoint the problem in more details ? +We are able to reproduce this behavior with Postgresql 7.4.8 and 8.0.3 + +I have included the output of top,vmstat,strace and systat from the=20 +Netapp from System B while running a single query that generates this=20 +behavior. + +R=E9my + +top output: + 06:27:28 up 5 days, 16:59, 6 users, load average: 1.04, 1.30, 1.01 +72 processes: 71 sleeping, 1 running, 0 zombie, 0 stopped +CPU states: cpu user nice system irq softirq iowait idle + total 2.7% 0.0% 1.0% 0.1% 0.2% 46.0% = +49.5% + cpu00 0.2% 0.0% 0.2% 0.0% 0.2% 2.2% = +97.2% + cpu01 5.3% 0.0% 1.9% 0.3% 0.3% 89.8% = +1.9% +Mem: 2061696k av, 2043936k used, 17760k free, 0k shrd, =20 +3916k buff + 1566332k actv, 296648k in_d, 30504k in_c +Swap: 16771584k av, 21552k used, 16750032k free =20 +1933772k cached + + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU=20 +COMMAND +30960 postgres 15 0 13424 10M 9908 D 2.7 0.5 2:00 1=20 +postmaster +30538 root 15 0 1080 764 524 S 0.7 0.0 0:43 0 sshd + 1 root 15 0 496 456 436 S 0.0 0.0 0:08 0 init + 2 root RT 0 0 0 0 SW 0.0 0.0 0:00 0=20 +migration/0 + 3 root RT 0 0 0 0 SW 0.0 0.0 0:00 1=20 +migration/1 + 4 root 15 0 0 0 0 SW 0.0 0.0 0:01 0=20 +keventd + 5 root 34 19 0 0 0 SWN 0.0 0.0 0:00 0=20 +ksoftirqd/0 + 6 root 34 19 0 0 0 SWN 0.0 0.0 0:00 1=20 +ksoftirqd/1 + 9 root 15 0 0 0 0 SW 0.0 0.0 0:24 1=20 +bdflush + 7 root 15 0 0 0 0 SW 0.0 0.0 6:53 1 = +kswapd + 8 root 15 0 0 0 0 SW 0.0 0.0 8:44 1 = +kscand + 10 root 15 0 0 0 0 SW 0.0 0.0 0:13 0=20 +kupdated + 11 root 25 0 0 0 0 SW 0.0 0.0 0:00 0=20 +mdrecoveryd + 17 root 15 0 0 0 0 SW 0.0 0.0 0:00 0=20 +ahc_dv_0 + + +vmstat output +procs memory swap io system =20= + + cpu + r b swpd free buff cache si so bi bo in cs us=20= + +sy id wa + 0 1 21552 17796 4872 1931928 2 3 3 1 27 6 2 =20= + +1 7 3 + 0 1 21552 18044 4880 1931652 0 0 1652 0 397 512 1 =20= + +2 50 47 + 0 1 21552 17976 4896 1931664 0 0 2468 0 407 552 2 =20= + +2 50 47 + 1 0 21552 17984 4896 1931608 0 0 2124 0 418 538 3 =20= + +3 48 46 + 0 1 21552 18028 4900 1931536 0 0 1592 0 385 509 1 =20= + +3 50 46 + 0 1 21552 18040 4916 1931488 0 0 1620 820 419 581 2 =20= + +2 50 46 + 0 1 21552 17968 4916 1931536 0 4 1708 4 402 554 3 =20= + +1 50 46 + 1 1 21552 18052 4916 1931388 0 0 1772 0 409 531 3 =20= + +1 49 47 + 0 1 21552 17912 4924 1931492 0 0 1772 0 408 565 3 =20= + +1 48 48 + 0 1 21552 17932 4932 1931440 0 4 1356 4 391 545 5 =20= + +0 49 46 + 0 1 21552 18320 4944 1931016 0 4 1500 840 414 571 1 =20= + +1 48 50 + 0 1 21552 17872 4944 1931440 0 0 2116 0 392 496 1 =20= + +5 46 48 + 0 1 21552 18060 4944 1931232 0 0 2232 0 423 597 1 =20= + +2 48 49 + 1 1 21552 17684 4944 1931584 0 0 1752 0 395 537 1 =20= + +1 50 48 + 0 1 21552 18000 4944 1931240 0 0 1576 0 401 549 0 =20= + +1 50 49 + + +NetApp stats: + CPU NFS CIFS HTTP Total Net kB/s Disk kB/s Tape kB/s=20 +Cache Cache CP CP Disk DAFS FCP iSCSI FCP kB/s + in out read write read write =20= + +age hit time ty util in out + 2% 0 0 0 139 0 0 2788 0 0 0 =20= + + 3 96% 0% - 15% 0 139 0 3 2277 + 2% 0 0 0 144 0 0 2504 0 0 0 =20= + + 3 96% 0% - 18% 0 144 0 3 2150 + 2% 0 0 0 130 0 0 2212 0 0 0 =20= + + 3 96% 0% - 13% 0 130 0 3 1879 + 3% 0 0 0 169 0 0 2937 80 0 0 =20= + + 3 96% 0% - 13% 0 169 0 4 2718 + 2% 0 0 0 139 0 0 2448 0 0 0 =20= + + 3 96% 0% - 12% 0 139 0 3 2096 + 2% 0 0 0 137 0 0 2116 0 0 0 =20= + + 3 96% 0% - 10% 0 137 0 3 1892 + 3% 0 0 0 107 0 0 2660 812 0 0 =20= + + 3 96% 24% T 20% 0 107 0 3 1739 + 2% 0 0 0 118 0 0 1788 0 0 0 =20= + + 3 96% 0% - 13% 0 118 0 3 1608 + 2% 0 0 0 136 0 0 2228 0 0 0 =20= + + 3 96% 0% - 11% 0 136 0 3 2018 + 2% 0 0 0 119 0 0 1940 0 0 0 =20= + + 3 96% 0% - 13% 0 119 0 3 1998 + 2% 0 0 0 136 0 0 2175 0 0 0 =20= + + 3 96% 0% - 14% 0 136 0 3 1929 + 2% 0 0 0 133 0 0 1924 0 0 0 =20= + + 3 96% 0% - 19% 0 133 0 3 2292 + 2% 0 0 0 115 0 0 2044 0 0 0 =20= + + 3 96% 0% - 11% 0 115 0 3 1682 + 2% 0 0 0 134 0 0 2256 0 0 0 =20= + + 3 96% 0% - 12% 0 134 0 3 2096 + 2% 0 0 0 112 0 0 2184 0 0 0 =20= + + 3 96% 0% - 12% 0 112 0 3 1633 + 2% 0 0 0 163 0 0 2348 0 0 0 =20= + + 3 96% 0% - 13% 0 163 0 4 2421 + 2% 0 0 0 120 0 0 2056 184 0 0 =20= + + 3 96% 8% T 14% 0 120 0 3 1703 + +strace output: +read(55, "\4\0\0\0\10fm}\1\0\0\0p\0\264\0\0 \2 \230\236\320\0020"...,=20 +8192) =3D 8192 +_llseek(55, 857997312, [857997312], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\\\315\321|\1\0\0\0p\0\354\0\0 \2 \250\236\260"...,=20 +8192) =3D 8192 +_llseek(55, 883220480, [883220480], SEEK_SET) =3D 0 +read(55, "\4\0\0\0T\17a~\1\0\0\0p\0\20\1\0 \2 \270\236\220\2D\235"...,=20= + +8192) =3D 8192 +_llseek(55, 858005504, [858005504], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\300\356\321|\1\0\0\0p\0\330\0\0 \2 \260\236\240"...,=20= + +8192) =3D 8192 +_llseek(55, 857964544, [857964544], SEEK_SET) =3D 0 +read(55, "\4\0\0\0lH\321|\1\0\0\0p\0<\1\0 \2 \300\236\200\2p\235"...,=20 +8192) =3D 8192 +_llseek(55, 857956352, [857956352], SEEK_SET) =3D 0 +read(55, "\4\0\0\0l\'\321|\1\0\0\0p\0\320\0\0 \2 \260\236\240\2\\"...,=20= + +8192) =3D 8192 +_llseek(55, 910802944, [910802944], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\10}\25\200\1\0\0\0l\0\274\1\0 \2 \250\236\260"...,=20 +8192) =3D 8192 +_llseek(55, 857948160, [857948160], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\370\5\321|\1\0\0\0p\0\350\0\0 \2 \230\236\320"...,=20 +8192) =3D 8192 +_llseek(56, 80371712, [80371712], SEEK_SET) =3D 0 +read(56, "\4\0\0\0Lf \217\1\0\0\0p\0\f\1\0 \2 \250\236\260\2T\235"...,=20= + +8192) =3D 8192 +read(102, "\2\0\34\0001\236\0\0\1\0\0\0\t\0\0\00020670\0\0\0B\6\0"...,=20= + +8192) =3D 8192 +_llseek(55, 857939968, [857939968], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\244\344\320|\1\0\0\0l\0\230\1\0 \2 \244\236\270"...,=20= + +8192) =3D 8192 +_llseek(55, 857923584, [857923584], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\224\242\320|\1\0\0\0p\0|\0\0 \2=20 +\234\236\310\002"..., 8192) =3D 8192 +_llseek(55, 57270272, [57270272], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\3204FK\1\0\0\0t\0\340\0\0 \2=20 +\310\236j\2\214\235"..., 8192) =3D 8192 +_llseek(55, 870727680, [870727680], SEEK_SET) =3D 0 +read(55, "\4\0\0\0x>\233}\1\0\0\0p\0@\1\0 \2 \250\236\260\2X\235"...,=20 +8192) =3D 8192 +_llseek(55, 1014734848, [1014734848], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\34\354\201\206\1\0\0\0p\0p\0\0 \2 \264\236\230"...,=20= + +8192) =3D 8192 +_llseek(55, 857874432, [857874432], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\214\331\317|\1\0\0\0l\0\324\1\0 \2 \224\236\330"...,=20= + +8192) =3D 8192 +_llseek(55, 760872960, [760872960], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\30\257\321v\1\0\0\0p\0\230\0\0 \2 \234\236\310"...,=20= + +8192) =3D 8192 +_llseek(55, 891715584, [891715584], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\370\220\347~\1\0\0\0p\0P\1\0 \2 \230\236\320\2"...,=20= + +8192) =3D 8192 +_llseek(55, 857858048, [857858048], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\250\227\317|\1\0\0\0p\0\264\0\0 \2 \254\236\250"...,=20= + +8192) =3D 8192 +_llseek(55, 666910720, [666910720], SEEK_SET) =3D 0 +read(55, "\4\0\0\0x\206\3q\1\0\0\0p\0004\1\0 \2=20 +\254\236\242\2P\235"..., 8192) =3D 8192 +_llseek(55, 857841664, [857841664], SEEK_SET) =3D 0 +read(55, "\4\0\0\0dT\317|\1\0\0\0p\0\224\0\0 \2 \214\236\350\2\30"...,=20= + +8192) =3D 8192 + + + +--Apple-Mail-1-986878859 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/enriched; + charset=ISO-8859-1 + +CourierWe have been trying to pinpoint what +originally seem to be a I/O bottleneck but which now seems to be an +issue with either Postgresql or RHES 3. + + +We have the following test environment on which we can reproduce the +problem: + + +1) Test System A + +Dell 6650 Quad Xeon Pentium 4 + +8 Gig of RAM + +OS: RHES 3 update 2 + +Storage: NetApp FAS270 connected using an FC card using 10 disks + + +2) Test System B + +Dell Dual Xeon Pentium III + +2 Gig o RAM + +OS: RHES 3 update 2 + +Storage: NetApp FAS920 connected using an FC card using 28 disks + + +Our Database size is around 30G.=20 + + +The behavior we see is that when running queries that do random reads +on disk, IOWAIT goes over 80% and actual disk IO falls to a crawl at a +throughput bellow 3000kB/s (We usually average 40000 kB/s to 80000 +kB/s on sequential read operations on the netapps) + + +The stats of the NetApp do confirm that it is sitting idle. Doing an +strace on the Postgresql process shows that is it doing seeks and +reads. + + +So my question is where is this iowait time spent ? + +Is there a way to pinpoint the problem in more details ? + +We are able to reproduce this behavior with Postgresql 7.4.8 and 8.0.3 + + +I have included the output of top,vmstat,strace and systat from the +Netapp from System B while running a single query that generates this +behavior. + + +R=E9my + + +top output: + + 06:27:28 up 5 days, 16:59, 6 users, load average: 1.04, 1.30, 1.01 + +72 processes: 71 sleeping, 1 running, 0 zombie, 0 stopped + +CPU states: cpu user nice system irq softirq iowait =20 +idle + + total 2.7% 0.0% 1.0% 0.1% 0.2% 46.0% =20 +49.5% + + cpu00 0.2% 0.0% 0.2% 0.0% 0.2% 2.2% =20 +97.2% + + cpu01 5.3% 0.0% 1.9% 0.3% 0.3% 89.8% =20 +1.9% + +Mem: 2061696k av, 2043936k used, 17760k free, 0k shrd, =20 +3916k buff + + 1566332k actv, 296648k in_d, 30504k in_c + +Swap: 16771584k av, 21552k used, 16750032k free =20 +1933772k cached + + + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU +COMMAND + +30960 postgres 15 0 13424 10M 9908 D 2.7 0.5 2:00 1 +postmaster + +30538 root 15 0 1080 764 524 S 0.7 0.0 0:43 0 sshd + + 1 root 15 0 496 456 436 S 0.0 0.0 0:08 0 init + + 2 root RT 0 0 0 0 SW 0.0 0.0 0:00 0 +migration/0 + + 3 root RT 0 0 0 0 SW 0.0 0.0 0:00 1 +migration/1 + + 4 root 15 0 0 0 0 SW 0.0 0.0 0:01 0 +keventd + + 5 root 34 19 0 0 0 SWN 0.0 0.0 0:00 0 +ksoftirqd/0 + + 6 root 34 19 0 0 0 SWN 0.0 0.0 0:00 1 +ksoftirqd/1 + + 9 root 15 0 0 0 0 SW 0.0 0.0 0:24 1 +bdflush + + 7 root 15 0 0 0 0 SW 0.0 0.0 6:53 1 +kswapd + + 8 root 15 0 0 0 0 SW 0.0 0.0 8:44 1 +kscand + + 10 root 15 0 0 0 0 SW 0.0 0.0 0:13 0 +kupdated + + 11 root 25 0 0 0 0 SW 0.0 0.0 0:00 0 +mdrecoveryd + + 17 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 +ahc_dv_0 + + + +vmstat output=20 + +procs memory swap io system = +=20 +cpu + + r b swpd free buff cache si so bi bo in cs us +sy id wa + + 0 1 21552 17796 4872 1931928 2 3 3 1 27 6 2=20= + +1 7 3 + + 0 1 21552 18044 4880 1931652 0 0 1652 0 397 512 1=20= + +2 50 47 + + 0 1 21552 17976 4896 1931664 0 0 2468 0 407 552 2=20= + +2 50 47 + + 1 0 21552 17984 4896 1931608 0 0 2124 0 418 538 3=20= + +3 48 46 + + 0 1 21552 18028 4900 1931536 0 0 1592 0 385 509 1=20= + +3 50 46 + + 0 1 21552 18040 4916 1931488 0 0 1620 820 419 581 2=20= + +2 50 46 + + 0 1 21552 17968 4916 1931536 0 4 1708 4 402 554 3=20= + +1 50 46 + + 1 1 21552 18052 4916 1931388 0 0 1772 0 409 531 3=20= + +1 49 47 + + 0 1 21552 17912 4924 1931492 0 0 1772 0 408 565 3=20= + +1 48 48 + + 0 1 21552 17932 4932 1931440 0 4 1356 4 391 545 5=20= + +0 49 46 + + 0 1 21552 18320 4944 1931016 0 4 1500 840 414 571 1=20= + +1 48 50 + + 0 1 21552 17872 4944 1931440 0 0 2116 0 392 496 1=20= + +5 46 48 + + 0 1 21552 18060 4944 1931232 0 0 2232 0 423 597 1=20= + +2 48 49 + + 1 1 21552 17684 4944 1931584 0 0 1752 0 395 537 1=20= + +1 50 48 + + 0 1 21552 18000 4944 1931240 0 0 1576 0 401 549 0=20= + +1 50 49 + + + +NetApp stats: + + CPU NFS CIFS HTTP Total Net kB/s Disk kB/s Tape kB/s +Cache Cache CP CP Disk DAFS FCP iSCSI FCP kB/s + + in out read write read write =20 +age hit time ty util in out + + 2% 0 0 0 139 0 0 2788 0 0 0 =20= + +3 96% 0% - 15% 0 139 0 3 2277 + + 2% 0 0 0 144 0 0 2504 0 0 0 =20= + +3 96% 0% - 18% 0 144 0 3 2150 + + 2% 0 0 0 130 0 0 2212 0 0 0 =20= + +3 96% 0% - 13% 0 130 0 3 1879 + + 3% 0 0 0 169 0 0 2937 80 0 0 =20= + +3 96% 0% - 13% 0 169 0 4 2718 + + 2% 0 0 0 139 0 0 2448 0 0 0 =20= + +3 96% 0% - 12% 0 139 0 3 2096 + + 2% 0 0 0 137 0 0 2116 0 0 0 =20= + +3 96% 0% - 10% 0 137 0 3 1892 + + 3% 0 0 0 107 0 0 2660 812 0 0 =20= + +3 96% 24% T 20% 0 107 0 3 1739 + + 2% 0 0 0 118 0 0 1788 0 0 0 =20= + +3 96% 0% - 13% 0 118 0 3 1608 + + 2% 0 0 0 136 0 0 2228 0 0 0 =20= + +3 96% 0% - 11% 0 136 0 3 2018 + + 2% 0 0 0 119 0 0 1940 0 0 0 =20= + +3 96% 0% - 13% 0 119 0 3 1998 + + 2% 0 0 0 136 0 0 2175 0 0 0 =20= + +3 96% 0% - 14% 0 136 0 3 1929 + + 2% 0 0 0 133 0 0 1924 0 0 0 =20= + +3 96% 0% - 19% 0 133 0 3 2292 + + 2% 0 0 0 115 0 0 2044 0 0 0 =20= + +3 96% 0% - 11% 0 115 0 3 1682 + + 2% 0 0 0 134 0 0 2256 0 0 0 =20= + +3 96% 0% - 12% 0 134 0 3 2096 + + 2% 0 0 0 112 0 0 2184 0 0 0 =20= + +3 96% 0% - 12% 0 112 0 3 1633 + + 2% 0 0 0 163 0 0 2348 0 0 0 =20= + +3 96% 0% - 13% 0 163 0 4 2421 + + 2% 0 0 0 120 0 0 2056 184 0 0 =20= + +3 96% 8% T 14% 0 120 0 3 1703 + + +strace output: + +read(55, "\4\0\0\0\10fm}\1\0\0\0p\0\264\0\0 \2 \230\236\320\0020"..., +8192) =3D 8192 + +_llseek(55, 857997312, [857997312], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\\\315\321|\1\0\0\0p\0\354\0\0 \2 \250\236\260"..., +8192) =3D 8192 + +_llseek(55, 883220480, [883220480], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0T\17a~\1\0\0\0p\0\20\1\0 \2 \270\236\220\2D\235"..., +8192) =3D 8192 + +_llseek(55, 858005504, [858005504], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\300\356\321|\1\0\0\0p\0\330\0\0 \2 +\260\236\240"..., 8192) =3D 8192 + +_llseek(55, 857964544, [857964544], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0lH\321|\1\0\0\0p\0<<\1\0 \2 \300\236\200\2p\235"..., +8192) =3D 8192 + +_llseek(55, 857956352, [857956352], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0l\'\321|\1\0\0\0p\0\320\0\0 \2 \260\236\240\2\\"..., +8192) =3D 8192 + +_llseek(55, 910802944, [910802944], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\10}\25\200\1\0\0\0l\0\274\1\0 \2 \250\236\260"..., +8192) =3D 8192 + +_llseek(55, 857948160, [857948160], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\370\5\321|\1\0\0\0p\0\350\0\0 \2 \230\236\320"..., +8192) =3D 8192 + +_llseek(56, 80371712, [80371712], SEEK_SET) =3D 0 + +read(56, "\4\0\0\0Lf \217\1\0\0\0p\0\f\1\0 \2 \250\236\260\2T\235"..., +8192) =3D 8192 + +read(102, "\2\0\34\0001\236\0\0\1\0\0\0\t\0\0\00020670\0\0\0B\6\0"..., +8192) =3D 8192 + +_llseek(55, 857939968, [857939968], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\244\344\320|\1\0\0\0l\0\230\1\0 \2 +\244\236\270"..., 8192) =3D 8192 + +_llseek(55, 857923584, [857923584], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\224\242\320|\1\0\0\0p\0|\0\0 \2 +\234\236\310\002"..., 8192) =3D 8192 + +_llseek(55, 57270272, [57270272], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\3204FK\1\0\0\0t\0\340\0\0 \2 +\310\236j\2\214\235"..., 8192) =3D 8192 + +_llseek(55, 870727680, [870727680], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0x>\233}\1\0\0\0p\0@\1\0 \2 \250\236\260\2X\235"..., +8192) =3D 8192 + +_llseek(55, 1014734848, [1014734848], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\34\354\201\206\1\0\0\0p\0p\0\0 \2 \264\236\230"..., +8192) =3D 8192 + +_llseek(55, 857874432, [857874432], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\214\331\317|\1\0\0\0l\0\324\1\0 \2 +\224\236\330"..., 8192) =3D 8192 + +_llseek(55, 760872960, [760872960], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\30\257\321v\1\0\0\0p\0\230\0\0 \2 \234\236\310"..., +8192) =3D 8192 + +_llseek(55, 891715584, [891715584], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\370\220\347~\1\0\0\0p\0P\1\0 \2 \230\236\320\2"..., +8192) =3D 8192 + +_llseek(55, 857858048, [857858048], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0\250\227\317|\1\0\0\0p\0\264\0\0 \2 +\254\236\250"..., 8192) =3D 8192 + +_llseek(55, 666910720, [666910720], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0x\206\3q\1\0\0\0p\0004\1\0 \2 +\254\236\242\2P\235"..., 8192) =3D 8192 + +_llseek(55, 857841664, [857841664], SEEK_SET) =3D 0 + +read(55, "\4\0\0\0dT\317|\1\0\0\0p\0\224\0\0 \2 \214\236\350\2\30"..., +8192) =3D 8192 + + =20 + + += + +--Apple-Mail-1-986878859-- + + +From pgsql-performance-owner@postgresql.org Mon Aug 29 13:23:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BDB2D77ED + for ; + Mon, 29 Aug 2005 13:23:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25009-08 + for ; + Mon, 29 Aug 2005 16:23:23 +0000 (GMT) +Received: from web53211.mail.yahoo.com (web53211.mail.yahoo.com + [206.190.49.81]) + by svr1.postgresql.org (Postfix) with SMTP id 437D4D6F5F + for ; + Mon, 29 Aug 2005 13:23:21 -0300 (ADT) +Received: (qmail 9578 invoked by uid 60001); 29 Aug 2005 16:23:20 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=YcxVTyik85IbDygyRR7Gk8lqBcJA+DY9kbbIgpkykgzdqVJnXq/k4JOPyhNFgyXWRIYggUTk8sOtWw/bTTlKA/rA0tG4E7ATBXfY/z+zByuRX5sO3KLBwXfTBLMnm1+EymDMQHN7kn0fyktNB+8ddgwpOHlxRbZM9Ig/JGARaRo= + ; +Message-ID: <20050829162320.9576.qmail@web53211.mail.yahoo.com> +Received: from [200.138.208.43] by web53211.mail.yahoo.com via HTTP; + Mon, 29 Aug 2005 16:23:20 GMT +Date: Mon, 29 Aug 2005 16:23:20 +0000 (GMT) +From: Carlos Henrique Reimer +Subject: shared buffers +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-1569728133-1125332600=:9424" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.47 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374, + HTML_50_60=0.095, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/493 +X-Sequence-Number: 14240 + +--0-1569728133-1125332600=:9424 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi, + +I�ve configured postgresql to use 1GB of shared buffers but meminfo and "top" are indicanting 0 shared buffers page. Why? + +It�s a Linux Redhat 9 box with 4GB RAM and postgresql 7.3. + +Thanks in advance! + +Reimer + + +--------------------------------- +Yahoo! Acesso Gr�tis: Internet r�pida e gr�tis. Instale o discador agora! +--0-1569728133-1125332600=:9424 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +
Hi,
+
 
+
I�ve configured postgresql to use 1GB of shared buffers but meminfo and "top" are indicanting 0 shared buffers page. Why?
+
 
+
It�s a Linux Redhat 9 box with 4GB RAM and postgresql 7.3.
+
 
+
Thanks in advance!
+
 
+
Reimer

+


Yahoo! Acesso Gr�tis: Internet r�pida e gr�tis. Instale o discador agora! +--0-1569728133-1125332600=:9424-- + +From pgsql-performance-owner@postgresql.org Mon Aug 29 14:27:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 424F5D7337 + for ; + Mon, 29 Aug 2005 14:27:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41970-06 + for ; + Mon, 29 Aug 2005 17:27:29 +0000 (GMT) +Received: from rwcrmhc12.comcast.net (rwcrmhc13.comcast.net [216.148.227.118]) + by svr1.postgresql.org (Postfix) with ESMTP id C3218D6FEB + for ; + Mon, 29 Aug 2005 14:27:27 -0300 (ADT) +Received: from jefftrout.com ([24.147.120.205]) + by comcast.net (rwcrmhc13) with SMTP + id <2005082917272601500a0cgue>; Mon, 29 Aug 2005 17:27:27 +0000 +Received: (qmail 17864 invoked from network); 29 Aug 2005 17:28:24 -0000 +Received: from c-24-147-120-205.hsd1.ma.comcast.net (HELO ?192.168.0.106?) + (24.147.120.205) + by 192.168.0.109 with SMTP; 29 Aug 2005 17:28:24 -0000 +In-Reply-To: <26476.1125259249@sss.pgh.pa.us> +References: + <26476.1125259249@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v733) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <486EB962-5B80-49B4-AF01-0C2DD77CC9EF@torgo.978.org> +Cc: postgres performance +Content-Transfer-Encoding: 7bit +From: Jeff Trout +Subject: Re: OSX & Performance +Date: Mon, 29 Aug 2005 13:27:25 -0400 +To: Tom Lane +X-Mailer: Apple Mail (2.733) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[AWL=-0.000, RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/494 +X-Sequence-Number: 14241 + + +On Aug 28, 2005, at 4:00 PM, Tom Lane wrote: + +> +> Hmm, can you provide a test case for other people to poke at? +> + +I'l try to put one together as small as I can make it. +The table in question is roughly 22M rows. There are about 8k rows +per timestamp (day granularity). + +> I see -O2 when building PG (CVS tip) on a fully up-to-date 10.4.2 +> machine. Maybe something odd in your environment, like a preset +> CFLAGS setting? +> + +8.0.3 doesn't have any optimization flags +8.1beta1 doesn't have any optimization +ie: gcc -no-cpp-precomp -Wall -Wmissing-prototypes -Wpointer-arith - +Wdeclaration-after-statement -Wold-style-definition -Wendif-labels - +fno-strict-aliasing -I../../src/port -I../../src/include -c +thread.c -o thread_srv.o + +I'm on 10.4.2, xcode 2.1 +Using built-in specs. +Target: powerpc-apple-darwin8 +Configured with: /private/var/tmp/gcc/gcc-5026.obj~19/src/configure -- +disable-checking --prefix=/usr --mandir=/share/man --enable- +languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^+.-]*$/ +s/$/-4.0/ --with-gxx-include-dir=/include/gcc/darwin/4.0/c++ -- +build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 -- +target=powerpc-apple-darwin8 +Thread model: posix +gcc version 4.0.0 (Apple Computer, Inc. build 5026) + +The snapshot on ftp.psotgresql.org (dated 8/29) also runs with no +optimization. + +No cflags are set. + +need to see anything from config.log? + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + + +From pgsql-performance-owner@postgresql.org Mon Aug 29 14:57:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CA1D3D7C6E + for ; + Mon, 29 Aug 2005 14:57:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50979-05 + for ; + Mon, 29 Aug 2005 17:57:35 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D9CBD7A1F + for ; + Mon, 29 Aug 2005 14:57:34 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7THvYxj011274; + Mon, 29 Aug 2005 13:57:35 -0400 (EDT) +To: Jeff Trout +Cc: postgres performance +Subject: Re: OSX & Performance +In-reply-to: <486EB962-5B80-49B4-AF01-0C2DD77CC9EF@torgo.978.org> +References: + <26476.1125259249@sss.pgh.pa.us> + <486EB962-5B80-49B4-AF01-0C2DD77CC9EF@torgo.978.org> +Comments: In-reply-to Jeff Trout + message dated "Mon, 29 Aug 2005 13:27:25 -0400" +Date: Mon, 29 Aug 2005 13:57:34 -0400 +Message-ID: <11273.1125338254@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/495 +X-Sequence-Number: 14242 + +Jeff Trout writes: +> On Aug 28, 2005, at 4:00 PM, Tom Lane wrote: +>> I see -O2 when building PG (CVS tip) on a fully up-to-date 10.4.2 +>> machine. Maybe something odd in your environment, like a preset +>> CFLAGS setting? + +> 8.0.3 doesn't have any optimization flags +> 8.1beta1 doesn't have any optimization +> ie: gcc -no-cpp-precomp -Wall -Wmissing-prototypes -Wpointer-arith - +> Wdeclaration-after-statement -Wold-style-definition -Wendif-labels - +> fno-strict-aliasing -I../../src/port -I../../src/include -c +> thread.c -o thread_srv.o + +You must have CFLAGS set to empty in your build environment, because +configure will certainly default to -O2 if not overridden. It works +fine for me on OS X. Maybe you want to trace through the configure +script and see why it's doing something else? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 29 15:08:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AC365D7CC1 + for ; + Mon, 29 Aug 2005 15:07:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50570-09 + for ; + Mon, 29 Aug 2005 18:07:20 +0000 (GMT) +Received: from web35207.mail.mud.yahoo.com (web35207.mail.mud.yahoo.com + [66.163.179.86]) + by svr1.postgresql.org (Postfix) with SMTP id 54852D7CB1 + for ; + Mon, 29 Aug 2005 15:07:17 -0300 (ADT) +Received: (qmail 74299 invoked by uid 60001); 29 Aug 2005 18:07:17 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=HLoGm6F3K510fyFbvU5ytEh4st9qXXXpmOc7A00iKpZVX6lr2lXhHIWwYiVNPsTh2vFahLb2bvchJusoKMfOGCAQ10CNuJLopP3/Uq0Wx7gFu7I6QWYqeTgWyjbxfsqC5In4GKuE0JDpu9NqP0SrZEApRx0ToblHoknYkjLGWZs= + ; +Message-ID: <20050829180717.74297.qmail@web35207.mail.mud.yahoo.com> +Received: from [65.218.233.130] by web35207.mail.mud.yahoo.com via HTTP; + Mon, 29 Aug 2005 11:07:17 PDT +Date: Mon, 29 Aug 2005 11:07:17 -0700 (PDT) +From: asif ali +Subject: Re: Weird performance drop after VACUUM +To: Michael Fuhr +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20050827014126.GA33637@winnie.fuhr.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.28 required=5 tests=[AWL=-0.093, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/496 +X-Sequence-Number: 14243 + +Michael +The database is on the same system. +What I am doing is only "VACUUM analyze +conversion_table" + +I did the the same thing on a newly created database. +And got the same result. So after "VACUUM analyze" +performance dropped. +Please see this. Runtime changes from "7755.115" to +"14859.291" ms + + +explain analyze +select keyword_id,sum(daily_impressions) as +daily_impressions , + sum(daily_clicks) as daily_clicks, +COALESCE(sum(daily_cpc::double precision),0) as +daily_cpc, sum(daily_revenues)as daily_revenues, +sum(daily_actions)as daily_actions + ,count(daily_cpc) as count from conversion_table c +where c.conversion_date BETWEEN '2005-06-07' and +'2005-08-17' + group by keyword_Id + +"HashAggregate (cost=18686.51..18686.54 rows=2 +width=52) (actual time=7585.827..7720.370 rows=55717 +loops=1)" +" -> Index Scan using conversion_table_pk on +conversion_table c (cost=0.00..18599.25 rows=4986 +width=52) (actual time=0.129..2882.066 rows=885493 +loops=1)" +" Index Cond: ((conversion_date >= +'2005-06-07'::date) AND (conversion_date <= +'2005-08-17'::date))" +"Total runtime: 7755.115 ms" + + +VACUUM analyze conversion_table + + +explain analyze + +select keyword_id,sum(daily_impressions) as +daily_impressions , + sum(daily_clicks) as daily_clicks, +COALESCE(sum(daily_cpc::double precision),0) as +daily_cpc, sum(daily_revenues)as daily_revenues, +sum(daily_actions)as daily_actions + ,count(daily_cpc) as count from conversion_table c +where c.conversion_date BETWEEN '2005-06-07' and +'2005-08-17' + group by keyword_Id + + +"GroupAggregate (cost=182521.76..200287.99 rows=20093 +width=37) (actual time=8475.580..12618.793 rows=55717 +loops=1)" +" -> Sort (cost=182521.76..184698.58 rows=870730 +width=37) (actual time=8475.246..9418.068 rows=885493 +loops=1)" +" Sort Key: keyword_id" +" -> Seq Scan on conversion_table c +(cost=0.00..27336.12 rows=870730 width=37) (actual +time=0.007..1520.788 rows=885493 loops=1)" +" Filter: ((conversion_date >= +'2005-06-07'::date) AND (conversion_date <= +'2005-08-17'::date))" +"Total runtime: 14859.291 ms" + + + + + + + + + +--- Michael Fuhr wrote: + +> On Fri, Aug 26, 2005 at 05:10:49PM -0700, asif ali +> wrote: +> > "GroupAggregate (cost=195623.66..206672.52 +> rows=20132 +> > width=16) (actual time=8205.283..10139.369 +> rows=55291 +> > loops=1)" +> > " -> Sort (cost=195623.66..198360.71 +> rows=1094820 +> > width=16) (actual time=8205.114..9029.501 +> rows=863883 +> > loops=1)" +> > " Sort Key: keyword_id" +> > " -> Seq Scan on keyword_conversion_table +> c +> > (cost=0.00..29990.83 rows=1094820 width=16) +> (actual +> > time=0.057..1422.319 rows=863883 loops=1)" +> > " Filter: ((conversion_date >= +> > '2005-06-07'::date) AND (conversion_date <= +> > '2005-08-17'::date))" +> > "Total runtime: 14683.617 ms" +> +> What are your effective_cache_size and work_mem +> (8.x) or sort_mem (7.x) +> settings? How much RAM does the machine have? If +> you have enough +> memory then raising those variables should result in +> better plans; +> you might also want to experiment with +> random_page_cost. Be careful +> not to set work_mem/sort_mem too high, though. See +> "Run-time +> Configuration" in the "Server Run-time Environment" +> chapter of the +> documentation for more information about these +> variables. +> +> -- +> Michael Fuhr +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + + + +____________________________________________________ +Start your day with Yahoo! - make it your home page +http://www.yahoo.com/r/hs + + +From pgsql-performance-owner@postgresql.org Mon Aug 29 15:42:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D888BD735E + for ; + Mon, 29 Aug 2005 15:41:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64036-04 + for ; + Mon, 29 Aug 2005 18:41:51 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 48C52D7275 + for ; + Mon, 29 Aug 2005 15:41:47 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Limit + group + join +Date: Mon, 29 Aug 2005 14:41:46 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3417DD207@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Limit + group + join +Thread-Index: AcWrcps0SaqA9Qz8SG6XfEbjw6qgEgBVh7Bg +From: "Merlin Moncure" +To: "Tobias Brox" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.056 required=5 tests=[AWL=0.006, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/497 +X-Sequence-Number: 14244 + +Tobias wrote: +> Splendid :-) Unfortunately we will not be upgrading for some monthes +> still, +> but anyway I'm happy. This provides yet another good argument for +> upgrading +> sooner. I'm also happy to see such a perfect match: +>=20 +> - A problem that can be reduced from beeing complex and +> production-specific, to simple and easily reproducible. +>=20 +> - Enthusiastic people testing it and pinpointing even more precisely +what +> conditions will cause the condition +>=20 +> - Programmers actually fixing the issue +>=20 +> - Testers verifying that it was fixed +>=20 +> Long live postgresql! :-) + +In the last three or so years since I've been really active with +postgresql, I've found two or three issues/bugs which I was able to +reproduce and reduce to a test case. In all instances the fix was in +cvs literally within minutes. + +Merlin + +From pgsql-performance-owner@postgresql.org Mon Aug 29 16:56:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 82398D6E21 + for ; + Mon, 29 Aug 2005 16:56:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80587-02 + for ; + Mon, 29 Aug 2005 19:56:14 +0000 (GMT) +Received: from hub.org (hub.org [200.46.204.220]) + by svr1.postgresql.org (Postfix) with ESMTP id E5623D7CC1 + for ; + Mon, 29 Aug 2005 16:56:13 -0300 (ADT) +Received: from localhost (av.hub.org [200.46.204.144]) + by hub.org (Postfix) with ESMTP id 5B29664B903 + for ; + Mon, 29 Aug 2005 16:56:16 -0300 (ADT) +Received: from hub.org ([200.46.204.220]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78445-06 for ; + Mon, 29 Aug 2005 19:56:11 +0000 (GMT) +Received: from ganymede.hub.org (blk-222-82-85.eastlink.ca [24.222.82.85]) + by hub.org (Postfix) with ESMTP id AED2764B8FF + for ; + Mon, 29 Aug 2005 16:56:13 -0300 (ADT) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 5522B3687D; Mon, 29 Aug 2005 16:56:15 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id 5414F35A0A + for ; + Mon, 29 Aug 2005 16:56:15 -0300 (ADT) +Date: Mon, 29 Aug 2005 16:56:15 -0300 (ADT) +From: "Marc G. Fournier" +X-X-Sender: scrappy@ganymede.hub.org +To: pgsql-performance@postgresql.org +Subject: getting an index to work with partial indices ... +Message-ID: <20050829165335.X1044@ganymede.hub.org> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.032 required=5 tests=[AWL=-0.018, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/498 +X-Sequence-Number: 14245 + + +Try as I might, I can't seem to get it to work ... table has >9million +rows in it, I've created an index "using btree ( priority ) where priority +< 0;", where the table distribution looks like: + + priority | count +----------+--------- + -2 | 138435 + -1 | 943250 + 1 | 3416 + 9 | 1134171 + | 7276960 +(5 rows) + +And it still won't use the index: + +# explain update table set priority = -3 where priority = -1; + QUERY PLAN +------------------------------------------------------------------ + Seq Scan on table (cost=0.00..400735.90 rows=993939 width=278) + Filter: (priority = -1) +(2 rows) + +But, ti will if I try 'priority = -2' ... what is teh threshhold for using +the index? obviously 10% of the records is too high ... + +thanks ... + +---- +Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) +Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664 + +From pgsql-performance-owner@postgresql.org Mon Aug 29 17:16:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A348D7F71 + for ; + Mon, 29 Aug 2005 17:15:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83652-04 + for ; + Mon, 29 Aug 2005 20:15:27 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id E6CA9D7E62 + for ; + Mon, 29 Aug 2005 17:15:26 -0300 (ADT) +Received: (qmail 9936 invoked from network); 29 Aug 2005 20:15:27 -0000 +Received: from pcp0012204803pcs.blairblvd.tn.nash.comcast.net (HELO + ?192.168.15.110?) (69.245.49.69) + by 0 with SMTP; 29 Aug 2005 20:15:27 -0000 +In-Reply-To: + <2773CAC687FD5F4689F526998C7E4E5F43F392@au3010avexu1.global.avaya.com> +References: + <2773CAC687FD5F4689F526998C7E4E5F43F392@au3010avexu1.global.avaya.com> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: multipart/alternative; boundary=Apple-Mail-33-1010433658 +Message-Id: <2408BBD7-2C6D-4FAD-82ED-A8E9DC07D83A@sitening.com> +Cc: +From: "Thomas F. O'Connell" +Subject: Re: Need indexes on empty tables for good performance ? +Date: Mon, 29 Aug 2005 15:15:21 -0500 +To: "Lenard, Rohan (Rohan)" +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.033 required=5 tests=[AWL=0.005, HTML_60_70=0.027, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/499 +X-Sequence-Number: 14246 + + +--Apple-Mail-33-1010433658 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/plain; + charset=WINDOWS-1252; + delsp=yes; + format=flowed + +Rohan, + +You should note that in Postgres, indexes are not inherited by child =20 +tables. + +Also, it seems difficult to select from a child table whose name you =20 +don't know unless you access the parent. And if you are accessing the =20= + +data via the parent, I'm reasonably certain that you will find that =20 +indexes aren't used (even if they exist on the children) as a result =20 +of the way the children are accessed. + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC + +Strategic Open Source: Open Your i=99 + +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-469-5150 +615-469-5151 (fax) + +On Aug 22, 2005, at 10:41 PM, Lenard, Rohan (Rohan) wrote: + +> I've read that indexes aren't used for COUNT(*) and I've noticed =20 +> (7.3.x) with EXPLAIN that indexes never seem to be used on empty =20 +> tables - is there any reason to have indexes on empty tables, or =20 +> will postgresql never use them. +> +> This is not as silly as it sounds - with table inheritance you =20 +> might have table children with the data and a parent that is =20 +> empty. It'd be nice to make sure postgresql knows to never really =20 +> look at the parent - especially is you don't know the names of all =20 +> the children .. +> +> Thoughts ? +> +> thx, +> Rohan + + +--Apple-Mail-33-1010433658 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=WINDOWS-1252 + +Rohan,

You should note that in = +Postgres, indexes are not inherited by child tables.

Also, it seems difficult to = +select from a child table whose name you don't know unless you access = +the parent. And if you are accessing the data via the parent, I'm = +reasonably certain that you will find that indexes aren't used (even if = +they exist on the children) as a result of the way the children are = +accessed.

--
Thomas F. O'Connell
Co-Founder, = +Information Architect
Sitening, = +LLC

Strategic Open Source: Open Your = +i=99

11= +0 30th Avenue North, Suite 6
Nashville, TN = +37203-6320
615-469-5150
615-469-5151 (fax)
= +

On Aug 22, 2005, at 10:41 PM, Lenard, Rohan (Rohan) = +wrote:

I've read that indexes aren't used for = +COUNT(*) and I've noticed (7.3.x) with EXPLAIN that indexes never seem = +to be used on empty tables - is there any reason to have indexes on = +empty tables, or will postgresql never use them.
= +
=A0
This is not = +as silly as it sounds - with table inheritance you might have table = +children with the data and a parent that is empty.=A0 It'd be nice to = +make sure postgresql knows to never really look at the parent - = +especially is you don't know the names of all the children = +..
=A0
Thoughts = +?
=A0
thx,
=A0 = +Rohan

= + +--Apple-Mail-33-1010433658-- + +From pgsql-performance-owner@postgresql.org Mon Aug 29 17:20:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B1ADBD7DBD; + Mon, 29 Aug 2005 17:19:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83627-08; Mon, 29 Aug 2005 20:19:05 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C5E0BD7CC1; + Mon, 29 Aug 2005 17:19:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7TKJ5Nv012791; + Mon, 29 Aug 2005 16:19:05 -0400 (EDT) +To: "Marc G. Fournier" +Cc: pgsql-performance@postgresql.org +Subject: Re: getting an index to work with partial indices ... +In-reply-to: <20050829165335.X1044@ganymede.hub.org> +References: <20050829165335.X1044@ganymede.hub.org> +Comments: In-reply-to "Marc G. Fournier" + message dated "Mon, 29 Aug 2005 16:56:15 -0300" +Date: Mon, 29 Aug 2005 16:19:05 -0400 +Message-ID: <12790.1125346745@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/500 +X-Sequence-Number: 14247 + +"Marc G. Fournier" writes: +> But, ti will if I try 'priority = -2' ... what is teh threshhold for using +> the index? obviously 10% of the records is too high ... + +Depends on a lot of factors, but usually somewhere between 1% and 10%. +(The new bitmap index scan code in 8.1 should be workable for higher +percentages.) If this doesn't seem to square with reality for you, +you might try reducing random_page_cost. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 29 17:29:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 28AFDD7F9D + for ; + Mon, 29 Aug 2005 17:29:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87635-10 + for ; + Mon, 29 Aug 2005 20:29:00 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 6600DD7F31 + for ; + Mon, 29 Aug 2005 17:28:58 -0300 (ADT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7TKSvsS023648 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Mon, 29 Aug 2005 14:28:59 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7TKSvvx099568; + Mon, 29 Aug 2005 14:28:57 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7TKSuEs099567; + Mon, 29 Aug 2005 14:28:56 -0600 (MDT) (envelope-from mfuhr) +Date: Mon, 29 Aug 2005 14:28:56 -0600 +From: Michael Fuhr +To: asif ali +Cc: pgsql-performance@postgresql.org +Subject: Re: Weird performance drop after VACUUM +Message-ID: <20050829202856.GA99478@winnie.fuhr.org> +References: <20050827014126.GA33637@winnie.fuhr.org> + <20050829180717.74297.qmail@web35207.mail.mud.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050829180717.74297.qmail@web35207.mail.mud.yahoo.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] +X-Spam-Level: +X-Archive-Number: 200508/501 +X-Sequence-Number: 14248 + +On Mon, Aug 29, 2005 at 11:07:17AM -0700, asif ali wrote: +> The database is on the same system. +> What I am doing is only "VACUUM analyze +> conversion_table" +> +> I did the the same thing on a newly created database. +> And got the same result. So after "VACUUM analyze" +> performance dropped. +> Please see this. Runtime changes from "7755.115" to +> "14859.291" ms + +As has been pointed out a couple of times, you're getting a different +plan after VACUUM ANALYZE because the row count estimates are more +accurate. Unfortunately the more accurate estimates result in a +query plan that's slower than the plan for the less accurate +estimates. PostgreSQL *thinks* the plan will be faster but your +results show that it isn't, so you might need to adjust some of the +planner's cost constants. + +A asked some questions that you didn't answer, so I'll ask them again: + +What's your effective_cache_size setting? +What's your work_mem (8.x) or sort_mem (7.x) setting? +What's your random_page_cost setting? +How much available RAM does the machine have? +What version of PostgreSQL are you running? + +Various tuning guides give advice on how to set the above and other +configuration variables. Here's one such guide: + +http://www.powerpostgresql.com/PerfList/ + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Mon Aug 29 18:26:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D7E2DD7D79 + for ; + Mon, 29 Aug 2005 18:09:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97038-04 + for ; + Mon, 29 Aug 2005 21:09:21 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 967DDD7E0E + for ; + Mon, 29 Aug 2005 18:09:16 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id EF90E152AE; Mon, 29 Aug 2005 16:09:17 -0500 (CDT) +Date: Mon, 29 Aug 2005 16:09:17 -0500 +From: "Jim C. Nasby" +To: tobbe +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance for relative large DB +Message-ID: <20050829210917.GC11282@pervasive.com> +References: <1124799264.282119.167760@g47g2000cwa.googlegroups.com> + <60wtmcptzg.fsf@dba2.int.libertyrms.com> + <1124864702.822522.64410@g49g2000cwa.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1124864702.822522.64410@g49g2000cwa.googlegroups.com> +X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 required=5 tests=[AWL=0.010] +X-Spam-Level: +X-Archive-Number: 200508/502 +X-Sequence-Number: 14249 + +On Tue, Aug 23, 2005 at 11:25:02PM -0700, tobbe wrote: +> Hi Chris. +> +> Thanks for the answer. +> Sorry that i was a bit unclear. +> +> 1) We update around 20.000 posts per night. +Doesn't seem like a lot at all. + +> 2) What i meant was that we suspect that the DBMS called PervasiveSQL +> that we are using today is much to small. That's why we're looking for +> alternatives. + +Just so no one gets confused, PervasiveSQL is our Btrieve-based +database; it has nothing to do with Pervasive Posgres or PosgreSQL. +Also, feel free to contact me off-list if you'd like our help with this. + +> Today we base our solution much on using querry-specific tables created +> at night, so instead of doing querrys direct on the "post" table (with +> 4-6M rows) at daytime, we have the data pre-aligned in several much +> smaller tables. This is just to make the current DBMS coop with our +> amount of data. +> +> What I am particulary interested in is if we can expect to run all our +> select querrys directly from the "post" table with PostgreSQL. + +Probably, depending on what those queries are, what hardware you have +and how the table is laid out. Unless you've got a really high query +load I suspect you could handle this on some fairly mundane hardware... + +> 3) How well does postgres work with load balancing environments. Is it +> built-in? + +As Chris said, there is no built-in solution. PGCluster +(http://pgfoundry.org/projects/pgcluster/) is a possible solution should +you need clustering/load balancing, but as I mentioned I suspect you +should be ok without it. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:12:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F0932D7F1E + for ; + Mon, 29 Aug 2005 19:15:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14717-08 + for ; + Mon, 29 Aug 2005 22:15:39 +0000 (GMT) +Received: from tierw.net.avaya.com (tierw.net.avaya.com [198.152.13.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 02A57D7EA7 + for ; + Mon, 29 Aug 2005 19:15:37 -0300 (ADT) +Received: from tierw.net.avaya.com (localhost [127.0.0.1]) + by tierw.net.avaya.com (Switch-3.1.2/Switch-3.1.0) with ESMTP id + j7TM2XE9029771 for ; + Mon, 29 Aug 2005 18:02:34 -0400 (EDT) +Received: from au3010avexu1.global.avaya.com (h135-27-64-251.avaya.com + [135.27.64.251]) + by tierw.net.avaya.com (Switch-3.1.2/Switch-3.1.0) with ESMTP id + j7TM0YE9027933 for ; + Mon, 29 Aug 2005 18:01:13 -0400 (EDT) +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C5ACE6.E73E5078" +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +Subject: Re: Need indexes on empty tables for good performance ? +Date: Tue, 30 Aug 2005 08:13:37 +1000 +Message-ID: + <2773CAC687FD5F4689F526998C7E4E5F489B7B@au3010avexu1.global.avaya.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Need indexes on empty tables for good performance ? +Thread-Index: AcWs1nJkWo99iBR7RHGnfWZOKlnzvAAEFJGg +From: "Lenard, Rohan (Rohan)" +To: "Thomas F. O'Connell" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.017 required=5 tests=[AWL=-0.011, HTML_60_70=0.027, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/523 +X-Sequence-Number: 14270 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5ACE6.E73E5078 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Actually the indexes on the child table do seem to get used - I just +wanted to make sure there was no penalty not having indexes on the empty +parent tables. +=20 +You are right - the parent is the best way to get at the unknown +children ...=20 + + + _____ =20 + + From: Thomas F. O'Connell [mailto:tfo@sitening.com]=20 + Sent: Tuesday, August 30, 2005 6:15 AM + To: Lenard, Rohan (Rohan) + Cc: pgsql-performance@postgresql.org + Subject: Re: [PERFORM] Need indexes on empty tables for good +performance ? +=09 +=09 + Rohan,=20 + + You should note that in Postgres, indexes are not inherited by +child tables. + + Also, it seems difficult to select from a child table whose name +you don't know unless you access the parent. And if you are accessing +the data via the parent, I'm reasonably certain that you will find that +indexes aren't used (even if they exist on the children) as a result of +the way the children are accessed. + +=09 + -- + Thomas F. O'Connell + Co-Founder, Information Architect + Sitening, LLC + + Strategic Open Source: Open Your i(tm) + + http://www.sitening.com/ + 110 30th Avenue North, Suite 6 + Nashville, TN 37203-6320 + 615-469-5150 + 615-469-5151 (fax) +=09 + + On Aug 22, 2005, at 10:41 PM, Lenard, Rohan (Rohan) wrote: + + + I've read that indexes aren't used for COUNT(*) and I've +noticed (7.3.x) with EXPLAIN that indexes never seem to be used on empty +tables - is there any reason to have indexes on empty tables, or will +postgresql never use them. + =20 + This is not as silly as it sounds - with table +inheritance you might have table children with the data and a parent +that is empty. It'd be nice to make sure postgresql knows to never +really look at the parent - especially is you don't know the names of +all the children .. + =20 + Thoughts ? + =20 + thx, + Rohan + + + +------_=_NextPart_001_01C5ACE6.E73E5078 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + +
Actually the indexes on the child table do seem = +to get used=20 +- I just wanted to make sure there was no penalty not = +having indexes on the=20 +empty parent tables.
+
 
+
You are right - the parent is the best way = +to get at=20 +the unknown children ... 

+
+
+
+ From: Thomas F. O'Connell=20 + [mailto:tfo@sitening.com]
Sent: Tuesday, August 30, 2005 = +6:15=20 + AM
To: Lenard, Rohan (Rohan)
Cc:=20 + pgsql-performance@postgresql.org
Subject: Re: [PERFORM] Need = +indexes=20 + on empty tables for good performance ?

+
Rohan, +

+
You should note that in Postgres, indexes are not inherited by = +child=20 + tables.
+

+
Also, it seems difficult to select from a child table whose name = +you=20 + don't know unless you access the parent. And if you are accessing the = +data via=20 + the parent, I'm reasonably certain that you will find that indexes = +aren't used=20 + (even if they exist on the children) as a result of the way the = +children are=20 + accessed.
+

+
+
--
+
Thomas F. O'Connell
+
Co-Founder, Information Architect
+
Sitening, LLC
+

+
Strategic Open Source: Open Your i™
+

+ +
110 30th Avenue North, Suite 6
+
Nashville, TN 37203-6320
+
615-469-5150
615-469-5151 (fax)

+
+
On Aug 22, 2005, at 10:41 PM, Lenard, Rohan (Rohan) = +wrote:
+
+
I've read that=20 + indexes aren't used for COUNT(*) and I've noticed (7.3.x) with = +EXPLAIN that=20 + indexes never seem to be used on empty tables - is there any reason = +to have=20 + indexes on empty tables, or will postgresql never use=20 + them.
+
 
+
This is not as=20 + silly as it sounds - with table inheritance you might have table = +children=20 + with the data and a parent that is empty.  It'd be nice to make = +sure=20 + postgresql knows to never really look at the parent - especially is = +you=20 + don't know the names of all the children ..
+
 
+
Thoughts=20 + ?
+
 
+
thx,
+
 =20 + = +Rohan

+ +------_=_NextPart_001_01C5ACE6.E73E5078-- + +From pgsql-performance-owner@postgresql.org Mon Aug 29 19:59:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 75383D7F31 + for ; + Mon, 29 Aug 2005 19:59:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25531-10 + for ; + Mon, 29 Aug 2005 22:59:13 +0000 (GMT) +Received: from web35204.mail.mud.yahoo.com (web35204.mail.mud.yahoo.com + [66.163.179.83]) + by svr1.postgresql.org (Postfix) with SMTP id 52972D7F1E + for ; + Mon, 29 Aug 2005 19:59:09 -0300 (ADT) +Received: (qmail 69967 invoked by uid 60001); 29 Aug 2005 22:59:12 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=JTicJ7aGs+Zeadh2ZMP3406znto2Jl38AgbZXtcRQgDr19CWTDZQIk7Vz/aYQsU0H6zvuFO1XJzmrIxnUw+qQJkzNhdLiSwP3kSdVjefA2vq76vPcH88TNafqoVwSN/k6TbAJLNunR2aUz0ZPKtUOQelJa0t1s+MrnJf5VGX3OY= + ; +Message-ID: <20050829225912.69965.qmail@web35204.mail.mud.yahoo.com> +Received: from [65.218.233.130] by web35204.mail.mud.yahoo.com via HTTP; + Mon, 29 Aug 2005 15:59:12 PDT +Date: Mon, 29 Aug 2005 15:59:12 -0700 (PDT) +From: asif ali +Subject: Re: Weird performance drop after VACUUM +To: Michael Fuhr +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20050829202856.GA99478@winnie.fuhr.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.28 required=5 tests=[AWL=-0.094, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/503 +X-Sequence-Number: 14250 + +Michael, +The +effective_cache_size, random_page_cost, work_mem +were set to default. (commented). +I have changed the setting of these and now the +performance is better see below. + +"HashAggregate (cost=42573.89..42925.52 rows=20093 +width=37) (actual time=5273.984..5430.733 rows=55717 +loops=1)" +" -> Seq Scan on keyword_conversion_table c +(cost=0.00..27336.12 rows=870730 width=37) (actual +time=0.052..1405.576 rows=885493 loops=1)" +" Filter: ((conversion_date >= +'2005-06-07'::date) AND (conversion_date <= +'2005-08-17'::date))" +"Total runtime: 5463.764 ms" + + + +Thanks a lot + + + +--- Michael Fuhr wrote: + +> On Mon, Aug 29, 2005 at 11:07:17AM -0700, asif ali +> wrote: +> > The database is on the same system. +> > What I am doing is only "VACUUM analyze +> > conversion_table" +> > +> > I did the the same thing on a newly created +> database. +> > And got the same result. So after "VACUUM analyze" +> > performance dropped. +> > Please see this. Runtime changes from "7755.115" +> to +> > "14859.291" ms +> +> As has been pointed out a couple of times, you're +> getting a different +> plan after VACUUM ANALYZE because the row count +> estimates are more +> accurate. Unfortunately the more accurate estimates +> result in a +> query plan that's slower than the plan for the less +> accurate +> estimates. PostgreSQL *thinks* the plan will be +> faster but your +> results show that it isn't, so you might need to +> adjust some of the +> planner's cost constants. +> +> A asked some questions that you didn't answer, so +> I'll ask them again: +> +> What's your effective_cache_size setting? +> What's your work_mem (8.x) or sort_mem (7.x) +> setting? +> What's your random_page_cost setting? +> How much available RAM does the machine have? +> What version of PostgreSQL are you running? +> +> Various tuning guides give advice on how to set the +> above and other +> configuration variables. Here's one such guide: +> +> http://www.powerpostgresql.com/PerfList/ +> +> -- +> Michael Fuhr +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + + + +____________________________________________________ +Start your day with Yahoo! - make it your home page +http://www.yahoo.com/r/hs + + +From pgsql-performance-owner@postgresql.org Mon Aug 29 22:26:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D65C1D82F7 + for ; + Mon, 29 Aug 2005 22:26:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60830-02 + for ; + Tue, 30 Aug 2005 01:26:30 +0000 (GMT) +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id AEE72D82D1 + for ; + Mon, 29 Aug 2005 22:26:27 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 092452505A; + Tue, 30 Aug 2005 09:26:27 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 296B424FF1; + Tue, 30 Aug 2005 09:26:26 +0800 (WST) +Message-ID: <4313B5F3.9000400@familyhealth.com.au> +Date: Tue, 30 Aug 2005 09:27:15 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Carlos Henrique Reimer +Cc: pgsql-performance@postgresql.org +Subject: Re: shared buffers +References: <20050829162320.9576.qmail@web53211.mail.yahoo.com> +In-Reply-To: <20050829162320.9576.qmail@web53211.mail.yahoo.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.062 required=5 tests=[AWL=0.012, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/504 +X-Sequence-Number: 14251 + +> I�ve configured postgresql to use 1GB of shared buffers but meminfo and +> "top" are indicanting 0 shared buffers page. Why? + +1GB shared buffers is far too much. Set it back to like 30000 buffers +max... + +Chris + + +From pgsql-performance-owner@postgresql.org Mon Aug 29 22:54:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 71E36D7A26 + for ; + Mon, 29 Aug 2005 22:54:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75632-05 + for ; + Tue, 30 Aug 2005 01:54:51 +0000 (GMT) +Received: from web53204.mail.yahoo.com (web53204.mail.yahoo.com + [206.190.49.74]) + by svr1.postgresql.org (Postfix) with SMTP id 26703D6E21 + for ; + Mon, 29 Aug 2005 22:54:50 -0300 (ADT) +Received: (qmail 54154 invoked by uid 60001); 30 Aug 2005 01:54:54 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; + h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=jyf4ihk8PLibD/muw8PHko9j+mgcq0o52j4fUI3GX7xI5iagO85uJ68T5X8tA85R+sgzH+WCTMUc1Qdr9FqPZApYmeDg/tG7lYT0MI09F8H/3UVbDVFp7+JIQvwZcfJ+g4xsJ2F0t0qTXtAETLAlZalMEYM8TUUsOVXd8vagETs= + ; +Message-ID: <20050830015454.54152.qmail@web53204.mail.yahoo.com> +Received: from [201.2.219.48] by web53204.mail.yahoo.com via HTTP; + Mon, 29 Aug 2005 22:54:54 ART +Date: Mon, 29 Aug 2005 22:54:54 -0300 (ART) +From: Carlos Henrique Reimer +Subject: Re: shared buffers +To: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <4313B5F3.9000400@familyhealth.com.au> +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-841335462-1125366894=:50910" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.321 required=5 tests=[AWL=-0.140, + DNS_FROM_RFC_ABUSE=0.374, HTML_40_50=0.086, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/505 +X-Sequence-Number: 14252 + +--0-841335462-1125366894=:50910 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +I forgot to say that it�s a 12GB database... + +Ok, I�ll set shared buffers to 30.000 pages but even so "meminfo" and "top" shouldn�t show some shared pages? + +I heard something about that Redhat 9 can�t handle very well RAM higher than 2GB. Is it right? + +Thanks in advance! + +Reimer + +Christopher Kings-Lynne escreveu: +> I�ve configured postgresql to use 1GB of shared buffers but meminfo and +> "top" are indicanting 0 shared buffers page. Why? + +1GB shared buffers is far too much. Set it back to like 30000 buffers +max... + +Chris + + + +--------------------------------- +Yahoo! Acesso Gr�tis: Internet r�pida e gr�tis. Instale o discador agora! +--0-841335462-1125366894=:50910 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +
I forgot to say that it�s a 12GB database...
+
 
+
Ok, I�ll set shared buffers to 30.000 pages but even so "meminfo" and "top" shouldn�t show some shared pages?
+
 
+
I heard something about that Redhat 9 can�t handle very well RAM higher than 2GB. Is it right?
+
Thanks in advance!
+
 
+
Reimer
+

Christopher Kings-Lynne <chriskl@familyhealth.com.au> escreveu:
+
> I�ve configured postgresql to use 1GB of shared buffers but meminfo and
> "top" are indicanting 0 shared buffers page. Why?

1GB shared buffers is far too much. Set it back to like 30000 buffers
max...

Chris

+


Yahoo! Acesso Gr�tis: Internet r�pida e gr�tis. Instale o discador agora! +--0-841335462-1125366894=:50910-- + +From pgsql-performance-owner@postgresql.org Mon Aug 29 23:07:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 561D9D8208 + for ; + Mon, 29 Aug 2005 23:07:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88236-07 + for ; + Tue, 30 Aug 2005 02:07:31 +0000 (GMT) +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 06185D818E + for ; + Mon, 29 Aug 2005 23:07:29 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id EDEEE24FE6; + Tue, 30 Aug 2005 10:07:32 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 9EBEA2505D; + Tue, 30 Aug 2005 10:07:30 +0800 (WST) +Message-ID: <4313BF95.3030105@familyhealth.com.au> +Date: Tue, 30 Aug 2005 10:08:21 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Carlos Henrique Reimer +Cc: pgsql-performance@postgresql.org +Subject: Re: shared buffers +References: <20050830015454.54152.qmail@web53204.mail.yahoo.com> +In-Reply-To: <20050830015454.54152.qmail@web53204.mail.yahoo.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.062 required=5 tests=[AWL=0.012, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/506 +X-Sequence-Number: 14253 + +> I forgot to say that it�s a 12GB database... + +That's actually not that large. + +> Ok, I�ll set shared buffers to 30.000 pages but even so "meminfo" and +> "top" shouldn�t show some shared pages? + +Yeah. The reason for not setting buffers so high is because PostgreSQL +cannot efficiently manage huge shared buffers, so you're better off +giving the RAM to Linux's disk cache. + +Chris + + +From pgsql-performance-owner@postgresql.org Mon Aug 29 23:16:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D83DD8077 + for ; + Mon, 29 Aug 2005 23:16:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22707-07 + for ; + Tue, 30 Aug 2005 02:16:27 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 33381D7A26 + for ; + Mon, 29 Aug 2005 23:16:25 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7U2GKt7016377; + Mon, 29 Aug 2005 22:16:20 -0400 (EDT) +To: Carlos Henrique Reimer +Cc: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: shared buffers +In-reply-to: <20050830015454.54152.qmail@web53204.mail.yahoo.com> +References: <20050830015454.54152.qmail@web53204.mail.yahoo.com> +Comments: In-reply-to Carlos Henrique Reimer + message dated "Mon, 29 Aug 2005 22:54:54 -0300" +Date: Mon, 29 Aug 2005 22:16:20 -0400 +Message-ID: <16376.1125368180@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/507 +X-Sequence-Number: 14254 + +Carlos Henrique Reimer writes: +> I heard something about that Redhat 9 can�t handle very well RAM higher than 2GB. Is it right? + +RHL 9 is certainly pretty long in the tooth. Why aren't you using a +more recent distro? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 30 01:53:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 36484D7978 + for ; + Tue, 30 Aug 2005 01:53:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13915-05 + for ; + Tue, 30 Aug 2005 04:53:32 +0000 (GMT) +Received: from spark.hss.co.in (spark.hss.co.in [203.145.155.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BE4FD7909 + for ; + Tue, 30 Aug 2005 01:53:30 -0300 (ADT) +Received: from ultra.hss.co.in (ultra [192.168.100.5]) + by spark.hss.co.in (8.12.10/8.12.10) with ESMTP id j7U4mF3q020767 + for ; + Tue, 30 Aug 2005 10:18:21 +0530 (IST) +Received: from sandesh.hss.hns.com (localhost [127.0.0.1]) + by ultra.hss.co.in (8.10.0/8.10.0) with ESMTP id j7U4sKB09411 + for ; + Tue, 30 Aug 2005 10:24:20 +0530 (IST) +Subject: How to improve Postgres performance +To: pgsql-performance@postgresql.org +X-Mailer: Lotus Notes Release 6.5 September 26, 2003 +Message-ID: + +From: Hemant Pandey +Date: Tue, 30 Aug 2005 10:05:02 +0530 +X-MIMETrack: Serialize by Router on Sandesh/HSS(Release 6.0|September 26, + 2002) at 30/08/2005 10:23:17 AM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.464 required=5 tests=[AWL=-0.000, + ROUND_THE_WORLD_LOCAL=0.464] +X-Spam-Level: +X-Archive-Number: 200508/508 +X-Sequence-Number: 14255 + + + + + +Hi All, + I am running an application, which connects to the postgres +database at initialization time and perform the database operations like +Select/Update. +Database queries are very simple. +On analyzing my application through Quantifier( Performance analyzing +tool), I found the most of the time my application is waiting on recv, +waiting for Database response. +When i run Vacuum on perticular tables, i observed that performance +improoves drastically. + +So please tell me how can i improve database performance through +configuration parameters. I had tried to change parameters in +postgresql.conf file but of no avail. +Now i am trying to Auto Vacuum, but don't know how to run Auto Vacuum. + +Please help me to solve these problems. + +Thanks in advance. +Hemant + +*********************** FSS-Unclassified *********************** +"DISCLAIMER: This message is proprietary to Flextronics Software +Systems Limited (FSS) and is intended solely for the use of the +individual to whom it is addressed. It may contain privileged or +confidential information and should not be circulated or used for +any purpose other than for what it is intended. If you have received +this message in error, please notify the originator immediately. +If you are not the intended recipient, you are notified that you are +strictly prohibited from using, copying, altering, or disclosing +the contents of this message. FSS accepts no responsibility for +loss or damage arising from the use of the information transmitted +by this email including damage from virus." + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 03:04:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 90526D7D06 + for ; + Tue, 30 Aug 2005 03:04:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33414-01 + for ; + Tue, 30 Aug 2005 06:04:40 +0000 (GMT) +Received: from zigo.dhs.org (ua-83-227-204-174.cust.bredbandsbolaget.se + [83.227.204.174]) + by svr1.postgresql.org (Postfix) with ESMTP id 57352D7CFC + for ; + Tue, 30 Aug 2005 03:04:37 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id C2B528467; Tue, 30 Aug 2005 08:04:35 +0200 (CEST) +Date: Tue, 30 Aug 2005 08:04:35 +0200 (CEST) +From: Dennis Bjorklund +To: Hemant Pandey +Cc: pgsql-performance@postgresql.org +Subject: Re: How to improve Postgres performance +In-Reply-To: + +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.321 required=5 tests=[AWL=-0.103, + DNS_FROM_RFC_ABUSE=0.374, FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/509 +X-Sequence-Number: 14256 + +On Tue, 30 Aug 2005, Hemant Pandey wrote: + +> So please tell me how can i improve database performance through +> configuration parameters. I had tried to change parameters in +> postgresql.conf file but of no avail. +> Now i am trying to Auto Vacuum, but don't know how to run Auto Vacuum. + +The most important part is that you need to run VACUUM ANALYZE regulary. +Vacuum can be started each night in a cron job, started from pg_autovacuum +when it thinks it's needed, or started in some other way. In any case, it +has to be run whenever the data in the database have changed enough. + +The parameters in the config that is most important in my experience is +effective_cache_size and shared_buffers. + +This is a text I like (it's for pg 7.4 but still useful): + + http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 04:05:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 100C2D77EE + for ; + Tue, 30 Aug 2005 04:05:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48069-01 + for ; + Tue, 30 Aug 2005 07:05:19 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A4F14D7270 + for ; + Tue, 30 Aug 2005 04:05:15 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id B6C2F30952; Tue, 30 Aug 2005 09:05:16 +0200 (MET DST) +From: William Yu +X-Newsgroups: pgsql.performance +Subject: Re: shared buffers +Date: Tue, 30 Aug 2005 00:05:15 -0700 +Organization: Hub.Org Networking Services +Lines: 13 +Message-ID: +References: <4313B5F3.9000400@familyhealth.com.au> + <20050830015454.54152.qmail@web53204.mail.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +In-Reply-To: <20050830015454.54152.qmail@web53204.mail.yahoo.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[AWL=0.024] +X-Spam-Level: +X-Archive-Number: 200508/510 +X-Sequence-Number: 14257 + +Carlos Henrique Reimer wrote: +> I forgot to say that it�s a 12GB database... +> +> Ok, I�ll set shared buffers to 30.000 pages but even so "meminfo" and +> "top" shouldn�t show some shared pages? +> +> I heard something about that Redhat 9 can�t handle very well RAM higher +> than 2GB. Is it right? +> Thanks in advance! + +RH9, like any 32-bit OS, is limited to 2GB address space w/o special +tricks. However, it can access > 2GB for the OS disk cache using PAE if +you are running the bigmem kernel. + +From pgsql-performance-owner@postgresql.org Tue Aug 30 09:37:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A8EBD8420 + for ; + Tue, 30 Aug 2005 09:37:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48925-02 + for ; + Tue, 30 Aug 2005 12:37:17 +0000 (GMT) +Received: from pelego.atua.com.br (unknown [200.248.138.60]) + by svr1.postgresql.org (Postfix) with ESMTP id 42EA1D806D + for ; + Tue, 30 Aug 2005 09:37:16 -0300 (ADT) +Received: from [10.0.0.171] (unknown [10.0.0.171]) + by pelego.atua.com.br (Postfix) with ESMTP id 7381A13F657 + for ; + Tue, 30 Aug 2005 09:37:17 -0300 (BRT) +Message-ID: <431452FD.3090402@atua.com.br> +Date: Tue, 30 Aug 2005 09:37:17 -0300 +From: Alvaro Nunes Melo +User-Agent: Debian Thunderbird 1.0 (X11/20050116) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL - Performance +Subject: RAID Configuration Sugestion +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.027 required=5 tests=[AWL=0.027] +X-Spam-Level: +X-Archive-Number: 200508/511 +X-Sequence-Number: 14258 + +Hello, + +We are about to install a new PostgreSQL server, and despite of being a +very humble configuration compared to the ones we see in the list, it's +the biggest one we've got till now. + +The server is a Dual Xeon 3.0 with 2 GB RAM and two SCSI disks. Our main +doubt is what is the best configuration for the disks. We are thinking +about use them in a RAID-0 array. Is this the best option? What do you +suggest on partitioning? Separate partitions for the OS, data and pg_xlog? + +We'll have some time to work on performance tests, and if someone is +interested we can provide our results. + +Thanks in advance, +Alvaro + +From pgsql-performance-owner@postgresql.org Tue Aug 30 09:58:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3476BD843C + for ; + Tue, 30 Aug 2005 09:58:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49832-10 + for ; + Tue, 30 Aug 2005 12:58:21 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.197.194]) + by svr1.postgresql.org (Postfix) with SMTP id 9939FD8471 + for ; + Tue, 30 Aug 2005 09:58:19 -0300 (ADT) +Received: (qmail 24048 invoked by uid 500); 30 Aug 2005 12:58:08 -0000 +Date: Tue, 30 Aug 2005 07:58:08 -0500 +From: Bruno Wolff III +To: Alvaro Nunes Melo +Cc: PostgreSQL - Performance +Subject: Re: RAID Configuration Sugestion +Message-ID: <20050830125808.GD22545@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Alvaro Nunes Melo , + PostgreSQL - Performance +References: <431452FD.3090402@atua.com.br> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <431452FD.3090402@atua.com.br> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/512 +X-Sequence-Number: 14259 + +On Tue, Aug 30, 2005 at 09:37:17 -0300, + Alvaro Nunes Melo wrote: +> +> The server is a Dual Xeon 3.0 with 2 GB RAM and two SCSI disks. Our main +> doubt is what is the best configuration for the disks. We are thinking +> about use them in a RAID-0 array. Is this the best option? What do you +> suggest on partitioning? Separate partitions for the OS, data and pg_xlog? + +You don't have a lot of options with just two disks. What are you trying +to accomplish with raid? + +Raid 0 will possibly give you some speed up, while raid 1 will give you some +fault tolerance, some speed of of reads, but cost you half your disk space. + +From pgsql-performance-owner@postgresql.org Tue Aug 30 10:05:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ADA13D84EB + for ; + Tue, 30 Aug 2005 10:05:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51434-10 + for ; + Tue, 30 Aug 2005 13:05:13 +0000 (GMT) +Received: from mail2.bona.us (mail2.bona.us [216.235.153.18]) + by svr1.postgresql.org (Postfix) with SMTP id E1037D84DF + for ; + Tue, 30 Aug 2005 10:05:11 -0300 (ADT) +Received: (qmail 7113 invoked by uid 399); 30 Aug 2005 13:10:58 -0000 +Received: from unknown (HELO Akshay) (210.212.168.94) + by mail2.bona.us with SMTP; 30 Aug 2005 13:10:58 -0000 +From: "Akshay Mathur" +To: +Subject: Observation about db response time +Date: Tue, 30 Aug 2005 18:35:30 +0530 +Message-ID: <003401c5ad63$8420d940$9701a8c0@pune.wibhu.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0035_01C5AD91.9DD91540" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.19 required=5 tests=[HTML_90_100=0.189, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/513 +X-Sequence-Number: 14260 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0035_01C5AD91.9DD91540 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +Hello Friends, + +We were having a database in pgsql7.4.2 The database was responding very +slowly even after full vacuum analyze (select count(*) from +some_table_having_18000_records was taking 18 Sec). + +We took a backup of that db and restored it back. Now the same db on +same PC is responding fast (same query is taking 18 ms). + +But we can't do the same as a solution of slow response. Do anybody has +faced similar problem? Is this due to any internal problem of pgsql? Is +there any clue to fasten the database? + +Regards, + +akshay + + +--------------------------------------- +Akshay Mathur +SMTS, Product Verification +AirTight Networks, Inc. ( +www.airtightnetworks.net) +O: +91 20 2588 1555 ext 205 +F: +91 20 2588 1445 + + +------=_NextPart_000_0035_01C5AD91.9DD91540 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + + + + +
+ +

Hello Friends,

+ +

 

+ +

We were having a database in pgsql7.4.2 The database = +was +responding very slowly even after full vacuum analyze (select count(*) from some_table_having_18000_records was = +taking 18 +Sec).

+ +

 

+ +

We took a backup of that db and restored it back. Now = +the +same db on same PC is responding fast (same query is taking 18 = +ms).

+ +

 

+ +

But we can't do the same as a solution of slow = +response. Do +anybody has faced similar problem? Is this due to any internal problem = +of +pgsql? Is there any clue to fasten the = +database?

+ +

 

+ +

Regards,

+ +

 

+ +

akshay<= +font +size=3D2 face=3DArial> + +

 

+ +

 

+ +

-----------------------------------= +----

+ +

Akshay Mathur

+ +

SMTS, Product = +Verification

+ +

AirTight = +Networks, Inc. +(= +www.airtightnetworks.net)

+ +

O: +91 20 2588 1555 ext = +205

+ +

F: +91 20 2588 1445

+ +

 

+ +
+ + + + + +------=_NextPart_000_0035_01C5AD91.9DD91540-- + + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 10:15:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 46800D8466 + for ; + Tue, 30 Aug 2005 10:12:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58059-01 + for ; + Tue, 30 Aug 2005 13:12:37 +0000 (GMT) +Received: from frank.wiles.org (frank.wiles.org [24.124.39.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F21BD7837 + for ; + Tue, 30 Aug 2005 10:12:35 -0300 (ADT) +Received: from kungfu (frank.wiles.org [127.0.0.1]) + by frank.wiles.org (8.13.1/8.13.1) with SMTP id j7UDCbOR007840; + Tue, 30 Aug 2005 08:12:37 -0500 +Date: Tue, 30 Aug 2005 08:13:22 -0500 +From: Frank Wiles +To: "Akshay Mathur" +Cc: pgsql-performance@postgresql.org +Subject: Re: Observation about db response time +Message-Id: <20050830081322.20a13d4f.frank@wiles.org> +In-Reply-To: <003401c5ad63$8420d940$9701a8c0@pune.wibhu.com> +References: <003401c5ad63$8420d940$9701a8c0@pune.wibhu.com> +X-Mailer: Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-redhat-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.018 required=5 tests=[AWL=0.018] +X-Spam-Level: +X-Archive-Number: 200508/514 +X-Sequence-Number: 14261 + +On Tue, 30 Aug 2005 18:35:30 +0530 +"Akshay Mathur" wrote: + +> Hello Friends, +> +> We were having a database in pgsql7.4.2 The database was responding +> very slowly even after full vacuum analyze (select count(*) from +> some_table_having_18000_records was taking 18 Sec). +> +> We took a backup of that db and restored it back. Now the same db on +> same PC is responding fast (same query is taking 18 ms). +> +> But we can't do the same as a solution of slow response. Do anybody +> has faced similar problem? Is this due to any internal problem of +> pgsql? Is there any clue to fasten the database? + + This could be because you don't have max_fsm_pages and + max_fsm_relations setup correctly or are not doing full vacuums + often enough. + + If your database deletes a ton of data as a matter of course then + sometimes a full vacuum will not clear up as much space as it could. + + Try increasing those configuration values and doing vacuums more + often. + + If you should also explore upgrading to the latest 8.0 as you will + no doubt see noticeable speed improvements. + + --------------------------------- + Frank Wiles + http://www.wiles.org + --------------------------------- + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 10:50:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 514A1D8420 + for ; + Tue, 30 Aug 2005 10:50:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65939-02 + for ; + Tue, 30 Aug 2005 13:50:31 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.197.194]) + by svr1.postgresql.org (Postfix) with SMTP id 3FEDED845E + for ; + Tue, 30 Aug 2005 10:50:29 -0300 (ADT) +Received: (qmail 29287 invoked by uid 500); 30 Aug 2005 13:50:18 -0000 +Date: Tue, 30 Aug 2005 08:50:18 -0500 +From: Bruno Wolff III +To: Alvaro Nunes Melo +Cc: pgsql-performance@postgresql.org +Subject: Re: RAID Configuration Sugestion +Message-ID: <20050830135018.GA27789@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Alvaro Nunes Melo , + pgsql-performance@postgresql.org +References: <431452FD.3090402@atua.com.br> <20050830125808.GD22545@wolff.to> + <43145BE1.9050306@atua.com.br> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <43145BE1.9050306@atua.com.br> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/515 +X-Sequence-Number: 14262 + +Please keep replies copied to the list so that others may contribute to +and learn from the discussion. + +On Tue, Aug 30, 2005 at 10:15:13 -0300, + Alvaro Nunes Melo wrote: +> Hello Bruno, +> +> Bruno Wolff III wrote: +> +> >On Tue, Aug 30, 2005 at 09:37:17 -0300, +> > Alvaro Nunes Melo wrote: +> > +> > +> >>The server is a Dual Xeon 3.0 with 2 GB RAM and two SCSI disks. Our main +> >>doubt is what is the best configuration for the disks. We are thinking +> >>about use them in a RAID-0 array. Is this the best option? What do you +> >>suggest on partitioning? Separate partitions for the OS, data and pg_xlog? +> > +> Our main goal is performance speedup. Disk space might not be a problem. +> I've read a lot here about movig pg_xlog to different partitions, and +> we'll surely make tests to see what configuration might be better. + +This isn't a very good mix of hardware for running postgres. Xeons have +some context switching issues for which you will probably see some +speed up in 8.1. (So if you aren't going into production for sevral +months you might want to be using 8.1beta.) Having only two disk drives +is also not a good idea. + +With what you have you either want to use raid 0 and not worry too much +about how the disks are partitioned or use one disk for wal logging +and the other for other stuff. There are other people on the list who +can probably give you a better idea of which of these options is likely +to be better in your case. However, they may need to know more about +your raid controller. In particular how much battery backed memory does +it have and its model. + +From pgsql-performance-owner@postgresql.org Tue Aug 30 11:04:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 70347D84BD + for ; + Tue, 30 Aug 2005 11:04:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69939-01 + for ; + Tue, 30 Aug 2005 14:04:45 +0000 (GMT) +Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [204.127.198.43]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C47AD84AE + for ; + Tue, 30 Aug 2005 11:04:44 -0300 (ADT) +Received: from jefftrout.com ([24.147.120.205]) + by comcast.net (rwcrmhc12) with SMTP + id <2005083014044701400aq57se>; Tue, 30 Aug 2005 14:04:48 +0000 +Received: (qmail 31849 invoked from network); 30 Aug 2005 14:05:46 -0000 +Received: from c-24-147-120-205.hsd1.ma.comcast.net (HELO ?192.168.0.106?) + (24.147.120.205) + by 192.168.0.109 with SMTP; 30 Aug 2005 14:05:46 -0000 +In-Reply-To: <11273.1125338254@sss.pgh.pa.us> +References: + <26476.1125259249@sss.pgh.pa.us> + <486EB962-5B80-49B4-AF01-0C2DD77CC9EF@torgo.978.org> + <11273.1125338254@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v734) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: postgres performance +Content-Transfer-Encoding: 7bit +From: Jeff Trout +Subject: Re: OSX & Performance +Date: Tue, 30 Aug 2005 10:04:44 -0400 +To: Tom Lane +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/516 +X-Sequence-Number: 14263 + + +On Aug 29, 2005, at 1:57 PM, Tom Lane wrote: +> +> You must have CFLAGS set to empty in your build environment, because +> configure will certainly default to -O2 if not overridden. It works +> fine for me on OS X. Maybe you want to trace through the configure +> script and see why it's doing something else? +> + +/me hangs head in shame. + +Yes. I'd been futzing with various settings and had CFLAGS set to +empty instead of cleared out. 8.0.3 and -snapshot (8/29) both seem +to now compile with -O2 + +Anyway, I tried putting together a nice self-data-producing test case +but that didn't cause the bug. So I'm trying to get this dump as +small as possible (I'll email you a url later). + +To tide things over, here's the gprof (and shark) output for my query +of doom. + +linux box: + + 6.36 0.41 0.41 240694 0.00 0.00 _bt_compare + 5.97 0.79 0.38 907242 0.00 0.00 AllocSetAlloc + 4.55 1.07 0.29 135008 0.00 0.00 hash_any + 4.16 1.34 0.27 185684 0.00 0.00 +MemoryContextAllocZeroAlig +ned + 3.30 1.55 0.21 39152 0.01 0.01 localsub + 2.98 1.74 0.19 1213172 0.00 0.00 AllocSetFreeIndex + 2.83 1.92 0.18 52695 0.00 0.00 nocachegetattr + 2.75 2.10 0.17 134775 0.00 0.00 hash_search + 2.51 2.25 0.16 47646 0.00 0.01 +StrategyBufferLookup + 2.28 2.40 0.14 71990 0.00 0.00 fmgr_isbuiltin + 2.20 2.54 0.14 33209 0.00 0.00 _bt_moveright + 1.88 2.66 0.12 78864 0.00 0.00 comparetup_heap + 1.57 2.76 0.10 63485 0.00 0.00 SearchCatCache + 1.41 2.85 0.09 39152 0.00 0.00 timesub + 1.26 2.93 0.08 325246 0.00 0.00 tas + 1.26 3.01 0.08 305883 0.00 0.00 AllocSetFree + 1.26 3.09 0.08 162622 0.00 0.00 LWLockAcquire + +and on osx: (self, total, library, func) + + 29.0% 29.0% postmaster _bt_checkkeys + 15.6% 15.6% postmaster FunctionCall2 + 10.4% 10.4% libSystem.B.dylib __isnand + 9.5% 9.5% postmaster timestamp_cmp_internal + 9.3% 9.3% postmaster _bt_step + 5.3% 5.3% postmaster timestamp_le + 4.9% 4.9% postmaster _bt_next + 3.6% 3.6% postmaster dyld_stub___isnand + 3.1% 3.1% postmaster timestamp_gt + 1.9% 1.9% postmaster int4eq + 1.3% 1.3% postmaster BufferGetBlockNumber + 0.6% 0.6% postmaster LWLockAcquire + 0.5% 0.5% postmaster LWLockRelease + 0.4% 0.4% postmaster hash_search + +On my failed simulated attempt here's what things looked liek (the +data should have been relatively similar). + +linux: + + 5.39 0.28 0.28 852086 0.00 0.00 AllocSetAlloc + 4.90 0.53 0.25 130165 0.00 0.00 hash_any + 4.12 0.73 0.21 214061 0.00 0.00 _bt_compare + 4.12 0.94 0.21 39152 0.01 0.01 localsub + 4.02 1.15 0.20 160487 0.00 0.00 +MemoryContextAllocZeroAlig +ned + 3.24 1.31 0.17 1157316 0.00 0.00 AllocSetFreeIndex + 3.14 1.48 0.16 64375 0.00 0.00 fmgr_isbuiltin + 2.55 1.60 0.13 56142 0.00 0.00 SearchCatCache + 2.35 1.73 0.12 130076 0.00 0.00 hash_search + 1.76 1.81 0.09 39152 0.00 0.00 timesub + 1.67 1.90 0.09 221469 0.00 0.00 +timestamp_cmp_internal + 1.67 1.99 0.09 56069 0.00 0.00 +MemoryContextCreate + 1.57 2.06 0.08 145787 0.00 0.00 LWLockRelease + 1.37 2.13 0.07 289119 0.00 0.00 pfree + 1.37 2.21 0.07 8002 0.01 0.02 +ExecMakeFunctionResult + 1.37 2.27 0.07 8000 0.01 0.22 ExecInitIndexScan + 1.18 2.33 0.06 291574 0.00 0.00 tas + +and on osx: (which runs very fast, usually a couple hundred ms faster +than the linux box) + + 5.9% 5.9% postmaster LWLockAcquire + 5.2% 5.2% postmaster AllocSetAlloc + 4.9% 4.9% postmaster LWLockRelease + 3.9% 3.9% postmaster hash_any + 3.6% 3.6% postmaster _bt_compare + 2.9% 2.9% postmaster hash_search + 2.6% 2.6% postmaster MemoryContextAllocZeroAligned + 2.6% 2.6% postmaster ExecInitExpr + 2.0% 2.0% mach_kernel ml_set_interrupts_enabled + 2.0% 2.0% postmaster fmgr_info_cxt_security + 2.0% 2.0% postmaster AllocSetFree + 1.6% 1.6% postmaster MemoryContextAlloc + 1.6% 1.6% postmaster FunctionCall2 + 1.6% 1.6% postmaster AllocSetDelete + 1.6% 1.6% libSystem.B.dylib __isnand + +which to me anyway, looks like basically the same profile. +So there must be something about the exact nature of hte data that is +kicking it in the nuts. + +I tried making a copy of hte table using select into, I get the same +performace. Clustered on the index.. same hting. + +The table is a timestamp (no tz), 2 ints and 4 doubles. The index is +on (timestamp, int1) + +As I said before, I'll send a url along to the dump once it has +dumped and I get it somewhere good (unless I get my test data +generator to invoke this problem). I could also get you access to +this machine, but be warned gprof on tiger is pretty useless from +what I've seen. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 11:46:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A3C5BD84E6 + for ; + Tue, 30 Aug 2005 11:45:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78523-02 + for ; + Tue, 30 Aug 2005 14:45:16 +0000 (GMT) +Received: from smtpauth04.mail.atl.earthlink.net + (smtpauth04.mail.atl.earthlink.net [209.86.89.64]) + by svr1.postgresql.org (Postfix) with ESMTP id B768CD84A0 + for ; + Tue, 30 Aug 2005 11:45:14 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=TFmJe7fdFb8vD7RUpIffqUaCxGGLKGHfE3NdlDibNdqre8A8MbcoBZeC4S588Rlx; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth04.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1EA7MV-0004BF-17; Tue, 30 Aug 2005 10:45:19 -0400 +Message-Id: <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Tue, 30 Aug 2005 10:45:15 -0400 +To: Alvaro Nunes Melo , + PostgreSQL - Performance +From: Ron +Subject: Re: RAID Configuration Sugestion +In-Reply-To: <431452FD.3090402@atua.com.br> +References: <431452FD.3090402@atua.com.br> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc08336fd781258abe18091a7a0d203f53350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.418 required=5 tests=[AWL=0.044, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/517 +X-Sequence-Number: 14264 + +At 08:37 AM 8/30/2005, Alvaro Nunes Melo wrote: +>Hello, +> +>We are about to install a new PostgreSQL server, and despite of +>being a very humble configuration compared to the ones we see in the +>list, it's the biggest one we've got till now. +> +>The server is a Dual Xeon 3.0 with 2 GB RAM and two SCSI disks. Our +>main doubt is what is the best configuration for the disks. We are +>thinking about use them in a RAID-0 array. Is this the best option? +>What do you suggest on partitioning? Separate partitions for the OS, +>data and pg_xlog? + +This is _very_ modest HW. Unless your DB and/or DB load is similarly +modest, you are not going to be happy with the performance of your DBMS. + +At a minimum, for safety reasons you want 4 HDs: 2 for a RAID 1 set +for the DB, and 2 for a RAID 1 set for the OS + pg_xlog. +2 extra HDs, even SCSI HDs, is cheap. Especially when compared to +the cost of corrupted or lost data. + +HD's and RAM are cheap enough that you should be able to upgrade in +more ways, but do at least that "upgrade"! + +Beyond that, the best ways to spend you limited $ are highly +dependent on your exact DB and its usage pattern. + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 11:53:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F0D9D84F7 + for ; + Tue, 30 Aug 2005 11:53:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77735-08 + for ; + Tue, 30 Aug 2005 14:53:47 +0000 (GMT) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id D92FDD84F5 + for ; + Tue, 30 Aug 2005 11:53:45 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 21372B80F + for ; + Tue, 30 Aug 2005 10:53:49 -0400 (EDT) +In-Reply-To: <003401c5ad63$8420d940$9701a8c0@pune.wibhu.com> +References: <003401c5ad63$8420d940$9701a8c0@pune.wibhu.com> +Mime-Version: 1.0 (Apple Message framework v734) +X-Priority: 3 (Normal) +Content-Type: multipart/alternative; boundary=Apple-Mail-4--1069943359 +Message-Id: <4A58CB9B-F92A-40F9-99B8-CD783B1B71C2@khera.org> +From: Vivek Khera +Subject: Re: Observation about db response time +Date: Tue, 30 Aug 2005 10:53:48 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.734) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.147 required=5 tests=[AWL=-0.113, HTML_60_70=0.027, + HTML_FONT_BIG=0.232, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/518 +X-Sequence-Number: 14265 + + +--Apple-Mail-4--1069943359 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On Aug 30, 2005, at 9:05 AM, Akshay Mathur wrote: + +> We were having a database in pgsql7.4.2 The database was responding +> very slowly even after full vacuum analyze (select count(*) from +> some_table_having_18000_records was taking 18 Sec). +On a 7.4.2 db, there should probably be no index bloat, but there +could be. Does REINDEX on your tables help? If not, then VACUUM +FULL followed by REINDEX may help. The latter should result in +nearly the same as your dump+restore. And you need to run vacuum +often enough to keep your tables from bloating. How often that is +depends on your update/delete rate. + +Also, updating to 8.0 may help. + +Vivek Khera, Ph.D. ++1-301-869-4449 x806 + + + +--Apple-Mail-4--1069943359 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +
On Aug 30, 2005, = +at 9:05 AM, Akshay Mathur wrote:

We were having a database in pgsql7.4.2 The = +database was responding very slowly even after full vacuum analyze = +(select count(*) from = +some_table_having_18000_records was taking 18 = +Sec).

On a 7.4.2 db, there = +should probably be no index bloat, but there could be.=A0 Does REINDEX = +on your tables help?=A0 If not, then VACUUM FULL followed by REINDEX may = +help.=A0 The latter should result in nearly the same as your = +dump+restore.=A0 And you need to run vacuum often enough to keep your = +tables from bloating.=A0 How often that is depends on your update/delete = +rate.

Also,= + updating to 8.0 may help.

Vivek Khera, Ph.D.

+1-301-869-4449 x806



= + +--Apple-Mail-4--1069943359-- + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:11:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D6B0D8556 + for ; + Tue, 30 Aug 2005 13:11:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98564-04 + for ; + Tue, 30 Aug 2005 16:10:59 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 2566FD8547 + for ; + Tue, 30 Aug 2005 13:10:58 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i31so797060wxd + for ; + Tue, 30 Aug 2005 09:10:58 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=r++98p1IMH1CtuOt3v7kzpPpjD1MWC8Vd5udydXdXUC0T9QmWGG6TovY6lhBsju8gW1UDgbCpdZRCx93USLLCKYjOdHM+tjO61gb8LxC1/sGnB25j6KrKJVmanQqFALswo5jNwoGAyW2dU4H3mF+iLT9dCm+TxpNFTWKOdL0cdI= +Received: by 10.70.90.15 with SMTP id n15mr133462wxb; + Tue, 30 Aug 2005 09:10:58 -0700 (PDT) +Received: by 10.70.128.19 with HTTP; Tue, 30 Aug 2005 09:10:58 -0700 (PDT) +Message-ID: +Date: Tue, 30 Aug 2005 11:10:58 -0500 +From: Matthew Nuzum +Reply-To: newz@bearfruit.org +To: pgsql-performance@postgresql.org +Subject: Re: RAID Configuration Sugestion +In-Reply-To: <20050830135018.GA27789@wolff.to> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <431452FD.3090402@atua.com.br> <20050830125808.GD22545@wolff.to> + <43145BE1.9050306@atua.com.br> <20050830135018.GA27789@wolff.to> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/522 +X-Sequence-Number: 14269 + +> > >On Tue, Aug 30, 2005 at 09:37:17 -0300, +> > > Alvaro Nunes Melo wrote: +> > >>The server is a Dual Xeon 3.0 with 2 GB RAM and two SCSI disks. Our m= +ain +> > >>doubt is what is the best configuration for the disks. We are thinkin= +g +> > >>about use them in a RAID-0 array. Is this the best option? What do yo= +u +> > >>suggest on partitioning? Separate partitions for the OS, data and pg_= +xlog? +> > > +> > Our main goal is performance speedup. Disk space might not be a problem= +. +> > I've read a lot here about movig pg_xlog to different partitions, and +> > we'll surely make tests to see what configuration might be better. +>=20 + +I've set up several servers with a config like this. Its not ideal, +but there's no reason you can't enjoy the benefits of a snappy +application. + +The best results I've had involve dedicating one drive to OS, swap, +logs, tmp and everything and dedicate one drive to postgres. If you +use *nix you can mount the second drive as /var/lib/pgsql (or where +ever postgres lives on your server) with noatime as a mount option. + +In retrospect, you might have saved the money on the second CPU and +gotten two more hard drives, but if you're running a dual task server +(i.e. LAMP) you may appreciate the second CPU. + +The beauty of a server like this is that it puts more of the wizardry +of creating a fast application into the hands of the app developer, +which results in a better db schema, optimized queries and generally +*thinking* about the performance of the code. I personally feel that +to be a very rewarding aspect of my job. (As a hobby I program +microntrollers that run at 4MHz and have only 256 bytes of RAM, so +that could just be me.;-) + +--=20 +Matthew Nuzum +www.bearfruit.org + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:29:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EF32D8547 + for ; + Tue, 30 Aug 2005 13:15:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96235-10 + for ; + Tue, 30 Aug 2005 16:15:53 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5426AD850C + for ; + Tue, 30 Aug 2005 13:15:52 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7UGFp8g022418; + Tue, 30 Aug 2005 12:15:51 -0400 (EDT) +To: =?ISO-8859-1?Q?R=E9my_Beaumont?= +Cc: pgsql-performance@postgresql.org +Subject: Re: High load and iowait but no disk access +In-reply-to: +References: +Comments: In-reply-to =?ISO-8859-1?Q?R=E9my_Beaumont?= + message dated "Mon, 29 Aug 2005 09:42:46 -0400" +Date: Tue, 30 Aug 2005 12:15:51 -0400 +Message-ID: <22417.1125418551@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/526 +X-Sequence-Number: 14273 + +=?ISO-8859-1?Q?R=E9my_Beaumont?= writes: +> The stats of the NetApp do confirm that it is sitting idle. + +Really? + +> CPU NFS CIFS HTTP Total Net kB/s Disk kB/s Tape kB/s +> Cache Cache CP CP Disk DAFS FCP iSCSI FCP kB/s +> in out read write read write +> age hit time ty util in out +> 2% 0 0 0 139 0 0 2788 0 0 0 +> 3 96% 0% - 15% 0 139 0 3 2277 +> 2% 0 0 0 144 0 0 2504 0 0 0 +> 3 96% 0% - 18% 0 144 0 3 2150 +> 2% 0 0 0 130 0 0 2212 0 0 0 +> 3 96% 0% - 13% 0 130 0 3 1879 +> 3% 0 0 0 169 0 0 2937 80 0 0 +> 3 96% 0% - 13% 0 169 0 4 2718 +> 2% 0 0 0 139 0 0 2448 0 0 0 +> 3 96% 0% - 12% 0 139 0 3 2096 + +I know zip about NetApps, but doesn't the 8th column indicate pretty +steady disk reads? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:21:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37195D85A5 + for ; + Tue, 30 Aug 2005 13:19:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99240-04 + for ; + Tue, 30 Aug 2005 16:19:29 +0000 (GMT) +Received: from iad2.emailsrvr.com (iad2.emailsrvr.com [207.97.227.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 692E6D85A2 + for ; + Tue, 30 Aug 2005 13:19:28 -0300 (ADT) +Received: from [10.10.20.22] (unknown [216.94.157.147]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + (Authenticated sender: remyb@medrium.com) + by relay2.r2.iad.emailsrvr.com (SMTP Server) with ESMTP id 6348344C36C; + Tue, 30 Aug 2005 12:19:28 -0400 (EDT) +In-Reply-To: <22417.1125418551@sss.pgh.pa.us> +References: + <22417.1125418551@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v622) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Message-Id: <2fa5224f3e5af53598e33d115a2af980@medrium.com> +Content-Transfer-Encoding: quoted-printable +Cc: pgsql-performance@postgresql.org +From: =?ISO-8859-1?Q?R=E9my_Beaumont?= +Subject: Re: High load and iowait but no disk access +Date: Tue, 30 Aug 2005 12:19:30 -0400 +To: Tom Lane +X-Mailer: Apple Mail (2.622) +X-Virus-Scanned: OK +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/524 +X-Sequence-Number: 14271 + + +On 30-Aug-05, at 12:15, Tom Lane wrote: + +> =3D?ISO-8859-1?Q?R=3DE9my_Beaumont?=3D writes: +>> The stats of the NetApp do confirm that it is sitting idle. +> +> Really? + + +> +>> CPU NFS CIFS HTTP Total Net kB/s Disk kB/s Tape kB/s +>> Cache Cache CP CP Disk DAFS FCP iSCSI FCP kB/s +>> in out read write read write +>> age hit time ty util in out +>> 2% 0 0 0 139 0 0 2788 0 0 0 +>> 3 96% 0% - 15% 0 139 0 3 2277 +>> 2% 0 0 0 144 0 0 2504 0 0 0 +>> 3 96% 0% - 18% 0 144 0 3 2150 +>> 2% 0 0 0 130 0 0 2212 0 0 0 +>> 3 96% 0% - 13% 0 130 0 3 1879 +>> 3% 0 0 0 169 0 0 2937 80 0 0 +>> 3 96% 0% - 13% 0 169 0 4 2718 +>> 2% 0 0 0 139 0 0 2448 0 0 0 +>> 3 96% 0% - 12% 0 139 0 3 2096 +> +> I know zip about NetApps, but doesn't the 8th column indicate pretty +> steady disk reads? +Yes, but they are very low. +At 15% usage, it's pretty much sitting idle if you consider that the OS=20= + +reports that one of the processor is spending more then 80% of it's=20 +time in IOwait. + +R=E9my +> +> regards, tom lane + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:26:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 76BE3D85B0 + for ; + Tue, 30 Aug 2005 13:25:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99012-07 + for ; + Tue, 30 Aug 2005 16:25:31 +0000 (GMT) +Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) + by svr1.postgresql.org (Postfix) with ESMTP id 59926D85BA + for ; + Tue, 30 Aug 2005 13:25:27 -0300 (ADT) +Received: from osgiliath.mathom.us ([151.200.14.55]) + by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-2.05 + (built Apr + 28 2005)) with ESMTPA id <0IM100E7PMYE2E40@vms048.mailsrvcs.net> for + pgsql-performance@postgresql.org; Tue, 30 Aug 2005 11:25:27 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id A973F60040E for + ; + Tue, 30 Aug 2005 12:25:25 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 03023-04 for ; Tue, + 30 Aug 2005 12:25:25 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 377DD60041D; Tue, 30 Aug 2005 12:25:25 -0400 (EDT) +Date: Tue, 30 Aug 2005 12:25:25 -0400 +From: Michael Stone +Subject: Re: High load and iowait but no disk access +In-reply-to: +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050830162525.GU14921@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=iso-8859-1; format=flowed +Content-transfer-encoding: 8BIT +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.04 required=5 tests=[AWL=-0.010, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/525 +X-Sequence-Number: 14272 + +On Mon, Aug 29, 2005 at 09:42:46AM -0400, R�my Beaumont wrote: +>We have been trying to pinpoint what originally seem to be a I/O +>bottleneck but which now seems to be an issue with either Postgresql or +>RHES 3. + +Nope, it's an IO bottleneck. + +>The behavior we see is that when running queries that do random reads +>on disk, IOWAIT goes over 80% and actual disk IO falls to a crawl at a +>throughput bellow 3000kB/s + +That's the sign of an IO bottleneck. + +>The stats of the NetApp do confirm that it is sitting idle. Doing an +>strace on the Postgresql process shows that is it doing seeks and +>reads. +> +>So my question is where is this iowait time spent ? + +Waiting for the seeks. postgres doesn't do async io, so it requests a +block, waits for it to come in, then requests another block, etc. The +utilization on the netapp isn't going to be high because it doesn't have +a queue of requests and can't do readahead because the IO is random. The +only way to improve the situation would be to reduce the latency of the +seeks. If I read the numbers right you're only getting about 130 +seeks/s, which ain't great. I don't know how much latency the netapp +adds in the this configuration; have you tried benchmarking +direct-attach disks? + +Mike Stone + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:31:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5381CD84DF + for ; + Tue, 30 Aug 2005 13:29:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01229-06 + for ; + Tue, 30 Aug 2005 16:29:04 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 76F68D8507 + for ; + Tue, 30 Aug 2005 13:29:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7UGT3X2022551; + Tue, 30 Aug 2005 12:29:03 -0400 (EDT) +To: =?ISO-8859-1?Q?R=E9my_Beaumont?= +Cc: pgsql-performance@postgresql.org +Subject: Re: High load and iowait but no disk access +In-reply-to: <2fa5224f3e5af53598e33d115a2af980@medrium.com> +References: + <22417.1125418551@sss.pgh.pa.us> + <2fa5224f3e5af53598e33d115a2af980@medrium.com> +Comments: In-reply-to =?ISO-8859-1?Q?R=E9my_Beaumont?= + message dated "Tue, 30 Aug 2005 12:19:30 -0400" +Date: Tue, 30 Aug 2005 12:29:02 -0400 +Message-ID: <22550.1125419342@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/527 +X-Sequence-Number: 14274 + +=?ISO-8859-1?Q?R=E9my_Beaumont?= writes: +> On 30-Aug-05, at 12:15, Tom Lane wrote: +>> I know zip about NetApps, but doesn't the 8th column indicate pretty +>> steady disk reads? + +> Yes, but they are very low. + +Sure, but that's more or less what you'd expect if the thing is randomly +seeking all over the disk :-(. Just because it's a NetApp doesn't mean +it's got zero seek time. + +You did not say what sort of query this is, but I gather that it's doing +an indexscan on a table that is not at all in index order. Possible +solutions involve reverting to a seqscan (have you forced the planner to +choose an indexscan here, either directly or by lowering random_page_cost?) +or CLUSTERing the table by the index (which would need to be repeated +periodically, so it's not a great answer). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Sep 6 01:12:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A9494D85B4 + for ; + Tue, 30 Aug 2005 13:39:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03743-06 + for ; + Tue, 30 Aug 2005 16:39:22 +0000 (GMT) +Received: from gghcwest.com (adsl-71-128-90-172.dsl.pltn13.pacbell.net + [71.128.90.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F47CD85AE + for ; + Tue, 30 Aug 2005 13:39:20 -0300 (ADT) +Received: from kane (pc111.gghcwest.com [192.168.168.111]) + by gghcwest.com (8.12.10/8.12.9) with ESMTP id j7UGdGmd003954; + Tue, 30 Aug 2005 09:39:16 -0700 +Received: from jwb by kane with local (Exim 3.36 #1 (Debian)) + id 1EA98n-0000jF-00; Tue, 30 Aug 2005 09:39:17 -0700 +Subject: Re: Observation about db response time +From: "Jeffrey W. Baker" +To: Frank Wiles +Cc: Akshay Mathur , + pgsql-performance@postgresql.org +In-Reply-To: <20050830081322.20a13d4f.frank@wiles.org> +References: <003401c5ad63$8420d940$9701a8c0@pune.wibhu.com> + <20050830081322.20a13d4f.frank@wiles.org> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Tue, 30 Aug 2005 09:39:17 -0700 +Message-Id: <1125419957.2658.0.camel@kane> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200509/81 +X-Sequence-Number: 14389 + +On Tue, 2005-08-30 at 08:13 -0500, Frank Wiles wrote: +> On Tue, 30 Aug 2005 18:35:30 +0530 +> "Akshay Mathur" wrote: +> +> > Hello Friends, +> > +> > We were having a database in pgsql7.4.2 The database was responding +> > very slowly even after full vacuum analyze (select count(*) from +> > some_table_having_18000_records was taking 18 Sec). +> > +> > We took a backup of that db and restored it back. Now the same db on +> > same PC is responding fast (same query is taking 18 ms). +> > +> > But we can't do the same as a solution of slow response. Do anybody +> > has faced similar problem? Is this due to any internal problem of +> > pgsql? Is there any clue to fasten the database? +> +> This could be because you don't have max_fsm_pages and +> max_fsm_relations setup correctly or are not doing full vacuums +> often enough. +> +> If your database deletes a ton of data as a matter of course then +> sometimes a full vacuum will not clear up as much space as it could. +> +> Try increasing those configuration values and doing vacuums more +> often. +> +> If you should also explore upgrading to the latest 8.0 as you will +> no doubt see noticeable speed improvements. + +This can also be caused by index bloat. VACUUM does not clear out the +index. You must use REINDEX for that. + +-jwb + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:42:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3BD6D8536 + for ; + Tue, 30 Aug 2005 13:42:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03120-08 + for ; + Tue, 30 Aug 2005 16:42:12 +0000 (GMT) +Received: from iad2.emailsrvr.com (iad2.emailsrvr.com [207.97.227.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B9A7D84DF + for ; + Tue, 30 Aug 2005 13:42:11 -0300 (ADT) +Received: from [10.10.20.22] (unknown [216.94.157.147]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + (Authenticated sender: remyb@medrium.com) + by relay3.r3.iad.emailsrvr.com (SMTP Server) with ESMTP id 834F244C547; + Tue, 30 Aug 2005 12:42:11 -0400 (EDT) +In-Reply-To: <22550.1125419342@sss.pgh.pa.us> +References: + <22417.1125418551@sss.pgh.pa.us> + <2fa5224f3e5af53598e33d115a2af980@medrium.com> + <22550.1125419342@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v622) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Message-Id: +Content-Transfer-Encoding: quoted-printable +Cc: pgsql-performance@postgresql.org +From: =?ISO-8859-1?Q?R=E9my_Beaumont?= +Subject: Re: High load and iowait but no disk access +Date: Tue, 30 Aug 2005 12:42:13 -0400 +To: Tom Lane +X-Mailer: Apple Mail (2.622) +X-Virus-Scanned: OK +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/528 +X-Sequence-Number: 14275 + + +On 30-Aug-05, at 12:29, Tom Lane wrote: + +> =3D?ISO-8859-1?Q?R=3DE9my_Beaumont?=3D writes: +>> On 30-Aug-05, at 12:15, Tom Lane wrote: +>>> I know zip about NetApps, but doesn't the 8th column indicate pretty +>>> steady disk reads? +> +>> Yes, but they are very low. +> +> Sure, but that's more or less what you'd expect if the thing is=20 +> randomly +> seeking all over the disk :-(. Just because it's a NetApp doesn't = +mean +> it's got zero seek time. +Per NetApp, the disk utilization percentage they report does include=20 +seek time, not just read/write operations. +NetApp has been involved in trying to figure out what is going on and=20 +their claim is that the NetApp filer is not IO bound. + +> +> You did not say what sort of query this is, but I gather that it's=20 +> doing +> an indexscan on a table that is not at all in index order. +Yes, most of those queries are doing an indexscan. It's a fresh=20 +restore of our production database that we have vacuumed/analyzed. + +> Possible +> solutions involve reverting to a seqscan (have you forced the planner=20= + +> to +> choose an indexscan here, either directly or by lowering=20 +> random_page_cost?) +No. +> or CLUSTERing the table by the index (which would need to be repeated +> periodically, so it's not a great answer). +Will try to cluster the tables and see if it changes anything. Still=20 +doesn't explain what is going on with those seeks. + +Thanks, + +R=E9my + +> +> regards, tom lane + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 13:56:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6AB94D85AE + for ; + Tue, 30 Aug 2005 13:56:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08187-04 + for ; + Tue, 30 Aug 2005 16:56:33 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id E958AD85A8 + for ; + Tue, 30 Aug 2005 13:56:32 -0300 (ADT) +Received: from [192.168.1.100] (clbb-248.saw.net [64.146.135.248]) + (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + j7UGrwcg029183; Tue, 30 Aug 2005 09:53:58 -0700 +Message-ID: <43148FC4.4000407@commandprompt.com> +Date: Tue, 30 Aug 2005 09:56:36 -0700 +From: "Joshua D. Drake" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ron +Cc: Alvaro Nunes Melo , + PostgreSQL - Performance +Subject: Re: RAID Configuration Sugestion +References: <431452FD.3090402@atua.com.br> + <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> +In-Reply-To: <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); + Tue, 30 Aug 2005 09:53:59 -0700 (PDT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.022 required=5 tests=[AWL=0.022] +X-Spam-Level: +X-Archive-Number: 200508/529 +X-Sequence-Number: 14276 + +Ron wrote: + +> At 08:37 AM 8/30/2005, Alvaro Nunes Melo wrote: +> +>> Hello, +>> +>> We are about to install a new PostgreSQL server, and despite of being +>> a very humble configuration compared to the ones we see in the list, +>> it's the biggest one we've got till now. +>> +>> The server is a Dual Xeon 3.0 with 2 GB RAM and two SCSI disks. Our +>> main doubt is what is the best configuration for the disks. We are +>> thinking about use them in a RAID-0 array. Is this the best option? +>> What do you suggest on partitioning? Separate partitions for the OS, +>> data and pg_xlog? +> +> +> This is _very_ modest HW. Unless your DB and/or DB load is similarly +> modest, you are not going to be happy with the performance of your DBMS. + +Well that is a pretty blanket statement. I have many customers who +happily run in less hardware that what is mentioned above. +It all depends on the application itself and how the database is utilized. + +> At a minimum, for safety reasons you want 4 HDs: 2 for a RAID 1 set +> for the DB, and 2 for a RAID 1 set for the OS + pg_xlog. +> 2 extra HDs, even SCSI HDs, is cheap. Especially when compared to the +> cost of corrupted or lost data. + +Your real test is going to be prototyping the performance you need. A +single RAID 1 mirror (don't use RAID 0) may be more +than enough. However based on the fact that you speced Xeons my guess is +you spent money on CPUs when you should have +spent money on hard drives. + +If you still have the budget, I would suggest considering either what +Ron suggested or possibly using a 4 drive RAID 10 instead. + +If you can't afford to put a couple more SCSI disks it may be worth +while to put a software RAID 1 with ATA disks for the OS and +swap and then use straight SCSI hardware RAID 1 for the DB. That will +allow you to push any swap operations off to the OS disks +without sacrificing the performance and reliability of the database itself. + +Sincerely, + +Joshua D. Drake + + +> +> HD's and RAM are cheap enough that you should be able to upgrade in +> more ways, but do at least that "upgrade"! +> +> Beyond that, the best ways to spend you limited $ are highly dependent +> on your exact DB and its usage pattern. +> +> Ron Peacetree +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly + + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 14:43:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9451DD864B + for ; + Tue, 30 Aug 2005 14:43:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20731-01 + for ; + Tue, 30 Aug 2005 17:43:07 +0000 (GMT) +Received: from mail.travelamericas.com (unknown [206.130.134.147]) + by svr1.postgresql.org (Postfix) with SMTP id 99DFCD85C4 + for ; + Tue, 30 Aug 2005 14:43:05 -0300 (ADT) +Received: (qmail 7310 invoked from network); 30 Aug 2005 17:43:06 -0000 +Received: from unknown (HELO ?10.0.0.253?) (10.0.0.253) + by verkiel.travelamericas.com with SMTP; 30 Aug 2005 17:43:06 -0000 +Message-ID: <43149AA9.4080902@travelamericas.com> +Date: Tue, 30 Aug 2005 10:43:05 -0700 +From: Chris Travers +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Lenard, Rohan (Rohan)" +Cc: "Thomas F. O'Connell" , pgsql-performance@postgresql.org +Subject: Re: Need indexes on empty tables for good performance ? +References: + <2773CAC687FD5F4689F526998C7E4E5F489B7B@au3010avexu1.global.avaya.com> +In-Reply-To: + <2773CAC687FD5F4689F526998C7E4E5F489B7B@au3010avexu1.global.avaya.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/530 +X-Sequence-Number: 14277 + +Lenard, Rohan (Rohan) wrote: + +> Actually the indexes on the child table do seem to get used - I just +> wanted to make sure there was no penalty not having indexes on the +> empty parent tables. +> +> You are right - the parent is the best way to get at the unknown +> children ... + +Indexes are created in the inheritance process, iirc. However, index +entries are not inherited, which means that index-based unique +constraints don't properly get inherited. + +Best Wishes, +Chris Travers +Metatron Technology Consulting + +From pgsql-performance-owner@postgresql.org Tue Aug 30 15:20:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D7920D8622 + for ; + Tue, 30 Aug 2005 15:16:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26678-09 + for ; + Tue, 30 Aug 2005 18:16:28 +0000 (GMT) +Received: from smtpauth05.mail.atl.earthlink.net + (smtpauth05.mail.atl.earthlink.net [209.86.89.65]) + by svr1.postgresql.org (Postfix) with ESMTP id C8003D8613 + for ; + Tue, 30 Aug 2005 15:16:27 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=VeYw/HueHM3JX1nTD6NFsNMkG3ZCbUEFiL6GR0pAY83N0bCleGYD0e9kBK/XdGS3; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth05.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1EAAen-0000TT-Gm; Tue, 30 Aug 2005 14:16:25 -0400 +Message-Id: <6.2.3.4.0.20050830132902.021a5308@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Tue, 30 Aug 2005 14:16:23 -0400 +To: "Joshua D. Drake" , + +From: Ron +Subject: Re: RAID Configuration Sugestion +In-Reply-To: <43148FC4.4000407@commandprompt.com> +References: <431452FD.3090402@atua.com.br> + <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> + <43148FC4.4000407@commandprompt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bce55e80f265605b9174f79ddc68331a8f350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.412 required=5 tests=[AWL=0.038, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/531 +X-Sequence-Number: 14278 + +At 12:56 PM 8/30/2005, Joshua D. Drake wrote: +>Ron wrote: +> +>>At 08:37 AM 8/30/2005, Alvaro Nunes Melo wrote: +>> +>>>Hello, +>>> +>>>We are about to install a new PostgreSQL server, and despite of +>>>being a very humble configuration compared to the ones we see in +>>>the list, it's the biggest one we've got till now. +>>> +>>>The server is a Dual Xeon 3.0 with 2 GB RAM and two SCSI disks. +>>>Our main doubt is what is the best configuration for the disks. We +>>>are thinking about use them in a RAID-0 array. Is this the best +>>>option? What do you suggest on partitioning? Separate partitions +>>>for the OS, data and pg_xlog? +>> +>> +>>This is _very_ modest HW. Unless your DB and/or DB load is +>>similarly modest, you are not going to be happy with the +>>performance of your DBMS. +> +>Well that is a pretty blanket statement. I have many customers who +>happily run in less hardware that what is mentioned above. +>It all depends on the application itself and how the database is utilized. + +If your customers "run happily" on 2 HD's, then IME they have very +modest DB storage and/or DB performance needs. For safety reasons, +the best thing to do if you only have 2 HD's is to run them as a RAID +1 with everything on them. The slightly better performing but +considerably less safe alternative is to put the OS + logs on 1 HD +and the DB on the other. Any resemblance to a semi-serious OLTP load +will reduce either such system to an HD IO bound one with poor IO rates. + +If, as above, your DBMS is bounded by the performance of one HD, then +you are AT BEST getting the raw IO rate of such a device: say +~70-80MB/s in average sustained raw sequential IO. Files system +overhead and any seeking behavior will rapidly reduce that number to +considerably less. Consider that the CPU <-> memory IO subsystem is +easily capable of ~3.2GBps. So you are talking about slowing the DB +server to at most ~1/40, maybe even as little as ~1/200, its +potential under such circumstances. + +If your DB can fit completely in RAM and/or does light duty write IO, +this may not be a serious issue. OTOH, once you start using those +HD's to any reasonable extent, most of the rest of the investment +you've made in server HW is wasted. + +As I keep saying, the highest priority in purchasing a DBMS is to +make sure you have enough HD IO bandwidth. RAM comes second, and CPU +is a distant third. + + +>>At a minimum, for safety reasons you want 4 HDs: 2 for a RAID 1 set +>>for the DB, and 2 for a RAID 1 set for the OS + pg_xlog. +>>2 extra HDs, even SCSI HDs, is cheap. Especially when compared to +>>the cost of corrupted or lost data. +> +>Your real test is going to be prototyping the performance you need. +>A single RAID 1 mirror (don't use RAID 0) may be more +>than enough. However based on the fact that you speced Xeons my +>guess is you spent money on CPUs when you should have +>spent money on hard drives. + +I agree with Josh on both points. Don't use RAID 0 for persistent +data unless you like losing data. Spend more on HDs and RAM and less +on CPU's (fast FSB is far more important than high clock rate. In +general buy the highest FSB with the slowest clock rate.). If fact, +if you are that strapped for cash, exchange those 2 SCSI HD's for +their $ equivalent in SATA HD's. The extra spindles will be well worth it. + + +>If you still have the budget, I would suggest considering either +>what Ron suggested or possibly using a 4 drive RAID 10 instead. + +IME, with only 4 HDs, it's usually better to split them them into two +RAID 1's (one for the db, one for everything else including the logs) +than it is to put everything on one RAID 10. YMMV. + + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 15:30:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B203FD7F46 + for ; + Tue, 30 Aug 2005 15:30:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31395-07 + for ; + Tue, 30 Aug 2005 18:30:15 +0000 (GMT) +Received: from iglassmail.istructure.com (istructure.com [24.199.154.122]) + by svr1.postgresql.org (Postfix) with ESMTP id 5724DD808F + for ; + Tue, 30 Aug 2005 15:30:12 -0300 (ADT) +Received: from iglassnoc3 ([192.168.177.128]) by iglassmail.istructure.com + with Microsoft SMTPSVC(6.0.3790.211); + Tue, 30 Aug 2005 14:30:12 -0400 +From: "Woody Woodring" +To: =?iso-8859-1?Q?'R=E9my_Beaumont'?= , + +Subject: Re: High load and iowait but no disk access +Date: Tue, 30 Aug 2005 14:30:07 -0400 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_022F_01C5AD6F.51C5CDA0" +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +thread-index: AcWtfP6puY7NIfQiSwWnwk9yBgadUQAD8ONw +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +In-Reply-To: +Message-ID: +X-OriginalArrivalTime: 30 Aug 2005 18:30:12.0574 (UTC) + FILETIME=[DBE067E0:01C5AD90] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.148 required=5 tests=[AWL=-0.148, HTML_10_20=0.295, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/533 +X-Sequence-Number: 14280 + +This is a multi-part message in MIME format. + +------=_NextPart_000_022F_01C5AD6F.51C5CDA0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Have you tried a different kernel? We run with a netapp over NFS = +without +any issues, but we have seen high IO-wait on other Dell boxes (running = +and +not running postgres) and RHES 3. We have replaced a Dell PowerEdge 350 +running RH 7.3 with a PE750 with more memory running RHES3 and it be = +bogged +down with IO waits due to syslog messages writing to the disk, the old +slower server could handle it fine. I don't know if it is a Dell thing = +or a +RH kernel, but we try different kernels on our boxes to try to find one = +that +works better. We have not found one that stands out over another +consistently but we have been moving away from Update 2 kernel +(2.4.21-15.ELsmp) due to server lockup issues. Unfortunately we get the +best disk throughput on our few remaining 7.3 boxes. +=20 +Woody +=20 +IGLASS Networks +www.iglass.net + + _____ =20 + +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of R=E9my = +Beaumont +Sent: Monday, August 29, 2005 9:43 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] High load and iowait but no disk access + + +We have been trying to pinpoint what originally seem to be a I/O = +bottleneck +but which now seems to be an issue with either Postgresql or RHES 3. + +We have the following test environment on which we can reproduce the +problem: + +1) Test System A +Dell 6650 Quad Xeon Pentium 4 +8 Gig of RAM +OS: RHES 3 update 2 +Storage: NetApp FAS270 connected using an FC card using 10 disks + +2) Test System B +Dell Dual Xeon Pentium III +2 Gig o RAM +OS: RHES 3 update 2 +Storage: NetApp FAS920 connected using an FC card using 28 disks + +Our Database size is around 30G.=20 + +The behavior we see is that when running queries that do random reads on +disk, IOWAIT goes over 80% and actual disk IO falls to a crawl at a +throughput bellow 3000kB/s (We usually average 40000 kB/s to 80000 kB/s = +on +sequential read operations on the netapps) + +The stats of the NetApp do confirm that it is sitting idle. Doing an = +strace +on the Postgresql process shows that is it doing seeks and reads. + +So my question is where is this iowait time spent ? +Is there a way to pinpoint the problem in more details ? +We are able to reproduce this behavior with Postgresql 7.4.8 and 8.0.3 + +I have included the output of top,vmstat,strace and systat from the = +Netapp +from System B while running a single query that generates this behavior. + +R=E9my + +top output: +06:27:28 up 5 days, 16:59, 6 users, load average: 1.04, 1.30, 1.01 +72 processes: 71 sleeping, 1 running, 0 zombie, 0 stopped +CPU states: cpu user nice system irq softirq iowait idle +total 2.7% 0.0% 1.0% 0.1% 0.2% 46.0% 49.5% +cpu00 0.2% 0.0% 0.2% 0.0% 0.2% 2.2% 97.2% +cpu01 5.3% 0.0% 1.9% 0.3% 0.3% 89.8% 1.9% +Mem: 2061696k av, 2043936k used, 17760k free, 0k shrd, 3916k buff +1566332k actv, 296648k in_d, 30504k in_c +Swap: 16771584k av, 21552k used, 16750032k free 1933772k cached + +PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND +30960 postgres 15 0 13424 10M 9908 D 2.7 0.5 2:00 1 postmaster +30538 root 15 0 1080 764 524 S 0.7 0.0 0:43 0 sshd +1 root 15 0 496 456 436 S 0.0 0.0 0:08 0 init +2 root RT 0 0 0 0 SW 0.0 0.0 0:00 0 migration/0 +3 root RT 0 0 0 0 SW 0.0 0.0 0:00 1 migration/1 +4 root 15 0 0 0 0 SW 0.0 0.0 0:01 0 keventd +5 root 34 19 0 0 0 SWN 0.0 0.0 0:00 0 ksoftirqd/0 +6 root 34 19 0 0 0 SWN 0.0 0.0 0:00 1 ksoftirqd/1 +9 root 15 0 0 0 0 SW 0.0 0.0 0:24 1 bdflush +7 root 15 0 0 0 0 SW 0.0 0.0 6:53 1 kswapd +8 root 15 0 0 0 0 SW 0.0 0.0 8:44 1 kscand +10 root 15 0 0 0 0 SW 0.0 0.0 0:13 0 kupdated +11 root 25 0 0 0 0 SW 0.0 0.0 0:00 0 mdrecoveryd +17 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 ahc_dv_0 + + +vmstat output=20 +procs memory swap io system cpu +r b swpd free buff cache si so bi bo in cs us sy id wa +0 1 21552 17796 4872 1931928 2 3 3 1 27 6 2 1 7 3 +0 1 21552 18044 4880 1931652 0 0 1652 0 397 512 1 2 50 47 +0 1 21552 17976 4896 1931664 0 0 2468 0 407 552 2 2 50 47 +1 0 21552 17984 4896 1931608 0 0 2124 0 418 538 3 3 48 46 +0 1 21552 18028 4900 1931536 0 0 1592 0 385 509 1 3 50 46 +0 1 21552 18040 4916 1931488 0 0 1620 820 419 581 2 2 50 46 +0 1 21552 17968 4916 1931536 0 4 1708 4 402 554 3 1 50 46 +1 1 21552 18052 4916 1931388 0 0 1772 0 409 531 3 1 49 47 +0 1 21552 17912 4924 1931492 0 0 1772 0 408 565 3 1 48 48 +0 1 21552 17932 4932 1931440 0 4 1356 4 391 545 5 0 49 46 +0 1 21552 18320 4944 1931016 0 4 1500 840 414 571 1 1 48 50 +0 1 21552 17872 4944 1931440 0 0 2116 0 392 496 1 5 46 48 +0 1 21552 18060 4944 1931232 0 0 2232 0 423 597 1 2 48 49 +1 1 21552 17684 4944 1931584 0 0 1752 0 395 537 1 1 50 48 +0 1 21552 18000 4944 1931240 0 0 1576 0 401 549 0 1 50 49 + + +NetApp stats: +CPU NFS CIFS HTTP Total Net kB/s Disk kB/s Tape kB/s Cache Cache CP CP = +Disk +DAFS FCP iSCSI FCP kB/s +in out read write read write age hit time ty util in out +2% 0 0 0 139 0 0 2788 0 0 0 3 96% 0% - 15% 0 139 0 3 2277 +2% 0 0 0 144 0 0 2504 0 0 0 3 96% 0% - 18% 0 144 0 3 2150 +2% 0 0 0 130 0 0 2212 0 0 0 3 96% 0% - 13% 0 130 0 3 1879 +3% 0 0 0 169 0 0 2937 80 0 0 3 96% 0% - 13% 0 169 0 4 2718 +2% 0 0 0 139 0 0 2448 0 0 0 3 96% 0% - 12% 0 139 0 3 2096 +2% 0 0 0 137 0 0 2116 0 0 0 3 96% 0% - 10% 0 137 0 3 1892 +3% 0 0 0 107 0 0 2660 812 0 0 3 96% 24% T 20% 0 107 0 3 1739 +2% 0 0 0 118 0 0 1788 0 0 0 3 96% 0% - 13% 0 118 0 3 1608 +2% 0 0 0 136 0 0 2228 0 0 0 3 96% 0% - 11% 0 136 0 3 2018 +2% 0 0 0 119 0 0 1940 0 0 0 3 96% 0% - 13% 0 119 0 3 1998 +2% 0 0 0 136 0 0 2175 0 0 0 3 96% 0% - 14% 0 136 0 3 1929 +2% 0 0 0 133 0 0 1924 0 0 0 3 96% 0% - 19% 0 133 0 3 2292 +2% 0 0 0 115 0 0 2044 0 0 0 3 96% 0% - 11% 0 115 0 3 1682 +2% 0 0 0 134 0 0 2256 0 0 0 3 96% 0% - 12% 0 134 0 3 2096 +2% 0 0 0 112 0 0 2184 0 0 0 3 96% 0% - 12% 0 112 0 3 1633 +2% 0 0 0 163 0 0 2348 0 0 0 3 96% 0% - 13% 0 163 0 4 2421 +2% 0 0 0 120 0 0 2056 184 0 0 3 96% 8% T 14% 0 120 0 3 1703 + +strace output: +read(55, "\4\0\0\0\10fm}\1\0\0\0p\0\264\0\0 \2 \230\236\320\0020"..., = +8192) +=3D 8192 +_llseek(55, 857997312, [857997312], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\\\315\321|\1\0\0\0p\0\354\0\0 \2 \250\236\260"..., = +8192) +=3D 8192 +_llseek(55, 883220480, [883220480], SEEK_SET) =3D 0 +read(55, "\4\0\0\0T\17a~\1\0\0\0p\0\20\1\0 \2 \270\236\220\2D\235"..., = +8192) +=3D 8192 +_llseek(55, 858005504, [858005504], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\300\356\321|\1\0\0\0p\0\330\0\0 \2 \260\236\240"..., +8192) =3D 8192 +_llseek(55, 857964544, [857964544], SEEK_SET) =3D 0 +read(55, "\4\0\0\0lH\321|\1\0\0\0p\0<\1\0 \2 \300\236\200\2p\235"..., = +8192) +=3D 8192 +_llseek(55, 857956352, [857956352], SEEK_SET) =3D 0 +read(55, "\4\0\0\0l\'\321|\1\0\0\0p\0\320\0\0 \2 \260\236\240\2\\"..., = +8192) +=3D 8192 +_llseek(55, 910802944, [910802944], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\10}\25\200\1\0\0\0l\0\274\1\0 \2 \250\236\260"..., = +8192) +=3D 8192 +_llseek(55, 857948160, [857948160], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\370\5\321|\1\0\0\0p\0\350\0\0 \2 \230\236\320"..., = +8192) +=3D 8192 +_llseek(56, 80371712, [80371712], SEEK_SET) =3D 0 +read(56, "\4\0\0\0Lf \217\1\0\0\0p\0\f\1\0 \2 \250\236\260\2T\235"..., = +8192) +=3D 8192 +read(102, "\2\0\34\0001\236\0\0\1\0\0\0\t\0\0\00020670\0\0\0B\6\0"..., = +8192) +=3D 8192 +_llseek(55, 857939968, [857939968], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\244\344\320|\1\0\0\0l\0\230\1\0 \2 \244\236\270"..., +8192) =3D 8192 +_llseek(55, 857923584, [857923584], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\224\242\320|\1\0\0\0p\0|\0\0 \2 \234\236\310\002"..., +8192) =3D 8192 +_llseek(55, 57270272, [57270272], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\3204FK\1\0\0\0t\0\340\0\0 \2 \310\236j\2\214\235"..., +8192) =3D 8192 +_llseek(55, 870727680, [870727680], SEEK_SET) =3D 0 +read(55, "\4\0\0\0x>\233}\1\0\0\0p\0@\1\0 \2 \250\236\260\2X\235"..., = +8192) +=3D 8192 +_llseek(55, 1014734848, [1014734848], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\34\354\201\206\1\0\0\0p\0p\0\0 \2 \264\236\230"..., = +8192) +=3D 8192 +_llseek(55, 857874432, [857874432], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\214\331\317|\1\0\0\0l\0\324\1\0 \2 \224\236\330"..., +8192) =3D 8192 +_llseek(55, 760872960, [760872960], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\30\257\321v\1\0\0\0p\0\230\0\0 \2 \234\236\310"..., = +8192) +=3D 8192 +_llseek(55, 891715584, [891715584], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\370\220\347~\1\0\0\0p\0P\1\0 \2 \230\236\320\2"..., = +8192) +=3D 8192 +_llseek(55, 857858048, [857858048], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\250\227\317|\1\0\0\0p\0\264\0\0 \2 \254\236\250"..., +8192) =3D 8192 +_llseek(55, 666910720, [666910720], SEEK_SET) =3D 0 +read(55, "\4\0\0\0x\206\3q\1\0\0\0p\0004\1\0 \2 \254\236\242\2P\235"..., +8192) =3D 8192 +_llseek(55, 857841664, [857841664], SEEK_SET) =3D 0 +read(55, "\4\0\0\0dT\317|\1\0\0\0p\0\224\0\0 \2 \214\236\350\2\30"..., = +8192) +=3D 8192 + + + + +------=_NextPart_000_022F_01C5AD6F.51C5CDA0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +
Have you tried a different kernel?  We run = +with a=20 +netapp over NFS without any issues, but we have seen high IO-wait on = +other Dell=20 +boxes (running  and not running postgres) and RHES 3.  We have = + +replaced a Dell PowerEdge 350 running RH 7.3  with a PE750 with = +more memory=20 +running RHES3 and it be bogged down with IO waits due to syslog messages = +writing=20 +to the disk, the old slower server could handle it fine.  I don't = +know if=20 +it is a Dell thing or a RH kernel, but we try different kernels on our = +boxes to=20 +try to find one that works better.  We have not found one that = +stands out=20 +over another consistently but we have been moving away from Update = +2 kernel=20 +(2.4.21-15.ELsmp) due to server lockup issues.  Unfortunately we = +get the=20 +best disk throughput on our few remaining 7.3 boxes.
+
 
+
Woody
+
 
+
IGLASS Networks
+

= + +
+
+From: = +pgsql-performance-owner@postgresql.org=20 +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of = +R=E9my=20 +Beaumont
Sent: Monday, August 29, 2005 9:43 AM
To:=20 +pgsql-performance@postgresql.org
Subject: [PERFORM] High load = +and=20 +iowait but no disk access

+
We have been trying to pinpoint what originally seem to be a = +I/O=20 +bottleneck but which now seems to be an issue with either Postgresql or = +RHES=20 +3.

We have the following test environment on which we can = +reproduce the=20 +problem:

1) Test System A
Dell 6650 Quad Xeon Pentium 4
8 = +Gig of=20 +RAM
OS: RHES 3 update 2
Storage: NetApp FAS270 connected using an = +FC card=20 +using 10 disks

2) Test System B
Dell Dual Xeon Pentium = +III
2 Gig o=20 +RAM
OS: RHES 3 update 2
Storage: NetApp FAS920 connected using an = +FC card=20 +using 28 disks

Our Database size is around 30G.

The = +behavior we=20 +see is that when running queries that do random reads on disk, IOWAIT = +goes over=20 +80% and actual disk IO falls to a crawl at a throughput bellow 3000kB/s = +(We=20 +usually average 40000 kB/s to 80000 kB/s on sequential read operations = +on the=20 +netapps)

The stats of the NetApp do confirm that it is sitting = +idle.=20 +Doing an strace on the Postgresql process shows that is it doing seeks = +and=20 +reads.

So my question is where is this iowait time spent ?
Is = +there a=20 +way to pinpoint the problem in more details ?
We are able to = +reproduce this=20 +behavior with Postgresql 7.4.8 and 8.0.3

I have included the = +output of=20 +top,vmstat,strace and systat from the Netapp from System B while running = +a=20 +single query that generates this behavior.

R=E9my

top=20 +output:
06:27:28 up 5 days, 16:59, 6 users, load average: 1.04, 1.30, = + +1.01
72 processes: 71 sleeping, 1 running, 0 zombie, 0 stopped
CPU = +states:=20 +cpu user nice system irq softirq iowait idle
total 2.7% 0.0% 1.0% = +0.1% 0.2%=20 +46.0% 49.5%
cpu00 0.2% 0.0% 0.2% 0.0% 0.2% 2.2% 97.2%
cpu01 5.3% = +0.0% 1.9%=20 +0.3% 0.3% 89.8% 1.9%
Mem: 2061696k av, 2043936k used, 17760k free, 0k = +shrd,=20 +3916k buff
1566332k actv, 296648k in_d, 30504k in_c
Swap: = +16771584k av,=20 +21552k used, 16750032k free 1933772k cached

PID USER PRI NI SIZE = +RSS=20 +SHARE STAT %CPU %MEM TIME CPU COMMAND
30960 postgres 15 0 13424 10M = +9908 D=20 +2.7 0.5 2:00 1 postmaster
30538 root 15 0 1080 764 524 S 0.7 0.0 0:43 = +0=20 +sshd
1 root 15 0 496 456 436 S 0.0 0.0 0:08 0 init
2 root RT 0 0 0 = +0 SW=20 +0.0 0.0 0:00 0 migration/0
3 root RT 0 0 0 0 SW 0.0 0.0 0:00 1=20 +migration/1
4 root 15 0 0 0 0 SW 0.0 0.0 0:01 0 keventd
5 root 34 = +19 0 0 0=20 +SWN 0.0 0.0 0:00 0 ksoftirqd/0
6 root 34 19 0 0 0 SWN 0.0 0.0 0:00 1=20 +ksoftirqd/1
9 root 15 0 0 0 0 SW 0.0 0.0 0:24 1 bdflush
7 root 15 = +0 0 0 0=20 +SW 0.0 0.0 6:53 1 kswapd
8 root 15 0 0 0 0 SW 0.0 0.0 8:44 1 = +kscand
10=20 +root 15 0 0 0 0 SW 0.0 0.0 0:13 0 kupdated
11 root 25 0 0 0 0 SW 0.0 = +0.0 0:00=20 +0 mdrecoveryd
17 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 = +ahc_dv_0


vmstat=20 +output
procs memory swap io system cpu
r b swpd free buff cache = +si so bi=20 +bo in cs us sy id wa
0 1 21552 17796 4872 1931928 2 3 3 1 27 6 2 1 7 = +3
0 1=20 +21552 18044 4880 1931652 0 0 1652 0 397 512 1 2 50 47
0 1 21552 17976 = +4896=20 +1931664 0 0 2468 0 407 552 2 2 50 47
1 0 21552 17984 4896 1931608 0 0 = +2124 0=20 +418 538 3 3 48 46
0 1 21552 18028 4900 1931536 0 0 1592 0 385 509 1 3 = +50=20 +46
0 1 21552 18040 4916 1931488 0 0 1620 820 419 581 2 2 50 46
0 1 = +21552=20 +17968 4916 1931536 0 4 1708 4 402 554 3 1 50 46
1 1 21552 18052 4916 = +1931388=20 +0 0 1772 0 409 531 3 1 49 47
0 1 21552 17912 4924 1931492 0 0 1772 0 = +408 565=20 +3 1 48 48
0 1 21552 17932 4932 1931440 0 4 1356 4 391 545 5 0 49 = +46
0 1=20 +21552 18320 4944 1931016 0 4 1500 840 414 571 1 1 48 50
0 1 21552 = +17872 4944=20 +1931440 0 0 2116 0 392 496 1 5 46 48
0 1 21552 18060 4944 1931232 0 0 = +2232 0=20 +423 597 1 2 48 49
1 1 21552 17684 4944 1931584 0 0 1752 0 395 537 1 1 = +50=20 +48
0 1 21552 18000 4944 1931240 0 0 1576 0 401 549 0 1 50=20 +49


NetApp stats:
CPU NFS CIFS HTTP Total Net kB/s Disk = +kB/s Tape=20 +kB/s Cache Cache CP CP Disk DAFS FCP iSCSI FCP kB/s
in out read write = +read=20 +write age hit time ty util in out
2% 0 0 0 139 0 0 2788 0 0 0 3 96% = +0% - 15%=20 +0 139 0 3 2277
2% 0 0 0 144 0 0 2504 0 0 0 3 96% 0% - 18% 0 144 0 3=20 +2150
2% 0 0 0 130 0 0 2212 0 0 0 3 96% 0% - 13% 0 130 0 3 1879
3% = +0 0 0=20 +169 0 0 2937 80 0 0 3 96% 0% - 13% 0 169 0 4 2718
2% 0 0 0 139 0 0 = +2448 0 0 0=20 +3 96% 0% - 12% 0 139 0 3 2096
2% 0 0 0 137 0 0 2116 0 0 0 3 96% 0% - = +10% 0=20 +137 0 3 1892
3% 0 0 0 107 0 0 2660 812 0 0 3 96% 24% T 20% 0 107 0 3=20 +1739
2% 0 0 0 118 0 0 1788 0 0 0 3 96% 0% - 13% 0 118 0 3 1608
2% = +0 0 0=20 +136 0 0 2228 0 0 0 3 96% 0% - 11% 0 136 0 3 2018
2% 0 0 0 119 0 0 = +1940 0 0 0=20 +3 96% 0% - 13% 0 119 0 3 1998
2% 0 0 0 136 0 0 2175 0 0 0 3 96% 0% - = +14% 0=20 +136 0 3 1929
2% 0 0 0 133 0 0 1924 0 0 0 3 96% 0% - 19% 0 133 0 3 = +2292
2%=20 +0 0 0 115 0 0 2044 0 0 0 3 96% 0% - 11% 0 115 0 3 1682
2% 0 0 0 134 0 = +0 2256=20 +0 0 0 3 96% 0% - 12% 0 134 0 3 2096
2% 0 0 0 112 0 0 2184 0 0 0 3 96% = +0% -=20 +12% 0 112 0 3 1633
2% 0 0 0 163 0 0 2348 0 0 0 3 96% 0% - 13% 0 163 0 = +4=20 +2421
2% 0 0 0 120 0 0 2056 184 0 0 3 96% 8% T 14% 0 120 0 3=20 +1703

strace output:
read(55, = +"\4\0\0\0\10fm}\1\0\0\0p\0\264\0\0 \2=20 +\230\236\320\0020"..., 8192) =3D 8192
_llseek(55, 857997312, = +[857997312],=20 +SEEK_SET) =3D 0
read(55, "\4\0\0\0\\\315\321|\1\0\0\0p\0\354\0\0 \2=20 +\250\236\260"..., 8192) =3D 8192
_llseek(55, 883220480, [883220480], = +SEEK_SET)=20 +=3D 0
read(55, "\4\0\0\0T\17a~\1\0\0\0p\0\20\1\0 \2 = +\270\236\220\2D\235"...,=20 +8192) =3D 8192
_llseek(55, 858005504, [858005504], SEEK_SET) =3D = +0
read(55,=20 +"\4\0\0\0\300\356\321|\1\0\0\0p\0\330\0\0 \2 \260\236\240"..., 8192) =3D = + +8192
_llseek(55, 857964544, [857964544], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0lH\321|\1\0\0\0p\0<\1\0 \2 \300\236\200\2p\235"..., 8192) = +=3D=20 +8192
_llseek(55, 857956352, [857956352], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0l\'\321|\1\0\0\0p\0\320\0\0 \2 \260\236\240\2\\"..., 8192) =3D=20 +8192
_llseek(55, 910802944, [910802944], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0\10}\25\200\1\0\0\0l\0\274\1\0 \2 \250\236\260"..., 8192) =3D=20 +8192
_llseek(55, 857948160, [857948160], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0\370\5\321|\1\0\0\0p\0\350\0\0 \2 \230\236\320"..., 8192) =3D=20 +8192
_llseek(56, 80371712, [80371712], SEEK_SET) =3D 0
read(56, = +"\4\0\0\0Lf=20 +\217\1\0\0\0p\0\f\1\0 \2 \250\236\260\2T\235"..., 8192) =3D = +8192
read(102,=20 +"\2\0\34\0001\236\0\0\1\0\0\0\t\0\0\00020670\0\0\0B\6\0"..., 8192) =3D=20 +8192
_llseek(55, 857939968, [857939968], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0\244\344\320|\1\0\0\0l\0\230\1\0 \2 \244\236\270"..., 8192) =3D = + +8192
_llseek(55, 857923584, [857923584], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0\224\242\320|\1\0\0\0p\0|\0\0 \2 \234\236\310\002"..., 8192) = +=3D=20 +8192
_llseek(55, 57270272, [57270272], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0\3204FK\1\0\0\0t\0\340\0\0 \2 \310\236j\2\214\235"..., 8192) = +=3D=20 +8192
_llseek(55, 870727680, [870727680], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0x>\233}\1\0\0\0p\0@\1\0 \2 \250\236\260\2X\235"..., 8192) = +=3D=20 +8192
_llseek(55, 1014734848, [1014734848], SEEK_SET) =3D = +0
read(55,=20 +"\4\0\0\0\34\354\201\206\1\0\0\0p\0p\0\0 \2 \264\236\230"..., 8192) =3D=20 +8192
_llseek(55, 857874432, [857874432], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0\214\331\317|\1\0\0\0l\0\324\1\0 \2 \224\236\330"..., 8192) =3D = + +8192
_llseek(55, 760872960, [760872960], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0\30\257\321v\1\0\0\0p\0\230\0\0 \2 \234\236\310"..., 8192) =3D=20 +8192
_llseek(55, 891715584, [891715584], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0\370\220\347~\1\0\0\0p\0P\1\0 \2 \230\236\320\2"..., 8192) =3D=20 +8192
_llseek(55, 857858048, [857858048], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0\250\227\317|\1\0\0\0p\0\264\0\0 \2 \254\236\250"..., 8192) =3D = + +8192
_llseek(55, 666910720, [666910720], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0x\206\3q\1\0\0\0p\0004\1\0 \2 \254\236\242\2P\235"..., 8192) = +=3D=20 +8192
_llseek(55, 857841664, [857841664], SEEK_SET) =3D 0
read(55,=20 +"\4\0\0\0dT\317|\1\0\0\0p\0\224\0\0 \2 \214\236\350\2\30"..., 8192) =3D=20 +8192


+ +------=_NextPart_000_022F_01C5AD6F.51C5CDA0-- + + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 15:29:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EEB71D8633 + for ; + Tue, 30 Aug 2005 15:28:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29130-06 + for ; + Tue, 30 Aug 2005 18:28:44 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id DC68FD85A0 + for ; + Tue, 30 Aug 2005 15:28:43 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7995263; Tue, 30 Aug 2005 11:31:01 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: High load and iowait but no disk access +Date: Tue, 30 Aug 2005 11:32:06 -0700 +User-Agent: KMail/1.8 +Cc: =?utf-8?q?R=C3=A9my_Beaumont?= +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508301132.06904.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 required=5 tests=[AWL=-0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/532 +X-Sequence-Number: 14279 + +Remy, + +> The behavior we see is that when running queries that do random reads +> on disk, IOWAIT goes over 80% and actual disk IO falls to a crawl at a +> throughput bellow 3000kB/s (We usually average 40000 kB/s to 80000 kB/s +> on sequential read operations on the netapps) + +This seems pretty low for a NetApp -- you should be able to manage up to +180mb/s, if not higher. Are you sure it's configured correctly? + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 30 15:49:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E688BD7BC4 + for ; + Tue, 30 Aug 2005 15:37:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32771-07 + for ; + Tue, 30 Aug 2005 18:37:32 +0000 (GMT) +Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 944A5D7B71 + for ; + Tue, 30 Aug 2005 15:37:30 -0300 (ADT) +Received: (from smtp@localhost) by ll.mit.edu (8.12.10/8.8.8) id + j7UIbTtY003609 + for ; + Tue, 30 Aug 2005 14:37:29 -0400 (EDT) +Received: from UNKNOWN( ), claiming to be "sty.llan" + via SMTP by llmail, id smtpdAAAddaahb; Tue Aug 30 14:36:19 2005 +Date: Tue, 30 Aug 2005 14:36:18 -0400 +From: george young +To: pgsql-performance@postgresql.org +Subject: Re: Observation about db response time +Message-Id: <20050830143618.2c10144d.gry@ll.mit.edu> +In-Reply-To: <2527.192.168.1.175.1125158337.squirrel@mailserv> +References: <2527.192.168.1.175.1125158337.squirrel@mailserv> +Reply-To: gry@ll.mit.edu +Organization: MIT Lincoln Laboratory +X-Mailer: Sylpheed version 2.0.1 (GTK+ 2.8.0; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.019 required=5 tests=[AWL=0.019] +X-Spam-Level: +X-Archive-Number: 200508/535 +X-Sequence-Number: 14282 + + On Sat, 27 Aug 2005 21:28:57 +0530 (IST) + threw this fish to the penguins: + +> Hello Friends, +> We were having a database in pgsql7.4. The database was responding very +> slowly even after full vacuum (select +> count(*) from some_table_having_18000_records was taking 18 Sec). + +One comment here: "select count(*)" may seem like a good benchmark, but +it's not generally. If your application really depends on this number, fine. +Otherwise, you should measure performance with a real query from your +application. The "select count(*)" can be very slow because it does +not use indexes. + +> We took a backup of that db and restored it back. Now the same db on +> same PC is responding fast (same query is taking 18 ms). + +This sounds like some index is getting gooped up. If you do a lot of +deleting from tables, your indexes can collect dead space that vacuum +can not reclaim. Try in sql "reindex table my_slow_table" for a +suspect table. In the contrib directory of the postgresql +distribution there is a script called "reindexdb". You can run this +to reindex your whole database. + +I also wonder about file system slowdowns. What hardware/OS/filesystem +are you using? + + +-- George + +-- +"Are the gods not just?" "Oh no, child. +What would become of us if they were?" (CSL) + +From pgsql-performance-owner@postgresql.org Tue Aug 30 15:44:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E50BD7F83 + for ; + Tue, 30 Aug 2005 15:42:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34352-06 + for ; + Tue, 30 Aug 2005 18:42:37 +0000 (GMT) +Received: from iad2.emailsrvr.com (iad2.emailsrvr.com [207.97.227.212]) + by svr1.postgresql.org (Postfix) with ESMTP id DE32ED7F46 + for ; + Tue, 30 Aug 2005 15:42:35 -0300 (ADT) +Received: from [10.10.20.22] (unknown [216.94.157.147]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + (Authenticated sender: remyb@medrium.com) + by relay3.r3.iad.emailsrvr.com (SMTP Server) with ESMTP id 11F7544C5E8; + Tue, 30 Aug 2005 14:42:36 -0400 (EDT) +In-Reply-To: <200508301132.06904.josh@agliodbs.com> +References: + <200508301132.06904.josh@agliodbs.com> +Mime-Version: 1.0 (Apple Message framework v622) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Message-Id: <22924e579ad7e7e0deb5133eb905618b@medrium.com> +Content-Transfer-Encoding: quoted-printable +Cc: pgsql-performance@postgresql.org +From: =?ISO-8859-1?Q?R=E9my_Beaumont?= +Subject: Re: High load and iowait but no disk access +Date: Tue, 30 Aug 2005 14:42:38 -0400 +To: josh@agliodbs.com +X-Mailer: Apple Mail (2.622) +X-Virus-Scanned: OK +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/534 +X-Sequence-Number: 14281 + + +On 30-Aug-05, at 14:32, Josh Berkus wrote: + +> Remy, +> +>> The behavior we see is that when running queries that do random reads +>> on disk, IOWAIT goes over 80% and actual disk IO falls to a crawl at = +a +>> throughput bellow 3000kB/s (We usually average 40000 kB/s to 80000=20 +>> kB/s +>> on sequential read operations on the netapps) +> +> This seems pretty low for a NetApp -- you should be able to manage up=20= + +> to +> 180mb/s, if not higher. Are you sure it's configured correctly? +Hi Josh, + +The config has been reviewed by NetApp. We do get rates higher then=20 +80mb/s, but on average, that's what we get. + +Do you have NetApp filers deployed ? +How many spindles do you have in your volume ? +On which OS are you running Postgres ? + +Thanks, + +R=E9my + +> +> --=20 +> --Josh +> +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 15:58:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AE028D76E9 + for ; + Tue, 30 Aug 2005 15:46:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35668-02 + for ; + Tue, 30 Aug 2005 18:46:14 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.244]) + by svr1.postgresql.org (Postfix) with ESMTP id E1970D6F02 + for ; + Tue, 30 Aug 2005 15:46:11 -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_01C5AD93.16A8668F" +Subject: Re: High load and iowait but no disk access +Date: Tue, 30 Aug 2005 14:46:10 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098C1C@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] High load and iowait but no disk access +Thread-Index: AcWtfP6puY7NIfQiSwWnwk9yBgadUQAD8ONwAAFHUkA= +From: "Anjan Dave" +To: "Woody Woodring" , + =?iso-8859-1?Q?R=E9my_Beaumont?= , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.059 required=5 tests=[AWL=0.002, HTML_30_40=0.056, + HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/538 +X-Sequence-Number: 14285 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C5AD93.16A8668F +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +I have seen references of changing the kernel io scheduler at boot = +time...not sure if it applies to RHEL3.0, or will help, but try setting = +'elevator=3Ddeadline' during boot time or via grub.conf. Have you tried = +running a simple 'dd' on the LUN? The drives are in RAID10 = +configuration, right? + +=20 + +Thanks, + +Anjan + + _____ =20 + +From: Woody Woodring [mailto:george.woodring@iglass.net]=20 +Sent: Tuesday, August 30, 2005 2:30 PM +To: 'R=E9my Beaumont'; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] High load and iowait but no disk access + +=20 + +Have you tried a different kernel? We run with a netapp over NFS = +without any issues, but we have seen high IO-wait on other Dell boxes = +(running and not running postgres) and RHES 3. We have replaced a Dell = +PowerEdge 350 running RH 7.3 with a PE750 with more memory running = +RHES3 and it be bogged down with IO waits due to syslog messages writing = +to the disk, the old slower server could handle it fine. I don't know = +if it is a Dell thing or a RH kernel, but we try different kernels on = +our boxes to try to find one that works better. We have not found one = +that stands out over another consistently but we have been moving away = +from Update 2 kernel (2.4.21-15.ELsmp) due to server lockup issues. = +Unfortunately we get the best disk throughput on our few remaining 7.3 = +boxes. + +=20 + +Woody + +=20 + +IGLASS Networks + +www.iglass.net + +=20 + + _____ =20 + +From: pgsql-performance-owner@postgresql.org = +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of R=E9my = +Beaumont +Sent: Monday, August 29, 2005 9:43 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] High load and iowait but no disk access + +We have been trying to pinpoint what originally seem to be a I/O = +bottleneck but which now seems to be an issue with either Postgresql or = +RHES 3. + +We have the following test environment on which we can reproduce the = +problem: + +1) Test System A +Dell 6650 Quad Xeon Pentium 4 +8 Gig of RAM +OS: RHES 3 update 2 +Storage: NetApp FAS270 connected using an FC card using 10 disks + +2) Test System B +Dell Dual Xeon Pentium III +2 Gig o RAM +OS: RHES 3 update 2 +Storage: NetApp FAS920 connected using an FC card using 28 disks + +Our Database size is around 30G.=20 + +The behavior we see is that when running queries that do random reads on = +disk, IOWAIT goes over 80% and actual disk IO falls to a crawl at a = +throughput bellow 3000kB/s (We usually average 40000 kB/s to 80000 kB/s = +on sequential read operations on the netapps) + +The stats of the NetApp do confirm that it is sitting idle. Doing an = +strace on the Postgresql process shows that is it doing seeks and reads. + +So my question is where is this iowait time spent ? +Is there a way to pinpoint the problem in more details ? +We are able to reproduce this behavior with Postgresql 7.4.8 and 8.0.3 + +I have included the output of top,vmstat,strace and systat from the = +Netapp from System B while running a single query that generates this = +behavior. + +R=E9my + +top output: +06:27:28 up 5 days, 16:59, 6 users, load average: 1.04, 1.30, 1.01 +72 processes: 71 sleeping, 1 running, 0 zombie, 0 stopped +CPU states: cpu user nice system irq softirq iowait idle +total 2.7% 0.0% 1.0% 0.1% 0.2% 46.0% 49.5% +cpu00 0.2% 0.0% 0.2% 0.0% 0.2% 2.2% 97.2% +cpu01 5.3% 0.0% 1.9% 0.3% 0.3% 89.8% 1.9% +Mem: 2061696k av, 2043936k used, 17760k free, 0k shrd, 3916k buff +1566332k actv, 296648k in_d, 30504k in_c +Swap: 16771584k av, 21552k used, 16750032k free 1933772k cached + +PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND +30960 postgres 15 0 13424 10M 9908 D 2.7 0.5 2:00 1 postmaster +30538 root 15 0 1080 764 524 S 0.7 0.0 0:43 0 sshd +1 root 15 0 496 456 436 S 0.0 0.0 0:08 0 init +2 root RT 0 0 0 0 SW 0.0 0.0 0:00 0 migration/0 +3 root RT 0 0 0 0 SW 0.0 0.0 0:00 1 migration/1 +4 root 15 0 0 0 0 SW 0.0 0.0 0:01 0 keventd +5 root 34 19 0 0 0 SWN 0.0 0.0 0:00 0 ksoftirqd/0 +6 root 34 19 0 0 0 SWN 0.0 0.0 0:00 1 ksoftirqd/1 +9 root 15 0 0 0 0 SW 0.0 0.0 0:24 1 bdflush +7 root 15 0 0 0 0 SW 0.0 0.0 6:53 1 kswapd +8 root 15 0 0 0 0 SW 0.0 0.0 8:44 1 kscand +10 root 15 0 0 0 0 SW 0.0 0.0 0:13 0 kupdated +11 root 25 0 0 0 0 SW 0.0 0.0 0:00 0 mdrecoveryd +17 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 ahc_dv_0 + + +vmstat output=20 +procs memory swap io system cpu +r b swpd free buff cache si so bi bo in cs us sy id wa +0 1 21552 17796 4872 1931928 2 3 3 1 27 6 2 1 7 3 +0 1 21552 18044 4880 1931652 0 0 1652 0 397 512 1 2 50 47 +0 1 21552 17976 4896 1931664 0 0 2468 0 407 552 2 2 50 47 +1 0 21552 17984 4896 1931608 0 0 2124 0 418 538 3 3 48 46 +0 1 21552 18028 4900 1931536 0 0 1592 0 385 509 1 3 50 46 +0 1 21552 18040 4916 1931488 0 0 1620 820 419 581 2 2 50 46 +0 1 21552 17968 4916 1931536 0 4 1708 4 402 554 3 1 50 46 +1 1 21552 18052 4916 1931388 0 0 1772 0 409 531 3 1 49 47 +0 1 21552 17912 4924 1931492 0 0 1772 0 408 565 3 1 48 48 +0 1 21552 17932 4932 1931440 0 4 1356 4 391 545 5 0 49 46 +0 1 21552 18320 4944 1931016 0 4 1500 840 414 571 1 1 48 50 +0 1 21552 17872 4944 1931440 0 0 2116 0 392 496 1 5 46 48 +0 1 21552 18060 4944 1931232 0 0 2232 0 423 597 1 2 48 49 +1 1 21552 17684 4944 1931584 0 0 1752 0 395 537 1 1 50 48 +0 1 21552 18000 4944 1931240 0 0 1576 0 401 549 0 1 50 49 + + +NetApp stats: +CPU NFS CIFS HTTP Total Net kB/s Disk kB/s Tape kB/s Cache Cache CP CP = +Disk DAFS FCP iSCSI FCP kB/s +in out read write read write age hit time ty util in out +2% 0 0 0 139 0 0 2788 0 0 0 3 96% 0% - 15% 0 139 0 3 2277 +2% 0 0 0 144 0 0 2504 0 0 0 3 96% 0% - 18% 0 144 0 3 2150 +2% 0 0 0 130 0 0 2212 0 0 0 3 96% 0% - 13% 0 130 0 3 1879 +3% 0 0 0 169 0 0 2937 80 0 0 3 96% 0% - 13% 0 169 0 4 2718 +2% 0 0 0 139 0 0 2448 0 0 0 3 96% 0% - 12% 0 139 0 3 2096 +2% 0 0 0 137 0 0 2116 0 0 0 3 96% 0% - 10% 0 137 0 3 1892 +3% 0 0 0 107 0 0 2660 812 0 0 3 96% 24% T 20% 0 107 0 3 1739 +2% 0 0 0 118 0 0 1788 0 0 0 3 96% 0% - 13% 0 118 0 3 1608 +2% 0 0 0 136 0 0 2228 0 0 0 3 96% 0% - 11% 0 136 0 3 2018 +2% 0 0 0 119 0 0 1940 0 0 0 3 96% 0% - 13% 0 119 0 3 1998 +2% 0 0 0 136 0 0 2175 0 0 0 3 96% 0% - 14% 0 136 0 3 1929 +2% 0 0 0 133 0 0 1924 0 0 0 3 96% 0% - 19% 0 133 0 3 2292 +2% 0 0 0 115 0 0 2044 0 0 0 3 96% 0% - 11% 0 115 0 3 1682 +2% 0 0 0 134 0 0 2256 0 0 0 3 96% 0% - 12% 0 134 0 3 2096 +2% 0 0 0 112 0 0 2184 0 0 0 3 96% 0% - 12% 0 112 0 3 1633 +2% 0 0 0 163 0 0 2348 0 0 0 3 96% 0% - 13% 0 163 0 4 2421 +2% 0 0 0 120 0 0 2056 184 0 0 3 96% 8% T 14% 0 120 0 3 1703 + +strace output: +read(55, "\4\0\0\0\10fm}\1\0\0\0p\0\264\0\0 \2 \230\236\320\0020"..., = +8192) =3D 8192 +_llseek(55, 857997312, [857997312], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\\\315\321|\1\0\0\0p\0\354\0\0 \2 \250\236\260"..., = +8192) =3D 8192 +_llseek(55, 883220480, [883220480], SEEK_SET) =3D 0 +read(55, "\4\0\0\0T\17a~\1\0\0\0p\0\20\1\0 \2 \270\236\220\2D\235"..., = +8192) =3D 8192 +_llseek(55, 858005504, [858005504], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\300\356\321|\1\0\0\0p\0\330\0\0 \2 \260\236\240"..., = +8192) =3D 8192 +_llseek(55, 857964544, [857964544], SEEK_SET) =3D 0 +read(55, "\4\0\0\0lH\321|\1\0\0\0p\0<\1\0 \2 \300\236\200\2p\235"..., = +8192) =3D 8192 +_llseek(55, 857956352, [857956352], SEEK_SET) =3D 0 +read(55, "\4\0\0\0l\'\321|\1\0\0\0p\0\320\0\0 \2 \260\236\240\2\\"..., = +8192) =3D 8192 +_llseek(55, 910802944, [910802944], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\10}\25\200\1\0\0\0l\0\274\1\0 \2 \250\236\260"..., = +8192) =3D 8192 +_llseek(55, 857948160, [857948160], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\370\5\321|\1\0\0\0p\0\350\0\0 \2 \230\236\320"..., = +8192) =3D 8192 +_llseek(56, 80371712, [80371712], SEEK_SET) =3D 0 +read(56, "\4\0\0\0Lf \217\1\0\0\0p\0\f\1\0 \2 \250\236\260\2T\235"..., = +8192) =3D 8192 +read(102, "\2\0\34\0001\236\0\0\1\0\0\0\t\0\0\00020670\0\0\0B\6\0"..., = +8192) =3D 8192 +_llseek(55, 857939968, [857939968], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\244\344\320|\1\0\0\0l\0\230\1\0 \2 \244\236\270"..., = +8192) =3D 8192 +_llseek(55, 857923584, [857923584], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\224\242\320|\1\0\0\0p\0|\0\0 \2 \234\236\310\002"..., = +8192) =3D 8192 +_llseek(55, 57270272, [57270272], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\3204FK\1\0\0\0t\0\340\0\0 \2 \310\236j\2\214\235"..., = +8192) =3D 8192 +_llseek(55, 870727680, [870727680], SEEK_SET) =3D 0 +read(55, "\4\0\0\0x>\233}\1\0\0\0p\0@\1\0 \2 \250\236\260\2X\235"..., = +8192) =3D 8192 +_llseek(55, 1014734848, [1014734848], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\34\354\201\206\1\0\0\0p\0p\0\0 \2 \264\236\230"..., = +8192) =3D 8192 +_llseek(55, 857874432, [857874432], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\214\331\317|\1\0\0\0l\0\324\1\0 \2 \224\236\330"..., = +8192) =3D 8192 +_llseek(55, 760872960, [760872960], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\30\257\321v\1\0\0\0p\0\230\0\0 \2 \234\236\310"..., = +8192) =3D 8192 +_llseek(55, 891715584, [891715584], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\370\220\347~\1\0\0\0p\0P\1\0 \2 \230\236\320\2"..., = +8192) =3D 8192 +_llseek(55, 857858048, [857858048], SEEK_SET) =3D 0 +read(55, "\4\0\0\0\250\227\317|\1\0\0\0p\0\264\0\0 \2 \254\236\250"..., = +8192) =3D 8192 +_llseek(55, 666910720, [666910720], SEEK_SET) =3D 0 +read(55, "\4\0\0\0x\206\3q\1\0\0\0p\0004\1\0 \2 \254\236\242\2P\235"..., = +8192) =3D 8192 +_llseek(55, 857841664, [857841664], SEEK_SET) =3D 0 +read(55, "\4\0\0\0dT\317|\1\0\0\0p\0\224\0\0 \2 \214\236\350\2\30"..., = +8192) =3D 8192 + + + + + + +------_=_NextPart_001_01C5AD93.16A8668F +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + +
+ +

I have seen references of changing = +the +kernel io scheduler at boot time…not sure if it applies to = +RHEL3.0, or +will help, but try setting ‘elevator=3Ddeadline’ during boot = +time or +via grub.conf. Have you tried running a simple ‘dd’ on the = +LUN? The +drives are in RAID10 configuration, right?

+ +

 

+ +

Thanks,

= + + +

Anjan

+ +
+ +
+ +
+ +
+ +

From: Woody = +Woodring +[mailto:george.woodring@iglass.net]
+Sent: Tuesday, August 30, = +2005 +2:30 PM
+To: 'R=E9my Beaumont'; +pgsql-performance@postgresql.org
+Subject: Re: [PERFORM] = +High load +and iowait but no disk access

+ +
+ +

 

+ +

Have you tried a different = +kernel?  +We run with a netapp over NFS without any issues, but we have seen high = +IO-wait +on other Dell boxes (running  and not running postgres) and RHES = +3.  +We have replaced a Dell PowerEdge 350 running RH 7.3  with a PE750 = +with +more memory running RHES3 and it be bogged down with IO waits due to = +syslog +messages writing to the disk, the old slower server could handle it = +fine.  +I don't know if it is a Dell thing or a RH kernel, but we try different = +kernels +on our boxes to try to find one that works better.  We have not = +found one +that stands out over another consistently but we have been moving = +away +from Update 2 kernel (2.4.21-15.ELsmp) due to server lockup = +issues.  +Unfortunately we get the best disk throughput on our few remaining 7.3 = +boxes.

+ +

 

+ +

Woody

+ +

 

+ +

IGLASS = +Networks

+ +

www.iglass.net

+ +

 

+ +
+ +
+ +
+ +

From: +pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of R=E9my Beaumont
+Sent: Monday, August 29, = +2005 9:43 +AM
+To: +pgsql-performance@postgresql.org
+Subject: [PERFORM] High = +load and +iowait but no disk access

+ +

We have been trying to pinpoint what originally seem to be a I/O +bottleneck but which now seems to be an issue with either Postgresql or = +RHES 3.
+
+We have the following test environment on which we can reproduce the = +problem:
+
+1) Test System A
+Dell 6650 Quad Xeon Pentium 4
+8 Gig of RAM
+OS: RHES 3 update 2
+Storage: NetApp FAS270 connected using an FC card using 10 disks
+
+2) Test System B
+Dell Dual Xeon Pentium III
+2 Gig o RAM
+OS: RHES 3 update 2
+Storage: NetApp FAS920 connected using an FC card using 28 disks
+
+Our Database size is around 30G.
+
+The behavior we see is that when running queries that do random reads on = +disk, +IOWAIT goes over 80% and actual disk IO falls to a crawl at a throughput = +bellow +3000kB/s (We usually average 40000 kB/s to 80000 kB/s on sequential read +operations on the netapps)
+
+The stats of the NetApp do confirm that it is sitting idle. Doing an = +strace on +the Postgresql process shows that is it doing seeks and reads.
+
+So my question is where is this iowait time spent ?
+Is there a way to pinpoint the problem in more details ?
+We are able to reproduce this behavior with Postgresql 7.4.8 and = +8.0.3
+
+I have included the output of top,vmstat,strace and systat from the = +Netapp from +System B while running a single query that generates this behavior.
+
+R=E9my
+
+top output:
+06:27:28 up 5 days, 16:59, 6 users, load average: 1.04, 1.30, 1.01
+72 processes: 71 sleeping, 1 running, 0 zombie, 0 stopped
+CPU states: cpu user nice system irq softirq iowait idle
+total 2.7% 0.0% 1.0% 0.1% 0.2% 46.0% 49.5%
+cpu00 0.2% 0.0% 0.2% 0.0% 0.2% 2.2% 97.2%
+cpu01 5.3% 0.0% 1.9% 0.3% 0.3% 89.8% 1.9%
+Mem: 2061696k av, 2043936k used, 17760k free, 0k shrd, 3916k buff
+1566332k actv, 296648k in_d, 30504k in_c
+Swap: 16771584k av, 21552k used, 16750032k free 1933772k cached
+
+PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
+30960 postgres 15 0 13424 10M 9908 D 2.7 0.5 2:00 1 postmaster
+30538 root 15 0 1080 764 524 S 0.7 0.0 0:43 0 sshd
+1 root 15 0 496 456 436 S 0.0 0.0 0:08 0 init
+2 root RT 0 0 0 0 SW 0.0 0.0 0:00 0 migration/0
+3 root RT 0 0 0 0 SW 0.0 0.0 0:00 1 migration/1
+4 root 15 0 0 0 0 SW 0.0 0.0 0:01 0 keventd
+5 root 34 19 0 0 0 SWN 0.0 0.0 0:00 0 ksoftirqd/0
+6 root 34 19 0 0 0 SWN 0.0 0.0 0:00 1 ksoftirqd/1
+9 root 15 0 0 0 0 SW 0.0 0.0 0:24 1 bdflush
+7 root 15 0 0 0 0 SW 0.0 0.0 6:53 1 kswapd
+8 root 15 0 0 0 0 SW 0.0 0.0 8:44 1 kscand
+10 root 15 0 0 0 0 SW 0.0 0.0 0:13 0 kupdated
+11 root 25 0 0 0 0 SW 0.0 0.0 0:00 0 mdrecoveryd
+17 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 ahc_dv_0
+
+
+vmstat output
+procs memory swap io system cpu
+r b swpd free buff cache si so bi bo in cs us sy id wa
+0 1 21552 17796 4872 1931928 2 3 3 1 27 6 2 1 7 3
+0 1 21552 18044 4880 1931652 0 0 1652 0 397 512 1 2 50 47
+0 1 21552 17976 4896 1931664 0 0 2468 0 407 552 2 2 50 47
+1 0 21552 17984 4896 1931608 0 0 2124 0 418 538 3 3 48 46
+0 1 21552 18028 4900 1931536 0 0 1592 0 385 509 1 3 50 46
+0 1 21552 18040 4916 1931488 0 0 1620 820 419 581 2 2 50 46
+0 1 21552 17968 4916 1931536 0 4 1708 4 402 554 3 1 50 46
+1 1 21552 18052 4916 1931388 0 0 1772 0 409 531 3 1 49 47
+0 1 21552 17912 4924 1931492 0 0 1772 0 408 565 3 1 48 48
+0 1 21552 17932 4932 1931440 0 4 1356 4 391 545 5 0 49 46
+0 1 21552 18320 4944 1931016 0 4 1500 840 414 571 1 1 48 50
+0 1 21552 17872 4944 1931440 0 0 2116 0 392 496 1 5 46 48
+0 1 21552 18060 4944 1931232 0 0 2232 0 423 597 1 2 48 49
+1 1 21552 17684 4944 1931584 0 0 1752 0 395 537 1 1 50 48
+0 1 21552 18000 4944 1931240 0 0 1576 0 401 549 0 1 50 49
+
+
+NetApp stats:
+CPU NFS CIFS HTTP Total Net kB/s Disk kB/s Tape kB/s Cache Cache CP CP = +Disk +DAFS FCP iSCSI FCP kB/s
+in out read write read write age hit time ty util in out
+2% 0 0 0 139 0 0 2788 0 0 0 3 96% 0% - 15% 0 139 0 3 2277
+2% 0 0 0 144 0 0 2504 0 0 0 3 96% 0% - 18% 0 144 0 3 2150
+2% 0 0 0 130 0 0 2212 0 0 0 3 96% 0% - 13% 0 130 0 3 1879
+3% 0 0 0 169 0 0 2937 80 0 0 3 96% 0% - 13% 0 169 0 4 2718
+2% 0 0 0 139 0 0 2448 0 0 0 3 96% 0% - 12% 0 139 0 3 2096
+2% 0 0 0 137 0 0 2116 0 0 0 3 96% 0% - 10% 0 137 0 3 1892
+3% 0 0 0 107 0 0 2660 812 0 0 3 96% 24% T 20% 0 107 0 3 1739
+2% 0 0 0 118 0 0 1788 0 0 0 3 96% 0% - 13% 0 118 0 3 1608
+2% 0 0 0 136 0 0 2228 0 0 0 3 96% 0% - 11% 0 136 0 3 2018
+2% 0 0 0 119 0 0 1940 0 0 0 3 96% 0% - 13% 0 119 0 3 1998
+2% 0 0 0 136 0 0 2175 0 0 0 3 96% 0% - 14% 0 136 0 3 1929
+2% 0 0 0 133 0 0 1924 0 0 0 3 96% 0% - 19% 0 133 0 3 2292
+2% 0 0 0 115 0 0 2044 0 0 0 3 96% 0% - 11% 0 115 0 3 1682
+2% 0 0 0 134 0 0 2256 0 0 0 3 96% 0% - 12% 0 134 0 3 2096
+2% 0 0 0 112 0 0 2184 0 0 0 3 96% 0% - 12% 0 112 0 3 1633
+2% 0 0 0 163 0 0 2348 0 0 0 3 96% 0% - 13% 0 163 0 4 2421
+2% 0 0 0 120 0 0 2056 184 0 0 3 96% 8% T 14% 0 120 0 3 1703
+
+strace output:
+read(55, "\4\0\0\0\10fm}\1\0\0\0p\0\264\0\0 \2 = +\230\236\320\0020"..., +8192) =3D 8192
+_llseek(55, 857997312, [857997312], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\\\315\321|\1\0\0\0p\0\354\0\0 \2 = +\250\236\260"..., +8192) =3D 8192
+_llseek(55, 883220480, [883220480], SEEK_SET) =3D 0
+read(55, "\4\0\0\0T\17a~\1\0\0\0p\0\20\1\0 \2 = +\270\236\220\2D\235"..., +8192) =3D 8192
+_llseek(55, 858005504, [858005504], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\300\356\321|\1\0\0\0p\0\330\0\0 \2 +\260\236\240"..., 8192) =3D 8192
+_llseek(55, 857964544, [857964544], SEEK_SET) =3D 0
+read(55, "\4\0\0\0lH\321|\1\0\0\0p\0<\1\0 \2 = +\300\236\200\2p\235"..., +8192) =3D 8192
+_llseek(55, 857956352, [857956352], SEEK_SET) =3D 0
+read(55, "\4\0\0\0l\'\321|\1\0\0\0p\0\320\0\0 \2 +\260\236\240\2\\"..., 8192) =3D 8192
+_llseek(55, 910802944, [910802944], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\10}\25\200\1\0\0\0l\0\274\1\0 \2 = +\250\236\260"..., +8192) =3D 8192
+_llseek(55, 857948160, [857948160], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\370\5\321|\1\0\0\0p\0\350\0\0 \2 = +\230\236\320"..., +8192) =3D 8192
+_llseek(56, 80371712, [80371712], SEEK_SET) =3D 0
+read(56, "\4\0\0\0Lf \217\1\0\0\0p\0\f\1\0 \2 +\250\236\260\2T\235"..., 8192) =3D 8192
+read(102, +"\2\0\34\0001\236\0\0\1\0\0\0\t\0\0\00020670\0\0\0B\6\0"..., = +8192) =3D +8192
+_llseek(55, 857939968, [857939968], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\244\344\320|\1\0\0\0l\0\230\1\0 \2 = +\244\236\270"..., +8192) =3D 8192
+_llseek(55, 857923584, [857923584], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\224\242\320|\1\0\0\0p\0|\0\0 \2 +\234\236\310\002"..., 8192) =3D 8192
+_llseek(55, 57270272, [57270272], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\3204FK\1\0\0\0t\0\340\0\0 \2 = +\310\236j\2\214\235"..., +8192) =3D 8192
+_llseek(55, 870727680, [870727680], SEEK_SET) =3D 0
+read(55, "\4\0\0\0x>\233}\1\0\0\0p\0@\1\0 \2 +\250\236\260\2X\235"..., 8192) =3D 8192
+_llseek(55, 1014734848, [1014734848], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\34\354\201\206\1\0\0\0p\0p\0\0 \2 +\264\236\230"..., 8192) =3D 8192
+_llseek(55, 857874432, [857874432], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\214\331\317|\1\0\0\0l\0\324\1\0 \2 +\224\236\330"..., 8192) =3D 8192
+_llseek(55, 760872960, [760872960], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\30\257\321v\1\0\0\0p\0\230\0\0 \2 +\234\236\310"..., 8192) =3D 8192
+_llseek(55, 891715584, [891715584], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\370\220\347~\1\0\0\0p\0P\1\0 \2 +\230\236\320\2"..., 8192) =3D 8192
+_llseek(55, 857858048, [857858048], SEEK_SET) =3D 0
+read(55, "\4\0\0\0\250\227\317|\1\0\0\0p\0\264\0\0 \2 +\254\236\250"..., 8192) =3D 8192
+_llseek(55, 666910720, [666910720], SEEK_SET) =3D 0
+read(55, "\4\0\0\0x\206\3q\1\0\0\0p\0004\1\0 \2 +\254\236\242\2P\235"..., 8192) =3D 8192
+_llseek(55, 857841664, [857841664], SEEK_SET) =3D 0
+read(55, "\4\0\0\0dT\317|\1\0\0\0p\0\224\0\0 \2 +\214\236\350\2\30"..., 8192) =3D 8192
+
+
+
+

+ +
+ + + + + +------_=_NextPart_001_01C5AD93.16A8668F-- + +From pgsql-performance-owner@postgresql.org Tue Aug 30 15:54:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E20AD7F46 + for ; + Tue, 30 Aug 2005 15:50:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34634-08 + for ; + Tue, 30 Aug 2005 18:50:16 +0000 (GMT) +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 528ECD7DD9 + for ; + Tue, 30 Aug 2005 15:50:15 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id i31so822926wxd + for ; + Tue, 30 Aug 2005 11:50:16 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=NQ9rOruHU2UuaX5blFauvBJI7D9xJLsWEREhkNDFUPZZ7scS6lQsrTO0bwjlxlvofn5AVYmEXyHrp1bIBAaDJ0HJONs/7T91NYnnQlMFfMHqe/ri+jrzVA8dNCGyNTtyD93/P3R/4IxG2TVvDnAnqVGcSPFqRYDx7vHlThVeJVk= +Received: by 10.70.78.19 with SMTP id a19mr138440wxb; + Tue, 30 Aug 2005 11:50:16 -0700 (PDT) +Received: by 10.70.128.19 with HTTP; Tue, 30 Aug 2005 11:50:16 -0700 (PDT) +Message-ID: +Date: Tue, 30 Aug 2005 13:50:16 -0500 +From: Matthew Nuzum +Reply-To: newz@bearfruit.org +To: pgsql-performance@postgresql.org +Subject: Re: RAID Configuration Sugestion +In-Reply-To: <6.2.3.4.0.20050830132902.021a5308@pop.earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <431452FD.3090402@atua.com.br> + <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> + <43148FC4.4000407@commandprompt.com> + <6.2.3.4.0.20050830132902.021a5308@pop.earthlink.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] +X-Spam-Level: +X-Archive-Number: 200508/537 +X-Sequence-Number: 14284 + +On 8/30/05, Ron wrote: +> >If you still have the budget, I would suggest considering either +> >what Ron suggested or possibly using a 4 drive RAID 10 instead. +>=20 +> IME, with only 4 HDs, it's usually better to split them them into two +> RAID 1's (one for the db, one for everything else including the logs) +> than it is to put everything on one RAID 10. YMMV. + +This coresponds to what I have observed as well. Of course, we all +know that work loads varry. + +Just a note for the OP who has only two drives, there are tools for a +variety of OSs that monitor the S.M.A.R.T. features of the drive and +give an early warning in case it senses impending failure. I've caught +two drives before failure with these types of tools. + +Also note that when reading discussions of this nature you must take +into consideration the value of your data. For some people, restoring +from a nightly backup is inconvienent, but not life-or-death. Some +people even do twice-daily backups so that in case of a failure they +can recover with little loss of data. This might be a good way to +mitigate the cost of expensive server hardware. If you cannot afford +to lose any data then you need to consider it imperitive to use some +type of RAID setup (not RAID 0) and to achieve great performance +you'll want more than 2 drives. +--=20 +Matthew Nuzum +www.bearfruit.org + +From pgsql-performance-owner@postgresql.org Tue Aug 30 15:54:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ACA01D8581 + for ; + Tue, 30 Aug 2005 15:50:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35972-03 + for ; + Tue, 30 Aug 2005 18:50:33 +0000 (GMT) +Received: from iad2.emailsrvr.com (iad2.emailsrvr.com [207.97.227.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 66535D76E9 + for ; + Tue, 30 Aug 2005 15:50:32 -0300 (ADT) +Received: from [10.10.20.22] (unknown [216.94.157.147]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + (Authenticated sender: remyb@medrium.com) + by relay3.r3.iad.emailsrvr.com (SMTP Server) with ESMTP id D11BF44C5EE; + Tue, 30 Aug 2005 14:50:32 -0400 (EDT) +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098C1C@vt-pe2550-001.vantage.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098C1C@vt-pe2550-001.vantage.vantage.com> +Mime-Version: 1.0 (Apple Message framework v622) +Content-Type: text/plain; charset=WINDOWS-1252; format=flowed +Message-Id: <6bb032ec58fb35eb6e5a3cefd3dd9360@medrium.com> +Content-Transfer-Encoding: quoted-printable +Cc: +From: =?ISO-8859-1?Q?R=E9my_Beaumont?= +Subject: Re: High load and iowait but no disk access +Date: Tue, 30 Aug 2005 14:50:35 -0400 +To: "Anjan Dave" +X-Mailer: Apple Mail (2.622) +X-Virus-Scanned: OK +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/536 +X-Sequence-Number: 14283 + + +On 30-Aug-05, at 14:46, Anjan Dave wrote: + +> I have seen references of changing the kernel io scheduler at boot=20 +> time=85not sure if it applies to RHEL3.0, or will help, but try = +setting=20 +> =91elevator=3Ddeadline=92 during boot time or via grub.conf. +That's only for RHEL 4.0. + +> Have you tried running a simple =91dd=92 on the LUN? +We get amazing performance using dd. +> The drives are in RAID10 configuration, right? +NetApp has their own type of raid format (RAID4 aka WAFL) + +R=E9my +> =A0 +> Thanks, +> Anjan +> +> From: Woody Woodring [mailto:george.woodring@iglass.net] +> Sent: Tuesday, August 30, 2005 2:30 PM +> To: 'R=E9my Beaumont'; pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] High load and iowait but no disk access +> =A0 +> Have you tried a different kernel?=A0 We run with a netapp over NFS=20 +> without any issues, but we have seen high IO-wait on other Dell boxes=20= + +> (running=A0 and not running postgres) and RHES 3.=A0 We have replaced = +a=20 +> Dell PowerEdge 350 running RH 7.3 =A0with a PE750 with more memory=20 +> running RHES3 and it be bogged down with IO waits due to syslog=20 +> messages writing to the disk, the old slower server could handle it=20 +> fine.=A0 I don't know if it is a Dell thing or a RH kernel, but we try=20= + +> different kernels on our boxes to try to find one that works better.=A0=20= + +> We have not found one that stands out over another=A0consistently but = +we=20 +> have been moving away from Update 2 kernel (2.4.21-15.ELsmp) due to=20 +> server lockup issues.=A0 Unfortunately we get the best disk throughput=20= + +> on our few remaining 7.3 boxes. +> =A0 +> Woody +> =A0 +> IGLASS Networks +> www.iglass.net +> =A0 +> +> +> From: pgsql-performance-owner@postgresql.org=20 +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of R=E9my=20 +> Beaumont +> Sent: Monday, August 29, 2005 9:43 AM +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] High load and iowait but no disk access +> We have been trying to pinpoint what originally seem to be a I/O=20 +> bottleneck but which now seems to be an issue with either Postgresql=20= + +> or RHES 3. +> +> We have the following test environment on which we can reproduce the=20= + +> problem: +> +> 1) Test System A +> Dell 6650 Quad Xeon Pentium 4 +> 8 Gig of RAM +> OS: RHES 3 update 2 +> Storage: NetApp FAS270 connected using an FC card using 10 disks +> +> 2) Test System B +> Dell Dual Xeon Pentium III +> 2 Gig o RAM +> OS: RHES 3 update 2 +> Storage: NetApp FAS920 connected using an FC card using 28 disks +> +> Our Database size is around 30G. +> +> The behavior we see is that when running queries that do random reads=20= + +> on disk, IOWAIT goes over 80% and actual disk IO falls to a crawl at a=20= + +> throughput bellow 3000kB/s (We usually average 40000 kB/s to 80000=20 +> kB/s on sequential read operations on the netapps) +> +> The stats of the NetApp do confirm that it is sitting idle. Doing an=20= + +> strace on the Postgresql process shows that is it doing seeks and=20 +> reads. +> +> So my question is where is this iowait time spent ? +> Is there a way to pinpoint the problem in more details ? +> We are able to reproduce this behavior with Postgresql 7.4.8 and = +8.0.3 +> +> I have included the output of top,vmstat,strace and systat from the=20= + +> Netapp from System B while running a single query that generates this=20= + +> behavior. +> +> R=E9my +> +> top output: +> 06:27:28 up 5 days, 16:59, 6 users, load average: 1.04, 1.30, 1.01 +> 72 processes: 71 sleeping, 1 running, 0 zombie, 0 stopped +> CPU states: cpu user nice system irq softirq iowait idle +> total 2.7% 0.0% 1.0% 0.1% 0.2% 46.0% 49.5% +> cpu00 0.2% 0.0% 0.2% 0.0% 0.2% 2.2% 97.2% +> cpu01 5.3% 0.0% 1.9% 0.3% 0.3% 89.8% 1.9% +> Mem: 2061696k av, 2043936k used, 17760k free, 0k shrd, 3916k buff +> 1566332k actv, 296648k in_d, 30504k in_c +> Swap: 16771584k av, 21552k used, 16750032k free 1933772k cached +> +> PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND +> 30960 postgres 15 0 13424 10M 9908 D 2.7 0.5 2:00 1 postmaster +> 30538 root 15 0 1080 764 524 S 0.7 0.0 0:43 0 sshd +> 1 root 15 0 496 456 436 S 0.0 0.0 0:08 0 init +> 2 root RT 0 0 0 0 SW 0.0 0.0 0:00 0 migration/0 +> 3 root RT 0 0 0 0 SW 0.0 0.0 0:00 1 migration/1 +> 4 root 15 0 0 0 0 SW 0.0 0.0 0:01 0 keventd +> 5 root 34 19 0 0 0 SWN 0.0 0.0 0:00 0 ksoftirqd/0 +> 6 root 34 19 0 0 0 SWN 0.0 0.0 0:00 1 ksoftirqd/1 +> 9 root 15 0 0 0 0 SW 0.0 0.0 0:24 1 bdflush +> 7 root 15 0 0 0 0 SW 0.0 0.0 6:53 1 kswapd +> 8 root 15 0 0 0 0 SW 0.0 0.0 8:44 1 kscand +> 10 root 15 0 0 0 0 SW 0.0 0.0 0:13 0 kupdated +> 11 root 25 0 0 0 0 SW 0.0 0.0 0:00 0 mdrecoveryd +> 17 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 ahc_dv_0 +> +> +> vmstat output +> procs memory swap io system cpu +> r b swpd free buff cache si so bi bo in cs us sy id wa +> 0 1 21552 17796 4872 1931928 2 3 3 1 27 6 2 1 7 3 +> 0 1 21552 18044 4880 1931652 0 0 1652 0 397 512 1 2 50 47 +> 0 1 21552 17976 4896 1931664 0 0 2468 0 407 552 2 2 50 47 +> 1 0 21552 17984 4896 1931608 0 0 2124 0 418 538 3 3 48 46 +> 0 1 21552 18028 4900 1931536 0 0 1592 0 385 509 1 3 50 46 +> 0 1 21552 18040 4916 1931488 0 0 1620 820 419 581 2 2 50 46 +> 0 1 21552 17968 4916 1931536 0 4 1708 4 402 554 3 1 50 46 +> 1 1 21552 18052 4916 1931388 0 0 1772 0 409 531 3 1 49 47 +> 0 1 21552 17912 4924 1931492 0 0 1772 0 408 565 3 1 48 48 +> 0 1 21552 17932 4932 1931440 0 4 1356 4 391 545 5 0 49 46 +> 0 1 21552 18320 4944 1931016 0 4 1500 840 414 571 1 1 48 50 +> 0 1 21552 17872 4944 1931440 0 0 2116 0 392 496 1 5 46 48 +> 0 1 21552 18060 4944 1931232 0 0 2232 0 423 597 1 2 48 49 +> 1 1 21552 17684 4944 1931584 0 0 1752 0 395 537 1 1 50 48 +> 0 1 21552 18000 4944 1931240 0 0 1576 0 401 549 0 1 50 49 +> +> +> NetApp stats: +> CPU NFS CIFS HTTP Total Net kB/s Disk kB/s Tape kB/s Cache Cache CP=20= + +> CP Disk DAFS FCP iSCSI FCP kB/s +> in out read write read write age hit time ty util in out +> 2% 0 0 0 139 0 0 2788 0 0 0 3 96% 0% - 15% 0 139 0 3 2277 +> 2% 0 0 0 144 0 0 2504 0 0 0 3 96% 0% - 18% 0 144 0 3 2150 +> 2% 0 0 0 130 0 0 2212 0 0 0 3 96% 0% - 13% 0 130 0 3 1879 +> 3% 0 0 0 169 0 0 2937 80 0 0 3 96% 0% - 13% 0 169 0 4 2718 +> 2% 0 0 0 139 0 0 2448 0 0 0 3 96% 0% - 12% 0 139 0 3 2096 +> 2% 0 0 0 137 0 0 2116 0 0 0 3 96% 0% - 10% 0 137 0 3 1892 +> 3% 0 0 0 107 0 0 2660 812 0 0 3 96% 24% T 20% 0 107 0 3 1739 +> 2% 0 0 0 118 0 0 1788 0 0 0 3 96% 0% - 13% 0 118 0 3 1608 +> 2% 0 0 0 136 0 0 2228 0 0 0 3 96% 0% - 11% 0 136 0 3 2018 +> 2% 0 0 0 119 0 0 1940 0 0 0 3 96% 0% - 13% 0 119 0 3 1998 +> 2% 0 0 0 136 0 0 2175 0 0 0 3 96% 0% - 14% 0 136 0 3 1929 +> 2% 0 0 0 133 0 0 1924 0 0 0 3 96% 0% - 19% 0 133 0 3 2292 +> 2% 0 0 0 115 0 0 2044 0 0 0 3 96% 0% - 11% 0 115 0 3 1682 +> 2% 0 0 0 134 0 0 2256 0 0 0 3 96% 0% - 12% 0 134 0 3 2096 +> 2% 0 0 0 112 0 0 2184 0 0 0 3 96% 0% - 12% 0 112 0 3 1633 +> 2% 0 0 0 163 0 0 2348 0 0 0 3 96% 0% - 13% 0 163 0 4 2421 +> 2% 0 0 0 120 0 0 2056 184 0 0 3 96% 8% T 14% 0 120 0 3 1703 +> +> strace output: +> read(55, "\4\0\0\0\10fm}\1\0\0\0p\0\264\0\0 \2 \230\236\320\0020"...,=20= + +> 8192) =3D 8192 +> _llseek(55, 857997312, [857997312], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\\\315\321|\1\0\0\0p\0\354\0\0 \2 \250\236\260"...,=20= + +> 8192) =3D 8192 +> _llseek(55, 883220480, [883220480], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0T\17a~\1\0\0\0p\0\20\1\0 \2=20 +> \270\236\220\2D\235"..., 8192) =3D 8192 +> _llseek(55, 858005504, [858005504], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\300\356\321|\1\0\0\0p\0\330\0\0 \2=20 +> \260\236\240"..., 8192) =3D 8192 +> _llseek(55, 857964544, [857964544], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0lH\321|\1\0\0\0p\0<\1\0 \2 \300\236\200\2p\235"...,=20= + +> 8192) =3D 8192 +> _llseek(55, 857956352, [857956352], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0l\'\321|\1\0\0\0p\0\320\0\0 \2=20 +> \260\236\240\2\\"..., 8192) =3D 8192 +> _llseek(55, 910802944, [910802944], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\10}\25\200\1\0\0\0l\0\274\1\0 \2 \250\236\260"...,=20= + +> 8192) =3D 8192 +> _llseek(55, 857948160, [857948160], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\370\5\321|\1\0\0\0p\0\350\0\0 \2 \230\236\320"...,=20= + +> 8192) =3D 8192 +> _llseek(56, 80371712, [80371712], SEEK_SET) =3D 0 +> read(56, "\4\0\0\0Lf \217\1\0\0\0p\0\f\1\0 \2=20 +> \250\236\260\2T\235"..., 8192) =3D 8192 +> read(102,=20 +> "\2\0\34\0001\236\0\0\1\0\0\0\t\0\0\00020670\0\0\0B\6\0"..., 8192) =3D=20= + +> 8192 +> _llseek(55, 857939968, [857939968], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\244\344\320|\1\0\0\0l\0\230\1\0 \2=20 +> \244\236\270"..., 8192) =3D 8192 +> _llseek(55, 857923584, [857923584], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\224\242\320|\1\0\0\0p\0|\0\0 \2=20 +> \234\236\310\002"..., 8192) =3D 8192 +> _llseek(55, 57270272, [57270272], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\3204FK\1\0\0\0t\0\340\0\0 \2=20 +> \310\236j\2\214\235"..., 8192) =3D 8192 +> _llseek(55, 870727680, [870727680], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0x>\233}\1\0\0\0p\0@\1\0 \2 \250\236\260\2X\235"...,=20= + +> 8192) =3D 8192 +> _llseek(55, 1014734848, [1014734848], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\34\354\201\206\1\0\0\0p\0p\0\0 \2=20 +> \264\236\230"..., 8192) =3D 8192 +> _llseek(55, 857874432, [857874432], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\214\331\317|\1\0\0\0l\0\324\1\0 \2=20 +> \224\236\330"..., 8192) =3D 8192 +> _llseek(55, 760872960, [760872960], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\30\257\321v\1\0\0\0p\0\230\0\0 \2=20 +> \234\236\310"..., 8192) =3D 8192 +> _llseek(55, 891715584, [891715584], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\370\220\347~\1\0\0\0p\0P\1\0 \2=20 +> \230\236\320\2"..., 8192) =3D 8192 +> _llseek(55, 857858048, [857858048], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0\250\227\317|\1\0\0\0p\0\264\0\0 \2=20 +> \254\236\250"..., 8192) =3D 8192 +> _llseek(55, 666910720, [666910720], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0x\206\3q\1\0\0\0p\0004\1\0 \2=20 +> \254\236\242\2P\235"..., 8192) =3D 8192 +> _llseek(55, 857841664, [857841664], SEEK_SET) =3D 0 +> read(55, "\4\0\0\0dT\317|\1\0\0\0p\0\224\0\0 \2=20 +> \214\236\350\2\30"..., 8192) =3D 8192 +> +> +> + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 16:27:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DD180D7D44 + for ; + Tue, 30 Aug 2005 16:27:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44752-02 + for ; + Tue, 30 Aug 2005 19:27:31 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 888EFD7BC4 + for ; + Tue, 30 Aug 2005 16:27:28 -0300 (ADT) +Received: from [192.168.1.100] (clbb-248.saw.net [64.146.135.248]) + (authenticated bits=0) + by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id + j7UJOvjZ024904; Tue, 30 Aug 2005 12:24:57 -0700 +Message-ID: <4314B329.20009@commandprompt.com> +Date: Tue, 30 Aug 2005 12:27:37 -0700 +From: "Joshua D. Drake" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050727) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ron +Cc: pgsql-performance@postgresql.org +Subject: Re: RAID Configuration Sugestion +References: <431452FD.3090402@atua.com.br> + <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> + <43148FC4.4000407@commandprompt.com> + <6.2.3.4.0.20050830132902.021a5308@pop.earthlink.net> +In-Reply-To: <6.2.3.4.0.20050830132902.021a5308@pop.earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); + Tue, 30 Aug 2005 12:24:58 -0700 (PDT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.022 required=5 tests=[AWL=0.022] +X-Spam-Level: +X-Archive-Number: 200508/539 +X-Sequence-Number: 14286 + + +> +>> If you still have the budget, I would suggest considering either what +>> Ron suggested or possibly using a 4 drive RAID 10 instead. +> +> +> IME, with only 4 HDs, it's usually better to split them them into two +> RAID 1's (one for the db, one for everything else including the logs) +> than it is to put everything on one RAID 10. YMMV. + +Really? That's interesting. My experience is different, I assume SCSI? +Software/Hardware Raid? + +Sincerely, + +Joshua D. Drake + + +> +> +> Ron Peacetree +> + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 16:42:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 413F9D8583 + for ; + Tue, 30 Aug 2005 16:34:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43716-08 + for ; + Tue, 30 Aug 2005 19:34:40 +0000 (GMT) +Received: from mail0.rawbw.com (mail0.rawbw.com [198.144.192.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C5C5D84F9 + for ; + Tue, 30 Aug 2005 16:34:38 -0300 (ADT) +Received: (from www@localhost) + by mail0.rawbw.com (8.11.6p2/8.11.6) id j7UJYe130017 + for pgsql-performance@postgresql.org; + Tue, 30 Aug 2005 12:34:40 -0700 (PDT) +Received: from cybs-gw.ic3.com (cybs-gw.ic3.com [66.185.177.10]) + by webmail.rawbw.com (IMP) with HTTP + for ; Tue, 30 Aug 2005 12:34:40 -0700 +Message-ID: <1125430480.4314b4d00a886@webmail.rawbw.com> +Date: Tue, 30 Aug 2005 12:34:40 -0700 +From: mudfoot@rawbw.com +To: pgsql-performance@postgresql.org +Subject: Re: High load and iowait but no disk access +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098C1C@vt-pe2550-001.vantage.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098C1C@vt-pe2550-001.vantage.vantage.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.1 +X-Originating-IP: 66.185.177.10 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/540 +X-Sequence-Number: 14287 + +This might be optimal behavior from the hardware. Random reads are hard to +optimize for--except if you have enough physical memory to hold the entire +dataset. Cached reads (either in array controller or OS buffer cache) should +return nearly immediately. But random reads probably aren't cached. And any +read-ahead alogorithms or other types of performance enhancements in the +hardware or OS go out the window--because the behavior isn't predictable. + +Each time a drive spindle needs to move to a new track, it requires at least a +couple of miliseconds. Sequential reads only require this movement +infrequently. But random reads may be forcing this movement for every IO operation. + +Since the bottleneck in random reads is the physical hard drives themselves, +everything else stands around waiting. Fancy hardware can optimize everything +else -- writes with write cache, sequential reads with read-ahead and read +cache. But there's no real solution to a purely random read workload except +perhaps creating different disk groups to help avoid spindle contention. + +I like this tool: http://www.soliddata.com/products/iotest.html +It allows you to select pure workloads (read/write/sequential/random), and it +runs against raw devices, so you bypass the OS buffer cache. When I've run it +I've always seen sequential activity get much much higher throughput than random. + +Quoting Anjan Dave : + +> I have seen references of changing the kernel io scheduler at boot time...not +> sure if it applies to RHEL3.0, or will help, but try setting +> 'elevator=deadline' during boot time or via grub.conf. Have you tried running +> a simple 'dd' on the LUN? The drives are in RAID10 configuration, right? +> +> +> +> Thanks, +> +> Anjan +> +> _____ +> +> From: Woody Woodring [mailto:george.woodring@iglass.net] +> Sent: Tuesday, August 30, 2005 2:30 PM +> To: 'R�my Beaumont'; pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] High load and iowait but no disk access +> +> +> +> Have you tried a different kernel? We run with a netapp over NFS without any +> issues, but we have seen high IO-wait on other Dell boxes (running and not +> running postgres) and RHES 3. We have replaced a Dell PowerEdge 350 running +> RH 7.3 with a PE750 with more memory running RHES3 and it be bogged down +> with IO waits due to syslog messages writing to the disk, the old slower +> server could handle it fine. I don't know if it is a Dell thing or a RH +> kernel, but we try different kernels on our boxes to try to find one that +> works better. We have not found one that stands out over another +> consistently but we have been moving away from Update 2 kernel +> (2.4.21-15.ELsmp) due to server lockup issues. Unfortunately we get the best +> disk throughput on our few remaining 7.3 boxes. +> +> +> +> Woody +> +> +> +> IGLASS Networks +> +> www.iglass.net +> +> +> +> _____ +> +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of R�my Beaumont +> Sent: Monday, August 29, 2005 9:43 AM +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] High load and iowait but no disk access +> +> We have been trying to pinpoint what originally seem to be a I/O bottleneck +> but which now seems to be an issue with either Postgresql or RHES 3. +> +> We have the following test environment on which we can reproduce the +> problem: +> +> 1) Test System A +> Dell 6650 Quad Xeon Pentium 4 +> 8 Gig of RAM +> OS: RHES 3 update 2 +> Storage: NetApp FAS270 connected using an FC card using 10 disks +> +> 2) Test System B +> Dell Dual Xeon Pentium III +> 2 Gig o RAM +> OS: RHES 3 update 2 +> Storage: NetApp FAS920 connected using an FC card using 28 disks +> +> Our Database size is around 30G. +> +> The behavior we see is that when running queries that do random reads on +> disk, IOWAIT goes over 80% and actual disk IO falls to a crawl at a +> throughput bellow 3000kB/s (We usually average 40000 kB/s to 80000 kB/s on +> sequential read operations on the netapps) +> +> The stats of the NetApp do confirm that it is sitting idle. Doing an strace +> on the Postgresql process shows that is it doing seeks and reads. +> +> So my question is where is this iowait time spent ? +> Is there a way to pinpoint the problem in more details ? +> We are able to reproduce this behavior with Postgresql 7.4.8 and 8.0.3 +> +> I have included the output of top,vmstat,strace and systat from the Netapp +> from System B while running a single query that generates this behavior. +> +> R�my +> +> top output: +> 06:27:28 up 5 days, 16:59, 6 users, load average: 1.04, 1.30, 1.01 +> 72 processes: 71 sleeping, 1 running, 0 zombie, 0 stopped +> CPU states: cpu user nice system irq softirq iowait idle +> total 2.7% 0.0% 1.0% 0.1% 0.2% 46.0% 49.5% +> cpu00 0.2% 0.0% 0.2% 0.0% 0.2% 2.2% 97.2% +> cpu01 5.3% 0.0% 1.9% 0.3% 0.3% 89.8% 1.9% +> Mem: 2061696k av, 2043936k used, 17760k free, 0k shrd, 3916k buff +> 1566332k actv, 296648k in_d, 30504k in_c +> Swap: 16771584k av, 21552k used, 16750032k free 1933772k cached +> +> PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND +> 30960 postgres 15 0 13424 10M 9908 D 2.7 0.5 2:00 1 postmaster +> 30538 root 15 0 1080 764 524 S 0.7 0.0 0:43 0 sshd +> 1 root 15 0 496 456 436 S 0.0 0.0 0:08 0 init +> 2 root RT 0 0 0 0 SW 0.0 0.0 0:00 0 migration/0 +> 3 root RT 0 0 0 0 SW 0.0 0.0 0:00 1 migration/1 +> 4 root 15 0 0 0 0 SW 0.0 0.0 0:01 0 keventd +> 5 root 34 19 0 0 0 SWN 0.0 0.0 0:00 0 ksoftirqd/0 +> 6 root 34 19 0 0 0 SWN 0.0 0.0 0:00 1 ksoftirqd/1 +> 9 root 15 0 0 0 0 SW 0.0 0.0 0:24 1 bdflush +> 7 root 15 0 0 0 0 SW 0.0 0.0 6:53 1 kswapd +> 8 root 15 0 0 0 0 SW 0.0 0.0 8:44 1 kscand +> 10 root 15 0 0 0 0 SW 0.0 0.0 0:13 0 kupdated +> 11 root 25 0 0 0 0 SW 0.0 0.0 0:00 0 mdrecoveryd +> 17 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 ahc_dv_0 +> +> +> vmstat output +> procs memory swap io system cpu +> r b swpd free buff cache si so bi bo in cs us sy id wa +> 0 1 21552 17796 4872 1931928 2 3 3 1 27 6 2 1 7 3 +> 0 1 21552 18044 4880 1931652 0 0 1652 0 397 512 1 2 50 47 +> 0 1 21552 17976 4896 1931664 0 0 2468 0 407 552 2 2 50 47 +> 1 0 21552 17984 4896 1931608 0 0 2124 0 418 538 3 3 48 46 +> 0 1 21552 18028 4900 1931536 0 0 1592 0 385 509 1 3 50 46 +> 0 1 21552 18040 4916 1931488 0 0 1620 820 419 581 2 2 50 46 +> 0 1 21552 17968 4916 1931536 0 4 1708 4 402 554 3 1 50 46 +> 1 1 21552 18052 4916 1931388 0 0 1772 0 409 531 3 1 49 47 +> 0 1 21552 17912 4924 1931492 0 0 1772 0 408 565 3 1 48 48 +> 0 1 21552 17932 4932 1931440 0 4 1356 4 391 545 5 0 49 46 +> 0 1 21552 18320 4944 1931016 0 4 1500 840 414 571 1 1 48 50 +> 0 1 21552 17872 4944 1931440 0 0 2116 0 392 496 1 5 46 48 +> 0 1 21552 18060 4944 1931232 0 0 2232 0 423 597 1 2 48 49 +> 1 1 21552 17684 4944 1931584 0 0 1752 0 395 537 1 1 50 48 +> 0 1 21552 18000 4944 1931240 0 0 1576 0 401 549 0 1 50 49 +> +> +> NetApp stats: +> CPU NFS CIFS HTTP Total Net kB/s Disk kB/s Tape kB/s Cache Cache CP CP Disk +> DAFS FCP iSCSI FCP kB/s +> in out read write read write age hit time ty util in out +> 2% 0 0 0 139 0 0 2788 0 0 0 3 96% 0% - 15% 0 139 0 3 2277 +> 2% 0 0 0 144 0 0 2504 0 0 0 3 96% 0% - 18% 0 144 0 3 2150 +> 2% 0 0 0 130 0 0 2212 0 0 0 3 96% 0% - 13% 0 130 0 3 1879 +> 3% 0 0 0 169 0 0 2937 80 0 0 3 96% 0% - 13% 0 169 0 4 2718 +> 2% 0 0 0 139 0 0 2448 0 0 0 3 96% 0% - 12% 0 139 0 3 2096 +> 2% 0 0 0 137 0 0 2116 0 0 0 3 96% 0% - 10% 0 137 0 3 1892 +> 3% 0 0 0 107 0 0 2660 812 0 0 3 96% 24% T 20% 0 107 0 3 1739 +> 2% 0 0 0 118 0 0 1788 0 0 0 3 96% 0% - 13% 0 118 0 3 1608 +> 2% 0 0 0 136 0 0 2228 0 0 0 3 96% 0% - 11% 0 136 0 3 2018 +> 2% 0 0 0 119 0 0 1940 0 0 0 3 96% 0% - 13% 0 119 0 3 1998 +> 2% 0 0 0 136 0 0 2175 0 0 0 3 96% 0% - 14% 0 136 0 3 1929 +> 2% 0 0 0 133 0 0 1924 0 0 0 3 96% 0% - 19% 0 133 0 3 2292 +> 2% 0 0 0 115 0 0 2044 0 0 0 3 96% 0% - 11% 0 115 0 3 1682 +> 2% 0 0 0 134 0 0 2256 0 0 0 3 96% 0% - 12% 0 134 0 3 2096 +> 2% 0 0 0 112 0 0 2184 0 0 0 3 96% 0% - 12% 0 112 0 3 1633 +> 2% 0 0 0 163 0 0 2348 0 0 0 3 96% 0% - 13% 0 163 0 4 2421 +> 2% 0 0 0 120 0 0 2056 184 0 0 3 96% 8% T 14% 0 120 0 3 1703 +> +> strace output: +> read(55, "\4\0\0\0\10fm}\1\0\0\0p\0\264\0\0 \2 \230\236\320\0020"..., 8192) = +> 8192 +> _llseek(55, 857997312, [857997312], SEEK_SET) = 0 +> read(55, "\4\0\0\0\\\315\321|\1\0\0\0p\0\354\0\0 \2 \250\236\260"..., 8192) = +> 8192 +> _llseek(55, 883220480, [883220480], SEEK_SET) = 0 +> read(55, "\4\0\0\0T\17a~\1\0\0\0p\0\20\1\0 \2 \270\236\220\2D\235"..., 8192) +> = 8192 +> _llseek(55, 858005504, [858005504], SEEK_SET) = 0 +> read(55, "\4\0\0\0\300\356\321|\1\0\0\0p\0\330\0\0 \2 \260\236\240"..., 8192) +> = 8192 +> _llseek(55, 857964544, [857964544], SEEK_SET) = 0 +> read(55, "\4\0\0\0lH\321|\1\0\0\0p\0<\1\0 \2 \300\236\200\2p\235"..., 8192) = +> 8192 +> _llseek(55, 857956352, [857956352], SEEK_SET) = 0 +> read(55, "\4\0\0\0l\'\321|\1\0\0\0p\0\320\0\0 \2 \260\236\240\2\\"..., 8192) +> = 8192 +> _llseek(55, 910802944, [910802944], SEEK_SET) = 0 +> read(55, "\4\0\0\0\10}\25\200\1\0\0\0l\0\274\1\0 \2 \250\236\260"..., 8192) = +> 8192 +> _llseek(55, 857948160, [857948160], SEEK_SET) = 0 +> read(55, "\4\0\0\0\370\5\321|\1\0\0\0p\0\350\0\0 \2 \230\236\320"..., 8192) = +> 8192 +> _llseek(56, 80371712, [80371712], SEEK_SET) = 0 +> read(56, "\4\0\0\0Lf \217\1\0\0\0p\0\f\1\0 \2 \250\236\260\2T\235"..., 8192) +> = 8192 +> read(102, "\2\0\34\0001\236\0\0\1\0\0\0\t\0\0\00020670\0\0\0B\6\0"..., 8192) +> = 8192 +> _llseek(55, 857939968, [857939968], SEEK_SET) = 0 +> read(55, "\4\0\0\0\244\344\320|\1\0\0\0l\0\230\1\0 \2 \244\236\270"..., 8192) +> = 8192 +> _llseek(55, 857923584, [857923584], SEEK_SET) = 0 +> read(55, "\4\0\0\0\224\242\320|\1\0\0\0p\0|\0\0 \2 \234\236\310\002"..., +> 8192) = 8192 +> _llseek(55, 57270272, [57270272], SEEK_SET) = 0 +> read(55, "\4\0\0\0\3204FK\1\0\0\0t\0\340\0\0 \2 \310\236j\2\214\235"..., +> 8192) = 8192 +> _llseek(55, 870727680, [870727680], SEEK_SET) = 0 +> read(55, "\4\0\0\0x>\233}\1\0\0\0p\0@\1\0 \2 \250\236\260\2X\235"..., 8192) = +> 8192 +> _llseek(55, 1014734848, [1014734848], SEEK_SET) = 0 +> read(55, "\4\0\0\0\34\354\201\206\1\0\0\0p\0p\0\0 \2 \264\236\230"..., 8192) +> = 8192 +> _llseek(55, 857874432, [857874432], SEEK_SET) = 0 +> read(55, "\4\0\0\0\214\331\317|\1\0\0\0l\0\324\1\0 \2 \224\236\330"..., 8192) +> = 8192 +> _llseek(55, 760872960, [760872960], SEEK_SET) = 0 +> read(55, "\4\0\0\0\30\257\321v\1\0\0\0p\0\230\0\0 \2 \234\236\310"..., 8192) +> = 8192 +> _llseek(55, 891715584, [891715584], SEEK_SET) = 0 +> read(55, "\4\0\0\0\370\220\347~\1\0\0\0p\0P\1\0 \2 \230\236\320\2"..., 8192) +> = 8192 +> _llseek(55, 857858048, [857858048], SEEK_SET) = 0 +> read(55, "\4\0\0\0\250\227\317|\1\0\0\0p\0\264\0\0 \2 \254\236\250"..., 8192) +> = 8192 +> _llseek(55, 666910720, [666910720], SEEK_SET) = 0 +> read(55, "\4\0\0\0x\206\3q\1\0\0\0p\0004\1\0 \2 \254\236\242\2P\235"..., +> 8192) = 8192 +> _llseek(55, 857841664, [857841664], SEEK_SET) = 0 +> read(55, "\4\0\0\0dT\317|\1\0\0\0p\0\224\0\0 \2 \214\236\350\2\30"..., 8192) +> = 8192 +> +> +> +> +> +> + + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 18:14:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AF5C0D7EE6 + for ; + Tue, 30 Aug 2005 18:13:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66555-09 + for ; + Tue, 30 Aug 2005 21:13:56 +0000 (GMT) +Received: from web31606.mail.mud.yahoo.com (web31606.mail.mud.yahoo.com + [68.142.198.152]) + by svr1.postgresql.org (Postfix) with SMTP id 4E111D7DD2 + for ; + Tue, 30 Aug 2005 18:13:54 -0300 (ADT) +Received: (qmail 48140 invoked by uid 60001); 30 Aug 2005 21:13:56 -0000 +Message-ID: <20050830211356.48138.qmail@web31606.mail.mud.yahoo.com> +Received: from [209.217.70.195] by web31606.mail.mud.yahoo.com via HTTP; + Tue, 30 Aug 2005 14:13:55 PDT +Date: Tue, 30 Aug 2005 14:13:55 -0700 (PDT) +From: Markus Benne +Reply-To: markus@m-bass.com +Subject: When to do a vacuum for highly active table +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/541 +X-Sequence-Number: 14288 + +We have a highly active table that has virtually all +entries updated every 5 minutes. Typical size of the +table is 50,000 entries, and entries have grown fat. + +We are currently vaccuming hourly, and towards the end +of the hour we are seeing degradation, when compared +to the top of the hour. + +Vaccum is slowly killing our system, as it is starting +to take up to 10 minutes, and load at the time of +vacuum is 6+ on a Linux box. During the vacuum, +overall system is goin unresponsive, then comes back +once vacuum completes. + +If we run vacuum less frequently, degradation +continues to the point that we can't keep up with the +throughput, plus vacuum takes longer anyway. + +Becoming quite a pickle:-) + +We are thinking of splitting the table in two: the +part the updates often, and the part the updates +infrequently as we suspect that record size impacts +vacuum. + +Any ideas? + + +Thanks, +Mark + +----------------- + +From pgsql-performance-owner@postgresql.org Tue Sep 6 01:12:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 077F9D707D + for ; + Tue, 30 Aug 2005 18:25:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72055-03 + for ; + Tue, 30 Aug 2005 21:25:51 +0000 (GMT) +Received: from linux.finestmedia.tv (linux.finestmedia.tv [213.180.31.12]) + by svr1.postgresql.org (Postfix) with ESMTP id AFAF0D706F + for ; + Tue, 30 Aug 2005 18:25:49 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by linux.finestmedia.tv (Postfix) with ESMTP id 4FC6718E71B + for ; + Wed, 31 Aug 2005 00:25:49 +0300 (EEST) +Received: from linux.finestmedia.tv ([127.0.0.1]) + by localhost (linux.finestmedia.tv [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 29451-04 for ; + Wed, 31 Aug 2005 00:25:46 +0300 (EEST) +Received: from err (err.fm.sise [192.168.2.19]) + by linux.finestmedia.tv (Postfix) with ESMTP id 5472718E718 + for ; + Wed, 31 Aug 2005 00:25:45 +0300 (EEST) +From: "Rigmor Ukuhe" +To: +Subject: Re: When to do a vacuum for highly active table +Date: Wed, 31 Aug 2005 00:25:44 +0300 +Organization: Finestmedia +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +Thread-Index: AcWtqCLO1Qji3rAwRQSxeM5zsbuD4QAAJ1CA +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 +In-Reply-To: <20050830211356.48138.qmail@web31606.mail.mud.yahoo.com> +Message-Id: <20050830212545.5472718E718@linux.finestmedia.tv> +X-Virus-Scanned: by amavisd-new at finestmedia.ee +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.026 required=5 tests=[AWL=0.026] +X-Spam-Level: +X-Archive-Number: 200509/80 +X-Sequence-Number: 14388 + + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance- +> owner@postgresql.org] On Behalf Of Markus Benne +> Sent: Wednesday, August 31, 2005 12:14 AM +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] When to do a vacuum for highly active table +> +> We have a highly active table that has virtually all +> entries updated every 5 minutes. Typical size of the +> table is 50,000 entries, and entries have grown fat. +> +> We are currently vaccuming hourly, and towards the end +> of the hour we are seeing degradation, when compared +> to the top of the hour. +> +> Vaccum is slowly killing our system, as it is starting +> to take up to 10 minutes, and load at the time of +> vacuum is 6+ on a Linux box. During the vacuum, +> overall system is goin unresponsive, then comes back +> once vacuum completes. + +Play with vacuum_cost_delay option. In our case it made BIG difference +(going from very heavy hitting to almost unnoticed vacuuming.) + +Hope it helps. + +Rigmor Ukuhe + +> +> If we run vacuum less frequently, degradation +> continues to the point that we can't keep up with the +> throughput, plus vacuum takes longer anyway. +> +> Becoming quite a pickle:-) +> +> We are thinking of splitting the table in two: the +> part the updates often, and the part the updates +> infrequently as we suspect that record size impacts +> vacuum. +> +> Any ideas? +> +> +> Thanks, +> Mark +> +> ----------------- +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 18:30:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3817ED86EE + for ; + Tue, 30 Aug 2005 18:30:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70857-10 + for ; + Tue, 30 Aug 2005 21:30:24 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id BEC6CD86AF + for ; + Tue, 30 Aug 2005 18:29:15 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7ULTH1Z024876; + Tue, 30 Aug 2005 17:29:17 -0400 (EDT) +To: markus@m-bass.com +Cc: pgsql-performance@postgresql.org +Subject: Re: When to do a vacuum for highly active table +In-reply-to: <20050830211356.48138.qmail@web31606.mail.mud.yahoo.com> +References: <20050830211356.48138.qmail@web31606.mail.mud.yahoo.com> +Comments: In-reply-to Markus Benne + message dated "Tue, 30 Aug 2005 14:13:55 -0700" +Date: Tue, 30 Aug 2005 17:29:17 -0400 +Message-ID: <24875.1125437357@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/542 +X-Sequence-Number: 14289 + +Markus Benne writes: +> We have a highly active table that has virtually all +> entries updated every 5 minutes. Typical size of the +> table is 50,000 entries, and entries have grown fat. + +> We are currently vaccuming hourly, and towards the end +> of the hour we are seeing degradation, when compared +> to the top of the hour. + +On something like this, you really need to be vacuuming more often +not less so; I'd think about how to do it every five or ten minutes +rather than backing off. With only 50K rows it should really not take +more than a couple of seconds to do the vacuum. When you wait till +there are 600K dead rows, it's going to take awhile, plus you are +suffering across-the-board performance degradation from all the dead +rows. + +If you are using PG 8.0, there are some "vacuum cost" knobs you can +fiddle with to slow down vacuum so it doesn't impose as much I/O load. +Ideally you could get it to where you could run vacuum as often as +you need to without noticing much impact on foreground processing. + +If you're not using 8.0 ... maybe it's time to update. + +Another thing you might want to do is look at "vacuum verbose" output, +which will give you some idea of the time spent in each step. It might +be there are specific aspects that could be improved. + +> We are thinking of splitting the table in two: the +> part the updates often, and the part the updates +> infrequently as we suspect that record size impacts +> vacuum. + +You just said that virtually all rows update constantly --- where's +the "infrequent" part? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 30 19:15:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BAD23D86C6 + for ; + Tue, 30 Aug 2005 19:15:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84803-01 + for ; + Tue, 30 Aug 2005 22:15:25 +0000 (GMT) +Received: from mail.envyfinancial.com (unknown [206.248.142.186]) + by svr1.postgresql.org (Postfix) with ESMTP id D5082D86C4 + for ; + Tue, 30 Aug 2005 19:15:20 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envyfinancial.com (Postfix) with ESMTP id 94AE81C73D; + Tue, 30 Aug 2005 18:05:03 -0400 (EDT) +Received: from mail.envyfinancial.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 27349-07; Tue, 30 Aug 2005 18:05:03 -0400 (EDT) +Received: by mail.envyfinancial.com (Postfix, from userid 500) + id 6A5931C742; Tue, 30 Aug 2005 18:05:03 -0400 (EDT) +Date: Tue, 30 Aug 2005 18:05:03 -0400 +From: mark@mark.mielke.cc +To: Tom Lane +Cc: markus@m-bass.com, pgsql-performance@postgresql.org +Subject: Re: When to do a vacuum for highly active table +Message-ID: <20050830220503.GA27740@mark.mielke.cc> +References: <20050830211356.48138.qmail@web31606.mail.mud.yahoo.com> + <24875.1125437357@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <24875.1125437357@sss.pgh.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envyfinancial.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.208 required=5 tests=[AWL=0.030, NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/543 +X-Sequence-Number: 14290 + +On Tue, Aug 30, 2005 at 05:29:17PM -0400, Tom Lane wrote: +> Markus Benne writes: +> > We have a highly active table that has virtually all +> > entries updated every 5 minutes. Typical size of the +> > table is 50,000 entries, and entries have grown fat. +> ... +> > We are thinking of splitting the table in two: the +> > part the updates often, and the part the updates +> > infrequently as we suspect that record size impacts +> > vacuum. +> You just said that virtually all rows update constantly --- where's +> the "infrequent" part? + +I think he means splitting it vertically, instead of horizontally, and +it sounds like an excellent idea, if a large enough portion of each +record is in fact mostly fixed. Otherwise, PostgreSQL is copying data +multiple times, only to have the data expire as part of a dead row. + +I've already started to notice such issues with postgresql - but more +because I'm using low-end hardware, and I'm projecting the effect for +when our database becomes much larger with much higher demand on the +database. + +This is the sort of scenario where a database without transactional +integrity would significantly out-perform one designed around it. If +records are fixed sized, and updated in place, these problems would +occur far less often. Is it heresy to suggest MySQL in here? :-) + +I switched from MySQL to PostgreSQL several months ago, and haven't +looked back - but they do work differently, and for certain uses, one +can destroy the other. Using a MyISAM table would be the way I would +go with this sort of problem. + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 20:04:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 92617D86A7 + for ; + Tue, 30 Aug 2005 20:04:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94807-07 + for ; + Tue, 30 Aug 2005 23:04:05 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 07736D8691 + for ; + Tue, 30 Aug 2005 20:04:04 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id CC26430956; Wed, 31 Aug 2005 01:04:03 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: When to do a vacuum for highly active table +Date: Tue, 30 Aug 2005 18:05:38 -0400 +Organization: cbbrowne Computing Inc +Lines: 33 +Message-ID: <6064tn6pxp.fsf@dba2.int.libertyrms.com> +References: <20050830211356.48138.qmail@web31606.mail.mud.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:Mb6tP0jYqjMBqYOk/ujn4/x8Npg= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.101 required=5 tests=[AWL=0.101] +X-Spam-Level: +X-Archive-Number: 200508/548 +X-Sequence-Number: 14295 + +thing@m-bass.com (Markus Benne) writes: +> We have a highly active table that has virtually all +> entries updated every 5 minutes. Typical size of the +> table is 50,000 entries, and entries have grown fat. +> +> We are currently vaccuming hourly, and towards the end +> of the hour we are seeing degradation, when compared +> to the top of the hour. + +You're not vacuuming the table nearly often enough. + +You should vacuum this table every five minutes, and possibly more +often than that. + +[We have some tables like that, albeit smaller than 50K entries, which +we vacuum once per minute in production...] + +> We are thinking of splitting the table in two: the part the updates +> often, and the part the updates infrequently as we suspect that +> record size impacts vacuum. + +There's *some* merit to that. + +You might discover that there's a "hot spot" that needs to be vacuumed +once per minute. + +But it may be simpler to just hit the table with a vacuum once every +few minutes even though some tuples are seldom updated. +-- +output = reverse("gro.gultn" "@" "enworbbc") +http://cbbrowne.com/info/spreadsheets.html +Signs of a Klingon Programmer #3: "By filing this TPR you have +challenged the honor of my family. Prepare to die!" + +From pgsql-performance-owner@postgresql.org Tue Aug 30 19:19:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A3ADD85E9 + for ; + Tue, 30 Aug 2005 19:19:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82130-10 + for ; + Tue, 30 Aug 2005 22:19:18 +0000 (GMT) +Received: from smtp102.biz.mail.mud.yahoo.com (smtp102.biz.mail.mud.yahoo.com + [68.142.200.237]) + by svr1.postgresql.org (Postfix) with SMTP id 937EFD84FF + for ; + Tue, 30 Aug 2005 19:19:16 -0300 (ADT) +Received: (qmail 68845 invoked from network); 30 Aug 2005 22:19:19 -0000 +Received: from unknown (HELO ?192.168.3.1?) + (ralph.mason@telogis.com@203.98.10.169 with plain) + by smtp102.biz.mail.mud.yahoo.com with SMTP; 30 Aug 2005 22:19:18 -0000 +Message-ID: <4314DBE0.9070708@telogis.com> +Date: Wed, 31 Aug 2005 10:21:20 +1200 +From: Ralph Mason +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: 'Real' auto vacuum? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/544 +X-Sequence-Number: 14291 + +This is a wild and crazy thought which I am sure is invalid for some +good reason. + +But why can't postgres just vacuum itself as it goes along? + +When a row is orphaned it's added to a list of possibly available rows. +When a new row is needed the list of possible rows is examined and the +first one with a transaction id less then the lowest running transaction +id is chosen to be the new row? These rows can be in a heap so it's +really fast to find one. + +Like magic - no more vacuuming. No more holes for people to fall into. + +Is this an oversimplification of the problem? + +Ralph + +From pgsql-performance-owner@postgresql.org Tue Aug 30 19:45:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A80AD8686 + for ; + Tue, 30 Aug 2005 19:45:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91135-02 + for ; + Tue, 30 Aug 2005 22:45:38 +0000 (GMT) +Received: from mail.envyfinancial.com (unknown [206.248.142.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AEE6D870F + for ; + Tue, 30 Aug 2005 19:45:36 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envyfinancial.com (Postfix) with ESMTP id 5895F1C7A7; + Tue, 30 Aug 2005 18:35:19 -0400 (EDT) +Received: from mail.envyfinancial.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 28101-03; Tue, 30 Aug 2005 18:35:19 -0400 (EDT) +Received: by mail.envyfinancial.com (Postfix, from userid 500) + id 15D581C7CA; Tue, 30 Aug 2005 18:35:19 -0400 (EDT) +Date: Tue, 30 Aug 2005 18:35:19 -0400 +From: mark@mark.mielke.cc +To: Ralph Mason +Cc: pgsql-performance@postgresql.org +Subject: Re: 'Real' auto vacuum? +Message-ID: <20050830223518.GA28168@mark.mielke.cc> +References: <4314DBE0.9070708@telogis.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4314DBE0.9070708@telogis.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envyfinancial.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.205 required=5 tests=[AWL=0.027, NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200508/545 +X-Sequence-Number: 14292 + +On Wed, Aug 31, 2005 at 10:21:20AM +1200, Ralph Mason wrote: +> This is a wild and crazy thought which I am sure is invalid for some +> good reason. +> +> But why can't postgres just vacuum itself as it goes along? +> +> When a row is orphaned it's added to a list of possibly available rows. +> When a new row is needed the list of possible rows is examined and the +> first one with a transaction id less then the lowest running transaction +> id is chosen to be the new row? These rows can be in a heap so it's +> really fast to find one. +> +> Like magic - no more vacuuming. No more holes for people to fall into. + +Yes please. :-) + +> Is this an oversimplification of the problem? + +But, yeah. It's probably not that easy, especially with really big +databases. Where is this free list stored? How efficient is it to keep +track of the lowest running transaction at all times? How does one +synchronize access to this free list, to ensure that processes don't +block up waiting for access to the free list? Is the fre list +journalled to prevent corruption, and the accidental re-use of a still +in use row? And, there would be a cost to scanning this list on every +insert or update. + +As an outsider (like you?) I see the current model as a design flaw as +well. A neat and tidy model on paper. Not so nice in real life. The +need to vacuum in batch mode, to keep the database from dying, seems +intuitively bad. + +I think there must be answers to this problem. Even simple +optimizations, such as defining a table such that any delete or update +within a table, upon commit, will attempt to vacuum just the rows that +should not be considered free for any new transactions. If it's in +use by an active transaction, oh well. It can be picked up by a batch +run of vacuum. If it's free though - let's do it now. + +I think any optimizations we come up with, will be more happily accepted +with a working patch that causes no breakage... :-) + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 19:55:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B422D86EA + for ; + Tue, 30 Aug 2005 19:55:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90789-06 + for ; + Tue, 30 Aug 2005 22:55:10 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id CF932D86D4 + for ; + Tue, 30 Aug 2005 19:55:09 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7998323; Tue, 30 Aug 2005 15:57:29 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: 'Real' auto vacuum? +Date: Tue, 30 Aug 2005 15:58:34 -0700 +User-Agent: KMail/1.8 +Cc: Ralph Mason +References: <4314DBE0.9070708@telogis.com> +In-Reply-To: <4314DBE0.9070708@telogis.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200508301558.34697.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 required=5 tests=[AWL=-0.002, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/546 +X-Sequence-Number: 14293 + +Ralph, + +> When a row is orphaned it's added to a list of possibly available rows. +> When a new row is needed the list of possible rows is examined and the +> first one with a transaction id less then the lowest running transaction +> id is chosen to be the new row? These rows can be in a heap so it's +> really fast to find one. + +This is the long-term plan. However, it's actually a lot harder than it +sounds. Patches welcome. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 30 20:02:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BD931D6E40 + for ; + Tue, 30 Aug 2005 20:02:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94332-03 + for ; + Tue, 30 Aug 2005 23:02:30 +0000 (GMT) +Received: from smtpauth09.mail.atl.earthlink.net + (smtpauth09.mail.atl.earthlink.net [209.86.89.69]) + by svr1.postgresql.org (Postfix) with ESMTP id 56989D8668 + for ; + Tue, 30 Aug 2005 20:02:29 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=FuHj2/mPj6faXiIrgDUtUtwA/RQ4TAL4KmNXJJRYugP0fkNNRFdk+W9JR0pdkcAI; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth09.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1EAF7f-0004sd-Kq; Tue, 30 Aug 2005 19:02:31 -0400 +Message-Id: <6.2.3.4.0.20050830154823.05ac9308@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Tue, 30 Aug 2005 19:02:28 -0400 +To: "Joshua D. Drake" , pgsql-performance@postgresql.org +From: Ron +Subject: Re: RAID Configuration Sugestion +In-Reply-To: <4314B329.20009@commandprompt.com> +References: <431452FD.3090402@atua.com.br> + <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> + <43148FC4.4000407@commandprompt.com> + <6.2.3.4.0.20050830132902.021a5308@pop.earthlink.net> + <4314B329.20009@commandprompt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc5c1988b3457bd03d90ce542a24f176e2350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.406 required=5 tests=[AWL=0.032, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/547 +X-Sequence-Number: 14294 + +At 03:27 PM 8/30/2005, Joshua D. Drake wrote: + + +>>>If you still have the budget, I would suggest considering either +>>>what Ron suggested or possibly using a 4 drive RAID 10 instead. +>> +>> +>>IME, with only 4 HDs, it's usually better to split them them into +>>two RAID 1's (one for the db, one for everything else including the +>>logs) than it is to put everything on one RAID 10. YMMV. +> +>Really? That's interesting. My experience is different, I assume +>SCSI? Software/Hardware Raid? + +The issue exists regardless of technologies used, although the +technology used does affect when things become an irritation or +serious problem. + +The issue with "everything on the same HD set" seems to be that under +light loads anything works reasonably well, but as load increases +contention between DB table access, OS access, and xlog writes can +cause performance problems. + +In particular, _everything_ else hangs while logs are being written +with "everything on the same HD set". Thus leaving you with the +nasty choices of small log writes that cause more seeking behavior, +and the resultant poor overall HD IO performance, or large log writes +that basically freeze the server until they are done. + +Having the logs on a different HD, and if possible different IO bus, +reduces this effect to a minimum and seems to be a better choice than +the "shared everything" approach. + +Although this effect seems largest when there are fewest HDs, the +general pattern is that one should use as many spindles as one can +make use of and that they should be as dedicated as possible in their +purpose(s). That's why the TPC bench marked systems tend to have +literally 100's of HD's and they tend to be split into very focused purposes. + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 20:05:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 295A6D86CE + for ; + Tue, 30 Aug 2005 20:05:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95447-03 + for ; + Tue, 30 Aug 2005 23:05:04 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 826A4D86A6 + for ; + Tue, 30 Aug 2005 20:05:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7UN54nF025547; + Tue, 30 Aug 2005 19:05:04 -0400 (EDT) +To: mark@mark.mielke.cc +Cc: markus@m-bass.com, pgsql-performance@postgresql.org +Subject: Re: When to do a vacuum for highly active table +In-reply-to: <20050830220503.GA27740@mark.mielke.cc> +References: <20050830211356.48138.qmail@web31606.mail.mud.yahoo.com> + <24875.1125437357@sss.pgh.pa.us> + <20050830220503.GA27740@mark.mielke.cc> +Comments: In-reply-to mark@mark.mielke.cc + message dated "Tue, 30 Aug 2005 18:05:03 -0400" +Date: Tue, 30 Aug 2005 19:05:04 -0400 +Message-ID: <25546.1125443104@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/549 +X-Sequence-Number: 14296 + +mark@mark.mielke.cc writes: +> I think he means splitting it vertically, instead of horizontally, and +> it sounds like an excellent idea, if a large enough portion of each +> record is in fact mostly fixed. Otherwise, PostgreSQL is copying data +> multiple times, only to have the data expire as part of a dead row. + +Only up to a point. Fields that are wide enough to get toasted +out-of-line (multiple Kb) do not get physically copied if there's +a row update that doesn't affect them. We don't really have enough +information about his table to guess whether there's any point in +manually partitioning the columns, but my leaning would be "probably +not" --- the overhead in joining the resulting two tables would be +high enough that you'd need a heck of a big improvement to justify it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 30 20:37:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AEECBD867A + for ; + Tue, 30 Aug 2005 20:37:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01375-09 + for ; + Tue, 30 Aug 2005 23:37:14 +0000 (GMT) +Received: from smtp102.biz.mail.mud.yahoo.com (smtp102.biz.mail.mud.yahoo.com + [68.142.200.237]) + by svr1.postgresql.org (Postfix) with SMTP id 4CF14D8653 + for ; + Tue, 30 Aug 2005 20:37:13 -0300 (ADT) +Received: (qmail 38594 invoked from network); 30 Aug 2005 23:37:17 -0000 +Received: from unknown (HELO ?192.168.3.1?) + (ralph.mason@telogis.com@203.98.10.169 with plain) + by smtp102.biz.mail.mud.yahoo.com with SMTP; 30 Aug 2005 23:37:16 -0000 +Message-ID: <4314EE25.30605@telogis.com> +Date: Wed, 31 Aug 2005 11:39:17 +1200 +From: Ralph Mason +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: mark@mark.mielke.cc +Cc: pgsql-performance@postgresql.org +Subject: Re: 'Real' auto vacuum? +References: <4314DBE0.9070708@telogis.com> + <20050830223518.GA28168@mark.mielke.cc> +In-Reply-To: <20050830223518.GA28168@mark.mielke.cc> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/550 +X-Sequence-Number: 14297 + +mark@mark.mielke.cc wrote: + +>But, yeah. It's probably not that easy, especially with really big +>databases. Where is this free list stored? How efficient is it to keep +>track of the lowest running transaction at all times? How does one +>synchronize access to this free list, to ensure that processes don't +>block up waiting for access to the free list? Is the fre list +>journalled to prevent corruption, and the accidental re-use of a still +>in use row? And, there would be a cost to scanning this list on every +>insert or update. +> +> +I suspect the freelist could be stored as an index, and just handily +postgres supports those out of the box. There would be a cost yes, +but then what is the cost of adding pages to the file all the time? I +guess as with all things there is no one size fits all, so perhaps you +could turn it off - although I expect for 99.9% of the cases 'on' would +be the better choice. If it gets broken there is already the reindex +code that can fix it. A coherency / fixing / recover of a table command +would probably be a useful tool anyway. + +>As an outsider (like you?) I see the current model as a design flaw as +>well. A neat and tidy model on paper. Not so nice in real life. The +>need to vacuum in batch mode, to keep the database from dying, seems +>intuitively bad. +> +> +We have a script that vacuums the database every 5 minutes, excessive - +yes, but turns out that any less is no good really. I think that this +is sub optimal, the DB work keeps running, but the vacuum can slow down +other tasks. It also probably flushes data that we would need out of +the page cache so it can look at data that isn't used often as the +vacuum runs. Not the most optimal data access pattern I could imagine. + +>I think there must be answers to this problem. Even simple +>optimizations, such as defining a table such that any delete or update +>within a table, upon commit, will attempt to vacuum just the rows that +>should not be considered free for any new transactions. If it's in +>use by an active transaction, oh well. It can be picked up by a batch +>run of vacuum. If it's free though - let's do it now. +> +> +Anything would be good - I think it's the achilles heel of postgres. +Perhaps there is something simple like that could fix 95% of the problem. + +>I think any optimizations we come up with, will be more happily accepted +>with a working patch that causes no breakage... :-) +> +> +> +I am sure they would. + +Cheers +Ralph + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 21:04:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9188CD86AE + for ; + Tue, 30 Aug 2005 21:04:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08824-05 + for ; + Wed, 31 Aug 2005 00:04:42 +0000 (GMT) +Received: from vms040pub.verizon.net (vms040pub.verizon.net [206.46.252.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 4CA3FD86A9 + for ; + Tue, 30 Aug 2005 21:04:41 -0300 (ADT) +Received: from osgiliath.mathom.us ([151.200.14.55]) + by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2-2.05 + (built Apr + 28 2005)) with ESMTPA id <0IM200H6487V0US1@vms040.mailsrvcs.net> for + pgsql-performance@postgresql.org; Tue, 30 Aug 2005 19:04:44 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 7601260043E for + ; + Tue, 30 Aug 2005 20:04:43 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 11456-04-2 for ; Tue, + 30 Aug 2005 20:04:43 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 3B11D60041D; Tue, 30 Aug 2005 20:04:43 -0400 (EDT) +Date: Tue, 30 Aug 2005 20:04:43 -0400 +From: Michael Stone +Subject: Re: RAID Configuration Sugestion +In-reply-to: <6.2.3.4.0.20050830154823.05ac9308@pop.earthlink.net> +To: pgsql-performance@postgresql.org +Mail-Followup-To: pgsql-performance@postgresql.org +Message-id: <20050831000443.GZ14921@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <431452FD.3090402@atua.com.br> + <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> + <43148FC4.4000407@commandprompt.com> + <6.2.3.4.0.20050830132902.021a5308@pop.earthlink.net> + <4314B329.20009@commandprompt.com> + <6.2.3.4.0.20050830154823.05ac9308@pop.earthlink.net> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.04 required=5 tests=[AWL=-0.010, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/551 +X-Sequence-Number: 14298 + +On Tue, Aug 30, 2005 at 07:02:28PM -0400, Ron wrote: +>purpose(s). That's why the TPC bench marked systems tend to have +>literally 100's of HD's and they tend to be split into very focused +>purposes. + +Of course, TPC benchmark systems are constructed such that cost and +storage capacity are irrelevant--in the real world things tend to be +more complicated. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Tue Aug 30 21:41:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 19519D845F + for ; + Tue, 30 Aug 2005 21:41:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20568-02 + for ; + Wed, 31 Aug 2005 00:41:42 +0000 (GMT) +Received: from smtpauth03.mail.atl.earthlink.net + (smtpauth03.mail.atl.earthlink.net [209.86.89.63]) + by svr1.postgresql.org (Postfix) with ESMTP id AC623D7BC4 + for ; + Tue, 30 Aug 2005 21:41:40 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=X8m3ogjwA7itRKelI5VyL92f5h5qmM8mIOlCL4KglD13uFb/EVDxP52TxTxpyYRQ; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth03.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1EAGfg-0005Kj-1H; Tue, 30 Aug 2005 20:41:44 -0400 +Message-Id: <6.2.3.4.0.20050830203126.0221feb8@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Tue, 30 Aug 2005 20:41:40 -0400 +To: Michael Stone , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: RAID Configuration Sugestion +In-Reply-To: <20050831000443.GZ14921@mathom.us> +References: <431452FD.3090402@atua.com.br> + <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> + <43148FC4.4000407@commandprompt.com> + <6.2.3.4.0.20050830132902.021a5308@pop.earthlink.net> + <4314B329.20009@commandprompt.com> + <6.2.3.4.0.20050830154823.05ac9308@pop.earthlink.net> + <20050831000443.GZ14921@mathom.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc44d7f6b7cee5b1b2aad82a9aecd5c5ff350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.4 required=5 tests=[AWL=0.026, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/552 +X-Sequence-Number: 14299 + +At 08:04 PM 8/30/2005, Michael Stone wrote: +>On Tue, Aug 30, 2005 at 07:02:28PM -0400, Ron wrote: +>>purpose(s). That's why the TPC bench marked systems tend to have +>>literally 100's of HD's and they tend to be split into very focused purposes. +> +>Of course, TPC benchmark systems are constructed such that cost and +>storage capacity are irrelevant--in the real world things tend to be +>more complicated. + +The scary thing is that I've worked on RW production systems that +bore a striking resemblance to a TPC benchmark system. As you can +imagine, they uniformly belonged to BIG organizations (read: lot's 'o +$$$) who were using the systems for mission critical stuff where +either it was company existence threatening for the system to be +done, or they would lose much $$$ per min of down time, or both. + +Financial institutions, insurance companies, central data mines for +Fortune 2000 companies, etc _all_ build systems that push the state +of the art in how much storage can be managed and how many HDs, CPUs, +RAM DIMMs, etc are usable. + +Historically, this has been the sole province of Oracle and DB2 on +the SW side and equally outrageously priced custom HW. Clearly, I'd +like to see PostgreSQL change that ;-) + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Tue Aug 30 21:43:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D6954D6E40 + for ; + Tue, 30 Aug 2005 21:43:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19136-06 + for ; + Wed, 31 Aug 2005 00:43:35 +0000 (GMT) +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by svr1.postgresql.org (Postfix) with ESMTP id D9C37D86BE + for ; + Tue, 30 Aug 2005 21:43:33 -0300 (ADT) +Received: from osgiliath.mathom.us ([151.200.14.55]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-2.05 + (built Apr + 28 2005)) with ESMTPA id <0IM200HZ7A0LHJM1@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Tue, 30 Aug 2005 19:43:37 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 802FF600652; Tue, + 30 Aug 2005 20:43:32 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 12171-04-5; Tue, 30 Aug 2005 20:43:32 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 5185D60041D; Tue, 30 Aug 2005 20:43:32 -0400 (EDT) +Date: Tue, 30 Aug 2005 20:43:32 -0400 +From: Michael Stone +Subject: Re: RAID Configuration Sugestion +In-reply-to: <6.2.3.4.0.20050830203126.0221feb8@pop.earthlink.net> +To: Ron +Cc: Michael Stone , + pgsql-performance@postgresql.org +Mail-Followup-To: Ron , + Michael Stone , + pgsql-performance@postgresql.org +Message-id: <20050831004332.GA14921@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us +References: <431452FD.3090402@atua.com.br> + <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> + <43148FC4.4000407@commandprompt.com> + <6.2.3.4.0.20050830132902.021a5308@pop.earthlink.net> + <4314B329.20009@commandprompt.com> + <6.2.3.4.0.20050830154823.05ac9308@pop.earthlink.net> + <20050831000443.GZ14921@mathom.us> + <6.2.3.4.0.20050830203126.0221feb8@pop.earthlink.net> +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.039 required=5 tests=[AWL=-0.011, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/553 +X-Sequence-Number: 14300 + +On Tue, Aug 30, 2005 at 08:41:40PM -0400, Ron wrote: +>The scary thing is that I've worked on RW production systems that +>bore a striking resemblance to a TPC benchmark system. As you can +>imagine, they uniformly belonged to BIG organizations (read: lot's 'o +>$$$) who were using the systems for mission critical stuff where +>either it was company existence threatening for the system to be +>done, or they would lose much $$$ per min of down time, or both. + +Yeah, and that market is relevant to someone with one dell server and 2 +hard disks how? + +Mike Stone + +From pgsql-performance-owner@postgresql.org Tue Aug 30 23:51:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AD4E4D6EBA + for ; + Tue, 30 Aug 2005 23:51:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50664-10 + for ; + Wed, 31 Aug 2005 02:50:57 +0000 (GMT) +Received: from smtpauth06.mail.atl.earthlink.net + (smtpauth06.mail.atl.earthlink.net [209.86.89.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 80148D6E65 + for ; + Tue, 30 Aug 2005 23:50:55 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=LIZrgEQ1vh0PGzpk3LTad4UNC+uPiBZXUg+sGJB8YD0ZW+bTncjHcy5dBAFQrVfz; + h=Received:Message-Id:X-Mailer:Date:To:From:Subject:In-Reply-To:References:Mime-Version:Content-Type:X-ELNK-Trace:X-Originating-IP; +Received: from [24.41.3.216] (helo=RJP-01.earthlink.net) + by smtpauth06.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1EAIgm-0008PZ-CI; Tue, 30 Aug 2005 22:51:00 -0400 +Message-Id: <6.2.3.4.0.20050830224550.05ac9828@pop.earthlink.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 +Date: Tue, 30 Aug 2005 22:50:57 -0400 +To: Michael Stone , + pgsql-performance@postgresql.org +From: Ron +Subject: Re: RAID Configuration Sugestion +In-Reply-To: <20050831004332.GA14921@mathom.us> +References: <431452FD.3090402@atua.com.br> + <6.2.3.4.0.20050830103240.0219b640@pop.earthlink.net> + <43148FC4.4000407@commandprompt.com> + <6.2.3.4.0.20050830132902.021a5308@pop.earthlink.net> + <4314B329.20009@commandprompt.com> + <6.2.3.4.0.20050830154823.05ac9308@pop.earthlink.net> + <20050831000443.GZ14921@mathom.us> + <6.2.3.4.0.20050830203126.0221feb8@pop.earthlink.net> + <20050831004332.GA14921@mathom.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc05468f44d6420521445079c5f3598995350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 24.41.3.216 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.395 required=5 tests=[AWL=0.021, + DNS_FROM_RFC_ABUSE=0.374] +X-Spam-Level: +X-Archive-Number: 200508/554 +X-Sequence-Number: 14301 + +At 08:43 PM 8/30/2005, Michael Stone wrote: +>On Tue, Aug 30, 2005 at 08:41:40PM -0400, Ron wrote: +>>The scary thing is that I've worked on RW production systems that +>>bore a striking resemblance to a TPC benchmark system. As you can +>>imagine, they uniformly belonged to BIG organizations (read: lot's +>>'o $$$) who were using the systems for mission critical stuff where +>>either it was company existence threatening for the system to be +>>done, or they would lose much $$$ per min of down time, or both. +> +>Yeah, and that market is relevant to someone with one dell server +>and 2 hard disks how? +Because successful small companies that _start_ with one small server +and 2 HDs grow to _become_ companies that need far more HW; ...and in +the perfect world their SW scales to their increased needs... + +_Without_ exponentially increasing their costs or overhead (as Oracle +and DB2 currently do) + +THIS is the real long term promise of OS DBMS. + +Ron Peacetree + + + +From pgsql-performance-owner@postgresql.org Wed Aug 31 02:18:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EF206D880E + for ; + Wed, 31 Aug 2005 02:18:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99800-07 + for ; + Wed, 31 Aug 2005 05:17:58 +0000 (GMT) +Received: from calypso.bi.lt (calypso.bi.lt [213.226.153.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 087BCD8831 + for ; + Wed, 31 Aug 2005 02:17:54 -0300 (ADT) +Received: by calypso.bi.lt (Postfix, from userid 101) + id E7E9C48054F; Wed, 31 Aug 2005 08:17:53 +0300 (EEST) +X-Original-To: pgsql-performance@postgresql.org +Received: from B027543 (inet.bee.lt [213.226.131.30]) + by calypso.bi.lt (Postfix) with SMTP id D60F94804CC + for ; + Wed, 31 Aug 2005 08:17:53 +0300 (EEST) +Message-ID: <00f601c5adeb$56fcb910$f20214ac@bite.lt> +From: "Mindaugas Riauba" +To: +References: <4314DBE0.9070708@telogis.com> + <200508301558.34697.josh@agliodbs.com> +Subject: Re: 'Real' auto vacuum? +Date: Wed, 31 Aug 2005 08:17:53 +0300 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="ISO-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.09 required=5 tests=[AWL=0.090] +X-Spam-Level: +X-Archive-Number: 200508/555 +X-Sequence-Number: 14302 + + +> > When a row is orphaned it's added to a list of possibly available rows. +> > When a new row is needed the list of possible rows is examined and the +> > first one with a transaction id less then the lowest running transaction +> > id is chosen to be the new row? These rows can be in a heap so it's +> > really fast to find one. +> +> This is the long-term plan. However, it's actually a lot harder than it +> sounds. Patches welcome. + + Some ETA? Since that would be the most welcome addition for us. We +have few very heavily updated databases where table bloat and constant +vacuuming is killing performance. + + Mindaugas + + +From pgsql-performance-owner@postgresql.org Tue Sep 6 00:46:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 10F6AD834F + for ; + Wed, 31 Aug 2005 07:22:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85447-05 + for ; + Wed, 31 Aug 2005 10:22:47 +0000 (GMT) +Received: from vey.eyjar.is (vey.eyjar.is [194.144.184.1]) + by svr1.postgresql.org (Postfix) with ESMTP id A9EBFD8347 + for ; + Wed, 31 Aug 2005 07:22:45 -0300 (ADT) +Received: from www.eyjar.is (localhost [127.0.0.1]) + by vey.eyjar.is (8.12.9-20030918-gdh-p1/8.12.9) with SMTP id + j7VAMhUO020800; Wed, 31 Aug 2005 10:22:44 GMT +Received: from 213.220.100.208 (SquirrelMail authenticated user gdh) + by www.eyjar.is with HTTP; Wed, 31 Aug 2005 10:22:44 -0000 (GMT) +Message-ID: <1913.213.220.100.208.1125483764.squirrel@www.eyjar.is> +Date: Wed, 31 Aug 2005 10:22:44 -0000 (GMT) +Subject: Query slow after VACUUM ANALYZE +From: gdh@eyjar.is +To: pgsql-performance@postgresql.org +Cc: gdh@eyjar.is +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-Spam-Search-By: milter1.eyjar.is +X-Spam-Search-Via: spamass-milter 0.5pre3 +X-Spam-DCC: SIHOPE-DCC-3: milter1.eyjar.is 1085; Body=1 Fuz1=1 Fuz2=1 +X-Virus-Scanned: by AMaViS - amavis-milter (http://www.amavis.org/) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200509/73 +X-Sequence-Number: 14381 + +Hi all + +I'm having a strange problem with a query which looks like this: + +SELECT id FROM orders WHERE id NOT IN (SELECT order_id FROM orders_items); + +The id fields are varchars (32), both indexed. The number of rows in the +tables are about 60000. + +Now, the really strange part is if I delete all data from orders_items, +run VACUUM ANALYZE, then import all the data, the query finshes in about 3 +seconds. Then I run VACUUM ANALYZE, and *after* the vacuum, the query +takes +about 30 minutes to run. The data is the same and this is the only query +running, and the machine load is effectively none. + +EXPLAIN'ng the query shows, before VACUUM ANALYZE, shows this: + + QUERY PLAN +------------------------------------------------------------------------- + Seq Scan on orders (cost=0.00..12184.14 rows=29526 width=33) + Filter: (NOT (hashed subplan)) + SubPlan + -> Seq Scan on orders_items (cost=0.00..0.00 rows=1 width=33) + +After the vacuum, the plan is like this: + + QUERY PLAN +-------------------------------------------------------------------------------- + Seq Scan on fsi_orders (cost=0.00..40141767.46 rows=29526 width=33) + Filter: (NOT (subplan)) + SubPlan + -> Seq Scan on fsi_orders_items (cost=0.00..1208.12 rows=60412 +width=33) + + +Any ideas what I can do to make the query running in < 10 seconds? + +Thanks, +Gu�mundur. + +From pgsql-performance-owner@postgresql.org Tue Sep 6 01:02:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 762C4D8373 + for ; + Wed, 31 Aug 2005 07:26:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84495-07 + for ; + Wed, 31 Aug 2005 10:26:24 +0000 (GMT) +Received: from vey.eyjar.is (vey.eyjar.is [194.144.184.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CBB5D8368 + for ; + Wed, 31 Aug 2005 07:26:23 -0300 (ADT) +Received: from www.eyjar.is (localhost [127.0.0.1]) + by vey.eyjar.is (8.12.9-20030918-gdh-p1/8.12.9) with SMTP id + j7VAQMUO021308; Wed, 31 Aug 2005 10:26:22 GMT +Received: from 213.220.100.208 (SquirrelMail authenticated user gdh) + by www.eyjar.is with HTTP; Wed, 31 Aug 2005 10:26:22 -0000 (GMT) +Message-ID: <1923.213.220.100.208.1125483982.squirrel@www.eyjar.is> +In-Reply-To: <1913.213.220.100.208.1125483764.squirrel@www.eyjar.is> +References: <1913.213.220.100.208.1125483764.squirrel@www.eyjar.is> +Date: Wed, 31 Aug 2005 10:26:22 -0000 (GMT) +Subject: Re: Query slow after VACUUM ANALYZE +From: gdh@eyjar.is +To: gdh@eyjar.is +Cc: pgsql-performance@postgresql.org, gdh@eyjar.is +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-Spam-Search-By: milter1.eyjar.is +X-Spam-Search-Via: spamass-milter 0.5pre3 +X-Spam-DCC: NIET: milter1.eyjar.is 1080; Body=1 Fuz1=1 Fuz2=1 +X-Virus-Scanned: by AMaViS - amavis-milter (http://www.amavis.org/) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 required=5 tests=[NO_REAL_NAME=0.178] +X-Spam-Level: +X-Archive-Number: 200509/78 +X-Sequence-Number: 14386 + +Hi again + +[..] + +> +> QUERY PLAN +> ------------------------------------------------------------------------- +> Seq Scan on orders (cost=0.00..12184.14 rows=29526 width=33) +> Filter: (NOT (hashed subplan)) +> SubPlan +> -> Seq Scan on orders_items (cost=0.00..0.00 rows=1 width=33) +> +> After the vacuum, the plan is like this: +> +> QUERY PLAN +> -------------------------------------------------------------------------------- +> Seq Scan on fsi_orders (cost=0.00..40141767.46 rows=29526 width=33) +> Filter: (NOT (subplan)) +> SubPlan +> -> Seq Scan on fsi_orders_items (cost=0.00..1208.12 rows=60412 +> width=33) +> + +This, of course, should be "orders", not "fsi_orders", and "orders_items", +not "fsi_orders_items". Sorry for the confusion. + +Additional info: I'm running PostgreSQL 7.4.8. + +Thanks, +Gu�mundur. + + +From pgsql-performance-owner@postgresql.org Wed Aug 31 10:51:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EF52D8527 + for ; + Wed, 31 Aug 2005 10:51:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46809-09 + for ; + Wed, 31 Aug 2005 13:51:40 +0000 (GMT) +Received: from mail.libertyrms.com (unknown [207.219.45.62]) + by svr1.postgresql.org (Postfix) with ESMTP id 872D6D8509 + for ; + Wed, 31 Aug 2005 10:51:38 -0300 (ADT) +Received: from dba5.int.libertyrms.com ([10.1.3.44]) + by mail.libertyrms.com with esmtp (Exim 4.22) id 1EAT0B-0005xV-Ej + for pgsql-performance@postgresql.org; Wed, 31 Aug 2005 09:51:43 -0400 +Message-ID: <4315B5EF.5020509@ca.afilias.info> +Date: Wed, 31 Aug 2005 09:51:43 -0400 +From: Brad Nicholson +User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: 'Real' auto vacuum? +References: <4314DBE0.9070708@telogis.com> + <200508301558.34697.josh@agliodbs.com> + <00f601c5adeb$56fcb910$f20214ac@bite.lt> +In-Reply-To: <00f601c5adeb$56fcb910$f20214ac@bite.lt> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-SA-Exim-Mail-From: bnichols@ca.afilias.info +X-SA-Exim-Scanned: No; SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.311 required=5 tests=[AWL=-0.220, + FORGED_RCVD_HELO=0.05, INFO_TLD=0.481] +X-Spam-Level: +X-Archive-Number: 200508/556 +X-Sequence-Number: 14303 + +Mindaugas Riauba wrote: + +>>>When a row is orphaned it's added to a list of possibly available rows. +>>>When a new row is needed the list of possible rows is examined and the +>>>first one with a transaction id less then the lowest running transaction +>>>id is chosen to be the new row? These rows can be in a heap so it's +>>>really fast to find one. +>>> +>>> +>>This is the long-term plan. However, it's actually a lot harder than it +>>sounds. Patches welcome. +>> +>> +> +> Some ETA? Since that would be the most welcome addition for us. We +>have few very heavily updated databases where table bloat and constant +>vacuuming is killing performance. +> +> +> +How often are you vacuuming (the definition of 'constantly' tends to +vary)? Are you vacuuming the whole database each time? If so, identify +which tables are being updated frequently, and vacuum those often. +Vacuum other tables less frequently. + +Also, are you you using VACUUM FULL (if so, you certainly don't want to be). + +-- +Brad Nicholson 416-673-4106 bnichols@ca.afilias.info +Database Administrator, Afilias Canada Corp. + + + +From pgsql-performance-owner@postgresql.org Wed Aug 31 15:25:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B389FD852F + for ; + Wed, 31 Aug 2005 15:25:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10680-06 + for ; + Wed, 31 Aug 2005 18:25:16 +0000 (GMT) +Received: from web53209.mail.yahoo.com (web53209.mail.yahoo.com + [206.190.49.79]) + by svr1.postgresql.org (Postfix) with SMTP id 2B811D842B + for ; + Wed, 31 Aug 2005 15:25:15 -0300 (ADT) +Received: (qmail 89933 invoked by uid 60001); 31 Aug 2005 18:25:15 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=F1lwtU6uvUNLkADAkLvTSFq+O50g8f5T6ynl8XBGWFyPh8fLJ1hx7R1Q5GK+0Jxw4XmLgBy1swoGRyBw9y8U6hhgsDiuoD4APiVjTqo9md6zsfTcqwTEAakyhMFmtXByKSY0Lx9nwZw04Gp8H6yh3acsa4gjdqki584Ue3ENec0= + ; +Message-ID: <20050831182515.89931.qmail@web53209.mail.yahoo.com> +Received: from [201.24.119.165] by web53209.mail.yahoo.com via HTTP; + Wed, 31 Aug 2005 15:25:15 ART +Date: Wed, 31 Aug 2005 15:25:15 -0300 (ART) +From: Carlos Henrique Reimer +Subject: Swapping +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-353803500-1125512715=:87763" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.596 required=5 tests=[AWL=0.165, + DNS_FROM_RFC_ABUSE=0.374, HTML_30_40=0.056, HTML_MESSAGE=0.001] +X-Spam-Level: +X-Archive-Number: 200508/557 +X-Sequence-Number: 14304 + +--0-353803500-1125512715=:87763 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi, + +I�m trying to tune a linux box with a 12 GB database and 4 GB RAM. First of all I would like to stop the swapping, so the shared_buffers and sort_mem were decreased but even so it started swapping two hours after DBMS started up. + +I would like to know some suggestions how to discover why is it swapping? + +I�ve collected the following data from the environment and saved at http://paginas.terra.com.br/educacao/rei/dados.htm + +1. select version() +2. uname -a +3. cat /proc/cpuinfo +4. cat /proc/meminfo +5. vmstat 5 +6. pg_stat_activity +7. postgresql.conf + +Thanks in advance! + +Reimer + + +__________________________________________________ +Converse com seus amigos em tempo real com o Yahoo! Messenger +http://br.download.yahoo.com/messenger/ +--0-353803500-1125512715=:87763 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +
+
Hi,
+
 
+
I�m trying to tune a linux box with a 12 GB database and 4 GB RAM. First of all I would like to stop the swapping, so the shared_buffers and sort_mem were decreased but even so it started swapping two hours after DBMS started up.
+
 
+
I would like to know some suggestions how to discover why is it swapping?
+
 
+
I�ve collected the following data from the environment and saved at http://paginas.terra.com.br/educacao/rei/dados.htm
+
 
+
1. select version()
+
2. uname -a
+
3. cat /proc/cpuinfo
+
4. cat /proc/meminfo
+
5. vmstat 5
+
6. pg_stat_activity
+
7. postgresql.conf
+
 
+
Thanks in advance!
+
 
+
Reimer

__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger
http://br.download.yahoo.com/messenger/ +--0-353803500-1125512715=:87763-- + +From pgsql-performance-owner@postgresql.org Wed Aug 31 15:49:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A578FD79BC + for ; + Wed, 31 Aug 2005 15:49:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16548-06 + for ; + Wed, 31 Aug 2005 18:49:18 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B7424D7708 + for ; + Wed, 31 Aug 2005 15:49:17 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7VInIZJ003610; + Wed, 31 Aug 2005 14:49:18 -0400 (EDT) +To: Carlos Henrique Reimer +Cc: pgsql-performance@postgresql.org +Subject: Re: Swapping +In-reply-to: <20050831182515.89931.qmail@web53209.mail.yahoo.com> +References: <20050831182515.89931.qmail@web53209.mail.yahoo.com> +Comments: In-reply-to Carlos Henrique Reimer + message dated "Wed, 31 Aug 2005 15:25:15 -0300" +Date: Wed, 31 Aug 2005 14:49:18 -0400 +Message-ID: <3609.1125514158@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] +X-Spam-Level: +X-Archive-Number: 200508/558 +X-Sequence-Number: 14305 + +Carlos Henrique Reimer writes: +> I would like to know some suggestions how to discover why is it swapping? + +Zero swap-in rate and swap-out rates in the single digits do not +constitute a swapping problem. It's reasonably likely that that +traffic isn't even coming from Postgres, but something else. +I'd say ignore it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 31 16:17:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 18F4ED8760 + for ; + Wed, 31 Aug 2005 16:17:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20036-09 + for ; + Wed, 31 Aug 2005 19:17:39 +0000 (GMT) +Received: from neutron.verseon.com (adsl-63-204-199-153.dsl.snfc21.pacbell.net + [63.204.199.153]) + by svr1.postgresql.org (Postfix) with ESMTP id E4232D8749 + for ; + Wed, 31 Aug 2005 16:17:37 -0300 (ADT) +content-class: urn:content-classes:message +Subject: Big question on insert performance/using COPY FROM +Date: Wed, 31 Aug 2005 12:17:38 -0700 +Message-ID: <08B420FF5BF7BC42A064212C2EB768801C10BE@neutron.verseon.com> +X-MS-Has-Attach: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MS-TNEF-Correlator: +Thread-Topic: Big question on insert performance/using COPY FROM +Thread-Index: AcWuYKag40d30iTBS4Gf8Alpk4yOrg== +X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 +From: "Morgan Kita" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 required=5 tests=[AWL=-0.000, + FORGED_RCVD_HELO=0.05] +X-Spam-Level: +X-Archive-Number: 200508/559 +X-Sequence-Number: 14306 + +Hi, + +I am currently trying to speed up the insertion of bulk loads to my = +database. I have fiddled with all of the parameters that I have seen = +suggested(aka checkpoint_segments, checkpoint_timeout, = +maintinence_work_mem, and shared buffers) with no success. I even turned = +off fysnc with no effect so I am pretty sure the biggest problem is that = +the DB is CPU limited at the moment because of the rather weak machine = +that postmaster is running on(Athlon 2400+ xp with 512 RAM), but that = +will change in the future so I am trying to get performance increases = +that don't involve changing the machine at the moment. + +I am currently inserting into the database through lipqxx's C++ = +interface. I am using prepared statements that perform regular inserts. = +I would like to use COPY FROM since I have read so much about its = +increased performance with respect to INSERT, but I am not sure how to = +use it in my case. So let me give you an idea on how the tables are laid = +out.=20 + +The real DB has more tables, but lets say for the sake of argument I = +have 3 tables; TB1, TB2, TB3. Lets say that TB1 has a primary key PK1 = +and a unique identifier column(type text) UK1 that has an index on it. = +TB2 then has a PK2, a UK2(type text) of its own with an index, and a = +foreign key FK2 that points to TB1's PK1. TB3 has a PK3 and a FK3 that = +points to FK2.=20 +TB1 TB2 TB3 +-------------- ------------------------------- = +---------------------- +PK1, UK1 PK2, UK2, FK2(PK1) PK3, FK3(PK2) + +Now in lipqxx I am parsing an input list of objects that are then = +written to these tables. Each object may produce one row in TB1, one row = +in TB2, and one row in TB3. The UK1 and UK2 indentifiers are used to = +prevent duplicate entries for TB1 and TB2 respectively. I know COPY FROM = +obeys these unique checks; however, my problem is the FKs. So lets say I = +try to insert a row into TB1. If it is unique on UK1 then it inserts a = +new row with some new primary key int4 identifier and if it is a = +duplicate then no insert is done but the already existing row's primary = +key identifier is returned. This identifier(duplicate or not) is used = +when populating TB2's row as the FK2 identifier. The row that is to be = +inserted into TB2 needs the primary key indentifier from the result of = +the attempted insert into TB1. Similarily the insert into TB3 needs the = +result of the pk indentifier of the attempted insert into TB2. Once that = +is done then I move on to parsing the next object for insertion into the = +3 tables. + +So lets say I want to insert a list of objects using COPY FROM... whats = +the way to do it? How can I at the very least get a list of the primary = +keys of TB1(newly inserted rows or from already existings row) returned = +from the COPY FROM insert into TB1 so I can use them for the COPY FROM = +insert into TB2 and so on? Is there a better way to do this? + +P.S. I am going to setup autovacuum for these bulk loads. My question = +though is why for bulkloads is VACUUM useful? I understand that it frees = +up dead rows as a result of UPDATE and such, but where are the dead rows = +created from plain INSERTS? + +Thanks, +Morgan + +From pgsql-performance-owner@postgresql.org Wed Aug 31 16:28:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FCB3D8760 + for ; + Wed, 31 Aug 2005 16:22:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21977-10 + for ; + Wed, 31 Aug 2005 19:22:31 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 064C0D8754 + for ; + Wed, 31 Aug 2005 16:22:29 -0300 (ADT) +Received: from [80.203.125.83] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1EAY7X-0004R0-Bp; Wed, 31 Aug 2005 21:19:49 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id 2466AAAEA; Wed, 31 Aug 2005 21:22:17 +0200 (CEST) +Date: Wed, 31 Aug 2005 21:22:17 +0200 +From: Tobias Brox +To: Carlos Henrique Reimer +Cc: pgsql-performance@postgresql.org +Subject: Re: Swapping +Message-ID: <20050831192217.GC5736@tobias.lan> +References: <20050831182515.89931.qmail@web53209.mail.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +In-Reply-To: <20050831182515.89931.qmail@web53209.mail.yahoo.com> +Organization: Group Nordicbet +User-Agent: Mutt/1.5.10i +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/560 +X-Sequence-Number: 14307 + +[Carlos Henrique Reimer - Wed at 03:25:15PM -0300] +> I=B4m trying to tune a linux box with a 12 GB database and 4 GB RAM. Fi= +rst +> of all I would like to stop the swapping, so the shared_buffers and sor= +t_mem +> were decreased but even so it started swapping two hours after DBMS sta= +rted +> up. +> =20 +> I would like to know some suggestions how to discover why is it swappin= +g? + +I agree with Tom Lane, nothing to worry about. Swapping is not a problem +per se, aggressive swapping is a problem. If you are absolutely sure you +want to ban all swapping, use "swapoff"? + +I'd trust linux to handle swap/cache sensibly. Eventually, become involv= +ed +with kernel hacking ;-) + +--=20 +Notice of Confidentiality: This email is sent unencrypted over the networ= +k, +and may be stored on several email servers; it can be read by third parti= +es +as easy as a postcard. Do not rely on email for confidential information= +. + +From pgsql-performance-owner@postgresql.org Wed Aug 31 17:37:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4BEE4D8695 + for ; + Wed, 31 Aug 2005 16:33:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26357-02 + for ; + Wed, 31 Aug 2005 19:33:35 +0000 (GMT) +Received: from mail.nordicbet.com (mail.nordicbet.com [193.69.167.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C949D84B4 + for ; + Wed, 31 Aug 2005 16:33:32 -0300 (ADT) +Received: from [80.203.125.83] (helo=tobias.nordicbet.invalid) + (Authenticated Sender=tobias@nordicbet.com) + by mail.nordicbet.com with esmtpa (Exim 4.50 #1 (Debian)) + id 1EAYIJ-0004y4-0k; Wed, 31 Aug 2005 21:30:56 +0200 +Received: by tobias.nordicbet.invalid (Postfix, from userid 500) + id 76AC5AAEA; Wed, 31 Aug 2005 21:33:17 +0200 (CEST) +Date: Wed, 31 Aug 2005 21:33:17 +0200 +From: Tobias Brox +To: Tobias Brox +Cc: Carlos Henrique Reimer , + pgsql-performance@postgresql.org +Subject: Re: Swapping +Message-ID: <20050831193317.GD5736@tobias.lan> +References: <20050831182515.89931.qmail@web53209.mail.yahoo.com> + <20050831192217.GC5736@tobias.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050831192217.GC5736@tobias.lan> +Organization: Group Nordicbet +User-Agent: Mutt/1.5.10i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 required=5 tests=[none] +X-Spam-Level: +X-Archive-Number: 200508/561 +X-Sequence-Number: 14308 + +[Tobias Brox - Wed at 09:22:17PM +0200] +> I'd trust linux to handle swap/cache sensibly. Eventually, become involved +> with kernel hacking ;-) + +Of course, there are also some files in /proc/sys/vm that you may want to +peek into, for tuning the swapping. Particularly, at later 2.6-kernels (I'm +running 2.6.12) you have the file /proc/sys/vm/swappiness, where the number +should be some percentage. I'm not completely sure how it works, but I +suppose that the higher you set it, the more likely it is to swap out +memory not beeing used. I think the default setting is probably sane, but +you may want to google a bit about it. + +-- +Notice of Confidentiality: This email is sent unencrypted over the network, +and may be stored on several email servers; it can be read by third parties +as easy as a postcard. Do not rely on email for confidential information. +