diff --git "a/pgsql-performance.200410" "b/pgsql-performance.200410" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200410" @@ -0,0 +1,47788 @@ +From pgsql-performance-owner@postgresql.org Fri Oct 1 06:46:28 2004 +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 0721732A2B4 + for ; + Fri, 1 Oct 2004 06:46:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61130-09 + for ; + Fri, 1 Oct 2004 05:46:24 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id DAF7032A29B + for ; + Fri, 1 Oct 2004 06:46:23 +0100 (BST) +Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk + [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP + id C6DBFA36F8; Fri, 1 Oct 2004 06:46:21 +0100 (BST) +Message-ID: <415CEE8E.8060805@ymogen.net> +Date: Fri, 01 Oct 2004 06:43:42 +0100 +From: Matt Clark +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Jim C. Nasby" +Cc: Postgresql Performance +Subject: Re: Caching of Queries +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <1096306670.40463.173.camel@jester> <41587867.4090505@ymogen.net> + <20040930221107.GP1297@decibel.org> +In-Reply-To: <20040930221107.GP1297@decibel.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/1 +X-Sequence-Number: 8477 + + +>If you're not using a connection pool of some kind then you might as +>well forget query plan caching, because your connect overhead will swamp +>the planning cost. This does not mean you have to use something like +>pgpool (which makes some rather questionable claims IMO); any decent web +>application language/environment will support connection pooling. +> +> +Hmm, a question of definition - there's a difference between a pool and +a persistent connection. Pretty much all web apps have one connection +per process, which is persistent (i.e. not dropped and remade for each +request), but not shared between processes, therefore not pooled. + +From pgsql-performance-owner@postgresql.org Fri Oct 1 07:31:08 2004 +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 C9E6932A3A0 + for ; + Fri, 1 Oct 2004 07:31:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73673-01 + for ; + Fri, 1 Oct 2004 06:31:03 +0000 (GMT) +Received: from purple.west.spy.net (mail.west.spy.net [66.149.231.226]) + by svr1.postgresql.org (Postfix) with ESMTP id A8AFC32A2D2 + for ; + Fri, 1 Oct 2004 07:30:58 +0100 (BST) +Received: from [192.168.1.50] (dustinti.west.spy.net [192.168.1.50]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (Client did not present a certificate) + by purple.west.spy.net (Postfix) with ESMTP id 4B62D5E + for ; + Thu, 30 Sep 2004 23:38:13 -0700 (PDT) +Mime-Version: 1.0 (Apple Message framework v619) +Content-Transfer-Encoding: 7bit +Message-Id: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> +Content-Type: text/plain; charset=US-ASCII; format=flowed +To: pgsql-performance@postgresql.org +From: Dustin Sallings +Subject: inconsistent/weird index usage +Date: Thu, 30 Sep 2004 23:30:49 -0700 +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/2 +X-Sequence-Number: 8478 + + + To save some time, let me start by saying + +PostgreSQL 7.4.3 on powerpc-apple-darwin7.4.0, compiled by GCC gcc +(GCC) 3.3 20030304 (Apple Computer, Inc. build 1640) + + OK, now on to details... + + I'm trying to implement oracle style ``partitions'' in postgres. I've +run into my first snag on what should be a fairly quick query. +Basically, I started with the following schema and split the +``samples'' table into one table for each year (1999-2004). + + +-- BEGIN SCHEMA + +create table sensor_types ( + sensor_type_id serial, + sensor_type text not null, + units varchar(10) not null, + primary key(sensor_type_id) +); + +create table sensors ( + sensor_id serial, + sensor_type_id integer not null, + serial char(16) not null, + name text not null, + low smallint not null, + high smallint not null, + active boolean default true, + primary key(sensor_id), + foreign key(sensor_type_id) references sensor_types(sensor_type_id) +); +create unique index sensors_byserial on sensors(serial); + +create table samples ( + ts datetime not null, + sensor_id integer not null, + sample float not null, + foreign key(sensor_id) references sensors(sensor_id) +); +create index samples_bytime on samples(ts); +create unique index samples_bytimeid on samples(ts, sensor_id); + +-- END SCHEMA + + Each samples_[year] table looks, and is indexed exactly as the above +samples table was by using the following commands: + +create index samples_1999_bytime on samples_1999(ts); +create index samples_2000_bytime on samples_2000(ts); +create index samples_2001_bytime on samples_2001(ts); +create index samples_2002_bytime on samples_2002(ts); +create index samples_2003_bytime on samples_2003(ts); +create index samples_2004_bytime on samples_2004(ts); + +create unique index samples_1999_bytimeid on samples_1999(ts, +sensor_id); +create unique index samples_2000_bytimeid on samples_2000(ts, +sensor_id); +create unique index samples_2001_bytimeid on samples_2001(ts, +sensor_id); +create unique index samples_2002_bytimeid on samples_2002(ts, +sensor_id); +create unique index samples_2003_bytimeid on samples_2003(ts, +sensor_id); +create unique index samples_2004_bytimeid on samples_2004(ts, +sensor_id); + + The tables contain the following number of rows: + +samples_1999 311030 +samples_2000 2142245 +samples_2001 2706571 +samples_2002 3111602 +samples_2003 3149316 +samples_2004 2375972 + + The following view creates the illusion of the old ``single-table'' +model: + +create view samples as + select * from samples_1999 + union select * from samples_2000 + union select * from samples_2001 + union select * from samples_2002 + union select * from samples_2003 + union select * from samples_2004 + + ...along with the following rule on the view for the applications +performing inserts: + +create rule sample_rule as on insert to samples + do instead + insert into samples_2004 (ts, sensor_id, sample) + values(new.ts, new.sensor_id, new.sample) + + + OK, now that that's over with, I have this one particular query that I +attempt to run for a report from my phone that no longer works because +it tries to do a table scan on *some* of the tables. Why it chooses +this table scan, I can't imagine. The query is as follows: + +select + s.serial as serial_num, + s.name as name, + date(ts) as day, + min(sample) as min_temp, + avg(sample) as avg_temp, + stddev(sample) as stddev_temp, + max(sample) as max_temp + from + samples inner join sensors s using (sensor_id) + where + ts > current_date - 7 + group by + serial_num, name, day + order by + serial_num, day desc + + + explain analyze reports the following (sorry for the horrible +wrapping): + + Sort (cost=1185281.45..1185285.95 rows=1800 width=50) (actual +time=82832.106..82832.147 rows=56 loops=1) + Sort Key: s.serial, date(samples.ts) + -> HashAggregate (cost=1185161.62..1185184.12 rows=1800 width=50) +(actual time=82830.624..82831.601 rows=56 loops=1) + -> Hash Join (cost=1063980.21..1181539.96 rows=206952 +width=50) (actual time=80408.123..81688.590 rows=66389 loops=1) + Hash Cond: ("outer".sensor_id = "inner".sensor_id) + -> Subquery Scan samples (cost=1063979.10..1155957.38 +rows=4598914 width=20) (actual time=80392.477..80922.764 rows=66389 +loops=1) + -> Unique (cost=1063979.10..1109968.24 +rows=4598914 width=20) (actual time=80392.451..80646.761 rows=66389 +loops=1) + -> Sort (cost=1063979.10..1075476.39 +rows=4598914 width=20) (actual time=80392.437..80442.787 rows=66389 +loops=1) + Sort Key: ts, sensor_id, sample + -> Append (cost=0.00..312023.46 +rows=4598914 width=20) (actual time=79014.428..80148.396 rows=66389 +loops=1) + -> Subquery Scan "*SELECT* 1" +(cost=0.00..9239.37 rows=103677 width=20) (actual +time=4010.181..4010.181 rows=0 loops=1) + -> Seq Scan on +samples_1999 (cost=0.00..8202.60 rows=103677 width=20) (actual +time=4010.165..4010.165 rows=0 loops=1) + Filter: (ts > +((('now'::text)::date - 7))::timestamp without time zone) + -> Subquery Scan "*SELECT* 2" +(cost=0.00..28646.17 rows=714082 width=20) (actual time=44.827..44.827 +rows=0 loops=1) + -> Index Scan using +samples_2000_bytime on samples_2000 (cost=0.00..21505.35 rows=714082 +width=20) (actual time=44.818..44.818 rows=0 loops=1) + Index Cond: (ts > +((('now'::text)::date - 7))::timestamp without time zone) + -> Subquery Scan "*SELECT* 3" +(cost=0.00..80393.33 rows=902191 width=20) (actual +time=34772.377..34772.377 rows=0 loops=1) + -> Seq Scan on +samples_2001 (cost=0.00..71371.42 rows=902191 width=20) (actual +time=34772.366..34772.366 rows=0 loops=1) + Filter: (ts > +((('now'::text)::date - 7))::timestamp without time zone) + -> Subquery Scan "*SELECT* 4" +(cost=0.00..92424.05 rows=1037201 width=20) (actual +time=40072.103..40072.103 rows=0 loops=1) + -> Seq Scan on +samples_2002 (cost=0.00..82052.04 rows=1037201 width=20) (actual +time=40072.090..40072.090 rows=0 loops=1) + Filter: (ts > +((('now'::text)::date - 7))::timestamp without time zone) + -> Subquery Scan "*SELECT* 5" +(cost=0.00..42380.58 rows=1049772 width=20) (actual time=49.455..49.455 +rows=0 loops=1) + -> Index Scan using +samples_2003_bytime on samples_2003 (cost=0.00..31882.86 rows=1049772 +width=20) (actual time=49.448..49.448 rows=0 loops=1) + Index Cond: (ts > +((('now'::text)::date - 7))::timestamp without time zone) + -> Subquery Scan "*SELECT* 6" +(cost=0.00..58939.96 rows=791991 width=20) (actual +time=65.458..1124.363 rows=66389 loops=1) + -> Index Scan using +samples_2004_bytime on samples_2004 (cost=0.00..51020.05 rows=791991 +width=20) (actual time=65.430..750.336 rows=66389 loops=1) + Index Cond: (ts > +((('now'::text)::date - 7))::timestamp without time zone) + -> Hash (cost=1.09..1.09 rows=9 width=38) (actual +time=15.295..15.295 rows=0 loops=1) + -> Seq Scan on sensors s (cost=0.00..1.09 rows=9 +width=38) (actual time=15.122..15.187 rows=9 loops=1) + Total runtime: 82865.119 ms + + + Essentially, what you can see here is that it's doing an index scan on +samples_2000, samples_2003, and samples_2004, but a sequential scan on +samples_1999, samples_2001, and samples_2002. It's very strange to me +that it would make these choices. If I disable sequential scans +altogether for this session, the query runs in under 4 seconds. + + This is a very cool solution for long-term storage, and isn't terribly +hard to manage. I actually have other report queries that seem to be +making pretty good index selection currently...but I always want more! +:) Does anyone have any suggestions as to how to get this to do what I +want? + + Of course, ideally, it would ignore five of the tables altogether. :) + +-- +SPY My girlfriend asked me which one I like better. +pub 1024/3CAE01D5 1994/11/03 Dustin Sallings +| Key fingerprint = 87 02 57 08 02 D0 DA D6 C8 0F 3E 65 51 98 D8 BE +L_______________________ I hope the answer won't upset her. ____________ + + +From pgsql-performance-owner@postgresql.org Fri Oct 1 14:53:39 2004 +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 30092329C83 + for ; + Fri, 1 Oct 2004 14:53:38 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97785-09 + for ; + Fri, 1 Oct 2004 13:53:30 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 9053A32A2E8 + for ; + Fri, 1 Oct 2004 14:53:30 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.12.9/8.12.9) with ESMTP id + i91DrSSZ002347; + sent by ; Fri, 1 Oct 2004 08:53:28 -0500 (CDT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by server11.icaen.uiowa.edu (8.12.9/smtp-service-1.6) with ESMTP id + i91DrLcl011436; (envelope-from ) Fri, + 1 Oct 2004 08:53:27 -0500 (CDT) +Message-ID: <415D614D.7010001@johnmeinel.com> +Date: Fri, 01 Oct 2004 08:53:17 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dustin Sallings +Cc: pgsql-performance@postgresql.org +Subject: Re: inconsistent/weird index usage +References: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> +In-Reply-To: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig6BFBC898713A4E75C9A401D3" +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.66n +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.75 + on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/3 +X-Sequence-Number: 8479 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig6BFBC898713A4E75C9A401D3 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Dustin Sallings wrote: +> + +[...] + +> OK, now that that's over with, I have this one particular query that +> I attempt to run for a report from my phone that no longer works because +> it tries to do a table scan on *some* of the tables. Why it chooses +> this table scan, I can't imagine. The query is as follows: +> +> select +> s.serial as serial_num, +> s.name as name, +> date(ts) as day, +> min(sample) as min_temp, +> avg(sample) as avg_temp, +> stddev(sample) as stddev_temp, +> max(sample) as max_temp +> from +> samples inner join sensors s using (sensor_id) +> where +> ts > current_date - 7 +> group by +> serial_num, name, day +> order by +> serial_num, day desc +> +> + +[ next section heavily clipped for clarity ] + +-> Seq Scan on samples_1999 (cost rows=103677) (actual rows=0 loops=1) + +-> Index Scan using samples_2000_bytime on samples_2000 (cost +rows=714082 (actual rows=0 loops=1) + + +-> Seq Scan on samples_2001 (cost rows=902191) (actual rows=0 loops=1) + +-> Seq Scan on samples_2002 (cost rows=1037201) (actual rows=0 loops=1) + +-> Index Scan using samples_2003_bytime on samples_2003 (cost +rows=1049772) (actual rows=0 loops=1) + +-> Index Scan using samples_2004_bytime on samples_2004 (cost +rows=791991) (actual rows=66389 loops=1) + +[...] +> +> +> Essentially, what you can see here is that it's doing an index scan +> on samples_2000, samples_2003, and samples_2004, but a sequential scan +> on samples_1999, samples_2001, and samples_2002. It's very strange to +> me that it would make these choices. If I disable sequential scans +> altogether for this session, the query runs in under 4 seconds. +> +> This is a very cool solution for long-term storage, and isn't +> terribly hard to manage. I actually have other report queries that seem +> to be making pretty good index selection currently...but I always want +> more! :) Does anyone have any suggestions as to how to get this to do +> what I want? +> +> Of course, ideally, it would ignore five of the tables altogether. :) +> +> -- +> SPY My girlfriend asked me which one I like better. +> pub 1024/3CAE01D5 1994/11/03 Dustin Sallings +> | Key fingerprint = 87 02 57 08 02 D0 DA D6 C8 0F 3E 65 51 98 D8 BE +> L_______________________ I hope the answer won't upset her. ____________ +> +> + +Just as a heads up. You have run vacuum analyze before running this +query, correct? + +Because you'll notice that the query planner is thinking that it will +have 103677 rows from 1999, 700,000 rows from 2000, 900,000 rows from +2001, etc, etc. Obviously the query planner is not planning well +considering it there are only 60,000 rows from 2004, and no rows from +anything else. + +It just seems like it hasn't updated it's statistics to be aware of when +the time is on most of the tables. + +(By the way, an indexed scan returning 0 entries is *really* fast, so I +wouldn't worry about ignoring the extra tables. :) + +I suppose the other question is whether this is a prepared or stored +query. Because sometimes the query planner cannot do enough optimization +in a stored query. (I ran into this problem where I had 1 column with +500,000+ entries referencing 1 number. If I ran manually, the time was +much better because I wasn't using *that* number. With a stored query, +it had to take into account that I *might* use that number, and didn't +want to do 500,000+ indexed lookups) + +The only other thing I can think of is that there might be some +collision between datetime and date. Like it is thinking it is looking +at the time of day when it plans the queries (hence why so many rows), +but really it is looking at the date. Perhaps a cast is in order to make +it work right. I don't really know. + +Interesting problem, though. +John +=:-> + + +--------------enig6BFBC898713A4E75C9A401D3 +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBXWFSJdeBCYSNAAMRAqGCAJ9qpnf3Y6wqz5TVhdcytGaNzk0hdQCgkXWD +GiG7bUscL8CcI4zP/qjM7zw= +=1TiM +-----END PGP SIGNATURE----- + +--------------enig6BFBC898713A4E75C9A401D3-- + +From pgsql-performance-owner@postgresql.org Fri Oct 1 15:38:52 2004 +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 811B732A26F + for ; + Fri, 1 Oct 2004 15:38:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15030-08 + for ; + Fri, 1 Oct 2004 14:38:43 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2314832A234 + for ; + Fri, 1 Oct 2004 15:38:46 +0100 (BST) +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 i91Eck99009346; + Fri, 1 Oct 2004 10:38:46 -0400 (EDT) +To: Dustin Sallings +Cc: pgsql-performance@postgresql.org +Subject: Re: inconsistent/weird index usage +In-reply-to: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> +References: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> +Comments: In-reply-to Dustin Sallings + message dated "Thu, 30 Sep 2004 23:30:49 -0700" +Date: Fri, 01 Oct 2004 10:38:46 -0400 +Message-ID: <9345.1096641526@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/4 +X-Sequence-Number: 8480 + +Dustin Sallings writes: +> The following view creates the illusion of the old ``single-table'' +> model: + +> create view samples as +> select * from samples_1999 +> union select * from samples_2000 +> union select * from samples_2001 +> union select * from samples_2002 +> union select * from samples_2003 +> union select * from samples_2004 + +You really, really, really want to use UNION ALL not UNION here. + +> OK, now that that's over with, I have this one particular query that I +> attempt to run for a report from my phone that no longer works because +> it tries to do a table scan on *some* of the tables. Why it chooses +> this table scan, I can't imagine. + +Most of the problem here comes from the fact that "current_date - 7" +isn't reducible to a constant and so the planner is making bad guesses +about how much of each table will be scanned. If possible, do the date +arithmetic on the client side and send over a simple literal constant. +If that's not practical you can fake it with a mislabeled IMMUTABLE +function --- see the list archives for previous discussions of the +same issue. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 1 15:43:20 2004 +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 AD696329E5D + for ; + Fri, 1 Oct 2004 15:43:18 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20067-04 + for ; + Fri, 1 Oct 2004 14:43:10 +0000 (GMT) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id C2D8D329C6B + for ; + Fri, 1 Oct 2004 15:43:12 +0100 (BST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 4.42) + id 1CDOck-0000a5-7W; Fri, 01 Oct 2004 14:43:06 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id A9E4F17988; Fri, 1 Oct 2004 15:43:05 +0100 (BST) +Message-ID: <415D6CF9.60909@archonet.com> +Date: Fri, 01 Oct 2004 15:43:05 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dustin Sallings +Cc: pgsql-performance@postgresql.org +Subject: Re: inconsistent/weird index usage +References: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> +In-Reply-To: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/5 +X-Sequence-Number: 8481 + +Dustin Sallings wrote: +> The following view creates the illusion of the old ``single-table'' +> model: +> +> create view samples as +> select * from samples_1999 +> union select * from samples_2000 +> union select * from samples_2001 +> union select * from samples_2002 +> union select * from samples_2003 +> union select * from samples_2004 + +Try this with UNION ALL (you know there won't be any duplicates) and +possibly with some limits too: + +SELECT * FROM samples_1999 WHERE ts BETWEEN '1999-01-01 00:00:00+00' AND +'1999-12-31 11:59:59+00' +UNION ALL ... + +> select +> s.serial as serial_num, +> s.name as name, +> date(ts) as day, +> min(sample) as min_temp, +> avg(sample) as avg_temp, +> stddev(sample) as stddev_temp, +> max(sample) as max_temp +> from +> samples inner join sensors s using (sensor_id) +> where +> ts > current_date - 7 +> group by +> serial_num, name, day +> order by +> serial_num, day desc + +Try restricting the timestamp too + +WHERE + ts BETWEEN (current_date -7) AND current_timestamp + +Hopefully that will give the planner enough smarts to know it can skip +most of the sample_200x tables. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Oct 1 16:13:29 2004 +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 1A89932A259 + for ; + Fri, 1 Oct 2004 16:13:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56587-05 + for ; + Fri, 1 Oct 2004 15:13:10 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with ESMTP id 684A7329E79 + for ; + Fri, 1 Oct 2004 16:13:07 +0100 (BST) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 580921C8B0; Fri, 1 Oct 2004 15:13:03 +0000 (GMT) +Date: Fri, 1 Oct 2004 10:13:03 -0500 +From: "Jim C. Nasby" +To: Matt Clark +Cc: Postgresql Performance +Subject: Re: Caching of Queries +Message-ID: <20041001151303.GU1297@decibel.org> +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <1096306670.40463.173.camel@jester> <41587867.4090505@ymogen.net> + <20040930221107.GP1297@decibel.org> <415CEE8E.8060805@ymogen.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <415CEE8E.8060805@ymogen.net> +X-Operating-System: FreeBSD 4.10-RELEASE-p2 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/6 +X-Sequence-Number: 8482 + +On Fri, Oct 01, 2004 at 06:43:42AM +0100, Matt Clark wrote: +> +> >If you're not using a connection pool of some kind then you might as +> >well forget query plan caching, because your connect overhead will swamp +> >the planning cost. This does not mean you have to use something like +> >pgpool (which makes some rather questionable claims IMO); any decent web +> >application language/environment will support connection pooling. +> > +> > +> Hmm, a question of definition - there's a difference between a pool and +> a persistent connection. Pretty much all web apps have one connection +> per process, which is persistent (i.e. not dropped and remade for each +> request), but not shared between processes, therefore not pooled. + +OK, that'd work too... the point is if you're re-connecting all the time +it doesn't really matter what else you do for performance. +-- +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 Fri Oct 1 16:47:09 2004 +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 288D532A265 + for ; + Fri, 1 Oct 2004 16:47:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49367-05 + for ; + Fri, 1 Oct 2004 15:47:03 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 1846E32A259 + for ; + Fri, 1 Oct 2004 16:47:01 +0100 (BST) +Received: from solent (unknown [213.165.136.10]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id A49009EB62; Fri, 1 Oct 2004 16:46:59 +0100 (BST) +Reply-To: +From: "Matt Clark" +To: "'Jim C. Nasby'" +Cc: "'Postgresql Performance'" +Subject: Re: Caching of Queries +Date: Fri, 1 Oct 2004 16:46:59 +0100 +Organization: Ymogen Ltd +Message-ID: <012601c4a7cd$e358d300$8300a8c0@solent> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +In-Reply-To: <20041001151303.GU1297@decibel.org> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/7 +X-Sequence-Number: 8483 + +> OK, that'd work too... the point is if you're re-connecting=20 +> all the time it doesn't really matter what else you do for=20 +> performance. + +Yeah, although there is the chap who was asking questions on the list +recently who had some very long-running code on his app servers, so was best +off closing the connection because he had far too many postmaster processes +just sitting there idle all the time! + +But you're right, it's a killer usually. + +M=20 + + +From pgsql-performance-owner@postgresql.org Fri Oct 1 17:30:11 2004 +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 4773C32A615 + for ; + Fri, 1 Oct 2004 17:30:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65788-03 + for ; + Fri, 1 Oct 2004 16:30:01 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 7555132A60B + for ; + Fri, 1 Oct 2004 17:30:01 +0100 (BST) +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 6441602; Fri, 01 Oct 2004 09:31:22 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane +Subject: Re: inconsistent/weird index usage +Date: Fri, 1 Oct 2004 09:29:36 -0700 +User-Agent: KMail/1.6.2 +Cc: Dustin Sallings , + pgsql-performance@postgresql.org +References: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> + <9345.1096641526@sss.pgh.pa.us> +In-Reply-To: <9345.1096641526@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200410010929.36026.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/8 +X-Sequence-Number: 8484 + +Tom, + +> Most of the problem here comes from the fact that "current_date - 7" +> isn't reducible to a constant and so the planner is making bad guesses +> about how much of each table will be scanned. + +I thought this was fixed in 7.4. No? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Oct 1 17:34:27 2004 +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 199FC32A2BA + for ; + Fri, 1 Oct 2004 17:34:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68003-02 + for ; + Fri, 1 Oct 2004 16:34: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 43B6432A2D6 + for ; + Fri, 1 Oct 2004 17:34:17 +0100 (BST) +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 i91GYFqS010776; + Fri, 1 Oct 2004 12:34:15 -0400 (EDT) +To: Josh Berkus +Cc: Dustin Sallings , + pgsql-performance@postgresql.org +Subject: Re: inconsistent/weird index usage +In-reply-to: <200410010929.36026.josh@agliodbs.com> +References: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> + <9345.1096641526@sss.pgh.pa.us> + <200410010929.36026.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Fri, 01 Oct 2004 09:29:36 -0700" +Date: Fri, 01 Oct 2004 12:34:15 -0400 +Message-ID: <10775.1096648455@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/9 +X-Sequence-Number: 8485 + +Josh Berkus writes: +>> Most of the problem here comes from the fact that "current_date - 7" +>> isn't reducible to a constant and so the planner is making bad guesses +>> about how much of each table will be scanned. + +> I thought this was fixed in 7.4. No? + +No. It's not fixed as of CVS tip either, although there was some talk +of doing something in time for 8.0. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 1 18:11:19 2004 +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 7A73532A2DF + for ; + Fri, 1 Oct 2004 18:11:18 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82106-01 + for ; + Fri, 1 Oct 2004 17:11:12 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id C7B8532A246 + for ; + Fri, 1 Oct 2004 18:11:06 +0100 (BST) +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 6441786 for pgsql-performance@postgresql.org; + Fri, 01 Oct 2004 10:12:28 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Postgresql Performance +Subject: Re: Caching of Queries +Date: Fri, 1 Oct 2004 10:10:40 -0700 +User-Agent: KMail/1.6.2 +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <20040930221107.GP1297@decibel.org> <415CEE8E.8060805@ymogen.net> +In-Reply-To: <415CEE8E.8060805@ymogen.net> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410011010.40705.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/11 +X-Sequence-Number: 8487 + +People: + +Transparent "query caching" is the "industry standard" for how these things +are handled. However, Postgres' lack of this feature has made me consider +other approaches, and I'm starting to wonder if the "standard" query caching +-- where a materialized query result, or some reduction thereof, is cached in +database memory -- isn't the best way to cache things. I'm going to +abbreviate it "SQC" for the rest of this e-mail. + +Obviously, the draw of SQC is its transparency to developers. With it, the +Java/Perl/PHP programmers and the DBA don't have to communicate at all -- you +set it up, give it some RAM, and it "just works". As someone who frequently +has to consult based on limited knowledge, I can understand the appeal. + +However, one of the problems with SQC, aside from the ones already mentioned +of stale data and/or cache-clearing, is that (at least in applications like +MySQL's) it is indiscriminate and caches, at least breifly, unique queries as +readily as common ones. Possibly Oracle's implementation is more +sophisticated; I've not had an opportunity. + +The other half of that problem is that an entire query is cached, rather than +just the relevant data to uniquely identify the request to the application. +This is bad in two respects; one that the entire query needs to be parsed to +see if a new query is materially equivalent, and that two materially +different queries which could utilize overlapping ranges of the same +underlying result set must instead cache their results seperately, eating up +yet more memory. + +To explain what I'm talking about, let me give you a counter-example of +another approach. + +I have a data-warehousing application with a web front-end. The data in the +application is quite extensive and complex, and only a summary is presented +to the public users -- but that summary is a query involving about 30 lines +and 16 joins. This summary information is available in 3 slightly different +forms. Further, the client has indicated that an up to 1/2 hour delay in +data "freshness" is acceptable. + +The first step is forcing that "materialized" view of the data into memory. +Right now I'm working on a reliable way to do that without using Memcached, +which won't install on our Solaris servers. Temporary tables have the +annoying property of being per-connection, which doesn't work in a pool of 60 +connections. + +The second step, which I completed first due to the lack of technical +obstacles, is to replace all queries against this data with calls to a +Set-Returning Function (SRF). This allowed me to re-direct where the data +was coming from -- presumably the same thing could be done through RULES, but +it would have been considerably harder to implement. + +The first thing the SRF does is check the criteria passed to it against a set +of cached (in a table) criteria with that user's permission level which is < +1/2 hour old. If the same criteria are found, then the SRF is returned a +set of row identifiers for the materialized view (MV), and looks up the rows +in the MV and returns those to the web client. + +If no identical set of criteria are found, then the query is run to get a set +of identifiers which are then cached, and the SRF returns the queried rows. + +Once I surmount the problem of storing all the caching information in +protected memory, the advantages of this approach over SQC are several: + +1) The materialized data is available in 3 different forms; a list, a detail +view, and a spreadsheet. Each form as somewhat different columns and +different rules about ordering, which would likely confuse an SQC planner. +In this implementation, all 3 forms are able to share the same cache. + +2) The application is comparing only sets of unambguous criteria rather than +long queries which would need to be compared in planner form in order to +determine query equivalence. + +3) With the identifier sets, we are able to cache other information as well, +such as a count of rows, further limiting the number of queries we must run. + +4) This approach is ideally suited to the pagination and re-sorting common to +a web result set. As only the identifiers are cached, the results can be +re-sorted and broken in to pages after the cache read, a fast, all-in-memory +operation. + +In conclusion, what I'm saying is that while forms of transparent query +caching (plan, materialized or whatever) may be desirable for other reasons, +it's quite possible to acheive a superior level of "query caching" through +tight integration with the front-end application. + +If people are interested in this, I'd love to see some suggestions on ways to +force the materialized view into dedicated memory. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Oct 1 19:26:44 2004 +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 D2668329E79 + for ; + Fri, 1 Oct 2004 19:26:42 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28516-06 + for ; + Fri, 1 Oct 2004 18:26:40 +0000 (GMT) +Received: from fdd00lnhub.fds.com (external.fds.com [208.15.90.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CFE8329DAE + for ; + Fri, 1 Oct 2004 19:26:41 +0100 (BST) +MIME-Version: 1.0 +X-Mailer: Lotus Notes Release 6.5 September 18, 2003 +Subject: Slow update/insert process +To: +Message-ID: + +From: Patrick Hatcher +Date: Fri, 1 Oct 2004 11:14:08 -0700 +X-MIMETrack: Serialize by Router on FDD00LNHUB/FSG/SVR/FDD(Release 6.5.2|June + 01, 2004) at 10/01/2004 02:26:09 PM, + Serialize complete at 10/01/2004 02:26:09 PM +Content-Type: multipart/alternative; + boundary="=_alternative 0064C27E88256F20_=" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_MESSAGE, LINES_OF_YELLING +X-Spam-Level: +X-Archive-Number: 200410/12 +X-Sequence-Number: 8488 + +This is a multipart message in MIME format. +--=_alternative 0064C27E88256F20_= +Content-Type: text/plain; charset="US-ASCII" + +Pg: 7.4.5 +RH 7.3 +8g Ram +200 g drive space +RAID0+1 +Tables vacuum on a nightly basis + +The following process below takes 8 hours to run on 90k records and I'm +not sure where to being to look for the bottleneck. This isn't the only +updating on this database that seems to take a long time to complete. Is +there something I should be looking for in my conf settings? + +TIA +Patrick + + +SQL: +---Bring back only selected records to run through the update process. +--Without the function the SQL takes < 10secs to return 90,000 records +SELECT count(pm.pm_delta_function_amazon(upc.keyp_upc,'amazon')) +FROM mdc_upc upc +JOIN public.mdc_products prod ON upc.keyf_products = prod.keyp_products +JOIN public.mdc_price_post_inc price ON prod.keyp_products = +price.keyf_product +JOIN public.mdc_attribute_product ap on ap.keyf_products = +prod.keyp_products and keyf_attribute=22 +WHERE +upper(trim(ap.attributevalue)) NOT IN ('ESTEE LAUDER', +'CLINIQUE','ORGINS','PRESCRIPTIVES','LANC?ME','CHANEL','ARAMIS','M.A.C','TAG +HEUER') +AND keyf_producttype<>222 +AND prod.action_publish = 1; + + +Function: + +CREATE OR REPLACE FUNCTION pm.pm_delta_function_amazon(int4, "varchar") + RETURNS bool AS +'DECLARE + varkeyf_upc ALIAS FOR $1; + varPassword ALIAS FOR $2; + varRealMD5 varchar; + varDeltaMD5 varchar; + varLastTouchDate date; + varQuery text; + varQuery1 text; + varQueryMD5 text; + varQueryRecord record; + varFuncStatus boolean := false; + +BEGIN + +-- Check the password + IF varPassword <> \'amazon\' THEN + Return false; + END IF; + + +-- Get the md5 hash for this product + SELECT into varQueryRecord md5(upc.keyp_upc || prod.description || +pm.pm_price_post_inc(prod.keyp_products)) AS md5 + FROM public.mdc_upc upc + JOIN public.mdc_products prod ON upc.keyf_products = +prod.keyp_products + JOIN public.mdc_price_post_inc price ON price.keyf_product = +prod.keyp_products + WHERE upc.keyp_upc = varkeyf_upc LIMIT 1 ; + + + IF NOT FOUND THEN + RAISE EXCEPTION \'varRealMD5 is NULL. UPC ID is %\', varkeyf_upc; + ELSE + varRealMD5:=varQueryRecord.md5; + END IF; + +-- Check that the product is in the delta table and return its hash for +comparison + SELECT into varQueryRecord md5_hash,last_touch_date + FROM pm.pm_delta_master_amazon + WHERE keyf_upc = varkeyf_upc LIMIT 1; + + IF NOT FOUND THEN + -- ADD and exit + INSERT INTO pm.pm_delta_master_amazon +(keyf_upc,status,md5_hash,last_touch_date) + values (varkeyf_upc,\'add\',varRealMD5,CURRENT_DATE); + varFuncStatus:=true; + RETURN varFuncStatus; + ELSE + --Update the record + --- If the hash matches then set the record to HOLD + IF varRealMD5 = varQueryRecord.md5_hash THEN + UPDATE pm.pm_delta_master_amazon + SET status= \'hold\', + last_touch_date = CURRENT_DATE + WHERE keyf_upc = varkeyf_upc AND last_touch_date <> CURRENT_DATE; + + varFuncStatus:=true; + ELSE + -- ELSE mark the item as ADD + UPDATE pm.pm_delta_master_amazon + SET status= \'add\', + last_touch_date = CURRENT_DATE + WHERE keyf_upc = varkeyf_upc; + varFuncStatus:=true; + END IF; + END IF; + + RETURN varFuncStatus; +END;' + LANGUAGE 'plpgsql' IMMUTABLE; + + + +TableDef +CREATE TABLE pm.pm_delta_master_amazon ( + keyf_upc int4 , + status varchar(6) , + md5_hash varchar(40) , + last_touch_date date + ) +GO + +CREATE INDEX status_idx + ON pm.pm_delta_master_amazon(status) +GO + + + + + +CONF +-------- +# WRITE AHEAD LOG +#--------------------------------------------------------------------------- + +# - Settings - + +#fsync = true # turns forced synchronization on or off +#wal_sync_method = fsync # the default varies across platforms: + # fsync, fdatasync, open_sync, or +open_datasync +wal_buffers = 32 # min 4, 8KB each + +# - Checkpoints - + +checkpoint_segments = 50 # in logfile segments, min 1, 16MB each +checkpoint_timeout = 600 # range 30-3600, in seconds +#checkpoint_warning = 30 # 0 is off, in seconds +#commit_delay = 0 # range 0-100000, in microseconds +#commit_siblings = 5 # range 1-1000 + + +Patrick Hatcher +Macys.Com + +--=_alternative 0064C27E88256F20_= +Content-Type: text/html; charset="US-ASCII" + + +
Pg: 7.4.5 +
RH 7.3 +
8g Ram +
200 g drive space +
RAID0+1 +
Tables vacuum on a nightly basis +
+
The following process below takes 8 +hours to run on 90k records and I'm not sure where to being to look for +the bottleneck.  This isn't the only updating on this database that +seems to take a long time to complete.  Is there something I should +be looking for in my conf settings?   +
+
TIA +
Patrick +
+
+
SQL: +
---Bring back only selected records +to run through the update process. +
--Without the function the SQL takes +< 10secs to return 90,000 records +
SELECT count(pm.pm_delta_function_amazon(upc.keyp_upc,'amazon')) +
FROM mdc_upc upc +
JOIN public.mdc_products prod ON upc.keyf_products += prod.keyp_products +
JOIN public.mdc_price_post_inc price +ON prod.keyp_products = price.keyf_product +
JOIN public.mdc_attribute_product ap +on ap.keyf_products = prod.keyp_products and keyf_attribute=22 +
WHERE +
upper(trim(ap.attributevalue)) NOT IN +('ESTEE LAUDER', 'CLINIQUE','ORGINS','PRESCRIPTIVES','LANC?ME','CHANEL','ARAMIS','M.A.C','TAG +HEUER') +
AND keyf_producttype<>222 +
AND prod.action_publish = 1; +
+
+
Function: +

+CREATE OR REPLACE FUNCTION pm.pm_delta_function_amazon(int4, "varchar")
+  RETURNS bool AS
+'DECLARE
+    varkeyf_upc             +   ALIAS FOR $1;
+    varPassword             +   ALIAS FOR $2;
+    varRealMD5             +   varchar;
+    varDeltaMD5             +   varchar;
+    varLastTouchDate        date;
+    varQuery             +    text;
+    varQuery1             +    text;
+    varQueryMD5             +   text;
+    varQueryRecord        record;
+    varFuncStatus        boolean +:= false;
+    
+BEGIN
+
+-- Check the password
+  IF varPassword <> \'amazon\' THEN
+    Return false;
+  END IF;
+
+
+--  Get the md5 hash for this product
+  SELECT into varQueryRecord md5(upc.keyp_upc || prod.description +|| pm.pm_price_post_inc(prod.keyp_products)) AS md5
+    FROM public.mdc_upc upc
+    JOIN public.mdc_products prod ON upc.keyf_products = prod.keyp_products
+    JOIN public.mdc_price_post_inc price ON price.keyf_product += prod.keyp_products
+    WHERE upc.keyp_upc = varkeyf_upc LIMIT 1 ;
+  
+
+  IF NOT FOUND THEN
+    RAISE EXCEPTION \'varRealMD5 is NULL. UPC ID is %\', varkeyf_upc;
+  ELSE
+    varRealMD5:=varQueryRecord.md5;
+  END IF;
+
+--  Check that the product is in the delta table and return its hash +for comparison
+  SELECT into varQueryRecord md5_hash,last_touch_date
+    FROM pm.pm_delta_master_amazon
+    WHERE keyf_upc = varkeyf_upc LIMIT 1;
+
+  IF NOT FOUND THEN
+    -- ADD and exit
+    INSERT INTO pm.pm_delta_master_amazon (keyf_upc,status,md5_hash,last_touch_date)
+    values (varkeyf_upc,\'add\',varRealMD5,CURRENT_DATE);
+    varFuncStatus:=true;
+    RETURN varFuncStatus;
+  ELSE
+    --Update the record
+      --- If the hash matches then set the record to HOLD
+    IF varRealMD5 = varQueryRecord.md5_hash THEN
+        UPDATE pm.pm_delta_master_amazon
+          SET status= \'hold\',
+          last_touch_date =  CURRENT_DATE
+        WHERE keyf_upc =  varkeyf_upc +AND last_touch_date <> CURRENT_DATE;
+        varFuncStatus:=true;
+    ELSE
+        --  ELSE mark the item as ADD
+        UPDATE pm.pm_delta_master_amazon
+          SET status= \'add\',
+          last_touch_date =  CURRENT_DATE
+        WHERE keyf_upc =  varkeyf_upc;
+        varFuncStatus:=true;
+    END IF;
+   END IF;
+
+  RETURN varFuncStatus;
+END;'
+  LANGUAGE 'plpgsql' IMMUTABLE;
+
+
+
+
TableDef +
CREATE TABLE pm.pm_delta_master_amazon +( +
    keyf_upc     +          int4 , +
    status       +          varchar(6) , +
    md5_hash     +          varchar(40) , +
    last_touch_date   +     date +
    ) +
GO +
+
CREATE INDEX status_idx +
    ON pm.pm_delta_master_amazon(status) +
GO +
+
+
+ +
+
CONF +
-------- +
# WRITE AHEAD LOG +
#--------------------------------------------------------------------------- +
+
# - Settings - +
+
#fsync = true         +          # turns forced synchronization on or +off +
#wal_sync_method = fsync     +   # the default varies across platforms: +
            +                    # +fsync, fdatasync, open_sync, or open_datasync +
wal_buffers = 32       +         # min 4, 8KB each +
+
# - Checkpoints - +
+
checkpoint_segments = 50     +   # in logfile segments, min 1, 16MB each +
checkpoint_timeout = 600     +   # range 30-3600, in seconds +
#checkpoint_warning = 30     +   # 0 is off, in seconds +
#commit_delay = 0       +        # range 0-100000, in microseconds +
#commit_siblings = 5       +     # range 1-1000 +
+
+
Patrick Hatcher
+Macys.Com
+
+--=_alternative 0064C27E88256F20_=-- + +From pgsql-performance-owner@postgresql.org Fri Oct 1 20:49:11 2004 +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 A8CC232A20D + for ; + Fri, 1 Oct 2004 20:49:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26646-08 + for ; + Fri, 1 Oct 2004 19:49:00 +0000 (GMT) +Received: from hotmail.com (bay18-dav5.bay18.hotmail.com [65.54.187.185]) + by svr1.postgresql.org (Postfix) with ESMTP id 06F0532A208 + for ; + Fri, 1 Oct 2004 20:49:01 +0100 (BST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 1 Oct 2004 12:49:00 -0700 +Received: from 67.81.98.198 by BAY18-DAV5.phx.gbl with DAV; + Fri, 01 Oct 2004 19:48:53 +0000 +X-Originating-IP: [67.81.98.198] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: , "Patrick Hatcher" +References: + +Subject: Re: Slow update/insert process +Date: Fri, 1 Oct 2004 15:48:50 -0400 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_004E_01C4A7CE.2553D890" +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 +Message-ID: +X-OriginalArrivalTime: 01 Oct 2004 19:49:00.0526 (UTC) + FILETIME=[B265E0E0:01C4A7EF] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_MESSAGE, LINES_OF_YELLING +X-Spam-Level: +X-Archive-Number: 200410/13 +X-Sequence-Number: 8489 + +This is a multi-part message in MIME format. + +------=_NextPart_000_004E_01C4A7CE.2553D890 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Some quick notes: + +- Using a side effect of a function to update the database feels bad to me +- how long does the SELECT into varQueryRecord md5(upc.keyp.... + function take / what does it's explain look like? +- There are a lot of non-indexed columns on that delta master table, such a= +s keyf_upc.=20 + I'm guessing you're doing 90,000 x {a lot of slow scans} +- My temptation would be to rewrite the processing to do a pass of updates,= + a pass of inserts,=20 + and then the SELECT + ----- Original Message -----=20 + From: Patrick Hatcher=20 + To: pgsql-performance@postgresql.org=20 + Sent: Friday, October 01, 2004 2:14 PM + Subject: [PERFORM] Slow update/insert process + + + + Pg: 7.4.5=20 + RH 7.3=20 + 8g Ram=20 + 200 g drive space=20 + RAID0+1=20 + Tables vacuum on a nightly basis=20 + + The following process below takes 8 hours to run on 90k records and I'm n= +ot sure where to being to look for the bottleneck. This isn't the only upd= +ating on this database that seems to take a long time to complete. Is ther= +e something I should be looking for in my conf settings?=20=20=20 + + TIA=20 + Patrick=20 + + + SQL:=20 + ---Bring back only selected records to run through the update process.=20 + --Without the function the SQL takes < 10secs to return 90,000 records=20 + SELECT count(pm.pm_delta_function_amazon(upc.keyp_upc,'amazon'))=20 + FROM mdc_upc upc=20 + JOIN public.mdc_products prod ON upc.keyf_products =3D prod.keyp_products= +=20 + JOIN public.mdc_price_post_inc price ON prod.keyp_products =3D price.keyf= +_product=20 + JOIN public.mdc_attribute_product ap on ap.keyf_products =3D prod.keyp_pr= +oducts and keyf_attribute=3D22=20 + WHERE=20 + upper(trim(ap.attributevalue)) NOT IN ('ESTEE LAUDER', 'CLINIQUE','ORGINS= +','PRESCRIPTIVES','LANC?ME','CHANEL','ARAMIS','M.A.C','TAG HEUER')=20 + AND keyf_producttype<>222=20 + AND prod.action_publish =3D 1;=20 + + + Function:=20 + + CREATE OR REPLACE FUNCTION pm.pm_delta_function_amazon(int4, "varchar") + RETURNS bool AS + 'DECLARE + varkeyf_upc ALIAS FOR $1; + varPassword ALIAS FOR $2; + varRealMD5 varchar; + varDeltaMD5 varchar; + varLastTouchDate date; + varQuery text; + varQuery1 text; + varQueryMD5 text; + varQueryRecord record; + varFuncStatus boolean :=3D false; +=20=20=20=20=20 + BEGIN + + -- Check the password + IF varPassword <> \'amazon\' THEN + Return false; + END IF; + + + -- Get the md5 hash for this product + SELECT into varQueryRecord md5(upc.keyp_upc || prod.description || pm.pm= +_price_post_inc(prod.keyp_products)) AS md5 + FROM public.mdc_upc upc + JOIN public.mdc_products prod ON upc.keyf_products =3D prod.keyp_produ= +cts + JOIN public.mdc_price_post_inc price ON price.keyf_product =3D prod.ke= +yp_products + WHERE upc.keyp_upc =3D varkeyf_upc LIMIT 1 ; +=20=20=20 + + IF NOT FOUND THEN + RAISE EXCEPTION \'varRealMD5 is NULL. UPC ID is %\', varkeyf_upc; + ELSE + varRealMD5:=3DvarQueryRecord.md5; + END IF; + + -- Check that the product is in the delta table and return its hash for = +comparison=20 + SELECT into varQueryRecord md5_hash,last_touch_date=20 + FROM pm.pm_delta_master_amazon + WHERE keyf_upc =3D varkeyf_upc LIMIT 1; + + IF NOT FOUND THEN + -- ADD and exit + INSERT INTO pm.pm_delta_master_amazon (keyf_upc,status,md5_hash,last_t= +ouch_date) + values (varkeyf_upc,\'add\',varRealMD5,CURRENT_DATE); + varFuncStatus:=3Dtrue; + RETURN varFuncStatus; + ELSE + --Update the record=20 + --- If the hash matches then set the record to HOLD + IF varRealMD5 =3D varQueryRecord.md5_hash THEN + UPDATE pm.pm_delta_master_amazon + SET status=3D \'hold\', + last_touch_date =3D CURRENT_DATE + WHERE keyf_upc =3D varkeyf_upc AND last_touch_date <> CURRENT_DAT= +E;=20 + varFuncStatus:=3Dtrue; + ELSE + -- ELSE mark the item as ADD + UPDATE pm.pm_delta_master_amazon + SET status=3D \'add\', + last_touch_date =3D CURRENT_DATE + WHERE keyf_upc =3D varkeyf_upc; + varFuncStatus:=3Dtrue; + END IF; + END IF; + + RETURN varFuncStatus; + END;' + LANGUAGE 'plpgsql' IMMUTABLE; + + + + TableDef=20 + CREATE TABLE pm.pm_delta_master_amazon (=20 + keyf_upc int4 ,=20 + status varchar(6) ,=20 + md5_hash varchar(40) ,=20 + last_touch_date date=20 + )=20 + GO=20 + + CREATE INDEX status_idx=20 + ON pm.pm_delta_master_amazon(status)=20 + GO=20 + + + + + CONF=20 + --------=20 + # WRITE AHEAD LOG=20 + #------------------------------------------------------------------------= +---=20 + + # - Settings -=20 + + #fsync =3D true # turns forced synchronization on or of= +f=20 + #wal_sync_method =3D fsync # the default varies across platforms:= +=20 + # fsync, fdatasync, open_sync, or open_da= +tasync=20 + wal_buffers =3D 32 # min 4, 8KB each=20 + + # - Checkpoints -=20 + + checkpoint_segments =3D 50 # in logfile segments, min 1, 16MB each= +=20 + checkpoint_timeout =3D 600 # range 30-3600, in seconds=20 + #checkpoint_warning =3D 30 # 0 is off, in seconds=20 + #commit_delay =3D 0 # range 0-100000, in microseconds=20 + #commit_siblings =3D 5 # range 1-1000=20 + + + Patrick Hatcher + Macys.Com + +------=_NextPart_000_004E_01C4A7CE.2553D890 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Some quick notes:
+
 
+
- Using a side effect of a function to upd= +ate the=20 +database feels bad to me
+
- how long does the  SELECT into varQueryRecord=20 +md5(upc.keyp....
+
  function take / what does it's expl= +ain look=20 +like?
+
- There are a lot of non-indexed columns o= +n that=20 +delta master table, such as keyf_upc.=20 +
+
   I'm guessing you'= +re doing=20 +90,000 x {a lot of slow scans}
+
- My temptation would be to rewrite the pr= +ocessing=20 +to do a pass of updates, a pass of inserts,
+
  and then the SELECT
+ +
----- Original Message -----
+ Fro= +m:=20 + Patrick= +=20 + Hatcher +
To: pgsql-performance@postgr= +esql.org=20 +
+
Sent: Friday, October 01, 2004 2:1= +4=20 + PM
+
Subject: [PERFORM] Slow update/ins= +ert=20 + process
+


Pg: 7.4.5
RH=20 + 7.3
8g Ram
200 g drive space
RAID0+1
Tables vacuu= +m on a=20 + nightly basis

The followi= +ng=20 + process below takes 8 hours to run on 90k records and I'm not sure where = +to=20 + being to look for the bottleneck.  This isn't the only updating on t= +his=20 + database that seems to take a long time to complete.  Is there somet= +hing=20 + I should be looking for in my conf settings?  

TIA
Patrick


SQL:= +=20 +
---Bring back only selected records = +to run=20 + through the update process.
-= +-Without=20 + the function the SQL takes < 10secs to return 90,000 records=20 +
SELECT=20 + count(pm.pm_delta_function_amazon(upc.keyp_upc,'amazon'))
FROM mdc_upc upc
JOIN public.mdc_products prod ON upc.keyf_products =3D=20 + prod.keyp_products
JOIN=20 + public.mdc_price_post_inc price ON prod.keyp_products =3D=20 + price.keyf_product
JOIN=20 + public.mdc_attribute_product ap on ap.keyf_products =3D prod.keyp_product= +s and=20 + keyf_attribute=3D22
WHERE=20 +
upper(trim(ap.attributevalue)= +) NOT IN=20 + ('ESTEE LAUDER',=20 + 'CLINIQUE','ORGINS','PRESCRIPTIVES','LANC?ME','CHANEL','ARAMIS','M.A.C','= +TAG=20 + HEUER')
AND=20 + keyf_producttype<>222
A= +ND=20 + prod.action_publish =3D 1;


Function:

C= +REATE OR=20 + REPLACE FUNCTION pm.pm_delta_function_amazon(int4, "varchar")
 RE= +TURNS=20 + bool AS
'DECLARE
   varkeyf_upc       &nbs= +p;=20 +        ALIAS FOR $1;
   varPassword &nbs= +p;=20 +              ALIAS FOR $2;
 = +=20 +  varRealMD5              =20 +  varchar;
   varDeltaMD5         &n= +bsp;=20 +      varchar;
   varLastTouchDate   &nbs= +p;=20 +    date;
   varQuery         &= +nbsp;=20 +       text;
   varQuery1      = +=20 +           text;
   varQueryMD5 &nbs= +p;=20 +              text;
 =20 +  varQueryRecord        record;
 =20 +  varFuncStatus        boolean :=3D false;
&nb= +sp;=20 +  
BEGIN

-- Check the password
 IF varPassword <= +>=20 + \'amazon\' THEN
   Return false;
 END IF;

--=20 +  Get the md5 hash for this product
 SELECT into varQueryReco= +rd=20 + md5(upc.keyp_upc || prod.description ||=20 + pm.pm_price_post_inc(prod.keyp_products)) AS md5
   FROM=20 + public.mdc_upc upc
   JOIN public.mdc_products prod ON=20 + upc.keyf_products =3D prod.keyp_products
   JOIN=20 + public.mdc_price_post_inc price ON price.keyf_product =3D=20 + prod.keyp_products
   WHERE upc.keyp_upc =3D varkeyf_upc LIM= +IT 1=20 + ;
 

 IF NOT FOUND THEN
   RAISE EXCEPTIO= +N=20 + \'varRealMD5 is NULL. UPC ID is %\', varkeyf_upc;
 ELSE
 = +=20 +  varRealMD5:=3DvarQueryRecord.md5;
 END IF;

--  = +Check=20 + that the product is in the delta table and return its hash for comparison= +=20 +
 SELECT into varQueryRecord md5_hash,last_touch_date
 = +=20 +  FROM pm.pm_delta_master_amazon
   WHERE keyf_upc =3D= +=20 + varkeyf_upc LIMIT 1;

 IF NOT FOUND THEN
   -- AD= +D and=20 + exit
   INSERT INTO pm.pm_delta_master_amazon=20 + (keyf_upc,status,md5_hash,last_touch_date)
   values=20 + (varkeyf_upc,\'add\',varRealMD5,CURRENT_DATE);
 =20 +  varFuncStatus:=3Dtrue;
   RETURN=20 + varFuncStatus;
 ELSE
   --Update the record
&nbs= +p;=20 +    --- If the hash matches then set the record to HOLD
 = +;=20 +  IF varRealMD5 =3D varQueryRecord.md5_hash THEN
    &nb= +sp;=20 +  UPDATE pm.pm_delta_master_amazon
       =20 +  SET status=3D \'hold\',
       =20 +  last_touch_date =3D  CURRENT_DATE
      &nbs= +p;WHERE=20 + keyf_upc =3D  varkeyf_upc AND last_touch_date <> CURRENT_DATE;= +=20 +
       varFuncStatus:=3Dtrue;
 =20 +  ELSE
       --  ELSE mark the item as= +=20 + ADD
       UPDATE pm.pm_delta_master_amazon
&nb= +sp;=20 +        SET status=3D \'add\',
     = +  =20 +  last_touch_date =3D  CURRENT_DATE
      &nbs= +p;WHERE=20 + keyf_upc =3D  varkeyf_upc;
     =20 +  varFuncStatus:=3Dtrue;
   END IF;
  END=20 + IF;

 RETURN varFuncStatus;
END;'
 LANGUAGE 'plpgsq= +l'=20 + IMMUTABLE;



TableDe= +f=20 +
CREATE TABLE pm.pm_delta_master_amaz= +on (=20 +
    keyf_upc  = +  =20 +           int4 ,
    status             &= +nbsp;=20 +   varchar(6) ,
  &n= +bsp;=20 + md5_hash               varchar(40) ,=20 +
    last_touch_date  = +  =20 +    date
  &nbs= +p;=20 + )
GO

CREATE INDEX status_idx

    ON=20 + pm.pm_delta_master_amazon(status)
GO



CONF
--------
# WRITE AHE= +AD=20 + LOG
#---------------------------------------------------------------= +------------=20 +

# - Settings -

#fsync =3D true         &n= +bsp;  =20 +       # turns forced synchronization on or off
= +#wal_sync_method =3D fsync      = +;  #=20 + the default varies across platforms:
                  &= +nbsp;=20 +             # fsync, fdatasync, open_sync, = +or=20 + open_datasync
wal_buffers =3D= + 32  =20 +              # min 4, 8KB each= +=20 +

# - Checkpoints -
checkpoint_segments =3D 50      = +;  #=20 + in logfile segments, min 1, 16MB each
checkpoint_timeout =3D 600        # range 30= +-3600, in=20 + seconds
#checkpoint_warning = +=3D 30=20 +        # 0 is off, in seconds
#commit_delay =3D 0        = +;  =20 +     # range 0-100000, in microseconds
#commit_siblings =3D 5       &n= +bsp;  =20 +  # range 1-1000


= +Patrick=20 + Hatcher
Macys.Com
+ +------=_NextPart_000_004E_01C4A7CE.2553D890-- + +From pgsql-performance-owner@postgresql.org Sat Oct 2 23:02:42 2004 +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 D95EF32A154 + for ; + Fri, 1 Oct 2004 23:07:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76137-02 + for ; + Fri, 1 Oct 2004 22:06:53 +0000 (GMT) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 72D0F329D5F + for ; + Fri, 1 Oct 2004 23:06:54 +0100 (BST) +Received: from cormallen.doxpop.com (ryanv@cormallen.doxpop.com + [199.164.165.137]) + by shire.ontko.com (8.12.3/8.12.3/Debian-7.1) with ESMTP id + i91M6skX009733 + for ; Fri, 1 Oct 2004 17:06:54 -0500 +From: Ryan VanMiddlesworth +To: pgsql-performance@postgresql.org +Subject: Query planner problem +Date: Fri, 1 Oct 2004 17:06:54 -0500 +User-Agent: KMail/1.7 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200410011706.54231.ryan@vanmiddlesworth.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/17 +X-Sequence-Number: 8493 + +Okay, I've got two queries that I think the planner should reduce to be +logically equivalent but it's not happening. The example queries below have +been simplified as much as possible while still producing the problem. + +What I'm trying to do is create a single prepared statement that can handle +null parameters rather than have to dynamically generate the statement in my +app code based on supplied parameters. + +Basically the date constants below would be substituted with parameters +supplied on a web search form (or nulls). + + +Here is the query and EXPLAIN that runs quickly: + SELECT case_id FROM case_data + WHERE case_filed_date > '2004-09-16' + AND case_filed_date < '2004-09-20' + + QUERY PLAN +------------------------------------------------------------- +Index Scan using case_data_case_filed_date on case_data +(cost=0.00..13790.52 rows=3614 width=18) + Index Cond: ((case_filed_date > '2004-09-16'::date) + AND (case_filed_date < '2004-09-20'::date)) + + +And here is the query and EXPLAIN from the version that I believe the planner +should reduce to be logically equivalent: + SELECT case_id FROM case_data + WHERE (('2004-09-16' IS NULL) OR (case_filed_date > '2004-09-16')) + AND (('2004-09-20' IS NULL) OR (case_filed_date < '2004-09-20')) + + QUERY PLAN +------------------------------------------------------------- +Seq Scan on case_data (cost=0.00..107422.02 rows=27509 width=18) + Filter: ((('2004-09-16' IS NULL) OR (case_filed_date > '2004-09-16'::date)) + AND (('2004-09-20' IS NULL) OR (case_filed_date < '2004-09-20'::date))) + + +I was hoping that the null comparisons would get folded out by the planner +relatively cheaply. But as you can see, the first query uses indexes and the +second one uses sequence scans, thereby taking much longer. I guess my +question is - is there a better way to accomplish what I'm doing in SQL or am +I going to have to dynamically generate the statement based on supplied +parameters? + +Thanks, +Ryan + +From pgsql-performance-owner@postgresql.org Sat Oct 2 04:15:33 2004 +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 710E432A514 + for ; + Sat, 2 Oct 2004 04:15:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35761-04 + for ; + Sat, 2 Oct 2004 03:15:17 +0000 (GMT) +Received: from hotmail.com (bay18-dav14.bay18.hotmail.com [65.54.187.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E0CA32A509 + for ; + Sat, 2 Oct 2004 04:15:16 +0100 (BST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 1 Oct 2004 20:14:00 -0700 +Received: from 67.81.98.198 by bay18-dav14.bay18.hotmail.com with DAV; + Sat, 02 Oct 2004 03:13:28 +0000 +X-Originating-IP: [67.81.98.198] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Josh Berkus" , + "Postgresql Performance" +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <20040930221107.GP1297@decibel.org> <415CEE8E.8060805@ymogen.net> + <200410011010.40705.josh@agliodbs.com> +Subject: Re: Caching of Queries +Date: Fri, 1 Oct 2004 23:13:28 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 8bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Message-ID: +X-OriginalArrivalTime: 02 Oct 2004 03:14:00.0519 (UTC) + FILETIME=[DCD57D70:01C4A82D] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/14 +X-Sequence-Number: 8490 + +I'm not sure I understand your req fully. If the same request is repeatedly +done with same parameters, you could implement a proxy web server with a +croned script to purge stale pages. If there is substantially the same data +being summarized, doing your own summary tables works; if accessed enough, +they're in memory. I interleaved some notes into your posting. + +----- Original Message ----- + +From: "Josh Berkus" + +To: "Postgresql Performance" + +Sent: Friday, October 01, 2004 1:10 PM + +Subject: Re: [PERFORM] Caching of Queries + + + + +> People: +> +> Transparent "query caching" is the "industry standard" for how these +things +> are handled. However, Postgres' lack of this feature has made me +consider +> other approaches, and I'm starting to wonder if the "standard" query +caching +> -- where a materialized query result, or some reduction thereof, is cached +in +> database memory -- isn't the best way to cache things. I'm going to +> abbreviate it "SQC" for the rest of this e-mail. +> +> Obviously, the draw of SQC is its transparency to developers. With it, +the +> Java/Perl/PHP programmers and the DBA don't have to communicate at all -- +you +> set it up, give it some RAM, and it "just works". As someone who +frequently +> has to consult based on limited knowledge, I can understand the appeal. + +My sense is that pg is currently unique among popular dbmses in having the +majority of applications being homegrown (a chicken / egg / advocacy issue - +if I install a CMS, I'm not the DBA or the PHP programmer - and I don't want +to change the code; we'll see more about this when native WinPg happens). + + + + +> +> However, one of the problems with SQC, aside from the ones already +mentioned +> of stale data and/or cache-clearing, is that (at least in applications +like +> MySQL's) it is indiscriminate and caches, at least breifly, unique queries +as +> readily as common ones. Possibly Oracle's implementation is more +> sophisticated; I've not had an opportunity. + +I'm not sure I agree here. Stale data and caching choice are +optimizer/buffer manager choices and implementation can decide whether to +allow stale data. These are design choices involving development effort and +choices of where to spend server cycles and memory. All buffering choices +cache unique objects, I'm not sure why this is bad (but sensing you want +control of the choices). FWIW, this is my impression of other dbmses. + +In MySQL, a global cache can be specified with size and globally, locally, +or through statement hints in queries to suggest caching results. I don't +believe that these could be used as common subexpressions (with an exception +of MERGE table component results). The optimizer knows nothing about the +cached results - SQL select statements are hashed, and can be replaced by +the the cached statement/results on a match. + +In DB2 and Oracle result sets are not cached. They have rich sets of +materialized view features (that match your requirements). They allow a +materialized view to be synchronous with table updates or asynchronous. +Synchronous is often an unrealistic option, and asynchronous materialized +views are refreshed at a specified schedule. The optimizers allow "query +rewrite" (in Oracle it is a session option) so one can connect to the +database and specify that the optimizer is allowed to replace subexpressions +with data from (possibly stale) materialized views. SQL Server 2K has more +restrictive synchronous MVs, but I've never used them. + +So, in your example use in Oracle, you would need to define appropriate MVs +with a � hour refresh frequency, and hope that the planner would use them in +your queries. The only change in the app is on connection you would allow +use of asynchronous stale data. + +You're suggesting an alternative involving identifying common, but +expensive, subexpressions and generating MVs for them. This is a pretty +sophisticated undertaking, and probably requires some theory research to +determine if it's viable. + + +> +> The other half of that problem is that an entire query is cached, rather +than +> just the relevant data to uniquely identify the request to the +application. +> This is bad in two respects; one that the entire query needs to be parsed +to +> see if a new query is materially equivalent, and that two materially +> different queries which could utilize overlapping ranges of the same +> underlying result set must instead cache their results separately, eating +up +> yet more memory. + +There are two separate issues. The cost of parse/optimization and the cost +of results retrieval. Other dbmses hash statement text. This is a good +thing, and probably 3 orders of magnitude faster than parse and +optimization. (Oracle also has options to replace literals with parameters +and match parse trees instead of text, expecting parse costs to be less than +planning costs.) MySQL on a match simply returns the result set. Oracle and +DB2 attempt to rewrite queries to use the DBA selected extracts. The MySQL +approach seems to be almost what you're describing: all it needs is the +statement hash, statement, and result set. The rest of your wish list, +identifying and caching data to satisfy multiple request is what query +rewrite does - as long as you've created the appropriate MV. + + + + +> +> To explain what I'm talking about, let me give you a counter-example of +> another approach. +> +> I have a data-warehousing application with a web front-end. The data in +the +> application is quite extensive and complex, and only a summary is +presented +> to the public users -- but that summary is a query involving about 30 +lines +> and 16 joins. This summary information is available in 3 slightly +different +> forms. Further, the client has indicated that an up to 1/2 hour delay in +> data "freshness" is acceptable. + +This sounds like a requirement for a summary table - if the data can be +summarized appropriately, and a regular refresh process. + + + + +> +> The first step is forcing that "materialized" view of the data into +memory. +> Right now I'm working on a reliable way to do that without using +Memcached, +> which won't install on our Solaris servers. Temporary tables have the +> annoying property of being per-connection, which doesn't work in a pool of +60 +> connections. + + + + +I'm not clear on your desire to keep the data in memory. If it is because of +I/O cost of the summary table, database buffers should be caching it. If you +want to store calculated results, again - why not use a summary table? The +con of summary tables is the customization / denormalization of the data, +and the need to have programs use them instead of source data - you seem to +be willing to do each of these things. + + +> +> The second step, which I completed first due to the lack of technical +> obstacles, is to replace all queries against this data with calls to a +> Set-Returning Function (SRF). This allowed me to re-direct where the +data +> was coming from -- presumably the same thing could be done through RULES, +but +> it would have been considerably harder to implement. +> +> The first thing the SRF does is check the criteria passed to it against a +set +> of cached (in a table) criteria with that user's permission level which is +< +> 1/2 hour old. If the same criteria are found, then the SRF is returned a +> set of row identifiers for the materialized view (MV), and looks up the +rows +> in the MV and returns those to the web client. +> +> If no identical set of criteria are found, then the query is run to get a +set +> of identifiers which are then cached, and the SRF returns the queried +rows. +> +> Once I surmount the problem of storing all the caching information in +> protected memory, the advantages of this approach over SQC are several: + +You are creating summary data on demand. I have had problems with this +approach, mostly because it tends to cost more than doing it in batch and +adds latency (unfortunately adding to peak load - so I tend to prefer +periodic extract/summarize programs). In either approach why don't you want +pg to cache the data? The result also feels more like persisted object data +than typical rdbms processing. + +> +> 1) The materialized data is available in 3 different forms; a list, a +detail +> view, and a spreadsheet. Each form as somewhat different columns and +> different rules about ordering, which would likely confuse an SQC planner. +> In this implementation, all 3 forms are able to share the same cache. + + + + +I'm not clear what the issue here is. Are you summarizing data differently +or using some business rules to identify orthogonal queries? + + +> +> 2) The application is comparing only sets of unambiguous criteria rather +than +> long queries which would need to be compared in planner form in order to +> determine query equivalence. + +> +> 3) With the identifier sets, we are able to cache other information as +well, +> such as a count of rows, further limiting the number of queries we must +run. +> +> 4) This approach is ideally suited to the pagination and re-sorting common +to +> a web result set. As only the identifiers are cached, the results can be +> re-sorted and broken in to pages after the cache read, a fast, +all-in-memory +> operation. +> +> In conclusion, what I'm saying is that while forms of transparent query +> caching (plan, materialized or whatever) may be desirable for other +reasons, +> it's quite possible to achieve a superior level of "query caching" through +> tight integration with the front-end application. + +This looks like you're building an object store to support a custom app that +periodically or on demand pulls rdbms data mart data. The description of the +use seems either static, suggesting summary tables or dynamic, suggesting +that you're mimicking some function of a periodically extracted OLAP cube. + + + + +> +> If people are interested in this, I'd love to see some suggestions on ways +to +> force the materialized view into dedicated memory. + + + + +Can you identify your objections to summarizing the data and letting pg +buffer it? + +/Aaron + +From pgsql-performance-owner@postgresql.org Sat Oct 2 21:02:55 2004 +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 062E9329EDF + for ; + Sat, 2 Oct 2004 21:02:46 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64223-01 + for ; + Sat, 2 Oct 2004 20:02:41 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id CFAF4329EDA + for ; + Sat, 2 Oct 2004 21:02:40 +0100 (BST) +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 6448983; Sat, 02 Oct 2004 13:04:03 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Aaron Werman" +Subject: Re: Caching of Queries +Date: Sat, 2 Oct 2004 13:04:21 -0700 +User-Agent: KMail/1.6.2 +Cc: "Postgresql Performance" +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <200410011010.40705.josh@agliodbs.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410021304.21281.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/15 +X-Sequence-Number: 8491 + +Aaron, + +> I'm not sure I understand your req fully. + +I'm not surprised. I got wrapped up in an overly involved example and +completely left off the points I was illustrating. So here's the points, in +brief: + +1) Query caching is not a single problem, but rather several different +problems requiring several different solutions. + +2) Of these several different solutions, any particular query result caching +implementation (but particularly MySQL's) is rather limited in its +applicability, partly due to the tradeoffs required. Per your explanation, +Oracle has improved this by offering a number of configurable options. + +3) Certain other caching problems would be solved in part by the ability to +construct "in-memory" tables which would be non-durable and protected from +cache-flushing. This is what I'm interested in chatting about. + +BTW, I AM using a summary table. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sat Oct 2 22:08:07 2004 +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 A6CD2329E52 + for ; + Sat, 2 Oct 2004 22:08:02 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76250-03 + for ; + Sat, 2 Oct 2004 21:07:57 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id DFCFC329DCD + for ; + Sat, 2 Oct 2004 22:07:59 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i92L7rbx077650 + for ; Sat, 2 Oct 2004 21:07:53 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i92KjUV9072856 + for pgsql-performance@postgresql.org; Sat, 2 Oct 2004 20:45:30 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Caching of Queries +Date: Sat, 02 Oct 2004 13:47:26 -0700 +Organization: Hub.Org Networking Services +Lines: 23 +Message-ID: +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <200410011010.40705.josh@agliodbs.com> + + <200410021304.21281.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.3) Gecko/20040910 +X-Accept-Language: en-us, en +In-Reply-To: <200410021304.21281.josh@agliodbs.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/16 +X-Sequence-Number: 8492 + +Josh Berkus wrote: + +> 1) Query caching is not a single problem, but rather several different +> problems requiring several different solutions. +> +> 2) Of these several different solutions, any particular query result caching +> implementation (but particularly MySQL's) is rather limited in its +> applicability, partly due to the tradeoffs required. Per your explanation, +> Oracle has improved this by offering a number of configurable options. +> +> 3) Certain other caching problems would be solved in part by the ability to +> construct "in-memory" tables which would be non-durable and protected from +> cache-flushing. This is what I'm interested in chatting about. + +Just my 2 cents on this whole issue. I would lean towards having result +caching in pgpool versus the main backend. I want every ounce of memory +on a database server devoted to the database. Caching results would +double the effect of cache flushing ... ie, now both the results and the +pages used to build the results are in memory pushing out other stuff to +disk that may be just as important. + +If it was in pgpool or something similar, I could devote a separate +machine just for caching results leaving the db server untouched. + +From pgsql-performance-owner@postgresql.org Sat Oct 2 23:52:52 2004 +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 A52D9329D58 + for ; + Sat, 2 Oct 2004 23:52:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97466-04 + for ; + Sat, 2 Oct 2004 22:52:45 +0000 (GMT) +Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) + by svr1.postgresql.org (Postfix) with SMTP id 6DFC7329D4D + for ; + Sat, 2 Oct 2004 23:52:46 +0100 (BST) +Received: (qmail 4249 invoked by uid 0); 3 Oct 2004 08:52:42 +1000 +Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) + (russell@pws.com.au@203.45.44.212) + by mail.pws.com.au with SMTP; 3 Oct 2004 08:52:42 +1000 +From: Russell Smith +To: Ryan VanMiddlesworth +Subject: Re: Query planner problem +Date: Sun, 3 Oct 2004 08:50:28 +1000 +User-Agent: KMail/1.7 +Cc: pgsql-performance@postgresql.org +References: <200410011706.54231.ryan@vanmiddlesworth.org> +In-Reply-To: <200410011706.54231.ryan@vanmiddlesworth.org> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200410030850.28345.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/19 +X-Sequence-Number: 8495 + +On Sat, 2 Oct 2004 08:06 am, Ryan VanMiddlesworth wrote: + +[snip] +> +> +> Here is the query and EXPLAIN that runs quickly: +> SELECT case_id FROM case_data +> WHERE case_filed_date > '2004-09-16' +> AND case_filed_date < '2004-09-20' +> +> QUERY PLAN +> ------------------------------------------------------------- +> Index Scan using case_data_case_filed_date on case_data +> (cost=0.00..13790.52 rows=3614 width=18) +> Index Cond: ((case_filed_date > '2004-09-16'::date) +> AND (case_filed_date < '2004-09-20'::date)) +> +> +> And here is the query and EXPLAIN from the version that I believe the planner +> should reduce to be logically equivalent: +> SELECT case_id FROM case_data +> WHERE (('2004-09-16' IS NULL) OR (case_filed_date > '2004-09-16')) +> AND (('2004-09-20' IS NULL) OR (case_filed_date < '2004-09-20')) +> +> QUERY PLAN +> ------------------------------------------------------------- +> Seq Scan on case_data (cost=0.00..107422.02 rows=27509 width=18) +> Filter: ((('2004-09-16' IS NULL) OR (case_filed_date > '2004-09-16'::date)) +> AND (('2004-09-20' IS NULL) OR (case_filed_date < '2004-09-20'::date))) +> +> +> I was hoping that the null comparisons would get folded out by the planner +> relatively cheaply. But as you can see, the first query uses indexes and the +> second one uses sequence scans, thereby taking much longer. I guess my +> question is - is there a better way to accomplish what I'm doing in SQL or am +> I going to have to dynamically generate the statement based on supplied +> parameters? +> +The Index does not store NULL values, so you have to do a tables scan to find NULL values. +That means the second query cannot use an Index, even if it wanted to. + +Regards + +Russell Smith + + +From pgsql-performance-owner@postgresql.org Sat Oct 2 23:49:23 2004 +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 632A2329DB1 + for ; + Sat, 2 Oct 2004 23:49:21 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98901-02 + for ; + Sat, 2 Oct 2004 22:49:15 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 341DF329D9F + for ; + Sat, 2 Oct 2004 23:49:17 +0100 (BST) +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 6449455; Sat, 02 Oct 2004 15:50:40 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: William Yu +Subject: Re: Caching of Queries +Date: Sat, 2 Oct 2004 15:50:58 -0700 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <200410021304.21281.josh@agliodbs.com> +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410021550.58484.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/18 +X-Sequence-Number: 8494 + +William, + +> Just my 2 cents on this whole issue. I would lean towards having result +> caching in pgpool versus the main backend. I want every ounce of memory +> on a database server devoted to the database. Caching results would +> double the effect of cache flushing ... ie, now both the results and the +> pages used to build the results are in memory pushing out other stuff to +> disk that may be just as important. +> +> If it was in pgpool or something similar, I could devote a separate +> machine just for caching results leaving the db server untouched. + +Oddly, Joe Conway just mentioned the same idea to me. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Oct 3 00:21:07 2004 +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 C5BE6329E53 + for ; + Sun, 3 Oct 2004 00:21:05 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04698-03 + for ; + Sat, 2 Oct 2004 23:20:58 +0000 (GMT) +Received: from fuji.krosing.net (217-159-136-226-dsl.kt.estpak.ee + [217.159.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 69665329E7B + for ; + Sun, 3 Oct 2004 00:20:59 +0100 (BST) +Received: from fuji.krosing.net (localhost [127.0.0.1]) + by fuji.krosing.net (8.12.11/8.12.11) with ESMTP id i92NKnJ5005745; + Sun, 3 Oct 2004 02:20:49 +0300 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.11/8.12.11/Submit) id i92NKgYf005744; + Sun, 3 Oct 2004 02:20:42 +0300 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: inconsistent/weird index usage +From: Hannu Krosing +To: Tom Lane +Cc: Josh Berkus , + Dustin Sallings , pgsql-performance@postgresql.org +In-Reply-To: <10775.1096648455@sss.pgh.pa.us> +References: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> + <9345.1096641526@sss.pgh.pa.us> <200410010929.36026.josh@agliodbs.com> + <10775.1096648455@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1096759241.5508.2.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Sun, 03 Oct 2004 02:20:41 +0300 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/20 +X-Sequence-Number: 8496 + +On R, 2004-10-01 at 19:34, Tom Lane wrote: +> Josh Berkus writes: +> >> Most of the problem here comes from the fact that "current_date - 7" +> >> isn't reducible to a constant and so the planner is making bad guesses +> >> about how much of each table will be scanned. +> +> > I thought this was fixed in 7.4. No? +> +> No. It's not fixed as of CVS tip either, although there was some talk +> of doing something in time for 8.0. + +That's weird - my 7.4.2 databases did not consider (now()-'15 +min'::interval) to be a constant whereas 7.4.5 does (i.e. it does use +index scan on index on datetime column) + +Is this somehow different for date types ? + +-------------- +Hannu + +From pgsql-performance-owner@postgresql.org Sun Oct 3 00:21:28 2004 +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 3C743329E70 + for ; + Sun, 3 Oct 2004 00:21:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05712-01 + for ; + Sat, 2 Oct 2004 23:21:16 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 64ECC329E55 + for ; + Sun, 3 Oct 2004 00:21:18 +0100 (BST) +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 i92NLHvq026955; + Sat, 2 Oct 2004 19:21:17 -0400 (EDT) +To: Ryan VanMiddlesworth +Cc: pgsql-performance@postgresql.org +Subject: Re: Query planner problem +In-reply-to: <200410011706.54231.ryan@vanmiddlesworth.org> +References: <200410011706.54231.ryan@vanmiddlesworth.org> +Comments: In-reply-to Ryan VanMiddlesworth + message dated "Fri, 01 Oct 2004 17:06:54 -0500" +Date: Sat, 02 Oct 2004 19:21:16 -0400 +Message-ID: <26954.1096759276@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/21 +X-Sequence-Number: 8497 + +Ryan VanMiddlesworth writes: +> And here is the query and EXPLAIN from the version that I believe the planner +> should reduce to be logically equivalent: +> SELECT case_id FROM case_data +> WHERE (('2004-09-16' IS NULL) OR (case_filed_date > '2004-09-16')) +> AND (('2004-09-20' IS NULL) OR (case_filed_date < '2004-09-20')) + +> I was hoping that the null comparisons would get folded out by the planner +> relatively cheaply. + +You could teach eval_const_expressions about simplifying NullTest nodes +if you think it's important enough. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Oct 3 00:44:26 2004 +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 E645A329E70 + for ; + Sun, 3 Oct 2004 00:44:25 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09422-09 + for ; + Sat, 2 Oct 2004 23:44: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 6EC91329E53 + for ; + Sun, 3 Oct 2004 00:44:21 +0100 (BST) +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 i92NiLi8027190; + Sat, 2 Oct 2004 19:44:22 -0400 (EDT) +To: Hannu Krosing +Cc: Josh Berkus , + Dustin Sallings , pgsql-performance@postgresql.org +Subject: Re: inconsistent/weird index usage +In-reply-to: <1096759241.5508.2.camel@fuji.krosing.net> +References: <6FA9AB99-1373-11D9-A87D-000A957659CC@spy.net> + <9345.1096641526@sss.pgh.pa.us> + <200410010929.36026.josh@agliodbs.com> + <10775.1096648455@sss.pgh.pa.us> + <1096759241.5508.2.camel@fuji.krosing.net> +Comments: In-reply-to Hannu Krosing + message dated "Sun, 03 Oct 2004 02:20:41 +0300" +Date: Sat, 02 Oct 2004 19:44:21 -0400 +Message-ID: <27189.1096760661@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/22 +X-Sequence-Number: 8498 + +Hannu Krosing writes: +>> No. It's not fixed as of CVS tip either, although there was some talk +>> of doing something in time for 8.0. + +> That's weird - my 7.4.2 databases did not consider (now()-'15 +> min'::interval) to be a constant whereas 7.4.5 does (i.e. it does use +> index scan on index on datetime column) + +The question isn't whether it can use it as an indexscan bound; the +question is whether it can derive an accurate rowcount estimate. +The issue is exactly that STABLE functions work for one but not the +other. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Oct 3 14:18:16 2004 +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 7FAC7329DBF + for ; + Sun, 3 Oct 2004 14:18:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54552-08 + for ; + Sun, 3 Oct 2004 13:18:03 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id EB58E329D83 + for ; + Sun, 3 Oct 2004 14:18:02 +0100 (BST) +Received: (qmail 5130 invoked from network); 3 Oct 2004 15:18:25 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 3 Oct 2004 15:18:25 +0200 +Date: Sun, 03 Oct 2004 15:20:49 +0200 +To: "Postgresql Performance" +Subject: Re: Caching of Queries +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <1096306670.40463.173.camel@jester> <41587867.4090505@ymogen.net> + <20040930221107.GP1297@decibel.org> +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <20040930221107.GP1297@decibel.org> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/23 +X-Sequence-Number: 8499 + + +> pgpool (which makes some rather questionable claims IMO); any decent web +> application language/environment will support connection pooling. + + That's why it should not be tied to something specific as pgpool. + + If you want performance, which is the case here, usually you have a +webserver serving static files, and an application server serving dynamic +pages. + This is not necessarily a huge application server, it can be as simple as +an Apache instance serving static files, with a special path mod_proxy'ed +to another instance of apache acting as an application server. + IMHO this is a nice way to do it, because you have a light weight static +files server which can spawn many processes without using precious +resources like memory and postgres connections, and a specialized server +which has a lot less processes, each one having more size, a db +connection, etc. The connexions are permanent, of course, so there is no +connection overhead. The proxy has an extra advantage buffering the data + from the "app server" and sending it back slowly to the client, so the app +server can then very quickly process the next request instead of hogging a +db connection while the html is slowly trickled back to the client. + IMHO the standard PHP way of doing things (just one server) is wrong +because every server process, even if it's serving static files, hogs a +connection and thus needs an extra layer for pooling. + Thus, I see query result caching as a way to pushing further +architectures which are already optimized for performance, not as a +band-aid for poor design solutions like the one-apache server with pooling. + + Now, a proposition : + + Here is where we are now, a typical slow query : + PREPARE myquery(text,integer) + EXECUTE myquery('john',2) + + My proposition : + PREPARE myquery(text,integer) + PLANNED USING ('john',2) + CACHED IF $1 IS NOT NULL AND $2 IS NOT NULL + DEPENDS ON $1, $2 + MAXIMUM CACHE TIME '5 minute'::interval + MINIMUM CACHE TIME '1 minute'::interval + MAXIMUM CACHE SIZE 2000000 + AS SELECT count(*) as number FROM mytable WHERE myname=$2 AND myfield>=$1; + + EXECUTE myquery('john',2) + + Explainations : + ----------- + PLANNED USING ('john',2) + Tells the planner to compute the stored query plan using the given +parameters. This is independent from caching but could be a nice feature +as it would avoid the possibility of storing a bad query plan. + + ----------- + CACHED IF $1 IS NOT NULL AND $2 IS NOT NULL + Specifies that the result is to be cached. There is an optional condition +(here, IF ...) telling postgres of when and where it should cache, or not +cache. It could be useful to avoid wasting cache space. + ----------- + DEPENDS ON $1, $2 + Defines the cache key. I don't know if this is useful, as the query +parameters make a pretty obvious cache key so why repeat them. It could be +used to add other data as a cache key, like : + DEPENDS ON (SELECT somefunction($1)) + Also a syntax for specifying which tables should be watched for updates, +and which should be ignored, could be interesting. + ----------- + MAXIMUM CACHE TIME '5 minute'::interval + Pretty obvious. + ----------- + MINIMUM CACHE TIME '1 minute'::interval + This query is a count and I want a fast but imprecise count. Thus, I +specify a minimum cache time of 1 minute, meaning that the result will +stay in the cache even if the tables change. This is dangerous, so I'd +suggest the following : + + MINIMUM CACHE TIME CASE WHEN result.number>10 THEN '1 minute'::interval +ELSE '5 second'::interval + + Thus the cache time is an expression ; it is evaluated after performed +the query. There needs to be a way to access the 'count' result, which I +called 'result.number' because of the SELECT count() as number. + The result could also be used in the CACHE IF. + + The idea here is that the count will vary over time, but we accept some +imprecision to gain speed. SWho cares if there are 225 or 227 messages in +a forum thread counter anyway ? However, if there are 2 messages, first +caching the query is less necessary because it's fast, and second a +variation in the count will be much easier to spot, thus we specify a +shorter cache duration for small counts and a longer duration for large +counts. + + For queries returning result sets, this is not usable of course, but a +special feature for speeding count() queries would be welcome ! + + ----------- + MAXIMUM CACHE SIZE 2000000 + Pretty obvious. Size in bytes. + + For queries returning several rows, MIN/MAX on result rows could be +useful also : + MAXIMUM RESULT ROWS nnn + Or maybe : + CACHE IF (select count(*) from result) > nnn + + + + Thinking about it, using prepared queries seems a bad idea ; maybe the +cache should act on the result of functions. This would force the +application programmers to put the queries they want to optimize in +functions, but as function code is shared between connections and prepared +statements are not, maybe it would be easier to implement, and would +shield against some subtle bugs, like PREPARing the different queries +under the same name... + + In that case the cache manager would also know if the function returns +SETOF or not, which would be interesting. + + What do you think of these optimizations ? + + Right now, a count() query cache could be implemented as a simple plsql +function with a table as the cache, by the way. + + + + + + + + + + + + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Sun Oct 3 14:25:22 2004 +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 3AE82329D41 + for ; + Sun, 3 Oct 2004 14:25:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57412-01 + for ; + Sun, 3 Oct 2004 13:24:59 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E141329D3E + for ; + Sun, 3 Oct 2004 14:24:57 +0100 (BST) +Received: (qmail 5333 invoked from network); 3 Oct 2004 15:25:20 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 3 Oct 2004 15:25:20 +0200 +To: "Postgresql Performance" +Subject: Re: Caching of Queries +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <20040930221107.GP1297@decibel.org> <415CEE8E.8060805@ymogen.net> + <200410011010.40705.josh@agliodbs.com> +Message-ID: +Date: Sun, 03 Oct 2004 15:27:46 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <200410011010.40705.josh@agliodbs.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/24 +X-Sequence-Number: 8500 + + +> 1) The materialized data is available in 3 different forms; a list, a +> detail +> view, and a spreadsheet. Each form as somewhat different columns and +> different rules about ordering, which would likely confuse an SQC +> planner. +> In this implementation, all 3 forms are able to share the same cache. + + See my proposal to cache function results. + You can create a cached function and : + + SELECT your rows FROM cached_function(parameters) WHERE ... ORDER BY... +GROUP BY... + + will only fetch the function result from the cache, and then the only +additional costs are the ORDER and GROUP BY... the query parsing is very +simple, it's just a select, and a "cached function scan" + + I think caching can be made much more powerful if it is made usable like +this. I mean, not only cache a query and its result, but being able to use +cached queries internally like this and manipulaing them, adds value to +the cached data and allows storing less data in the cache because +duplicates are avoided. Thus we could use cached results in CHECK() +conditions, inside plsql functions, anywhere... + +From pgsql-performance-owner@postgresql.org Sun Oct 3 14:27:33 2004 +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 DA4B7329F19 + for ; + Sun, 3 Oct 2004 14:27:26 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55660-10 + for ; + Sun, 3 Oct 2004 13:27:17 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id C1F9F329F17 + for ; + Sun, 3 Oct 2004 14:27:17 +0100 (BST) +Received: (qmail 5407 invoked from network); 3 Oct 2004 15:27:40 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 3 Oct 2004 15:27:40 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Caching of Queries +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <200410011010.40705.josh@agliodbs.com> + + <200410021304.21281.josh@agliodbs.com> +Message-ID: +Date: Sun, 03 Oct 2004 15:30:05 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/25 +X-Sequence-Number: 8501 + + +> If it was in pgpool or something similar, I could devote a separate +> machine just for caching results leaving the db server untouched. + + BUT you would be limited to caching complete queries. There is a more +efficient strategy... + + + + +From pgsql-performance-owner@postgresql.org Sun Oct 3 16:26:35 2004 +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 C01C8329CFB + for ; + Sun, 3 Oct 2004 16:26:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85717-06 + for ; + Sun, 3 Oct 2004 15:26:33 +0000 (GMT) +Received: from sraigw.sra.co.jp (sraigw.sra.co.jp [202.32.10.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DA60329C70 + for ; + Sun, 3 Oct 2004 16:26:32 +0100 (BST) +Received: from srascb.sra.co.jp (srascb [133.137.8.65]) + by sraigw.sra.co.jp (Postfix) with ESMTP + id 91615633AD; Mon, 4 Oct 2004 00:26:30 +0900 (JST) +Received: from srascb.sra.co.jp (localhost [127.0.0.1]) + by localhost.sra.co.jp (Postfix) with ESMTP + id 795E410CD06; Mon, 4 Oct 2004 00:26:30 +0900 (JST) +Received: from sranhm.sra.co.jp (sranhm [133.137.44.16]) + by srascb.sra.co.jp (Postfix) with ESMTP + id 5FCA510CD04; Mon, 4 Oct 2004 00:26:30 +0900 (JST) +Received: from localhost (sraihb-hub.sra.co.jp [133.137.8.6]) + by sranhm.sra.co.jp (8.9.3+3.2W/3.7W-srambox) with ESMTP id AAA15518; + Mon, 4 Oct 2004 00:26:29 +0900 +Date: Mon, 04 Oct 2004 00:28:23 +0900 (JST) +Message-Id: <20041004.002823.85416338.t-ishii@sra.co.jp> +To: matt@ymogen.net +Cc: pg@rbt.ca, awerman2@hotmail.com, scottakirkwood@gmail.com, + pgsql-performance@postgresql.org +Subject: Re: Caching of Queries +From: Tatsuo Ishii +In-Reply-To: <415887AE.6070909@ymogen.net> +References: <41587867.4090505@ymogen.net> <1096317453.40463.226.camel@jester> + <415887AE.6070909@ymogen.net> +X-Mailer: Mew version 2.3 on Emacs 20.7 / Mule 4.1 + =?iso-2022-jp?B?KBskQjAqGyhCKQ==?= +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/26 +X-Sequence-Number: 8502 + +> >>More to the point though, I think this is a feature that really really +> >>should be in the DB, because then it's trivial for people to use. +> >> +> >> +> > +> >How does putting it into PGPool make it any less trivial for people to +> >use? +> > +> The answers are at http://www2b.biglobe.ne.jp/~caco/pgpool/index-e.html +> . Specifically, it's a separate application that needs configuration, +> the homepage has no real discussion of the potential pitfalls of pooling +> and what this implementation does to get around them, you get the idea. + +I don't know what you are exactly referring to in above URL when you +are talking about "potential pitfalls of pooling". Please explain +more. +-- +Tatsuo Ishii + +From pgsql-performance-owner@postgresql.org Sun Oct 3 16:27:10 2004 +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 EDC9D329D76 + for ; + Sun, 3 Oct 2004 16:27:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85945-05 + for ; + Sun, 3 Oct 2004 15:26:51 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id E4EB5329E2C + for ; + Sun, 3 Oct 2004 16:26:49 +0100 (BST) +Received: (qmail 8856 invoked from network); 3 Oct 2004 17:27:12 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 3 Oct 2004 17:27:12 +0200 +To: Shiar , pgsql-performance@postgresql.org +Subject: Re: index not used when using function +References: <20040929194131.GH22917@shiar.org> +Message-ID: +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: Sun, 03 Oct 2004 17:29:37 +0200 +In-Reply-To: <20040929194131.GH22917@shiar.org> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/27 +X-Sequence-Number: 8503 + + + Maybe add an order by artist to force a groupaggregate ? + + +> Hi all, a small question: +> +> I've got this table "songs" and an index on column artist. Since +> there's about +> one distinct artist for every 10 rows, it would be nice if it could use +> this +> index when counting artists. It doesn't however: +> +> lyrics=> EXPLAIN ANALYZE SELECT count(DISTINCT artist) FROM songs; +> Aggregate (cost=31961.26..31961.26 rows=1 width=14) (actual +> time=808.863..808.864 rows=1 loops=1) +> -> Seq Scan on songs (cost=0.00..31950.41 rows=4341 width=14) +> (actual time=26.801..607.172 rows=25207 loops=1) +> Total runtime: 809.106 ms +> +> Even with enable_seqscan to off, it just can't seem to use the index. +> The same +> query without the count() works just fine: +> +> lyrics=> EXPLAIN ANALYZE SELECT DISTINCT artist FROM songs; +> Unique (cost=0.00..10814.96 rows=828 width=14) (actual +> time=0.029..132.903 rows=3280 loops=1) +> -> Index Scan using songs_artist_key on songs (cost=0.00..10804.11 +> rows=4341 width=14) (actual time=0.027..103.448 rows=25207 loops=1) +> Total runtime: 135.697 ms +> +> Of course I can just take the number of rows from the latter query, but +> I'm +> still wondering why it can't use indexes with functions. +> +> Thanks + + + +From pgsql-performance-owner@postgresql.org Sun Oct 3 22:57:03 2004 +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 8D333329E6F + for ; + Sun, 3 Oct 2004 22:57:02 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71331-05 + for ; + Sun, 3 Oct 2004 21:56:51 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id C947E329E3D + for ; + Sun, 3 Oct 2004 22:56:53 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CEELT-0002xE-00; Sun, 03 Oct 2004 17:56:43 -0400 +To: Russell Smith +Cc: Ryan VanMiddlesworth , + pgsql-performance@postgresql.org +Subject: Re: Query planner problem +References: <200410011706.54231.ryan@vanmiddlesworth.org> + <200410030850.28345.mr-russ@pws.com.au> +In-Reply-To: <200410030850.28345.mr-russ@pws.com.au> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 03 Oct 2004 17:56:42 -0400 +Message-ID: <878yan1n51.fsf@stark.xeocode.com> +Lines: 12 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/28 +X-Sequence-Number: 8504 + + +Russell Smith writes: + +> The Index does not store NULL values + +This is false. + +Though the fact that NULL values are indexed in postgres doesn't help with +this poster's actual problem. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Oct 4 18:27:00 2004 +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 C3B3E329F5E; + Mon, 4 Oct 2004 18:26:57 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88179-07; Mon, 4 Oct 2004 17:26:52 +0000 (GMT) +Received: from fdd00lnhub.fds.com (external.fds.com [208.15.90.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0AA46329EA5; + Mon, 4 Oct 2004 18:26:51 +0100 (BST) +In-Reply-To: + +To: "Patrick Hatcher +Cc: pgsql-performance@postgresql.org, + pgsql-performance-owner@postgresql.org +Subject: Re: Slow update/insert process +MIME-Version: 1.0 +X-Mailer: Lotus Notes Release 6.5 September 18, 2003 +Message-ID: + +From: Patrick Hatcher +Date: Mon, 4 Oct 2004 10:14:13 -0700 +X-MIMETrack: Serialize by Router on FDD00LNHUB/FSG/SVR/FDD(Release 6.5.2|June + 01, 2004) at 10/04/2004 01:26:20 PM, + Serialize complete at 10/04/2004 01:26:20 PM +Content-Type: multipart/alternative; + boundary="=_alternative 005FDF4C88256F23_=" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=3.3 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_MESSAGE, LINES_OF_YELLING, LINES_OF_YELLING_2, TO_HAS_SPACES +X-Spam-Level: *** +X-Archive-Number: 200410/29 +X-Sequence-Number: 8505 + +This is a multipart message in MIME format. +--=_alternative 005FDF4C88256F23_= +Content-Type: text/plain; charset="US-ASCII" + +Thanks for the help. +I found the culprit. The user had created a function within the function +( pm.pm_price_post_inc(prod.keyp_products)). Once this was fixed the time +dropped dramatically. + + +Patrick Hatcher +Macys.Com +Legacy Integration Developer +415-422-1610 office +HatcherPT - AIM + + + +Patrick Hatcher +Sent by: pgsql-performance-owner@postgresql.org +10/01/04 11:14 AM + +To + +cc + +Subject +[PERFORM] Slow update/insert process + + + + + + + +Pg: 7.4.5 +RH 7.3 +8g Ram +200 g drive space +RAID0+1 +Tables vacuum on a nightly basis + +The following process below takes 8 hours to run on 90k records and I'm +not sure where to being to look for the bottleneck. This isn't the only +updating on this database that seems to take a long time to complete. Is +there something I should be looking for in my conf settings? + +TIA +Patrick + + +SQL: +---Bring back only selected records to run through the update process. +--Without the function the SQL takes < 10secs to return 90,000 records +SELECT count(pm.pm_delta_function_amazon(upc.keyp_upc,'amazon')) +FROM mdc_upc upc +JOIN public.mdc_products prod ON upc.keyf_products = prod.keyp_products +JOIN public.mdc_price_post_inc price ON prod.keyp_products = +price.keyf_product +JOIN public.mdc_attribute_product ap on ap.keyf_products = +prod.keyp_products and keyf_attribute=22 +WHERE +upper(trim(ap.attributevalue)) NOT IN ('ESTEE LAUDER', +'CLINIQUE','ORGINS','PRESCRIPTIVES','LANC?ME','CHANEL','ARAMIS','M.A.C','TAG +HEUER') +AND keyf_producttype<>222 +AND prod.action_publish = 1; + + +Function: + +CREATE OR REPLACE FUNCTION pm.pm_delta_function_amazon(int4, "varchar") + RETURNS bool AS +'DECLARE + varkeyf_upc ALIAS FOR $1; + varPassword ALIAS FOR $2; + varRealMD5 varchar; + varDeltaMD5 varchar; + varLastTouchDate date; + varQuery text; + varQuery1 text; + varQueryMD5 text; + varQueryRecord record; + varFuncStatus boolean := false; + +BEGIN + +-- Check the password + IF varPassword <> \'amazon\' THEN + Return false; + END IF; + + +-- Get the md5 hash for this product + SELECT into varQueryRecord md5(upc.keyp_upc || prod.description || +pm.pm_price_post_inc(prod.keyp_products)) AS md5 + FROM public.mdc_upc upc + JOIN public.mdc_products prod ON upc.keyf_products = prod.keyp_products + JOIN public.mdc_price_post_inc price ON price.keyf_product = +prod.keyp_products + WHERE upc.keyp_upc = varkeyf_upc LIMIT 1 ; + + + IF NOT FOUND THEN + RAISE EXCEPTION \'varRealMD5 is NULL. UPC ID is %\', varkeyf_upc; + ELSE + varRealMD5:=varQueryRecord.md5; + END IF; + +-- Check that the product is in the delta table and return its hash for +comparison + SELECT into varQueryRecord md5_hash,last_touch_date + FROM pm.pm_delta_master_amazon + WHERE keyf_upc = varkeyf_upc LIMIT 1; + + IF NOT FOUND THEN + -- ADD and exit + INSERT INTO pm.pm_delta_master_amazon +(keyf_upc,status,md5_hash,last_touch_date) + values (varkeyf_upc,\'add\',varRealMD5,CURRENT_DATE); + varFuncStatus:=true; + RETURN varFuncStatus; + ELSE + --Update the record + --- If the hash matches then set the record to HOLD + IF varRealMD5 = varQueryRecord.md5_hash THEN + UPDATE pm.pm_delta_master_amazon + SET status= \'hold\', + last_touch_date = CURRENT_DATE + WHERE keyf_upc = varkeyf_upc AND last_touch_date <> CURRENT_DATE; + varFuncStatus:=true; + ELSE + -- ELSE mark the item as ADD + UPDATE pm.pm_delta_master_amazon + SET status= \'add\', + last_touch_date = CURRENT_DATE + WHERE keyf_upc = varkeyf_upc; + varFuncStatus:=true; + END IF; + END IF; + + RETURN varFuncStatus; +END;' + LANGUAGE 'plpgsql' IMMUTABLE; + + + +TableDef +CREATE TABLE pm.pm_delta_master_amazon ( + keyf_upc int4 , + status varchar(6) , + md5_hash varchar(40) , + last_touch_date date + ) +GO + +CREATE INDEX status_idx + ON pm.pm_delta_master_amazon(status) +GO + + + + +CONF +-------- +# WRITE AHEAD LOG +#--------------------------------------------------------------------------- + + +# - Settings - + +#fsync = true # turns forced synchronization on or off +#wal_sync_method = fsync # the default varies across platforms: + # fsync, fdatasync, open_sync, or +open_datasync +wal_buffers = 32 # min 4, 8KB each + +# - Checkpoints - + +checkpoint_segments = 50 # in logfile segments, min 1, 16MB each +checkpoint_timeout = 600 # range 30-3600, in seconds +#checkpoint_warning = 30 # 0 is off, in seconds +#commit_delay = 0 # range 0-100000, in microseconds +#commit_siblings = 5 # range 1-1000 + + +Patrick Hatcher +Macys.Com + +--=_alternative 005FDF4C88256F23_= +Content-Type: text/html; charset="US-ASCII" + + +
Thanks for the help. +
I found the culprit.  The user +had created a function within the function ( +pm.pm_price_post_inc(prod.keyp_products)). +Once this was fixed the time dropped dramatically. +
+
+Patrick Hatcher
+Macys.Com
+Legacy Integration Developer
+415-422-1610 office
+HatcherPT - AIM
+
+
+
+ + +
Patrick Hatcher <PHatcher@macys.com> + +
Sent by: pgsql-performance-owner@postgresql.org +

10/01/04 11:14 AM +

+ + + + +
+
To
+
<pgsql-performance@postgresql.org> +
+
cc
+
+
+
Subject
+
[PERFORM] Slow update/insert +process
+
+ + +
+
+
+
+
+

+Pg: 7.4.5

+RH 7.3

+8g Ram

+200 g drive space

+RAID0+1

+Tables vacuum on a nightly basis

+

+The following process below takes 8 hours to run on 90k records and I'm +not sure where to being to look for the bottleneck.  This isn't the +only updating on this database that seems to take a long time to complete. + Is there something I should be looking for in my conf settings?  
+
+

+TIA

+Patrick

+
+

+SQL:

+---Bring back only selected records to run through the update process.
+
+--Without the function the SQL takes < 10secs to return 90,000 records
+
+SELECT count(pm.pm_delta_function_amazon(upc.keyp_upc,'amazon'))
+
+FROM mdc_upc upc

+JOIN public.mdc_products prod ON upc.keyf_products = prod.keyp_products
+
+JOIN public.mdc_price_post_inc price ON prod.keyp_products = price.keyf_product
+
+JOIN public.mdc_attribute_product ap on ap.keyf_products = prod.keyp_products +and keyf_attribute=22

+WHERE
+upper(trim(ap.attributevalue)) NOT IN ('ESTEE LAUDER', 'CLINIQUE','ORGINS','PRESCRIPTIVES','LANC?ME','CHANEL','ARAMIS','M.A.C','TAG +HEUER')

+AND keyf_producttype<>222

+AND prod.action_publish = 1;

+
+

+Function:

+
+CREATE OR REPLACE FUNCTION pm.pm_delta_function_amazon(int4, "varchar")
+ RETURNS bool AS
+'DECLARE
+   varkeyf_upc                ALIAS +FOR $1;
+   varPassword                ALIAS +FOR $2;
+   varRealMD5                varchar;
+   varDeltaMD5                varchar;
+   varLastTouchDate        date;
+   varQuery                 +text;
+   varQuery1                 +text;
+   varQueryMD5                text;
+   varQueryRecord        record;
+   varFuncStatus        boolean := false;
+  
+BEGIN
+
+-- Check the password
+ IF varPassword <> \'amazon\' THEN
+   Return false;
+ END IF;
+
+
+--  Get the md5 hash for this product
+ SELECT into varQueryRecord md5(upc.keyp_upc || prod.description || pm.pm_price_post_inc(prod.keyp_products)) +AS md5
+   FROM public.mdc_upc upc
+   JOIN public.mdc_products prod ON upc.keyf_products = prod.keyp_products
+   JOIN public.mdc_price_post_inc price ON price.keyf_product = prod.keyp_products
+   WHERE upc.keyp_upc = varkeyf_upc LIMIT 1 ;
+
+
+ IF NOT FOUND THEN
+   RAISE EXCEPTION \'varRealMD5 is NULL. UPC ID is %\', varkeyf_upc;
+ ELSE
+   varRealMD5:=varQueryRecord.md5;
+ END IF;
+
+--  Check that the product is in the delta table and return its hash +for comparison
+ SELECT into varQueryRecord md5_hash,last_touch_date
+   FROM pm.pm_delta_master_amazon
+   WHERE keyf_upc = varkeyf_upc LIMIT 1;
+
+ IF NOT FOUND THEN
+   -- ADD and exit
+   INSERT INTO pm.pm_delta_master_amazon (keyf_upc,status,md5_hash,last_touch_date)
+   values (varkeyf_upc,\'add\',varRealMD5,CURRENT_DATE);
+   varFuncStatus:=true;
+   RETURN varFuncStatus;
+ ELSE
+   --Update the record
+     --- If the hash matches then set the record to HOLD
+   IF varRealMD5 = varQueryRecord.md5_hash THEN
+       UPDATE pm.pm_delta_master_amazon
+         SET status= \'hold\',
+         last_touch_date =  CURRENT_DATE
+       WHERE keyf_upc =  varkeyf_upc AND last_touch_date +<> CURRENT_DATE;
+       varFuncStatus:=true;
+   ELSE
+       --  ELSE mark the item as ADD
+       UPDATE pm.pm_delta_master_amazon
+         SET status= \'add\',
+         last_touch_date =  CURRENT_DATE
+       WHERE keyf_upc =  varkeyf_upc;
+       varFuncStatus:=true;
+   END IF;
+  END IF;
+
+ RETURN varFuncStatus;
+END;'
+ LANGUAGE 'plpgsql' IMMUTABLE;

+
+
+

+TableDef

+CREATE TABLE pm.pm_delta_master_amazon (
+    keyf_upc               +int4 ,

+    status                 +varchar(6) ,

+    md5_hash               +varchar(40) ,

+    last_touch_date        date
+    )

+GO

+

+CREATE INDEX status_idx

+    ON pm.pm_delta_master_amazon(status)
+
+GO

+
+
+
+

+CONF

+--------

+# WRITE AHEAD LOG

+#---------------------------------------------------------------------------
+
+

+# - Settings -

+

+#fsync = true                   +# turns forced synchronization on or off

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

+                     +           # fsync, fdatasync, open_sync, +or open_datasync

+wal_buffers = 32                # +min 4, 8KB each

+

+# - Checkpoints -

+

+checkpoint_segments = 50        # in logfile segments, +min 1, 16MB each

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

+#checkpoint_warning = 30        # 0 is off, in seconds
+
+#commit_delay = 0               # range +0-100000, in microseconds

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

+Patrick Hatcher
+Macys.Com
+
+--=_alternative 005FDF4C88256F23_=-- + +From pgsql-performance-owner@postgresql.org Mon Oct 4 18:39:04 2004 +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 21BFE329F8A + for ; + Mon, 4 Oct 2004 18:39:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92935-04 + for ; + Mon, 4 Oct 2004 17:38:59 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id F1789329F6A + for ; + Mon, 4 Oct 2004 18:38:59 +0100 (BST) +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 6456240; Mon, 04 Oct 2004 10:40:21 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Steve Atkins +Subject: Re: Performance suggestions for an update-mostly database? +Date: Mon, 4 Oct 2004 10:38:14 -0700 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <20041004174019.GA25671@gp.word-to-the-wise.com> +In-Reply-To: <20041004174019.GA25671@gp.word-to-the-wise.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410041038.14571.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/31 +X-Sequence-Number: 8507 + +Steve, + +> I'm used to performance tuning on a select-heavy database, but this +> will have a very different impact on the system. Does anyone have any +> experience with an update heavy system, and have any performance hints +> or hardware suggestions? + +Minimal/no indexes on the table(s). Raise checkpoint_segments and consider +using commit_siblings/commit_delay if it's a multi-stream application. +Figure out ways to do inserts instead of updates where possible, and COPY +instead of insert, where possible. Put your WAL on its own disk resource. + +I'm a little curious as to what kind of app would be 95% writes. A log? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Oct 4 18:33:36 2004 +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 B74B432A05F + for ; + Mon, 4 Oct 2004 18:33:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91468-02 + for ; + Mon, 4 Oct 2004 17:33:29 +0000 (GMT) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id B577E32A050 + for ; + Mon, 4 Oct 2004 18:33:28 +0100 (BST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id 451CF90000E; Mon, 4 Oct 2004 10:40:19 -0700 (PDT) +Date: Mon, 4 Oct 2004 10:40:19 -0700 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Performance suggestions for an update-mostly database? +Message-ID: <20041004174019.GA25671@gp.word-to-the-wise.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/30 +X-Sequence-Number: 8506 + +I'm putting together a system where the operation mix is likely to be +>95% update, <5% select on primary key. + +I'm used to performance tuning on a select-heavy database, but this +will have a very different impact on the system. Does anyone have any +experience with an update heavy system, and have any performance hints +or hardware suggestions? + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Mon Oct 4 18:53:49 2004 +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 C4B3432A42A + for ; + Mon, 4 Oct 2004 18:53:48 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96984-03 + for ; + Mon, 4 Oct 2004 17:53:43 +0000 (GMT) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 92DDC32A417 + for ; + Mon, 4 Oct 2004 18:53:44 +0100 (BST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id 64D7190000E; Mon, 4 Oct 2004 11:00:36 -0700 (PDT) +Date: Mon, 4 Oct 2004 11:00:36 -0700 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Re: Performance suggestions for an update-mostly database? +Message-ID: <20041004180036.GA26390@gp.word-to-the-wise.com> +References: <20041004174019.GA25671@gp.word-to-the-wise.com> + <200410041038.14571.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200410041038.14571.josh@agliodbs.com> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/32 +X-Sequence-Number: 8508 + +On Mon, Oct 04, 2004 at 10:38:14AM -0700, Josh Berkus wrote: +> Steve, +> +> > I'm used to performance tuning on a select-heavy database, but this +> > will have a very different impact on the system. Does anyone have any +> > experience with an update heavy system, and have any performance hints +> > or hardware suggestions? +> +> Minimal/no indexes on the table(s). Raise checkpoint_segments and consider +> using commit_siblings/commit_delay if it's a multi-stream application. +> Figure out ways to do inserts instead of updates where possible, and COPY +> instead of insert, where possible. Put your WAL on its own disk resource. + +Thanks. + +> I'm a little curious as to what kind of app would be 95% writes. A log? + +It's the backend to a web application. The applications mix of queries +is pretty normal, but it uses a large, in-core, write-through cache +between the business logic and the database. It has more than usual +locality on queries over short time periods, so the vast majority of +reads should be answered out of the cache and not touch the database. + +In some ways something like Berkeley DB might be a better match to the +frontend, but I'm comfortable with PostgreSQL and prefer to have the +power of SQL commandline for when I need it. + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Mon Oct 4 20:00:36 2004 +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 83A49329F69 + for ; + Mon, 4 Oct 2004 20:00:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18946-09 + for ; + Mon, 4 Oct 2004 19:00:26 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 53336329E91 + for ; + Mon, 4 Oct 2004 20:00:26 +0100 (BST) +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 6456684; Mon, 04 Oct 2004 12:01:48 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Steve Atkins +Subject: Re: Performance suggestions for an update-mostly database? +Date: Mon, 4 Oct 2004 12:02:03 -0700 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <20041004174019.GA25671@gp.word-to-the-wise.com> + <200410041038.14571.josh@agliodbs.com> + <20041004180036.GA26390@gp.word-to-the-wise.com> +In-Reply-To: <20041004180036.GA26390@gp.word-to-the-wise.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410041202.03548.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/33 +X-Sequence-Number: 8509 + +Steve, + +> In some ways something like Berkeley DB might be a better match to the +> frontend, but I'm comfortable with PostgreSQL and prefer to have the +> power of SQL commandline for when I need it. + +Well, if data corruption is not a concern, you can always turn off +checkpointing. This will save you a fair amount of overhead. + +You could also look at telegraphCQ. It's not prodcucton yet, but their idea +of "streams" as data sources really seems to fit with what you're talking +about. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Oct 4 20:18:59 2004 +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 8560D329E32 + for ; + Mon, 4 Oct 2004 20:18:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27014-07 + for ; + Mon, 4 Oct 2004 19:18:52 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with ESMTP id 69A8C329D9F + for ; + Mon, 4 Oct 2004 20:18:52 +0100 (BST) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 2D86C1C8F8; Mon, 4 Oct 2004 19:18:50 +0000 (GMT) +Date: Mon, 4 Oct 2004 14:18:50 -0500 +From: "Jim C. Nasby" +To: Josh Berkus +Cc: Postgresql Performance +Subject: Re: Caching of Queries +Message-ID: <20041004191850.GS1297@decibel.org> +References: <00e801c4a4b6$5526dd30$8300a8c0@solent> + <20040930221107.GP1297@decibel.org> <415CEE8E.8060805@ymogen.net> + <200410011010.40705.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200410011010.40705.josh@agliodbs.com> +X-Operating-System: FreeBSD 4.10-RELEASE-p2 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/34 +X-Sequence-Number: 8510 + +On Fri, Oct 01, 2004 at 10:10:40AM -0700, Josh Berkus wrote: +> Transparent "query caching" is the "industry standard" for how these things +> are handled. However, Postgres' lack of this feature has made me consider +> other approaches, and I'm starting to wonder if the "standard" query caching +> -- where a materialized query result, or some reduction thereof, is cached in +> database memory -- isn't the best way to cache things. I'm going to +> abbreviate it "SQC" for the rest of this e-mail. + +Not to quibble, but are you sure that's the standard? Oracle and DB2 +don't do this, and I didn't think MSSQL did either. What they do do is +cache query *plans*. This is a *huge* deal in Oracle; search +http://asktom.oracle.com for 'soft parse'. + +In any case, I think a means of marking some specific queries as being +cachable is an excellent idea; perfect for 'static data' scenarios. What +I don't know is how much will be saved. +-- +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 Oct 4 20:23:01 2004 +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 6DFE132A47E + for ; + Mon, 4 Oct 2004 20:22:59 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28057-04 + for ; + Mon, 4 Oct 2004 19:22:53 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with ESMTP id D63BA32A318 + for ; + Mon, 4 Oct 2004 20:22:54 +0100 (BST) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 365271C8F8; Mon, 4 Oct 2004 19:22:54 +0000 (GMT) +Date: Mon, 4 Oct 2004 14:22:54 -0500 +From: "Jim C. Nasby" +To: Josh Berkus +Cc: Steve Atkins , + pgsql-performance@postgresql.org +Subject: Re: Performance suggestions for an update-mostly database? +Message-ID: <20041004192254.GT1297@decibel.org> +References: <20041004174019.GA25671@gp.word-to-the-wise.com> + <200410041038.14571.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200410041038.14571.josh@agliodbs.com> +X-Operating-System: FreeBSD 4.10-RELEASE-p2 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/35 +X-Sequence-Number: 8511 + +And obviously make sure you're vacuuming frequently. + +On Mon, Oct 04, 2004 at 10:38:14AM -0700, Josh Berkus wrote: +> Steve, +> +> > I'm used to performance tuning on a select-heavy database, but this +> > will have a very different impact on the system. Does anyone have any +> > experience with an update heavy system, and have any performance hints +> > or hardware suggestions? +> +> Minimal/no indexes on the table(s). Raise checkpoint_segments and consider +> using commit_siblings/commit_delay if it's a multi-stream application. +> Figure out ways to do inserts instead of updates where possible, and COPY +> instead of insert, where possible. Put your WAL on its own disk resource. +> +> I'm a little curious as to what kind of app would be 95% writes. A log? +> +> -- +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + +-- +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 Oct 5 00:28:05 2004 +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 A7E7B329E01 + for ; + Tue, 5 Oct 2004 00:28:01 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98525-04 + for ; + Mon, 4 Oct 2004 23:27:55 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 7ADC1329D9F + for ; + Tue, 5 Oct 2004 00:27:56 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 73so3431920rnk + for ; + Mon, 04 Oct 2004 16:27:52 -0700 (PDT) +Received: by 10.38.208.76 with SMTP id f76mr2869849rng; + Mon, 04 Oct 2004 16:27:51 -0700 (PDT) +Received: by 10.38.151.40 with HTTP; Mon, 4 Oct 2004 16:27:51 -0700 (PDT) +Message-ID: <59b2d39b0410041627d405f39@mail.gmail.com> +Date: Mon, 4 Oct 2004 16:27:51 -0700 +From: Miles Keaton +Reply-To: Miles Keaton +To: pgsql-performance@postgresql.org +Subject: would number of fields in a table affect search-query time? +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/36 +X-Sequence-Number: 8512 + +would the number of fields in a table significantly affect the +search-query time? + +(meaning: less fields = much quicker response?) + +I have this database table of items with LOTS of properties per-item, +that takes a LONG time to search. + +So as I was benchmarking it against SQLite, MySQL and some others, I +exported just a few fields for testing, into all three databases. + +What surprised me the most is that the subset, even in the original +database, gave search results MUCH faster than the full table! + +I know I'm being vague, but does anyone know if this is just common +knowledge ("duh! of course!") or if I should be looking at is as a +problem to fix? + +From pgsql-performance-owner@postgresql.org Tue Oct 5 00:32:42 2004 +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 4BAD132A2B4 + for ; + Tue, 5 Oct 2004 00:32:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98136-10 + for ; + Mon, 4 Oct 2004 23:32: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 E5F0B329E01 + for ; + Tue, 5 Oct 2004 00:32:10 +0100 (BST) +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 i94NW93t007325; + Mon, 4 Oct 2004 19:32:10 -0400 (EDT) +To: Miles Keaton +Cc: pgsql-performance@postgresql.org +Subject: Re: would number of fields in a table affect search-query time? +In-reply-to: <59b2d39b0410041627d405f39@mail.gmail.com> +References: <59b2d39b0410041627d405f39@mail.gmail.com> +Comments: In-reply-to Miles Keaton + message dated "Mon, 04 Oct 2004 16:27:51 -0700" +Date: Mon, 04 Oct 2004 19:32:09 -0400 +Message-ID: <7324.1096932729@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/37 +X-Sequence-Number: 8513 + +Miles Keaton writes: +> What surprised me the most is that the subset, even in the original +> database, gave search results MUCH faster than the full table! + +The subset table's going to be physically much smaller, so it could just +be that this reflects smaller I/O load. Hard to tell without a lot more +detail about what case you were testing. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 5 00:34:49 2004 +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 317B4329E01 + for ; + Tue, 5 Oct 2004 00:34:44 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01525-02 + for ; + Mon, 4 Oct 2004 23:34:38 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id 95EC2329DF7 + for ; + Tue, 5 Oct 2004 00:34:37 +0100 (BST) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1CEcLk-0003UO-00 + for ; Tue, 05 Oct 2004 01:34:36 +0200 +Date: Tue, 5 Oct 2004 01:34:36 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: would number of fields in a table affect search-query time? +Message-ID: <20041004233436.GB13394@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <59b2d39b0410041627d405f39@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <59b2d39b0410041627d405f39@mail.gmail.com> +X-Operating-System: Linux 2.6.6 on a i686 +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/38 +X-Sequence-Number: 8514 + +On Mon, Oct 04, 2004 at 04:27:51PM -0700, Miles Keaton wrote: +> would the number of fields in a table significantly affect the +> search-query time? + +More fields = larger records = fewer records per page = if you read in +everything, you'll need more I/O. + +> I have this database table of items with LOTS of properties per-item, +> that takes a LONG time to search. + +It's a bit hard to say anything without seeing your actual tables and +queries; I'd guess you either have a lot of matches or you're doing a +sequential scan. + +You might want to normalize your tables, but again, it's hard to say anything +without seeing your actual data. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Tue Oct 5 03:07:28 2004 +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 8C9B5329F40 + for ; + Tue, 5 Oct 2004 03:07:27 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33280-01 + for ; + Tue, 5 Oct 2004 02:07:18 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CF0D329D20 + for ; + Tue, 5 Oct 2004 03:07:20 +0100 (BST) +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 6458521; Mon, 04 Oct 2004 19:08:41 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Miles Keaton +Subject: Re: would number of fields in a table affect search-query time? +Date: Mon, 4 Oct 2004 19:06:33 -0700 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <59b2d39b0410041627d405f39@mail.gmail.com> +In-Reply-To: <59b2d39b0410041627d405f39@mail.gmail.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410041906.33483.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/39 +X-Sequence-Number: 8515 + +Miles, + +> would the number of fields in a table significantly affect the +> search-query time? + +Yes. + +In addition to the issues mentioned previously, there is the issue of +criteria; an OR query on 8 fields is going to take longer to filter than an +OR query on 2 fields. + +Anyway, I think maybe you should tell us more about your database design. +Often the fastest solution involves a more sophisticated approach toward +querying your tables. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Oct 5 07:39:39 2004 +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 AF642329CB7 + for ; + Tue, 5 Oct 2004 07:39:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92176-02 + for ; + Tue, 5 Oct 2004 06:39:26 +0000 (GMT) +Received: from pd3mo1so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net + [24.71.223.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CF2732A369 + for ; + Tue, 5 Oct 2004 07:39:25 +0100 (BST) +Received: from pd3mr3so.prod.shaw.ca + (pd3mr3so-qfe3.prod.shaw.ca [10.0.141.179]) by l-daemon + (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) + with ESMTP id <0I5300F7PMHPI420@l-daemon> for + pgsql-performance@postgresql.org; Tue, 05 Oct 2004 00:39:25 -0600 (MDT) +Received: from pn2ml10so.prod.shaw.ca ([10.0.121.80]) + by pd3mr3so.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 + (built Mar + 15 2004)) with ESMTP id <0I5300JQ4MHPSQ10@pd3mr3so.prod.shaw.ca> for + pgsql-performance@postgresql.org; Tue, 05 Oct 2004 00:39:25 -0600 (MDT) +Received: from [192.168.1.10] + (S01060050bac04c93.ed.shawcable.net [68.148.193.184]) + by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 + 2003)) with ESMTP id <0I530015CMHPQJ@l-daemon> for + pgsql-performance@postgresql.org; + Tue, 05 Oct 2004 00:39:25 -0600 (MDT) +Date: Tue, 05 Oct 2004 00:39:23 -0600 +From: Patrick Clery +Subject: Re: Comparing user attributes with bitwise operators +In-reply-to: <87sm9eluc3.fsf@stark.xeocode.com> +To: Greg Stark +Cc: pgsql-performance@postgresql.org +Message-id: <200410050039.24230.patrick@phpforhire.com> +MIME-version: 1.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: 7bit +Content-disposition: inline +References: <200409160141.37604.patrick@phpforhire.com> + <200409182126.13686.patrick@phpforhire.com> + <87sm9eluc3.fsf@stark.xeocode.com> +User-Agent: KMail/1.7 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 + tests=FAKE_HELO_SHAW_CA +X-Spam-Level: +X-Archive-Number: 200410/40 +X-Sequence-Number: 8516 + +Sorry I have taken this long to reply, Greg, but here are the results of the +personals site done with contrib/intarray: + +The first thing I did was add a serial column to the attributes table. So +instead of having a unique constraint on (attribute_id,value_id), every row +has a unique value: + +datingsite=> \d attribute_names + Table "public.attribute_names" + Column | Type | +Modifiers +----------------+-----------------------+--------------------------------------------------------------------------- + attribute_id | integer | not null default +nextval('public.attribute_names_attribute_id_seq'::text) + attribute_name | character varying(50) | not null +Indexes: + "attribute_names_pkey" PRIMARY KEY, btree (attribute_id) + "attribute_names_attribute_id_key" UNIQUE, btree (attribute_id, +attribute_name + +an example insert: +insert into attribute_names (attribute_name) values ('languages'); + + + +datingsite=> \d attribute_values + Table "public.attribute_values" + Column | Type | +Modifiers +--------------+------------------------+------------------------------------------------------------------------ + attribute_id | integer | not null + order_id | integer | not null default +(nextval('order_id_seq'::text) - 1) + label | character varying(255) | not null + value_id | integer | not null default +nextval('public.attribute_values_value_id_seq'::text) +Indexes: + "attribute_values_pkey" PRIMARY KEY, btree (value_id) +Foreign-key constraints: + "attribute_values_attribute_id_fkey" FOREIGN KEY (attribute_id) REFERENCES +attribute_names(attribute_id) + +an example insert (22 is the attribute_id of "languages"): +insert into attribute_values (attribute_id, label) values (22, 'English'); + + +The "value_id" column is where the integers inside the int[] arrays will +reference. Even age (between 18-99) and height (between 48-84) have rows for +every possible choice, as well as "Ask me!" where a user could choose to +leave that blank. + +Here is "the int[] table": + +create table people_attributes ( + person_id int references people (person_id) on delete cascade initially +deferred, + askmecount int not null default 0, + age int not null references attribute_values(value_id) on delete restrict, + gender int not null references attribute_values(value_id) on delete +restrict, + bodytype int not null references attribute_values(value_id) on delete +restrict, + children int not null references attribute_values(value_id) on delete +restrict, + drinking int not null references attribute_values(value_id) on delete +restrict, + education int not null references attribute_values(value_id) on delete +restrict, + ethnicity int not null references attribute_values(value_id) on delete +restrict, + eyecolor int not null references attribute_values(value_id) on delete +restrict, + haircolor int not null references attribute_values(value_id) on delete +restrict, + hairstyle int not null references attribute_values(value_id) on delete +restrict, + height int not null references attribute_values(value_id) on delete +restrict, + income int not null references attribute_values(value_id) on delete +restrict, + languages int[] not null, + occupation int not null references attribute_values(value_id) on delete +restrict, + orientation int not null references attribute_values(value_id) on delete +restrict, + relation int not null references attribute_values(value_id) on delete +restrict, + religion int not null references attribute_values(value_id) on delete +restrict, + smoking int not null references attribute_values(value_id) on delete +restrict, + want_children int not null references attribute_values(value_id) on delete +restrict, + weight int not null references attribute_values(value_id) on delete +restrict, + + seeking int[] not null, + + primary key (person_id) +) +without oids; + + +If you'll notice that "seeking" and "languages" are both int[] types. I did +this because those will be multiple choice. The index was created like so: + +create index people_attributes_search on people_attributes using gist ( + (array[ + age, + gender, + orientation, + children, + drinking, + education, + ethnicity, + eyecolor, + haircolor, + hairstyle, + height, + income, + occupation, + relation, + religion, + smoking, + want_children, + weight + ] + seeking + languages) gist__int_ops + ); + +seeking and languages are appended with the intarray + op. + + +I'm not going to go too in depth on how this query was generated since that +was mostly done with the PHP side of things, but from the structure it should +be obvious. I did, however, have to generate a few SQL functions using Smarty +templates since it would be way to tedious to map all these values by hand. + +There are 96,000 rows (people) in the people_attributes table. Here is what is +going on in the following query: "Show me all single (48) females (88) who +are heterosexual (92) age between 18 and 31 (95|96|97|98|99|100|101|102|103| +104|105|106|107|108)" + +EXPLAIN ANALYZE SELECT * +FROM people_attributes pa +WHERE person_id <> 1 +AND (ARRAY[age, gender, orientation, children, drinking, education, +ethnicity, eyecolor, haircolor, hairstyle, height, income, occupation, +relation, religion, smoking, want_children, weight] + seeking + languages) @@ +'48 & 89 & 92 & ( 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 +| 106 | 107 | 108 )' + + +Index Scan using people_attributes_search on people_attributes pa +(cost=0.00..386.45 rows=96 width=140) (actual time=0.057..19.266 rows=516 +loops=1) + Index Cond: (((ARRAY[age, gender, orientation, children, drinking, +education, ethnicity, eyecolor, haircolor, hairstyle, height, income, +occupation, relation, religion, smoking, want_children, weight] + seeking) + +languages) @@ '48 & 89 & 92 & ( ( ( ( ( ( ( ( ( ( ( ( ( 95 | 96 ) | 97 ) | +98 ) | 99 ) | 100 ) | 101 ) | 102 ) | 103 ) | 104 ) | 105 ) | 106 ) | 107 ) | +108 )'::query_int) + Filter: (person_id <> 1) + Total runtime: 21.646 ms + + +The speed only seems to vary significant on very broad searches, e.g: "All +females." But once the threshold of about 2 or more attributes is met, the +times are very acceptable. + +If we get a little more specific by adding "non-smokers and non-drinkers +between 18 and 22", slight improvements: + + +EXPLAIN ANALYZE SELECT * +FROM people_attributes pa +WHERE person_id <> 1 +AND (ARRAY[age, gender, orientation, children, drinking, education, +ethnicity, eyecolor, haircolor, hairstyle, height, income, occupation, +relation, religion, smoking, want_children, weight] + seeking + languages) @@ +'48 & 89 & 92 & ( 95 | 96 | 97 | 98) & 67 & 2' + +Index Scan using people_attributes_search on people_attributes pa +(cost=0.00..386.45 rows=96 width=140) (actual time=0.077..13.090 rows=32 +loops=1) + Index Cond: (((ARRAY[age, gender, orientation, children, drinking, +education, ethnicity, eyecolor, haircolor, hairstyle, height, income, +occupation, relation, religion, smoking, want_children, weight] + seeking) + +languages) @@ '48 & 89 & 92 & ( ( ( 95 | 96 ) | 97 ) | 98 ) & 67 & +2'::query_int) + Filter: (person_id <> 1) + Total runtime: 13.393 ms + + +All in all, my final thoughts on this are that it is "hella faster" than the +previous methods. Vertical tables for your user attributes will not work for +a personals site -- there are just too many conditions to be able to +efficiently use an index. Out of all the methods I have tried, verticle table +was not even remotely scalable on large amounts of data. Horizontal table is +the way to go, but it wouldn't perform like this if not for the intarray +module. The array method works quite nicely, especially for the columns like +"languages" and "seeking" that are multiple choice. However, even though this +method is fast, I still might opt for caching the results because the "real +world" search query involves a lot more and will be executed non-stop. But to +have it run this fast the first time certainly helps. + +The only drawback I can think of is that the attributes no longer have values +like 1,2,3 -- instead they could be any integer value. This puts a spin on +the programming side of things, which required me to write "code that writes +code" on a few occassions during the attribute "mapping" process. For +example, keeping an associative array of all the attributes without fetching +that data from the database each time. My advice: if you're not a masochist, +use a template engine (or simply parse out a print_r() ) to create these PHP +arrays or SQL functions. + +Greg, thanks a lot for the advice. I owe you a beer ;) + + +On Saturday 18 September 2004 23:07, you wrote: +> Patrick Clery writes: +> > PLAN +> > ------------------------------------------------------------------------- +> >-------------------------------------------------------------------------- +> >-------------- Limit (cost=6.03..6.03 rows=1 width=68) (actual +> > time=69.391..69.504 rows=10 loops=1) -> Sort (cost=6.03..6.03 rows=1 +> > width=68) (actual time=69.381..69.418 rows=10 loops=1) Sort Key: age +> > -> Index Scan using people_attributes_search on +> > people_attributes (cost=0.00..6.02 rows=1 width=68) (actual +> > time=0.068..61.648 rows=937 loops=1) Index Cond: +> > (('{30,31,32,33,34,35,36,37,38,39,40}'::integer[] && age) AND +> > ('{2}'::integer[] && gender) AND ('{1,2,4}'::integer[] && orientation)) +> > Total runtime: 69.899 ms +> > (6 rows) +> +> ... +> +> > - Is there a way of speeding up the sort? +> +> The sort seems to have only taken 8ms out of 69ms or just over 10%. As long +> as the index scan doesn't match too many records the sort should never be +> any slower so it shouldn't be the performance bottleneck. You might +> consider putting a subquery inside the order by with a limit to ensure that +> the sort never gets more than some safe maximum. Something like: +> +> select * from (select * from people_attributes where ... limit 1000) order +> by age limit 10 +> +> This means if the query matches more than 1000 it won't be sorted properly +> by age; you'll get the top 10 out of some random subset. But you're +> protected against ever having to sort more than 1000 records. +> +> > - Will using queries like " WHERE orientation IN (1,2,4) " be any +> > better/worse? +> +> Well they won't use the GiST index, so no. If there was a single column +> with a btree index then this would be the cleanest way to go. +> +> > - The queries with the GiST index are faster, but is it of any benefit +> > when the int[] arrays all contain a single value? +> +> Well you've gone from 5 minutes to 60ms. You'll have to do more than one +> test to be sure but it sure seems like it's of some benefit. +> +> If they're always a single value you could make it an expression index +> instead and not have to change your data model. +> +> Just have the fields be integers individually and make an index as: +> +> create index idx on people_attributes using gist ( +> (array[age]) gist__int_ops, +> (array[gender]) gist__int_ops, +> ... +> ) +> +> +> However I would go one step further. I would make the index simply: +> +> create index idx on people_attributes using gist ( +> (array[age,gender,orientation,...]) gist__int_ops +> ) +> +> And ensure that all of these attributes have distinct domains. Ie, that +> they don't share any values. There are 4 billion integer values available +> so that shouldn't be an issue. +> +> Then you could use query_int to compare them the way you want. You +> misunderstood how query_int is supposed to work. You index an array column +> and then you can check it against a query_int just as you're currently +> checking for overlap. Think of @@ as a more powerful version of the overlap +> operator that can do complex logical expressions. +> +> The equivalent of +> +> where '{30,31,32,33,34,35,36,37,38,39,40}'::int[] && age +> and '{2}'::int[] && gender +> and '{1,2,4}'::int[] && orientation +> +> would then become: +> +> WHERE array[age,gender,orientation] @@ +> '(30|31|32|33|34|35|36|37|38|39|40)&(2)&(1|2|4)' +> +> except you would have to change orientation and gender to not both have a +> value of 2. +> +> You might consider doing the expression index a bit of overkill actually. +> You might consider just storing a column "attributes" with an integer array +> directly in the table. +> +> You would also want a table that lists the valid attributes to be sure not +> to have any overlaps: +> +> 1 age 1 +> 2 age 2 +> ... +> 101 gender male +> 102 gender female +> 103 orientation straight +> 104 orientation gay +> 105 orientation bi +> 106 bodytype scrawny +> ... +> +> > - Is there any hope for this structure? +> +> You'll have to test this carefully. I tried using GiST indexes for my +> project and found that I couldn't load the data and build the GiST indexes +> fast enough. You have to test the costs of building and maintaining this +> index, especially since it has so many columns in it. +> +> But it looks like your queries are in trouble without it so hopefully it'll +> be ok on the insert/update side for you. + +From pgsql-performance-owner@postgresql.org Mon Oct 11 13:03:28 2004 +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 CBCFA32A080 + for ; + Tue, 5 Oct 2004 07:49:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93944-02 + for ; + Tue, 5 Oct 2004 06:49:30 +0000 (GMT) +Received: from vertigo.530collins.mel.nella.net.au + (vertigo.530collins.mel.nella.net.au [202.76.191.244]) + by svr1.postgresql.org (Postfix) with ESMTP id A014632A482 + for ; + Tue, 5 Oct 2004 07:49:27 +0100 (BST) +Received: from capricorn ([202.61.206.7]) + by vertigo.530collins.mel.nella.net.au (8.12.8/8.12.8) with SMTP id + i956rN3r017717 + for ; Tue, 5 Oct 2004 16:53:26 +1000 +From: "Chris Hutchinson" +To: +Subject: EXPLAIN ANALYZE much slower than running query normally +Date: Tue, 5 Oct 2004 16:49:26 +1000 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Importance: Normal +X--MailScanner-Information: Please contact the ISP for more information +X--MailScanner: Found to be clean +X--MailScanner-SpamScore: sss +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/130 +X-Sequence-Number: 8606 + +Running a trivial query in v7.4.2 (installed with fedora core2) using +EXPLAIN ANALYZE is taking considerably longer than just running the query +(2mins vs 6 secs). I was using this query to quickly compare a couple of +systems after installing a faster disk. + +Is this sort of slowdown to be expected? + +Here's the query: +---------------------------------------- +[chris@fedora tmp]$ time psql dbt << ENDSQL +> select count(*) from etab; +> ENDSQL + count +--------- + 9646782 +(1 row) + + +real 0m6.532s +user 0m0.005s +sys 0m0.002s +[chris@fedora tmp]$ time psql dbt << ENDSQL +> explain analyze select count(*) from etab; +> ENDSQL + QUERY PLAN + +---------------------------------------------------------------------------- +--------------- +----------------------------- + Aggregate (cost=182029.78..182029.78 rows=1 width=0) (actual +time=112701.488..112701.493 +rows=1 loops=1) + -> Seq Scan on etab (cost=0.00..157912.82 rows=9646782 width=0) (actual +time=0.053..578 +59.120 rows=9646782 loops=1) + Total runtime: 112701.862 ms +(3 rows) + + +real 1m52.716s +user 0m0.003s +sys 0m0.005s +--------------------------------------- + +Thanks in advance for any clues. + +Chris Hutchinson + + +From pgsql-performance-owner@postgresql.org Tue Oct 5 16:35:48 2004 +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 6FFDD329F70 + for ; + Tue, 5 Oct 2004 16:35:46 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50932-04 + for ; + Tue, 5 Oct 2004 15:35:36 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 33790329CDD + for ; + Tue, 5 Oct 2004 16:35:35 +0100 (BST) +Received: from solent (unknown [213.165.136.10]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id A24ABA3405; Tue, 5 Oct 2004 16:35:28 +0100 (BST) +Reply-To: +From: "Matt Clark" +To: "'Tatsuo Ishii'" +Cc: , , , + +Subject: Re: Caching of Queries +Date: Tue, 5 Oct 2004 16:35:28 +0100 +Organization: Ymogen Ltd +Message-ID: <012501c4aaf0$f12d0930$8300a8c0@solent> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +In-Reply-To: <20041004.002823.85416338.t-ishii@sra.co.jp> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/41 +X-Sequence-Number: 8517 + + +> I don't know what you are exactly referring to in above URL=20 +> when you are talking about "potential pitfalls of pooling".=20 +> Please explain more. + +Sorry, I wasn't implying that pgpool doesn't deal with the issues, just that +some people aren't necessarily aware of them up front. For instance, pgpool +does an 'abort transaction' and a 'reset all' in lieu of a full reconnect +(of course, since a full reconnect is exactly what we are trying to avoid). +Is this is enough to guarantee that a given pooled connection behaves +exactly as a non-pooled connection would from a client perspective? For +instance, temporary tables are usually dropped at the end of a session, so a +client (badly coded perhaps) that does not already use persistent +connections might be confused when the sequence 'connect, create temp table +foo ..., disconnect, connect, create temp table foo ...' results in the +error 'Relation 'foo' already exists'. + + + +From pgsql-performance-owner@postgresql.org Tue Oct 5 17:22:00 2004 +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 0675C329E12 + for ; + Tue, 5 Oct 2004 17:21:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66659-03 + for ; + Tue, 5 Oct 2004 16:21:48 +0000 (GMT) +Received: from snowwhite.lulu.com (mail.lulu.com [66.193.5.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 2956832A332 + for ; + Tue, 5 Oct 2004 17:21:47 +0100 (BST) +Received: from [10.0.0.32] (meatwad.rdu.lulu.com [10.0.0.32]) + (authenticated bits=0) + by snowwhite.lulu.com (8.12.8/8.12.8) with ESMTP id i95GMTbO017772 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) + for ; Tue, 5 Oct 2004 12:22:32 -0400 +Message-ID: <4162CA14.6080206@lulu.com> +Date: Tue, 05 Oct 2004 12:21:40 -0400 +From: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Excessive context switching on SMP Xeons +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/42 +X-Sequence-Number: 8518 + +All, + +I realize the excessive-context-switching-on-xeon issue has been +discussed at length in the past, but I wanted to follow up and verify my +conclusion from those discussions: + +On a 2-way or 4-way Xeon box, there is no way to avoid excessive +(30,000-60,000 per second) context switches when using PostgreSQL 7.4.5 +to query a data set small enough to fit into main memory under a +significant load. + +I am experiencing said symptom on two different dual-Xeon boxes, both +Dells with ServerWorks chipsets, running the latest RH9 and RHEL3 +kernels, respectively. The databases are 90% read, 10% write, and are +small enough to fit entirely into main memory, between pg shared buffers +and kernel buffers. + +We recently invested in an solid-state storage device +(http://www.superssd.com/products/ramsan-320/) to help write +performance. Our entire pg data directory is stored on it. Regrettably +(and in retrospect, unsurprisingly) we found that opening up the I/O +bottleneck does little for write performance when the server is under +load, due to the bottleneck created by excessive context switching. Is +the only solution then to move to a different SMP architecture such as +Itanium 2 or Opteron? If so, should we expect to see an additional +benefit from running PostgreSQL on a 64-bit architecture, versus 32-bit, +context switching aside? Alternatively, are there good 32-bit SMP +architectures to consider other than Xeon, given the high cost of +Itanium 2 and Opteron systems? + +More generally, how have others scaled "up" their PostgreSQL +environments? We will eventually have to invent some "outward" +scalability within the logic of our application (e.g. do read-only +transactions against a pool of Slony-I subscribers), but in the short +term we still have an urgent need to scale upward. Thoughts? General wisdom? + +Best Regards, + +Bill Montgomery + +From pgsql-performance-owner@postgresql.org Tue Oct 5 17:33:43 2004 +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 66508329F35 + for ; + Tue, 5 Oct 2004 17:33:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70476-05 + for ; + Tue, 5 Oct 2004 16:33:31 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id A1F52329F26 + for ; + Tue, 5 Oct 2004 17:33:30 +0100 (BST) +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 6461122 for pgsql-performance@postgresql.org; + Tue, 05 Oct 2004 09:34:52 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Comparing user attributes with bitwise operators +Date: Tue, 5 Oct 2004 09:32:38 -0700 +User-Agent: KMail/1.6.2 +References: <200409160141.37604.patrick@phpforhire.com> + <87sm9eluc3.fsf@stark.xeocode.com> + <200410050039.24230.patrick@phpforhire.com> +In-Reply-To: <200410050039.24230.patrick@phpforhire.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410050932.38595.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/43 +X-Sequence-Number: 8519 + +Patrick, + +First off, thanks for posting this solution! I love to see a new demo of The +Power of Postgres(tm) and have been wondering about this particular problem +since it came up on IRC. + +> The array method works quite nicely, especially for the +> columns like "languages" and "seeking" that are multiple choice. However, +> even though this method is fast, I still might opt for caching the results +> because the "real world" search query involves a lot more and will be +> executed non-stop. But to have it run this fast the first time certainly +> helps. + +Now, for the bad news: you need to test having a large load of users updating +their data. The drawback to GiST indexes is that they are low-concurrency, +because the updating process needs to lock the whole index (this has been on +our TODO list for about a decade, but it's a hard problem). + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Oct 5 17:48:37 2004 +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 EDEA132A332 + for ; + Tue, 5 Oct 2004 17:48:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75505-04 + for ; + Tue, 5 Oct 2004 16:48:30 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id C19AC329FEA + for ; + Tue, 5 Oct 2004 17:48:29 +0100 (BST) +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 6461203 for pgsql-performance@postgresql.org; + Tue, 05 Oct 2004 09:49:52 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +Date: Tue, 5 Oct 2004 09:47:36 -0700 +User-Agent: KMail/1.6.2 +References: <4162CA14.6080206@lulu.com> +In-Reply-To: <4162CA14.6080206@lulu.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410050947.36174.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/44 +X-Sequence-Number: 8520 + +Bill, + +> I realize the excessive-context-switching-on-xeon issue has been +> discussed at length in the past, but I wanted to follow up and verify my +> conclusion from those discussions: + +First off, the good news: Gavin Sherry and OSDL may have made some progress +on this. We'll be testing as soon as OSDL gets the Scalable Test Platform +running again. If you have the CS problem (which I don't think you do, see +below) and a test box, I'd be thrilled to have you test it. + +> On a 2-way or 4-way Xeon box, there is no way to avoid excessive +> (30,000-60,000 per second) context switches when using PostgreSQL 7.4.5 +> to query a data set small enough to fit into main memory under a +> significant load. + +Hmmm ... some clarification: +1) I don't really consider a CS of 30,000 to 60,000 on Xeon to be excessive. +People demonstrating the problem on dual or quad Xeon reported CS levels of +150,000 or more. So you probably don't have this issue at all -- depending +on the load, your level could be considered "normal". + +2) The problem is not limited to Xeon, Linux, or x86 architecture. It has +been demonstrated, for example, on 8-way Solaris machines. It's just worse +(and thus more noticable) on Xeon. + +> I am experiencing said symptom on two different dual-Xeon boxes, both +> Dells with ServerWorks chipsets, running the latest RH9 and RHEL3 +> kernels, respectively. The databases are 90% read, 10% write, and are +> small enough to fit entirely into main memory, between pg shared buffers +> and kernel buffers. + +Ah. Well, you do have the worst possible architecture for PostgreSQL-SMP +performance. The ServerWorks chipset is badly flawed (the company is now, I +believe, bankrupt from recalled products) and Xeons have several performance +issues on databases based on online tests. + +> We recently invested in an solid-state storage device +> (http://www.superssd.com/products/ramsan-320/) to help write +> performance. Our entire pg data directory is stored on it. Regrettably +> (and in retrospect, unsurprisingly) we found that opening up the I/O +> bottleneck does little for write performance when the server is under +> load, due to the bottleneck created by excessive context switching. + +Well, if you're CPU-bound, improved I/O won't help you, no. + +> Is +> the only solution then to move to a different SMP architecture such as +> Itanium 2 or Opteron? If so, should we expect to see an additional +> benefit from running PostgreSQL on a 64-bit architecture, versus 32-bit, +> context switching aside? + +Your performance will almost certainly be better for a variety of reasons on +Opteron/Itanium. However, I'm still not convinced that you have the CS +bug. + +> Alternatively, are there good 32-bit SMP +> architectures to consider other than Xeon, given the high cost of +> Itanium 2 and Opteron systems? + +AthalonMP appears to be less suseptible to the CS bug than Xeon, and the +effect of the bug is not as severe. However, a quad-Opteron box can be +built for less than $6000; what's your standard for "expensive"? If you +don't have that much money, then you may be stuck for options. + +> More generally, how have others scaled "up" their PostgreSQL +> environments? We will eventually have to invent some "outward" +> scalability within the logic of our application (e.g. do read-only +> transactions against a pool of Slony-I subscribers), but in the short +> term we still have an urgent need to scale upward. Thoughts? General +> wisdom? + +As long as you're on x86, scaling outward is the way to go. If you want to +continue to scale upwards, ask Andrew Sullivan about his experiences running +PostgreSQL on big IBM boxes. But if you consider an quad-Opteron server +expensive, I don't think that's an option for you. + +Overall, though, I'm not convinced that you have the CS bug and I think it's +more likely that you have a few "bad queries" which are dragging down the +whole system. Troubleshoot those and your CPU-bound problems may go away. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Oct 5 22:08:49 2004 +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 784A4329E64 + for ; + Tue, 5 Oct 2004 22:08:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55104-05 + for ; + Tue, 5 Oct 2004 21:08:35 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id D854732A0B4 + for ; + Tue, 5 Oct 2004 22:08:37 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i95L8Xc1056190 + for ; Tue, 5 Oct 2004 21:08:34 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i95L8UIW056176 + for pgsql-performance@postgresql.org; Tue, 5 Oct 2004 21:08:30 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Excessive context switching on SMP Xeons +Date: Tue, 05 Oct 2004 23:08:23 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 117 +Message-ID: <41630D47.2020704@bigfoot.com> +References: <4162CA14.6080206@lulu.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +In-Reply-To: <4162CA14.6080206@lulu.com> +X-Enigmail-Version: 0.86.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/46 +X-Sequence-Number: 8522 + +Bill Montgomery wrote: +> All, +> +> I realize the excessive-context-switching-on-xeon issue has been +> discussed at length in the past, but I wanted to follow up and verify my +> conclusion from those discussions: +> +> On a 2-way or 4-way Xeon box, there is no way to avoid excessive +> (30,000-60,000 per second) context switches when using PostgreSQL 7.4.5 +> to query a data set small enough to fit into main memory under a +> significant load. +> +> I am experiencing said symptom on two different dual-Xeon boxes, both +> Dells with ServerWorks chipsets, running the latest RH9 and RHEL3 +> kernels, respectively. The databases are 90% read, 10% write, and are +> small enough to fit entirely into main memory, between pg shared buffers +> and kernel buffers. +> + +I don't know if my box is not loaded enough but I have a dual-Xeon box, +by DELL with the HT enabled and I'm not experiencing this kind of CS +problem, normaly hour CS is around 100000 per second. + +# cat /proc/version +Linux version 2.4.9-e.24smp (bhcompile@porky.devel.redhat.com) (gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-118.7.2)) #1 SMP Tue May 27 16:07:39 EDT 2003 + + +# cat /proc/cpuinfo +processor : 0 +vendor_id : GenuineIntel +cpu family : 15 +model : 2 +model name : Intel(R) Xeon(TM) CPU 2.80GHz +stepping : 7 +cpu MHz : 2787.139 +cache size : 512 KB +fdiv_bug : no +hlt_bug : no +f00f_bug : no +coma_bug : no +fpu : yes +fpu_exception : yes +cpuid level : 2 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm +bogomips : 5557.45 + +processor : 1 +vendor_id : GenuineIntel +cpu family : 15 +model : 2 +model name : Intel(R) Xeon(TM) CPU 2.80GHz +stepping : 7 +cpu MHz : 2787.139 +cache size : 512 KB +fdiv_bug : no +hlt_bug : no +f00f_bug : no +coma_bug : no +fpu : yes +fpu_exception : yes +cpuid level : 2 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm +bogomips : 5570.56 + +processor : 2 +vendor_id : GenuineIntel +cpu family : 15 +model : 2 +model name : Intel(R) Xeon(TM) CPU 2.80GHz +stepping : 7 +cpu MHz : 2787.139 +cache size : 512 KB +fdiv_bug : no +hlt_bug : no +f00f_bug : no +coma_bug : no +fpu : yes +fpu_exception : yes +cpuid level : 2 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm +bogomips : 5570.56 + +processor : 3 +vendor_id : GenuineIntel +cpu family : 15 +model : 2 +model name : Intel(R) Xeon(TM) CPU 2.80GHz +stepping : 7 +cpu MHz : 2787.139 +cache size : 512 KB +fdiv_bug : no +hlt_bug : no +f00f_bug : no +coma_bug : no +fpu : yes +fpu_exception : yes +cpuid level : 2 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm +bogomips : 5570.56 + + + + + +Regards +Gaetano Mendola + + + + + + + + +From pgsql-performance-owner@postgresql.org Tue Oct 5 22:08:49 2004 +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 44A6C329D9F + for ; + Tue, 5 Oct 2004 22:08:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54878-06 + for ; + Tue, 5 Oct 2004 21:08:36 +0000 (GMT) +Received: from snowwhite.lulu.com (mail.lulu.com [66.193.5.50]) + by svr1.postgresql.org (Postfix) with ESMTP id C6D7032A082 + for ; + Tue, 5 Oct 2004 22:08:36 +0100 (BST) +Received: from [10.0.0.32] (meatwad.rdu.lulu.com [10.0.0.32]) + (authenticated bits=0) + by snowwhite.lulu.com (8.12.8/8.12.8) with ESMTP id i95L9LbO022592 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) + for ; Tue, 5 Oct 2004 17:09:21 -0400 +Message-ID: <41630D50.3020308@lulu.com> +Date: Tue, 05 Oct 2004 17:08:32 -0400 +From: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> +In-Reply-To: <200410050947.36174.josh@agliodbs.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/45 +X-Sequence-Number: 8521 + +Thanks for the helpful response. + +Josh Berkus wrote: + +> First off, the good news: Gavin Sherry and OSDL may have made some +> progress +> +>on this. We'll be testing as soon as OSDL gets the Scalable Test Platform +>running again. If you have the CS problem (which I don't think you do, see +>below) and a test box, I'd be thrilled to have you test it. +> + +I'd be thrilled to test it too, if for no other reason that to determine +whether what I'm experiencing really is the "CS problem". + +>1) I don't really consider a CS of 30,000 to 60,000 on Xeon to be excessive. +>People demonstrating the problem on dual or quad Xeon reported CS levels of +>150,000 or more. So you probably don't have this issue at all -- depending +>on the load, your level could be considered "normal". +> + +Fair enough. I never see nearly this much context switching on my dual +Xeon boxes running dozens (sometimes hundreds) of concurrent apache +processes, but I'll concede this could just be due to the more parallel +nature of a bunch of independent apache workers. + +>>I am experiencing said symptom on two different dual-Xeon boxes, both +>>Dells with ServerWorks chipsets, running the latest RH9 and RHEL3 +>>kernels, respectively. The databases are 90% read, 10% write, and are +>>small enough to fit entirely into main memory, between pg shared buffers +>>and kernel buffers. +>> +> +>Ah. Well, you do have the worst possible architecture for PostgreSQL-SMP +>performance. The ServerWorks chipset is badly flawed (the company is now, I +>believe, bankrupt from recalled products) and Xeons have several performance +>issues on databases based on online tests. +> + +Hence my desire for recommendations on alternate architectures ;-) + +>AthalonMP appears to be less suseptible to the CS bug than Xeon, and the +>effect of the bug is not as severe. However, a quad-Opteron box can be +>built for less than $6000; what's your standard for "expensive"? If you +>don't have that much money, then you may be stuck for options. +> + +Being a 24x7x365 shop, and these servers being mission critical, I +require vendors that can offer 24x7 4-hour part replacement, like Dell +or IBM. I haven't seen 4-way 64-bit boxes meeting that requirement for +less than $20,000, and that's for a very minimally configured box. A +suitably configured pair will likely end up costing $50,000 or more. I +would like to avoid an unexpected expense of that size, unless there's +no other good alternative. That said, I'm all ears for a cheaper +alternative that meets my support and performance requirements. + +>Overall, though, I'm not convinced that you have the CS bug and I think it's +>more likely that you have a few "bad queries" which are dragging down the +>whole system. Troubleshoot those and your CPU-bound problems may go away. +> + +You may be right, but to compare apples to apples, here's some vmstat +output from a pgbench run: + +[billm@xxx billm]$ pgbench -i -s 20 pgbench + +[billm@xxx billm]$ pgbench -s 20 -t 500 -c 100 pgbench +starting vacuum...end. +transaction type: TPC-B (sort of) +scaling factor: 20 +number of clients: 100 +number of transactions per client: 500 +number of transactions actually processed: 50000/50000 +tps = 369.717832 (including connections establishing) +tps = 370.852058 (excluding connections establishing) + +and some of the vmstat output... + +[billm@poe billm]$ vmstat 1 +procs memory swap io +system cpu + r b swpd free buff cache si so bi bo in cs us sy +wa id + 0 1 0 863108 220620 1571924 0 0 4 64 34 50 1 +0 0 98 + 0 1 0 863092 220620 1571932 0 0 0 3144 171 2037 3 +3 47 47 + 0 1 0 863084 220620 1571956 0 0 0 5840 202 3702 6 +3 46 45 + 1 1 0 862656 220620 1572420 0 0 0 12948 631 42093 69 +22 5 5 +11 0 0 862188 220620 1572828 0 0 0 12644 531 41330 70 +23 2 5 + 9 0 0 862020 220620 1573076 0 0 0 8396 457 28445 43 +17 17 22 + 9 0 0 861620 220620 1573556 0 0 0 13564 726 44330 72 +22 2 5 + 8 1 0 861248 220620 1573980 0 0 0 12564 660 43667 65 +26 2 7 + 3 1 0 860704 220624 1574236 0 0 0 14588 646 41176 62 +25 5 8 + 0 1 0 860440 220624 1574476 0 0 0 42184 865 31704 44 +23 15 18 + 8 0 0 860320 220624 1574628 0 0 0 10796 403 19971 31 +10 29 29 + 0 1 0 860040 220624 1574884 0 0 0 23588 654 36442 49 +20 13 17 + 0 1 0 859984 220624 1574932 0 0 0 4940 229 3884 5 +3 45 46 + 0 1 0 859940 220624 1575004 0 0 0 12140 355 13454 20 +10 35 35 + 0 1 0 859904 220624 1575044 0 0 0 5044 218 6922 11 +5 41 43 + 1 1 0 859868 220624 1575052 0 0 0 4808 199 2029 3 +3 47 48 + 0 1 0 859720 220624 1575180 0 0 0 21596 485 18075 28 +13 29 30 +11 1 0 859372 220624 1575532 0 0 0 24520 609 41409 62 +33 2 3 + +While pgbench does not generate quite as high a number of CS as our app, +it is an apples-to-apples comparison, and rules out the possibility of +poorly written queries in our app. Still, 40k CS/sec seems high to me. +While pgbench is just a synthetic benchmark, and not necessarily the +best benchmark, yada yada, 370 tps seems like pretty poor performance. +I've benchmarked the IO subsystem at 70MB/s of random 8k writes, yet +pgbench typically doesn't use more than 10MB/s of that bandwidth (a +little more at checkpoints). + +So I guess the question is this: now that I've opened up the IO +bottleneck that exists on most database servers, am I really truly CPU +bound now, and not just suffering from poorly handled spinlocks on my +Xeon/ServerWorks platform? If so, is the expense of a 64-bit system +worth it, or is the price/performance for PostgreSQL still better on an +alternative 32-bit platform, like AthlonMP? + +Best Regards, + +Bill Montgomery + +From pgsql-performance-owner@postgresql.org Tue Oct 5 23:37:25 2004 +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 99C54329F2F + for ; + Tue, 5 Oct 2004 23:37:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77413-05 + for ; + Tue, 5 Oct 2004 22:37:08 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id E658E329EF2 + for ; + Tue, 5 Oct 2004 23:37:09 +0100 (BST) +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 6462887 for pgsql-performance@postgresql.org; + Tue, 05 Oct 2004 15:38:32 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +Date: Tue, 5 Oct 2004 15:38:51 -0700 +User-Agent: KMail/1.6.2 +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> +In-Reply-To: <41630D50.3020308@lulu.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410051538.51664.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/47 +X-Sequence-Number: 8523 + +Bill, + +> I'd be thrilled to test it too, if for no other reason that to determine +> whether what I'm experiencing really is the "CS problem". + +Hmmm ... Gavin's patch is built against 8.0, and any version of the patch +would require linux 2.6, probably 2.6.7 minimum. Can you test on that linux +version? Do you have the resources to back-port Gavin's patch? + +> Fair enough. I never see nearly this much context switching on my dual +> Xeon boxes running dozens (sometimes hundreds) of concurrent apache +> processes, but I'll concede this could just be due to the more parallel +> nature of a bunch of independent apache workers. + +Certainly could be. Heavy CSes only happen when you have a number of +long-running processes with contention for RAM in my experience. If Apache +is dispatching thing quickly enough, they'd never arise. + +> Hence my desire for recommendations on alternate architectures ;-) + +Well, you could certainly stay on Xeon if there's better support availability. +Just get off Dell *650's. + +> Being a 24x7x365 shop, and these servers being mission critical, I +> require vendors that can offer 24x7 4-hour part replacement, like Dell +> or IBM. I haven't seen 4-way 64-bit boxes meeting that requirement for +> less than $20,000, and that's for a very minimally configured box. A +> suitably configured pair will likely end up costing $50,000 or more. I +> would like to avoid an unexpected expense of that size, unless there's +> no other good alternative. That said, I'm all ears for a cheaper +> alternative that meets my support and performance requirements. + +No, you're going to pay through the nose for that support level. It's how +things work. + +> tps = 369.717832 (including connections establishing) +> tps = 370.852058 (excluding connections establishing) + +Doesn't seem too bad to me. Have anything to compare it to? + +What's in your postgresql.conf? + +--Josh + +From pgsql-performance-owner@postgresql.org Tue Oct 5 23:56:19 2004 +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 C023632A626 + for ; + Tue, 5 Oct 2004 23:55:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82753-05 + for ; + Tue, 5 Oct 2004 22:55:32 +0000 (GMT) +Received: from pw6tiger.de (pw6tiger.de [217.160.140.116]) + by svr1.postgresql.org (Postfix) with SMTP id EFA5A32A130 + for ; + Tue, 5 Oct 2004 23:55:32 +0100 (BST) +Received: (qmail 29414 invoked by uid 505); 5 Oct 2004 22:55:29 -0000 +Received: from vygen@gmx.de by planwerk6 by uid 89 with qmail-scanner-1.14 + (virus scan: Clear:. + Processed in 0.390171 secs); 05 Oct 2004 22:55:29 -0000 +Received: from p508cd17a.dip0.t-ipconnect.de (HELO ?192.168.1.102?) + (vygen@planwerk6.de@80.140.209.122) + by pw6tiger.de with SMTP; 5 Oct 2004 22:55:28 -0000 +From: Janning Vygen +To: pgsql-performance@postgresql.org +Subject: slow rule on update +Date: Wed, 6 Oct 2004 00:55:04 +0200 +User-Agent: KMail/1.7 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200410060055.06211.vygen@gmx.de> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/48 +X-Sequence-Number: 8524 + +Hi, + +(pg_version 7.4.2, i do run vacuum analyze on the whole database frequently +and just before executing statements below) + +i dont know if anyone can help me because i dont know really where the problem +is, but i try. If any further information is needed i'll be glad to send. + +my real rule much longer (more calculation instead of "+ 1") but this shortcut +has the same disadvantages in performance: + +CREATE RULE ru_sp_update AS ON UPDATE TO Spiele +DO + UPDATE punktecache SET pc_punkte = pc_punkte + 1 + + FROM Spieletipps AS stip + NATURAL JOIN tippspieltage2spiele AS tspt2sp + + WHERE punktecache.tr_kurzname = stip.tr_kurzname + AND punktecache.mg_name = stip.mg_name + AND punktecache.tspt_name = tspt2sp.tspt_name + AND stip.sp_id = OLD.sp_id +; + +punktecache is a materialized view which should be updated by this rule + +# \d punktecache + Table "public.punktecache" + Column | Type | Modifiers +-------------+----------+----------- + tr_kurzname | text | not null + mg_name | text | not null + tspt_name | text | not null + pc_punkte | smallint | not null +Indexes: + "pk_punktecache" primary key, btree (tr_kurzname, mg_name, tspt_name) +Foreign-key constraints: + "fk_mitglieder" FOREIGN KEY (tr_kurzname, mg_name) REFERENCES +mitglieder(tr_kurzname, mg_name) ON UPDATE CASCADE ON DELETE CASCADE + "fk_tippspieltage" FOREIGN KEY (tr_kurzname, tspt_name) REFERENCES +tippspieltage(tr_kurzname, tspt_name) ON UPDATE CASCADE ON DELETE CASCADE + + +my update statement: + +explain analyze UPDATE spiele +SET sp_heimtore = spup.spup_heimtore, + sp_gasttore = spup.spup_gasttore, + sp_abpfiff = spup.spup_abpfiff +FROM spieleupdates AS spup +WHERE spiele.sp_id = spup.sp_id; + +and output from explain +[did i post explain's output right? i just copied it, but i wonder if there is +a more pretty print like method to post explain's output?] + + + Nested Loop (cost=201.85..126524.78 rows=1 width=45) (actual +time=349.694..290491.442 rows=100990 loops=1) + -> Nested Loop (cost=201.85..126518.97 rows=1 width=57) (actual +time=349.623..288222.145 rows=100990 loops=1) + -> Hash Join (cost=201.85..103166.61 rows=4095 width=64) (actual +time=131.376..8890.220 rows=102472 loops=1) + Hash Cond: (("outer".tspt_name = "inner".tspt_name) AND +("outer".tr_kurzname = "inner".tr_kurzname)) + -> Seq Scan on punktecache (cost=0.00..40970.20 rows=2065120 +width=45) (actual time=0.054..4356.321 rows=2065120 loops=1) + -> Hash (cost=178.16..178.16 rows=4738 width=35) (actual +time=102.259..102.259 rows=0 loops=1) + -> Nested Loop (cost=0.00..178.16 rows=4738 width=35) +(actual time=17.262..88.076 rows=10519 loops=1) + -> Seq Scan on spieleupdates spup +(cost=0.00..0.00 rows=1 width=4) (actual time=0.015..0.024 rows=1 loops=1) + -> Index Scan using ix_tspt2sp_fk_spiele on +tippspieltage2spiele tspt2sp (cost=0.00..118.95 rows=4737 width=31) (actual +time=17.223..69.486 rows=10519 loops=1) + Index Cond: ("outer".sp_id = tspt2sp.sp_id) + -> Index Scan using pk_spieletipps on spieletipps stip +(cost=0.00..5.69 rows=1 width=25) (actual time=2.715..2.717 rows=1 +loops=102472) + Index Cond: (("outer".tr_kurzname = stip.tr_kurzname) AND +("outer".mg_name = stip.mg_name) AND ("outer".sp_id = stip.sp_id)) + -> Index Scan using pk_spiele on spiele (cost=0.00..5.78 rows=1 width=4) +(actual time=0.012..0.014 rows=1 loops=100990) + Index Cond: (spiele.sp_id = "outer".sp_id) + Total runtime: 537319.321 ms + + +Can this be made any faster? Can you give me a hint where to start research? + +My guess is that the update statement inside the rule doesnt really uses the +index on punktecache, but i dont know why and i dont know how to change it. + +Any hint or help is is very appreciated. + +kind regards +janning + +From pgsql-performance-owner@postgresql.org Wed Oct 6 01:42:24 2004 +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 0BA7A329E93 + for ; + Wed, 6 Oct 2004 01:42:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06983-03 + for ; + Wed, 6 Oct 2004 00:42:07 +0000 (GMT) +Received: from khan.acc.umu.se (khan.acc.umu.se [130.239.18.139]) + by svr1.postgresql.org (Postfix) with ESMTP id 5BB42329D41 + for ; + Wed, 6 Oct 2004 01:42:09 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by amavisd-new (Postfix) with ESMTP id 22D0DD223 + for ; + Wed, 6 Oct 2004 02:42:08 +0200 (MEST) +Received: from shaka.acc.umu.se (shaka.acc.umu.se [130.239.18.148]) + by khan.acc.umu.se (Postfix) with ESMTP id 79363D2E2 + for ; + Wed, 6 Oct 2004 02:42:05 +0200 (MEST) +Received: by shaka.acc.umu.se (Postfix, from userid 23132) + id 385C2F; Wed, 6 Oct 2004 02:42:05 +0200 (MEST) +Date: Wed, 6 Oct 2004 02:42:04 +0200 +From: Nichlas =?iso-8859-1?Q?L=F6fdahl?= +To: pgsql-performance@postgresql.org +Subject: Planner picks the wrong plan? +Message-ID: <20041006004204.GA13074@shaka.acc.umu.se> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at acc.umu.se +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/49 +X-Sequence-Number: 8525 + +Hello! + +I'm using Postgres 7.4.5, sort_mem is 8192. Tables analyzed / vacuumed. + +Here's a function I'm using to get an age from the user's birthday: + +agey(date) -> SELECT date_part('year', age($1::timestamp)) + + +The problem is, why do the plans differ so much between Q1 & Q3 below? Something with age() being a non-IMMUTABLE function? + + +Q1: explain analyze SELECT al.pid, al.owner, al.title, al.front, al.created_at, al.n_images, u.username as owner_str, u.image as owner_image, u.puid as owner_puid FROM albums al , users u WHERE u.uid = al.owner AND al.security='a' AND al.n_images > 0 AND date_part('year', age(u.born)) > 17 AND date_part('year', age(u.born)) < 20 AND city = 1 ORDER BY al.id DESC LIMIT 9; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Limit (cost=5700.61..5700.63 rows=9 width=183) (actual time=564.291..564.299 rows=9 loops=1) + -> Sort (cost=5700.61..5700.82 rows=83 width=183) (actual time=564.289..564.291 rows=9 loops=1) + Sort Key: al.id + -> Nested Loop (cost=0.00..5697.97 rows=83 width=183) (actual time=30.029..526.211 rows=4510 loops=1) + -> Seq Scan on users u (cost=0.00..5311.05 rows=86 width=86) (actual time=5.416..421.264 rows=3021 loops=1) + Filter: ((date_part('year'::text, age((('now'::text)::date)::timestamp with time zone, (born)::timestamp with time zone)) > 17::double precision) AND (date_part('year'::text, age((('now'::text)::date)::timestamp with time zone, (born)::timestamp with time zone)) < 20::double precision) AND (city = 1)) + -> Index Scan using albums_owner_key on albums al (cost=0.00..4.47 rows=2 width=101) (actual time=0.014..0.025 rows=1 loops=3021) + Index Cond: ("outer".uid = al."owner") + Filter: (("security" = 'a'::bpchar) AND (n_images > 0)) + Total runtime: 565.120 ms +(10 rows) + + +Result when removing the second age-check (AND date_part('year', age(u.born)) < 20): + +Q2: explain analyze SELECT al.pid, al.owner, al.title, al.front, al.created_at, al.n_images, u.username as owner_str, u.image as owner_image, u.puid as owner_puid FROM albums al, users u WHERE u.uid = al.owner AND al.security='a' AND al.n_images > 0 AND date_part('year', age(u.born)) > 17 AND city = 1 ORDER BY al.id DESC LIMIT 9; +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..140.95 rows=9 width=183) (actual time=0.217..2.474 rows=9 loops=1) + -> Nested Loop (cost=0.00..86200.99 rows=5504 width=183) (actual time=0.216..2.464 rows=9 loops=1) + -> Index Scan Backward using albums_id_key on albums al (cost=0.00..2173.32 rows=27610 width=101) (actual time=0.086..1.080 rows=40 loops=1) + Filter: (("security" = 'a'::bpchar) AND (n_images > 0)) + -> Index Scan using users_pkey on users u (cost=0.00..3.03 rows=1 width=86) (actual time=0.031..0.031 rows=0 loops=40) + Index Cond: (u.uid = "outer"."owner") + Filter: ((date_part('year'::text, age((('now'::text)::date)::timestamp with time zone, (born)::timestamp with time zone)) > 17::double precision) AND (city = 1)) + Total runtime: 2.611 ms +(8 rows) + +Trying another approach: adding a separate "stale" age-column to the users-table: + +alter table users add column age smallint; +update users set age=date_part('year'::text, age((('now'::text)::date)::timestamp with time zone, (born)::timestamp with time zone)); +analyze users; + +Result with separate column: +Q3: explain analyze SELECT al.pid, al.owner, al.title, al.front, al.created_at, al.n_images, u.username as owner_str, u.image as owner_image, u.puid as owner_puid FROM albums al , users u WHERE u.uid = al.owner AND al.security='a' AND al.n_images > 0 AND age > 17 AND age < 20 AND city = 1 ORDER BY al.id DESC LIMIT 9; +-------------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..263.40 rows=9 width=183) (actual time=0.165..2.832 rows=9 loops=1) + -> Nested Loop (cost=0.00..85925.69 rows=2936 width=183) (actual time=0.163..2.825 rows=9 loops=1) + -> Index Scan Backward using albums_id_key on albums al (cost=0.00..2173.32 rows=27610 width=101) (actual time=0.043..1.528 rows=56 loops=1) + Filter: (("security" = 'a'::bpchar) AND (n_images > 0)) + -> Index Scan using users_pkey on users u (cost=0.00..3.02 rows=1 width=86) (actual time=0.020..0.020 rows=0 loops=56) + Index Cond: (u.uid = "outer"."owner") + Filter: ((age > 17) AND (age < 20) AND (city = 1)) + Total runtime: 2.973 ms +(8 rows) + +My question is, why doesn't the planner pick the same plan for Q1 & Q3? + +/Nichlas + +From pgsql-performance-owner@postgresql.org Wed Oct 6 04:24:52 2004 +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 93992329FDA + for ; + Wed, 6 Oct 2004 04:24:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40314-09 + for ; + Wed, 6 Oct 2004 03:24:49 +0000 (GMT) +Received: from roue.portalpotty.net (roue.portalpotty.net [69.44.62.206]) + by svr1.postgresql.org (Postfix) with ESMTP id 03764329FD7 + for ; + Wed, 6 Oct 2004 04:24:48 +0100 (BST) +Received: from max by roue.portalpotty.net with local (Exim 4.34) + id 1CF2Q2-0001sB-A4 + for pgsql-performance@postgresql.org; Tue, 05 Oct 2004 20:24:46 -0700 +Date: Tue, 5 Oct 2004 23:24:46 -0400 +From: Max Baker +To: pgsql-performance@postgresql.org +Subject: test post +Message-ID: <20041006032446.GB7136@warped.org> +Mail-Followup-To: pgsql-performance@postgresql.org +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.4.1i +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - roue.portalpotty.net +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [514 32003] / [47 12] +X-AntiAbuse: Sender Address Domain - roue.portalpotty.net +X-Source: /usr/bin/mutt +X-Source-Args: mutt +X-Source-Dir: /home/max +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/50 +X-Sequence-Number: 8526 + +please ignore if this goes through. They've been bouncing and I'm trying to +find out why. + +-m + +From pgsql-performance-owner@postgresql.org Wed Oct 6 04:30:17 2004 +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 BDB5632A00F + for ; + Wed, 6 Oct 2004 04:30:15 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43204-08 + for ; + Wed, 6 Oct 2004 03:30:06 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E8CC32A003 + for ; + Wed, 6 Oct 2004 04:30:04 +0100 (BST) +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 i963Turd020688; + Tue, 5 Oct 2004 23:29:57 -0400 (EDT) +To: Nichlas =?iso-8859-1?Q?L=F6fdahl?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Planner picks the wrong plan? +In-reply-to: <20041006004204.GA13074@shaka.acc.umu.se> +References: <20041006004204.GA13074@shaka.acc.umu.se> +Comments: In-reply-to Nichlas =?iso-8859-1?Q?L=F6fdahl?= + message dated "Wed, 06 Oct 2004 02:42:04 +0200" +Date: Tue, 05 Oct 2004 23:29:56 -0400 +Message-ID: <20687.1097033396@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/51 +X-Sequence-Number: 8527 + +Nichlas =?iso-8859-1?Q?L=F6fdahl?= writes: +> My question is, why doesn't the planner pick the same plan for Q1 & Q3? + +I think it's mostly that after you've added and ANALYZEd the "age" +column, the planner has a pretty good idea of how many rows will pass +the "age > 17 AND age < 20" condition. It can't do very much with the +equivalent condition in the original form, though, and in fact ends up +drastically underestimating the number of matching rows (86 vs reality +of 3021). That leads directly to a bad plan choice :-( + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Oct 6 05:50:18 2004 +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 3C601329FA5 + for ; + Wed, 6 Oct 2004 05:50:17 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64517-08 + for ; + Wed, 6 Oct 2004 04:50:07 +0000 (GMT) +Received: from wren.rentec.com (wren.rentec.com [65.213.84.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 53AFB329FA0 + for ; + Wed, 6 Oct 2004 05:50:05 +0100 (BST) +Received: from [172.16.160.107] (stange-dhcp1.rentec.com [172.16.160.107]) + by wren.rentec.com (8.12.9/8.12.1) with ESMTP id i964nueP010922; + Wed, 6 Oct 2004 00:49:57 -0400 (EDT) +Message-ID: <41636D8E.1090403@rentec.com> +Date: Tue, 05 Oct 2004 23:59:10 -0400 +From: Alan Stange +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> <200410051538.51664.josh@agliodbs.com> +In-Reply-To: <200410051538.51664.josh@agliodbs.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/52 +X-Sequence-Number: 8528 + +A few quick random observations on the Xeon v. Opteron comparison: + +- running a dual Xeon with hyperthreading turned on really isn't the +same as having a quad cpu system. I haven't seen postgresql specific +benchmarks, but the general case has been that HT is a benefit in a few +particular work loads but with no benefit in general. + +- We're running postgresql 8 (in production!) on a dual Opteron 250, +Linux 2.6, 8GB memory, 1.7TB of attached fiber channel disk, etc. This +machine is fast. A dual 2.8 Ghz Xeon with 512K caches (with or +without HT enabled) simlpy won't be in the same performance league as +this dual Opteron system (assuming identical disk systems, etc). We run +a Linux 2.6 kernel because it scales under load so much better than the +2.4 kernels. + +The units we're using (and we have a lot of them) are SunFire v20z. You +can get a dualie Opteron 250 for $7K with 4GB memory from Sun. My +personal experience with this setup in a mission critical config is to +not depend on 4 hour spare parts, but to spend the money and install the +spare in the rack. Naturally, one can go cheaper with slower cpus, +different vendors, etc. + + +I don't care to go into the whole debate of Xeon v. Opteron here. We +also have a lot of dual Xeon systems. In every comparison I've done with +our codes, the dual Opteron clearly outperforms the dual Xeon, when +running on one and both cpus. + + +-- Alan + + + +Josh Berkus wrote: + +>Bill, +> +> +> +>>I'd be thrilled to test it too, if for no other reason that to determine +>>whether what I'm experiencing really is the "CS problem". +>> +>> +> +>Hmmm ... Gavin's patch is built against 8.0, and any version of the patch +>would require linux 2.6, probably 2.6.7 minimum. Can you test on that linux +>version? Do you have the resources to back-port Gavin's patch? +> +> +> +>>Fair enough. I never see nearly this much context switching on my dual +>>Xeon boxes running dozens (sometimes hundreds) of concurrent apache +>>processes, but I'll concede this could just be due to the more parallel +>>nature of a bunch of independent apache workers. +>> +>> +> +>Certainly could be. Heavy CSes only happen when you have a number of +>long-running processes with contention for RAM in my experience. If Apache +>is dispatching thing quickly enough, they'd never arise. +> +> +> +>>Hence my desire for recommendations on alternate architectures ;-) +>> +>> +> +>Well, you could certainly stay on Xeon if there's better support availability. +>Just get off Dell *650's. +> +> +> +>>Being a 24x7x365 shop, and these servers being mission critical, I +>>require vendors that can offer 24x7 4-hour part replacement, like Dell +>>or IBM. I haven't seen 4-way 64-bit boxes meeting that requirement for +>>less than $20,000, and that's for a very minimally configured box. A +>>suitably configured pair will likely end up costing $50,000 or more. I +>>would like to avoid an unexpected expense of that size, unless there's +>>no other good alternative. That said, I'm all ears for a cheaper +>>alternative that meets my support and performance requirements. +>> +>> +> +>No, you're going to pay through the nose for that support level. It's how +>things work. +> +> +> +>>tps = 369.717832 (including connections establishing) +>>tps = 370.852058 (excluding connections establishing) +>> +>> +> +>Doesn't seem too bad to me. Have anything to compare it to? +> +>What's in your postgresql.conf? +> +>--Josh +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> + + +From pgsql-performance-owner@postgresql.org Mon Oct 11 13:03:40 2004 +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 AA8BD32A05D + for ; + Wed, 6 Oct 2004 08:31:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98677-02 + for ; + Wed, 6 Oct 2004 07:30:57 +0000 (GMT) +Received: from www.hanseo.hs.kr (unknown [210.90.30.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FAB232A256 + for ; + Wed, 6 Oct 2004 08:30:56 +0100 (BST) +Received: from [192.168.123.8] ([211.238.40.5]) (authenticated bits=0) + by www.hanseo.hs.kr (8.12.9/8.12.9) with ESMTP id i967Ud0X003214 + for ; Wed, 6 Oct 2004 16:30:44 +0900 +Message-ID: <41639F3C.4050103@siche.net> +Date: Wed, 06 Oct 2004 16:31:08 +0900 +From: HyunSung Jang +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: ko-kr, ko, en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: why my query is not using index?? +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/131 +X-Sequence-Number: 8607 + +postgres=# explain ANALYZE select * from test where today < '2004-01-01'; + QUERY PLAN +---------------------------------------------------------------------------------------------------- + Seq Scan on test (cost=0.00..19.51 rows=334 width=44) (actual +time=0.545..2.429 rows=721 loops=1) + Filter: (today < '2004-01-01 00:00:00'::timestamp without time zone) + Total runtime: 3.072 ms +(3 rows) + +postgres=# explain ANALYZE select * from test where today > '2003-01-01' +and today < '2004-01-01'; + QUERY +PLAN +----------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using idx_today on test (cost=0.00..18.89 rows=6 width=44) +(actual time=0.055..1.098 rows=365 loops=1) + Index Cond: ((today > '2003-01-01 00:00:00'::timestamp without time +zone) AND (today < '2004-01-01 00:00:00'::timestamp without time zone)) + Total runtime: 1.471 ms +(3 rows) + +hello + +I was expected 1st query should using index, but it doesn't +2nd query doing perfect as you see. + +can you explain to me why it's not doing that i expected?? +now I'm currently using postgresql 8.0pre3 on linux + +/hyunsung jang. + +From pgsql-performance-owner@postgresql.org Wed Oct 6 08:44:26 2004 +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 AA6A132A07F + for ; + Wed, 6 Oct 2004 08:44:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01996-02 + for ; + Wed, 6 Oct 2004 07:44:12 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id E1D6B32A3F6 + for ; + Wed, 6 Oct 2004 08:44:13 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CF6Sw-0004sI-00; Wed, 06 Oct 2004 03:44:02 -0400 +To: Alan Stange +Cc: josh@agliodbs.com, pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> <200410051538.51664.josh@agliodbs.com> + <41636D8E.1090403@rentec.com> +In-Reply-To: <41636D8E.1090403@rentec.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 06 Oct 2004 03:44:02 -0400 +Message-ID: <87acv0z3y5.fsf@stark.xeocode.com> +Lines: 29 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/53 +X-Sequence-Number: 8529 + + +Alan Stange writes: + +> A few quick random observations on the Xeon v. Opteron comparison: +> +> - running a dual Xeon with hyperthreading turned on really isn't the same as +> having a quad cpu system. I haven't seen postgresql specific benchmarks, but +> the general case has been that HT is a benefit in a few particular work +> loads but with no benefit in general. + +Part of the FUD with hyperthreading did have a kernel of truth that lied in +older kernels' schedulers. For example with Linux until recently the kernel +can easily end up scheduling two processes on the two virtual processors of +one single physical processor, leaving the other physical processor totally +idle. + +With modern kernels' schedulers I would expect hyperthreading to live up to +its billing of adding 10% to 20% performance. Ie., a dual Xeon machine with +hyperthreading won't be as fast as four processors, but it should be 10-20% +faster than a dual Xeon without hyperthreading. + +As with all things that will only help if you're bound by the right limited +resource to begin with. If you're I/O bound it isn't going to help. I would +expect Postgres with its heavy demand on memory bandwidth and shared memory +could potentially benefit more than usual from being able to context switch +during pipeline stalls. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Oct 6 10:29:28 2004 +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 4B882329F04 + for ; + Wed, 6 Oct 2004 10:29:27 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30492-01 + for ; + Wed, 6 Oct 2004 09:29:15 +0000 (GMT) +Received: from mail.hamburg.cityline.net (ns.mcs-hh.de [194.77.146.129]) + by svr1.postgresql.org (Postfix) with ESMTP id 8863532A188 + for ; + Wed, 6 Oct 2004 10:29:15 +0100 (BST) +Received: from [212.1.56.10] (helo=aconitin.toxine.lan) + by mail.hamburg.cityline.net with asmtp (TLSv1:RC4-MD5:128) + (Exim 4.32) id 1CF86j-0004rG-Si + for pgsql-performance@postgresql.org; Wed, 06 Oct 2004 11:29:13 +0200 +From: Ole Langbehn +Organization: freiheit.com +To: pgsql-performance@postgresql.org +Subject: sequential scan on select distinct +Date: Wed, 6 Oct 2004 11:30:58 +0200 +User-Agent: KMail/1.7 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200410061130.58625.ole@freiheit.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/54 +X-Sequence-Number: 8530 + +Hi, + +I'm using Postgres 7.4.5. Tables are analyzed & vacuumed. + +I am wondering why postgresql never uses an index on queries of the type +'select distinct ...' while e.g. mysql uses the index on the same query. +See the following explains: + + +postgresql: + +explain analyze select distinct "land" from "customer_dim"; +---------------------------------------------------------------------------= +------------------------------------------------------------+ + QUERY PLAN = + | +---------------------------------------------------------------------------= +------------------------------------------------------------+ + Unique (cost=3D417261.85..430263.66 rows=3D18 width=3D15) (actual time=3D= +45875.235..67204.694 rows=3D103 loops=3D1) | + -> Sort (cost=3D417261.85..423762.75 rows=3D2600362 width=3D15) (actua= +l time=3D45875.226..54114.473 rows=3D2600362 loops=3D1) | + Sort Key: land = + | + -> Seq Scan on customer_dim (cost=3D0.00..84699.62 rows=3D260036= +2 width=3D15) (actual time=3D0.048..10733.227 rows=3D2600362 loops=3D1) | + Total runtime: 67246.465 ms = + | +---------------------------------------------------------------------------= +------------------------------------------------------------+ + + +mysql: + +explain select DISTINCT `customer_dim`.`land` from `customer_dim`; +--------------+-------+---------------+---------------+---------+--------+-= +--------+-------------+ + table | type | possible_keys | key | key_len | ref | = + rows | Extra | +--------------+-------+---------------+---------------+---------+--------+-= +--------+-------------+ + customer_dim | index | [NULL] | IDX_cstd_land | 81 | [NULL] | = +2600362 | Using index | +--------------+-------+---------------+---------------+---------+--------+-= +--------+-------------+ +1 row in result (first row: 8 msec; total: 9 msec) + + + +The result set contains 103 rows (but i get this behavior with every query = +of +this kind). My tables consist of at least a million rows. + +The indexes on the column 'land' are standard indexes, so in case of +postgresql, it's a btree-index. I've tried to change the index type, but to= + no +avail. + +So, why doesn't postgresql use the index, and (how) could i persuade postgr= +esql +to use an index for this type of query? + +TiA + +--=20 +Ole Langbehn + +freiheit.com technologies gmbh +Theodorstr. 42-90 / 22761 Hamburg, Germany +fon =A0 =A0 =A0 +49 (0)40 / 890584-0 +fax =A0 =A0 =A0 +49 (0)40 / 890584-20 + +Freie Software durch B=FCcherkauf f=F6rdern | http://bookzilla.de/ + +From pgsql-benchmarks-owner@postgresql.org Wed Oct 6 11:15:49 2004 +X-Original-To: pgsql-benchmarks-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 34DD6329D7F; + Wed, 6 Oct 2004 11:15:46 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40870-09; Wed, 6 Oct 2004 10:15:33 +0000 (GMT) +Received: from mailer.unicite.fr.netcentrex.net (unknown [62.161.167.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B0F4329CDD; + Wed, 6 Oct 2004 11:15:33 +0100 (BST) +Received: from [192.168.101.228] ([192.168.101.228]) by + mailer.unicite.fr.netcentrex.net with SMTP (Microsoft Exchange + Internet Mail Service Version 5.5.2657.72) + id 42CX026B; Wed, 6 Oct 2004 12:15:32 +0200 +Message-ID: <4163C5C3.3030304@fr.netcentrex.net> +Date: Wed, 06 Oct 2004 12:15:31 +0200 +From: =?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= + +Organization: NetCentrex +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-benchmarks@postgresql.org, pgsql-performance@postgresql.org +Subject: stats on cursor and query execution troubleshooting +Content-Type: multipart/alternative; + boundary="------------040806000209030206000904" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/1 +X-Sequence-Number: 18 + +This is a multi-part message in MIME format. +--------------040806000209030206000904 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable + +Hi, + +I'm looking for the statistic of memory, CPU, filesystem access while=20 +executing some regular SQL query, and I want to compare them to +same kind of results while executing a cursor function. + +The stat collector give me good results (sequencial scans , acceded=20 +tuple .....) for regular query but nor for cursor (as explain in the=20 +documentation) + +For more results, i have activated some log level in the postgresql.conf : + show_query_stats =3D true + +But I have some trouble in the results interpretation such as : + +! system usage stats: + +! 2.776053 elapsed 1.880000 user 0.520000 system sec + +! [1.910000 user 0.540000 sys total] + +! 0/0 [0/0] filesystem blocks in/out + +! 5/1 [319/148] page faults/reclaims, 0 [0] swaps + +! 0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent + +! 0/0 [0/0] voluntary/involuntary context switches + +! postgres usage stats: + +! Shared blocks: 3877 read, 0 written, buffer hit rate= + =3D 0.00% + +! Local blocks: 0 read, 0 written, buffer hit rate= + =3D 0.00% + +! Direct blocks: 0 read, 0 written + +Here is result done after fetching ALL a row with 178282 records in the=20 +table. +looking at the i/o stat of linux I saw a filesystem access while=20 +executing this request but not in the previous log !!! + +! 0/0 [0/0] filesystem blocks in/out + + +I'm running postgresql 7.2.4 under redhat 7.2 + +Does am i wrong in my interpretation ? + +Does any newest postgresql version could told me execution paln for a=20 +fetch AND better stats ? + +thx + +Ps: please excuse my poor english + +--=20 +Alban M=E9dici +R&D software engineer +------------------------------ +you can contact me @ : +http://www.netcentrex.net +------------------------------ + + +--------------040806000209030206000904 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + +Hi,
+
+I'm looking for the statistic of memory,  CPU,  filesystem access while +executing some regular SQL query,  and I want to compare them to
+same kind of results while executing a cursor function.
+
+The stat collector give me good results (sequencial scans ,  acceded +tuple .....)  for regular query but nor for cursor (as explain in the +documentation)
+
+For more results, i have activated some log level in the +postgresql.conf :
+    show_query_stats = true
+
+But I have some trouble in the results interpretation  such as :
+
+
! system usage stats:
+
!       2.776053 elapsed 1.880000 user 0.520000 system sec
+
!       [1.910000 user 0.540000 sys total]
+
!       0/0 [0/0] filesystem blocks in/out
+
!       5/1 [319/148] page faults/reclaims, 0 [0] swaps
+
!       0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent
+
!       0/0 [0/0] voluntary/involuntary context switches
+
! postgres usage stats:
+
!       Shared blocks:       3877 read,          0 written, buffer hit rate = 0.00%
+
!       Local  blocks:          0 read,          0 written, buffer hit rate = 0.00%
+!       Direct blocks:          0 +read,          0 written
+
+Here is  result done after fetching ALL a row with 178282 records in +the table.
+looking at the i/o stat of linux I saw a filesystem access while +executing this request but not in the previous log !!!
+
!       0/0 [0/0] filesystem blocks in/out
+
+
+I'm running postgresql 7.2.4  under redhat 7.2
+
+Does am i wrong in my interpretation ?
+
+Does any newest postgresql version could told me execution paln for a +fetch AND better stats ?
+
+thx
+
+Ps: please excuse my poor english
+
+
-- 
+Alban Médici
+R&D software engineer
+------------------------------
+you can contact me @ :
+http://www.netcentrex.net
+------------------------------
+ + + +--------------040806000209030206000904-- + +From pgsql-performance-owner@postgresql.org Wed Oct 6 11:16:50 2004 +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 CC07432A3A5 + for ; + Wed, 6 Oct 2004 11:16:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41331-09 + for ; + Wed, 6 Oct 2004 10:16:31 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 61CA332A2ED + for ; + Wed, 6 Oct 2004 11:16:21 +0100 (BST) +Received: (qmail 3818 invoked from network); 6 Oct 2004 12:16:46 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 6 Oct 2004 12:16:46 +0200 +To: "Ole Langbehn" , + pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +References: <200410061130.58625.ole@freiheit.com> +Message-ID: +Date: Wed, 06 Oct 2004 12:19:24 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <200410061130.58625.ole@freiheit.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/56 +X-Sequence-Number: 8532 + + + You could try : + + explain analyze select "land" from "customer_dim" group by "land"; + It will be a lot faster but I can't make it use the index on my machine... + + Example : + + create table dummy as (select id, id%255 as number from a large table +with 1M rows); + so we have a table with 256 (0-255) disctinct "number" values. + +-------------------------------------------------------------------------------- +=> explain analyze select distinct number from dummy; + Unique (cost=69.83..74.83 rows=200 width=4) (actual +time=13160.490..14414.004 rows=255 loops=1) + -> Sort (cost=69.83..72.33 rows=1000 width=4) (actual +time=13160.483..13955.792 rows=1000000 loops=1) + Sort Key: number + -> Seq Scan on dummy (cost=0.00..20.00 rows=1000 width=4) +(actual time=0.052..1759.145 rows=1000000 loops=1) + Total runtime: 14442.872 ms + +=> Horribly slow because it has to sort 1M rows for the Unique. + +-------------------------------------------------------------------------------- +=> explain analyze select number from dummy group by number; + HashAggregate (cost=22.50..22.50 rows=200 width=4) (actual +time=1875.214..1875.459 rows=255 loops=1) + -> Seq Scan on dummy (cost=0.00..20.00 rows=1000 width=4) (actual +time=0.107..1021.014 rows=1000000 loops=1) + Total runtime: 1875.646 ms + +=> A lot faster because it HashAggregates instead of sorting (but still +seq scan) + +-------------------------------------------------------------------------------- +Now : +create index dummy_idx on dummy(number); +Let's try again. +-------------------------------------------------------------------------------- +explain analyze select distinct number from dummy; + Unique (cost=0.00..35301.00 rows=200 width=4) (actual +time=0.165..21781.732 rows=255 loops=1) + -> Index Scan using dummy_idx on dummy (cost=0.00..32801.00 +rows=1000000 width=4) (actual time=0.162..21154.752 rows=1000000 loops=1) + Total runtime: 21782.270 ms + +=> Index scan the whole table. argh. I should have ANALYZized. +-------------------------------------------------------------------------------- +explain analyze select number from dummy group by number; + HashAggregate (cost=17402.00..17402.00 rows=200 width=4) (actual +time=1788.425..1788.668 rows=255 loops=1) + -> Seq Scan on dummy (cost=0.00..14902.00 rows=1000000 width=4) +(actual time=0.048..960.063 rows=1000000 loops=1) + Total runtime: 1788.855 ms +=> Still the same... +-------------------------------------------------------------------------------- +Let's make a function : +The function starts at the lowest number and advances to the next number +in the index until they are all exhausted. + + +CREATE OR REPLACE FUNCTION sel_distinct() + RETURNS SETOF INTEGER + LANGUAGE plpgsql + AS ' +DECLARE + pos INTEGER; +BEGIN + SELECT INTO pos number FROM dummy ORDER BY number ASC LIMIT 1; + IF NOT FOUND THEN + RAISE NOTICE ''no records.''; + RETURN; + END IF; + + LOOP + RETURN NEXT pos; + SELECT INTO pos number FROM dummy WHERE number>pos ORDER BY number ASC +LIMIT 1; + IF NOT FOUND THEN + RETURN; + END IF; + END LOOP; +END; +'; + +explain analyze select * from sel_distinct(); + Function Scan on sel_distinct (cost=0.00..12.50 rows=1000 width=4) +(actual time=215.472..215.696 rows=255 loops=1) + Total runtime: 215.839 ms + + That's better ! +-------------------------------------------------------------------------------- +Why not use DESC instead of ASC ? + +CREATE OR REPLACE FUNCTION sel_distinct() + RETURNS SETOF INTEGER + LANGUAGE plpgsql + AS ' +DECLARE + pos INTEGER; +BEGIN + SELECT INTO pos number FROM dummy ORDER BY number DESC LIMIT 1; + IF NOT FOUND THEN + RAISE NOTICE ''no records.''; + RETURN; + END IF; + + LOOP + RETURN NEXT pos; + SELECT INTO pos number FROM dummy WHERE number; + Wed, 6 Oct 2004 14:11:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91108-04 + for ; + Wed, 6 Oct 2004 13:11:52 +0000 (GMT) +Received: from wren.rentec.com (wren.rentec.com [65.213.84.9]) + by svr1.postgresql.org (Postfix) with ESMTP id DC9B532A160 + for ; + Wed, 6 Oct 2004 14:11:53 +0100 (BST) +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by wren.rentec.com (8.12.9/8.12.1) with ESMTP id i96DBpeP003622; + Wed, 6 Oct 2004 09:11:51 -0400 (EDT) +Message-ID: <4163EF16.3030804@rentec.com> +Date: Wed, 06 Oct 2004 09:11:50 -0400 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +References: <4162CA14.6080206@lulu.com> + <200410050947.36174.josh@agliodbs.com> <41630D50.3020308@lulu.com> + <200410051538.51664.josh@agliodbs.com> <41636D8E.1090403@rentec.com> + <87acv0z3y5.fsf@stark.xeocode.com> +In-Reply-To: <87acv0z3y5.fsf@stark.xeocode.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.3 tagged_above=0.0 required=5.0 tests=BETTERMEMORY +X-Spam-Level: +X-Archive-Number: 200410/57 +X-Sequence-Number: 8533 + +Greg Stark wrote: + +>Alan Stange writes: +> +> +>>A few quick random observations on the Xeon v. Opteron comparison: +>> +>>- running a dual Xeon with hyperthreading turned on really isn't the same as +>>having a quad cpu system. I haven't seen postgresql specific benchmarks, but +>>the general case has been that HT is a benefit in a few particular work +>>loads but with no benefit in general. +>> +>> +>Part of the FUD with hyperthreading did have a kernel of truth that lied in +>older kernels' schedulers. For example with Linux until recently the kernel +>can easily end up scheduling two processes on the two virtual processors of +>one single physical processor, leaving the other physical processor totally +>idle. +> +>With modern kernels' schedulers I would expect hyperthreading to live up to +>its billing of adding 10% to 20% performance. Ie., a dual Xeon machine with +>hyperthreading won't be as fast as four processors, but it should be 10-20% +>faster than a dual Xeon without hyperthreading. +> +>As with all things that will only help if you're bound by the right limited +>resource to begin with. If you're I/O bound it isn't going to help. I would +>expect Postgres with its heavy demand on memory bandwidth and shared memory +>could potentially benefit more than usual from being able to context switch +>during pipeline stalls. +> +> +All true. I'd be surprised if HT on an older 2.8 Ghz Xeon with only a +512K cache will see any real benefit. The dual Xeon is already memory +starved, now further increase the memory pressure on the caches (because +the 512K is now "shared" by two virtual processors) and you probably +won't see a gain. It's memory stalls all around. To be clear, the +context switch in this case isn't a kernel context switch but a "virtual +cpu" context switch. + +The probable reason we see dual Opteron boxes way outperforming dual +Xeons boxes is exactly because of Postgresql's heavy demand on memory. +The Opteron's have a much better memory system. + +A quick search on google or digging around in the comp.arch archives +will provide lots of details. HP's web site has (had?) some +benchmarks comparing these systems. HP sells both Xeon and Opteron +systems, so the comparison were quite "fair". Their numbers showed the +Opteron handily outperfoming the Xeons. + +-- Alan + +From pgsql-benchmarks-owner@postgresql.org Wed Oct 6 15:16:51 2004 +X-Original-To: pgsql-benchmarks-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2793F329E8E; + Wed, 6 Oct 2004 15:16:50 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12764-06; Wed, 6 Oct 2004 14:16:44 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D2716329E64; + Wed, 6 Oct 2004 15:16:43 +0100 (BST) +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 i96EGeKS025577; + Wed, 6 Oct 2004 10:16:40 -0400 (EDT) +To: =?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= + +Cc: pgsql-benchmarks@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] stats on cursor and query execution troubleshooting +In-reply-to: <4163C5C3.3030304@fr.netcentrex.net> +References: <4163C5C3.3030304@fr.netcentrex.net> +Comments: In-reply-to =?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= + + message dated "Wed, 06 Oct 2004 12:15:31 +0200" +Date: Wed, 06 Oct 2004 10:16:39 -0400 +Message-ID: <25576.1097072199@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/2 +X-Sequence-Number: 19 + +=?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= writes: +> I'm looking for the statistic of memory, CPU, filesystem access while=20 +> executing some regular SQL query, and I want to compare them to +> same kind of results while executing a cursor function. + +I think your second query is finding all the disk pages it needs in +kernel disk cache, because they were all read in by the first query. +This has little to do with cursor versus non cursor, and everything +to do with hitting recently-read data again. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Oct 6 16:45:40 2004 +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 4854032A039 + for ; + Wed, 6 Oct 2004 16:45:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49427-03 + for ; + Wed, 6 Oct 2004 15:45:35 +0000 (GMT) +Received: from snowwhite.lulu.com (mail.lulu.com [66.193.5.50]) + by svr1.postgresql.org (Postfix) with ESMTP id F136F329DB1 + for ; + Wed, 6 Oct 2004 16:45:33 +0100 (BST) +Received: from [10.0.0.32] (meatwad.rdu.lulu.com [10.0.0.32]) + (authenticated bits=0) + by snowwhite.lulu.com (8.12.8/8.12.8) with ESMTP id i96FkJbO002919 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) + for ; Wed, 6 Oct 2004 11:46:19 -0400 +Message-ID: <4164131A.6080601@lulu.com> +Date: Wed, 06 Oct 2004 11:45:30 -0400 +From: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> <200410051538.51664.josh@agliodbs.com> +In-Reply-To: <200410051538.51664.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/59 +X-Sequence-Number: 8535 + +Josh Berkus wrote: + +>>I'd be thrilled to test it too, if for no other reason that to determine +>>whether what I'm experiencing really is the "CS problem". +>> +>> +> +>Hmmm ... Gavin's patch is built against 8.0, and any version of the patch +>would require linux 2.6, probably 2.6.7 minimum. Can you test on that linux +>version? Do you have the resources to back-port Gavin's patch? +> +> + +I don't currently have any SMP Xeon systems running a 2.6 kernel, but it +could be arranged. As for back-porting the patch to 7.4.5, probably so, +but I'd have to see it first. + +>>tps = 369.717832 (including connections establishing) +>>tps = 370.852058 (excluding connections establishing) +>> +>> +> +>Doesn't seem too bad to me. Have anything to compare it to? +> +> + +Yes, about 280 tps on the same machine with the data directory on a +3-disk RAID 5 w/ a 128MB cache, rather than the SSD. I was expecting a +much larger increase, given that the RAID does about 3MB/s of random 8k +writes, and the SSD device does about 70MB/s of random 8k writes. Said +differently, I thought my CPU bottleneck would be much higher, as to +allow for more than a 30% increase in pgbench TPS when I took the IO +bottleneck out of the equation. (That said, I'm not tuning for pgbench, +but it is a useful comparison that everyone on the list is familiar +with, and takes out the possibility that my app just has a bunch of +poorly written queries). + +>What's in your postgresql.conf? +> +> + +Some relevant parameters: +shared_buffers = 16384 +sort_mem = 2048 +vacuum_mem = 16384 +max_fsm_pages = 200000 +max_fsm_relations = 10000 +fsync = true +wal_sync_method = fsync +wal_buffers = 32 +checkpoint_segments = 6 +effective_cache_size = 262144 +random_page_cost = 0.25 + +Everything else is left at the default (or not relevant to this post). +Anything blatantly stupid in there for my setup? + +Thanks, + +Bill Montgomery + +From pgsql-performance-owner@postgresql.org Wed Oct 6 17:08:49 2004 +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 7E943329E8B + for ; + Wed, 6 Oct 2004 17:08:43 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55100-07 + for ; + Wed, 6 Oct 2004 16:08:02 +0000 (GMT) +Received: from mail.hamburg.cityline.net (ns.mcs-hh.de [194.77.146.129]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D706329E4B + for ; + Wed, 6 Oct 2004 17:08:01 +0100 (BST) +Received: from [212.1.56.10] (helo=aconitin.toxine.lan) + by mail.hamburg.cityline.net with asmtp (TLSv1:RC4-MD5:128) + (Exim 4.32) id 1CFEKb-00073J-4j + for pgsql-performance@postgresql.org; Wed, 06 Oct 2004 18:07:57 +0200 +From: Ole Langbehn +Organization: freiheit.com +To: pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +Date: Wed, 6 Oct 2004 18:09:43 +0200 +User-Agent: KMail/1.7 +References: <200410061130.58625.ole@freiheit.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: <200410061809.43549.ole@freiheit.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/60 +X-Sequence-Number: 8536 + +Am Mittwoch, 6. Oktober 2004 12:19 schrieb Pierre-Fr=E9d=E9ric Caillaud: +> You could try : +> +> explain analyze select "land" from "customer_dim" group by "land"; +> It will be a lot faster but I can't make it use the index on my machine.= +.. +this already speeds up my queries to about 1/4th of the time, which is abou= +t=20 +the range of mysql and oracle. +> +> Example : +> +> [..] +> +> Hum hum ! Again, a lot better ! +> Index scan backwards seems a lot faster than index scan forwards. Why, I +> don't know, but here you go from 15 seconds to 14 milliseconds... +thanks for this very extensive answer, it helped me a lot. +> +> I don't know WHY (oh why) postgres does not use this kind of strategy +> when distinct'ing an indexed field... Anybody got an idea ? +That's the big question I still would like to see answered too. Can anyone= +=20 +tell us? + +TiA +--=20 +Ole Langbehn + +From pgsql-performance-owner@postgresql.org Wed Oct 6 17:41:36 2004 +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 366C3329ED4 + for ; + Wed, 6 Oct 2004 17:41:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68294-08 + for ; + Wed, 6 Oct 2004 16:41:30 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id E7E96329CA4 + for ; + Wed, 6 Oct 2004 17:41:28 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CFEqm-00085M-00; Wed, 06 Oct 2004 12:41:12 -0400 +To: =?iso-8859-1?q?Pierre-Fr=E9d=E9ric_Caillaud?= + +Cc: "Ole Langbehn" , + pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +References: <200410061130.58625.ole@freiheit.com> +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 06 Oct 2004 12:41:12 -0400 +Message-ID: <874ql7ztnb.fsf@stark.xeocode.com> +Lines: 39 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/61 +X-Sequence-Number: 8537 + + +Pierre-Fr�d�ric Caillaud writes: + +> I don't know WHY (oh why) postgres does not use this kind of strategy +> when distinct'ing an indexed field... Anybody got an idea ? + +Well there are two questions here. Why given the current plans available does +postgres choose a sequential scan instead of an index scan. And why isn't +there this kind of "skip index scan" available. + +Postgres chooses a sequential scan with a sort (or hash aggregate) over an +index scan because it expects it to be faster. sequential scans are much +faster than random access scans of indexes, plus index scans need to read many +more blocks. If you're finding the index scan to be just as fast as sequential +scans you might consider lowering random_page_cost closer to 1.0. But note +that you may be getting fooled by a testing methodology where more things are +cached than would be in production. + +why isn't a "skip index scan" plan available? Well, nobody's written the code +yet. It would part of the same code needed to get an index scan used for: + + select y,min(x) from bar group by y + +And possibly also related to the TODO item: + + Use index to restrict rows returned by multi-key index when used with + non-consecutive keys to reduce heap accesses + + For an index on col1,col2,col3, and a WHERE clause of col1 = 5 and col3 = + 9, spin though the index checking for col1 and col3 matches, rather than + just col1 + + +Note that the optimizer would have to make a judgement call based on the +expected number of distinct values. If you had much more than 256 distinct +values then the your plpgsql function wouldn't have performed well at all. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Oct 6 18:28:11 2004 +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 379F232A400 + for ; + Wed, 6 Oct 2004 18:28:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83506-10 + for ; + Wed, 6 Oct 2004 17:28:01 +0000 (GMT) +Received: from fe08.axelero.hu (fe08.axelero.hu [195.228.240.96]) + by svr1.postgresql.org (Postfix) with ESMTP id 1798632A3FB + for ; + Wed, 6 Oct 2004 18:27:59 +0100 (BST) +Received: from fe08 (localhost-02 [127.0.2.1]) + by fe08.axelero.hu (8.12.11/8.12.11) with SMTP id i96HQxcf092268 + for ; + Wed, 6 Oct 2004 19:26:59 +0200 (CEST) +Received: from fe08.axelero.hu [127.0.2.1] via SMTP gateway + by fe08 [195.228.240.96]; id A068691C51D + at Wed, 06 Oct 2004 19:26:59 +0200 +Received: from fejleszt4 (121-248-182-81.adsl-fixip.axelero.hu + [81.182.248.121]) + by fe08.axelero.hu (8.12.11/8.12.11) with SMTP id i96HQw2i092255 + for ; + Wed, 6 Oct 2004 19:26:58 +0200 (CEST) +Message-ID: <019301c4abc9$ef251ea0$0403a8c0@fejleszt4> +From: =?iso-8859-1?Q?SZUCS_G=E1bor?= +To: +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> <200410051538.51664.josh@agliodbs.com> + <4164131A.6080601@lulu.com> +Subject: Re: Excessive context switching on SMP Xeons +Date: Wed, 6 Oct 2004 19:28:45 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-RAVMilter-Version: 8.4.3(snapshot 20030217) (fe08.axelero.hu) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/62 +X-Sequence-Number: 8538 + +Hmmm... + +I may be mistaken (I think last time I read about optimization params was in +7.3 docs), but doesn't RPC < 1 mean that random read is faster than +sequential read? In your case, do you really think reading randomly is 4x +faster than reading sequentially? Doesn't seem to make sense, even with a +zillion-disk array. Theoretically. + +Also not sure, but sort_mem and vacuum_mem seem to be too small to me. + +G. +%----------------------- cut here -----------------------% +\end + +----- Original Message ----- +From: "Bill Montgomery" +Sent: Wednesday, October 06, 2004 5:45 PM + + +> Some relevant parameters: +> shared_buffers = 16384 +> sort_mem = 2048 +> vacuum_mem = 16384 +> max_fsm_pages = 200000 +> max_fsm_relations = 10000 +> fsync = true +> wal_sync_method = fsync +> wal_buffers = 32 +> checkpoint_segments = 6 +> effective_cache_size = 262144 +> random_page_cost = 0.25 + + +From pgsql-performance-owner@postgresql.org Wed Oct 6 18:31:28 2004 +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 3AED732A260 + for ; + Wed, 6 Oct 2004 18:31:26 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84278-07 + for ; + Wed, 6 Oct 2004 17:31:21 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 25427329EE4 + for ; + Wed, 6 Oct 2004 18:31:19 +0100 (BST) +Received: (qmail 17839 invoked from network); 6 Oct 2004 19:31:43 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 6 Oct 2004 19:31:43 +0200 +Date: Wed, 06 Oct 2004 19:34:22 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +References: <200410061130.58625.ole@freiheit.com> + <874ql7ztnb.fsf@stark.xeocode.com> +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <874ql7ztnb.fsf@stark.xeocode.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/63 +X-Sequence-Number: 8539 + + + There are even three questions here : + + - given that 'SELECT DISTINCT field FROM table' is exactly +the same as 'SELECT field FROM table GROUP BY field", postgres could +transform the first into the second and avoid itself a (potentially +killer) sort. + + On my example the table was not too large but on a very large table, +sorting all the values and then discinct'ing them does not look too +appealing. + + Currently Postgres does Sort+Unique, but there could be a DistinctSort +instead of a Sort, that is a thing that sorts and removes the duplicates +at the same time. Not that much complicated to code than a sort, and much +faster in this case. + Or there could be a DistinctHash, which would be similar or rather +identical to a HashAggregate and would again skip the sort. + + It would (as a bonus) speed up queries like UNION (not ALL), that kind of +things. For example : + + explain (select number from dummy) union (select number from dummy); + Unique (cost=287087.62..297087.62 rows=2000000 width=4) + -> Sort (cost=287087.62..292087.62 rows=2000000 width=4) + Sort Key: number + -> Append (cost=0.00..49804.00 rows=2000000 width=4) + -> Subquery Scan "*SELECT* 1" (cost=0.00..24902.00 +rows=1000000 width=4) + -> Seq Scan on dummy (cost=0.00..14902.00 +rows=1000000 width=4) + -> Subquery Scan "*SELECT* 2" (cost=0.00..24902.00 +rows=1000000 width=4) + -> Seq Scan on dummy (cost=0.00..14902.00 +rows=1000000 width=4) + + This is scary ! + +I can rewrite it as such (and the planner could, too) : + +explain select * from ((select number from dummy) union all (select number + from dummy)) as foo group by number; + HashAggregate (cost=74804.00..74804.00 rows=200 width=4) + -> Subquery Scan foo (cost=0.00..69804.00 rows=2000000 width=4) + -> Append (cost=0.00..49804.00 rows=2000000 width=4) + -> Subquery Scan "*SELECT* 1" (cost=0.00..24902.00 +rows=1000000 width=4) + -> Seq Scan on dummy (cost=0.00..14902.00 +rows=1000000 width=4) + -> Subquery Scan "*SELECT* 2" (cost=0.00..24902.00 +rows=1000000 width=4) + -> Seq Scan on dummy (cost=0.00..14902.00 +rows=1000000 width=4) + +which avoids a large sort... + +However there must be cases in which performing a sort is faster, like +when there are a lot of distinct values and the HashAggregate becomes huge +too. + +> Well there are two questions here. Why given the current plans available +> does +> postgres choose a sequential scan instead of an index scan. And why isn't + + Well because it needs to get all the rows in the table in order. + in this case seq scan+sort is about twice as fast as index scan. + Interestingly, once I ANALYZED the table, postgres will chooses to +index-scan, which is slower. + +> there this kind of "skip index scan" available. + + It would be really nice to have a skip index scan available. + + I have an other idea, lets call it the indexed sequential scan : + When pg knows there are a lot of rows to access, it will ignore the index +and seqscan. This is because index access is very random, thus slow. +However postgres could implement an "indexed sequential scan" where : + - the page numbers for the matching rows are looked up in the index + (this is fast as an index has good locality) + - the page numbers are grouped so we have a list of pages with one and +only one instance of each page number + - the list is then sorted so we have page numbers in-order + - the pages are loaded in sorted order (doing a kind of partial +sequential scan) which would be faster than reading them randomly. + + Other ideas later + + +> Postgres chooses a sequential scan with a sort (or hash aggregate) over +> an +> index scan because it expects it to be faster. sequential scans are much +> faster than random access scans of indexes, plus index scans need to +> read many +> more blocks. If you're finding the index scan to be just as fast as +> sequential +> scans you might consider lowering random_page_cost closer to 1.0. But +> note +> that you may be getting fooled by a testing methodology where more +> things are +> cached than would be in production. +> +> why isn't a "skip index scan" plan available? Well, nobody's written the +> code +> yet. It would part of the same code needed to get an index scan used for: +> +> select y,min(x) from bar group by y +> +> And possibly also related to the TODO item: +> +> Use index to restrict rows returned by multi-key index when used with +> non-consecutive keys to reduce heap accesses +> +> For an index on col1,col2,col3, and a WHERE clause of col1 = 5 and +> col3 = +> 9, spin though the index checking for col1 and col3 matches, rather +> than +> just col1 +> +> +> Note that the optimizer would have to make a judgement call based on the +> expected number of distinct values. If you had much more than 256 +> distinct +> values then the your plpgsql function wouldn't have performed well at +> all. +> + + + +From pgsql-performance-owner@postgresql.org Wed Oct 6 19:55:23 2004 +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 AE2AC329D20 + for ; + Wed, 6 Oct 2004 19:55:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12724-02 + for ; + Wed, 6 Oct 2004 18:55:17 +0000 (GMT) +Received: from pd4mo1so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net + [24.71.223.10]) + by svr1.postgresql.org (Postfix) with ESMTP id C95A432A0C4 + for ; + Wed, 6 Oct 2004 19:55:14 +0100 (BST) +Received: from pd3mr3so.prod.shaw.ca + (pd3mr3so-qfe3.prod.shaw.ca [10.0.141.179]) by l-daemon + (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) + with ESMTP id <0I5600MYUF7RJL60@l-daemon> for + pgsql-performance@postgresql.org; Wed, 06 Oct 2004 12:55:03 -0600 (MDT) +Received: from pn2ml9so.prod.shaw.ca ([10.0.121.7]) + by pd3mr3so.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 + (built Mar + 15 2004)) with ESMTP id <0I5600GDAF7RGJD0@pd3mr3so.prod.shaw.ca> for + pgsql-performance@postgresql.org; Wed, 06 Oct 2004 12:55:03 -0600 (MDT) +Received: from [192.168.1.10] + (S01060050bac04c93.ed.shawcable.net [68.148.193.184]) + by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 + 2003)) with ESMTP id <0I5600J7SF7Q3C@l-daemon> for + pgsql-performance@postgresql.org; + Wed, 06 Oct 2004 12:55:03 -0600 (MDT) +Date: Wed, 06 Oct 2004 12:55:02 -0600 +From: Patrick Clery +Subject: Re: Comparing user attributes with bitwise operators +In-reply-to: <200410050932.38595.josh@agliodbs.com> +To: pgsql-performance@postgresql.org +Message-id: <200410061255.03052.patrick@phpforhire.com> +MIME-version: 1.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: 7bit +Content-disposition: inline +References: <200409160141.37604.patrick@phpforhire.com> + <200410050039.24230.patrick@phpforhire.com> + <200410050932.38595.josh@agliodbs.com> +User-Agent: KMail/1.7 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 + tests=FAKE_HELO_SHAW_CA +X-Spam-Level: +X-Archive-Number: 200410/64 +X-Sequence-Number: 8540 + +Another problem I should note is that when I first insert all the data into +the people_attributes table ("the int[] table"), the GiST index is not used: + +THE INDEX: +"people_attributes_search" gist ((ARRAY[age, gender, orientation, children, +drinking, education, +ethnicity, eyecolor, haircolor, hairstyle, height, income, occupation, +relation, religion, smoking, w +ant_children, weight] + seeking + languages)) + +PART OF THE QUERY PLAN: +Seq Scan on people_attributes pa (cost=0.00..0.00 rows=1 width=20) + Filter: (((ARRAY[age, gender, orientation, children, +drinking, education, ethnicity, eyecolor, haircolor, hairstyle, height, +income, occupation, relation, religion, smoking, want_children, weight] + +seeking) + languages) @@ '( ( 4 | 5 ) | 6 ) & 88 & 48 & ( 69 | 70 ) & 92 & +( ( ( ( ( ( ( ( ( ( ( ( ( 95 | 96 ) | 97 ) | 98 ) | 99 ) | 100 ) | 101 ) | +102 ) | 103 ) | 104 ) | 105 ) | 106 ) | 107 ) | 108 ) & +( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( 190 +| 191 ) | 192 ) | 193 ) | 194 ) | 195 ) | 196 ) | 197 ) | 198 ) | 199 ) | +200 ) | 201 ) | 202 ) | 203 ) | 204 ) | 205 ) | 206 ) | 207 ) | 208 ) | 209 ) +| 210 ) | 211 ) | 212 ) | 213 ) | 214 ) | 215 ) | 216 ) | 217 ) | 218 ) | +219 ) | 220 ) | 221 ) | 222 ) | 223 ) | 224 ) | 225 ) | 226 ) | 227 ) | 228 ) +| 229 ) | 230 ) | 231 ) | 232 ) | 233 ) | 234 ) | 235 ) | 236 ) | 237 ) | +238 ) | 239 ) | 240 ) | 241 ) | 242 ) | 243 )'::query_int) + + +So I run "VACUUM ANALYZE people_attributes", then run again: + +PART OF THE QUERY PLAN: +Index Scan using people_attributes_pkey on people_attributes pa +(cost=0.00..5.32 rows=1 width=20) + Index Cond: (pa.person_id = "outer".person_id) + Filter: (((ARRAY[age, gender, orientation, children, drinking, +education, ethnicity, eyecolor, haircolor, hairstyle, height, income, +occupation, relation, religion, smoking, want_children, weight] + seeking) + +languages) @@ '( ( 4 | 5 ) | 6 ) & 88 & 48 & ( 69 | 70 ) & 92 & +( ( ( ( ( ( ( ( ( ( ( ( ( 95 | 96 ) | 97 ) | 98 ) | 99 ) | 100 ) | 101 ) | +102 ) | 103 ) | 104 ) | 105 ) | 106 ) | 107 ) | 108 ) & +( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( 190 +| 191 ) | 192 ) | 193 ) | 194 ) | 195 ) | 196 ) | 197 ) | 198 ) | 199 ) | +200 ) | 201 ) | 202 ) | 203 ) | 204 ) | 205 ) | 206 ) | 207 ) | 208 ) | 209 ) +| 210 ) | 211 ) | 212 ) | 213 ) | 214 ) | 215 ) | 216 ) | 217 ) | 218 ) | +219 ) | 220 ) | 221 ) | 222 ) | 223 ) | 224 ) | 225 ) | 226 ) | 227 ) | 228 ) +| 229 ) | 230 ) | 231 ) | 232 ) | 233 ) | 234 ) | 235 ) | 236 ) | 237 ) | +238 ) | 239 ) | 240 ) | 241 ) | 242 ) | 243 )'::query_int) + +Still not using the index. I'm trying to DROP INDEX and recreate it, but the +query just stalls. I remember last time this situation happened that I just +dropped and recreated the index, and voila it was using the index again. Now +I can't seem to get this index to drop. Here's the table structure: + + + Column | Type | Modifiers +---------------+-----------+-------------------- + person_id | integer | not null + askmecount | integer | not null default 0 + age | integer | not null + gender | integer | not null + bodytype | integer | not null + children | integer | not null + drinking | integer | not null + education | integer | not null + ethnicity | integer | not null + eyecolor | integer | not null + haircolor | integer | not null + hairstyle | integer | not null + height | integer | not null + income | integer | not null + languages | integer[] | not null + occupation | integer | not null + orientation | integer | not null + relation | integer | not null + religion | integer | not null + smoking | integer | not null + want_children | integer | not null + weight | integer | not null + seeking | integer[] | not null +Indexes: + "people_attributes_pkey" PRIMARY KEY, btree (person_id) + "people_attributes_search" gist ((ARRAY[age, gender, orientation, +children, drinking, education, +ethnicity, eyecolor, haircolor, hairstyle, height, income, occupation, +relation, religion, smoking, w +ant_children, weight] + seeking + languages)) +Foreign-key constraints: + "people_attributes_weight_fkey" FOREIGN KEY (weight) REFERENCES +attribute_values(value_id) ON DEL +ETE RESTRICT + "people_attributes_person_id_fkey" FOREIGN KEY (person_id) REFERENCES +people(person_id) ON DELETE + CASCADE DEFERRABLE INITIALLY DEFERRED + "people_attributes_age_fkey" FOREIGN KEY (age) REFERENCES +attribute_values(value_id) ON DELETE RE +STRICT + "people_attributes_gender_fkey" FOREIGN KEY (gender) REFERENCES +attribute_values(value_id) ON DEL +ETE RESTRICT + "people_attributes_bodytype_fkey" FOREIGN KEY (bodytype) REFERENCES +attribute_values(value_id) ON + DELETE RESTRICT + "people_attributes_children_fkey" FOREIGN KEY (children) REFERENCES +attribute_values(value_id) ON + DELETE RESTRICT + "people_attributes_drinking_fkey" FOREIGN KEY (drinking) REFERENCES +attribute_values(value_id) ON + DELETE RESTRICT + "people_attributes_education_fkey" FOREIGN KEY (education) REFERENCES +attribute_values(value_id) +ON DELETE RESTRICT + "people_attributes_ethnicity_fkey" FOREIGN KEY (ethnicity) REFERENCES +attribute_values(value_id) +ON DELETE RESTRICT + "people_attributes_eyecolor_fkey" FOREIGN KEY (eyecolor) REFERENCES +attribute_values(value_id) ON + DELETE RESTRICT + "people_attributes_haircolor_fkey" FOREIGN KEY (haircolor) REFERENCES +attribute_values(value_id) +ON DELETE RESTRICT + "people_attributes_hairstyle_fkey" FOREIGN KEY (hairstyle) REFERENCES +attribute_values(value_id) +ON DELETE RESTRICT + "people_attributes_height_fkey" FOREIGN KEY (height) REFERENCES +attribute_values(value_id) ON DELETE RESTRICT + "people_attributes_income_fkey" FOREIGN KEY (income) REFERENCES +attribute_values(value_id) ON DELETE RESTRICT + "people_attributes_occupation_fkey" FOREIGN KEY (occupation) REFERENCES +attribute_values(value_id +) ON DELETE RESTRICT + "people_attributes_orientation_fkey" FOREIGN KEY (orientation) REFERENCES +attribute_values(value_ +id) ON DELETE RESTRICT + "people_attributes_relation_fkey" FOREIGN KEY (relation) REFERENCES +attribute_values(value_id) ON + DELETE RESTRICT + "people_attributes_religion_fkey" FOREIGN KEY (religion) REFERENCES +attribute_values(value_id) ON + DELETE RESTRICT + "people_attributes_smoking_fkey" FOREIGN KEY (smoking) REFERENCES +attribute_values(value_id) ON D +ELETE RESTRICT + "people_attributes_want_children_fkey" FOREIGN KEY (want_children) +REFERENCES attribute_values(va +lue_id) ON DELETE RESTRICT + + +Is it all the foreign keys that are stalling the drop? I have done VACUUM +ANALYZE on the entire db. Could anyone offer some insight as to why this +index is not being used or why the index is not dropping easily? + + +On Tuesday 05 October 2004 10:32, you wrote: +> Patrick, +> +> First off, thanks for posting this solution! I love to see a new demo of +> The Power of Postgres(tm) and have been wondering about this particular +> problem since it came up on IRC. +> +> > The array method works quite nicely, especially for the +> > columns like "languages" and "seeking" that are multiple choice. However, +> > even though this method is fast, I still might opt for caching the +> > results because the "real world" search query involves a lot more and +> > will be executed non-stop. But to have it run this fast the first time +> > certainly helps. +> +> Now, for the bad news: you need to test having a large load of users +> updating their data. The drawback to GiST indexes is that they are +> low-concurrency, because the updating process needs to lock the whole index +> (this has been on our TODO list for about a decade, but it's a hard +> problem). + +From pgsql-performance-owner@postgresql.org Wed Oct 6 20:28:06 2004 +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 4CD8D32A039 + for ; + Wed, 6 Oct 2004 20:28:00 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21457-02 + for ; + Wed, 6 Oct 2004 19:27:54 +0000 (GMT) +Received: from pd2mo3so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net + [24.71.223.10]) + by svr1.postgresql.org (Postfix) with ESMTP id A8D3C32A00E + for ; + Wed, 6 Oct 2004 20:27:55 +0100 (BST) +Received: from pd2mr3so.prod.shaw.ca + (pd2mr3so-qfe3.prod.shaw.ca [10.0.141.108]) by l-daemon + (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) + with ESMTP id <0I56005G2GQIS6C0@l-daemon> for + pgsql-performance@postgresql.org; Wed, 06 Oct 2004 13:27:54 -0600 (MDT) +Received: from pn2ml9so.prod.shaw.ca ([10.0.121.7]) + by pd2mr3so.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 + (built Mar + 15 2004)) with ESMTP id <0I56003UFGQIAI40@pd2mr3so.prod.shaw.ca> for + pgsql-performance@postgresql.org; Wed, 06 Oct 2004 13:27:54 -0600 (MDT) +Received: from [192.168.1.10] + (S01060050bac04c93.ed.shawcable.net [68.148.193.184]) + by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 + 2003)) with ESMTP id <0I5600F0XGQIM4@l-daemon> for + pgsql-performance@postgresql.org; + Wed, 06 Oct 2004 13:27:54 -0600 (MDT) +Date: Wed, 06 Oct 2004 13:27:55 -0600 +From: Patrick Clery +Subject: Re: Comparing user attributes with bitwise operators +In-reply-to: <200410061325.38807.patrick@phpforhire.com> +To: pgsql-performance@postgresql.org +Message-id: <200410061327.55989.patrick@phpforhire.com> +MIME-version: 1.0 +Content-type: text/plain; charset=iso-8859-1 +Content-transfer-encoding: 7bit +Content-disposition: inline +References: <200409160141.37604.patrick@phpforhire.com> + <200410061255.03052.patrick@phpforhire.com> + <200410061325.38807.patrick@phpforhire.com> +User-Agent: KMail/1.7 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 + tests=FAKE_HELO_SHAW_CA +X-Spam-Level: +X-Archive-Number: 200410/65 +X-Sequence-Number: 8541 + +Err... I REINDEX'ed it and it is now using the index. :) + +I'd still appreciate if anyone could tell me why this needs to be +reindexed. Is the index not updated when the records are inserted? + +> On Wednesday 06 October 2004 12:55, I wrote: +> > Another problem I should note is that when I first insert all the data +> > into the people_attributes table ("the int[] table"), the GiST index is +> > not used: +> > +> > THE INDEX: +> > "people_attributes_search" gist ((ARRAY[age, gender, orientation, +> > children, drinking, education, +> > ethnicity, eyecolor, haircolor, hairstyle, height, income, occupation, +> > relation, religion, smoking, w +> > ant_children, weight] + seeking + languages)) +> > +> > PART OF THE QUERY PLAN: +> > Seq Scan on people_attributes pa (cost=0.00..0.00 rows=1 width=20) +> > Filter: (((ARRAY[age, gender, orientation, children, +> > drinking, education, ethnicity, eyecolor, haircolor, hairstyle, height, +> > income, occupation, relation, religion, smoking, want_children, weight] + +> > seeking) + languages) @@ '( ( 4 | 5 ) | 6 ) & 88 & 48 & ( 69 | 70 ) & 92 +> > & ( ( ( ( ( ( ( ( ( ( ( ( ( 95 | 96 ) | 97 ) | 98 ) | 99 ) | 100 ) | 101 +> > ) | 102 ) | 103 ) | 104 ) | 105 ) | 106 ) | 107 ) | 108 ) & +> > ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( +> > ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( 190 +> > +> > | 191 ) | 192 ) | 193 ) | 194 ) | 195 ) | 196 ) | 197 ) | 198 ) | 199 ) | +> > +> > 200 ) | 201 ) | 202 ) | 203 ) | 204 ) | 205 ) | 206 ) | 207 ) | 208 ) | +> > 209 ) +> > +> > | 210 ) | 211 ) | 212 ) | 213 ) | 214 ) | 215 ) | 216 ) | 217 ) | 218 ) | +> > +> > 219 ) | 220 ) | 221 ) | 222 ) | 223 ) | 224 ) | 225 ) | 226 ) | 227 ) | +> > 228 ) +> > +> > | 229 ) | 230 ) | 231 ) | 232 ) | 233 ) | 234 ) | 235 ) | 236 ) | 237 ) | +> > +> > 238 ) | 239 ) | 240 ) | 241 ) | 242 ) | 243 )'::query_int) +> > +> > +> > So I run "VACUUM ANALYZE people_attributes", then run again: +> > +> > PART OF THE QUERY PLAN: +> > Index Scan using people_attributes_pkey on people_attributes pa +> > (cost=0.00..5.32 rows=1 width=20) +> > Index Cond: (pa.person_id = "outer".person_id) +> > Filter: (((ARRAY[age, gender, orientation, children, drinking, +> > education, ethnicity, eyecolor, haircolor, hairstyle, height, income, +> > occupation, relation, religion, smoking, want_children, weight] + +> > seeking) + languages) @@ '( ( 4 | 5 ) | 6 ) & 88 & 48 & ( 69 | 70 ) & 92 +> > & ( ( ( ( ( ( ( ( ( ( ( ( ( 95 | 96 ) | 97 ) | 98 ) | 99 ) | 100 ) | 101 +> > ) | 102 ) | 103 ) | 104 ) | 105 ) | 106 ) | 107 ) | 108 ) & +> > ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( +> > ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( 190 +> > +> > | 191 ) | 192 ) | 193 ) | 194 ) | 195 ) | 196 ) | 197 ) | 198 ) | 199 ) | +> > +> > 200 ) | 201 ) | 202 ) | 203 ) | 204 ) | 205 ) | 206 ) | 207 ) | 208 ) | +> > 209 ) +> > +> > | 210 ) | 211 ) | 212 ) | 213 ) | 214 ) | 215 ) | 216 ) | 217 ) | 218 ) | +> > +> > 219 ) | 220 ) | 221 ) | 222 ) | 223 ) | 224 ) | 225 ) | 226 ) | 227 ) | +> > 228 ) +> > +> > | 229 ) | 230 ) | 231 ) | 232 ) | 233 ) | 234 ) | 235 ) | 236 ) | 237 ) | +> > +> > 238 ) | 239 ) | 240 ) | 241 ) | 242 ) | 243 )'::query_int) +> > +> > Still not using the index. I'm trying to DROP INDEX and recreate it, but +> > the query just stalls. I remember last time this situation happened that +> > I just dropped and recreated the index, and voila it was using the index +> > again. Now I can't seem to get this index to drop. Here's the table +> > structure: +> > +> > +> > Column | Type | Modifiers +> > ---------------+-----------+-------------------- +> > person_id | integer | not null +> > askmecount | integer | not null default 0 +> > age | integer | not null +> > gender | integer | not null +> > bodytype | integer | not null +> > children | integer | not null +> > drinking | integer | not null +> > education | integer | not null +> > ethnicity | integer | not null +> > eyecolor | integer | not null +> > haircolor | integer | not null +> > hairstyle | integer | not null +> > height | integer | not null +> > income | integer | not null +> > languages | integer[] | not null +> > occupation | integer | not null +> > orientation | integer | not null +> > relation | integer | not null +> > religion | integer | not null +> > smoking | integer | not null +> > want_children | integer | not null +> > weight | integer | not null +> > seeking | integer[] | not null +> > Indexes: +> > "people_attributes_pkey" PRIMARY KEY, btree (person_id) +> > "people_attributes_search" gist ((ARRAY[age, gender, orientation, +> > children, drinking, education, +> > ethnicity, eyecolor, haircolor, hairstyle, height, income, occupation, +> > relation, religion, smoking, w +> > ant_children, weight] + seeking + languages)) +> > Foreign-key constraints: +> > "people_attributes_weight_fkey" FOREIGN KEY (weight) REFERENCES +> > attribute_values(value_id) ON DEL +> > ETE RESTRICT +> > "people_attributes_person_id_fkey" FOREIGN KEY (person_id) REFERENCES +> > people(person_id) ON DELETE +> > CASCADE DEFERRABLE INITIALLY DEFERRED +> > "people_attributes_age_fkey" FOREIGN KEY (age) REFERENCES +> > attribute_values(value_id) ON DELETE RE +> > STRICT +> > "people_attributes_gender_fkey" FOREIGN KEY (gender) REFERENCES +> > attribute_values(value_id) ON DEL +> > ETE RESTRICT +> > "people_attributes_bodytype_fkey" FOREIGN KEY (bodytype) REFERENCES +> > attribute_values(value_id) ON +> > DELETE RESTRICT +> > "people_attributes_children_fkey" FOREIGN KEY (children) REFERENCES +> > attribute_values(value_id) ON +> > DELETE RESTRICT +> > "people_attributes_drinking_fkey" FOREIGN KEY (drinking) REFERENCES +> > attribute_values(value_id) ON +> > DELETE RESTRICT +> > "people_attributes_education_fkey" FOREIGN KEY (education) REFERENCES +> > attribute_values(value_id) +> > ON DELETE RESTRICT +> > "people_attributes_ethnicity_fkey" FOREIGN KEY (ethnicity) REFERENCES +> > attribute_values(value_id) +> > ON DELETE RESTRICT +> > "people_attributes_eyecolor_fkey" FOREIGN KEY (eyecolor) REFERENCES +> > attribute_values(value_id) ON +> > DELETE RESTRICT +> > "people_attributes_haircolor_fkey" FOREIGN KEY (haircolor) REFERENCES +> > attribute_values(value_id) +> > ON DELETE RESTRICT +> > "people_attributes_hairstyle_fkey" FOREIGN KEY (hairstyle) REFERENCES +> > attribute_values(value_id) +> > ON DELETE RESTRICT +> > "people_attributes_height_fkey" FOREIGN KEY (height) REFERENCES +> > attribute_values(value_id) ON DELETE RESTRICT +> > "people_attributes_income_fkey" FOREIGN KEY (income) REFERENCES +> > attribute_values(value_id) ON DELETE RESTRICT +> > "people_attributes_occupation_fkey" FOREIGN KEY (occupation) +> > REFERENCES attribute_values(value_id +> > ) ON DELETE RESTRICT +> > "people_attributes_orientation_fkey" FOREIGN KEY (orientation) +> > REFERENCES attribute_values(value_ +> > id) ON DELETE RESTRICT +> > "people_attributes_relation_fkey" FOREIGN KEY (relation) REFERENCES +> > attribute_values(value_id) ON +> > DELETE RESTRICT +> > "people_attributes_religion_fkey" FOREIGN KEY (religion) REFERENCES +> > attribute_values(value_id) ON +> > DELETE RESTRICT +> > "people_attributes_smoking_fkey" FOREIGN KEY (smoking) REFERENCES +> > attribute_values(value_id) ON D +> > ELETE RESTRICT +> > "people_attributes_want_children_fkey" FOREIGN KEY (want_children) +> > REFERENCES attribute_values(va +> > lue_id) ON DELETE RESTRICT +> > +> > +> > Is it all the foreign keys that are stalling the drop? I have done VACUUM +> > ANALYZE on the entire db. Could anyone offer some insight as to why this +> > index is not being used or why the index is not dropping easily? +> > +> > On Tuesday 05 October 2004 10:32, you wrote: +> > > Patrick, +> > > +> > > First off, thanks for posting this solution! I love to see a new demo +> > > of The Power of Postgres(tm) and have been wondering about this +> > > particular problem since it came up on IRC. +> > > +> > > > The array method works quite nicely, especially for the +> > > > columns like "languages" and "seeking" that are multiple choice. +> > > > However, even though this method is fast, I still might opt for +> > > > caching the results because the "real world" search query involves a +> > > > lot more and will be executed non-stop. But to have it run this fast +> > > > the first time certainly helps. +> > > +> > > Now, for the bad news: you need to test having a large load of users +> > > updating their data. The drawback to GiST indexes is that they are +> > > low-concurrency, because the updating process needs to lock the whole +> > > index (this has been on our TODO list for about a decade, but it's a +> > > hard problem). +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 6: Have you searched our list archives? +> > +> > http://archives.postgresql.org + +From pgsql-performance-owner@postgresql.org Wed Oct 6 20:40:52 2004 +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 BC605329EE3 + for ; + Wed, 6 Oct 2004 20:40:50 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26505-05 + for ; + Wed, 6 Oct 2004 19:40: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 265B132A4E0 + for ; + Wed, 6 Oct 2004 20:40:45 +0100 (BST) +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 i96JcQme029195; + Wed, 6 Oct 2004 15:38:26 -0400 (EDT) +To: Greg Stark +Cc: =?iso-8859-1?q?Pierre-Fr=E9d=E9ric_Caillaud?= + , + "Ole Langbehn" , pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +In-reply-to: <874ql7ztnb.fsf@stark.xeocode.com> +References: <200410061130.58625.ole@freiheit.com> + <874ql7ztnb.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "06 Oct 2004 12:41:12 -0400" +Date: Wed, 06 Oct 2004 15:38:26 -0400 +Message-ID: <29194.1097091506@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/67 +X-Sequence-Number: 8543 + +Greg Stark writes: +> why isn't a "skip index scan" plan available? Well, nobody's written the code +> yet. + +I don't really think it would be a useful plan anyway. What *would* be +useful is to support HashAggregate as an implementation alternative for +DISTINCT --- currently I believe we only consider that for GROUP BY. +The DISTINCT planning code is fairly old and crufty and hasn't been +redesigned lately. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Oct 6 20:40:04 2004 +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 D3B1E329FEF + for ; + Wed, 6 Oct 2004 20:39:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25337-04 + for ; + Wed, 6 Oct 2004 19:39:06 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 7925D32A493 + for ; + Wed, 6 Oct 2004 20:38:58 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CFHcm-0000xZ-00; Wed, 06 Oct 2004 15:38:56 -0400 +To: Patrick Clery +Cc: pgsql-performance@postgresql.org +Subject: Re: Comparing user attributes with bitwise operators +References: <200409160141.37604.patrick@phpforhire.com> + <200410050039.24230.patrick@phpforhire.com> + <200410050932.38595.josh@agliodbs.com> + <200410061255.03052.patrick@phpforhire.com> +In-Reply-To: <200410061255.03052.patrick@phpforhire.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 06 Oct 2004 15:38:56 -0400 +Message-ID: <87y8ijy6un.fsf@stark.xeocode.com> +Lines: 27 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/66 +X-Sequence-Number: 8542 + + +Patrick Clery writes: + +> PART OF THE QUERY PLAN: +> Index Scan using people_attributes_pkey on people_attributes pa (cost=0.00..5.32 rows=1 width=20) +> Index Cond: (pa.person_id = "outer".person_id) +> Filter: (((ARRAY[age, gender, orientation, children, drinking, + +You'll probably have to show the rest of the plan for anyone to have much idea +what's going on. It seems to be part of a join of some sort and the planner is +choosing to drive the join from the wrong table. This may make it awkward to +force the right plan using enable_seqscan or anything like that. But GiST +indexes don't have very good selectivity estimates so I'm not sure you can +hope for the optimizer to guess right on its own. + +> Is it all the foreign keys that are stalling the drop? I have done VACUUM +> ANALYZE on the entire db. Could anyone offer some insight as to why this +> index is not being used or why the index is not dropping easily? + +I don't think foreign keys cause problems dropping indexes. Foreign key +constraints are just checked whenever there's an insert/update/delete. Perhaps +you're just underestimating the size of this index and the amount of time +it'll take to delete it? Or are there queries actively executing using the +index while you're trying to delete it? Or a vacuum running? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Oct 6 21:02:40 2004 +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 AA65F32A404 + for ; + Wed, 6 Oct 2004 21:02:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31452-06 + for ; + Wed, 6 Oct 2004 20:02:29 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id D40BB32A3FA + for ; + Wed, 6 Oct 2004 21:02:29 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CFHzS-00017E-00; Wed, 06 Oct 2004 16:02:22 -0400 +To: Tom Lane +Cc: Greg Stark , + =?iso-8859-1?q??= =?iso-8859-1?q? Pierre-Fr�d�ric Caillaud?= , + "Ole Langbehn" , pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +References: <200410061130.58625.ole@freiheit.com> + <874ql7ztnb.fsf@stark.xeocode.com> <29194.1097091506@sss.pgh.pa.us> +In-Reply-To: <29194.1097091506@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 06 Oct 2004 16:02:22 -0400 +Message-ID: <87sm8ry5rl.fsf@stark.xeocode.com> +Lines: 31 +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-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char E9 hex) in message + header 'Cc' + Cc: ...= =?iso-8859-1?q? Pierre-Fr\351d\351ric Caillaud?... ^ +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/68 +X-Sequence-Number: 8544 + + +Tom Lane writes: + +> Greg Stark writes: +> > why isn't a "skip index scan" plan available? Well, nobody's written the code +> > yet. +> +> I don't really think it would be a useful plan anyway. + +Well it would clearly be useful in this test case, where has a small number of +distinct values in a large table, and an index on the column. His plpgsql +function that emulates such a plan is an order of magnitude faster than the +hash aggregate plan even though it has to do entirely separate index scans for +each key value. + +I'm not sure where the break-even point would be, but it would probably be +pretty low. Probably somewhere around the order of 1% distinct values in the +table. That might be uncommon, but certainly not impossible. + +But regardless of how uncommon it is, it could be considered important in +another sense: when you need it there really isn't any alternative. It's an +algorithmic improvement with no bound on the performance difference. Nothing +short of using a manually maintained materialized view would bring the +performance into the same ballpark. + +So even if it's only useful occasionally, not having the plan available can +leave postgres with no effective plan for what should be an easy query. + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Oct 6 21:05:03 2004 +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 EAAFC32A02D + for ; + Wed, 6 Oct 2004 21:05:01 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31323-08 + for ; + Wed, 6 Oct 2004 20:04:54 +0000 (GMT) +Received: from neomail10.traderonline.com (email.traderonline.com + [65.213.231.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D0AE329FF4 + for ; + Wed, 6 Oct 2004 21:04:54 +0100 (BST) +Received: from dyounger-IBM + (64-139-89-109-ubr02b-epensb01-pa.hfc.comcastbusiness.net + [64.139.89.109]) + by neomail10.traderonline.com (8.12.10/8.12.8) with ESMTP id + i96K4of6002273 + for ; Wed, 6 Oct 2004 16:04:50 -0400 +Message-Id: <6.1.2.0.2.20041006152747.033bcd50@pop.traderonline.com> +X-Sender: dylists@mail.ptd.net (Unverified) +X-Mailer: QUALCOMM Windows Eudora Version 6.1.2.0 +Date: Wed, 06 Oct 2004 16:04:52 -0400 +To: pgsql-performance@postgresql.org +From: Doug Y +Subject: The never ending quest for clarity on shared_buffers +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/69 +X-Sequence-Number: 8545 + +Hello, + We recently upgraded os from rh 7.2 (2.4 kernel) to Suse 9.1 (2.6 +kernel), and psql from 7.3.4 to 7.4.2 + + One of the quirks I've noticed is how the queries don't always have the +same explain plans on the new psql... but that's a different email I think. + + My main question is I'm trying to convince the powers that be to let me +use persistent DB connections (from apache 2 / php), and my research has +yielded conflicting documentation about the shared_buffers setting... real +shocker there :) + + For idle persistent connections, do each of them allocate the memory +specified by this setting (shared_buffers * 8k), or is it one pool used by +all the connection (which seems the logical conclusion based on the name +SHARED_buffers)? Personally I'm more inclined to think the latter choice, +but I've seen references that alluded to both cases, but never a definitive +answer. + + For what its worth, shared_buffers is currently set to 50000 (on a 4G +system). Also, effective_cache_size is 125000. max_connections is 256, so I +don't want to end up with a possible 100G (50k * 8k * 256) of memory tied +up... not that it would be possible, but you never know. + + I typically never see more than a dozen or so concurrent connections to +the db (serving 3 web servers), so I'm thinking of actually using something +like pgpool to keep about 10 per web server, rather than use traditional +persistent connections of 1 per Apache child, which would probably average +about 50 per web server. + +Thanks. + + +From pgsql-performance-owner@postgresql.org Wed Oct 6 21:20:47 2004 +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 5B701329F66 + for ; + Wed, 6 Oct 2004 21:20:42 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37473-01 + for ; + Wed, 6 Oct 2004 20:20:37 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DC6F329E89 + for ; + Wed, 6 Oct 2004 21:20:37 +0100 (BST) +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 i96KK3Do029715; + Wed, 6 Oct 2004 16:20:04 -0400 (EDT) +To: Greg Stark +Cc: =?iso-8859-1?q??= =?iso-8859-1?q? Pierre-Fr�d�ric Caillaud?= , + "Ole Langbehn" , pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +In-reply-to: <87sm8ry5rl.fsf@stark.xeocode.com> +References: <200410061130.58625.ole@freiheit.com> + <874ql7ztnb.fsf@stark.xeocode.com> <29194.1097091506@sss.pgh.pa.us> + <87sm8ry5rl.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "06 Oct 2004 16:02:22 -0400" +Date: Wed, 06 Oct 2004 16:20:03 -0400 +Message-ID: <29712.1097094003@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char E9 hex) in message + header 'Cc' + Cc: ...= =?iso-8859-1?q? Pierre-Fr\351d\351ric Caillaud?... ^ +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/70 +X-Sequence-Number: 8546 + +Greg Stark writes: +> But regardless of how uncommon it is, it could be considered important in +> another sense: when you need it there really isn't any alternative. It's an +> algorithmic improvement with no bound on the performance difference. + +[ shrug... ] There are an infinite number of special cases for which +that claim could be made. The more we load down the planner with +seldom-useful special cases, the *lower* the overall performance will +be, because we'll waste cycles checking for the special cases in every +case ... + +In this particular case, it's not merely a matter of the planner, either. +You'd need some new type of plan node in the executor, so there's a +pretty fair amount of added code bulk that will have to be written and +then maintained. + +I'm open to being persuaded that this is worth doing, but the bar is +going to be high; I think there are a lot of other more-profitable ways +to invest our coding effort and planning cycles. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Oct 6 22:36:19 2004 +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 63DCD329EEF + for ; + Wed, 6 Oct 2004 22:36:17 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57880-02 + for ; + Wed, 6 Oct 2004 21:36:09 +0000 (GMT) +Received: from vsmtp1.tin.it (vsmtp1.tin.it [212.216.176.141]) + by svr1.postgresql.org (Postfix) with ESMTP id BB8EA329EBD + for ; + Wed, 6 Oct 2004 22:36:07 +0100 (BST) +Received: from angus.tin.it (82.53.57.193) by vsmtp1.tin.it (7.0.027) + id 4162DC020009E4F5 for pgsql-performance@postgresql.org; + Wed, 6 Oct 2004 23:36:07 +0200 +Message-Id: <6.1.2.0.2.20041006230239.0201bd40@box.tin.it> +X-Sender: angusgb@box.tin.it (Unverified) +X-Mailer: QUALCOMM Windows Eudora Version 6.1.2.0 +Date: Wed, 06 Oct 2004 23:36:05 +0200 +To: pgsql-performance@postgresql.org +From: Gabriele Bartolini +Subject: Data warehousing requirements +Mime-Version: 1.0 +Content-Type: multipart/mixed; x-avg-checked=avg-ok-13F04943; + boundary="=======395821=======" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_RFCI +X-Spam-Level: +X-Archive-Number: 200410/71 +X-Sequence-Number: 8547 + +--=======395821======= +Content-Type: text/plain; x-avg-checked=avg-ok-13F04943; charset=us-ascii; + format=flowed +Content-Transfer-Encoding: 8bit + +Hi guys, + + I just discussed about my problem on IRC. I am building a Web usage +mining system based on Linux, PostgreSQL and C++ made up of an OLTP +database which feeds several and multi-purpose data warehouses about users' +behaviour on HTTP servers. + + I modelled every warehouse using the star schema, with a fact table and +then 'n' dimension tables linked using a surrogate ID. + + Discussing with the guys of the chat, I came up with these conclusions, +regarding the warehouse's performance: + +1) don't use referential integrity in the facts table +2) use INTEGER and avoid SMALLINT and NUMERIC types for dimensions' IDs +3) use an index for every dimension's ID in the fact table + + As far as administration is concerned: run VACUUM ANALYSE daily and +VACUUM FULL periodically. + + Is there anything else I should keep in mind? + + Also, I was looking for advice regarding hardware requirements for a +data warehouse system that needs to satisfy online queries. I have indeed +no idea at the moment. I can only predict 4 million about records a month +in the fact table, does it make sense or not? is it too much? + + Data needs to be easily backed up and eventually replicated. + + Having this in mind, what hardware architecture should I look for? How +many hard disks do I need, what kind and what RAID solution do you suggest +me to adopt (5 or 10 - I think)? + +Thank you so much, +-Gabriele +-- +Gabriele Bartolini: Web Programmer, ht://Dig & IWA/HWG Member, ht://Check +maintainer +Current Location: Prato, Toscana, Italia +angusgb@tin.it | http://www.prato.linux.it/~gbartolini | ICQ#129221447 + > "Leave every hope, ye who enter!", Dante Alighieri, Divine Comedy, The +Inferno + +--=======395821======= +Content-Type: text/plain; charset=us-ascii; x-avg=cert; + x-avg-checked=avg-ok-13F04943 +Content-Disposition: inline + + +--- +Outgoing mail is certified Virus Free. +Checked by AVG anti-virus system (http://www.grisoft.com). +Version: 6.0.773 / Virus Database: 520 - Release Date: 05/10/2004 + +--=======395821=======-- + + +From pgsql-performance-owner@postgresql.org Wed Oct 6 23:28:19 2004 +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 970B932A0F8 + for ; + Wed, 6 Oct 2004 23:28:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73209-05 + for ; + Wed, 6 Oct 2004 22:28:09 +0000 (GMT) +Received: from mail.refractions.net (mail.refractions.net [24.68.236.214]) + by svr1.postgresql.org (Postfix) with ESMTP id DED0032A0D0 + for ; + Wed, 6 Oct 2004 23:28:10 +0100 (BST) +Received: from lion.animals (lion [192.168.50.200]) + by mail.refractions.net (Postfix) with ESMTP + id E59902BEC6; Wed, 6 Oct 2004 15:28:09 -0700 (PDT) +Received: by lion.animals (Postfix, from userid 88) + id 7400AE3BA; Wed, 6 Oct 2004 15:28:09 -0700 (PDT) +Received: from [192.168.50.11] (unknown [192.168.50.11]) + by lion.animals (Postfix) with ESMTP + id 13D26E3B7; Wed, 6 Oct 2004 15:28:08 -0700 (PDT) +Message-ID: <41647127.3060407@refractions.net> +Date: Wed, 06 Oct 2004 15:26:47 -0700 +From: Paul Ramsey +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Doug Y +Cc: pgsql-performance@postgresql.org +Subject: Re: The never ending quest for clarity on shared_buffers +References: <6.1.2.0.2.20041006152747.033bcd50@pop.traderonline.com> +In-Reply-To: <6.1.2.0.2.20041006152747.033bcd50@pop.traderonline.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/72 +X-Sequence-Number: 8548 + +Doug Y wrote: + +> For idle persistent connections, do each of them allocate the memory +> specified by this setting (shared_buffers * 8k), or is it one pool used +> by all the connection (which seems the logical conclusion based on the +> name SHARED_buffers)? Personally I'm more inclined to think the latter +> choice, but I've seen references that alluded to both cases, but never a +> definitive answer. + +The shared_buffers are shared (go figure) :). It is all one pool shared +by all connections. The sort_mem and vacuum_mem are *per*connection* +however, so when allocating that size you have to take into account your +expected number of concurrent connections. + +Paul + +From pgsql-performance-owner@postgresql.org Thu Oct 7 00:56:02 2004 +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 B3A37329ED1 + for ; + Thu, 7 Oct 2004 00:56:00 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94940-01 + for ; + Wed, 6 Oct 2004 23:55:53 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AAD0329D62 + for ; + Thu, 7 Oct 2004 00:55:55 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i96NtpJm094954 + for ; Wed, 6 Oct 2004 23:55:51 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i96NmUQG092858 + for pgsql-performance@postgresql.org; Wed, 6 Oct 2004 23:48:30 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Excessive context switching on SMP Xeons +Date: Thu, 07 Oct 2004 01:48:22 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 19 +Message-ID: <41648446.5020102@bigfoot.com> +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> <200410051538.51664.josh@agliodbs.com> + <41636D8E.1090403@rentec.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Alan Stange +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +In-Reply-To: <41636D8E.1090403@rentec.com> +X-Enigmail-Version: 0.86.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/73 +X-Sequence-Number: 8549 + +Alan Stange wrote: +> A few quick random observations on the Xeon v. Opteron comparison: + +[SNIP] + +> I don't care to go into the whole debate of Xeon v. Opteron here. We +> also have a lot of dual Xeon systems. In every comparison I've done with +> our codes, the dual Opteron clearly outperforms the dual Xeon, when +> running on one and both cpus. + +Here http://www6.tomshardware.com/cpu/20030422/ both were tested and there is +a database performance section, unfortunatelly they used MySQL. + + +Regards +Gaetano Mendola + + + + +From pgsql-performance-owner@postgresql.org Thu Oct 7 02:07:01 2004 +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 20996329EE9 + for ; + Thu, 7 Oct 2004 02:07:00 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08437-05 + for ; + Thu, 7 Oct 2004 01:06:52 +0000 (GMT) +Received: from sraigw.sra.co.jp (sraigw.sra.co.jp [202.32.10.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 372FD329CD9 + for ; + Thu, 7 Oct 2004 02:06:54 +0100 (BST) +Received: from srascb.sra.co.jp (srascb [133.137.8.65]) + by sraigw.sra.co.jp (Postfix) with ESMTP + id AD88062253; Thu, 7 Oct 2004 10:06:53 +0900 (JST) +Received: from srascb.sra.co.jp (localhost [127.0.0.1]) + by localhost.sra.co.jp (Postfix) with ESMTP + id 9470B10CD06; Thu, 7 Oct 2004 10:06:53 +0900 (JST) +Received: from sranhm.sra.co.jp (sranhm [133.137.44.16]) + by srascb.sra.co.jp (Postfix) with ESMTP + id 7513E10CD04; Thu, 7 Oct 2004 10:06:53 +0900 (JST) +Received: from localhost (IDENT:t-ishii@hub-es6.sra.co.jp [133.137.44.7]) + by sranhm.sra.co.jp (8.9.3+3.2W/3.7W-srambox) with ESMTP id KAA32531; + Thu, 7 Oct 2004 10:06:53 +0900 +Date: Thu, 07 Oct 2004 10:08:47 +0900 (JST) +Message-Id: <20041007.100847.26272104.t-ishii@sra.co.jp> +To: matt@ymogen.net +Cc: pg@rbt.ca, awerman2@hotmail.com, scottakirkwood@gmail.com, + pgsql-performance@postgresql.org +Subject: Re: Caching of Queries +From: Tatsuo Ishii +In-Reply-To: <012501c4aaf0$f12d0930$8300a8c0@solent> +References: <20041004.002823.85416338.t-ishii@sra.co.jp> + <012501c4aaf0$f12d0930$8300a8c0@solent> +X-Mailer: Mew version 2.3 on Emacs 20.7 / Mule 4.1 + =?iso-2022-jp?B?KBskQjAqGyhCKQ==?= +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/74 +X-Sequence-Number: 8550 + +> > I don't know what you are exactly referring to in above URL +> > when you are talking about "potential pitfalls of pooling". +> > Please explain more. +> +> Sorry, I wasn't implying that pgpool doesn't deal with the issues, just that +> some people aren't necessarily aware of them up front. For instance, pgpool +> does an 'abort transaction' and a 'reset all' in lieu of a full reconnect +> (of course, since a full reconnect is exactly what we are trying to avoid). +> Is this is enough to guarantee that a given pooled connection behaves +> exactly as a non-pooled connection would from a client perspective? For +> instance, temporary tables are usually dropped at the end of a session, so a +> client (badly coded perhaps) that does not already use persistent +> connections might be confused when the sequence 'connect, create temp table +> foo ..., disconnect, connect, create temp table foo ...' results in the +> error 'Relation 'foo' already exists'. + +First, it's not a particular problem with pgpool. As far as I know any +connection pool solution has exactly the same problem. Second, it's +easy to fix if PostgreSQL provides a functionarity such as:"drop all +temporary tables if any". I think we should implement it if we agree +that connection pooling should be implemented outside the PostgreSQL +engine itself. I think cores agree with this. +-- +Tatsuo Ishii + +From pgsql-performance-owner@postgresql.org Thu Oct 7 02:30:07 2004 +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 C47A132A5DA + for ; + Thu, 7 Oct 2004 02:30:06 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15330-01 + for ; + Thu, 7 Oct 2004 01:29:53 +0000 (GMT) +Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F0A132A5ED + for ; + Thu, 7 Oct 2004 02:29:56 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by sue.samurai.com (Postfix) with ESMTP id 18382197CE; + Wed, 6 Oct 2004 21:29:57 -0400 (EDT) +Received: from sue.samurai.com ([127.0.0.1]) + by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 54699-01-3; Wed, 6 Oct 2004 21:29:55 -0400 (EDT) +Received: from localhost (unknown [61.88.101.19]) + by sue.samurai.com (Postfix) with ESMTP id 6B1BE197A8; + Wed, 6 Oct 2004 21:29:53 -0400 (EDT) +Subject: Re: The never ending quest for clarity on shared_buffers +From: Neil Conway +To: Paul Ramsey +Cc: Doug Y , pgsql-performance@postgresql.org +In-Reply-To: <41647127.3060407@refractions.net> +References: <6.1.2.0.2.20041006152747.033bcd50@pop.traderonline.com> + <41647127.3060407@refractions.net> +Content-Type: text/plain +Message-Id: <1097112547.13119.108.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Thu, 07 Oct 2004 11:29:07 +1000 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/75 +X-Sequence-Number: 8551 + +On Thu, 2004-10-07 at 08:26, Paul Ramsey wrote: +> The shared_buffers are shared (go figure) :). It is all one pool shared +> by all connections. + +Yeah, I thought this was pretty clear. Doug, can you elaborate on where +you saw the misleading docs? + +> The sort_mem and vacuum_mem are *per*connection* however, so when +> allocating that size you have to take into account your +> expected number of concurrent connections. + +Allocations of size `sort_mem' can actually can actually happen several +times within a *single* connection (if the query plan happens to involve +a number of sort steps or hash tables) -- the limit is on the amount of +memory that will be used for a single sort/hash table. So choosing the +right figure is actually a little more complex than that. + +-Neil + + + +From pgsql-performance-owner@postgresql.org Thu Oct 7 06:47:58 2004 +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 05A6132AB16 + for ; + Thu, 7 Oct 2004 06:40:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58139-02 + for ; + Thu, 7 Oct 2004 05:38:46 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id E1DD332A4B9 + for ; + Thu, 7 Oct 2004 06:38:46 +0100 (BST) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr4.postgresql.org (Postfix) with ESMTP id 519165AFE00 + for ; + Thu, 7 Oct 2004 04:18:33 +0000 (GMT) +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 i973CEMt023363; + Wed, 6 Oct 2004 23:12:14 -0400 (EDT) +To: Tatsuo Ishii +Cc: matt@ymogen.net, pg@rbt.ca, awerman2@hotmail.com, + scottakirkwood@gmail.com, pgsql-performance@postgresql.org +Subject: Re: Caching of Queries +In-reply-to: <20041007.100847.26272104.t-ishii@sra.co.jp> +References: <20041004.002823.85416338.t-ishii@sra.co.jp> + <012501c4aaf0$f12d0930$8300a8c0@solent> + <20041007.100847.26272104.t-ishii@sra.co.jp> +Comments: In-reply-to Tatsuo Ishii + message dated "Thu, 07 Oct 2004 10:08:47 +0900" +Date: Wed, 06 Oct 2004 23:12:14 -0400 +Message-ID: <23362.1097118734@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/77 +X-Sequence-Number: 8553 + +Tatsuo Ishii writes: +> First, it's not a particular problem with pgpool. As far as I know any +> connection pool solution has exactly the same problem. Second, it's +> easy to fix if PostgreSQL provides a functionarity such as:"drop all +> temporary tables if any". + +I don't like that definition exactly --- it would mean that every time +we add more backend-local state, we expect client drivers to know to +issue the right incantation to reset that kind of state. + +I'm thinking we need to invent a command like "RESET CONNECTION" that +resets GUC variables, drops temp tables, forgets active NOTIFYs, and +generally does whatever else needs to be done to make the session state +appear virgin. When we add more such state, we can fix it inside the +backend without bothering clients. + +I now realize that our "RESET ALL" command for GUC variables was not +fully thought out. We could possibly redefine it as doing the above, +but that might break some applications ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Oct 7 05:14:01 2004 +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 97FCA32AE37 + for ; + Thu, 7 Oct 2004 05:13:56 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42791-09 + for ; + Thu, 7 Oct 2004 04:13:17 +0000 (GMT) +Received: from wren.rentec.com (unknown [65.213.84.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F1B932A5C7 + for ; + Thu, 7 Oct 2004 05:06:52 +0100 (BST) +Received: from [172.16.160.107] (stange-dhcp1.rentec.com [172.16.160.107]) + by wren.rentec.com (8.12.9/8.12.1) with ESMTP id i9745LBD002387; + Thu, 7 Oct 2004 00:05:21 -0400 (EDT) +Message-ID: <4164B48C.9060202@rentec.com> +Date: Wed, 06 Oct 2004 23:14:20 -0400 +From: Alan Stange +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola +Cc: pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> <200410051538.51664.josh@agliodbs.com> + <41636D8E.1090403@rentec.com> <41648446.5020102@bigfoot.com> +In-Reply-To: <41648446.5020102@bigfoot.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/76 +X-Sequence-Number: 8552 + +Here's a few numbers from the Opteron 250. If I get some time I'll post +a more comprehensive comparison including some other systems. + +The system is a Sun v20z. Dual Opteron 250, 2.4Ghz, Linux 2.6, 8 GB +memory. I did a compile and install of pg 8.0 beta 3. I created a +data base on a tmpfs file system and ran pgbench. Everything was "out +of the box", meaning I did not tweak any config files. + +I used this for pgbench: +$ pgbench -i -s 32 + +and this for pgbench invocations: +$ pgbench -s 32 -c 1 -t 10000 -v + + +clients tps +1 1290 +2 1780 +4 1760 +8 1680 +16 1376 +32 904 + + +How are these results useful? In some sense, this is a speed of light +number for the Opteron 250. You'll never go faster on this system with +a real storage subsystem involved instead of a tmpfs file system. It's +also a set of numbers that anyone else can reproduce as we don't have to +deal with any differences in file systems, disk subsystems, networking, +etc. Finally, it's a set of results that anyone else can compute on +Xeon's or other systems and make a simple (and naive) comparisons. + + +Just to stay on topic: vmstat reported about 30K cs / second while +this was running the 1 and 2 client cases. + +-- Alan + + +From pgsql-performance-owner@postgresql.org Thu Oct 7 08:46:30 2004 +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 4EE0032ABB9 + for ; + Thu, 7 Oct 2004 08:46:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78834-10 + for ; + Thu, 7 Oct 2004 07:45:55 +0000 (GMT) +Received: from sraigw.sra.co.jp (sraigw.sra.co.jp [202.32.10.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F0CB32A822 + for ; + Thu, 7 Oct 2004 08:44:58 +0100 (BST) +Received: from srascb.sra.co.jp (srascb [133.137.8.65]) + by sraigw.sra.co.jp (Postfix) with ESMTP + id EAA2062072; Thu, 7 Oct 2004 16:16:48 +0900 (JST) +Received: from srascb.sra.co.jp (localhost [127.0.0.1]) + by localhost.sra.co.jp (Postfix) with ESMTP + id CA96010CD06; Thu, 7 Oct 2004 16:16:48 +0900 (JST) +Received: from sranhm.sra.co.jp (sranhm [133.137.44.16]) + by srascb.sra.co.jp (Postfix) with ESMTP + id A55F110CD04; Thu, 7 Oct 2004 16:16:48 +0900 (JST) +Received: from localhost (IDENT:t-ishii@srapc2345.sra.co.jp [133.137.44.184]) + by sranhm.sra.co.jp (8.9.3+3.2W/3.7W-srambox) with ESMTP id QAA15134; + Thu, 7 Oct 2004 16:16:48 +0900 +Date: Thu, 07 Oct 2004 16:18:42 +0900 (JST) +Message-Id: <20041007.161842.77062117.t-ishii@sra.co.jp> +To: tgl@sss.pgh.pa.us +Cc: matt@ymogen.net, pg@rbt.ca, awerman2@hotmail.com, + scottakirkwood@gmail.com, pgsql-performance@postgresql.org +Subject: Re: Caching of Queries +From: Tatsuo Ishii +In-Reply-To: <23362.1097118734@sss.pgh.pa.us> +References: <012501c4aaf0$f12d0930$8300a8c0@solent> + <20041007.100847.26272104.t-ishii@sra.co.jp> + <23362.1097118734@sss.pgh.pa.us> +X-Mailer: Mew version 2.3 on Emacs 20.7 / Mule 4.1 + =?iso-2022-jp?B?KBskQjAqGyhCKQ==?= +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/78 +X-Sequence-Number: 8554 + +> Tatsuo Ishii writes: +> > First, it's not a particular problem with pgpool. As far as I know any +> > connection pool solution has exactly the same problem. Second, it's +> > easy to fix if PostgreSQL provides a functionarity such as:"drop all +> > temporary tables if any". +> +> I don't like that definition exactly --- it would mean that every time +> we add more backend-local state, we expect client drivers to know to +> issue the right incantation to reset that kind of state. +> +> I'm thinking we need to invent a command like "RESET CONNECTION" that +> resets GUC variables, drops temp tables, forgets active NOTIFYs, and +> generally does whatever else needs to be done to make the session state +> appear virgin. When we add more such state, we can fix it inside the +> backend without bothering clients. + +Great. It's much better than I propose. + +> I now realize that our "RESET ALL" command for GUC variables was not +> fully thought out. We could possibly redefine it as doing the above, +> but that might break some applications ... +> +> regards, tom lane +> + +From pgsql-performance-owner@postgresql.org Thu Oct 7 12:43:44 2004 +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 09FAF32A1A9 + for ; + Thu, 7 Oct 2004 12:43:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26108-06 + for ; + Thu, 7 Oct 2004 11:42:47 +0000 (GMT) +Received: from hotmail.com (bay18-dav8.bay18.hotmail.com [65.54.187.188]) + by svr1.postgresql.org (Postfix) with ESMTP id C9F4732AAE7 + for ; + Thu, 7 Oct 2004 12:30:37 +0100 (BST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 7 Oct 2004 04:30:01 -0700 +Received: from 67.81.98.198 by BAY18-DAV8.phx.gbl with DAV; + Thu, 07 Oct 2004 11:29:53 +0000 +X-Originating-IP: [67.81.98.198] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: , "Gabriele Bartolini" +References: <6.1.2.0.2.20041006230239.0201bd40@box.tin.it> +Subject: Re: Data warehousing requirements +Date: Thu, 7 Oct 2004 07:30:07 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Message-ID: +X-OriginalArrivalTime: 07 Oct 2004 11:30:01.0026 (UTC) + FILETIME=[FB8B3A20:01C4AC60] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/79 +X-Sequence-Number: 8555 + +Consider how the fact table is going to be used, and review hacking it up +based on usage. Fact tables should be fairly narrow, so if there are extra +columns beyond keys and dimension keys consider breaking it into parallel +tables (vertical partitioning). + +Horizontal partitioning is your friend; especially if it is large - consider +slicing the data into chunks. If the fact table is date driven it might be +worthwhile to break it into separate tables based on date key. This wins in +reducing the working set of queries and in buffering. If there is a real +hotspot, such as current month's activity, you might want to keep a separate +table with just the (most) active data.Static tables of unchanged data can +simplify backups, etc., as well. + +Consider summary tables if you know what type of queries you'll hit. +Especially here, MVCC is not your friend because it has extra work to do for +aggregate functions. + +Cluster helps if you bulk load. + +In most warehouses, the data is downstream data from existing operational +systems. Because of that you're not able to use database features to +preserve integrity. In most cases, the data goes through an +extract/transform/load process - and the output is considered acceptable. +So, no RI is correct for star or snowflake design. Pretty much no anything +else that adds intelligence - no triggers, no objects, no constraints of any +sort. Many designers try hard to avoid nulls. + +On the hardware side - RAID5 might work here because of the low volume if +you can pay the write performance penalty. To size hardware you need to +estimate load in terms of transaction type (I usually make bucket categories +of small, medium, and large effort needs) and transaction rate. Then try to +estimate how much CPU and I/O they'll use. + +/Aaron + +"Let us not speak of them; but look, and pass on." + +----- Original Message ----- +From: "Gabriele Bartolini" +To: +Sent: Wednesday, October 06, 2004 5:36 PM +Subject: [PERFORM] Data warehousing requirements + + +> Hi guys, +> +> I just discussed about my problem on IRC. I am building a Web usage +> mining system based on Linux, PostgreSQL and C++ made up of an OLTP +> database which feeds several and multi-purpose data warehouses about +users' +> behaviour on HTTP servers. +> +> I modelled every warehouse using the star schema, with a fact table +and +> then 'n' dimension tables linked using a surrogate ID. +> +> Discussing with the guys of the chat, I came up with these +conclusions, +> regarding the warehouse's performance: +> +> 1) don't use referential integrity in the facts table +> 2) use INTEGER and avoid SMALLINT and NUMERIC types for dimensions' IDs +> 3) use an index for every dimension's ID in the fact table +> +> As far as administration is concerned: run VACUUM ANALYSE daily and +> VACUUM FULL periodically. +> +> Is there anything else I should keep in mind? +> +> Also, I was looking for advice regarding hardware requirements for a +> data warehouse system that needs to satisfy online queries. I have indeed +> no idea at the moment. I can only predict 4 million about records a month +> in the fact table, does it make sense or not? is it too much? +> +> Data needs to be easily backed up and eventually replicated. +> +> Having this in mind, what hardware architecture should I look for? How +> many hard disks do I need, what kind and what RAID solution do you suggest +> me to adopt (5 or 10 - I think)? +> +> Thank you so much, +> -Gabriele +> -- +> Gabriele Bartolini: Web Programmer, ht://Dig & IWA/HWG Member, ht://Check +> maintainer +> Current Location: Prato, Toscana, Italia +> angusgb@tin.it | http://www.prato.linux.it/~gbartolini | ICQ#129221447 +> > "Leave every hope, ye who enter!", Dante Alighieri, Divine Comedy, The +> Inferno +> + + +---------------------------------------------------------------------------- +---- + + +> +> --- +> Outgoing mail is certified Virus Free. +> Checked by AVG anti-virus system (http://www.grisoft.com). +> Version: 6.0.773 / Virus Database: 520 - Release Date: 05/10/2004 +> + + +---------------------------------------------------------------------------- +---- + + +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> + +From pgsql-performance-owner@postgresql.org Thu Oct 7 13:00:25 2004 +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 7490832A2F7 + for ; + Thu, 7 Oct 2004 13:00:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28992-05 + for ; + Thu, 7 Oct 2004 11:59:37 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id AEDED32A009 + for ; + Thu, 7 Oct 2004 12:58:08 +0100 (BST) +Received: (qmail 27673 invoked from network); 7 Oct 2004 13:58:30 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 7 Oct 2004 13:58:30 +0200 +In-Reply-To: <29194.1097091506@sss.pgh.pa.us> +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +References: <200410061130.58625.ole@freiheit.com> + <874ql7ztnb.fsf@stark.xeocode.com> <29194.1097091506@sss.pgh.pa.us> +Subject: Re: sequential scan on select distinct +To: pgsql-performance@postgresql.org +Message-ID: +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Date: Thu, 07 Oct 2004 14:01:13 +0200 +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/80 +X-Sequence-Number: 8556 + + +> I don't really think it would be a useful plan anyway. What *would* be +> useful is to support HashAggregate as an implementation alternative for +> DISTINCT --- currently I believe we only consider that for GROUP BY. +> The DISTINCT planning code is fairly old and crufty and hasn't been +> redesigned lately. +> +> regards, tom lane + + I see this as a minor annoyance only because I can write GROUP BY +instead of DISTINCT and get the speed boost. It probably annoys people +trying to port applications to postgres though, forcing them to rewrite +their queries. + +* SELECT DISTINCT : 21442.296 ms (by default, uses an index scan) +disabling index_scan => Sort + Unique : 14512.105 ms + +* GROUP BY : 1793.651 ms using HashAggregate +* skip index scan by function : 13.833 ms + + The HashAggregate speed boost is good, but rather pathetic compared +to a "skip index scan" ; but it's still worth having if updating the +DISTINCT code is easy. + + Note that it would also benefit UNION queries which apparently use +DISTINCT +internally and currently produce this : +------------------------------------------------------------------------------ +explain analyze select number from + ((select number from dummy) union (select number from dummy)) as foo; + + Subquery Scan foo (cost=287087.62..317087.62 rows=2000000 width=4) +(actual time=33068.776..35575.330 rows=255 loops=1) + -> Unique (cost=287087.62..297087.62 rows=2000000 width=4) (actual +time=33068.763..35574.126 rows=255 loops=1) + -> Sort (cost=287087.62..292087.62 rows=2000000 width=4) +(actual time=33068.757..34639.180 rows=2000000 loops=1) + Sort Key: number + -> Append (cost=0.00..49804.00 rows=2000000 width=4) +(actual time=0.055..7412.551 rows=2000000 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..24902.00 +rows=1000000 width=4) (actual time=0.054..3104.165 rows=1000000 loops=1) + -> Seq Scan on dummy (cost=0.00..14902.00 +rows=1000000 width=4) (actual time=0.051..1792.348 rows=1000000 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=0.00..24902.00 +rows=1000000 width=4) (actual time=0.048..3034.462 rows=1000000 loops=1) + -> Seq Scan on dummy (cost=0.00..14902.00 +rows=1000000 width=4) (actual time=0.044..1718.682 rows=1000000 loops=1) + Total runtime: 36265.662 ms +------------------------------------------------------------------------------ + +But could instead do this : +explain analyze select number from + ((select number from dummy) union all (select number from dummy)) as foo +group by number; + + HashAggregate (cost=74804.00..74804.00 rows=200 width=4) (actual +time=10753.648..10753.890 rows=255 loops=1) + -> Subquery Scan foo (cost=0.00..69804.00 rows=2000000 width=4) +(actual time=0.059..8992.084 rows=2000000 loops=1) + -> Append (cost=0.00..49804.00 rows=2000000 width=4) (actual +time=0.055..6688.639 rows=2000000 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..24902.00 +rows=1000000 width=4) (actual time=0.054..2749.708 rows=1000000 loops=1) + -> Seq Scan on dummy (cost=0.00..14902.00 +rows=1000000 width=4) (actual time=0.052..1640.427 rows=1000000 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=0.00..24902.00 +rows=1000000 width=4) (actual time=0.038..2751.916 rows=1000000 loops=1) + -> Seq Scan on dummy (cost=0.00..14902.00 +rows=1000000 width=4) (actual time=0.034..1637.818 rows=1000000 loops=1) + Total runtime: 10754.120 ms +------------------------------------------------------------------------------ + A 3x speedup, but still a good thing to have. + When I LIMIT the two subqueries to 100k rows instead of a million, the +times are about equal. + When I LIMIT one of the subqueries to 100k and leave the other to 1M, + UNION ALL 17949.609 ms + UNION + GROUP BY 6130.417 ms + + Still some performance to be gained... + +------------------------------------------------------------------------------ + Of course it can't use a skip index scan on a subquery, but I could +instead : + I know it's pretty stupid to use the same table twice but it's just an +example. However, if you think about table partitions and views, a "select +distinct number" from a view having multiple partitions would yield this +type of query, and that table partitioning seems like a hot subject lately. + +let's create a dummy example view : +create view dummy_view as (select * from dummy) union all (select * from +dummy); + +explain analyze select number from dummy_view group by number; + HashAggregate (cost=74804.00..74804.00 rows=200 width=4) (actual +time=10206.456..10206.713 rows=255 loops=1) + -> Subquery Scan dummy_view (cost=0.00..69804.00 rows=2000000 +width=4) (actual time=0.060..8431.776 rows=2000000 loops=1) + -> Append (cost=0.00..49804.00 rows=2000000 width=8) (actual +time=0.055..6122.125 rows=2000000 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..24902.00 +rows=1000000 width=8) (actual time=0.054..2456.566 rows=1000000 loops=1) + -> Seq Scan on dummy (cost=0.00..14902.00 +rows=1000000 width=8) (actual time=0.048..1107.151 rows=1000000 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=0.00..24902.00 +rows=1000000 width=8) (actual time=0.036..2471.748 rows=1000000 loops=1) + -> Seq Scan on dummy (cost=0.00..14902.00 +rows=1000000 width=8) (actual time=0.031..1104.482 rows=1000000 loops=1) + Total runtime: 10206.945 ms + +A smarter planner could rewrite it into this : +select number from ((select distinct number from dummy) union (select +distinct number from dummy)) as foo; + +and notice it would index-skip-scan the two partitions (here, example with +my function) + +explain analyze select number from ((select sel_distinct as number from +sel_distinct()) union all (select sel_distinct as number + from sel_distinct())) as foo group by number; + HashAggregate (cost=70.00..70.00 rows=200 width=4) (actual +time=29.078..29.332 rows=255 loops=1) + -> Subquery Scan foo (cost=0.00..65.00 rows=2000 width=4) (actual +time=13.378..28.587 rows=510 loops=1) + -> Append (cost=0.00..45.00 rows=2000 width=4) (actual +time=13.373..28.003 rows=510 loops=1) + -> Subquery Scan "*SELECT* 1" (cost=0.00..22.50 rows=1000 +width=4) (actual time=13.373..13.902 rows=255 loops=1) + -> Function Scan on sel_distinct (cost=0.00..12.50 +rows=1000 width=4) (actual time=13.367..13.619 rows=255 loops=1) + -> Subquery Scan "*SELECT* 2" (cost=0.00..22.50 rows=1000 +width=4) (actual time=13.269..13.800 rows=255 loops=1) + -> Function Scan on sel_distinct (cost=0.00..12.50 +rows=1000 width=4) (actual time=13.263..13.512 rows=255 loops=1) + Total runtime: 29.569 ms + + So, if a query with UNION or UNION ALL+DISTINCT tries to put DISTINCT +inside the subqueries and yields an index skip scan, here is a massive +speedup. + + You will tell me "but if the UNION ALL has 10 subqueries, planning is +going to take forever !" + Well not necessarily. The above query with 10 subqueries UNIONALLed then +GROUPed takes : + UNION : 320509.522 ms (the Sort + Unique truly becomes humongous). + UNION ALL + GROUP : 54586.759 ms (you see there is already interest in +rewiring DISTINCT/UNION) + skip scan + UNION : 147.941 ms + skip scan + UNION ALL + group : 147.313 ms + +> Well it would clearly be useful in this test case, where has a small +> number of distinct values in a large table, and an index on the column. +> His plpgsql function that emulates such a plan is an order of magnitude +> faster than the hash aggregate plan even though it has to do entirely +> separate index scans for each key value. + + Actually, it is more like two orders of magnitude (100x faster) : +in fact the time for a seq scan is O(N rows) whereas the time for the skip +index scan should be, if I'm not mistaken, something like +O((N distinct values) * (log N rows)) ; in my case there are 256 distinct +values for 1M rows and a speedup of 100x, so if there were 10M rows the +speedup would be like 300x (depending on the base of the log which I assume +is 2). And if the skip index scan is implemented in postgres instead of in +a function, it could be much, much faster... + +> [ shrug... ] There are an infinite number of special cases for which +> that claim could be made. The more we load down the planner with +> seldom-useful special cases, the *lower* the overall performance will +> be, because we'll waste cycles checking for the special cases in every +> case ... + + In a general way, you are absolutely right... special-casing a case +for a speedup of 2x for instance would be worthless... but we are +considering +a HUGE speedup here. And, if this mode is only used for DISTINCT and +GROUP BY queries, no planning cycles will be wasted at all on queries which +do not use DISTINCT nor GROUP BY. + + Present state is that DISTINCT and UNION are slow with or without using +the GROUP BY trick. Including the index skip scan in the planning options +would only happen when appropriate cases are detected. This detection +would be very fast. The index skip scan would then speed up the query so +much that the additional planning cost would not matter. If there are many +distinct values, so that seq scan is faster than skip scan, the query will +be slow enough anyway so that the additional planning cost does not +matter. The only problem cases are queries with small tables where startup +time is important, but in that case the planner has stats about the number +of rows in the table, and again excluding skip scan from the start would +be fast. + + Lateral thought : + Create a new index type which only indexes one row for each value. This +index would use very little space and would be very fast to update (on my +table it would index only 256 values). Keep the Index Scan code and all, +but use this index type when you can. + This solution is less general and also has a few drawbacks. + + Another thought : +\d dummy + Table �public.dummy� + Colonne | Type | Modificateurs +---------+---------+--------------- + id | integer | + number | integer | +Index : + �dummy_idx� btree (number) + �dummy_idx_2� btree (number, id) + +explain analyze select * from dummy where id=1; + + Seq Scan on dummy (cost=0.00..17402.00 rows=1 width=8) (actual +time=274.480..1076.092 rows=1 loops=1) + Filter: (id = 1) + Total runtime: 1076.168 ms + +explain analyze select * from dummy where number between 0 and 256 and +id=1; + Index Scan using dummy_idx_2 on dummy (cost=0.00..6.02 rows=1 width=8) +(actual time=1.449..332.020 rows=1 loops=1) + Index Cond: ((number >= 0) AND (number <= 256) AND (id = 1)) + Total runtime: 332.112 ms + + In this case we have no index on id, but using a skip index scan, +emulated by the "between" to force use of the (number,id) index, even +though it must look in all the 256 possible values for number, still +speeds it up by 3x. Interestingly, with only 16 distinct values, the time +is quite the same. Thus, the "skip index scan" could be used in cases +where there is a multicolumn index, but the WHERE misses a column. + +This would not waste planning cycles because : +- If the index we need exists and there is no "distinct" or "group by" +without aggregate, the planner does not even consider using the skip index +scan. +- If the index we need does not exist, the planner only loses the cycles +needed to check if there is a multicolumn index which may be used. In this +case, either there is no such index, and a seq scan is chosen, which will +be slow, so the time wasted for the check is negligible ; or an index is +found and can be used, and the time gained by the skip index scan is well +amortized. + + Currently one has to carefully consider which queries will be used +frequently and need indexes, and which ones are infrequent and don't +justify an index (but these queries will be very slow). With the skip +index scan, these less frequent queries don't always mean a seq scan. Thus +people will need to create less infrequently used indexes, and will have a +higher INSERT/UPDATE speed/ + +------------------------------------------------------------------------------------------------ + + The skip scan would also be a winner on this type of query which is a +killer, a variant of the famous 'TOP 10' query : +EXPLAIN SELECT max(id), number FROM dummy GROUP BY number; -> 2229.141 ms + + Postgres uses a Seq scan + HashAggregate. Come on, we have an index btree +(number, id), use it ! A simple customization on my skip scan emulation +function takes 13.683 ms... + + I know that Postgres does not translate max() on on indexed column to +ORDER BY column DESC LIMIT 1, because it would be extremely hard to +implement due to the general nature of aggregates which is a very good +thing. It does not bother me because I can still write ORDER BY column +DESC LIMIT 1. + + Where it does bother me is if I want the highest ID from each number, +which can only be expressed by +SELECT max(id), number FROM dummy GROUP BY number; + and not with LIMITs. + + Suppose I want the first 10 higher id's for each number, which is another +variant on the "killer top 10 query". I'm stuck, I cannot even use max(), +I have to write a custom aggregate which would keep the 10 highest values, +which would be very slow, so I have to use my function and put a LIMIT 10 +instead of a LIMIT 1 in each query, along with a FOR and some other +conditions to check if there are less than 10 id's for a number, etc, +which more or less amounts to "select the next number, then select the +associated id's". It'll still be fast a lot faster than seq scan, but it +gets more and more complicated. + + However I'd like to write : + + select number,id from dummy ORDER BY number DESC, id DESC MULTILIMIT +50,10; + The MULTILIMIT means "I want 50 numbers and 10 id's for each number." + MULTILIMIT NULL,10 would mean "I want all numbers and 10 id's for each +number." + NULL is not mandatory, it could also be -1, a keyword or something. +MULTILIMIT could simply be LIMIT too, because LIMIT takes one parameter. + The OFFSET clause could also evolve accordingly. + + And this would naturally use a skip index scan, and benefit a whole class +of queries which have traditionnaly been difficult to get right... + + Conclusion : + + smarting up the DISTINCT planner has the following benefits : + - speedup on DISTINCT + - speedup on UNION which seems to use DISTINCT internally + + index skip scan has the following benefits : + - massive speedup (x100) on queries involving DISTINCT or its GROUP BY +variant + - same thing (x300) on UNION queries if the parser tries to rewrite the +query and put the DISTINCT inside the subqueries + - paves the way for a MULTILIMIT which gives an elegant, and very +efficient way of expressing traditionnaly difficult queries like the "Top +10 by category" which are used quite often and give headaches to dba's. + - Possibility to use a multicolumn index with a WHERE not including all +left columns + + index skip scan has the following drawbacks : + - more complexity + - additional planning time + + This last drawback is in fact, limited because : + - It is easy and fast to know when the index skip scan will never be +used, so in most queries which won't need it, the possibility can be +eliminated without wasting cycles in planning + - When it is used, the performance gains are so massive that it is +justified + - People who use many queries where planning time is significant +comparing to execution time are probably using SQL functions or prepared +queries. + + Enough arguments, maybe not to convince you, but to have a second thought +on it ? + +--------------------------------------------------------------- + + Side Note : + + What do you think about the idea of an "UniqueSort" which would do +sort+unique in one pass ? This could also be simple to code, and would also +offer advantages to all queries using UNION. The sort would be faster and +consume less storage space because the data size would diminish as +duplicates +are eliminated along the way. + +From pgsql-performance-owner@postgresql.org Thu Oct 7 16:35:48 2004 +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 6B2A232A0D0 + for ; + Thu, 7 Oct 2004 16:35:46 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06019-02 + for ; + Thu, 7 Oct 2004 15:35:37 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A9C3A32A3D2 + for ; + Thu, 7 Oct 2004 16:35:37 +0100 (BST) +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 i97FZZS9029075; + Thu, 7 Oct 2004 11:35:35 -0400 (EDT) +To: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +Cc: pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +In-reply-to: +References: <200410061130.58625.ole@freiheit.com> + <874ql7ztnb.fsf@stark.xeocode.com> + <29194.1097091506@sss.pgh.pa.us> +Comments: In-reply-to =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + + message dated "Thu, 07 Oct 2004 14:01:13 +0200" +Date: Thu, 07 Oct 2004 11:35:34 -0400 +Message-ID: <29074.1097163334@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/81 +X-Sequence-Number: 8557 + +=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= writes: +> Present state is that DISTINCT and UNION are slow with or without using +> the GROUP BY trick. Including the index skip scan in the planning options +> would only happen when appropriate cases are detected. This detection +> would be very fast. + +You have no basis whatever for making that last assertion; and since +it's the critical point, I don't intend to let you slide by without +backing it up. I think that looking for relevant indexes would be +nontrivial; the more so in cases like you've been armwaving about just +above, where you have to find a relevant index for each of several +subqueries. The fact that the optimization wins a lot when it wins +is agreed, but the time spent trying to apply it when it doesn't work +is a cost that has to be set against that. I don't accept your premise +that every query for which skip-index isn't relevant is so slow that +planning time does not matter. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Oct 7 16:48:57 2004 +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 6C58D32A0F8 + for ; + Thu, 7 Oct 2004 16:48:55 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10588-02 + for ; + Thu, 7 Oct 2004 15:48:52 +0000 (GMT) +Received: from snowwhite.lulu.com (mail.lulu.com [66.193.5.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B8B132A04B + for ; + Thu, 7 Oct 2004 16:48:49 +0100 (BST) +Received: from [10.0.0.32] (meatwad.rdu.lulu.com [10.0.0.32]) + (authenticated bits=0) + by snowwhite.lulu.com (8.12.8/8.12.8) with ESMTP id i97FnVbO022152 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); + Thu, 7 Oct 2004 11:49:32 -0400 +Message-ID: <41656559.70100@lulu.com> +Date: Thu, 07 Oct 2004 11:48:41 -0400 +From: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alan Stange +Cc: Gaetano Mendola , + pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> <200410051538.51664.josh@agliodbs.com> + <41636D8E.1090403@rentec.com> <41648446.5020102@bigfoot.com> + <4164B48C.9060202@rentec.com> +In-Reply-To: <4164B48C.9060202@rentec.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/82 +X-Sequence-Number: 8558 + +Alan Stange wrote: + +> Here's a few numbers from the Opteron 250. If I get some time I'll +> post a more comprehensive comparison including some other systems. +> +> The system is a Sun v20z. Dual Opteron 250, 2.4Ghz, Linux 2.6, 8 GB +> memory. I did a compile and install of pg 8.0 beta 3. I created a +> data base on a tmpfs file system and ran pgbench. Everything was "out +> of the box", meaning I did not tweak any config files. +> +> I used this for pgbench: +> $ pgbench -i -s 32 +> +> and this for pgbench invocations: +> $ pgbench -s 32 -c 1 -t 10000 -v +> +> +> clients tps 1 1290 2 +> 1780 4 1760 8 1680 +> 16 1376 32 904 + + +The same test on a Dell PowerEdge 1750, Dual Xeon 3.2 GHz, 512k cache, +HT on, Linux 2.4.21-20.ELsmp (RHEL 3), 4GB memory, pg 7.4.5: + +$ pgbench -i -s 32 pgbench +$ pgbench -s 32 -c 1 -t 10000 -v + +clients tps avg CS/sec +------- ----- ---------- + 1 601 48,000 + 2 889 77,000 + 4 1006 80,000 + 8 985 59,000 + 16 966 47,000 + 32 913 46,000 + +Far less performance that the Dual Opterons with a low number of +clients, but the gap narrows as the number of clients goes up. Anyone +smarter than me care to explain? + +Anyone have a 4-way Opteron to run the same benchmark on? + +-Bill + +> How are these results useful? In some sense, this is a speed of light +> number for the Opteron 250. You'll never go faster on this system +> with a real storage subsystem involved instead of a tmpfs file +> system. It's also a set of numbers that anyone else can reproduce as +> we don't have to deal with any differences in file systems, disk +> subsystems, networking, etc. Finally, it's a set of results that +> anyone else can compute on Xeon's or other systems and make a simple +> (and naive) comparisons. +> +> +> Just to stay on topic: vmstat reported about 30K cs / second while +> this was running the 1 and 2 client cases. +> +> -- Alan + + + +From pgsql-performance-owner@postgresql.org Thu Oct 7 18:11:26 2004 +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 950C6329D41 + for ; + Thu, 7 Oct 2004 18:11:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37432-04 + for ; + Thu, 7 Oct 2004 17:11:13 +0000 (GMT) +Received: from vsmtp3.tin.it (vsmtp3alice.tin.it [212.216.176.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 72F8B329E5F + for ; + Thu, 7 Oct 2004 18:11:07 +0100 (BST) +Received: from angus.tin.it (82.51.64.122) by vsmtp3.tin.it (7.0.027) + id 414B175C008A43F4; Thu, 7 Oct 2004 19:07:07 +0200 +Message-Id: <6.1.2.0.2.20041007183909.0201f310@box.tin.it> +X-Sender: angusgb@box.tin.it (Unverified) +X-Mailer: QUALCOMM Windows Eudora Version 6.1.2.0 +Date: Thu, 07 Oct 2004 19:07:04 +0200 +To: "Aaron Werman" , +From: Gabriele Bartolini +Subject: Re: Data warehousing requirements +In-Reply-To: +References: <6.1.2.0.2.20041006230239.0201bd40@box.tin.it> + +Mime-Version: 1.0 +Content-Type: multipart/mixed; x-avg-checked=avg-ok-16C74A51; + boundary="=======7EC77ACB=======" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_RFCI +X-Spam-Level: +X-Archive-Number: 200410/84 +X-Sequence-Number: 8560 + +--=======7EC77ACB======= +Content-Type: text/plain; x-avg-checked=avg-ok-16C74A51; charset=us-ascii; + format=flowed +Content-Transfer-Encoding: 8bit + +At 13.30 07/10/2004, Aaron Werman wrote: +>Consider how the fact table is going to be used, and review hacking it up +>based on usage. Fact tables should be fairly narrow, so if there are extra +>columns beyond keys and dimension keys consider breaking it into parallel +>tables (vertical partitioning). + +Hmm ... I have only an extra column. Sorry if I ask you to confirm this, +but practically vertical partitioning allows me to divide a table into 2 +tables (like if I cut them vertically, right?) having the same key. If I +had 2 extra columns, that could be the case, couldn't it? + +>Horizontal partitioning is your friend; especially if it is large - consider +>slicing the data into chunks. If the fact table is date driven it might be +>worthwhile to break it into separate tables based on date key. This wins in +>reducing the working set of queries and in buffering. If there is a real +>hotspot, such as current month's activity, you might want to keep a separate +>table with just the (most) active data.Static tables of unchanged data can +>simplify backups, etc., as well. + +In this case, you mean I can chunk data into: "facts_04_08" for the august +2004 facts. Is this the case? + +Otherwise, is it right my point of view that I can get good results by +using a different approach, based on mixing vertical partitioning and the +CLUSTER facility of PostgreSQL? Can I vertically partition also dimension +keys from the fact table or not? + +However, this subject is awesome and interesting. Far out ... data +warehousing seems to be really continous modeling, doesn't it! :-) + +>Consider summary tables if you know what type of queries you'll hit. + +At this stage, I can't predict it yet. But of course I need some sort of +summary. I will keep it in mind. + +>Especially here, MVCC is not your friend because it has extra work to do for +>aggregate functions. + +Why does it have extra work? Do you mind being more precise, Aaron? It is +really interesting. (thanks) + +>Cluster helps if you bulk load. + +Is it maybe because I can update or build them once the load operation has +finished? + +>In most warehouses, the data is downstream data from existing operational +>systems. + +That's my case too. + +>Because of that you're not able to use database features to +>preserve integrity. In most cases, the data goes through an +>extract/transform/load process - and the output is considered acceptable. +>So, no RI is correct for star or snowflake design. Pretty much no anything +>else that adds intelligence - no triggers, no objects, no constraints of any +>sort. Many designers try hard to avoid nulls. + +That's another interesting argument. Again, I had in mind the space +efficiency principle and I decided to use null IDs for dimension tables if +I don't have the information. I noticed though that in those cases I can't +use any index and performances result very poor. + +I have a dimension table 'categories' referenced through the 'id_category' +field in the facts table. I decided to set it to NULL in case I don't have +any category to associate to it. I believe it is better to set a '0' value +if I don't have any category, allowing me not to use a "SELECT * from facts +where id_category IS NULL" which does not use the INDEX I had previously +created on that field. + +>On the hardware side - RAID5 might work here because of the low volume if +>you can pay the write performance penalty. To size hardware you need to +>estimate load in terms of transaction type (I usually make bucket categories +>of small, medium, and large effort needs) and transaction rate. Then try to +>estimate how much CPU and I/O they'll use. + +Thank you so much again Aaron. Your contribution has been really important +to me. + +Ciao, +-Gabriele + +>"Let us not speak of them; but look, and pass on." + +P.S.: Dante rules ... :-) + +-- +Gabriele Bartolini: Web Programmer, ht://Dig & IWA/HWG Member, ht://Check +maintainer +Current Location: Prato, Toscana, Italia +angusgb@tin.it | http://www.prato.linux.it/~gbartolini | ICQ#129221447 + > "Leave every hope, ye who enter!", Dante Alighieri, Divine Comedy, The +Inferno + +--=======7EC77ACB======= +Content-Type: text/plain; charset=us-ascii; x-avg=cert; + x-avg-checked=avg-ok-16C74A51 +Content-Disposition: inline + + +--- +Outgoing mail is certified Virus Free. +Checked by AVG anti-virus system (http://www.grisoft.com). +Version: 6.0.773 / Virus Database: 520 - Release Date: 05/10/2004 + +--=======7EC77ACB=======-- + + +From pgsql-performance-owner@postgresql.org Thu Oct 7 18:08:21 2004 +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 2AA4732A088 + for ; + Thu, 7 Oct 2004 18:08:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35483-08 + for ; + Thu, 7 Oct 2004 17:08:17 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id D7EE332A063 + for ; + Thu, 7 Oct 2004 18:08:15 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CFbkS-0001VQ-00; Thu, 07 Oct 2004 13:08:12 -0400 +To: =?iso-8859-1?q?Pierre-Fr=E9d=E9ric_Caillaud?= + +Cc: "Tom Lane" , "Greg Stark" , + pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +References: <200410061130.58625.ole@freiheit.com> + <874ql7ztnb.fsf@stark.xeocode.com> <29194.1097091506@sss.pgh.pa.us> + +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 07 Oct 2004 13:08:11 -0400 +Message-ID: <87pt3u78xw.fsf@stark.xeocode.com> +Lines: 21 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/83 +X-Sequence-Number: 8559 + + +Pierre-Fr�d�ric Caillaud writes: + +> I see this as a minor annoyance only because I can write GROUP BY +> instead of DISTINCT and get the speed boost. It probably annoys people +> trying to port applications to postgres though, forcing them to rewrite +> their queries. + +Yeah, really DISTINCT and DISTINCT ON are just special cases of GROUP BY. It +seems it makes more sense to put the effort into GROUP BY and just have +DISTINCT and DISTINCT ON go through the same code path. Effectively rewriting +it internally as a GROUP BY. + +The really tricky part is that a DISTINCT ON needs to know about a first() +aggregate. And to make optimal use of indexes, a last() aggregate as well. And +ideally the planner/executor needs to know something is magic about +first()/last() (and potentially min()/max() at some point) and that they don't +need the complete set of tuples to calculate their results. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Oct 7 18:19:32 2004 +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 836D4329E63 + for ; + Thu, 7 Oct 2004 18:19:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38820-09 + for ; + Thu, 7 Oct 2004 17:19:20 +0000 (GMT) +Received: from mail.hamburg.cityline.net (jewel.mcs-hh.de [194.77.146.129]) + by svr1.postgresql.org (Postfix) with ESMTP id 469B1329D41 + for ; + Thu, 7 Oct 2004 18:19:20 +0100 (BST) +Received: from [212.1.56.10] (helo=aconitin.toxine.lan) + by mail.hamburg.cityline.net with asmtp (TLSv1:RC4-MD5:128) + (Exim 4.32) id 1CFbvC-0006e4-0w; Thu, 07 Oct 2004 19:19:18 +0200 +From: Ole Langbehn +Organization: freiheit.com +To: =?iso-8859-15?q?Pierre-Fr=E9d=E9ric_Caillaud?= + +Subject: Re: sequential scan on select distinct +Date: Thu, 7 Oct 2004 19:21:08 +0200 +User-Agent: KMail/1.7 +Cc: pgsql-performance@postgresql.org +References: <200410061130.58625.ole@freiheit.com> + <29194.1097091506@sss.pgh.pa.us> +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: <200410071921.08685.ole@freiheit.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/85 +X-Sequence-Number: 8561 + +Am Donnerstag, 7. Oktober 2004 14:01 schrieb Pierre-Fr=E9d=E9ric Caillaud: +> Side Note : +> +> What do you think about the idea of an "UniqueSort" which would do +> sort+unique in one pass ?=20 +This is what oracle does and it is quite fast with it... +--=20 +Ole Langbehn + +freiheit.com technologies gmbh +Theodorstr. 42-90 / 22761 Hamburg, Germany +fon =A0 =A0 =A0 +49 (0)40 / 890584-0 +fax =A0 =A0 =A0 +49 (0)40 / 890584-20 + +Freie Software durch B=FCcherkauf f=F6rdern | http://bookzilla.de/ + +From pgsql-performance-owner@postgresql.org Thu Oct 7 18:26:49 2004 +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 2C3BA329EB4 + for ; + Thu, 7 Oct 2004 18:26:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41438-08 + for ; + Thu, 7 Oct 2004 17:26:44 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DEA0329E94 + for ; + Thu, 7 Oct 2004 18:26:44 +0100 (BST) +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 i97HQfej000200; + Thu, 7 Oct 2004 13:26:41 -0400 (EDT) +To: Ole Langbehn +Cc: =?iso-8859-15?q?Pierre-Fr=E9d=E9ric_Caillaud?= + , pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +In-reply-to: <200410071921.08685.ole@freiheit.com> +References: <200410061130.58625.ole@freiheit.com> + <29194.1097091506@sss.pgh.pa.us> + <200410071921.08685.ole@freiheit.com> +Comments: In-reply-to Ole Langbehn + message dated "Thu, 07 Oct 2004 19:21:08 +0200" +Date: Thu, 07 Oct 2004 13:26:41 -0400 +Message-ID: <199.1097170001@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/86 +X-Sequence-Number: 8562 + +Ole Langbehn writes: +>> What do you think about the idea of an "UniqueSort" which would do +>> sort+unique in one pass ? + +> This is what oracle does and it is quite fast with it... + +Hashing is at least as fast, if not faster. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Oct 7 19:15:51 2004 +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 37146329FD7 + for ; + Thu, 7 Oct 2004 19:15:50 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57108-06 + for ; + Thu, 7 Oct 2004 18:15:39 +0000 (GMT) +Received: from mail3.panix.com (mail3.panix.com [166.84.1.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A5B8329F32 + for ; + Thu, 7 Oct 2004 19:15:39 +0100 (BST) +Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) + by mail3.panix.com (Postfix) with ESMTP id 3638F981E9; + Thu, 7 Oct 2004 14:15:38 -0400 (EDT) +Received: (from adler@localhost) + by panix2.panix.com (8.11.6p2-a/8.8.8/PanixN1.1) id i97IFcB14523; + Thu, 7 Oct 2004 14:15:38 -0400 (EDT) +Date: Thu, 7 Oct 2004 14:15:38 -0400 +From: Michael Adler +To: Bill Montgomery +Cc: Alan Stange , Gaetano Mendola , + pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +Message-ID: <20041007181537.GA1693@pobox.com> +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> <200410051538.51664.josh@agliodbs.com> + <41636D8E.1090403@rentec.com> <41648446.5020102@bigfoot.com> + <4164B48C.9060202@rentec.com> <41656559.70100@lulu.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <41656559.70100@lulu.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/87 +X-Sequence-Number: 8563 + +On Thu, Oct 07, 2004 at 11:48:41AM -0400, Bill Montgomery wrote: +> Alan Stange wrote: +> +> The same test on a Dell PowerEdge 1750, Dual Xeon 3.2 GHz, 512k cache, +> HT on, Linux 2.4.21-20.ELsmp (RHEL 3), 4GB memory, pg 7.4.5: +> +> Far less performance that the Dual Opterons with a low number of +> clients, but the gap narrows as the number of clients goes up. Anyone +> smarter than me care to explain? + +You'll have to wait for someone smarter than you, but I will posit +this: Did you use a tmpfs filesystem like Alan? You didn't mention +either way. Alan did that as an attempt remove IO as a variable. + +-Mike + +From pgsql-performance-owner@postgresql.org Thu Oct 7 19:29:19 2004 +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 ACCA1329F49 + for ; + Thu, 7 Oct 2004 19:29:15 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59971-07 + for ; + Thu, 7 Oct 2004 18:29:04 +0000 (GMT) +Received: from ram.rentec.com (ram.rentec.com [192.5.35.66]) + by svr1.postgresql.org (Postfix) with ESMTP id A53EE329D69 + for ; + Thu, 7 Oct 2004 19:29:04 +0100 (BST) +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by ram.rentec.com (8.12.9/8.12.1) with ESMTP id i97ISsi2002393; + Thu, 7 Oct 2004 14:28:54 -0400 (EDT) +Message-ID: <41658AE6.3070700@rentec.com> +Date: Thu, 07 Oct 2004 14:28:54 -0400 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bill Montgomery +Cc: Gaetano Mendola , + pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> <200410051538.51664.josh@agliodbs.com> + <41636D8E.1090403@rentec.com> <41648446.5020102@bigfoot.com> + <4164B48C.9060202@rentec.com> <41656559.70100@lulu.com> +In-Reply-To: <41656559.70100@lulu.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/88 +X-Sequence-Number: 8564 + +Bill Montgomery wrote: + +> Alan Stange wrote: +> +>> Here's a few numbers from the Opteron 250. If I get some time I'll +>> post a more comprehensive comparison including some other systems. +>> +>> The system is a Sun v20z. Dual Opteron 250, 2.4Ghz, Linux 2.6, 8 GB +>> memory. I did a compile and install of pg 8.0 beta 3. I created a +>> data base on a tmpfs file system and ran pgbench. Everything was +>> "out of the box", meaning I did not tweak any config files. +>> +>> I used this for pgbench: +>> $ pgbench -i -s 32 +>> +>> and this for pgbench invocations: +>> $ pgbench -s 32 -c 1 -t 10000 -v +>> +>> +>> clients tps 1 1290 2 +>> 1780 4 1760 8 1680 +>> 16 1376 32 904 +> +> +> +> The same test on a Dell PowerEdge 1750, Dual Xeon 3.2 GHz, 512k cache, +> HT on, Linux 2.4.21-20.ELsmp (RHEL 3), 4GB memory, pg 7.4.5: +> +> $ pgbench -i -s 32 pgbench +> $ pgbench -s 32 -c 1 -t 10000 -v +> +> clients tps avg CS/sec +> ------- ----- ---------- +> 1 601 48,000 +> 2 889 77,000 +> 4 1006 80,000 +> 8 985 59,000 +> 16 966 47,000 +> 32 913 46,000 +> +> Far less performance that the Dual Opterons with a low number of +> clients, but the gap narrows as the number of clients goes up. Anyone +> smarter than me care to explain? + +boy, did Thunderbird ever botch the format of the table I entered... + +I thought the falloff at 32 clients was a bit steep as well. One +thought that crossed my mind is that "pgbench -s 32 -c 32 ..." might not +be valid. From the pgbench README: + + -s scaling_factor + this should be used with -i (initialize) option. + number of tuples generated will be multiple of the + scaling factor. For example, -s 100 will imply 10M + (10,000,000) tuples in the accounts table. + default is 1. NOTE: scaling factor should be at least + as large as the largest number of clients you intend + to test; else you'll mostly be measuring update contention. + +Another possible cause is the that pgbench process is cpu starved and +isn't able to keep driving the postgresql processes. So I ran pgbench +from another system with all else the same. The numbers were a bit +smaller but otherwise similar. + + +I then reran everything using -s 64: + +clients tps +1 1254 +2 1645 +4 1713 +8 1548 +16 1396 +32 1060 + +Still starting to head down a bit. In the 32 client case, the system +was ~60% user time, ~25% sytem and ~15% idle. Anyway, the machine is +clearly hitting some contention somewhere. It could be in the tmpfs +code, VM system, etc. + +-- Alan + + + + + +From pgsql-performance-owner@postgresql.org Thu Oct 7 19:48:56 2004 +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 4916D32A51A + for ; + Thu, 7 Oct 2004 19:48:54 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68051-03 + for ; + Thu, 7 Oct 2004 18:48:51 +0000 (GMT) +Received: from snowwhite.lulu.com (mail.lulu.com [66.193.5.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CA6632A50B + for ; + Thu, 7 Oct 2004 19:48:51 +0100 (BST) +Received: from [10.0.0.32] (meatwad.rdu.lulu.com [10.0.0.32]) + (authenticated bits=0) + by snowwhite.lulu.com (8.12.8/8.12.8) with ESMTP id i97InabO025282 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); + Thu, 7 Oct 2004 14:49:37 -0400 +Message-ID: <41658F8D.9090204@lulu.com> +Date: Thu, 07 Oct 2004 14:48:45 -0400 +From: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Michael Adler +Cc: pgsql-performance@postgresql.org +Subject: Re: Excessive context switching on SMP Xeons +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <41630D50.3020308@lulu.com> <200410051538.51664.josh@agliodbs.com> + <41636D8E.1090403@rentec.com> <41648446.5020102@bigfoot.com> + <4164B48C.9060202@rentec.com> <41656559.70100@lulu.com> + <20041007181537.GA1693@pobox.com> +In-Reply-To: <20041007181537.GA1693@pobox.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/89 +X-Sequence-Number: 8565 + +Michael Adler wrote: + +>On Thu, Oct 07, 2004 at 11:48:41AM -0400, Bill Montgomery wrote: +> +> +>>Alan Stange wrote: +>> +>>The same test on a Dell PowerEdge 1750, Dual Xeon 3.2 GHz, 512k cache, +>>HT on, Linux 2.4.21-20.ELsmp (RHEL 3), 4GB memory, pg 7.4.5: +>> +>>Far less performance that the Dual Opterons with a low number of +>>clients, but the gap narrows as the number of clients goes up. Anyone +>>smarter than me care to explain? +>> +>> +> +>You'll have to wait for someone smarter than you, but I will posit +>this: Did you use a tmpfs filesystem like Alan? You didn't mention +>either way. Alan did that as an attempt remove IO as a variable. +> +>-Mike +> +> + +Yes, I should have been more explicit. My goal was to replicate his +experiment as closely as possible in my environment, so I did run my +postgres data directory on a tmpfs. + +-Bill Montgomery + +From pgsql-performance-owner@postgresql.org Mon Oct 11 13:03:48 2004 +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 ABBB032A08B + for ; + Thu, 7 Oct 2004 21:26:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01157-04 + for ; + Thu, 7 Oct 2004 20:26:08 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id BA927329E8B + for ; + Thu, 7 Oct 2004 21:26:07 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i97KQ4Jm002823 + for ; Thu, 7 Oct 2004 20:26:04 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i97K02mH094943 + for pgsql-performance@postgresql.org; Thu, 7 Oct 2004 20:00:02 GMT +From: Mischa Sandberg +Reply-To: ischamay.andbergsay@activestateway.com +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: sequential scan on select distinct +References: <200410061130.58625.ole@freiheit.com> + <29194.1097091506@sss.pgh.pa.us> + <200410071921.08685.ole@freiheit.com> + <199.1097170001@sss.pgh.pa.us> +In-Reply-To: <199.1097170001@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 22 +Message-ID: <8fh9d.25089$MV5.20638@clgrps13> +Date: Thu, 07 Oct 2004 20:00:04 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200410/132 +X-Sequence-Number: 8608 + +Tom Lane wrote: +> Ole Langbehn writes: +> +>>>What do you think about the idea of an "UniqueSort" which would do +>>>sort+unique in one pass ? +> +>>This is what oracle does and it is quite fast with it... + +> Hashing is at least as fast, if not faster. +> +> regards, tom lane + +I got good mileage in a different SQL engine, by combining the +hash-aggregate and sort nodes into a single operator. +The hash table was just an index into the equivalent of the heap used +for generating runs. That gave me partially aggregated data, +or eliminated duplicate keys, without extra memory overhead of the +hash-aggregation node below the sort. Memory was scarce then ... :-) + +BTW I'm really puzzled that Oracle is pushing 'index skip scan' as a new +feature. Wasn't this in the original Oracle Rdb --- one of Gennady +Antoshenkov's tweaks? + +From pgsql-performance-owner@postgresql.org Thu Oct 7 23:48:48 2004 +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 8214C32A0A4 + for ; + Thu, 7 Oct 2004 23:48:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40301-10 + for ; + Thu, 7 Oct 2004 22:48:37 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 7628F32A04B + for ; + Thu, 7 Oct 2004 23:48:38 +0100 (BST) +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 6473573; Thu, 07 Oct 2004 15:50:01 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Data warehousing requirements +Date: Thu, 7 Oct 2004 15:50:20 -0700 +User-Agent: KMail/1.6.2 +Cc: Gabriele Bartolini , "Aaron Werman" +References: <6.1.2.0.2.20041006230239.0201bd40@box.tin.it> + + <6.1.2.0.2.20041007183909.0201f310@box.tin.it> +In-Reply-To: <6.1.2.0.2.20041007183909.0201f310@box.tin.it> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200410071550.20665.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/90 +X-Sequence-Number: 8566 + +Gabriele, + +> That's another interesting argument. Again, I had in mind the space +> efficiency principle and I decided to use null IDs for dimension tables if +> I don't have the information. I noticed though that in those cases I can't +> use any index and performances result very poor. + +For one thing, this is false optimization; a NULL isn't saving you any table +size on an INT or BIGINT column. NULLs are only smaller on variable-width +columns. If you're going to start counting bytes, make sure it's an informed +count. + +More importantly, you should never, ever allow null FKs on a star-topology +database. LEFT OUTER JOINs are vastly less efficient than INNER JOINs in a +query, and the difference between having 20 outer joins for your data view, +vs 20 regular joins, can easily be a difference of 100x in execution time. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Oct 8 03:03:25 2004 +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 7520432A601 + for ; + Fri, 8 Oct 2004 03:03:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22512-10 + for ; + Fri, 8 Oct 2004 02:03:19 +0000 (GMT) +Received: by svr1.postgresql.org (Postfix, from userid 1001) + id 2829032B4C1; Fri, 8 Oct 2004 03:50:02 +0100 (BST) +Received: from hotmail.com (bay18-dav1.bay18.hotmail.com [65.54.187.181]) + by svr1.postgresql.org (Postfix) with ESMTP id A0A2632AC6D + for ; + Fri, 8 Oct 2004 02:20:01 +0100 (BST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 7 Oct 2004 18:20:01 -0700 +Received: from 67.81.98.198 by BAY18-DAV1.phx.gbl with DAV; + Fri, 08 Oct 2004 01:19:29 +0000 +X-Originating-IP: [67.81.98.198] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: , "Gabriele Bartolini" +References: <6.1.2.0.2.20041006230239.0201bd40@box.tin.it> + + <6.1.2.0.2.20041007183909.0201f310@box.tin.it> +Subject: Re: Data warehousing requirements +Date: Thu, 7 Oct 2004 21:19:44 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Message-ID: +X-OriginalArrivalTime: 08 Oct 2004 01:20:01.0210 (UTC) + FILETIME=[EEC441A0:01C4ACD4] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/91 +X-Sequence-Number: 8567 + + +----- Original Message ----- +From: "Gabriele Bartolini" +To: "Aaron Werman" ; + +Sent: Thursday, October 07, 2004 1:07 PM +Subject: Re: [PERFORM] Data warehousing requirements + + +> At 13.30 07/10/2004, Aaron Werman wrote: +> >Consider how the fact table is going to be used, and review hacking it up +> >based on usage. Fact tables should be fairly narrow, so if there are +extra +> >columns beyond keys and dimension keys consider breaking it into parallel +> >tables (vertical partitioning). +> +> Hmm ... I have only an extra column. Sorry if I ask you to confirm this, +> but practically vertical partitioning allows me to divide a table into 2 +> tables (like if I cut them vertically, right?) having the same key. If I +> had 2 extra columns, that could be the case, couldn't it? + +Yes - it's splitting a table's columns and copying the PK. If you have only +one column and it's narrow - partitioning becomes harder to justify. + +> +> >Horizontal partitioning is your friend; especially if it is large - +consider +> >slicing the data into chunks. If the fact table is date driven it might +be +> >worthwhile to break it into separate tables based on date key. This wins +in +> >reducing the working set of queries and in buffering. If there is a real +> >hotspot, such as current month's activity, you might want to keep a +separate +> >table with just the (most) active data.Static tables of unchanged data +can +> >simplify backups, etc., as well. +> +> In this case, you mean I can chunk data into: "facts_04_08" for the august +> 2004 facts. Is this the case? + +Exactly. The problem is when you need to query across the chunks. There was +a discussion here of creating views ala + +create view facts as + select * from facts_04_07 where datekey between '01/07/2004' and +'31/07/2004' + union all + select * from facts_04_08 where datekey between '01/08/2004' and +'31/08/2004' + union all + select * from facts_04_09 where datekey between '01/09/2004' and +'30/09/2004' + ... + +hoping the restrictions would help the planner prune chunks out. Has anyone +tried this? + +> +> Otherwise, is it right my point of view that I can get good results by +> using a different approach, based on mixing vertical partitioning and the +> CLUSTER facility of PostgreSQL? Can I vertically partition also dimension +> keys from the fact table or not? + +If you can do that, you probably should beyond a star schema. The standard +definition of a star schema is a single very large fact table with very +small dimension tables. The point of a star is that it can be used to +efficiantly restrict results out by merging the dimensional restrictions and +only extracting matches from the fact table. E.g., + +select + count(*) +from + people_fact, /* 270M */ + states_dim, /* only 50 something */ + gender_dim, /* 2 */ + age_dim /* say 115 */ +where + age_dim.age > 65 + and + gender_dim.gender = 'F' + and + states_dim.state_code in ('PR', 'ME') + and + age_dim.age_key = people_fact.age_key + and + gender_dim.gender_key = people_fact.gender_key + and + states_dim.state_key = people_fact.state_key + +(I had to write out this trivial query because most DBAs don't realize going +in how ugly star queries are.) If you split the fact table so ages were in a +vertical partition you would optimize queries which didn't use the age data, +but if you needed the age data, you would have to join two large tables - +which is not a star query. + +What you're thinking about on the cluster front is fun. You can split groups +of dimension keys off to seperate vertical partitions, but you can only +cluster each on a single key. So you need to split each one off, which +results in your inventing the index! (-: + +> +> However, this subject is awesome and interesting. Far out ... data +> warehousing seems to be really continous modeling, doesn't it! :-) +> +> >Consider summary tables if you know what type of queries you'll hit. +> +> At this stage, I can't predict it yet. But of course I need some sort of +> summary. I will keep it in mind. +> +> >Especially here, MVCC is not your friend because it has extra work to do +for +> >aggregate functions. +> +> Why does it have extra work? Do you mind being more precise, Aaron? It is +> really interesting. (thanks) + +The standard reasons - that a lot of queries that seem intuitively to be +resolvable statically or through indices have to walk the data to find +current versions. Keeping aggregates (especially if you can allow them to be +slightly stale) can reduce lots of reads. A big goal of horizontal +partitioning is to give the planner some way of reducing the query scope. + +> +> >Cluster helps if you bulk load. +> +> Is it maybe because I can update or build them once the load operation has +> finished? + +If you have streaming loads, clustering can be a pain to implement well. + +> +> >In most warehouses, the data is downstream data from existing operational +> >systems. +> +> That's my case too. +> +> >Because of that you're not able to use database features to +> >preserve integrity. In most cases, the data goes through an +> >extract/transform/load process - and the output is considered acceptable. +> >So, no RI is correct for star or snowflake design. Pretty much no +anything +> >else that adds intelligence - no triggers, no objects, no constraints of +any +> >sort. Many designers try hard to avoid nulls. +> +> That's another interesting argument. Again, I had in mind the space +> efficiency principle and I decided to use null IDs for dimension tables if +> I don't have the information. I noticed though that in those cases I can't +> use any index and performances result very poor. +> +> I have a dimension table 'categories' referenced through the 'id_category' +> field in the facts table. I decided to set it to NULL in case I don't have +> any category to associate to it. I believe it is better to set a '0' value +> if I don't have any category, allowing me not to use a "SELECT * from +facts +> where id_category IS NULL" which does not use the INDEX I had previously +> created on that field. + +(Sorry for being a pain in the neck, but BTW - that is not a star query; it +should be + +SELECT + facts.* +from + facts, + id_dim +where + facts.id_key = id_dim.id_key + and + id_dim.id_category IS NULL + +[and it really gets to the whole problem of indexing low cardinality +fields]) + + +> +> >On the hardware side - RAID5 might work here because of the low volume if +> >you can pay the write performance penalty. To size hardware you need to +> >estimate load in terms of transaction type (I usually make bucket +categories +> >of small, medium, and large effort needs) and transaction rate. Then try +to +> >estimate how much CPU and I/O they'll use. +> +> Thank you so much again Aaron. Your contribution has been really important +> to me. +> +> Ciao, +> -Gabriele +> +> >"Let us not speak of them; but look, and pass on." +> +> P.S.: Dante rules ... :-) + +:-) + +that quote was not a reference to anyone in this group! + +Good luck, +/Aaron + +> +> -- +> Gabriele Bartolini: Web Programmer, ht://Dig & IWA/HWG Member, ht://Check +> maintainer +> Current Location: Prato, Toscana, Italia +> angusgb@tin.it | http://www.prato.linux.it/~gbartolini | ICQ#129221447 +> > "Leave every hope, ye who enter!", Dante Alighieri, Divine Comedy, The +> Inferno +> + +From pgsql-performance-owner@postgresql.org Fri Oct 8 03:43:40 2004 +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 0E978329E46 + for ; + Fri, 8 Oct 2004 03:43:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40814-09 + for ; + Fri, 8 Oct 2004 02:43:37 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B850329E42 + for ; + Fri, 8 Oct 2004 03:43:35 +0100 (BST) +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 i982hXd3027540; + Thu, 7 Oct 2004 22:43:33 -0400 (EDT) +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org, Gabriele Bartolini , + "Aaron Werman" +Subject: Re: Data warehousing requirements +In-reply-to: <200410071550.20665.josh@agliodbs.com> +References: <6.1.2.0.2.20041006230239.0201bd40@box.tin.it> + + <6.1.2.0.2.20041007183909.0201f310@box.tin.it> + <200410071550.20665.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Thu, 07 Oct 2004 15:50:20 -0700" +Date: Thu, 07 Oct 2004 22:43:33 -0400 +Message-ID: <27539.1097203413@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/92 +X-Sequence-Number: 8568 + +Josh Berkus writes: +> For one thing, this is false optimization; a NULL isn't saving you any table +> size on an INT or BIGINT column. NULLs are only smaller on variable-width +> columns. + +Uh ... not true. The column will not be stored, either way. Now if you +had a row that otherwise had no nulls, the first null in the column will +cause a null-columns-bitmap to be added, which might more than eat up +the savings from storing a single int or bigint. But after the first +null, each additional null in a row is a win, free-and-clear, whether +it's fixed-width or not. + +(There are also some alignment considerations that might cause the +savings to vanish.) + +> More importantly, you should never, ever allow null FKs on a star-topology +> database. LEFT OUTER JOINs are vastly less efficient than INNER JOINs in a +> query, and the difference between having 20 outer joins for your data view, +> vs 20 regular joins, can easily be a difference of 100x in execution time. + +It's not so much that they are necessarily inefficient as that they +constrain the planner's freedom of action. You need to think a lot more +carefully about the order of joining than when you use inner joins. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 8 06:54:41 2004 +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 AF8B432A04D + for ; + Fri, 8 Oct 2004 06:54:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90991-01 + for ; + Fri, 8 Oct 2004 05:54:33 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id B733C32A04A + for ; + Fri, 8 Oct 2004 06:54:32 +0100 (BST) +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 6474953; Thu, 07 Oct 2004 22:55:55 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Data warehousing requirements +Date: Thu, 7 Oct 2004 22:53:26 -0700 +User-Agent: KMail/1.6.2 +Cc: Tom Lane , Gabriele Bartolini , + "Aaron Werman" +References: <6.1.2.0.2.20041006230239.0201bd40@box.tin.it> + <200410071550.20665.josh@agliodbs.com> + <27539.1097203413@sss.pgh.pa.us> +In-Reply-To: <27539.1097203413@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200410072253.26169.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/93 +X-Sequence-Number: 8569 + +Tom, + +Well, I sit corrected. Obviously I misread that. + +> It's not so much that they are necessarily inefficient as that they +> constrain the planner's freedom of action. You need to think a lot more +> carefully about the order of joining than when you use inner joins. + +I've also found that OUTER JOINS constrain the types of joins that can/will be +used as well as the order. Maybe you didn't intend it that way, but (for +example) OUTER JOINs seem much more likely to use expensive merge joins. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-benchmarks-owner@postgresql.org Fri Oct 8 09:47:56 2004 +X-Original-To: pgsql-benchmarks-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CF7A329E47; + Fri, 8 Oct 2004 09:47:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32175-09; Fri, 8 Oct 2004 08:47:44 +0000 (GMT) +Received: from mailer.unicite.fr.netcentrex.net (unknown [62.161.167.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 777A7329E51; + Fri, 8 Oct 2004 09:47:43 +0100 (BST) +Received: from [192.168.101.228] ([192.168.101.228]) by + mailer.unicite.fr.netcentrex.net with SMTP (Microsoft Exchange + Internet Mail Service Version 5.5.2657.72) + id 42CX03QZ; Fri, 8 Oct 2004 10:47:42 +0200 +Message-ID: <4166542E.2020809@fr.netcentrex.net> +Date: Fri, 08 Oct 2004 10:47:42 +0200 +From: =?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= + +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-benchmarks@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] stats on cursor and query execution troubleshooting +References: <4163C5C3.3030304@fr.netcentrex.net> + <25576.1097072199@sss.pgh.pa.us> +In-Reply-To: <25576.1097072199@sss.pgh.pa.us> +Content-Type: multipart/alternative; + boundary="------------030409030803050401070308" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_20_30, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/3 +X-Sequence-Number: 20 + +This is a multi-part message in MIME format. +--------------030409030803050401070308 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable + +Thanks for your repply, but I still don"t understand why the statistic=20 +logs : + +! 0/0 [0/0] filesystem blocks in/out + + +it told me there is no hard disk access, I'm sure there is, I heard my=20 +HDD, and see activity using gkrellm (even using my first query ; big=20 +select *) ? + +2004-10-08 10:40:05 DEBUG: query: select * from "LINE_Line"; +2004-10-08 10:40:53 DEBUG: QUERY STATISTICS +! system usage stats: +! 48.480196 elapsed 42.010000 user 0.700000 system sec +! [42.030000 user 0.720000 sys total] +! 0/0 [0/0] filesystem blocks in/out +! 6/23 [294/145] page faults/reclaims, 0 [0] swaps +! 0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent +! 0/0 [0/0] voluntary/involuntary context switches +! postgres usage stats: +! Shared blocks: 3902 read, 0 written, buffer hit=20 +rate =3D 11.78% +! Local blocks: 0 read, 0 written, buffer hit=20 +rate =3D 0.00% +! Direct blocks: 0 read, 0 written + + +looking at the web some logs, I saw those fields filled (i/o filesystem) +Does my postgresql.conf missing an option or is therer a known bug of my=20 +postgresql server 7.2.4 ? + + + +thx +regards + +Alban M=E9dici + + +on 06/10/2004 16:16 Tom Lane said the following: + +>=3D?ISO-8859-1?Q?=3D22Alban_M=3DE9dici_=3D28NetCentrex=3D29=3D22?=3D writes: +>=20=20 +> +>>I'm looking for the statistic of memory, CPU, filesystem access while= +=3D20 +>>executing some regular SQL query, and I want to compare them to +>>same kind of results while executing a cursor function. +>>=20=20=20=20 +>> +> +>I think your second query is finding all the disk pages it needs in +>kernel disk cache, because they were all read in by the first query. +>This has little to do with cursor versus non cursor, and everything +>to do with hitting recently-read data again. +> +> regards, tom lane +> +>=20=20 +> + +--=20 +Alban M=E9dici +R&D software engineer +------------------------------ +you can contact me @ : +http://www.netcentrex.net +------------------------------ + + +--------------030409030803050401070308 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + +Thanks for your repply,  but I still don"t understand why the +statistic logs   :
+
+
!       0/0 [0/0] filesystem blocks in/out
+
+
+it told me there is no hard disk access, I'm sure there is,  I +heard my HDD,  and see activity using gkrellm (even using my first +query ; big select *) ?
+
+2004-10-08 10:40:05 DEBUG:  query: select * from "LINE_Line";
+2004-10-08 10:40:53 DEBUG:  QUERY STATISTICS
+! system usage stats:
+!       48.480196 elapsed 42.010000 user 0.700000 system sec
+!       [42.030000 user 0.720000 sys total]
+!       0/0 [0/0] filesystem blocks in/out
+!       6/23 [294/145] page faults/reclaims, 0 [0] swaps
+!       0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent
+!       0/0 [0/0] voluntary/involuntary context switches
+! postgres usage stats:
+!       Shared blocks:       3902 read,          0 written, buffer hit +rate = 11.78%
+!       Local  blocks:          0 read,          0 written, buffer hit +rate = 0.00%
+!       Direct blocks:          0 read,          0 written
+
+
+looking at the web some logs,  I saw those fields filled (i/o +filesystem)
+Does my postgresql.conf missing an option or is therer a known bug of +my postgresql server  7.2.4 ?
+
+
+
+thx
+regards
+
+Alban Médici
+
+
+
on 06/10/2004 16:16 Tom Lane said the following: +
+
=?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= <amedici@fr.netcentrex.net> writes:
+  
+
+
I'm looking for the statistic of memory,  CPU,  filesystem access while=20
+executing some regular SQL query,  and I want to compare them to
+same kind of results while executing a cursor function.
+    
+
+

+I think your second query is finding all the disk pages it needs in
+kernel disk cache, because they were all read in by the first query.
+This has little to do with cursor versus non cursor, and everything
+to do with hitting recently-read data again.
+
+			regards, tom lane
+
+  
+
+
+
-- 
+Alban Médici
+R&D software engineer
+------------------------------
+you can contact me @ :
+http://www.netcentrex.net
+------------------------------
+ + + +--------------030409030803050401070308-- + +From pgsql-performance-owner@postgresql.org Fri Oct 8 09:51:56 2004 +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 A044832AE5E + for ; + Fri, 8 Oct 2004 09:51:53 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35873-05 + for ; + Fri, 8 Oct 2004 08:51:48 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 3250932AC69 + for ; + Fri, 8 Oct 2004 09:51:46 +0100 (BST) +Received: (qmail 10834 invoked from network); 8 Oct 2004 10:52:12 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 8 Oct 2004 10:52:12 +0200 +Date: Fri, 08 Oct 2004 10:54:59 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +References: <200410061130.58625.ole@freiheit.com> + <874ql7ztnb.fsf@stark.xeocode.com> + <29194.1097091506@sss.pgh.pa.us> + <87pt3u78xw.fsf@stark.xeocode.com> +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <87pt3u78xw.fsf@stark.xeocode.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/95 +X-Sequence-Number: 8571 + + +> The really tricky part is that a DISTINCT ON needs to know about a +> first() +> aggregate. And to make optimal use of indexes, a last() aggregate as +> well. And +> ideally the planner/executor needs to know something is magic about +> first()/last() (and potentially min()/max() at some point) and that they +> don't +> need the complete set of tuples to calculate their results. + + I'm going to be accused of hand-waving again, but please pardon me, I'm +enthusiastic, and I like to propose new idead, you can kick me if you +don't like them or if I put out too much uninformed bull ! + + Idea : + + The aggregate accumulation function could have a way to say : +"stop ! I've had enough of these values ! Get on with the next item in the +GROUP BY clause !" + I don't know how, or if, the planner could use this (guess: no) or the +index scan use this (guess: no) but it would at least save the function +calls. I'd guess this idea is quite useless. + + Aggregates could have an additional attribute saying how much values it +will need ('max_rows' maybe). This would prevent the creation of "magic" +aggregates for max() (which is a kind of special-casing), keep it generic +(so users can create magic aggregates like this). + Aggregates already consist of a bunch of functions (start, accumulate, +return retuls) so this could be just another element in this set. + This information would be known ahead of time and could influence the +query plans too. I'm going to wave my hand and say "not too much planning +cost" because I guess the aggregate details are fetched during planning so +fetching one more attribute would not be that long... + For instance first() would have max_rows=1, and users could code a "first +N accumulator-in-array" which would have max_rows=N... + This does not solve the problem of min() and max() which need max_rows=1 +only if the result is sorted... hum... maybe another attribute like +max_rows_sorted = 1 for max() and -1 for min() meaning 'first 1' or 'last +1' (or first N or last N)... according to the "order by" clause it would +be known that the 'first N' of an 'order by ... asc' is the same as the +'last N' from an 'order by ... desc' + + ??? + + + + + + + +From pgsql-performance-owner@postgresql.org Fri Oct 8 10:11:26 2004 +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 5A20A329F24 + for ; + Fri, 8 Oct 2004 10:11:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41833-04 + for ; + Fri, 8 Oct 2004 09:11:18 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) + by svr1.postgresql.org (Postfix) with ESMTP id 65AC932AF62 + for ; + Fri, 8 Oct 2004 10:11:17 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 77so6816rnk + for ; + Fri, 08 Oct 2004 02:11:16 -0700 (PDT) +Received: by 10.38.65.39 with SMTP id n39mr48739rna; + Fri, 08 Oct 2004 02:11:16 -0700 (PDT) +Received: by 10.38.163.22 with HTTP; Fri, 8 Oct 2004 02:11:16 -0700 (PDT) +Message-ID: <758d5e7f041008021163fb40eb@mail.gmail.com> +Date: Fri, 8 Oct 2004 11:11:16 +0200 +From: Dawid Kuroczko +Reply-To: Dawid Kuroczko +To: pgsql-performance@postgresql.org +Subject: integer[] indexing. +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.9 tagged_above=0.0 required=5.0 + tests=FROM_ENDS_IN_NUMS +X-Spam-Level: +X-Archive-Number: 200410/96 +X-Sequence-Number: 8572 + +I have a large table with a column: +ids integer[] not null + +most of these entries (over 95%) contain only one array element, some +can contain up to 10 array elements. seqscan is naturally slow. GIST +on int_array works nice, but GIST isn't exactly a speed daemon when it +comes to updating. + +So I thought, why not create partial indexes? + +CREATE INDEX one_element_array_index ON table ((ids[1])) WHERE icount(ids) <= 1; +CREATE INDEX many_element_array_index ON table USING GIST (ids) WHERE +icount(ids) > 1; + +Now, if I select WHERE icount(ids) <= 1 AND ids[1] = 33 I get +lightning fast results. +If I select WHERE icount(ids) > 1 AND ids && '{33}' -- I get them even faster. + +But when I phrase the query: + +SELECT * FROM table WHERE (icount(ids) <= 1 AND ids[1] = 33) OR +(icount(ids) > 1 AND ids && '{33}'); + +Planner insists on using seqscan. Even with enable_seqscan = off; + +Any hints, comments? :) [ I think thsese partial indexes take best of +two worlds, only if planner wanted to take advantage of it... :) ] + + Regards, + Dawid + +From pgsql-performance-owner@postgresql.org Fri Oct 8 10:26:29 2004 +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 1FA5F32A343 + for ; + Fri, 8 Oct 2004 10:26:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46826-01 + for ; + Fri, 8 Oct 2004 09:26:21 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 57C8832A0EB + for ; + Fri, 8 Oct 2004 10:26:21 +0100 (BST) +Received: (qmail 12098 invoked from network); 8 Oct 2004 11:26:48 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 8 Oct 2004 11:26:48 +0200 +To: "Dawid Kuroczko" , + pgsql-performance@postgresql.org +Subject: Re: integer[] indexing. +References: <758d5e7f041008021163fb40eb@mail.gmail.com> +Message-ID: +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: Fri, 08 Oct 2004 11:29:35 +0200 +In-Reply-To: <758d5e7f041008021163fb40eb@mail.gmail.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200410/97 +X-Sequence-Number: 8573 + + + disclaimer : brainless proposition + +(SELECT * FROM table WHERE (icount(ids) <= 1 AND ids[1] = 33) +UNION ALL +(SELECT * FROM table WHERE (icount(ids) > 1 AND ids && '{33}')); + + + +From pgsql-performance-owner@postgresql.org Fri Oct 8 10:54:10 2004 +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 E28D332A090 + for ; + Fri, 8 Oct 2004 10:54:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52331-08 + for ; + Fri, 8 Oct 2004 09:53:58 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 56423329E83 + for ; + Fri, 8 Oct 2004 10:53:59 +0100 (BST) +Received: (qmail 13015 invoked from network); 8 Oct 2004 11:54:26 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 8 Oct 2004 11:54:26 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: sequential scan on select distinct +References: <200410061130.58625.ole@freiheit.com> + <29194.1097091506@sss.pgh.pa.us> + <200410071921.08685.ole@freiheit.com> + <199.1097170001@sss.pgh.pa.us> +Message-ID: +Date: Fri, 08 Oct 2004 11:57:13 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <199.1097170001@sss.pgh.pa.us> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/98 +X-Sequence-Number: 8574 + + +> Hashing is at least as fast, if not faster. +> regards, tom lane + + Probably quite faster if the dataset is not huge... + UniqueSort would be useful for GROUP BY x ORDER BY x though + + +From pgsql-performance-owner@postgresql.org Mon Oct 11 13:02:48 2004 +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 1C83432A31D + for ; + Fri, 8 Oct 2004 13:10:37 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91914-08 + for ; + Fri, 8 Oct 2004 12:10:29 +0000 (GMT) +Received: from scaup.mail.pas.earthlink.net (scaup.mail.pas.earthlink.net + [207.217.120.49]) + by svr1.postgresql.org (Postfix) with ESMTP id B3AE032A311 + for ; + Fri, 8 Oct 2004 13:10:32 +0100 (BST) +Received: from lsanca1-ar6-4-62-201-153.lsanca1.elnk.dsl.genuity.net + ([4.62.201.153] helo=bsd.mvh) + by scaup.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) + id 1CFtZv-0001FB-00 + for pgsql-performance@postgresql.org; Fri, 08 Oct 2004 05:10:31 -0700 +Received: from localhost (localhost [127.0.0.1]) + by bsd.mvh (Postfix) with ESMTP id 6489B5485C + for ; + Fri, 8 Oct 2004 05:10:31 -0700 (PDT) +Received: from bsd.mvh ([127.0.0.1]) + by localhost (bsd.mvh [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 73471-07 for ; + Fri, 8 Oct 2004 05:10:30 -0700 (PDT) +Received: by bsd.mvh (Postfix, from userid 1000) + id EEB485486C; Fri, 8 Oct 2004 05:10:29 -0700 (PDT) +From: Mike Harding +To: pgsql-performance@postgresql.org +Subject: COPY slows down? +Message-Id: <20041008121029.EEB485486C@bsd.mvh> +Date: Fri, 8 Oct 2004 05:10:29 -0700 (PDT) +X-Virus-Scanned: by amavisd-new at bsd.mvh +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/129 +X-Sequence-Number: 8605 + + +I just ran a COPY of a million records several times, and each time I +ran it it ran apparently exponentially slower. If I do an insert of +10 million records, even with 2 indexes (same table) it doesn't appear +to slow down at all. Any ideas? + +- Mike H. + +(I apologize for the ^Hs) + +Script started on Wed Oct 6 08:37:32 2004 +bash-3.00$ psql +Welcome to psql 7.4.5, the PostgreSQL interactive terminal. + +Type: \copyright for distribution terms + \h for help with SQL commands + \? for help on internal slash commands + \g or terminate with semicolon to execute query + \q to quit + +mvh=# \timing +Timing is on. +mvh=# \timingreindex table bgtest;mvh=# delete from bgtest;mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump'; +COPY +Time: 69796.130 ms +mvh=# vacuum analyze; +VACUUM +Time: 19148.621 ms +mvh=# vacuum analyze;mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump'; +COPY +Time: 89189.939 ms +mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump';mvh=# vacuum analyze; +VACUUM +Time: 26814.670 ms +mvh=# vacuum analyze;mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump'; +COPY +Time: 131131.982 ms +mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump';mvh=# vacuum analyze; +VACUUM +Time: 64997.264 ms +mvh=# vacuum analyze;mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump'; +COPY +Time: 299977.697 ms +mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump';mvh=# vacuum analyze; +VACUUM +Time: 103541.716 ms +mvh=# vacuum analyze;mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump'; +COPY +Time: 455292.600 ms +mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump';mvh=# vacuum analyze; +VACUUM +Time: 138910.015 ms +mvh=# vacuum analyze;mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump'; +COPY +Time: 612119.661 ms +mvh=# copy bgtest from '/home/mvh/databasestuff/dbdmp/bgdump';mvh=# vacuum analyze; +VACUUM +Time: 151331.243 ms +mvh=# \q +bash-3.00$ exit + +Script done on Wed Oct 6 10:43:04 2004 + + +From pgsql-performance-owner@postgresql.org Fri Oct 8 13:29:06 2004 +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 144B032A446 + for ; + Fri, 8 Oct 2004 13:29:05 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00267-03 + for ; + Fri, 8 Oct 2004 12:28:56 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.229.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AB5CF32A46B + for ; + Fri, 8 Oct 2004 13:28:58 +0100 (BST) +Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1CFtrk-0002Yw-00 + for ; Fri, 08 Oct 2004 14:28:56 +0200 +Received: from srv.protecting.net ([212.126.218.242]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Fri, 08 Oct 2004 14:28:56 +0200 +Received: from hf0722x by srv.protecting.net with local (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Fri, 08 Oct 2004 14:28:56 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Harald Fuchs +Subject: Re: integer[] indexing. +Date: 08 Oct 2004 14:28:52 +0200 +Organization: Linux Private Site +Lines: 24 +Message-ID: +References: <758d5e7f041008021163fb40eb@mail.gmail.com> + +Reply-To: hf0722x@protecting.net +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: srv.protecting.net +User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/99 +X-Sequence-Number: 8575 + +In article , +=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= writes: + +> disclaimer : brainless proposition + +> (SELECT * FROM table WHERE (icount(ids) <= 1 AND ids[1] = 33) +> UNION ALL +> (SELECT * FROM table WHERE (icount(ids) > 1 AND ids && '{33}')); + +I guess my proposition is even more brainless :-) + +If 95% of all records have only one value, how about putting the first +(and most often only) value into a separate column with a btree index +on it? Something like that: + + CREATE TABLE tbl ( + -- other columns + id1 INT NOT NULL, + idN INT[] NULL + ); + + CREATE INDEX tbl_id1_ix ON tbl (id1); + +If id1 is selective enough, you probably don't need another index on idn. + + +From pgsql-performance-owner@postgresql.org Fri Oct 8 13:38:20 2004 +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 C493A32A701 + for ; + Fri, 8 Oct 2004 13:38:18 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01328-07 + for ; + Fri, 8 Oct 2004 12:38:10 +0000 (GMT) +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 87C4E32A6BE + for ; + Fri, 8 Oct 2004 13:38:12 +0100 (BST) +Received: from [212.227.126.203] (helo=mrvnet.kundenserver.de) + by moutng.kundenserver.de with esmtp (Exim 3.35 #1) + id 1CFu0d-0005w4-00; Fri, 08 Oct 2004 14:38:07 +0200 +Received: from [172.23.4.132] (helo=config5.kundenserver.de) + by mrvnet.kundenserver.de with esmtp (Exim 3.35 #1) + id 1CFu0c-0006fr-00; Fri, 08 Oct 2004 14:38:06 +0200 +Received: from www-data by config5.kundenserver.de with local (Exim 3.35 #1 + (Debian)) id 1CFu0c-0002BW-00; Fri, 08 Oct 2004 14:38:06 +0200 +To: =?iso-8859-1?Q?Josh_Berkus?= +Subject: =?iso-8859-1?Q?Re:_Re:__Data_warehousing_requirements?= +From: +Cc: , + =?iso-8859-1?Q?Tom_Lane?= , + =?iso-8859-1?Q?Gabriele_Bartolini?= , + =?iso-8859-1?Q?Aaron_Werman?= +Message-Id: <28292295$10972388454166893d146f88.44056315@config5.schlund.de> +X-Binford: 6100 (more power) +X-Originating-From: 28292295 +X-Mailer: Webmail +X-Routing: UK +X-Received: from config5 by 193.23.116.11 with HTTP id 28292295 for + josh@agliodbs.com; Fri, 8 Oct 2004 14:38:01 +0200 +Content-Type: text/plain; + charset="iso-8859-1" +Mime-Version: 1.0 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Date: Fri, 8 Oct 2004 14:38:01 +0200 +X-Provags-ID: kundenserver.de abuse@kundenserver.de ident:@172.23.4.132 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200410/100 +X-Sequence-Number: 8576 + + +Josh Berkus wrote on 08.10.2004, 07:53:26: +> +> > It's not so much that they are necessarily inefficient as that they +> > constrain the planner's freedom of action. You need to think a lot more +> > carefully about the order of joining than when you use inner joins. +> +> I've also found that OUTER JOINS constrain the types of joins that can/will be +> used as well as the order. Maybe you didn't intend it that way, but (for +> example) OUTER JOINs seem much more likely to use expensive merge joins. +> + +Unfortunately, yes thats true - thats is for correctness, not an +optimization decision. Outer joins constrain you on both join order AND +on join type. Nested loops and hash joins avoid touching all rows in +the right hand table, which is exactly what you don't want when you +have a right outer join to perform, since you wish to include rows in +that table when there is no match. Thus, we MUST choose a merge join +even when (if it wasn't an outer join) we would have chosen a nested +loops or hash. + +Best Regards, Simon Riggs + +From pgsql-benchmarks-owner@postgresql.org Fri Oct 8 14:56:09 2004 +X-Original-To: pgsql-benchmarks-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 27CDB32A090; + Fri, 8 Oct 2004 14:56:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27480-02; Fri, 8 Oct 2004 13:55:54 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AFDC4329E3E; + Fri, 8 Oct 2004 14:55:57 +0100 (BST) +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 i98DtuVB011895; + Fri, 8 Oct 2004 09:55:57 -0400 (EDT) +To: =?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= + +Cc: pgsql-benchmarks@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] stats on cursor and query execution troubleshooting +In-reply-to: <4166542E.2020809@fr.netcentrex.net> +References: <4163C5C3.3030304@fr.netcentrex.net> + <25576.1097072199@sss.pgh.pa.us> + <4166542E.2020809@fr.netcentrex.net> +Comments: In-reply-to =?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= + + message dated "Fri, 08 Oct 2004 10:47:42 +0200" +Date: Fri, 08 Oct 2004 09:55:56 -0400 +Message-ID: <11894.1097243756@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/4 +X-Sequence-Number: 21 + +=?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= writes: +> Thanks for your repply, but I still don"t understand why the statistic +> logs : +> ! 0/0 [0/0] filesystem blocks in/out +> it told me there is no hard disk access, I'm sure there is, + +Complain to your friendly local kernel hacker. We just report what +getrusage() tells us; so if the number is wrong then it's a kernel bug. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 8 15:03:45 2004 +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 CAE2732A821 + for ; + Fri, 8 Oct 2004 15:03:42 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30015-06 + for ; + Fri, 8 Oct 2004 14:03: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 7E6C832A641 + for ; + Fri, 8 Oct 2004 15:03:35 +0100 (BST) +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 i98E3RQn011973; + Fri, 8 Oct 2004 10:03:27 -0400 (EDT) +To: Dawid Kuroczko +Cc: pgsql-performance@postgresql.org +Subject: Re: integer[] indexing. +In-reply-to: <758d5e7f041008021163fb40eb@mail.gmail.com> +References: <758d5e7f041008021163fb40eb@mail.gmail.com> +Comments: In-reply-to Dawid Kuroczko + message dated "Fri, 08 Oct 2004 11:11:16 +0200" +Date: Fri, 08 Oct 2004 10:03:26 -0400 +Message-ID: <11972.1097244206@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 + tests=MAILTO_TO_SPAM_ADDR +X-Spam-Level: * +X-Archive-Number: 200410/102 +X-Sequence-Number: 8578 + +Dawid Kuroczko writes: +> But when I phrase the query: + +> SELECT * FROM table WHERE (icount(ids) <= 1 AND ids[1] = 33) OR +> (icount(ids) > 1 AND ids && '{33}'); + +> Planner insists on using seqscan. Even with enable_seqscan = off; + +The OR-index-scan mechanism isn't currently smart enough to use partial +indexes that are only valid for some of the OR'd clauses rather than all +of them. Feel free to fix it ;-). (This might not even be very hard; +I haven't looked.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 8 15:23:02 2004 +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 97C2132B1CA + for ; + Fri, 8 Oct 2004 15:22:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36347-07 + for ; + Fri, 8 Oct 2004 14:22: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 616D832B1A7 + for ; + Fri, 8 Oct 2004 15:22:51 +0100 (BST) +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 i98EMiRm012170; + Fri, 8 Oct 2004 10:22:44 -0400 (EDT) +To: simon@2ndquadrant.com +Cc: =?iso-8859-1?Q?Josh_Berkus?= , + pgsql-performance@postgresql.org, + =?iso-8859-1?Q?Gabriele_Bartolini?= , + =?iso-8859-1?Q?Aaron_Werman?= +Subject: Re: =?iso-8859-1?Q?Re:_Re:__Data_warehousing_requirements?= +In-reply-to: <28292295$10972388454166893d146f88.44056315@config5.schlund.de> +References: <28292295$10972388454166893d146f88.44056315@config5.schlund.de> +Comments: In-reply-to + message dated "Fri, 08 Oct 2004 14:38:01 +0200" +Date: Fri, 08 Oct 2004 10:22:44 -0400 +Message-ID: <12169.1097245364@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/103 +X-Sequence-Number: 8579 + + writes: +> Unfortunately, yes thats true - thats is for correctness, not an +> optimization decision. Outer joins constrain you on both join order AND +> on join type. Nested loops and hash joins avoid touching all rows in +> the right hand table, which is exactly what you don't want when you +> have a right outer join to perform, since you wish to include rows in +> that table when there is no match. Thus, we MUST choose a merge join +> even when (if it wasn't an outer join) we would have chosen a nested +> loops or hash. + +The alternative of course is to flip it around to be a left outer join +so that we can use those plan types. But depending on the relative +sizes of the two tables this may be a loser. + +If you are using a FULL join then it is indeed true that mergejoin is +the only supported plan type. I don't think that was at issue here +though. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 8 15:47:57 2004 +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 5B9E2329EE6 + for ; + Fri, 8 Oct 2004 15:47:55 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45195-05 + for ; + Fri, 8 Oct 2004 14:47:43 +0000 (GMT) +Received: from mail.deg.cc (unknown [64.139.134.201]) + by svr1.postgresql.org (Postfix) with ESMTP id CF3D5329F72 + for ; + Fri, 8 Oct 2004 15:47:43 +0100 (BST) +Received: from deg.cc (unknown [198.70.16.205]) + by mail.deg.cc (Postfix) with ESMTP id A0E145608A + for ; + Fri, 8 Oct 2004 10:47:40 -0400 (EDT) +Message-ID: <4166A8E8.4060102@deg.cc> +Date: Fri, 08 Oct 2004 10:49:12 -0400 +From: Pallav Kalva +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040308 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Query Tuning +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/104 +X-Sequence-Number: 8580 + +Hi, + + I have a problem with the below query, when i do explain on the +below query on my live database it doesnt use any index specified on the +tables and does seq scan on the table which is 400k records. But if i +copy the same table onto a different database on a different machine it +uses all the indexes specified and query runs much quicker. I ran +analyze, vacuum analyze and rebuilt indexes on the live database but +still there is no difference in the performance. Can anyone tell why +this odd behavior ? + +Thanks! + +Query +-------- + +SELECT a.total as fsbos, b.total as foreclosures, c.total as +auctions, d.latestDate as lastUpdated +FROM ((SELECT count(1) as total + FROM Properties p INNER JOIN Datasources ds + ON p.datasource = ds.sourceId + WHERE p.countyState = 'GA' + AND ds.sourceType = 'fsbo' + AND p.status in (1,2) + )) a, + ((SELECT count(1) as total + FROM Properties p INNER JOIN Datasources ds + ON p.datasource = ds.sourceId + WHERE p.countyState = 'GA' + AND ds.sourceType = 'foreclosure' + AND (p.status in (1,2) + OR (p.status = 0 AND p.LastReviewed2 >= current_timestamp - +INTERVAL '14 days') ) + )) b, + ((SELECT count(1) as total + FROM Properties p + WHERE p.datasource = 1087 + AND p.countyState = 'GA' + AND p.status in (1,2) + )) c, + ((SELECT to_char(max(entryDate2), 'MM/DD/YYYY HH24:MI') as latestDate + FROM Properties p + WHERE p.countyState = 'GA' +)) d + +Explain from the Live database +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=1334730.95..1334731.02 rows=1 width=56) + -> Nested Loop (cost=1026932.25..1026932.30 rows=1 width=24) + -> Nested Loop (cost=704352.11..704352.14 rows=1 width=16) + -> Subquery Scan b (cost=375019.89..375019.90 rows=1 +width=8) + -> Aggregate (cost=375019.89..375019.89 rows=1 +width=0) + -> Hash Join (cost=308.72..374844.49 +rows=70158 width=0) + Hash Cond: ("outer".datasource = +"inner".sourceid) + -> Seq Scan on properties p +(cost=0.00..373289.10 rows=72678 width=4) + Filter: ((countystate = +'GA'::bpchar) AND ((status = 0) OR (status = 1) OR (status = 2)) AND +((lastreviewed2 >= (('now'::text)::timestamp(6) with time zone - '14 +days'::interval)) OR (status = 1) OR (status = 2))) + -> Hash (cost=288.05..288.05 +rows=8267 width=4) + -> Seq Scan on datasources ds +(cost=0.00..288.05 rows=8267 width=4) + Filter: ((sourcetype)::text += 'foreclosure'::text) + -> Subquery Scan c (cost=329332.22..329332.23 rows=1 +width=8) + -> Aggregate (cost=329332.22..329332.22 rows=1 +width=0) + -> Seq Scan on properties p +(cost=0.00..329321.06 rows=4464 width=0) + Filter: ((datasource = 1087) AND +(countystate = 'GA'::bpchar) AND ((status = 1) OR (status = 2))) + -> Subquery Scan a (cost=322580.14..322580.15 rows=1 width=8) + -> Aggregate (cost=322580.14..322580.14 rows=1 width=0) + -> Hash Join (cost=288.24..322579.28 rows=344 +width=0) + Hash Cond: ("outer".datasource = +"inner".sourceid) + -> Seq Scan on properties p +(cost=0.00..321993.05 rows=39273 width=4) + Filter: ((countystate = 'GA'::bpchar) +AND ((status = 1) OR (status = 2))) + -> Hash (cost=288.05..288.05 rows=75 width=4) + -> Seq Scan on datasources ds +(cost=0.00..288.05 rows=75 width=4) + Filter: ((sourcetype)::text = +'fsbo'::text) + -> Subquery Scan d (cost=307798.70..307798.72 rows=1 width=32) + -> Aggregate (cost=307798.70..307798.71 rows=1 width=8) + -> Seq Scan on properties p (cost=0.00..307337.04 +rows=184666 width=8) + Filter: (countystate = 'GA'::bpchar) + +Explain on the Copy of the Live database for the same query + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=5380.81..5380.88 rows=1 width=56) + -> Nested Loop (cost=3714.30..3714.35 rows=1 width=48) + -> Nested Loop (cost=2687.15..2687.18 rows=1 width=40) + -> Subquery Scan a (cost=1022.76..1022.77 rows=1 width=8) + -> Aggregate (cost=1022.76..1022.76 rows=1 width=0) + -> Nested Loop (cost=0.00..1022.75 rows=2 +width=0) + -> Seq Scan on datasources ds +(cost=0.00..4.44 rows=2 width=4) + Filter: ((sourcetype)::text = +'fsbo'::text) + -> Index Scan using +idx_properties_datasourcestateauctiondate on properties p +(cost=0.00..509.14 rows=2 width=4) + Index Cond: (p.datasource = +"outer".sourceid) + Filter: ((countystate = +'GA'::bpchar) AND ((status = 1) OR (status = 2))) + -> Subquery Scan d (cost=1664.39..1664.40 rows=1 width=32) + -> Aggregate (cost=1664.39..1664.39 rows=1 width=8) + -> Index Scan using properties_idx_search on +properties p (cost=0.00..1663.35 rows=416 width=8) + Index Cond: (countystate = 'GA'::bpchar) + -> Subquery Scan b (cost=1027.15..1027.16 rows=1 width=8) + -> Aggregate (cost=1027.15..1027.15 rows=1 width=0) + -> Nested Loop (cost=0.00..1027.14 rows=3 width=0) + -> Seq Scan on datasources ds +(cost=0.00..4.44 rows=2 width=4) + Filter: ((sourcetype)::text = +'foreclosure'::text) + -> Index Scan using +idx_properties_datasourcestateauctiondate on properties p +(cost=0.00..511.32 rows=3 width=4) + Index Cond: (p.datasource = +"outer".sourceid) + Filter: ((countystate = 'GA'::bpchar) +AND ((status = 0) OR (status = 1) OR (status = 2)) AND ((lastreviewed2 + >= (('now'::text)::timestamp(6) with time zone - '14 days'::interval)) +OR (status = 1) OR (status = 2))) + -> Subquery Scan c (cost=1666.51..1666.52 rows=1 width=8) + -> Aggregate (cost=1666.51..1666.51 rows=1 width=0) + -> Index Scan using properties_idx_search on properties +p (cost=0.00..1666.46 rows=18 width=0) + Index Cond: (countystate = 'GA'::bpchar) + Filter: ((datasource = 1087) AND ((status = 1) OR +(status = 2))) + + + + +From pgsql-performance-owner@postgresql.org Fri Oct 8 17:43:14 2004 +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 5908832A704 + for ; + Fri, 8 Oct 2004 17:43:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82826-04 + for ; + Fri, 8 Oct 2004 16:42: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 327F132A6A5 + for ; + Fri, 8 Oct 2004 17:42:59 +0100 (BST) +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 i98GguGn013658; + Fri, 8 Oct 2004 12:42:57 -0400 (EDT) +To: Pallav Kalva +Cc: pgsql-performance@postgresql.org +Subject: Re: Query Tuning +In-reply-to: <4166A8E8.4060102@deg.cc> +References: <4166A8E8.4060102@deg.cc> +Comments: In-reply-to Pallav Kalva + message dated "Fri, 08 Oct 2004 10:49:12 -0400" +Date: Fri, 08 Oct 2004 12:42:56 -0400 +Message-ID: <13657.1097253776@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200410/105 +X-Sequence-Number: 8581 + +Pallav Kalva writes: +> I have a problem with the below query, when i do explain on the +> below query on my live database it doesnt use any index specified on the +> tables and does seq scan on the table which is 400k records. But if i +> copy the same table onto a different database on a different machine it +> uses all the indexes specified and query runs much quicker. + +It looks to me like you've never vacuumed/analyzed the copy, and so you +get a different plan there. The fact that that plan is better than the +one made with statistics is unhappy making :-( ... but when you only +show us EXPLAIN output rather than EXPLAIN ANALYZE, it's impossible to +speculate about why. Also, what PG version is this? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 8 18:28:37 2004 +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 2CFBA32AABA + for ; + Fri, 8 Oct 2004 18:28:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94752-10 + for ; + Fri, 8 Oct 2004 17:27:54 +0000 (GMT) +Received: from mail.deg.cc (unknown [64.139.134.201]) + by svr1.postgresql.org (Postfix) with ESMTP id A2EAA329E64 + for ; + Fri, 8 Oct 2004 18:27:54 +0100 (BST) +Received: from deg.cc (unknown [198.70.16.205]) + by mail.deg.cc (Postfix) with ESMTP + id 711FB560C1; Fri, 8 Oct 2004 13:27:49 -0400 (EDT) +Message-ID: <4166CE72.2050900@deg.cc> +Date: Fri, 08 Oct 2004 13:29:22 -0400 +From: Pallav Kalva +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040308 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Query Tuning +References: <4166A8E8.4060102@deg.cc> <13657.1097253776@sss.pgh.pa.us> +In-Reply-To: <13657.1097253776@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.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200410/106 +X-Sequence-Number: 8582 + +Tom Lane wrote: + +>Pallav Kalva writes: +> +> +>> I have a problem with the below query, when i do explain on the +>>below query on my live database it doesnt use any index specified on the +>>tables and does seq scan on the table which is 400k records. But if i +>>copy the same table onto a different database on a different machine it +>>uses all the indexes specified and query runs much quicker. +>> +>> +> +>It looks to me like you've never vacuumed/analyzed the copy, and so you +>get a different plan there. The fact that that plan is better than the +>one made with statistics is unhappy making :-( ... but when you only +>show us EXPLAIN output rather than EXPLAIN ANALYZE, it's impossible to +>speculate about why. Also, what PG version is this? +> +> regards, tom lane +> +> +> +Thanks! for the quick reply. I cant run the EXPLAIN ANALYZE on the live +database because, it takes lot of time and hols up lot of other queries +on the table. The postgres version I am using is 7.4 . when you say " i +never vacuum/analyxed the copy" you mean the Live database ? or the copy +of the live database ? . I run vacuum database daily on my live database +as a part of daily maintanence. + + + +From pgsql-performance-owner@postgresql.org Fri Oct 8 20:32:17 2004 +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 DB4EA329E3B + for ; + Fri, 8 Oct 2004 20:32:15 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34411-07 + for ; + Fri, 8 Oct 2004 19:31:47 +0000 (GMT) +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B47E329F5B + for ; + Fri, 8 Oct 2004 20:31:46 +0100 (BST) +Received: from gary (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id 49E15FBBB7 + for ; + Fri, 8 Oct 2004 20:31:53 +0100 (BST) +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Fri, 08 Oct 2004 20:32:22 +0100 +MIME-Version: 1.0 +Subject: Odd planner choice? +Message-ID: <4166F956.21282.29EC515A@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: Multipart/Alternative; boundary="Alt-Boundary-24044.703353178" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.1 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE, HTML_TITLE_EMPTY, NO_DNS_FOR_FROM +X-Spam-Level: ** +X-Archive-Number: 200410/107 +X-Sequence-Number: 8583 + +--Alt-Boundary-24044.703353178 +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body + +I'm looking at one of my standard queries and have encountered some strange +performance problems. + +The query below is to search for vacant staff member date/time slots given a series of +target date/times. The data contained in the booking_plan/staff_booking tables contain +the existing bookings, so I'm looking for "clashing" bookings to eliminate them from a +candidate list. + +The query is: + +select distinct b.staff_id from staff_booking b, booking_plan bp, t_search_reqt_dates rd +where b.booking_id = bp.booking_id +and rd.datetime_from <= bp.datetime_to and rd.datetime_to >= bp.datetime_from +AND bp.booking_date between rd.reqt_date-1 and rd.reqt_date+1 +and rd.search_id = 13 +and rd.reqt_date between '2004-09-30' AND '2005-12-31' + +There are 197877 rows in staff_booking, 573416 rows in booking_plan and 26 rows in +t_search_reqt_dates. + +The t_search reqt_dates is a temp table created and populated with the target +date/times. The temp table is *not* analyzed, all the other are. + +The "good" query plan comes with the criteria on search_id and reqt_date given in the +last two lines in the query. Note all the rows in the temp table are search_id = 13 and all +the rows are between the two dates, so the whole 26 rows is always pulled out. + +In this case it is doing exactly what I expect. It is pulling all rows from the +t_search_reqt_dates table, then pulling the relevant records from the booking_plan and +then hashing with staff_booking. Excellent performance. + +The problem is I don't need the clauses for search_id and reqt_dates as the whole table +is always read anyway. The good plan is because the planner thinks just one row will be +read from t_search_reqt_dates. + +If I remove the redundant clauses, the planner now estimates 1000 rows returned from +the table, not unreasonable since it has no statistics. But *why* in that case, with *more* +estimated rows does it choose to materialize that table (26 rows) 573416 times!!! + +whenever it estimates more than one row it chooses the bad plan. + +I really want to remove the redundant clauses, but I can't. If I analyse the table, then it +knows there are 26 rows and chooses the "bad" plan whatever I do. + +Any ideas??? + +Cheers, +Gary. + +-------------------- Plans for above query ------------------------ + +Good QUERY PLAN +Unique (cost=15440.83..15447.91 rows=462 width=4) (actual time=1342.000..1342.000 +rows=110 loops=1) + -> Sort (cost=15440.83..15444.37 rows=7081 width=4) (actual +time=1342.000..1342.000 rows=2173 loops=1) + Sort Key: b.staff_id + -> Hash Join (cost=10784.66..15350.26 rows=7081 width=4) (actual +time=601.000..1331.000 rows=2173 loops=1) + Hash Cond: ("outer".booking_id = "inner".booking_id) + -> Seq Scan on staff_booking b (cost=0.00..4233.39 rows=197877 width=8) +(actual time=0.000..400.000 rows=197877 loops=1) + -> Hash (cost=10781.12..10781.12 rows=7080 width=4) (actual +time=591.000..591.000 rows=0 loops=1) + -> Nested Loop (cost=0.00..10781.12 rows=7080 width=4) (actual +time=10.000..581.000 rows=2173 loops=1) + Join Filter: (("outer".datetime_from <= "inner".datetime_to) AND +("outer".datetime_to >= "inner".datetime_from)) + -> Seq Scan on t_search_reqt_dates rd (cost=0.00..16.50 rows=1 +width=20) (actual time=0.000..0.000 rows=26 loops=1) + Filter: ((search_id = 13) AND (reqt_date >= '2004-09-30'::date) AND +(reqt_date <= '2005-12-31'::date)) + -> Index Scan using booking_plan_idx2 on booking_plan bp +(cost=0.00..10254.91 rows=63713 width=24) (actual time=0.000..11.538 rows=5871 +loops=26) + Index Cond: ((bp.booking_date >= ("outer".reqt_date - 1)) AND +(bp.booking_date <= ("outer".reqt_date + 1))) +Total runtime: 1342.000 ms + + +Bad QUERY PLAN +Unique (cost=7878387.29..7885466.50 rows=462 width=4) (actual +time=41980.000..41980.000 rows=110 loops=1) + -> Sort (cost=7878387.29..7881926.90 rows=7079211 width=4) (actual +time=41980.000..41980.000 rows=2173 loops=1) + Sort Key: b.staff_id + -> Nested Loop (cost=5314.32..7480762.73 rows=7079211 width=4) (actual +time=6579.000..41980.000 rows=2173 loops=1) + Join Filter: (("inner".datetime_from <= "outer".datetime_to) AND +("inner".datetime_to >= "outer".datetime_from) AND ("outer".booking_date >= +("inner".reqt_date - 1)) AND ("outer".booking_date <= ("inner".reqt_date + 1))) + -> Hash Join (cost=5299.32..26339.73 rows=573416 width=24) (actual +time=2413.000..7832.000 rows=573416 loops=1) + Hash Cond: ("outer".booking_id = "inner".booking_id) + -> Seq Scan on booking_plan bp (cost=0.00..7646.08 rows=573416 +width=24) (actual time=0.000..1201.000 rows=573416 loops=1) + -> Hash (cost=4233.39..4233.39 rows=197877 width=8) (actual +time=811.000..811.000 rows=0 loops=1) + -> Seq Scan on staff_booking b (cost=0.00..4233.39 rows=197877 +width=8) (actual time=0.000..430.000 rows=197877 loops=1) + -> Materialize (cost=15.00..20.00 rows=1000 width=20) (actual +time=0.001..0.019 rows=26 loops=573416) + -> Seq Scan on t_search_reqt_dates rd (cost=0.00..15.00 rows=1000 +width=20) (actual time=0.000..0.000 rows=26 loops=1) +Total runtime: 41980.000 ms + + +--Alt-Boundary-24044.703353178 +Content-type: text/html; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body + + + + + + +
I'm looking at one of my standard queries and have encountered some strange +performance problems.
+

+
+
The query below is to search for vacant staff member date/time slots given a series of +target date/times. The data contained in the booking_plan/staff_booking tables contain +the existing bookings, so I'm looking for "clashing" bookings to eliminate them from a +candidate list.
+

+
+
The query is:
+

+
+
select distinct b.staff_id  from staff_booking b, booking_plan bp, t_search_reqt_dates rd
+
where b.booking_id = bp.booking_id
+
and rd.datetime_from <= bp.datetime_to and rd.datetime_to >= bp.datetime_from
+
AND bp.booking_date between rd.reqt_date-1 and rd.reqt_date+1
+
and rd.search_id = 13
+
and rd.reqt_date between '2004-09-30' AND '2005-12-31'
+

+
+
There are 197877 rows in staff_booking, 573416 rows in booking_plan and 26 rows in +t_search_reqt_dates.
+

+
+
The t_search reqt_dates is a temp table created and populated with the target +date/times. The temp table is *not* analyzed, all the other are.
+

+
+
The "good" query plan comes with the criteria on search_id and reqt_date given in the +last two lines in the query. Note all the rows in the temp table are search_id = 13 and all +the rows are between the two dates, so the whole 26 rows is always pulled out.
+

+
+
In this case it is doing exactly what I expect. It is pulling all rows from the +t_search_reqt_dates table, then pulling the relevant records from the booking_plan and +then hashing with staff_booking. Excellent performance.
+

+
+
The problem is I don't need the clauses for search_id and reqt_dates as the whole table +is always read anyway. The good plan is because the planner thinks just one row will be +read from t_search_reqt_dates.
+

+
+
If I remove the redundant clauses, the planner now estimates 1000 rows returned from +the table, not unreasonable since it has no statistics. But *why* in that case, with *more* +estimated rows does it choose to materialize that table (26 rows) 573416 times!!!
+

+
+
whenever it estimates more than one row it chooses the bad plan.
+

+
+
I really want to remove the redundant clauses, but I can't. If I analyse the table, then it +knows there are 26 rows and chooses the "bad" plan whatever I do.
+

+
+
Any ideas???
+

+
+
Cheers,
+
Gary.
+

+
+
-------------------- Plans for above query ------------------------
+

+
+
Good QUERY PLAN
+
Unique  (cost=15440.83..15447.91 rows=462 width=4) (actual time=1342.000..1342.000 +rows=110 loops=1)
+
  ->  Sort  (cost=15440.83..15444.37 rows=7081 width=4) (actual +time=1342.000..1342.000 rows=2173 loops=1)
+
        Sort Key: b.staff_id
+
        ->  Hash Join  (cost=10784.66..15350.26 rows=7081 width=4) +(actual +time=601.000..1331.000 rows=2173 loops=1)
+
              Hash Cond: ("outer".booking_id += "inner".booking_id)
+
              ->  Seq Scan on staff_booking +b  (cost=0.00..4233.39 rows=197877 width=8) +(actual time=0.000..400.000 rows=197877 loops=1)
+
              ->  Hash  (cost=10781.12..10781.12 +rows=7080 width=4) (actual +time=591.000..591.000 rows=0 loops=1)
+
                    +->  Nested Loop  (cost=0.00..10781.12 rows=7080 width=4) (actual +time=10.000..581.000 rows=2173 loops=1)
+
                          +Join Filter: (("outer".datetime_from <= "inner".datetime_to) AND +("outer".datetime_to >= "inner".datetime_from))
+
                          +->  Seq Scan on t_search_reqt_dates rd  (cost=0.00..16.50 rows=1 +width=20) (actual time=0.000..0.000 rows=26 loops=1)
+
                                +Filter: ((search_id = 13) AND (reqt_date >= '2004-09-30'::date) AND +(reqt_date <= '2005-12-31'::date))
+
                          +->  Index Scan using booking_plan_idx2 on booking_plan bp +(cost=0.00..10254.91 rows=63713 width=24) (actual time=0.000..11.538 rows=5871 +loops=26)
+
                                +Index Cond: ((bp.booking_date >= ("outer".reqt_date - 1)) AND +(bp.booking_date <= ("outer".reqt_date + 1)))
+
Total runtime: 1342.000 ms
+

+
+

+
+
Bad QUERY PLAN
+
Unique  (cost=7878387.29..7885466.50 rows=462 width=4) (actual +time=41980.000..41980.000 rows=110 loops=1)
+
  ->  Sort  (cost=7878387.29..7881926.90 rows=7079211 width=4) (actual +time=41980.000..41980.000 rows=2173 loops=1)
+
        Sort Key: b.staff_id
+
        ->  Nested Loop  (cost=5314.32..7480762.73 rows=7079211 +width=4) (actual +time=6579.000..41980.000 rows=2173 loops=1)
+
              Join Filter: (("inner".datetime_from +<= "outer".datetime_to) AND +("inner".datetime_to >= "outer".datetime_from) AND ("outer".booking_date >= +("inner".reqt_date - 1)) AND ("outer".booking_date <= ("inner".reqt_date + 1)))
+
              ->  Hash Join  +(cost=5299.32..26339.73 rows=573416 width=24) (actual +time=2413.000..7832.000 rows=573416 loops=1)
+
                    +Hash Cond: ("outer".booking_id = "inner".booking_id)
+
                    +->  Seq Scan on booking_plan bp  (cost=0.00..7646.08 rows=573416 +width=24) (actual time=0.000..1201.000 rows=573416 loops=1)
+
                    +->  Hash  (cost=4233.39..4233.39 rows=197877 width=8) (actual +time=811.000..811.000 rows=0 loops=1)
+
                          +->  Seq Scan on staff_booking b  (cost=0.00..4233.39 rows=197877 +width=8) (actual time=0.000..430.000 rows=197877 loops=1)
+
              ->  Materialize  +(cost=15.00..20.00 rows=1000 width=20) (actual +time=0.001..0.019 rows=26 loops=573416)
+
                    +->  Seq Scan on t_search_reqt_dates rd  (cost=0.00..15.00 rows=1000 +width=20) (actual time=0.000..0.000 rows=26 loops=1)
+
Total runtime: 41980.000 ms
+
+ + + +--Alt-Boundary-24044.703353178-- + +From pgsql-performance-owner@postgresql.org Fri Oct 8 20:46:13 2004 +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 C32C432A187 + for ; + Fri, 8 Oct 2004 20:46:10 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38300-06 + for ; + Fri, 8 Oct 2004 19:45:25 +0000 (GMT) +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 5739E32A42A + for ; + Fri, 8 Oct 2004 20:45:26 +0100 (BST) +Received: from gary (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id 6D762FBBB7 + for ; + Fri, 8 Oct 2004 20:45:34 +0100 (BST) +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Fri, 08 Oct 2004 20:46:03 +0100 +MIME-Version: 1.0 +Subject: Re: Odd planner choice? +Message-ID: <4166FC8B.19594.29F8D953@localhost> +In-reply-to: <4166F956.21282.29EC515A@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200410/108 +X-Sequence-Number: 8584 + +Oops, forgot to mention: + +PostgreSQL 8.0 beta 2 Windows. + +Thanks, +Gary. + +On 8 Oct 2004 at 20:32, Gary Doades wrote: + +> +> I'm looking at one of my standard queries and have encountered some strange performance +> problems. +> +> The query below is to search for vacant staff member date/time slots given a series of target +> date/times. The data contained in the booking_plan/staff_booking tables contain the existing +> bookings, so I'm looking for "clashing" bookings to eliminate them from a candidate list. +> +> The query is: +> +> select distinct b.staff_id from staff_booking b, booking_plan bp, t_search_reqt_dates rd +> where b.booking_id = bp.booking_id +> and rd.datetime_from <= bp.datetime_to and rd.datetime_to >= bp.datetime_from +> AND bp.booking_date between rd.reqt_date-1 and rd.reqt_date+1 +> and rd.search_id = 13 +> and rd.reqt_date between '2004-09-30' AND '2005-12-31' +> +> There are 197877 rows in staff_booking, 573416 rows in booking_plan and 26 rows in +> t_search_reqt_dates. +> +> The t_search reqt_dates is a temp table created and populated with the target date/times. The +> temp table is *not* analyzed, all the other are. +> +> The "good" query plan comes with the criteria on search_id and reqt_date given in the last two +> lines in the query. Note all the rows in the temp table are search_id = 13 and all the rows are +> between the two dates, so the whole 26 rows is always pulled out. +> +> In this case it is doing exactly what I expect. It is pulling all rows from the t_search_reqt_dates +> table, then pulling the relevant records from the booking_plan and then hashing with +> staff_booking. Excellent performance. +> +> The problem is I don't need the clauses for search_id and reqt_dates as the whole table is +> always read anyway. The good plan is because the planner thinks just one row will be read from +> t_search_reqt_dates. +> +> If I remove the redundant clauses, the planner now estimates 1000 rows returned from the table, +> not unreasonable since it has no statistics. But *why* in that case, with *more* estimated rows +> does it choose to materialize that table (26 rows) 573416 times!!! +> +> whenever it estimates more than one row it chooses the bad plan. +> +> I really want to remove the redundant clauses, but I can't. If I analyse the table, then it knows +> there are 26 rows and chooses the "bad" plan whatever I do. +> +> Any ideas??? +> +> Cheers, +> Gary. +> +> -------------------- Plans for above query ------------------------ +> +> Good QUERY PLAN +> Unique (cost=15440.83..15447.91 rows=462 width=4) (actual time=1342.000..1342.000 +> rows=110 loops=1) +> -> Sort (cost=15440.83..15444.37 rows=7081 width=4) (actual time=1342.000..1342.000 +> rows=2173 loops=1) +> Sort Key: b.staff_id +> -> Hash Join (cost=10784.66..15350.26 rows=7081 width=4) (actual +> time=601.000..1331.000 rows=2173 loops=1) +> Hash Cond: ("outer".booking_id = "inner".booking_id) +> -> Seq Scan on staff_booking b (cost=0.00..4233.39 rows=197877 width=8) (actual +> time=0.000..400.000 rows=197877 loops=1) +> -> Hash (cost=10781.12..10781.12 rows=7080 width=4) (actual +> time=591.000..591.000 rows=0 loops=1) +> -> Nested Loop (cost=0.00..10781.12 rows=7080 width=4) (actual +> time=10.000..581.000 rows=2173 loops=1) +> Join Filter: (("outer".datetime_from <= "inner".datetime_to) AND +> ("outer".datetime_to >= "inner".datetime_from)) +> -> Seq Scan on t_search_reqt_dates rd (cost=0.00..16.50 rows=1 width=20) +> (actual time=0.000..0.000 rows=26 loops=1) +> Filter: ((search_id = 13) AND (reqt_date >= '2004-09-30'::date) AND +> (reqt_date <= '2005-12-31'::date)) +> -> Index Scan using booking_plan_idx2 on booking_plan bp +> (cost=0.00..10254.91 rows=63713 width=24) (actual time=0.000..11.538 rows=5871 loops=26) +> Index Cond: ((bp.booking_date >= ("outer".reqt_date - 1)) AND +> (bp.booking_date <= ("outer".reqt_date + 1))) +> Total runtime: 1342.000 ms +> +> +> Bad QUERY PLAN +> Unique (cost=7878387.29..7885466.50 rows=462 width=4) (actual time=41980.000..41980.000 +> rows=110 loops=1) +> -> Sort (cost=7878387.29..7881926.90 rows=7079211 width=4) (actual +> time=41980.000..41980.000 rows=2173 loops=1) +> Sort Key: b.staff_id +> -> Nested Loop (cost=5314.32..7480762.73 rows=7079211 width=4) (actual +> time=6579.000..41980.000 rows=2173 loops=1) +> Join Filter: (("inner".datetime_from <= "outer".datetime_to) AND ("inner".datetime_to >= +> "outer".datetime_from) AND ("outer".booking_date >= ("inner".reqt_date - 1)) AND +> ("outer".booking_date <= ("inner".reqt_date + 1))) +> -> Hash Join (cost=5299.32..26339.73 rows=573416 width=24) (actual +> time=2413.000..7832.000 rows=573416 loops=1) +> Hash Cond: ("outer".booking_id = "inner".booking_id) +> -> Seq Scan on booking_plan bp (cost=0.00..7646.08 rows=573416 width=24) +> (actual time=0.000..1201.000 rows=573416 loops=1) +> -> Hash (cost=4233.39..4233.39 rows=197877 width=8) (actual +> time=811.000..811.000 rows=0 loops=1) +> -> Seq Scan on staff_booking b (cost=0.00..4233.39 rows=197877 width=8) +> (actual time=0.000..430.000 rows=197877 loops=1) +> -> Materialize (cost=15.00..20.00 rows=1000 width=20) (actual time=0.001..0.019 +> rows=26 loops=573416) +> -> Seq Scan on t_search_reqt_dates rd (cost=0.00..15.00 rows=1000 width=20) +> (actual time=0.000..0.000 rows=26 loops=1) +> Total runtime: 41980.000 ms +> + + + +From pgsql-performance-owner@postgresql.org Fri Oct 8 21:05:20 2004 +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 68A18329ED7 + for ; + Fri, 8 Oct 2004 21:05:17 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44059-06 + for ; + Fri, 8 Oct 2004 20:04: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 B5DEF32A518 + for ; + Fri, 8 Oct 2004 21:04:48 +0100 (BST) +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 i98K4g31015494; + Fri, 8 Oct 2004 16:04:43 -0400 (EDT) +To: "Gary Doades" +Cc: pgsql-performance@postgresql.org +Subject: Re: Odd planner choice? +In-reply-to: <4166F956.21282.29EC515A@localhost> +References: <4166F956.21282.29EC515A@localhost> +Comments: In-reply-to "Gary Doades" + message dated "Fri, 08 Oct 2004 20:32:22 +0100" +Date: Fri, 08 Oct 2004 16:04:42 -0400 +Message-ID: <15493.1097265882@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200410/109 +X-Sequence-Number: 8585 + +"Gary Doades" writes: +> If I remove the redundant clauses, the planner now estimates 1000 rows returned from +> the table, not unreasonable since it has no statistics. But *why* in that case, with *more* +> estimated rows does it choose to materialize that table (26 rows) 573416 times!!! + +It isn't. It's materializing that once and scanning it 573416 times, +once for each row in the outer relation. And this is not a bad plan +given the estimates. If it had stuck to what you call the good plan, +and there *had* been 1000 rows in the temp table, that plan would have +run 1000 times longer than it did. + +As a general rule, if your complaint is that you get a bad plan for an +unanalyzed table, the response is going to be "so analyze the table". + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 8 21:29:58 2004 +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 B98FB32A088 + for ; + Fri, 8 Oct 2004 21:29:55 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53183-01 + for ; + Fri, 8 Oct 2004 20:29:21 +0000 (GMT) +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 58C71329E3B + for ; + Fri, 8 Oct 2004 21:29:19 +0100 (BST) +Received: from gary (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id DE04CFBBB7 + for ; + Fri, 8 Oct 2004 21:29:27 +0100 (BST) +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Fri, 08 Oct 2004 21:29:57 +0100 +MIME-Version: 1.0 +Subject: Re: Odd planner choice? +Message-ID: <416706D5.13084.2A2108B2@localhost> +In-reply-to: <15493.1097265882@sss.pgh.pa.us> +References: <4166F956.21282.29EC515A@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200410/110 +X-Sequence-Number: 8586 + +On 8 Oct 2004 at 16:04, Tom Lane wrote: + +> "Gary Doades" writes: +> > If I remove the redundant clauses, the planner now estimates 1000 rows returned from +> > the table, not unreasonable since it has no statistics. But *why* in that case, with *more* +> > estimated rows does it choose to materialize that table (26 rows) 573416 times!!! +> +> It isn't. It's materializing that once and scanning it 573416 times, +> once for each row in the outer relation. And this is not a bad plan +> given the estimates. If it had stuck to what you call the good plan, +> and there *had* been 1000 rows in the temp table, that plan would have +> run 1000 times longer than it did. +> +> As a general rule, if your complaint is that you get a bad plan for an +> unanalyzed table, the response is going to be "so analyze the table". +> + +The problem is in this case is that if I *do* analyse the table I *always* get the bad plan. +Bad in this case meaning the query takes a lot longer. I'm still not sure why it can't +choose the better plan by just reading the 26 rows once and index scan the +booking_plan table 26 times (as in the "good" plan). + +OK, with 1000 row estimate I can see that index scanning 1000 times into the +booking_plan table would take some time, but the even if planner estimates 5 rows it still +produces the same slow query. + +If I analyze the table it then knows there are 26 rows and therefore always goes slow. + +This is why I am not analyzing this table, to fool the planner into thinking there is only +one row and produce a much faster access plan. Not ideal I know. + +Just using one redundant clause I now get: + +select distinct b.staff_id from staff_booking b, booking_plan bp, t_search_reqt_dates rd +where b.booking_id = bp.booking_id +and rd.datetime_from <= bp.datetime_to and rd.datetime_to >= bp.datetime_from +AND bp.booking_date between rd.reqt_date-1 and rd.reqt_date+1 +and rd.search_id = 13 + +QUERY PLAN +Unique (cost=50885.97..50921.37 rows=462 width=4) (actual +time=35231.000..35241.000 rows=110 loops=1) + -> Sort (cost=50885.97..50903.67 rows=35397 width=4) (actual +time=35231.000..35241.000 rows=2173 loops=1) + Sort Key: b.staff_id + -> Hash Join (cost=44951.32..50351.07 rows=35397 width=4) (actual +time=34530.000..35231.000 rows=2173 loops=1) + Hash Cond: ("outer".booking_id = "inner".booking_id) + -> Seq Scan on staff_booking b (cost=0.00..4233.39 rows=197877 width=8) +(actual time=0.000..351.000 rows=197877 loops=1) + -> Hash (cost=44933.62..44933.62 rows=35397 width=4) (actual +time=34530.000..34530.000 rows=0 loops=1) + -> Nested Loop (cost=15.50..44933.62 rows=35397 width=4) (actual +time=8342.000..34520.000 rows=2173 loops=1) + Join Filter: (("inner".datetime_from <= "outer".datetime_to) AND +("inner".datetime_to >= "outer".datetime_from) AND ("outer".booking_date >= +("inner".reqt_date - 1)) AND ("outer".booking_date <= ("inner".reqt_date + 1))) + -> Seq Scan on booking_plan bp (cost=0.00..7646.08 rows=573416 +width=24) (actual time=0.000..1053.000 rows=573416 loops=1) + -> Materialize (cost=15.50..15.53 rows=5 width=20) (actual +time=0.001..0.019 rows=26 loops=573416) + -> Seq Scan on t_search_reqt_dates rd (cost=0.00..15.50 rows=5 +width=20) (actual time=0.000..0.000 rows=26 loops=1) + Filter: (search_id = 13) +Total runtime: 35241.000 ms + +If this is the only answer for now, then fair enough I will just have to do more testing. + +Regards, +Gary. + + +From pgsql-performance-owner@postgresql.org Fri Oct 8 22:42:15 2004 +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 6D5EF329DBF + for ; + Fri, 8 Oct 2004 22:42:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71225-10 + for ; + Fri, 8 Oct 2004 21:41:31 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 95FDE32A004 + for ; + Fri, 8 Oct 2004 22:41:32 +0100 (BST) +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 6480235; Fri, 08 Oct 2004 14:42:55 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: First set of OSDL Shared Mem scalability results, some wierdness ... +Date: Fri, 8 Oct 2004 14:43:16 -0700 +User-Agent: KMail/1.6.2 +Cc: testperf-general@pgfoundry.org +MIME-Version: 1.0 +Content-Disposition: inline +Message-Id: <200410081443.16109.josh@agliodbs.com> +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.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200410/111 +X-Sequence-Number: 8587 + +Folks, + +I'm hoping that some of you can shed some light on this. + +I've been trying to peg the "sweet spot" for shared memory using OSDL's +equipment. With Jan's new ARC patch, I was expecting that the desired +amount of shared_buffers to be greatly increased. This has not turned out to +be the case. + +The first test series was using OSDL's DBT2 (OLTP) test, with 150 +"warehouses". All tests were run on a 4-way Pentium III 700mhz 3.8GB RAM +system hooked up to a rather high-end storage device (14 spindles). Tests +were on PostgreSQL 8.0b3, Linux 2.6.7. + +Here's a top-level summary: + +shared_buffers % RAM NOTPM20* +1000 0.2% 1287 +23000 5% 1507 +46000 10% 1481 +69000 15% 1382 +92000 20% 1375 +115000 25% 1380 +138000 30% 1344 + +* = New Order Transactions Per Minute, last 20 Minutes + Higher is better. The maximum possible is 1800. + +As you can see, the "sweet spot" appears to be between 5% and 10% of RAM, +which is if anything *lower* than recommendations for 7.4! + +This result is so surprising that I want people to take a look at it and tell +me if there's something wrong with the tests or some bottlenecking factor +that I've not seen. + +in order above: +http://khack.osdl.org/stp/297959/ +http://khack.osdl.org/stp/297960/ +http://khack.osdl.org/stp/297961/ +http://khack.osdl.org/stp/297962/ +http://khack.osdl.org/stp/297963/ +http://khack.osdl.org/stp/297964/ +http://khack.osdl.org/stp/297965/ + +Please note that many of the Graphs in these reports are broken. For one +thing, some aren't recorded (flat lines) and the CPU usage graph has +mislabeled lines. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Oct 8 23:13:16 2004 +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 6368432A10B + for ; + Fri, 8 Oct 2004 23:13:14 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78395-10 + for ; + Fri, 8 Oct 2004 22:13:02 +0000 (GMT) +Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) + by svr1.postgresql.org (Postfix) with ESMTP id 85DE232A12D + for ; + Fri, 8 Oct 2004 23:13:03 +0100 (BST) +Received: from [65.87.16.98] (HELO vulture.corp.neopolitan.com) + by mx1.neopolitan.us (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 6056326; Fri, 08 Oct 2004 15:13:00 -0700 +Subject: Re: First set of OSDL Shared Mem scalability results, +From: "J. Andrew Rogers" +To: josh@agliodbs.com, pgsql-performance@postgresql.org +In-Reply-To: <200410081443.16109.josh@agliodbs.com> +References: <200410081443.16109.josh@agliodbs.com> +Content-Type: text/plain +Organization: +Message-Id: <1097273580.25588.18.camel@vulture.corp.neopolitan.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 08 Oct 2004 15:13:00 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/112 +X-Sequence-Number: 8588 + +I have an idea that makes some assumptions about internals that I think +are correct. + +When you have a huge number of buffers in a list that has to be +traversed to look for things in cache, e.g. 100k, you will generate an +almost equivalent number of cache line misses on the processor to jump +through all those buffers. As I understand it (and I haven't looked so +I could be wrong), the buffer cache is searched by traversing it +sequentially. OTOH, it seems reasonable to me that the OS disk cache +may actually be using a tree structure that would generate vastly fewer +cache misses by comparison to find a buffer. This could mean a +substantial linear search cost as a function of the number of buffers, +big enough to rise above the noise floor when you have hundreds of +thousands of buffers. + +Cache misses start to really add up when a code path generates many, +many thousands of them, and differences in the access path between the +buffer cache and disk cache would be reflected when you have that many +buffers. I've seen these types of unexpected performance anomalies +before that got traced back to code patterns and cache efficiency and +gotten integer factors improvements by making some seemingly irrelevant +code changes. + +So I guess my question would be 1) are my assumptions about the +internals correct, and 2) if they are, is there a way to optimize +searching the buffer cache so that a search doesn't iterate over a +really long buffer list that is bottlenecked on cache line replacement. + +My random thought of the day, + +j. andrew rogers + + + +From pgsql-performance-owner@postgresql.org Fri Oct 8 23:21:44 2004 +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 64BE6329DBF + for ; + Fri, 8 Oct 2004 23:21:43 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79799-10 + for ; + Fri, 8 Oct 2004 22:21: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 57C0132A12D + for ; + Fri, 8 Oct 2004 23:21:33 +0100 (BST) +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 i98MLSRV021366; + Fri, 8 Oct 2004 18:21:28 -0400 (EDT) +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org, testperf-general@pgfoundry.org, + Jan Wieck +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +In-reply-to: <200410081443.16109.josh@agliodbs.com> +References: <200410081443.16109.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Fri, 08 Oct 2004 14:43:16 -0700" +Date: Fri, 08 Oct 2004 18:21:28 -0400 +Message-ID: <21365.1097274088@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/113 +X-Sequence-Number: 8589 + +Josh Berkus writes: +> Here's a top-level summary: + +> shared_buffers % RAM NOTPM20* +> 1000 0.2% 1287 +> 23000 5% 1507 +> 46000 10% 1481 +> 69000 15% 1382 +> 92000 20% 1375 +> 115000 25% 1380 +> 138000 30% 1344 + +> As you can see, the "sweet spot" appears to be between 5% and 10% of RAM, +> which is if anything *lower* than recommendations for 7.4! + +This doesn't actually surprise me a lot. There are a number of aspects +of Postgres that will get slower the more buffers there are. + +One thing that I hadn't focused on till just now, which is a new +overhead in 8.0, is that StrategyDirtyBufferList() scans the *entire* +buffer list *every time it's called*, which is to say once per bgwriter +loop. And to add insult to injury, it's doing that with the BufMgrLock +held (not that it's got any choice). + +We could alleviate this by changing the API between this function and +BufferSync, such that StrategyDirtyBufferList can stop as soon as it's +found all the buffers that are going to be written in this bgwriter +cycle ... but AFAICS that means abandoning the "bgwriter_percent" knob +since you'd never really know how many dirty pages there were +altogether. + +BTW, what is the actual size of the test database (disk footprint wise) +and how much of that do you think is heavily accessed during the run? +It's possible that the test conditions are such that adjusting +shared_buffers isn't going to mean anything anyway. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 8 23:32:51 2004 +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 204EE32A10B + for ; + Fri, 8 Oct 2004 23:32:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85620-03 + for ; + Fri, 8 Oct 2004 22:32: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 C639732A102 + for ; + Fri, 8 Oct 2004 23:32:35 +0100 (BST) +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 i98MWWwB021490; + Fri, 8 Oct 2004 18:32:33 -0400 (EDT) +To: "J. Andrew Rogers" +Cc: josh@agliodbs.com, pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, +In-reply-to: <1097273580.25588.18.camel@vulture.corp.neopolitan.com> +References: <200410081443.16109.josh@agliodbs.com> + <1097273580.25588.18.camel@vulture.corp.neopolitan.com> +Comments: In-reply-to "J. Andrew Rogers" + message dated "08 Oct 2004 15:13:00 -0700" +Date: Fri, 08 Oct 2004 18:32:32 -0400 +Message-ID: <21489.1097274752@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/114 +X-Sequence-Number: 8590 + +"J. Andrew Rogers" writes: +> As I understand it (and I haven't looked so I could be wrong), the +> buffer cache is searched by traversing it sequentially. + +You really should look first. + +The main-line code paths use hashed lookups. There are some cases that +do linear searches through the buffer headers or the CDB lists; in +theory those are supposed to be non-performance-critical cases, though +I am suspicious that some are not (see other response). In any case, +those structures are considerably more compact than the buffers proper, +and I doubt that cache misses per se are the killer factor. + +This does raise a question for Josh though, which is "where's the +oprofile results?" If we do have major problems at the level of cache +misses then oprofile would be able to prove it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 8 23:40:05 2004 +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 21E0632A10B + for ; + Fri, 8 Oct 2004 23:40:02 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85227-06 + for ; + Fri, 8 Oct 2004 22:39:49 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id 04769329E5C + for ; + Fri, 8 Oct 2004 23:39:51 +0100 (BST) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1CG3Or-0003vH-00 + for ; Sat, 09 Oct 2004 00:39:45 +0200 +Date: Sat, 9 Oct 2004 00:39:45 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, +Message-ID: <20041008223945.GA15067@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <200410081443.16109.josh@agliodbs.com> + <1097273580.25588.18.camel@vulture.corp.neopolitan.com> + <21489.1097274752@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <21489.1097274752@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.6 on a i686 +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/115 +X-Sequence-Number: 8591 + +On Fri, Oct 08, 2004 at 06:32:32PM -0400, Tom Lane wrote: +> This does raise a question for Josh though, which is "where's the +> oprofile results?" If we do have major problems at the level of cache +> misses then oprofile would be able to prove it. + +Or cachegrind. I've found it to be really effective at pinpointing cache +misses in the past (one CPU-intensive routine was sped up by 30% just by +avoiding a memory clear). :-) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sat Oct 9 00:07:43 2004 +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 4F38D32A5DB + for ; + Sat, 9 Oct 2004 00:06:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94346-01 + for ; + Fri, 8 Oct 2004 23:06:34 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id C2EB932A42A + for ; + Sat, 9 Oct 2004 00:06:34 +0100 (BST) +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 6480716; Fri, 08 Oct 2004 16:07:55 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, +Date: Fri, 8 Oct 2004 16:08:14 -0700 +User-Agent: KMail/1.6.2 +Cc: Tom Lane , "J. Andrew Rogers" +References: <200410081443.16109.josh@agliodbs.com> + <1097273580.25588.18.camel@vulture.corp.neopolitan.com> + <21489.1097274752@sss.pgh.pa.us> +In-Reply-To: <21489.1097274752@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200410081608.14043.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/116 +X-Sequence-Number: 8592 + +Tom, + +> This does raise a question for Josh though, which is "where's the +> oprofile results?" =C2=A0If we do have major problems at the level of cac= +he +> misses then oprofile would be able to prove it. + +Missing, I'm afraid. OSDL has been having technical issues with STP all we= +ek. + +Hopefully the next test run will have them. + +--=20 +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sat Oct 9 00:30:36 2004 +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 189E8329FF2 + for ; + Sat, 9 Oct 2004 00:30:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95808-08 + for ; + Fri, 8 Oct 2004 23:29:59 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 48472329F17 + for ; + Sat, 9 Oct 2004 00:30:01 +0100 (BST) +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 6480816; Fri, 08 Oct 2004 16:31:19 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Date: Fri, 8 Oct 2004 16:31:41 -0700 +User-Agent: KMail/1.6.2 +Cc: Tom Lane , testperf-general@pgfoundry.org, + Jan Wieck +References: <200410081443.16109.josh@agliodbs.com> + <21365.1097274088@sss.pgh.pa.us> +In-Reply-To: <21365.1097274088@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200410081631.41545.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/117 +X-Sequence-Number: 8593 + +Tom, + +> BTW, what is the actual size of the test database (disk footprint wise) +> and how much of that do you think is heavily accessed during the run? +> It's possible that the test conditions are such that adjusting +> shared_buffers isn't going to mean anything anyway. + +The raw data is 32GB, but a lot of the activity is incremental, that is +inserts and updates to recent inserts. Still, according to Mark, most of +the data does get queried in the course of filling orders. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sat Oct 9 04:20:05 2004 +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 B841432B43C + for ; + Sat, 9 Oct 2004 04:20:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45254-05 + for ; + Sat, 9 Oct 2004 03:19:58 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 1634632B429 + for ; + Sat, 9 Oct 2004 04:19:57 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i993Ju2B046079 + for ; Sat, 9 Oct 2004 03:19:56 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i992nwbS038767 + for pgsql-performance@postgresql.org; Sat, 9 Oct 2004 02:49:58 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Date: Fri, 08 Oct 2004 22:10:19 -0400 +Organization: cbbrowne Computing Inc +Lines: 48 +Message-ID: +References: <200410081443.16109.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:MSmAo22qNssFcOru6grzK7aLro0= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/118 +X-Sequence-Number: 8594 + +josh@agliodbs.com (Josh Berkus) wrote: +> I've been trying to peg the "sweet spot" for shared memory using +> OSDL's equipment. With Jan's new ARC patch, I was expecting that +> the desired amount of shared_buffers to be greatly increased. This +> has not turned out to be the case. + +That doesn't surprise me. + +My primary expectation would be that ARC would be able to make small +buffers much more effective alongside vacuums and seq scans than they +used to be. That does not establish anything about the value of +increasing the size buffer caches... + +> This result is so surprising that I want people to take a look at it +> and tell me if there's something wrong with the tests or some +> bottlenecking factor that I've not seen. + +I'm aware of two conspicuous scenarios where ARC would be expected to +_substantially_ improve performance: + + 1. When it allows a VACUUM not to throw useful data out of + the shared cache in that VACUUM now only 'chews' on one + page of the cache; + + 2. When it allows a Seq Scan to not push useful data out of + the shared cache, for much the same reason. + +I don't imagine either scenario are prominent in the OSDL tests. + +Increasing the number of cache buffers _is_ likely to lead to some +slowdowns: + + - Data that passes through the cache also passes through kernel + cache, so it's recorded twice, and read twice... + + - The more cache pages there are, the more work is needed for + PostgreSQL to manage them. That will notably happen anywhere + that there is a need to scan the cache. + + - If there are any inefficiencies in how the OS kernel manages shared + memory, as their size scales, well, that will obviously cause a + slowdown. +-- +If this was helpful, rate me +http://www.ntlug.org/~cbbrowne/internet.html +"One World. One Web. One Program." -- MICROS~1 hype +"Ein Volk, ein Reich, ein Fuehrer" -- Nazi hype +(One people, one country, one leader) + +From pgsql-performance-owner@postgresql.org Sat Oct 9 12:21:03 2004 +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 5763232A1F1 + for ; + Sat, 9 Oct 2004 12:20:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34288-05 + for ; + Sat, 9 Oct 2004 11:20:50 +0000 (GMT) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 875FC32A1B6 + for ; + Sat, 9 Oct 2004 12:20:50 +0100 (BST) +Received: from sysexperts.com + (c-24-6-183-218.client.comcast.net[24.6.183.218]) + by comcast.net (sccrmhc13) with ESMTP + id <2004100911204901600c0k3ne>; Sat, 9 Oct 2004 11:20:50 +0000 +Received: from localhost (localhost [127.0.0.1]) (uid 1000) + by filer with local; Sat, 09 Oct 2004 04:20:48 -0700 + id 0000545D.4167C990.00003826 +Date: Sat, 9 Oct 2004 04:20:48 -0700 +From: Kevin Brown +To: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Message-ID: <20041009112048.GA665@filer> +Mail-Followup-To: Kevin Brown , + pgsql-performance@postgresql.org +References: <200410081443.16109.josh@agliodbs.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +In-Reply-To: +Organization: Frobozzco International +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/119 +X-Sequence-Number: 8595 + +Christopher Browne wrote: +> Increasing the number of cache buffers _is_ likely to lead to some +> slowdowns: +> +> - Data that passes through the cache also passes through kernel +> cache, so it's recorded twice, and read twice... + +Even worse, memory that's used for the PG cache is memory that's not +available to the kernel's page cache. Even if the overall memory +usage in the system isn't enough to cause some paging to disk, most +modern kernels will adjust the page/disk cache size dynamically to fit +the memory demands of the system, which in this case means it'll be +smaller if running programs need more memory for their own use. + +This is why I sometimes wonder whether or not it would be a win to use +mmap() to access the data and index files -- doing so under a truly +modern OS would surely at the very least save a buffer copy (from the +page/disk cache to program memory) because the OS could instead +direcly map the buffer cache pages directly to the program's memory +space. + +Since PG often has to have multiple files open at the same time, and +in a production database many of those files will be rather large, PG +would have to limit the size of the mmap()ed region on 32-bit +platforms, which means that things like the order of mmap() operations +to access various parts of the file can become just as important in +the mmap()ed case as it is in the read()/write() case (if not more +so!). I would imagine that the use of mmap() on a 64-bit platform +would be a much, much larger win because PG would most likely be able +to mmap() entire files and let the OS work out how to order disk reads +and writes. + +The biggest problem as I see it is that (I think) mmap() would have to +be made to cooperate with malloc() for virtual address space. I +suspect issues like this have already been worked out by others, +however... + + + +-- +Kevin Brown kevin@sysexperts.com + +From pgsql-performance-owner@postgresql.org Sat Oct 9 16:05:30 2004 +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 C9946329DBE + for ; + Sat, 9 Oct 2004 16:05:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79030-09 + for ; + Sat, 9 Oct 2004 15:05:18 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 0433832A928 + for ; + Sat, 9 Oct 2004 16:05:16 +0100 (BST) +Received: from ool-43529386.dyn.optonline.net ([67.82.147.134] + helo=[192.168.1.9]) + by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) + (Exim 4.42) id 1CGImZ-0000Rs-DG; Sat, 09 Oct 2004 11:05:15 -0400 +Message-ID: <4167FD71.9050501@zeut.net> +Date: Sat, 09 Oct 2004 11:02:09 -0400 +From: Matthew +User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +References: <200410081443.16109.josh@agliodbs.com> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 67.82.147.134 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: Zeut +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/120 +X-Sequence-Number: 8596 + +Christopher Browne wrote: + +>josh@agliodbs.com (Josh Berkus) wrote: +> +> +>>This result is so surprising that I want people to take a look at it +>>and tell me if there's something wrong with the tests or some +>>bottlenecking factor that I've not seen. +>> +>> +>I'm aware of two conspicuous scenarios where ARC would be expected to +>_substantially_ improve performance: +> +> 1. When it allows a VACUUM not to throw useful data out of +> the shared cache in that VACUUM now only 'chews' on one +> page of the cache; +> + +Right, Josh, I assume you didn't run these test with pg_autovacuum +running, which might be interesting. + +Also how do these numbers compare to 7.4? They may not be what you +expected, but they might still be an improvment. + +Matthew + + +From pgsql-performance-owner@postgresql.org Sat Oct 9 16:07:33 2004 +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 12BE732A0F0 + for ; + Sat, 9 Oct 2004 16:07:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83161-02 + for ; + Sat, 9 Oct 2004 15:07: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 0E60B329DBE + for ; + Sat, 9 Oct 2004 16:07:29 +0100 (BST) +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 i99F7TRX027697; + Sat, 9 Oct 2004 11:07:29 -0400 (EDT) +To: Kevin Brown +Cc: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +In-reply-to: <20041009112048.GA665@filer> +References: <200410081443.16109.josh@agliodbs.com> + <20041009112048.GA665@filer> +Comments: In-reply-to Kevin Brown + message dated "Sat, 09 Oct 2004 04:20:48 -0700" +Date: Sat, 09 Oct 2004 11:07:28 -0400 +Message-ID: <27696.1097334448@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/121 +X-Sequence-Number: 8597 + +Kevin Brown writes: +> This is why I sometimes wonder whether or not it would be a win to use +> mmap() to access the data and index files -- + +mmap() is Right Out because it does not afford us sufficient control +over when changes to the in-memory data will propagate to disk. The +address-space-management problems you describe are also a nasty +headache, but that one is the showstopper. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Oct 9 21:37:34 2004 +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 B2F3B32A010 + for ; + Sat, 9 Oct 2004 21:37:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49483-06 + for ; + Sat, 9 Oct 2004 20:37:16 +0000 (GMT) +Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [204.127.198.39]) + by svr1.postgresql.org (Postfix) with ESMTP id B975932A00B + for ; + Sat, 9 Oct 2004 21:37:16 +0100 (BST) +Received: from sysexperts.com + (c-24-6-183-218.client.comcast.net[24.6.183.218]) + by comcast.net (rwcrmhc13) with ESMTP + id <20041009203713015003c198e>; Sat, 9 Oct 2004 20:37:13 +0000 +Received: from localhost (localhost [127.0.0.1]) (uid 1000) + by filer with local; Sat, 09 Oct 2004 13:37:12 -0700 + id 000064D1.41684BF8.00005448 +Date: Sat, 9 Oct 2004 13:37:12 -0700 +From: Kevin Brown +To: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Message-ID: <20041009203710.GB665@filer> +Mail-Followup-To: Kevin Brown , + pgsql-performance@postgresql.org +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +In-Reply-To: <27696.1097334448@sss.pgh.pa.us> +Organization: Frobozzco International +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/122 +X-Sequence-Number: 8598 + +Tom Lane wrote: +> Kevin Brown writes: +> > This is why I sometimes wonder whether or not it would be a win to use +> > mmap() to access the data and index files -- +> +> mmap() is Right Out because it does not afford us sufficient control +> over when changes to the in-memory data will propagate to disk. The +> address-space-management problems you describe are also a nasty +> headache, but that one is the showstopper. + +Huh? Surely fsync() or fdatasync() of the file descriptor associated +with the mmap()ed region at the appropriate times would accomplish +much of this? I'm particularly confused since PG's entire approach to +disk I/O is predicated on the notion that the OS, and not PG, is the +best arbiter of when data hits the disk. Otherwise it would be using +raw partitions for the highest-speed data store, yes? + +Also, there isn't any particular requirement to use mmap() for +everything -- you can use traditional open/write/close calls for the +WAL and mmap() for the data/index files (but it wouldn't surprise me +if this would require some extensive code changes). + +That said, if it's typical for many changes to made to a page +internally before PG needs to commit that page to disk, then your +argument makes sense, and that's especially true if we simply cannot +have the page written to disk in a partially-modified state (something +I can easily see being an issue for the WAL -- would the same hold +true of the index/data files?). + + + +-- +Kevin Brown kevin@sysexperts.com + +From pgsql-performance-owner@postgresql.org Sat Oct 9 22:01:15 2004 +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 AF56832A1BF + for ; + Sat, 9 Oct 2004 22:01:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55961-09 + for ; + Sat, 9 Oct 2004 21:01:04 +0000 (GMT) +Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 4330032A143 + for ; + Sat, 9 Oct 2004 22:01:03 +0100 (BST) +Received: from sysexperts.com + (c-24-6-183-218.client.comcast.net[24.6.183.218]) + by comcast.net (rwcrmhc11) with ESMTP + id <2004100921010201300c3se8e>; Sat, 9 Oct 2004 21:01:02 +0000 +Received: from localhost (localhost [127.0.0.1]) (uid 1000) + by filer with local; Sat, 09 Oct 2004 14:01:02 -0700 + id 000064D1.4168518E.0000554D +Date: Sat, 9 Oct 2004 14:01:02 -0700 +From: Kevin Brown +To: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Message-ID: <20041009210102.GC665@filer> +Mail-Followup-To: Kevin Brown , + pgsql-performance@postgresql.org +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +In-Reply-To: <20041009203710.GB665@filer> +Organization: Frobozzco International +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/123 +X-Sequence-Number: 8599 + +I wrote: +> That said, if it's typical for many changes to made to a page +> internally before PG needs to commit that page to disk, then your +> argument makes sense, and that's especially true if we simply cannot +> have the page written to disk in a partially-modified state (something +> I can easily see being an issue for the WAL -- would the same hold +> true of the index/data files?). + +Also, even if multiple changes would be made to the page, with the +page being valid for a disk write only after all such changes are +made, the use of mmap() (in conjunction with an internal buffer that +would then be copied to the mmap()ed memory space at the appropriate +time) would potentially save a system call over the use of write() +(even if write() were used to write out multiple pages). However, +there is so much lower-hanging fruit than this that an mmap() +implementation almost certainly isn't worth pursuing for this alone. + +So: it seems to me that mmap() is worth pursuing only if most internal +buffers tend to be written to only once or if it's acceptable for a +partially modified data/index page to be written to disk (which I +suppose could be true for data/index pages in the face of a rock-solid +WAL). + + +-- +Kevin Brown kevin@sysexperts.com + +From pgsql-performance-owner@postgresql.org Sun Oct 10 00:06:56 2004 +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 B3DDF32A235 + for ; + Sun, 10 Oct 2004 00:05:48 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78696-07 + for ; + Sat, 9 Oct 2004 23:05:36 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 84E24329D95 + for ; + Sun, 10 Oct 2004 00:05:37 +0100 (BST) +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 i99N5bBm004860; + Sat, 9 Oct 2004 19:05:37 -0400 (EDT) +To: Kevin Brown +Cc: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +In-reply-to: <20041009203710.GB665@filer> +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> +Comments: In-reply-to Kevin Brown + message dated "Sat, 09 Oct 2004 13:37:12 -0700" +Date: Sat, 09 Oct 2004 19:05:37 -0400 +Message-ID: <4859.1097363137@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/124 +X-Sequence-Number: 8600 + +Kevin Brown writes: +> Tom Lane wrote: +>> mmap() is Right Out because it does not afford us sufficient control +>> over when changes to the in-memory data will propagate to disk. + +> ... that's especially true if we simply cannot +> have the page written to disk in a partially-modified state (something +> I can easily see being an issue for the WAL -- would the same hold +> true of the index/data files?). + +You're almost there. Remember the fundamental WAL rule: log entries +must hit disk before the data changes they describe. That means that we +need not only a way of forcing changes to disk (fsync) but a way of +being sure that changes have *not* gone to disk yet. In the existing +implementation we get that by just not issuing write() for a given page +until we know that the relevant WAL log entries are fsync'd down to +disk. (BTW, this is what the LSN field on every page is for: it tells +the buffer manager the latest WAL offset that has to be flushed before +it can safely write the page.) + +mmap provides msync which is comparable to fsync, but AFAICS it +provides no way to prevent an in-memory change from reaching disk too +soon. This would mean that WAL entries would have to be written *and +flushed* before we could make the data change at all, which would +convert multiple updates of a single page into a series of write-and- +wait-for-WAL-fsync steps. Not good. fsync'ing WAL once per transaction +is bad enough, once per atomic action is intolerable. + +There is another reason for doing things this way. Consider a backend +that goes haywire and scribbles all over shared memory before crashing. +When the postmaster sees the abnormal child termination, it forcibly +kills the other active backends and discards shared memory altogether. +This gives us fairly good odds that the crash did not affect any data on +disk. It's not perfect of course, since another backend might have been +in process of issuing a write() when the disaster happens, but it's +pretty good; and I think that that isolation has a lot to do with PG's +good reputation for not corrupting data in crashes. If we had a large +fraction of the address space mmap'd then this sort of crash would be +just about guaranteed to propagate corruption into the on-disk files. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Oct 10 10:20:25 2004 +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 A767332A9CD + for ; + Sun, 10 Oct 2004 10:20:17 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87000-03 + for ; + Sun, 10 Oct 2004 09:20:12 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 0981E32A038 + for ; + Sun, 10 Oct 2004 10:20:13 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9A9KA2B087637 + for ; Sun, 10 Oct 2004 09:20:10 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9A9JxJA087537 + for pgsql-performance@postgresql.org; Sun, 10 Oct 2004 09:19:59 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: kernel 2.6 synchronous directory +Date: Sun, 10 Oct 2004 11:19:59 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 16 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +X-Enigmail-Version: 0.86.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/125 +X-Sequence-Number: 8601 + +Hi all, +I'm wondering if setting the $PG_DATA directory +as synchronous directory in order to make a crash +event more safe will penalyze the performances. + +If you run a kernel 2.6 the command is: + +chattr +S $PG_DATA + + + +Regards +Gaetano Mendola + + + + +From pgsql-performance-owner@postgresql.org Sun Oct 10 10:50:24 2004 +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 5EE0E32B429 + for ; + Sun, 10 Oct 2004 10:50:21 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90836-05 + for ; + Sun, 10 Oct 2004 09:50:16 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 67DA632B41C + for ; + Sun, 10 Oct 2004 10:50:15 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9A9oA2B093342 + for ; Sun, 10 Oct 2004 09:50:10 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9A9POaU088856 + for pgsql-performance@postgresql.org; Sun, 10 Oct 2004 09:25:24 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: First set of OSDL Shared Mem scalability results, some wierdness +Date: Sun, 10 Oct 2004 11:25:23 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 26 +Message-ID: <41690003.2010905@bigfoot.com> +References: <200410081443.16109.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Josh Berkus +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +In-Reply-To: <200410081443.16109.josh@agliodbs.com> +X-Enigmail-Version: 0.86.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/126 +X-Sequence-Number: 8602 + +Josh Berkus wrote: +> Folks, +> +> I'm hoping that some of you can shed some light on this. +> +> I've been trying to peg the "sweet spot" for shared memory using OSDL's +> equipment. With Jan's new ARC patch, I was expecting that the desired +> amount of shared_buffers to be greatly increased. This has not turned out to +> be the case. +> +> The first test series was using OSDL's DBT2 (OLTP) test, with 150 +> "warehouses". All tests were run on a 4-way Pentium III 700mhz 3.8GB RAM +> system hooked up to a rather high-end storage device (14 spindles). Tests +> were on PostgreSQL 8.0b3, Linux 2.6.7. + +I'd like to see these tests running using the cpu affinity capability in order +to oblige a backend to not change CPU during his life, this could drastically +increase the cache hit. + + +Regards +Gaetano Mendola + + + + + +From pgsql-performance-owner@postgresql.org Sun Oct 10 22:49:02 2004 +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 662F032ACAB + for ; + Sun, 10 Oct 2004 22:48:59 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79976-10 + for ; + Sun, 10 Oct 2004 21:48:52 +0000 (GMT) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 10AF132AC9D + for ; + Sun, 10 Oct 2004 22:48:49 +0100 (BST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 414BF8467; Sun, 10 Oct 2004 23:48:48 +0200 (CEST) +Date: Sun, 10 Oct 2004 23:48:48 +0200 (CEST) +From: Dennis Bjorklund +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, + +Subject: Re: First set of OSDL Shared Mem scalability results, some +In-Reply-To: <200410081443.16109.josh@agliodbs.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/127 +X-Sequence-Number: 8603 + +On Fri, 8 Oct 2004, Josh Berkus wrote: + +> As you can see, the "sweet spot" appears to be between 5% and 10% of RAM, +> which is if anything *lower* than recommendations for 7.4! + +What recommendation is that? To have shared buffers being about 10% of the +ram sounds familiar to me. What was recommended for 7.4? In the past we +used to say that the worst value is 50% since then the same things might +be cached both by pg and the os disk cache. + +Why do we excpect the shared buffer size sweet spot to change because of +the new arc stuff? And why would it make it better to have bigger shared +mem? + +Wouldn't it be the opposit, that now we don't invalidate as much of the +cache for vacuums and seq. scan so now we can do as good caching as +before but with less shared buffers. + +That said, testing and getting some numbers of good sizes for shared mem +is good. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Mon Oct 11 10:54:54 2004 +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 BA7DF32AA72 + for ; + Mon, 11 Oct 2004 10:54:52 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45725-05 + for ; + Mon, 11 Oct 2004 09:54:45 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FEC732A59E + for ; + Mon, 11 Oct 2004 10:54:46 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 77so211241rnk + for ; + Mon, 11 Oct 2004 02:54:41 -0700 (PDT) +Received: by 10.38.73.61 with SMTP id v61mr1530119rna; + Mon, 11 Oct 2004 02:54:41 -0700 (PDT) +Received: by 10.38.163.22 with HTTP; Mon, 11 Oct 2004 02:54:41 -0700 (PDT) +Message-ID: <758d5e7f04101102543eab8dca@mail.gmail.com> +Date: Mon, 11 Oct 2004 11:54:41 +0200 +From: Dawid Kuroczko +Reply-To: Dawid Kuroczko +To: pgsql-performance@postgresql.org +Subject: Views, joins and LIMIT +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.9 tagged_above=0.0 required=5.0 + tests=FROM_ENDS_IN_NUMS +X-Spam-Level: +X-Archive-Number: 200410/128 +X-Sequence-Number: 8604 + +I've been wondering... + +Suppose we have two tables +CREATE TABLE messages ( + message_id serial PRIMARY KEY, + message text NOT NULL +); +CREATE TABLE entries ( + entry_id serial PRIMARY KEY, + message_id integer NOT NULL REFERENCES messages +); + +And we have a join: +SELECT entry_id,message FROM entries NATURAL JOIN messages ORDER BY +entry_id DESC LIMIT 10; + +The typical planners order of doing things is -- join the tables, +perform sort, perform limit. + +But in the above case (which I guess is quite common) few things can be assumed. +1) to perform ORDER BY we don't need any join (entry_id is in our +entries table). +2) entries.entry_id references PRIMARY KEY, which is unique, so we +will have not less, not more but exactly one row per join (one row +from messages per one row from entries) +3) Knowing above, instead of performing join on each of thousands of +entries rows, we could perform ORDER BY and LIMIT before JOINing. +4) And then, after LIMITing we could JOIN those 5 rows. + +This I guess would be quite benefitial for VIEWs. :) + +Other thing that would be, I guess, benefitial for views would be +special handling of lines like this: + +SELECT entry_id,message_id FROM entries NATURAL JOIN messages; + +Here there is no reason to perform JOIN at all -- the data will not be used. +As above, since entries.message_id IS NOT NULL REFERENCES messages +and messages is UNIQUE (PRIMARY KEY) we are sure there will be one-to-one(*) +mapping between two tables. And since these keys are not used, no need to +waste time and perform JOIN. + +I wonder what you all think about it. :) + + Regards, + Dawid + +(*) not exactly one-to-one, because same messages.message_id can be +references many times from entries.message_id, but the join will +return exactly the same number of lines as would select * from +entries; + +From pgsql-performance-owner@postgresql.org Mon Oct 11 13:16:36 2004 +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 7624932A4C8 + for ; + Mon, 11 Oct 2004 13:16:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89712-05 + for ; + Mon, 11 Oct 2004 12:16:20 +0000 (GMT) +Received: from pw6tiger.de (pw6tiger.de [217.160.140.116]) + by svr1.postgresql.org (Postfix) with SMTP id 5550632A3B8 + for ; + Mon, 11 Oct 2004 13:16:22 +0100 (BST) +Received: (qmail 30577 invoked by uid 505); 11 Oct 2004 12:16:22 -0000 +Received: from vygen@gmx.de by planwerk6 by uid 89 with qmail-scanner-1.14 + (virus scan: Clear:. + Processed in 0.139657 secs); 11 Oct 2004 12:16:22 -0000 +Received: from isi-dial-146-203.isionline-dialin.de (HELO ?192.168.1.10?) + (vygen@planwerk6.de@195.158.146.203) + by pw6tiger.de with SMTP; 11 Oct 2004 12:16:22 -0000 +From: Janning Vygen +To: "Chris Hutchinson" +Subject: Re: EXPLAIN ANALYZE much slower than running query normally +Date: Mon, 11 Oct 2004 14:15:56 +0200 +User-Agent: KMail/1.7 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200410111415.56547.vygen@gmx.de> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/133 +X-Sequence-Number: 8609 + +Am Dienstag, 5. Oktober 2004 08:49 schrieb Chris Hutchinson: +> Running a trivial query in v7.4.2 (installed with fedora core2) using +> EXPLAIN ANALYZE is taking considerably longer than just running the query +> (2mins vs 6 secs). I was using this query to quickly compare a couple of +> systems after installing a faster disk. +> +> Is this sort of slowdown to be expected? + +no. + +did you run VACCUM ANALYZE before? you should do it after pg_restore your db +to a new filesystem + +in which order did you ran the queries. If you start your server and run two +equal queries, the second one will be much faster because of some or even all +data needed to answer the query is still in the shared buffers. + +janning + + + +From pgsql-performance-owner@postgresql.org Mon Oct 11 13:25:32 2004 +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 92A8832A9C1 + for ; + Mon, 11 Oct 2004 13:25:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90995-07 + for ; + Mon, 11 Oct 2004 12:25:22 +0000 (GMT) +Received: from pw6tiger.de (pw6tiger.de [217.160.140.116]) + by svr1.postgresql.org (Postfix) with SMTP id 2533232A937 + for ; + Mon, 11 Oct 2004 13:25:24 +0100 (BST) +Received: (qmail 31354 invoked by uid 505); 11 Oct 2004 12:25:25 -0000 +Received: from vygen@gmx.de by planwerk6 by uid 89 with qmail-scanner-1.14 + (virus scan: Clear:. + Processed in 0.170588 secs); 11 Oct 2004 12:25:25 -0000 +Received: from isi-dial-146-203.isionline-dialin.de (HELO ?192.168.1.10?) + (vygen@planwerk6.de@195.158.146.203) + by pw6tiger.de with SMTP; 11 Oct 2004 12:25:24 -0000 +From: Janning Vygen +To: HyunSung Jang +Subject: Re: why my query is not using index?? +Date: Mon, 11 Oct 2004 14:25:02 +0200 +User-Agent: KMail/1.7 +References: <41639F3C.4050103@siche.net> +In-Reply-To: <41639F3C.4050103@siche.net> +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200410111425.02671.vygen@gmx.de> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/134 +X-Sequence-Number: 8610 + +Am Mittwoch, 6. Oktober 2004 09:31 schrieben Sie: +> postgres=# explain ANALYZE select * from test where today < '2004-01-01'; +> QUERY PLAN +>------------------------- Seq Scan on test (cost=0.00..19.51 rows=334 +> width=44) (actual +> time=0.545..2.429 rows=721 loops=1) +> Filter: (today < '2004-01-01 00:00:00'::timestamp without time zone) +> Total runtime: 3.072 ms +> (3 rows) +> +> postgres=# explain ANALYZE select * from test where today > '2003-01-01' +> and today < '2004-01-01'; +> QUERY +> PLAN +> --------------------------------------------------------------- Index +> Scan using idx_today on test (cost=0.00..18.89 rows=6 width=44) (actual +> time=0.055..1.098 rows=365 loops=1) +> Index Cond: ((today > '2003-01-01 00:00:00'::timestamp without time +> zone) AND (today < '2004-01-01 00:00:00'::timestamp without time zone)) +> Total runtime: 1.471 ms +> (3 rows) +> +> hello +> +> I was expected 1st query should using index, but it doesn't +> 2nd query doing perfect as you see. + +postgres uses a seq scan if its faster. In your case postgres seems to know +that most of your rows have a date < 2004-01-01 and so doesn't need to +consult the index if it has to read every page anyway. seq scan can be faster +on small tables. try (in psql) "SET enable_seqscan TO off;" before running +your query and see how postgres plans it without using seq scan. + +janning + + + + +From pgsql-performance-owner@postgresql.org Mon Oct 11 15:14:37 2004 +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 72E5932A518 + for ; + Mon, 11 Oct 2004 15:14:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31047-03 + for ; + Mon, 11 Oct 2004 14:14: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 7B81C32AEB4 + for ; + Mon, 11 Oct 2004 15:14:25 +0100 (BST) +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 i9BEEIxB004866; + Mon, 11 Oct 2004 10:14:19 -0400 (EDT) +To: Dawid Kuroczko +Cc: pgsql-performance@postgresql.org +Subject: Re: Views, joins and LIMIT +In-reply-to: <758d5e7f04101102543eab8dca@mail.gmail.com> +References: <758d5e7f04101102543eab8dca@mail.gmail.com> +Comments: In-reply-to Dawid Kuroczko + message dated "Mon, 11 Oct 2004 11:54:41 +0200" +Date: Mon, 11 Oct 2004 10:14:18 -0400 +Message-ID: <4865.1097504058@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 + tests=MAILTO_TO_SPAM_ADDR +X-Spam-Level: * +X-Archive-Number: 200410/135 +X-Sequence-Number: 8611 + +Dawid Kuroczko writes: +> This I guess would be quite benefitial for VIEWs. :) + +Have you tried it? + +regression-# SELECT entry_id,message FROM entries NATURAL JOIN messages ORDER BY entry_id DESC LIMIT 10; + QUERY PLAN + +----------------------------------------------------------------------------------------------------- + Limit (cost=0.00..48.88 rows=10 width=36) + -> Nested Loop (cost=0.00..4887.52 rows=1000 width=36) + -> Index Scan Backward using entries_pkey on entries (cost=0.00..52.00 rows=1000 width=8) + -> Index Scan using messages_pkey on messages (cost=0.00..4.82 rows=1 width=36) + Index Cond: ("outer".message_id = messages.message_id) +(5 rows) + +> Other thing that would be, I guess, benefitial for views would be +> special handling of lines like this: + +> SELECT entry_id,message_id FROM entries NATURAL JOIN messages; + +> Here there is no reason to perform JOIN at all -- the data will not be used. +> As above, since entries.message_id IS NOT NULL REFERENCES messages +> and messages is UNIQUE (PRIMARY KEY) we are sure there will be one-to-one(*) +> mapping between two tables. And since these keys are not used, no need to +> waste time and perform JOIN. + +The bang-for-the-buck ratio on that seems much too low. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 11 15:22:12 2004 +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 0E4A232C12A + for ; + Mon, 11 Oct 2004 15:22:10 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32319-09 + for ; + Mon, 11 Oct 2004 14:22:01 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CC9B232C0E7 + for ; + Mon, 11 Oct 2004 15:22:04 +0100 (BST) +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 i9BEM3YO004973; + Mon, 11 Oct 2004 10:22:04 -0400 (EDT) +To: Mike Harding +Cc: pgsql-performance@postgresql.org +Subject: Re: COPY slows down? +In-reply-to: <20041008121029.EEB485486C@bsd.mvh> +References: <20041008121029.EEB485486C@bsd.mvh> +Comments: In-reply-to Mike Harding + message dated "Fri, 08 Oct 2004 05:10:29 -0700" +Date: Mon, 11 Oct 2004 10:22:03 -0400 +Message-ID: <4972.1097504523@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/136 +X-Sequence-Number: 8612 + +Mike Harding writes: +> I just ran a COPY of a million records several times, and each time I +> ran it it ran apparently exponentially slower. + +Tell us about indexes, foreign keys involving this table, triggers, rules? + +Some mention of your PG version would be appropriate, too. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 11 15:26:16 2004 +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 741A532A7C4 + for ; + Mon, 11 Oct 2004 15:26:14 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36332-04 + for ; + Mon, 11 Oct 2004 14:26: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 BC95232A44B + for ; + Mon, 11 Oct 2004 15:26:08 +0100 (BST) +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 i9BEQ8f7005033; + Mon, 11 Oct 2004 10:26:09 -0400 (EDT) +To: HyunSung Jang +Cc: pgsql-performance@postgresql.org +Subject: Re: why my query is not using index?? +In-reply-to: <41639F3C.4050103@siche.net> +References: <41639F3C.4050103@siche.net> +Comments: In-reply-to HyunSung Jang + message dated "Wed, 06 Oct 2004 16:31:08 +0900" +Date: Mon, 11 Oct 2004 10:26:08 -0400 +Message-ID: <5032.1097504768@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/137 +X-Sequence-Number: 8613 + +HyunSung Jang writes: +> can you explain to me why it's not doing that i expected?? + +Have you ANALYZEd this table recently? The estimated row counts seem +way off. + + regards, tom lane + +From pgsql-benchmarks-owner@postgresql.org Mon Oct 11 16:39:14 2004 +X-Original-To: pgsql-benchmarks-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A2BB32B0E9; + Mon, 11 Oct 2004 16:39:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65553-01; Mon, 11 Oct 2004 15:39:06 +0000 (GMT) +Received: from mailer.unicite.fr.netcentrex.net (unknown [62.161.167.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 324A132AA59; + Mon, 11 Oct 2004 16:39:04 +0100 (BST) +Received: from [192.168.101.228] ([192.168.101.228]) by + mailer.unicite.fr.netcentrex.net with SMTP (Microsoft Exchange + Internet Mail Service Version 5.5.2657.72) + id 42CX0WPL; Mon, 11 Oct 2004 17:39:02 +0200 +Message-ID: <416AA915.1000008@fr.netcentrex.net> +Date: Mon, 11 Oct 2004 17:39:01 +0200 +From: =?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= + +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-benchmarks@postgresql.org +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] stats on cursor and query execution +References: <4163C5C3.3030304@fr.netcentrex.net> + <25576.1097072199@sss.pgh.pa.us> + <4166542E.2020809@fr.netcentrex.net> + <11894.1097243756@sss.pgh.pa.us> +In-Reply-To: <11894.1097243756@sss.pgh.pa.us> +Content-Type: multipart/alternative; + boundary="------------060000070001090402020807" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_20_30, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/5 +X-Sequence-Number: 22 + +This is a multi-part message in MIME format. +--------------060000070001090402020807 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable + +Ok thanks tom, what shall we do without U ? + +by the way I have look at my kernel and getrusage() is well configure=20 +and return good results. +i/o stats too. + +I test an other version of postgresql and now, it works fine. +It' seems to be an install bug. + +thx +regards, Alban M=E9dici + + +on 08/10/2004 15:55 Tom Lane said the following: + +>=3D?ISO-8859-1?Q?=3D22Alban_M=3DE9dici_=3D28NetCentrex=3D29=3D22?=3D writes: +>=20=20 +> +>>Thanks for your repply, but I still don"t understand why the statistic +>>logs : +>>! 0/0 [0/0] filesystem blocks in/out +>>it told me there is no hard disk access, I'm sure there is, +>>=20=20=20=20 +>> +> +>Complain to your friendly local kernel hacker. We just report what +>getrusage() tells us; so if the number is wrong then it's a kernel bug. +> +> regards, tom lane +> +>=20=20 +> + +--=20 +Alban M=E9dici +R&D software engineer +------------------------------ +you can contact me @ : +IPPhone : +33 (0)2 31 46 37 68 +alban.medici@fr.netcentrex.net +http://www.netcentrex.net +------------------------------ + + +--------------060000070001090402020807 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + +Ok thanks tom, what shall we do without U ?
+
+by the way I have look at my kernel and getrusage() is well configure +and return good results.
+i/o stats too.
+
+I test an other version of postgresql and now, it works fine.
+It' seems to be an install bug.
+
+thx
+regards, Alban Médici
+
+

+on 08/10/2004 15:55 Tom Lane said the following: +
+
=?ISO-8859-1?Q?=22Alban_M=E9dici_=28NetCentrex=29=22?= <amedici@fr.netcentrex.net> writes:
+  
+
+
Thanks for your repply,  but I still don"t understand why the statistic
+logs   :
+!       0/0 [0/0] filesystem blocks in/out
+it told me there is no hard disk access, I'm sure there is,
+    
+
+

+Complain to your friendly local kernel hacker.  We just report what
+getrusage() tells us; so if the number is wrong then it's a kernel bug.
+
+			regards, tom lane
+
+  
+
+
+
-- 
+Alban Médici
+R&D software engineer
+------------------------------
+you can contact me @ :
+IPPhone : +33 (0)2 31 46 37 68
+alban.medici@fr.netcentrex.net
+http://www.netcentrex.net
+------------------------------
+ + + +--------------060000070001090402020807-- + +From pgsql-performance-owner@postgresql.org Mon Oct 11 18:38:31 2004 +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 57B1C32A2F0 + for ; + Mon, 11 Oct 2004 18:38:27 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05897-07 + for ; + Mon, 11 Oct 2004 17:38:20 +0000 (GMT) +Received: from smtp100.rog.mail.re2.yahoo.com (smtp100.rog.mail.re2.yahoo.com + [206.190.36.78]) + by svr1.postgresql.org (Postfix) with SMTP id 5F49D32A19B + for ; + Mon, 11 Oct 2004 18:38:20 +0100 (BST) +Received: from unknown (HELO phlogiston.dydns.org) + (a.sullivan@rogers.com@65.49.125.184 with login) + by smtp100.rog.mail.re2.yahoo.com with SMTP; 11 Oct 2004 17:38:19 -0000 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 5FF244054; Mon, 11 Oct 2004 13:38:19 -0400 (EDT) +Date: Mon, 11 Oct 2004 13:38:19 -0400 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: IBM P-series machines (was: Excessive context switching on SMP Xeons) +Message-ID: <20041011173819.GB22076@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200410050947.36174.josh@agliodbs.com> +User-Agent: Mutt/1.5.6+20040722i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/139 +X-Sequence-Number: 8615 + +On Tue, Oct 05, 2004 at 09:47:36AM -0700, Josh Berkus wrote: +> As long as you're on x86, scaling outward is the way to go. If you want to +> continue to scale upwards, ask Andrew Sullivan about his experiences running +> PostgreSQL on big IBM boxes. But if you consider an quad-Opteron server +> expensive, I don't think that's an option for you. + +Well, they're not that big, and both Chris Browne and Andrew Hammond +are at least as qualified to talk about this as I. But since Josh +mentioned it, I'll put some anecdotal rablings here just in case +anyone is interested. + +We used to run our systems on Solaris 7, then 8, on Sun E4500s. We +found the performance on those boxes surprisingly bad under certain +pathological loads. I ultimately traced this to some remarkably poor +shared memory handling by Solaris: during relatively heavy load +(in particular, thousands of selects per second on the same set of +tuples) we'd see an incredible number of semaphore operations, and +concluded that the buffer handling was killing us. + +I think we could have tuned this away, but for independent reasons we +decided to dump Sun gear (the hardware had become unreliable, and we +were not satisfied with the service we were getting). We ended up +choosing IBM P650s as a replacement. + +The 650s are not cheap, but boy are they fast. I don't have any +numbers I can share, but I can tell you that we recently had a few +days in which our write load was as large as the entire write load +for last year, and you couldn't tell. It is too early for us to say +whether the P series lives up to its billing in terms of relibility: +the real reason we use these machines is reliability, so if +approaching 100% uptime isn't important to you, the speed may not be +worth it. + +We're also, for the record, doing experiments with Opterons. So far, +we're impressed, and you can buy a lot of Opteron for the cost of one +P650. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +I remember when computers were frustrating because they *did* exactly what +you told them to. That actually seems sort of quaint now. + --J.D. Baldwin + +From pgsql-performance-owner@postgresql.org Tue Oct 12 01:28:33 2004 +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 88AA532A6B1 + for ; + Tue, 12 Oct 2004 01:28:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19369-10 + for ; + Tue, 12 Oct 2004 00:28:16 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C2B932A623 + for ; + Tue, 12 Oct 2004 01:28:18 +0100 (BST) +Received: from [134.22.69.18] (dyn-69-18.tor.dsl.tht.net [134.22.69.18]) + by tht.net (Postfix) with ESMTP + id 3098677887; Mon, 11 Oct 2004 14:21:11 -0400 (EDT) +Subject: Re: IBM P-series machines (was: Excessive context +From: Rod Taylor +To: Andrew Sullivan +Cc: Postgresql Performance +In-Reply-To: <20041011173819.GB22076@phlogiston.dyndns.org> +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <20041011173819.GB22076@phlogiston.dyndns.org> +Content-Type: text/plain +Message-Id: <1097518852.54644.20.camel@home> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 11 Oct 2004 14:20:52 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/148 +X-Sequence-Number: 8624 + +On Mon, 2004-10-11 at 13:38, Andrew Sullivan wrote: +> On Tue, Oct 05, 2004 at 09:47:36AM -0700, Josh Berkus wrote: +> > As long as you're on x86, scaling outward is the way to go. If you want to +> > continue to scale upwards, ask Andrew Sullivan about his experiences running +> > PostgreSQL on big IBM boxes. But if you consider an quad-Opteron server +> > expensive, I don't think that's an option for you. + + +> The 650s are not cheap, but boy are they fast. I don't have any +> numbers I can share, but I can tell you that we recently had a few +> days in which our write load was as large as the entire write load +> for last year, and you couldn't tell. It is too early for us to say +> whether the P series lives up to its billing in terms of relibility: +> the real reason we use these machines is reliability, so if +> approaching 100% uptime isn't important to you, the speed may not be +> worth it. + +Agreed completely, and the 570 knocks the 650 out of the water -- nearly +double the performance for math heavy queries. Beware vendor support for +Linux on these things though -- we ran into many of the same issues with +vendor support on the IBM machines as we did with the Opterons. + + +From pgsql-performance-owner@postgresql.org Mon Oct 11 21:49:27 2004 +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 4F22632A14D + for ; + Mon, 11 Oct 2004 21:49:21 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63552-07 + for ; + Mon, 11 Oct 2004 20:49:18 +0000 (GMT) +Received: from mail1.acecape.com (mail1.acecape.com [66.114.74.12]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B7D232A10C + for ; + Mon, 11 Oct 2004 21:49:18 +0100 (BST) +Received: from p65-147.acedsl.com (p65-147.acedsl.com [66.114.65.147]) + by mail1.acecape.com (8.12.11/8.12.11) with ESMTP id i9BKn56d018997; + Mon, 11 Oct 2004 16:49:05 -0400 +Date: Mon, 11 Oct 2004 16:49:44 -0400 (EDT) +From: Francisco Reyes +X-X-Sender: fran@zoraida.natserv.net +To: Janning Vygen +Cc: HyunSung Jang , pgsql-performance@postgresql.org +Subject: Re: why my query is not using index?? +In-Reply-To: <200410111425.02671.vygen@gmx.de> +Message-ID: <20041011163756.M97379@zoraida.natserv.net> +References: <41639F3C.4050103@siche.net> <200410111425.02671.vygen@gmx.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/140 +X-Sequence-Number: 8616 + +On Mon, 11 Oct 2004, Janning Vygen wrote: + +> postgres uses a seq scan if its faster. In your case postgres seems to know +> that most of your rows have a date < 2004-01-01 and so doesn't need to +> consult the index if it has to read every page anyway. seq scan can be faster +> on small tables. try (in psql) "SET enable_seqscan TO off;" before running +> your query and see how postgres plans it without using seq scan. + + +I was about to post and saw this message. +I have a query that was using sequential scans. Upon turning seqscan to +off it changed to using the index. What does that mean? +The tables are under 5k records so I wonder if that is why the optimizer +is option, on it's default state, to do sequential scans. + +I was also wondering if there is a relation between the sequential scans +and the fact that my entire query is a series of left joins: + +(1)FROM Accounts +(2)LEFT JOIN Equity_Positions ON Accounts.Account_ID = +(3)Equity_Positions.Account_ID +(4)LEFT JOIN Equities USING( Equity_ID ) +(5)LEFT JOIN Benchmarks USING( Benchmark_ID ) +(6)LEFT JOIN Equity_Prices ON Equities.equity_id = Equity_Prices.equity_id +(7) AND Equity_Positions.Equity_Date = Equity_Prices.Date +(8)LEFT JOIN Benchmark_Positions ON Equities.Benchmark_ID = +(9)Benchmark_Positions.Benchmark_ID +(10) AND Equity_Positions.Equity_Date = +(11)Benchmark_Positions.Benchmark_Date +(12)WHERE Client_ID =32 + +When I saw the default explain I was surprised to see that indexes were +not been used. For example the join on lines 4,5 are exactly the primary +key of the tables yet a sequential scan was used. + +The default explain was: + +Sort (cost=382.01..382.15 rows=56 width=196) + Sort Key: accounts.account_group, accounts.account_name, +equities.equity_description, equity_positions.equity_date + -> Hash Left Join (cost=357.36..380.39 rows=56 width=196) + Hash Cond: (("outer".benchmark_id = "inner".benchmark_id) AND ("outer".equity_date = "inner".benchmark_date)) + -> Hash Left Join (cost=353.41..375.46 rows=56 width=174) + Hash Cond: (("outer".equity_id = "inner".equity_id) AND ("outer".equity_date = "inner".date)) + -> Hash Left Join (cost=292.22..296.90 rows=56 width=159) + Hash Cond: ("outer".benchmark_id = "inner".benchmark_id) + -> Merge Right Join (cost=290.40..294.51 rows=56 width=137) + Merge Cond: ("outer".equity_id = "inner".equity_id) + -> Sort (cost=47.19..48.83 rows=655 width=70) + Sort Key: equities.equity_id + -> Seq Scan on equities (cost=0.00..16.55 rows=655 width=70) + -> Sort (cost=243.21..243.35 rows=56 width=67) + Sort Key: equity_positions.equity_id + -> Nested Loop Left Join (cost=0.00..241.58 rows=56 width=67) + -> Seq Scan on accounts (cost=0.00..5.80 rows=3 width=44) + Filter: (client_id = 32) + -> Index Scan using positions_acct_equity_date on equity_positions (cost=0.00..78.30 rows=23 width=27) + Index Cond: ("outer".account_id = equity_positions.account_id) + -> Hash (cost=1.66..1.66 rows=66 width=22) + -> Seq Scan on benchmarks (cost=0.00..1.66 rows=66 width=22) + -> Hash (cost=50.79..50.79 rows=2079 width=23) + -> Seq Scan on equity_prices (cost=0.00..50.79 rows=2079 width=23) + -> Hash (cost=3.30..3.30 rows=130 width=30) + -> Seq Scan on benchmark_positions (cost=0.00..3.30 rows=130 width=30) + + +After set enable_seqscan to off; +It becomes + +Sort (cost=490.82..490.96 rows=56 width=196) + Sort Key: accounts.account_group, accounts.account_name, +equities.equity_description, equity_positions.equity_date + -> Merge Left Join (cost=309.75..489.20 rows=56 width=196) + Merge Cond: ("outer".benchmark_id = "inner".benchmark_id) + Join Filter: ("outer".equity_date = "inner".benchmark_date) + -> Nested Loop Left Join (cost=309.75..644.88 rows=56 width=174) + -> Merge Left Join (cost=309.75..315.90 rows=56 width=159) + Merge Cond: ("outer".benchmark_id = "inner".benchmark_id) + -> Sort (cost=309.75..309.89 rows=56 width=137) + Sort Key: equities.benchmark_id + -> Merge Right Join (cost=254.43..308.12 rows=56 width=137) + Merge Cond: ("outer".equity_id = "inner".equity_id) + -> Index Scan using equities_pkey on equities (cost=0.00..51.21 rows=655 width=70) + -> Sort (cost=254.43..254.57 rows=56 width=67) + Sort Key: equity_positions.equity_id + -> Nested Loop Left Join (cost=0.00..252.81 rows=56 width=67) + -> Index Scan using accounts_pkey on accounts (cost=0.00..17.02 rows=3 width=44) + Filter: (client_id = 32) + -> Index Scan using positions_acct_equity_date on equity_positions (cost=0.00..78.30 rows=23 width=27) + Index Cond: ("outer".account_id = equity_positions.account_id) + -> Index Scan using benchmarks_pkey on benchmarks (cost=0.00..5.57 rows=66 width=22) + -> Index Scan using equity_prices_equity_date on equity_prices (cost=0.00..5.86 rows=1 width=23) + Index Cond: (("outer".equity_id = equity_prices.equity_id) AND ("outer".equity_date = equity_prices.date)) + -> Index Scan using benchpositions_acct_equity_date on benchmark_positions (cost=0.00..10.82 rows=130 width=30) + +From pgsql-performance-owner@postgresql.org Mon Oct 11 22:03:47 2004 +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 058DD329E7B + for ; + Mon, 11 Oct 2004 22:03:46 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68539-07 + for ; + Mon, 11 Oct 2004 21:03:35 +0000 (GMT) +Received: from mail1.acecape.com (mail1.acecape.com [66.114.74.12]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BDC5329D5F + for ; + Mon, 11 Oct 2004 22:03:36 +0100 (BST) +Received: from p65-147.acedsl.com (p65-147.acedsl.com [66.114.65.147]) + by mail1.acecape.com (8.12.11/8.12.11) with ESMTP id i9BL3bLP025166 + for ; Mon, 11 Oct 2004 17:03:37 -0400 +Date: Mon, 11 Oct 2004 17:04:16 -0400 (EDT) +From: Francisco Reyes +X-X-Sender: fran@zoraida.natserv.net +To: PostgreSQL performance +Subject: Understanding explains +Message-ID: <20041011164950.J97379@zoraida.natserv.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/141 +X-Sequence-Number: 8617 + +Is there a tutorial or reference to the different terms that appear on the +explain output? + + +Items such as "Nested Loop", "Hash".. + +Also is there a way to easily tell which of two explains is "worse". +Example I am running a query with "set enable_seqscan to off;" and i see +the explain now shows index scans, but not sure if is any faster now. + +I tried "explain analyze" and the "total runtime" for the one with +seq_scan off was faster, but after repeathing them they both dropped in +time, likely due to data getting cached. Even after the time drops for +both the one with seqscan off was always faster. + +Is there any disadvantage of having the enable_seqscan off? + +From pgsql-performance-owner@postgresql.org Mon Oct 11 22:06:10 2004 +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 0977932A35C + for ; + Mon, 11 Oct 2004 22:06:05 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71639-01 + for ; + Mon, 11 Oct 2004 21:05:57 +0000 (GMT) +Received: from vsmtp3.tin.it (vsmtp3alice.tin.it [212.216.176.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 16FD332A1C4 + for ; + Mon, 11 Oct 2004 22:05:57 +0100 (BST) +Received: from angus.tin.it (82.51.56.159) by vsmtp3.tin.it (7.0.027) + id 414B175C00A42ED0 for pgsql-performance@postgresql.org; + Mon, 11 Oct 2004 23:05:57 +0200 +Message-Id: <6.1.2.0.2.20041011224414.01fadec0@box.tin.it> +X-Sender: angusgb@box.tin.it (Unverified) +X-Mailer: QUALCOMM Windows Eudora Version 6.1.2.0 +Date: Mon, 11 Oct 2004 23:05:59 +0200 +To: pgsql-performance@postgresql.org +From: Gabriele Bartolini +Subject: Normal case or bad query plan? +Mime-Version: 1.0 +Content-Type: multipart/mixed; x-avg-checked=avg-ok-55D43834; + boundary="=======6D9D418A=======" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_RFCI +X-Spam-Level: +X-Archive-Number: 200410/142 +X-Sequence-Number: 8618 + +--=======6D9D418A======= +Content-Type: text/plain; x-avg-checked=avg-ok-55D43834; charset=us-ascii; + format=flowed +Content-Transfer-Encoding: 8bit + +Hi guys, + + please consider this scenario. I have this table: + +CREATE TABLE ip2location ( + ip_address_from BIGINT NOT NULL, + ip_address_to BIGINT NOT NULL, + id_location BIGINT NOT NULL, + PRIMARY KEY (ip_address_from, ip_address_to) +); + +I created a cluster on its primary key, by running: +CLUSTER ip2location_ip_address_from_key ON ip2location; + +This allowed me to organise data in a more efficient way: the data that is +contained are ranges of IP addresses with empty intersections; for every IP +class there is a related location's ID. The total number of entries is 1392443. + +For every IP address I have, an application retrieves the corresponding +location's id from the above table, by running a query like: + +SELECT id_location FROM ip2location WHERE '11020000111' >= ip_address_from +AND '11020000111' <= ip_address_to; + +For instance, by running the 'EXPLAIN ANALYSE' command, I get this "funny" +result: + + + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------- + Seq Scan on ip2location (cost=0.00..30490.65 rows=124781 width=8) +(actual time=5338.120..40237.283 rows=1 loops=1) + Filter: ((1040878301::bigint >= ip_address_from) AND +(1040878301::bigint <= ip_address_to)) + Total runtime: 40237.424 ms + + +With other data, that returns an empty set, I get: + +explain SELECT id_location FROM ip2location WHERE '11020000111' >= +ip_address_from AND '11020000111' <= ip_address_to; + + QUERY PLAN +------------------------------------------------------------------------------------------------------- + Index Scan using ip2location_ip_address_from_key on +ip2location (cost=0.00..419.16 rows=140 width=8) + Index Cond: ((11020000111::bigint >= ip_address_from) AND +(11020000111::bigint <= ip_address_to)) + + +I guess the planner chooses the best of the available options for the first +case, the sequential scan. This is not confirmed though by the fact that, +after I ran "SET enable_scan TO off", I got this: + QUERY +PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using ip2location_ip_address_from_key on +ip2location (cost=0.00..31505.73 rows=124781 width=8) (actual +time=2780.172..2780.185 rows=1 loops=1) + Index Cond: ((1040878301::bigint >= ip_address_from) AND +(1040878301::bigint <= ip_address_to)) + Total runtime: 2780.359 ms + + +Is this a normal case or should I worry? What am I missing? Do you have any +suggestion or comment to do (that would be extremely appreciated)? Is the +CLUSTER I created worthwhile or not? + +Thank you, +-Gabriele + +-- +Gabriele Bartolini: Web Programmer, ht://Dig & IWA/HWG Member, ht://Check +maintainer +Current Location: Prato, Toscana, Italia +angusgb@tin.it | http://www.prato.linux.it/~gbartolini | ICQ#129221447 + > "Leave every hope, ye who enter!", Dante Alighieri, Divine Comedy, The +Inferno + +--=======6D9D418A======= +Content-Type: text/plain; charset=us-ascii; x-avg=cert; + x-avg-checked=avg-ok-55D43834 +Content-Disposition: inline + + +--- +Outgoing mail is certified Virus Free. +Checked by AVG anti-virus system (http://www.grisoft.com). +Version: 6.0.773 / Virus Database: 520 - Release Date: 05/10/2004 + +--=======6D9D418A=======-- + + +From pgsql-performance-owner@postgresql.org Tue Oct 12 05:09:09 2004 +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 905E232A572 + for ; + Tue, 12 Oct 2004 05:09:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72106-07 + for ; + Tue, 12 Oct 2004 04:08:55 +0000 (GMT) +Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) + by svr1.postgresql.org (Postfix) with SMTP id 747B2329ECA + for ; + Tue, 12 Oct 2004 05:08:53 +0100 (BST) +Received: (qmail 19966 invoked by uid 1112); 11 Oct 2004 21:17:24 -0000 +Date: Mon, 11 Oct 2004 16:17:24 -0500 (EST) +From: Kris Jurka +X-X-Sender: books@leary.csoft.net +To: Gabriele Bartolini +Cc: pgsql-performance@postgresql.org +Subject: Re: Normal case or bad query plan? +In-Reply-To: <6.1.2.0.2.20041011224414.01fadec0@box.tin.it> +Message-ID: +References: <6.1.2.0.2.20041011224414.01fadec0@box.tin.it> +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.6 tagged_above=0.0 required=5.0 + tests=DATE_IN_PAST_06_12 +X-Spam-Level: +X-Archive-Number: 200410/152 +X-Sequence-Number: 8628 + + + +On Mon, 11 Oct 2004, Gabriele Bartolini wrote: + +> --------------------------------------------------------------------------------------------------------------------- +> Seq Scan on ip2location (cost=0.00..30490.65 rows=124781 width=8) +> (actual time=5338.120..40237.283 rows=1 loops=1) +> Filter: ((1040878301::bigint >= ip_address_from) AND +> (1040878301::bigint <= ip_address_to)) +> Total runtime: 40237.424 ms +> + +I believe the problem is that pg's lack of cross-column statistics is +producing the poor number of rows estimate. The number of rows mataching +just the first 1040878301::bigint >= ip_address_from condition is 122774 +which is roughtly 10% of the table. I imagine the query planner +believes that the other condition alone will match the other 90% of the +table. The problem is that it doesn't know that these two ranges' +intersection is actually tiny. The planner assumes a complete or nearly +complete overlap so it thinks it will need to fetch 10% of the rows from +both the index and the heap and chooses a seqscan. + +Kris Jurka + +From pgsql-performance-owner@postgresql.org Mon Oct 11 22:26:18 2004 +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 3289632A1CB + for ; + Mon, 11 Oct 2004 22:26:17 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74558-06 + for ; + Mon, 11 Oct 2004 21:26:06 +0000 (GMT) +Received: from pw6tiger.de (pw6tiger.de [217.160.140.116]) + by svr1.postgresql.org (Postfix) with SMTP id BC05F32A1A4 + for ; + Mon, 11 Oct 2004 22:26:06 +0100 (BST) +Received: (qmail 9227 invoked by uid 505); 11 Oct 2004 21:26:05 -0000 +Received: from vygen@gmx.de by planwerk6 by uid 89 with qmail-scanner-1.14 + (virus scan: Clear:. + Processed in 0.263111 secs); 11 Oct 2004 21:26:05 -0000 +Received: from p508cc1e2.dip0.t-ipconnect.de (HELO ?192.168.1.102?) + (vygen@planwerk6.de@80.140.193.226) + by pw6tiger.de with SMTP; 11 Oct 2004 21:26:05 -0000 +From: Janning Vygen +To: Francisco Reyes +Subject: Re: why my query is not using index?? +Date: Mon, 11 Oct 2004 23:26:02 +0200 +User-Agent: KMail/1.7 +Cc: HyunSung Jang , pgsql-performance@postgresql.org +References: <41639F3C.4050103@siche.net> <200410111425.02671.vygen@gmx.de> + <20041011163756.M97379@zoraida.natserv.net> +In-Reply-To: <20041011163756.M97379@zoraida.natserv.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200410112326.02486.vygen@gmx.de> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/143 +X-Sequence-Number: 8619 + +Am Montag, 11. Oktober 2004 22:49 schrieb Francisco Reyes: +> On Mon, 11 Oct 2004, Janning Vygen wrote: +> > postgres uses a seq scan if its faster. In your case postgres seems to +> > know that most of your rows have a date < 2004-01-01 and so doesn't need +> > to consult the index if it has to read every page anyway. seq scan can be +> > faster on small tables. try (in psql) "SET enable_seqscan TO off;" +> > before running your query and see how postgres plans it without using seq +> > scan. +> +> I was about to post and saw this message. +> I have a query that was using sequential scans. Upon turning seqscan to +> off it changed to using the index. What does that mean? + +enable_seqscan off means that postgres is not allowed to use seqscan. +default is on and postgres decides for each table lookup which method is +faster: seq scan or index scan. thats what the planner does: deciding which +access method might be the fastest. + +> The tables are under 5k records so I wonder if that is why the optimizer +> is option, on it's default state, to do sequential scans. + +if you have small tables, postgres is using seqscan to reduce disk lookups. +postgresql reads disk pages in 8k blocks. if your whole table is under 8k +there is no reason for postgres to load an index from another disk page +because it has to load the whole disk anyway. + +not sure, but i think postgres also analyzes the table to see which values are +in there. if you have a huge table with a column of integers and postgres +knows that 99% are of value 1 and you are looking for a row with a value of +1, why should it use an index just to see that it has to load the whole table +to find a matching row. + +And that's why you can't make performance tests with small tables. you need +test data which is as close as possible to real data. + +> I was also wondering if there is a relation between the sequential scans +> and the fact that my entire query is a series of left joins: + +no. + +janning + +From pgsql-performance-owner@postgresql.org Mon Oct 11 22:34:10 2004 +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 95118329F15 + for ; + Mon, 11 Oct 2004 22:34:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78526-01 + for ; + Mon, 11 Oct 2004 21:33: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 7CE31329F2B + for ; + Mon, 11 Oct 2004 22:33:57 +0100 (BST) +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 i9BLXv1q023516; + Mon, 11 Oct 2004 17:33:58 -0400 (EDT) +To: Gabriele Bartolini +Cc: pgsql-performance@postgresql.org +Subject: Re: Normal case or bad query plan? +In-reply-to: <6.1.2.0.2.20041011224414.01fadec0@box.tin.it> +References: <6.1.2.0.2.20041011224414.01fadec0@box.tin.it> +Comments: In-reply-to Gabriele Bartolini + message dated "Mon, 11 Oct 2004 23:05:59 +0200" +Date: Mon, 11 Oct 2004 17:33:57 -0400 +Message-ID: <23515.1097530437@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/144 +X-Sequence-Number: 8620 + +Gabriele Bartolini writes: +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------- +> Seq Scan on ip2location (cost=0.00..30490.65 rows=124781 width=8) +> (actual time=5338.120..40237.283 rows=1 loops=1) +> Filter: ((1040878301::bigint >= ip_address_from) AND +> (1040878301::bigint <= ip_address_to)) +> Total runtime: 40237.424 ms + +> Is this a normal case or should I worry? What am I missing? + +The striking thing about that is the huge difference between estimated +rowcount (124781) and actual (1). The planner would certainly have +picked an indexscan if it thought the query would select only one row. + +I suspect that you haven't ANALYZEd this table in a long time, if ever. +You really need reasonably up-to-date ANALYZE stats if you want the +planner to do an adequate job of planning range queries. It may well be +that you need to increase the analyze statistics target for this table, +also --- in BIGINT terms the distribution is probably pretty irregular, +which will mean you need finer-grain statistics to get good estimates. + +(BTW, have you looked at the inet datatype to see if that would fit your +needs?) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 11 23:03:18 2004 +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 4816C329C89 + for ; + Mon, 11 Oct 2004 23:03:17 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83145-04 + for ; + Mon, 11 Oct 2004 22:03:07 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.201]) + by svr1.postgresql.org (Postfix) with ESMTP id B089732A091 + for ; + Mon, 11 Oct 2004 23:03:08 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 74so350081rnk + for ; + Mon, 11 Oct 2004 15:03:07 -0700 (PDT) +Received: by 10.38.151.14 with SMTP id y14mr1517843rnd; + Mon, 11 Oct 2004 15:03:07 -0700 (PDT) +Received: by 10.38.76.43 with HTTP; Mon, 11 Oct 2004 15:03:07 -0700 (PDT) +Message-ID: <37d451f70410111503755fb751@mail.gmail.com> +Date: Mon, 11 Oct 2004 17:03:07 -0500 +From: Rosser Schwarz +Reply-To: Rosser Schwarz +To: Francisco Reyes +Subject: Re: Understanding explains +Cc: PostgreSQL performance +In-Reply-To: <20041011164950.J97379@zoraida.natserv.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <20041011164950.J97379@zoraida.natserv.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/145 +X-Sequence-Number: 8621 + +while you weren't looking, Francisco Reyes wrote: + +> Is there any disadvantage of having the enable_seqscan off? + +Plenty. + +The planner will choose whichever plan looks "cheapest", based on the +information it has available (table size, statistics, &c). If a +sequential scan looks cheaper, and in your case above it clearly is, +the planner will choose that query plan. Setting enable_seqscan = +false doesn't actually disable sequential scans; it merely makes them +seem radically more expensive to the planner, in hopes of biasing its +choice towards another query plan. In your case, that margin made an +index scan look less expensive than sequential scan, but your query +runtimes clearly suggest otherwise. + +In general, it's best to let the planner make the appropriate choice +without any artificial constraints. I've seen pathalogical cases +where the planner makes the wrong choice(s), but upon analysis, +they're almost always attributable to poor statistics, long +un-vacuumed tables, &c. + +/rls + +-- +:wq + +From pgsql-performance-owner@postgresql.org Tue Oct 12 00:50:46 2004 +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 1B0A3329EAB + for ; + Tue, 12 Oct 2004 00:50:44 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11711-02 + for ; + Mon, 11 Oct 2004 23:50:32 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 275A2329E65 + for ; + Tue, 12 Oct 2004 00:50:34 +0100 (BST) +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 6491475 for pgsql-performance@postgresql.org; + Mon, 11 Oct 2004 16:51:50 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: PostgreSQL performance +Subject: TestPerf Project started +Date: Mon, 11 Oct 2004 16:52:14 -0700 +User-Agent: KMail/1.6.2 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Message-Id: <200410111652.14890.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/146 +X-Sequence-Number: 8622 + +Folks, + +In order to have a place for scripts, graphs, results, etc., I've started the +TestPerf project on pgFoundry: +http://pgfoundry.org/projects/testperf/ + +If you are interested in doing performance testing for PostgreSQL, please join +the mailing list for the project. I could certainly use some help +scripting. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Oct 12 01:21:24 2004 +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 9426D32A684 + for ; + Tue, 12 Oct 2004 01:21:21 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19534-01 + for ; + Tue, 12 Oct 2004 00:21:16 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 20FD232A2C3 + for ; + Tue, 12 Oct 2004 01:21:17 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.12.9/8.12.9) with ESMTP id + i9C0LBSp009554; + sent by ; Mon, 11 Oct 2004 19:21:15 -0500 (CDT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by server11.icaen.uiowa.edu (8.12.9/smtp-service-1.6) with ESMTP id + i9C0Cj4p002504; (envelope-from ) Mon, + 11 Oct 2004 19:12:45 -0500 (CDT) +Message-ID: <416B217D.9090000@johnmeinel.com> +Date: Mon, 11 Oct 2004 19:12:45 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Francisco Reyes +Cc: pgsql-performance@postgresql.org +Subject: Re: why my query is not using index?? +References: <41639F3C.4050103@siche.net> <200410111425.02671.vygen@gmx.de> + <20041011163756.M97379@zoraida.natserv.net> +In-Reply-To: <20041011163756.M97379@zoraida.natserv.net> +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig020F595836BEAD80916D9EEE" +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.66n +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.75 + on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/147 +X-Sequence-Number: 8623 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig020F595836BEAD80916D9EEE +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Francisco Reyes wrote: +> On Mon, 11 Oct 2004, Janning Vygen wrote: +> +[...] +> When I saw the default explain I was surprised to see that indexes were +> not been used. For example the join on lines 4,5 are exactly the primary +> key of the tables yet a sequential scan was used. +> + +Note this: +> The default explain was: +> +> Sort (cost=382.01..382.15 rows=56 width=196) +> Sort Key: accounts.account_group, accounts.account_name, + +[...] + +Versus this: +> +> After set enable_seqscan to off; +> It becomes +> +> Sort (cost=490.82..490.96 rows=56 width=196) +> Sort Key: accounts.account_group, accounts.account_name, + +[...] + +Postgres believes that it will cost 382 to do a sequential scan, versus +490 for an indexed scan. Hence why it prefers to do the sequential scan. +Try running explain analyze to see if how accurate it is. + +As Janning mentioned, sometimes sequential scans *are* faster. If the +number of entries that will be found is large compared to the number of +total entries (I don't know the percentages, but probably >30-40%), then +it is faster to just load the data and scan through it, rather than +doing a whole bunch of indexed lookups. + +John +=:-> + +--------------enig020F595836BEAD80916D9EEE +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBayF9JdeBCYSNAAMRAhXHAJ9Oe5UXhr7l4rMCNpQU88A1ePzZmACdH7td +cedOaVSPnnV6RVTC4dpe8fo= +=J1/L +-----END PGP SIGNATURE----- + +--------------enig020F595836BEAD80916D9EEE-- + +From pgsql-performance-owner@postgresql.org Tue Oct 12 01:28:40 2004 +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 24F26329E7B + for ; + Tue, 12 Oct 2004 01:28:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20439-03 + for ; + Tue, 12 Oct 2004 00:28: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 CB908329E65 + for ; + Tue, 12 Oct 2004 01:28:31 +0100 (BST) +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 i9C0SSGY025941; + Mon, 11 Oct 2004 20:28:28 -0400 (EDT) +To: "Chris Hutchinson" +Cc: pgsql-performance@postgresql.org +Subject: Re: EXPLAIN ANALYZE much slower than running query normally +In-reply-to: +References: +Comments: In-reply-to "Chris Hutchinson" + message dated "Tue, 05 Oct 2004 16:49:26 +1000" +Date: Mon, 11 Oct 2004 20:28:28 -0400 +Message-ID: <25940.1097540908@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/149 +X-Sequence-Number: 8625 + +"Chris Hutchinson" writes: +> Running a trivial query in v7.4.2 (installed with fedora core2) using +> EXPLAIN ANALYZE is taking considerably longer than just running the query +> (2mins vs 6 secs). I was using this query to quickly compare a couple of +> systems after installing a faster disk. + +Turning on EXPLAIN ANALYZE will incur two gettimeofday() kernel calls +per row (in this particular plan), which is definitely nontrivial +overhead if there's not much I/O going on. I couldn't duplicate your +results exactly, but I did see a test case with 2.5 million one-column +rows go from <4 seconds to 21 seconds, which makes the cost of a +gettimeofday about 3.4 microseconds on my machine (Fedora Core 3, P4 +running at something over 1Ghz). When I widened the rows to a couple +hundred bytes, the raw runtime went up to 30 seconds and the analyzed +time to 50, so the overhead per row is pretty constant, as you'd expect. + +Some tests with a simple loop around a gettimeofday call yielded a value +of 2.16 microsec/gettimeofday, so there's some overhead attributable to +the EXPLAIN mechanism as well, but the kernel call is clearly the bulk +of it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 12 02:13:46 2004 +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 6F0AB32A3C1 + for ; + Tue, 12 Oct 2004 02:13:42 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33170-09 + for ; + Tue, 12 Oct 2004 01:13:37 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id E34AD32A2AE + for ; + Tue, 12 Oct 2004 02:13:38 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CHBEF-0004T2-00; Mon, 11 Oct 2004 21:13:27 -0400 +To: John Meinel +Cc: Francisco Reyes , + pgsql-performance@postgresql.org +Subject: Re: why my query is not using index?? +References: <41639F3C.4050103@siche.net> <200410111425.02671.vygen@gmx.de> + <20041011163756.M97379@zoraida.natserv.net> + <416B217D.9090000@johnmeinel.com> +In-Reply-To: <416B217D.9090000@johnmeinel.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 11 Oct 2004 21:13:27 -0400 +Message-ID: <87fz4k3fig.fsf@stark.xeocode.com> +Lines: 15 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/150 +X-Sequence-Number: 8626 + + +John Meinel writes: + +> As Janning mentioned, sometimes sequential scans *are* faster. If the number of +> entries that will be found is large compared to the number of total entries (I +> don't know the percentages, but probably >30-40%), + +Actually 30%-40% is unrealistic. The traditional rule of thumb for the +break-even point was 10%. In POstgres the actual percentage varies based on +how wide the records are and how correlated the location of the records is +with the index. Usually it's between 5%-10% but it can be even lower than that +sometimes. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Oct 12 02:48:52 2004 +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 AFC29329EAB + for ; + Tue, 12 Oct 2004 02:48:49 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39405-05 + for ; + Tue, 12 Oct 2004 01:48:37 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id D3905329E7E + for ; + Tue, 12 Oct 2004 02:48:40 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9C1maJ7042300 + for ; Tue, 12 Oct 2004 01:48:36 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9C1ZD83039309 + for pgsql-performance@postgresql.org; Tue, 12 Oct 2004 01:35:13 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: IBM P-series machines (was: Excessive context +Date: Mon, 11 Oct 2004 21:34:44 -0400 +Organization: cbbrowne Computing Inc +Lines: 55 +Message-ID: +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <20041011173819.GB22076@phlogiston.dyndns.org> + <1097518852.54644.20.camel@home> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:RQnEtCKDkofbB7SGiselPsJNRl8= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/151 +X-Sequence-Number: 8627 + +pg@rbt.ca (Rod Taylor) wrote: +> On Mon, 2004-10-11 at 13:38, Andrew Sullivan wrote: +>> On Tue, Oct 05, 2004 at 09:47:36AM -0700, Josh Berkus wrote: +>> > As long as you're on x86, scaling outward is the way to go. If +>> > you want to continue to scale upwards, ask Andrew Sullivan about +>> > his experiences running PostgreSQL on big IBM boxes. But if you +>> > consider an quad-Opteron server expensive, I don't think that's +>> > an option for you. +> +>> The 650s are not cheap, but boy are they fast. I don't have any +>> numbers I can share, but I can tell you that we recently had a few +>> days in which our write load was as large as the entire write load +>> for last year, and you couldn't tell. It is too early for us to +>> say whether the P series lives up to its billing in terms of +>> relibility: the real reason we use these machines is reliability, +>> so if approaching 100% uptime isn't important to you, the speed may +>> not be worth it. +> +> Agreed completely, and the 570 knocks the 650 out of the water -- +> nearly double the performance for math heavy queries. Beware vendor +> support for Linux on these things though -- we ran into many of the +> same issues with vendor support on the IBM machines as we did with +> the Opterons. + +The 650s are running AIX, not Linux. + +Based on the "Signal 11" issue, I'm not certain what would be the +'best' answer. It appears that the problem relates to proprietary +bits of AIX libc. In theory, that would have been more easily +resolvable with a source-available GLIBC. + +On the other hand, I'm not sure what happens to support for any of the +interesting hardware extensions. I'm not sure, for instance, that we +could run HACMP on Linux on this hardware. + +As for "vendor support" for Opteron, that sure looks like a +trainwreck... If you're going through IBM, then they won't want to +respond to any issues if you're not running a "bog-standard" RHAS/RHES +release from Red Hat. And that, on Opteron, is preposterous, because +there's plenty of the bits of Opteron support that only ever got put +in Linux 2.6, whilst RHAT is still back in the 2.4 days. + +In a way, that's just as well, at this point. There's plenty of stuff +surrounding this that is still pretty experimental; the longer RHAT +waits to support 2.6, the greater the likelihood that Linux support +for Opteron will have settled down to the point that the result will +actually be supportable by RHAT, and by proxy, by IBM and others. + +There is some risk that if RHAT waits _too_ long for 2.6, people will +have already jumped ship to SuSE. No benefits without risks... +-- +(reverse (concatenate 'string "gro.mca" "@" "enworbbc")) +http://www.ntlug.org/~cbbrowne/rdbms.html +If at first you don't succeed, then you didn't do it right! +If at first you don't succeed, then skydiving definitely isn't for you. + +From pgsql-performance-owner@postgresql.org Tue Oct 12 05:55:49 2004 +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 000D432A13F + for ; + Tue, 12 Oct 2004 05:55:46 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84330-06 + for ; + Tue, 12 Oct 2004 04:55:37 +0000 (GMT) +Received: from mail1.acecape.com (mail1.acecape.com [66.114.74.12]) + by svr1.postgresql.org (Postfix) with ESMTP id 510B332C241 + for ; + Tue, 12 Oct 2004 05:55:36 +0100 (BST) +Received: from p65-147.acedsl.com (p65-147.acedsl.com [66.114.65.147]) + by mail1.acecape.com (8.12.11/8.12.11) with ESMTP id i9C4tX7c016065; + Tue, 12 Oct 2004 00:55:33 -0400 +Date: Tue, 12 Oct 2004 00:56:15 -0400 (EDT) +From: Francisco Reyes +X-X-Sender: fran@zoraida.natserv.net +To: John Meinel +Cc: pgsql-performance@postgresql.org +Subject: Re: why my query is not using index?? +In-Reply-To: <416B217D.9090000@johnmeinel.com> +Message-ID: <20041012005231.U98867@zoraida.natserv.net> +References: <41639F3C.4050103@siche.net> <200410111425.02671.vygen@gmx.de> + <20041011163756.M97379@zoraida.natserv.net> + <416B217D.9090000@johnmeinel.com> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/153 +X-Sequence-Number: 8629 + +On Mon, 11 Oct 2004, John Meinel wrote: + +> Postgres believes that it will cost 382 to do a sequential scan, versus 490 +> for an indexed scan. Hence why it prefers to do the sequential scan. Try +> running explain analyze to see if how accurate it is. + +With explain analyze I have with sequential scan on +Sort (cost=382.01..382.15 rows=56 width=196) +(actual time=64.346..64.469 rows=24 loops=1) + + +And with seqscan off +Sort (cost=490.82..490.96 rows=56 width=196) +(actual time=56.668..56.789 rows=24 loops=1) + +So I guess that for this particular query I am better off setting the +seqscan off. + +From pgsql-performance-owner@postgresql.org Tue Oct 12 05:59:13 2004 +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 09B8632C2A7 + for ; + Tue, 12 Oct 2004 05:59:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87047-07 + for ; + Tue, 12 Oct 2004 04:59:02 +0000 (GMT) +Received: from mail1.acecape.com (mail1.acecape.com [66.114.74.12]) + by svr1.postgresql.org (Postfix) with ESMTP id D914532C2A6 + for ; + Tue, 12 Oct 2004 05:59:02 +0100 (BST) +Received: from p65-147.acedsl.com (p65-147.acedsl.com [66.114.65.147]) + by mail1.acecape.com (8.12.11/8.12.11) with ESMTP id i9C4wtJZ017053; + Tue, 12 Oct 2004 00:58:55 -0400 +Date: Tue, 12 Oct 2004 00:59:37 -0400 (EDT) +From: Francisco Reyes +X-X-Sender: fran@zoraida.natserv.net +To: Rosser Schwarz +Cc: PostgreSQL performance +Subject: Re: Understanding explains +In-Reply-To: <37d451f70410111503755fb751@mail.gmail.com> +Message-ID: <20041012005749.G98867@zoraida.natserv.net> +References: <20041011164950.J97379@zoraida.natserv.net> + <37d451f70410111503755fb751@mail.gmail.com> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/154 +X-Sequence-Number: 8630 + +On Mon, 11 Oct 2004, Rosser Schwarz wrote: + +> In general, it's best to let the planner make the appropriate choice +> without any artificial constraints. + +As someone suggested ran with Explain analyze. +With seqscan_off was better. +Ran a vacuum analyze this afternoon so the stats were up to date. +Although I will leave the setting as it's default for most of everything I +do, it seems that for some reason in this case it mases sense to turn it +off. + +From pgsql-performance-owner@postgresql.org Tue Oct 12 06:26:31 2004 +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 BE35F329F0D + for ; + Tue, 12 Oct 2004 06:26:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92567-06 + for ; + Tue, 12 Oct 2004 05:26:19 +0000 (GMT) +Received: from vsmtp4.tin.it (unknown [212.216.176.150]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CF2D329F33 + for ; + Tue, 12 Oct 2004 06:26:17 +0100 (BST) +Received: from angus.tin.it (82.53.64.64) by vsmtp4.tin.it (7.0.027) + id 41568C9D006D2FD9; Tue, 12 Oct 2004 07:26:09 +0200 +Message-Id: <6.1.2.0.2.20041012072112.01ed8810@box.tin.it> +X-Sender: angusgb@box.tin.it (Unverified) +X-Mailer: QUALCOMM Windows Eudora Version 6.1.2.0 +Date: Tue, 12 Oct 2004 07:26:12 +0200 +To: Tom Lane +From: Gabriele Bartolini +Subject: Re: Normal case or bad query plan? +Cc: pgsql-performance@postgresql.org +In-Reply-To: <23515.1097530437@sss.pgh.pa.us> +References: <6.1.2.0.2.20041011224414.01fadec0@box.tin.it> + <23515.1097530437@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: multipart/mixed; x-avg-checked=avg-ok-2C527FEE; + boundary="=======636B5308=======" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_RFCI +X-Spam-Level: +X-Archive-Number: 200410/155 +X-Sequence-Number: 8631 + +--=======636B5308======= +Content-Type: text/plain; x-avg-checked=avg-ok-2C527FEE; charset=us-ascii; + format=flowed +Content-Transfer-Encoding: 8bit + +Hi Tom, + + thanks for your interest. + +At 23.33 11/10/2004, Tom Lane wrote: + +>Gabriele Bartolini writes: +> > QUERY PLAN +> > +> --------------------------------------------------------------------------------------------------------------------- +> > Seq Scan on ip2location (cost=0.00..30490.65 rows=124781 width=8) +> > (actual time=5338.120..40237.283 rows=1 loops=1) +> > Filter: ((1040878301::bigint >= ip_address_from) AND +> > (1040878301::bigint <= ip_address_to)) +> > Total runtime: 40237.424 ms +> +> > Is this a normal case or should I worry? What am I missing? +> +>The striking thing about that is the huge difference between estimated +>rowcount (124781) and actual (1). The planner would certainly have +>picked an indexscan if it thought the query would select only one row. +> +>I suspect that you haven't ANALYZEd this table in a long time, if ever. +>You really need reasonably up-to-date ANALYZE stats if you want the +>planner to do an adequate job of planning range queries. + +That's the thing ... I had just peformed a VACUUM ANALYSE :-( + + +> It may well be that you need to increase the analyze statistics target +> for this table, +>also --- in BIGINT terms the distribution is probably pretty irregular, +>which will mean you need finer-grain statistics to get good estimates. + +You mean ... SET STATISTICS for the two columns, don't you? + +>(BTW, have you looked at the inet datatype to see if that would fit your +>needs?) + +Yes, I know. In other cases I use it. But this is a type of data coming +from an external source (www.ip2location.com) and I can't change it. + +Thank you so much. I will try to play with the grain of the statistics, +otherwise - if worse comes to worst - I will simply disable the seq scan +after connecting. + +-Gabriele +-- +Gabriele Bartolini: Web Programmer, ht://Dig & IWA/HWG Member, ht://Check +maintainer +Current Location: Prato, Toscana, Italia +angusgb@tin.it | http://www.prato.linux.it/~gbartolini | ICQ#129221447 + > "Leave every hope, ye who enter!", Dante Alighieri, Divine Comedy, The +Inferno + +--=======636B5308======= +Content-Type: text/plain; charset=us-ascii; x-avg=cert; + x-avg-checked=avg-ok-2C527FEE +Content-Disposition: inline + + +--- +Outgoing mail is certified Virus Free. +Checked by AVG anti-virus system (http://www.grisoft.com). +Version: 6.0.773 / Virus Database: 520 - Release Date: 05/10/2004 + +--=======636B5308=======-- + + +From pgsql-performance-owner@postgresql.org Tue Oct 12 06:27:09 2004 +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 9E03332AA03 + for ; + Tue, 12 Oct 2004 06:27:05 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93247-03 + for ; + Tue, 12 Oct 2004 05:26: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 98625329E25 + for ; + Tue, 12 Oct 2004 06:26:56 +0100 (BST) +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 i9C5QrYI028284; + Tue, 12 Oct 2004 01:26:53 -0400 (EDT) +To: Francisco Reyes +Cc: John Meinel , + pgsql-performance@postgresql.org +Subject: Re: why my query is not using index?? +In-reply-to: <20041012005231.U98867@zoraida.natserv.net> +References: <41639F3C.4050103@siche.net> <200410111425.02671.vygen@gmx.de> + <20041011163756.M97379@zoraida.natserv.net> + <416B217D.9090000@johnmeinel.com> + <20041012005231.U98867@zoraida.natserv.net> +Comments: In-reply-to Francisco Reyes + message dated "Tue, 12 Oct 2004 00:56:15 -0400" +Date: Tue, 12 Oct 2004 01:26:53 -0400 +Message-ID: <28283.1097558813@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/156 +X-Sequence-Number: 8632 + +Francisco Reyes writes: +> With explain analyze I have with sequential scan on +> Sort (cost=382.01..382.15 rows=56 width=196) +> (actual time=64.346..64.469 rows=24 loops=1) + +> And with seqscan off +> Sort (cost=490.82..490.96 rows=56 width=196) +> (actual time=56.668..56.789 rows=24 loops=1) + +> So I guess that for this particular query I am better off setting the +> seqscan off. + +For that kind of margin, you'd be a fool to do any such thing. + +You might want to look at making some adjustment to random_page_cost +to bring the estimated costs in line with reality (though I'd counsel +taking more than one example into account while you tweak it). But +setting seqscan off as a production setting is just a recipe for +shooting yourself in the foot. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 12 06:46:40 2004 +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 C5F3032BBEA + for ; + Tue, 12 Oct 2004 06:45:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98035-06 + for ; + Tue, 12 Oct 2004 05:45: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 E090932BB20 + for ; + Tue, 12 Oct 2004 06:45:16 +0100 (BST) +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 i9C5jFsq028412; + Tue, 12 Oct 2004 01:45:16 -0400 (EDT) +To: Gabriele Bartolini +Cc: pgsql-performance@postgresql.org +Subject: Re: Normal case or bad query plan? +In-reply-to: <6.1.2.0.2.20041012072112.01ed8810@box.tin.it> +References: <6.1.2.0.2.20041011224414.01fadec0@box.tin.it> + <23515.1097530437@sss.pgh.pa.us> + <6.1.2.0.2.20041012072112.01ed8810@box.tin.it> +Comments: In-reply-to Gabriele Bartolini + message dated "Tue, 12 Oct 2004 07:26:12 +0200" +Date: Tue, 12 Oct 2004 01:45:15 -0400 +Message-ID: <28411.1097559915@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/157 +X-Sequence-Number: 8633 + +Gabriele Bartolini writes: +> Seq Scan on ip2location (cost=0.00..30490.65 rows=124781 width=8) +> (actual time=5338.120..40237.283 rows=1 loops=1) +> Filter: ((1040878301::bigint >= ip_address_from) AND +> (1040878301::bigint <= ip_address_to)) +> Total runtime: 40237.424 ms +>> +>> I suspect that you haven't ANALYZEd this table in a long time, if ever. +>> You really need reasonably up-to-date ANALYZE stats if you want the +>> planner to do an adequate job of planning range queries. + +> That's the thing ... I had just peformed a VACUUM ANALYSE :-( + +In that case I think Kris Jurka had it right: the problem is the planner +doesn't know enough about the relationship of the ip_address_from and +ip_address_to columns to realize that this is a very selective query. +But actually, even *had* it realized that, it would have had little +choice but to use a seqscan, because neither of the independent +conditions is really very useful as an index condition by itself. + +Assuming that this problem is representative of your query load, you +really need to recast the data representation to make it more readily +searchable. I think you might be able to get somewhere by combining +ip_address_from and ip_address_to into a single CIDR column and then +using the network-overlap operator to probe for matches to your query +address. (This assumes that the from/to pairs are actually meant to +represent CIDR subnets; if not you need some other idea.) Another +possibility is to convert to a geometric type and use an rtree index +with an "overlaps" operator. I'm too tired to work out the details, +but try searching for "decorrelation" in the list archives to see some +related problems. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 12 07:53:20 2004 +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 3710532AC81 + for ; + Tue, 12 Oct 2004 07:53:15 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41694-03 + for ; + Tue, 12 Oct 2004 06:53:04 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id C30D932A590 + for ; + Tue, 12 Oct 2004 07:53:02 +0100 (BST) +Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk + [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP + id 4E504A384A; Tue, 12 Oct 2004 07:53:01 +0100 (BST) +Message-ID: <416B7F4C.5070600@ymogen.net> +Date: Tue, 12 Oct 2004 07:53:00 +0100 +From: Matt Clark +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: IBM P-series machines +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <20041011173819.GB22076@phlogiston.dyndns.org> + <1097518852.54644.20.camel@home> + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/158 +X-Sequence-Number: 8634 + + +>As for "vendor support" for Opteron, that sure looks like a +>trainwreck... If you're going through IBM, then they won't want to +>respond to any issues if you're not running a "bog-standard" RHAS/RHES +>release from Red Hat. And that, on Opteron, is preposterous, because +>there's plenty of the bits of Opteron support that only ever got put +>in Linux 2.6, whilst RHAT is still back in the 2.4 days. +> +> +> + +To be fair, they have backported a boatload of 2.6 features to their kernel: +http://www.redhat.com/software/rhel/kernel26/ + +And that page certainly isn't an exhaustive list... + +M + +From pgsql-performance-owner@postgresql.org Tue Oct 12 12:43:58 2004 +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 04BE8329E84 + for ; + Tue, 12 Oct 2004 12:43:54 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78033-05 + for ; + Tue, 12 Oct 2004 11:43:42 +0000 (GMT) +Received: from web54110.mail.yahoo.com (web54110.mail.yahoo.com + [206.190.37.245]) + by svr1.postgresql.org (Postfix) with SMTP id A7457329DB0 + for ; + Tue, 12 Oct 2004 12:43:43 +0100 (BST) +Message-ID: <20041012114343.69531.qmail@web54110.mail.yahoo.com> +Received: from [129.94.6.30] by web54110.mail.yahoo.com via HTTP; + Tue, 12 Oct 2004 04:43:43 PDT +Date: Tue, 12 Oct 2004 04:43:43 -0700 (PDT) +From: my ho +Subject: Re: execute cursor fetch +To: pgsql-performance@postgresql.org +In-Reply-To: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/159 +X-Sequence-Number: 8635 + +Hi, +If anyone can help pls, I have a question abt the +execution of cursor create/fetch/move , in particular +about disk cost. When a cursor is created, is the +whole table (with the required columns) got put into +memory? otherwise how does it work? (in term of disk +read and transfer?) after user issues command +move/fetch, how does postgre speed up the query in +compare to normal selection? +Thanks a lot, +regards, +MT Ho + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Mail Address AutoComplete - You start. We finish. +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Tue Oct 12 13:21:15 2004 +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 3453632A207 + for ; + Tue, 12 Oct 2004 13:21:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88801-06 + for ; + Tue, 12 Oct 2004 12:21:01 +0000 (GMT) +Received: from hotmail.com (bay18-dav8.bay18.hotmail.com [65.54.187.188]) + by svr1.postgresql.org (Postfix) with ESMTP id 91A2F32A1EB + for ; + Tue, 12 Oct 2004 13:21:00 +0100 (BST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 12 Oct 2004 05:21:00 -0700 +Received: from 67.81.98.198 by BAY18-DAV8.phx.gbl with DAV; + Tue, 12 Oct 2004 12:20:46 +0000 +X-Originating-IP: [67.81.98.198] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Kris Jurka" , + "Gabriele Bartolini" +Cc: +References: <6.1.2.0.2.20041011224414.01fadec0@box.tin.it> + +Subject: Re: Normal case or bad query plan? +Date: Tue, 12 Oct 2004 08:20:52 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Message-ID: +X-OriginalArrivalTime: 12 Oct 2004 12:21:00.0672 (UTC) + FILETIME=[EF4CE800:01C4B055] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/160 +X-Sequence-Number: 8636 + +Makes sense. See DB2 8.2 info on their new implementation of cross column +statistics. If this is common and you're willing to change code, you can +fake that by adding a operation index on some hash function of both columns, +and search for both columns and the hash. + +----- Original Message ----- +From: "Kris Jurka" +To: "Gabriele Bartolini" +Cc: +Sent: Monday, October 11, 2004 5:17 PM +Subject: Re: [PERFORM] Normal case or bad query plan? + + +> +> +> On Mon, 11 Oct 2004, Gabriele Bartolini wrote: +> +> +> -------------------------------------------------------------------------- +------------------------------------------- +> > Seq Scan on ip2location (cost=0.00..30490.65 rows=124781 width=8) +> > (actual time=5338.120..40237.283 rows=1 loops=1) +> > Filter: ((1040878301::bigint >= ip_address_from) AND +> > (1040878301::bigint <= ip_address_to)) +> > Total runtime: 40237.424 ms +> > +> +> I believe the problem is that pg's lack of cross-column statistics is +> producing the poor number of rows estimate. The number of rows mataching +> just the first 1040878301::bigint >= ip_address_from condition is 122774 +> which is roughtly 10% of the table. I imagine the query planner +> believes that the other condition alone will match the other 90% of the +> table. The problem is that it doesn't know that these two ranges' +> intersection is actually tiny. The planner assumes a complete or nearly +> complete overlap so it thinks it will need to fetch 10% of the rows from +> both the index and the heap and chooses a seqscan. +> +> Kris Jurka +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> + +From pgsql-performance-owner@postgresql.org Tue Oct 12 13:36:25 2004 +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 8828532A7BC + for ; + Tue, 12 Oct 2004 13:36:19 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91533-08 + for ; + Tue, 12 Oct 2004 12:36:10 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 22A8732A486 + for ; + Tue, 12 Oct 2004 13:36:10 +0100 (BST) +Received: (qmail 12858 invoked from network); 12 Oct 2004 14:36:10 +0200 +Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 12 Oct 2004 14:36:10 +0200 +To: "my ho" , pgsql-performance@postgresql.org +Subject: Re: execute cursor fetch +References: <20041012114343.69531.qmail@web54110.mail.yahoo.com> +Message-ID: +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: Tue, 12 Oct 2004 14:36:10 +0200 +In-Reply-To: <20041012114343.69531.qmail@web54110.mail.yahoo.com> +User-Agent: Opera M2/7.54 (Linux, build 751) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/161 +X-Sequence-Number: 8637 + + + I just discovered this : + +http://www.postgresql.org/docs/7.4/static/jdbc-query.html#AEN24298 + + +On Tue, 12 Oct 2004 04:43:43 -0700 (PDT), my ho +wrote: + +> Hi, +> If anyone can help pls, I have a question abt the +> execution of cursor create/fetch/move , in particular +> about disk cost. When a cursor is created, is the +> whole table (with the required columns) got put into +> memory? otherwise how does it work? (in term of disk +> read and transfer?) after user issues command +> move/fetch, how does postgre speed up the query in +> compare to normal selection? +> Thanks a lot, +> regards, +> MT Ho +> +> +> +> +> __________________________________ +> Do you Yahoo!? +> Yahoo! Mail Address AutoComplete - You start. We finish. +> http://promotions.yahoo.com/new_mail +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> + + + +From pgsql-performance-owner@postgresql.org Tue Oct 12 14:05:52 2004 +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 8D64F329CFB + for ; + Tue, 12 Oct 2004 14:05:49 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00356-09 + for ; + Tue, 12 Oct 2004 13:05:37 +0000 (GMT) +Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CED4C32A92B + for ; + Tue, 12 Oct 2004 14:05:36 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 4F52D2BD73 + for ; + Tue, 12 Oct 2004 15:05:22 +0200 (SAST) +Received: from ucsns.ucs.co.za ([127.0.0.1]) + by localhost (ucsns.ucs.co.za [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 01807-04 for ; + Tue, 12 Oct 2004 15:05:12 +0200 (SAST) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 1E4C62BD72 + for ; + Tue, 12 Oct 2004 15:05:12 +0200 (SAST) +Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) + by ucspost.ucs.co.za (Postfix) with ESMTP id 6BD65DA1A6 + for ; + Tue, 12 Oct 2004 15:05:14 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with SMTP id 6302497A48 + for ; + Tue, 12 Oct 2004 15:05:15 +0200 (SAST) +Date: Tue, 12 Oct 2004 15:05:15 +0200 +From: Stef +To: pgsql-performance@postgresql.org +Subject: Re: execute cursor fetch +Message-ID: <20041012150515.167c5e5e@svb.ucs.co.za> +In-Reply-To: +References: <20041012114343.69531.qmail@web54110.mail.yahoo.com> + +X-Mailer: Sylpheed-Claws 0.9.12b (GTK+ 1.2.10; i386-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: GFoC95e6r)_TTG>n~=uFLojP=O~4W@Ms]>:.DMm/')(z3\Mwj^XP@? + Q:3";lD.OM1"^mDu}2NJ@US:)dO:U*iY5EM50&Tx. +X-Operating-System: sid +X-X-X: _-^-_ +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at ucs.co.za +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/162 +X-Sequence-Number: 8638 + +Pierre-Fr=E9d=E9ric Caillaud mentioned : +=3D> http://www.postgresql.org/docs/7.4/static/jdbc-query.html#AEN24298 + +My question is : +Is this only true for postgres versions >=3D 7.4 ? + +I see the same section about "Setting fetch size to turn cursors on and off" +is not in the postgres 7.3.7 docs. Does this mean 7.3 the JDBC driver +for postgres < 7.4 doesn't support this ? + +Kind Regards +Stefan + +From pgsql-performance-owner@postgresql.org Tue Oct 12 15:08:07 2004 +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 C529A32B1AB + for ; + Tue, 12 Oct 2004 15:08:05 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26915-02 + for ; + Tue, 12 Oct 2004 14:07: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 964C132B19A + for ; + Tue, 12 Oct 2004 15:07:56 +0100 (BST) +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 i9CE7vuv001857; + Tue, 12 Oct 2004 10:07:57 -0400 (EDT) +To: my ho +Cc: pgsql-performance@postgresql.org +Subject: Re: execute cursor fetch +In-reply-to: <20041012114343.69531.qmail@web54110.mail.yahoo.com> +References: <20041012114343.69531.qmail@web54110.mail.yahoo.com> +Comments: In-reply-to my ho + message dated "Tue, 12 Oct 2004 04:43:43 -0700" +Date: Tue, 12 Oct 2004 10:07:56 -0400 +Message-ID: <1856.1097590076@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/163 +X-Sequence-Number: 8639 + +my ho writes: +> If anyone can help pls, I have a question abt the +> execution of cursor create/fetch/move , in particular +> about disk cost. When a cursor is created, is the +> whole table (with the required columns) got put into +> memory? + +No. The plan is set up and then incrementally executed each time you +say FETCH. + +> how does postgre speed up the query in +> compare to normal selection? + +The only difference from a SELECT is that the planner will prefer +"fast-start" plans, on the theory that you may not be intending +to retrieve the whole result. For instance it might prefer an +indexscan to a seqscan + sort, when it otherwise wouldn't. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 12 15:29:47 2004 +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 A52A532A1BB + for ; + Tue, 12 Oct 2004 15:29:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35685-01 + for ; + Tue, 12 Oct 2004 14:29:39 +0000 (GMT) +Received: from vsmtp4.tin.it (unknown [212.216.176.150]) + by svr1.postgresql.org (Postfix) with ESMTP id E6A1732A0AC + for ; + Tue, 12 Oct 2004 15:29:42 +0100 (BST) +Received: from ims3d.cp.tin.it (192.168.70.103) by vsmtp4.tin.it (7.0.027) + id 41568C9D00709332; Tue, 12 Oct 2004 16:29:42 +0200 +Received: from [192.168.70.227] by ims3d.cp.tin.it with HTTP; + Tue, 12 Oct 2004 16:29:36 +0200 +Date: Tue, 12 Oct 2004 16:29:36 +0200 +Message-ID: <41536BE0000113F4@ims3d.cp.tin.it> +In-Reply-To: +From: "Gabriele Bartolini" +Subject: Re: Normal case or bad query plan? +To: "Kris Jurka" +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset="ISO-8859-15" +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/164 +X-Sequence-Number: 8640 + +Hi Kris, + +>I believe the problem is that pg's lack of cross-column statistics is +>producing the poor number of rows estimate. The number of rows mataching + +I got your point now. I had not understood it last night but it makes really +sense. + +>which is roughtly 10% of the table. I imagine the query planner +>believes that the other condition alone will match the other 90% of the + +>table. The problem is that it doesn't know that these two ranges' +>intersection is actually tiny. The planner assumes a complete or nearly +>complete overlap so it thinks it will need to fetch 10% of the rows from + +Yep, because it performs those checks separately and it gets 10% for one +check and 90% for the other. + +As Tom says, I should somehow make PostgreSQL see my data as a single entity +in order to perform a real range check. I will study some way to obtain +it. + +However, I got better results by specifying the grane of the statistics +through "ALTER TABLE ... SET STATISTICS". + +FYI I set it to 1000 (the maximum) and I reduced the query's estimated time +by the 90% (from 40000ms to 4000ms) although much slower than the index +scan (200ms). + +I will play a bit with data types as Tom suggested. + +For now, thanks anyone who tried and helped me. + +Ciao, +-Gabriele + + +From pgsql-performance-owner@postgresql.org Tue Oct 12 15:41:12 2004 +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 367AD32BD1F + for ; + Tue, 12 Oct 2004 15:41:09 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40863-01 + for ; + Tue, 12 Oct 2004 14:40:55 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id A849832B1DF + for ; + Tue, 12 Oct 2004 15:40:56 +0100 (BST) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1CHNpe-00027y-00 + for ; Tue, 12 Oct 2004 16:40:54 +0200 +Date: Tue, 12 Oct 2004 16:40:54 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Normal case or bad query plan? +Message-ID: <20041012144054.GA8166@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <41536BE0000113F4@ims3d.cp.tin.it> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <41536BE0000113F4@ims3d.cp.tin.it> +X-Operating-System: Linux 2.6.6 on a i686 +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/165 +X-Sequence-Number: 8641 + +On Tue, Oct 12, 2004 at 04:29:36PM +0200, Gabriele Bartolini wrote: +> FYI I set it to 1000 (the maximum) and I reduced the query's estimated time +> by the 90% (from 40000ms to 4000ms) although much slower than the index +> scan (200ms). + +Note that the estimated times are _not_ in ms. They are in multiples of a +disk fetch (?). Thus, you can't compare estimated and real times like that. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Tue Oct 12 16:26:06 2004 +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 1B3C332A026 + for ; + Tue, 12 Oct 2004 16:26:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58295-02 + for ; + Tue, 12 Oct 2004 15:25:59 +0000 (GMT) +Received: from heimdall.hig.se (heimdall.hig.se [130.243.8.180]) + by svr1.postgresql.org (Postfix) with SMTP id CB282329F96 + for ; + Tue, 12 Oct 2004 16:25:57 +0100 (BST) +Received: from webmail.student.hig.se ([130.243.8.161]) + by heimdall.hig.se (SAVSMTP 3.1.0.29) with SMTP id M2004101217220519020 + for ; Tue, 12 Oct 2004 17:22:05 +0200 +Received: from 130.243.14.147 (SquirrelMail authenticated user nd02tsk); + by webmail.student.hig.se with HTTP; + Tue, 12 Oct 2004 17:45:01 +0200 (CEST) +Message-ID: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> +Date: Tue, 12 Oct 2004 17:45:01 +0200 (CEST) +Subject: Which plattform do you recommend I run PostgreSQL for best + performance? +From: nd02tsk@student.hig.se +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.3 +X-Mailer: SquirrelMail/1.4.3 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 (Normal) +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200410/166 +X-Sequence-Number: 8642 + +Hello + +I am doing a comparison between MySQL and PostgreSQL. + +In the MySQL manual it says that MySQL performs best with Linux 2.4 with +ReiserFS on x86. Can anyone official, or in the know, give similar +information regarding PostgreSQL? + +Also, any links to benchmarking tests available on the internet between +MySQL and PostgreSQL would be appreciated. + +Thank you! + +Tim + + + +From pgsql-performance-owner@postgresql.org Tue Oct 12 16:47:51 2004 +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 2AF9132BFBC + for ; + Tue, 12 Oct 2004 16:47:46 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66459-02 + for ; + Tue, 12 Oct 2004 15:47:36 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id E208632BF28 + for ; + Tue, 12 Oct 2004 16:47:36 +0100 (BST) +Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk + [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP + id 7BA21A2CAE; Tue, 12 Oct 2004 16:47:34 +0100 (BST) +Message-ID: <416BFC96.9070506@ymogen.net> +Date: Tue, 12 Oct 2004 16:47:34 +0100 +From: Matt Clark +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: nd02tsk@student.hig.se +Cc: pgsql-performance@postgresql.org +Subject: Re: Which plattform do you recommend I run PostgreSQL for +References: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> +In-Reply-To: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> +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.0 tagged_above=0.0 required=5.0 tests=SUBJ_HAS_SPACES +X-Spam-Level: +X-Archive-Number: 200410/167 +X-Sequence-Number: 8643 + + +>In the MySQL manual it says that MySQL performs best with Linux 2.4 with +>ReiserFS on x86. Can anyone official, or in the know, give similar +>information regarding PostgreSQL? +> +> +I'm neither official, nor in the know, but I do have a spare moment! I +can tell you that any *NIX variant on any modern hardware platform will +give you good performance, except for Cygwin/x86. Any differences +between OSes on the same hardware are completely swamped by far more +direct concerns like IO systems, database design, OS tuning etc. Pick +the OS you're most familiar with is usually a good recommendation (and +not just for Postgres). + +From pgsql-performance-owner@postgresql.org Tue Oct 12 17:26:36 2004 +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 62F7832A35C + for ; + Tue, 12 Oct 2004 17:26:33 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80025-09 + for ; + Tue, 12 Oct 2004 16:26:31 +0000 (GMT) +Received: from mail1.acecape.com (mail1.acecape.com [66.114.74.12]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C87E32A2FA + for ; + Tue, 12 Oct 2004 17:26:30 +0100 (BST) +Received: from p65-147.acedsl.com (p65-147.acedsl.com [66.114.65.147]) + by mail1.acecape.com (8.12.11/8.12.11) with ESMTP id i9CGQSeV026344; + Tue, 12 Oct 2004 12:26:29 -0400 +Date: Tue, 12 Oct 2004 12:27:14 -0400 (EDT) +From: Francisco Reyes +X-X-Sender: fran@zoraida.natserv.net +To: nd02tsk@student.hig.se +Cc: pgsql-performance@postgresql.org +Subject: Re: Which plattform do you recommend I run PostgreSQL for +In-Reply-To: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> +Message-ID: <20041012121734.Q4531@zoraida.natserv.net> +References: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.0 tagged_above=0.0 required=5.0 tests=SUBJ_HAS_SPACES +X-Spam-Level: +X-Archive-Number: 200410/168 +X-Sequence-Number: 8644 + +On Tue, 12 Oct 2004 nd02tsk@student.hig.se wrote: + +> In the MySQL manual it says that MySQL performs best with Linux 2.4 with +> ReiserFS on x86. Can anyone official, or in the know, give similar +> information regarding PostgreSQL? + +Don't know which OS/filesystem PostgreSQL runs best on, but you should +test on whatever OS and filesystem you are most experienced. + +Whatever speed gain you may get from "best setups" will mean little if +the machine crashes and you don't know how to fix it and get it back +up quickly. + +From pgsql-performance-owner@postgresql.org Tue Oct 19 22:03:21 2004 +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 E418332C33E + for ; + Tue, 12 Oct 2004 18:21:50 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19589-03 + for ; + Tue, 12 Oct 2004 17:21:42 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D24B32CA51 + for ; + Tue, 12 Oct 2004 18:18:49 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9CHImJ7017315 + for ; Tue, 12 Oct 2004 17:18:48 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9CGurEp096229 + for pgsql-performance@postgresql.org; Tue, 12 Oct 2004 16:56:53 GMT +From: Mischa Sandberg +Reply-To: ischamay.andbergsay@activestateway.com +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Normal case or bad query plan? +References: <6.1.2.0.2.20041011224414.01fadec0@box.tin.it> +In-Reply-To: <6.1.2.0.2.20041011224414.01fadec0@box.tin.it> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 129 +Message-ID: +Date: Tue, 12 Oct 2004 16:56:53 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200410/286 +X-Sequence-Number: 8762 + +This may sound more elaborate than it's worth, but I don't know of +a better way to avoid a table scan. + +You want to index on a computed value that is a common prefix of your +FROM and TO fields. + +The next step is to search on a fixed SET of prefixes of different +lengths. For example, some of your ranges might be common in the first 3 +bytes of ipaddr, some in two, some in only one. + +You create and index on one common prefix of either 1,2 or 3 bytes, for +each row. + +Your query then looks something like (pardon my ignorance in PGSQL) + + select * + from ip2location + where ip2prefix in ( + network(:myaddr || '/8'), + network(:myaddr || '/16'), + network(:myaddr || '/24'), + :myaddr --- assuming single-address ranges are possible + ) + and :myaddr between ip_address_from and ip_address_to + +Although this looks a little gross, it hits very few records. +It also adapts cleanly to a join between ip2location and a table of +ip addrs. + +Gabriele Bartolini wrote: +> Hi guys, +> +> please consider this scenario. I have this table: +> +> CREATE TABLE ip2location ( +> ip_address_from BIGINT NOT NULL, +> ip_address_to BIGINT NOT NULL, +> id_location BIGINT NOT NULL, +> PRIMARY KEY (ip_address_from, ip_address_to) +> ); +> +> I created a cluster on its primary key, by running: +> CLUSTER ip2location_ip_address_from_key ON ip2location; +> +> This allowed me to organise data in a more efficient way: the data that +> is contained are ranges of IP addresses with empty intersections; for +> every IP class there is a related location's ID. The total number of +> entries is 1392443. +> +> For every IP address I have, an application retrieves the corresponding +> location's id from the above table, by running a query like: +> +> SELECT id_location FROM ip2location WHERE '11020000111' >= +> ip_address_from AND '11020000111' <= ip_address_to; +> +> For instance, by running the 'EXPLAIN ANALYSE' command, I get this +> "funny" result: +> +> +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------- +> +> Seq Scan on ip2location (cost=0.00..30490.65 rows=124781 width=8) +> (actual time=5338.120..40237.283 rows=1 loops=1) +> Filter: ((1040878301::bigint >= ip_address_from) AND +> (1040878301::bigint <= ip_address_to)) +> Total runtime: 40237.424 ms +> +> +> With other data, that returns an empty set, I get: +> +> explain SELECT id_location FROM ip2location WHERE '11020000111' >= +> ip_address_from AND '11020000111' <= ip_address_to; +> +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------- +> +> Index Scan using ip2location_ip_address_from_key on ip2location +> (cost=0.00..419.16 rows=140 width=8) +> Index Cond: ((11020000111::bigint >= ip_address_from) AND +> (11020000111::bigint <= ip_address_to)) +> +> +> I guess the planner chooses the best of the available options for the +> first case, the sequential scan. This is not confirmed though by the +> fact that, after I ran "SET enable_scan TO off", I got this: +> +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------------------------------ +> +> Index Scan using ip2location_ip_address_from_key on ip2location +> (cost=0.00..31505.73 rows=124781 width=8) (actual +> time=2780.172..2780.185 rows=1 loops=1) +> Index Cond: ((1040878301::bigint >= ip_address_from) AND +> (1040878301::bigint <= ip_address_to)) +> Total runtime: 2780.359 ms +> +> +> Is this a normal case or should I worry? What am I missing? Do you have +> any suggestion or comment to do (that would be extremely appreciated)? +> Is the CLUSTER I created worthwhile or not? +> +> Thank you, +> -Gabriele +> +> -- +> Gabriele Bartolini: Web Programmer, ht://Dig & IWA/HWG Member, +> ht://Check maintainer +> Current Location: Prato, Toscana, Italia +> angusgb@tin.it | http://www.prato.linux.it/~gbartolini | ICQ#129221447 +> > "Leave every hope, ye who enter!", Dante Alighieri, Divine Comedy, +> The Inferno +> +> +> ------------------------------------------------------------------------ +> +> +> --- +> Outgoing mail is certified Virus Free. +> Checked by AVG anti-virus system (http://www.grisoft.com). +> Version: 6.0.773 / Virus Database: 520 - Release Date: 05/10/2004 +> +> +> ------------------------------------------------------------------------ +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + +From pgsql-performance-owner@postgresql.org Tue Oct 12 22:18:57 2004 +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 6311332ACB7 + for ; + Tue, 12 Oct 2004 22:18:54 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28987-05 + for ; + Tue, 12 Oct 2004 21:18:50 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id EEE64329EEB + for ; + Tue, 12 Oct 2004 22:18:51 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9CLImJ7029941 + for ; Tue, 12 Oct 2004 21:18:48 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9CKo2Bk019231 + for pgsql-performance@postgresql.org; Tue, 12 Oct 2004 20:50:02 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Which plattform do you recommend I run PostgreSQL for best + performance? +Date: Tue, 12 Oct 2004 16:02:53 -0400 +Organization: cbbrowne Computing Inc +Lines: 44 +Message-ID: +References: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:nlmAziT7r6hsj/8FJNbIoHTLWJw= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/170 +X-Sequence-Number: 8646 + +In an attempt to throw the authorities off his trail, nd02tsk@student.hig.se transmitted: +> I am doing a comparison between MySQL and PostgreSQL. +> +> In the MySQL manual it says that MySQL performs best with Linux 2.4 with +> ReiserFS on x86. Can anyone official, or in the know, give similar +> information regarding PostgreSQL? + +The fastest I have ever seen PostgreSQL run is on an IBM pSeries 650 +system using AIX 5.1 and JFS2. There aren't many Linux systems that +are anywhere _near_ as fast as that. + +There's some indication that FreeBSD 4.9, running the Berkeley FFS +filesystem might be the quickest way of utilizing pedestrian IA-32 +hardware, although it is _much_ more important to have a system for +which you have a competent sysadmin than it is to have some +"tweaked-out" OS configuration. + +In practice, competent people generally prefer to have systems that +hum along nicely as opposed to systems that have ben "tweaked out" +such that any little change will cause them to cave in. + +Benchmarks are useful in determining: + + a) Whether or not it is realistic to attempt a project, and + + b) Whether or not you have made conspicuous errors in configuring + your systems. + +They are notoriously BAD as predictive tools, as the benchmarks +sponsored by vendors get tweaked to make the vendors' products look +good, as opposed to being written to be useful for prediction. + +See if you see anything useful from MySQL in this regard: + + +> Also, any links to benchmarking tests available on the internet +> between MySQL and PostgreSQL would be appreciated. + +Most database vendors have licenses that specifically forbid +publishing benchmarks. +-- +(reverse (concatenate 'string "gro.mca" "@" "enworbbc")) +http://www3.sympatico.ca/cbbrowne/oses.html +Do you know where your towel is? + +From pgsql-performance-owner@postgresql.org Tue Oct 12 21:30:31 2004 +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 31BDF32A611 + for ; + Tue, 12 Oct 2004 21:30:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12497-01 + for ; + Tue, 12 Oct 2004 20:30:27 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id AC2C632A526 + for ; + Tue, 12 Oct 2004 21:30:28 +0100 (BST) +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 6495340; Tue, 12 Oct 2004 13:31:52 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Which plattform do you recommend I run PostgreSQL for best + performance? +Date: Tue, 12 Oct 2004 13:32:13 -0700 +User-Agent: KMail/1.6.2 +Cc: nd02tsk@student.hig.se +References: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> +In-Reply-To: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410121332.13849.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/169 +X-Sequence-Number: 8645 + +Tim, + +> In the MySQL manual it says that MySQL performs best with Linux 2.4 with +> ReiserFS on x86. Can anyone official, or in the know, give similar +> information regarding PostgreSQL? + +PostgreSQL runs on a lot more platforms than MySQL; it's not even reasonable +to compare some of them, like rtLinux, AIX or Cygwin. The only reasonable +comparative testing that's been done seems to indicate that: +Linux 2.6 is more efficient than FreeBSD which is more efficient than Linux +2.4 all of which are significantly more efficient than Solaris, and +ReiserFS, XFS and JFS *seem* to outperform other Linux journalling FSes. + +However, as others have said, configuration and hardware will probably make +more difference than your choice of OS except in extreme cases. And all of +the above is being further tested, particularly the filesystems. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Oct 13 02:03:28 2004 +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 62FF532B684 + for ; + Wed, 13 Oct 2004 02:03:26 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84099-05 + for ; + Wed, 13 Oct 2004 01:03:18 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id E678632B4B6 + for ; + Wed, 13 Oct 2004 02:03:20 +0100 (BST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i9D12vN08023; + Tue, 12 Oct 2004 21:02:57 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200410130102.i9D12vN08023@candle.pha.pa.us> +Subject: Re: Caching of Queries +In-Reply-To: <20041007.161842.77062117.t-ishii@sra.co.jp> +To: Tatsuo Ishii +Date: Tue, 12 Oct 2004 21:02:57 -0400 (EDT) +Cc: tgl@sss.pgh.pa.us, matt@ymogen.net, pg@rbt.ca, + awerman2@hotmail.com, scottakirkwood@gmail.com, + pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/171 +X-Sequence-Number: 8647 + + +Added to TODO: + +* Add RESET CONNECTION command to reset all session state + + This would include resetting of all variables (RESET ALL), dropping of + all temporary tables, removal of any NOTIFYs, etc. This could be used + for connection pooling. We could also change RESET ALL to have this + functionality. + + +--------------------------------------------------------------------------- + +Tatsuo Ishii wrote: +> > Tatsuo Ishii writes: +> > > First, it's not a particular problem with pgpool. As far as I know any +> > > connection pool solution has exactly the same problem. Second, it's +> > > easy to fix if PostgreSQL provides a functionarity such as:"drop all +> > > temporary tables if any". +> > +> > I don't like that definition exactly --- it would mean that every time +> > we add more backend-local state, we expect client drivers to know to +> > issue the right incantation to reset that kind of state. +> > +> > I'm thinking we need to invent a command like "RESET CONNECTION" that +> > resets GUC variables, drops temp tables, forgets active NOTIFYs, and +> > generally does whatever else needs to be done to make the session state +> > appear virgin. When we add more such state, we can fix it inside the +> > backend without bothering clients. +> +> Great. It's much better than I propose. +> +> > I now realize that our "RESET ALL" command for GUC variables was not +> > fully thought out. We could possibly redefine it as doing the above, +> > but that might break some applications ... +> > +> > regards, tom lane +> > +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Tue Oct 19 22:03:32 2004 +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 3AC4F329FC6 + for ; + Wed, 13 Oct 2004 09:49:02 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94681-09 + for ; + Wed, 13 Oct 2004 08:48:57 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id EA60032A2BC + for ; + Wed, 13 Oct 2004 09:48:58 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9D8mtJ7097029 + for ; Wed, 13 Oct 2004 08:48:55 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9D8kxi8096514 + for pgsql-performance@postgresql.org; Wed, 13 Oct 2004 08:46:59 GMT +From: CoL +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Which plattform do you recommend I run PostgreSQL for best +Date: Wed, 13 Oct 2004 10:46:59 +0200 +Organization: Hub.Org Networking Services +Lines: 20 +Message-ID: +References: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Thunderbird CoL +X-Accept-Language: en-us, en +In-Reply-To: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/287 +X-Sequence-Number: 8763 + +hi, + +nd02tsk@student.hig.se wrote: +> Hello +> +> I am doing a comparison between MySQL and PostgreSQL. +> +> In the MySQL manual it says that MySQL performs best with Linux 2.4 with +> ReiserFS on x86. Can anyone official, or in the know, give similar +> information regarding PostgreSQL? +> +> Also, any links to benchmarking tests available on the internet between +> MySQL and PostgreSQL would be appreciated. + +http://www.potentialtech.com/wmoran/postgresql.php +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html +http://candle.pha.pa.us/main/writings/pgsql/hw_performance/ +http://database.sarang.net/database/postgres/optimizing_postgresql.html + +C. + +From pgsql-performance-owner@postgresql.org Wed Oct 13 10:14:30 2004 +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 6549D32C61D + for ; + Wed, 13 Oct 2004 10:14:27 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02925-05 + for ; + Wed, 13 Oct 2004 09:14:20 +0000 (GMT) +Received: from zaphod.profecta.se (zaphod.profecta.se [193.235.206.49]) + by svr1.postgresql.org (Postfix) with ESMTP id DD92232C609 + for ; + Wed, 13 Oct 2004 10:14:20 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by zaphod.profecta.se (Postfix) with ESMTP id 9D0241140 + for ; + Wed, 13 Oct 2004 11:14:13 +0200 (CEST) +Received: from [192.168.128.80] (ip050.noname4us.com [212.247.87.50]) + by zaphod.profecta.se (Postfix) with ESMTP id 310A91124 + for ; + Wed, 13 Oct 2004 11:14:13 +0200 (CEST) +Subject: query problem +From: Robin Ericsson +To: pgsql-performance@postgresql.org +Content-Type: multipart/mixed; boundary="=-o5nK7lU1Fuj/F/D20jNX" +Organization: Profecta HB +Date: Wed, 13 Oct 2004 11:21:11 +0200 +Message-Id: <1097659271.24018.68.camel@pylver.localhost.nu.> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/172 +X-Sequence-Number: 8648 + +--=-o5nK7lU1Fuj/F/D20jNX +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +Hi, + +I sent this to general earlier but I was redirected to performance. + +The query have been running ok for quite some time, but after I did a +vacuum on the database, it's very very slow. This IN-query is only 2 +ids. Before the problem that in was a subselect-query returning around +6-7 ids. The tables included in the query are described in database.txt. + +status=# select count(id) from data; + count +--------- + 1577621 +(1 row) + +status=# select count(data_id) from data_values; + count +--------- + 9680931 +(1 row) + +I did run a new explain analyze on the query and found the attached +result. The obvious problem I see is a full index scan in +"idx_dv_data_id". I tried dropping and adding the index again, thats why +is't called "idx_data_values_data_id" in the dump. + +status=# EXPLAIN ANALYZE +status-# SELECT +status-# data.entered, +status-# data.machine_id, +status-# datatemplate_intervals.template_id, +status-# data_values.value +status-# FROM +status-# data, data_values, datatemplate_intervals +status-# WHERE +status-# datatemplate_intervals.id = data_values.template_id AND +status-# data_values.data_id = data.id AND +status-# data.machine_id IN (2,3) AND +status-# current_timestamp::timestamp - interval '60 seconds' < +data.entered; + + + +Regards, +Robin + + +-- +Robin Ericsson +Profecta HB + +--=-o5nK7lU1Fuj/F/D20jNX +Content-Disposition: attachment; filename=explain2.txt +Content-Type: text/plain; name=explain2.txt; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + Hash Join (cost=28646.01..274260.15 rows=555706 width=24) (actual time=102323.087..102323.196 rows=5 loops=1) + Hash Cond: ("outer".template_id = "inner".id) + -> Merge Join (cost=28644.09..265922.62 rows=555706 width=24) (actual time=102322.632..102322.709 rows=5 loops=1) + Merge Cond: ("outer".data_id = "inner".id) + -> Index Scan using idx_dv_data_id on data_values (cost=0.00..205034.19 rows=9580032 width=16) (actual time=17.503..86263.130 +rows=9596747 loops=1) + -> Sort (cost=28644.09..28870.83 rows=90697 width=16) (actual time=0.829..0.835 rows=1 loops=1) + Sort Key: data.id + -> Index Scan using idx_d_entered on data (cost=0.00..20202.81 rows=90697 width=16) (actual time=0.146..0.185 rows=1 loops=1) + Index Cond: (((('now'::text)::timestamp(6) with time zone)::timestamp without time zone - '00:01:00'::interval) < entered) + Filter: ((machine_id = 2) OR (machine_id = 3)) + -> Hash (cost=1.74..1.74 rows=74 width=8) (actual time=0.382..0.382 rows=0 loops=1) + -> Seq Scan on datatemplate_intervals (cost=0.00..1.74 rows=74 width=8) (actual time=0.024..0.250 rows=74 loops=1) + Total runtime: 102323.491 ms +(13 rows) + + +--=-o5nK7lU1Fuj/F/D20jNX +Content-Disposition: attachment; filename=database.txt +Content-Type: text/plain; name=database.txt; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + +status=# \d data + Table "public.data" + Column | Type | Modifiers +------------+-----------------------------+-------------------------------------------- + id | integer | not null default nextval('data_seq'::text) + updated | timestamp without time zone | + entered | timestamp without time zone | + machine_id | integer | + datas | character varying(512)[] | +Indexes: + "data_pkey" primary key, btree (id) + "idx_d_entered" btree (entered) + "idx_d_machine_id" btree (machine_id) +Foreign-key constraints: + "machine_id" FOREIGN KEY (machine_id) REFERENCES machines(id) +Triggers: + data_datestamp BEFORE INSERT OR UPDATE ON data FOR EACH ROW EXECUTE PROCEDURE datestamp_e() + +status=# \d data_values + Table "public.data_values" + Column | Type | Modifiers +-------------+-----------------------------+----------- + updated | timestamp without time zone | + entered | timestamp without time zone | + data_id | integer | + template_id | integer | + value | character varying(512) | +Indexes: + "idx_data_values_data_id" btree (data_id) + "idx_dv_template_id" btree (template_id) +Foreign-key constraints: + "data_id" FOREIGN KEY (data_id) REFERENCES data(id) + "template_id" FOREIGN KEY (template_id) REFERENCES datatemplate_intervals(id) +Triggers: + data_values_datestamp BEFORE INSERT OR UPDATE ON data_values FOR EACH ROW EXECUTE PROCEDURE +datestamp_e() + +status=# \d datatemplate_intervals + Table "public.datatemplate_intervals" + Column | Type | Modifiers +-------------+-----------------------------+-------------------------------------------------------------- + id | integer | not null default +nextval('datatemplate_intervals_seq'::text) + updated | timestamp without time zone | + entered | timestamp without time zone | + machine_id | integer | + template_id | integer | + interval | integer | +Indexes: + "datatemplate_intervals_pkey" primary key, btree (id) + "idx_di_machine_id" btree (machine_id) + "idx_di_template_id" btree (template_id) +Foreign-key constraints: + "machine_id" FOREIGN KEY (machine_id) REFERENCES machines(id) + "template_id" FOREIGN KEY (template_id) REFERENCES datatemplates(id) +Triggers: + datatemplate_intervals_datestamp BEFORE INSERT OR UPDATE ON datatemplate_intervals FOR EACH +ROW EXECUTE PROCEDURE datestamp_e() + + +--=-o5nK7lU1Fuj/F/D20jNX-- + + +From pgsql-performance-owner@postgresql.org Wed Oct 13 15:38:02 2004 +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 CDF5A32B4DE + for ; + Wed, 13 Oct 2004 15:38:00 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08358-05 + for ; + Wed, 13 Oct 2004 14:37:46 +0000 (GMT) +Received: from server272.com (server272.com [64.14.68.49]) + by svr1.postgresql.org (Postfix) with SMTP id 51FCB32B922 + for ; + Wed, 13 Oct 2004 15:37:49 +0100 (BST) +Received: (qmail 14280 invoked from network); 13 Oct 2004 14:38:08 -0000 +Received: from unknown (HELO pesky) (63.170.214.187) + by server272.com with SMTP; 13 Oct 2004 14:38:08 -0000 +Subject: Re: query problem +From: ken +To: Robin Ericsson +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1097659271.24018.68.camel@pylver.localhost.nu.> +References: <1097659271.24018.68.camel@pylver.localhost.nu.> +Content-Type: text/plain +Message-Id: <1097678263.9676.275.camel@pesky> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 13 Oct 2004 07:37:43 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/173 +X-Sequence-Number: 8649 + +On Wed, 2004-10-13 at 02:21, Robin Ericsson wrote: +> Hi, +> +> I sent this to general earlier but I was redirected to performance. +> +> The query have been running ok for quite some time, but after I did a +> vacuum on the database, it's very very slow. + +Did you do a VACUUM FULL ANALYZE on the database or just a VACUUM? It +looks like your statistics in your query are all off which ANALYZE +should fix. + + + +> This IN-query is only 2 +> ids. Before the problem that in was a subselect-query returning around +> 6-7 ids. The tables included in the query are described in database.txt. +> +> status=# select count(id) from data; +> count +> --------- +> 1577621 +> (1 row) +> +> status=# select count(data_id) from data_values; +> count +> --------- +> 9680931 +> (1 row) +> +> I did run a new explain analyze on the query and found the attached +> result. The obvious problem I see is a full index scan in +> "idx_dv_data_id". I tried dropping and adding the index again, thats why +> is't called "idx_data_values_data_id" in the dump. +> +> status=# EXPLAIN ANALYZE +> status-# SELECT +> status-# data.entered, +> status-# data.machine_id, +> status-# datatemplate_intervals.template_id, +> status-# data_values.value +> status-# FROM +> status-# data, data_values, datatemplate_intervals +> status-# WHERE +> status-# datatemplate_intervals.id = data_values.template_id AND +> status-# data_values.data_id = data.id AND +> status-# data.machine_id IN (2,3) AND +> status-# current_timestamp::timestamp - interval '60 seconds' < +> data.entered; +> +> +> +> Regards, +> Robin +> + + +From pgsql-performance-owner@postgresql.org Wed Oct 13 16:03:21 2004 +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 AB89A329F4D + for ; + Wed, 13 Oct 2004 16:03:19 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15894-07 + for ; + Wed, 13 Oct 2004 15:03:15 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 39B34329F3E + for ; + Wed, 13 Oct 2004 16:03:14 +0100 (BST) +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 i9DF3DDD014685; + Wed, 13 Oct 2004 11:03:13 -0400 (EDT) +To: Robin Ericsson +Cc: pgsql-performance@postgresql.org +Subject: Re: query problem +In-reply-to: <1097659271.24018.68.camel@pylver.localhost.nu.> +References: <1097659271.24018.68.camel@pylver.localhost.nu.> +Comments: In-reply-to Robin Ericsson + message dated "Wed, 13 Oct 2004 11:21:11 +0200" +Date: Wed, 13 Oct 2004 11:03:13 -0400 +Message-ID: <14684.1097679793@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/174 +X-Sequence-Number: 8650 + +Robin Ericsson writes: +> I sent this to general earlier but I was redirected to performance. + +Actually, I think I suggested that you consult the pgsql-performance +archives, where this type of problem has been hashed out before. +See for instance this thread: +http://archives.postgresql.org/pgsql-performance/2004-07/msg00169.php +particularly +http://archives.postgresql.org/pgsql-performance/2004-07/msg00175.php +http://archives.postgresql.org/pgsql-performance/2004-07/msg00184.php +http://archives.postgresql.org/pgsql-performance/2004-07/msg00185.php +which show three different ways of getting the planner to do something +sane with an index range bound like "now() - interval". + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Oct 13 17:19:13 2004 +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 048EC32A4C4 + for ; + Wed, 13 Oct 2004 17:19:10 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47143-06 + for ; + Wed, 13 Oct 2004 16:19:04 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 12FF332B980 + for ; + Wed, 13 Oct 2004 17:19:02 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9DGJ1J9048775 + for ; Wed, 13 Oct 2004 16:19:01 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9DG43Dc043313 + for pgsql-performance@postgresql.org; Wed, 13 Oct 2004 16:04:03 GMT +From: Chris Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Opteron vs RHAT +Date: Wed, 13 Oct 2004 11:52:28 -0400 +Organization: cbbrowne Computing Inc +Lines: 24 +Message-ID: <60fz4ivcn7.fsf_-_@dba2.int.libertyrms.com> +References: <4162CA14.6080206@lulu.com> <200410050947.36174.josh@agliodbs.com> + <20041011173819.GB22076@phlogiston.dyndns.org> + <1097518852.54644.20.camel@home> + + <416B7F4C.5070600@ymogen.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:/FtYmNcpjHRMUzCxI5qunzsWgXs= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/177 +X-Sequence-Number: 8653 + +matt@ymogen.net (Matt Clark) writes: +>>As for "vendor support" for Opteron, that sure looks like a +>>trainwreck... If you're going through IBM, then they won't want to +>>respond to any issues if you're not running a "bog-standard" RHAS/RHES +>>release from Red Hat. And that, on Opteron, is preposterous, because +>>there's plenty of the bits of Opteron support that only ever got put +>>in Linux 2.6, whilst RHAT is still back in the 2.4 days. +> +> To be fair, they have backported a boatload of 2.6 features to their kernel: +> http://www.redhat.com/software/rhel/kernel26/ +> +> And that page certainly isn't an exhaustive list... + +To be fair, we keep on actually running into things that _can't_ be +backported, like fibrechannel drivers that were written to take +advantage of changes in the SCSI support in 2.6. + +This sort of thing will be particularly problematic with Opteron, +where the porting efforts for AMD64 have taken place alongside the +creation of 2.6. +-- +let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];; +http://www.ntlug.org/~cbbrowne/linuxxian.html +A VAX is virtually a computer, but not quite. + +From pgsql-performance-owner@postgresql.org Wed Oct 13 16:54:32 2004 +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 AFA8432A684 + for ; + Wed, 13 Oct 2004 16:54:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37055-06 + for ; + Wed, 13 Oct 2004 15:54:24 +0000 (GMT) +Received: from zaphod.profecta.se (profecta1.cust.morotsmedia.se + [193.235.206.49]) + by svr1.postgresql.org (Postfix) with ESMTP id A62A332A465 + for ; + Wed, 13 Oct 2004 16:54:22 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by zaphod.profecta.se (Postfix) with ESMTP + id 60E7A10F4; Wed, 13 Oct 2004 17:54:08 +0200 (CEST) +Received: from [192.168.128.80] (ip050.noname4us.com [212.247.87.50]) + by zaphod.profecta.se (Postfix) with ESMTP + id 06659A57; Wed, 13 Oct 2004 17:54:08 +0200 (CEST) +Subject: Re: query problem +From: Robin Ericsson +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <14684.1097679793@sss.pgh.pa.us> +References: <1097659271.24018.68.camel@pylver.localhost.nu.> + <14684.1097679793@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Profecta HB +Date: Wed, 13 Oct 2004 18:01:10 +0200 +Message-Id: <1097683270.24018.124.camel@pylver.localhost.nu.> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.0 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/175 +X-Sequence-Number: 8651 + +On Wed, 2004-10-13 at 11:03 -0400, Tom Lane wrote: +> Robin Ericsson writes: +> > I sent this to general earlier but I was redirected to performance. +> +> Actually, I think I suggested that you consult the pgsql-performance +> archives, where this type of problem has been hashed out before. +> See for instance this thread: +> http://archives.postgresql.org/pgsql-performance/2004-07/msg00169.php +> particularly +> http://archives.postgresql.org/pgsql-performance/2004-07/msg00175.php +> http://archives.postgresql.org/pgsql-performance/2004-07/msg00184.php +> http://archives.postgresql.org/pgsql-performance/2004-07/msg00185.php +> which show three different ways of getting the planner to do something +> sane with an index range bound like "now() - interval". + +Using exact timestamp makes the query go back as it should in speed (see +explain below). However I still have the problem using a stored +procedure or even using the "ago"-example from above. + + + + +regards, +Robin + +status=# explain analyse +status-# SELECT +status-# data.entered, +status-# data.machine_id, +status-# datatemplate_intervals.template_id, +status-# data_values.value +status-# FROM +status-# data, data_values, datatemplate_intervals +status-# WHERE +status-# datatemplate_intervals.id = +data_values.template_id AND +status-# data_values.data_id = data.id AND +status-# data.machine_id IN (SELECT machine_id FROM +machine_group_xref WHERE group_id = 1) AND +status-# '2004-10-13 17:47:36.902062' < data.entered +status-# ; + +QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=3.09..481.28 rows=777 width=24) (actual +time=0.637..1.804 rows=57 loops=1) + Hash Cond: ("outer".template_id = "inner".id) + -> Nested Loop (cost=1.17..467.71 rows=776 width=24) (actual +time=0.212..1.012 rows=57 loops=1) + -> Hash IN Join (cost=1.17..9.56 rows=146 width=16) (actual +time=0.165..0.265 rows=9 loops=1) + Hash Cond: ("outer".machine_id = "inner".machine_id) + -> Index Scan using idx_d_entered on data +(cost=0.00..6.14 rows=159 width=16) (actual time=0.051..0.097 rows=10 +loops=1) + Index Cond: ('2004-10-13 +17:47:36.902062'::timestamp without time zone < entered) + -> Hash (cost=1.14..1.14 rows=11 width=4) (actual +time=0.076..0.076 rows=0 loops=1) + -> Seq Scan on machine_group_xref +(cost=0.00..1.14 rows=11 width=4) (actual time=0.017..0.054 rows=11 +loops=1) + Filter: (group_id = 1) + -> Index Scan using idx_data_values_data_id on data_values +(cost=0.00..3.07 rows=5 width=16) (actual time=0.018..0.047 rows=6 +loops=9) + Index Cond: (data_values.data_id = "outer".id) + -> Hash (cost=1.74..1.74 rows=74 width=8) (actual time=0.382..0.382 +rows=0 loops=1) + -> Seq Scan on datatemplate_intervals (cost=0.00..1.74 +rows=74 width=8) (actual time=0.024..0.248 rows=74 loops=1) + Total runtime: 2.145 ms +(15 rows) + + + +From pgsql-performance-owner@postgresql.org Wed Oct 13 17:09:22 2004 +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 C9FD532B163 + for ; + Wed, 13 Oct 2004 17:09:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41523-08 + for ; + Wed, 13 Oct 2004 16:09:15 +0000 (GMT) +Received: from saturn.opentools.org (saturn.opentools.org [66.250.40.202]) + by svr1.postgresql.org (Postfix) with ESMTP id ADE7A32A684 + for ; + Wed, 13 Oct 2004 17:09:15 +0100 (BST) +Received: by saturn.opentools.org (Postfix, from userid 500) + id 934FD3ECC; Wed, 13 Oct 2004 12:21:27 -0400 (EDT) +Received: from localhost (localhost [127.0.0.1]) + by saturn.opentools.org (Postfix) with ESMTP id 8C0E5F58D + for ; + Wed, 13 Oct 2004 12:21:27 -0400 (EDT) +Date: Wed, 13 Oct 2004 12:21:27 -0400 (EDT) +From: Aaron Mulder +X-X-Sender: ammulder@saturn.opentools.org +To: pgsql-performance@postgresql.org +Subject: Free PostgreSQL Training, Philadelphia, Oct 30 +Message-ID: +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.5 tagged_above=0.0 required=5.0 tests=SUB_FREE_OFFER +X-Spam-Level: +X-Archive-Number: 200410/176 +X-Sequence-Number: 8652 + +All, + My company (Chariot Solutions) is sponsoring a day of free +PostgreSQL training by Bruce Momjian (one of the core PostgreSQL +developers). The day is split into 2 sessions (plus a Q&A session): + + * Mastering PostgreSQL Administration + * PostgreSQL Performance Tuning + + Registration is required, and space is limited. The location is +Malvern, PA (suburb of Philadelphia) and it's on Saturday Oct 30. For +more information or to register, see + +http://chariotsolutions.com/postgresql.jsp + +Thanks, + Aaron + +From pgsql-performance-owner@postgresql.org Wed Oct 13 17:23:51 2004 +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 DD1ED32B439 + for ; + Wed, 13 Oct 2004 17:23:49 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49724-05 + for ; + Wed, 13 Oct 2004 16:23:44 +0000 (GMT) +Received: from adsl-63-196-151-90.dsl.lsan03.pacbell.net (mail.valleypres.org + [63.196.151.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 912D932A526 + for ; + Wed, 13 Oct 2004 17:23:43 +0100 (BST) +Received: from clamav.valleypres.org ([172.16.14.58]) + by adsl-63-196-151-90.dsl.lsan03.pacbell.net with esmtp (Exim 3.13 #5) + id 1CHluf-0008MM-00; Wed, 13 Oct 2004 09:23:41 -0700 +Received: from AT10111 (unknown [172.16.31.147]) + by clamav.valleypres.org (Postfix) with SMTP id 9F14717C3BC; + Wed, 13 Oct 2004 09:23:37 -0700 (PDT) +Reply-To: +From: "Bryan Encina" +To: "'Aaron Mulder'" , + +Subject: Re: Free PostgreSQL Training, Philadelphia, Oct 30 +Date: Wed, 13 Oct 2004 09:23:47 -0700 +Message-ID: <036401c4b141$04defe10$931f10ac@AT10111> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +Importance: Normal +X-yoursite-MailScanner-Information: Please contact the ISP for more + information +X-yoursite-MailScanner: Found to be clean +X-MailScanner-From: bryan.encina@valleypres.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/178 +X-Sequence-Number: 8654 + +> All, +> My company (Chariot Solutions) is sponsoring a day of free +> PostgreSQL training by Bruce Momjian (one of the core PostgreSQL +> developers). The day is split into 2 sessions (plus a Q&A session): +> +> * Mastering PostgreSQL Administration +> * PostgreSQL Performance Tuning +> +> Registration is required, and space is limited. The location is +> Malvern, PA (suburb of Philadelphia) and it's on Saturday Oct 30. For +> more information or to register, see +> +> http://chariotsolutions.com/postgresql.jsp +> +> Thanks, +> Aaron + +Wow, that's good stuff, too bad there's no one doing stuff like that in the +Los Angeles area. + +-b + + +From pgsql-general-owner@postgresql.org Wed Oct 13 17:20:44 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B620432C231 + for ; + Wed, 13 Oct 2004 17:20:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49116-01 + for ; + Wed, 13 Oct 2004 16:20:31 +0000 (GMT) +Received: from zaphod.profecta.se (profecta1.cust.morotsmedia.se + [193.235.206.49]) + by svr1.postgresql.org (Postfix) with ESMTP id 265F232C223 + for ; + Wed, 13 Oct 2004 17:20:29 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by zaphod.profecta.se (Postfix) with ESMTP id A8C9011A4 + for ; + Wed, 13 Oct 2004 18:20:17 +0200 (CEST) +Received: from [192.168.128.80] (ip050.noname4us.com [212.247.87.50]) + by zaphod.profecta.se (Postfix) with ESMTP id 67E7611A3 + for ; + Wed, 13 Oct 2004 18:20:17 +0200 (CEST) +Subject: Re: [PERFORM] query problem +From: Robin Ericsson +To: pgsql-general@postgresql.org +In-Reply-To: <1097683270.24018.124.camel@pylver.localhost.nu.> +References: <1097659271.24018.68.camel@pylver.localhost.nu.> + <14684.1097679793@sss.pgh.pa.us> + <1097683270.24018.124.camel@pylver.localhost.nu.> +Content-Type: text/plain +Organization: Profecta HB +Date: Wed, 13 Oct 2004 18:27:20 +0200 +Message-Id: <1097684840.24018.133.camel@pylver.localhost.nu.> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.0 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/550 +X-Sequence-Number: 67074 + +On Wed, 2004-10-13 at 18:01 +0200, Robin Ericsson wrote: +> Using exact timestamp makes the query go back as it should in speed (see +> explain below). However I still have the problem using a stored +> procedure or even using the "ago"-example from above. + +Well, changing ago() to use timestamp without time zone it goes ok in +the query. This query now takes ~2ms. + +SELECT + data.entered, + data.machine_id, + datatemplate_intervals.template_id, + data_values.value +FROM + data, data_values, datatemplate_intervals +WHERE + datatemplate_intervals.id = data_values.template_id AND + data_values.data_id = data.id AND + data.machine_id IN (SELECT machine_id FROM machine_group_xref +WHERE group_id = 1) AND + ago('60 seconds') < data.entered + +Using it in this procedure. +select * from get_current_machine_status('60 seconds', 1); +takes ~100s. Maybe there's some obvious wrong I do about it? + +CREATE TYPE public.mstatus_holder AS + (entered timestamp, + machine_id int4, + template_id int4, + value varchar); +CREATE OR REPLACE FUNCTION public.get_current_machine_status(interval, +int4) + RETURNS SETOF mstatus_holder AS +' + SELECT + data.entered, + data.machine_id, + datatemplate_intervals.template_id, + data_values.value + FROM + data, data_values, datatemplate_intervals + WHERE + datatemplate_intervals.id = data_values.template_id AND + data_values.data_id = data.id AND + data.machine_id IN (SELECT machine_id FROM machine_group_xref WHERE +group_id = $2) AND + ago($1) < data.entered +' + LANGUAGE 'sql' VOLATILE; + + +Regards, + Robin + + + +From pgsql-general-owner@postgresql.org Wed Oct 13 17:29:42 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 31CE232A115 + for ; + Wed, 13 Oct 2004 17:29:40 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52004-03 + for ; + Wed, 13 Oct 2004 16:29:34 +0000 (GMT) +Received: from zaphod.profecta.se (profecta1.cust.morotsmedia.se + [193.235.206.49]) + by svr1.postgresql.org (Postfix) with ESMTP id C5FE232A0AC + for ; + Wed, 13 Oct 2004 17:29:34 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by zaphod.profecta.se (Postfix) with ESMTP id A2ABB1111 + for ; + Wed, 13 Oct 2004 18:29:23 +0200 (CEST) +Received: from [192.168.128.80] (ip050.noname4us.com [212.247.87.50]) + by zaphod.profecta.se (Postfix) with ESMTP id 49F37981 + for ; + Wed, 13 Oct 2004 18:29:23 +0200 (CEST) +Subject: Re: [PERFORM] query problem +From: Robin Ericsson +To: Postgres general mailing list +In-Reply-To: <1097684840.24018.133.camel@pylver.localhost.nu.> +References: <1097659271.24018.68.camel@pylver.localhost.nu.> + <14684.1097679793@sss.pgh.pa.us> + <1097683270.24018.124.camel@pylver.localhost.nu.> + <1097684840.24018.133.camel@pylver.localhost.nu.> +Content-Type: text/plain +Organization: Profecta HB +Date: Wed, 13 Oct 2004 18:36:26 +0200 +Message-Id: <1097685386.24018.134.camel@pylver.localhost.nu.> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.0 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/551 +X-Sequence-Number: 67075 + +Sorry, this should have been going to performance. + + + +Regards, + Robin + + +From pgsql-performance-owner@postgresql.org Wed Oct 13 17:30:13 2004 +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 C362032A892 + for ; + Wed, 13 Oct 2004 17:30:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49846-09 + for ; + Wed, 13 Oct 2004 16:29:58 +0000 (GMT) +Received: from zaphod.profecta.se (zaphod.profecta.se [193.235.206.49]) + by svr1.postgresql.org (Postfix) with ESMTP id 32D8332A6B1 + for ; + Wed, 13 Oct 2004 17:29:58 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by zaphod.profecta.se (Postfix) with ESMTP id E187611A3 + for ; + Wed, 13 Oct 2004 18:29:46 +0200 (CEST) +Received: from [192.168.128.80] (ip050.noname4us.com [212.247.87.50]) + by zaphod.profecta.se (Postfix) with ESMTP id A3BB71194 + for ; + Wed, 13 Oct 2004 18:29:46 +0200 (CEST) +Subject: [Fwd: Re: [GENERAL] query problem] +From: Robin Ericsson +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: Profecta HB +Date: Wed, 13 Oct 2004 18:36:50 +0200 +Message-Id: <1097685410.24018.136.camel@pylver.localhost.nu.> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.0 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/179 +X-Sequence-Number: 8655 + +Sent this to wrong list. + +-------- Forwarded Message -------- +From: Robin Ericsson +To: pgsql-general@postgresql.org +Subject: Re: [GENERAL] [PERFORM] query problem +Date: Wed, 13 Oct 2004 18:27:20 +0200 +On Wed, 2004-10-13 at 18:01 +0200, Robin Ericsson wrote: +> Using exact timestamp makes the query go back as it should in speed (see +> explain below). However I still have the problem using a stored +> procedure or even using the "ago"-example from above. + +Well, changing ago() to use timestamp without time zone it goes ok in +the query. This query now takes ~2ms. + +SELECT + data.entered, + data.machine_id, + datatemplate_intervals.template_id, + data_values.value +FROM + data, data_values, datatemplate_intervals +WHERE + datatemplate_intervals.id = data_values.template_id AND + data_values.data_id = data.id AND + data.machine_id IN (SELECT machine_id FROM machine_group_xref +WHERE group_id = 1) AND + ago('60 seconds') < data.entered + +Using it in this procedure. +select * from get_current_machine_status('60 seconds', 1); +takes ~100s. Maybe there's some obvious wrong I do about it? + +CREATE TYPE public.mstatus_holder AS + (entered timestamp, + machine_id int4, + template_id int4, + value varchar); +CREATE OR REPLACE FUNCTION public.get_current_machine_status(interval, +int4) + RETURNS SETOF mstatus_holder AS +' + SELECT + data.entered, + data.machine_id, + datatemplate_intervals.template_id, + data_values.value + FROM + data, data_values, datatemplate_intervals + WHERE + datatemplate_intervals.id = data_values.template_id AND + data_values.data_id = data.id AND + data.machine_id IN (SELECT machine_id FROM machine_group_xref WHERE +group_id = $2) AND + ago($1) < data.entered +' + LANGUAGE 'sql' VOLATILE; + + +Regards, + Robin + + + +---------------------------(end of broadcast)--------------------------- +TIP 7: don't forget to increase your free space map settings +-- +Robin Ericsson +Profecta HB + + +From pgsql-performance-owner@postgresql.org Wed Oct 13 17:47:31 2004 +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 DC1C532C1B0 + for ; + Wed, 13 Oct 2004 17:47:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57066-07 + for ; + Wed, 13 Oct 2004 16:47:23 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EDDB32C117 + for ; + Wed, 13 Oct 2004 17:47:22 +0100 (BST) +Received: from solent (unknown [213.165.136.10]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id BD3F7A3105; Wed, 13 Oct 2004 17:47:20 +0100 (BST) +Reply-To: +From: "Matt Clark" +To: "'Chris Browne'" , + +Subject: Re: Opteron vs RHAT +Date: Wed, 13 Oct 2004 17:47:20 +0100 +Organization: Ymogen Ltd +Message-ID: <021b01c4b144$4e822120$8300a8c0@solent> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Importance: Normal +In-Reply-To: <60fz4ivcn7.fsf_-_@dba2.int.libertyrms.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/180 +X-Sequence-Number: 8656 + +> >>trainwreck... If you're going through IBM, then they won't want to=20 +> >>respond to any issues if you're not running a=20 +> "bog-standard" RHAS/RHES=20 +> >>release from Red Hat.=20=20 +...> To be fair, we keep on actually running into things that=20 +> _can't_ be backported, like fibrechannel drivers that were=20 +> written to take advantage of changes in the SCSI support in 2.6. + +I thought IBM had good support for SUSE? I don't know why I thought that... + + +From pgsql-performance-owner@postgresql.org Wed Oct 13 19:57:55 2004 +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 D770C329F4D + for ; + Wed, 13 Oct 2004 19:57:53 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98492-05 + for ; + Wed, 13 Oct 2004 18:57:45 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 9176532AA03 + for ; + Wed, 13 Oct 2004 19:57:45 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9DIviQ13537; + Wed, 13 Oct 2004 11:57:44 -0700 +Date: Wed, 13 Oct 2004 11:57:44 -0700 +From: Mark Wong +To: pgsql-performance@postgresql.org +Cc: neilc@samurai.com, swm@alcove.com.au, + Stephen Hemminger +Subject: futex results with dbt-3 +Message-ID: <20041013115744.A11278@osdl.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/181 +X-Sequence-Number: 8657 + +Hi guys, + +I have some DBT-3 (decision support) results using Gavin's original +futex patch fix. It's on out 8-way Pentium III Xeon systems +in our STP environment. Definitely see some overall throughput +performance on the tests, about 15% increase, but not change with +respect to the number of context switches. + +Perhaps it doesn't really address what's causing the incredible number +of context switches, but still helps. I think I'm seeing what Gavin +has, that it seems to solves some concurrency problems on x86 platforms. + +Here's results without futexes: + http://khack.osdl.org/stp/298114/ + +Results with futexes: + http://khack.osdl.org/stp/298115/ + +Mark + +From pgsql-performance-owner@postgresql.org Wed Oct 13 21:12:16 2004 +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 411F132ABB7 + for ; + Wed, 13 Oct 2004 21:12:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23310-05 + for ; + Wed, 13 Oct 2004 20:11:59 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) + by svr1.postgresql.org (Postfix) with ESMTP id D7B73329FB1 + for ; + Wed, 13 Oct 2004 21:11:15 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 73so388935rnk + for ; + Wed, 13 Oct 2004 13:10:48 -0700 (PDT) +Received: by 10.38.165.75 with SMTP id n75mr2611842rne; + Wed, 13 Oct 2004 13:10:48 -0700 (PDT) +Received: by 10.38.151.56 with HTTP; Wed, 13 Oct 2004 13:10:48 -0700 (PDT) +Message-ID: <18f60194041013131067b6afd9@mail.gmail.com> +Date: Wed, 13 Oct 2004 13:10:48 -0700 +From: Aaron Glenn +Reply-To: Aaron Glenn +To: pgsql-performance@postgresql.org +Subject: Re: Free PostgreSQL Training, Philadelphia, Oct 30 +In-Reply-To: <036401c4b141$04defe10$931f10ac@AT10111> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + <036401c4b141$04defe10$931f10ac@AT10111> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/182 +X-Sequence-Number: 8658 + +On Wed, 13 Oct 2004 09:23:47 -0700, Bryan Encina + wrote: +> +> Wow, that's good stuff, too bad there's no one doing stuff like that in the +> Los Angeles area. +> +> -b + +That makes two of us. Hanging out with Tom, Bruce, and others at OSCON +2002 was one of the most informative and fun times I've had. That and +I could really stand to brush up on my Postgres basics + + +aaron.glenn + +From pgsql-performance-owner@postgresql.org Wed Oct 13 23:34:43 2004 +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 1C1DE32ACAB + for ; + Wed, 13 Oct 2004 23:34:40 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58277-08 + for ; + Wed, 13 Oct 2004 22:34:36 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BB6B32A219 + for ; + Wed, 13 Oct 2004 23:34:37 +0100 (BST) +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 6500372; Wed, 13 Oct 2004 15:36:01 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org, + Aaron Glenn +Subject: Re: Free PostgreSQL Training, Philadelphia, Oct 30 +Date: Wed, 13 Oct 2004 15:36:33 -0700 +User-Agent: KMail/1.6.2 +References: + <036401c4b141$04defe10$931f10ac@AT10111> + <18f60194041013131067b6afd9@mail.gmail.com> +In-Reply-To: <18f60194041013131067b6afd9@mail.gmail.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410131536.33286.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/183 +X-Sequence-Number: 8659 + +Aaron, + +> That makes two of us. Hanging out with Tom, Bruce, and others at OSCON +> 2002 was one of the most informative and fun times I've had. That and +> I could really stand to brush up on my Postgres basics + +You're thinking of Jan. Tom wasn't at OSCON. ;-) + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Oct 14 01:49:31 2004 +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 0EC3432BBB2 + for ; + Thu, 14 Oct 2004 01:49:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90454-01 + for ; + Thu, 14 Oct 2004 00:49:12 +0000 (GMT) +Received: from smtp108.mail.sc5.yahoo.com (smtp108.mail.sc5.yahoo.com + [66.163.170.6]) + by svr1.postgresql.org (Postfix) with SMTP id B717F32BB9E + for ; + Thu, 14 Oct 2004 01:49:14 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp108.mail.sc5.yahoo.com with SMTP; 14 Oct 2004 00:49:14 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9E0n294074029; Wed, 13 Oct 2004 20:49:07 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <416DCCFF.70304@Yahoo.com> +Date: Wed, 13 Oct 2004 20:49:03 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +References: <200410081443.16109.josh@agliodbs.com> + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/184 +X-Sequence-Number: 8660 + +On 10/8/2004 10:10 PM, Christopher Browne wrote: + +> josh@agliodbs.com (Josh Berkus) wrote: +>> I've been trying to peg the "sweet spot" for shared memory using +>> OSDL's equipment. With Jan's new ARC patch, I was expecting that +>> the desired amount of shared_buffers to be greatly increased. This +>> has not turned out to be the case. +> +> That doesn't surprise me. + +Neither does it surprise me. + +> +> My primary expectation would be that ARC would be able to make small +> buffers much more effective alongside vacuums and seq scans than they +> used to be. That does not establish anything about the value of +> increasing the size buffer caches... + +The primary goal of ARC is to prevent total cache eviction caused by +sequential scans. Which means it is designed to avoid the catastrophic +impact of a pg_dump or other, similar access in parallel to the OLTP +traffic. It would be much more interesting to see how a half way into a +2 hour measurement interval started pg_dump affects the response times. + +One also has to take a closer look at the data of the DBT2. What amount +of that 32GB is high-frequently accessed, and therefore a good thing to +live in the PG shared cache? A cache significantly larger than that +doesn't make sense to me, under no cache strategy. + + +Jan + + +> +>> This result is so surprising that I want people to take a look at it +>> and tell me if there's something wrong with the tests or some +>> bottlenecking factor that I've not seen. +> +> I'm aware of two conspicuous scenarios where ARC would be expected to +> _substantially_ improve performance: +> +> 1. When it allows a VACUUM not to throw useful data out of +> the shared cache in that VACUUM now only 'chews' on one +> page of the cache; +> +> 2. When it allows a Seq Scan to not push useful data out of +> the shared cache, for much the same reason. +> +> I don't imagine either scenario are prominent in the OSDL tests. +> +> Increasing the number of cache buffers _is_ likely to lead to some +> slowdowns: +> +> - Data that passes through the cache also passes through kernel +> cache, so it's recorded twice, and read twice... +> +> - The more cache pages there are, the more work is needed for +> PostgreSQL to manage them. That will notably happen anywhere +> that there is a need to scan the cache. +> +> - If there are any inefficiencies in how the OS kernel manages shared +> memory, as their size scales, well, that will obviously cause a +> slowdown. + + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-performance-owner@postgresql.org Thu Oct 14 01:52:56 2004 +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 2A12732BBB6 + for ; + Thu, 14 Oct 2004 01:52:55 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90645-02 + for ; + Thu, 14 Oct 2004 00:52:46 +0000 (GMT) +Received: from smtp110.mail.sc5.yahoo.com (smtp110.mail.sc5.yahoo.com + [66.163.170.8]) + by svr1.postgresql.org (Postfix) with SMTP id 417B232BBB2 + for ; + Thu, 14 Oct 2004 01:52:46 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp110.mail.sc5.yahoo.com with SMTP; 14 Oct 2004 00:52:46 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9E0qg94074054; Wed, 13 Oct 2004 20:52:45 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <416DCDDB.1010902@Yahoo.com> +Date: Wed, 13 Oct 2004 20:52:43 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Kevin Brown +Cc: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +References: <200410081443.16109.josh@agliodbs.com> + <20041009112048.GA665@filer> +In-Reply-To: <20041009112048.GA665@filer> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/185 +X-Sequence-Number: 8661 + +On 10/9/2004 7:20 AM, Kevin Brown wrote: + +> Christopher Browne wrote: +>> Increasing the number of cache buffers _is_ likely to lead to some +>> slowdowns: +>> +>> - Data that passes through the cache also passes through kernel +>> cache, so it's recorded twice, and read twice... +> +> Even worse, memory that's used for the PG cache is memory that's not +> available to the kernel's page cache. Even if the overall memory + +Which underlines my previous statement, that a PG shared cache much +larger than the high-frequently accessed data portion of the DB is +counterproductive. Double buffering (kernel-disk-buffer plus shared +buffer) only makes sense for data that would otherwise cause excessive +memory copies in and out of the shared buffer. After that, in only +lowers the memory available for disk buffers. + + +Jan + +> usage in the system isn't enough to cause some paging to disk, most +> modern kernels will adjust the page/disk cache size dynamically to fit +> the memory demands of the system, which in this case means it'll be +> smaller if running programs need more memory for their own use. +> +> This is why I sometimes wonder whether or not it would be a win to use +> mmap() to access the data and index files -- doing so under a truly +> modern OS would surely at the very least save a buffer copy (from the +> page/disk cache to program memory) because the OS could instead +> direcly map the buffer cache pages directly to the program's memory +> space. +> +> Since PG often has to have multiple files open at the same time, and +> in a production database many of those files will be rather large, PG +> would have to limit the size of the mmap()ed region on 32-bit +> platforms, which means that things like the order of mmap() operations +> to access various parts of the file can become just as important in +> the mmap()ed case as it is in the read()/write() case (if not more +> so!). I would imagine that the use of mmap() on a 64-bit platform +> would be a much, much larger win because PG would most likely be able +> to mmap() entire files and let the OS work out how to order disk reads +> and writes. +> +> The biggest problem as I see it is that (I think) mmap() would have to +> be made to cooperate with malloc() for virtual address space. I +> suspect issues like this have already been worked out by others, +> however... +> +> +> + + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-performance-owner@postgresql.org Thu Oct 14 03:30:24 2004 +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 6784C32BDD6 + for ; + Thu, 14 Oct 2004 03:30:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11081-06 + for ; + Thu, 14 Oct 2004 02:30:09 +0000 (GMT) +Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 8939732BDD1 + for ; + Thu, 14 Oct 2004 03:30:11 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by sue.samurai.com (Postfix) with ESMTP id DECF1197E8; + Wed, 13 Oct 2004 22:30:11 -0400 (EDT) +Received: from sue.samurai.com ([127.0.0.1]) + by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 94238-01-9; Wed, 13 Oct 2004 22:30:09 -0400 (EDT) +Received: from [61.88.101.19] (unknown [61.88.101.19]) + by sue.samurai.com (Postfix) with ESMTP id D1CAC197D0; + Wed, 13 Oct 2004 22:30:07 -0400 (EDT) +Subject: Re: futex results with dbt-3 +From: Neil Conway +To: Mark Wong +Cc: pgsql-performance@postgresql.org, Gavin Sherry , + Stephen Hemminger +In-Reply-To: <20041013115744.A11278@osdl.org> +References: <20041013115744.A11278@osdl.org> +Content-Type: multipart/mixed; boundary="=-HuItn3AfDAyHfOdEZ/QL" +Message-Id: <1097721005.4682.2.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Thu, 14 Oct 2004 12:30:05 +1000 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/186 +X-Sequence-Number: 8662 + +--=-HuItn3AfDAyHfOdEZ/QL +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +On Thu, 2004-10-14 at 04:57, Mark Wong wrote: +> I have some DBT-3 (decision support) results using Gavin's original +> futex patch fix. + +I sent an initial description of the futex patch to the mailing lists +last week, but it never appeared (from talking to Marc I believe it +exceeded the size limit on -performance). In any case, the "futex patch" +uses the Linux 2.6 futex API to implement PostgreSQL spinlocks. The hope +is that using futexes will lead to better performance when there is +contention for spinlocks (e.g. on a busy SMP system). The original patch +was written by Stephen Hemminger at OSDL; Gavin and myself have done a +bunch of additional bugfixing and optimization, as well as added IA64 +support. + +I've attached a WIP copy of the patch to this email (it supports x86, +x86-64 (untested) and IA64 -- more architectures can be added at +request). I'll post a longer writeup when I submit the patch to +-patches. + +> Definitely see some overall throughput performance on the tests, about +> 15% increase, but not change with respect to the number of context +> switches. + +I'm glad to see that there is a performance improvement; in my own +testing on an 8-way P3 system provided by OSDL, I saw a similar +improvement in pgbench performance (50 concurrent clients, 1000 +transactions each, scale factor 75; without the patch, TPS/sec was +between 180 and 185, with the patch TPS/sec was between 200 and 215). + +As for context switching, there was some earlier speculation that the +patch might improve or even resolve the "CS storm" issue that some +people have experienced with SMP Xeon P4 systems. I don't think we have +enough evidence to answer this one way or the other at this point. + +-Neil + + +--=-HuItn3AfDAyHfOdEZ/QL +Content-Disposition: attachment; filename=futex-spin-16.patch +Content-Type: text/x-patch; name=futex-spin-16.patch; charset=iso-8859-1 +Content-Transfer-Encoding: 7bit + +Index: src/backend/storage/lmgr/s_lock.c +=================================================================== +RCS file: /var/lib/cvs/pgsql/src/backend/storage/lmgr/s_lock.c,v +retrieving revision 1.32 +diff -c -r1.32 s_lock.c +*** src/backend/storage/lmgr/s_lock.c 30 Aug 2004 23:47:20 -0000 1.32 +--- src/backend/storage/lmgr/s_lock.c 13 Oct 2004 06:23:26 -0000 +*************** +*** 15,26 **** + */ + #include "postgres.h" + + #include +- #include + + #include "storage/s_lock.h" + #include "miscadmin.h" + + /* + * s_lock_stuck() - complain about a stuck spinlock + */ +--- 15,49 ---- + */ + #include "postgres.h" + ++ #ifdef S_LOCK_TEST ++ #undef Assert ++ #define Assert(cond) DoAssert(cond, #cond, __FILE__, __LINE__) ++ ++ #define DoAssert(cond, text, file, line) \ ++ if (!(cond)) \ ++ { \ ++ printf("ASSERTION FAILED! [%s], file = %s, line = %d\n", \ ++ text, file, line); \ ++ abort(); \ ++ } ++ #endif ++ + #include + + #include "storage/s_lock.h" + #include "miscadmin.h" + ++ #ifdef S_LOCK_TEST ++ #define LOCK_TEST_MSG() \ ++ do \ ++ { \ ++ fprintf(stdout, "*"); \ ++ fflush(stdout); \ ++ } while (0); ++ #else ++ #define LOCK_TEST_MSG() ++ #endif ++ + /* + * s_lock_stuck() - complain about a stuck spinlock + */ +*************** +*** 38,43 **** +--- 61,131 ---- + #endif + } + ++ #ifdef HAVE_FUTEX ++ /* ++ * futex_lock_contended() is similar to s_lock() for the normal TAS ++ * implementation of spinlocks. When this function is invoked, we have ++ * failed to immediately acquire the spinlock, so we should spin some ++ * number of times attempting to acquire the lock before invoking ++ * sys_futex() to have the kernel wake us up later. "val" is the ++ * current value of the mutex we saw when we tried to acquire it; it ++ * may have changed since then, of course. ++ */ ++ void ++ futex_lock_contended(volatile slock_t *lock, slock_t val, ++ const char *file, int line) ++ { ++ int loop_count = 0; ++ ++ #define MAX_LOCK_WAIT 30 ++ #define SPINS_BEFORE_WAIT 100 ++ ++ Assert(val != FUTEX_UNLOCKED); ++ ++ if (val == FUTEX_LOCKED_NOWAITER) ++ val = atomic_exchange(lock, FUTEX_LOCKED_WAITER); ++ ++ while (val != FUTEX_UNLOCKED) ++ { ++ static struct timespec delay = { .tv_sec = MAX_LOCK_WAIT, ++ .tv_nsec = 0 }; ++ ++ LOCK_TEST_MSG(); ++ ++ #if defined(__i386__) || defined(__x86_64__) ++ /* See spin_delay() */ ++ __asm__ __volatile__(" rep; nop\n"); ++ #endif ++ ++ /* ++ * XXX: This code is derived from the Drepper algorithm, which ++ * doesn't spin (why, I'm not sure). We should actually change ++ * the lock status to "lock, with waiters" just before we wait ++ * on the futex, not before we begin looping (that avoids a ++ * system call when the lock is released). ++ */ ++ ++ /* XXX: worth using __builtin_expect() here? */ ++ if (++loop_count >= SPINS_BEFORE_WAIT) ++ { ++ loop_count = 0; ++ if (sys_futex(lock, FUTEX_OP_WAIT, ++ FUTEX_LOCKED_WAITER, &delay)) ++ { ++ if (errno == ETIMEDOUT) ++ s_lock_stuck(lock, file, line); ++ } ++ } ++ ++ /* ++ * Do a non-locking test before asserting the bus lock. ++ */ ++ if (*lock == FUTEX_UNLOCKED) ++ val = atomic_exchange(lock, FUTEX_LOCKED_WAITER); ++ } ++ } ++ ++ #else + + /* + * s_lock(lock) - platform-independent portion of waiting for a spinlock. +*************** +*** 98,107 **** + + pg_usleep(cur_delay * 10000L); + +! #if defined(S_LOCK_TEST) +! fprintf(stdout, "*"); +! fflush(stdout); +! #endif + + /* increase delay by a random fraction between 1X and 2X */ + cur_delay += (int) (cur_delay * +--- 186,192 ---- + + pg_usleep(cur_delay * 10000L); + +! LOCK_TEST_MSG(); + + /* increase delay by a random fraction between 1X and 2X */ + cur_delay += (int) (cur_delay * +*************** +*** 114,119 **** +--- 199,205 ---- + } + } + } ++ #endif /* HAVE_FUTEX */ + + /* + * Various TAS implementations that cannot live in s_lock.h as no inline +*************** +*** 134,140 **** + * All the gcc flavors that are not inlined + */ + +- + #if defined(__m68k__) + static void + tas_dummy() /* really means: extern int tas(slock_t +--- 220,225 ---- +*************** +*** 265,272 **** +--- 350,361 ---- + + test_lock.pad1 = test_lock.pad2 = 0x44; + ++ printf("Address of lock variable: %p\n", &test_lock.lock); ++ + S_INIT_LOCK(&test_lock.lock); + ++ printf("<1> Value of lock variable: %d\n", test_lock.lock); ++ + if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44) + { + printf("S_LOCK_TEST: failed, declared datatype is wrong size\n"); +*************** +*** 280,285 **** +--- 369,375 ---- + } + + S_LOCK(&test_lock.lock); ++ printf("<2> Value of lock variable: %d\n", test_lock.lock); + + if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44) + { +*************** +*** 289,299 **** +--- 379,391 ---- + + if (S_LOCK_FREE(&test_lock.lock)) + { ++ printf("<3> Value of lock variable: %d\n", test_lock.lock); + printf("S_LOCK_TEST: failed, lock not locked\n"); + return 1; + } + + S_UNLOCK(&test_lock.lock); ++ printf("<4> Value of lock variable: %d\n", test_lock.lock); + + if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44) + { +*************** +*** 326,332 **** + printf(" if S_LOCK() and TAS() are working.\n"); + fflush(stdout); + +! s_lock(&test_lock.lock, __FILE__, __LINE__); + + printf("S_LOCK_TEST: failed, lock not locked\n"); + return 1; +--- 418,424 ---- + printf(" if S_LOCK() and TAS() are working.\n"); + fflush(stdout); + +! S_LOCK(&test_lock.lock); + + printf("S_LOCK_TEST: failed, lock not locked\n"); + return 1; +Index: src/include/storage/s_lock.h +=================================================================== +RCS file: /var/lib/cvs/pgsql/src/include/storage/s_lock.h,v +retrieving revision 1.132 +diff -c -r1.132 s_lock.h +*** src/include/storage/s_lock.h 6 Oct 2004 23:41:59 -0000 1.132 +--- src/include/storage/s_lock.h 13 Oct 2004 06:22:54 -0000 +*************** +*** 46,55 **** + * will "fail" if interrupted. Therefore TAS() should always be invoked + * in a retry loop, even if you are certain the lock is free. + * +! * ANOTHER CAUTION: be sure that TAS() and S_UNLOCK() represent sequence +! * points, ie, loads and stores of other values must not be moved across +! * a lock or unlock. In most cases it suffices to make the operation be +! * done through a "volatile" pointer. + * + * On most supported platforms, TAS() uses a tas() function written + * in assembly language to execute a hardware atomic-test-and-set +--- 46,57 ---- + * will "fail" if interrupted. Therefore TAS() should always be invoked + * in a retry loop, even if you are certain the lock is free. + * +! * ANOTHER CAUTION: be sure that TAS() and S_UNLOCK() represent +! * sequence points, ie, loads and stores of other values must not be +! * moved across a lock or unlock. In most cases it suffices to make +! * the operation be done through a "volatile" pointer; also, adding +! * "memory" to the list of clobbered registers (for GCC inline asm) +! * may also be necessary. + * + * On most supported platforms, TAS() uses a tas() function written + * in assembly language to execute a hardware atomic-test-and-set +*************** +*** 73,83 **** + #ifndef S_LOCK_H + #define S_LOCK_H + + #include "storage/pg_sema.h" + + #ifdef HAVE_SPINLOCKS /* skip spinlocks if requested */ + +- + #if defined(__GNUC__) || defined(__ICC) + /************************************************************************* + * All the gcc inlines +--- 75,86 ---- + #ifndef S_LOCK_H + #define S_LOCK_H + ++ #include ++ + #include "storage/pg_sema.h" + + #ifdef HAVE_SPINLOCKS /* skip spinlocks if requested */ + + #if defined(__GNUC__) || defined(__ICC) + /************************************************************************* + * All the gcc inlines +*************** +*** 107,116 **** + *---------- + */ + + +! #if defined(__i386__) || defined(__x86_64__) /* AMD Opteron */ +! #define HAS_TEST_AND_SET + + typedef unsigned char slock_t; + + #define TAS(lock) tas(lock) +--- 110,322 ---- + *---------- + */ + ++ /* ++ * Linux 2.6 introduced the "futex" API. This provides an efficient ++ * building block for implementing concurrency primitives, via the ++ * sys_futex system call. The gist is that a futex is an aligned ++ * integer. It is decremented and incremented via atomic instructions, ++ * like a normal spinlock. In the contended case, the sys_futex() ++ * system call allows us to enter the kernel and have it awaken us ++ * when the futex is free. The best reference for understanding ++ * futexes is "Futexes are Tricky" by Ulrich Drepper; the ++ * implementation of spinlocks using mutexes is a fairly close ++ * transcription of the example code provided in that paper. ++ * ++ * If futexes are available at compile-time, we attempt to use them at ++ * run-time. It is possible that they aren't available (e.g. we're ++ * compiled on a Linux 2.6 system and run on a Linux 2.4 system), so ++ * we fallback to using normal TAS in that case. ++ */ ++ #if defined(__linux__) + +! #include +! +! #ifdef SYS_futex +! /* +! * Additional atomic operations are required to use futexes. We +! * consider futexes to be available on a system iff the sys_futex +! * system call is available AND we have implemented the necessary +! * assembly routines for the CPU architecture. If both conditions do +! * not hold, we fall back to using the normal TAS technique. +! */ +! #if defined(__i386__) || defined(__x86_64__) +! #define HAVE_FUTEX +! +! typedef int slock_t; +! +! static __inline__ slock_t +! atomic_cmp_exchange(volatile slock_t *ptr, slock_t old, slock_t new) +! { +! slock_t prev; +! __asm__ __volatile__( +! " lock \n" +! " cmpxchgl %1,%2 \n" +! : "=a"(prev) +! : "q"(new), "m"(*ptr), "0"(old) +! : "memory", "cc"); +! +! return prev; +! } +! +! static __inline__ slock_t +! atomic_exchange(volatile slock_t *ptr, slock_t x) +! { +! /* no lock prefix needed, xchgl is always locked */ +! __asm__ __volatile__( +! " xchgl %0,%1 \n" +! :"=q"(x) +! :"m"(*ptr), "0"(x) +! :"memory"); +! +! return x; +! } +! +! /* +! * XXX: is there a more efficient way to write this? Perhaps using +! * decl...? +! */ +! static __inline__ slock_t +! atomic_dec(volatile slock_t *ptr) +! { +! slock_t prev = -1; +! +! __asm__ __volatile__( +! " lock \n" +! " xadd %0,%1 \n" +! :"=q"(prev) +! :"m"(*ptr), "0"(prev) +! :"memory", "cc"); +! +! return prev; +! } +! #endif /* defined(__i386__) || defined(__x86_64__) */ +! +! #if defined(__ia64__) || defined(__ia64) +! /* Intel Itanium */ +! #define HAVE_FUTEX +! +! typedef int slock_t; +! +! static __inline__ slock_t +! atomic_cmp_exchange(volatile slock_t *ptr, slock_t old, slock_t new) +! { +! long int prev; +! +! __asm__ __volatile__( +! " mov ar.ccv=%2;;" +! " cmpxchg4.acq %0 = %4,%3,ar.ccv" +! : "=r" (prev), "=m" (*ptr) +! : "r" (old), "r" (new), "m" (*ptr) +! : "memory"); +! +! return (slock_t) prev; +! } +! +! static __inline__ slock_t +! atomic_exchange(volatile slock_t *ptr, slock_t x) +! { +! /* Note that xchg has "acquire" semantics implicitely */ +! __asm__ __volatile__( +! " xchg4 %0=%1,%2 \n" +! : "+r"(x), "+m"(*ptr) +! : +! : "memory"); +! +! return x; +! } +! +! static __inline__ slock_t +! atomic_dec(volatile slock_t *ptr) +! { +! slock_t result; +! +! /* +! * Note that IA64 does _not_ guarantee that fetchadd is always +! * atomic. However, it should always be atomic when the operand is +! * -1; see the IA64 docs for details. +! */ +! __asm__ __volatile__( +! "fetchadd4.rel %0=[%1],%2" +! : "=r"(result) +! : "r"(ptr), "i"(-1) +! : "memory"); +! +! return result; +! } +! +! #endif /* __ia64__ || __ia64 */ +! +! #endif /* SYS_futex */ +! #endif /* defined(__linux__) */ +! +! #ifdef HAVE_FUTEX +! +! /* +! * Legal states of a futex. +! */ +! #define FUTEX_UNLOCKED 0 +! #define FUTEX_LOCKED_NOWAITER 1 +! #define FUTEX_LOCKED_WAITER 2 +! +! /* +! * Futex operations (for sys_futex()). +! */ +! #define FUTEX_OP_WAIT 0 +! #define FUTEX_OP_WAKE 1 +! +! #define S_LOCK(lock) futex_lock((lock), __FILE__, __LINE__) +! #define S_UNLOCK(lock) futex_unlock(lock) +! #define S_LOCK_FREE(lock) (*(lock) == FUTEX_UNLOCKED) +! #define S_INIT_LOCK(lock) (*(lock) = FUTEX_UNLOCKED) +! #define SPIN_DELAY() +! +! #define NUM_DELAYS 100 + ++ extern void ++ futex_lock_contended(volatile slock_t *lock, slock_t val, ++ const char *file, int line); ++ ++ static __inline__ int ++ sys_futex(volatile int *ptr, int op, int val, struct timespec *timeout) ++ { ++ return syscall(SYS_futex, ptr, op, val, timeout); ++ } ++ ++ static __inline__ void ++ futex_lock(volatile slock_t *lock, const char *file, int line) ++ { ++ /* ++ * In the common case, there is no contention for the lock, so we ++ * can acquire it with a single compare-exchange instruction. Thus, ++ * it is important to avoid the overhead of a function call. If we ++ * need to contend for the futex we need to spin or make a kernel ++ * call anyway, so a function call doesn't hurt. ++ */ ++ slock_t val = atomic_cmp_exchange(lock, ++ FUTEX_UNLOCKED, ++ FUTEX_LOCKED_NOWAITER); ++ ++ if (val != FUTEX_UNLOCKED) ++ futex_lock_contended(lock, val, file, line); ++ } ++ ++ static __inline__ void ++ futex_unlock(volatile slock_t *lock) ++ { ++ Assert(*lock == FUTEX_LOCKED_NOWAITER || ++ *lock == FUTEX_LOCKED_WAITER); ++ if (atomic_dec(lock) != FUTEX_LOCKED_NOWAITER) ++ { ++ *lock = FUTEX_UNLOCKED; ++ sys_futex(lock, FUTEX_OP_WAKE, 1, NULL); ++ } ++ } ++ ++ #else ++ ++ #if defined(__i386__) || defined(__x86_64__) ++ ++ #define HAS_TEST_AND_SET + typedef unsigned char slock_t; + + #define TAS(lock) tas(lock) +*************** +*** 120,130 **** + { + register slock_t _res = 1; + +! /* Use a non-locking test before asserting the bus lock */ + __asm__ __volatile__( + " cmpb $0,%1 \n" + " jne 1f \n" +- " lock \n" + " xchgb %0,%1 \n" + "1: \n" + : "+q"(_res), "+m"(*lock) +--- 326,336 ---- + { + register slock_t _res = 1; + +! /* Use a non-locking test before doing xchgb, which implicitely +! * asserts the bus lock */ + __asm__ __volatile__( + " cmpb $0,%1 \n" + " jne 1f \n" + " xchgb %0,%1 \n" + "1: \n" + : "+q"(_res), "+m"(*lock) +*************** +*** 167,173 **** + + #endif /* __i386__ || __x86_64__ */ + +- + #if defined(__ia64__) || defined(__ia64) /* __ia64 used by ICC compiler? */ + /* Intel Itanium */ + #define HAS_TEST_AND_SET +--- 373,378 ---- +*************** +*** 453,459 **** + + typedef unsigned int slock_t; + #endif +! + + #endif /* __GNUC__ */ + +--- 658,664 ---- + + typedef unsigned int slock_t; + #endif +! #endif /* ! HAVE_FUTEX */ + + #endif /* __GNUC__ */ + +*************** +*** 697,703 **** + + + /* Blow up if we didn't have any way to do spinlocks */ +! #ifndef HAS_TEST_AND_SET + #error PostgreSQL does not have native spinlock support on this platform. To continue the compilation, rerun configure using --disable-spinlocks. However, performance will be poor. Please report this to pgsql-bugs@postgresql.org. + #endif + +--- 902,908 ---- + + + /* Blow up if we didn't have any way to do spinlocks */ +! #if !defined(HAS_TEST_AND_SET) && !defined(HAVE_FUTEX) + #error PostgreSQL does not have native spinlock support on this platform. To continue the compilation, rerun configure using --disable-spinlocks. However, performance will be poor. Please report this to pgsql-bugs@postgresql.org. + #endif + + +--=-HuItn3AfDAyHfOdEZ/QL-- + + +From pgsql-performance-owner@postgresql.org Thu Oct 14 04:47:31 2004 +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 D813D32C6D4 + for ; + Thu, 14 Oct 2004 04:47:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34447-03 + for ; + Thu, 14 Oct 2004 03:47:16 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CF8932C59B + for ; + Thu, 14 Oct 2004 04:47:13 +0100 (BST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i9E3l5910978; + Wed, 13 Oct 2004 23:47:05 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200410140347.i9E3l5910978@candle.pha.pa.us> +Subject: Re: Free PostgreSQL Training, Philadelphia, Oct 30 +In-Reply-To: <200410131536.33286.josh@agliodbs.com> +To: josh@agliodbs.com +Date: Wed, 13 Oct 2004 23:47:05 -0400 (EDT) +Cc: pgsql-performance@postgresql.org, + Aaron Glenn +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/187 +X-Sequence-Number: 8663 + +Josh Berkus wrote: +> Aaron, +> +> > That makes two of us. Hanging out with Tom, Bruce, and others at OSCON +> > 2002 was one of the most informative and fun times I've had. That and +> > I could really stand to brush up on my Postgres basics +> +> You're thinking of Jan. Tom wasn't at OSCON. ;-) + +Ah, but he said 2002 and I think Tom was there that year. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Oct 14 04:52:46 2004 +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 33E6A32C6E1 + for ; + Thu, 14 Oct 2004 04:52:44 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34642-05 + for ; + Thu, 14 Oct 2004 03:52:40 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id BB7D832C6DE + for ; + Thu, 14 Oct 2004 04:52:40 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CHwfD-0005tv-00; Wed, 13 Oct 2004 23:52:27 -0400 +To: Jan Wieck +Cc: Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +References: <200410081443.16109.josh@agliodbs.com> + <416DCCFF.70304@Yahoo.com> +In-Reply-To: <416DCCFF.70304@Yahoo.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 13 Oct 2004 23:52:27 -0400 +Message-ID: <871xg25538.fsf@stark.xeocode.com> +Lines: 34 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/188 +X-Sequence-Number: 8664 + +Jan Wieck writes: + +> On 10/8/2004 10:10 PM, Christopher Browne wrote: +> +> > josh@agliodbs.com (Josh Berkus) wrote: +> >> I've been trying to peg the "sweet spot" for shared memory using +> >> OSDL's equipment. With Jan's new ARC patch, I was expecting that +> >> the desired amount of shared_buffers to be greatly increased. This +> >> has not turned out to be the case. +> > That doesn't surprise me. +> +> Neither does it surprise me. + +There's been some speculation that having a large shared buffers be about 50% +of your RAM is pessimal as it guarantees the OS cache is merely doubling up on +all the buffers postgres is keeping. I wonder whether there's a second sweet +spot where the postgres cache is closer to the total amount of RAM. + +That configuration would have disadvantages for servers running other jobs +besides postgres. And I was led to believe earlier that postgres starts each +backend with a fairly fresh slate as far as the ARC algorithm, so it wouldn't +work well for a postgres server that had lots of short to moderate life +sessions. + +But if it were even close it could be interesting. Reading the data with +O_DIRECT and having a single global cache could be interesting experiments. I +know there are arguments against each of these, but ... + +I'm still pulling for an mmap approach to eliminate postgres's buffer cache +entirely in the long term, but it seems like slim odds now. But one way or the +other having two layers of buffering seems like a waste. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Oct 14 05:17:56 2004 +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 81E8A32C59B + for ; + Thu, 14 Oct 2004 05:17:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42297-04 + for ; + Thu, 14 Oct 2004 04:17:42 +0000 (GMT) +Received: from smtp108.mail.sc5.yahoo.com (smtp108.mail.sc5.yahoo.com + [66.163.170.6]) + by svr1.postgresql.org (Postfix) with SMTP id D2F9E32A60E + for ; + Thu, 14 Oct 2004 05:17:41 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp108.mail.sc5.yahoo.com with SMTP; 14 Oct 2004 04:17:40 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9E4HX94074613; Thu, 14 Oct 2004 00:17:34 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <416DFDDE.5070600@Yahoo.com> +Date: Thu, 14 Oct 2004 00:17:34 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +References: <200410081443.16109.josh@agliodbs.com> + + <416DCCFF.70304@Yahoo.com> <871xg25538.fsf@stark.xeocode.com> +In-Reply-To: <871xg25538.fsf@stark.xeocode.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/189 +X-Sequence-Number: 8665 + +On 10/13/2004 11:52 PM, Greg Stark wrote: + +> Jan Wieck writes: +> +>> On 10/8/2004 10:10 PM, Christopher Browne wrote: +>> +>> > josh@agliodbs.com (Josh Berkus) wrote: +>> >> I've been trying to peg the "sweet spot" for shared memory using +>> >> OSDL's equipment. With Jan's new ARC patch, I was expecting that +>> >> the desired amount of shared_buffers to be greatly increased. This +>> >> has not turned out to be the case. +>> > That doesn't surprise me. +>> +>> Neither does it surprise me. +> +> There's been some speculation that having a large shared buffers be about 50% +> of your RAM is pessimal as it guarantees the OS cache is merely doubling up on +> all the buffers postgres is keeping. I wonder whether there's a second sweet +> spot where the postgres cache is closer to the total amount of RAM. + +Which would require that shared memory is not allowed to be swapped out, +and that is allowed in Linux by default IIRC, not to completely distort +the entire test. + + +Jan + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-performance-owner@postgresql.org Thu Oct 14 05:22:55 2004 +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 E7F1732A43F + for ; + Thu, 14 Oct 2004 05:22:53 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42515-05 + for ; + Thu, 14 Oct 2004 04:22:44 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 0347132BEED + for ; + Thu, 14 Oct 2004 05:22:44 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CHx8T-0005zx-00; Thu, 14 Oct 2004 00:22:41 -0400 +To: Jan Wieck +Cc: Greg Stark , Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +References: <200410081443.16109.josh@agliodbs.com> + <416DCCFF.70304@Yahoo.com> + <871xg25538.fsf@stark.xeocode.com> <416DFDDE.5070600@Yahoo.com> +In-Reply-To: <416DFDDE.5070600@Yahoo.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 14 Oct 2004 00:22:40 -0400 +Message-ID: <87sm8i3p4f.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/190 +X-Sequence-Number: 8666 + +Jan Wieck writes: + +> Which would require that shared memory is not allowed to be swapped out, and +> that is allowed in Linux by default IIRC, not to completely distort the entire +> test. + +Well if it's getting swapped out then it's clearly not being used effectively. + +There are APIs to bar swapping out pages and the tests could be run without +swap. I suggested it only as an experiment though, there are lots of details +between here and having it be a good configuration for production use. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Oct 14 05:29:26 2004 +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 72BB532BD7F + for ; + Thu, 14 Oct 2004 05:29:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44858-04 + for ; + Thu, 14 Oct 2004 04:29:22 +0000 (GMT) +Received: from smtp111.mail.sc5.yahoo.com (smtp111.mail.sc5.yahoo.com + [66.163.170.9]) + by svr1.postgresql.org (Postfix) with SMTP id 680A732A9C1 + for ; + Thu, 14 Oct 2004 05:29:21 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp111.mail.sc5.yahoo.com with SMTP; 14 Oct 2004 04:29:20 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9E4TI94074678; Thu, 14 Oct 2004 00:29:19 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <416E009F.3010709@Yahoo.com> +Date: Thu, 14 Oct 2004 00:29:19 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +References: <200410081443.16109.josh@agliodbs.com> + + <416DCCFF.70304@Yahoo.com> <871xg25538.fsf@stark.xeocode.com> + <416DFDDE.5070600@Yahoo.com> <87sm8i3p4f.fsf@stark.xeocode.com> +In-Reply-To: <87sm8i3p4f.fsf@stark.xeocode.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/191 +X-Sequence-Number: 8667 + +On 10/14/2004 12:22 AM, Greg Stark wrote: + +> Jan Wieck writes: +> +>> Which would require that shared memory is not allowed to be swapped out, and +>> that is allowed in Linux by default IIRC, not to completely distort the entire +>> test. +> +> Well if it's getting swapped out then it's clearly not being used effectively. + +Is it really that easy if 3 different cache algorithms (PG cache, kernel +buffers and swapping) are competing for the same chips? + + +Jan + +> +> There are APIs to bar swapping out pages and the tests could be run without +> swap. I suggested it only as an experiment though, there are lots of details +> between here and having it be a good configuration for production use. +> + + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-hackers-win32-owner@postgresql.org Thu Oct 14 18:06:23 2004 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 05CE332A4FC; + Thu, 14 Oct 2004 18:02:06 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76102-09; Thu, 14 Oct 2004 17:02:03 +0000 (GMT) +Received: from hotmail.com (bay10-dav14.bay10.hotmail.com [64.4.37.188]) + by svr1.postgresql.org (Postfix) with ESMTP id 79BAA32A273; + Thu, 14 Oct 2004 18:02:02 +0100 (BST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 14 Oct 2004 10:02:01 -0700 +Received: from 199.249.167.148 by BAY10-DAV14.phx.gbl with DAV; + Thu, 14 Oct 2004 17:01:43 +0000 +X-Originating-IP: [199.249.167.148] +X-Originating-Email: [mikesmialek2@hotmail.com] +X-Sender: mikesmialek2@hotmail.com +From: "MikeSmialek2@Hotmail.com" +To: , + +Subject: Performance on Win32 vs Cygwin +Date: Thu, 14 Oct 2004 12:01:38 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Message-ID: +X-OriginalArrivalTime: 14 Oct 2004 17:02:01.0458 (UTC) + FILETIME=[85F02D20:01C4B20F] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/64 +X-Sequence-Number: 2354 + +Hi, + +We are experiencing slow performance on 8 Beta 2 Dev3 on Win32 and are +trying to determine why. Any info is appreciated. + +We have a Web Server and a DB server both running Win2KServer with all +service packs and critical updates. + +An ASP page on the Web Server hits the DB Server with a simple query that +returns 205 rows and makes the ASP page delivered to the user about 350K. + +On an ethernet lan a client pc perceives just under 1 sec performance with +the following DB Server configuration: + PIII 550Mhz + 256MB RAM + 7200 RPM HD + cygwin + Postgresql 7.1.3 + PGODBC 7.3.2 + +We set up another DB Server with 8 beta (same Web Server, same network, same +client pc) and now the client pc perceives response of just over 3 sec with +the following DB server config: + PIII 700 Mhz + 448MB RAM + 7200 RPM HD + 8 Beta 2 Dev3 on Win32 running as a service + +Is the speed decrease because it's a beta? +Is the speed decrease because it's running on Win instead of cygwin? + +We did not install cygwin on the new DB Server. + +Thanks, + +Mike + + + + +From pgsql-hackers-win32-owner@postgresql.org Thu Oct 14 18:29:46 2004 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CC97B32A821; + Thu, 14 Oct 2004 18:29:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90314-01; Thu, 14 Oct 2004 17:29:29 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id E02DE32A084; + Thu, 14 Oct 2004 18:29:28 +0100 (BST) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 3A50A8F38F; Thu, 14 Oct 2004 19:29:26 +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 on Win32 vs Cygwin +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Date: Thu, 14 Oct 2004 19:29:25 +0200 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE475EE5@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [pgsql-hackers-win32] Performance on Win32 vs Cygwin +Thread-Index: AcSyEDdpszD9R4IDSBicK3E0DhHuuAAAu0PA +From: "Magnus Hagander" +To: "MikeSmialek2@Hotmail.com" , + , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/65 +X-Sequence-Number: 2355 + +>Hi, +> +>We are experiencing slow performance on 8 Beta 2 Dev3 on Win32 and are +>trying to determine why. Any info is appreciated. +> +>We have a Web Server and a DB server both running Win2KServer with all +>service packs and critical updates. +> +>An ASP page on the Web Server hits the DB Server with a simple=20 +>query that +>returns 205 rows and makes the ASP page delivered to the user=20 +>about 350K. +> +>On an ethernet lan a client pc perceives just under 1 sec=20 +>performance with +>the following DB Server configuration: +> PIII 550Mhz +> 256MB RAM +> 7200 RPM HD +> cygwin +> Postgresql 7.1.3 +> PGODBC 7.3.2 +> +>We set up another DB Server with 8 beta (same Web Server, same=20 +>network, same +>client pc) and now the client pc perceives response of just=20 +>over 3 sec with +>the following DB server config: +> PIII 700 Mhz +> 448MB RAM +> 7200 RPM HD +> 8 Beta 2 Dev3 on Win32 running as a service +> +>Is the speed decrease because it's a beta? +>Is the speed decrease because it's running on Win instead of cygwin? +> +>We did not install cygwin on the new DB Server. + +IIRC, previous versions of postgresql (< 8.0) did not correctly sync +disks when running on Cygwin. I'm not 100% sure, can someone confirm? +8.0 does, and I beleive it does both under native win32 and cygwin. + +It's been my experience that the native version is slightly faster than +the cygwin one, but I've only compared 8.0 to 8.0. + + +//Magnus + + +From pgsql-performance-owner@postgresql.org Thu Oct 14 19:33:27 2004 +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 013A332B1B3 + for ; + Thu, 14 Oct 2004 19:33:25 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09484-07 + for ; + Thu, 14 Oct 2004 18:33:21 +0000 (GMT) +Received: from providerst.com.br (unknown [200.253.138.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 93E4832B1AA + for ; + Thu, 14 Oct 2004 19:33:21 +0100 (BST) +Brma: igor [192.168.1.104] +Received: from sistemas (igor [192.168.1.104]) + by providerst.com.br (8.11.6/8.11.6) with SMTP id i9EIQGp11506 + for ; Thu, 14 Oct 2004 16:26:16 -0200 +Message-ID: <003101c4b21d$10f00e60$6801a8c0@providerst.local> +From: "Igor Maciel Macaubas" +To: +Subject: Performance vs Schemas +Date: Thu, 14 Oct 2004 15:38:52 -0300 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_002E_01C4B203.E88590D0" +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.9 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_FONTCOLOR_BLUE, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/193 +X-Sequence-Number: 8669 + +This is a multi-part message in MIME format. + +------=_NextPart_000_002E_01C4B203.E88590D0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi all, + +I recently migrated my database from schema 'public' to multiple schema. +I have around 100 tables, and divided them in 14 different schemas, and the= +n adapted my application to use schemas as well. +I could percept that the query / insert / update times get pretty much fast= +er then when I was using the old unique schema, and I'd just like to confir= +m with you if using schemas speed up the things. Is that true ? + +What else I can do to speed up the query processing, best pratices, recomme= +ndations ... ? What about indexed views, does postgresql supports it? + +Regards, +Igor +-- +igor@providerst.com.br + +------=_NextPart_000_002E_01C4B203.E88590D0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi all,
+
 
+
I recently migrated my database from sc= +hema=20 +'public' to multiple schema.
+
I have around 100 tables, and divided t= +hem in=20 +14 different schemas, and then adapted my application to use schemas a= +s=20 +well.
+
I could percept that the query / insert= + /=20 +update times get pretty much faster then when I was using the old unique sc= +hema,=20 +and I'd just like to confirm with you if using schemas speed up the things.= + Is=20 +that true ?
+
 
+
What else I can do to speed up the quer= +y=20 +processing, best pratices, recommendations ... ? What about indexed views, = +does=20 +postgresql supports it?
+
 
+
Regards,
+
Igor
--
igor@providerst.com.br
+
 
+ +------=_NextPart_000_002E_01C4B203.E88590D0-- + + +From pgsql-performance-owner@postgresql.org Thu Oct 14 19:45:24 2004 +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 7C0BD32A589 + for ; + Thu, 14 Oct 2004 19:45:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14773-04 + for ; + Thu, 14 Oct 2004 18:45:14 +0000 (GMT) +Received: from loki.globexplorer.com (unknown [208.35.14.101]) + by svr1.postgresql.org (Postfix) with ESMTP id BF20732A200 + for ; + Thu, 14 Oct 2004 19:45:11 +0100 (BST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Performance vs Schemas +Date: Thu, 14 Oct 2004 11:45:10 -0700 +Message-ID: + <71E37EF6B7DCC1499CEA0316A256832801D4B992@loki.wc.globexplorer.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Performance vs Schemas +Thread-Index: AcSyHJ3fb3RT00EXRvSCzjKrxBWKgwAAGqen +From: "Gregory S. Williamson" +To: "Igor Maciel Macaubas" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/194 +X-Sequence-Number: 8670 + +Igor, + +I'm not sure if it is proper to state that schemas are themselves speeding = +things up. + +As an example, we have data that is usually accessed by county; when we put= + all of the data into one big table and select from it using a code for a c= +ounty of interest, the process is fairly slow as there are several hundred = +thousand candidate rows from that county in a table with many millions of r= +ows. When we broke out certain aspects of the data into schemas (one per co= +unty) the searches become very fast indeed because we can skip the searchin= +g for a specific county code with the relevant tables and there is less (un= +needed) data in the table being searched.=20=20 + +As always, "EXPLAIN ANALYZE ..." is your friend in understanding what the p= +lanner is doing with a given query. + +See for some useful i= +nformation, especially under the performance tips section. + +HTH, + +Greg Williamson +DBA +GlobeXplorer LLC + +-----Original Message----- +From: Igor Maciel Macaubas [mailto:igor@providerst.com.br] +Sent: Thu 10/14/2004 11:38 AM +To: pgsql-performance@postgresql.org +Cc:=09 +Subject: [PERFORM] Performance vs Schemas +Hi all, + +I recently migrated my database from schema 'public' to multiple schema. +I have around 100 tables, and divided them in 14 different schemas, and the= +n adapted my application to use schemas as well. +I could percept that the query / insert / update times get pretty much fast= +er then when I was using the old unique schema, and I'd just like to confir= +m with you if using schemas speed up the things. Is that true ? + +What else I can do to speed up the query processing, best pratices, recomme= +ndations ... ? What about indexed views, does postgresql supports it? + +Regards, +Igor +-- +igor@providerst.com.br + + + + +From pgsql-performance-owner@postgresql.org Tue Oct 19 22:03:49 2004 +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 1B15F32B42D + for ; + Thu, 14 Oct 2004 20:28:17 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28139-03 + for ; + Thu, 14 Oct 2004 19:28:02 +0000 (GMT) +Received: from hotmail.com (bay9-dav25.bay9.hotmail.com [64.4.46.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 6837A32B3F1 + for ; + Thu, 14 Oct 2004 20:28:02 +0100 (BST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 14 Oct 2004 12:28:01 -0700 +Received: from 67.81.98.198 by bay9-dav25.bay9.hotmail.com with DAV; + Thu, 14 Oct 2004 19:27:36 +0000 +X-Originating-IP: [67.81.98.198] +X-Originating-Email: [awerman@hotmail.com] +X-Sender: awerman@hotmail.com +From: "Aaron Werman" +To: "Gregory S. Williamson" , + "Igor Maciel Macaubas" , + +References: + <71E37EF6B7DCC1499CEA0316A256832801D4B992@loki.wc.globexplorer.net> +Subject: Re: Performance vs Schemas +Date: Thu, 14 Oct 2004 15:27:51 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: 7bit +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 +Message-ID: +X-OriginalArrivalTime: 14 Oct 2004 19:28:01.0699 (UTC) + FILETIME=[EB72DF30:01C4B223] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/289 +X-Sequence-Number: 8765 + +Right - if you split a table to a lot of more selective tables, it can often +dramatically change the plan options (e.g. - in a single table, selectivity +for a query may be 1% and require an expensive nested loop while in the more +restrictive table it may match 14% of the data and do a cheaper scan). + +Also - don't forget that just rebuilding a database cleanly can dramatically +improve performance. + +The only dbms I know that indexes views is MS SQL Server 2000, where it is a +limited form of materialized queries. pg doesn't do MQs, but check out +functional indices. + +/Aaron + +----- Original Message ----- +From: "Gregory S. Williamson" +To: "Igor Maciel Macaubas" ; + +Sent: Thursday, October 14, 2004 2:45 PM +Subject: Re: [PERFORM] Performance vs Schemas + + +Igor, + +I'm not sure if it is proper to state that schemas are themselves speeding +things up. + +As an example, we have data that is usually accessed by county; when we put +all of the data into one big table and select from it using a code for a +county of interest, the process is fairly slow as there are several hundred +thousand candidate rows from that county in a table with many millions of +rows. When we broke out certain aspects of the data into schemas (one per +county) the searches become very fast indeed because we can skip the +searching for a specific county code with the relevant tables and there is +less (unneeded) data in the table being searched. + +As always, "EXPLAIN ANALYZE ..." is your friend in understanding what the +planner is doing with a given query. + +See for some useful +information, especially under the performance tips section. + +HTH, + +Greg Williamson +DBA +GlobeXplorer LLC + +-----Original Message----- +From: Igor Maciel Macaubas [mailto:igor@providerst.com.br] +Sent: Thu 10/14/2004 11:38 AM +To: pgsql-performance@postgresql.org +Cc: +Subject: [PERFORM] Performance vs Schemas +Hi all, + +I recently migrated my database from schema 'public' to multiple schema. +I have around 100 tables, and divided them in 14 different schemas, and then +adapted my application to use schemas as well. +I could percept that the query / insert / update times get pretty much +faster then when I was using the old unique schema, and I'd just like to +confirm with you if using schemas speed up the things. Is that true ? + +What else I can do to speed up the query processing, best pratices, +recommendations ... ? What about indexed views, does postgresql supports it? + +Regards, +Igor +-- +igor@providerst.com.br + + + + +---------------------------(end of broadcast)--------------------------- +TIP 6: Have you searched our list archives? + + http://archives.postgresql.org + +From pgsql-hackers-win32-owner@postgresql.org Thu Oct 14 20:41:21 2004 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8425732B2F2; + Thu, 14 Oct 2004 20:41:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32120-03; Thu, 14 Oct 2004 19:41:02 +0000 (GMT) +Received: from smartmx-06.inode.at (smartmx-06.inode.at [213.229.60.38]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B17732B2B4; + Thu, 14 Oct 2004 20:41:02 +0100 (BST) +Received: from [62.99.252.218] (port=61998 helo=[192.168.0.2]) + by smartmx-06.inode.at with esmtp (Exim 4.30) + id 1CIBTB-0001OO-99; Thu, 14 Oct 2004 21:41:01 +0200 +Message-ID: <416ED64B.3070000@x-ray.at> +Date: Thu, 14 Oct 2004 21:40:59 +0200 +From: Reini Urban +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; + rv:1.8a3) Gecko/20040817 +X-Accept-Language: de, en +MIME-Version: 1.0 +To: pgsql-hackers-win32@postgresql.org +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance on Win32 vs Cygwin +References: <6BCB9D8A16AC4241919521715F4D8BCE475EE5@algol.sollentuna.se> +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCE475EE5@algol.sollentuna.se> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/67 +X-Sequence-Number: 2357 + +Magnus Hagander schrieb: +> IIRC, previous versions of postgresql (< 8.0) did not correctly sync +> disks when running on Cygwin. I'm not 100% sure, can someone confirm? +> 8.0 does, and I beleive it does both under native win32 and cygwin. + +yes, sync is a NOOP on cygwin. + +> It's been my experience that the native version is slightly faster than +> the cygwin one, but I've only compared 8.0 to 8.0. + +Sure. This is expected. Cygwin's interim's layer costs a lot of time. +(process handling, path resolution) +-- +Reini Urban +http://xarch.tu-graz.ac.at/home/rurban/ + +From pgsql-performance-owner@postgresql.org Thu Oct 14 20:59:17 2004 +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 8BECF32BA38 + for ; + Thu, 14 Oct 2004 20:59:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37592-10 + for ; + Thu, 14 Oct 2004 19:58:58 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id F0C3F32AE2C + for ; + Thu, 14 Oct 2004 20:58:58 +0100 (BST) +Received: (qmail 17950 invoked from network); 14 Oct 2004 20:00:23 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 14 Oct 2004 20:00:23 -0000 +Subject: Re: Excessive context switching on SMP Xeons +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Bill Montgomery +Cc: Michael Adler , + perform +In-Reply-To: <41658F8D.9090204@lulu.com> +References: <4162CA14.6080206@lulu.com> + <200410050947.36174.josh@agliodbs.com> <41630D50.3020308@lulu.com> + <200410051538.51664.josh@agliodbs.com> <41636D8E.1090403@rentec.com> + <41648446.5020102@bigfoot.com> <4164B48C.9060202@rentec.com> + <41656559.70100@lulu.com> <20041007181537.GA1693@pobox.com> + <41658F8D.9090204@lulu.com> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1097783954.7978.501.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Thu, 14 Oct 2004 15:59:14 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/195 +X-Sequence-Number: 8671 + +Bill, + +In order to manifest the context switch problem you will definitely +require clients to be set to more than one in pgbench. It only occurs +when 2 or more backends need access to shared memory. + +If you want help backpatching Gavin's patch I'll be glad to do it for +you, but you do need a recent kernel. + +Dave + + +On Thu, 2004-10-07 at 14:48, Bill Montgomery wrote: +> Michael Adler wrote: +> +> >On Thu, Oct 07, 2004 at 11:48:41AM -0400, Bill Montgomery wrote: +> > +> > +> >>Alan Stange wrote: +> >> +> >>The same test on a Dell PowerEdge 1750, Dual Xeon 3.2 GHz, 512k cache, +> >>HT on, Linux 2.4.21-20.ELsmp (RHEL 3), 4GB memory, pg 7.4.5: +> >> +> >>Far less performance that the Dual Opterons with a low number of +> >>clients, but the gap narrows as the number of clients goes up. Anyone +> >>smarter than me care to explain? +> >> +> >> +> > +> >You'll have to wait for someone smarter than you, but I will posit +> >this: Did you use a tmpfs filesystem like Alan? You didn't mention +> >either way. Alan did that as an attempt remove IO as a variable. +> > +> >-Mike +> > +> > +> +> Yes, I should have been more explicit. My goal was to replicate his +> experiment as closely as possible in my environment, so I did run my +> postgres data directory on a tmpfs. +> +> -Bill Montgomery +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 +www.postgresintl.com + + +From pgsql-performance-owner@postgresql.org Thu Oct 14 21:26:11 2004 +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 D9E0D32C3D2 + for ; + Thu, 14 Oct 2004 21:25:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45862-04 + for ; + Thu, 14 Oct 2004 20:25:34 +0000 (GMT) +Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [204.127.202.56]) + by svr1.postgresql.org (Postfix) with ESMTP id 2204532BB53 + for ; + Thu, 14 Oct 2004 21:25:34 +0100 (BST) +Received: from sysexperts.com + (c-24-6-183-218.client.comcast.net[24.6.183.218]) + by comcast.net (sccrmhc12) with ESMTP + id <2004101420253201200fshgme>; Thu, 14 Oct 2004 20:25:34 +0000 +Received: from localhost (localhost [127.0.0.1]) (uid 1000) + by filer with local; Thu, 14 Oct 2004 13:25:31 -0700 + id 000063D2.416EE0BB.00000CC1 +Date: Thu, 14 Oct 2004 13:25:31 -0700 +From: Kevin Brown +To: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Message-ID: <20041014202531.GD665@filer> +Mail-Followup-To: Kevin Brown , + pgsql-performance@postgresql.org +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +In-Reply-To: <4859.1097363137@sss.pgh.pa.us> +Organization: Frobozzco International +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/196 +X-Sequence-Number: 8672 + +Tom Lane wrote: +> Kevin Brown writes: +> > Tom Lane wrote: +> >> mmap() is Right Out because it does not afford us sufficient control +> >> over when changes to the in-memory data will propagate to disk. +> +> > ... that's especially true if we simply cannot +> > have the page written to disk in a partially-modified state (something +> > I can easily see being an issue for the WAL -- would the same hold +> > true of the index/data files?). +> +> You're almost there. Remember the fundamental WAL rule: log entries +> must hit disk before the data changes they describe. That means that we +> need not only a way of forcing changes to disk (fsync) but a way of +> being sure that changes have *not* gone to disk yet. In the existing +> implementation we get that by just not issuing write() for a given page +> until we know that the relevant WAL log entries are fsync'd down to +> disk. (BTW, this is what the LSN field on every page is for: it tells +> the buffer manager the latest WAL offset that has to be flushed before +> it can safely write the page.) +> +> mmap provides msync which is comparable to fsync, but AFAICS it +> provides no way to prevent an in-memory change from reaching disk too +> soon. This would mean that WAL entries would have to be written *and +> flushed* before we could make the data change at all, which would +> convert multiple updates of a single page into a series of write-and- +> wait-for-WAL-fsync steps. Not good. fsync'ing WAL once per transaction +> is bad enough, once per atomic action is intolerable. + +Hmm...something just occurred to me about this. + +Would a hybrid approach be possible? That is, use mmap() to handle +reads, and use write() to handle writes? + +Any code that wishes to write to a page would have to recognize that +it's doing so and fetch a copy from the storage manager (or +something), which would look to see if the page already exists as a +writeable buffer. If it doesn't, it creates it by allocating the +memory and then copying the page from the mmap()ed area to the new +buffer, and returning it. If it does, it just returns a pointer to +the buffer. There would obviously have to be some bookkeeping +involved: the storage manager would have to know how to map a mmap()ed +page back to a writeable buffer and vice-versa, so that once it +decides to write the buffer it can determine which page in the +original file the buffer corresponds to (so it can do the appropriate +seek()). + +In a write-heavy database, you'll end up with a lot of memory copy +operations, but with the scheme we currently use you get that anyway +(it just happens in kernel code instead of user code), so I don't see +that as much of a loss, if any. Where you win is in a read-heavy +database: you end up being able to read directly from the pages in the +kernel's page cache and thus save a memory copy from kernel space to +user space, not to mention the context switch that happens due to +issuing the read(). + + +Obviously you'd want to mmap() the file read-only in order to prevent +the issues you mention regarding an errant backend, and then reopen +the file read-write for the purpose of writing to it. In fact, you +could decouple the two: mmap() the file, then close the file -- the +mmap()ed region will remain mapped. Then, as long as the file remains +mapped, you need to open the file again only when you want to write to +it. + + +-- +Kevin Brown kevin@sysexperts.com + +From pgsql-performance-owner@postgresql.org Thu Oct 14 21:57:18 2004 +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 B17C032C143 + for ; + Thu, 14 Oct 2004 21:57:14 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58792-01 + for ; + Thu, 14 Oct 2004 20:57:10 +0000 (GMT) +Received: from providerst.com.br (unknown [200.253.138.61]) + by svr1.postgresql.org (Postfix) with ESMTP id B925C32C12B + for ; + Thu, 14 Oct 2004 21:57:06 +0100 (BST) +Brma: igor [192.168.1.104] +Received: from sistemas (igor [192.168.1.104]) + by providerst.com.br (8.11.6/8.11.6) with SMTP id i9EKo2p12490 + for ; Thu, 14 Oct 2004 18:50:02 -0200 +Message-ID: <001301c4b231$280c4190$6801a8c0@providerst.local> +From: "Igor Maciel Macaubas" +To: +Subject: View & Query Performance +Date: Thu, 14 Oct 2004 18:02:41 -0300 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0010_01C4B217.FFA54670" +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.2 tagged_above=0.0 required=5.0 tests=HTML_60_70, + HTML_FONTCOLOR_BLUE, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/197 +X-Sequence-Number: 8673 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0010_01C4B217.FFA54670 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi all, + +I'm trying to find smarter ways to dig data from my database, and have the = +following scenario: + +table1 +-- id +-- name +=2E +=2E +=2E +=2E +=2E +=2E + +table2 +-- id +-- number +=2E +=2E +=2E +=2E +=2E +=2E + +I want to create a view to give me back just what I want: +The id, the name and the number. +I tought in doing the following: +create view my_view as select t1.id, t1.name, t2.number from table1 as t1, = +table2 as t2 where t1.id =3D t2.id; + +Will this be enough fast ? Are there a faster way to make it work ?! +This table is mid-big, around 100K registers ..=20 + +Regards, +Igor +-- +igor@providerst.com.br + + + +------=_NextPart_000_0010_01C4B217.FFA54670 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi all,
+
 
+
I'm trying to find smarter ways to dig = +data from=20 +my database, and have the following scenario:
+
 
+
table1
+
-- id
+
-- name
+
.
+
.
+
.
+
.
+
.
+
.
+
 
+
table2
+
-- id
+
-- number
+
.
+
.
+
.
+
.
+
.
+
.
+
 
+
I want to create a view to give me back= + just=20 +what I want:
+
The id, the name and the number.= +
+
I tought in doing the following:= +
+
create view my_view as select= + t1.id,=20 +t1.name, t2.number from table1 as t1, table2 as t2 where t1.id = +=3D=20 +t2.id;
+
 
+
Will this be enough fast ? Are there a = +faster=20 +way to make it work ?!
+
This table is mid-big, around 100K regi= +sters ..=20 +
+
 
+
Regards,
+
Igor
--
igor@providerst.com.br
+
 
+
 
+
 
+ +------=_NextPart_000_0010_01C4B217.FFA54670-- + + +From pgsql-hackers-win32-owner@postgresql.org Thu Oct 14 22:49:49 2004 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D507632B010; + Thu, 14 Oct 2004 22:46:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72230-08; Thu, 14 Oct 2004 21:46:02 +0000 (GMT) +Received: from hotmail.com (bay10-dav18.bay10.hotmail.com [64.4.37.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 2AF6D32B00A; + Thu, 14 Oct 2004 22:46:03 +0100 (BST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 14 Oct 2004 14:46:03 -0700 +Received: from 199.249.167.148 by BAY10-DAV18.phx.gbl with DAV; + Thu, 14 Oct 2004 21:45:55 +0000 +X-Originating-IP: [199.249.167.148] +X-Originating-Email: [mikesmialek2@hotmail.com] +X-Sender: mikesmialek2@hotmail.com +From: "MikeSmialek2@Hotmail.com" +To: "Magnus Hagander" , + , + +References: <6BCB9D8A16AC4241919521715F4D8BCE475EE5@algol.sollentuna.se> +Subject: Re: Performance on Win32 vs Cygwin +Date: Thu, 14 Oct 2004 16:45:51 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Message-ID: +X-OriginalArrivalTime: 14 Oct 2004 21:46:03.0135 (UTC) + FILETIME=[3391B8F0:01C4B237] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/70 +X-Sequence-Number: 2360 + +Thanks Magnus, + +So are we correct to rely on +- 8 being slower than 7.x in general and +- 8 on Win32 being a little faster than 8 on Cygwin? + +Will the final release of 8 be faster than the beta? + +Thanks, + +Mike + + +----- Original Message ----- +From: "Magnus Hagander" +To: "MikeSmialek2@Hotmail.com" ; +; +Sent: Thursday, October 14, 2004 12:29 PM +Subject: SV: [pgsql-hackers-win32] Performance on Win32 vs Cygwin + + +>Hi, +> +>We are experiencing slow performance on 8 Beta 2 Dev3 on Win32 and are +>trying to determine why. Any info is appreciated. +> +>We have a Web Server and a DB server both running Win2KServer with all +>service packs and critical updates. +> +>An ASP page on the Web Server hits the DB Server with a simple +>query that +>returns 205 rows and makes the ASP page delivered to the user +>about 350K. +> +>On an ethernet lan a client pc perceives just under 1 sec +>performance with +>the following DB Server configuration: +> PIII 550Mhz +> 256MB RAM +> 7200 RPM HD +> cygwin +> Postgresql 7.1.3 +> PGODBC 7.3.2 +> +>We set up another DB Server with 8 beta (same Web Server, same +>network, same +>client pc) and now the client pc perceives response of just +>over 3 sec with +>the following DB server config: +> PIII 700 Mhz +> 448MB RAM +> 7200 RPM HD +> 8 Beta 2 Dev3 on Win32 running as a service +> +>Is the speed decrease because it's a beta? +>Is the speed decrease because it's running on Win instead of cygwin? +> +>We did not install cygwin on the new DB Server. + +IIRC, previous versions of postgresql (< 8.0) did not correctly sync +disks when running on Cygwin. I'm not 100% sure, can someone confirm? +8.0 does, and I beleive it does both under native win32 and cygwin. + +It's been my experience that the native version is slightly faster than +the cygwin one, but I've only compared 8.0 to 8.0. + + +//Magnus + + +From pgsql-performance-owner@postgresql.org Thu Oct 14 23:18:18 2004 +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 8A3D332B1AA + for ; + Thu, 14 Oct 2004 23:18:09 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81361-06 + for ; + Thu, 14 Oct 2004 22:17:59 +0000 (GMT) +Received: from cmailm2.svr.pol.co.uk (cmailm2.svr.pol.co.uk [195.92.193.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 739D032B1A4 + for ; + Thu, 14 Oct 2004 23:17:59 +0100 (BST) +Received: from modem-649.lynx.dialup.pol.co.uk ([217.135.194.137] + helo=happyplace) by cmailm2.svr.pol.co.uk with smtp (Exim 4.14) + id 1CIDux-0002Vd-I8; Thu, 14 Oct 2004 23:17:51 +0100 +From: "Simon Riggs" +To: , +Cc: +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Date: Thu, 14 Oct 2004 23:36:22 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +In-Reply-To: <200410081443.16109.josh@agliodbs.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=LOTS_OF_STUFF +X-Spam-Level: +X-Archive-Number: 200410/198 +X-Sequence-Number: 8674 + + +First off, I'd like to get involved with these tests - pressure of other +work only has prevented me. + +Here's my take on the results so far: + +I think taking the ratio of the memory allocated to shared_buffers against +the total memory available on the server is completely fallacious. That is +why they cannnot be explained - IMHO the ratio has no real theoretical +basis. + +The important ratio for me is the amount of shared_buffers against the total +size of the database in the benchmark test. Every database workload has a +differing percentage of the total database size that represents the "working +set", or the memory that can be beneficially cached. For the tests that +DBT-2 is performing, I say that there is only so many blocks that are worth +the trouble caching. If you cache more than this, you are wasting your time. + +For me, these tests don't show that there is a "sweet spot" that you should +set your shared_buffers to, only that for that specific test, you have +located the correct size for shared_buffers. For me, it would be an +incorrect inference that this could then be interpreted that this was the +percentage of the available RAM where the "sweet spot" lies for all +workloads. + +The theoretical basis for my comments is this: DBT-2 is essentially a static +workload. That means, for a long test, we can work out with reasonable +certainty the probability that a block will be requested, for every single +block in the database. Given a particular size of cache, you can work out +what your overall cache hit ratio is and therfore what your speed up is +compared with retrieving every single block from disk (the no cache +scenario). If you draw a graph of speedup (y) against cache size as a % of +total database size, the graph looks like an upside-down "L" - i.e. the +graph rises steeply as you give it more memory, then turns sharply at a +particular point, after which it flattens out. The "turning point" is the +"sweet spot" we all seek - the optimum amount of cache memory to allocate - +but this spot depends upon the worklaod and database size, not on available +RAM on the system under test. + +Clearly, the presence of the OS disk cache complicates this. Since we have +two caches both allocated from the same pot of memory, it should be clear +that if we overallocate one cache beyond its optimium effectiveness, while +the second cache is still in its "more is better" stage, then we will get +reduced performance. That seems to be the case here. I wouldn't accept that +a fixed ratio between the two caches exists for ALL, or even the majority of +workloads - though clearly broad brush workloads such as "OLTP" and "Data +Warehousing" do have similar-ish requirements. + +As an example, lets look at an example: +An application with two tables: SmallTab has 10,000 rows of 100 bytes each +(so table is ~1 Mb)- one row per photo in a photo gallery web site. LargeTab +has large objects within it and has 10,000 photos, average size 10 Mb (so +table is ~100Gb). Assuming all photos are requested randomly, you can see +that an optimum cache size for this workload is 1Mb RAM, 100Gb disk. Trying +to up the cache doesn't have much effect on the probability that a photo +(from LargeTab) will be in cache, unless you have a large % of 100Gb of RAM, +when you do start to make gains. (Please don't be picky about indexes, +catalog, block size etc). That clearly has absolutely nothing at all to do +with the RAM of the system on which it is running. + +I think Jan has said this also in far fewer words, but I'll leave that to +Jan to agree/disagree... + +I say this: ARC in 8.0 PostgreSQL allows us to sensibly allocate as large a +shared_buffers cache as is required by the database workload, and this +should not be constrained to a small percentage of server RAM. + +Best Regards, + +Simon Riggs + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Josh Berkus +> Sent: 08 October 2004 22:43 +> To: pgsql-performance@postgresql.org +> Cc: testperf-general@pgfoundry.org +> Subject: [PERFORM] First set of OSDL Shared Mem scalability results, +> some wierdness ... +> +> +> Folks, +> +> I'm hoping that some of you can shed some light on this. +> +> I've been trying to peg the "sweet spot" for shared memory using OSDL's +> equipment. With Jan's new ARC patch, I was expecting that the desired +> amount of shared_buffers to be greatly increased. This has not +> turned out to +> be the case. +> +> The first test series was using OSDL's DBT2 (OLTP) test, with 150 +> "warehouses". All tests were run on a 4-way Pentium III 700mhz +> 3.8GB RAM +> system hooked up to a rather high-end storage device (14 +> spindles). Tests +> were on PostgreSQL 8.0b3, Linux 2.6.7. +> +> Here's a top-level summary: +> +> shared_buffers % RAM NOTPM20* +> 1000 0.2% 1287 +> 23000 5% 1507 +> 46000 10% 1481 +> 69000 15% 1382 +> 92000 20% 1375 +> 115000 25% 1380 +> 138000 30% 1344 +> +> * = New Order Transactions Per Minute, last 20 Minutes +> Higher is better. The maximum possible is 1800. +> +> As you can see, the "sweet spot" appears to be between 5% and 10% of RAM, +> which is if anything *lower* than recommendations for 7.4! +> +> This result is so surprising that I want people to take a look at +> it and tell +> me if there's something wrong with the tests or some bottlenecking factor +> that I've not seen. +> +> in order above: +> http://khack.osdl.org/stp/297959/ +> http://khack.osdl.org/stp/297960/ +> http://khack.osdl.org/stp/297961/ +> http://khack.osdl.org/stp/297962/ +> http://khack.osdl.org/stp/297963/ +> http://khack.osdl.org/stp/297964/ +> http://khack.osdl.org/stp/297965/ +> +> Please note that many of the Graphs in these reports are broken. For one +> thing, some aren't recorded (flat lines) and the CPU usage graph has +> mislabeled lines. +> +> -- +> --Josh +> +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 00:55:56 2004 +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 0FB6632AC23 + for ; + Fri, 15 Oct 2004 00:55:54 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02518-10 + for ; + Thu, 14 Oct 2004 23:55:48 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id A502932A9F8 + for ; + Fri, 15 Oct 2004 00:55:50 +0100 (BST) +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 6504705; Thu, 14 Oct 2004 16:57:14 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Date: Thu, 14 Oct 2004 16:57:45 -0700 +User-Agent: KMail/1.6.2 +Cc: "Simon Riggs" , + +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410141657.45415.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/199 +X-Sequence-Number: 8675 + +Simon, + + + +> If you draw a graph of speedup (y) against cache size as a +> % of total database size, the graph looks like an upside-down "L" - i.e. +> the graph rises steeply as you give it more memory, then turns sharply at a +> particular point, after which it flattens out. The "turning point" is the +> "sweet spot" we all seek - the optimum amount of cache memory to allocate - +> but this spot depends upon the worklaod and database size, not on available +> RAM on the system under test. + +Hmmm ... how do you explain, then the "camel hump" nature of the real +performance? That is, when we allocated even a few MB more than the +"optimum" ~190MB, overall performance stated to drop quickly. The result is +that allocating 2x optimum RAM is nearly as bad as allocating too little +(e.g. 8MB). + +The only explanation I've heard of this so far is that there is a significant +loss of efficiency with larger caches. Or do you see the loss of 200MB out +of 3500MB would actually affect the Kernel cache that much? + +Anyway, one test of your theory that I can run immediately is to run the exact +same workload on a bigger, faster server and see if the desired quantity of +shared_buffers is roughly the same. I'm hoping that you're wrong -- not +because I don't find your argument persuasive, but because if you're right it +leaves us without any reasonable ability to recommend shared_buffer settings. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Oct 15 01:09:09 2004 +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 9198C32A90A + for ; + Fri, 15 Oct 2004 01:09:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08770-03 + for ; + Fri, 15 Oct 2004 00:08:56 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 3589332A828 + for ; + Fri, 15 Oct 2004 01:08:57 +0100 (BST) +Received: from localhost (osdlab.pdx.osdl.net [172.20.1.28]) + by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i9F08t916459; + Thu, 14 Oct 2004 17:08:55 -0700 +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Mem +From: "Timothy D. Witham" +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org, + Simon Riggs , testperf-general@pgfoundry.org +In-Reply-To: <200410141657.45415.josh@agliodbs.com> +References: + <200410141657.45415.josh@agliodbs.com> +Content-Type: text/plain +Organization: Open Source Development Lab, Inc. +Date: Thu, 14 Oct 2004 17:09:05 -0700 +Message-Id: <1097798945.6387.86.camel@wookie-zd7> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.0 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/200 +X-Sequence-Number: 8676 + +On Thu, 2004-10-14 at 16:57 -0700, Josh Berkus wrote: +> Simon, +> +> +> +> > If you draw a graph of speedup (y) against cache size as a +> > % of total database size, the graph looks like an upside-down "L" - i.e. +> > the graph rises steeply as you give it more memory, then turns sharply at a +> > particular point, after which it flattens out. The "turning point" is the +> > "sweet spot" we all seek - the optimum amount of cache memory to allocate - +> > but this spot depends upon the worklaod and database size, not on available +> > RAM on the system under test. +> +> Hmmm ... how do you explain, then the "camel hump" nature of the real +> performance? That is, when we allocated even a few MB more than the +> "optimum" ~190MB, overall performance stated to drop quickly. The result is +> that allocating 2x optimum RAM is nearly as bad as allocating too little +> (e.g. 8MB). +> +> The only explanation I've heard of this so far is that there is a significant +> loss of efficiency with larger caches. Or do you see the loss of 200MB out +> of 3500MB would actually affect the Kernel cache that much? +> + In a past life there seemed to be a sweet spot around the +applications +working set. Performance went up until you got just a little larger +than +the cache needed to hold the working set and then went down. Most of +the time a nice looking hump. It seems to have to do with the +additional pages +not increasing your hit ratio but increasing the amount of work to get a +hit in cache. This seemed to be independent of the actual database +software being used. (I observed this running Oracle, Informix, Sybase +and Ingres.) + +> Anyway, one test of your theory that I can run immediately is to run the exact +> same workload on a bigger, faster server and see if the desired quantity of +> shared_buffers is roughly the same. I'm hoping that you're wrong -- not +> because I don't find your argument persuasive, but because if you're right it +> leaves us without any reasonable ability to recommend shared_buffer settings. +> +-- +Timothy D. Witham - Chief Technology Officer - wookie@osdl.org +Open Source Development Lab Inc - A non-profit corporation +12725 SW Millikan Way - Suite 400 - Beaverton OR, 97005 +(503)-626-2455 x11 (office) (503)-702-2871 (cell) +(503)-626-2436 (fax) + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 02:19:26 2004 +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 05A7932BA82 + for ; + Fri, 15 Oct 2004 02:19:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25035-05 + for ; + Fri, 15 Oct 2004 01:19:16 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id E259A32B3AB + for ; + Fri, 15 Oct 2004 02:19:19 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9F1JFJ9025861 + for ; Fri, 15 Oct 2004 01:19:15 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9F0o1pt018278 + for pgsql-performance@postgresql.org; Fri, 15 Oct 2004 00:50:01 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Date: Thu, 14 Oct 2004 20:10:59 -0400 +Organization: cbbrowne Computing Inc +Lines: 37 +Message-ID: +References: <200410081443.16109.josh@agliodbs.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:XQr6mfAZWXpVgi6qa+zMNUctOcE= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/204 +X-Sequence-Number: 8680 + +Quoth simon@2ndquadrant.com ("Simon Riggs"): +> I say this: ARC in 8.0 PostgreSQL allows us to sensibly allocate as +> large a shared_buffers cache as is required by the database +> workload, and this should not be constrained to a small percentage +> of server RAM. + +I don't think that this particularly follows from "what ARC does." + +"What ARC does" is to prevent certain conspicuous patterns of +sequential accesses from essentially trashing the contents of the +cache. + +If a particular benchmark does not include conspicuous vacuums or +sequential scans on large tables, then there is little reason to +expect ARC to have a noticeable impact on performance. + +It _could_ be that this implies that ARC allows you to get some use +out of a larger shared cache, as it won't get blown away by vacuums +and Seq Scans. But it is _not_ obvious that this is a necessary +truth. + +_Other_ truths we know about are: + + a) If you increase the shared cache, that means more data that is + represented in both the shared cache and the OS buffer cache, + which seems rather a waste; + + b) The larger the shared cache, the more pages there are for the + backend to rummage through before it looks to the filesystem, + and therefore the more expensive cache misses get. Cache hits + get more expensive, too. Searching through memory is not + costless. +-- +(format nil "~S@~S" "cbbrowne" "acm.org") +http://linuxfinances.info/info/linuxdistributions.html +"The X-Files are too optimistic. The truth is *not* out there..." +-- Anthony Ord + +From pgsql-performance-owner@postgresql.org Fri Oct 15 01:25:44 2004 +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 F3DF632B1BD + for ; + Fri, 15 Oct 2004 01:25:40 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10722-06 + for ; + Fri, 15 Oct 2004 00:25:34 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 4203332B0E9 + for ; + Fri, 15 Oct 2004 01:25:36 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 74so123281rnk + for ; + Thu, 14 Oct 2004 17:25:37 -0700 (PDT) +Received: by 10.38.102.60 with SMTP id z60mr3324377rnb; + Thu, 14 Oct 2004 17:25:36 -0700 (PDT) +Received: by 10.38.151.75 with HTTP; Thu, 14 Oct 2004 17:25:36 -0700 (PDT) +Message-ID: <157f64840410141725162e43b5@mail.gmail.com> +Date: Thu, 14 Oct 2004 20:25:36 -0400 +From: Aaron Werman +Reply-To: Aaron Werman +To: pgsql-performance@postgresql.org, + Kevin Brown +Subject: mmap (was First set of OSDL Shared Mem scalability results, + some wierdness ... +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/201 +X-Sequence-Number: 8677 + +pg to my mind is unique in not trying to avoid OS buffering. Other +dbmses spend a substantial effort to create a virtual OS (task +management, I/O drivers, etc.) both in code and support. Choosing mmap +seems such a limiting an option - it adds OS dependency and limits +kernel developer options (2G limits, global mlock serializations, +porting problems, inability to schedule or parallelize I/O, still +having to coordinate writers and readers). + +More to the point, I think it is very hard to effectively coordinate +multithreaded I/O, and mmap seems used mostly to manage relatively +simple scenarios. If the I/O options are: +- OS (which has enormous investment and is stable, but is general +purpose with overhead) +- pg (direct I/O would be costly and potentially destabilizing, but +with big possible performance rewards) +- mmap (a feature mostly used to reduce buffer copies in less +concurrent apps such as image processing that has major architectural +risk including an order of magnitude more semaphores, but can reduce +some extra block copies) +mmap doesn't look that promising. + +/Aaron + +----- Original Message ----- +From: "Kevin Brown" +To: +Sent: Thursday, October 14, 2004 4:25 PM +Subject: Re: [PERFORM] First set of OSDL Shared Mem scalability +results, some wierdness ... + + +> Tom Lane wrote: +> > Kevin Brown writes: +> > > Tom Lane wrote: +> > >> mmap() is Right Out because it does not afford us sufficient control +> > >> over when changes to the in-memory data will propagate to disk. +> > +> > > ... that's especially true if we simply cannot +> > > have the page written to disk in a partially-modified state (something +> > > I can easily see being an issue for the WAL -- would the same hold +> > > true of the index/data files?). +> > +> > You're almost there. Remember the fundamental WAL rule: log entries +> > must hit disk before the data changes they describe. That means that we +> > need not only a way of forcing changes to disk (fsync) but a way of +> > being sure that changes have *not* gone to disk yet. In the existing +> > implementation we get that by just not issuing write() for a given page +> > until we know that the relevant WAL log entries are fsync'd down to +> > disk. (BTW, this is what the LSN field on every page is for: it tells +> > the buffer manager the latest WAL offset that has to be flushed before +> > it can safely write the page.) +> > +> > mmap provides msync which is comparable to fsync, but AFAICS it +> > provides no way to prevent an in-memory change from reaching disk too +> > soon. This would mean that WAL entries would have to be written *and +> > flushed* before we could make the data change at all, which would +> > convert multiple updates of a single page into a series of write-and- +> > wait-for-WAL-fsync steps. Not good. fsync'ing WAL once per transaction +> > is bad enough, once per atomic action is intolerable. +> +> Hmm...something just occurred to me about this. +> +> Would a hybrid approach be possible? That is, use mmap() to handle +> reads, and use write() to handle writes? +> +> Any code that wishes to write to a page would have to recognize that +> it's doing so and fetch a copy from the storage manager (or +> something), which would look to see if the page already exists as a +> writeable buffer. If it doesn't, it creates it by allocating the +> memory and then copying the page from the mmap()ed area to the new +> buffer, and returning it. If it does, it just returns a pointer to +> the buffer. There would obviously have to be some bookkeeping +> involved: the storage manager would have to know how to map a mmap()ed +> page back to a writeable buffer and vice-versa, so that once it +> decides to write the buffer it can determine which page in the +> original file the buffer corresponds to (so it can do the appropriate +> seek()). +> +> In a write-heavy database, you'll end up with a lot of memory copy +> operations, but with the scheme we currently use you get that anyway +> (it just happens in kernel code instead of user code), so I don't see +> that as much of a loss, if any. Where you win is in a read-heavy +> database: you end up being able to read directly from the pages in the +> kernel's page cache and thus save a memory copy from kernel space to +> user space, not to mention the context switch that happens due to +> issuing the read(). +> +> +> Obviously you'd want to mmap() the file read-only in order to prevent +> the issues you mention regarding an errant backend, and then reopen +> the file read-write for the purpose of writing to it. In fact, you +> could decouple the two: mmap() the file, then close the file -- the +> mmap()ed region will remain mapped. Then, as long as the file remains +> mapped, you need to open the file again only when you want to write to +> it. +> +> +> -- +> Kevin Brown kevin@sysexperts.com +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> +-- + +Regards, +/Aaron + +From pgsql-performance-owner@postgresql.org Fri Oct 15 01:52:47 2004 +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 4BBEE32A805 + for ; + Fri, 15 Oct 2004 01:52:44 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18222-02 + for ; + Fri, 15 Oct 2004 00:52:38 +0000 (GMT) +Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 8096C32A407 + for ; + Fri, 15 Oct 2004 01:52:40 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by sue.samurai.com (Postfix) with ESMTP id D706D197A4; + Thu, 14 Oct 2004 20:52:40 -0400 (EDT) +Received: from sue.samurai.com ([127.0.0.1]) + by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 42357-01-6; Thu, 14 Oct 2004 20:52:40 -0400 (EDT) +Received: from [61.88.101.19] (unknown [61.88.101.19]) + by sue.samurai.com (Postfix) with ESMTP id 309B519792; + Thu, 14 Oct 2004 20:52:38 -0400 (EDT) +Subject: Re: Performance vs Schemas +From: Neil Conway +To: Igor Maciel Macaubas +Cc: pgsql-performance@postgresql.org +In-Reply-To: <003101c4b21d$10f00e60$6801a8c0@providerst.local> +References: <003101c4b21d$10f00e60$6801a8c0@providerst.local> +Content-Type: text/plain +Message-Id: <1097801555.29932.11.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Fri, 15 Oct 2004 10:52:35 +1000 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/202 +X-Sequence-Number: 8678 + +On Fri, 2004-10-15 at 04:38, Igor Maciel Macaubas wrote: +> I have around 100 tables, and divided them in 14 different schemas, +> and then adapted my application to use schemas as well. +> I could percept that the query / insert / update times get pretty much +> faster then when I was using the old unique schema, and I'd just like +> to confirm with you if using schemas speed up the things. Is that true +> ? + +Schemas are a namespacing technique; AFAIK they shouldn't significantly +affect performance (either positively or negatively). + +> What about indexed views, does postgresql supports it? + +No, you'll need to create indexes on the view's base tables. + +-Neil + + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 02:08:49 2004 +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 9974732A61F + for ; + Fri, 15 Oct 2004 02:08:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20828-05 + for ; + Fri, 15 Oct 2004 01:08:41 +0000 (GMT) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 6781B32A518 + for ; + Fri, 15 Oct 2004 02:08:42 +0100 (BST) +Received: from sysexperts.com + (c-24-6-183-218.client.comcast.net[24.6.183.218]) + by comcast.net (sccrmhc13) with ESMTP + id <20041015010842016000kbste>; Fri, 15 Oct 2004 01:08:43 +0000 +Received: from localhost (localhost [127.0.0.1]) (uid 1000) + by filer with local; Thu, 14 Oct 2004 18:08:41 -0700 + id 000071AD.416F2319.00001B0A +Date: Thu, 14 Oct 2004 18:08:41 -0700 +From: Kevin Brown +To: pgsql-performance@postgresql.org +Subject: Re: mmap (was First set of OSDL Shared Mem scalability results, + some wierdness ... +Message-ID: <20041015010841.GE665@filer> +Mail-Followup-To: Kevin Brown , + pgsql-performance@postgresql.org +References: <157f64840410141725162e43b5@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +In-Reply-To: <157f64840410141725162e43b5@mail.gmail.com> +Organization: Frobozzco International +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/203 +X-Sequence-Number: 8679 + +Aaron Werman wrote: +> pg to my mind is unique in not trying to avoid OS buffering. Other +> dbmses spend a substantial effort to create a virtual OS (task +> management, I/O drivers, etc.) both in code and support. Choosing mmap +> seems such a limiting an option - it adds OS dependency and limits +> kernel developer options (2G limits, global mlock serializations, +> porting problems, inability to schedule or parallelize I/O, still +> having to coordinate writers and readers). + +I'm not sure I entirely agree with this. Whether you access a file +via mmap() or via read(), the end result is that you still have to +access it, and since PG has significant chunks of system-dependent +code that it heavily relies on as it is (e.g., locking mechanisms, +shared memory), writing the I/O subsystem in a similar way doesn't +seem to me to be that much of a stretch (especially since PG already +has the storage manager), though it might involve quite a bit of work. + +As for parallelization of I/O, the use of mmap() for reads should +signficantly improve parallelization -- now instead of issuing read() +system calls, possibly for the same set of blocks, all the backends +would essentially be examining the same data directly. The +performance improvements as a result of accessing the kernel's cache +pages directly instead of having it do buffer copies to process-local +memory should increase as concurrency goes up. But see below. + +> More to the point, I think it is very hard to effectively coordinate +> multithreaded I/O, and mmap seems used mostly to manage relatively +> simple scenarios. + +PG already manages and coordinates multithreaded I/O. The mechanisms +used to coordinate writes needn't change at all. But the way reads +are done relative to writes might have to be rethought, since an +mmap()ed buffer always reflects what's actually in kernel space at the +time the buffer is accessed, while a buffer retrieved via read() +reflects the state of the file at the time of the read(). If it's +necessary for the state of the buffers to be fixed at examination +time, then mmap() will be at best a draw, not a win. + +> mmap doesn't look that promising. + +This ultimately depends on two things: how much time is spent copying +buffers around in kernel memory, and how much advantage can be gained +by freeing up the memory used by the backends to store the +backend-local copies of the disk pages they use (and thus making that +memory available to the kernel to use for additional disk buffering). +The gains from the former are likely small. The gains from the latter +are probably also small, but harder to estimate. + +The use of mmap() is probably one of those optimizations that should +be done when there's little else left to optimize, because the +potential gains are possibly (if not probably) relatively small and +the amount of work involved may be quite large. + + +So I agree -- compared with other, much lower-hanging fruit, mmap() +doesn't look promising. + + + +-- +Kevin Brown kevin@sysexperts.com + +From pgsql-performance-owner@postgresql.org Fri Oct 15 02:41:46 2004 +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 65FA932A273 + for ; + Fri, 15 Oct 2004 02:41:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30856-01 + for ; + Fri, 15 Oct 2004 01:41:38 +0000 (GMT) +Received: from millenium.mst.co.jp (unknown [210.230.185.241]) + by svr1.postgresql.org (Postfix) with ESMTP id 5964F32BB51 + for ; + Fri, 15 Oct 2004 02:41:40 +0100 (BST) +Received: from mst1x5r347kymb (lc12114 [192.168.1.114]) + by millenium.mst.co.jp (8.11.6p2/3.7W) with SMTP id i9F1fWq08516; + Fri, 15 Oct 2004 10:41:32 +0900 +Message-ID: <00cb01c4b258$1e51a5b0$7201a8c0@mst1x5r347kymb> +From: "Iain" +To: "Igor Maciel Macaubas" , + +References: <003101c4b21d$10f00e60$6801a8c0@providerst.local> +Subject: Re: Performance vs Schemas +Date: Fri, 15 Oct 2004 10:41:35 +0900 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_00C3_01C4B2A3.8B373140" +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.6 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_FONTCOLOR_BLUE, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/205 +X-Sequence-Number: 8681 + +This is a multi-part message in MIME format. + +------=_NextPart_000_00C3_01C4B2A3.8B373140 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit + +Hi Igor, + +I expect that when you moved your tables to different schemas that you +effectively did a physical re-organization (ie unload/reload of the tables). +It's nothing to do with the use of schemas as such. If you had reloaded your +tables into the same system schema you would have experienced the same +speedup as the data tables would be more compact. + +regards +Iain + ----- Original Message ----- + From: Igor Maciel Macaubas + To: pgsql-performance@postgresql.org + Sent: Friday, October 15, 2004 3:38 AM + Subject: [PERFORM] Performance vs Schemas + + + Hi all, + + I recently migrated my database from schema 'public' to multiple schema. + I have around 100 tables, and divided them in 14 different schemas, and +then adapted my application to use schemas as well. + I could percept that the query / insert / update times get pretty much +faster then when I was using the old unique schema, and I'd just like to +confirm with you if using schemas speed up the things. Is that true ? + + What else I can do to speed up the query processing, best pratices, +recommendations ... ? What about indexed views, does postgresql supports it? + + Regards, + Igor + -- + igor@providerst.com.br + +------=_NextPart_000_00C3_01C4B2A3.8B373140 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi Igor,
+
 
+
I expect that when you moved your= + tables=20 +to different schemas that you effectively did a physical re-organization (i= +e=20 +unload/reload of the tables). It's nothing to do with the use of= +=20 +schemas as such. If you had reloaded your tables into the same system= +=20 +schema you would have experienced the same speedup as the data tables = +would=20 +be more compact.
+
 
+
regards
+
Iain
+
+
----- Original Message -----
+ From:=20 + = +Igor=20 + Maciel Macaubas
+
To: pgsql-performance@postgr= +esql.org=20 +
+
Sent: Friday, October 15, 2= +004=20 + 3:38 AM
+
Subject: [PERFORM] Performa= +nce vs=20 + Schemas
+

+
Hi all,
+
 
+
I recently migrated my database from = +schema=20 + 'public' to multiple schema.
+
I have around 100 tables, and divided= + them in=20 + 14 different schemas, and then adapted my application to use schemas= + as=20 + well.
+
I could percept that the query / inse= +rt /=20 + update times get pretty much faster then when I was using the old unique= +=20 + schema, and I'd just like to confirm with you if using schemas speed up t= +he=20 + things. Is that true ?
+
 
+
What else I can do to speed up the qu= +ery=20 + processing, best pratices, recommendations ... ? What about indexed views= +,=20 + does postgresql supports it?
+
 
+
Regards,
+
Igor
--
igor@providerst.com.br
<= +/DIV> +
 
+ +------=_NextPart_000_00C3_01C4B2A3.8B373140-- + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 06:13:42 2004 +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 92FB432C91F + for ; + Fri, 15 Oct 2004 06:13:40 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76884-10 + for ; + Fri, 15 Oct 2004 05:13:37 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8672D32C91E + for ; + Fri, 15 Oct 2004 06:13:37 +0100 (BST) +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 i9F5DaWu005236; + Fri, 15 Oct 2004 01:13:36 -0400 (EDT) +To: Kevin Brown +Cc: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +In-reply-to: <20041014202531.GD665@filer> +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + <20041014202531.GD665@filer> +Comments: In-reply-to Kevin Brown + message dated "Thu, 14 Oct 2004 13:25:31 -0700" +Date: Fri, 15 Oct 2004 01:13:36 -0400 +Message-ID: <5235.1097817216@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/206 +X-Sequence-Number: 8682 + +Kevin Brown writes: +> Hmm...something just occurred to me about this. + +> Would a hybrid approach be possible? That is, use mmap() to handle +> reads, and use write() to handle writes? + +Nope. Have you read the specs regarding mmap-vs-stdio synchronization? +Basically it says that there are no guarantees whatsoever if you try +this. The SUS text is a bit weaselly ("the application must ensure +correct synchronization") but the HPUX mmap man page, among others, +lays it on the line: + + It is also unspecified whether write references to a memory region + mapped with MAP_SHARED are visible to processes reading the file and + whether writes to a file are visible to processes that have mapped the + modified portion of that file, except for the effect of msync(). + +It might work on particular OSes but I think depending on such behavior +would be folly... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 08:28:31 2004 +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 6C7DB32C2F3 + for ; + Fri, 15 Oct 2004 08:28:27 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11608-02 + for ; + Fri, 15 Oct 2004 07:28:22 +0000 (GMT) +Received: from mailer.unicite.fr.netcentrex.net (unknown [62.161.167.249]) + by svr1.postgresql.org (Postfix) with ESMTP id B60AB32C2FC + for ; + Fri, 15 Oct 2004 08:28:20 +0100 (BST) +Received: from akira ([192.168.101.228]) by mailer.unicite.fr.netcentrex.net + with SMTP (Microsoft Exchange Internet Mail Service Version + 5.5.2657.72) id 42CYABK1; Fri, 15 Oct 2004 09:28:18 +0200 +From: "Alban Medici (NetCentrex)" +To: "'Igor Maciel Macaubas'" , + +Subject: Re: View & Query Performance +Date: Fri, 15 Oct 2004 09:28:18 +0200 +Organization: NetCentrex +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0050_01C4B299.4E97AD00" +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Thread-Index: AcSyMMsrEu7NNwBtSRmj3nO3Tb/vEQAV2chA +In-Reply-To: <001301c4b231$280c4190$6801a8c0@providerst.local> +Message-Id: <20041015072820.B60AB32C2FC@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_60_70, + HTML_FONTCOLOR_BLUE, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/207 +X-Sequence-Number: 8683 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0050_01C4B299.4E97AD00 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Can you tell us more about the structure of your tables, +witch sort of index did you set on witch fields ? +=20 +Did you really need to get ALL records at once, instead you may be could use +paging (cursor or SELECT LIMIT OFFSET ) ? +=20 +And did you well configure your .conf ? +=20 +Regards +=20 +Alban M=E9dici + + _____=20=20 + +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Igor Maciel +Macaubas +Sent: jeudi 14 octobre 2004 23:03 +To: pgsql-performance@postgresql.org +Subject: [PERFORM] View & Query Performance + + +Hi all, +=20 +I'm trying to find smarter ways to dig data from my database, and have the +following scenario: +=20 +table1 +-- id +-- name +=2E +=2E +=2E +=2E +=2E +=2E +=20 +table2 +-- id +-- number +=2E +=2E +=2E +=2E +=2E +=2E +=20 +I want to create a view to give me back just what I want: +The id, the name and the number. +I tought in doing the following: +create view my_view as select t1.id, t1.name, t2.number from table1 as t1, +table2 as t2 where t1.id =3D t2.id; +=20 +Will this be enough fast ? Are there a faster way to make it work ?! +This table is mid-big, around 100K registers ..=20 +=20 +Regards, +Igor +-- +igor@providerst.com.br +=20 +=20 +=20 + +------=_NextPart_000_0050_01C4B299.4E97AD00 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
Can you tell us more about the structure of your= +=20 +tables,
+
witch sort of index did you set on witch fields=20 +?
+
 
+
Did you really need to get ALL records at=20 +once, instead you may be could use pa= +ging=20 +(cursor or SELECT LIMIT OFFSET ) ?
+
 
+
And did you= + well=20 +configure your .conf ?
+
 
+
Regards
+
 
+
Alban=20 +M=E9dici

+
+
+From: pgsql-performance-owner@postgresq= +l.org=20 +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Igor Ma= +ciel=20 +Macaubas
Sent: jeudi 14 octobre 2004 23:03
To:=20 +pgsql-performance@postgresql.org
Subject: [PERFORM] View & Qu= +ery=20 +Performance

+
+
Hi all,
+
 
+
I'm trying to find smarter ways to dig = +data from=20 +my database, and have the following scenario:
+
 
+
table1
+
-- id
+
-- name
+
.
+
.
+
.
+
.
+
.
+
.
+
 
+
table2
+
-- id
+
-- number
+
.
+
.
+
.
+
.
+
.
+
.
+
 
+
I want to create a view to give me back= + just=20 +what I want:
+
The id, the name and the number.= +
+
I tought in doing the following:= +
+
create view my_view as select= + t1.id,=20 +t1.name, t2.number from table1 as t1, table2 as t2 where t1.id = +=3D=20 +t2.id;
+
 
+
Will this be enough fast ? Are there a = +faster=20 +way to make it work ?!
+
This table is mid-big, around 100K regi= +sters ..=20 +
+
 
+
Regards,
+
Igor
--
igor@providerst.com.br
+
 
+
 
+
 
+ +------=_NextPart_000_0050_01C4B299.4E97AD00-- + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 08:37:38 2004 +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 1BE1432C302 + for ; + Fri, 15 Oct 2004 08:37:37 +0100 (BST) +Received: 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-05 + for ; + Fri, 15 Oct 2004 07:37:32 +0000 (GMT) +Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net + [194.217.242.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BCF132C30B + for ; + Fri, 15 Oct 2004 08:37:33 +0100 (BST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-33.mail.demon.net with esmtp (Exim 4.42) + id 1CIMeu-0004g7-9m; Fri, 15 Oct 2004 07:38:06 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 5F20C15A0F; Fri, 15 Oct 2004 08:37:07 +0100 (BST) +Message-ID: <416F7E22.6000702@archonet.com> +Date: Fri, 15 Oct 2004 08:37:06 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Igor Maciel Macaubas +Cc: pgsql-performance@postgresql.org +Subject: Re: View & Query Performance +References: <001301c4b231$280c4190$6801a8c0@providerst.local> +In-Reply-To: <001301c4b231$280c4190$6801a8c0@providerst.local> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/208 +X-Sequence-Number: 8684 + +Igor Maciel Macaubas wrote: +> Hi all, +> +> I'm trying to find smarter ways to dig data from my database, and +> have the following scenario: +> +> table1 -- id -- name . . . . . . +> +> table2 -- id -- number . . . . . . +> +> I want to create a view to give me back just what I want: The id, the +> name and the number. I tought in doing the following: create view +> my_view as select t1.id, t1.name, t2.number from table1 as t1, table2 +> as t2 where t1.id = t2.id; +> +> Will this be enough fast ? Are there a faster way to make it work ?! +> This table is mid-big, around 100K registers .. + +That's as simple a way as you will find. If you apply further +conditions, e.g. + SELECT * FROM my_view WHERE id = 123; +then you should see any index on "id" being used. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Oct 15 08:37:54 2004 +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 C949132C304 + for ; + Fri, 15 Oct 2004 08:37:52 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12291-07 + for ; + Fri, 15 Oct 2004 07:37:48 +0000 (GMT) +Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A26C32C302 + for ; + Fri, 15 Oct 2004 08:37:45 +0100 (BST) +Received: from modem-141.leopard.dialup.pol.co.uk ([217.135.144.141] + helo=happyplace) by cmailg1.svr.pol.co.uk with smtp (Exim 4.14) + id 1CIMef-0003L8-1L; Fri, 15 Oct 2004 08:37:37 +0100 +From: "Simon Riggs" +To: "Timothy D. Witham" , +Cc: , + +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +Date: Fri, 15 Oct 2004 08:55:59 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +In-Reply-To: <1097798945.6387.86.camel@wookie-zd7> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/209 +X-Sequence-Number: 8685 + +>Timothy D. Witham +> On Thu, 2004-10-14 at 16:57 -0700, Josh Berkus wrote: +> > Simon, +> > +> > +> > +> > > If you draw a graph of speedup (y) against cache size as a +> > > % of total database size, the graph looks like an upside-down +> "L" - i.e. +> > > the graph rises steeply as you give it more memory, then +> turns sharply at a +> > > particular point, after which it flattens out. The "turning +> point" is the +> > > "sweet spot" we all seek - the optimum amount of cache memory +> to allocate - +> > > but this spot depends upon the worklaod and database size, +> not on available +> > > RAM on the system under test. +> > +> > Hmmm ... how do you explain, then the "camel hump" nature of the real +> > performance? That is, when we allocated even a few MB more than the +> > "optimum" ~190MB, overall performance stated to drop quickly. +> The result is +> > that allocating 2x optimum RAM is nearly as bad as allocating +> too little +> > (e.g. 8MB). + +Two ways of explaining this: +1. Once you've hit the optimum size of shared_buffers, you may not yet have +hit the optimum size of the OS cache. If that is true, every extra block +given to shared_buffers is wasted, yet detracts from the beneficial effect +of the OS cache. I don't see how the small drop in size of the OS cache +could have the effect you have measured, so I suggest that this possible +explanation doesn't fit the results well. + +2. There is some algorithmic effect within PostgreSQL that makes larger +shared_buffers much worse than smaller ones. Imagine that each extra block +we hold in cache has the positive benefit from caching, minus a postulated +negative drag effect. With that model we would get: Once the optimal size of +the cache has been reached the positive benefit tails off to almost zero and +we are just left with the situation that each new block added to +shared_buffers acts as a further drag on performance. That model would fit +the results, so we can begin to look at what the drag effect might be. + +Speculating wildly because I don't know that portion of the code this might +be: +CONJECTURE 1: the act of searching for a block in cache is an O(n) +operation, not an O(1) or O(log n) operation - so searching a larger cache +has an additional slowing effect on the application, via a buffer cache lock +that is held while the cache is searched - larger caches are locked for +longer than smaller caches, so this causes additional contention in the +system, which then slows down performance. + +The effect might show up by examining the oprofile results for the test +cases. What we would be looking for is something that is being called more +frequently with larger shared_buffers - this could be anything....but my +guess is the oprofile results won't be similar and could lead us to a better +understanding. + +> > +> > The only explanation I've heard of this so far is that there is +> a significant +> > loss of efficiency with larger caches. Or do you see the loss +> of 200MB out +> > of 3500MB would actually affect the Kernel cache that much? +> > +> In a past life there seemed to be a sweet spot around the +> applications +> working set. Performance went up until you got just a little larger +> than +> the cache needed to hold the working set and then went down. Most of +> the time a nice looking hump. It seems to have to do with the +> additional pages +> not increasing your hit ratio but increasing the amount of work to get a +> hit in cache. This seemed to be independent of the actual database +> software being used. (I observed this running Oracle, Informix, Sybase +> and Ingres.) + +Good, our experiences seems to be similar. + +> +> > Anyway, one test of your theory that I can run immediately is +> to run the exact +> > same workload on a bigger, faster server and see if the desired +> quantity of +> > shared_buffers is roughly the same. + +I agree that you could test this by running on a bigger or smaller server, +i.e. one with more or less RAM. Running on a faster/slower server at the +same time might alter the results and confuse the situation. + +> I'm hoping that you're wrong -- not +> because I don't find your argument persuasive, but because if +> you're right it +> > leaves us without any reasonable ability to recommend +> shared_buffer settings. +> + +For the record, what I think we need is dynamically resizable +shared_buffers, not a-priori knowledge of what you should set shared_buffers +to. I've been thinking about implementing a scheme that helps you decide how +big the shared_buffers SHOULD BE, by making the LRU list bigger than the +cache itself, so you'd be able to see whether there is beneficial effect in +increasing shared_buffers. + +...remember that this applies to other databases too, and with those we find +that they have dynamically resizable memory. + +Having said all that, there are still a great many other performance tests +to run so that we CAN recommend other settings, such as the optimizer cost +parameters, bg writer defaults etc. + +Best Regards, + +Simon Riggs +2nd Quadrant + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 10:19:58 2004 +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 B6DB432C26C + for ; + Fri, 15 Oct 2004 10:19:48 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43938-01 + for ; + Fri, 15 Oct 2004 09:19:43 +0000 (GMT) +Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 49EB432C24C + for ; + Fri, 15 Oct 2004 10:19:44 +0100 (BST) +Received: from sysexperts.com + (c-24-6-183-218.client.comcast.net[24.6.183.218]) + by comcast.net (rwcrmhc11) with ESMTP + id <2004101509194201300t513se>; Fri, 15 Oct 2004 09:19:42 +0000 +Received: from localhost (localhost [127.0.0.1]) (uid 1000) + by filer with local; Fri, 15 Oct 2004 02:19:41 -0700 + id 0000AFFE.416F962D.0000335A +Date: Fri, 15 Oct 2004 02:19:40 -0700 +From: Kevin Brown +To: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Message-ID: <20041015091940.GF665@filer> +Mail-Followup-To: Kevin Brown , + pgsql-performance@postgresql.org +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + <20041014202531.GD665@filer> <5235.1097817216@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +In-Reply-To: <5235.1097817216@sss.pgh.pa.us> +Organization: Frobozzco International +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/210 +X-Sequence-Number: 8686 + +Tom Lane wrote: +> Kevin Brown writes: +> > Hmm...something just occurred to me about this. +> +> > Would a hybrid approach be possible? That is, use mmap() to handle +> > reads, and use write() to handle writes? +> +> Nope. Have you read the specs regarding mmap-vs-stdio synchronization? +> Basically it says that there are no guarantees whatsoever if you try +> this. The SUS text is a bit weaselly ("the application must ensure +> correct synchronization") but the HPUX mmap man page, among others, +> lays it on the line: +> +> It is also unspecified whether write references to a memory region +> mapped with MAP_SHARED are visible to processes reading the file and +> whether writes to a file are visible to processes that have mapped the +> modified portion of that file, except for the effect of msync(). +> +> It might work on particular OSes but I think depending on such behavior +> would be folly... + +Yeah, and at this point it can't be considered portable in any real +way because of this. Thanks for the perspective. I should have +expected the general specification to be quite broken in this regard, +not to mention certain implementations. :-) + +Good thing there's a lot of lower-hanging fruit than this... + + + +-- +Kevin Brown kevin@sysexperts.com + +From pgsql-performance-owner@postgresql.org Fri Oct 15 11:25:40 2004 +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 9314332C28B + for ; + Fri, 15 Oct 2004 11:25:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60815-04 + for ; + Fri, 15 Oct 2004 10:25:30 +0000 (GMT) +Received: from mail.core.genedata.com (mail.core.genedata.com + [157.161.173.16]) + by svr1.postgresql.org (Postfix) with ESMTP id 07AA332C2B1 + for ; + Fri, 15 Oct 2004 11:25:29 +0100 (BST) +Received: from relay.core.genedata.com (root@nila-e0.core.genedata.com + [172.20.16.64]) (authenticated bits=128) + by mail.core.genedata.com (8.13.1/8.13.1) with ESMTP id i9FAPRZW002208 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) + for ; Fri, 15 Oct 2004 12:25:27 +0200 +Received: from relay.ch.genedata.com (root@vesuvio-e0.ch.genedata.com + [172.20.16.80]) (authenticated bits=128) + by relay.core.genedata.com (8.13.1/8.13.1) with ESMTP id i9FAPQE0013485 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) + for ; Fri, 15 Oct 2004 12:25:26 +0200 +X-DomainKeys: Sendmail dk v0.2.2 relay.core.genedata.com i9FAPQE0013485 +DomainKey-Signature: a=rsa-sha1; s=genedata; d=genedata.com; c=simple; q=dns; + h=received:from:organization:to:subject:date:user-agent:mime-version:content-disposition:content-type:content-transfer-encoding:message-id:x-filter-version; + b=rLjItBje6hzXRWSPVoPiE/m6NHQuFKUWfa5vLIEXX6VDHU0MkDJvQ23VtgwHY7Zc +Received: from rotokaua.ch.genedata.com (rotokaua.ch.genedata.com + [172.20.39.133]) + by relay.ch.genedata.com (8.13.1/8.13.1) with ESMTP id i9FAPQX7019139 + for ; Fri, 15 Oct 2004 12:25:26 +0200 +From: Bernd +Organization: Genedata +To: pgsql-performance@postgresql.org +Subject: Select with qualified join condition / Batch inserts +Date: Fri, 15 Oct 2004 12:25:26 +0200 +User-Agent: KMail/1.6.2 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Message-Id: <200410151225.26083.bernd_pg@genedata.com> +X-Filter-Version: 1.15 (nila) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/211 +X-Sequence-Number: 8687 + +Hi, + +we are working on a product which was originally developed against an Oracle +database and which should be changed to also work with postgres. + +Overall the changes we had to make are very small and we are very pleased with +the good performance of postgres - but we also found queries which execute +much faster on Oracle. Since I am not yet familiar with tuning queries for +postgres, it would be great if someone could give me a hint on the following +two issues. (We are using PG 8.0.0beta3 on Linux kernel 2.4.27): + +1/ The following query takes about 5 sec. with postrgres whereas on Oracle it +executes in about 30 ms (although both tables only contain 200 k records in +the postgres version). + +SQL: + +SELECT cmp.WELL_INDEX, cmp.COMPOUND, con.CONCENTRATION + FROM SCR_WELL_COMPOUND cmp, SCR_WELL_CONCENTRATION con + WHERE cmp.BARCODE=con.BARCODE + AND cmp.WELL_INDEX=con.WELL_INDEX + AND cmp.MAT_ID=con.MAT_ID + AND cmp.MAT_ID = 3 + AND cmp.BARCODE='910125864' + AND cmp.ID_LEVEL = 1; + +Table-def: + Table "public.scr_well_compound" + Column | Type | Modifiers +------------+------------------------+----------- + mat_id | numeric(10,0) | not null + barcode | character varying(240) | not null + well_index | numeric(5,0) | not null + id_level | numeric(3,0) | not null + compound | character varying(240) | not null +Indexes: + "scr_wcm_pk" PRIMARY KEY, btree (id_level, mat_id, barcode, well_index) +Foreign-key constraints: + "scr_wcm_mat_fk" FOREIGN KEY (mat_id) REFERENCES scr_mapping_table(mat_id) +ON DELETE CASCADE + + Table "public.scr_well_concentration" + Column | Type | Modifiers +---------------+------------------------+----------- + mat_id | numeric(10,0) | not null + barcode | character varying(240) | not null + well_index | numeric(5,0) | not null + concentration | numeric(20,10) | not null +Indexes: + "scr_wco_pk" PRIMARY KEY, btree (mat_id, barcode, well_index) +Foreign-key constraints: + "scr_wco_mat_fk" FOREIGN KEY (mat_id) REFERENCES scr_mapping_table(mat_id) +ON DELETE CASCADE + +I tried several variants of the query (including the SQL 92 JOIN ON syntax) +but with no success. I have also rebuilt the underlying indices. + +A strange observation is that the same query runs pretty fast without the +restriction to a certain MAT_ID, i. e. omitting the MAT_ID=3 part. + +Also fetching the data for both tables separately is pretty fast and a +possible fallback would be to do the actual join in the application (which is +of course not as beautiful as doing it using SQL ;-) + +2/ Batch-inserts using jdbc (maybe this should go to the jdbc-mailing list - +but it is also performance related ...): +Performing many inserts using a PreparedStatement and batch execution makes a +significant performance improvement in Oracle. In postgres, I did not observe +any performance improvement using batch execution. Are there any special +caveats when using batch execution with postgres? + +Thanks and regards + +Bernd + + + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 11:36:43 2004 +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 DA9F832C0CE + for ; + Fri, 15 Oct 2004 11:36:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64632-07 + for ; + Fri, 15 Oct 2004 10:36:35 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 68EF8329FB1 + for ; + Fri, 15 Oct 2004 11:36:36 +0100 (BST) +Received: from solent (unknown [213.165.136.10]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id 22D4BA3244; Fri, 15 Oct 2004 11:36:35 +0100 (BST) +Reply-To: +From: "Matt Clark" +To: "'Bernd'" , + +Subject: Re: Select with qualified join condition / Batch inserts +Date: Fri, 15 Oct 2004 11:36:35 +0100 +Organization: Ymogen Ltd +Message-ID: <001e01c4b2a2$d82b77f0$8300a8c0@solent> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +In-Reply-To: <200410151225.26083.bernd_pg@genedata.com> +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=UPPERCASE_50_75 +X-Spam-Level: * +X-Archive-Number: 200410/212 +X-Sequence-Number: 8688 + +> SELECT cmp.WELL_INDEX, cmp.COMPOUND, con.CONCENTRATION +> FROM SCR_WELL_COMPOUND cmp, SCR_WELL_CONCENTRATION con +> WHERE cmp.BARCODE=con.BARCODE +> AND cmp.WELL_INDEX=con.WELL_INDEX +> AND cmp.MAT_ID=con.MAT_ID +> AND cmp.MAT_ID = 3 +> AND cmp.BARCODE='910125864' +> AND cmp.ID_LEVEL = 1; + +Quick guess - type mismatch forcing sequential scan. Try some quotes: + AND cmp.MAT_ID = '3' + AND cmp.BARCODE='910125864' + AND cmp.ID_LEVEL = '1'; + +M + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 11:45:09 2004 +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 1B9EC32C20B + for ; + Fri, 15 Oct 2004 11:45:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64245-09 + for ; + Fri, 15 Oct 2004 10:45:02 +0000 (GMT) +Received: from usbb-lacimss1.unisys.com (usbb-lacimss1.unisys.com + [192.63.108.51]) + by svr1.postgresql.org (Postfix) with ESMTP id 7081232C12F + for ; + Fri, 15 Oct 2004 11:45:02 +0100 (BST) +Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.21]unverified) by + usbb-lacimss1 with InterScan Messaging Security Suite; + Fri, 15 Oct 2004 06:48:01 -0400 +Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.23]) by + usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Fri, 15 Oct 2004 06:44:42 -0400 +Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by + usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Fri, 15 Oct 2004 06:44:41 -0400 +Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by + gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.47); + Fri, 15 Oct 2004 11:44:39 +0100 +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: Select with qualified join condition / Batch inserts +Date: Fri, 15 Oct 2004 12:44:37 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Select with qualified join condition / Batch inserts +Thread-Index: AcSyownVZObCmInqSUWgaP1oAebrewAAMkPA +From: "Leeuw van der, Tim" +To: , "Bernd" , + +X-OriginalArrivalTime: 15 Oct 2004 10:44:39.0048 (UTC) + FILETIME=[F86C5880:01C4B2A3] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/213 +X-Sequence-Number: 8689 + +But he's testing with v8 beta3, so you'd expect the typecast problem not to= + appear? + +Are all tables fully vacuumed? Should the statistics-target be raised for s= +ome columns, perhaps? What about the config file? + +--Tim + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owne= +r@postgresql.org]On Behalf Of Matt Clark +Sent: Friday, October 15, 2004 12:37 PM +To: 'Bernd'; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Select with qualified join condition / Batch inserts + + +> SELECT cmp.WELL_INDEX, cmp.COMPOUND, con.CONCENTRATION=20 +> FROM SCR_WELL_COMPOUND cmp, SCR_WELL_CONCENTRATION con=20 +> WHERE cmp.BARCODE=3Dcon.BARCODE=20 +> AND cmp.WELL_INDEX=3Dcon.WELL_INDEX=20 +> AND cmp.MAT_ID=3Dcon.MAT_ID=20 +> AND cmp.MAT_ID =3D 3=20 +> AND cmp.BARCODE=3D'910125864'=20 +> AND cmp.ID_LEVEL =3D 1; + +Quick guess - type mismatch forcing sequential scan. Try some quotes: + AND cmp.MAT_ID =3D '3'=20 + AND cmp.BARCODE=3D'910125864'=20 + AND cmp.ID_LEVEL =3D '1'; + +M + + +---------------------------(end of broadcast)--------------------------- +TIP 3: if posting/reading through Usenet, please send an appropriate + subscribe-nomail command to majordomo@postgresql.org so that your + message can get through to the mailing list cleanly + +From pgsql-performance-owner@postgresql.org Tue Oct 19 22:15:15 2004 +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 D1E5B32C2CC + for ; + Fri, 15 Oct 2004 11:48:15 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68737-05 + for ; + Fri, 15 Oct 2004 10:48:09 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 4EFA732C2BA + for ; + Fri, 15 Oct 2004 11:48:10 +0100 (BST) +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.11.6/8.11.4) with ESMTP id i9FAlua30359; + Fri, 15 Oct 2004 20:47:56 +1000 +Date: Fri, 15 Oct 2004 20:47:56 +1000 (EST) +From: Gavin Sherry +To: Bernd +Cc: pgsql-performance@postgresql.org +Subject: Re: Select with qualified join condition / Batch inserts +In-Reply-To: <200410151225.26083.bernd_pg@genedata.com> +Message-ID: +References: <200410151225.26083.bernd_pg@genedata.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/292 +X-Sequence-Number: 8768 + +On Fri, 15 Oct 2004, Bernd wrote: + +> Hi, +> +> we are working on a product which was originally developed against an Oracle +> database and which should be changed to also work with postgres. +> +> Overall the changes we had to make are very small and we are very pleased with +> the good performance of postgres - but we also found queries which execute +> much faster on Oracle. Since I am not yet familiar with tuning queries for +> postgres, it would be great if someone could give me a hint on the following +> two issues. (We are using PG 8.0.0beta3 on Linux kernel 2.4.27): +> +> 1/ The following query takes about 5 sec. with postrgres whereas on Oracle it +> executes in about 30 ms (although both tables only contain 200 k records in +> the postgres version). +> +> SQL: +> +> SELECT cmp.WELL_INDEX, cmp.COMPOUND, con.CONCENTRATION +> FROM SCR_WELL_COMPOUND cmp, SCR_WELL_CONCENTRATION con +> WHERE cmp.BARCODE=con.BARCODE +> AND cmp.WELL_INDEX=con.WELL_INDEX +> AND cmp.MAT_ID=con.MAT_ID +> AND cmp.MAT_ID = 3 +> AND cmp.BARCODE='910125864' +> AND cmp.ID_LEVEL = 1; +> +> Table-def: +> Table "public.scr_well_compound" +> Column | Type | Modifiers +> ------------+------------------------+----------- +> mat_id | numeric(10,0) | not null +> barcode | character varying(240) | not null +> well_index | numeric(5,0) | not null +> id_level | numeric(3,0) | not null +> compound | character varying(240) | not null +> Indexes: +> "scr_wcm_pk" PRIMARY KEY, btree (id_level, mat_id, barcode, well_index) + +I presume you've VACUUM FULL'd and ANALYZE'd? Can we also see a plan? +EXPLAIN ANALYZE . +http://www.postgresql.org/docs/7.4/static/sql-explain.html. + +You may need to create indexes with other primary columns. Ie, on mat_id +or barcode. + + +> 2/ Batch-inserts using jdbc (maybe this should go to the jdbc-mailing list - +> but it is also performance related ...): +> Performing many inserts using a PreparedStatement and batch execution makes a +> significant performance improvement in Oracle. In postgres, I did not observe +> any performance improvement using batch execution. Are there any special +> caveats when using batch execution with postgres? + +The JDBC people should be able to help with that. + +Gavin + +From pgsql-performance-owner@postgresql.org Fri Oct 15 13:53:28 2004 +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 698D232C0D9 + for ; + Fri, 15 Oct 2004 13:53:25 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05648-03 + for ; + Fri, 15 Oct 2004 12:53:17 +0000 (GMT) +Received: from ram.rentec.com (ram.rentec.com [192.5.35.66]) + by svr1.postgresql.org (Postfix) with ESMTP id D0A6232C0CE + for ; + Fri, 15 Oct 2004 13:53:19 +0100 (BST) +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by ram.rentec.com (8.12.9/8.12.1) with ESMTP id i9FCrJnK001841; + Fri, 15 Oct 2004 08:53:19 -0400 (EDT) +Message-ID: <416FC83F.3020900@rentec.com> +Date: Fri, 15 Oct 2004 08:53:19 -0400 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Kevin Brown , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + <20041014202531.GD665@filer> <5235.1097817216@sss.pgh.pa.us> +In-Reply-To: <5235.1097817216@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/214 +X-Sequence-Number: 8690 + +Tom Lane wrote: + +>Kevin Brown writes: +> +> +>>Hmm...something just occurred to me about this. +>> +>> +>>Would a hybrid approach be possible? That is, use mmap() to handle +>>reads, and use write() to handle writes? +>> +>> +> +>Nope. Have you read the specs regarding mmap-vs-stdio synchronization? +>Basically it says that there are no guarantees whatsoever if you try +>this. The SUS text is a bit weaselly ("the application must ensure +>correct synchronization") but the HPUX mmap man page, among others, +>lays it on the line: +> +> It is also unspecified whether write references to a memory region +> mapped with MAP_SHARED are visible to processes reading the file and +> whether writes to a file are visible to processes that have mapped the +> modified portion of that file, except for the effect of msync(). +> +>It might work on particular OSes but I think depending on such behavior +>would be folly... +> +We have some anecdotal experience along these lines: There was a set +of kernel bugs in Solaris 2.6 or 7 related to this as well. We had +several kernel panics and it took a bit to chase down, but the basic +feedback was "oops. we're screwed". I've forgotten most of the +details right now; the basic problem was a file was being read+written +via mmap and read()/write() at (essentially) the same time from the same +pid. It would panic the system quite reliably. I believe the bugs +related to this have been resolved in Solaris, but it was unpleasant to +chase that problem down... + +-- Alan + +From pgsql-performance-owner@postgresql.org Fri Oct 15 15:17:15 2004 +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 C1A4232C61A + for ; + Fri, 15 Oct 2004 15:17:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31954-08 + for ; + Fri, 15 Oct 2004 14:17:04 +0000 (GMT) +Received: from auscorpex-1.austin.messageone.com + (auscorpex-1.austin.messageone.com [66.219.55.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 670C932C60E + for ; + Fri, 15 Oct 2004 15:17:06 +0100 (BST) +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.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: Select with qualified join condition / Batch inserts +Date: Fri, 15 Oct 2004 09:17:06 -0500 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Select with qualified join condition / Batch inserts +Thread-Index: AcSyoZgjV0sYiqBoQ/ytF3TSIWTHdwAH2UIw +From: "Michael Nonemacher" +To: "Bernd" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/215 +X-Sequence-Number: 8691 + +> 2/ Batch-inserts using jdbc (maybe this should go to the jdbc-mailing +list -=20 +> but it is also performance related ...): +> Performing many inserts using a PreparedStatement and batch execution +makes a=20 +> significant performance improvement in Oracle. In postgres, I did not +observe=20 +> any performance improvement using batch execution. Are there any +special=20 +> caveats when using batch execution with postgres? + +When you call executeBatch(), it doesn't send all the queries in a +single round-trip; it just iterates through the batched queries and +executes them one by one. In my own applications, I've done +simulated-batch queries like this: + +insert into T (a, b, c) + select 1,2,3 union all + select 2,3,4 union all + select 3,4,5 + +It's ugly, and you have to structure your code in such a way that the +query can't get too large, but it provides a similar performance benefit +to batching. You probably don't save nearly as much parse time as using +a batched PreparedStatement, but you at least get rid of the network +roundtrips. + +(Of course, it'd be much nicer if statement-batching worked. There have +been rumblings about doing this, and some discussion on how to do it, +but I haven't heard about any progress. Anyone?) + +mike + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Bernd +Sent: Friday, October 15, 2004 5:25 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] Select with qualified join condition / Batch inserts + + +Hi, + +we are working on a product which was originally developed against an +Oracle=20 +database and which should be changed to also work with postgres.=20 + +Overall the changes we had to make are very small and we are very +pleased with=20 +the good performance of postgres - but we also found queries which +execute=20 +much faster on Oracle. Since I am not yet familiar with tuning queries +for=20 +postgres, it would be great if someone could give me a hint on the +following=20 +two issues. (We are using PG 8.0.0beta3 on Linux kernel 2.4.27): + +1/ The following query takes about 5 sec. with postrgres whereas on +Oracle it=20 +executes in about 30 ms (although both tables only contain 200 k records +in=20 +the postgres version). + +SQL: + +SELECT cmp.WELL_INDEX, cmp.COMPOUND, con.CONCENTRATION=20 + FROM SCR_WELL_COMPOUND cmp, SCR_WELL_CONCENTRATION con=20 + WHERE cmp.BARCODE=3Dcon.BARCODE=20 + AND cmp.WELL_INDEX=3Dcon.WELL_INDEX=20 + AND cmp.MAT_ID=3Dcon.MAT_ID=20 + AND cmp.MAT_ID =3D 3=20 + AND cmp.BARCODE=3D'910125864'=20 + AND cmp.ID_LEVEL =3D 1; + +Table-def: + Table "public.scr_well_compound" + Column | Type | Modifiers +------------+------------------------+----------- + mat_id | numeric(10,0) | not null + barcode | character varying(240) | not null + well_index | numeric(5,0) | not null + id_level | numeric(3,0) | not null + compound | character varying(240) | not null +Indexes: + "scr_wcm_pk" PRIMARY KEY, btree (id_level, mat_id, barcode, +well_index) Foreign-key constraints: + "scr_wcm_mat_fk" FOREIGN KEY (mat_id) REFERENCES +scr_mapping_table(mat_id)=20 +ON DELETE CASCADE + + Table "public.scr_well_concentration" + Column | Type | Modifiers +---------------+------------------------+----------- + mat_id | numeric(10,0) | not null + barcode | character varying(240) | not null + well_index | numeric(5,0) | not null + concentration | numeric(20,10) | not null +Indexes: + "scr_wco_pk" PRIMARY KEY, btree (mat_id, barcode, well_index) +Foreign-key constraints: + "scr_wco_mat_fk" FOREIGN KEY (mat_id) REFERENCES +scr_mapping_table(mat_id)=20 +ON DELETE CASCADE + +I tried several variants of the query (including the SQL 92 JOIN ON +syntax)=20 +but with no success. I have also rebuilt the underlying indices. + +A strange observation is that the same query runs pretty fast without +the=20 +restriction to a certain MAT_ID, i. e. omitting the MAT_ID=3D3 part. + +Also fetching the data for both tables separately is pretty fast and a=20 +possible fallback would be to do the actual join in the application +(which is=20 +of course not as beautiful as doing it using SQL ;-) + +2/ Batch-inserts using jdbc (maybe this should go to the jdbc-mailing +list -=20 +but it is also performance related ...): +Performing many inserts using a PreparedStatement and batch execution +makes a=20 +significant performance improvement in Oracle. In postgres, I did not +observe=20 +any performance improvement using batch execution. Are there any special + +caveats when using batch execution with postgres? + +Thanks and regards + +Bernd + + + + +---------------------------(end of broadcast)--------------------------- +TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + +From pgsql-hackers-win32-owner@postgresql.org Fri Oct 15 16:37:52 2004 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C014B32BEB1 + for ; + Fri, 15 Oct 2004 16:37:50 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65540-04 + for ; + Fri, 15 Oct 2004 15:37: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 B4C4232BE65 + for ; + Fri, 15 Oct 2004 16:37:44 +0100 (BST) +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 i9FFbeBe009632; + Fri, 15 Oct 2004 11:37:40 -0400 (EDT) +To: "MikeSmialek2@Hotmail.com" +Cc: "Magnus Hagander" , + pgsql-performance@postgresql.org, pgsql-hackers-win32@postgresql.org +Subject: Re: Performance on Win32 vs Cygwin +In-reply-to: +References: <6BCB9D8A16AC4241919521715F4D8BCE475EE5@algol.sollentuna.se> + +Comments: In-reply-to "MikeSmialek2@Hotmail.com" + message dated "Thu, 14 Oct 2004 16:45:51 -0500" +Date: Fri, 15 Oct 2004 11:37:40 -0400 +Message-ID: <9631.1097854660@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200410/71 +X-Sequence-Number: 2361 + +"MikeSmialek2@Hotmail.com" writes: +> So are we correct to rely on +> - 8 being slower than 7.x in general and + +I think this is a highly unlikely claim ... *especially* if you are +comparing against 7.1. The point about sync() being a no-op is real, +but offhand I think it would only come into play at checkpoints. We +have never issued sync() during regular queries. + +What seems more likely to me is that you have neglected to do any +performance tuning on the new installation. Have you vacuumed/analyzed +all your tables? Checked the postgresql.conf settings for sanity? + +If you'd like to do an apples-to-apples comparison to prove whether +7.1's failure to sync() is relevant, then turn off fsync in the 8.0 +configuration and see how much difference that makes. + +If you can identify specific queries that are slower in 8.0 than 7.1, +I'd be interested to see the EXPLAIN ANALYZE details from each. +(Actually, I'm not sure 7.1 had EXPLAIN ANALYZE; you may have to +settle for EXPLAIN from it.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 17:07:39 2004 +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 D8C2932BEC2 + for ; + Fri, 15 Oct 2004 17:07:37 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75775-04 + for ; + Fri, 15 Oct 2004 16:07:32 +0000 (GMT) +Received: from neomail07.traderonline.com (email.traderonline.com + [65.213.231.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 8871D32BE0C + for ; + Fri, 15 Oct 2004 17:07:30 +0100 (BST) +Received: from [192.168.1.68] + (64-139-89-109-ubr02b-epensb01-pa.hfc.comcastbusiness.net + [64.139.89.109]) + by neomail07.traderonline.com (8.12.10/8.12.8) with ESMTP id + i9FG7TOY018965 + for ; Fri, 15 Oct 2004 12:07:29 -0400 +Message-ID: <416FF5BF.8060200@ptd.net> +Date: Fri, 15 Oct 2004 12:07:27 -0400 +From: Doug Y +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Tuning shared_buffers with ipcs ? +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/217 +X-Sequence-Number: 8693 + +Hello, +I've seen a couple references to using ipcs to help properly size +shared_buffers. + +I don't claim to be a SA guru, so could someone help explain how to +interpret the output of ipcs and how that relates to shared_buffers? How +does one determine the size of the segment arrays? I see the total size +using ipcs -m which is roughly shared_buffers * 8k. + +I tried all of the dash commands in the ipcs man page, and the only one +that might give a clue is ipcs -t which shows the time the semaphores +were last used. If you look at the example I give below, it appears as +if I'm only using 4 of the 17 semaphores (PG was started on Oct 8). + +Am I correct in assuming that if the arrays are all the same size then I +should only need about 1/4 of my currently allocated shared_buffers? + +------ Shared Memory Operation/Change Times -------- +shmid owner last-op last-changed +847183872 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847216641 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847249410 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847282179 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847314948 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847347717 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847380486 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847413255 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847446024 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847478793 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847511562 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847544331 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847577100 postgres Fri Oct 8 11:03:31 2004 Fri Oct 8 11:03:31 2004 +847609869 postgres Fri Oct 15 11:34:28 2004 Fri Oct 15 11:34:29 2004 +847642638 postgres Fri Oct 15 11:33:35 2004 Fri Oct 15 11:33:35 2004 +847675407 postgres Fri Oct 15 11:34:28 2004 Fri Oct 15 11:34:29 2004 +847708176 postgres Fri Oct 15 11:27:17 2004 Fri Oct 15 11:32:20 2004 + +Also, isn't the shared memory supposed to show up in free? Its always +showing as 0: + +# free + total used free shared buffers cached +Mem: 3896928 3868424 28504 0 59788 3605548 +-/+ buffers/cache: 203088 3693840 +Swap: 1052216 16 1052200 + +Thanks! + + +From pgsql-hackers-win32-owner@postgresql.org Fri Oct 15 17:22:51 2004 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F87B32BEDE; + Fri, 15 Oct 2004 17:22:49 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79806-09; Fri, 15 Oct 2004 16:22:42 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id B4AFF32BEC5; + Fri, 15 Oct 2004 17:22:41 +0100 (BST) +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.6944.0 +Subject: Re: Performance on Win32 vs Cygwin +Date: Fri, 15 Oct 2004 12:22:40 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7506@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [pgsql-hackers-win32] Performance on Win32 vs Cygwin +Thread-Index: AcSyN8X/LYt2ZT6+S2Kt3p2J/oCEXwAmmvmw +From: "Merlin Moncure" +To: "MikeSmialek2@Hotmail.com" +Cc: , , + "Magnus Hagander" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200410/72 +X-Sequence-Number: 2362 + +> Thanks Magnus, +>=20 +> So are we correct to rely on +> - 8 being slower than 7.x in general and +> - 8 on Win32 being a little faster than 8 on Cygwin? +>=20 +> Will the final release of 8 be faster than the beta? + +I'm pretty certain that previous to 8.0 no win32 based postgesql +properly sync()ed the files. Win32 does not have sync(), and it is +impossible to emulate it without relying on the application to track +which files to sync. 8.0 does this because it fsync()s the files +individually. Therefore, benchmarking fsync=3Don on 8.0 to a <8.0 version +of windows is not apples to apples. This includes, by the way, the SFU +based port of postgresql because they didn't implement sync() there, +either. + +Other than the sync() issue, the cygwin/win32 i/o performance should be +roughly equal. Unless I'm terribly mistaken about things, all the i/o +calls should boil down to win32 api calls. + +The cygwin IPC stack is implemented differently...pg 8.0 win32 native +version does all the ipc stuff by hand, so you might get slightly +different behavior there. + +Merln + +From pgsql-performance-owner@postgresql.org Fri Oct 15 17:48:31 2004 +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 18C76329F33 + for ; + Fri, 15 Oct 2004 17:48:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89548-03 + for ; + Fri, 15 Oct 2004 16:48: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 E74C932BF01 + for ; + Fri, 15 Oct 2004 17:48:22 +0100 (BST) +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 i9FGmFl0010203; + Fri, 15 Oct 2004 12:48:15 -0400 (EDT) +To: "Simon Riggs" +Cc: "Timothy D. Witham" , josh@agliodbs.com, + pgsql-performance@postgresql.org, testperf-general@pgfoundry.org +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +In-reply-to: +References: +Comments: In-reply-to "Simon Riggs" + message dated "Fri, 15 Oct 2004 08:55:59 +0100" +Date: Fri, 15 Oct 2004 12:48:14 -0400 +Message-ID: <10202.1097858894@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/219 +X-Sequence-Number: 8695 + +"Simon Riggs" writes: +> Speculating wildly because I don't know that portion of the code this might +> be: +> CONJECTURE 1: the act of searching for a block in cache is an O(n) +> operation, not an O(1) or O(log n) operation + +I'm not sure how this meme got into circulation, but I've seen a couple +of people recently either conjecturing or asserting that. Let me remind +people of the actual facts: + +1. We use a hashtable to keep track of which blocks are currently in +shared buffers. Either a cache hit or a cache miss should be O(1), +because the hashtable size is scaled proportionally to shared_buffers, +and so the number of hash entries examined should remain constant. + +2. There are some allegedly-not-performance-critical operations that do +scan through all the buffers, and therefore are O(N) in shared_buffers. + +I just eyeballed all the latter, and came up with this list of O(N) +operations and their call points: + +AtEOXact_Buffers + transaction commit or abort +UnlockBuffers + transaction abort, backend exit +StrategyDirtyBufferList + background writer's idle loop +FlushRelationBuffers + VACUUM + DROP TABLE, DROP INDEX + TRUNCATE, CLUSTER, REINDEX + ALTER TABLE SET TABLESPACE +DropRelFileNodeBuffers + TRUNCATE (only for ON COMMIT TRUNC temp tables) + REINDEX (inplace case only) + smgr_internal_unlink (ie, the tail end of DROP TABLE/INDEX) +DropBuffers + DROP DATABASE + +The fact that the first two are called during transaction commit/abort +is mildly alarming. The constant factors are going to be very tiny +though, because what these routines actually do is scan backend-local +status arrays looking for locked buffers, which they're not going to +find very many of. For instance AtEOXact_Buffers looks like + + int i; + + for (i = 0; i < NBuffers; i++) + { + if (PrivateRefCount[i] != 0) + { + // some code that should never be executed at all in the commit + // case, and not that much in the abort case either + } + } + +I suppose with hundreds of thousands of shared buffers this might get to +the point of being noticeable, but I've never seen it show up at all in +profiling with more-normal buffer counts. Not sure if it's worth +devising a more complex data structure to aid in finding locked buffers. +(To some extent this code is intended to be belt-and-suspenders stuff +for catching omissions elsewhere, and so a more complex data structure +that could have its own bugs is not especially attractive.) + +The one that's bothering me at the moment is StrategyDirtyBufferList, +which is a new overhead in 8.0. It wouldn't directly affect foreground +query performance, but indirectly it would hurt by causing the bgwriter +to suck more CPU cycles than one would like (and it holds the BufMgrLock +while it's doing it, too :-(). One easy way you could see whether this +is an issue in the OSDL test is to see what happens if you double all +three bgwriter parameters (delay, percent, maxpages). This should +result in about the same net I/O demand from the bgwriter, but +StrategyDirtyBufferList will be executed half as often. + +I doubt that the other ones are issues. We could improve them by +devising a way to quickly find all buffers for a given relation, but +I am just about sure that complicating the buffer management to do so +would be a net loss for normal workloads. + +> For the record, what I think we need is dynamically resizable +> shared_buffers, not a-priori knowledge of what you should set +> shared_buffers to. + +This isn't likely to happen because the SysV shared memory API isn't +conducive to it. Absent some amazingly convincing demonstration that +we have to have it, the effort of making it happen in a portable way +isn't going to get spent. + +> I've been thinking about implementing a scheme that helps you decide how +> big the shared_buffers SHOULD BE, by making the LRU list bigger than the +> cache itself, so you'd be able to see whether there is beneficial effect in +> increasing shared_buffers. + +ARC already keeps such a list --- couldn't you learn what you want to +know from the existing data structure? It'd be fairly cool if we could +put out warnings "you ought to increase shared_buffers" analogous to the +existing facility for noting excessive checkpointing. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 17:57:38 2004 +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 AC05132BEE1 + for ; + Fri, 15 Oct 2004 17:57:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91708-09 + for ; + Fri, 15 Oct 2004 16:57:28 +0000 (GMT) +Received: from lax-gate3.raytheon.com (lax-gate3.raytheon.com + [199.46.200.232]) + by svr1.postgresql.org (Postfix) with ESMTP id 6219D32BEDB + for ; + Fri, 15 Oct 2004 17:57:22 +0100 (BST) +Received: from ds02w00.directory.ray.com (ds02w00.directory.ray.com + [147.25.146.118]) + by lax-gate3.raytheon.com (8.12.10/8.12.10) with ESMTP id + i9FGupdw003025 for ; + Fri, 15 Oct 2004 09:56:56 -0700 (PDT) +Received: from ds02w00 (localhost [127.0.0.1]) + by ds02w00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + i9FGuekD027050 + for ; Fri, 15 Oct 2004 16:56:44 GMT +Received: from ds02w00.directory.ray.com with LMTP by ds02w00 + (2.0.6/sieved-2-0-build-559) + for ; Fri, 15 Oct 2004 16:56:40 +0000 +Received: from notesserver5.ftw.us.ray.com (notesserver5.ftw.us.ray.com + [151.168.145.35]) + by ds02w00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + i9FGsolF026508 sender Richard_D_Levine@raytheon.com for + ; Fri, 15 Oct 2004 16:54:51 GMT +Subject: Does PostgreSQL run with Oracle? +To: +X-Mailer: Lotus Notes Release 5.0.8 June 18, 2001 +Message-ID: +From: Richard_D_Levine@raytheon.com +Date: Fri, 15 Oct 2004 11:54:44 -0500 +X-MIMETrack: Serialize by Router on NotesServer5/HDC(Release 5.0.13a |April 8, + 2004) at 10/15/2004 11:54:51 AM +MIME-Version: 1.0 +Content-type: text/plain; charset=us-ascii +X-SPAM: 0.00 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200410/220 +X-Sequence-Number: 8696 + +My basic question to the community is "is PostgreSQL approximately as fast +as Oracle?" + +I don't want benchmarks, they're BS. I want a gut feel from this community +because I know many of you are in mixed shops that run both products, or +have had experience with both. + +I fully intend to tune, vacuum, analyze, size buffers, etc. I've read what +people have written on the topic, and from that my gut feel is that using +PostgreSQL will not adversely affect performance of my application versus +Oracle. I know it won't adversely affect my pocket book. I also know that +requests for help will be quick, clear, and multifaceted. + +I'm currently running single processor UltraSPARC workstations, and intend +to use Intel Arch laptops and Linux. The application is a big turnkey +workstation app. I know the hardware switch alone will enhance +performance, and may do so to the point where even a slower database will +still be adequate. + +Whadyall think? + +Thanks, + +Rick + + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 17:58:13 2004 +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 7C81532BEF9 + for ; + Fri, 15 Oct 2004 17:58:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92621-03 + for ; + Fri, 15 Oct 2004 16:57:52 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id E561E32BEF3 + for ; + Fri, 15 Oct 2004 17:57:51 +0100 (BST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i9FGvZQ13745; + Fri, 15 Oct 2004 12:57:35 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200410151657.i9FGvZQ13745@candle.pha.pa.us> +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability +In-Reply-To: <10202.1097858894@sss.pgh.pa.us> +To: Tom Lane +Date: Fri, 15 Oct 2004 12:57:35 -0400 (EDT) +Cc: Simon Riggs , + "Timothy D. Witham" , josh@agliodbs.com, + pgsql-performance@postgresql.org, testperf-general@pgfoundry.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/221 +X-Sequence-Number: 8697 + +Tom Lane wrote: +> > I've been thinking about implementing a scheme that helps you decide how +> > big the shared_buffers SHOULD BE, by making the LRU list bigger than the +> > cache itself, so you'd be able to see whether there is beneficial effect in +> > increasing shared_buffers. +> +> ARC already keeps such a list --- couldn't you learn what you want to +> know from the existing data structure? It'd be fairly cool if we could +> put out warnings "you ought to increase shared_buffers" analogous to the +> existing facility for noting excessive checkpointing. + +Agreed. ARC already keeps a list of buffers it had to push out recently +so if it needs them again soon it knows its sizing of recent/frequent +might be off (I think). Anyway, such a log report would be super-cool, +say if you pushed out a buffer and needed it very soon, and the ARC +buffers are already at their maximum for that buffer pool. + +-- + 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 Fri Oct 15 18:02:39 2004 +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 5EE0332BFD4 + for ; + Fri, 15 Oct 2004 18:02:38 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93458-08 + for ; + Fri, 15 Oct 2004 17:02:26 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 81327329F39 + for ; + Fri, 15 Oct 2004 18:02:24 +0100 (BST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i9FH2Kj19214; + Fri, 15 Oct 2004 13:02:20 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200410151702.i9FH2Kj19214@candle.pha.pa.us> +Subject: Re: Does PostgreSQL run with Oracle? +In-Reply-To: +To: Richard_D_Levine@raytheon.com +Date: Fri, 15 Oct 2004 13:02:20 -0400 (EDT) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/222 +X-Sequence-Number: 8698 + +Richard_D_Levine@raytheon.com wrote: +> My basic question to the community is "is PostgreSQL approximately as fast +> as Oracle?" +> +> I don't want benchmarks, they're BS. I want a gut feel from this community +> because I know many of you are in mixed shops that run both products, or +> have had experience with both. +> +> I fully intend to tune, vacuum, analyze, size buffers, etc. I've read what +> people have written on the topic, and from that my gut feel is that using +> PostgreSQL will not adversely affect performance of my application versus +> Oracle. I know it won't adversely affect my pocket book. I also know that +> requests for help will be quick, clear, and multifaceted. +> +> I'm currently running single processor UltraSPARC workstations, and intend +> to use Intel Arch laptops and Linux. The application is a big turnkey +> workstation app. I know the hardware switch alone will enhance +> performance, and may do so to the point where even a slower database will +> still be adequate. + +I have always been told we are +/- 10% of Oracle. That's what I say at +talks and no one has disputed that. We are +10-30% faster than +Informix. + +-- + 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 Fri Oct 15 18:08:23 2004 +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 A3F7F32C05E + for ; + Fri, 15 Oct 2004 18:08:21 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94863-09 + for ; + Fri, 15 Oct 2004 17:08:15 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 21D5F32C03F + for ; + Fri, 15 Oct 2004 18:08:13 +0100 (BST) +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 i9FH81KD010424; + Fri, 15 Oct 2004 13:08:01 -0400 (EDT) +To: Bernd +Cc: pgsql-performance@postgresql.org +Subject: Re: Select with qualified join condition / Batch inserts +In-reply-to: <200410151225.26083.bernd_pg@genedata.com> +References: <200410151225.26083.bernd_pg@genedata.com> +Comments: In-reply-to Bernd + message dated "Fri, 15 Oct 2004 12:25:26 +0200" +Date: Fri, 15 Oct 2004 13:08:01 -0400 +Message-ID: <10423.1097860081@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/223 +X-Sequence-Number: 8699 + +Bernd writes: +> 1/ The following query takes about 5 sec. with postrgres whereas on Oracle it +> executes in about 30 ms (although both tables only contain 200 k records in +> the postgres version). + +What does EXPLAIN ANALYZE have to say about it? Have you ANALYZEd the +tables involved in the query? + +You would in any case be very well advised to change the "numeric" +columns to integer, bigint, or smallint when appropriate. There is +a substantial performance advantage to using the simple integral +datatypes instead of the general numeric type. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 18:13:35 2004 +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 345D332BEEA + for ; + Fri, 15 Oct 2004 18:13:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97879-06 + for ; + Fri, 15 Oct 2004 17:13:22 +0000 (GMT) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 205C932BC0E + for ; + Fri, 15 Oct 2004 18:13:21 +0100 (BST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id E694A900015; Fri, 15 Oct 2004 10:19:48 -0700 (PDT) +Date: Fri, 15 Oct 2004 10:19:48 -0700 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Re: Does PostgreSQL run with Oracle? +Message-ID: <20041015171948.GA14759@gp.word-to-the-wise.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/224 +X-Sequence-Number: 8700 + +On Fri, Oct 15, 2004 at 11:54:44AM -0500, Richard_D_Levine@raytheon.com wrote: +> My basic question to the community is "is PostgreSQL approximately as fast +> as Oracle?" + +> I'm currently running single processor UltraSPARC workstations, and intend +> to use Intel Arch laptops and Linux. The application is a big turnkey +> workstation app. I know the hardware switch alone will enhance +> performance, and may do so to the point where even a slower database will +> still be adequate. + +I have found that PostgreSQL seems to perform poorly on Solaris/SPARC +(less so after recent improvements, but still...) compared to x86 +systems - more so than the delta between Oracle on the two platforms. +Just a gut impression, but it might mean that comparing the two +databases on SPARC may not be that useful comparison if you're +planning to move to x86. + +Cheers, + Steve + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 18:51:18 2004 +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 50680329FBD + for ; + Fri, 15 Oct 2004 18:51:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10339-01 + for ; + Fri, 15 Oct 2004 17:51:06 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E97EE32A07C + for ; + Fri, 15 Oct 2004 18:51:05 +0100 (BST) +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 i9FHp50c010906; + Fri, 15 Oct 2004 13:51:05 -0400 (EDT) +To: Doug Y +Cc: pgsql-performance@postgresql.org +Subject: Re: Tuning shared_buffers with ipcs ? +In-reply-to: <416FF5BF.8060200@ptd.net> +References: <416FF5BF.8060200@ptd.net> +Comments: In-reply-to Doug Y + message dated "Fri, 15 Oct 2004 12:07:27 -0400" +Date: Fri, 15 Oct 2004 13:51:05 -0400 +Message-ID: <10905.1097862665@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/225 +X-Sequence-Number: 8701 + +Doug Y writes: +> I've seen a couple references to using ipcs to help properly size +> shared_buffers. + +I have not seen any such claim, and I do not see any way offhand that +ipcs could help. + +> I tried all of the dash commands in the ipcs man page, and the only one +> that might give a clue is ipcs -t which shows the time the semaphores +> were last used. If you look at the example I give below, it appears as +> if I'm only using 4 of the 17 semaphores (PG was started on Oct 8). + +This might tell you something about how many concurrent backends you've +used, but nothing about how many shared buffers you need. + + regards, tom lane + +From pgsql-hackers-win32-owner@postgresql.org Fri Oct 15 18:55:22 2004 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B07432C0D3 + for ; + Fri, 15 Oct 2004 18:55:19 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09572-05 + for ; + Fri, 15 Oct 2004 17:55: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 430A232C037 + for ; + Fri, 15 Oct 2004 18:55:13 +0100 (BST) +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 i9FHtCE1011491; + Fri, 15 Oct 2004 13:55:12 -0400 (EDT) +To: "Merlin Moncure" +Cc: "MikeSmialek2@Hotmail.com" , + pgsql-hackers-win32@postgresql.org, pgsql-performance@postgresql.org, + "Magnus Hagander" +Subject: Re: [PERFORM] Performance on Win32 vs Cygwin +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB3412A7506@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A7506@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Fri, 15 Oct 2004 12:22:40 -0400" +Date: Fri, 15 Oct 2004 13:55:11 -0400 +Message-ID: <11490.1097862911@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/73 +X-Sequence-Number: 2363 + +"Merlin Moncure" writes: +> I'm pretty certain that previous to 8.0 no win32 based postgesql +> properly sync()ed the files. Win32 does not have sync(), and it is +> impossible to emulate it without relying on the application to track +> which files to sync. 8.0 does this because it fsync()s the files +> individually. Therefore, benchmarking fsync=on on 8.0 to a <8.0 version +> of windows is not apples to apples. This includes, by the way, the SFU +> based port of postgresql because they didn't implement sync() there, +> either. + +This is all true, but for performance testing I am not sure that you'd +notice much difference, because the sync or lack of it only happens +within checkpoints. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 19:06:33 2004 +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 226BC32C0F7 + for ; + Fri, 15 Oct 2004 19:06:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14102-04 + for ; + Fri, 15 Oct 2004 18:06:20 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id ECA3732C0D5 + for ; + Fri, 15 Oct 2004 19:06:19 +0100 (BST) +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 i9FI6Iu9011591; + Fri, 15 Oct 2004 14:06:18 -0400 (EDT) +To: Richard_D_Levine@raytheon.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Does PostgreSQL run with Oracle? +In-reply-to: +References: +Comments: In-reply-to Richard_D_Levine@raytheon.com + message dated "Fri, 15 Oct 2004 11:54:44 -0500" +Date: Fri, 15 Oct 2004 14:06:18 -0400 +Message-ID: <11590.1097863578@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/227 +X-Sequence-Number: 8703 + +Richard_D_Levine@raytheon.com writes: +> My basic question to the community is "is PostgreSQL approximately as fast +> as Oracle?" + +The anecdotal evidence I've seen leaves me with the impression that when +you first take an Oracle-based app and drop it into Postgres, it won't +perform particularly well, but with tuning and tweaking you can roughly +equal and often exceed the original performance. The two DBs are enough +unalike that a database schema that's been tuned for Oracle is probably +mistuned for Postgres. You will certainly find "some things are faster, +some are slower" at the end of the day, but we've had lots of satisfied +switchers ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 19:16:13 2004 +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 2B0DF329EEB + for ; + Fri, 15 Oct 2004 19:16:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16384-10 + for ; + Fri, 15 Oct 2004 18:16:03 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B2C7329E7E + for ; + Fri, 15 Oct 2004 19:15:59 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 73so6290rnk + for ; + Fri, 15 Oct 2004 11:15:57 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; 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:references; + b=o+W9CsWbxlsYzGJhpP8is7mB6XloZkGGB4zvKlb+ttVSS0dhwq8ktoZE1Eqkuyi+uX53Fz5+9LBTL1n4XGt5c8ktWbaZ+Eo8RG69nj5YVEUxjFpvZQOxTJxlP07FkbCAc1Gc4mT1ln0In8W4N8KCL0YJT4EJGewbpahpoT6F+FU +Received: by 10.38.72.80 with SMTP id u80mr354382rna; + Fri, 15 Oct 2004 11:15:25 -0700 (PDT) +Received: by 10.38.208.68 with HTTP; Fri, 15 Oct 2004 11:15:25 -0700 (PDT) +Message-ID: <9662496504101511152592fe4f@mail.gmail.com> +Date: Fri, 15 Oct 2004 11:15:25 -0700 +From: Marc Slemko +Reply-To: Marc Slemko +To: "richard_d_levine@raytheon.com" +Subject: Re: Does PostgreSQL run with Oracle? +Cc: pgsql-performance@postgresql.org +In-Reply-To: +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200410/228 +X-Sequence-Number: 8704 + +On Fri, 15 Oct 2004 11:54:44 -0500, richard_d_levine@raytheon.com + wrote: +> My basic question to the community is "is PostgreSQL approximately as fast +> as Oracle?" +> +> I don't want benchmarks, they're BS. I want a gut feel from this community +> because I know many of you are in mixed shops that run both products, or +> have had experience with both. + +That all depends on exactly what your application needs to do. + +There are many more features that Oracle has and postgres doesn't than +vice versa. If you need to do something with your data that isn't +possible to do as efficiently without one of those features, then yes +postgresql can be much slower. If you don't need any such features, +it can be ballpark, until you start getting into fairly hefty +hardware. + +From pgsql-performance-owner@postgresql.org Fri Oct 15 19:51:45 2004 +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 828B032BDCC + for ; + Fri, 15 Oct 2004 19:51:44 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25036-08 + for ; + Fri, 15 Oct 2004 18:51:37 +0000 (GMT) +Received: from neomail07.traderonline.com (email.traderonline.com + [65.213.231.10]) + by svr1.postgresql.org (Postfix) with ESMTP id EB82932BD81 + for ; + Fri, 15 Oct 2004 19:51:36 +0100 (BST) +Received: from [192.168.1.68] + (64-139-89-109-ubr02b-epensb01-pa.hfc.comcastbusiness.net + [64.139.89.109]) + by neomail07.traderonline.com (8.12.10/8.12.8) with ESMTP id + i9FIpZOY004409; Fri, 15 Oct 2004 14:51:35 -0400 +Message-ID: <41701C35.4060808@ptd.net> +Date: Fri, 15 Oct 2004 14:51:33 -0400 +From: Doug Y +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Tuning shared_buffers with ipcs ? +References: <416FF5BF.8060200@ptd.net> <10905.1097862665@sss.pgh.pa.us> +In-Reply-To: <10905.1097862665@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/229 +X-Sequence-Number: 8705 + +Tom Lane wrote: + +>Doug Y writes: +> +> +>>I've seen a couple references to using ipcs to help properly size +>>shared_buffers. +>> +>> +> +>I have not seen any such claim, and I do not see any way offhand that +>ipcs could help. +> +> +Directly from: +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html + +"As a rule of thumb, observe shared memory usage of PostgreSQL with +tools like ipcs and determine the setting." + +I've seen references in the admin + +>>I tried all of the dash commands in the ipcs man page, and the only one +>>that might give a clue is ipcs -t which shows the time the semaphores +>>were last used. If you look at the example I give below, it appears as +>>if I'm only using 4 of the 17 semaphores (PG was started on Oct 8). +>> +>> +> +>This might tell you something about how many concurrent backends you've +>used, but nothing about how many shared buffers you need. +> +> +Thats strange, I know I've had more than 4 concurrent connections on +that box... (I just checked and there were at least a dozen). A mirror +DB with the same config also has the same basic output from ipcs, except +that it has times for 11 of the 17 arrays slots and most of them are the +time when we do our backup dump (which makes sense that it would require +more memory at that time.) + +> regards, tom lane +> +> +> +> +I'm not saying you're wrong, because I don't know how the nitty gritty +stuff works, I'm just trying to find something to work with, since +presently there isn't anything other than anecdotal evidence. From what +I've inferred, there seems to be some circumstantial evidence supporting +my theory. + +Thanks. + +From pgsql-performance-owner@postgresql.org Fri Oct 15 20:24:34 2004 +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 CD1E7329EEB + for ; + Fri, 15 Oct 2004 20:24:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35839-08 + for ; + Fri, 15 Oct 2004 19:24:25 +0000 (GMT) +Received: from cmailg3.svr.pol.co.uk (cmailg3.svr.pol.co.uk [195.92.195.173]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C0C4329E4A + for ; + Fri, 15 Oct 2004 20:24:26 +0100 (BST) +Received: from modem-3812.rhino.dialup.pol.co.uk ([62.137.110.228] + helo=happyplace) by cmailg3.svr.pol.co.uk with smtp (Exim 4.14) + id 1CIXga-0008Eq-2P; Fri, 15 Oct 2004 20:24:20 +0100 +From: "Simon Riggs" +To: "Bruce Momjian" , + "Tom Lane" +Cc: "Timothy D. Witham" , , + , +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +Date: Fri, 15 Oct 2004 20:42:39 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +In-Reply-To: <200410151657.i9FGvZQ13745@candle.pha.pa.us> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/230 +X-Sequence-Number: 8706 + +> Bruce Momjian +> Tom Lane wrote: +> > > I've been thinking about implementing a scheme that helps you +> decide how +> > > big the shared_buffers SHOULD BE, by making the LRU list +> bigger than the +> > > cache itself, so you'd be able to see whether there is +> beneficial effect in +> > > increasing shared_buffers. +> > +> > ARC already keeps such a list --- couldn't you learn what you want to +> > know from the existing data structure? It'd be fairly cool if we could +> > put out warnings "you ought to increase shared_buffers" analogous to the +> > existing facility for noting excessive checkpointing. + +First off, many thanks for taking the time to provide the real detail on the +code. + +That gives us some much needed direction in interpreting the oprofile +output. + +> +> Agreed. ARC already keeps a list of buffers it had to push out recently +> so if it needs them again soon it knows its sizing of recent/frequent +> might be off (I think). Anyway, such a log report would be super-cool, +> say if you pushed out a buffer and needed it very soon, and the ARC +> buffers are already at their maximum for that buffer pool. +> + +OK, I guess I hadn't realised we were half-way there. + +The "increase shared_buffers" warning would be useful, but it would be much +cooler to have some guidance as to how big to set it, especially since this +requires a restart of the server. + +What I had in mind was a way of keeping track of how the buffer cache hit +ratio would look at various sizes of shared_buffers, for example 50%, 80%, +120%, 150%, 200% and 400% say. That way you'd stand a chance of plotting the +curve and thereby assessing how much memory could be allocated. I've got a +few ideas, but I need to check out the code first. + +I'll investigate both simple/complex options as an 8.1 feature. + +Best Regards, Simon Riggs + + + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 20:43:05 2004 +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 D345A32B18D + for ; + Fri, 15 Oct 2004 20:43:00 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42641-09 + for ; + Fri, 15 Oct 2004 19:42:54 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C46432BDF1 + for ; + Fri, 15 Oct 2004 20:42:54 +0100 (BST) +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 6507959; Fri, 15 Oct 2004 12:44:18 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +Date: Fri, 15 Oct 2004 12:44:52 -0700 +User-Agent: KMail/1.6.2 +Cc: "Simon Riggs" , + "Bruce Momjian" , "Tom Lane" , + "Timothy D. Witham" , +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410151244.52735.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/231 +X-Sequence-Number: 8707 + +People: + +> First off, many thanks for taking the time to provide the real detail on +> the code. +> +> That gives us some much needed direction in interpreting the oprofile +> output. + +I have some oProfile output; however, it's in 2 out of 20 tests I ran recently +and I need to get them sorted out. + +--Josh + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Oct 15 20:45:57 2004 +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 8EDDD32BD54 + for ; + Fri, 15 Oct 2004 20:45:55 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43116-10 + for ; + Fri, 15 Oct 2004 19:45:47 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.203]) + by svr1.postgresql.org (Postfix) with ESMTP id B139132A1B4 + for ; + Fri, 15 Oct 2004 20:45:46 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 77so12909rnk + for ; + Fri, 15 Oct 2004 12:45:46 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; 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:references; + b=TuQkRQd9H2CsEZl+pfcz0aXQeEExeYhscgjB88Z9Vc2Be/LTmX33qRVS54roYQWhikhkHiilFOj+pJmy03rKmTae7AJkWUyLwOt2BoA7qVnw+yHMjl80ZMXp3XJHwHyQF2oW7loybIDzkTQC9xrilfgQ02/S4WwWdpwcx7XO1Ck +Received: by 10.38.99.68 with SMTP id w68mr98078rnb; + Fri, 15 Oct 2004 12:45:11 -0700 (PDT) +Received: by 10.38.126.17 with HTTP; Fri, 15 Oct 2004 12:45:11 -0700 (PDT) +Message-ID: +Date: Fri, 15 Oct 2004 15:45:11 -0400 +From: Mike Rylander +Reply-To: Mike Rylander +To: "richard_d_levine@raytheon.com" +Subject: Re: Does PostgreSQL run with Oracle? +Cc: pgsql-performance@postgresql.org +In-Reply-To: +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200410/232 +X-Sequence-Number: 8708 + +On Fri, 15 Oct 2004 11:54:44 -0500, richard_d_levine@raytheon.com + wrote: +> My basic question to the community is "is PostgreSQL approximately as fast +> as Oracle?" + +My personal experience comparing PG to Oracle is across platforms, +Oracle on Sun/Solaris (2.7, quad-proc R440) and PG on Intel/Linux (2.6 +kernel, dual P3/1GHz). When both were tuned for the specific app I +saw a 45% speedup after switching to PG. This was with a customized +CRM and System Monitoring application serving ~40,000 trouble tickets +and monitoring 5,000 metric datapoints every 5-30 minutes. + +The hardware was definitely not comparable (the Intel boxes have more +horsepower and faster disks), but dollar for dollar, including support +costs, PG is the winner by a BIG margin. YMMV, of course, and my +results are apparently above average. + +Another big plus I found was that PG is much easier to admin as long +as you turn on pg_autovacuum. + +--miker + +From pgsql-performance-owner@postgresql.org Fri Oct 15 20:53:38 2004 +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 6B80B32BE02 + for ; + Fri, 15 Oct 2004 20:53:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47213-07 + for ; + Fri, 15 Oct 2004 19:53: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 C0DE932BDF7 + for ; + Fri, 15 Oct 2004 20:53:29 +0100 (BST) +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 i9FJrSJ0020132; + Fri, 15 Oct 2004 15:53:28 -0400 (EDT) +To: Doug Y +Cc: pgsql-performance@postgresql.org +Subject: Re: Tuning shared_buffers with ipcs ? +In-reply-to: <41701C35.4060808@ptd.net> +References: <416FF5BF.8060200@ptd.net> <10905.1097862665@sss.pgh.pa.us> + <41701C35.4060808@ptd.net> +Comments: In-reply-to Doug Y + message dated "Fri, 15 Oct 2004 14:51:33 -0400" +Date: Fri, 15 Oct 2004 15:53:28 -0400 +Message-ID: <20131.1097870008@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/233 +X-Sequence-Number: 8709 + +Doug Y writes: +> Tom Lane wrote: +>> I have not seen any such claim, and I do not see any way offhand that +>> ipcs could help. +>> +> Directly from: +> http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html +> "As a rule of thumb, observe shared memory usage of PostgreSQL with +> tools like ipcs and determine the setting." + +[ shrug ... ] So ask elein why she thinks that will help. + +>> This might tell you something about how many concurrent backends you've +>> used, but nothing about how many shared buffers you need. +>> +> Thats strange, I know I've had more than 4 concurrent connections on +> that box... (I just checked and there were at least a dozen). + +There is more than one per-backend semaphore per semaphore set, 16 per +set if memory serves; so the ipcs evidence points to a maximum of +between 49 and 64 concurrently active backends. It's not telling you a +darn thing about appropriate shared_buffers settings, however. + +> A mirror DB with the same config also has the same basic output from +> ipcs, except that it has times for 11 of the 17 arrays slots and most +> of them are the time when we do our backup dump (which makes sense +> that it would require more memory at that time.) + +That doesn't follow either. I think you may have some bottleneck that +causes client requests to pile up during a backup dump. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 21:09:21 2004 +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 6B80632BDA7 + for ; + Fri, 15 Oct 2004 21:09:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52686-06 + for ; + Fri, 15 Oct 2004 20:09:08 +0000 (GMT) +Received: from mail.trippynames.com (unknown [38.113.223.19]) + by svr1.postgresql.org (Postfix) with ESMTP id B9FCD32BD54 + for ; + Fri, 15 Oct 2004 21:09:08 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by mail.trippynames.com (Postfix) with ESMTP id C00F1A10C6; + Fri, 15 Oct 2004 13:09:07 -0700 (PDT) +Received: from mail.trippynames.com ([127.0.0.1]) + by localhost (rand.nxad.com [127.0.0.1]) (amavisd-new, + port 10024) with LMTP + id 32974-05; Fri, 15 Oct 2004 13:09:04 -0700 (PDT) +Received: from [192.168.1.104] (wbar4.sjo1-4.28.216.220.sjo1.dsl-verizon.net + [4.28.216.220]) + by mail.trippynames.com (Postfix) with ESMTP id C0F51A10C0; + Fri, 15 Oct 2004 13:09:03 -0700 (PDT) +In-Reply-To: <20041015010841.GE665@filer> +References: <157f64840410141725162e43b5@mail.gmail.com> + <20041015010841.GE665@filer> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <0E3BB9CB-1EE6-11D9-A0BB-000A95C705DC@chittenden.org> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Sean Chittenden +Subject: Re: mmap (was First set of OSDL Shared Mem scalability results, + some wierdness ... +Date: Fri, 15 Oct 2004 13:09:01 -0700 +To: Kevin Brown +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/234 +X-Sequence-Number: 8710 + +>> pg to my mind is unique in not trying to avoid OS buffering. Other +>> dbmses spend a substantial effort to create a virtual OS (task +>> management, I/O drivers, etc.) both in code and support. Choosing mmap +>> seems such a limiting an option - it adds OS dependency and limits +>> kernel developer options (2G limits, global mlock serializations, +>> porting problems, inability to schedule or parallelize I/O, still +>> having to coordinate writers and readers). + +2G limits? That must be a Linux limitation, not a limitation with +mmap(2). On OS-X and FreeBSD it's anywhere from 4GB to ... well, +whatever the 64bit limit is (which is bigger than any data file in +$PGDATA). An mlock(2) serialization problem is going to be cheaper +than hitting the disk in nearly all cases and should be no worse than a +context switch or semaphore (what we use for the current locking +scheme), of which PostgreSQL causes plenty of 'em because it's +multi-process, not multi-threaded. Coordination of data isn't +necessary if you mmap(2) data as a private block, which takes a +snapshot of the page at the time you make the mmap(2) call and gets +copied only when the page is written to. More on that later. + +> I'm not sure I entirely agree with this. Whether you access a file +> via mmap() or via read(), the end result is that you still have to +> access it, and since PG has significant chunks of system-dependent +> code that it heavily relies on as it is (e.g., locking mechanisms, +> shared memory), writing the I/O subsystem in a similar way doesn't +> seem to me to be that much of a stretch (especially since PG already +> has the storage manager), though it might involve quite a bit of work. + +Obviously you have to access the file on the hard drive, but you're +forgetting an enormous advantage of mmap(2). With a read(2) system +call, the program has to allocate space for the read(2), then it copies +data from the kernel into the allocated memory in the userland's newly +allocated memory location. With mmap(2) there is no second copy. + +Let's look at what happens with a read(2) call. To read(2) data you +have to have a block of memory to copy data into. Assume your OS of +choice has a good malloc(3) implementation and it only needs to call +brk(2) once to extend the process's memory address after the first +malloc(3) call. There's your first system call, which guarantees one +context switch. The second hit, a much larger hit, is the actual +read(2) call itself, wherein the kernel has to copy the data twice: +once into a kernel buffer, then from the kernel buffer into the +userland's memory space. Yuk. Webserver's figured this out long ago +that read(2) is slow and evil in terms of performance. Apache uses +mmap(2) to send static files at performance levels that don't suck and +is actually quite fast (in terms of responsiveness, I'm not talking +about Apache's parallelism/concurrency performance levels... which in +1.X aren't great). + +mmap(2) is a totally different animal in that you don't ever need to +make calls to read(2): mmap(2) is used in place of those calls (With +#ifdef and a good abstraction, the rest of PostgreSQL wouldn't know it +was working with a page of mmap(2)'ed data or need to know that it is). + Instead you mmap(2) a file descriptor and the kernel does some heavy +lifting/optimized magic in its VM. The kernel reads the file +descriptor and places the data it reads into its buffer (exactly the +same as what happens with read(2)), but, instead of copying the data to +the userspace, mmap(2) adjusts the process's address space and maps the +address of the kernel buffer into the process's address space. No +copying necessary. The savings here are *huge*! + +Depending on the mmap(2) implementation, the VM may not even get a page +from disk until its actually needed. So, lets say you mmap(2) a 16M +file. The address space picks up an extra 16M of bits that the process +*can* use, but doesn't necessarily use. So if a user reads only ten +pages out of a 16MB file, only 10 pages (10 * getpagesize()), or +usually 40,960K, which is 0.24% the amount of disk access (((4096 * 10) +/ (16 *1024 * 1024)) * 100). Did I forget to mention that if the file +is already in the kernel's buffers, there's no need for the kernel to +access the hard drive? Another big win for data that's hot/frequently +accessed. + +There's another large savings if the machine is doing network IO too... + +> As for parallelization of I/O, the use of mmap() for reads should +> signficantly improve parallelization -- now instead of issuing read() +> system calls, possibly for the same set of blocks, all the backends +> would essentially be examining the same data directly. The +> performance improvements as a result of accessing the kernel's cache +> pages directly instead of having it do buffer copies to process-local +> memory should increase as concurrency goes up. But see below. + +That's kinda true... though not quite correct. The improvement in IO +concurrency comes from zero-socket-copy operations from the disk to the +network controller. If a write(2) system call is issued on a page of +mmap(2)'ed data (and your operating system supports it, I know FreeBSD +does, but don't think Linux does), then the page of data is DMA'ed by +the network controller and sent out without the data needing to be +copied into the network controller's buffer. So, instead of the CPU +copying data from the OS's buffer to a kernel buffer, the network card +grabs the chunk of data in one interrupt because of the DMA (direct +memory access). This is a pretty big deal for web serving, but if +you've got a database sending large sets of data over the network, +assuming the network isn't the bottle neck, this results in a heafty +performance boost (that won't be noticed by most until they're running +huge, very busy installations). This optimization comes for free and +without needing to add one line of code to an application once mmap(2) +has been added to an application. + +>> More to the point, I think it is very hard to effectively coordinate +>> multithreaded I/O, and mmap seems used mostly to manage relatively +>> simple scenarios. +> +> PG already manages and coordinates multithreaded I/O. The mechanisms +> used to coordinate writes needn't change at all. But the way reads +> are done relative to writes might have to be rethought, since an +> mmap()ed buffer always reflects what's actually in kernel space at the +> time the buffer is accessed, while a buffer retrieved via read() +> reflects the state of the file at the time of the read(). If it's +> necessary for the state of the buffers to be fixed at examination +> time, then mmap() will be at best a draw, not a win. + +Here's where things can get interesting from a transaction stand point. + Your statement is correct up until you make the assertion that a page +needs to be fixed. If you're doing a read(2) transaction, mmap(2) a +region and set the MAP_PRIVATE flag so the ground won't change +underneath you. No copying of this page is done by the kernel unless +it gets written to. If you're doing a write(2) or are directly +scribbling on an mmap(2)'ed page[1], you need to grab some kind of an +exclusive lock on the page/file (mlock(2) is going to be no more +expensive than a semaphore, but probably less expensive). We already +do that with semaphores, however. So for databases that don't have +high contention for the same page/file of data, there are no additional +copies made. When a piece of data is written, a page is duplicated +before it gets scribbled on, but the application never knows this +happens. The next time a process mmap(2)'s a region of memory that's +been written to, it'll get the updated data without any need to flush a +cache or mark pages as dirty: the operating system does all of this for +us (and probably faster too). mmap(2) implementations are, IMHO, more +optimized that shared memory implementations (mmap(2) is a VM function, +which gets many eyes to look it over and is always being tuned, whereas +shared mem is a bastardized subsystem that works, but isn't integral to +any performance areas in the kernel so it gets neglected. Just my +observations from the *BSD commit lists. Linux it may be different). + +[1] I forgot to mention earlier, you don't have to write(2) data to a +file if it's mmap(2)'ed, you can change the contents of an mmap(2)'ed +region, then msync(2) it back to disk (to ensure it gets written out) +or let the last munmap(2) call do that for you (which would be just as +dangerous as running without fsync... but would result in an additional +performance boost). + +>> mmap doesn't look that promising. +> +> This ultimately depends on two things: how much time is spent copying +> buffers around in kernel memory, and how much advantage can be gained +> by freeing up the memory used by the backends to store the +> backend-local copies of the disk pages they use (and thus making that +> memory available to the kernel to use for additional disk buffering). + +Someone on IRC pointed me to some OSDL benchmarks, which broke down +where time is being spent. Want to know what the most expensive part +of PostgreSQL is? *drum roll* + +http://khack.osdl.org/stp/297960/profile/DBT_2_Profile-tick.sort + +3967393 total 1.7735 +2331284 default_idle 36426.3125 +825716 do_sigaction 1290.1813 +133126 __copy_from_user_ll 1040.0469 + 97780 __copy_to_user_ll 763.9062 + 43135 finish_task_switch 269.5938 + 30973 do_anonymous_page 62.4456 + 24175 scsi_request_fn 22.2197 + 23355 __do_softirq 121.6406 + 17039 __wake_up 133.1172 + 16527 __make_request 10.8730 + 9823 try_to_wake_up 13.6431 + 9525 generic_unplug_device 66.1458 + 8799 find_get_page 78.5625 + 7878 scsi_end_request 30.7734 + +Copying data to/from userspace and signal handling!!!! Let's hear it +for the need for mmap(2)!!! *crowd goes wild* + +> The gains from the former are likely small. The gains from the latter +> are probably also small, but harder to estimate. + +I disagree. + +> The use of mmap() is probably one of those optimizations that should +> be done when there's little else left to optimize, because the +> potential gains are possibly (if not probably) relatively small and +> the amount of work involved may be quite large. + +If system/kernel time is where most of your database spends its time, +then mmap(2) is a huge optimization that is very much worth pursuing. +It's stable (nearly all webservers use it, notably Apache), widely +deployed, POSIX specified (granted not all implementations are 100% +consistent, but that's an OS bug and mmap(2) doesn't have to be turned +on for those platforms: it's no worse than where we are now), and well +optimized by operating system hackers. I guarantee that your operating +system of choice has a faster VM and disk cache than PostgreSQL's +userland cache, nevermind using the OSs buffers leads to many +performance boosts as the OS can short-circuit common pathways that +would require data copying (ex: zero-socket-copy operations and copying +data to/from userland). + +mmap(2) isn't a panacea or replacement for good software design, but it +certainly does make IO operations vastly faster, which is what +PostgreSQL does a lot of (hence its need for a userland cache). +Remember, back when PostgreSQL had its architecture thunk up, mmap(2) +hardly existed in anyone's eyes, nevermind it being widely used or a +POSIX function. It wasn't until Apache started using it that Operating +System vendors felt the need to implement it or make it work well. Now +it's integral to nearly all virtual memory implementations and a modern +OS can't live without it or have it broken in any way. It would be +largely beneficial to PostgreSQL to heavily utilize mmap(2). + +A few places it should be used include: + +*) Storage. It is a good idea to mmap(2) all files instead of +read(2)'ing files. mmap(2) doesn't fetch a page from disk until its +actually needed, which is a nifty savings. Sure it causes a fault in +the kernel, but it won't the second time that page is accessed. +Changes are necessary to src/backend/storage/file/, possibly +src/backend/storage/freespace/ (why is it using fread(3) and not +read(2)?), src/backend/storage/large_object/ can remain gimpy since +people should use BYTEA instead (IMHO), src/backend/storage/page/ +doesn't need changes (I don't think), src/backend/storage/smgr/ +shouldn't need any modifications either. + +*) ARC. Why unmmap(2) data if you don't need to? With ARC, it's +possible for the database to coach the operating system in what pages +should be persistent. ARC's a smart algorithm for handling the needs +of a database. Instead of having a cache of pages in userland, +PostgreSQL would have a cache of mmap(2)'ed pages. It's shared between +processes, the changes are public to external programs read(2)'ing +data, and its quick. The needs for shared memory by the kernel drops +to nearly nothing. The needs for mmap(2)'able space in the kernel, +however, does go up. Unlike SysV shared mem, this can normally be +changed on the fly. The end result would be, if a page is needed, it +checks to see if its in the cache. If it is, the mmap(2)'ed page is +returned. If it isn't, the page gets read(2)/mmap(2) like it currently +is loaded (except in the mmap(2) case where after the data has been +loaded, the page gets munmap(2)'ed). If ARC decides to keep the page, +the page doesn't get munmap(2)'ed. I don't think any changes need to +be made though to take advantage of mmap(2) if the changes are made in +the places mentioned above in the Storage point. + + +A few other perks: + +*) DIRECTIO can be used without much of a cache coherency headache +since the cache of data is in the kernel, not userland. + +*) NFS. I'm not suggesting multiple clients use the same data +directory via NFS (unless read only), but if there were a single client +accessing a data directory over NFS, performance would be much better +than it is today because data consistency is handled by the kernel so +in flight packets for writes that get dropped or lost won't cause a +slow down (mmap(2) behaves differently with NFS pages) or corruption. + +*) mmap(2) is conditional on the operating system's abilities, but +doesn't require any architectural changes. It does change the location +of the cache, from being in the userland, down in to the kernel. This +is a change for database administrators, but a good one, IMHO. +Previously, the operating system would be split 25% kernel, 75% user +because PostgreSQL would need the available RAM for its cache. Now, +that can be moved closer to the opposite, 75% kernel, 25% user because +most of the memory is mmap(2)'ed pages instead of actual memory in the +userland. + +*) Pages can be protected via PROT_(EXEC|READ|WRITE). For backends +that aren't making changes to the DDL or system catalogs (permissions, +etc.), pages that are loaded from the catalogs could be loaded with the +protection PROT_READ, which would prevent changes to the catalogs. All +DDL and permission altering commands (anything that touches the system +catalogs) would then load the page with the PROT_WRITE bit set, make +their changes, then PROT_READ the page again. This would provide a +first line of defense against buggy programs or exploits. + +*) Eliminates the double caching done currently (caching in PostgreSQL +and the kernel) by pushing the cache into the kernel... but without +PostgreSQL knowing it's working on a page that's in the kernel. + +Please ask questions if you have them. + +-sc + +-- +Sean Chittenden + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 21:11:23 2004 +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 936A432BEBB + for ; + Fri, 15 Oct 2004 21:11:21 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52512-07 + for ; + Fri, 15 Oct 2004 20:11:14 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B9F532BDFB + for ; + Fri, 15 Oct 2004 21:11:15 +0100 (BST) +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 6508067; Fri, 15 Oct 2004 13:12:39 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +Date: Fri, 15 Oct 2004 13:13:13 -0700 +User-Agent: KMail/1.6.2 +Cc: Tom Lane , "Simon Riggs" , + "Timothy D. Witham" , testperf-general@pgfoundry.org +References: + <10202.1097858894@sss.pgh.pa.us> +In-Reply-To: <10202.1097858894@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200410151313.13624.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/235 +X-Sequence-Number: 8711 + +Tom, Simon: + +First off, two test runs with OProfile are available at: +http://khack.osdl.org/stp/298124/ +http://khack.osdl.org/stp/298121/ + +> AtEOXact_Buffers +> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0transaction commit or abo= +rt +> UnlockBuffers +> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0transaction abort, backen= +d exit + +Actually, this might explain the "hump" shape of the curve for this test.= +=20=20 +DBT2 is an OLTP test, which means that (at this scale level) it's attemptin= +g=20 +to do approximately 30 COMMITs per second as well as one ROLLBACK every 3= +=20 +seconds. When I get the tests on DBT3 running, if we see a more gentle= +=20 +dropoff on overallocated memory, it would indicate that the above may be a= +=20 +factor. + +--=20 +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Oct 15 21:16:39 2004 +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 1EFFC32BDDD + for ; + Fri, 15 Oct 2004 21:16:38 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55674-01 + for ; + Fri, 15 Oct 2004 20:16:30 +0000 (GMT) +Received: from mail.trippynames.com (unknown [38.113.223.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A26732BD81 + for ; + Fri, 15 Oct 2004 21:16:32 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by mail.trippynames.com (Postfix) with ESMTP id EB232A1004; + Fri, 15 Oct 2004 13:16:30 -0700 (PDT) +Received: from mail.trippynames.com ([127.0.0.1]) + by localhost (rand.nxad.com [127.0.0.1]) (amavisd-new, + port 10024) with LMTP + id 33979-04; Fri, 15 Oct 2004 13:16:29 -0700 (PDT) +Received: from [192.168.1.104] (wbar4.sjo1-4.28.216.220.sjo1.dsl-verizon.net + [4.28.216.220]) + by mail.trippynames.com (Postfix) with ESMTP id A3633A10C0; + Fri, 15 Oct 2004 13:16:29 -0700 (PDT) +In-Reply-To: <5235.1097817216@sss.pgh.pa.us> +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + <20041014202531.GD665@filer> <5235.1097817216@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <17EBD8C6-1EE7-11D9-A0BB-000A95C705DC@chittenden.org> +Content-Transfer-Encoding: 7bit +Cc: Kevin Brown , + pgsql-performance@postgresql.org +From: Sean Chittenden +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +Date: Fri, 15 Oct 2004 13:16:27 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/236 +X-Sequence-Number: 8712 + +> this. The SUS text is a bit weaselly ("the application must ensure +> correct synchronization") but the HPUX mmap man page, among others, +> lays it on the line: +> +> It is also unspecified whether write references to a memory region +> mapped with MAP_SHARED are visible to processes reading the file +> and +> whether writes to a file are visible to processes that have +> mapped the +> modified portion of that file, except for the effect of msync(). +> +> It might work on particular OSes but I think depending on such behavior +> would be folly... + +Agreed. Only OSes with a coherent file system buffer cache should ever +use mmap(2). In order for this to work on HPUX, msync(2) would need to +be used. -sc + +-- +Sean Chittenden + + +From pgsql-performance-owner@postgresql.org Fri Oct 15 21:34:13 2004 +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 025AE32BEE6 + for ; + Fri, 15 Oct 2004 21:34:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59343-07 + for ; + Fri, 15 Oct 2004 20: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 2EBDB32BECD + for ; + Fri, 15 Oct 2004 21:34:08 +0100 (BST) +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 i9FKY25J026069; + Fri, 15 Oct 2004 16:34:02 -0400 (EDT) +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org, "Simon Riggs" , + "Timothy D. Witham" , testperf-general@pgfoundry.org +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +In-reply-to: <200410151313.13624.josh@agliodbs.com> +References: + <10202.1097858894@sss.pgh.pa.us> + <200410151313.13624.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Fri, 15 Oct 2004 13:13:13 -0700" +Date: Fri, 15 Oct 2004 16:34:02 -0400 +Message-ID: <26068.1097872442@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/237 +X-Sequence-Number: 8713 + +Josh Berkus writes: +> First off, two test runs with OProfile are available at: +> http://khack.osdl.org/stp/298124/ +> http://khack.osdl.org/stp/298121/ + +Hmm. The stuff above 1% in the first of these is + +Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a unit mask of 0x00 (No unit mask) count 100000 +samples % app name symbol name +8522858 19.7539 vmlinux default_idle +3510225 8.1359 vmlinux recalc_sigpending_tsk +1874601 4.3449 vmlinux .text.lock.signal +1653816 3.8331 postgres SearchCatCache +1080908 2.5053 postgres AllocSetAlloc +920369 2.1332 postgres AtEOXact_Buffers +806218 1.8686 postgres OpernameGetCandidates +803125 1.8614 postgres StrategyDirtyBufferList +746123 1.7293 vmlinux __copy_from_user_ll +651978 1.5111 vmlinux __copy_to_user_ll +640511 1.4845 postgres XLogInsert +630797 1.4620 vmlinux rm_from_queue +607833 1.4088 vmlinux next_thread +436682 1.0121 postgres LWLockAcquire +419672 0.9727 postgres yyparse + +In the second test AtEOXact_Buffers is much lower (down around 0.57 +percent) but the other suspects are similar. Since the only difference +in parameters is shared_buffers (36000 vs 9000), it does look like we +are approaching the point where AtEOXact_Buffers is a problem, but so +far it's only a 2% drag. + +I suspect the reason recalc_sigpending_tsk is so high is that the +original coding of PG_TRY involved saving and restoring the signal mask, +which led to a whole lot of sigsetmask-type kernel calls. Is this test +with beta3, or something older? + +Another interesting item here is the costs of __copy_from_user_ll/ +__copy_to_user_ll: + +36000 buffers: +746123 1.7293 vmlinux __copy_from_user_ll +651978 1.5111 vmlinux __copy_to_user_ll + +9000 buffers: +866414 2.0810 vmlinux __copy_from_user_ll +852620 2.0479 vmlinux __copy_to_user_ll + +Presumably the higher costs for 9000 buffers reflect an increased amount +of shuffling of data between kernel and user space. So 36000 is not +enough to make the working set totally memory-resident, but even if we +drove this cost to zero we'd only be buying a couple percent. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 21:36:27 2004 +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 DE7A832C4CF + for ; + Fri, 15 Oct 2004 21:36:25 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59307-10 + for ; + Fri, 15 Oct 2004 20:36:18 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 72E8E32C279 + for ; + Fri, 15 Oct 2004 21:36:17 +0100 (BST) +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 6508228; Fri, 15 Oct 2004 13:37:42 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +Date: Fri, 15 Oct 2004 13:38:17 -0700 +User-Agent: KMail/1.6.2 +Cc: Tom Lane , "Simon Riggs" , + "Timothy D. Witham" , testperf-general@pgfoundry.org +References: + <200410151313.13624.josh@agliodbs.com> + <26068.1097872442@sss.pgh.pa.us> +In-Reply-To: <26068.1097872442@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200410151338.17277.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/238 +X-Sequence-Number: 8714 + +Tom, + +> I suspect the reason recalc_sigpending_tsk is so high is that the +> original coding of PG_TRY involved saving and restoring the signal mask, +> which led to a whole lot of sigsetmask-type kernel calls. Is this test +> with beta3, or something older? + +Beta3, *without* Gavin or Neil's Futex patch. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Oct 15 21:40:04 2004 +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 7C04132ACB1 + for ; + Fri, 15 Oct 2004 21:39:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61786-04 + for ; + Fri, 15 Oct 2004 20:39:55 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 49A9032A47F + for ; + Fri, 15 Oct 2004 21:39:54 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9FKdm611366; + Fri, 15 Oct 2004 13:39:48 -0700 +Date: Fri, 15 Oct 2004 13:39:47 -0700 +From: Mark Wong +To: Sean Chittenden +Cc: Kevin Brown , + pgsql-performance@postgresql.org +Subject: Re: mmap (was First set of OSDL Shared Mem scalability results, + some wierdness ... +Message-ID: <20041015133947.A9225@osdl.org> +References: <157f64840410141725162e43b5@mail.gmail.com> + <20041015010841.GE665@filer> + <0E3BB9CB-1EE6-11D9-A0BB-000A95C705DC@chittenden.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +In-Reply-To: <0E3BB9CB-1EE6-11D9-A0BB-000A95C705DC@chittenden.org>; + from sean@chittenden.org on Fri, Oct 15, 2004 at 01:09:01PM -0700 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/239 +X-Sequence-Number: 8715 + +On Fri, Oct 15, 2004 at 01:09:01PM -0700, Sean Chittenden wrote: +[snip] +> > +> > This ultimately depends on two things: how much time is spent copying +> > buffers around in kernel memory, and how much advantage can be gained +> > by freeing up the memory used by the backends to store the +> > backend-local copies of the disk pages they use (and thus making that +> > memory available to the kernel to use for additional disk buffering). +> +> Someone on IRC pointed me to some OSDL benchmarks, which broke down +> where time is being spent. Want to know what the most expensive part +> of PostgreSQL is? *drum roll* +> +> http://khack.osdl.org/stp/297960/profile/DBT_2_Profile-tick.sort +> +> 3967393 total 1.7735 +> 2331284 default_idle 36426.3125 +> 825716 do_sigaction 1290.1813 +> 133126 __copy_from_user_ll 1040.0469 +> 97780 __copy_to_user_ll 763.9062 +> 43135 finish_task_switch 269.5938 +> 30973 do_anonymous_page 62.4456 +> 24175 scsi_request_fn 22.2197 +> 23355 __do_softirq 121.6406 +> 17039 __wake_up 133.1172 +> 16527 __make_request 10.8730 +> 9823 try_to_wake_up 13.6431 +> 9525 generic_unplug_device 66.1458 +> 8799 find_get_page 78.5625 +> 7878 scsi_end_request 30.7734 +> +> Copying data to/from userspace and signal handling!!!! Let's hear it +> for the need for mmap(2)!!! *crowd goes wild* +> +[snip] + +I know where the do_sigaction is coming from in this particular case. +Manfred Spraul tracked it to a pair of pgsignal calls in libpq. +Commenting out those two calls out virtually eliminates do_sigaction from +the kernel profile for this workload. I've lost track of the discussion +over the past year, but I heard a rumor that it was finally addressed to +some degree. I did understand it touched on a lot of other things, but +can anyone summarize where that discussion has gone? + +Mark + +From pgsql-performance-owner@postgresql.org Fri Oct 15 22:18:18 2004 +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 BC81A32A232 + for ; + Fri, 15 Oct 2004 22:18:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71353-06 + for ; + Fri, 15 Oct 2004 21:18:13 +0000 (GMT) +Received: from neomail03.traderonline.com (email.traderonline.com + [65.213.231.10]) + by svr1.postgresql.org (Postfix) with ESMTP id E16D632A205 + for ; + Fri, 15 Oct 2004 22:18:13 +0100 (BST) +Received: from [192.168.1.68] + (64-139-89-109-ubr02b-epensb01-pa.hfc.comcastbusiness.net + [64.139.89.109]) + by neomail03.traderonline.com (8.12.10/8.12.8) with ESMTP id + i9FKffPG025327; Fri, 15 Oct 2004 16:41:41 -0400 +Message-ID: <41703E94.3030800@ptd.net> +Date: Fri, 15 Oct 2004 17:18:12 -0400 +From: Doug Y +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Tuning shared_buffers with ipcs ? +References: <416FF5BF.8060200@ptd.net> <10905.1097862665@sss.pgh.pa.us> + <41701C35.4060808@ptd.net> <20131.1097870008@sss.pgh.pa.us> +In-Reply-To: <20131.1097870008@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/240 +X-Sequence-Number: 8716 + +Tom Lane wrote: + +>Doug Y writes: +> +> +>>Tom Lane wrote: +>> +>> +>>>This might tell you something about how many concurrent backends you've +>>>used, but nothing about how many shared buffers you need. +>>> +>>> +>>> +>>Thats strange, I know I've had more than 4 concurrent connections on +>>that box... (I just checked and there were at least a dozen). +>> +>> +> +>There is more than one per-backend semaphore per semaphore set, 16 per +>set if memory serves; so the ipcs evidence points to a maximum of +>between 49 and 64 concurrently active backends. It's not telling you a +>darn thing about appropriate shared_buffers settings, however. +> +> +> +>>A mirror DB with the same config also has the same basic output from +>>ipcs, except that it has times for 11 of the 17 arrays slots and most +>>of them are the time when we do our backup dump (which makes sense +>>that it would require more memory at that time.) +>> +>> +> +>That doesn't follow either. I think you may have some bottleneck that +>causes client requests to pile up during a backup dump. +> +> regards, tom lane +> +> +Ok, that explains the number of arrays... max_connections / 16. + +Thanks... my mind works better when I can associate actual settings to +effects like that. And I'm sure that performance takes a hit during out +back-up dump. We're in the process of migrating them to dedicated mirror +machine to run dumps/reports etc from crons so that it won't negatively +affect the DB servers that get queries from the web applications. + +Thanks again for clarification. + +From pgsql-performance-owner@postgresql.org Fri Oct 15 22:22:36 2004 +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 011AD329EAC + for ; + Fri, 15 Oct 2004 22:22:35 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73448-04 + for ; + Fri, 15 Oct 2004 21:22: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 13A0F329E86 + for ; + Fri, 15 Oct 2004 22:22:32 +0100 (BST) +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 i9FLMQMP026391; + Fri, 15 Oct 2004 17:22:26 -0400 (EDT) +To: Sean Chittenden +Cc: Kevin Brown , + pgsql-performance@postgresql.org +Subject: Re: mmap (was First set of OSDL Shared Mem scalability results, + some wierdness ... +In-reply-to: <0E3BB9CB-1EE6-11D9-A0BB-000A95C705DC@chittenden.org> +References: <157f64840410141725162e43b5@mail.gmail.com> + <20041015010841.GE665@filer> + <0E3BB9CB-1EE6-11D9-A0BB-000A95C705DC@chittenden.org> +Comments: In-reply-to Sean Chittenden + message dated "Fri, 15 Oct 2004 13:09:01 -0700" +Date: Fri, 15 Oct 2004 17:22:26 -0400 +Message-ID: <26390.1097875346@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/241 +X-Sequence-Number: 8717 + +Sean Chittenden writes: +> Coordination of data isn't +> necessary if you mmap(2) data as a private block, which takes a +> snapshot of the page at the time you make the mmap(2) call and gets +> copied only when the page is written to. More on that later. + +We cannot move to a model where different backends have different +views of the same page, which seems to me to be inherent in the idea of +using MAP_PRIVATE for anything. To take just one example, a backend +that had mapped one btree index page some time ago could get completely +confused if that page splits, because it might see the effects of the +split in nearby index pages but not in the one that was split. Or it +could follow an index link to a heap entry that isn't there anymore, +or miss an entry it should have seen. MVCC doesn't save you from this +because btree adjustments happen below the level of transactions. + +However the really major difficulty with using mmap is that it breaks +the scheme we are currently using for WAL, because you don't have any +way to restrict how soon a change in an mmap'd page will go to disk. +(No, I don't believe that mlock guarantees this. It says that the +page will not be removed from main memory; it does not specify that, +say, the syncer won't write the contents out anyway.) + +> Let's look at what happens with a read(2) call. To read(2) data you +> have to have a block of memory to copy data into. Assume your OS of +> choice has a good malloc(3) implementation and it only needs to call +> brk(2) once to extend the process's memory address after the first +> malloc(3) call. There's your first system call, which guarantees one +> context switch. + +Wrong. Our reads occur into shared memory allocated at postmaster +startup, remember? + +> mmap(2) is a totally different animal in that you don't ever need to +> make calls to read(2): mmap(2) is used in place of those calls (With +> #ifdef and a good abstraction, the rest of PostgreSQL wouldn't know it +> was working with a page of mmap(2)'ed data or need to know that it is). + +Instead, you have to worry about address space management and keeping a +consistent view of the data. + +> ... If a write(2) system call is issued on a page of +> mmap(2)'ed data (and your operating system supports it, I know FreeBSD +> does, but don't think Linux does), then the page of data is DMA'ed by +> the network controller and sent out without the data needing to be +> copied into the network controller's buffer. + +Perfectly irrelevant to Postgres, since there is no situation where we'd +ever write directly from a disk buffer to a socket; in the present +implementation there are at least two levels of copy needed in between +(datatype-specific output function and protocol message assembly). And +that's not even counting the fact that any data item large enough to +make the savings interesting would have been sliced, diced, and +compressed by TOAST. + +> ... If you're doing a write(2) or are directly +> scribbling on an mmap(2)'ed page[1], you need to grab some kind of an +> exclusive lock on the page/file (mlock(2) is going to be no more +> expensive than a semaphore, but probably less expensive). + +More incorrect information. The locking involved here is done by +LWLockAcquire, which is significantly *less* expensive than a kernel +call in the case where there is no need to block. (If you have to +block, any kernel call to do so is probably about as bad as any other.) +Switching over to mlock would likely make things considerably slower. +In any case, you didn't actually mean to say mlock did you? It doesn't +lock pages against writes by other processes AFAICS. + +> shared mem is a bastardized subsystem that works, but isn't integral to +> any performance areas in the kernel so it gets neglected. + +What performance issues do you think shared memory needs to have fixed? +We don't issue any shmem kernel calls after the initial shmget, so +comparing the level of kernel tenseness about shmget to the level of +tenseness about mmap is simply irrelevant. Perhaps the reason you don't +see any traffic about this on the kernel lists is that shared memory +already works fine and doesn't need any fixing. + +> Please ask questions if you have them. + +Do you have any arguments that are actually convincing? What I just +read was a proposal to essentially throw away not only the entire +low-level data access model, but the entire low-level locking model, +and start from scratch. There is no possible way we could support both +this approach and the current one, which means that we'd be permanently +dropping support for all platforms without high-quality mmap +implementations; and despite your enthusiasm I don't think that that +category includes every interesting platform. Furthermore, you didn't +give any really convincing reasons to think that the enormous effort +involved would be repaid. Those oprofile reports Josh just put up +showed 3% of the CPU time going into userspace/kernelspace copying. +Even assuming that that number consists entirely of reads and writes of +shared buffers (and of course no other kernel call ever transfers any +data across that boundary ;-)), there's no way we are going to buy into +this sort of project in hopes of a 3% win. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 22:27:53 2004 +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 9CAF7329E76 + for ; + Fri, 15 Oct 2004 22:27:52 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73448-10 + for ; + Fri, 15 Oct 2004 21:27: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 1350F32A750 + for ; + Fri, 15 Oct 2004 22:27:34 +0100 (BST) +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 i9FLRUKS026452; + Fri, 15 Oct 2004 17:27:30 -0400 (EDT) +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org, "Simon Riggs" , + "Timothy D. Witham" , testperf-general@pgfoundry.org +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +In-reply-to: <200410151338.17277.josh@agliodbs.com> +References: + <200410151313.13624.josh@agliodbs.com> + <26068.1097872442@sss.pgh.pa.us> + <200410151338.17277.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Fri, 15 Oct 2004 13:38:17 -0700" +Date: Fri, 15 Oct 2004 17:27:29 -0400 +Message-ID: <26451.1097875649@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/242 +X-Sequence-Number: 8718 + +Josh Berkus writes: +>> I suspect the reason recalc_sigpending_tsk is so high is that the +>> original coding of PG_TRY involved saving and restoring the signal mask, +>> which led to a whole lot of sigsetmask-type kernel calls. Is this test +>> with beta3, or something older? + +> Beta3, *without* Gavin or Neil's Futex patch. + +Hmm, in that case the cost deserves some further investigation. Can we +find out just what that routine does and where it's being called from? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 22:32:24 2004 +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 C938532A4F1 + for ; + Fri, 15 Oct 2004 22:32:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76961-02 + for ; + Fri, 15 Oct 2004 21:32:17 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id D431032A388 + for ; + Fri, 15 Oct 2004 22:32:17 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9FLW6X21560; + Fri, 15 Oct 2004 14:32:06 -0700 +Date: Fri, 15 Oct 2004 14:32:06 -0700 +From: Mark Wong +To: Tom Lane +Cc: josh@agliodbs.com, Simon Riggs , + testperf-general@pgfoundry.org, pgsql-performance@postgresql.org +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +Message-ID: <20041015143206.A17724@osdl.org> +References: + <200410151313.13624.josh@agliodbs.com> + <26068.1097872442@sss.pgh.pa.us> + <200410151338.17277.josh@agliodbs.com> + <26451.1097875649@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +In-Reply-To: <26451.1097875649@sss.pgh.pa.us>; + from tgl@sss.pgh.pa.us on Fri, Oct 15, 2004 at 05:27:29PM -0400 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/243 +X-Sequence-Number: 8719 + +On Fri, Oct 15, 2004 at 05:27:29PM -0400, Tom Lane wrote: +> Josh Berkus writes: +> >> I suspect the reason recalc_sigpending_tsk is so high is that the +> >> original coding of PG_TRY involved saving and restoring the signal mask, +> >> which led to a whole lot of sigsetmask-type kernel calls. Is this test +> >> with beta3, or something older? +> +> > Beta3, *without* Gavin or Neil's Futex patch. +> +> Hmm, in that case the cost deserves some further investigation. Can we +> find out just what that routine does and where it's being called from? +> + +There's a call-graph feature with oprofile as of version 0.8 with +the opstack tool, but I'm having a terrible time figuring out why the +output isn't doing the graphing part. Otherwise, I'd have that +available already... + +Mark + +From pgsql-performance-owner@postgresql.org Fri Oct 15 22:38:17 2004 +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 A5C7732A772 + for ; + Fri, 15 Oct 2004 22:38:15 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77045-06 + for ; + Fri, 15 Oct 2004 21:37: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 3D20E32A5CC + for ; + Fri, 15 Oct 2004 22:37:55 +0100 (BST) +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 i9FLbohv026543; + Fri, 15 Oct 2004 17:37:50 -0400 (EDT) +To: Mark Wong +Cc: Sean Chittenden , + Kevin Brown , pgsql-performance@postgresql.org +Subject: Re: mmap (was First set of OSDL Shared Mem scalability results, + some wierdness ... +In-reply-to: <20041015133947.A9225@osdl.org> +References: <157f64840410141725162e43b5@mail.gmail.com> + <20041015010841.GE665@filer> + <0E3BB9CB-1EE6-11D9-A0BB-000A95C705DC@chittenden.org> + <20041015133947.A9225@osdl.org> +Comments: In-reply-to Mark Wong + message dated "Fri, 15 Oct 2004 13:39:47 -0700" +Date: Fri, 15 Oct 2004 17:37:50 -0400 +Message-ID: <26542.1097876270@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/244 +X-Sequence-Number: 8720 + +Mark Wong writes: +> I know where the do_sigaction is coming from in this particular case. +> Manfred Spraul tracked it to a pair of pgsignal calls in libpq. +> Commenting out those two calls out virtually eliminates do_sigaction from +> the kernel profile for this workload. + +Hmm, I suppose those are the ones associated with suppressing SIGPIPE +during send(). It looks to me like those should go away in 8.0 if you +have compiled with ENABLE_THREAD_SAFETY ... exactly how is PG being +built in the current round of tests? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 22:45:03 2004 +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 87BF932A750 + for ; + Fri, 15 Oct 2004 22:44:59 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80109-02 + for ; + Fri, 15 Oct 2004 21:44:40 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 31BA732A602 + for ; + Fri, 15 Oct 2004 22:44:41 +0100 (BST) +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 i9FLiYHQ026630; + Fri, 15 Oct 2004 17:44:34 -0400 (EDT) +To: Mark Wong +Cc: josh@agliodbs.com, Simon Riggs , + testperf-general@pgfoundry.org, pgsql-performance@postgresql.org +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +In-reply-to: <20041015143206.A17724@osdl.org> +References: + <200410151313.13624.josh@agliodbs.com> + <26068.1097872442@sss.pgh.pa.us> + <200410151338.17277.josh@agliodbs.com> + <26451.1097875649@sss.pgh.pa.us> <20041015143206.A17724@osdl.org> +Comments: In-reply-to Mark Wong + message dated "Fri, 15 Oct 2004 14:32:06 -0700" +Date: Fri, 15 Oct 2004 17:44:34 -0400 +Message-ID: <26629.1097876674@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/245 +X-Sequence-Number: 8721 + +Mark Wong writes: +> On Fri, Oct 15, 2004 at 05:27:29PM -0400, Tom Lane wrote: +>> Hmm, in that case the cost deserves some further investigation. Can we +>> find out just what that routine does and where it's being called from? + +> There's a call-graph feature with oprofile as of version 0.8 with +> the opstack tool, but I'm having a terrible time figuring out why the +> output isn't doing the graphing part. Otherwise, I'd have that +> available already... + +I was wondering if this might be associated with do_sigaction. +do_sigaction is only 0.23 percent of the runtime according to the +oprofile results: +http://khack.osdl.org/stp/298124/oprofile/DBT_2_Profile-all.oprofile.txt +but the profile results for the same run: +http://khack.osdl.org/stp/298124/profile/DBT_2_Profile-tick.sort +show do_sigaction very high and recalc_sigpending_tsk nowhere at all. +Something funny there. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 15 22:56:51 2004 +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 9B64632A99B + for ; + Fri, 15 Oct 2004 22:56:48 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83776-03 + for ; + Fri, 15 Oct 2004 21:56:45 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id DD67032A920 + for ; + Fri, 15 Oct 2004 22:56:46 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9FLuU927102; + Fri, 15 Oct 2004 14:56:30 -0700 +Date: Fri, 15 Oct 2004 14:56:30 -0700 +From: Mark Wong +To: Tom Lane +Cc: Sean Chittenden , + Kevin Brown , pgsql-performance@postgresql.org +Subject: Re: mmap (was First set of OSDL Shared Mem scalability results, + some wierdness ... +Message-ID: <20041015145630.A21918@osdl.org> +References: <157f64840410141725162e43b5@mail.gmail.com> + <20041015010841.GE665@filer> + <0E3BB9CB-1EE6-11D9-A0BB-000A95C705DC@chittenden.org> + <20041015133947.A9225@osdl.org> <26542.1097876270@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +In-Reply-To: <26542.1097876270@sss.pgh.pa.us>; + from tgl@sss.pgh.pa.us on Fri, Oct 15, 2004 at 05:37:50PM -0400 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/246 +X-Sequence-Number: 8722 + +On Fri, Oct 15, 2004 at 05:37:50PM -0400, Tom Lane wrote: +> Mark Wong writes: +> > I know where the do_sigaction is coming from in this particular case. +> > Manfred Spraul tracked it to a pair of pgsignal calls in libpq. +> > Commenting out those two calls out virtually eliminates do_sigaction from +> > the kernel profile for this workload. +> +> Hmm, I suppose those are the ones associated with suppressing SIGPIPE +> during send(). It looks to me like those should go away in 8.0 if you +> have compiled with ENABLE_THREAD_SAFETY ... exactly how is PG being +> built in the current round of tests? +> + +Ah, yes. Ok. It's not being configured with any options. That'll be easy to +rememdy though. I'll get that change made and we can try again. + +Mark + +From pgsql-performance-owner@postgresql.org Fri Oct 15 23:11:02 2004 +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 5E51332A115 + for ; + Fri, 15 Oct 2004 23:10:59 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87453-04 + for ; + Fri, 15 Oct 2004 22:10:39 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id CF2AA32A750 + for ; + Fri, 15 Oct 2004 23:10:37 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9FMAMO29943; + Fri, 15 Oct 2004 15:10:22 -0700 +Date: Fri, 15 Oct 2004 15:10:22 -0700 +From: Mark Wong +To: Tom Lane +Cc: josh@agliodbs.com, Simon Riggs , + testperf-general@pgfoundry.org, pgsql-performance@postgresql.org +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +Message-ID: <20041015151022.A27429@osdl.org> +References: + <200410151313.13624.josh@agliodbs.com> + <26068.1097872442@sss.pgh.pa.us> + <200410151338.17277.josh@agliodbs.com> + <26451.1097875649@sss.pgh.pa.us> <20041015143206.A17724@osdl.org> + <26629.1097876674@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +In-Reply-To: <26629.1097876674@sss.pgh.pa.us>; + from tgl@sss.pgh.pa.us on Fri, Oct 15, 2004 at 05:44:34PM -0400 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/247 +X-Sequence-Number: 8723 + +On Fri, Oct 15, 2004 at 05:44:34PM -0400, Tom Lane wrote: +> Mark Wong writes: +> > On Fri, Oct 15, 2004 at 05:27:29PM -0400, Tom Lane wrote: +> >> Hmm, in that case the cost deserves some further investigation. Can we +> >> find out just what that routine does and where it's being called from? +> +> > There's a call-graph feature with oprofile as of version 0.8 with +> > the opstack tool, but I'm having a terrible time figuring out why the +> > output isn't doing the graphing part. Otherwise, I'd have that +> > available already... +> +> I was wondering if this might be associated with do_sigaction. +> do_sigaction is only 0.23 percent of the runtime according to the +> oprofile results: +> http://khack.osdl.org/stp/298124/oprofile/DBT_2_Profile-all.oprofile.txt +> but the profile results for the same run: +> http://khack.osdl.org/stp/298124/profile/DBT_2_Profile-tick.sort +> show do_sigaction very high and recalc_sigpending_tsk nowhere at all. +> Something funny there. +> + +I have always attributed those kind of differences based on how +readprofile and oprofile collect their data. Granted I don't exactly +understand it. Anyone familiar with the two differences? + +Mark + +From pgsql-performance-owner@postgresql.org Fri Oct 15 23:32:52 2004 +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 5FD04329F42 + for ; + Fri, 15 Oct 2004 23:32:35 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90333-08 + for ; + Fri, 15 Oct 2004 22:32:29 +0000 (GMT) +Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) + by svr1.postgresql.org (Postfix) with SMTP id 68A8D32A07C + for ; + Fri, 15 Oct 2004 23:30:59 +0100 (BST) +Received: (qmail 28085 invoked by uid 1112); 15 Oct 2004 22:30:17 -0000 +Date: Fri, 15 Oct 2004 17:30:17 -0500 (EST) +From: Kris Jurka +X-X-Sender: books@leary.csoft.net +To: Stef +Cc: pgsql-performance@postgresql.org +Subject: Re: execute cursor fetch +In-Reply-To: <20041012150515.167c5e5e@svb.ucs.co.za> +Message-ID: +References: <20041012114343.69531.qmail@web54110.mail.yahoo.com> + <20041012150515.167c5e5e@svb.ucs.co.za> +MIME-Version: 1.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/248 +X-Sequence-Number: 8724 + + + +On Tue, 12 Oct 2004, Stef wrote: + +> Pierre-Fr=E9d=E9ric Caillaud mentioned : +> =3D> http://www.postgresql.org/docs/7.4/static/jdbc-query.html#AEN24298 +>=20 +> My question is : +> Is this only true for postgres versions >=3D 7.4 ? +>=20 +> I see the same section about "Setting fetch size to turn cursors on and o= +ff" +> is not in the postgres 7.3.7 docs. Does this mean 7.3 the JDBC driver +> for postgres < 7.4 doesn't support this ? +>=20 + +You need the 7.4 JDBC driver, but can run it against a 7.3 (or 7.2)=20 +database. Also note the 8.0 JDBC driver can only do this against a 7.4 or= +=20 +8.0 database and not older versions. + +Kris Jurka + +From pgsql-performance-owner@postgresql.org Sat Oct 16 02:22:51 2004 +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 9C93B329E7E + for ; + Sat, 16 Oct 2004 02:22:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24672-08 + for ; + Sat, 16 Oct 2004 01:22:35 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 38162329E43 + for ; + Sat, 16 Oct 2004 02:22:36 +0100 (BST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i9G1M3h03028; + Fri, 15 Oct 2004 21:22:03 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200410160122.i9G1M3h03028@candle.pha.pa.us> +Subject: Re: mmap (was First set of OSDL Shared Mem scalability results, +In-Reply-To: <26542.1097876270@sss.pgh.pa.us> +To: Tom Lane +Date: Fri, 15 Oct 2004 21:22:03 -0400 (EDT) +Cc: Mark Wong , Sean Chittenden , + Kevin Brown , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/249 +X-Sequence-Number: 8725 + +Tom Lane wrote: +> Mark Wong writes: +> > I know where the do_sigaction is coming from in this particular case. +> > Manfred Spraul tracked it to a pair of pgsignal calls in libpq. +> > Commenting out those two calls out virtually eliminates do_sigaction from +> > the kernel profile for this workload. +> +> Hmm, I suppose those are the ones associated with suppressing SIGPIPE +> during send(). It looks to me like those should go away in 8.0 if you +> have compiled with ENABLE_THREAD_SAFETY ... exactly how is PG being +> built in the current round of tests? + +Yes, those calls are gone in 8.0 with --enable-thread-safety and were +added specifically because of Manfred's reports. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-hackers-owner@postgresql.org Sat Oct 16 17:54:26 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6733A32A15D; + Sat, 16 Oct 2004 17:54:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10850-03; Sat, 16 Oct 2004 16:54: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 E1F7F32A2C6; + Sat, 16 Oct 2004 17:54:18 +0100 (BST) +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 i9GGsHSA004665; + Sat, 16 Oct 2004 12:54:17 -0400 (EDT) +To: pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org +Subject: Getting rid of AtEOXact_Buffers (was Re: [Testperf-general] Re: + [PERFORM] First set of OSDL Shared Memscalability results, + some wierdness ...) +In-reply-to: <26068.1097872442@sss.pgh.pa.us> +References: + <10202.1097858894@sss.pgh.pa.us> + <200410151313.13624.josh@agliodbs.com> + <26068.1097872442@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Fri, 15 Oct 2004 16:34:02 -0400" +Date: Sat, 16 Oct 2004 12:54:17 -0400 +Message-ID: <4664.1097945657@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/525 +X-Sequence-Number: 60028 + +I wrote: +> Josh Berkus writes: +>> First off, two test runs with OProfile are available at: +>> http://khack.osdl.org/stp/298124/ +>> http://khack.osdl.org/stp/298121/ + +> Hmm. The stuff above 1% in the first of these is + +> Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a unit mask of 0x00 (No unit mask) count 100000 +> samples % app name symbol name +> ... +> 920369 2.1332 postgres AtEOXact_Buffers +> ... + +> In the second test AtEOXact_Buffers is much lower (down around 0.57 +> percent) but the other suspects are similar. Since the only difference +> in parameters is shared_buffers (36000 vs 9000), it does look like we +> are approaching the point where AtEOXact_Buffers is a problem, but so +> far it's only a 2% drag. + +It occurs to me that given the 8.0 resource manager mechanism, we could +in fact dispense with AtEOXact_Buffers, or perhaps better turn it into a +no-op unless #ifdef USE_ASSERT_CHECKING. We'd just get rid of the +special case for transaction termination in resowner.c and let the +resource owner be responsible for releasing locked buffers always. The +OSDL results suggest that this won't matter much at the level of 10000 +or so shared buffers, but for 100000 or more buffers the linear scan in +AtEOXact_Buffers is going to become a problem. + +We could also get rid of the linear search in UnlockBuffers(). The only +thing it's for anymore is to release a BM_PIN_COUNT_WAITER flag, and +since a backend could not be doing more than one of those at a time, +we don't really need an array of flags for that, only a single variable. +This does not show in the OSDL results, which I presume means that their +test case is not exercising transaction aborts; but I think we need to +zap both routines to make the world safe for large shared_buffers +values. (See also +http://archives.postgresql.org/pgsql-performance/2004-10/msg00218.php) + +Any objection to doing this for 8.0? + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Sat Oct 16 22:16:41 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B755329D20; + Sat, 16 Oct 2004 22:16:33 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60907-08; Sat, 16 Oct 2004 21:16:26 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id E2C78329D22; + Sat, 16 Oct 2004 22:16:27 +0100 (BST) +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 6518021; Sat, 16 Oct 2004 14:17:50 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Getting rid of AtEOXact_Buffers (was Re: [Testperf-general] Re: + [PERFORM] First set of OSDL Shared Memscalability results, + some wierdness ...) +Date: Sat, 16 Oct 2004 14:18:26 -0700 +User-Agent: KMail/1.6.2 +Cc: Tom Lane , pgsql-hackers@postgreSQL.org +References: + <26068.1097872442@sss.pgh.pa.us> <4664.1097945657@sss.pgh.pa.us> +In-Reply-To: <4664.1097945657@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200410161418.26557.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/529 +X-Sequence-Number: 60032 + +Tom, + +> We could also get rid of the linear search in UnlockBuffers(). =C2=A0The = +only +> thing it's for anymore is to release a BM_PIN_COUNT_WAITER flag, and +> since a backend could not be doing more than one of those at a time, +> we don't really need an array of flags for that, only a single variable. +> This does not show in the OSDL results, which I presume means that their +> test case is not exercising transaction aborts; + +In the test, one out of every 100 new order transactions is aborted (about = +1=20 +out of 150 transactions overall). + +--=20 +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-hackers-owner@postgresql.org Sat Oct 16 22:19:25 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 83029329D28; + Sat, 16 Oct 2004 22:19:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63801-02; Sat, 16 Oct 2004 21:19:16 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E9A2329D20; + Sat, 16 Oct 2004 22:19:15 +0100 (BST) +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 i9GLJCkp000179; + Sat, 16 Oct 2004 17:19:12 -0400 (EDT) +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: Getting rid of AtEOXact_Buffers (was Re: [Testperf-general] Re: + [PERFORM] First set of OSDL Shared Memscalability results, + some wierdness ...) +In-reply-to: <200410161418.26557.josh@agliodbs.com> +References: + <26068.1097872442@sss.pgh.pa.us> <4664.1097945657@sss.pgh.pa.us> + <200410161418.26557.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Sat, 16 Oct 2004 14:18:26 -0700" +Date: Sat, 16 Oct 2004 17:19:11 -0400 +Message-ID: <178.1097961551@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/530 +X-Sequence-Number: 60033 + +Josh Berkus writes: +>> This does not show in the OSDL results, which I presume means that their +>> test case is not exercising transaction aborts; + +> In the test, one out of every 100 new order transactions is aborted (about 1 +> out of 150 transactions overall). + +Okay, but that just ensures that any bottlenecks in xact abort will be +down in the noise in this test case ... + +In any case, those changes are in CVS now if you want to try them. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Sat Oct 16 22:35:07 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 55143329D22; + Sat, 16 Oct 2004 22:35:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64460-09; Sat, 16 Oct 2004 21:34:44 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id DCC4C329DB3; + Sat, 16 Oct 2004 22:34:45 +0100 (BST) +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 6518089; Sat, 16 Oct 2004 14:36:09 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Getting rid of AtEOXact_Buffers (was Re: [Testperf-general] Re: + [PERFORM] First set of OSDL Shared Memscalability results, + some wierdness ...) +Date: Sat, 16 Oct 2004 14:36:45 -0700 +User-Agent: KMail/1.6.2 +Cc: Tom Lane , pgsql-hackers@postgresql.org +References: + <200410161418.26557.josh@agliodbs.com> + <178.1097961551@sss.pgh.pa.us> +In-Reply-To: <178.1097961551@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200410161436.45310.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/532 +X-Sequence-Number: 60035 + +Tom, + +> In any case, those changes are in CVS now if you want to try them. + +OK. Will have to wait until OSDL gives me a dedicated testing machine +sometime mon/tues/wed. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Oct 19 22:22:46 2004 +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 E59B932A334 + for ; + Sun, 17 Oct 2004 08:53:55 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78403-07 + for ; + Sun, 17 Oct 2004 07:53:45 +0000 (GMT) +Received: from dbl.q-ag.de (dbl.q-ag.de [213.172.117.3]) + by svr1.postgresql.org (Postfix) with ESMTP id C8017329E65 + for ; + Sun, 17 Oct 2004 08:53:42 +0100 (BST) +Received: from [127.0.0.2] (dbl [127.0.0.1]) + by dbl.q-ag.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i9H7rBSL028958; + Sun, 17 Oct 2004 09:53:13 +0200 +Message-ID: <417221B5.1050704@colorfullife.com> +Date: Sun, 17 Oct 2004 09:39:33 +0200 +From: Manfred Spraul +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.7.3) Gecko/20040922 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: neilc@samurai.com +Cc: markw@osdl.org, pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +Content-Type: multipart/mixed; boundary="------------090401080301040305060201" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/293 +X-Sequence-Number: 8769 + +This is a multi-part message in MIME format. +--------------090401080301040305060201 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Neil wrote: + +>. In any case, the "futex patch" +>uses the Linux 2.6 futex API to implement PostgreSQL spinlocks. +> +Has anyone tried to replace the whole lwlock implementation with +pthread_rwlock? At least for Linux with recent glibcs, pthread_rwlock is +implemented with futexes, i.e. we would get a fast lock handling without +os specific hacks. Perhaps other os contain user space pthread locks, too. +Attached is an old patch. I tested it on an uniprocessor system a year +ago and it didn't provide much difference, but perhaps the scalability +is better. You'll have to add -lpthread to the library list for linking. + +Regarding Neil's patch: + +>! /* +>! * XXX: is there a more efficient way to write this? Perhaps using +>! * decl...? +>! */ +>! static __inline__ slock_t +>! atomic_dec(volatile slock_t *ptr) +>! { +>! slock_t prev = -1; +>! +>! __asm__ __volatile__( +>! " lock \n" +>! " xadd %0,%1 \n" +>! :"=q"(prev) +>! :"m"(*ptr), "0"(prev) +>! :"memory", "cc"); +>! +>! return prev; +>! } +> +xadd is not supported by original 80386 cpus, it was added for 80486 +cpus. There is no instruction in the 80386 cpu that allows to atomically +decrement and retrieve the old value of an integer. The only option are +atomic_dec_test_zero or atomic_dec_test_negative - that can be +implemented by looking at the sign/zero flag. Depending on what you want +this may be enough. Or make the futex code conditional for > 80386 cpus. + +-- + Manfred + +--------------090401080301040305060201 +Content-Type: text/plain; + name="patch-pthread-force" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="patch-pthread-force" + +--- p7.3.3.orig/src/backend/storage/lmgr/lwlock.c 2002-09-25 22:31:40.000000000 +0200 ++++ postgresql-7.3.3/src/backend/storage/lmgr/lwlock.c 2003-09-06 14:15:01.000000000 +0200 +@@ -26,6 +26,28 @@ + #include "storage/proc.h" + #include "storage/spin.h" + ++#define USE_PTHREAD_LOCKS ++ ++#ifdef USE_PTHREAD_LOCKS ++ ++#include ++#include ++typedef pthread_rwlock_t LWLock; ++ ++inline static void ++InitLWLock(LWLock *p) ++{ ++ pthread_rwlockattr_t rwattr; ++ int i; ++ ++ pthread_rwlockattr_init(&rwattr); ++ pthread_rwlockattr_setpshared(&rwattr, PTHREAD_PROCESS_SHARED); ++ i=pthread_rwlock_init(p, &rwattr); ++ pthread_rwlockattr_destroy(&rwattr); ++ if (i) ++ elog(FATAL, "pthread_rwlock_init failed"); ++} ++#else + + typedef struct LWLock + { +@@ -38,6 +60,17 @@ + /* tail is undefined when head is NULL */ + } LWLock; + ++inline static void ++InitLWLock(LWLock *lock) ++{ ++ SpinLockInit(&lock->mutex); ++ lock->releaseOK = true; ++ lock->exclusive = 0; ++ lock->shared = 0; ++ lock->head = NULL; ++ lock->tail = NULL; ++} ++#endif + /* + * This points to the array of LWLocks in shared memory. Backends inherit + * the pointer by fork from the postmaster. LWLockIds are indexes into +@@ -61,7 +94,7 @@ + static LWLockId held_lwlocks[MAX_SIMUL_LWLOCKS]; + + +-#ifdef LOCK_DEBUG ++#if defined(LOCK_DEBUG) && !defined(USE_PTHREAD_LOCKS) + bool Trace_lwlocks = false; + + inline static void +@@ -153,12 +186,7 @@ + */ + for (id = 0, lock = LWLockArray; id < numLocks; id++, lock++) + { +- SpinLockInit(&lock->mutex); +- lock->releaseOK = true; +- lock->exclusive = 0; +- lock->shared = 0; +- lock->head = NULL; +- lock->tail = NULL; ++ InitLWLock(lock); + } + + /* +@@ -185,7 +213,116 @@ + return (LWLockId) (LWLockCounter[0]++); + } + ++#ifdef USE_PTHREAD_LOCKS ++/* ++ * LWLockAcquire - acquire a lightweight lock in the specified mode ++ * ++ * If the lock is not available, sleep until it is. ++ * ++ * Side effect: cancel/die interrupts are held off until lock release. ++ */ ++void ++LWLockAcquire(LWLockId lockid, LWLockMode mode) ++{ ++ int i; ++ PRINT_LWDEBUG("LWLockAcquire", lockid, &LWLockArray[lockid]); ++ ++ /* ++ * We can't wait if we haven't got a PGPROC. This should only occur ++ * during bootstrap or shared memory initialization. Put an Assert ++ * here to catch unsafe coding practices. ++ */ ++ Assert(!(proc == NULL && IsUnderPostmaster)); ++ ++ /* ++ * Lock out cancel/die interrupts until we exit the code section ++ * protected by the LWLock. This ensures that interrupts will not ++ * interfere with manipulations of data structures in shared memory. ++ */ ++ HOLD_INTERRUPTS(); ++ ++ if (mode == LW_EXCLUSIVE) { ++ i = pthread_rwlock_wrlock(&LWLockArray[lockid]); ++ } else { ++ i = pthread_rwlock_rdlock(&LWLockArray[lockid]); ++ } ++ if (i) ++ elog(FATAL, "Unexpected error from pthread_rwlock."); ++ ++ /* Add lock to list of locks held by this backend */ ++ Assert(num_held_lwlocks < MAX_SIMUL_LWLOCKS); ++ held_lwlocks[num_held_lwlocks++] = lockid; ++} ++ ++/* ++ * LWLockConditionalAcquire - acquire a lightweight lock in the specified mode ++ * ++ * If the lock is not available, return FALSE with no side-effects. ++ * ++ * If successful, cancel/die interrupts are held off until lock release. ++ */ ++bool ++LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode) ++{ ++ int i; ++ PRINT_LWDEBUG("LWLockConditionalAcquire", lockid, &LWLockArray[lockid]); ++ ++ HOLD_INTERRUPTS(); ++ ++ if (mode == LW_EXCLUSIVE) { ++ i = pthread_rwlock_trywrlock(&LWLockArray[lockid]); ++ } else { ++ i = pthread_rwlock_tryrdlock(&LWLockArray[lockid]); ++ } ++ switch(i) { ++ case 0: ++ /* Add lock to list of locks held by this backend */ ++ Assert(num_held_lwlocks < MAX_SIMUL_LWLOCKS); ++ held_lwlocks[num_held_lwlocks++] = lockid; ++ return true; ++ case EBUSY: ++ RESUME_INTERRUPTS(); ++ return false; ++ default: ++ elog(FATAL, "Unexpected error from pthread_rwlock_try."); ++ return false; ++ } ++} ++ ++/* ++ * LWLockRelease - release a previously acquired lock ++ */ ++void ++LWLockRelease(LWLockId lockid) ++{ ++ int i; ++ ++ /* ++ * Remove lock from list of locks held. Usually, but not always, it ++ * will be the latest-acquired lock; so search array backwards. ++ */ ++ for (i = num_held_lwlocks; --i >= 0;) ++ { ++ if (lockid == held_lwlocks[i]) ++ break; ++ } ++ if (i < 0) ++ elog(ERROR, "LWLockRelease: lock %d is not held", (int) lockid); ++ num_held_lwlocks--; ++ for (; i < num_held_lwlocks; i++) ++ held_lwlocks[i] = held_lwlocks[i + 1]; ++ ++ i = pthread_rwlock_unlock(&LWLockArray[lockid]); ++ if (i) ++ elog(FATAL, "Unexpected error from pthread_rwlock_unlock."); ++ ++ /* ++ * Now okay to allow cancel/die interrupts. ++ */ ++ RESUME_INTERRUPTS(); ++} + ++#else + /* + * LWLockAcquire - acquire a lightweight lock in the specified mode + * +@@ -499,6 +636,7 @@ + RESUME_INTERRUPTS(); + } + ++#endif + + /* + * LWLockReleaseAll - release all currently-held locks + +--------------090401080301040305060201-- + + +From pgsql-hackers-owner@postgresql.org Sun Oct 17 20:42:21 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 89DFE32A2A1; + Sun, 17 Oct 2004 20:42:14 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15654-04; Sun, 17 Oct 2004 19:42:11 +0000 (GMT) +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.184]) + by svr1.postgresql.org (Postfix) with ESMTP id C9A4D32A1BC; + Sun, 17 Oct 2004 20:42:08 +0100 (BST) +Received: from [212.227.126.202] (helo=mrvnet.kundenserver.de) + by moutng.kundenserver.de with esmtp (Exim 3.35 #1) + id 1CJGuo-00014X-00; Sun, 17 Oct 2004 21:42:02 +0200 +Received: from [172.23.4.143] (helo=config16.kundenserver.de) + by mrvnet.kundenserver.de with esmtp (Exim 3.35 #1) + id 1CJGun-00032J-00; Sun, 17 Oct 2004 21:42:01 +0200 +Received: from www-data by config16.kundenserver.de with local (Exim 3.35 #1 + (Debian)) id 1CJGun-00087B-00; Sun, 17 Oct 2004 21:42:01 +0200 +To: =?iso-8859-1?Q?Tom_Lane?= , + +Subject: + =?iso-8859-1?Q?Re:__Getting_rid_of_AtEOXact_Buffers_(was_Re:_[Testperf-general]_Re:_[PERFORM]_First_set_of_OSDL_Shared_Memscalability_results, + _some_wierdness_=2E=2E=2E)?= +From: +Cc: , + +Message-Id: <28292295$10980398474172c227e88c75.95384212@config16.schlund.de> +X-Binford: 6100 (more power) +X-Originating-From: 28292295 +X-Mailer: Webmail +X-Routing: UK +X-Received: from config16 by 217.135.203.211 with HTTP id 28292295 for + tgl@sss.pgh.pa.us; Sun, 17 Oct 2004 21:40:01 +0200 +Content-Type: text/plain; + charset="iso-8859-1" +Mime-Version: 1.0 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Date: Sun, 17 Oct 2004 21:40:01 +0200 +X-Provags-ID: kundenserver.de abuse@kundenserver.de ident:@172.23.4.143 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200410/552 +X-Sequence-Number: 60055 + + +Seeing as I've missed the last N messages... I'll just reply to this +one, rather than each of them in turn... + +Tom Lane wrote on 16.10.2004, 18:54:17: +> I wrote: +> > Josh Berkus writes: +> >> First off, two test runs with OProfile are available at: +> >> http://khack.osdl.org/stp/298124/ +> >> http://khack.osdl.org/stp/298121/ +> +> > Hmm. The stuff above 1% in the first of these is +> +> > Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a unit mask of 0x00 (No unit mask) count 100000 +> > samples % app name symbol name +> > ... +> > 920369 2.1332 postgres AtEOXact_Buffers +> > ... +> +> > In the second test AtEOXact_Buffers is much lower (down around 0.57 +> > percent) but the other suspects are similar. Since the only difference +> > in parameters is shared_buffers (36000 vs 9000), it does look like we +> > are approaching the point where AtEOXact_Buffers is a problem, but so +> > far it's only a 2% drag. + +Yes... as soon as you first mentioned AtEOXact_Buffers, I realised I'd +seen it near the top of the oprofile results on previous tests. + +Although you don't say this, I presume you're acting on the thought that +a 2% drag would soon become a much larger contention point with more +users and/or smaller transactions - since these things are highly +non-linear. + +> +> It occurs to me that given the 8.0 resource manager mechanism, we could +> in fact dispense with AtEOXact_Buffers, or perhaps better turn it into a +> no-op unless #ifdef USE_ASSERT_CHECKING. We'd just get rid of the +> special case for transaction termination in resowner.c and let the +> resource owner be responsible for releasing locked buffers always. The +> OSDL results suggest that this won't matter much at the level of 10000 +> or so shared buffers, but for 100000 or more buffers the linear scan in +> AtEOXact_Buffers is going to become a problem. + +If the resource owner is always responsible for releasing locked +buffers, who releases the locks if the backend crashes? Do we need some +additional code in bgwriter (or?) to clean up buffer locks? + +> +> We could also get rid of the linear search in UnlockBuffers(). The only +> thing it's for anymore is to release a BM_PIN_COUNT_WAITER flag, and +> since a backend could not be doing more than one of those at a time, +> we don't really need an array of flags for that, only a single variable. +> This does not show in the OSDL results, which I presume means that their +> test case is not exercising transaction aborts; but I think we need to +> zap both routines to make the world safe for large shared_buffers +> values. (See also +> http://archives.postgresql.org/pgsql-performance/2004-10/msg00218.php) + +Yes, that's important. + +> Any objection to doing this for 8.0? +> + +As you say, if these issues are definitely kicking in at 100000 +shared_buffers - there's a good few people out there with 800Mb +shared_buffers already. + +Could I also suggest that we adopt your earlier suggestion of raising +the bgwriter parameters as a permanent measure - i.e. changing the +defaults in postgresql.conf. That way, StrategyDirtyBufferList won't +immediately show itself as a problem when using the default parameter +set. It would be a shame to remove one obstacle only to leave another +one following so close behind. [...and that also argues against an +earlier thought to introduce more fine grained values for the +bgwriter's parameters, ISTM] + +Also, what will Vacuum delay do to the O(N) effect of +FlushRelationBuffers when called by VACUUM? Will the locks be held for +longer? + +I think we should do some tests while running a VACUUM in the background +also, which isn't part of the DBT-2 set-up, but perhaps we might argue +*it should be for the PostgreSQL version*? + +Dare we hope for a scalability increase in 8.0 after all.... + +Best Regards, + +Simon Riggs + +From pgsql-hackers-owner@postgresql.org Sun Oct 17 21:12:55 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 04380329E4C; + Sun, 17 Oct 2004 21:12:48 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22889-01; Sun, 17 Oct 2004 20:12:37 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E4FA1329D3B; + Sun, 17 Oct 2004 21:12:38 +0100 (BST) +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 i9HKCZMF010585; + Sun, 17 Oct 2004 16:12:35 -0400 (EDT) +To: simon@2ndquadrant.com +Cc: josh@agliodbs.com, pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: + =?iso-8859-1?Q?Re:__Getting_rid_of_AtEOXact_Buffers_(was_Re:_[Testperf-general]_Re:_[PERFORM]_First_set_of_OSDL_Shared_Memscalability_results, + _some_wierdness_=2E=2E=2E)?= +In-reply-to: <28292295$10980398474172c227e88c75.95384212@config16.schlund.de> +References: <28292295$10980398474172c227e88c75.95384212@config16.schlund.de> +Comments: In-reply-to + message dated "Sun, 17 Oct 2004 21:40:01 +0200" +Date: Sun, 17 Oct 2004 16:12:35 -0400 +Message-ID: <10584.1098043955@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/554 +X-Sequence-Number: 60057 + + writes: +> If the resource owner is always responsible for releasing locked +> buffers, who releases the locks if the backend crashes? + +The ensuing system reset takes care of that. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 18 01:50:10 2004 +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 63C6E329FF6 + for ; + Mon, 18 Oct 2004 01:50:01 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78993-04 + for ; + Mon, 18 Oct 2004 00:49:55 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 71AC0329EA8 + for ; + Mon, 18 Oct 2004 01:49:58 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9I0nsJ9079812 + for ; Mon, 18 Oct 2004 00:49:54 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9I0M7C6074762 + for pgsql-performance@postgresql.org; Mon, 18 Oct 2004 00:22:07 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: [HACKERS] Getting rid of AtEOXact Buffers (was Re: + [Testperf-general] +Date: Mon, 18 Oct 2004 02:22:08 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 11 +Message-ID: <41730CB0.60903@bigfoot.com> +References: <28292295$10980398474172c227e88c75.95384212@config16.schlund.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: simon@2ndquadrant.com +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +In-Reply-To: <28292295$10980398474172c227e88c75.95384212@config16.schlund.de> +X-Enigmail-Version: 0.86.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/256 +X-Sequence-Number: 8732 + +simon@2ndquadrant.com wrote: + +> If the resource owner is always responsible for releasing locked +> buffers, who releases the locks if the backend crashes? + +The semaphore "undo" I hope. + + +Regards +Gaetano Mendola + + +From pgsql-performance-owner@postgresql.org Mon Oct 18 09:50:31 2004 +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 A4AF3329E6E + for ; + Mon, 18 Oct 2004 09:50:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94421-01 + for ; + Mon, 18 Oct 2004 08:50:23 +0000 (GMT) +Received: from audi.ibcp.fr (audi-ghost.ibcp.fr [193.55.43.240]) + by svr1.postgresql.org (Postfix) with ESMTP id 65A3A32A18A + for ; + Mon, 18 Oct 2004 09:50:22 +0100 (BST) +Received: from ibcp.fr (gdeleage15.ibcp.fr [193.51.160.66]) + by audi.ibcp.fr (Postfix) with ESMTP id 8FC841AF369 + for ; + Mon, 18 Oct 2004 10:50:21 +0200 (CEST) +Message-ID: <417383CD.3050802@ibcp.fr> +Date: Mon, 18 Oct 2004 10:50:21 +0200 +From: charavay +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040308 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Indexes performance +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/257 +X-Sequence-Number: 8733 + +Hello ! +We have difficulties with the use of indexes. For example, we have two +tables : + + * table lnk : + +Table "public.lnk" + Column | Type | Modifiers +--------+-----------------------+----------- + index | integer | not null + sgaccn | character varying(12) | not null +Indexes: + "pkey1" primary key, btree ("index", sgaccn) +Foreign-key constraints: + "fk_sgaccn1" FOREIGN KEY (sgaccn) REFERENCES main_tbl(sgaccn) ON UPDATE +CASCADE ON DELETE CASCADE + + * table dic : + +Table "public.dic" + Column | Type | Modifiers + +--------+-----------------------+-------------------------------------------------------------------- + index | integer | not null default +nextval('public.dic_index_seq'::text) + word | character varying(60) | not null +Indexes: + "dic_pkey" primary key, btree ("index") + "dic_word_idx" unique, btree (word) + "dic_word_key" unique, btree (word) + + + +The table lnk contains 33 000 000 tuples and table dic contains 303 000 +tuples. + +When we try to execute a join between these two tables, the planner +proposes to excute a hash-join plan : + +explain select sgaccn from dic, lnk where dic.index=lnk.index; + QUERY PLAN + +----------------------------------------------------------------------------------- + Hash Join (cost=6793.29..1716853.80 rows=33743101 width=11) + Hash Cond: ("outer"."index" = "inner"."index") + -> Seq Scan on lnk (cost=0.00..535920.00 rows=33743100 width=15) + -> Hash (cost=4994.83..4994.83 rows=303783 width=4) + -> Seq Scan dic (cost=0.00..4994.83 rows=303783 width=4) +(5 rows) + +So the planner decides to scan 33 000 000 of tuples and we would like to +force it to scan the table dic (303 000 tuples) and to use +the index on the integer index to execute the join. So we have set the +parameters enable_hashjoin and enable_mergejoin to off. So the planner +proposes the following query : + + QUERY PLAN + +-------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..102642540.60 rows=33743101 width=11) + -> Seq Scan on refs_ra_lnk1 (cost=0.00..535920.00 rows=33743100 +width=15) + -> Index Scan using refs_ra_dic_new_pkey on refs_ra_dic_new +(cost=0.00..3.01 rows=1 width=4) + Index Cond: (refs_ra_dic_new."index" = "outer"."index") +(4 rows) + +We were surprised of this response because the planner continues to +propose us to scan the 33 000 000 of tuples instead of the smaller +table. Is there any way to force it to scan the smaller table ? + +Thanks + +Celine Charavay + + +From pgsql-performance-owner@postgresql.org Mon Oct 18 16:28:48 2004 +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 80293329F8C + for ; + Mon, 18 Oct 2004 16:28:46 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14799-02 + for ; + Mon, 18 Oct 2004 15:28:41 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C7BA329DB0 + for ; + Mon, 18 Oct 2004 16:28:40 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9IFSAJ12704; + Mon, 18 Oct 2004 08:28:10 -0700 +Date: Mon, 18 Oct 2004 08:28:10 -0700 +From: Mark Wong +To: Bruce Momjian +Cc: Tom Lane , Sean Chittenden , + Kevin Brown , pgsql-performance@postgresql.org +Subject: Re: mmap (was First set of OSDL Shared Mem scalability results, + some wierdness ... +Message-ID: <20041018082810.A11062@osdl.org> +References: <26542.1097876270@sss.pgh.pa.us> + <200410160122.i9G1M3h03028@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +In-Reply-To: <200410160122.i9G1M3h03028@candle.pha.pa.us>; + from pgman@candle.pha.pa.us on Fri, Oct 15, 2004 at 09:22:03PM + -0400 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/258 +X-Sequence-Number: 8734 + +On Fri, Oct 15, 2004 at 09:22:03PM -0400, Bruce Momjian wrote: +> Tom Lane wrote: +> > Mark Wong writes: +> > > I know where the do_sigaction is coming from in this particular case. +> > > Manfred Spraul tracked it to a pair of pgsignal calls in libpq. +> > > Commenting out those two calls out virtually eliminates do_sigaction from +> > > the kernel profile for this workload. +> > +> > Hmm, I suppose those are the ones associated with suppressing SIGPIPE +> > during send(). It looks to me like those should go away in 8.0 if you +> > have compiled with ENABLE_THREAD_SAFETY ... exactly how is PG being +> > built in the current round of tests? +> +> Yes, those calls are gone in 8.0 with --enable-thread-safety and were +> added specifically because of Manfred's reports. +> + +Ok, I had the build commands changed for installing PostgreSQL in STP. +The do_sigaction call isn't at the top of the profile anymore, here's +a reference for those who are interested; it should have the same test +parameters as the one Tom referenced a little earlier: + http://khack.osdl.org/stp/298230/ + +Mark + +From pgsql-performance-owner@postgresql.org Mon Oct 18 19:01:23 2004 +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 B3E54329F90 + for ; + Mon, 18 Oct 2004 19:01:21 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68545-01 + for ; + Mon, 18 Oct 2004 18:01:13 +0000 (GMT) +Received: from shenley.e-rm.co.uk (shenley.e-rm.co.uk [217.154.196.234]) + by svr1.postgresql.org (Postfix) with ESMTP id E2D1632A94E + for ; + Mon, 18 Oct 2004 19:00:12 +0100 (BST) +Received: from gator.e-rm.internal ([192.168.2.1] helo=dev1) + by shenley.e-rm.co.uk with esmtp (Exim 3.35 #1 (Debian)) + id 1CJbnc-0003pu-00 + for ; Mon, 18 Oct 2004 19:00:00 +0100 +From: "Rod Dutton" +To: +Subject: Queries slow using stored procedures +Date: Mon, 18 Oct 2004 19:01:25 +0100 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0028_01C4B544.DFB19FA0" +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +Thread-Index: AcS1PHuwz718w8JtTi2M+MPIPiou1g== +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +Message-Id: +X-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_50_60, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/259 +X-Sequence-Number: 8735 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0028_01C4B544.DFB19FA0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +Hi, + +I have a problem where a query inside a function is up to 100 times slower +inside a function than as a stand alone query run in psql. + +The column 'botnumber' is a character(10), is indexed and there are 125000 +rows in the table. + +Help please! + +This query is fast:- + +explain analyze + SELECT batchserial + FROM transbatch + WHERE botnumber = '1-7' + LIMIT 1; + + QUERY PLAN + +---------------------------------------------------------------------------- +---------------------------------------------------- + Limit (cost=0.00..0.42 rows=1 width=4) (actual time=0.73..148.23 rows=1 +loops=1) + -> Index Scan using ind_tbatchx on transbatch (cost=0.00..18.73 rows=45 +width=4) (actual time=0.73..148.22 rows=1 loops=1) + Index Cond: (botnumber = '1-7'::bpchar) + Total runtime: 148.29 msec +(4 rows) + + +This function is slow:- + +CREATE OR REPLACE FUNCTION sp_test_rod3 ( ) returns integer +as ' +DECLARE + bot char(10); + oldbatch INTEGER; +BEGIN + + bot := ''1-7''; + + SELECT INTO oldbatch batchserial + FROM transbatch + WHERE botnumber = bot + LIMIT 1; + + IF FOUND THEN + RETURN 1; + ELSE + RETURN 0; + END IF; + +END; +' +language plpgsql ; + + +explain analyze SELECT sp_test_rod3(); + + QUERY PLAN + +---------------------------------------------------------------------------- +------------ + Result (cost=0.00..0.01 rows=1 width=0) (actual time=1452.39..1452.40 +rows=1 loops=1) + Total runtime: 1452.42 msec +(2 rows) + + +------=_NextPart_000_0028_01C4B544.DFB19FA0 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + +
Hi,
+
 
+
I have a = +problem=20 +where a query inside a function is up to 100 times slower inside a function= + than=20 +as a stand alone query run in psql.
+
 
+
The colum= +n=20 +'botnumber' is a character(10), is indexed and there are 125000 rows i= +n the=20 +table.
+
 
+
Help=20 +please!
+
 
+
This quer= +y is=20 +fast:-
+
 
+
explain= +=20 +analyze  
+
&nb= +sp;=20 +SELECT batchserial
  FROM transbatch
  WHERE botnumb= +er =3D=20 +'1-7'
  LIMIT 1;
+
           = +            &nb= +sp;            = +            &nb= +sp;         =20 +QUERY=20 +PLAN            = +;            &n= +bsp;            = +;            &n= +bsp;        =20 +
-----------------------------------------------------------------------= +---------------------------------------------------------
 Limit&nb= +sp;=20 +(cost=3D0.00..0.42 rows=3D1 width=3D4) (actual time=3D0.73..148.23 rows=3D1= +=20 +loops=3D1)
   ->  Index Scan using ind_tbatchx on=20 +transbatch  (cost=3D0.00..18.73 rows=3D45 width=3D4) (actual time=3D0.= +73..148.22=20 +rows=3D1 loops=3D1)
         Ind= +ex Cond:=20 +(botnumber =3D '1-7'::bpchar)
 Total runtime: 148.29 msec
(4=20 +rows)
+
 
+
 
+
Thi= +s function=20 +is slow:-
+
 
+
CRE= +ATE OR=20 +REPLACE FUNCTION  sp_test_rod3 ( ) returns=20 +integer         
as=20 +'
DECLARE
  bot char(10);
  oldbatch=20 +INTEGER;
BEGIN
+
 
+
&nb= +sp; bot :=3D=20 +''1-7'';
+
 
+
&nb= +sp; SELECT=20 +INTO oldbatch batchserial
  FROM transbatch
  WHERE botnumb= +er =3D=20 +bot
  LIMIT 1;
+
 
+
&nb= +sp; IF=20 +FOUND THEN
    RETURN 1;
  ELSE
  &n= +bsp;=20 +RETURN 0;
  END IF;
+
 
+
END;
'
language plpgsql  ;
+
 
+
exp= +lain=20 +analyze SELECT sp_test_rod3();
+
           = +            &nb= +sp;            = +  =20 +QUERY=20 +PLAN            = +;            &n= +bsp;            = +; =20 +
-----------------------------------------------------------------------= +-----------------
 Result =20 +(cost=3D0.00..0.01 rows=3D1 width=3D0) (actual time=3D1452.39..1452.40 rows= +=3D1=20 +loops=3D1)
 Total runtime: 1452.42 msec
(2=20 +rows)
+ +------=_NextPart_000_0028_01C4B544.DFB19FA0-- + + +From pgsql-performance-owner@postgresql.org Mon Oct 18 19:13:40 2004 +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 54086329E57 + for ; + Mon, 18 Oct 2004 19:13:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69404-09 + for ; + Mon, 18 Oct 2004 18:13:29 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id A7CAC329DFC + for ; + Mon, 18 Oct 2004 19:13:28 +0100 (BST) +Received: from [192.168.1.20] (clbb-248.saw.net [64.146.135.248]) + (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i9IIDOu16699; + Mon, 18 Oct 2004 11:13:24 -0700 +Message-ID: <4174074F.5010607@commandprompt.com> +Date: Mon, 18 Oct 2004 11:11:27 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: nd02tsk@student.hig.se +Cc: pgsql-performance@postgresql.org +Subject: Re: How to time several queries? +References: <2612.130.243.12.107.1098124104.squirrel@130.243.12.107> +In-Reply-To: <2612.130.243.12.107.1098124104.squirrel@130.243.12.107> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/261 +X-Sequence-Number: 8737 + +nd02tsk@student.hig.se wrote: + +>Hello +> +>I posted this on the general list but think it would be more appropriate +>here. Sorry. +> +>I know it is possible to time isolated queries through the settting of the +>\timing option in psql. This makes PgSQL report the time it took to +>perform one operation. +> +>I would like to know how one can get a time summary of many operations, if +>it is at all possible. +> +> +> +Hello, + +You can turn on statement and duration logging in the postgresql.conf + + +>Thank you. +> +>Tim +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 4: Don't 'kill -9' the postmaster +> +> + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL + + +From pgsql-performance-owner@postgresql.org Mon Oct 18 19:09:24 2004 +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 812C7329E57 + for ; + Mon, 18 Oct 2004 19:09:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70667-05 + for ; + Mon, 18 Oct 2004 18:09:07 +0000 (GMT) +Received: from heimdall.hig.se (heimdall.hig.se [130.243.8.180]) + by svr1.postgresql.org (Postfix) with SMTP id 8F21E329E7F + for ; + Mon, 18 Oct 2004 19:09:04 +0100 (BST) +Received: from webmail.student.hig.se ([130.243.8.161]) + by heimdall.hig.se (SAVSMTP 3.1.0.29) with SMTP id M2004101820045716856 + for ; Mon, 18 Oct 2004 20:04:57 +0200 +Received: from 130.243.12.107 (SquirrelMail authenticated user nd02tsk); + by webmail.student.hig.se with HTTP; + Mon, 18 Oct 2004 20:28:24 +0200 (CEST) +Message-ID: <2612.130.243.12.107.1098124104.squirrel@130.243.12.107> +Date: Mon, 18 Oct 2004 20:28:24 +0200 (CEST) +Subject: How to time several queries? +From: nd02tsk@student.hig.se +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.3 +X-Mailer: SquirrelMail/1.4.3 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 (Normal) +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200410/260 +X-Sequence-Number: 8736 + +Hello + +I posted this on the general list but think it would be more appropriate +here. Sorry. + +I know it is possible to time isolated queries through the settting of the +\timing option in psql. This makes PgSQL report the time it took to +perform one operation. + +I would like to know how one can get a time summary of many operations, if +it is at all possible. + +Thank you. + +Tim + + + +From pgsql-performance-owner@postgresql.org Mon Oct 18 19:44:56 2004 +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 D60D2329C89 + for ; + Mon, 18 Oct 2004 19:44:54 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82034-05 + for ; + Mon, 18 Oct 2004 18:44:45 +0000 (GMT) +Received: from smtp110.mail.sc5.yahoo.com (smtp110.mail.sc5.yahoo.com + [66.163.170.8]) + by svr1.postgresql.org (Postfix) with SMTP id 42B79329F9B + for ; + Mon, 18 Oct 2004 19:44:45 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp110.mail.sc5.yahoo.com with SMTP; 18 Oct 2004 18:44:43 -0000 +Received: from [172.21.8.18] (ismtp.afilias.com [216.217.55.254]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9IIid94027894; Mon, 18 Oct 2004 14:44:40 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <41740F11.1070902@Yahoo.com> +Date: Mon, 18 Oct 2004 14:44:33 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bruce Momjian +Cc: josh@agliodbs.com, pgsql-performance@postgresql.org, + Aaron Glenn +Subject: Re: Free PostgreSQL Training, Philadelphia, Oct 30 +References: <200410140347.i9E3l5910978@candle.pha.pa.us> +In-Reply-To: <200410140347.i9E3l5910978@candle.pha.pa.us> +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.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200410/262 +X-Sequence-Number: 8738 + +On 10/13/2004 11:47 PM, Bruce Momjian wrote: + +> Josh Berkus wrote: +>> Aaron, +>> +>> > That makes two of us. Hanging out with Tom, Bruce, and others at OSCON +>> > 2002 was one of the most informative and fun times I've had. That and +>> > I could really stand to brush up on my Postgres basics +>> +>> You're thinking of Jan. Tom wasn't at OSCON. ;-) +> +> Ah, but he said 2002 and I think Tom was there that year. +> + +And I wasn't, which makes it rather difficult to hang out with me. + +I will however be in Malvern too, since it's just around the corner for me. + + +Jan + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-performance-owner@postgresql.org Mon Oct 18 20:17:44 2004 +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 F329032A892 + for ; + Mon, 18 Oct 2004 20:17:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90817-06 + for ; + Mon, 18 Oct 2004 19:17:38 +0000 (GMT) +Received: from smtp109.mail.sc5.yahoo.com (smtp109.mail.sc5.yahoo.com + [66.163.170.7]) + by svr1.postgresql.org (Postfix) with SMTP id 309F632A887 + for ; + Mon, 18 Oct 2004 20:17:35 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp109.mail.sc5.yahoo.com with SMTP; 18 Oct 2004 19:17:33 -0000 +Received: from [172.21.8.18] (ismtp.afilias.com [216.217.55.254]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9IJHH94028842; Mon, 18 Oct 2004 15:17:23 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <417416B7.4060209@Yahoo.com> +Date: Mon, 18 Oct 2004 15:17:11 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Simon Riggs +Cc: josh@agliodbs.com, pgsql-performance@postgresql.org, + testperf-general@pgfoundry.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +References: +In-Reply-To: +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.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200410/263 +X-Sequence-Number: 8739 + +On 10/14/2004 6:36 PM, Simon Riggs wrote: + +> [...] +> I think Jan has said this also in far fewer words, but I'll leave that to +> Jan to agree/disagree... + +I do agree. The total DB size has as little to do with the optimum +shared buffer cache size as the total available RAM of the machine. + +After reading your comments it appears more clear to me. All what those +tests did show is the amount of high frequently accessed data in this +database population and workload combination. + +> +> I say this: ARC in 8.0 PostgreSQL allows us to sensibly allocate as large a +> shared_buffers cache as is required by the database workload, and this +> should not be constrained to a small percentage of server RAM. + +Right. + + +Jan + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-performance-owner@postgresql.org Mon Oct 18 20:37:59 2004 +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 8F77032A887 + for ; + Mon, 18 Oct 2004 20:37:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99517-03 + for ; + Mon, 18 Oct 2004 19:37:55 +0000 (GMT) +Received: from smtp111.mail.sc5.yahoo.com (smtp111.mail.sc5.yahoo.com + [66.163.170.9]) + by svr1.postgresql.org (Postfix) with SMTP id 8065F32A34A + for ; + Mon, 18 Oct 2004 20:37:55 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp111.mail.sc5.yahoo.com with SMTP; 18 Oct 2004 19:37:54 -0000 +Received: from [172.21.8.18] (ismtp.afilias.com [216.217.55.254]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9IJbo94029432; Mon, 18 Oct 2004 15:37:52 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <41741B87.4090104@Yahoo.com> +Date: Mon, 18 Oct 2004 15:37:43 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +References: <200410081443.16109.josh@agliodbs.com> + + +In-Reply-To: +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.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200410/264 +X-Sequence-Number: 8740 + +On 10/14/2004 8:10 PM, Christopher Browne wrote: + +> Quoth simon@2ndquadrant.com ("Simon Riggs"): +>> I say this: ARC in 8.0 PostgreSQL allows us to sensibly allocate as +>> large a shared_buffers cache as is required by the database +>> workload, and this should not be constrained to a small percentage +>> of server RAM. +> +> I don't think that this particularly follows from "what ARC does." + +The combination of ARC together with the background writer is supposed +to allow us to allocate the optimum even if that is large. The former +implementation of the LRU without background writer would just hang the +server for a long time during a checkpoint, which is absolutely +inacceptable for any OLTP system. + + +Jan + +> +> "What ARC does" is to prevent certain conspicuous patterns of +> sequential accesses from essentially trashing the contents of the +> cache. +> +> If a particular benchmark does not include conspicuous vacuums or +> sequential scans on large tables, then there is little reason to +> expect ARC to have a noticeable impact on performance. +> +> It _could_ be that this implies that ARC allows you to get some use +> out of a larger shared cache, as it won't get blown away by vacuums +> and Seq Scans. But it is _not_ obvious that this is a necessary +> truth. +> +> _Other_ truths we know about are: +> +> a) If you increase the shared cache, that means more data that is +> represented in both the shared cache and the OS buffer cache, +> which seems rather a waste; +> +> b) The larger the shared cache, the more pages there are for the +> backend to rummage through before it looks to the filesystem, +> and therefore the more expensive cache misses get. Cache hits +> get more expensive, too. Searching through memory is not +> costless. + + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-performance-owner@postgresql.org Mon Oct 18 20:43:25 2004 +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 C6B9C32A97D + for ; + Mon, 18 Oct 2004 20:43:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01054-05 + for ; + Mon, 18 Oct 2004 19:43:12 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 5376F32A887 + for ; + Mon, 18 Oct 2004 20:43:10 +0100 (BST) +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 6524695; Mon, 18 Oct 2004 12:44:34 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Indexes performance +Date: Mon, 18 Oct 2004 12:45:10 -0700 +User-Agent: KMail/1.6.2 +Cc: charavay +References: <417383CD.3050802@ibcp.fr> +In-Reply-To: <417383CD.3050802@ibcp.fr> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200410181245.10810.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/265 +X-Sequence-Number: 8741 + +Charavay, + +> -------------------------------------------------------------------------= +-- +>-------- Hash Join =A0(cost=3D6793.29..1716853.80 rows=3D33743101 width=3D= +11) +> =A0 =A0Hash Cond: ("outer"."index" =3D "inner"."index") +> =A0 =A0-> =A0Seq Scan on lnk =A0(cost=3D0.00..535920.00 rows=3D33743100 w= +idth=3D15) +> =A0 =A0-> =A0Hash =A0(cost=3D4994.83..4994.83 rows=3D303783 width=3D4) +> =A0 =A0 =A0 =A0 =A0-> =A0Seq Scan dic =A0(cost=3D0.00..4994.83 rows=3D303= +783 width=3D4) +> (5 rows) + +According to the estimate, you are selecting all of the rows in the databas= +e.=20=20=20 +This is going to require a Seq Scan no matter what. + +--=20 +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-hackers-owner@postgresql.org Mon Oct 18 21:36:43 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C7D6D32A507 + for ; + Mon, 18 Oct 2004 21:36:40 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17568-09 + for ; + Mon, 18 Oct 2004 20:36:33 +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 251EF32A0C8 + for ; + Mon, 18 Oct 2004 21:36:34 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp104.mail.sc5.yahoo.com with SMTP; 18 Oct 2004 20:36:33 -0000 +Received: from [172.21.8.18] (ismtp.afilias.com [216.217.55.254]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9IKaQ94031018; Mon, 18 Oct 2004 16:36:26 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <41742943.4050603@Yahoo.com> +Date: Mon, 18 Oct 2004 16:36:19 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: simon@2ndquadrant.com +Cc: Tom Lane , josh@agliodbs.com, + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: Getting rid of AtEOXact Buffers (was Re: [Testperf-general] +References: <28292295$10980398474172c227e88c75.95384212@config16.schlund.de> +In-Reply-To: <28292295$10980398474172c227e88c75.95384212@config16.schlund.de> +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.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200410/612 +X-Sequence-Number: 60115 + +On 10/17/2004 3:40 PM, simon@2ndquadrant.com wrote: + +> Seeing as I've missed the last N messages... I'll just reply to this +> one, rather than each of them in turn... +> +> Tom Lane wrote on 16.10.2004, 18:54:17: +>> I wrote: +>> > Josh Berkus writes: +>> >> First off, two test runs with OProfile are available at: +>> >> http://khack.osdl.org/stp/298124/ +>> >> http://khack.osdl.org/stp/298121/ +>> +>> > Hmm. The stuff above 1% in the first of these is +>> +>> > Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a unit mask of 0x00 (No unit mask) count 100000 +>> > samples % app name symbol name +>> > ... +>> > 920369 2.1332 postgres AtEOXact_Buffers +>> > ... +>> +>> > In the second test AtEOXact_Buffers is much lower (down around 0.57 +>> > percent) but the other suspects are similar. Since the only difference +>> > in parameters is shared_buffers (36000 vs 9000), it does look like we +>> > are approaching the point where AtEOXact_Buffers is a problem, but so +>> > far it's only a 2% drag. +> +> Yes... as soon as you first mentioned AtEOXact_Buffers, I realised I'd +> seen it near the top of the oprofile results on previous tests. +> +> Although you don't say this, I presume you're acting on the thought that +> a 2% drag would soon become a much larger contention point with more +> users and/or smaller transactions - since these things are highly +> non-linear. +> +>> +>> It occurs to me that given the 8.0 resource manager mechanism, we could +>> in fact dispense with AtEOXact_Buffers, or perhaps better turn it into a +>> no-op unless #ifdef USE_ASSERT_CHECKING. We'd just get rid of the +>> special case for transaction termination in resowner.c and let the +>> resource owner be responsible for releasing locked buffers always. The +>> OSDL results suggest that this won't matter much at the level of 10000 +>> or so shared buffers, but for 100000 or more buffers the linear scan in +>> AtEOXact_Buffers is going to become a problem. +> +> If the resource owner is always responsible for releasing locked +> buffers, who releases the locks if the backend crashes? Do we need some +> additional code in bgwriter (or?) to clean up buffer locks? + +If the backend crashes, the postmaster (assuming a possibly corrupted +shared memory) restarts the whole lot ... so why bother? + +> +>> +>> We could also get rid of the linear search in UnlockBuffers(). The only +>> thing it's for anymore is to release a BM_PIN_COUNT_WAITER flag, and +>> since a backend could not be doing more than one of those at a time, +>> we don't really need an array of flags for that, only a single variable. +>> This does not show in the OSDL results, which I presume means that their +>> test case is not exercising transaction aborts; but I think we need to +>> zap both routines to make the world safe for large shared_buffers +>> values. (See also +>> http://archives.postgresql.org/pgsql-performance/2004-10/msg00218.php) +> +> Yes, that's important. +> +>> Any objection to doing this for 8.0? +>> +> +> As you say, if these issues are definitely kicking in at 100000 +> shared_buffers - there's a good few people out there with 800Mb +> shared_buffers already. +> +> Could I also suggest that we adopt your earlier suggestion of raising +> the bgwriter parameters as a permanent measure - i.e. changing the +> defaults in postgresql.conf. That way, StrategyDirtyBufferList won't +> immediately show itself as a problem when using the default parameter +> set. It would be a shame to remove one obstacle only to leave another +> one following so close behind. [...and that also argues against an +> earlier thought to introduce more fine grained values for the +> bgwriter's parameters, ISTM] + +I realized that StrategyDirtyBufferList currently wasts a lot of time by +first scanning over all the buffers that haven't even been hit since +it's last call and neither have been dirty last time (and thus, are at +the beginning of the list and can't be dirty anyway). If we would have a +way to give it a smart "point in the list to start scanning" ... + + +> +> Also, what will Vacuum delay do to the O(N) effect of +> FlushRelationBuffers when called by VACUUM? Will the locks be held for +> longer? + +Vacuum only naps at the points where it checks for interrupts, and at +that time it isn't supposed to hold any critical locks. + + +Jan + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-performance-owner@postgresql.org Mon Oct 18 21:59:08 2004 +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 78D0132A585 + for ; + Mon, 18 Oct 2004 21:59:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27745-01 + for ; + Mon, 18 Oct 2004 20:58:53 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id B4E8532A552 + for ; + Mon, 18 Oct 2004 21:58:51 +0100 (BST) +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 6524976 for pgsql-performance@postgresql.org; + Mon, 18 Oct 2004 14:00:15 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: [Testperf-general] Re: First set of OSDL Shared Memscalability + results, some wierdness ... +Date: Mon, 18 Oct 2004 14:00:45 -0700 +User-Agent: KMail/1.6.2 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410181400.45005.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/267 +X-Sequence-Number: 8743 + +Simon, + +> I agree that you could test this by running on a bigger or smaller server, +> i.e. one with more or less RAM. Running on a faster/slower server at the +> same time might alter the results and confuse the situation. + +Unfortunately, a faster server is the only option I have that also has more +RAM. If I double the RAM and double the processors at the same time, what +would you expect to happen to the shared_buffers curve? + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-hackers-owner@postgresql.org Mon Oct 18 22:01:36 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 80D9B329F5D + for ; + Mon, 18 Oct 2004 22:01:35 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29152-03 + for ; + Mon, 18 Oct 2004 21:01: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 29574329F4C + for ; + Mon, 18 Oct 2004 22:01:30 +0100 (BST) +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 i9IL1PkW006909; + Mon, 18 Oct 2004 17:01:26 -0400 (EDT) +To: Jan Wieck +Cc: simon@2ndquadrant.com, josh@agliodbs.com, + pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: Getting rid of AtEOXact Buffers (was Re: [Testperf-general] Re: + [PERFORM] First set of OSDL Shared Memscalability results, + some wierdness ...) +In-reply-to: <41742943.4050603@Yahoo.com> +References: <28292295$10980398474172c227e88c75.95384212@config16.schlund.de> + <41742943.4050603@Yahoo.com> +Comments: In-reply-to Jan Wieck + message dated "Mon, 18 Oct 2004 16:36:19 -0400" +Date: Mon, 18 Oct 2004 17:01:25 -0400 +Message-ID: <6908.1098133285@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/613 +X-Sequence-Number: 60116 + +Jan Wieck writes: +> I realized that StrategyDirtyBufferList currently wasts a lot of time by +> first scanning over all the buffers that haven't even been hit since +> it's last call and neither have been dirty last time (and thus, are at +> the beginning of the list and can't be dirty anyway). If we would have a +> way to give it a smart "point in the list to start scanning" ... + +I don't think it's true that they *can't* be dirty. + +(1) Buffers are marked dirty when released, whereas they are moved to +the fronts of the lists when acquired. + +(2) the cntxDirty bit can be set asynchronously to any BufMgrLock'd +operation. + +But it sure seems like we are doing more work than we really need to. + +One idea I had was for the bgwriter to collect all the dirty pages up to +say halfway on the LRU lists, and then write *all* of these, not just +the first N, over as many rounds as are needed. Then go back and call +StrategyDirtyBufferList again to get a new list. (We don't want it to +write every dirty buffer this way, because the ones near the front of +the list are likely to be dirtied again right away. But certainly we +could write more than 1% of the dirty buffers without getting into the +area of the recently-used buffers.) + +There isn't any particularly good reason for this to share code with +checkpoint-style BufferSync, btw. BufferSync could just as easily scan +the buffers linearly, since it doesn't matter what order it writes them +in. So we could change StrategyDirtyBufferList to stop as soon as it's +halfway up the LRU lists, which would save at least a few cycles. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Mon Oct 18 22:19:56 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 017FE329FAF + for ; + Mon, 18 Oct 2004 22:19:49 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31757-06 + for ; + Mon, 18 Oct 2004 21:19:38 +0000 (GMT) +Received: from smtp018.mail.yahoo.com (smtp018.mail.yahoo.com + [216.136.174.115]) + by svr1.postgresql.org (Postfix) with SMTP id 53ADB329EBB + for ; + Mon, 18 Oct 2004 22:19:38 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp018.mail.yahoo.com with SMTP; 18 Oct 2004 21:19:37 -0000 +Received: from [172.21.8.18] (ismtp.afilias.com [216.217.55.254]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9ILJT94032117; Mon, 18 Oct 2004 17:19:30 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <41743355.9060005@Yahoo.com> +Date: Mon, 18 Oct 2004 17:19:17 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jan Wieck +Cc: simon@2ndquadrant.com, Tom Lane , + josh@agliodbs.com, pgsql-hackers@postgresql.org, + pgsql-performance@postgresql.org +Subject: Autotuning of shared buffer size (was: Re: Getting rid + of AtEOXact Buffers (was Re: [Testperf-general] Re: [PERFORM] First set + of OSDL Shared Memscalability results, some wierdness ...)) +References: <28292295$10980398474172c227e88c75.95384212@config16.schlund.de> + <41742943.4050603@Yahoo.com> +In-Reply-To: <41742943.4050603@Yahoo.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.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200410/614 +X-Sequence-Number: 60117 + +Trying to think a little out of the box, how "common" is it in modern +operating systems to be able to swap out shared memory? + +Maybe we're not using the ARC algorithm correctly after all. The ARC +algorithm does not consider the second level OS buffer cache in it's +design. Maybe the total size of the ARC cache directory should not be 2x +the size of what is configured as the shared buffer cache, but rather 2x +the size of the effective cache size (in 8k pages). If we assume that +the job of the T1 queue is better done by the OS buffers anyway (and +this is what this discussion seems to point out), we shouldn't hold them +in shared buffers (only very few of them and evict them ASAP). We just +account for them and assume that the OS will have those cached that we +find in our T1 directory. I think with the right configuration for +effective cache size, this is a fair assumption. The T2 queue represents +the frequently used blocks. If our implementation would cause the +unused/used portions of the buffers not to move around, the OS will swap +out currently unused portions of the shared buffer cache and utilize +those as OS buffers. + +To verify this theory it would be interesting what the ARC strategy +after a long DBT run with a "large" buffer cache thinks a good T2 size +would be. Enabling the strategy debug message and running postmaster +with -d1 will show that. In theory, this size should be anywhere near +the sweet spot. + + +Jan + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-performance-owner@postgresql.org Tue Oct 19 01:02:23 2004 +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 0C098329E48 + for ; + Tue, 19 Oct 2004 01:02:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71236-10 + for ; + Tue, 19 Oct 2004 00:02: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 2265D329E23 + for ; + Tue, 19 Oct 2004 01:02:05 +0100 (BST) +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 i9J023jU009791; + Mon, 18 Oct 2004 20:02:03 -0400 (EDT) +To: charavay +Cc: pgsql-performance@postgresql.org +Subject: Re: Indexes performance +In-reply-to: <417383CD.3050802@ibcp.fr> +References: <417383CD.3050802@ibcp.fr> +Comments: In-reply-to charavay + message dated "Mon, 18 Oct 2004 10:50:21 +0200" +Date: Mon, 18 Oct 2004 20:02:03 -0400 +Message-ID: <9790.1098144123@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/270 +X-Sequence-Number: 8746 + +charavay writes: +> ... So the planner decides to scan 33 000 000 of tuples and we would like to +> force it to scan the table dic (303 000 tuples) and to use +> the index on the integer index to execute the join. + +I'm mystified why you think that that will be a superior plan. It still +requires visiting every row of the larger table (I assume that all of +the larger table's rows do join to some row of the smaller table). +All that it accomplishes is to force those visits to occur in a +quasi-random order; which not only loses any chance of kernel read-ahead +optimizations, but very likely causes each page of the table to be read +more than once. + +AFAICT the planner made exactly the right choice by picking a hashjoin. +Have you tried comparing its estimates against actual runtimes for the +different plans? (See EXPLAIN ANALYZE.) + +Offhand the only way I can think of to force it to do the nestloop the +other way around from what it wants to is to temporarily drop the +index it wants to use. You can do that conveniently like so: + + begin; + alter table dic drop constraint dic_pkey; + explain analyze select ...; + rollback; + +which of course would be no good for production, but it should at least +serve to destroy your illusions about wanting to do it in production. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 19 08:25:37 2004 +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 3351132A0E7 + for ; + Tue, 19 Oct 2004 08:25:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82887-04 + for ; + Tue, 19 Oct 2004 07:25:23 +0000 (GMT) +Received: from mailer.unicite.fr.netcentrex.net (unknown [62.161.167.249]) + by svr1.postgresql.org (Postfix) with ESMTP id D191332A06D + for ; + Tue, 19 Oct 2004 08:25:18 +0100 (BST) +Received: from akira ([192.168.101.228]) by mailer.unicite.fr.netcentrex.net + with SMTP (Microsoft Exchange Internet Mail Service Version + 5.5.2657.72) id 42CYALCL; Tue, 19 Oct 2004 09:25:17 +0200 +From: "Alban Medici (NetCentrex)" +To: +Subject: Re: Queries slow using stored procedures +Date: Tue, 19 Oct 2004 09:25:08 +0200 +Organization: NetCentrex +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_007C_01C4B5BD.8C390510" +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Thread-Index: AcS1PHuwz718w8JtTi2M+MPIPiou1gAbm7fg +In-Reply-To: +Message-Id: <20041019072518.D191332A06D@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=HTML_50_60, + HTML_FONTCOLOR_BLUE, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/271 +X-Sequence-Number: 8747 + +This is a multi-part message in MIME format. + +------=_NextPart_000_007C_01C4B5BD.8C390510 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +You seem to not have index on botnumber, but in your query bot number is +the clause. + +I don't explain you why the same query is so long. +but have your try procedure with a loop structure (witch create cursor) ? + +you could try + + +CREATE OR REPLACE FUNCTION sp_test_Alban1 ( ) returns integer +as ' +DECLARE + bot char(10); + oldbatch INTEGER; + rec RECORD; + query VARCHAR; + +BEGIN + + -- initialisation + bot := ''1-7''; + query := '' SELECT batchserial FROM transbatch WHERE botnumber = ' || +quote_ident(bot) || '' ;''; + + + FOR rec IN EXECUTE var_query LOOP + return rec."batchserial ".; + END LOOP; + + --else + return 0; + +END; +' +language plpgsql ; + +does it return the same results in the same time ? + + _____ + +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Rod Dutton +Sent: lundi 18 octobre 2004 20:01 +To: pgsql-performance@postgresql.org +Subject: [PERFORM] Queries slow using stored procedures + + +Hi, + +I have a problem where a query inside a function is up to 100 times slower +inside a function than as a stand alone query run in psql. + +The column 'botnumber' is a character(10), is indexed and there are 125000 +rows in the table. + +Help please! + +This query is fast:- + +explain analyze + SELECT batchserial + FROM transbatch + WHERE botnumber = '1-7' + LIMIT 1; + + QUERY PLAN + +---------------------------------------------------------------------------- +---------------------------------------------------- + Limit (cost=0.00..0.42 rows=1 width=4) (actual time=0.73..148.23 rows=1 +loops=1) + -> Index Scan using ind_tbatchx on transbatch (cost=0.00..18.73 rows=45 +width=4) (actual time=0.73..148.22 rows=1 loops=1) + Index Cond: (botnumber = '1-7'::bpchar) + Total runtime: 148.29 msec +(4 rows) + + +This function is slow:- + +CREATE OR REPLACE FUNCTION sp_test_rod3 ( ) returns integer +as ' +DECLARE + bot char(10); + oldbatch INTEGER; +BEGIN + + bot := ''1-7''; + + SELECT INTO oldbatch batchserial + FROM transbatch + WHERE botnumber = bot + LIMIT 1; + + IF FOUND THEN + RETURN 1; + ELSE + RETURN 0; + END IF; + +END; +' +language plpgsql ; + + +explain analyze SELECT sp_test_rod3(); + + QUERY PLAN + +---------------------------------------------------------------------------- +------------ + Result (cost=0.00..0.01 rows=1 width=0) (actual time=1452.39..1452.40 +rows=1 loops=1) + Total runtime: 1452.42 msec +(2 rows) + + +------=_NextPart_000_007C_01C4B5BD.8C390510 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + +
You seem to not have index on botnumber,  b= +ut in=20 +your query bot number is the clause.
+
 
+
I don't explain you why the same query is so=20 +long.
+
but have your try procedure with a loop structur= +e=20 +(witch create cursor) ?
+
 
+
you could try
+
 
+
 
+
+
CR= +EATE OR=20 +REPLACE FUNCTION  sp_test_Alban1 ( )=20 +returns integer         
a= +s=20 +'
DECLARE
  bot char(10);
  oldbatch=20 +INTEGER;
+
  rec=20 +RECORD;
+
= +  query=20 +VARCHAR;
+
= +
BEGIN
+
 
+
  -- initialisation
+
  bot :=3D ''1-7'';
+
  query  :=3D ''= +=20 +SELECT  batchserial FROM transbatch WHERE=20 +botnumber  =3D ' || quote_ident(bot) || '' <optionaly your limit=20 +clause> ;'';
+
 
+
 
+
   FOR rec = +IN=20 +EXECUTE var_query  LOOP
        = +return=20 +rec."batchserial ".;
    
+
   END=20 +LOOP;
+
    <= +/DIV> +
   =20 +--else
+
    return=20 +0;
+
 
+
END;
'
language plpgsql =20 +;
+
does it return the same results in the same time= +=20 +? 

+
+
+From: pgsql-performance-owner@postgresq= +l.org=20 +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Rod=20 +Dutton
Sent: lundi 18 octobre 2004 20:01
To:=20 +pgsql-performance@postgresql.org
Subject: [PERFORM] Queries slow = +using=20 +stored procedures

+
+
Hi,
+
 
+
I have a = +problem=20 +where a query inside a function is up to 100 times slower inside a function= + than=20 +as a stand alone query run in psql.
+
 
+
The colum= +n=20 +'botnumber' is a character(10), is indexed and there are 125000 rows i= +n the=20 +table.
+
 
+
Help=20 +please!
+
 
+
This quer= +y is=20 +fast:-
+
 
+
explain= +=20 +analyze  
+
&nb= +sp;=20 +SELECT batchserial
  FROM transbatch
  WHERE botnumb= +er =3D=20 +'1-7'
  LIMIT 1;
+
           = +            &nb= +sp;            = +            &nb= +sp;         =20 +QUERY=20 +PLAN            = +;            &n= +bsp;            = +;            &n= +bsp;        =20 +
-----------------------------------------------------------------------= +---------------------------------------------------------
 Limit&nb= +sp;=20 +(cost=3D0.00..0.42 rows=3D1 width=3D4) (actual time=3D0.73..148.23 rows=3D1= +=20 +loops=3D1)
   ->  Index Scan using ind_tbatchx on=20 +transbatch  (cost=3D0.00..18.73 rows=3D45 width=3D4) (actual time=3D0.= +73..148.22=20 +rows=3D1 loops=3D1)
         Ind= +ex Cond:=20 +(botnumber =3D '1-7'::bpchar)
 Total runtime: 148.29 msec
(4=20 +rows)
+
 
+
 
+
This=20 +function is slow:-
+
 
+
CREATE=20 +OR REPLACE FUNCTION  sp_test_rod3 ( ) returns=20 +integer         
as=20 +'
DECLARE
  bot char(10);
  oldbatch=20 +INTEGER;
BEGIN
+
 
+
 =20 +bot :=3D ''1-7'';
+
 
+
 =20 +SELECT INTO oldbatch batchserial
  FROM transbatch
  WHERE= +=20 +botnumber =3D bot
  LIMIT 1;
+
 
+
 =20 +IF FOUND THEN
    RETURN 1;
 =20 +ELSE
    RETURN 0;
  END=20 +IF;
+
 
+
END;
'
language plpgsql  ;
+
 
+
explain analyze SELECT sp_test_rod3();
+
           = +            &nb= +sp;            = +  =20 +QUERY=20 +PLAN            = +;            &n= +bsp;            = +; =20 +
-----------------------------------------------------------------------= +-----------------
 Result =20 +(cost=3D0.00..0.01 rows=3D1 width=3D0) (actual time=3D1452.39..1452.40 rows= +=3D1=20 +loops=3D1)
 Total runtime: 1452.42 msec
(2=20 +rows)
+ +------=_NextPart_000_007C_01C4B5BD.8C390510-- + + +From pgsql-performance-owner@postgresql.org Tue Oct 19 16:15:21 2004 +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 EBE35329F3E + for ; + Tue, 19 Oct 2004 16:15:19 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26376-05 + for ; + Tue, 19 Oct 2004 15:15:15 +0000 (GMT) +Received: from MER-TSM1.NASDAQ.COM (mer-tsm1.nasdaq.com [206.200.253.23]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B46D329F28 + for ; + Tue, 19 Oct 2004 16:15:12 +0100 (BST) +Received: from 206.200.98.133 (mer-exb1.corp.nasdaq.com) by + MER-TSM1.NASDAQ.COM with ESMTP (Nasdaq SMTP Gateway and will be + monitored for compliance. (MMS v5.6.3)); Tue, 19 Oct 2004 11:14:55 + -0400 +X-Server-Uuid: EECCD282-DD20-463F-80F0-CC7552CC1D9A +Received: from MER-EXCH1.CORP.NASDAQ.COM ([206.200.99.75]) by + MER-EXB1.CORP.NASDAQ.COM with Microsoft SMTPSVC(5.0.2195.6713); Tue, 19 + Oct 2004 11:14:55 -0400 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Why isn't this index being used? +Date: Tue, 19 Oct 2004 11:14:55 -0400 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Why isn't this index being used? +Thread-Index: AcS17mM1apA4pmIcRmWqLEsoOHDDYw== +From: "Knutsen, Mark" +To: pgsql-performance@postgresql.org +X-OriginalArrivalTime: 19 Oct 2004 15:14:55.0288 (UTC) + FILETIME=[63B53380:01C4B5EE] +X-WSS-ID: 6D6BF0E51V85192542-01-01 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C4B5EE.638E0C40" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=HTML_60_70, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/272 +X-Sequence-Number: 8748 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C4B5EE.638E0C40 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: quoted-printable + +The following is from a database of several hundred million rows of real +data that has been VACUUM ANALYZEd. + +=20 + +Why isn't the index being used for a query that seems tailor-made for +it? The results (6,300 rows) take about ten minutes to retrieve with a +sequential scan. + +=20 + +A copy of this database with "integer" in place of "smallint", a primary +key in column order (date, time, type, subtype) and a secondary index in +the required order (type, subtype, date, time) correctly uses the +secondary index to return results in under a second. + +=20 + +Actually, the integer version is the first one I made, and the smallint +is the copy, but that shouldn't matter. + +=20 + +Postgres is version "postgresql-server-7.3.4-3.rhl9" from Red Hat Linux +9. + +=20 + +=3D=3D=3D=3D=3D + +=20 + +testdb2=3D# \d db + + Table "public.db" + + Column | Type | Modifiers + +---------+------------------------+----------- + + date | date | not null + + time | time without time zone | not null + + type | smallint | not null + + subtype | smallint | not null + + value | integer | + +Indexes: db_pkey primary key btree ("type", subtype, date, "time") + +=20 + +testdb2=3D# set enable_seqscan to off; + +SET + +=20 + +testdb2=3D# explain select * from db where type=3D90 and subtype=3D70 and +date=3D'7/1/2004'; + + QUERY PLAN + +------------------------------------------------------------------------ +------ + + Seq Scan on db (cost=3D100000000.00..107455603.76 rows=3D178 width=3D20) + + Filter: (("type" =3D 90) AND (subtype =3D 70) AND (date =3D +'2004-07-01'::date)) + +(2 rows) + + +------_=_NextPart_001_01C4B5EE.638E0C40 +Content-Type: text/html; + charset=us-ascii +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

The following is from a database of several hund= +red million +rows of real data that has been VACUUM ANALYZEd. + +

 

+ +

Why isn't the index being used for a query that = +seems +tailor-made for it? The results (6,300 rows) take about ten minutes to retr= +ieve +with a sequential scan.

+ +

 

+ +

A copy of this database with "integer"= + in +place of "smallint", a primary key in column order (date, time, t= +ype, +subtype) and a secondary index in the required order (type, subtype, date, +time) correctly uses the secondary index to return results in under a secon= +d.

+ +

 

+ +

Actually, the integer version is the first one I +made, and the smallint is the copy, but that shouldn't matter.

+ +

 

+ +

Postgres is version "postgresql-server-7.3.= +4-3.rhl9" +from Red Hat Linux 9.

+ +

 

+ +

=3D=3D=3D=3D=3D

+ +

 

+ +

testdb2=3D# \d db

+ +

        = +      +Table "public.db"

+ +

 Column  +|          +Type          | Modifiers= +

+ +

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

+ +

 date    | +date            = +;       +| not null

+ +

 time    | time without time +zone | not null

+ +

 type    | +smallint           &= +nbsp;   +| not null

+ +

 subtype | +smallint           &= +nbsp;   +| not null

+ +

 value   | +integer           &n= +bsp;    +|

+ +

Indexes: db_pkey primary key btree +("type", subtype, date, "time")

+ +

 

+ +

testdb2=3D# set enable_seqscan to off;

+ +

SET

+ +

 

+ +

testdb2=3D# explain select * from db where type= +=3D90 and +subtype=3D70 and date=3D'7/1/2004';

+ +

        = +            &nb= +sp;             +QUERY PLAN

+ +

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

+ +

 Seq Scan on db  +(cost=3D100000000.00..107455603.76 rows=3D178 width=3D20)= +

+ +

   Filter: (("type" =3D 90) = +AND +(subtype =3D 70) AND (date =3D '2004-07-01'::date))

+ +

(2 rows)

+ +
+ + + + + +------_=_NextPart_001_01C4B5EE.638E0C40-- + + +From pgsql-performance-owner@postgresql.org Tue Oct 19 16:28:37 2004 +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 63382329F08 + for ; + Tue, 19 Oct 2004 16:28:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29928-09 + for ; + Tue, 19 Oct 2004 15:28:22 +0000 (GMT) +Received: from neomail10.traderonline.com (email.traderonline.com + [65.213.231.10]) + by svr1.postgresql.org (Postfix) with ESMTP id A8FC2329EC2 + for ; + Tue, 19 Oct 2004 16:28:21 +0100 (BST) +Received: from [192.168.1.68] + (64-139-89-109-ubr02b-epensb01-pa.hfc.comcastbusiness.net + [64.139.89.109]) + by neomail10.traderonline.com (8.12.10/8.12.8) with ESMTP id + i9JFSGB1009630; Tue, 19 Oct 2004 11:28:17 -0400 +Message-ID: <41753290.8010709@ptd.net> +Date: Tue, 19 Oct 2004 11:28:16 -0400 +From: Doug Y +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Knutsen, Mark" +Cc: pgsql-performance@postgresql.org +Subject: Re: Why isn't this index being used? +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/273 +X-Sequence-Number: 8749 + +Hi, I ran into a similar problem using bigints... + +See: +http://www.postgresql.org/docs/7.3/static/datatype.html#DATATYPE-INT + +small & big int have to be cast when used in querries... try: +explain select * from db where type=90::smallint and +subtype=70::smallint and date='7/1/2004'; +or +explain select * from db where type='90' and subtype='70' and +date='7/1/2004'; + +Knutsen, Mark wrote: + +> The following is from a database of several hundred million rows of +> real data that has been VACUUM ANALYZEd. +> +> +> +> Why isn't the index being used for a query that seems tailor-made for +> it? The results (6,300 rows) take about ten minutes to retrieve with a +> sequential scan. +> +> +> +> A copy of this database with "integer" in place of "smallint", a +> primary key in column order (date, time, type, subtype) and a +> secondary index in the required order (type, subtype, date, time) +> correctly uses the secondary index to return results in under a second. +> +> +> +> Actually, the integer version is the first one I made, and the +> smallint is the copy, but that shouldn't matter. +> +> +> +> Postgres is version "postgresql-server-7.3.4-3.rhl9" from Red Hat Linux 9. +> +> +> +> ===== +> +> +> +> testdb2=# \d db +> +> Table "public.db" +> +> Column | Type | Modifiers +> +> ---------+------------------------+----------- +> +> date | date | not null +> +> time | time without time zone | not null +> +> type | smallint | not null +> +> subtype | smallint | not null +> +> value | integer | +> +> Indexes: db_pkey primary key btree ("type", subtype, date, "time") +> +> +> +> testdb2=# set enable_seqscan to off; +> +> SET +> +> +> +> testdb2=# explain select * from db where type=90 and subtype=70 and +> date='7/1/2004'; +> +> QUERY PLAN +> +> ------------------------------------------------------------------------------ +> +> Seq Scan on db (cost=100000000.00..107455603.76 rows=178 width=20) +> +> Filter: (("type" = 90) AND (subtype = 70) AND (date = +> '2004-07-01'::date)) +> +> (2 rows) +> + + +From pgsql-performance-owner@postgresql.org Tue Oct 19 16:34:10 2004 +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 22CE432A15B + for ; + Tue, 19 Oct 2004 16:34:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33090-10 + for ; + Tue, 19 Oct 2004 15:34:03 +0000 (GMT) +Received: from MER-TSM1.NASDAQ.COM (mer-tsm1.nasdaq.com [206.200.253.23]) + by svr1.postgresql.org (Postfix) with ESMTP id 500E9329F5F + for ; + Tue, 19 Oct 2004 16:34:02 +0100 (BST) +Received: from 206.200.98.133 (mer-exb1.corp.nasdaq.com) by + MER-TSM1.NASDAQ.COM with ESMTP (Nasdaq SMTP Gateway and will be + monitored for compliance. (MMS v5.6.3)); Tue, 19 Oct 2004 11:33:51 + -0400 +X-Server-Uuid: EECCD282-DD20-463F-80F0-CC7552CC1D9A +Received: from MER-EXCH1.CORP.NASDAQ.COM ([206.200.99.75]) by + MER-EXB1.CORP.NASDAQ.COM with Microsoft SMTPSVC(5.0.2195.6713); Tue, 19 + Oct 2004 11:33:51 -0400 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Re: Why isn't this index being used? +Date: Tue, 19 Oct 2004 11:33:50 -0400 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Why isn't this index being used? +Thread-Index: AcS18Enzx69p7zdlRmm1ga2GD0WIcgAAG2lQ +From: "Knutsen, Mark" +To: "Doug Y" +Cc: pgsql-performance@postgresql.org +X-OriginalArrivalTime: 19 Oct 2004 15:33:51.0030 (UTC) + FILETIME=[08A9AD60:01C4B5F1] +X-WSS-ID: 6D6BEC551V85193690-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/274 +X-Sequence-Number: 8750 + +(Why don't replies automatically go to the list?) + +Sure enough, quoting the constants fixes the problem. + +Is it a best practice to always quote constants? + +> -----Original Message----- +> From: Doug Y [mailto:dylists@ptd.net] +> Sent: Tuesday, October 19, 2004 11:28 AM +> To: Knutsen, Mark +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Why isn't this index being used? +>=20 +> Hi, I ran into a similar problem using bigints... +>=20 +> See: +> http://www.postgresql.org/docs/7.3/static/datatype.html#DATATYPE-INT +>=20 +> small & big int have to be cast when used in querries... try: +> explain select * from db where type=3D90::smallint and +> subtype=3D70::smallint and date=3D'7/1/2004'; +> or +> explain select * from db where type=3D'90' and subtype=3D'70' and +> date=3D'7/1/2004'; +>=20 +> Knutsen, Mark wrote: +>=20 +> > The following is from a database of several hundred million rows of +> > real data that has been VACUUM ANALYZEd. +> > +> > +> > +> > Why isn't the index being used for a query that seems tailor-made +for +> > it? The results (6,300 rows) take about ten minutes to retrieve with +a +> > sequential scan. +> > +> > +> > +> > A copy of this database with "integer" in place of "smallint", a +> > primary key in column order (date, time, type, subtype) and a +> > secondary index in the required order (type, subtype, date, time) +> > correctly uses the secondary index to return results in under a +second. +> > +> > +> > +> > Actually, the integer version is the first one I made, and the +> > smallint is the copy, but that shouldn't matter. +> > +> > +> > +> > Postgres is version "postgresql-server-7.3.4-3.rhl9" from Red Hat +Linux +> 9. +> > +> > +> > +> > =3D=3D=3D=3D=3D +> > +> > +> > +> > testdb2=3D# \d db +> > +> > Table "public.db" +> > +> > Column | Type | Modifiers +> > +> > ---------+------------------------+----------- +> > +> > date | date | not null +> > +> > time | time without time zone | not null +> > +> > type | smallint | not null +> > +> > subtype | smallint | not null +> > +> > value | integer | +> > +> > Indexes: db_pkey primary key btree ("type", subtype, date, "time") +> > +> > +> > +> > testdb2=3D# set enable_seqscan to off; +> > +> > SET +> > +> > +> > +> > testdb2=3D# explain select * from db where type=3D90 and subtype=3D70 a= +nd +> > date=3D'7/1/2004'; +> > +> > QUERY PLAN +> > +> > +------------------------------------------------------------------------ +> ------ +> > +> > Seq Scan on db (cost=3D100000000.00..107455603.76 rows=3D178 width=3D= +20) +> > +> > Filter: (("type" =3D 90) AND (subtype =3D 70) AND (date =3D +> > '2004-07-01'::date)) +> > +> > (2 rows) + + + +From pgsql-performance-owner@postgresql.org Tue Oct 19 16:38:27 2004 +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 25B5C32A0A2 + for ; + Tue, 19 Oct 2004 16:38:26 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34760-08 + for ; + Tue, 19 Oct 2004 15:38:24 +0000 (GMT) +Received: from roue.portalpotty.net (roue.portalpotty.net [69.44.62.206]) + by svr1.postgresql.org (Postfix) with ESMTP id 30A3332A0A1 + for ; + Tue, 19 Oct 2004 16:38:23 +0100 (BST) +Received: from max by roue.portalpotty.net with local (Exim 4.34) + id 1CJw45-0005YA-F7 + for pgsql-performance@postgresql.org; Tue, 19 Oct 2004 08:38:21 -0700 +Date: Tue, 19 Oct 2004 11:38:21 -0400 +From: Max Baker +To: pgsql-performance@postgresql.org +Subject: Vacuum takes a really long time, vacuum full required +Message-ID: <20041019153821.GA21258@warped.org> +Mail-Followup-To: pgsql-performance@postgresql.org +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.4.1i +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - roue.portalpotty.net +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [514 32003] / [47 12] +X-AntiAbuse: Sender Address Domain - roue.portalpotty.net +X-Source: /usr/bin/mutt +X-Source-Args: mutt +X-Source-Dir: /home/max +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/275 +X-Sequence-Number: 8751 + +Hi Folks, + +This is my _4th_ time trying to post this, me and the mailing list software +are fighting. I think it's because of the attachments so I'll just put +links to them instead. All apologies if this gets duplicated. + +I've been having problems maintaining the speed of the database in the +long run. VACUUMs of the main tables happen a few times a day after maybe +50,000 or less rows are added and deleted (say 6 times a day). + +I have a whole lot (probably too much) indexing going on to try to speed +things up. + +Whatever the case, the database still slows down to a halt after a month or +so, and I have to go in and shut everything down and do a VACUUM FULL by +hand. One index (of many many) takes 2000 seconds to vacuum. The whole +process takes a few hours. + +I would love suggestions on what I can do either inside my application, or +from a dba point of view to keep the database maintained without having to +inflict downtime. This is for 'Netdisco' -- an open source network +management software by the way. I'ld like to fix this for everyone who uses +it. + + +Sys Info : + +$ uname -a + FreeBSD xxxx.ucsc.edu 4.10-STABLE FreeBSD 4.10-STABLE #0: Mon Aug 16 +14:56:19 PDT 2004 root@xxxx.ucsc.edu:/usr/src/sys/compile/xxxx i386 + +$ pg_config --version + PostgreSQL 7.3.2 + +$ cat postgresql.conf + max_connections = 32 + shared_buffers = 3900 # 30Mb - Bsd current kernel limit + max_fsm_relations = 1000 # min 10, fsm is free space map, ~40 bytes + max_fsm_pages = 10000 # min 1000, fsm is free space map, ~6 bytes + max_locks_per_transaction = 64 # min 10 + wal_buffers = 8 # min 4, typically 8KB each + +The log of the vacuum and the db schema could not be attached, so they are +at : + http://netdisco.net/db_vacuum.txt + http://netdisco.net/pg_all.input + +Thanks for any help! +-m + +From pgsql-performance-owner@postgresql.org Tue Oct 19 16:44:48 2004 +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 6A7A532A138 + for ; + Tue, 19 Oct 2004 16:44:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37627-09 + for ; + Tue, 19 Oct 2004 15:44:43 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 91A0B32A11E + for ; + Tue, 19 Oct 2004 16:44:42 +0100 (BST) +Received: from [134.22.69.212] (dyn-69-212.tor.dsl.tht.net [134.22.69.212]) + by tht.net (Postfix) with ESMTP + id 4824176AD0; Tue, 19 Oct 2004 11:41:07 -0400 (EDT) +Subject: Re: Vacuum takes a really long time, vacuum full required +From: Rod Taylor +To: Max Baker +Cc: Postgresql Performance +In-Reply-To: <20041019153821.GA21258@warped.org> +References: <20041019153821.GA21258@warped.org> +Content-Type: text/plain +Message-Id: <1098200416.750.238.camel@home> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 19 Oct 2004 11:40:17 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/276 +X-Sequence-Number: 8752 + +> Whatever the case, the database still slows down to a halt after a month or +> so, and I have to go in and shut everything down and do a VACUUM FULL by +> hand. One index (of many many) takes 2000 seconds to vacuum. The whole +> process takes a few hours. + +Do a REINDEX on that table instead, and regular vacuum more frequently. + +> $ pg_config --version +> PostgreSQL 7.3.2 + +7.4.x deals with index growth a little better 7.3 and older did. + + +From pgsql-performance-owner@postgresql.org Tue Oct 19 16:47:27 2004 +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 9D1BA32A0D8 + for ; + Tue, 19 Oct 2004 16:47:25 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40473-02 + for ; + Tue, 19 Oct 2004 15:47:22 +0000 (GMT) +Received: from smtp100.rog.mail.re2.yahoo.com (smtp100.rog.mail.re2.yahoo.com + [206.190.36.78]) + by svr1.postgresql.org (Postfix) with SMTP id 1D86B32A2A7 + for ; + Tue, 19 Oct 2004 16:47:20 +0100 (BST) +Received: from unknown (HELO phlogiston.dydns.org) + (a.sullivan@rogers.com@65.49.125.184 with login) + by smtp100.rog.mail.re2.yahoo.com with SMTP; 19 Oct 2004 15:47:19 -0000 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 541F04058; Tue, 19 Oct 2004 11:47:18 -0400 (EDT) +Date: Tue, 19 Oct 2004 11:47:18 -0400 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Why isn't this index being used? +Message-ID: <20041019154718.GG3359@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: + +User-Agent: Mutt/1.5.6+20040722i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/277 +X-Sequence-Number: 8753 + +On Tue, Oct 19, 2004 at 11:33:50AM -0400, Knutsen, Mark wrote: +> (Why don't replies automatically go to the list?) + +Because sometimes you don't want them to. There's been dozens of +discussions about this. BTW, mutt has a nice feature which allows +you to reply to lists -- I imagine other MUAs have such a feature +too. + +> Sure enough, quoting the constants fixes the problem. +> +> Is it a best practice to always quote constants? + +No, but it's very useful in these cases. The problem is I believe +this is fixed in 8.0, BTW. See the FAQ, question 4.8 + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +I remember when computers were frustrating because they *did* exactly what +you told them to. That actually seems sort of quaint now. + --J.D. Baldwin + +From pgsql-performance-owner@postgresql.org Tue Oct 19 17:21:12 2004 +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 6920B32A53B + for ; + Tue, 19 Oct 2004 17:21:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50862-08 + for ; + Tue, 19 Oct 2004 16:21:06 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id F36EF32A540 + for ; + Tue, 19 Oct 2004 17:21:05 +0100 (BST) +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 i9JGL5nA016630; + Tue, 19 Oct 2004 12:21:05 -0400 (EDT) +To: Max Baker +Cc: pgsql-performance@postgresql.org +Subject: Re: Vacuum takes a really long time, vacuum full required +In-reply-to: <20041019153821.GA21258@warped.org> +References: <20041019153821.GA21258@warped.org> +Comments: In-reply-to Max Baker + message dated "Tue, 19 Oct 2004 11:38:21 -0400" +Date: Tue, 19 Oct 2004 12:21:04 -0400 +Message-ID: <16629.1098202864@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/278 +X-Sequence-Number: 8754 + +Max Baker writes: +> I've been having problems maintaining the speed of the database in the +> long run. VACUUMs of the main tables happen a few times a day after maybe +> 50,000 or less rows are added and deleted (say 6 times a day). + +> I have a whole lot (probably too much) indexing going on to try to speed +> things up. + +> Whatever the case, the database still slows down to a halt after a month or +> so, and I have to go in and shut everything down and do a VACUUM FULL by +> hand. One index (of many many) takes 2000 seconds to vacuum. The whole +> process takes a few hours. + +The first and foremost recommendation is to increase your FSM settings; +you seem to be using the defaults, which are pegged for a database size +of not more than about 100Mb. + +Second is to update to PG 7.4. I think you are probably suffering from +index bloat to some extent, and 7.4 should help. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 19 17:27:00 2004 +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 982E432A091 + for ; + Tue, 19 Oct 2004 17:26:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52031-10 + for ; + Tue, 19 Oct 2004 16:26:48 +0000 (GMT) +Received: from ar-sd.net (unknown [82.77.155.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 287E3329F7A + for ; + Tue, 19 Oct 2004 17:26:46 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by ar-sd.net (Postfix) with ESMTP id D122420491 + for ; + Tue, 19 Oct 2004 19:30:35 +0300 (EEST) +Received: from ar-sd.net ([127.0.0.1]) + by localhost (linz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 30316-01 for ; + Tue, 19 Oct 2004 19:30:34 +0300 (EEST) +Received: from forge (unknown [192.168.0.11]) + by ar-sd.net (Postfix) with SMTP id 2199D203AA + for ; + Tue, 19 Oct 2004 19:30:34 +0300 (EEST) +Message-ID: <0bef01c4b5f8$70026ae0$0b00a8c0@forge> +From: "Andrei Bintintan" +To: +Subject: Index not used in query. Why? +Date: Tue, 19 Oct 2004 19:26:49 +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.2720.3000 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 +X-Virus-Scanned: by amavisd-new at ar-sd.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/279 +X-Sequence-Number: 8755 + +Hi to all! I have the following query. The execution time is very big, it +doesn't use the indexes and I don't understand why... + + +SELECT count(o.id) FROM orders o + + INNER JOIN report r ON o.id=r.id_order + + INNER JOIN status s ON o.id_status=s.id + + INNER JOIN contact c ON o.id_ag=c.id + + INNER JOIN endkunde e ON +o.id_endkunde=e.id + + INNER JOIN zufriden z ON +r.id_zufriden=z.id + + INNER JOIN plannung v ON +v.id=o.id_plannung + + INNER JOIN mpsworker w ON +v.id_worker=w.id + + INNER JOIN person p ON p.id = w.id_person + + WHERE o.id_status > 3 + +The query explain: + + + +Aggregate (cost=32027.38..32027.38 rows=1 width=4) + + -> Hash Join (cost=23182.06..31944.82 rows=33022 width=4) + + Hash Cond: ("outer".id_person = "inner".id) + + -> Hash Join (cost=23179.42..31446.85 rows=33022 width=8) + + Hash Cond: ("outer".id_endkunde = "inner".id) + + -> Hash Join (cost=21873.54..28891.42 rows=33022 width=12) + + Hash Cond: ("outer".id_ag = "inner".id) + + -> Hash Join (cost=21710.05..28067.50 rows=33021 +width=16) + + Hash Cond: ("outer".id_status = "inner".id) + + -> Hash Join (cost=21708.97..27571.11 rows=33021 +width=20) + + Hash Cond: ("outer".id_worker = "inner".id) + + -> Hash Join (cost=21707.49..27074.31 +rows=33021 width=20) + + Hash Cond: ("outer".id_zufriden = +"inner".id) + + -> Hash Join +(cost=21706.34..26564.09 rows=35772 width=24) + + Hash Cond: ("outer".id_plannung += "inner".id) + + -> Hash Join +(cost=20447.15..23674.04 rows=35771 width=24) + + Hash Cond: ("outer".id = +"inner".id_order) + + -> Seq Scan on orders o +(cost=0.00..1770.67 rows=36967 width=20) + + Filter: (id_status > +3) + + -> Hash +(cost=20208.32..20208.32 rows=37132 width=8) + + -> Seq Scan on +report r (cost=0.00..20208.32 rows=37132 width=8) + + -> Hash (cost=913.15..913.15 +rows=54015 width=8) + + -> Seq Scan on plannung v +(cost=0.00..913.15 rows=54015 width=8) + + -> Hash (cost=1.12..1.12 rows=12 +width=4) + + -> Seq Scan on zufriden z +(cost=0.00..1.12 rows=12 width=4) + + -> Hash (cost=1.39..1.39 rows=39 width=8) + + -> Seq Scan on mpsworker w +(cost=0.00..1.39 rows=39 width=8) + + -> Hash (cost=1.06..1.06 rows=6 width=4) + + -> Seq Scan on status s (cost=0.00..1.06 +rows=6 width=4) + + -> Hash (cost=153.19..153.19 rows=4119 width=4) + + -> Seq Scan on contact c (cost=0.00..153.19 +rows=4119 width=4) + + -> Hash (cost=1077.91..1077.91 rows=38391 width=4) + + -> Seq Scan on endkunde e (cost=0.00..1077.91 +rows=38391 width=4) + + -> Hash (cost=2.51..2.51 rows=51 width=4) + + -> Seq Scan on person p (cost=0.00..2.51 rows=51 width=4) + + + + + +As you can see, no index is used.I made everywhere indexes where the jons +are made. If I use the following query the indexes are used: + + + +SELECT count(o.id) FROM orders o + + INNER JOIN report r ON o.id=r.id_order + + INNER JOIN status s ON o.id_status=s.id + + INNER JOIN contact c ON o.id_ag=c.id + + INNER JOIN endkunde e ON +o.id_endkunde=e.id + + INNER JOIN zufriden z ON +r.id_zufriden=z.id + + INNER JOIN plannung v ON +v.id=o.id_plannung + + INNER JOIN mpsworker w ON +v.id_worker=w.id + + INNER JOIN person p ON p.id = w.id_person + + WHERE o.id_status =4 + + + +Aggregate (cost=985.55..985.55 rows=1 width=4) + + -> Hash Join (cost=5.28..985.42 rows=50 width=4) + + Hash Cond: ("outer".id_person = "inner".id) + + -> Hash Join (cost=2.64..982.03 rows=50 width=8) + + Hash Cond: ("outer".id_worker = "inner".id) + + -> Nested Loop (cost=1.15..979.79 rows=50 width=8) + + -> Nested Loop (cost=1.15..769.64 rows=49 width=8) + + -> Nested Loop (cost=1.15..535.57 rows=48 +width=12) + + -> Seq Scan on status s (cost=0.00..1.07 +rows=1 width=4) + + Filter: (4 = id) + + -> Nested Loop (cost=1.15..534.01 rows=48 +width=16) + + -> Hash Join (cost=1.15..366.37 +rows=47 width=20) + + Hash Cond: ("outer".id_zufriden += "inner".id) + + -> Nested Loop +(cost=0.00..364.48 rows=51 width=24) + + -> Index Scan using +orders_id_status_idx on orders o (cost=0.00..69.55 rows=52 width=20) + + Index Cond: +(id_status = 4) + + -> Index Scan using +report_id_order_idx on report r (cost=0.00..5.66 rows=1 width=8) + + Index Cond: +("outer".id = r.id_order) + + -> Hash (cost=1.12..1.12 +rows=12 width=4) + + -> Seq Scan on zufriden z +(cost=0.00..1.12 rows=12 width=4) + + -> Index Scan using endkunde_pkey on +endkunde e (cost=0.00..3.55 rows=1 width=4) + + Index Cond: ("outer".id_endkunde += e.id) + + -> Index Scan using contact_pkey on contact c +(cost=0.00..4.86 rows=1 width=4) + + Index Cond: ("outer".id_ag = c.id) + + -> Index Scan using plannung_pkey on plannung v +(cost=0.00..4.28 rows=1 width=8) + + Index Cond: (v.id = "outer".id_plannung) + + -> Hash (cost=1.39..1.39 rows=39 width=8) + + -> Seq Scan on mpsworker w (cost=0.00..1.39 rows=39 +width=8) + + -> Hash (cost=2.51..2.51 rows=51 width=4) + + -> Seq Scan on person p (cost=0.00..2.51 rows=51 width=4) + + + + + +Best regards, + +Andy. + + + + +From pgsql-performance-owner@postgresql.org Tue Oct 19 17:53:10 2004 +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 C843032A0EC + for ; + Tue, 19 Oct 2004 17:53:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64106-02 + for ; + Tue, 19 Oct 2004 16:53: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 DE92E32A0A2 + for ; + Tue, 19 Oct 2004 17:53:04 +0100 (BST) +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 i9JGqnaR016866; + Tue, 19 Oct 2004 12:52:50 -0400 (EDT) +To: "Andrei Bintintan" +Cc: pgsql-performance@postgresql.org +Subject: Re: Index not used in query. Why? +In-reply-to: <0bef01c4b5f8$70026ae0$0b00a8c0@forge> +References: <0bef01c4b5f8$70026ae0$0b00a8c0@forge> +Comments: In-reply-to "Andrei Bintintan" + message dated "Tue, 19 Oct 2004 19:26:49 +0300" +Date: Tue, 19 Oct 2004 12:52:49 -0400 +Message-ID: <16865.1098204769@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/280 +X-Sequence-Number: 8756 + +"Andrei Bintintan" writes: +> Hi to all! I have the following query. The execution time is very big, it +> doesn't use the indexes and I don't understand why... + +Indexes are not necessarily the best way to do a large join. + +> If I use the following query the indexes are used: + +The key reason this wins seems to be that the id_status = 4 condition +is far more selective than id_status > 3 (the estimates are 52 and 36967 +rows respectively ... is that accurate?) which means that the second +query is inherently about 1/700th as much work. This, and not the use +of indexes, is the fundamental reason why it's faster. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Oct 20 16:08:52 2004 +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 359EF32A00B + for ; + Tue, 19 Oct 2004 18:49:59 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82656-04 + for ; + Tue, 19 Oct 2004 17:49:44 +0000 (GMT) +Received: from ar-sd.net (unknown [82.77.155.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D5CF329FA4 + for ; + Tue, 19 Oct 2004 18:49:42 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by ar-sd.net (Postfix) with ESMTP id 7BD5020491; + Tue, 19 Oct 2004 20:53:32 +0300 (EEST) +Received: from ar-sd.net ([127.0.0.1]) + by localhost (linz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 30470-07; Tue, 19 Oct 2004 20:53:31 +0300 (EEST) +Received: from forge (unknown [192.168.0.11]) + by ar-sd.net (Postfix) with SMTP id 4E26D203AA; + Tue, 19 Oct 2004 20:53:31 +0300 (EEST) +Message-ID: <0c4501c4b604$06f15460$0b00a8c0@forge> +From: "Contact AR-SD.NET" +To: "Tom Lane" +Cc: +References: <0bef01c4b5f8$70026ae0$0b00a8c0@forge> + <16865.1098204769@sss.pgh.pa.us> +Subject: Re: Index not used in query. Why? +Date: Tue, 19 Oct 2004 20:49:45 +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.2720.3000 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 +X-Virus-Scanned: by amavisd-new at ar-sd.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/318 +X-Sequence-Number: 8794 + +Is there a solution to make it faster? +At the end I need only in the query the id_status =4 and 6, but if I write +in the sql query (where condition) where id_status in (4,6), the explain +says the same(the slow version). + +For example: +SELECT count(o.id) FROM orders o + INNER JOIN report r ON o.id=r.id_order + INNER JOIN status s ON o.id_status=s.id + INNER JOIN contact c ON o.id_ag=c.id + INNER JOIN endkunde e ON +o.id_endkunde=e.id + INNER JOIN zufriden z ON +r.id_zufriden=z.id + INNER JOIN plannung v ON +v.id=o.id_plannung + INNER JOIN mpsworker w ON +v.id_worker=w.id + INNER JOIN person p ON p.id = w.id_person + WHERE o.id_status in (4,6); + +The result for this query is also without index searches. + +I really have to make this query a little more faster. Suggestions? + +Regards, +Andy. + +----- Original Message ----- +From: "Tom Lane" +To: "Andrei Bintintan" +Cc: +Sent: Tuesday, October 19, 2004 7:52 PM +Subject: Re: [PERFORM] Index not used in query. Why? + + +> "Andrei Bintintan" writes: +> > Hi to all! I have the following query. The execution time is very big, +it +> > doesn't use the indexes and I don't understand why... +> +> Indexes are not necessarily the best way to do a large join. +> +> > If I use the following query the indexes are used: +> +> The key reason this wins seems to be that the id_status = 4 condition +> is far more selective than id_status > 3 (the estimates are 52 and 36967 +> rows respectively ... is that accurate?) which means that the second +> query is inherently about 1/700th as much work. This, and not the use +> of indexes, is the fundamental reason why it's faster. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> + + +From pgsql-performance-owner@postgresql.org Tue Oct 19 19:12:56 2004 +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 57C4A32A401 + for ; + Tue, 19 Oct 2004 19:12:54 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90732-07 + for ; + Tue, 19 Oct 2004 18:12:47 +0000 (GMT) +Received: from roue.portalpotty.net (roue.portalpotty.net [69.44.62.206]) + by svr1.postgresql.org (Postfix) with ESMTP id 107E432A42F + for ; + Tue, 19 Oct 2004 19:12:47 +0100 (BST) +Received: from max by roue.portalpotty.net with local (Exim 4.34) + id 1CJyTV-0006EW-Ix; Tue, 19 Oct 2004 11:12:45 -0700 +Date: Tue, 19 Oct 2004 14:12:45 -0400 +From: Max Baker +To: Rod Taylor +Cc: Postgresql Performance +Subject: Re: Vacuum takes a really long time, vacuum full required +Message-ID: <20041019181245.GJ21258@warped.org> +Mail-Followup-To: Rod Taylor , + Postgresql Performance +References: <20041019153821.GA21258@warped.org> + <1098200416.750.238.camel@home> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1098200416.750.238.camel@home> +User-Agent: Mutt/1.4.1i +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - roue.portalpotty.net +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [514 32003] / [47 12] +X-AntiAbuse: Sender Address Domain - roue.portalpotty.net +X-Source: /usr/bin/mutt +X-Source-Args: mutt +X-Source-Dir: /home/max +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/281 +X-Sequence-Number: 8757 + +Hi Rod, + +On Tue, Oct 19, 2004 at 11:40:17AM -0400, Rod Taylor wrote: +> > Whatever the case, the database still slows down to a halt after a month or +> > so, and I have to go in and shut everything down and do a VACUUM FULL by +> > hand. One index (of many many) takes 2000 seconds to vacuum. The whole +> > process takes a few hours. +> +> Do a REINDEX on that table instead, and regular vacuum more frequently. + +Great, this is exactly what I think it needs. Meanwhile, I was checking out + + http://www.postgresql.org/docs/7.3/static/sql-reindex.html + +Which suggests I might be able to do a drop/add on each index with the +database 'live'. + +However, the DROP INDEX command was taking an awfully long time to complete +and it hung my app in the mean time. Does anyone know if the DROP INDEX +causes an exclusive lock, or is it just a lengthy process? + +> > $ pg_config --version +> > PostgreSQL 7.3.2 +> +> 7.4.x deals with index growth a little better 7.3 and older did. + +Will do. Meanwhile I'm stuck supporting older 7.x versions, so I'm still +looking for a solution for them. + +Thanks! +-m + +From pgsql-performance-owner@postgresql.org Tue Oct 19 19:43:42 2004 +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 379D832A0C2 + for ; + Tue, 19 Oct 2004 19:43:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00929-06 + for ; + Tue, 19 Oct 2004 18:43:30 +0000 (GMT) +Received: from roue.portalpotty.net (roue.portalpotty.net [69.44.62.206]) + by svr1.postgresql.org (Postfix) with ESMTP id AD10F32A015 + for ; + Tue, 19 Oct 2004 19:43:30 +0100 (BST) +Received: from max by roue.portalpotty.net with local (Exim 4.34) + id 1CJyxF-0006Mi-Ht + for pgsql-performance@postgresql.org; Tue, 19 Oct 2004 11:43:29 -0700 +Date: Tue, 19 Oct 2004 14:43:29 -0400 +From: Max Baker +To: pgsql-performance@postgresql.org +Subject: Re: Free PostgreSQL Training, Philadelphia, Oct 30 +Message-ID: <20041019184329.GO21258@warped.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.1i +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - roue.portalpotty.net +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [514 32003] / [47 12] +X-AntiAbuse: Sender Address Domain - roue.portalpotty.net +X-Source: /usr/bin/mutt +X-Source-Args: mutt +X-Source-Dir: /home/max +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/282 +X-Sequence-Number: 8758 + +On Wed, Oct 13, 2004 at 12:21:27PM -0400, Aaron Mulder wrote: +> All, +> My company (Chariot Solutions) is sponsoring a day of free +> PostgreSQL training by Bruce Momjian (one of the core PostgreSQL +> developers). The day is split into 2 sessions (plus a Q&A session): +> +> * Mastering PostgreSQL Administration +> * PostgreSQL Performance Tuning +> +> Registration is required, and space is limited. The location is +> Malvern, PA (suburb of Philadelphia) and it's on Saturday Oct 30. For +> more information or to register, see +> +> http://chariotsolutions.com/postgresql.jsp + +I'm up in New York City and would be taking the train down to Philly. Is +anyone coming from Philly or New York that would be able to give me a lift +to/from the train station? Sounds like a great event. + +Cheers, +-m + +From pgsql-performance-owner@postgresql.org Tue Oct 19 20:35:34 2004 +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 6758F32ABEE + for ; + Tue, 19 Oct 2004 20:35:27 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18226-08 + for ; + Tue, 19 Oct 2004 19:35:23 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 565E932A484 + for ; + Tue, 19 Oct 2004 20:35:24 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 74so369270rnk + for ; + Tue, 19 Oct 2004 12:35:24 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=SVcP5nOyK7w3LPPrzsyDb7Vt+tvWvW4NtKpTAtEfx5o1hXOVBH1lQUFHt44Z9aATULohkdZbPFjNaXck65pekayN87p7aYrzPWAe6HOoc7kJ4YB7bjzv48ieGhrlnAsRFAD4YMiTD19cw9eUEo1z1vWK24hQuVeah+se84mmLjk +Received: by 10.38.24.12 with SMTP id 12mr2139150rnx; + Tue, 19 Oct 2004 12:35:24 -0700 (PDT) +Received: by 10.38.165.32 with HTTP; Tue, 19 Oct 2004 12:35:24 -0700 (PDT) +Message-ID: <27c475ec04101912351c451e8@mail.gmail.com> +Date: Tue, 19 Oct 2004 15:35:24 -0400 +From: Matt Nuzum +Reply-To: matt@followers.net +To: pgsql-performance +Subject: Speeding up this function +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/283 +X-Sequence-Number: 8759 + +Hello, I've thought it would be nice to index certain aspects of my +apache log files for analysis. I've used several different techniques +and have something usable now, but I'd like to tweak it one step +further. + +My first performance optimization was to change the logformat into a +CSV format. I processed the logfiles with PHP and plsql stored +procedures. Unfortunately, it took more than 24 hours to process 1 +days worth of log files. + +I've now switched to using C# (using mono) to create hash-tables to do +almost all of the pre-processing. This has brought the time down to +about 3 hours. Actually, if I take out one step it brought the +process down to about 6 minutes, which is a tremendous improvement. + +The one step that is adding 2.5+ hours to the job is not easily done +in C#, as far as I know. + +Once the mostly-normalized data has been put into a table called +usage_raw_access I then use this query: +insert into usage_access select * , +usage_normalize_session(accountid,client,atime) as sessionid +from usage_raw_access; + +All it does is try to "link" pageviews together into a session. +here's the function: + create or replace function usage_normalize_session (varchar(12), +inet, timestamptz) returns integer as ' + DECLARE + -- $1 = Account ID, $2 = IP Address, $3 = Time + RecordSet record; + BEGIN + SELECT INTO RecordSet DISTINCT sessionid FROM usage_access ua + WHERE ua.accountid = $1 + AND ua.client = $2 + AND ua.atime <= ($3 - ''20 min''::interval)::timestamptz; + + if found + then return RecordSet.sessionid; + end if; + + return nextval(''usage_session_ids''); + END;' + language plpgsql; + +And the table usage_access looks like this: + Table "public.usage_access" + Column | Type | Modifiers +-------------+--------------------------+----------- +[snip] +client | inet | +atime | timestamp with time zone | +accountid | character varying(12) | +sessionid | integer | +Indexes: usage_acccess_req_url btree (req_url), + usage_access_accountid btree (accountid), + usage_access_atime btree (atime), + usage_access_hostid btree (hostid), + usage_access_sessionid btree (sessionid) + usage_access_sessionlookup btree (accountid,client,atime); + +As you can see, this looks for clients who have visited the same site +within 20 min. If there is no match, a unique sessionid is assigned +from a sequence. If there is a visit, the session id assigned to them +is used. I'm only able to process about 25 records per second with my +setup. My window to do this job is 3-4 hours and the shorter the +better. + +Here is an explain analyze of the query I do (note I limited it to 1000): +EXPLAIN ANALYZE +insert into usage_access select * , +usage_normalize_session(accountid,client,atime) as sessionid from +usage_raw_access limit 1000; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------- + Subquery Scan "*SELECT*" (cost=0.00..20.00 rows=1000 width=196) +(actual time=51.63..47634.22 rows=1000 loops=1) + -> Limit (cost=0.00..20.00 rows=1000 width=196) (actual +time=51.59..47610.23 rows=1000 loops=1) + -> Seq Scan on usage_raw_access (cost=0.00..20.00 rows=1000 +width=196) (actual time=51.58..47606.14 rows=1001 loops=1) + Total runtime: 48980.54 msec + +I also did an explain of the query that's performed inside the function: + +EXPLAIN ANALYZE +select sessionid from usage_access ua where ua.accountid = 'XYZ' and +ua.client = '64.68.88.45'::inet and ua.atime <= '2003-11-02 +04:50:01-05'::timestamptz; + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------- +Index Scan using usage_access_sessionlookup on usage_access ua +(cost=0.00..6.02 rows=1 width=4) (actual time=0.29..0.29 rows=0 +loops=1) + Index Cond: ((accountid = 'XYZ'::character varying) AND (client = +'64.68.88.45'::inet) AND (atime <= '2003-11-02 04:50:01-05'::timestamp +with time zone)) +Total runtime: 0.35 msec +(3 rows) + + +What I'd really like to know is if someone knows a way to do any of +the following: + a: Make the INSERT into ... SELECT *,usage_access_sessionlookup().. work faster + b: Make the usage_access_sessionlookup() smarter,better,etc. + c: Do this in C# using a hash-table or some other procedure that +would be quicker. + d: Find an algorithm to create the sessionid without having to do any +database or hash-table lookups. As the dataset gets bigger, it won't +fit in RAM and the lookup queries will become I/O bound, drastically +slowing things down. + +d: is my first choice. + +For some reason I just can't seem to get my mind around the data. I +wonder if there's someway to create a unique value from client ip +address, the accountid and the period of time so that all visits by +the IP for the account in that period would match. + +I thought of using the date_part function to create a unique period, +but it would be a hack because if someone visits at 11:50 pm and +continues to browse for an hour they would be counted as two sessions. + That's not the end of the world, but some of my customers in +drastically different time zones would always have skewed results. + +I tried and tried to get C# to turn the apache date string into a +usable time but could not. I just leave the date intact and let +postgresql handle it when I do the copy. Therefore, though I'd like +to do it in my C# program, I'll likely have to do the sessionid code +in a stored procedure. + +I'd really love some feedback on ways to optimize this. Any +suggestions are greatly appreciated. + +-- +Matthew Nuzum | Makers of "Elite Content Management System" +www.followers.net | View samples of Elite CMS in action +matt@followers.net | http://www.followers.net/portfolio/ + +From pgsql-performance-owner@postgresql.org Tue Oct 19 20:49:57 2004 +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 D80FF32ABEE + for ; + Tue, 19 Oct 2004 20:49:55 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24565-03 + for ; + Tue, 19 Oct 2004 19:49:45 +0000 (GMT) +Received: from mail.autorevenue.com (ip-208.178.167.106.gblx.net + [208.178.167.106]) + by svr1.postgresql.org (Postfix) with ESMTP id 60A2232AA22 + for ; + Tue, 19 Oct 2004 20:49:43 +0100 (BST) +Received: from jeremydunn ([192.168.1.79]) (authenticated) + by mail.autorevenue.com (8.11.6/8.11.6) with ESMTP id i9JJnaU12950; + Tue, 19 Oct 2004 15:49:36 -0400 +Reply-To: +From: "Jeremy Dunn" +To: , + "Postgresql Performance" +Subject: Re: Speeding up this function +Date: Tue, 19 Oct 2004 15:49:45 -0400 +Organization: AutoRevenue +Message-ID: <008e01c4b614$c86aa550$4f01a8c0@jeremydunn> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +In-Reply-To: <27c475ec04101912351c451e8@mail.gmail.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/284 +X-Sequence-Number: 8760 + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of +> Matt Nuzum +> Sent: Tuesday, October 19, 2004 3:35 PM +> To: pgsql-performance +> Subject: [PERFORM] Speeding up this function +> + +> +> All it does is try to "link" pageviews together into a session. +> here's the function: +> create or replace function usage_normalize_session +> (varchar(12), inet, timestamptz) returns integer as ' DECLARE +> -- $1 = Account ID, $2 = IP Address, $3 = Time +> RecordSet record; +> BEGIN +> SELECT INTO RecordSet DISTINCT sessionid FROM usage_access ua +> WHERE ua.accountid = $1 +> AND ua.client = $2 +> AND ua.atime <= ($3 - ''20 +> min''::interval)::timestamptz; +> +> if found +> then return RecordSet.sessionid; +> end if; +> +> return nextval(''usage_session_ids''); +> END;' +> language plpgsql; +> + +This is probably a stupid question, but why are you trying to create +sessions after the fact? Since it appears that users of your site must +login, why not just assign a sessionID to them at login time, and keep +it in the URL for the duration of the session? Then it would be easy to +track where they've been. + +- Jeremy + + +From pgsql-performance-owner@postgresql.org Tue Oct 19 20:55:13 2004 +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 C4EDF32A096 + for ; + Tue, 19 Oct 2004 20:55:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26815-01 + for ; + Tue, 19 Oct 2004 19:55:04 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 71C5932A084 + for ; + Tue, 19 Oct 2004 20:55:04 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 73so375340rnk + for ; + Tue, 19 Oct 2004 12:55:04 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; 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:references; + b=LTXl/v2hYcx/LR6tVuX4NrgsLuM1QEcpxnR7TeKGP+ylldNzzlkUXOI1PFrGHd0J+BExNbZqWbm2IxADaw+ZY7B2YpXn1hhntu9F+P9N5kIFwf63YBTozYm0cPQVkqpOZEDesbi7PzocR4wcYxE5Y/ZWoSehD2bHS7cezNr8WtE +Received: by 10.38.152.19 with SMTP id z19mr2147997rnd; + Tue, 19 Oct 2004 12:55:04 -0700 (PDT) +Received: by 10.38.165.32 with HTTP; Tue, 19 Oct 2004 12:55:04 -0700 (PDT) +Message-ID: <27c475ec04101912556af1d77e@mail.gmail.com> +Date: Tue, 19 Oct 2004 15:55:04 -0400 +From: Matt Nuzum +Reply-To: matt@followers.net +To: jdunn@autorevenue.com +Subject: Re: Speeding up this function +Cc: Postgresql Performance +In-Reply-To: <008e01c4b614$c86aa550$4f01a8c0@jeremydunn> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <27c475ec04101912351c451e8@mail.gmail.com> + <008e01c4b614$c86aa550$4f01a8c0@jeremydunn> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/285 +X-Sequence-Number: 8761 + +On Tue, 19 Oct 2004 15:49:45 -0400, Jeremy Dunn wrote: +> > -----Original Message----- +> > From: pgsql-performance-owner@postgresql.org +> > [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of +> > Matt Nuzum +> > Sent: Tuesday, October 19, 2004 3:35 PM +> > To: pgsql-performance +> > Subject: [PERFORM] Speeding up this function +> > +> + +> +> This is probably a stupid question, but why are you trying to create +> sessions after the fact? Since it appears that users of your site must +> login, why not just assign a sessionID to them at login time, and keep +> it in the URL for the duration of the session? Then it would be easy to +> track where they've been. +> +> - Jeremy +> +> + +You don't have to log in to visit the sites. These log files are +actually for many domains. Right now, we do logging with a web-bug +and it does handle the sessions, but it relies on javascript and we +want to track a lot more than we are now. Plus, that code is in +JavaScript and one of our primary motiviations is to ditch MySQL +completely. + +-- +Matthew Nuzum | Makers of "Elite Content Management System" +www.followers.net | View samples of Elite CMS in action +matt@followers.net | http://www.followers.net/portfolio/ + +From pgsql-performance-owner@postgresql.org Tue Oct 19 22:52:31 2004 +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 65F9F329E89 + for ; + Tue, 19 Oct 2004 22:52:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13797-01 + for ; + Tue, 19 Oct 2004 21:52: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 44F82329E6E + for ; + Tue, 19 Oct 2004 22:52:19 +0100 (BST) +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 i9JLqDkc020152; + Tue, 19 Oct 2004 17:52:13 -0400 (EDT) +To: Manfred Spraul +Cc: neilc@samurai.com, markw@osdl.org, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +In-reply-to: <417221B5.1050704@colorfullife.com> +References: <417221B5.1050704@colorfullife.com> +Comments: In-reply-to Manfred Spraul + message dated "Sun, 17 Oct 2004 09:39:33 +0200" +Date: Tue, 19 Oct 2004 17:52:13 -0400 +Message-ID: <20151.1098222733@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/294 +X-Sequence-Number: 8770 + +Manfred Spraul writes: +> Has anyone tried to replace the whole lwlock implementation with +> pthread_rwlock? At least for Linux with recent glibcs, pthread_rwlock is +> implemented with futexes, i.e. we would get a fast lock handling without +> os specific hacks. + +"At least for Linux" does not strike me as equivalent to "without +OS-specific hacks". + +The bigger problem here is that the SMP locking bottlenecks we are +currently seeing are *hardware* issues (AFAICT anyway). The only way +that futexes can offer a performance win is if they have a smarter way +of executing the basic atomic-test-and-set sequence than we do; +and if so, we could read their code and adopt that method without having +to buy into any large reorganization of our code. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 19 22:57:59 2004 +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 E084A329E4F + for ; + Tue, 19 Oct 2004 22:57:57 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18052-09 + for ; + Tue, 19 Oct 2004 21:57:47 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id C17AA32A37B + for ; + Tue, 19 Oct 2004 22:57:45 +0100 (BST) +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 6529810; Tue, 19 Oct 2004 14:59:11 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +Date: Tue, 19 Oct 2004 14:59:48 -0700 +User-Agent: KMail/1.6.2 +Cc: Tom Lane , + Manfred Spraul , neilc@samurai.com, + markw@osdl.org +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> +In-Reply-To: <20151.1098222733@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200410191459.48080.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/295 +X-Sequence-Number: 8771 + +Tom, + +> The bigger problem here is that the SMP locking bottlenecks we are +> currently seeing are *hardware* issues (AFAICT anyway). =C2=A0The only way +> that futexes can offer a performance win is if they have a smarter way +> of executing the basic atomic-test-and-set sequence than we do; +> and if so, we could read their code and adopt that method without having +> to buy into any large reorganization of our code. + +Well, initial results from Gavin/Neil's patch seem to indicate that, while= +=20 +futexes do not cure the CSStorm bug, they do lessen its effects in terms of= +=20 +real performance loss. + +--=20 +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-general-owner@postgresql.org Tue Oct 19 23:09:32 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EE3A1329E77 + for ; + Tue, 19 Oct 2004 23:09:26 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30186-05 + for ; + Tue, 19 Oct 2004 22:09:22 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DA60329E6F + for ; + Tue, 19 Oct 2004 23:09:24 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 73so393035rnk + for ; + Tue, 19 Oct 2004 15:09:22 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; 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:references; + b=kPiOeanz1JVvEsqk8dIbi4hXLgfuVGjtSHHBc9Fct0Dh6w+sQviztFbsutbBCL+pBpvALABYgHDCArKFqqUJIwaWhkP8LO+0IgyICLPQpse0DSkuOdpVYjrmMFtoBywOBwTaQ9JL2QuXWgepnqNJjwecJC499gfW1b1r1kvroXs +Received: by 10.38.152.19 with SMTP id z19mr2207450rnd; + Tue, 19 Oct 2004 15:09:21 -0700 (PDT) +Received: by 10.38.165.1 with HTTP; Tue, 19 Oct 2004 15:09:21 -0700 (PDT) +Message-ID: +Date: Tue, 19 Oct 2004 17:09:21 -0500 +From: Kevin Barnard +Reply-To: Kevin Barnard +To: "MikeSmialek2@Hotmail.com" +Subject: Re: [PERFORM] Performance on Win32 vs Cygwin +Cc: PostgreSQL +In-Reply-To: +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200410/861 +X-Sequence-Number: 67384 + +Have you looked at the 7.3 configuration file vs. the 8.0. It's +possible that the 7.3 file is tweakled better then the 8.0. Have you +anaylzed the tables after loading the data into 8.0 + + +On Thu, 14 Oct 2004 12:01:38 -0500, MikeSmialek2@Hotmail.com + wrote: +> Hi, +> +> We are experiencing slow performance on 8 Beta 2 Dev3 on Win32 and are +> trying to determine why. Any info is appreciated. +> +> We have a Web Server and a DB server both running Win2KServer with all +> service packs and critical updates. +> +> An ASP page on the Web Server hits the DB Server with a simple query that +> returns 205 rows and makes the ASP page delivered to the user about 350K. +> +> On an ethernet lan a client pc perceives just under 1 sec performance with +> the following DB Server configuration: +> PIII 550Mhz +> 256MB RAM +> 7200 RPM HD +> cygwin +> Postgresql 7.1.3 +> PGODBC 7.3.2 +> +> We set up another DB Server with 8 beta (same Web Server, same network, same +> client pc) and now the client pc perceives response of just over 3 sec with +> the following DB server config: +> PIII 700 Mhz +> 448MB RAM +> 7200 RPM HD +> 8 Beta 2 Dev3 on Win32 running as a service +> +> Is the speed decrease because it's a beta? +> Is the speed decrease because it's running on Win instead of cygwin? +> +> We did not install cygwin on the new DB Server. +> +> Thanks, +> +> Mike +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> + +From pgsql-performance-owner@postgresql.org Tue Oct 19 23:32:11 2004 +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 5257232A087 + for ; + Tue, 19 Oct 2004 23:32:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40973-05 + for ; + Tue, 19 Oct 2004 22:31:59 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.195]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AA3132A0F4 + for ; + Tue, 19 Oct 2004 23:32:00 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 73so395398rnk + for ; + Tue, 19 Oct 2004 15:32:00 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=jaqaVwwr0jWoW0C6unOf4Gk1VEACtIVDrSfW3+UHxuOwM2+COPo51IivOpOSVAyMRCWZwTLLdsrhoPB4OfwgDkW+5NoTfe/4uoZMh5kTSyor9vWGqBOs2asFyVycFtrBAPWARWrwq5nELo966bIqIL8VVFAt1REUathkn44xFfA +Received: by 10.38.181.77 with SMTP id d77mr2218334rnf; + Tue, 19 Oct 2004 15:32:00 -0700 (PDT) +Received: by 10.38.76.42 with HTTP; Tue, 19 Oct 2004 15:31:59 -0700 (PDT) +Message-ID: <4a0cafe2041019153133f854e9@mail.gmail.com> +Date: Tue, 19 Oct 2004 17:31:59 -0500 +From: Josh Close +Reply-To: Josh Close +To: POSTGRES-PERFORMANCE +Subject: how much mem to give postgres? +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/296 +X-Sequence-Number: 8772 + +I'm trying to figure out what I need to do to get my postgres server +moving faster. It's just crawling right now. It's on a p4 HT with 2 +gigs of mem. + +I was thinking I need to increase the amount of shared buffers, but +I've been told "the sweet spot for shared_buffers is usually on the +order of 10000 buffers". I already have it set at 21,078. If you have, +say 100 gigs of ram, are you supposed to still only give postgres +10,000? + +Also, do I need to up the shmmax at all? I've used the formula "250 kB ++ 8.2 kB * shared_buffers + 14.2 kB * max_connections up to infinity" +at http://www.postgresql.org/docs/7.4/interactive/kernel-resources.html#SYSVIPC +but it's never quite high enough, so I just make sure it's above the +amount that the postgres log says it needs. + +What else can I do to speed this server up? I'm running vacuum analyze +on the heavily updated/inserted/deleted db's once an hour, and doing a +full vacuum once a night. Should I change the vacuum mem setting at +all? + +Are there any other settings I should be concerned with? I've heard +about the effective_cache_size setting, but I haven't seen anything on +what the size should be. + +Any help would be great. This server is very very slow at the moment. + +Also, I'm using a 2.6.8.1 kernel with high mem enabled, so all the ram +is recognized. + +Thanks. + +-Josh + +From pgsql-performance-owner@postgresql.org Tue Oct 19 23:40:10 2004 +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 3718332A179 + for ; + Tue, 19 Oct 2004 23:39:57 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51510-05 + for ; + Tue, 19 Oct 2004 22:39:52 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 121CB32A10D + for ; + Tue, 19 Oct 2004 23:39:54 +0100 (BST) +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 i9JMdmQ8027698; + Tue, 19 Oct 2004 18:39:49 -0400 (EDT) +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org, + Manfred Spraul , neilc@samurai.com, + markw@osdl.org +Subject: Re: futex results with dbt-3 +In-reply-to: <200410191459.48080.josh@agliodbs.com> +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <200410191459.48080.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Tue, 19 Oct 2004 14:59:48 -0700" +Date: Tue, 19 Oct 2004 18:39:48 -0400 +Message-ID: <27697.1098225588@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/297 +X-Sequence-Number: 8773 + +Josh Berkus writes: +>> The bigger problem here is that the SMP locking bottlenecks we are +>> currently seeing are *hardware* issues (AFAICT anyway). + +> Well, initial results from Gavin/Neil's patch seem to indicate that, while +> futexes do not cure the CSStorm bug, they do lessen its effects in terms of +> real performance loss. + +It would be reasonable to expect that futexes would have a somewhat more +efficient code path in the case where you have to block (mainly because +SysV semaphores have such a heavyweight API, much more complex than we +really need). However, the code path that is killing us is the one +where you *don't* actually need to block. If we had a proper fix for +the problem then the context swap storm itself would go away, and +whatever advantage you might be able to measure now for futexes likewise +would go away. + +In other words, I'm not real excited about a wholesale replacement of +code in order to speed up a code path that I don't want to be taking +in the first place; especially not if that replacement puts a fence +between me and working on the code path that I do care about. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Oct 20 00:22:09 2004 +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 B3A9C329F05 + for ; + Wed, 20 Oct 2004 00:21:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61243-07 + for ; + Tue, 19 Oct 2004 23:21:20 +0000 (GMT) +Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) + by svr1.postgresql.org (Postfix) with SMTP id B0ADB329D86 + for ; + Wed, 20 Oct 2004 00:21:20 +0100 (BST) +Received: (qmail 22105 invoked by uid 0); 20 Oct 2004 09:21:16 +1000 +Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) + (russell@pws.com.au@203.45.44.212) + by mail.pws.com.au with SMTP; 20 Oct 2004 09:21:16 +1000 +From: Russell Smith +To: Gavin Sherry +Subject: Re: Select with qualified join condition / Batch inserts +Date: Wed, 20 Oct 2004 09:18:57 +1000 +User-Agent: KMail/1.7 +Cc: Bernd , pgsql-performance@postgresql.org +References: <200410151225.26083.bernd_pg@genedata.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200410200918.57761.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/298 +X-Sequence-Number: 8774 + +On Fri, 15 Oct 2004 08:47 pm, Gavin Sherry wrote: +> On Fri, 15 Oct 2004, Bernd wrote: +> +> > Hi, +[snip] + +> > Table-def: +> > Table "public.scr_well_compound" +> > Column | Type | Modifiers +> > ------------+------------------------+----------- +> > mat_id | numeric(10,0) | not null +> > barcode | character varying(240) | not null +> > well_index | numeric(5,0) | not null +> > id_level | numeric(3,0) | not null +> > compound | character varying(240) | not null +> > Indexes: +> > "scr_wcm_pk" PRIMARY KEY, btree (id_level, mat_id, barcode, well_index) +> +numeric is not optimized by postgresql like it is by Oracle. You will get much better +performance by changing the numeric types to int, big int, or small int. + +That should get the query time down to somewhere near what Oracle is giving you. + +Regards + +Russell Smith. + + + +[snip] + +From pgsql-performance-owner@postgresql.org Wed Oct 20 00:28:41 2004 +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 2134F32A7F9 + for ; + Wed, 20 Oct 2004 00:25:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61903-07 + for ; + Tue, 19 Oct 2004 23:25:29 +0000 (GMT) +Received: from biglumber.com (biglumber.com [207.228.252.42]) + by svr1.postgresql.org (Postfix) with SMTP id 910C932A091 + for ; + Wed, 20 Oct 2004 00:25:27 +0100 (BST) +Received: (qmail 16108 invoked from network); 19 Oct 2004 23:25:26 -0000 +Received: from unknown (HELO localhost) (207.228.252.42) + by 0 with SMTP; 19 Oct 2004 23:25:26 -0000 +From: "Greg Sabino Mullane" +To: pgsql-performance@postgresql.org +Subject: Re: Does PostgreSQL run with Oracle? +X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 +X-Request-PGP: + http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 +In-Reply-To: +Date: Tue, 19 Oct 2004 23:25:26 -0000 +X-Mailer: JoyMail 1.48 +Message-ID: <1f817f45d6cda937b40fda765f490601@biglumber.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/299 +X-Sequence-Number: 8775 + + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + + +> My basic question to the community is "is PostgreSQL approximately +> as fast as Oracle?" +> +> I don't want benchmarks, they're BS. I want a gut feel from this community +> because I know many of you are in mixed shops that run both products, or +> have had experience with both. + +My gut feeling is not just "as fast", but "often times faster." I've found very +few cases in which Oracle was faster, and that was usually due to some easily +spotted difference such as tablespace support. + +- -- +Greg Sabino Mullane greg@turnstep.com +PGP Key: 0x14964AC8 200410191925 + +-----BEGIN PGP SIGNATURE----- + +iD8DBQFBdaK0vJuQZxSWSsgRApPRAKDTjM+QybR2HnB1UNOao1RY7YDU9ACcDhnr +zvH1gwn35Ah8mixo2XHOFr4= +=NNZf +-----END PGP SIGNATURE----- + + + +From pgsql-performance-owner@postgresql.org Wed Oct 20 01:07:44 2004 +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 4071732A23E + for ; + Wed, 20 Oct 2004 01:07:43 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73580-05 + for ; + Wed, 20 Oct 2004 00:07:36 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E27A32A214 + for ; + Wed, 20 Oct 2004 01:07:37 +0100 (BST) +Received: (qmail 24831 invoked from network); 20 Oct 2004 02:07:38 +0200 +Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) + by boutiquenumerique.com with SMTP; 20 Oct 2004 02:07:38 +0200 +Date: Wed, 20 Oct 2004 02:08:16 +0200 +To: pgsql-performance +Subject: Re: Speeding up this function +References: <27c475ec04101912351c451e8@mail.gmail.com> +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <27c475ec04101912351c451e8@mail.gmail.com> +User-Agent: Opera M2/7.54 (Linux, build 751) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/300 +X-Sequence-Number: 8776 + + + How many lines do you have in your daily logfiles + +> As you can see, this looks for clients who have visited the same site +> within 20 min. If there is no match, a unique sessionid is assigned +> from a sequence. If there is a visit, the session id assigned to them +> is used. I'm only able to process about 25 records per second with my +> setup. My window to do this job is 3-4 hours and the shorter the +> better. + + I'd say your function is flawed because if a client stays more than 20 +minutes he'll get two sessions. + I'd propose the following : + + * solution with postgres (variant #1): + - insert everything into big table, + - SELECT make_session(...) FROM big table GROUP BY account_id + + (you may or may not wish to use the ip address, using it will duplicate +sessions for people using anonimyzing crowds-style proxies, not using it +will merge sessions from the same user from two different ip's). I'd not +use it. + use an index-powered GroupAggregate maybe. + + Now it's well ordered, ie. all accesses from the same account are +grouped, you just have to find 'gaps' of more than 20 minutes in the +atimes to merge or make sessions. This is made by the aggregate +'make_session' which has an internal state consisting of a list of +sessions of the form : + - session : + - session start time + - session end time + + all the aggregate does is look if the atime of the incoming row is < +(session end time + 20 min) + if <, update session to mark session end time to atime + if >, create a new session with session start time = session end time = +atime + and append it to the session list + + So you get a table of session arrays, you just have to assign them id's +and trackback to the URLs to mark them. + + If an aggregate can issue INSERT or UPDATE queries, it can even generate +session ids on the fly in a table, which simplifies its internal state. + + * solution with postgres (variant #2): + + - insert everything into raw_table, + - CREATE TABLE sorted_table + just like raw_table but with a "id SERIAL PRIMARY KEY" added. + - INSERT INTO sorted_table SELECT * FROM raw_table ORDER by account_id, +atime; + + the aggregate was basically comparing the atime's of two adjacent lines +to detect a gap of more than 20 minutes, so you could also do a join +between rows a and b + where b.id = a.id+1 + AND ( + b.account_id != a.account_id + OR (b.atime > a.atime+20 minutes) + OR b does not exist ) + + this will give you the rows which mark a session start, then you have to +join again to update all the rows in that session (BETWEEN id's) with the +session id. + + * solution without postgres + + Take advantage of the fact that the sessions are created and then die to +only use RAM for the active sessions. + Read the logfile sequentially, you'll need to parse the date, if you +can't do it use another language, change your apache date format output, +or write a parser. + + Basically you're doing event-driven programming like in a logic +simulator, where the events are session expirations. + + As you read the file, + - keep a hash of sessions indexed on account_id, + - and also a sorted (btree) list of sessions indexed on a the session +expiry time. + It's very important that this list has fast insertion even in the middle, +which is why a tree structure would be better. Try a red-black tree. + + For each record do: + - look in the hashtable for account_id, find expiry date for this +session, + if session still alive you're in that session, + update session expiry date and btree index accordingly + append url and infos to a list in the session if you want to keep them + else + expire session and start a new one, insert into hash and btree + store the expired session on disk and remove it from memory, you dont +need it anymore ! + + And, as you see the atime advancing, scan the btree for sessions to +expire. + It's ordered by expiry date, so that's fast. + For all expired sessions found, + expire session + store the expired session on disk and remove it from memory, you dont +need it anymore ! + + + That'd be my preferred solution. You'll need a good implementation of a +sorted tree, you can find that in opensource. + + * solution with postgres (variant #3) + + just like variant #2 but instead of an aggregate use a plpgsql procedure +which reads the logs ordered by account_id, atime, while keeping a copy of +the last row, and detecting session expirations on the fly. + + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Wed Oct 20 01:33:27 2004 +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 D34F1329F9B + for ; + Wed, 20 Oct 2004 01:33:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91479-03 + for ; + Wed, 20 Oct 2004 00:33:10 +0000 (GMT) +Received: from cmailm1.svr.pol.co.uk (cmailm1.svr.pol.co.uk [195.92.193.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 29BB7329F0C + for ; + Wed, 20 Oct 2004 01:33:12 +0100 (BST) +Received: from modem-1859.llama.dialup.pol.co.uk ([217.135.183.67] + helo=Nightingale) by cmailm1.svr.pol.co.uk with smtp (Exim 4.14) + id 1CK4Pg-0008QN-Hz; Wed, 20 Oct 2004 01:33:12 +0100 +Message-ID: <01f301c4b63c$643340b0$6400a8c0@Nightingale> +From: "Simon Riggs" +To: "Josh Close" , + "POSTGRES-PERFORMANCE" +References: <4a0cafe2041019153133f854e9@mail.gmail.com> +Subject: Re: how much mem to give postgres? +Date: Wed, 20 Oct 2004 01:33:16 +0100 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/301 +X-Sequence-Number: 8777 + +>Josh Close +> I'm trying to figure out what I need to do to get my postgres server +> moving faster. It's just crawling right now. It's on a p4 HT with 2 +> gigs of mem. + +....and using what version of PostgreSQL are you using? 8.0beta, I hope? + +> I was thinking I need to increase the amount of shared buffers, but +> I've been told "the sweet spot for shared_buffers is usually on the +> order of 10000 buffers". I already have it set at 21,078. If you have, +> say 100 gigs of ram, are you supposed to still only give postgres +> 10,000? + +Thats under test currently. My answer would be, "clearly not", others +differ, for varying reasons. + +> Also, do I need to up the shmmax at all? I've used the formula "250 kB +> + 8.2 kB * shared_buffers + 14.2 kB * max_connections up to infinity" +> at +http://www.postgresql.org/docs/7.4/interactive/kernel-resources.html#SYSVIPC +> but it's never quite high enough, so I just make sure it's above the +> amount that the postgres log says it needs. + +shmmax isn't a tuning parameter for PostgreSQL, its just a limit. If you get +no error messages, then its high enough. + +> Are there any other settings I should be concerned with? I've heard +> about the effective_cache_size setting, but I haven't seen anything on +> what the size should be. + +wal_buffers if the databases are heavily updated. + +> Any help would be great. This server is very very slow at the moment. +> + +Try *very fast disks*, especially for the logs. + +Best regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Wed Oct 20 02:53:40 2004 +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 4922C32A0C2 + for ; + Wed, 20 Oct 2004 02:53:40 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29089-01 + for ; + Wed, 20 Oct 2004 01:53:35 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.202]) + by svr1.postgresql.org (Postfix) with ESMTP id B540D329F75 + for ; + Wed, 20 Oct 2004 02:53:37 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 73so414090rnk + for ; + Tue, 19 Oct 2004 18:53:38 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=T3K9MaxSDJgKoe2EwE8ohedc9NHCV9PzhjXVWD/ofRJY599qu8qPG3zqGIIyf68WcSE8HO3BDb5uUzutW/X5muz4pwQ9vzwCVsQzaJ5cT8BuLEpks0x9TdO0OAumJyBkXqqmHDlAcQtnPydKsB3zYtRKDvOhBDZwiEQTnFj38Uw +Received: by 10.38.72.80 with SMTP id u80mr2280650rna; + Tue, 19 Oct 2004 18:53:37 -0700 (PDT) +Received: by 10.38.165.15 with HTTP; Tue, 19 Oct 2004 18:53:37 -0700 (PDT) +Message-ID: <97b3fe2041019185337a8c3d8@mail.gmail.com> +Date: Wed, 20 Oct 2004 11:53:37 +1000 +From: Brock Henry +Reply-To: Brock Henry +To: pgsql-performance@postgresql.org +Subject: Insert performance, what should I expect? +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/302 +X-Sequence-Number: 8778 + +Hi,=20 + +I've after some opinions about insert performance. + +I'm importing a file with 13,002 lines to a database that ends up with +75,703 records across 6 tables. This is a partial file =E2=80=93 the real d= +ata +is 4 files with total lines 95174. I'll be loading these files each +morning, and then running a number of queries on them. + +The select queries run fast enough, (mostly - 2 queries are slow but +I'll look into that later), but importing is slower than I'd like it +to be, but I'm wondering what to expect? + +I've done some manual benchmarking running my script 'time script.pl' +I realise my script uses some of the time, bench marking shows that +%50 of the time is spent in dbd:execute. + +Test 1, For each import, I'm dropping all indexes and pkeys/fkeys, +then importing, then adding keys and indexes. Then I've got successive +runs. I figure the reindexing will get more expensive as the database +grows? + +Successive Imports: 44,49,50,57,55,61,72 (seconds) +=3D average 1051inserts/second (which now that I've written this seems +fairly good) + +Test 2, no dropping etc of indexes, just INSERTs +Import =E2=80=93 61, 62, 73, 68, 78, 74 (seconds) +=3D average 1091 inserts/second + +Machine is Linux 2.6.4, 1GB RAM, 3.something GHz XEON processor, SCSI +hdd's (raid1). PostgreSQL 7.4.2. Lightly loaded machine, not doing +much other than my script. Script and DB on same machine. + +Sysctl =E2=80=93a | grep shm +kernel.shmmni =3D 4096 +kernel.shmall =3D 134217728 (pages or bytes? Anyway=E2=80=A6) +kernel.shmmax =3D 134217728 + +postgresql.conf +tcpip_socket =3D true +max_connections =3D 32 +superuser_reserved_connections =3D 2 +shared_buffers =3D 8192=20=20=20=20=20=20=20 +sort_mem =3D 4096=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +vacuum_mem =3D 16384=20=20=20=20=20=20 +max_fsm_relations =3D 300=20=20 +fsync =3D true=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +wal_buffers =3D 64=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +checkpoint_segments =3D 10=20=20=20=20=20=20=20=20=20 +effective_cache_size =3D 16000=20=20=20=20 +syslog =3D 1=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20 +silent_mode =3D false=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +log_connections =3D true +log_pid =3D true +log_timestamp =3D true +stats_start_collector =3D true +stats_row_level =3D true + +Can I expect it to go faster than this? I'll see where I can make my +script itself go faster, but I don't think I'll be able to do much. +I'll do some pre-prepare type stuff, but I don't expect significant +gains, maybe 5-10%. I'd could happily turn off fsync for this job, but +not for some other databases the server is hosting. + +Any comments/suggestions would be appreciated. + +Thanks :) + +Brock Henry + +From pgsql-performance-owner@postgresql.org Wed Oct 20 03:12:30 2004 +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 4EC8132AEDA + for ; + Wed, 20 Oct 2004 03:12:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62207-08 + for ; + Wed, 20 Oct 2004 02:12:22 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 41859329E72 + for ; + Wed, 20 Oct 2004 03:12:21 +0100 (BST) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.66]) + by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) + (Exim 4.42) id 1CK5xd-0000lz-EP; Tue, 19 Oct 2004 22:12:21 -0400 +Message-ID: <4175C97A.2080300@zeut.net> +Date: Tue, 19 Oct 2004 22:12:10 -0400 +From: "Matthew T. O'Connor" +Organization: Terrie O'Connor Realtors +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Brock Henry +Cc: pgsql-performance@postgresql.org +Subject: Re: Insert performance, what should I expect? +References: <97b3fe2041019185337a8c3d8@mail.gmail.com> +In-Reply-To: <97b3fe2041019185337a8c3d8@mail.gmail.com> +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 67.80.199.173 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/303 +X-Sequence-Number: 8779 + +Brock Henry wrote: + +>Hi, +> +>I've after some opinions about insert performance. +> +Have you looked into using the copy command instead of inserts? For +bulk loading of data it can be significantly faster. + +From pgsql-performance-owner@postgresql.org Wed Oct 20 03:17:28 2004 +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 2036C32AEA9 + for ; + Wed, 20 Oct 2004 03:17:27 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93420-09 + for ; + Wed, 20 Oct 2004 02:17:22 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E2EAE32AEAC + for ; + Wed, 20 Oct 2004 03:17:25 +0100 (BST) +Received: from [134.22.69.212] (dyn-69-212.tor.dsl.tht.net [134.22.69.212]) + by tht.net (Postfix) with ESMTP + id 326DD76B52; Tue, 19 Oct 2004 22:13:27 -0400 (EDT) +Subject: Re: Insert performance, what should I expect? +From: Rod Taylor +To: Brock Henry +Cc: Postgresql Performance +In-Reply-To: <97b3fe2041019185337a8c3d8@mail.gmail.com> +References: <97b3fe2041019185337a8c3d8@mail.gmail.com> +Content-Type: text/plain +Message-Id: <1098238348.747.20.camel@home> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 19 Oct 2004 22:12:28 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/304 +X-Sequence-Number: 8780 + +> I've done some manual benchmarking running my script 'time script.pl' +> I realise my script uses some of the time, bench marking shows that +> %50 of the time is spent in dbd:execute. + +The perl drivers don't currently use database level prepared statements +which would give a small boost. + +But your best bet is to switch to using COPY instead of INSERT. Two ways +to do this. + +1) Drop DBD::Pg and switch to the Pg driver for Perl instead (non-DBI +compliant) which has functions similar to putline() that allow COPY to +be used. + +2) Have your perl script output a .sql file with the data prepared (COPY +statements) which you feed into the database via psql. + +You can probably achieve a 50% increase in throughput. + + +From pgsql-performance-owner@postgresql.org Wed Oct 20 05:02:43 2004 +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 CAC0A32AF4A + for ; + Wed, 20 Oct 2004 05:02:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73174-08 + for ; + Wed, 20 Oct 2004 04:02:34 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 42E6332AF0C + for ; + Wed, 20 Oct 2004 05:02:31 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 73so425702rnk + for ; + Tue, 19 Oct 2004 21:02:30 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; 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:references; + b=cBu7ohHjSXpGh5QXF7aMIn9pFQEOXe1q5wR7VskXABmRTrgV80luQs2r3svAcDxSTZqdgKn4VbeHcx/7h2MV1pMiu7rww2i1MviEtJLceXE3iJkHwkEiBDof3h6ghiv1Ve9ybl7zNMOOiZPoRbOxe8KrPQFXP8bZkC3t1eTgP68 +Received: by 10.38.181.77 with SMTP id d77mr2339362rnf; + Tue, 19 Oct 2004 21:02:30 -0700 (PDT) +Received: by 10.38.76.42 with HTTP; Tue, 19 Oct 2004 21:02:30 -0700 (PDT) +Message-ID: <4a0cafe2041019210265656d4e@mail.gmail.com> +Date: Tue, 19 Oct 2004 23:02:30 -0500 +From: Josh Close +Reply-To: Josh Close +To: POSTGRES-PERFORMANCE +Subject: Re: how much mem to give postgres? +In-Reply-To: <01f301c4b63c$643340b0$6400a8c0@Nightingale> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <4a0cafe2041019153133f854e9@mail.gmail.com> + <01f301c4b63c$643340b0$6400a8c0@Nightingale> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/305 +X-Sequence-Number: 8781 + +On Wed, 20 Oct 2004 01:33:16 +0100, Simon Riggs wrote: +> ....and using what version of PostgreSQL are you using? 8.0beta, I hope? + +I'm using version 7.4.5. + +> > I was thinking I need to increase the amount of shared buffers, but +> > I've been told "the sweet spot for shared_buffers is usually on the +> > order of 10000 buffers". I already have it set at 21,078. If you have, +> > say 100 gigs of ram, are you supposed to still only give postgres +> > 10,000? +> +> Thats under test currently. My answer would be, "clearly not", others +> differ, for varying reasons. + +Should I stick the rule of around 15% of mem then? I haven't found any +information on why you should use certain settings at all. I read +somewhere on the postgres site about using as much memory as possible, +but leave a little room for other processes. Whould that be an ok +theory? I'd kinda like to know why I should or shouldn't do something +like this. + +-Josh + +From pgsql-performance-owner@postgresql.org Wed Oct 20 05:35:38 2004 +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 EA1F432AEF3 + for ; + Wed, 20 Oct 2004 05:35:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81047-03 + for ; + Wed, 20 Oct 2004 04:35: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 CB93632AEFF + for ; + Wed, 20 Oct 2004 05:35:32 +0100 (BST) +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 i9K4ZVb6029977; + Wed, 20 Oct 2004 00:35:31 -0400 (EDT) +To: Josh Close +Cc: POSTGRES-PERFORMANCE +Subject: Re: how much mem to give postgres? +In-reply-to: <4a0cafe2041019153133f854e9@mail.gmail.com> +References: <4a0cafe2041019153133f854e9@mail.gmail.com> +Comments: In-reply-to Josh Close + message dated "Tue, 19 Oct 2004 17:31:59 -0500" +Date: Wed, 20 Oct 2004 00:35:31 -0400 +Message-ID: <29976.1098246931@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/306 +X-Sequence-Number: 8782 + +Josh Close writes: +> I'm trying to figure out what I need to do to get my postgres server +> moving faster. It's just crawling right now. + +I suspect that fooling with shared_buffers is entirely the wrong tree +for you to be barking up. My suggestion is to be looking at individual +queries that are slow, and seeing how to speed those up. This might +involve adding indexes, or tweaking the query source, or adjusting +planner parameters, or several other things. EXPLAIN ANALYZE is your +friend ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Oct 20 06:23:51 2004 +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 724A632A8DD + for ; + Wed, 20 Oct 2004 06:23:49 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91232-05 + for ; + Wed, 20 Oct 2004 05:23:39 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 240DF329F9F + for ; + Wed, 20 Oct 2004 06:23:39 +0100 (BST) +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 6531652; Tue, 19 Oct 2004 22:25:03 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org, Josh Close +Subject: Re: how much mem to give postgres? +Date: Tue, 19 Oct 2004 22:23:24 -0700 +User-Agent: KMail/1.6.2 +References: <4a0cafe2041019153133f854e9@mail.gmail.com> +In-Reply-To: <4a0cafe2041019153133f854e9@mail.gmail.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410192223.24285.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/307 +X-Sequence-Number: 8783 + +JJosh, + +> I'm trying to figure out what I need to do to get my postgres server +> moving faster. It's just crawling right now. It's on a p4 HT with 2 +> gigs of mem. + +There have been issues with Postgres+HT, especially on Linux 2.4. Try +turning HT off if other tuning doesn't solve things. + +Otherwise, see: +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Oct 20 08:51:09 2004 +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 A766632A8ED + for ; + Wed, 20 Oct 2004 08:51:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31150-03 + for ; + Wed, 20 Oct 2004 07:51:01 +0000 (GMT) +Received: from mail1.catalyst.net.nz (godel.catalyst.net.nz [202.49.159.12]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C5A232A892 + for ; + Wed, 20 Oct 2004 08:51:00 +0100 (BST) +Received: from 222-152-142-149.jetstream.xtra.co.nz ([222.152.142.149] + helo=lamb.mcmillan.net.nz) by mail1.catalyst.net.nz with asmtp + (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) + id 1CKBFH-00032E-Rv; Wed, 20 Oct 2004 20:50:56 +1300 +Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) + by lamb.mcmillan.net.nz (Postfix) with ESMTP id 59E66AD97BBE; + Wed, 20 Oct 2004 20:50:45 +1300 (NZDT) +Subject: Re: Insert performance, what should I expect? +From: Andrew McMillan +To: Brock Henry +Cc: pgsql-performance@postgresql.org +In-Reply-To: <97b3fe2041019185337a8c3d8@mail.gmail.com> +References: <97b3fe2041019185337a8c3d8@mail.gmail.com> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-fDpxLEsYDsVSux/w1NKM" +Date: Wed, 20 Oct 2004 20:50:44 +1300 +Message-Id: <1098258644.22373.161.camel@lamb.mcmillan.net.nz> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/308 +X-Sequence-Number: 8784 + +--=-fDpxLEsYDsVSux/w1NKM +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Wed, 2004-10-20 at 11:53 +1000, Brock Henry wrote: +>=20 +> Test 1, For each import, I'm dropping all indexes and pkeys/fkeys, +> then importing, then adding keys and indexes. Then I've got successive +> runs. I figure the reindexing will get more expensive as the database +> grows? + +Sounds like the right approach to me, if the tables are empty before the +import. + + +> Successive Imports: 44,49,50,57,55,61,72 (seconds) +> =3D average 1051inserts/second (which now that I've written this seems +> fairly good) + +(A) Are you doing the whole thing inside a transaction? This will be +significantly quicker. COPY would probably be quicker still, but the +biggest difference will be a single transaction. + +(B) If you are starting with empty files, are you ensuring that the dead +records are vacuumed before you start? I would recommend a "vacuum +full" on the affected tables prior to the first import run (i.e. when +the tables are empty). This is likely to be the reason that the timing +on your successive imports increases so much. + + + +> sort_mem =3D 4096=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 + +You probably want to increase this - if you have 1G of RAM then there is +probably some spare. But if you actually expect to use 32 connections +then 32 * 4M =3D 128M might mean a careful calculation is needed. If you +are really only likely to have 1-2 connections running concurrently then +increase it to (e.g.) 32768. + +> max_fsm_relations =3D 300=20=20 + +If you do a "vacuum full verbose;" the last line will give you some +clues as to what to set this (and max_fsm_pages) too. + + +> effective_cache_size =3D 16000=20=20=20=20 + +16000 * 8k =3D 128M seems low for a 1G machine - probably you could say +64000 without fear of being wrong. What does "free" show as "cached"? +Depending on how dedicated the machine is to the database, the effective +cache size may be as much as 80-90% of that. + + +> Can I expect it to go faster than this? I'll see where I can make my +> script itself go faster, but I don't think I'll be able to do much. +> I'll do some pre-prepare type stuff, but I don't expect significant +> gains, maybe 5-10%. I'd could happily turn off fsync for this job, but +> not for some other databases the server is hosting. + +You can probably double the speed - maybe more. + +Cheers, + Andrew, +------------------------------------------------------------------------- +Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington +WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St +DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 + How many things I can do without! -- Socrates +------------------------------------------------------------------------- + + +--=-fDpxLEsYDsVSux/w1NKM +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (GNU/Linux) + +iD8DBQBBdhjUjJA0f48GgBIRAqjyAKC8ABSJoxFHklEVFE5KethNR5j5ZQCdHmMP +mSFjmB/Yjs3HNcSYWoJdeeM= +=mKj3 +-----END PGP SIGNATURE----- + +--=-fDpxLEsYDsVSux/w1NKM-- + + +From pgsql-performance-owner@postgresql.org Wed Oct 20 12:12:32 2004 +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 64B0732A75E + for ; + Wed, 20 Oct 2004 12:12:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74330-10 + for ; + Wed, 20 Oct 2004 11:12:23 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.206]) + by svr1.postgresql.org (Postfix) with ESMTP id 242FF32A9B5 + for ; + Wed, 20 Oct 2004 12:12:25 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 73so455941rnk + for ; + Wed, 20 Oct 2004 04:12:25 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; 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:references; + b=pxTN5mK5QQHkviWwOfU0fA5j7l5TKkxnVJCF+gb0JGc88siR2Jz8q0ef1y1eZx19i3SX1KYdQE4VtW6wSwgcFZQo1Fofm8IrLshTZbVzxGU5/EFdA4NyOUn0zvzFptFXq6JtXdXPpJHNRdyPZj1I4pETU6l+DEeWzU4nqe6UBGI +Received: by 10.38.152.46 with SMTP id z46mr524849rnd; + Wed, 20 Oct 2004 04:10:35 -0700 (PDT) +Received: by 10.38.151.75 with HTTP; Wed, 20 Oct 2004 04:10:35 -0700 (PDT) +Message-ID: <157f648404102004103a126b27@mail.gmail.com> +Date: Wed, 20 Oct 2004 07:10:35 -0400 +From: Aaron Werman +Reply-To: Aaron Werman +To: pgsql-performance@postgresql.org +Subject: Re: Free PostgreSQL Training, Philadelphia, Oct 30 +In-Reply-To: <20041019184329.GO21258@warped.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + <20041019184329.GO21258@warped.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/309 +X-Sequence-Number: 8785 + +I'm driving from Tenafly NJ and going to both sessions. If you're able +to get to the George Washington Bridge (A train to 178th Street [Port +Authority North] and a bus over the bridge), I can drive you down. I'm +not sure right now about the return because I have confused plans to +meet someone. + +/Aaron + + +On Tue, 19 Oct 2004 14:43:29 -0400, Max Baker wrote: +> On Wed, Oct 13, 2004 at 12:21:27PM -0400, Aaron Mulder wrote: +> > All, +> > My company (Chariot Solutions) is sponsoring a day of free +> > PostgreSQL training by Bruce Momjian (one of the core PostgreSQL +> > developers). The day is split into 2 sessions (plus a Q&A session): +> > +> > * Mastering PostgreSQL Administration +> > * PostgreSQL Performance Tuning +> > +> > Registration is required, and space is limited. The location is +> > Malvern, PA (suburb of Philadelphia) and it's on Saturday Oct 30. For +> > more information or to register, see +> > +> > http://chariotsolutions.com/postgresql.jsp +> +> I'm up in New York City and would be taking the train down to Philly. Is +> anyone coming from Philly or New York that would be able to give me a lift +> to/from the train station? Sounds like a great event. +> +> Cheers, +> -m +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + + +-- + +Regards, +/Aaron + +From pgsql-performance-owner@postgresql.org Wed Oct 20 12:31:30 2004 +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 384C432A0AE + for ; + Wed, 20 Oct 2004 12:31:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80084-06 + for ; + Wed, 20 Oct 2004 11:31:20 +0000 (GMT) +Received: from heimdall.hig.se (heimdall.hig.se [130.243.8.180]) + by svr1.postgresql.org (Postfix) with SMTP id 6FBAB32A093 + for ; + Wed, 20 Oct 2004 12:31:16 +0100 (BST) +Received: from webmail.student.hig.se ([130.243.8.161]) + by heimdall.hig.se (SAVSMTP 3.1.0.29) with SMTP id M2004102013270611230 + for ; Wed, 20 Oct 2004 13:27:06 +0200 +Received: from 130.243.12.121 (SquirrelMail authenticated user nd02tsk); + by webmail.student.hig.se with HTTP; + Wed, 20 Oct 2004 13:50:38 +0200 (CEST) +Message-ID: <3879.130.243.12.121.1098273038.squirrel@130.243.12.121> +Date: Wed, 20 Oct 2004 13:50:38 +0200 (CEST) +Subject: Re: How to time several queries? +From: nd02tsk@student.hig.se +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.3 +X-Mailer: SquirrelMail/1.4.3 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 (Normal) +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, + UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200410/310 +X-Sequence-Number: 8786 + +It doesn't seem to work. I want a time summary at the end. I am inserting +insert queries from a file with the \i option. + +This is the outcome: + +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.672 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.730 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.698 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.805 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.670 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.831 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.815 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.793 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.660 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.667 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.754 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.668 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.688 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.671 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.787 ms +[7259] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27'); +[7259] LOG: duration: 1.722 ms +[7309] LOG: statement: DELETE FROM weather; +[7309] LOG: duration: 11.314 ms +[7330] LOG: statement: INSERT INTO weather VALUES ('San Francisco', 46, +50, 0.25, '1994-11-27') + + +Tim + + + +From pgsql-performance-owner@postgresql.org Wed Oct 20 16:08:57 2004 +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 21790329F1F + for ; + Wed, 20 Oct 2004 13:51:06 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02911-05 + for ; + Wed, 20 Oct 2004 12:50:57 +0000 (GMT) +Received: from ms-smtp-02.tampabay.rr.com (ms-smtp-02-smtplb.tampabay.rr.com + [65.32.5.132]) + by svr1.postgresql.org (Postfix) with ESMTP id 86638329E72 + for ; + Wed, 20 Oct 2004 13:50:57 +0100 (BST) +Received: from MATTSPC (222-60.26-24.tampabay.rr.com [24.26.60.222]) + by ms-smtp-02.tampabay.rr.com (8.12.10/8.12.7) with ESMTP id + i9KConZn016806; Wed, 20 Oct 2004 08:50:50 -0400 (EDT) +Message-Id: <200410201250.i9KConZn016806@ms-smtp-02.tampabay.rr.com> +From: "Matthew Nuzum" +To: , +Subject: Re: How to time several queries? +Date: Wed, 20 Oct 2004 08:50:42 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +In-reply-to: <2612.130.243.12.107.1098124104.squirrel@130.243.12.107> +Thread-index: AcS1QaijScudGnrvSma4ma/DI8PrLgBYV7gg +X-Virus-Scanned: Symantec AntiVirus Scan Engine +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/319 +X-Sequence-Number: 8795 + +When I'm using psql and I want to time queries, which is what I've been +doing for a little over a day now, I do the following: + +Select now(); query 1; query 2; query 3; select now(); + +This works fine unless you're doing selects with a lot of rows which will +cause your first timestamp to scroll off the screen. + +-- +Matthew Nuzum + "Man was born free, and everywhere +www.bearfruit.org : he is in chains," Rousseau ++~~~~~~~~~~~~~~~~~~+ "Then you will know the truth, and +the TRUTH will set you free," Jesus Christ (John 8:32 NIV) + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of +nd02tsk@student.hig.se +Sent: Monday, October 18, 2004 2:28 PM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] How to time several queries? + +Hello + +I posted this on the general list but think it would be more appropriate +here. Sorry. + +I know it is possible to time isolated queries through the settting of the +\timing option in psql. This makes PgSQL report the time it took to +perform one operation. + +I would like to know how one can get a time summary of many operations, if +it is at all possible. + +Thank you. + +Tim + + + +---------------------------(end of broadcast)--------------------------- +TIP 4: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Wed Oct 20 13:34:55 2004 +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 4B64432A12E + for ; + Wed, 20 Oct 2004 13:34:54 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00190-03 + for ; + Wed, 20 Oct 2004 12:34:45 +0000 (GMT) +Received: from heimdall.hig.se (heimdall.hig.se [130.243.8.180]) + by svr1.postgresql.org (Postfix) with SMTP id ABC4932A11E + for ; + Wed, 20 Oct 2004 13:34:46 +0100 (BST) +Received: from webmail.student.hig.se ([130.243.8.161]) + by heimdall.hig.se (SAVSMTP 3.1.0.29) with SMTP id M2004102014304115757 + for ; Wed, 20 Oct 2004 14:30:41 +0200 +Received: from 130.243.12.121 (SquirrelMail authenticated user nd02tsk); + by webmail.student.hig.se with HTTP; + Wed, 20 Oct 2004 14:54:12 +0200 (CEST) +Message-ID: <3992.130.243.12.121.1098276852.squirrel@130.243.12.121> +In-Reply-To: +References: <3388.130.243.14.147.1097595901.squirrel@130.243.14.147> + +Date: Wed, 20 Oct 2004 14:54:12 +0200 (CEST) +Subject: Re: Which plattform do you recommend I run PostgreSQL +From: nd02tsk@student.hig.se +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.3 +X-Mailer: SquirrelMail/1.4.3 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 (Normal) +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200410/311 +X-Sequence-Number: 8787 + +Thank you. + +Tim + +> hi, +> +> nd02tsk@student.hig.se wrote: +>> Hello +>> +>> I am doing a comparison between MySQL and PostgreSQL. +>> +>> In the MySQL manual it says that MySQL performs best with Linux 2.4 with +>> ReiserFS on x86. Can anyone official, or in the know, give similar +>> information regarding PostgreSQL? +>> +>> Also, any links to benchmarking tests available on the internet between +>> MySQL and PostgreSQL would be appreciated. +> +> http://www.potentialtech.com/wmoran/postgresql.php +> http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html +> http://candle.pha.pa.us/main/writings/pgsql/hw_performance/ +> http://database.sarang.net/database/postgres/optimizing_postgresql.html +> +> C. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + + + +From pgsql-performance-owner@postgresql.org Wed Oct 20 14:06:26 2004 +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 E65CD32A15F + for ; + Wed, 20 Oct 2004 14:06:25 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08428-10 + for ; + Wed, 20 Oct 2004 13:06:15 +0000 (GMT) +Received: from mail.ebuz.de (web01.ebuz.de [62.146.49.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 47F3532A124 + for ; + Wed, 20 Oct 2004 14:06:17 +0100 (BST) +Received: from [217.232.163.185] (helo=nixe) + by mail.ebuz.de with asmtp (Exim 3.33 #1) id 1CKGAQ-000Epr-00 + for pgsql-performance@postgresql.org; Wed, 20 Oct 2004 15:06:14 +0200 +Date: Wed, 20 Oct 2004 15:10:15 +0200 +From: Tom Fischer +To: pgsql-performance@postgresql.org +Subject: OS desicion +Message-ID: <20041020151015.766bb00c@nixe> +Organization: eBuz Internetdienste GbR +X-Mailer: Sylpheed-Claws 0.9.12b (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/313 +X-Sequence-Number: 8789 + +Hi List, + +I have a Dual-Xeon 3Ghz System with with GB RAM and an Adaptec 212=DF SCSI +RAID with 4 SCA Harddiscs. Our customer wants to have the Machine tuned +for best Database performance. Which OS should we used? We are tending +between Linux 2.6 or FreeBSD. The Database Size is 5GB and ascending. +Most SQL-Queries are Selects, the Tablesizes are beetween 300k and up to +10 MB. I've read the Hardware Performance Guide and the result was to +take FreeBSD in the Decision too :) + +And what is on this Context Switiching Bug i have read in the Archive?=20 + +Hope you can help me + +Regards + +Tom + +From pgsql-performance-owner@postgresql.org Wed Oct 20 13:57:24 2004 +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 3554A32A11C + for ; + Wed, 20 Oct 2004 13:57:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06547-07 + for ; + Wed, 20 Oct 2004 12:57:13 +0000 (GMT) +Received: from saturn.opentools.org (saturn.opentools.org [66.250.40.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 122D432A16E + for ; + Wed, 20 Oct 2004 13:57:16 +0100 (BST) +Received: by saturn.opentools.org (Postfix, from userid 500) + id D22EC3E99; Wed, 20 Oct 2004 09:11:25 -0400 (EDT) +Received: from localhost (localhost [127.0.0.1]) + by saturn.opentools.org (Postfix) with ESMTP id CBB37F5A0 + for ; + Wed, 20 Oct 2004 09:11:25 -0400 (EDT) +Date: Wed, 20 Oct 2004 09:11:25 -0400 (EDT) +From: Aaron Mulder +X-X-Sender: ammulder@saturn.opentools.org +To: pgsql-performance@postgresql.org +Subject: Re: Free PostgreSQL Training, Philadelphia, Oct 30 +In-Reply-To: <157f648404102004103a126b27@mail.gmail.com> +Message-ID: +References: + <20041019184329.GO21258@warped.org> + <157f648404102004103a126b27@mail.gmail.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/312 +X-Sequence-Number: 8788 + + If anyone is going to take the train all the way, please e-mail me +offline. There is a train station relatively close to the event (NY to +Philly then the R5 to Malvern), but it's not within walking distance, so +we'll figure out some way to pick people up from there. + +Thanks, + Aaron + +On Wed, 20 Oct 2004, Aaron Werman wrote: +> I'm driving from Tenafly NJ and going to both sessions. If you're able +> to get to the George Washington Bridge (A train to 178th Street [Port +> Authority North] and a bus over the bridge), I can drive you down. I'm +> not sure right now about the return because I have confused plans to +> meet someone. +> +> /Aaron +> +> +> On Tue, 19 Oct 2004 14:43:29 -0400, Max Baker wrote: +> > On Wed, Oct 13, 2004 at 12:21:27PM -0400, Aaron Mulder wrote: +> > > All, +> > > My company (Chariot Solutions) is sponsoring a day of free +> > > PostgreSQL training by Bruce Momjian (one of the core PostgreSQL +> > > developers). The day is split into 2 sessions (plus a Q&A session): +> > > +> > > * Mastering PostgreSQL Administration +> > > * PostgreSQL Performance Tuning +> > > +> > > Registration is required, and space is limited. The location is +> > > Malvern, PA (suburb of Philadelphia) and it's on Saturday Oct 30. For +> > > more information or to register, see +> > > +> > > http://chariotsolutions.com/postgresql.jsp +> > +> > I'm up in New York City and would be taking the train down to Philly. Is +> > anyone coming from Philly or New York that would be able to give me a lift +> > to/from the train station? Sounds like a great event. +> > +> > Cheers, +> > -m +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 3: if posting/reading through Usenet, please send an appropriate +> > subscribe-nomail command to majordomo@postgresql.org so that your +> > message can get through to the mailing list cleanly +> > +> +> +> -- +> +> Regards, +> /Aaron +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> + +From pgsql-performance-owner@postgresql.org Wed Oct 20 14:23:39 2004 +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 EA41F32A1FF + for ; + Wed, 20 Oct 2004 14:23:38 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13084-09 + for ; + Wed, 20 Oct 2004 13:23:23 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 940E232A11E + for ; + Wed, 20 Oct 2004 14:23:24 +0100 (BST) +Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk + [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP + id 458A8A3A8E; Wed, 20 Oct 2004 14:23:22 +0100 (BST) +Message-ID: <417666C9.80008@ymogen.net> +Date: Wed, 20 Oct 2004 14:23:21 +0100 +From: Matt Clark +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Fischer +Cc: pgsql-performance@postgresql.org +Subject: Re: OS desicion +References: <20041020151015.766bb00c@nixe> +In-Reply-To: <20041020151015.766bb00c@nixe> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/314 +X-Sequence-Number: 8790 + +You are asking the wrong question. The best OS is the OS you (and/or +the customer) knows and can administer competently. The real +performance differences between unices are so small as to be ignorable +in this context. The context switching bug is not OS-dependent, but +varys in severity across machine architectures (I understand it to be +mostly P4/Athlon related, but don't take my word for it). + +M + +Tom Fischer wrote: + +>Hi List, +> +>I have a Dual-Xeon 3Ghz System with with GB RAM and an Adaptec 212� SCSI +>RAID with 4 SCA Harddiscs. Our customer wants to have the Machine tuned +>for best Database performance. Which OS should we used? We are tending +>between Linux 2.6 or FreeBSD. The Database Size is 5GB and ascending. +>Most SQL-Queries are Selects, the Tablesizes are beetween 300k and up to +>10 MB. I've read the Hardware Performance Guide and the result was to +>take FreeBSD in the Decision too :) +> +>And what is on this Context Switiching Bug i have read in the Archive? +> +>Hope you can help me +> +>Regards +> +>Tom +> +>---------------------------(end of broadcast)--------------------------- +>TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> + +From pgsql-performance-owner@postgresql.org Wed Oct 20 14:36:58 2004 +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 D21CD32A1FF + for ; + Wed, 20 Oct 2004 14:36:57 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17237-09 + for ; + Wed, 20 Oct 2004 13:36:46 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) + by svr1.postgresql.org (Postfix) with ESMTP id B2670329F90 + for ; + Wed, 20 Oct 2004 14:36:48 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 74so454090rnk + for ; + Wed, 20 Oct 2004 06:36:49 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; 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:references; + b=W37flJuiyWw8N8vsFdmSEhpLS1CCwtm6PzuC7TKPyA4aDHp6nitkJdRIYbgxDR5mGzM+L8a9S7MISuNB2bgPMMchEbB50ikYB1uhhRDfEM0VzkFf3ng6VBLtqzOznHQoSp5pwDMal7aowkYCdZz2y0P5YrVO1BiQky7QgfgO5qI +Received: by 10.38.152.39 with SMTP id z39mr2542808rnd; + Wed, 20 Oct 2004 06:36:49 -0700 (PDT) +Received: by 10.38.76.42 with HTTP; Wed, 20 Oct 2004 06:36:49 -0700 (PDT) +Message-ID: <4a0cafe204102006361e372071@mail.gmail.com> +Date: Wed, 20 Oct 2004 08:36:49 -0500 +From: Josh Close +Reply-To: Josh Close +To: POSTGRES-PERFORMANCE +Subject: Re: how much mem to give postgres? +In-Reply-To: <29976.1098246931@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <4a0cafe2041019153133f854e9@mail.gmail.com> + <29976.1098246931@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/315 +X-Sequence-Number: 8791 + +On Wed, 20 Oct 2004 00:35:31 -0400, Tom Lane wrote: +> I suspect that fooling with shared_buffers is entirely the wrong tree +> for you to be barking up. My suggestion is to be looking at individual +> queries that are slow, and seeing how to speed those up. This might +> involve adding indexes, or tweaking the query source, or adjusting +> planner parameters, or several other things. EXPLAIN ANALYZE is your +> friend ... +> +> regards, tom lane + +Only problem is, a "select count(1)" is taking a long time. Indexes +shouldn't matter with this since it's counting every row, right? The +tables are fairly well indexed also, I could probably add a few more. + +If shared_buffers isn't the way to go ( you said 10k is the sweetspot +), then what about the effective_cache_size? I was suggested on the +general list about possibly setting that to 75% of ram. + +Thanks. + +-Josh + +From pgsql-performance-owner@postgresql.org Wed Oct 20 14:40:06 2004 +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 BCDA232A20C + for ; + Wed, 20 Oct 2004 14:40:05 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21520-01 + for ; + Wed, 20 Oct 2004 13:39:50 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) + by svr1.postgresql.org (Postfix) with ESMTP id D198132A245 + for ; + Wed, 20 Oct 2004 14:39:53 +0100 (BST) +Received: by mproxy.gmail.com with SMTP id 74so454395rnk + for ; + Wed, 20 Oct 2004 06:39:53 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; 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:references; + b=JarKR8W2Nk6BbYEST7obGQAqKM5OGGUuTNxuC6dZjrGXmdYrhrxaKDXRuXT2n4Ayjf1A0EmqYZmMqzP8KLX3MelxoNWf7tsO/oKeO/izWwEMQYzjbm2QNojaH5fmo1kLZFPaC6Gjivm5Gl+dJ8sYI908E2Aygcr1fIpMFOi6HQ0 +Received: by 10.38.24.12 with SMTP id 12mr2533446rnx; + Wed, 20 Oct 2004 06:39:53 -0700 (PDT) +Received: by 10.38.76.42 with HTTP; Wed, 20 Oct 2004 06:39:53 -0700 (PDT) +Message-ID: <4a0cafe204102006391f726a4f@mail.gmail.com> +Date: Wed, 20 Oct 2004 08:39:53 -0500 +From: Josh Close +Reply-To: Josh Close +To: POSTGRES-PERFORMANCE +Subject: Re: how much mem to give postgres? +In-Reply-To: <200410192223.24285.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <4a0cafe2041019153133f854e9@mail.gmail.com> + <200410192223.24285.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/316 +X-Sequence-Number: 8792 + +On Tue, 19 Oct 2004 22:23:24 -0700, Josh Berkus wrote: +> There have been issues with Postgres+HT, especially on Linux 2.4. Try +> turning HT off if other tuning doesn't solve things. +> +> Otherwise, see: +> http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +How would I turn that off? In the kernel config? Not too familiar with +that. I have a 2 proc xeon with 4 gigs of mem on the way for postgres, +so I hope HT isn't a problem. If HT is turned off, does it just not +use the other "half" of the processor? Or does the processor just work +as one unit? + +Also, I'm taking a look at that site right now :) + +-Josh + +From pgsql-performance-owner@postgresql.org Wed Oct 20 15:07:08 2004 +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 427F132A2AE + for ; + Wed, 20 Oct 2004 15:07:06 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28376-04 + for ; + Wed, 20 Oct 2004 14:06:59 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 429F932A298 + for ; + Wed, 20 Oct 2004 15:07:01 +0100 (BST) +Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk + [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP + id 453E4A338F; Wed, 20 Oct 2004 15:07:01 +0100 (BST) +Message-ID: <41767104.10702@ymogen.net> +Date: Wed, 20 Oct 2004 15:07:00 +0100 +From: Matt Clark +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Close +Cc: POSTGRES-PERFORMANCE +Subject: Re: how much mem to give postgres? +References: <4a0cafe2041019153133f854e9@mail.gmail.com> + <200410192223.24285.josh@agliodbs.com> + <4a0cafe204102006391f726a4f@mail.gmail.com> +In-Reply-To: <4a0cafe204102006391f726a4f@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/317 +X-Sequence-Number: 8793 + + +>How would I turn that off? In the kernel config? Not too familiar with +>that. I have a 2 proc xeon with 4 gigs of mem on the way for postgres, +>so I hope HT isn't a problem. If HT is turned off, does it just not +>use the other "half" of the processor? Or does the processor just work +>as one unit? +> +> +You turn it off in the BIOS. There is no 'other half', the processor is +just pretending to have two cores by shuffling registers around, which +gives maybe a 5-10% performance gain in certain multithreaded +situations. A hack to overcome marchitactural limitations due +to the overly long pipeline in the Prescott core.. Really of +most use for desktop interactivity rather than actual throughput. + +M + +From pgsql-performance-owner@postgresql.org Wed Oct 20 17:14:04 2004 +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 A37C432B11B + for ; + Wed, 20 Oct 2004 17:14:02 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14348-01 + for ; + Wed, 20 Oct 2004 16:13:57 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id 8F05B32B10F + for ; + Wed, 20 Oct 2004 17:13:56 +0100 (BST) +Received: (qmail 9379 invoked from network); 20 Oct 2004 16:13:53 -0000 +Received: from pcp02680586pcs.nash01.tn.comcast.net (HELO ?192.168.0.114?) + (68.52.123.224) by 0 with SMTP; 20 Oct 2004 16:13:53 -0000 +In-Reply-To: <0c4501c4b604$06f15460$0b00a8c0@forge> +References: <0bef01c4b5f8$70026ae0$0b00a8c0@forge> + <16865.1098204769@sss.pgh.pa.us> + <0c4501c4b604$06f15460$0b00a8c0@forge> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <0736EED9-22B3-11D9-A5E5-000D93AE0944@sitening.com> +Content-Transfer-Encoding: 7bit +Cc: +From: Thomas F.O'Connell +Subject: Re: Index not used in query. Why? +Date: Wed, 20 Oct 2004 11:13:49 -0500 +To: "Contact AR-SD.NET" +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/320 +X-Sequence-Number: 8796 + +There's a chance that you could gain from quoting the '4' and '6' if +those orders.id_status isn't a pure int column and is indexed. + +See http://www.postgresql.org/docs/7.4/static/datatype.html#DATATYPE-INT + +-tfo + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-260-0005 + +On Oct 19, 2004, at 12:49 PM, Contact AR-SD.NET wrote: + +> Is there a solution to make it faster? +> At the end I need only in the query the id_status =4 and 6, but if I +> write +> in the sql query (where condition) where id_status in (4,6), the +> explain +> says the same(the slow version). +> +> For example: +> SELECT count(o.id) FROM orders o +> INNER JOIN report r ON +> o.id=r.id_order +> INNER JOIN status s ON +> o.id_status=s.id +> INNER JOIN contact c ON o.id_ag=c.id +> INNER JOIN endkunde e ON +> o.id_endkunde=e.id +> INNER JOIN zufriden z ON +> r.id_zufriden=z.id +> INNER JOIN plannung v ON +> v.id=o.id_plannung +> INNER JOIN mpsworker w ON +> v.id_worker=w.id +> INNER JOIN person p ON p.id = +> w.id_person +> WHERE o.id_status in (4,6); +> +> The result for this query is also without index searches. +> +> I really have to make this query a little more faster. Suggestions? +> +> Regards, +> Andy. +> +> ----- Original Message ----- +> From: "Tom Lane" +> To: "Andrei Bintintan" +> Cc: +> Sent: Tuesday, October 19, 2004 7:52 PM +> Subject: Re: [PERFORM] Index not used in query. Why? +> +> +>> "Andrei Bintintan" writes: +>>> Hi to all! I have the following query. The execution time is very +>>> big, +> it +>>> doesn't use the indexes and I don't understand why... +>> +>> Indexes are not necessarily the best way to do a large join. +>> +>>> If I use the following query the indexes are used: +>> +>> The key reason this wins seems to be that the id_status = 4 condition +>> is far more selective than id_status > 3 (the estimates are 52 and +>> 36967 +>> rows respectively ... is that accurate?) which means that the second +>> query is inherently about 1/700th as much work. This, and not the use +>> of indexes, is the fundamental reason why it's faster. +>> +>> regards, tom lane +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 4: Don't 'kill -9' the postmaster +>> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to +> majordomo@postgresql.org) + + +From pgsql-performance-owner@postgresql.org Wed Oct 20 17:39:17 2004 +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 0341C32A12E + for ; + Wed, 20 Oct 2004 17:39:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31312-08 + for ; + Wed, 20 Oct 2004 16:39:10 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B26332A04B + for ; + Wed, 20 Oct 2004 17:39:09 +0100 (BST) +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 6533609; Wed, 20 Oct 2004 09:40:33 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: OS desicion +Date: Wed, 20 Oct 2004 09:38:51 -0700 +User-Agent: KMail/1.6.2 +Cc: Matt Clark , Tom Fischer +References: <20041020151015.766bb00c@nixe> <417666C9.80008@ymogen.net> +In-Reply-To: <417666C9.80008@ymogen.net> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410200938.51391.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/321 +X-Sequence-Number: 8797 + +Tom, + +> You are asking the wrong question. The best OS is the OS you (and/or +> the customer) knows and can administer competently. + +I'll have to 2nd this. + +> The real +> performance differences between unices are so small as to be ignorable +> in this context. + +Well, at least the difference between Linux and BSD. There are substantial +tradeoffs should you chose to use Solaris or UnixWare. + +> The context switching bug is not OS-dependent, but +> varys in severity across machine architectures (I understand it to be +> mostly P4/Athlon related, but don't take my word for it). + +The bug is at its apparent worst on multi-processor HT Xeons and weak +northbridges running Linux 2.4. However, it has been demonstrated (with +lesser impact) on Solaris/Sparc, PentiumIII, and Athalon. Primarily it +seems to affect data warehousing applications. Your choice of OS is not +affected by this bug. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Oct 20 18:12:10 2004 +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 78A9832A791 + for ; + Wed, 20 Oct 2004 18:12:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53445-06 + for ; + Wed, 20 Oct 2004 17:11:58 +0000 (GMT) +Received: from rambo.iniquinet.com (rambo.iniquinet.com [69.39.89.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 7176E32A1BB + for ; + Wed, 20 Oct 2004 18:11:54 +0100 (BST) +Received: (qmail 6077 invoked by uid 1010); 20 Oct 2004 12:45:37 -0400 +Received: from Robert_Creager@LogicalChaos.org by rambo.iniquinet.com by uid + 1002 with qmail-scanner-1.20 (clamscan: 0.70. spamassassin: 2.64. + Clear:RC:0(63.147.78.131):SA:0(-4.6/6.0):. + Processed in 1.281667 secs); 20 Oct 2004 16:45:37 -0000 +Received: from unknown (HELO thunder.mshome.net) + (perl?test@logicalchaos.org@63.147.78.131) + by rambo.iniquinet.com with AES256-SHA encrypted SMTP; + 20 Oct 2004 12:45:36 -0400 +Received: from localhost.localdomain (thunder.mshome.net [192.168.0.250]) + by thunder.mshome.net (Postfix) with ESMTP id C1C2639C9; + Wed, 20 Oct 2004 10:45:31 -0600 (MDT) +Received: from logicalchaos.org (thunder.mshome.net [192.168.0.250]) + by thunder.mshome.net (Postfix) with SMTP id 4303931CF; + Wed, 20 Oct 2004 10:45:28 -0600 (MDT) +Date: Wed, 20 Oct 2004 10:45:27 -0600 +From: Robert Creager +To: Rod Taylor +Cc: Brock Henry , + Postgresql Performance +Subject: Re: Insert performance, what should I expect? +Message-ID: <20041020104527.14927c06@thunder.mshome.net> +In-Reply-To: <1098238348.747.20.camel@home> +References: <97b3fe2041019185337a8c3d8@mail.gmail.com> + <1098238348.747.20.camel@home> +Organization: Starlight Vision, LLC. +X-Mailer: Sylpheed-Claws 0.9.12a (GTK+ 1.2.10; i586-mandrake-linux-gnu) +Mime-Version: 1.0 +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg="pgp-sha1"; + boundary="Signature=_Wed__20_Oct_2004_10_45_27_-0600_FSwak.CH9e/r+FHK" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/323 +X-Sequence-Number: 8799 + +--Signature=_Wed__20_Oct_2004_10_45_27_-0600_FSwak.CH9e/r+FHK +Content-Type: text/plain; charset=US-ASCII +Content-Disposition: inline +Content-Transfer-Encoding: 7bit + +When grilled further on (Tue, 19 Oct 2004 22:12:28 -0400), +Rod Taylor confessed: + +> > I've done some manual benchmarking running my script 'time script.pl' +> > I realise my script uses some of the time, bench marking shows that +> > %50 of the time is spent in dbd:execute. +> > +> 1) Drop DBD::Pg and switch to the Pg driver for Perl instead (non-DBI +> compliant) which has functions similar to putline() that allow COPY to +> be used. + +COPY can be used with DBD::Pg, per a script I use: + +$dbh->do( "COPY temp_obs_$band ( $col_list ) FROM stdin" ); +$dbh->func( join ( "\t", @data ) . "\n", 'putline' ); +$dbh->func( "\\.\n", 'putline' ); +$dbh->func( 'endcopy' ); + +With sets of data from 1000 to 8000 records, my COPY performance is consistent +at ~10000 records per second. + +Cheers, +Rob + +-- + 10:39:31 up 2 days, 16:25, 2 users, load average: 2.15, 2.77, 3.06 +Linux 2.6.5-02 #8 SMP Mon Jul 12 21:34:44 MDT 2004 + +--Signature=_Wed__20_Oct_2004_10_45_27_-0600_FSwak.CH9e/r+FHK +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iEYEARECAAYFAkF2licACgkQLQ/DKuwDYzkCTQCfTAdnx0jDOUE3N2PyTesJcIgQ +AvIAnitYXOsWZpmcQJGXM1rOFCJ+4p8y +=ysQM +-----END PGP SIGNATURE----- + +--Signature=_Wed__20_Oct_2004_10_45_27_-0600_FSwak.CH9e/r+FHK-- + + +From pgsql-performance-owner@postgresql.org Mon Oct 25 16:57:46 2004 +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 8A09232A178 + for ; + Wed, 20 Oct 2004 17:52:27 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34483-10 + for ; + Wed, 20 Oct 2004 16:52:12 +0000 (GMT) +Received: from dbl.q-ag.de (dbl.q-ag.de [213.172.117.3]) + by svr1.postgresql.org (Postfix) with ESMTP id AA73032A134 + for ; + Wed, 20 Oct 2004 17:52:08 +0100 (BST) +Received: from [127.0.0.2] (dbl [127.0.0.1]) + by dbl.q-ag.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i9KGpoSL003977; + Wed, 20 Oct 2004 18:51:52 +0200 +Message-ID: <417697A5.1050600@colorfullife.com> +Date: Wed, 20 Oct 2004 18:51:49 +0200 +From: Manfred Spraul +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.7.3) Gecko/20040922 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: neilc@samurai.com, markw@osdl.org, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> +In-Reply-To: <20151.1098222733@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/411 +X-Sequence-Number: 8887 + +Tom Lane wrote: + +>Manfred Spraul writes: +> +> +>>Has anyone tried to replace the whole lwlock implementation with +>>pthread_rwlock? At least for Linux with recent glibcs, pthread_rwlock is +>>implemented with futexes, i.e. we would get a fast lock handling without +>>os specific hacks. +>> +>> +> +>"At least for Linux" does not strike me as equivalent to "without +>OS-specific hacks". +> +> +> +For me, "at least for Linux" means that I have tested the patch with +Linux. I'd expect that the patch works on most recent unices +(pthread_rwlock_t is probably mandatory for Unix98 compatibility). You +and others on this mailing list have access to other systems - my patch +should be seen as a call for testers, not as a proposal for merging. I +expect that Linux is not the only OS with fast user space semaphores, +and if an OS has such objects, then the pthread_ locking functions are +hopefully implemented by using them. IMHO it's better to support the +standard function instead of trying to use the native (and OS specific) +fast semaphore functions. + +>The bigger problem here is that the SMP locking bottlenecks we are +>currently seeing are *hardware* issues (AFAICT anyway). The only way +>that futexes can offer a performance win is if they have a smarter way +>of executing the basic atomic-test-and-set sequence than we do; +> +> +lwlocks operations are not a basic atomic-test-and-set sequence. They +are spinlock, several nonatomic operations, spin_unlock. + +-- + Manfred + +From pgsql-performance-owner@postgresql.org Wed Oct 20 18:10:24 2004 +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 3C96D32B0DF + for ; + Wed, 20 Oct 2004 18:10:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49924-06 + for ; + Wed, 20 Oct 2004 17:10:11 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id D2E7832AEB0 + for ; + Wed, 20 Oct 2004 18:10:10 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9KHA1g13777; + Wed, 20 Oct 2004 10:10:01 -0700 +Date: Wed, 20 Oct 2004 10:10:01 -0700 +From: Mark Wong +To: Manfred Spraul +Cc: neilc@samurai.com, pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +Message-ID: <20041020101001.A13359@osdl.org> +References: <417221B5.1050704@colorfullife.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +In-Reply-To: <417221B5.1050704@colorfullife.com>; + from manfred@colorfullife.com on Sun, Oct 17, 2004 at 09:39:33AM + +0200 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/322 +X-Sequence-Number: 8798 + +On Sun, Oct 17, 2004 at 09:39:33AM +0200, Manfred Spraul wrote: +> Neil wrote: +> +> >. In any case, the "futex patch" +> >uses the Linux 2.6 futex API to implement PostgreSQL spinlocks. +> > +> Has anyone tried to replace the whole lwlock implementation with +> pthread_rwlock? At least for Linux with recent glibcs, pthread_rwlock is +> implemented with futexes, i.e. we would get a fast lock handling without +> os specific hacks. Perhaps other os contain user space pthread locks, too. +> Attached is an old patch. I tested it on an uniprocessor system a year +> ago and it didn't provide much difference, but perhaps the scalability +> is better. You'll have to add -lpthread to the library list for linking. + +I've heard that simply linking to the pthreads libraries, regardless of +whether you're using them or not creates a significant overhead. Has +anyone tried it for kicks? + +Mark + +From pgsql-performance-owner@postgresql.org Wed Oct 20 18:12:54 2004 +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 26E0C329FED + for ; + Wed, 20 Oct 2004 18:12:53 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55793-04 + for ; + Wed, 20 Oct 2004 17:12:49 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 66175329FB2 + for ; + Wed, 20 Oct 2004 18:12:45 +0100 (BST) +Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk + [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP + id 33139A2EB2; Wed, 20 Oct 2004 18:12:39 +0100 (BST) +Message-ID: <41769C86.5090208@ymogen.net> +Date: Wed, 20 Oct 2004 18:12:38 +0100 +From: Matt Clark +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, + Tom Fischer +Subject: Re: OS desicion +References: <20041020151015.766bb00c@nixe> <417666C9.80008@ymogen.net> + <200410200938.51391.josh@agliodbs.com> +In-Reply-To: <200410200938.51391.josh@agliodbs.com> +Content-Type: multipart/alternative; + boundary="------------050501040502070906030603" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.4 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: * +X-Archive-Number: 200410/324 +X-Sequence-Number: 8800 + +This is a multi-part message in MIME format. +--------------050501040502070906030603 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + +>>The real +>>performance differences between unices are so small as to be ignorable +>>in this context. +>> +>> +> <> +> Well, at least the difference between Linux and BSD. There are +> substantial +> tradeoffs should you chose to use Solaris or UnixWare. + +Yes, quite right, I should have said 'popular x86-based unices'. + +--------------050501040502070906030603 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +
+
+
+
The real 
+performance differences between unices are so small as to be ignorable
+in this context. 
+    
+
+ <>
+Well, at least the difference between Linux and BSD. There are +substantial
+tradeoffs should you chose to use Solaris or UnixWare.
+
+Yes, quite right, I should have said 'popular x86-based unices'. 
+ + + +--------------050501040502070906030603-- + +From pgsql-performance-owner@postgresql.org Mon Oct 25 16:58:29 2004 +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 9864A32B16F + for ; + Wed, 20 Oct 2004 18:15:09 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66618-01 + for ; + Wed, 20 Oct 2004 17:14:55 +0000 (GMT) +Received: from dbl.q-ag.de (dbl.q-ag.de [213.172.117.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 2858632A2FD + for ; + Wed, 20 Oct 2004 18:14:54 +0100 (BST) +Received: from [127.0.0.2] (dbl [127.0.0.1]) + by dbl.q-ag.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i9KHEkSL004225; + Wed, 20 Oct 2004 19:14:47 +0200 +Message-ID: <41769D06.7080407@colorfullife.com> +Date: Wed, 20 Oct 2004 19:14:46 +0200 +From: Manfred Spraul +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.7.3) Gecko/20040922 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mark Wong +Cc: neilc@samurai.com, pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +References: <417221B5.1050704@colorfullife.com> + <20041020101001.A13359@osdl.org> +In-Reply-To: <20041020101001.A13359@osdl.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/419 +X-Sequence-Number: 8895 + +Mark Wong wrote: + +>I've heard that simply linking to the pthreads libraries, regardless of +>whether you're using them or not creates a significant overhead. Has +>anyone tried it for kicks? +> +> +> +That depends on the OS and the functions that are used. The typical +worst case is buffered IO of single characters: The single threaded +implementation is just copy and update buffer status, the multi threaded +implementation contains full locking. + +For most other functions there is no difference at all. +-- + Manfred + + +From pgsql-performance-owner@postgresql.org Wed Oct 20 18:15:58 2004 +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 9266832A3B9 + for ; + Wed, 20 Oct 2004 18:15:56 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54367-10 + for ; + Wed, 20 Oct 2004 17:15: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 9C65732A37C + for ; + Wed, 20 Oct 2004 18:15:41 +0100 (BST) +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 i9KHFZKW007179; + Wed, 20 Oct 2004 13:15:35 -0400 (EDT) +To: Manfred Spraul +Cc: neilc@samurai.com, markw@osdl.org, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +In-reply-to: <417697A5.1050600@colorfullife.com> +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <417697A5.1050600@colorfullife.com> +Comments: In-reply-to Manfred Spraul + message dated "Wed, 20 Oct 2004 18:51:49 +0200" +Date: Wed, 20 Oct 2004 13:15:35 -0400 +Message-ID: <7178.1098292535@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/325 +X-Sequence-Number: 8801 + +Manfred Spraul writes: +> Tom Lane wrote: +>> The bigger problem here is that the SMP locking bottlenecks we are +>> currently seeing are *hardware* issues (AFAICT anyway). The only way +>> that futexes can offer a performance win is if they have a smarter way +>> of executing the basic atomic-test-and-set sequence than we do; +>> +> lwlocks operations are not a basic atomic-test-and-set sequence. They +> are spinlock, several nonatomic operations, spin_unlock. + +Right, and it is the spinlock that is the problem. See discussions a +few months back: at least on Intel SMP machines, most of the problem +seems to have to do with trading the spinlock's cache line back and +forth between CPUs. It's difficult to see how a futex is going to avoid +that. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Oct 20 18:21:17 2004 +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 028B132A341 + for ; + Wed, 20 Oct 2004 18:21:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66940-04 + for ; + Wed, 20 Oct 2004 17:21:11 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F400E32A31C + for ; + Wed, 20 Oct 2004 18:21:11 +0100 (BST) +Received: from [134.22.69.212] (dyn-69-212.tor.dsl.tht.net [134.22.69.212]) + by tht.net (Postfix) with ESMTP + id 96D0B76BA8; Wed, 20 Oct 2004 13:21:13 -0400 (EDT) +Subject: Re: Insert performance, what should I expect? +From: Rod Taylor +To: Robert Creager +Cc: Brock Henry , + Postgresql Performance +In-Reply-To: <20041020104527.14927c06@thunder.mshome.net> +References: <97b3fe2041019185337a8c3d8@mail.gmail.com> + <1098238348.747.20.camel@home> + <20041020104527.14927c06@thunder.mshome.net> +Content-Type: text/plain +Message-Id: <1098292819.747.188.camel@home> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 20 Oct 2004 13:20:19 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/326 +X-Sequence-Number: 8802 + +On Wed, 2004-10-20 at 12:45, Robert Creager wrote: +> When grilled further on (Tue, 19 Oct 2004 22:12:28 -0400), +> Rod Taylor confessed: +> +> > > I've done some manual benchmarking running my script 'time script.pl' +> > > I realise my script uses some of the time, bench marking shows that +> > > %50 of the time is spent in dbd:execute. +> > > +> > 1) Drop DBD::Pg and switch to the Pg driver for Perl instead (non-DBI +> > compliant) which has functions similar to putline() that allow COPY to +> > be used. +> +> COPY can be used with DBD::Pg, per a script I use: +> +> $dbh->do( "COPY temp_obs_$band ( $col_list ) FROM stdin" ); +> $dbh->func( join ( "\t", @data ) . "\n", 'putline' ); +> $dbh->func( "\\.\n", 'putline' ); +> $dbh->func( 'endcopy' ); + +Thanks for that. All of the conversations I've seen on the subject +stated that DBD::Pg only supported standard DB features -- copy not +amongst them. + +> With sets of data from 1000 to 8000 records, my COPY performance is consistent +> at ~10000 records per second. + +Well done. + + + +From pgsql-performance-owner@postgresql.org Mon Oct 25 16:57:57 2004 +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 C431E329EC2 + for ; + Wed, 20 Oct 2004 18:39:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94125-09 + for ; + Wed, 20 Oct 2004 17:39:22 +0000 (GMT) +Received: from dbl.q-ag.de (dbl.q-ag.de [213.172.117.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 85BF832A17A + for ; + Wed, 20 Oct 2004 18:39:22 +0100 (BST) +Received: from [127.0.0.2] (dbl [127.0.0.1]) + by dbl.q-ag.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i9KHdDSL005028; + Wed, 20 Oct 2004 19:39:14 +0200 +Message-ID: <4176A2C1.3070205@colorfullife.com> +Date: Wed, 20 Oct 2004 19:39:13 +0200 +From: Manfred Spraul +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.7.3) Gecko/20040922 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: neilc@samurai.com, markw@osdl.org, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <417697A5.1050600@colorfullife.com> <7178.1098292535@sss.pgh.pa.us> +In-Reply-To: <7178.1098292535@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/413 +X-Sequence-Number: 8889 + +Tom Lane wrote: + +>Manfred Spraul writes: +> +> +>>Tom Lane wrote: +>> +>> +>>>The bigger problem here is that the SMP locking bottlenecks we are +>>>currently seeing are *hardware* issues (AFAICT anyway). The only way +>>>that futexes can offer a performance win is if they have a smarter way +>>>of executing the basic atomic-test-and-set sequence than we do; +>>> +>>> +>>> +>>lwlocks operations are not a basic atomic-test-and-set sequence. They +>>are spinlock, several nonatomic operations, spin_unlock. +>> +>> +> +>Right, and it is the spinlock that is the problem. See discussions a +>few months back: at least on Intel SMP machines, most of the problem +>seems to have to do with trading the spinlock's cache line back and +>forth between CPUs. +> +I'd disagree: cache line bouncing is one problem. If this happens then +there is only one solution: The number of changes to that cacheline must +be reduced. The tools that are used in the linux kernel are: +- hashing. An emergency approach if there is no other solution. I think +RedHat used it for the buffer cache RH AS: Instead of one buffer cache, +there were lots of smaller buffer caches with individual locks. The +cache was chosen based on the file position (probably mixed with some +pointers to avoid overloading cache 0). +- For read-heavy loads: sequence locks. A reader reads a counter value +and then accesses the data structure. At the end it checks if the +counter was modified. If it's still the same value then it can continue, +otherwise it must retry. Writers acquire a normal spinlock and then +modify the counter value. RCU is the second option, but there are +patents - please be careful before using that tool. +- complete rewrites that avoid the global lock. I think the global +buffer cache is now gone, everything is handled per-file. I think there +is a global list for buffer replacement, but the at the top of the +buffer replacement strategy is a simple clock algorithm. That means that +simple lookups/accesses just set a (local) referenced bit and don't have +to acquire a global lock. I know that this is the total opposite of ARC, +but perhaps it's the only scalable solution. ARC could be used as the +second level strategy. + +But: According to the descriptions the problem is a context switch +storm. I don't see that cache line bouncing can cause a context switch +storm. What causes the context switch storm? If it's the pg_usleep in +s_lock, then my patch should help a lot: with pthread_rwlock locks, this +line doesn't exist anymore. + +-- + Manfred + +From pgsql-performance-owner@postgresql.org Wed Oct 20 18:44:24 2004 +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 2EDBB329F1E + for ; + Wed, 20 Oct 2004 18:44:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36063-03 + for ; + Wed, 20 Oct 2004 17:44:14 +0000 (GMT) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id B12F2329F0C + for ; + Wed, 20 Oct 2004 18:44:13 +0100 (BST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id 0EB529029FB; Wed, 20 Oct 2004 10:50:39 -0700 (PDT) +Date: Wed, 20 Oct 2004 10:50:39 -0700 +From: Steve Atkins +To: POSTGRES-PERFORMANCE +Subject: Re: how much mem to give postgres? +Message-ID: <20041020175038.GA1339@gp.word-to-the-wise.com> +References: <4a0cafe2041019153133f854e9@mail.gmail.com> + <200410192223.24285.josh@agliodbs.com> + <4a0cafe204102006391f726a4f@mail.gmail.com> + <41767104.10702@ymogen.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <41767104.10702@ymogen.net> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/327 +X-Sequence-Number: 8803 + +On Wed, Oct 20, 2004 at 03:07:00PM +0100, Matt Clark wrote: + +> You turn it off in the BIOS. There is no 'other half', the processor is +> just pretending to have two cores by shuffling registers around, which +> gives maybe a 5-10% performance gain in certain multithreaded +> situations. + + +> A hack to overcome marchitactural limitations due +> to the overly long pipeline in the Prescott core.. Really of +> most use for desktop interactivity rather than actual throughput. + + +Hyperthreading is actually an excellent architectural feature that +can give significant performance gains when implemented well and used +for an appropriate workload under a decently HT aware OS. + +IMO, typical RDBMS streams are not an obviously appropriate workload, +Intel didn't implement it particularly well and I don't think there +are any OSes that support it particularly well. + + +But don't write off using it in the future, when it's been improved +at both the OS and the silicon levels. + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Wed Oct 20 19:16:33 2004 +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 EB0EC329F19 + for ; + Wed, 20 Oct 2004 19:16:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58685-01 + for ; + Wed, 20 Oct 2004 18:16:22 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 15AD8329EC2 + for ; + Wed, 20 Oct 2004 19:16:19 +0100 (BST) +Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk + [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP + id 4B10BA2EB2; Wed, 20 Oct 2004 19:16:19 +0100 (BST) +Message-ID: <4176AB72.6040101@ymogen.net> +Date: Wed, 20 Oct 2004 19:16:18 +0100 +From: Matt Clark +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Steve Atkins +Cc: POSTGRES-PERFORMANCE +Subject: Re: how much mem to give postgres? +References: <4a0cafe2041019153133f854e9@mail.gmail.com> + <200410192223.24285.josh@agliodbs.com> + <4a0cafe204102006391f726a4f@mail.gmail.com> + <41767104.10702@ymogen.net> + <20041020175038.GA1339@gp.word-to-the-wise.com> +In-Reply-To: <20041020175038.GA1339@gp.word-to-the-wise.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/328 +X-Sequence-Number: 8804 + + +> +>Hyperthreading is actually an excellent architectural feature that +>can give significant performance gains when implemented well and used +>for an appropriate workload under a decently HT aware OS. +> +>IMO, typical RDBMS streams are not an obviously appropriate workload, +>Intel didn't implement it particularly well and I don't think there +>are any OSes that support it particularly well. +> +> +>But don't write off using it in the future, when it's been improved +>at both the OS and the silicon levels. +> +> +> +You are quite right of course - unfortunately the current Intel +implementation meets nearly none of these criteria! As Rod Taylor +pointed out off-list, IBM's SMT implementation on the Power5 is vastly +superior. Though he's also just told me that Sun is beating IBM on +price/performance for his workload, so who knows how reliable a chap he +is... ;-) + +M + +From pgsql-performance-owner@postgresql.org Wed Oct 20 19:32:58 2004 +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 A5F9F32A341 + for ; + Wed, 20 Oct 2004 19:32:57 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63024-09 + for ; + Wed, 20 Oct 2004 18:32:55 +0000 (GMT) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BB0D32A1C9 + for ; + Wed, 20 Oct 2004 19:32:55 +0100 (BST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id 65E599029FB; Wed, 20 Oct 2004 11:39:22 -0700 (PDT) +Date: Wed, 20 Oct 2004 11:39:22 -0700 +From: Steve Atkins +To: POSTGRES-PERFORMANCE +Subject: Re: how much mem to give postgres? +Message-ID: <20041020183922.GB2120@gp.word-to-the-wise.com> +References: <4a0cafe2041019153133f854e9@mail.gmail.com> + <200410192223.24285.josh@agliodbs.com> + <4a0cafe204102006391f726a4f@mail.gmail.com> + <41767104.10702@ymogen.net> + <20041020175038.GA1339@gp.word-to-the-wise.com> + <4176AB72.6040101@ymogen.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4176AB72.6040101@ymogen.net> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/329 +X-Sequence-Number: 8805 + +On Wed, Oct 20, 2004 at 07:16:18PM +0100, Matt Clark wrote: +> > +> >Hyperthreading is actually an excellent architectural feature that +> >can give significant performance gains when implemented well and used +> >for an appropriate workload under a decently HT aware OS. +> > +> >IMO, typical RDBMS streams are not an obviously appropriate workload, +> >Intel didn't implement it particularly well and I don't think there +> >are any OSes that support it particularly well. +> > +> > +> >But don't write off using it in the future, when it's been improved +> >at both the OS and the silicon levels. +> > +> > +> > +> You are quite right of course - unfortunately the current Intel +> implementation meets nearly none of these criteria! + +Indeed. And when I said "no OSes support it particularly well" I meant +the x86 SMT implementation, rather than SMT in general. + +As Rod pointed out, AIX seems to have decent support and Power has a +very nice implementation, and the same is probably true for at least +one other OS/architecture implementation. + +> As Rod Taylor pointed out off-list, IBM's SMT implementation on the +> Power5 is vastly superior. Though he's also just told me that Sun +> is beating IBM on price/performance for his workload, so who knows +> how reliable a chap he is... ;-) + +:) + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Wed Oct 20 23:06:13 2004 +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 7DD0C32A165 + for ; + Wed, 20 Oct 2004 23:06:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56436-03 + for ; + Wed, 20 Oct 2004 22:05:59 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id D88F432A155 + for ; + Wed, 20 Oct 2004 23:05:57 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9KM5Sc10745; + Wed, 20 Oct 2004 15:05:28 -0700 +Date: Wed, 20 Oct 2004 15:05:28 -0700 +From: Mark Wong +To: Manfred Spraul +Cc: Tom Lane , neilc@samurai.com, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +Message-ID: <20041020150528.B7838@osdl.org> +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <417697A5.1050600@colorfullife.com> <7178.1098292535@sss.pgh.pa.us> + <4176A2C1.3070205@colorfullife.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +In-Reply-To: <4176A2C1.3070205@colorfullife.com>; + from manfred@colorfullife.com on Wed, Oct 20, 2004 at 07:39:13PM + +0200 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/330 +X-Sequence-Number: 8806 + +On Wed, Oct 20, 2004 at 07:39:13PM +0200, Manfred Spraul wrote: +> +> But: According to the descriptions the problem is a context switch +> storm. I don't see that cache line bouncing can cause a context switch +> storm. What causes the context switch storm? If it's the pg_usleep in +> s_lock, then my patch should help a lot: with pthread_rwlock locks, this +> line doesn't exist anymore. +> + +I gave Manfred's patch a try on my 4-way Xeon system with Tom's test_script.sql +files. I ran 4 processes of test_script.sql against 8.0beta3 (without any +patches) and from my observations with top, the cpu utilization between +processors was pretty erratic. They'd jump anywhere from 30% - 70%. + +With the futex patches that Neil and Gavin have been working on, I'd see +the processors evenly utilized at about 50% each. + +With just Manfred's patch I think there might be a problem somewhere with +the patch, or something else, as only one processor is doing anything at a +time and 100% utilized. + +Here are some other details, per Manfred's request: + +Linux 2.6.8.1 (on a gentoo distro) +gcc 3.3.4 +glibc 2.3.3.20040420 + +Mark + +From pgsql-performance-owner@postgresql.org Thu Oct 21 01:27:37 2004 +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 3BAE432A64E + for ; + Thu, 21 Oct 2004 01:27:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56381-10 + for ; + Thu, 21 Oct 2004 00:27:25 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 84D7732A569 + for ; + Thu, 21 Oct 2004 01:27:24 +0100 (BST) +Received: (qmail 17092 invoked from network); 21 Oct 2004 00:28:47 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 21 Oct 2004 00:28:47 -0000 +Message-ID: <41770285.5090604@fastcrypt.com> +Date: Wed, 20 Oct 2004 20:27:49 -0400 +From: Dave Cramer +Reply-To: pg@fastcrypt.com +Organization: Postgres International +User-Agent: Mozilla Thunderbird 0.8 (X11/20041001) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Manfred Spraul , neilc@samurai.com, + markw@osdl.org, pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <417697A5.1050600@colorfullife.com> <7178.1098292535@sss.pgh.pa.us> +In-Reply-To: <7178.1098292535@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/331 +X-Sequence-Number: 8807 + +Forgive my naivete, but do futex's implement some priority algorithm for +which process gets control. One of the problems as I understand it is +that linux does (did ) not implement a priority algorithm, so it is +possible for the context which just gave up control to be the next +context woken up, which of course is a complete waste of time. + +--dc-- + +Tom Lane wrote: + +>Manfred Spraul writes: +> +> +>>Tom Lane wrote: +>> +>> +>>>The bigger problem here is that the SMP locking bottlenecks we are +>>>currently seeing are *hardware* issues (AFAICT anyway). The only way +>>>that futexes can offer a performance win is if they have a smarter way +>>>of executing the basic atomic-test-and-set sequence than we do; +>>> +>>> +>>> +>>lwlocks operations are not a basic atomic-test-and-set sequence. They +>>are spinlock, several nonatomic operations, spin_unlock. +>> +>> +> +>Right, and it is the spinlock that is the problem. See discussions a +>few months back: at least on Intel SMP machines, most of the problem +>seems to have to do with trading the spinlock's cache line back and +>forth between CPUs. It's difficult to see how a futex is going to avoid +>that. +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> +> +> + +-- +Dave Cramer +www.postgresintl.com +519 939 0336 +ICQ#14675561 + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 01:28:28 2004 +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 20BCE32AEC8 + for ; + Thu, 21 Oct 2004 01:28:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57552-07 + for ; + Thu, 21 Oct 2004 00:28:13 +0000 (GMT) +Received: from smtp812.mail.sc5.yahoo.com (smtp812.mail.sc5.yahoo.com + [66.163.170.82]) + by svr1.postgresql.org (Postfix) with SMTP id B780432AE2C + for ; + Thu, 21 Oct 2004 01:28:11 +0100 (BST) +Received: from unknown (HELO ?192.168.0.2?) (jellej@pacbell.net@67.127.86.222 + with login) + by smtp812.mail.sc5.yahoo.com with SMTP; 21 Oct 2004 00:28:07 -0000 +Date: Wed, 20 Oct 2004 17:28:08 -0700 (PDT) +From: jelle +X-X-Sender: jelle@localhost.localdomain +Reply-To: jellej@pacbell.net +To: Postgresql Performance +Subject: iostat question +Message-ID: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/332 +X-Sequence-Number: 8808 + + +Hello All, + +I have an iostat question in that one of the raid arrays seems to act +differently than the other 3. Is this reasonable behavior for the +database or should I suspect a hardware or configuration problem? + +But first some background: +Postgresql 7.4.2 +Linux 2.4.20, 2GB RAM, 1-Xeon 2.4ghz with HT turned off +3Ware SATA RAID controller with 8 identical drives configured as 4 + RAID-1 spindles +64MB RAM disk + +postgresql.conf differences to postgresql.conf.sample: +tcpip_socket = true +max_connections = 128 +shared_buffers = 2048 +vacuum_mem = 16384 +max_fsm_pages = 50000 +wal_buffers = 128 +checkpoint_segments = 64 +effective_cache_size = 196000 +random_page_cost = 1 +default_statistics_target = 100 +stats_command_string = true +stats_block_level = true +stats_row_level = true + +The database is spread over 5 spindles: +/ram0 holds the busiest insert/update/delete table and assoc. indexes for + temporary session data +/sda5 holds the OS and most of the tables and indexes +/sdb2 holds the WAL +/sdc1 holds the 2nd busiest i/u/d table (70% of the writes) +/sdd1 holds the single index for that busy table on/sdc1 + +Lately we have 45 connections open from a python/psycopg connection pool. +99% of the reads are cached. +No swapping. + +And finally iostat reports: + +Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s +avgrq-sz avgqu-sz await svctm %util +/dev/sda5 0.01 3.32 0.01 0.68 0.16 32.96 0.08 16.48 +48.61 0.09 12.16 2.01 0.14 +/dev/sdb2 0.00 6.38 0.00 3.54 0.01 79.36 0.00 39.68 +22.39 0.12 3.52 1.02 0.36 +/dev/sdc1 0.03 0.13 0.00 0.08 0.27 1.69 0.13 0.84 +24.06 0.13 163.28 13.75 0.11 +/dev/sdd1 0.01 8.67 0.00 0.77 0.06 82.35 0.03 41.18 +107.54 0.09 10.51 2.76 0.21 + +The /sdc1's await seems awfully long compared to the rest to the stats. + +Jelle + + +-- + +http://www.sv650.org/audiovisual/loading_a_bike.mpeg +Osama-in-October office pool. + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 03:25:25 2004 +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 B35CC32ADC5 + for ; + Thu, 21 Oct 2004 03:25:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07802-02 + for ; + Thu, 21 Oct 2004 02:25:16 +0000 (GMT) +Received: from mail.ge-ts.com.hk (unknown [202.66.115.131]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B05932A4B0 + for ; + Thu, 21 Oct 2004 03:25:17 +0100 (BST) +Received: from raysiu ([172.16.96.15]) + by mail.ge-ts.com.hk (8.12.8/8.12.8) with SMTP id i9L2PGCh013233 + for ; Thu, 21 Oct 2004 10:25:17 +0800 +Message-ID: <069201c4b715$34851670$0f6010ac@raysiu> +From: "Ray" +To: +Subject: create index with substr function +Date: Thu, 21 Oct 2004 10:25:17 +0800 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_068F_01C4B758.4260C620" +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.5 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/333 +X-Sequence-Number: 8809 + +This is a multi-part message in MIME format. + +------=_NextPart_000_068F_01C4B758.4260C620 +Content-Type: text/plain; + charset="big5" +Content-Transfer-Encoding: quoted-printable + +Hi All, + +I have a table in my postgres: +Table: doc + Column | Type | Modifiers=20 + ---------------+-----------------------------+----------- + doc_id | bigint | not null + comp_grp_id | bigint | not null + doc_type | character varying(10)| not null + doc_urn | character varying(20)| not null + +I want to create an index on doc_urn column with using substr function like= + this: +CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree (SUBSTR(doc_urn,10)); + +but there is an error: + +ERROR: parser: parse error at or near "10" at character 68 + +what's wrong for this SQL? As I have found some reference on the internet, = +I can't find anything wrong in this SQL. + +Thanks +Ray= + +------=_NextPart_000_068F_01C4B758.4260C620 +Content-Type: text/html; + charset="big5" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi All,
+
 
+
I have a table in my postgres:
+
Table: doc
+
    =20 +Column    =20 +|           =20 +Type            = +; |=20 +Modifiers
    =20 +---------------+-----------------------------+-----------
 doc_id&n= +bsp;         |=20 +bigint           &nb= +sp;         =20 +| not null
 comp_grp_id |=20 +bigint           &nb= +sp;         =20 +| not null
 doc_type      | character= +=20 +varying(10)| not null
 doc_urn      &= +nbsp;=20 +| character varying(20)| not null
+
I want to create an index on doc_urn colum= +n with=20 +using substr function like this:
+
CREATE INDEX idx_doc_substr_doc_urn ON doc= + USING=20 +btree (SUBSTR(doc_urn,10));
+
 
+
but there is an error:
+

ERROR:  parser: parse error at or near "10" at character 68 +
 
+
what's wrong for this SQL? As I have found some reference on the inter= +net,=20 +I can't find anything wrong in this SQL.
+
 
+
Thanks
+
Ray
+ +------=_NextPart_000_068F_01C4B758.4260C620-- + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 06:12:22 2004 +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 7757D32B1E5 + for ; + Thu, 21 Oct 2004 06:12:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61307-02 + for ; + Thu, 21 Oct 2004 05:12:16 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C3FB32B18C + for ; + Thu, 21 Oct 2004 06:11:39 +0100 (BST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr4.postgresql.org (Postfix) with ESMTP id 857515AF563 + for ; + Thu, 21 Oct 2004 03:05:30 +0000 (GMT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 2B4F235B1F; Wed, 20 Oct 2004 19:57:54 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 29D1C35AF8; Wed, 20 Oct 2004 19:57:54 -0700 (PDT) +Date: Wed, 20 Oct 2004 19:57:54 -0700 (PDT) +From: Stephan Szabo +To: Ray +Cc: pgsql-performance@postgresql.org +Subject: Re: create index with substr function +In-Reply-To: <069201c4b715$34851670$0f6010ac@raysiu> +Message-ID: <20041020195604.T32588@megazone.bigpanda.com> +References: <069201c4b715$34851670$0f6010ac@raysiu> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/335 +X-Sequence-Number: 8811 + + +On Thu, 21 Oct 2004, Ray wrote: + +> Hi All, +> +> I have a table in my postgres: +> Table: doc +> Column | Type | Modifiers +> ---------------+-----------------------------+----------- +> doc_id | bigint | not null +> comp_grp_id | bigint | not null +> doc_type | character varying(10)| not null +> doc_urn | character varying(20)| not null +> +> I want to create an index on doc_urn column with using substr function like this: +> CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree (SUBSTR(doc_urn,10)); +> +> but there is an error: +> +> ERROR: parser: parse error at or near "10" at character 68 +> +> what's wrong for this SQL? As I have found some reference on the +> internet, I can't find anything wrong in this SQL. + +What version are you using? If you're using anything previous to 7.4 then +the above definately won't work and the only work around I know of is to +make another function which takes only the column argument and calls +substr with the 10 constant. + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 06:11:40 2004 +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 4393632B10F + for ; + Thu, 21 Oct 2004 06:11:38 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58206-07 + for ; + Thu, 21 Oct 2004 05:11:35 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C14C32B0DF + for ; + Thu, 21 Oct 2004 06:11:31 +0100 (BST) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr4.postgresql.org (Postfix) with ESMTP id 119D65AF423 + for ; + Thu, 21 Oct 2004 03:01:49 +0000 (GMT) +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 i9L2xEMF010775; + Wed, 20 Oct 2004 22:59:14 -0400 (EDT) +To: "Ray" +Cc: pgsql-performance@postgresql.org +Subject: Re: create index with substr function +In-reply-to: <069201c4b715$34851670$0f6010ac@raysiu> +References: <069201c4b715$34851670$0f6010ac@raysiu> +Comments: In-reply-to "Ray" + message dated "Thu, 21 Oct 2004 10:25:17 +0800" +Date: Wed, 20 Oct 2004 22:59:14 -0400 +Message-ID: <10774.1098327554@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/334 +X-Sequence-Number: 8810 + +"Ray" writes: +> CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree (SUBSTR(doc_urn,10)); +> ERROR: parser: parse error at or near "10" at character 68 + +This will work in 7.4, but not older releases. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Oct 21 06:12:22 2004 +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 44D0432B1EA + for ; + Thu, 21 Oct 2004 06:12:21 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61057-03 + for ; + Thu, 21 Oct 2004 05:12:15 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id 3769E32B1FB + for ; + Thu, 21 Oct 2004 06:11:41 +0100 (BST) +Received: from mail.ge-ts.com.hk (unknown [202.66.115.131]) + by svr4.postgresql.org (Postfix) with ESMTP id 9E8135AF5FC + for ; + Thu, 21 Oct 2004 03:13:08 +0000 (GMT) +Received: from raysiu ([172.16.96.15]) + by mail.ge-ts.com.hk (8.12.8/8.12.8) with SMTP id i9L3B5Ch013400 + for ; Thu, 21 Oct 2004 11:11:05 +0800 +Message-ID: <06e201c4b71b$9ae9cc70$0f6010ac@raysiu> +From: "Ray" +To: +References: <069201c4b715$34851670$0f6010ac@raysiu> + <20041020195604.T32588@megazone.bigpanda.com> +Subject: Re: create index with substr function +Date: Thu, 21 Oct 2004 11:11:05 +0800 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/336 +X-Sequence-Number: 8812 + +Thank you all kindly response..... : ) + +I am currently using postgres 7.3, so any example or solution for version +after 7.4 if i want to create an index with substr function??? + +Thanks, +Ray + + +----- Original Message ----- +From: "Stephan Szabo" +To: "Ray" +Cc: +Sent: Thursday, October 21, 2004 10:57 AM +Subject: Re: [PERFORM] create index with substr function + + +> +> On Thu, 21 Oct 2004, Ray wrote: +> +> > Hi All, +> > +> > I have a table in my postgres: +> > Table: doc +> > Column | Type | Modifiers +> > ---------------+-----------------------------+----------- +> > doc_id | bigint | not null +> > comp_grp_id | bigint | not null +> > doc_type | character varying(10)| not null +> > doc_urn | character varying(20)| not null +> > +> > I want to create an index on doc_urn column with using substr function +like this: +> > CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree +(SUBSTR(doc_urn,10)); +> > +> > but there is an error: +> > +> > ERROR: parser: parse error at or near "10" at character 68 +> > +> > what's wrong for this SQL? As I have found some reference on the +> > internet, I can't find anything wrong in this SQL. +> +> What version are you using? If you're using anything previous to 7.4 then +> the above definately won't work and the only work around I know of is to +> make another function which takes only the column argument and calls +> substr with the 10 constant. +> + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 06:44:53 2004 +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 B6FFF32AE15 + for ; + Thu, 21 Oct 2004 06:44:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70432-03 + for ; + Thu, 21 Oct 2004 05:44:48 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id EFCF932A7AD + for ; + Thu, 21 Oct 2004 06:44:48 +0100 (BST) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.203]) + by svr4.postgresql.org (Postfix) with ESMTP id 081775AF51C + for ; + Thu, 21 Oct 2004 03:36:55 +0000 (GMT) +Received: by mproxy.gmail.com with SMTP id 73so586619rnk + for ; + Wed, 20 Oct 2004 20:34:55 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; 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:references; + b=fMzchdGnZQLA9E1hUQqXxc18YROGwM8N3BApSyw2dQh6JOQNwBUPc/WY9wj2HPlq0ZL6ITUORNQ01zbjvnU9eM+jaQbm8KgSstH0vWquZb+XrJQ8zC/39P57MW3d1i57LuDsROQjoMDTfRuKJ+LrqVxT9vkN2r8egqjnWlkrWsg +Received: by 10.39.1.26 with SMTP id d26mr2874209rni; + Wed, 20 Oct 2004 20:34:55 -0700 (PDT) +Received: by 10.38.76.43 with HTTP; Wed, 20 Oct 2004 20:34:55 -0700 (PDT) +Message-ID: <37d451f704102020346fdbb855@mail.gmail.com> +Date: Wed, 20 Oct 2004 22:34:55 -0500 +From: Rosser Schwarz +Reply-To: Rosser Schwarz +To: Ray +Subject: Re: create index with substr function +Cc: pgsql-performance@postgresql.org +In-Reply-To: <069201c4b715$34851670$0f6010ac@raysiu> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <069201c4b715$34851670$0f6010ac@raysiu> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200410/337 +X-Sequence-Number: 8813 + +while you weren't looking, Ray wrote: + +> CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree (SUBSTR(doc_urn,10)); + +CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree ((SUBSTR(doc_urn,10))); + +You need an additional set of parens around the SUBSTR() call. + +/rls + +-- +:wq + +From pgsql-performance-owner@postgresql.org Thu Oct 21 06:45:24 2004 +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 DA1AC32AE59 + for ; + Thu, 21 Oct 2004 06:45:14 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71154-02 + for ; + Thu, 21 Oct 2004 05:45:09 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id EAA3E32AE41 + for ; + Thu, 21 Oct 2004 06:44:56 +0100 (BST) +Received: from mail.ge-ts.com.hk (unknown [202.66.115.131]) + by svr4.postgresql.org (Postfix) with ESMTP id B08555AF5D5 + for ; + Thu, 21 Oct 2004 03:40:56 +0000 (GMT) +Received: from raysiu ([172.16.96.15]) + by mail.ge-ts.com.hk (8.12.8/8.12.8) with SMTP id i9L3bPCh013589; + Thu, 21 Oct 2004 11:37:26 +0800 +Message-ID: <078b01c4b71f$4936e4e0$0f6010ac@raysiu> +From: "Ray" +To: "Rosser Schwarz" +Cc: +References: <069201c4b715$34851670$0f6010ac@raysiu> + <37d451f704102020346fdbb855@mail.gmail.com> +Subject: Re: create index with substr function +Date: Thu, 21 Oct 2004 11:37:26 +0800 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/338 +X-Sequence-Number: 8814 + +sorry it doesn't works, as my postgres is 7.3 not 7.4. any other alternative +solution for version after 7.4?? + +Thank +Ray : ) + +----- Original Message ----- +From: "Rosser Schwarz" +To: "Ray" +Cc: +Sent: Thursday, October 21, 2004 11:34 AM +Subject: Re: [PERFORM] create index with substr function + + +> while you weren't looking, Ray wrote: +> +> > CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree +(SUBSTR(doc_urn,10)); +> +> CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree +((SUBSTR(doc_urn,10))); +> +> You need an additional set of parens around the SUBSTR() call. +> +> /rls +> +> -- +> :wq +> + + +From pgsql-performance-owner@postgresql.org Mon Oct 25 16:57:49 2004 +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 E752032AEF5 + for ; + Thu, 21 Oct 2004 06:46:18 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71477-07 + for ; + Thu, 21 Oct 2004 05:46:14 +0000 (GMT) +Received: from dbl.q-ag.de (dbl.q-ag.de [213.172.117.3]) + by svr1.postgresql.org (Postfix) with ESMTP id D716732AE2A + for ; + Thu, 21 Oct 2004 06:46:09 +0100 (BST) +Received: from [127.0.0.2] (dbl [127.0.0.1]) + by dbl.q-ag.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i9L5jsSL029502; + Thu, 21 Oct 2004 07:45:55 +0200 +Message-ID: <41774D11.1030906@colorfullife.com> +Date: Thu, 21 Oct 2004 07:45:53 +0200 +From: Manfred Spraul +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.7.3) Gecko/20040922 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mark Wong +Cc: Tom Lane , neilc@samurai.com, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <417697A5.1050600@colorfullife.com> <7178.1098292535@sss.pgh.pa.us> + <4176A2C1.3070205@colorfullife.com> <20041020150528.B7838@osdl.org> +In-Reply-To: <20041020150528.B7838@osdl.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/412 +X-Sequence-Number: 8888 + +Mark Wong wrote: + +>Here are some other details, per Manfred's request: +> +>Linux 2.6.8.1 (on a gentoo distro) +> +> +How complicated are Tom's test scripts? His immediate reply was that I +should retest with Fedora, to rule out any gentoo bugs. + +I have a dual-cpu system with RH FC, I could use it for testing. + +-- + Manfred + +From pgsql-performance-owner@postgresql.org Thu Oct 21 07:19:05 2004 +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 6E5E832AD91 + for ; + Thu, 21 Oct 2004 07:19:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80409-02 + for ; + Thu, 21 Oct 2004 06:18:59 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id DE07132A849 + for ; + Thu, 21 Oct 2004 07:18:59 +0100 (BST) +Received: from [192.168.1.20] (clbb-248.saw.net [64.146.135.248]) + (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i9L6FRD07936; + Wed, 20 Oct 2004 23:15:27 -0700 +Message-ID: <4177538C.7010900@commandprompt.com> +Date: Wed, 20 Oct 2004 23:13:32 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Ray , pgsql-performance@postgresql.org +Subject: Re: create index with substr function +References: <069201c4b715$34851670$0f6010ac@raysiu> + <10774.1098327554@sss.pgh.pa.us> +In-Reply-To: <10774.1098327554@sss.pgh.pa.us> +Content-Type: multipart/alternative; + boundary="------------080507080403000504090501" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=HTML_20_30, + HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: * +X-Archive-Number: 200410/339 +X-Sequence-Number: 8815 + +This is a multi-part message in MIME format. +--------------080507080403000504090501 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>"Ray" writes: +> +> +>>CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree (SUBSTR(doc_urn,10)); +>>ERROR: parser: parse error at or near "10" at character 68 +>> +>> +> +>This will work in 7.4, but not older releases. +> +> +> +Can't you just use a SQL function that calls the substr function? I have +done that with date functions before +like: + +CREATE OR REPLACE FUNCTION get_month(text) returns double precision AS ' + SELECT date_part('month',$1); +' LANGUAGE 'SQL' IMMUTABLE; + +CREATE INDEX get_month_idx on foo(get_month(date_field)); + +Or in this case: + +CREATE OR REPLACE FUNCTION sub_text(text) returns text AS ' + SELECT SUBSTR($1,10) from foo; +' LANGUAGE 'SQL' IMMUTABLE; + +CREATE INDEX sub_text_idx ON foo(sub_text(doc_urn)); + +This works on 7.3.6??? + +Sincerely, + +Joshua D. Drake + + + + +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 7: don't forget to increase your free space map settings +> +> + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL + + +--------------080507080403000504090501 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Tom Lane wrote:
+
+
"Ray" <ray_siu@ge-ts.com.hk> writes:
+  
+
+
CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree (SUBSTR(doc_urn,10));
+ERROR:  parser: parse error at or near "10" at character 68
+    
+
+

+This will work in 7.4, but not older releases.
+
+  
+
+Can't you just use a SQL function that calls the substr function? I +have done that with date functions before
+like:
+
CREATE OR REPLACE FUNCTION get_month(text) returns double precision AS '
+   SELECT date_part('month',$1);
+' LANGUAGE 'SQL' IMMUTABLE;
+
+CREATE INDEX get_month_idx on foo(get_month(date_field));
+Or in this case:
+
+CREATE OR REPLACE FUNCTION sub_text(text) returns text AS '
+      SELECT SUBSTR($1,10) from foo;
+' LANGUAGE 'SQL' IMMUTABLE;
+
+CREATE INDEX sub_text_idx ON foo(sub_text(doc_urn));
+
+This works on 7.3.6???
+
+Sincerely,
+
+Joshua D. Drake
+
+
+
+
+
+
			regards, tom lane
+
+---------------------------(end of broadcast)---------------------------
+TIP 7: don't forget to increase your free space map settings
+  
+
+
+
+
-- 
+Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
+Postgresql support, programming shared hosting and dedicated hosting.
++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
+PostgreSQL Replicator -- production quality replication for PostgreSQL
+ + + +--------------080507080403000504090501-- + +From pgsql-performance-owner@postgresql.org Thu Oct 21 08:58:23 2004 +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 A292B32AE3A + for ; + Thu, 21 Oct 2004 08:58:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12997-07 + for ; + Thu, 21 Oct 2004 07:58:03 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 8FA0332A0C3 + for ; + Thu, 21 Oct 2004 08:58:03 +0100 (BST) +Received: from solent (unknown [213.165.136.10]) + by bayswater1.ymogen.net (Postfix) with ESMTP id 80325A39CA + for ; + Thu, 21 Oct 2004 08:58:01 +0100 (BST) +Reply-To: +From: "Matt Clark" +To: +Subject: Anything to be gained from a 'Postgres Filesystem'? +Date: Thu, 21 Oct 2004 08:58:01 +0100 +Organization: Ymogen Ltd +Message-ID: <008601c4b743$aff57f10$8300a8c0@solent> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/340 +X-Sequence-Number: 8816 + +I suppose I'm just idly wondering really. Clearly it's against PG +philosophy to build an FS or direct IO management into PG, but now it's so +relatively easy to plug filesystems into the main open-source Oses, It +struck me that there might be some useful changes to, say, XFS or ext3, that +could be made that would help PG out. + +I'm thinking along the lines of an FS that's aware of PG's strategies and +requirements and therefore optimised to make those activities as efiicient +as possible - possibly even being aware of PG's disk layout and treating +files differently on that basis. + +Not being an FS guru I'm not really clear on whether this would help much +(enough to be worth it anyway) or not - any thoughts? And if there were +useful gains to be had, would it need a whole new FS or could an existing +one be modified? + +So there might be (as I said, I'm not an FS guru...): +* great append performance for the WAL? +* optimised scattered writes for checkpointing? +* Knowledge that FSYNC is being used for preserving ordering a lot of the +time, rather than requiring actual writes to disk (so long as the writes +eventually happen in order...)? + + +Matt + + + +Matt Clark +Ymogen Ltd +P: 0845 130 4531 +W: https://ymogen.net/ +M: 0774 870 1584 +=20 + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 09:24:31 2004 +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 5F221329E7D + for ; + Thu, 21 Oct 2004 09:24:26 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20410-10 + for ; + Thu, 21 Oct 2004 08:24:05 +0000 (GMT) +Received: from mailer.unicite.fr.netcentrex.net (unknown [62.161.167.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 7275F329E5C + for ; + Thu, 21 Oct 2004 09:24:05 +0100 (BST) +Received: from akira ([192.168.101.228]) by mailer.unicite.fr.netcentrex.net + with SMTP (Microsoft Exchange Internet Mail Service Version + 5.5.2657.72) id 42CYASGM; Thu, 21 Oct 2004 10:24:04 +0200 +From: "Alban Medici (NetCentrex)" +To: +Subject: Re: Free PostgreSQL Training, Philadelphia, Oct 30 +Date: Thu, 21 Oct 2004 10:24:04 +0200 +Organization: NetCentrex +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +In-Reply-To: +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Thread-Index: AcS2pMduY5IzJ7+sSdSL6SqR98shiQAomPOg +Message-Id: <20041021082405.7275F329E5C@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/341 +X-Sequence-Number: 8817 + +Nobody got a plane to came from europe :-) ??? +As a poor frenchie I will not come ... +Have a good time + +Alban + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Aaron Mulder +Sent: mercredi 20 octobre 2004 15:11 +To: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Free PostgreSQL Training, Philadelphia, Oct 30 + + If anyone is going to take the train all the way, please e-mail me +offline. There is a train station relatively close to the event (NY to +Philly then the R5 to Malvern), but it's not within walking distance, so +we'll figure out some way to pick people up from there. + +Thanks, + Aaron + +On Wed, 20 Oct 2004, Aaron Werman wrote: +> I'm driving from Tenafly NJ and going to both sessions. If you're able +> to get to the George Washington Bridge (A train to 178th Street [Port +> Authority North] and a bus over the bridge), I can drive you down. I'm +> not sure right now about the return because I have confused plans to +> meet someone. +> +> /Aaron +> +> +> On Tue, 19 Oct 2004 14:43:29 -0400, Max Baker wrote: +> > On Wed, Oct 13, 2004 at 12:21:27PM -0400, Aaron Mulder wrote: +> > > All, +> > > My company (Chariot Solutions) is sponsoring a day of free +> > > PostgreSQL training by Bruce Momjian (one of the core PostgreSQL +> > > developers). The day is split into 2 sessions (plus a Q&A session): +> > > +> > > * Mastering PostgreSQL Administration +> > > * PostgreSQL Performance Tuning +> > > +> > > Registration is required, and space is limited. The +> > > location is Malvern, PA (suburb of Philadelphia) and it's on +> > > Saturday Oct 30. For more information or to register, see +> > > +> > > http://chariotsolutions.com/postgresql.jsp +> > +> > I'm up in New York City and would be taking the train down to +> > Philly. Is anyone coming from Philly or New York that would be able +> > to give me a lift to/from the train station? Sounds like a great event. +> > +> > Cheers, +> > -m +> > +> > ---------------------------(end of +> > broadcast)--------------------------- +> > TIP 3: if posting/reading through Usenet, please send an appropriate +> > subscribe-nomail command to majordomo@postgresql.org so that your +> > message can get through to the mailing list cleanly +> > +> +> +> -- +> +> Regards, +> /Aaron +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> + +---------------------------(end of broadcast)--------------------------- +TIP 6: Have you searched our list archives? + + http://archives.postgresql.org + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 09:27:46 2004 +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 ACBB032A056 + for ; + Thu, 21 Oct 2004 09:27:44 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24856-02 + for ; + Thu, 21 Oct 2004 08:27:41 +0000 (GMT) +Received: from usbb-lacimss2.unisys.com (usbb-lacimss2.unisys.com + [192.63.108.52]) + by svr1.postgresql.org (Postfix) with ESMTP id 09B81329FB2 + for ; + Thu, 21 Oct 2004 09:27:41 +0100 (BST) +Received: from usbb-lacgw2.lac.uis.unisys.com ([129.226.160.22]unverified) by + usbb-lacimss2 with InterScan Messaging Security Suite; + Thu, 21 Oct 2004 04:30:55 -0400 +Received: from usbb-lacgw2.lac.uis.unisys.com ([129.226.160.25]) by + usbb-lacgw2.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); + Thu, 21 Oct 2004 04:27:40 -0400 +Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by + usbb-lacgw2.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); + Thu, 21 Oct 2004 04:27:39 -0400 +Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by + gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.47); + Thu, 21 Oct 2004 09:27:24 +0100 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +Date: Thu, 21 Oct 2004 10:27:22 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Anything to be gained from a 'Postgres Filesystem'? +Thread-Index: AcS3RRCYZb82zgd2TRuDst9A9MylTQAAmKLw +From: "Leeuw van der, Tim" +To: , +X-OriginalArrivalTime: 21 Oct 2004 08:27:24.0229 (UTC) + FILETIME=[CA912F50:01C4B747] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/342 +X-Sequence-Number: 8818 + +Hiya, + +Looking at that list, I got the feeling that you'd want to push that PG-awa= +reness down into the block-io layer as well, then, so as to be able to opti= +mise for (perhaps) conflicting goals depending on what the app does; for th= +e IO system to be able to read the apps mind it needs to have some knowledg= +e of what the app is / needs / wants and I get the impression that this awa= +reness needs to go deeper than the FS only. + +--Tim + +(But you might have time to rewrite Linux/BSD as a PG-OS? just kidding!) + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owne= +r@postgresql.org]On Behalf Of Matt Clark +Sent: Thursday, October 21, 2004 9:58 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] Anything to be gained from a 'Postgres Filesystem'? + + +I suppose I'm just idly wondering really. Clearly it's against PG +philosophy to build an FS or direct IO management into PG, but now it's so +relatively easy to plug filesystems into the main open-source Oses, It +struck me that there might be some useful changes to, say, XFS or ext3, that +could be made that would help PG out. + +I'm thinking along the lines of an FS that's aware of PG's strategies and +requirements and therefore optimised to make those activities as efiicient +as possible - possibly even being aware of PG's disk layout and treating +files differently on that basis. + +Not being an FS guru I'm not really clear on whether this would help much +(enough to be worth it anyway) or not - any thoughts? And if there were +useful gains to be had, would it need a whole new FS or could an existing +one be modified? + +So there might be (as I said, I'm not an FS guru...): +* great append performance for the WAL? +* optimised scattered writes for checkpointing? +* Knowledge that FSYNC is being used for preserving ordering a lot of the +time, rather than requiring actual writes to disk (so long as the writes +eventually happen in order...)? + + +Matt + + + +Matt Clark +Ymogen Ltd +P: 0845 130 4531 +W: https://ymogen.net/ +M: 0774 870 1584 +=20 + + +---------------------------(end of broadcast)--------------------------- +TIP 2: you can get off all lists at once with the unregister command + (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + +From pgsql-performance-owner@postgresql.org Thu Oct 21 09:32:52 2004 +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 EACCA32A03C + for ; + Thu, 21 Oct 2004 09:32:50 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27321-03 + for ; + Thu, 21 Oct 2004 08:32:45 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 0497732A026 + for ; + Thu, 21 Oct 2004 09:32:46 +0100 (BST) +Received: (qmail 6706 invoked from network); 21 Oct 2004 10:32:47 +0200 +Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) + by boutiquenumerique.com with SMTP; 21 Oct 2004 10:32:47 +0200 +To: matt@ymogen.net, pgsql-performance@postgresql.org +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +References: <008601c4b743$aff57f10$8300a8c0@solent> +Message-ID: +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: Thu, 21 Oct 2004 10:33:31 +0200 +In-Reply-To: <008601c4b743$aff57f10$8300a8c0@solent> +User-Agent: Opera M2/7.54 (Linux, build 751) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/343 +X-Sequence-Number: 8819 + + + Reiser4 ? + +On Thu, 21 Oct 2004 08:58:01 +0100, Matt Clark wrote: + +> I suppose I'm just idly wondering really. Clearly it's against PG +> philosophy to build an FS or direct IO management into PG, but now it's +> so +> relatively easy to plug filesystems into the main open-source Oses, It +> struck me that there might be some useful changes to, say, XFS or ext3, +> that +> could be made that would help PG out. +> +> I'm thinking along the lines of an FS that's aware of PG's strategies and +> requirements and therefore optimised to make those activities as +> efiicient +> as possible - possibly even being aware of PG's disk layout and treating +> files differently on that basis. +> +> Not being an FS guru I'm not really clear on whether this would help much +> (enough to be worth it anyway) or not - any thoughts? And if there were +> useful gains to be had, would it need a whole new FS or could an existing +> one be modified? +> +> So there might be (as I said, I'm not an FS guru...): +> * great append performance for the WAL? +> * optimised scattered writes for checkpointing? +> * Knowledge that FSYNC is being used for preserving ordering a lot of the +> time, rather than requiring actual writes to disk (so long as the writes +> eventually happen in order...)? +> +> +> Matt +> +> +> +> Matt Clark +> Ymogen Ltd +> P: 0845 130 4531 +> W: https://ymogen.net/ +> M: 0774 870 1584 +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 09:38:53 2004 +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 7BE3D329E65 + for ; + Thu, 21 Oct 2004 09:38:52 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25984-08 + for ; + Thu, 21 Oct 2004 08:38:41 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B53F32A0F7 + for ; + Thu, 21 Oct 2004 09:38:41 +0100 (BST) +Received: from solent (unknown [213.165.136.10]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id 029CBA37B2; Thu, 21 Oct 2004 09:38:41 +0100 (BST) +Reply-To: +From: "Matt Clark" +To: "'Leeuw van der, Tim'" , + +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +Date: Thu, 21 Oct 2004 09:38:40 +0100 +Organization: Ymogen Ltd +Message-ID: <008b01c4b749$5e0862c0$8300a8c0@solent> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +In-Reply-To: + +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/344 +X-Sequence-Number: 8820 + +> Looking at that list, I got the feeling that you'd want to +> push that PG-awareness down into the block-io layer as well, +> then, so as to be able to optimise for (perhaps) conflicting +> goals depending on what the app does; for the IO system to be +> able to read the apps mind it needs to have some knowledge of +> what the app is / needs / wants and I get the impression that +> this awareness needs to go deeper than the FS only. + +That's a fair point, it would need be a kernel patch really, although not +necessarily a very big one, more a case of looking at FDs and if they're +flagged in some way then get the PGfs to do the job instead of/as well as +the normal code path. + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 11:27:32 2004 +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 40ACA32A10E + for ; + Thu, 21 Oct 2004 11:27:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55557-09 + for ; + Thu, 21 Oct 2004 10:27:28 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id C442932A0A1 + for ; + Thu, 21 Oct 2004 11:27:29 +0100 (BST) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1CKaAJ-0000BO-00 + for ; Thu, 21 Oct 2004 12:27:27 +0200 +Date: Thu, 21 Oct 2004 12:27:27 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +Message-ID: <20041021102727.GB586@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <008601c4b743$aff57f10$8300a8c0@solent> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <008601c4b743$aff57f10$8300a8c0@solent> +X-Operating-System: Linux 2.6.8.1 on a i686 +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/345 +X-Sequence-Number: 8821 + +On Thu, Oct 21, 2004 at 08:58:01AM +0100, Matt Clark wrote: +> I suppose I'm just idly wondering really. Clearly it's against PG +> philosophy to build an FS or direct IO management into PG, but now it's so +> relatively easy to plug filesystems into the main open-source Oses, It +> struck me that there might be some useful changes to, say, XFS or ext3, that +> could be made that would help PG out. + +This really sounds like a poor replacement for just making PostgreSQL use raw +devices to me. (I have no idea why that isn't done already, but presumably it +isn't all that easy to get right. :-) ) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu Oct 21 11:44:29 2004 +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 6B3A632A10E + for ; + Thu, 21 Oct 2004 11:44:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58400-10 + for ; + Thu, 21 Oct 2004 10:44:25 +0000 (GMT) +Received: from usbb-lacimss3.unisys.com (usbb-lacimss3.unisys.com + [192.63.108.53]) + by svr1.postgresql.org (Postfix) with ESMTP id C2BF932A0E5 + for ; + Thu, 21 Oct 2004 11:44:24 +0100 (BST) +Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.43]unverified) by + usbb-lacimss3 with InterScan Messaging Security Suite; + Thu, 21 Oct 2004 06:48:08 -0400 +Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.44]) by + USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); + Thu, 21 Oct 2004 06:44:13 -0400 +Received: from gbmk-eugw1.eu.uis.unisys.com ([129.221.133.28]) by + USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); + Thu, 21 Oct 2004 06:44:13 -0400 +Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by + gbmk-eugw1.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.47); + Thu, 21 Oct 2004 11:44:11 +0100 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +Date: Thu, 21 Oct 2004 12:44:10 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Anything to be gained from a 'Postgres Filesystem'? +Thread-Index: AcS3WWQJaLJXjRM2RjW9o2B6un6TMAAAFA8g +From: "Leeuw van der, Tim" +To: "Steinar H. Gunderson" , + +X-OriginalArrivalTime: 21 Oct 2004 10:44:11.0592 (UTC) + FILETIME=[E6896480:01C4B75A] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/346 +X-Sequence-Number: 8822 + +Hi, + +I guess the difference is in 'severe hacking inside PG' vs. 'some unknown a= +mount of hacking that doesn't touch PG code'. + +Hacking PG internally to handle raw devices will meet with strong resistanc= +e from large portions of the development team. I don't expect (m)any core d= +evs of PG will be excited about rewriting the entire I/O architecture of PG= + and duplicating large amounts of OS type of code inside the application, j= +ust to try to attain an unknown performance benefit. + +PG doesn't use one big file, as some databases do, but many small files. No= +w PG would need to be able to do file-management, if you put the PG databas= +e on a raw disk partition! That's icky stuff, and you'll find much resistan= +ce against putting such code inside PG. +So why not try to have the external FS know a bit about PG and it's directo= +ry-layout, and it's IO requirements? Then such type of code can at least be= + maintained outside the application, and will not be as much of a burden to= + the rest of the application. + +(I'm not sure if it's a good idea to create a PG-specific FS in your OS of = +choice, but it's certainly gonna be easier than getting FS code inside of P= +G) + +cheers, + +--Tim + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owne= +r@postgresql.org]On Behalf Of Steinar H. Gunderson +Sent: Thursday, October 21, 2004 12:27 PM +To: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Anything to be gained from a 'Postgres Filesystem'? + + +On Thu, Oct 21, 2004 at 08:58:01AM +0100, Matt Clark wrote: +> I suppose I'm just idly wondering really. Clearly it's against PG +> philosophy to build an FS or direct IO management into PG, but now it's so +> relatively easy to plug filesystems into the main open-source Oses, It +> struck me that there might be some useful changes to, say, XFS or ext3, t= +hat +> could be made that would help PG out. + +This really sounds like a poor replacement for just making PostgreSQL use r= +aw +devices to me. (I have no idea why that isn't done already, but presumably = +it +isn't all that easy to get right. :-) ) + +/* Steinar */ +--=20 +Homepage: http://www.sesse.net/ + +---------------------------(end of broadcast)--------------------------- +TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + +From pgsql-performance-owner@postgresql.org Thu Oct 21 12:47:18 2004 +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 05C3B32A165 + for ; + Thu, 21 Oct 2004 12:47:18 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78512-07 + for ; + Thu, 21 Oct 2004 11:47:13 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.200]) + by svr1.postgresql.org (Postfix) with ESMTP id EC72532A15F + for ; + Thu, 21 Oct 2004 12:47:15 +0100 (BST) +Received: by rproxy.gmail.com with SMTP id 73so9646rnk + for ; + Thu, 21 Oct 2004 04:47:15 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=a4IEXvhcEt0imSl9ZsbCTf8czV2q5PhOPRzhQea50sB2IOftrF7HeZjxJXhFlJqZN0uRess89681a6MFLMIDGBdc5by13poSIeAa8RVpn4R6wiRpk2dlx3PUc0NU5pi0QITqfymm+rZaTICkf5fHqUCGerAptjLoI4dh/3AiN8M= +Received: by 10.39.1.26 with SMTP id d26mr3033814rni; + Thu, 21 Oct 2004 04:47:14 -0700 (PDT) +Received: by 10.38.151.75 with HTTP; Thu, 21 Oct 2004 04:47:14 -0700 (PDT) +Message-ID: <157f6484041021044720eb7520@mail.gmail.com> +Date: Thu, 21 Oct 2004 07:47:14 -0400 +From: Aaron Werman +Reply-To: Aaron Werman +To: "Leeuw van der, Tim" +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +Cc: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +In-Reply-To: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/347 +X-Sequence-Number: 8823 + +The intuitive thing would be to put pg into a file system. + +/Aaron + +On Thu, 21 Oct 2004 12:44:10 +0200, Leeuw van der, Tim + wrote: +> Hi, +> +> I guess the difference is in 'severe hacking inside PG' vs. 'some unknown amount of hacking that doesn't touch PG code'. +> +> Hacking PG internally to handle raw devices will meet with strong resistance from large portions of the development team. I don't expect (m)any core devs of PG will be excited about rewriting the entire I/O architecture of PG and duplicating large amounts of OS type of code inside the application, just to try to attain an unknown performance benefit. +> +> PG doesn't use one big file, as some databases do, but many small files. Now PG would need to be able to do file-management, if you put the PG database on a raw disk partition! That's icky stuff, and you'll find much resistance against putting such code inside PG. +> So why not try to have the external FS know a bit about PG and it's directory-layout, and it's IO requirements? Then such type of code can at least be maintained outside the application, and will not be as much of a burden to the rest of the application. +> +> (I'm not sure if it's a good idea to create a PG-specific FS in your OS of choice, but it's certainly gonna be easier than getting FS code inside of PG) +> +> cheers, +> +> --Tim +> +> +> +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Steinar H. Gunderson +> Sent: Thursday, October 21, 2004 12:27 PM +> To: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Anything to be gained from a 'Postgres Filesystem'? +> +> On Thu, Oct 21, 2004 at 08:58:01AM +0100, Matt Clark wrote: +> > I suppose I'm just idly wondering really. Clearly it's against PG +> > philosophy to build an FS or direct IO management into PG, but now it's so +> > relatively easy to plug filesystems into the main open-source Oses, It +> > struck me that there might be some useful changes to, say, XFS or ext3, that +> > could be made that would help PG out. +> +> This really sounds like a poor replacement for just making PostgreSQL use raw +> devices to me. (I have no idea why that isn't done already, but presumably it +> isn't all that easy to get right. :-) ) +> +> /* Steinar */ +> -- +> Homepage: http://www.sesse.net/ +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> + + +-- + +Regards, +/Aaron + +From pgsql-performance-owner@postgresql.org Thu Oct 21 13:02:14 2004 +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 7974A32B15F + for ; + Thu, 21 Oct 2004 13:02:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85403-09 + for ; + Thu, 21 Oct 2004 12:01:58 +0000 (GMT) +Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) + by svr1.postgresql.org (Postfix) with ESMTP id D7C7F32B181 + for ; + Thu, 21 Oct 2004 13:01:58 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by sue.samurai.com (Postfix) with ESMTP id 13140197FB; + Thu, 21 Oct 2004 08:01:58 -0400 (EDT) +Received: from sue.samurai.com ([127.0.0.1]) + by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 56250-01-6; Thu, 21 Oct 2004 08:01:57 -0400 (EDT) +Received: from [220.101.3.10] (r220-101-3-10.cpe.unwired.net.au + [220.101.3.10]) + by sue.samurai.com (Postfix) with ESMTP id EC516197F0; + Thu, 21 Oct 2004 08:01:55 -0400 (EDT) +Message-ID: <4177A538.5070002@samurai.com> +Date: Thu, 21 Oct 2004 22:02:00 +1000 +From: Neil Conway +User-Agent: Mozilla Thunderbird 0.8 (Macintosh/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: matt@ymogen.net +Cc: pgsql-performance@postgresql.org +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +References: <008601c4b743$aff57f10$8300a8c0@solent> +In-Reply-To: <008601c4b743$aff57f10$8300a8c0@solent> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/348 +X-Sequence-Number: 8824 + +Matt Clark wrote: +> I'm thinking along the lines of an FS that's aware of PG's strategies and +> requirements and therefore optimised to make those activities as efiicient +> as possible - possibly even being aware of PG's disk layout and treating +> files differently on that basis. + +As someone else noted, this doesn't belong in the filesystem (rather the +kernel's block I/O layer/buffer cache). But I agree, an API by which we +can tell the kernel what kind of I/O behavior to expect would be good. +The kernel needs to provide good behavior for a wide range of +applications, but the DBMS can take advantage of a lot of +domain-specific information. In theory, being able to pass that +domain-specific information on to the kernel would mean we could get +better performance without needing to reimplement large chunks of +functionality that really ought to be done by the kernel anyway (as +implementing raw I/O would require, for example). On the other hand, it +would probably mean adding a fair bit of OS-specific hackery, which +we've largely managed to avoid in the past. + +The closest API to what you're describing that I'm aware of is +posix_fadvise(). While that is technically-speaking a POSIX standard, it +is not widely implemented (I know Linux 2.6 implements it; based on some +quick googling, it looks like AIX does too). Using posix_fadvise() has +been discussed in the past, so you might want to search the archives. We +could use FADV_SEQUENTIAL to request more aggressive readahead on a file +that we know we're about to sequentially scan. We might be able to use +FADV_NOREUSE on the WAL. We might be able to get away with specifying +FADV_RANDOM for indexes all of the time, or at least most of the time. +One question is how this would interact with concurrent access (AFAICS +there is no way to fetch the "current advice" on an fd...) + +Also, I would imagine Win32 provides some means to inform the kernel +about your expected I/O pattern, but I haven't checked. Does anyone know +of any other relevant APIs? + +-Neil + +From pgsql-performance-owner@postgresql.org Thu Oct 21 14:45:21 2004 +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 DA92432A138 + for ; + Thu, 21 Oct 2004 14:45:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19314-05 + for ; + Thu, 21 Oct 2004 13:45:07 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id A009332A11C + for ; + Thu, 21 Oct 2004 14:45:08 +0100 (BST) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1CKdFa-0000Rs-00 + for ; Thu, 21 Oct 2004 15:45:06 +0200 +Date: Thu, 21 Oct 2004 15:45:06 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +Message-ID: <20041021134506.GA1667@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: + +X-Operating-System: Linux 2.6.8.1 on a i686 +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/349 +X-Sequence-Number: 8825 + +On Thu, Oct 21, 2004 at 12:44:10PM +0200, Leeuw van der, Tim wrote: +> Hacking PG internally to handle raw devices will meet with strong +> resistance from large portions of the development team. I don't expect +> (m)any core devs of PG will be excited about rewriting the entire I/O +> architecture of PG and duplicating large amounts of OS type of code inside +> the application, just to try to attain an unknown performance benefit. + +Well, at least I see people claiming >30% difference between different file +systems, but no, I'm not shouting "bah, you'd better do this or I'll warez +Oracle" :-) I have no idea how much you can improve over the "best" +filesystems out there, but having two layers of journalling (both WAL _and_ +FS journalling) on top of each other don't make all that much sense to me. +:-) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu Oct 21 14:55:20 2004 +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 1879232B17C + for ; + Thu, 21 Oct 2004 14:55:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23358-04 + for ; + Thu, 21 Oct 2004 13:55:14 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E2D032A263 + for ; + Thu, 21 Oct 2004 14:55:15 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9LDswG02355; + Thu, 21 Oct 2004 06:54:58 -0700 +Date: Thu, 21 Oct 2004 06:54:58 -0700 +From: Mark Wong +To: Manfred Spraul +Cc: Tom Lane , neilc@samurai.com, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +Message-ID: <20041021065458.A5580@osdl.org> +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <417697A5.1050600@colorfullife.com> <7178.1098292535@sss.pgh.pa.us> + <4176A2C1.3070205@colorfullife.com> <20041020150528.B7838@osdl.org> + <41774D11.1030906@colorfullife.com> +Mime-Version: 1.0 +Content-Type: multipart/mixed; boundary="sdtB3X0nJg68CQEu" +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +In-Reply-To: <41774D11.1030906@colorfullife.com>; + from manfred@colorfullife.com on Thu, Oct 21, 2004 at 07:45:53AM + +0200 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/350 +X-Sequence-Number: 8826 + +--sdtB3X0nJg68CQEu +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline + +On Thu, Oct 21, 2004 at 07:45:53AM +0200, Manfred Spraul wrote: +> Mark Wong wrote: +> +> >Here are some other details, per Manfred's request: +> > +> >Linux 2.6.8.1 (on a gentoo distro) +> > +> > +> How complicated are Tom's test scripts? His immediate reply was that I +> should retest with Fedora, to rule out any gentoo bugs. +> +> I have a dual-cpu system with RH FC, I could use it for testing. +> + +Pretty, simple. One to load the database, and 1 to query it. I'll +attach them. + +Mark + +--sdtB3X0nJg68CQEu +Content-Type: text/plain; charset=us-ascii +Content-Disposition: attachment; filename="test_createscript.sql" + +drop table test_data; + +create table test_data(f1 int); + +insert into test_data values (random() * 100); +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; +insert into test_data select random() * 100 from test_data; + +create index test_index on test_data(f1); + +vacuum verbose analyze test_data; +checkpoint; + +--sdtB3X0nJg68CQEu +Content-Type: text/plain; charset=us-ascii +Content-Disposition: attachment; filename="test_script.sql" + +-- force nestloop indexscan plan +set enable_seqscan to 0; +set enable_mergejoin to 0; +set enable_hashjoin to 0; + +explain +select count(*) from test_data a, test_data b, test_data c +where a.f1 = b.f1 and b.f1 = c.f1; + +select count(*) from test_data a, test_data b, test_data c +where a.f1 = b.f1 and b.f1 = c.f1; + +--sdtB3X0nJg68CQEu-- + +From pgsql-performance-owner@postgresql.org Thu Oct 21 15:21:12 2004 +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 942F232A17C + for ; + Thu, 21 Oct 2004 15:21:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32287-05 + for ; + Thu, 21 Oct 2004 14:21: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 C780332A11C + for ; + Thu, 21 Oct 2004 15:21:05 +0100 (BST) +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 i9LEKtIM015150; + Thu, 21 Oct 2004 10:20:55 -0400 (EDT) +To: "Steinar H. Gunderson" +Cc: pgsql-performance@postgresql.org +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +In-reply-to: <20041021134506.GA1667@uio.no> +References: + + <20041021134506.GA1667@uio.no> +Comments: In-reply-to "Steinar H. Gunderson" + message dated "Thu, 21 Oct 2004 15:45:06 +0200" +Date: Thu, 21 Oct 2004 10:20:55 -0400 +Message-ID: <15149.1098368455@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/351 +X-Sequence-Number: 8827 + +"Steinar H. Gunderson" writes: +> ... I have no idea how much you can improve over the "best" +> filesystems out there, but having two layers of journalling (both WAL _and_ +> FS journalling) on top of each other don't make all that much sense to me. + +Which is why setting the FS to journal metadata but not file contents is +often suggested as best practice for a PG-only filesystem. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Oct 21 15:23:31 2004 +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 B34A332A219 + for ; + Thu, 21 Oct 2004 15:23:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33848-04 + for ; + Thu, 21 Oct 2004 14:23:23 +0000 (GMT) +Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E72732A263 + for ; + Thu, 21 Oct 2004 15:23:20 +0100 (BST) +Received: (from smtp@localhost) + by ll.mit.edu (8.12.10/8.8.8) id i9LEMxRs000661; + Thu, 21 Oct 2004 10:22:59 -0400 (EDT) +Received: from sty.llan.ll.mit.edu( ), claiming to be "sty.llan" + via SMTP by llpost, id smtpdAAA8mayq6; Thu Oct 21 10:22:37 2004 +Date: Thu, 21 Oct 2004 10:22:37 -0400 +From: george young +To: "Ray" +Cc: pgsql-performance@postgresql.org +Subject: Re: create index with substr function +Message-Id: <20041021102237.5ae1d14e.gry@ll.mit.edu> +In-Reply-To: <078b01c4b71f$4936e4e0$0f6010ac@raysiu> +References: <069201c4b715$34851670$0f6010ac@raysiu> + <37d451f704102020346fdbb855@mail.gmail.com> + <078b01c4b71f$4936e4e0$0f6010ac@raysiu> +Reply-To: gry@ll.mit.edu +Organization: MIT Lincoln Laboratory +X-Mailer: Sylpheed version 0.9.10 (GTK+ 1.2.10; 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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/352 +X-Sequence-Number: 8828 + +As previously suggested by Stephan Szabo, you need to create a helper +function, e.g.: +create or replace function after9(text)returns text language plpgsql immutable as ' + begin + return substr($1, 10); + end; +'; + +You may need the "immutable" specification is to allow the +function's use in an index. + +Then use this function in the index creation: + +CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree (after9(doc_urn)); + +I think that should do it. + + +-- George +> +On Thu, 21 Oct 2004 11:37:26 +0800 +"Ray" threw this fish to the penguins: + +> sorry it doesn't works, as my postgres is 7.3 not 7.4. any other alternative +> solution for version after 7.4?? +> +> Thank +> Ray : ) +> +> ----- Original Message ----- +> From: "Rosser Schwarz" +> To: "Ray" +> Cc: +> Sent: Thursday, October 21, 2004 11:34 AM +> Subject: Re: [PERFORM] create index with substr function +> +> +> > while you weren't looking, Ray wrote: +> > +> > > CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree +> (SUBSTR(doc_urn,10)); +> > +> > CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree +> ((SUBSTR(doc_urn,10))); +> > +> > You need an additional set of parens around the SUBSTR() call. +> > +> > /rls +> > +> > -- +> > :wq +> > +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + +-- +"Are the gods not just?" "Oh no, child. +What would become of us if they were?" (CSL) + +From pgsql-performance-owner@postgresql.org Thu Oct 21 15:34:24 2004 +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 6A22732AA2B + for ; + Thu, 21 Oct 2004 15:34:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38578-03 + for ; + Thu, 21 Oct 2004 14:34:15 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B07D32AA12 + for ; + Thu, 21 Oct 2004 15:34:17 +0100 (BST) +Received: by rproxy.gmail.com with SMTP id 74so24405rnk + for ; + Thu, 21 Oct 2004 07:34:17 -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; + b=A2pYI9jfZtpzE9euxgct9C1w28Hn+BYYMAIbeDGbU/EsaErtcADCTPmR3Ksyr2k4hjUDP/L95xj0M3INrOgFJaVBBLsL2CtiFOE9MMODLGiLNtkrw4MgSleYG7RCqhJR00w6kb2QsktwM0JoCS3vKqa2u6hBswrj3wSHy2rsNc0= +Received: by 10.38.152.39 with SMTP id z39mr3124662rnd; + Thu, 21 Oct 2004 07:34:17 -0700 (PDT) +Received: by 10.38.125.26 with HTTP; Thu, 21 Oct 2004 07:34:17 -0700 (PDT) +Message-ID: +Date: Thu, 21 Oct 2004 17:34:17 +0300 +From: Victor Ciurus +Reply-To: Victor Ciurus +To: pgsql-performance@postgresql.org +Subject: Simple machine-killing query! +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/353 +X-Sequence-Number: 8829 + +Hi all, + +I'm writing this because I've reached the limit of my imagination and +patience! So here is it... + +2 tables: +1 containing 27 million variable lenght, alpha-numeric records +(strings) in 1 (one) field. (10 - 145 char lenght per record) +1 containing 2.5 million variable lenght, alpha-numeric records +(strings) in 1 (one) field. + +table wehere created using: +CREATE TABLE "public"."BIGMA" ("string" VARCHAR(255) NOT NULL) WITH OIDS; + +CREATE INDEX "BIGMA_INDEX" ON "public"."BIGMA" USING btree ("string"); +and +CREATE TABLE "public"."DIRTY" ("string" VARCHAR(128) NOT NULL) WITH OIDS; + +CREATE INDEX "DIRTY_INDEX" ON "public"."DIRTY" USING btree ("string"); + +What I am requested to do is to keep all records from 'BIGMA' that do +not apear in 'DIRTY' +So far I have tried solving this by going for: + +[explain] select * from BIGMA where string not in (select * from DIRTY); + QUERY PLAN +------------------------------------------------------------------------ + Seq Scan on bigma (cost=0.00..24582291.25 rows=500 width=145) + Filter: (NOT (subplan)) + SubPlan + -> Seq Scan on dirty (cost=0.00..42904.63 rows=2503963 width=82) +(4 rows) + +AND + +[explain] select * from bigma,dirty where bigma.email!=dirty.email; + QUERY PLAN +----------------------------------------------------------------------- + Nested Loop (cost=20.00..56382092.13 rows=2491443185 width=227) + Join Filter: (("inner".email)::text <> ("outer".email)::text) + -> Seq Scan on dirty (cost=0.00..42904.63 rows=2503963 width=82) + -> Materialize (cost=20.00..30.00 rows=1000 width=145) + -> Seq Scan on bigma (cost=0.00..20.00 rows=1000 width=145) +(5 rows) + +Now the problem is that both of my previous tries seem to last +forever! I'm not a pqsql guru so that's why I'm asking you fellas to +guide mw right! I've tried this on mysql previosly but there seems to +be no way mysql can handle this large query. + +QUESTIONS: +What can I do in order to make this work? +Where do I make mistakes? Is there a way I can improve the performance +in table design, query style, server setting so that I can get this +monster going and producing a result? + +Thanks all for your preciuos time and answers! + +Victor C. + +From pgsql-performance-owner@postgresql.org Thu Oct 21 16:02:32 2004 +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 6A61D32AB6A + for ; + Thu, 21 Oct 2004 16:02:26 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47942-05 + for ; + Thu, 21 Oct 2004 15:02:16 +0000 (GMT) +Received: from zoidberg.portrix.net (port-212-202-157-208.static.qsc.de + [212.202.157.208]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C8D832A0E5 + for ; + Thu, 21 Oct 2004 16:02:09 +0100 (BST) +Received: from [127.0.0.1] (port-212-202-157-213.static.qsc.de + [212.202.157.213]) (authenticated bits=0) + by zoidberg.portrix.net (8.12.3/8.12.3/Debian-6.6) with ESMTP id + i9LF20Dd027395 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); + Thu, 21 Oct 2004 17:02:01 +0200 +Message-ID: <4177CF68.2050108@ppp0.net> +Date: Thu, 21 Oct 2004 17:02:00 +0200 +From: Jan Dittmer +User-Agent: Mozilla/5.0 (X11; U; Linux i686; + rv:1.7.3) Gecko/20040926 Thunderbird/0.8 Mnenhy/0.6.0.104 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Neil Conway +Cc: matt@ymogen.net, pgsql-performance@postgresql.org +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +References: <008601c4b743$aff57f10$8300a8c0@solent> + <4177A538.5070002@samurai.com> +In-Reply-To: <4177A538.5070002@samurai.com> +X-Enigmail-Version: 0.86.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +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.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200410/354 +X-Sequence-Number: 8830 + +Neil Conway wrote: +> Also, I would imagine Win32 provides some means to inform the kernel +> about your expected I/O pattern, but I haven't checked. Does anyone know +> of any other relevant APIs? + +See CreateFile, Parameter dwFlagsAndAttributes + +http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp + +There is FILE_FLAG_NO_BUFFERING, FILE_FLAG_OPEN_NO_RECALL, +FILE_FLAG_RANDOM_ACCESS and even FILE_FLAG_POSIX_SEMANTICS + +Jan + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 16:06:12 2004 +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 64EBE329F6D + for ; + Thu, 21 Oct 2004 16:06:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49763-05 + for ; + Thu, 21 Oct 2004 15:06:06 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EE4232AA47 + for ; + Thu, 21 Oct 2004 16:06:05 +0100 (BST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 788B2359E0; Thu, 21 Oct 2004 08:05:59 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 770653541C; Thu, 21 Oct 2004 08:05:59 -0700 (PDT) +Date: Thu, 21 Oct 2004 08:05:59 -0700 (PDT) +From: Stephan Szabo +To: Victor Ciurus +Cc: pgsql-performance@postgresql.org +Subject: Re: Simple machine-killing query! +In-Reply-To: +Message-ID: <20041021075757.A54616@megazone.bigpanda.com> +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/355 +X-Sequence-Number: 8831 + + +On Thu, 21 Oct 2004, Victor Ciurus wrote: + +> Hi all, +> +> I'm writing this because I've reached the limit of my imagination and +> patience! So here is it... +> +> 2 tables: +> 1 containing 27 million variable lenght, alpha-numeric records +> (strings) in 1 (one) field. (10 - 145 char lenght per record) +> 1 containing 2.5 million variable lenght, alpha-numeric records +> (strings) in 1 (one) field. +> +> table wehere created using: +> CREATE TABLE "public"."BIGMA" ("string" VARCHAR(255) NOT NULL) WITH OIDS; + +> CREATE INDEX "BIGMA_INDEX" ON "public"."BIGMA" USING btree ("string"); +> and +> CREATE TABLE "public"."DIRTY" ("string" VARCHAR(128) NOT NULL) WITH OIDS; + +> CREATE INDEX "DIRTY_INDEX" ON "public"."DIRTY" USING btree ("string"); +> +> What I am requested to do is to keep all records from 'BIGMA' that do +> not apear in 'DIRTY' +> So far I have tried solving this by going for: +> +> [explain] select * from BIGMA where string not in (select * from DIRTY); +> QUERY PLAN +> ------------------------------------------------------------------------ +> Seq Scan on bigma (cost=0.00..24582291.25 rows=500 width=145) +> Filter: (NOT (subplan)) +> SubPlan +> -> Seq Scan on dirty (cost=0.00..42904.63 rows=2503963 width=82) +> (4 rows) + +Have you analyzed bigma? The number of rows from the two explains for that +table look suspiciously like default values. + +Also, what version are you using, because there are some differences from +7.3 to 7.4 that change possible suggestions. + +The first is that on 7.4, you may be able to do better with a higher +sort_mem which could possible switch over to the hashed implementation, +although I think it's probably going to take a pretty high value given the +size. + +The second is that you might get better results (even on older versions) +from an exists or left join solution, something like (assuming no nulls in +bigma.email): + +select * from bigma where not exists(select 1 from dirty where dirty.email +!= bigma.email); + +select bigma.* from bigma left outer join dirty on (dirty.email = +bigma.email) where dirty.email is null; + +If you've got nulls in bigma.email you have to be a little more careful. + +> [explain] select * from bigma,dirty where bigma.email!=dirty.email; + +This *almost* certainly does not do what you want. For most data sets +this is going to give you a number of rows very close to # of rows in +dirty * # of rows in bigma. Needless to say, this is going to take a long +time. + +From pgsql-performance-owner@postgresql.org Thu Oct 21 16:14:39 2004 +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 377E432A014 + for ; + Thu, 21 Oct 2004 16:14:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53130-06 + for ; + Thu, 21 Oct 2004 15:14:21 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 916BA329F45 + for ; + Thu, 21 Oct 2004 16:14:17 +0100 (BST) +Received: by rproxy.gmail.com with SMTP id 73so37559rnk + for ; + Thu, 21 Oct 2004 08:14:14 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=nzdYqxeVZqXLTp49IeT5waWE7IqaiMcSXaEWBbhi3+l442omzMhES7SDZd5u3IixvlD9uixNOw82duTkyKzvOwtYAdm7MmN9pynAr5eGnaBTVc4cu/507mSIMv7r4hRCjKAHfV347BP34uFxSTR3I2p0pMFX4pKInBZ/sP77/6M= +Received: by 10.38.181.77 with SMTP id d77mr3130083rnf; + Thu, 21 Oct 2004 08:14:14 -0700 (PDT) +Received: by 10.38.151.75 with HTTP; Thu, 21 Oct 2004 08:14:14 -0700 (PDT) +Message-ID: <157f648404102108141836a5ac@mail.gmail.com> +Date: Thu, 21 Oct 2004 11:14:14 -0400 +From: Aaron Werman +Reply-To: Aaron Werman +To: Victor Ciurus +Subject: Re: Simple machine-killing query! +Cc: pgsql-performance@postgresql.org +In-Reply-To: +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/356 +X-Sequence-Number: 8832 + +Sounds like you need some way to match a subset of the data first, +rather than try indices that are bigger than the data. Can you add +operation indices, perhaps on the first 10 bytes of the keys in both +tables or on a integer hash of all of the strings? If so you could +join on the exact set difference over the set difference of the +operation match. + +/Aaron + + +On Thu, 21 Oct 2004 17:34:17 +0300, Victor Ciurus wrote: +> Hi all, +> +> I'm writing this because I've reached the limit of my imagination and +> patience! So here is it... +> +> 2 tables: +> 1 containing 27 million variable lenght, alpha-numeric records +> (strings) in 1 (one) field. (10 - 145 char lenght per record) +> 1 containing 2.5 million variable lenght, alpha-numeric records +> (strings) in 1 (one) field. +> +> table wehere created using: +> CREATE TABLE "public"."BIGMA" ("string" VARCHAR(255) NOT NULL) WITH OIDS; + +> CREATE INDEX "BIGMA_INDEX" ON "public"."BIGMA" USING btree ("string"); +> and +> CREATE TABLE "public"."DIRTY" ("string" VARCHAR(128) NOT NULL) WITH OIDS; + +> CREATE INDEX "DIRTY_INDEX" ON "public"."DIRTY" USING btree ("string"); +> +> What I am requested to do is to keep all records from 'BIGMA' that do +> not apear in 'DIRTY' +> So far I have tried solving this by going for: +> +> [explain] select * from BIGMA where string not in (select * from DIRTY); +> QUERY PLAN +> ------------------------------------------------------------------------ +> Seq Scan on bigma (cost=0.00..24582291.25 rows=500 width=145) +> Filter: (NOT (subplan)) +> SubPlan +> -> Seq Scan on dirty (cost=0.00..42904.63 rows=2503963 width=82) +> (4 rows) +> +> AND +> +> [explain] select * from bigma,dirty where bigma.email!=dirty.email; +> QUERY PLAN +> ----------------------------------------------------------------------- +> Nested Loop (cost=20.00..56382092.13 rows=2491443185 width=227) +> Join Filter: (("inner".email)::text <> ("outer".email)::text) +> -> Seq Scan on dirty (cost=0.00..42904.63 rows=2503963 width=82) +> -> Materialize (cost=20.00..30.00 rows=1000 width=145) +> -> Seq Scan on bigma (cost=0.00..20.00 rows=1000 width=145) +> (5 rows) +> +> Now the problem is that both of my previous tries seem to last +> forever! I'm not a pqsql guru so that's why I'm asking you fellas to +> guide mw right! I've tried this on mysql previosly but there seems to +> be no way mysql can handle this large query. +> +> QUESTIONS: +> What can I do in order to make this work? +> Where do I make mistakes? Is there a way I can improve the performance +> in table design, query style, server setting so that I can get this +> monster going and producing a result? +> +> Thanks all for your preciuos time and answers! +> +> Victor C. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> + + +-- + +Regards, +/Aaron + +From pgsql-performance-owner@postgresql.org Thu Oct 21 16:42:05 2004 +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 9204832ABC7 + for ; + Thu, 21 Oct 2004 16:42:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62336-08 + for ; + Thu, 21 Oct 2004 15:41:55 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C82332A452 + for ; + Thu, 21 Oct 2004 16:41:51 +0100 (BST) +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 i9LFfnUk016018; + Thu, 21 Oct 2004 11:41:49 -0400 (EDT) +To: Victor Ciurus +Cc: pgsql-performance@postgresql.org +Subject: Re: Simple machine-killing query! +In-reply-to: +References: +Comments: In-reply-to Victor Ciurus + message dated "Thu, 21 Oct 2004 17:34:17 +0300" +Date: Thu, 21 Oct 2004 11:41:48 -0400 +Message-ID: <16017.1098373308@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/357 +X-Sequence-Number: 8833 + +Victor Ciurus writes: +> What I am requested to do is to keep all records from 'BIGMA' that do +> not apear in 'DIRTY' +> So far I have tried solving this by going for: + +> [explain] select * from BIGMA where string not in (select * from DIRTY); +> QUERY PLAN +> ------------------------------------------------------------------------ +> Seq Scan on bigma (cost=0.00..24582291.25 rows=500 width=145) +> Filter: (NOT (subplan)) +> SubPlan +> -> Seq Scan on dirty (cost=0.00..42904.63 rows=2503963 width=82) +> (4 rows) + +If you are using PG 7.4, you can get reasonable performance out of this +approach, but you need to jack sort_mem up to the point where the whole +DIRTY table will fit into sort_mem (so that you get a hashed-subplan +plan and not a plain subplan). If you find yourself setting sort_mem to +more than say half of your machine's available RAM, you should probably +forget that idea. + +> [explain] select * from bigma,dirty where bigma.email!=dirty.email; + +This of course does not give the right answer at all. + +A trick that people sometimes use is an outer join: + +select * from bigma left join dirty on (bigma.email=dirty.email) +where dirty.email is null; + +Understanding why this works is left as an exercise for the reader +... but it does work, and pretty well too. If you're using pre-7.4 +PG then this is about the only effective solution AFAIR. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Oct 21 16:49:33 2004 +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 CC3C232A154 + for ; + Thu, 21 Oct 2004 16:49:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65023-10 + for ; + Thu, 21 Oct 2004 15:49:26 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id 3587B329E61 + for ; + Thu, 21 Oct 2004 16:49:24 +0100 (BST) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1CKfBr-0000gY-00 + for ; Thu, 21 Oct 2004 17:49:23 +0200 +Date: Thu, 21 Oct 2004 17:49:23 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +Message-ID: <20041021154923.GA2574@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + + <20041021134506.GA1667@uio.no> <15149.1098368455@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <15149.1098368455@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.8.1 on a i686 +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/358 +X-Sequence-Number: 8834 + +On Thu, Oct 21, 2004 at 10:20:55AM -0400, Tom Lane wrote: +>> ... I have no idea how much you can improve over the "best" +>> filesystems out there, but having two layers of journalling (both WAL _and_ +>> FS journalling) on top of each other don't make all that much sense to me. +> Which is why setting the FS to journal metadata but not file contents is +> often suggested as best practice for a PG-only filesystem. + +Mm, but you still journal the metadata. Oh well, noatime etc.. :-) + +By the way, I'm probably hitting a FAQ here, but would O_DIRECT help +PostgreSQL any, given large enough shared_buffers? + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu Oct 21 18:03:48 2004 +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 C9C0832A15F + for ; + Thu, 21 Oct 2004 18:03:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89977-03 + for ; + Thu, 21 Oct 2004 17:03:45 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.206]) + by svr1.postgresql.org (Postfix) with ESMTP id 01E7F32A095 + for ; + Thu, 21 Oct 2004 18:03:45 +0100 (BST) +Received: by rproxy.gmail.com with SMTP id 73so54722rnk + for ; + Thu, 21 Oct 2004 10:03:41 -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:references; + b=IQ9dpCYO4Dn87UkWt+DaueTvl0uZ9UpNxzs0DafKjH8V9qTrq9lgc7ClqoVdp09Q+fVYEKNkAe9GU1ZPA2GkqediNQInZdYrNRcaVa7vc1pM06h3OF8Q7xtg6oXNkYvlCxMiLsr3RpTJ+gjxMvntCAPN2nY028swawfUfzAw6Zg= +Received: by 10.38.151.68 with SMTP id y68mr3190700rnd; + Thu, 21 Oct 2004 10:03:41 -0700 (PDT) +Received: by 10.38.125.26 with HTTP; Thu, 21 Oct 2004 10:03:41 -0700 (PDT) +Message-ID: +Date: Thu, 21 Oct 2004 20:03:41 +0300 +From: Victor Ciurus +Reply-To: Victor Ciurus +To: pgsql-performance@postgresql.org +Subject: Re: Simple machine-killing query! +Cc: Tom Lane +In-Reply-To: <16017.1098373308@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + <16017.1098373308@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/359 +X-Sequence-Number: 8835 + +Well guys, + +Your replies have been more than helpful to me, showing me both the +learning stuff I still have to get in my mind about real SQL and the +wonder called PostgreSQL and a very good solution from Tom Lane +(thanks a lot sir!)! + +Indeed, changing mem_sort and other server parmeters along with the +quite strange (to me!) outer join Tom mentioned finally got me to +finalize the cleaning task and indeed in warp speed (some 5 mintues or +less!). I am running PG v7.4.5 on a PIV Celeron 1,7Ghz with 1,5Gb ram +so talking about the time performance I might say that I'm more than +pleased with the result. As with the amazement PG "caused" me through +its reliability so far I am decided to go even deeper in learning it! + +Thanks again all for your precious help! + +Regards, +Victor + + +> +> If you are using PG 7.4, you can get reasonable performance out of this +> approach, but you need to jack sort_mem up to the point where the whole +> DIRTY table will fit into sort_mem (so that you get a hashed-subplan +> plan and not a plain subplan). If you find yourself setting sort_mem to +> more than say half of your machine's available RAM, you should probably +> forget that idea. +> +> > [explain] select * from bigma,dirty where bigma.email!=dirty.email; +> +> This of course does not give the right answer at all. +> +> A trick that people sometimes use is an outer join: +> +> select * from bigma left join dirty on (bigma.email=dirty.email) +> where dirty.email is null; +> +> Understanding why this works is left as an exercise for the reader +> ... but it does work, and pretty well too. If you're using pre-7.4 +> PG then this is about the only effective solution AFAIR. +> +> regards, tom lane +> + +From pgsql-performance-owner@postgresql.org Thu Oct 21 18:15:09 2004 +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 09B1E32AB6A + for ; + Thu, 21 Oct 2004 18:15:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92384-08 + for ; + Thu, 21 Oct 2004 17:15:04 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A60B32AA72 + for ; + Thu, 21 Oct 2004 18:15:04 +0100 (BST) +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 6538430; Thu, 21 Oct 2004 10:16:27 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org, + Victor Ciurus +Subject: Re: Simple machine-killing query! +Date: Thu, 21 Oct 2004 10:14:39 -0700 +User-Agent: KMail/1.6.2 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200410211014.39916.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/360 +X-Sequence-Number: 8836 + +Victor, + +> [explain] select * from BIGMA where string not in (select * from DIRTY); +> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0QUERY PLAN +> ------------------------------------------------------------------------ +> =A0Seq Scan on bigma =A0(cost=3D0.00..24582291.25 rows=3D500 width=3D145) +> =A0 =A0Filter: (NOT (subplan)) +> =A0 =A0SubPlan +> =A0 =A0 =A0-> =A0Seq Scan on dirty =A0(cost=3D0.00..42904.63 rows=3D25039= +63 width=3D82) + +This is what you call an "evil query". I'm not surprised it takes forever= +;=20 +you're telling the database "Compare every value in 2.7 million rows of tex= +t=20 +against 2.5 million rows of text and give me those that don't match." The= +re=20 +is simply no way, on ANY RDBMS, for this query to execute and not eat all o= +f=20 +your RAM and CPU for a long time. + +You're simply going to have to allocate shared_buffers and sort_mem (about = +2GB=20 +of sort_mem would be good) to the query, and turn the computer over to the= +=20 +task until it's done. And, for the sake of sanity, when you find the=20 +200,000 rows that don't match, flag them so that you don't have to do this= +=20 +again. + +--=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Oct 21 19:40:49 2004 +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 DA80B329E6D + for ; + Thu, 21 Oct 2004 19:40:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20382-04 + for ; + Thu, 21 Oct 2004 18:40:35 +0000 (GMT) +Received: from mail.trippynames.com (mail.trippynames.com [38.113.223.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 803C732A938 + for ; + Thu, 21 Oct 2004 19:40:35 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by mail.trippynames.com (Postfix) with ESMTP id 3EE08A3232; + Thu, 21 Oct 2004 11:40:34 -0700 (PDT) +Received: from mail.trippynames.com ([127.0.0.1]) + by localhost (rand.nxad.com [127.0.0.1]) (amavisd-new, + port 10024) with LMTP + id 84941-07; Thu, 21 Oct 2004 11:40:33 -0700 (PDT) +Received: from [192.168.1.102] (wbar4.sjo1-4.28.216.220.sjo1.dsl-verizon.net + [4.28.216.220]) + by mail.trippynames.com (Postfix) with ESMTP id C4E90A323B; + Thu, 21 Oct 2004 11:40:20 -0700 (PDT) +In-Reply-To: <4177A538.5070002@samurai.com> +References: <008601c4b743$aff57f10$8300a8c0@solent> + <4177A538.5070002@samurai.com> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: matt@ymogen.net, pgsql-performance@postgresql.org +From: Sean Chittenden +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +Date: Thu, 21 Oct 2004 11:40:08 -0700 +To: Neil Conway +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/361 +X-Sequence-Number: 8837 + +> As someone else noted, this doesn't belong in the filesystem (rather +> the kernel's block I/O layer/buffer cache). But I agree, an API by +> which we can tell the kernel what kind of I/O behavior to expect would +> be good. +[snip] +> The closest API to what you're describing that I'm aware of is +> posix_fadvise(). While that is technically-speaking a POSIX standard, +> it is not widely implemented (I know Linux 2.6 implements it; based on +> some quick googling, it looks like AIX does too). + +Don't forget about the existence/usefulness/widely implemented +madvise(2)/posix_madvise(2) call, which can give the OS the following +hints: MADV_NORMAL, MADV_SEQUENTIAL, MADV_RANDOM, MADV_WILLNEED, +MADV_DONTNEED, and MADV_FREE. :) -sc + +-- +Sean Chittenden + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 21:26:49 2004 +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 4C34C32A8D5 + for ; + Thu, 21 Oct 2004 21:26:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53966-01 + for ; + Thu, 21 Oct 2004 20:26:39 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id D150D32A0DC + for ; + Thu, 21 Oct 2004 21:26:39 +0100 (BST) +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 6539044; Thu, 21 Oct 2004 13:28:04 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Links to OSDL test results up +Date: Thu, 21 Oct 2004 13:28:46 -0700 +User-Agent: KMail/1.6.2 +Cc: "Simon Riggs" , + +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410211328.46068.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/362 +X-Sequence-Number: 8838 + +Simon, Folks, + +I've put links to all of my OSDL-STP test results up on the TestPerf project: +http://pgfoundry.org/forum/forum.php?thread_id=164&forum_id=160 + +SHare&Enjoy! + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Oct 21 21:29:52 2004 +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 026C432ABD5 + for ; + Thu, 21 Oct 2004 21:29:52 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52533-10 + for ; + Thu, 21 Oct 2004 20:29:41 +0000 (GMT) +Received: from mail.trippynames.com (mail.trippynames.com [38.113.223.19]) + by svr1.postgresql.org (Postfix) with ESMTP id B228F32ABB2 + for ; + Thu, 21 Oct 2004 21:29:40 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by mail.trippynames.com (Postfix) with ESMTP id EA4C4A4694; + Thu, 21 Oct 2004 13:29:39 -0700 (PDT) +Received: from mail.trippynames.com ([127.0.0.1]) + by localhost (rand.nxad.com [127.0.0.1]) (amavisd-new, + port 10024) with LMTP + id 98075-08; Thu, 21 Oct 2004 13:29:37 -0700 (PDT) +Received: from [192.168.1.102] (wbar4.sjo1-4.28.216.220.sjo1.dsl-verizon.net + [4.28.216.220]) + by mail.trippynames.com (Postfix) with ESMTP id 18BD1A464B; + Thu, 21 Oct 2004 13:29:36 -0700 (PDT) +In-Reply-To: <26390.1097875346@sss.pgh.pa.us> +References: <157f64840410141725162e43b5@mail.gmail.com> + <20041015010841.GE665@filer> + <0E3BB9CB-1EE6-11D9-A0BB-000A95C705DC@chittenden.org> + <26390.1097875346@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: Kevin Brown , + pgsql-performance@postgresql.org +From: Sean Chittenden +Subject: Re: mmap (was First set of OSDL Shared Mem scalability results, + some wierdness ... +Date: Thu, 21 Oct 2004 13:29:34 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/363 +X-Sequence-Number: 8839 + +> However the really major difficulty with using mmap is that it breaks +> the scheme we are currently using for WAL, because you don't have any +> way to restrict how soon a change in an mmap'd page will go to disk. +> (No, I don't believe that mlock guarantees this. It says that the +> page will not be removed from main memory; it does not specify that, +> say, the syncer won't write the contents out anyway.) + +I had to think about this for a minute (now nearly a week) and reread +the docs on WAL before I groked what could happen here. You're +absolutely right in that WAL needs to be taken into account first. How +does this execution path sound to you? + +By default, all mmap(2)'ed pages are MAP_SHARED. There are no +complications with regards to reads. + +When a backend wishes to write a page, the following steps are taken: + +1) Backend grabs a lock from the lockmgr to write to the page (exactly +as it does now) + +2) Backend mmap(2)'s a second copy of the page(s) being written to, +this time with the MAP_PRIVATE flag set. Mapping a copy of the page +again is wasteful in terms of address space, but does not require any +more memory than our current scheme. The re-mapping of the page with +MAP_PRIVATE prevents changes to the data that other backends are +viewing. + +3) The writing backend, can then scribble on its private copy of the +page(s) as it sees fit. + +4) Once completed making changes and a transaction is to be committed, +the backend WAL logs its changes. + +5) Once the WAL logging is complete and it has hit the disk, the +backend msync(2)'s its private copy of the pages to disk (ASYNC or +SYNC, it doesn't really matter too much to me). + +6) Optional(?). I'm not sure whether or not the backend would need to +also issues an msync(2) MS_INVALIDATE, but, I suspect it would not need +to on systems with unified buffer caches such as FreeBSD or OS-X. On +HPUX, or other older *NIX'es, it may be necessary. *shrug* I could be +trying to be overly protective here. + +7) Backend munmap(2)'s its private copy of the written on page(s). + +8) Backend releases its lock from the lockmgr. + +At this point, the remaining backends now are able to see the updated +pages of data. + +>> Let's look at what happens with a read(2) call. To read(2) data you +>> have to have a block of memory to copy data into. Assume your OS of +>> choice has a good malloc(3) implementation and it only needs to call +>> brk(2) once to extend the process's memory address after the first +>> malloc(3) call. There's your first system call, which guarantees one +>> context switch. +> +> Wrong. Our reads occur into shared memory allocated at postmaster +> startup, remember? + +Doh. Fair enough. In most programs that involve read(2), a call to +alloc(3) needs to be made. + +>> mmap(2) is a totally different animal in that you don't ever need to +>> make calls to read(2): mmap(2) is used in place of those calls (With +>> #ifdef and a good abstraction, the rest of PostgreSQL wouldn't know it +>> was working with a page of mmap(2)'ed data or need to know that it +>> is). +> +> Instead, you have to worry about address space management and keeping a +> consistent view of the data. + +Which is largely handled by mmap() and the VM. + +>> ... If a write(2) system call is issued on a page of +>> mmap(2)'ed data (and your operating system supports it, I know FreeBSD +>> does, but don't think Linux does), then the page of data is DMA'ed by +>> the network controller and sent out without the data needing to be +>> copied into the network controller's buffer. +> +> Perfectly irrelevant to Postgres, since there is no situation where +> we'd +> ever write directly from a disk buffer to a socket; in the present +> implementation there are at least two levels of copy needed in between +> (datatype-specific output function and protocol message assembly). And +> that's not even counting the fact that any data item large enough to +> make the savings interesting would have been sliced, diced, and +> compressed by TOAST. + +The biggest winners will be columns whos storage type is PLAIN or +EXTERNAL. writev(2) from mmap(2)'ed pages and non-mmap(2)'ed pages +would be a nice perk too (not sure if PostgreSQL uses this or not). +Since compression isn't happening on most tuples under 1K in size and +most tuples in a database are going to be under that, most tuples are +going to be uncompressed. Total pages for the database, however, is +likely a different story. For large tuples that are uncompressed and +larger than a page, it is probably beneficial to use sendfile(2) +instead of mmap(2) + write(2)'ing the page/file. + +If a large tuple is compressed, it'd be interesting to see if it'd be +worthwhile to have the data uncompressed onto an anonymously mmap(2)'ed +page(s) that way the benefits of zero-socket-copies could be used. + +>> shared mem is a bastardized subsystem that works, but isn't integral +>> to +>> any performance areas in the kernel so it gets neglected. +> +> What performance issues do you think shared memory needs to have fixed? +> We don't issue any shmem kernel calls after the initial shmget, so +> comparing the level of kernel tenseness about shmget to the level of +> tenseness about mmap is simply irrelevant. Perhaps the reason you +> don't +> see any traffic about this on the kernel lists is that shared memory +> already works fine and doesn't need any fixing. + +I'm gunna get flamed for this, but I think its improperly used as a +second level cache on top of the operating system's cache. mmap(2) +would consolidate all caching into the kernel. + +>> Please ask questions if you have them. +> +> Do you have any arguments that are actually convincing? + +Three things come to mind. + +1) A single cache for pages +2) Ability to give access hints to the kernel regarding future IO +3) On the fly memory use for a cache. There would be no need to +preallocate slabs of shared memory on startup. + +And a more minor point would be: + +4) Not having shared pages get lost when the backend dies (mmap(2) uses +refcounts and cleans itself up, no need for ipcs/ipcrm/ipcclean). This +isn't too practical in production though, but it sucks doing PostgreSQL +development on OS-X because there is no ipcs/ipcrm command. + +> What I just read was a proposal to essentially throw away not only the +> entire +> low-level data access model, but the entire low-level locking model, +> and start from scratch. + + From the above list, steps 2, 3, 5, 6, and 7 would be different than +our current approach, all of which could be safely handled with some +#ifdef's on platforms that don't have mmap(2). + +> There is no possible way we could support both +> this approach and the current one, which means that we'd be permanently +> dropping support for all platforms without high-quality mmap +> implementations; + +Architecturally, I don't see anything different or incompatibilities +that aren't solved with an #ifdef USE_MMAP/#else/#endif. + +> Furthermore, you didn't +> give any really convincing reasons to think that the enormous effort +> involved would be repaid. + +Steven's has a great reimplementaion of cat(1) that uses mmap(1) and +benchmarks the two. I did my own version of that here: + +http://people.freebsd.org/~seanc/mmap_test/ + +When read(2)'ing/write(2)'ing /etc/services 100,000 times without +mmap(2), it takes 82 seconds. With mmap(2), it takes anywhere from 1.1 +to 18 seconds. Worst case scenario with mmap(2) yields a speedup by a +factor of four. Best case scenario... *shrug* something better than +4x. I doubt PostgreSQL would see 4x speedups in the IO department, but +I do think it would be vastly greater than the 3% suggested. + +> Those oprofile reports Josh just put up +> showed 3% of the CPU time going into userspace/kernelspace copying. +> Even assuming that that number consists entirely of reads and writes of +> shared buffers (and of course no other kernel call ever transfers any +> data across that boundary ;-)), there's no way we are going to buy into +> this sort of project in hopes of a 3% win. + +Would it be helpful if I created a test program that demonstrated that +the execution path for writing mmap(2)'ed pages as outlined above? + +-sc + +-- +Sean Chittenden + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 21:36:31 2004 +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 0B67A32A017 + for ; + Thu, 21 Oct 2004 21:36:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55162-07 + for ; + Thu, 21 Oct 2004 20:36:21 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id 7F28632A002 + for ; + Thu, 21 Oct 2004 21:36:20 +0100 (BST) +Received: (qmail 16834 invoked from network); 21 Oct 2004 20:36:18 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.22?) + (64.3.242.80) by 0 with SMTP; 21 Oct 2004 20:36:18 -0000 +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Thomas F.O'Connell +Subject: Performance Anomalies in 7.4.5 +Date: Thu, 21 Oct 2004 15:36:02 -0500 +To: PgSQL - Performance +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/364 +X-Sequence-Number: 8840 + +I'm seeing some weird behavior on a repurposed server that was wiped +clean and set up to run as a database and application server with +postgres and Apache, as well as some command-line PHP scripts. + +The box itself is a quad processor (2.4 GHz Intel Xeons) Debian woody +GNU/Linux (2.6.2) system. + +postgres is crawling on some fairly routine queries. I'm wondering if +this could somehow be related to the fact that this isn't a +database-only server, but Apache is not really using any resources when +postgres slows to a crawl. + +Here's an example of analysis of a recent query: + +EXPLAIN ANALYZE SELECT COUNT(DISTINCT u.id) +FROM userdata as u, userdata_history as h +WHERE h.id = '18181' +AND h.id = u.id; + +QUERY PLAN +------------------------------------------------------------------------ +------------------------------------------------------------------------ + Aggregate (cost=0.02..0.02 rows=1 width=8) (actual +time=298321.421..298321.422 rows=1 loops=1) + -> Nested Loop (cost=0.00..0.01 rows=1 width=8) (actual +time=1.771..298305.531 rows=2452 loops=1) + Join Filter: ("inner".id = "outer".id) + -> Seq Scan on userdata u (cost=0.00..0.00 rows=1 width=8) +(actual time=0.026..11.869 rows=2452 loops=1) + -> Seq Scan on userdata_history h (cost=0.00..0.00 rows=1 +width=8) (actual time=0.005..70.519 rows=41631 loops=2452) + Filter: (id = 18181::bigint) + Total runtime: 298321.926 ms +(7 rows) + +userdata has a primary/foreign key on id, which references +userdata_history.id, which is a primary key. + +At the time of analysis, the userdata table had < 2,500 rows. +userdata_history had < 50,000 rows. I can't imagine how even a seq scan +could result in a runtime of nearly 5 minutes in these circumstances. + +Also, doing a count( * ) from each table individually returns nearly +instantly. + +I can provide details of postgresql.conf and kernel settings if +necessary, but I'm using some pretty well tested settings that I use +any time I admin a postgres installation these days based on box +resources and database size. I'm more interested in knowing if there +are any bird's eye details I should be checking immediately. + +Thanks. + +-tfo + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-260-0005 + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 21:50:38 2004 +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 A73DB32A518 + for ; + Thu, 21 Oct 2004 21:50:35 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57362-07 + for ; + Thu, 21 Oct 2004 20:50:24 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id 7BE5F32A002 + for ; + Thu, 21 Oct 2004 21:50:24 +0100 (BST) +Received: (qmail 21915 invoked from network); 21 Oct 2004 20:50:24 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.22?) + (64.3.242.80) by 0 with SMTP; 21 Oct 2004 20:50:24 -0000 +Mime-Version: 1.0 (Apple Message framework v619) +In-Reply-To: +References: +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Thomas F.O'Connell +Subject: Re: Performance Anomalies in 7.4.5 +Date: Thu, 21 Oct 2004 15:50:20 -0500 +To: PgSQL - Performance +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/365 +X-Sequence-Number: 8841 + +I know, I know: I should've done this before I posted. REINDEXing and +VACUUMing mostly fixed this problem. Which gets me back to where I was +yesterday, reviewing an import process (that existed previously) that +populates tables in this system that seems to allow small data sets to +cause simple queries like this to crawl. Is there anything about +general COPY/INSERT activity that can cause small data sets to become +so severely slow in postgres that can be prevented other than being +diligent about VACUUMing? I was hoping that pg_autovacuum along with +post-import manual VACUUMs would be sufficient, but it doesn't seem to +be the case necessarily. Granted, I haven't done a methodical and +complete review of the process, but I'm still surprised at how quickly +it seems able to debilitate postgres with even small amounts of data. I +had a similar situation crawl yesterday based on a series of COPYs +involving 5 rows! + +As in, can I look for something to treat the cause rather than the +symptoms? + +If not, should I be REINDEXing manually, as well as VACUUMing manually +after large data imports (whether via COPY or INSERT)? Or will a VACUUM +FULL ANALYZE be enough? + +Thanks! + +-tfo + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-260-0005 + +On Oct 21, 2004, at 3:36 PM, Thomas F.O'Connell wrote: + +> I'm seeing some weird behavior on a repurposed server that was wiped +> clean and set up to run as a database and application server with +> postgres and Apache, as well as some command-line PHP scripts. +> +> The box itself is a quad processor (2.4 GHz Intel Xeons) Debian woody +> GNU/Linux (2.6.2) system. +> +> postgres is crawling on some fairly routine queries. I'm wondering if +> this could somehow be related to the fact that this isn't a +> database-only server, but Apache is not really using any resources +> when postgres slows to a crawl. +> +> Here's an example of analysis of a recent query: +> +> EXPLAIN ANALYZE SELECT COUNT(DISTINCT u.id) +> FROM userdata as u, userdata_history as h +> WHERE h.id = '18181' +> AND h.id = u.id; +> +> QUERY PLAN +> ----------------------------------------------------------------------- +> ----------------------------------------------------------------------- +> -- +> Aggregate (cost=0.02..0.02 rows=1 width=8) (actual +> time=298321.421..298321.422 rows=1 loops=1) +> -> Nested Loop (cost=0.00..0.01 rows=1 width=8) (actual +> time=1.771..298305.531 rows=2452 loops=1) +> Join Filter: ("inner".id = "outer".id) +> -> Seq Scan on userdata u (cost=0.00..0.00 rows=1 width=8) +> (actual time=0.026..11.869 rows=2452 loops=1) +> -> Seq Scan on userdata_history h (cost=0.00..0.00 rows=1 +> width=8) (actual time=0.005..70.519 rows=41631 loops=2452) +> Filter: (id = 18181::bigint) +> Total runtime: 298321.926 ms +> (7 rows) +> +> userdata has a primary/foreign key on id, which references +> userdata_history.id, which is a primary key. +> +> At the time of analysis, the userdata table had < 2,500 rows. +> userdata_history had < 50,000 rows. I can't imagine how even a seq +> scan could result in a runtime of nearly 5 minutes in these +> circumstances. +> +> Also, doing a count( * ) from each table individually returns nearly +> instantly. +> +> I can provide details of postgresql.conf and kernel settings if +> necessary, but I'm using some pretty well tested settings that I use +> any time I admin a postgres installation these days based on box +> resources and database size. I'm more interested in knowing if there +> are any bird's eye details I should be checking immediately. +> +> Thanks. +> +> -tfo +> +> -- +> Thomas F. O'Connell +> Co-Founder, Information Architect +> Sitening, LLC +> http://www.sitening.com/ +> 110 30th Avenue North, Suite 6 +> Nashville, TN 37203-6320 +> 615-260-0005 +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 8: explain analyze is your friend + + +From pgsql-performance-owner@postgresql.org Mon Oct 25 16:58:07 2004 +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 4C28C32A06A + for ; + Thu, 21 Oct 2004 22:21:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69877-05 + for ; + Thu, 21 Oct 2004 21:20:47 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id DBBA532A5A2 + for ; + Thu, 21 Oct 2004 22:20:48 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9LLKjJ7070808 + for ; Thu, 21 Oct 2004 21:20:45 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9LL4ul7065956 + for pgsql-performance@postgresql.org; Thu, 21 Oct 2004 21:04:56 GMT +From: Bricklen +User-Agent: Mozilla Thunderbird 0.8 (X11/20040926) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Performance Anomalies in 7.4.5 +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 69 +Message-ID: <_vVdd.31479$z96.8087@clgrps12> +Date: Thu, 21 Oct 2004 21:04:58 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200410/415 +X-Sequence-Number: 8891 + +Thomas F.O'Connell wrote: +> I'm seeing some weird behavior on a repurposed server that was wiped +> clean and set up to run as a database and application server with +> postgres and Apache, as well as some command-line PHP scripts. +> +> The box itself is a quad processor (2.4 GHz Intel Xeons) Debian woody +> GNU/Linux (2.6.2) system. +> +> postgres is crawling on some fairly routine queries. I'm wondering if +> this could somehow be related to the fact that this isn't a +> database-only server, but Apache is not really using any resources when +> postgres slows to a crawl. +> +> Here's an example of analysis of a recent query: +> +> EXPLAIN ANALYZE SELECT COUNT(DISTINCT u.id) +> FROM userdata as u, userdata_history as h +> WHERE h.id = '18181' +> AND h.id = u.id; +> +> QUERY PLAN +> ------------------------------------------------------------------------ +> ------------------------------------------------------------------------ +> Aggregate (cost=0.02..0.02 rows=1 width=8) (actual +> time=298321.421..298321.422 rows=1 loops=1) +> -> Nested Loop (cost=0.00..0.01 rows=1 width=8) (actual +> time=1.771..298305.531 rows=2452 loops=1) +> Join Filter: ("inner".id = "outer".id) +> -> Seq Scan on userdata u (cost=0.00..0.00 rows=1 width=8) +> (actual time=0.026..11.869 rows=2452 loops=1) +> -> Seq Scan on userdata_history h (cost=0.00..0.00 rows=1 +> width=8) (actual time=0.005..70.519 rows=41631 loops=2452) +> Filter: (id = 18181::bigint) +> Total runtime: 298321.926 ms +> (7 rows) +> +> userdata has a primary/foreign key on id, which references +> userdata_history.id, which is a primary key. +> +> At the time of analysis, the userdata table had < 2,500 rows. +> userdata_history had < 50,000 rows. I can't imagine how even a seq scan +> could result in a runtime of nearly 5 minutes in these circumstances. +> +> Also, doing a count( * ) from each table individually returns nearly +> instantly. +> +> I can provide details of postgresql.conf and kernel settings if +> necessary, but I'm using some pretty well tested settings that I use +> any time I admin a postgres installation these days based on box +> resources and database size. I'm more interested in knowing if there +> are any bird's eye details I should be checking immediately. +> +> Thanks. +> +> -tfo +> +> -- +> Thomas F. O'Connell +> Co-Founder, Information Architect +> Sitening, LLC +> http://www.sitening.com/ +> 110 30th Avenue North, Suite 6 +> Nashville, TN 37203-6320 +> 615-260-0005 + +Is your enable_seqscan set to true? +Try it after issuing set enable_seqscan to off; + + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 22:05:27 2004 +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 BDDDC32A540 + for ; + Thu, 21 Oct 2004 22:05:26 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65708-01 + for ; + Thu, 21 Oct 2004 21:05:22 +0000 (GMT) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id D8A2A329F05 + for ; + Thu, 21 Oct 2004 22:05:22 +0100 (BST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id D74E38467; Thu, 21 Oct 2004 23:05:20 +0200 (CEST) +Date: Thu, 21 Oct 2004 23:05:20 +0200 (CEST) +From: Dennis Bjorklund +To: "Thomas F.O'Connell" +Cc: PgSQL - Performance +Subject: Re: Performance Anomalies in 7.4.5 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/366 +X-Sequence-Number: 8842 + +On Thu, 21 Oct 2004, Thomas F.O'Connell wrote: + +> Aggregate (cost=0.02..0.02 rows=1 width=8) (actual +> time=298321.421..298321.422 rows=1 loops=1) +> -> Nested Loop (cost=0.00..0.01 rows=1 width=8) (actual +> time=1.771..298305.531 rows=2452 loops=1) +> Join Filter: ("inner".id = "outer".id) +> -> Seq Scan on userdata u (cost=0.00..0.00 rows=1 width=8) +> (actual time=0.026..11.869 rows=2452 loops=1) +> -> Seq Scan on userdata_history h (cost=0.00..0.00 rows=1 +> width=8) (actual time=0.005..70.519 rows=41631 loops=2452) +> Filter: (id = 18181::bigint) + +It looks like you have not run ANALYZE recently. Most people run VACUUM +ANALYZE every night (or similar) in a cron job. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Thu Oct 21 22:11:58 2004 +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 A3D71329F05 + for ; + Thu, 21 Oct 2004 22:11:56 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67153-02 + for ; + Thu, 21 Oct 2004 21:11:44 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id CBABA32A2BF + for ; + Thu, 21 Oct 2004 22:11:44 +0100 (BST) +Received: (qmail 29794 invoked from network); 21 Oct 2004 21:11:43 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.22?) + (64.3.242.80) by 0 with SMTP; 21 Oct 2004 21:11:43 -0000 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Message-Id: +Content-Transfer-Encoding: quoted-printable +Cc: PgSQL - Performance +From: Thomas F.O'Connell +Subject: Re: Performance Anomalies in 7.4.5 +Date: Thu, 21 Oct 2004 16:11:39 -0500 +To: Dennis Bjorklund +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/367 +X-Sequence-Number: 8843 + +The irony is that I had just disabled pg_autovacuum the previous day=20 +during analysis of a wider issue affecting imports of data into the=20 +system. + +-tfo + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-260-0005 + +On Oct 21, 2004, at 4:05 PM, Dennis Bjorklund wrote: + +> On Thu, 21 Oct 2004, Thomas F.O'Connell wrote: +> +>> Aggregate (cost=3D0.02..0.02 rows=3D1 width=3D8) (actual +>> time=3D298321.421..298321.422 rows=3D1 loops=3D1) +>> -> Nested Loop (cost=3D0.00..0.01 rows=3D1 width=3D8) (actual +>> time=3D1.771..298305.531 rows=3D2452 loops=3D1) +>> Join Filter: ("inner".id =3D "outer".id) +>> -> Seq Scan on userdata u (cost=3D0.00..0.00 rows=3D1 width= +=3D8) +>> (actual time=3D0.026..11.869 rows=3D2452 loops=3D1) +>> -> Seq Scan on userdata_history h (cost=3D0.00..0.00 rows=3D1 +>> width=3D8) (actual time=3D0.005..70.519 rows=3D41631 loops=3D2452) +>> Filter: (id =3D 18181::bigint) +> +> It looks like you have not run ANALYZE recently. Most people run VACUUM +> ANALYZE every night (or similar) in a cron job. +> +> --=20 +> /Dennis Bj=F6rklund + +From pgsql-performance-owner@postgresql.org Thu Oct 21 22:53:29 2004 +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 94C3B32A6C8 + for ; + Thu, 21 Oct 2004 22:53:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79473-04 + for ; + Thu, 21 Oct 2004 21:53: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 CF0B832A65B + for ; + Thu, 21 Oct 2004 22:53:19 +0100 (BST) +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 i9LLrJ1b025229; + Thu, 21 Oct 2004 17:53:19 -0400 (EDT) +To: "Thomas F.O'Connell" +Cc: PgSQL - Performance +Subject: Re: Performance Anomalies in 7.4.5 +In-reply-to: +References: +Comments: In-reply-to "Thomas F.O'Connell" + message dated "Thu, 21 Oct 2004 15:36:02 -0500" +Date: Thu, 21 Oct 2004 17:53:19 -0400 +Message-ID: <25228.1098395599@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/368 +X-Sequence-Number: 8844 + +"Thomas F.O'Connell" writes: +> -> Nested Loop (cost=0.00..0.01 rows=1 width=8) (actual +> time=1.771..298305.531 rows=2452 loops=1) +> Join Filter: ("inner".id = "outer".id) +> -> Seq Scan on userdata u (cost=0.00..0.00 rows=1 width=8) +> (actual time=0.026..11.869 rows=2452 loops=1) +> -> Seq Scan on userdata_history h (cost=0.00..0.00 rows=1 +> width=8) (actual time=0.005..70.519 rows=41631 loops=2452) +> Filter: (id = 18181::bigint) +> Total runtime: 298321.926 ms +> (7 rows) + +What's killing you here is that the planner thinks these tables are +completely empty (notice the zero cost estimates, which implies the +table has zero blocks --- the fact that the rows estimate is 1 and not 0 +is the result of sanity-check clamping inside costsize.c). This leads +it to choose a nestloop, which would be the best plan if there were only +a few rows involved, but it degenerates rapidly when there are not. + +It's easy to fall into this trap when truncating and reloading tables; +all you need is an "analyze" while the table is empty. The rule of +thumb is to analyze just after you reload the table, not just before. + +I'm getting more and more convinced that we need to drop the reltuples +and relpages entries in pg_class, in favor of checking the physical +table size whenever we make a plan. We could derive the tuple count +estimate by having ANALYZE store a tuples-per-page estimate in pg_class +and then multiply by the current table size; tuples-per-page should be +a much more stable figure than total tuple count. + +One drawback to this is that it would require an additional lseek per +table while planning, but that doesn't seem like a huge penalty. + +Probably the most severe objection to doing things this way is that the +selected plan could change unexpectedly as a result of the physical +table size changing. Right now the DBA can keep tight rein on actions +that might affect plan selection (ie, VACUUM and ANALYZE), but that +would go by the board with this. OTOH, we seem to be moving towards +autovacuum, which also takes away any guarantees in this department. + +In any case this is speculation for 8.1; I think it's too late for 8.0. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Oct 21 23:11:15 2004 +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 758A432A773 + for ; + Thu, 21 Oct 2004 23:11:14 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83591-09 + for ; + Thu, 21 Oct 2004 22:11:02 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with ESMTP id 95CA032A774 + for ; + Thu, 21 Oct 2004 23:11:03 +0100 (BST) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 9DCE61C8F3; Thu, 21 Oct 2004 22:11:00 +0000 (GMT) +Date: Thu, 21 Oct 2004 17:11:00 -0500 +From: "Jim C. Nasby" +To: Steve Atkins +Cc: pgsql-performance@postgresql.org +Subject: Re: Does PostgreSQL run with Oracle? +Message-ID: <20041021221100.GI68407@decibel.org> +References: + <20041015171948.GA14759@gp.word-to-the-wise.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20041015171948.GA14759@gp.word-to-the-wise.com> +X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/369 +X-Sequence-Number: 8845 + +On Fri, Oct 15, 2004 at 10:19:48AM -0700, Steve Atkins wrote: +> On Fri, Oct 15, 2004 at 11:54:44AM -0500, Richard_D_Levine@raytheon.com wrote: +> > My basic question to the community is "is PostgreSQL approximately as fast +> > as Oracle?" +> +> > I'm currently running single processor UltraSPARC workstations, and intend +> > to use Intel Arch laptops and Linux. The application is a big turnkey +> > workstation app. I know the hardware switch alone will enhance +> > performance, and may do so to the point where even a slower database will +> > still be adequate. +> +> I have found that PostgreSQL seems to perform poorly on Solaris/SPARC +> (less so after recent improvements, but still...) compared to x86 +> systems - more so than the delta between Oracle on the two platforms. +> Just a gut impression, but it might mean that comparing the two +> databases on SPARC may not be that useful comparison if you're +> planning to move to x86. + +As a point of reference, an IBM hardware sales rep I worked with a few +years ago told me that he got a lot of sales from Oracle shops that were +running Sun and switched to RS/6000. Basically, for a given workload, it +would take 2x the number of Sun CPUs as RS/6000 CPUs. The difference in +Oracle licensing costs was usually enough to pay for the new hardware in +one year. +-- +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 Thu Oct 21 23:15:11 2004 +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 F355932A7B8 + for ; + Thu, 21 Oct 2004 23:15:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85537-04 + for ; + Thu, 21 Oct 2004 22:14:56 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with ESMTP id C07BD32A7A8 + for ; + Thu, 21 Oct 2004 23:14:57 +0100 (BST) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 3D6851C8F3; Thu, 21 Oct 2004 22:14:57 +0000 (GMT) +Date: Thu, 21 Oct 2004 17:14:57 -0500 +From: "Jim C. Nasby" +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, Matt Clark , + Tom Fischer +Subject: Re: OS desicion +Message-ID: <20041021221457.GJ68407@decibel.org> +References: <20041020151015.766bb00c@nixe> <417666C9.80008@ymogen.net> + <200410200938.51391.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200410200938.51391.josh@agliodbs.com> +X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/370 +X-Sequence-Number: 8846 + +On Wed, Oct 20, 2004 at 09:38:51AM -0700, Josh Berkus wrote: +> Tom, +> +> > You are asking the wrong question. The best OS is the OS you (and/or +> > the customer) knows and can administer competently. +> +> I'll have to 2nd this. + +I'll 3rd but add one tidbit: FreeBSD will schedule disk I/O based on +process priority, while linux won't. This can be very handy for things +like vacuum. +-- +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 Thu Oct 21 23:20:19 2004 +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 73BDC32A014 + for ; + Thu, 21 Oct 2004 23:18:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86773-05 + for ; + Thu, 21 Oct 2004 22:18:29 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with ESMTP id BEBB1329E15 + for ; + Thu, 21 Oct 2004 23:18:31 +0100 (BST) +Received: by flake.decibel.org (Postfix, from userid 1001) + id A12511C8F7; Thu, 21 Oct 2004 22:18:30 +0000 (GMT) +Date: Thu, 21 Oct 2004 17:18:30 -0500 +From: "Jim C. Nasby" +To: pgsql-performance@postgresql.org +Subject: Re: Anything to be gained from a 'Postgres Filesystem'? +Message-ID: <20041021221830.GK68407@decibel.org> +References: <008601c4b743$aff57f10$8300a8c0@solent> + <20041021102727.GB586@uio.no> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20041021102727.GB586@uio.no> +X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/371 +X-Sequence-Number: 8847 + +Note that most people are now moving away from raw devices for databases +in most applicaitons. The relatively small performance gain isn't worth +the hassles. + +On Thu, Oct 21, 2004 at 12:27:27PM +0200, Steinar H. Gunderson wrote: +> On Thu, Oct 21, 2004 at 08:58:01AM +0100, Matt Clark wrote: +> > I suppose I'm just idly wondering really. Clearly it's against PG +> > philosophy to build an FS or direct IO management into PG, but now it's so +> > relatively easy to plug filesystems into the main open-source Oses, It +> > struck me that there might be some useful changes to, say, XFS or ext3, that +> > could be made that would help PG out. +> +> This really sounds like a poor replacement for just making PostgreSQL use raw +> devices to me. (I have no idea why that isn't done already, but presumably it +> isn't all that easy to get right. :-) ) +> +> /* Steinar */ +> -- +> Homepage: http://www.sesse.net/ +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> + +-- +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 Thu Oct 21 23:21:43 2004 +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 2DE3232A7BC + for ; + Thu, 21 Oct 2004 23:21:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86184-10 + for ; + Thu, 21 Oct 2004 22:21:34 +0000 (GMT) +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 859C532A79B + for ; + Thu, 21 Oct 2004 23:21:35 +0100 (BST) +Received: from gary (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id 38221FBBB7 + for ; + Thu, 21 Oct 2004 23:22:11 +0100 (BST) +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Thu, 21 Oct 2004 23:21:35 +0100 +MIME-Version: 1.0 +Subject: Re: Performance Anomalies in 7.4.5 +Message-ID: <4178447F.961.6D7BBB5B@localhost> +In-reply-to: +References: +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/372 +X-Sequence-Number: 8848 + +On 21 Oct 2004 at 15:50, Thomas F.O'Connell wrote: + +> If not, should I be REINDEXing manually, as well as VACUUMing manually +> after large data imports (whether via COPY or INSERT)? Or will a VACUUM +> FULL ANALYZE be enough? +> + +It's not the vacuuming that's important here, just the analyze. If you import any data into +a table, Postgres often does not *know* that until you gather the statistics on the table. +You are simply running into the problem of the planner not knowing how much +data/distribution of data in your tables. + +If you have large imports it may be faster overall to drop the indexes first, then insert the +data, then put the indexes back on, then analyze. + +Cheers, +Gary. + + +From pgsql-performance-owner@postgresql.org Fri Oct 22 04:15:10 2004 +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 48BDD32B22A + for ; + Fri, 22 Oct 2004 04:15:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61668-02 + for ; + Fri, 22 Oct 2004 03:14:55 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.198]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C5E132A33D + for ; + Fri, 22 Oct 2004 04:14:58 +0100 (BST) +Received: by rproxy.gmail.com with SMTP id 77so140208rnk + for ; + Thu, 21 Oct 2004 20:14:59 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=W68+CTdasbZBZnZb+NTQQjE3pIm8JZ2N0KCS1SZO5xLQl9uJ8kR8d8s4tirp+9VXBYtG7gpTUxXOUrNAGPChLqTJZMa3jZLSLEGYDWcbW3isDE1h1O8COe6foYIGBXS8L5CmAZksehXRO9mJkwDxRLZ9NwkhFir/UzU1CVBRxAA= +Received: by 10.38.14.9 with SMTP id 9mr3188075rnn; + Thu, 21 Oct 2004 20:14:59 -0700 (PDT) +Received: by 10.38.77.73 with HTTP; Thu, 21 Oct 2004 20:14:59 -0700 (PDT) +Message-ID: <38242de904102120143c55ba34@mail.gmail.com> +Date: Thu, 21 Oct 2004 21:14:59 -0600 +From: Joshua Marsh +Reply-To: Joshua Marsh +To: pgsql-performance@postgresql.org +Subject: Large Database Performance suggestions +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/373 +X-Sequence-Number: 8849 + +Hello everyone, + +I am currently working on a data project that uses PostgreSQL +extensively to store, manage and maintain the data. We haven't had +any problems regarding database size until recently. The three major +tables we use never get bigger than 10 million records. With this +size, we can do things like storing the indexes or even the tables in +memory to allow faster access. + +Recently, we have found customers who are wanting to use our service +with data files between 100 million and 300 million records. At that +size, each of the three major tables will hold between 150 million and +700 million records. At this size, I can't expect it to run queries +in 10-15 seconds (what we can do with 10 million records), but would +prefer to keep them all under a minute. + +We did some original testing and with a server with 8GB or RAM and +found we can do operations on data file up to 50 million fairly well, +but performance drop dramatically after that. Does anyone have any +suggestions on a good way to improve performance for these extra large +tables? Things that have come to mind are Replication and Beowulf +clusters, but from what I have recently studied, these don't do so wel +with singular processes. We will have parallel process running, but +it's more important that the speed of each process be faster than +several parallel processes at once. + +Any help would be greatly appreciated! + +Thanks, + +Joshua Marsh + +P.S. Off-topic, I have a few invitations to gmail. If anyone would +like one, let me know. + +From pgsql-performance-owner@postgresql.org Fri Oct 22 04:30:21 2004 +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 3F1A132B22A + for ; + Fri, 22 Oct 2004 04:30:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63835-05 + for ; + Fri, 22 Oct 2004 03:30:07 +0000 (GMT) +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 60C9A32A681 + for ; + Fri, 22 Oct 2004 04:30:08 +0100 (BST) +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.11.6/8.11.4) with ESMTP id i9M3TvN31573; + Fri, 22 Oct 2004 13:29:57 +1000 +Date: Fri, 22 Oct 2004 13:29:57 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Joshua Marsh +Cc: pgsql-performance@postgresql.org +Subject: Re: Large Database Performance suggestions +In-Reply-To: <38242de904102120143c55ba34@mail.gmail.com> +Message-ID: +References: <38242de904102120143c55ba34@mail.gmail.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/374 +X-Sequence-Number: 8850 + +On Thu, 21 Oct 2004, Joshua Marsh wrote: + +> Recently, we have found customers who are wanting to use our service +> with data files between 100 million and 300 million records. At that +> size, each of the three major tables will hold between 150 million and +> 700 million records. At this size, I can't expect it to run queries +> in 10-15 seconds (what we can do with 10 million records), but would +> prefer to keep them all under a minute. + +To provide any useful information, we'd need to look at your table schemas +and sample queries. + +The values for sort_mem and shared_buffers will also be useful. + +Are you VACUUMing and ANALYZEing? (or is the data read only?)) + +gavin + +From pgsql-performance-owner@postgresql.org Fri Oct 22 04:37:05 2004 +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 6EF9932B22F + for ; + Fri, 22 Oct 2004 04:37:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65995-04 + for ; + Fri, 22 Oct 2004 03:36: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 D460832A33D + for ; + Fri, 22 Oct 2004 04:37:00 +0100 (BST) +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 i9M3b1CX002569; + Thu, 21 Oct 2004 23:37:01 -0400 (EDT) +To: Joshua Marsh +Cc: pgsql-performance@postgresql.org +Subject: Re: Large Database Performance suggestions +In-reply-to: <38242de904102120143c55ba34@mail.gmail.com> +References: <38242de904102120143c55ba34@mail.gmail.com> +Comments: In-reply-to Joshua Marsh + message dated "Thu, 21 Oct 2004 21:14:59 -0600" +Date: Thu, 21 Oct 2004 23:37:00 -0400 +Message-ID: <2568.1098416220@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/375 +X-Sequence-Number: 8851 + +Joshua Marsh writes: +> ... We did some original testing and with a server with 8GB or RAM and +> found we can do operations on data file up to 50 million fairly well, +> but performance drop dramatically after that. + +What you have to ask is *why* does it drop dramatically? There aren't +any inherent limits in Postgres that are going to kick in at that level. +I'm suspicious that you could improve the situation by adjusting +sort_mem and/or other configuration parameters; but there's not enough +info here to make specific recommendations. I would suggest posting +EXPLAIN ANALYZE results for your most important queries both in the size +range where you are getting good results, and the range where you are not. +Then we'd have something to chew on. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 22 05:13:04 2004 +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 BF70A329E73 + for ; + Fri, 22 Oct 2004 05:13:01 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74172-03 + for ; + Fri, 22 Oct 2004 04:12: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 1B57A32A154 + for ; + Fri, 22 Oct 2004 05:12:48 +0100 (BST) +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 i9M4CiNN002824; + Fri, 22 Oct 2004 00:12:44 -0400 (EDT) +To: Sean Chittenden +Cc: Kevin Brown , + pgsql-performance@postgresql.org +Subject: Re: mmap (was First set of OSDL Shared Mem scalability results, + some wierdness ... +In-reply-to: +References: <157f64840410141725162e43b5@mail.gmail.com> + <20041015010841.GE665@filer> + <0E3BB9CB-1EE6-11D9-A0BB-000A95C705DC@chittenden.org> + <26390.1097875346@sss.pgh.pa.us> + +Comments: In-reply-to Sean Chittenden + message dated "Thu, 21 Oct 2004 13:29:34 -0700" +Date: Fri, 22 Oct 2004 00:12:44 -0400 +Message-ID: <2823.1098418364@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/376 +X-Sequence-Number: 8852 + +Sean Chittenden writes: +> When a backend wishes to write a page, the following steps are taken: +> ... +> 2) Backend mmap(2)'s a second copy of the page(s) being written to, +> this time with the MAP_PRIVATE flag set. +> ... +> 5) Once the WAL logging is complete and it has hit the disk, the +> backend msync(2)'s its private copy of the pages to disk (ASYNC or +> SYNC, it doesn't really matter too much to me). + +My man page for mmap says that changes in a MAP_PRIVATE region are +private; they do not affect the file at all, msync or no. So I don't +think the above actually works. + +In any case, this scheme still forces you to flush WAL records to disk +before making the changed page visible to other backends, so I don't +see how it improves the situation. In the existing scheme we only have +to fsync WAL at (1) transaction commit, (2) when we are forced to write +a page out from shared buffers because we are short of buffers, or (3) +checkpoint. Anything that implies an fsync per atomic action is going +to be a loser. It does not matter how great your kernel API is if you +only get to perform one atomic action per disk rotation :-( + +The important point here is that you can't postpone making changes at +the page level visible to other backends; there's no MVCC at this level. +Consider for example two backends wanting to insert a new row. If they +both MAP_PRIVATE the same page, they'll probably choose the same tuple +slot on the page to insert into (certainly there is nothing to stop that +from happening). Now you have conflicting definitions for the same +CTID, not to mention probably conflicting uses of the page's physical +free space; disaster ensues. So "atomic action" really means "lock +page, make changes, add WAL record to in-memory WAL buffers, unlock +page" with the understanding that as soon as you unlock the page the +changes you've made in it are visible to all other backends. You +*can't* afford to put a WAL fsync in this sequence. + +You could possibly buy back most of the lossage in this scenario if +there were some efficient way for a backend to hold the low-level lock +on a page just until some other backend wanted to modify the page; +whereupon the previous owner would have to do what's needed to make his +changes visible before releasing the lock. Given the right access +patterns you don't have to fsync very often (though given the wrong +access patterns you're still in deep trouble). But we don't have any +such mechanism and I think the communication costs of one would be +forbidding. + +> [ much snipped ] +> 4) Not having shared pages get lost when the backend dies (mmap(2) uses +> refcounts and cleans itself up, no need for ipcs/ipcrm/ipcclean). + +Actually, that is not a bug that's a feature. One of the things that +scares me about mmap is that a crashing backend is able to scribble all +over live disk buffers before it finally SEGV's (think about memcpy gone +wrong and similar cases). In our existing scheme there's a pretty good +chance that we will be able to commit hara-kiri before any of the +trashed data gets written out. In an mmap scheme, it's time to dig out +your backup tapes, because there simply is no distinction between +transient and permanent data --- the kernel has no way to know that you +didn't mean it. + +In short, I remain entirely unconvinced that mmap is of any interest to us. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 22 06:01:35 2004 +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 6BC2932B2B3 + for ; + Fri, 22 Oct 2004 06:01:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85741-02 + for ; + Fri, 22 Oct 2004 05:01:15 +0000 (GMT) +Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net + [63.231.195.114]) + by svr1.postgresql.org (Postfix) with SMTP id 0DC0232B2A9 + for ; + Fri, 22 Oct 2004 06:01:18 +0100 (BST) +Received: (qmail 61471 invoked by uid 0); 22 Oct 2004 05:01:19 -0000 +Received: from mpls-pop-14.inet.qwest.net (63.231.195.14) + by mpls-qmqp-03.inet.qwest.net with QMQP; 22 Oct 2004 05:01:19 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-14.inet.qwest.net with SMTP; 22 Oct 2004 05:01:18 -0000 +Date: Thu, 21 Oct 2004 23:03:34 -0600 +Message-Id: <1098421413.21035.78.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Joshua Marsh" +Cc: pgsql-performance@postgresql.org +Subject: Re: Large Database Performance suggestions +In-Reply-To: <38242de904102120143c55ba34@mail.gmail.com> +References: <38242de904102120143c55ba34@mail.gmail.com> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/377 +X-Sequence-Number: 8853 + +On Thu, 2004-10-21 at 21:14, Joshua Marsh wrote: +> Hello everyone, +> +> I am currently working on a data project that uses PostgreSQL +> extensively to store, manage and maintain the data. We haven't had +> any problems regarding database size until recently. The three major +> tables we use never get bigger than 10 million records. With this +> size, we can do things like storing the indexes or even the tables in +> memory to allow faster access. +> +> Recently, we have found customers who are wanting to use our service +> with data files between 100 million and 300 million records. At that +> size, each of the three major tables will hold between 150 million and +> 700 million records. At this size, I can't expect it to run queries +> in 10-15 seconds (what we can do with 10 million records), but would +> prefer to keep them all under a minute. +> +> We did some original testing and with a server with 8GB or RAM and +> found we can do operations on data file up to 50 million fairly well, +> but performance drop dramatically after that. Does anyone have any +> suggestions on a good way to improve performance for these extra large +> tables? Things that have come to mind are Replication and Beowulf +> clusters, but from what I have recently studied, these don't do so wel +> with singular processes. We will have parallel process running, but +> it's more important that the speed of each process be faster than +> several parallel processes at once. + + +I'd assume that what's happening is that up to a certain data set size, +it all fits in memory, and you're going from CPU/memory bandwidth +limited to I/O limited. If this is the case, then a faster storage +subsystem is the only real answer. If the database is mostly read, then +a large RAID5 or RAID 1+0 array should help quite a bit. + +You might wanna post some explain analyze of the queries that are going +slower at some point in size, along with schema for those tables etc... + + +From pgsql-performance-owner@postgresql.org Fri Oct 22 12:38:37 2004 +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 8BBA6329E55 + for ; + Fri, 22 Oct 2004 12:38:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83997-10 + for ; + Fri, 22 Oct 2004 11:38:20 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id A1CE532A2F9 + for ; + Fri, 22 Oct 2004 12:38:26 +0100 (BST) +Received: (qmail 28191 invoked from network); 22 Oct 2004 11:39:50 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 22 Oct 2004 11:39:50 -0000 +Message-ID: <4178F149.9090408@fastcrypt.com> +Date: Fri, 22 Oct 2004 07:38:49 -0400 +From: Dave Cramer +Reply-To: pg@fastcrypt.com +Organization: Postgres International +User-Agent: Mozilla Thunderbird 0.8 (X11/20041001) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Joshua Marsh +Cc: pgsql-performance@postgresql.org +Subject: Re: Large Database Performance suggestions +References: <38242de904102120143c55ba34@mail.gmail.com> +In-Reply-To: <38242de904102120143c55ba34@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/378 +X-Sequence-Number: 8854 + +Josh, + +Your hardware setup would be useful too. It's surprising how slow some +big name servers really are. +If you are seriously considering memory sizes over 4G you may want to +look at an opteron. + +Dave + +Joshua Marsh wrote: + +>Hello everyone, +> +>I am currently working on a data project that uses PostgreSQL +>extensively to store, manage and maintain the data. We haven't had +>any problems regarding database size until recently. The three major +>tables we use never get bigger than 10 million records. With this +>size, we can do things like storing the indexes or even the tables in +>memory to allow faster access. +> +>Recently, we have found customers who are wanting to use our service +>with data files between 100 million and 300 million records. At that +>size, each of the three major tables will hold between 150 million and +>700 million records. At this size, I can't expect it to run queries +>in 10-15 seconds (what we can do with 10 million records), but would +>prefer to keep them all under a minute. +> +>We did some original testing and with a server with 8GB or RAM and +>found we can do operations on data file up to 50 million fairly well, +>but performance drop dramatically after that. Does anyone have any +>suggestions on a good way to improve performance for these extra large +>tables? Things that have come to mind are Replication and Beowulf +>clusters, but from what I have recently studied, these don't do so wel +>with singular processes. We will have parallel process running, but +>it's more important that the speed of each process be faster than +>several parallel processes at once. +> +>Any help would be greatly appreciated! +> +>Thanks, +> +>Joshua Marsh +> +>P.S. Off-topic, I have a few invitations to gmail. If anyone would +>like one, let me know. +> +>---------------------------(end of broadcast)--------------------------- +>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> +> +> +> + +-- +Dave Cramer +http://www.postgresintl.com +519 939 0336 +ICQ#14675561 + + +From pgsql-hackers-owner@postgresql.org Fri Oct 22 19:53:02 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7ED0DEAEDAB; + Fri, 22 Oct 2004 19:52:57 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25645-02; Fri, 22 Oct 2004 18:53:00 +0000 (GMT) +Received: from cmailm3.svr.pol.co.uk (cmailm3.svr.pol.co.uk [195.92.193.19]) + by svr1.postgresql.org (Postfix) with ESMTP id DAF64EAED89; + Fri, 22 Oct 2004 19:52:51 +0100 (BST) +Received: from modem-910.orangutan.dialup.pol.co.uk ([217.135.227.142] + helo=[192.168.0.102]) by cmailm3.svr.pol.co.uk with esmtp (Exim 4.41) + id 1CL4XE-0003h7-N3; Fri, 22 Oct 2004 19:53:09 +0100 +Subject: ARC Memory Usage analysis +From: Simon Riggs +To: pgsql-patches@postgresql.org, pgsql-hackers@postgresql.org +Cc: josh@agliodbs.com +Content-Type: multipart/mixed; boundary="=-yt9apKN4oP+msuzo0upS" +Organization: 2nd Quadrant +Message-Id: <1098471059.20926.49.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 22 Oct 2004 19:50:59 +0100 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/752 +X-Sequence-Number: 60255 + +--=-yt9apKN4oP+msuzo0upS +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +I've been using the ARC debug options to analyse memory usage on the +PostgreSQL 8.0 server. This is a precursor to more complex performance +analysis work on the OSDL test suite. + +I've simplified some of the ARC reporting into a single log line, which +is enclosed here as a patch on freelist.c. This includes reporting of: +- the total memory in use, which wasn't previously reported +- the cache hit ratio, which was slightly incorrectly calculated +- a useful-ish value for looking at the "B" lists in ARC +(This is a patch against cvstip, but I'm not sure whether this has +potential for inclusion in 8.0...) + +The total memory in use is useful because it allows you to tell whether +shared_buffers is set too high. If it is set too high, then memory usage +will continue to grow slowly up to the max, without any corresponding +increase in cache hit ratio. If shared_buffers is too small, then memory +usage will climb quickly and linearly to its maximum. + +The last one I've called "turbulence" in an attempt to ascribe some +useful meaning to B1/B2 hits - I've tried a few other measures though +without much success. Turbulence is the hit ratio of B1+B2 lists added +together. By observation, this is zero when ARC gives smooth operation, +and goes above zero otherwise. Typically, turbulence occurs when +shared_buffers is too small for the working set of the database/workload +combination and ARC repeatedly re-balances the lengths of T1/T2 as a +result of "near-misses" on the B1/B2 lists. Turbulence doesn't usually +cut in until the cache is fully utilized, so there is usually some delay +after startup. + +We also recently discussed that I would add some further memory analysis +features for 8.1, so I've been trying to figure out how. + +The idea that B1, B2 represent something really useful doesn't seem to +have been borne out - though I'm open to persuasion there. + +I originally envisaged a "shadow list" operating in extension of the +main ARC list. This will require some re-coding, since the variables and +macros are all hard-coded to a single set of lists. No complaints, just +it will take a little longer than we all thought (for me, that is...) + +My proposal is to alter the code to allow an array of memory linked +lists. The actual list would be [0] - other additional lists would be +created dynamically as required i.e. not using IFDEFs, since I want this +to be controlled by a SIGHUP GUC to allow on-site tuning, not just lab +work. This will then allow reporting against the additional lists, so +that cache hit ratios can be seen with various other "prototype" +shared_buffer settings. + +Any thoughts? + +-- +Best Regards, Simon Riggs + +--=-yt9apKN4oP+msuzo0upS +Content-Disposition: attachment; filename=freelist.patch +Content-Type: text/x-patch; name=freelist.patch; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Index: freelist.c +=================================================================== +RCS file: /projects/cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v +retrieving revision 1.48 +diff -d -c -r1.48 freelist.c +*** freelist.c 16 Sep 2004 16:58:31 -0000 1.48 +--- freelist.c 22 Oct 2004 18:15:38 -0000 +*************** +*** 126,131 **** +--- 126,133 ---- + if (StrategyControl->stat_report + DebugSharedBuffers < now) + { + long all_hit, ++ buf_used, ++ b_hit, + b1_hit, + t1_hit, + t2_hit, +*************** +*** 155,161 **** + } + + if (StrategyControl->num_lookup == 0) +! all_hit = b1_hit = t1_hit = t2_hit = b2_hit = 0; + else + { + b1_hit = (StrategyControl->num_hit[STRAT_LIST_B1] * 100 / +--- 157,163 ---- + } + + if (StrategyControl->num_lookup == 0) +! all_hit = buf_used = b_hit = b1_hit = t1_hit = t2_hit = b2_hit = 0; + else + { + b1_hit = (StrategyControl->num_hit[STRAT_LIST_B1] * 100 / +*************** +*** 166,181 **** + StrategyControl->num_lookup); + b2_hit = (StrategyControl->num_hit[STRAT_LIST_B2] * 100 / + StrategyControl->num_lookup); +! all_hit = b1_hit + t1_hit + t2_hit + b2_hit; + } + + errcxtold = error_context_stack; + error_context_stack = NULL; +! elog(DEBUG1, "ARC T1target=%5d B1len=%5d T1len=%5d T2len=%5d B2len=%5d", + T1_TARGET, B1_LENGTH, T1_LENGTH, T2_LENGTH, B2_LENGTH); +! elog(DEBUG1, "ARC total =%4ld%% B1hit=%4ld%% T1hit=%4ld%% T2hit=%4ld%% B2hit=%4ld%%", + all_hit, b1_hit, t1_hit, t2_hit, b2_hit); +! elog(DEBUG1, "ARC clean buffers at LRU T1= %5d T2= %5d", + t1_clean, t2_clean); + error_context_stack = errcxtold; + +--- 168,187 ---- + StrategyControl->num_lookup); + b2_hit = (StrategyControl->num_hit[STRAT_LIST_B2] * 100 / + StrategyControl->num_lookup); +! all_hit = t1_hit + t2_hit; +! b_hit = b1_hit + b2_hit; +! buf_used = T1_LENGTH + T2_LENGTH; + } + + errcxtold = error_context_stack; + error_context_stack = NULL; +! elog(DEBUG1, "shared_buffers used=%8ld cache hits=%4ld%% turbulence=%4ld%%", +! buf_used, all_hit, b_hit); +! elog(DEBUG2, "ARC T1target=%5d B1len=%5d T1len=%5d T2len=%5d B2len=%5d", + T1_TARGET, B1_LENGTH, T1_LENGTH, T2_LENGTH, B2_LENGTH); +! elog(DEBUG2, "ARC total =%4ld%% B1hit=%4ld%% T1hit=%4ld%% T2hit=%4ld%% B2hit=%4ld%%", + all_hit, b1_hit, t1_hit, t2_hit, b2_hit); +! elog(DEBUG2, "ARC clean buffers at LRU T1= %5d T2= %5d", + t1_clean, t2_clean); + error_context_stack = errcxtold; + + +--=-yt9apKN4oP+msuzo0upS-- + + +From pgsql-performance-owner@postgresql.org Fri Oct 22 20:06:26 2004 +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 7A36FEAEDBA + for ; + Fri, 22 Oct 2004 20:06:25 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29194-05 + for ; + Fri, 22 Oct 2004 19:06:24 +0000 (GMT) +Received: from exchange.musicreports.com (mail.musicreports.com + [64.161.179.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 75110EAEDA4 + for ; + Fri, 22 Oct 2004 20:06:14 +0100 (BST) +Received: from [192.168.20.70] (RG-HP-XP [192.168.20.70]) by + exchange.musicreports.com with SMTP (Microsoft Exchange + Internet Mail Service Version 5.5.2653.13) + id SSYKJPJ2; Fri, 22 Oct 2004 12:07:11 -0700 +Message-ID: <41795A35.4060802@paccomsys.com> +Date: Fri, 22 Oct 2004 12:06:30 -0700 +From: Roger Ging +User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Slow query +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/379 +X-Sequence-Number: 8855 + +The following query has never finished. I have let it run for over 24 +hours. This is a one time update that is part of a conversion script +from MSSQL data. All of the tables are freshly built and inserted +into. I have not run explain analyze because it does not return in a +reasonable time. Explain output is posted below. Any suggestions on +syntax changes or anything else to improve this would be appreciated. + +Dual PIII 1Ghz +4 GB RAM +4 spindle IDE RAID 0 on LSI controller. +Postgres 7.4.5 +Linux version 2.6.3-7mdk-p3-smp-64GB + +postgresql.cong snip: + +tcpip_socket = true +max_connections = 40 +shared_buffers = 1000 +sort_mem = 65536 +fsync = true + + +source_song_title +-10,500,000 rows +source_song +-9,500,000 rows +source_system 10 rows +source_title +- 5,600,000 + +Code run right before this query: +create index ssa_source_song_id on source_song_artist (source_song_id); +analyze source_song_artist; +create index sa_artist_id on source_artist (artist_id); +analyze source_artist; +create index ss_source_song_id on source_song (source_song_id); +analyze source_song; +create index st_title_id on source_title (title_id); +analyze source_title; + +source_song.source_song_id = int4 +source_song_title.source_song_id = int4 +source_title.title_id = int4 +source_song_title.title_id = int4 + +update source_song_title set +source_song_title_id = nextval('source_song_title_seq') +,licensing_match_order = (select licensing_match_order from +source_system where source_system_id = ss.source_system_id) +,affiliation_match_order = (select affiliation_match_order from +source_system where source_system_id = ss.source_system_id) +,title = st.title +from source_song_title sst +join source_song ss on ss.source_song_id = sst.source_song_id +join source_title st on st.title_id = sst.title_id +where source_song_title.source_song_id = sst.source_song_id; + + +Explain output: +"Hash Join (cost=168589.60..16651072.43 rows=6386404 width=335)" +" Hash Cond: ("outer".title_id = "inner".title_id)" +" -> Merge Join (cost=0.00..1168310.61 rows=6386403 width=311)" +" Merge Cond: ("outer".source_song_id = "inner".source_song_id)" +" -> Merge Join (cost=0.00..679279.40 rows=6386403 width=16)" +" Merge Cond: ("outer".source_song_id = +"inner".source_song_id)" +" -> Index Scan using source_song_title_pkey on +source_song_title sst (cost=0.00..381779.37 rows=10968719 width=8)" +" -> Index Scan using ss_source_song_id on source_song ss +(cost=0.00..190583.36 rows=6386403 width=8)" +" -> Index Scan using source_song_title_pkey on +source_song_title (cost=0.00..381779.37 rows=10968719 width=303)" +" -> Hash (cost=117112.08..117112.08 rows=5513808 width=32)" +" -> Seq Scan on source_title st (cost=0.00..117112.08 +rows=5513808 width=32)" +" SubPlan" +" -> Seq Scan on source_system (cost=0.00..1.14 rows=2 width=4)" +" Filter: (source_system_id = $0)" +" -> Seq Scan on source_system (cost=0.00..1.14 rows=2 width=2)" +" Filter: (source_system_id = $0)" + + +From pgsql-hackers-owner@postgresql.org Fri Oct 22 20:37:09 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E616EAE4A0 + for ; + Fri, 22 Oct 2004 20:37:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39963-04 + for ; + Fri, 22 Oct 2004 19:37:05 +0000 (GMT) +Received: from smtp016.mail.yahoo.com (smtp016.mail.yahoo.com + [216.136.174.113]) + by svr1.postgresql.org (Postfix) with SMTP id 4489EEAD274 + for ; + Fri, 22 Oct 2004 20:36:56 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp016.mail.yahoo.com with SMTP; 22 Oct 2004 19:37:15 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9MJbB94016993; Fri, 22 Oct 2004 15:37:12 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <41796115.2020501@Yahoo.com> +Date: Fri, 22 Oct 2004 15:35:49 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Simon Riggs +Cc: pgsql-patches@postgresql.org, pgsql-hackers@postgresql.org, + josh@agliodbs.com +Subject: Re: ARC Memory Usage analysis +References: <1098471059.20926.49.camel@localhost.localdomain> +In-Reply-To: <1098471059.20926.49.camel@localhost.localdomain> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/755 +X-Sequence-Number: 60258 + +On 10/22/2004 2:50 PM, Simon Riggs wrote: + +> I've been using the ARC debug options to analyse memory usage on the +> PostgreSQL 8.0 server. This is a precursor to more complex performance +> analysis work on the OSDL test suite. +> +> I've simplified some of the ARC reporting into a single log line, which +> is enclosed here as a patch on freelist.c. This includes reporting of: +> - the total memory in use, which wasn't previously reported +> - the cache hit ratio, which was slightly incorrectly calculated +> - a useful-ish value for looking at the "B" lists in ARC +> (This is a patch against cvstip, but I'm not sure whether this has +> potential for inclusion in 8.0...) +> +> The total memory in use is useful because it allows you to tell whether +> shared_buffers is set too high. If it is set too high, then memory usage +> will continue to grow slowly up to the max, without any corresponding +> increase in cache hit ratio. If shared_buffers is too small, then memory +> usage will climb quickly and linearly to its maximum. +> +> The last one I've called "turbulence" in an attempt to ascribe some +> useful meaning to B1/B2 hits - I've tried a few other measures though +> without much success. Turbulence is the hit ratio of B1+B2 lists added +> together. By observation, this is zero when ARC gives smooth operation, +> and goes above zero otherwise. Typically, turbulence occurs when +> shared_buffers is too small for the working set of the database/workload +> combination and ARC repeatedly re-balances the lengths of T1/T2 as a +> result of "near-misses" on the B1/B2 lists. Turbulence doesn't usually +> cut in until the cache is fully utilized, so there is usually some delay +> after startup. +> +> We also recently discussed that I would add some further memory analysis +> features for 8.1, so I've been trying to figure out how. +> +> The idea that B1, B2 represent something really useful doesn't seem to +> have been borne out - though I'm open to persuasion there. +> +> I originally envisaged a "shadow list" operating in extension of the +> main ARC list. This will require some re-coding, since the variables and +> macros are all hard-coded to a single set of lists. No complaints, just +> it will take a little longer than we all thought (for me, that is...) +> +> My proposal is to alter the code to allow an array of memory linked +> lists. The actual list would be [0] - other additional lists would be +> created dynamically as required i.e. not using IFDEFs, since I want this +> to be controlled by a SIGHUP GUC to allow on-site tuning, not just lab +> work. This will then allow reporting against the additional lists, so +> that cache hit ratios can be seen with various other "prototype" +> shared_buffer settings. + +All the existing lists live in shared memory, so that dynamic approach +suffers from the fact that the memory has to be allocated during ipc_init. + +What do you think about my other theory to make C actually 2x effective +cache size and NOT to keep T1 in shared buffers but to assume T1 lives +in the OS buffer cache? + + +Jan + +> +> Any thoughts? +> +> +> +> ------------------------------------------------------------------------ +> +> Index: freelist.c +> =================================================================== +> RCS file: /projects/cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v +> retrieving revision 1.48 +> diff -d -c -r1.48 freelist.c +> *** freelist.c 16 Sep 2004 16:58:31 -0000 1.48 +> --- freelist.c 22 Oct 2004 18:15:38 -0000 +> *************** +> *** 126,131 **** +> --- 126,133 ---- +> if (StrategyControl->stat_report + DebugSharedBuffers < now) +> { +> long all_hit, +> + buf_used, +> + b_hit, +> b1_hit, +> t1_hit, +> t2_hit, +> *************** +> *** 155,161 **** +> } +> +> if (StrategyControl->num_lookup == 0) +> ! all_hit = b1_hit = t1_hit = t2_hit = b2_hit = 0; +> else +> { +> b1_hit = (StrategyControl->num_hit[STRAT_LIST_B1] * 100 / +> --- 157,163 ---- +> } +> +> if (StrategyControl->num_lookup == 0) +> ! all_hit = buf_used = b_hit = b1_hit = t1_hit = t2_hit = b2_hit = 0; +> else +> { +> b1_hit = (StrategyControl->num_hit[STRAT_LIST_B1] * 100 / +> *************** +> *** 166,181 **** +> StrategyControl->num_lookup); +> b2_hit = (StrategyControl->num_hit[STRAT_LIST_B2] * 100 / +> StrategyControl->num_lookup); +> ! all_hit = b1_hit + t1_hit + t2_hit + b2_hit; +> } +> +> errcxtold = error_context_stack; +> error_context_stack = NULL; +> ! elog(DEBUG1, "ARC T1target=%5d B1len=%5d T1len=%5d T2len=%5d B2len=%5d", +> T1_TARGET, B1_LENGTH, T1_LENGTH, T2_LENGTH, B2_LENGTH); +> ! elog(DEBUG1, "ARC total =%4ld%% B1hit=%4ld%% T1hit=%4ld%% T2hit=%4ld%% B2hit=%4ld%%", +> all_hit, b1_hit, t1_hit, t2_hit, b2_hit); +> ! elog(DEBUG1, "ARC clean buffers at LRU T1= %5d T2= %5d", +> t1_clean, t2_clean); +> error_context_stack = errcxtold; +> +> --- 168,187 ---- +> StrategyControl->num_lookup); +> b2_hit = (StrategyControl->num_hit[STRAT_LIST_B2] * 100 / +> StrategyControl->num_lookup); +> ! all_hit = t1_hit + t2_hit; +> ! b_hit = b1_hit + b2_hit; +> ! buf_used = T1_LENGTH + T2_LENGTH; +> } +> +> errcxtold = error_context_stack; +> error_context_stack = NULL; +> ! elog(DEBUG1, "shared_buffers used=%8ld cache hits=%4ld%% turbulence=%4ld%%", +> ! buf_used, all_hit, b_hit); +> ! elog(DEBUG2, "ARC T1target=%5d B1len=%5d T1len=%5d T2len=%5d B2len=%5d", +> T1_TARGET, B1_LENGTH, T1_LENGTH, T2_LENGTH, B2_LENGTH); +> ! elog(DEBUG2, "ARC total =%4ld%% B1hit=%4ld%% T1hit=%4ld%% T2hit=%4ld%% B2hit=%4ld%%", +> all_hit, b1_hit, t1_hit, t2_hit, b2_hit); +> ! elog(DEBUG2, "ARC clean buffers at LRU T1= %5d T2= %5d", +> t1_clean, t2_clean); +> error_context_stack = errcxtold; +> +> +> +> ------------------------------------------------------------------------ +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-performance-owner@postgresql.org Fri Oct 22 20:40:56 2004 +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 52611EAD274 + for ; + Fri, 22 Oct 2004 20:40:55 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39736-10 + for ; + Fri, 22 Oct 2004 19:40:53 +0000 (GMT) +Received: from smtp100.rog.mail.re2.yahoo.com (smtp100.rog.mail.re2.yahoo.com + [206.190.36.78]) + by svr1.postgresql.org (Postfix) with SMTP id 8284AEAE4C2 + for ; + Fri, 22 Oct 2004 20:40:41 +0100 (BST) +Received: from unknown (HELO phlogiston.dydns.org) + (a.sullivan@rogers.com@65.49.125.184 with login) + by smtp100.rog.mail.re2.yahoo.com with SMTP; 22 Oct 2004 19:41:00 -0000 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id E608D4058; Fri, 22 Oct 2004 15:40:58 -0400 (EDT) +Date: Fri, 22 Oct 2004 15:40:58 -0400 +From: Andrew Sullivan +To: PgSQL - Performance +Subject: Re: Performance Anomalies in 7.4.5 +Message-ID: <20041022194058.GC22395@phlogiston.dyndns.org> +Mail-Followup-To: PgSQL - Performance +References: + <25228.1098395599@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <25228.1098395599@sss.pgh.pa.us> +User-Agent: Mutt/1.5.6+20040722i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/380 +X-Sequence-Number: 8856 + + +> Probably the most severe objection to doing things this way is that the +> selected plan could change unexpectedly as a result of the physical +> table size changing. Right now the DBA can keep tight rein on actions +> that might affect plan selection (ie, VACUUM and ANALYZE), but that +> would go by the board with this. OTOH, we seem to be moving towards +> autovacuum, which also takes away any guarantees in this department. + +But aren't we requiring that we can disable autovacuum on some +tables? I've actually used, more than once, the finger-on-the-scale +method of thumping values in pg_class when I had a pretty good idea +of how the table was changing, particularly when it would change in +such a way as to confuse the planner. There are still enough cases +where the planner doesn't quite get things right that I'd really +prefer the ability to give it clues, at least indirectly. I can't +imagine that there's going to be a lot of enthusiasm for hints, so +anything that isn't a sure-fire planner helper is a potential loss, +at least to me. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +I remember when computers were frustrating because they *did* exactly what +you told them to. That actually seems sort of quaint now. + --J.D. Baldwin + +From pgsql-hackers-owner@postgresql.org Mon Oct 25 01:19:33 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DC1BEAD7E2; + Fri, 22 Oct 2004 21:09:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48953-07; Fri, 22 Oct 2004 20:09:50 +0000 (GMT) +Received: from is.rice.edu (is.rice.edu [128.42.42.24]) + by svr1.postgresql.org (Postfix) with ESMTP id C7DD1EAE493; + Fri, 22 Oct 2004 21:09:41 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by localhost.is.rice.edu (Postfix) with ESMTP + id 85679419ED; Fri, 22 Oct 2004 15:10:01 -0500 (CDT) +Received: from is.rice.edu ([127.0.0.1]) + by localhost (it.is.rice.edu [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 02747-02; Fri, 22 Oct 2004 15:09:55 -0500 (CDT) +Received: by is.rice.edu (Postfix, from userid 18612) + id C5AB6419C1; Fri, 22 Oct 2004 15:09:55 -0500 (CDT) +Date: Fri, 22 Oct 2004 15:09:55 -0500 +From: Kenneth Marshall +To: Jan Wieck +Cc: Simon Riggs , + pgsql-patches@postgresql.org, pgsql-hackers@postgresql.org, + josh@agliodbs.com +Subject: Re: ARC Memory Usage analysis +Message-ID: <20041022200955.GC4382@it.is.rice.edu> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <41796115.2020501@Yahoo.com> +User-Agent: Mutt/1.4.2i +X-Virus-Scanned: by amavis-20030314-p2 at is.rice.edu +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/802 +X-Sequence-Number: 60305 + +On Fri, Oct 22, 2004 at 03:35:49PM -0400, Jan Wieck wrote: +> On 10/22/2004 2:50 PM, Simon Riggs wrote: +> +> >I've been using the ARC debug options to analyse memory usage on the +> >PostgreSQL 8.0 server. This is a precursor to more complex performance +> >analysis work on the OSDL test suite. +> > +> >I've simplified some of the ARC reporting into a single log line, which +> >is enclosed here as a patch on freelist.c. This includes reporting of: +> >- the total memory in use, which wasn't previously reported +> >- the cache hit ratio, which was slightly incorrectly calculated +> >- a useful-ish value for looking at the "B" lists in ARC +> >(This is a patch against cvstip, but I'm not sure whether this has +> >potential for inclusion in 8.0...) +> > +> >The total memory in use is useful because it allows you to tell whether +> >shared_buffers is set too high. If it is set too high, then memory usage +> >will continue to grow slowly up to the max, without any corresponding +> >increase in cache hit ratio. If shared_buffers is too small, then memory +> >usage will climb quickly and linearly to its maximum. +> > +> >The last one I've called "turbulence" in an attempt to ascribe some +> >useful meaning to B1/B2 hits - I've tried a few other measures though +> >without much success. Turbulence is the hit ratio of B1+B2 lists added +> >together. By observation, this is zero when ARC gives smooth operation, +> >and goes above zero otherwise. Typically, turbulence occurs when +> >shared_buffers is too small for the working set of the database/workload +> >combination and ARC repeatedly re-balances the lengths of T1/T2 as a +> >result of "near-misses" on the B1/B2 lists. Turbulence doesn't usually +> >cut in until the cache is fully utilized, so there is usually some delay +> >after startup. +> > +> >We also recently discussed that I would add some further memory analysis +> >features for 8.1, so I've been trying to figure out how. +> > +> >The idea that B1, B2 represent something really useful doesn't seem to +> >have been borne out - though I'm open to persuasion there. +> > +> >I originally envisaged a "shadow list" operating in extension of the +> >main ARC list. This will require some re-coding, since the variables and +> >macros are all hard-coded to a single set of lists. No complaints, just +> >it will take a little longer than we all thought (for me, that is...) +> > +> >My proposal is to alter the code to allow an array of memory linked +> >lists. The actual list would be [0] - other additional lists would be +> >created dynamically as required i.e. not using IFDEFs, since I want this +> >to be controlled by a SIGHUP GUC to allow on-site tuning, not just lab +> >work. This will then allow reporting against the additional lists, so +> >that cache hit ratios can be seen with various other "prototype" +> >shared_buffer settings. +> +> All the existing lists live in shared memory, so that dynamic approach +> suffers from the fact that the memory has to be allocated during ipc_init. +> +> What do you think about my other theory to make C actually 2x effective +> cache size and NOT to keep T1 in shared buffers but to assume T1 lives +> in the OS buffer cache? +> +> +> Jan +> +Jan, + + From the articles that I have seen on the ARC algorithm, I do not think +that using the effective cache size to set C would be a win. The design +of the ARC process is to allow the cache to optimize its use in response +to the actual workload. It may be the best use of the cache in some cases +to have the entire cache allocated to T1 and similarly for T2. If fact, +the ability to alter the behavior as needed is one of the key advantages. + +--Ken + +From pgsql-hackers-owner@postgresql.org Fri Oct 22 21:23:40 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A1E5EAE48B; + Fri, 22 Oct 2004 21:23:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51144-10; Fri, 22 Oct 2004 20:23:39 +0000 (GMT) +Received: from cmailg4.svr.pol.co.uk (cmailg4.svr.pol.co.uk [195.92.195.174]) + by svr1.postgresql.org (Postfix) with ESMTP id C6D2DEAD819; + Fri, 22 Oct 2004 21:23:30 +0100 (BST) +Received: from modem-1017.lemur.dialup.pol.co.uk ([217.135.131.249] + helo=[192.168.0.102]) by cmailg4.svr.pol.co.uk with esmtp (Exim 4.41) + id 1CL5wz-0001kY-HN; Fri, 22 Oct 2004 21:23:49 +0100 +Subject: Re: ARC Memory Usage analysis +From: Simon Riggs +To: Jan Wieck +Cc: pgsql-patches@postgresql.org, pgsql-hackers@postgresql.org, + josh@agliodbs.com +In-Reply-To: <41796115.2020501@Yahoo.com> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Message-Id: <1098476499.20926.100.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 22 Oct 2004 21:21:39 +0100 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/757 +X-Sequence-Number: 60260 + +On Fri, 2004-10-22 at 20:35, Jan Wieck wrote: +> On 10/22/2004 2:50 PM, Simon Riggs wrote: +> +> > +> > My proposal is to alter the code to allow an array of memory linked +> > lists. The actual list would be [0] - other additional lists would be +> > created dynamically as required i.e. not using IFDEFs, since I want this +> > to be controlled by a SIGHUP GUC to allow on-site tuning, not just lab +> > work. This will then allow reporting against the additional lists, so +> > that cache hit ratios can be seen with various other "prototype" +> > shared_buffer settings. +> +> All the existing lists live in shared memory, so that dynamic approach +> suffers from the fact that the memory has to be allocated during ipc_init. +> + +[doh] - dreaming again. Yes of course, server startup it is then. [That +way, we can include the memory for it at server startup, then allow the +GUC to be turned off after a while to avoid another restart?] + +> What do you think about my other theory to make C actually 2x effective +> cache size and NOT to keep T1 in shared buffers but to assume T1 lives +> in the OS buffer cache? + +Summarised like that, I understand it. + +My observation is that performance varies significantly between startups +of the database, which does indicate that the OS cache is working well. +So, yes it does seem as if we have a 3 tier cache. I understand you to +be effectively suggesting that we go back to having just a 2-tier cache. + +I guess we've got two options: +1. Keep ARC as it is, but just allocate much of the available physical +memory to shared_buffers, so you know that effective_cache_size is low +and that its either in T1 or its on disk. +2. Alter ARC so that we experiment with the view that T1 is in the OS +and T2 is in shared_buffers, we don't bother keeping T1. (as you say) + +Hmmm...I think I'll pass on trying to judge its effectiveness - +simplifying things is likely to make it easier to understand and predict +behaviour. It's well worth trying, and it seems simple enough to make a +patch that keeps T1target at zero. + +i.e. Scientific method: conjecture + experimental validation = theory + +If you make up a patch, probably against BETA4, Josh and I can include it in the performance testing that I'm hoping we can do over the next few weeks. + +Whatever makes 8.0 a high performance release is well worth it. + +Best Regards, + +Simon Riggs + + +From pgsql-hackers-owner@postgresql.org Fri Oct 22 21:45:30 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 11373EAE4A0 + for ; + Fri, 22 Oct 2004 21:45:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59322-05 + for ; + Fri, 22 Oct 2004 20:45:27 +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 C0115EAE492 + for ; + Fri, 22 Oct 2004 21:45:18 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp106.mail.sc5.yahoo.com with SMTP; 22 Oct 2004 20:45:38 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9MKjT94018232; Fri, 22 Oct 2004 16:45:29 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <41796DA0.30108@Yahoo.com> +Date: Fri, 22 Oct 2004 16:29:20 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Simon Riggs +Cc: pgsql-patches@postgresql.org, pgsql-hackers@postgresql.org, + josh@agliodbs.com +Subject: Re: ARC Memory Usage analysis +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> + <1098476499.20926.100.camel@localhost.localdomain> +In-Reply-To: <1098476499.20926.100.camel@localhost.localdomain> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/759 +X-Sequence-Number: 60262 + +On 10/22/2004 4:21 PM, Simon Riggs wrote: + +> On Fri, 2004-10-22 at 20:35, Jan Wieck wrote: +>> On 10/22/2004 2:50 PM, Simon Riggs wrote: +>> +>> > +>> > My proposal is to alter the code to allow an array of memory linked +>> > lists. The actual list would be [0] - other additional lists would be +>> > created dynamically as required i.e. not using IFDEFs, since I want this +>> > to be controlled by a SIGHUP GUC to allow on-site tuning, not just lab +>> > work. This will then allow reporting against the additional lists, so +>> > that cache hit ratios can be seen with various other "prototype" +>> > shared_buffer settings. +>> +>> All the existing lists live in shared memory, so that dynamic approach +>> suffers from the fact that the memory has to be allocated during ipc_init. +>> +> +> [doh] - dreaming again. Yes of course, server startup it is then. [That +> way, we can include the memory for it at server startup, then allow the +> GUC to be turned off after a while to avoid another restart?] +> +>> What do you think about my other theory to make C actually 2x effective +>> cache size and NOT to keep T1 in shared buffers but to assume T1 lives +>> in the OS buffer cache? +> +> Summarised like that, I understand it. +> +> My observation is that performance varies significantly between startups +> of the database, which does indicate that the OS cache is working well. +> So, yes it does seem as if we have a 3 tier cache. I understand you to +> be effectively suggesting that we go back to having just a 2-tier cache. + +Effectively yes, just with the difference that we keep a pseudo T1 list +and hope that what we are tracking there is what the OS is caching. As +said before, if the effective cache size is set properly, that is what +should happen. + +> +> I guess we've got two options: +> 1. Keep ARC as it is, but just allocate much of the available physical +> memory to shared_buffers, so you know that effective_cache_size is low +> and that its either in T1 or its on disk. +> 2. Alter ARC so that we experiment with the view that T1 is in the OS +> and T2 is in shared_buffers, we don't bother keeping T1. (as you say) +> +> Hmmm...I think I'll pass on trying to judge its effectiveness - +> simplifying things is likely to make it easier to understand and predict +> behaviour. It's well worth trying, and it seems simple enough to make a +> patch that keeps T1target at zero. + +Not keeping T1target at zero, because that would keep T2 at the size of +shared_buffers. What I suspect is that in the current calculation the +T1target is underestimated. It is incremented on B1 hits, but B1 is only +of T2 size. What it currently tells is what got pushed from T1 into the +OS cache. It could well be that it would work much more effective if it +would fuzzily tell what got pushed out of the OS cache to disk. + + +Jan + +> +> i.e. Scientific method: conjecture + experimental validation = theory +> +> If you make up a patch, probably against BETA4, Josh and I can include it in the performance testing that I'm hoping we can do over the next few weeks. +> +> Whatever makes 8.0 a high performance release is well worth it. +> +> Best Regards, +> +> Simon Riggs + + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-performance-owner@postgresql.org Fri Oct 22 21:37:10 2004 +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 F00AAEAD7E2 + for ; + Fri, 22 Oct 2004 21:37:09 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56489-04 + for ; + Fri, 22 Oct 2004 20:37: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 3CDFAEAC955 + for ; + Fri, 22 Oct 2004 21:36:59 +0100 (BST) +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 i9MKbEwk018708; + Fri, 22 Oct 2004 16:37:14 -0400 (EDT) +To: Roger Ging +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow query +In-reply-to: <41795A35.4060802@paccomsys.com> +References: <41795A35.4060802@paccomsys.com> +Comments: In-reply-to Roger Ging + message dated "Fri, 22 Oct 2004 12:06:30 -0700" +Date: Fri, 22 Oct 2004 16:37:14 -0400 +Message-ID: <18707.1098477434@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/381 +X-Sequence-Number: 8857 + +Roger Ging writes: +> update source_song_title set +> source_song_title_id = nextval('source_song_title_seq') +> ,licensing_match_order = (select licensing_match_order from +> source_system where source_system_id = ss.source_system_id) +> ,affiliation_match_order = (select affiliation_match_order from +> source_system where source_system_id = ss.source_system_id) +> ,title = st.title +> from source_song_title sst +> join source_song ss on ss.source_song_id = sst.source_song_id +> join source_title st on st.title_id = sst.title_id +> where source_song_title.source_song_id = sst.source_song_id; + +Why is "source_song_title sst" in there? To the extent that +source_song_id is not unique, you are multiply updating rows +because of the self-join. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Fri Oct 22 21:45:48 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B921CEAD819 + for ; + Fri, 22 Oct 2004 21:45:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58432-06 + for ; + Fri, 22 Oct 2004 20:45:44 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CF4FAEAE4A2 + for ; + Fri, 22 Oct 2004 21:45:36 +0100 (BST) +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 i9MKjpQZ018765; + Fri, 22 Oct 2004 16:45:51 -0400 (EDT) +To: Jan Wieck +Cc: Simon Riggs , + pgsql-patches@postgresql.org, pgsql-hackers@postgresql.org, + josh@agliodbs.com +Subject: Re: [PATCHES] ARC Memory Usage analysis +In-reply-to: <41796115.2020501@Yahoo.com> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> +Comments: In-reply-to Jan Wieck + message dated "Fri, 22 Oct 2004 15:35:49 -0400" +Date: Fri, 22 Oct 2004 16:45:51 -0400 +Message-ID: <18764.1098477951@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/760 +X-Sequence-Number: 60263 + +Jan Wieck writes: +> What do you think about my other theory to make C actually 2x effective +> cache size and NOT to keep T1 in shared buffers but to assume T1 lives +> in the OS buffer cache? + +What will you do when initially fetching a page? It's not supposed to +go directly into T2 on first use, but we're going to have some +difficulty accessing a page that's not in shared buffers. I don't think +you can equate the T1/T2 dichotomy to "is in shared buffers or not". + +You could maybe have a T3 list of "pages that aren't in shared buffers +anymore but we think are still in OS buffer cache", but what would be +the point? It'd be a sufficiently bad model of reality as to be pretty +much useless for stats gathering, I'd think. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 25 16:58:04 2004 +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 77955EAE4AB + for ; + Fri, 22 Oct 2004 21:55:40 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63013-04 + for ; + Fri, 22 Oct 2004 20:55:39 +0000 (GMT) +Received: from dbl.q-ag.de (dbl.q-ag.de [213.172.117.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 9813EEAC955 + for ; + Fri, 22 Oct 2004 21:55:28 +0100 (BST) +Received: from [127.0.0.2] (dbl [127.0.0.1]) + by dbl.q-ag.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i9MKtdSL004760; + Fri, 22 Oct 2004 22:55:40 +0200 +Message-ID: <417973CA.1090807@colorfullife.com> +Date: Fri, 22 Oct 2004 22:55:38 +0200 +From: Manfred Spraul +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.7.3) Gecko/20040922 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mark Wong +Cc: Tom Lane , neilc@samurai.com, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <417697A5.1050600@colorfullife.com> <7178.1098292535@sss.pgh.pa.us> + <4176A2C1.3070205@colorfullife.com> <20041020150528.B7838@osdl.org> + <41774D11.1030906@colorfullife.com> <20041021065458.A5580@osdl.org> +In-Reply-To: <20041021065458.A5580@osdl.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/414 +X-Sequence-Number: 8890 + +Mark Wong wrote: + +>Pretty, simple. One to load the database, and 1 to query it. I'll +>attach them. +> +> +> +I've tested it on my dual-cpu computer: +- it works, both cpus run within the postmaster. It seems something your +gentoo setup is broken. +- the number of context switch is down slightly, but not significantly: +The glibc implementation is more or less identical to the implementation +right now in lwlock.c: a spinlock that protects a few variables that are +used to implement the actual mutex, several wait queues: one for +spinlock busy, one or two for the actual mutex code. + +Around 25% of the context switches are from spinlock collisions, the +rest are from actual mutex collisions. It might be possible to get rid +of the spinlock collisions by writing a special, futex based semaphore +function that only supports exclusive access [like sem_wait/sem_post], +but I don't think that it's worth the effort: 75% of the context +switches would remain. +What's needed is a buffer manager that can do lookups without a global lock. + +-- + Manfred + +From pgsql-performance-owner@postgresql.org Fri Oct 22 22:13:12 2004 +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 04EEAEAE486 + for ; + Fri, 22 Oct 2004 22:13:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67643-07 + for ; + Fri, 22 Oct 2004 21:13:11 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 26798EAE4AC + for ; + Fri, 22 Oct 2004 22:13:02 +0100 (BST) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.66]) + by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) + (Exim 4.42) id 1CL6iu-0001Bf-BH; Fri, 22 Oct 2004 17:13:20 -0400 +Message-ID: <417977EE.8050207@zeut.net> +Date: Fri, 22 Oct 2004 17:13:18 -0400 +From: "Matthew T. O'Connor" +Organization: Terrie O'Connor Realtors +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Andrew Sullivan +Cc: PgSQL - Performance +Subject: Re: Performance Anomalies in 7.4.5 +References: + <25228.1098395599@sss.pgh.pa.us> + <20041022194058.GC22395@phlogiston.dyndns.org> +In-Reply-To: <20041022194058.GC22395@phlogiston.dyndns.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 67.80.199.173 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/382 +X-Sequence-Number: 8858 + +Andrew Sullivan wrote: + +>>Probably the most severe objection to doing things this way is that the +>>selected plan could change unexpectedly as a result of the physical +>>table size changing. Right now the DBA can keep tight rein on actions +>>that might affect plan selection (ie, VACUUM and ANALYZE), but that +>>would go by the board with this. OTOH, we seem to be moving towards +>>autovacuum, which also takes away any guarantees in this department. +>> +>> +> +>But aren't we requiring that we can disable autovacuum on some +>tables? +> +Yes that is the long term goal, but the autovac in 8.0 is still all or +nothing. + +From pgsql-hackers-owner@postgresql.org Fri Oct 22 23:03:02 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CB44EAE486; + Fri, 22 Oct 2004 23:03:00 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81138-05; Fri, 22 Oct 2004 22:03:05 +0000 (GMT) +Received: from cmailg4.svr.pol.co.uk (cmailg4.svr.pol.co.uk [195.92.195.174]) + by svr1.postgresql.org (Postfix) with ESMTP id B5A44EAE483; + Fri, 22 Oct 2004 23:02:56 +0100 (BST) +Received: from modem-3564.lion.dialup.pol.co.uk ([217.135.173.236] + helo=[192.168.0.102]) by cmailg4.svr.pol.co.uk with esmtp (Exim 4.41) + id 1CL7VD-0007Us-LU; Fri, 22 Oct 2004 23:03:15 +0100 +Subject: Re: [PATCHES] ARC Memory Usage analysis +From: Simon Riggs +To: Tom Lane +Cc: Jan Wieck , pgsql-patches@postgresql.org, + pgsql-hackers@postgresql.org, josh@agliodbs.com +In-Reply-To: <18764.1098477951@sss.pgh.pa.us> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <18764.1098477951@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Message-Id: <1098482465.20926.122.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 22 Oct 2004 23:01:05 +0100 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/768 +X-Sequence-Number: 60271 + +On Fri, 2004-10-22 at 21:45, Tom Lane wrote: +> Jan Wieck writes: +> > What do you think about my other theory to make C actually 2x effective +> > cache size and NOT to keep T1 in shared buffers but to assume T1 lives +> > in the OS buffer cache? +> +> What will you do when initially fetching a page? It's not supposed to +> go directly into T2 on first use, but we're going to have some +> difficulty accessing a page that's not in shared buffers. I don't think +> you can equate the T1/T2 dichotomy to "is in shared buffers or not". +> + +Yes, there are issues there. I want Jan to follow his thoughts through. +This is important enough that its worth it - there's only a few even +attempting this. + +> You could maybe have a T3 list of "pages that aren't in shared buffers +> anymore but we think are still in OS buffer cache", but what would be +> the point? It'd be a sufficiently bad model of reality as to be pretty +> much useless for stats gathering, I'd think. +> + +The OS cache is in many ways a wild horse, I agree. Jan is trying to +think of ways to harness it, whereas I had mostly ignored it - but its +there. Raw disk usage never allowed this opportunity. + +For high performance systems, we can assume that the OS cache is ours to +play with - what will we do with it? We need to use it for some +purposes, yet would like to ignore it for others. + +-- +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Sat Oct 23 08:44:55 2004 +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 C78BAEAE515 + for ; + Sat, 23 Oct 2004 08:44:53 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92528-02 + for ; + Sat, 23 Oct 2004 07:44:58 +0000 (GMT) +Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) + by svr1.postgresql.org (Postfix) with ESMTP id B3CD3EAE514 + for ; + Sat, 23 Oct 2004 08:44:44 +0100 (BST) +Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net + [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP + id 854FDC146; Sat, 23 Oct 2004 16:33:47 +0900 (JST) +Received: from localhost (localhost [127.0.0.1]) + by angelic.cynic.net (Postfix) with ESMTP + id 208548736; Sat, 23 Oct 2004 16:33:40 +0900 (JST) +Date: Sat, 23 Oct 2004 16:33:40 +0900 (JST) +From: Curt Sampson +X-X-Sender: cjs@angelic-vtfw.cvpn.cynic.net +To: Tom Lane +Cc: Kevin Brown , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +In-Reply-To: <4859.1097363137@sss.pgh.pa.us> +Message-ID: +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/383 +X-Sequence-Number: 8859 + +On Sat, 9 Oct 2004, Tom Lane wrote: + +> mmap provides msync which is comparable to fsync, but AFAICS it +> provides no way to prevent an in-memory change from reaching disk too +> soon. This would mean that WAL entries would have to be written *and +> flushed* before we could make the data change at all, which would +> convert multiple updates of a single page into a series of write-and- +> wait-for-WAL-fsync steps. Not good. fsync'ing WAL once per transaction +> is bad enough, once per atomic action is intolerable. + +Back when I was working out how to do this, I reckoned that you could +use mmap by keeping a write queue for each modified page. Reading, +you'd have to read the datum from the page and then check the write +queue for that page to see if that datum had been updated, using the +new value if it's there. Writing, you'd add the modified datum to the +write queue, but not apply the write queue to the page until you'd had +confirmation that the corresponding transaction log entry had been +written. So multiple writes are no big deal; they just all queue up in +the write queue, and at any time you can apply as much of the write +queue to the page itself as the current log entry will allow. + +There are several different strategies available for mapping and +unmapping the pages, and in fact there might need to be several +available to get the best performance out of different systems. Most +OSes do not seem to be optimized for having thousands or tens of +thousands of small mappings (certainly NetBSD isn't), but I've never +done any performance tests to see what kind of strategies might work +well or not. + +cjs +-- +Curt Sampson +81 90 7737 2974 http://www.NetBSD.org + Make up enjoying your city life...produced by BIC CAMERA + +From pgsql-performance-owner@postgresql.org Sat Oct 23 11:50:44 2004 +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 06039EAE539 + for ; + Sat, 23 Oct 2004 11:50:42 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21961-07 + for ; + Sat, 23 Oct 2004 10:50:51 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id EB1A9EAE506 + for ; + Sat, 23 Oct 2004 11:50:38 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9NAomJ7025300 + for ; Sat, 23 Oct 2004 10:50:48 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9NAVIRG021829 + for pgsql-performance@postgresql.org; Sat, 23 Oct 2004 10:31:18 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Insert performance, what should I expect? +Date: Sat, 23 Oct 2004 12:31:32 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 12 +Message-ID: <417A3304.9000608@bigfoot.com> +References: <97b3fe2041019185337a8c3d8@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Brock Henry +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +In-Reply-To: <97b3fe2041019185337a8c3d8@mail.gmail.com> +X-Enigmail-Version: 0.86.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/384 +X-Sequence-Number: 8860 + +Brock Henry wrote: + > Any comments/suggestions would be appreciated. + +Tune also the disk I/O elevator. + +look at this: http://www.varlena.com/varlena/GeneralBits/49.php + + +Regards +Gaetano Mendola + + + +From pgsql-performance-owner@postgresql.org Sat Oct 23 12:20:41 2004 +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 778AFEAE539 + for ; + Sat, 23 Oct 2004 12:20:40 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29319-02 + for ; + Sat, 23 Oct 2004 11:20:50 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 10039EAE50A + for ; + Sat, 23 Oct 2004 12:20:37 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9NBKmJ7030022 + for ; Sat, 23 Oct 2004 11:20:48 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9NApQBV025377 + for pgsql-performance@postgresql.org; Sat, 23 Oct 2004 10:51:26 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: futex results with dbt-3 +Date: Sat, 23 Oct 2004 12:51:39 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 30 +Message-ID: <417A37BB.9050305@bigfoot.com> +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <200410191459.48080.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Josh Berkus +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +In-Reply-To: <200410191459.48080.josh@agliodbs.com> +X-Enigmail-Version: 0.86.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/386 +X-Sequence-Number: 8862 + +Josh Berkus wrote: + > Tom, + > + > + >>The bigger problem here is that the SMP locking bottlenecks we are + >>currently seeing are *hardware* issues (AFAICT anyway). The only way + >>that futexes can offer a performance win is if they have a smarter way + >>of executing the basic atomic-test-and-set sequence than we do; + >>and if so, we could read their code and adopt that method without having + >>to buy into any large reorganization of our code. + > + > + > Well, initial results from Gavin/Neil's patch seem to indicate that, while + > futexes do not cure the CSStorm bug, they do lessen its effects in terms of + > real performance loss. + +I proposed weeks ago to see how the CSStorm is affected by stick each backend +in one processor ( where the process was born ) using the cpu-affinity capability +( kernel 2.6 ), is this proposal completely out of mind ? + + +Regards +Gaetano Mendola + + + + + + + + +From pgsql-performance-owner@postgresql.org Sat Oct 23 12:15:10 2004 +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 2AE46EAE55D + for ; + Sat, 23 Oct 2004 12:15:06 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25127-10 + for ; + Sat, 23 Oct 2004 11:15:15 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C8E1EAE558 + for ; + Sat, 23 Oct 2004 12:15:02 +0100 (BST) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1CLJru-0006YS-00 + for ; Sat, 23 Oct 2004 13:15:30 +0200 +Date: Sat, 23 Oct 2004 13:15:30 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Insert performance, what should I expect? +Message-ID: <20041023111530.GA24976@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <97b3fe2041019185337a8c3d8@mail.gmail.com> + <417A3304.9000608@bigfoot.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <417A3304.9000608@bigfoot.com> +X-Operating-System: Linux 2.6.8.1 on a i686 +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/385 +X-Sequence-Number: 8861 + +On Sat, Oct 23, 2004 at 12:31:32PM +0200, Gaetano Mendola wrote: +>> Any comments/suggestions would be appreciated. +> Tune also the disk I/O elevator. +> +> look at this: http://www.varlena.com/varlena/GeneralBits/49.php + +Mm, interesting. I've heard somewhere that the best for database-like loads +on Linux is to disable the anticipatory I/O scheduler +(http://kerneltrap.org/node/view/567), which should probably +influence the numbers for elvtune also -- anybody know whether this is true +or not for PostgreSQL? + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sat Oct 23 13:07:38 2004 +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 71636EAE4D0 + for ; + Sat, 23 Oct 2004 13:07:37 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36291-06 + for ; + Sat, 23 Oct 2004 12:07:46 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.203]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BCFDEAE557 + for ; + Sat, 23 Oct 2004 13:07:32 +0100 (BST) +Received: by rproxy.gmail.com with SMTP id 77so290028rnk + for ; + Sat, 23 Oct 2004 05:08:04 -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:references; + b=i6aqtIxT3PNAbXNa7FLBAniwsZmT0LyTT1SDgy7eZq1Jk5i4r9wD+fjXs502V4vjtEJPAUsi6yHyOUQnPIPQ504D+X/g+b51+tqQZ3xMiUqLMaaaram4VN/k7I+QZTJM9vJfkJNY8154u/an6/hlA3kGQ8WuZezf572O6EuEqvI= +Received: by 10.38.79.21 with SMTP id c21mr195711rnb; + Sat, 23 Oct 2004 05:08:04 -0700 (PDT) +Received: by 10.38.77.73 with HTTP; Sat, 23 Oct 2004 05:08:04 -0700 (PDT) +Message-ID: <38242de9041023050832a57cbf@mail.gmail.com> +Date: Sat, 23 Oct 2004 06:08:04 -0600 +From: Joshua Marsh +Reply-To: Joshua Marsh +To: pgsql-performance@postgresql.org +Subject: Re: Slow query +In-Reply-To: <18707.1098477434@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <41795A35.4060802@paccomsys.com> <18707.1098477434@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/387 +X-Sequence-Number: 8863 + +Any time you run subqueries, it's going to slow down the update +process a lot. Each record that is updated in source_song_title runs +two additional queries. When I do large updates like this, I usualy +Run a transaction that will select all the new data into a new table +on a join. For example + +SELECT + a.*, + b.licensing_match_order, + b.affiliation_match_order, + d.title +INTO + updated_data +FROM + source_song_title AS a +INNER JOIN + source_system AS b +ON + b.id = d.id +INNER JOIN + source_song AS c +ON + a.id = c.id +INNER JOIN + source_title AS d +ON + a.id = d.id + +I'm not sure that query does what you want, but you get the idea. +Then just drop the old table and rename the updated_data table. This +way instead of doing a bunch of updates, you do one select and a +rename. + +-Josh + +On Fri, 22 Oct 2004 16:37:14 -0400, Tom Lane wrote: +> Roger Ging writes: +> > update source_song_title set +> > source_song_title_id = nextval('source_song_title_seq') +> > ,licensing_match_order = (select licensing_match_order from +> > source_system where source_system_id = ss.source_system_id) +> > ,affiliation_match_order = (select affiliation_match_order from +> > source_system where source_system_id = ss.source_system_id) +> > ,title = st.title +> > from source_song_title sst +> > join source_song ss on ss.source_song_id = sst.source_song_id +> > join source_title st on st.title_id = sst.title_id +> > where source_song_title.source_song_id = sst.source_song_id; +> +> Why is "source_song_title sst" in there? To the extent that +> source_song_id is not unique, you are multiply updating rows +> because of the self-join. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> + +From pgsql-performance-owner@postgresql.org Mon Oct 25 16:58:12 2004 +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 75C06EAE4CE + for ; + Sat, 23 Oct 2004 16:53:40 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84567-01 + for ; + Sat, 23 Oct 2004 15:53:50 +0000 (GMT) +Received: from manta.curalia.se (manta.curalia.se [213.115.149.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 10CFEEAE575 + for ; + Sat, 23 Oct 2004 16:53:35 +0100 (BST) +Received: from 192.168.1.13 + (c-a95b70d5.025-98-73746f7.cust.bredbandsbolaget.se + [213.112.91.169]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by manta.curalia.se (Postfix) with ESMTP id 66DDBABC003 + for ; + Sat, 23 Oct 2004 17:54:07 +0200 (CEST) +Subject: different io elevators in linux +From: Bjorn Bength +To: pgsql-performance@postgresql.org +Content-Type: text/plain; charset=ISO-8859-15 +Organization: Curalia AB +Date: Sat, 23 Oct 2004 17:54:05 +0200 +Message-Id: <1098546845.7754.8.camel@localhost> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/417 +X-Sequence-Number: 8893 + +I haven't read much FAQs but has anyone done some benchmarks with +different io schedulers in linux with postgresql? + +Look at these: +http://kerneltrap.org/node/view/843 +http://simonraven.nuit.ca/blog/archives/2004/05/20/quikconf/ + + +Maybe its well known knowledge but i just found this information and +haven't had time to do my own testing yet. + +mvh + +-- +Bj�rn Bength | Systems Designer +-- +Curalia AB | www.curalia.se +Tj�rhovsgatan 21, SE - 116 28 Stockholm, Sweden +Phone: +46 (0)8-410 064 40 +-- + + +From pgsql-performance-owner@postgresql.org Sat Oct 23 19:10:40 2004 +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 3FE72EAE58B + for ; + Sat, 23 Oct 2004 19:10:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11768-05 + for ; + Sat, 23 Oct 2004 18:10:43 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 59C6FEAE582 + for ; + Sat, 23 Oct 2004 19:10:29 +0100 (BST) +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 i9NIB4Fc026468; + Sat, 23 Oct 2004 14:11:04 -0400 (EDT) +To: Curt Sampson +Cc: Kevin Brown , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, + some wierdness ... +In-reply-to: +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + +Comments: In-reply-to Curt Sampson + message dated "Sat, 23 Oct 2004 16:33:40 +0900" +Date: Sat, 23 Oct 2004 14:11:04 -0400 +Message-ID: <26467.1098555064@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/388 +X-Sequence-Number: 8864 + +Curt Sampson writes: +> Back when I was working out how to do this, I reckoned that you could +> use mmap by keeping a write queue for each modified page. Reading, +> you'd have to read the datum from the page and then check the write +> queue for that page to see if that datum had been updated, using the +> new value if it's there. Writing, you'd add the modified datum to the +> write queue, but not apply the write queue to the page until you'd had +> confirmation that the corresponding transaction log entry had been +> written. So multiple writes are no big deal; they just all queue up in +> the write queue, and at any time you can apply as much of the write +> queue to the page itself as the current log entry will allow. + +Seems to me the overhead of any such scheme would swamp the savings from +avoiding kernel/userspace copies ... the locking issues alone would be +painful. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Oct 23 19:20:47 2004 +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 39392EAE57E + for ; + Sat, 23 Oct 2004 19:20:46 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12041-09 + for ; + Sat, 23 Oct 2004 18:20:55 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A277FEAE589 + for ; + Sat, 23 Oct 2004 19:20:40 +0100 (BST) +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 i9NILACQ026544; + Sat, 23 Oct 2004 14:21:10 -0400 (EDT) +To: Gaetano Mendola +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +In-reply-to: <417A37BB.9050305@bigfoot.com> +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <200410191459.48080.josh@agliodbs.com> + <417A37BB.9050305@bigfoot.com> +Comments: In-reply-to Gaetano Mendola + message dated "Sat, 23 Oct 2004 12:51:39 +0200" +Date: Sat, 23 Oct 2004 14:21:10 -0400 +Message-ID: <26543.1098555670@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/389 +X-Sequence-Number: 8865 + +Gaetano Mendola writes: +> I proposed weeks ago to see how the CSStorm is affected by stick each +> backend in one processor ( where the process was born ) using the +> cpu-affinity capability ( kernel 2.6 ), is this proposal completely +> out of mind ? + +That was investigated long ago. See for instance +http://archives.postgresql.org/pgsql-performance/2004-04/msg00313.php + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Oct 23 20:20:46 2004 +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 88731EACD47 + for ; + Sat, 23 Oct 2004 20:20:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25797-03 + for ; + Sat, 23 Oct 2004 19:20:50 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id AD237EAC8F4 + for ; + Sat, 23 Oct 2004 20:20:35 +0100 (BST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i9NJKnJ7026417 + for ; Sat, 23 Oct 2004 19:20:49 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i9NIuesG022004 + for pgsql-performance@postgresql.org; Sat, 23 Oct 2004 18:56:40 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: futex results with dbt-3 +Date: Sat, 23 Oct 2004 20:56:58 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 21 +Message-ID: <417AA97A.6080202@bigfoot.com> +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <200410191459.48080.josh@agliodbs.com> + <417A37BB.9050305@bigfoot.com> <26543.1098555670@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Tom Lane +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +In-Reply-To: <26543.1098555670@sss.pgh.pa.us> +X-Enigmail-Version: 0.86.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/390 +X-Sequence-Number: 8866 + +Tom Lane wrote: +> Gaetano Mendola writes: +> +>>I proposed weeks ago to see how the CSStorm is affected by stick each +>>backend in one processor ( where the process was born ) using the +>>cpu-affinity capability ( kernel 2.6 ), is this proposal completely +>>out of mind ? +> +> +> That was investigated long ago. See for instance +> http://archives.postgresql.org/pgsql-performance/2004-04/msg00313.php +> + +If I read correctly this help on the CSStorm, I guess also that this could +also help the performances. Unfortunatelly I do not have any kernel 2.6 running +on SMP to give it a try. + + +Regards +Gaetano Mendola + + +From pgsql-performance-owner@postgresql.org Sun Oct 24 00:20:55 2004 +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 5E8CD3A2B2F + for ; + Sun, 24 Oct 2004 00:20:55 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77918-02 + for ; + Sat, 23 Oct 2004 23:20:34 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id A050E3A1D95 + for ; + Sun, 24 Oct 2004 00:20:52 +0100 (BST) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i9NNImb01527; + Sun, 24 Oct 2004 01:18:49 +0200 +Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i9NNKsf21405; + Sun, 24 Oct 2004 01:20:54 +0200 +Message-ID: <417AE74E.7030004@bigfoot.com> +Date: Sun, 24 Oct 2004 01:20:46 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: josh@agliodbs.com +Cc: "pgsql-performance@postgresql.org" +Subject: Re: futex results with dbt-3 +References: <417221B5.1050704@colorfullife.com> + <200410191459.48080.josh@agliodbs.com> + <417A37BB.9050305@bigfoot.com> + <200410231548.42762.josh@agliodbs.com> +In-Reply-To: <200410231548.42762.josh@agliodbs.com> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/391 +X-Sequence-Number: 8867 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Josh Berkus wrote: +| Gaetano, +| +| +|>I proposed weeks ago to see how the CSStorm is affected by stick each +|>backend in one processor ( where the process was born ) using the +|>cpu-affinity capability ( kernel 2.6 ), is this proposal completely out of +|>mind ? +| +| +| I don't see how that would help. The problem is not backends switching +| processors, it's the buffermgrlock needing to be swapped between processors. + +This is not clear to me. What happen if during a spinlock a backend is +moved away from one processor to another one ? + + +Regards +Gaetano Mendola + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBeudN7UpzwH2SGd4RAkL9AKCUY9vsw1CPmBV1kC7BKxUtuneN2wCfXaYr +E8utuJI34MAIP8jUm6By09M= +=oRvU +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Sun Oct 24 06:08:17 2004 +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 510493A3B7C + for ; + Sun, 24 Oct 2004 06:08:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41941-10 + for ; + Sun, 24 Oct 2004 05:07:46 +0000 (GMT) +Received: from roue.portalpotty.net (roue.portalpotty.net [69.44.62.206]) + by svr1.postgresql.org (Postfix) with ESMTP id 58B8C3A3B09 + for ; + Sun, 24 Oct 2004 06:08:07 +0100 (BST) +Received: from max by roue.portalpotty.net with local (Exim 4.34) + id 1CLabz-00039o-Q2; Sat, 23 Oct 2004 22:08:11 -0700 +Date: Sun, 24 Oct 2004 01:08:11 -0400 +From: Max Baker +To: Rod Taylor +Cc: Postgresql Performance +Subject: Re: Vacuum takes a really long time, vacuum full required +Message-ID: <20041024050811.GA12044@warped.org> +Mail-Followup-To: Rod Taylor , + Postgresql Performance +References: <20041019153821.GA21258@warped.org> + <1098200416.750.238.camel@home> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1098200416.750.238.camel@home> +User-Agent: Mutt/1.4.1i +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - roue.portalpotty.net +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [514 32003] / [47 12] +X-AntiAbuse: Sender Address Domain - roue.portalpotty.net +X-Source: /usr/bin/mutt +X-Source-Args: mutt +X-Source-Dir: /home/max +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/392 +X-Sequence-Number: 8868 + +On Tue, Oct 19, 2004 at 11:40:17AM -0400, Rod Taylor wrote: +> > Whatever the case, the database still slows down to a halt after a month or +> > so, and I have to go in and shut everything down and do a VACUUM FULL by +> > hand. One index (of many many) takes 2000 seconds to vacuum. The whole +> > process takes a few hours. +> +> Do a REINDEX on that table instead, and regular vacuum more frequently. +> +> > $ pg_config --version +> > PostgreSQL 7.3.2 +> +> 7.4.x deals with index growth a little better 7.3 and older did. + +I did a REINDEX of the database. The results are pretty insane, the db went +from 16GB to 381MB. Needless to say things are running a lot faster. + +I will now take Tom's well-given advice and upgrade to 7.4. But at least +now I have something to tell my users who are not able to do a DB upgrade +for whatever reason. + +Thanks for all your help folks! +-m + +Before: +# du -h pgsql + 135K pgsql/global + 128M pgsql/pg_xlog + 80M pgsql/pg_clog + 3.6M pgsql/base/1 + 3.6M pgsql/base/16975 + 1.0K pgsql/base/16976/pgsql_tmp + 16G pgsql/base/16976 + 16G pgsql/base + 16G pgsql + +After Reindex: +# du /data/pgsql/ + 131K /data/pgsql/global + 128M /data/pgsql/pg_xlog + 81M /data/pgsql/pg_clog + 3.6M /data/pgsql/base/1 + 3.6M /data/pgsql/base/16975 + 1.0K /data/pgsql/base/16976/pgsql_tmp + 268M /data/pgsql/base/16976 + 275M /data/pgsql/base + 484M /data/pgsql/ + +After Vacuum: +# du /data/pgsql/ + 131K /data/pgsql/global + 144M /data/pgsql/pg_xlog + 81M /data/pgsql/pg_clog + 3.6M /data/pgsql/base/1 + 3.6M /data/pgsql/base/16975 + 1.0K /data/pgsql/base/16976/pgsql_tmp + 149M /data/pgsql/base/16976 + 156M /data/pgsql/base + 381M /data/pgsql/ + +netdisco=> select relname, relpages from pg_class order by relpages desc; + +Before: + relname | relpages +---------------------------------+---------- + idx_node_switch_port_active | 590714 + idx_node_switch_port | 574344 + idx_node_switch | 482202 + idx_node_mac | 106059 + idx_node_mac_active | 99842 + +After: + relname | relpages +---------------------------------+---------- + node_ip | 13829 + node | 9560 + device_port | 2124 + node_ip_pkey | 1354 + idx_node_ip_ip | 1017 + idx_node_ip_mac_active | 846 + + +From pgsql-performance-owner@postgresql.org Sun Oct 24 06:46:32 2004 +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 382233A3AC3 + for ; + Sun, 24 Oct 2004 06:46:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51348-03 + for ; + Sun, 24 Oct 2004 05:46:01 +0000 (GMT) +Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) + by svr1.postgresql.org (Postfix) with ESMTP id 68AD93A3E68 + for ; + Sun, 24 Oct 2004 06:46:20 +0100 (BST) +Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net + [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP + id 6647BC000; Sun, 24 Oct 2004 14:46:24 +0900 (JST) +Received: from localhost (localhost [127.0.0.1]) + by angelic.cynic.net (Postfix) with ESMTP + id 76D518736; Sun, 24 Oct 2004 14:46:16 +0900 (JST) +Date: Sun, 24 Oct 2004 14:46:16 +0900 (JST) +From: Curt Sampson +X-X-Sender: cjs@angelic-vtfw.cvpn.cynic.net +To: Tom Lane +Cc: Kevin Brown , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +In-Reply-To: <26467.1098555064@sss.pgh.pa.us> +Message-ID: +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + + <26467.1098555064@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/393 +X-Sequence-Number: 8869 + +On Sat, 23 Oct 2004, Tom Lane wrote: + +> Seems to me the overhead of any such scheme would swamp the savings from +> avoiding kernel/userspace copies ... + +Well, one really can't know without testing, but memory copies are +extremely expensive if they go outside of the cache. + +> the locking issues alone would be painful. + +I don't see why they would be any more painful than the current locking +issues. In fact, I don't see any reason to add more locking than we +already use when updating pages. + +cjs +-- +Curt Sampson +81 90 7737 2974 http://www.NetBSD.org + Make up enjoying your city life...produced by BIC CAMERA + +From pgsql-performance-owner@postgresql.org Sun Oct 24 15:39:38 2004 +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 54CD73A3BF0 + for ; + Sun, 24 Oct 2004 15:39:38 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49256-04 + for ; + Sun, 24 Oct 2004 14:39: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 82FC43A2BE5 + for ; + Sun, 24 Oct 2004 15:39:29 +0100 (BST) +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 i9OEdZio008439; + Sun, 24 Oct 2004 10:39:35 -0400 (EDT) +To: Curt Sampson +Cc: Kevin Brown , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +In-reply-to: +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + + <26467.1098555064@sss.pgh.pa.us> + +Comments: In-reply-to Curt Sampson + message dated "Sun, 24 Oct 2004 14:46:16 +0900" +Date: Sun, 24 Oct 2004 10:39:35 -0400 +Message-ID: <8438.1098628775@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/394 +X-Sequence-Number: 8870 + +Curt Sampson writes: +> On Sat, 23 Oct 2004, Tom Lane wrote: +>> Seems to me the overhead of any such scheme would swamp the savings from +>> avoiding kernel/userspace copies ... + +> Well, one really can't know without testing, but memory copies are +> extremely expensive if they go outside of the cache. + +Sure, but what about all the copying from write queue to page? + +>> the locking issues alone would be painful. + +> I don't see why they would be any more painful than the current locking +> issues. + +Because there are more locks --- the write queue data structure will +need to be locked separately from the page. (Even with a separate write +queue per page, there will need to be a shared data structure that +allows you to allocate and find write queues, and that thing will be a +subject of contention. See BufMgrLock, which is not held while actively +twiddling the contents of pages, but is a serious cause of contention +anyway.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Oct 24 19:12:05 2004 +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 B1CEA3A3F85 + for ; + Sun, 24 Oct 2004 19:12:00 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88806-05 + for ; + Sun, 24 Oct 2004 18:11:30 +0000 (GMT) +Received: from mra04.ex.eclipse.net.uk (mra04.ex.eclipse.net.uk + [212.104.129.139]) + by svr1.postgresql.org (Postfix) with ESMTP id B58123A3F9E + for ; + Sun, 24 Oct 2004 19:11:49 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mra04.ex.eclipse.net.uk (Postfix) with ESMTP id 53475133D81 + for ; + Sun, 24 Oct 2004 19:06:42 +0100 (BST) +Received: from mra04.ex.eclipse.net.uk ([127.0.0.1]) + by localhost (mra04.ex.eclipse.net.uk [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 20604-01-13 for ; + Sun, 24 Oct 2004 19:06:41 +0100 (BST) +Received: from dev1 (unknown [82.152.145.238]) + by mra04.ex.eclipse.net.uk (Postfix) with ESMTP id F2D16133C61 + for ; + Sun, 24 Oct 2004 19:06:40 +0100 (BST) +From: "Rod Dutton" +To: +Subject: Queries slow using stored procedures +Date: Sun, 24 Oct 2004 19:13:23 +0100 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0000_01C4B9FD.887BB690" +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +Thread-Index: AcS1PHuwz718w8JtTi2M+MPIPiou1gEuIX0Q +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +Message-Id: <20041024180640.F2D16133C61@mra04.ex.eclipse.net.uk> +X-Virus-Scanned: by Eclipse VIRUSshield at eclipse.net.uk +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=HTML_50_60, + HTML_FONTCOLOR_BLUE, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/395 +X-Sequence-Number: 8871 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0000_01C4B9FD.887BB690 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + + +Hi, + +Has anybody got any ideas on my recent posting ? (thanks in advance) :- + + +I have a problem where a query inside a function is up to 100 times slower +inside a function than as a stand alone query run in psql. + +The column 'botnumber' is a character(10), is indexed and there are 125000 +rows in the table. + +Help please! + +This query is fast:- + +explain analyze + SELECT batchserial + FROM transbatch + WHERE botnumber = '1-7' + LIMIT 1; + + QUERY PLAN + +---------------------------------------------------------------------------- +---------------------------------------------------- + Limit (cost=0.00..0.42 rows=1 width=4) (actual time=0.73..148.23 rows=1 +loops=1) + -> Index Scan using ind_tbatchx on transbatch (cost=0.00..18.73 rows=45 +width=4) (actual time=0.73..148.22 rows=1 loops=1) + Index Cond: (botnumber = '1-7'::bpchar) + Total runtime: 148.29 msec +(4 rows) + + +This function is slow:- + +CREATE OR REPLACE FUNCTION sp_test_rod3 ( ) returns integer +as ' +DECLARE + bot char(10); + oldbatch INTEGER; +BEGIN + + bot := ''1-7''; + + SELECT INTO oldbatch batchserial + FROM transbatch + WHERE botnumber = bot + LIMIT 1; + + IF FOUND THEN + RETURN 1; + ELSE + RETURN 0; + END IF; + +END; +' +language plpgsql ; + + +explain analyze SELECT sp_test_rod3(); + + QUERY PLAN + +---------------------------------------------------------------------------- +------------ + Result (cost=0.00..0.01 rows=1 width=0) (actual time=1452.39..1452.40 +rows=1 loops=1) + Total runtime: 1452.42 msec +(2 rows) + + +------=_NextPart_000_0000_01C4B9FD.887BB690 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + +
 
+
+
Hi,= + 
+
 
+
Has anybody got any ideas = +on my=20 +recent posting ? (thanks in advance) :-<= +/DIV> +
 
+
 
+
I have a = +problem=20 +where a query inside a function is up to 100 times slower inside a function= + than=20 +as a stand alone query run in psql.
+
 
+
The colum= +n=20 +'botnumber' is a character(10), is indexed and there are 125000 rows i= +n the=20 +table.
+
 
+
Help=20 +please!
+
 
+
This quer= +y is=20 +fast:-
+
 
+
explain= +=20 +analyze  
+
&nb= +sp;=20 +SELECT batchserial
  FROM transbatch
  WHERE botnumb= +er =3D=20 +'1-7'
  LIMIT 1;
+
           = +            &nb= +sp;            = +            &nb= +sp;         =20 +QUERY=20 +PLAN            = +;            &n= +bsp;            = +;            &n= +bsp;        =20 +
-----------------------------------------------------------------------= +---------------------------------------------------------
 Limit&nb= +sp;=20 +(cost=3D0.00..0.42 rows=3D1 width=3D4) (actual time=3D0.73..148.23 rows=3D1= +=20 +loops=3D1)
   ->  Index Scan using ind_tbatchx on=20 +transbatch  (cost=3D0.00..18.73 rows=3D45 width=3D4) (actual time=3D0.= +73..148.22=20 +rows=3D1 loops=3D1)
         Ind= +ex Cond:=20 +(botnumber =3D '1-7'::bpchar)
 Total runtime: 148.29 msec
(4=20 +rows)
+
 
+
 
+
This=20 +function is slow:-
+
 
+
CREATE=20 +OR REPLACE FUNCTION  sp_test_rod3 ( ) returns=20 +integer         
as=20 +'
DECLARE
  bot char(10);
  oldbatch=20 +INTEGER;
BEGIN
+
 
+
 =20 +bot :=3D ''1-7'';
+
 
+
 =20 +SELECT INTO oldbatch batchserial
  FROM transbatch
  WHERE= +=20 +botnumber =3D bot
  LIMIT 1;
+
 
+
 =20 +IF FOUND THEN
    RETURN 1;
 =20 +ELSE
    RETURN 0;
  END=20 +IF;
+
 
+
END;
'
language plpgsql  ;
+
 
+
explain analyze SELECT sp_test_rod3();
+
           = +            &nb= +sp;            = +  =20 +QUERY=20 +PLAN            = +;            &n= +bsp;            = +; =20 +
-----------------------------------------------------------------------= +-----------------
 Result =20 +(cost=3D0.00..0.01 rows=3D1 width=3D0) (actual time=3D1452.39..1452.40 rows= +=3D1=20 +loops=3D1)
 Total runtime: 1452.42 msec
(2=20 +rows)
+ +------=_NextPart_000_0000_01C4B9FD.887BB690-- + + +From pgsql-performance-owner@postgresql.org Sun Oct 24 19:25:55 2004 +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 A87C33A3F93 + for ; + Sun, 24 Oct 2004 19:25:53 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94664-01 + for ; + Sun, 24 Oct 2004 18:25:21 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 53D993A3B60 + for ; + Sun, 24 Oct 2004 19:25:46 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.12.9/8.12.9) with ESMTP id + i9OIPmMq027018; (envelope-from ) Sun, + 24 Oct 2004 13:25:48 -0500 (CDT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by server11.icaen.uiowa.edu (8.12.9/smtp-service-1.6) with ESMTP id + i9OIPlBN022250; (envelope-from ) Sun, + 24 Oct 2004 13:25:47 -0500 (CDT) +Message-ID: <417BF3AD.6010901@johnmeinel.com> +Date: Sun, 24 Oct 2004 13:25:49 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rod Dutton +Cc: pgsql-performance@postgresql.org +Subject: Re: Queries slow using stored procedures +References: <20041024180640.F2D16133C61@mra04.ex.eclipse.net.uk> +In-Reply-To: <20041024180640.F2D16133C61@mra04.ex.eclipse.net.uk> +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig14D8A891B7D53A803E849F3A" +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.66n +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.75 + on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/396 +X-Sequence-Number: 8872 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig14D8A891B7D53A803E849F3A +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Rod Dutton wrote: +> +> Hi, +> +> Has anybody got any ideas on my recent posting ? (thanks in advance) :- +> +> +> I have a problem where a query inside a function is up to 100 times +> slower inside a function than as a stand alone query run in psql. +> +> The column 'botnumber' is a character(10), is indexed and there are +> 125000 rows in the table. +> + +[...] + +I had a similar problem before, where the function version (stored +procedure or prepared query) was much slower. I had a bunch of tables +all with references to another table. I was querying all of the +references to see if anyone from any of the tables was referencing a +particular row in the base table. + +It turned out that one of the child tables was referencing the same row +300,000/500,000 times. So if I happened to pick *that* number, postgres +wanted to a sequential scan because of all the potential results. In my +testing, I never picked that number, so it was very fast, since it knew +it wouldn't get in trouble. + +In the case of the stored procedure, it didn't know which number I was +going to ask for, so it had to plan for the worst, and *always* do a +sequential scan. + +So the question is... In your table, does the column "botnumber" have +the same value repeated many, many times, but '1-7' only occurs a few? + +If you change the function to: + +CREATE OR REPLACE FUNCTION sp_test_rod3 ( ) returns integer +as ' +DECLARE + bot char(10); + oldbatch INTEGER; +BEGIN + + SELECT INTO oldbatch batchserial + FROM transbatch + WHERE botnumber = ''1-7'' + LIMIT 1; + + IF FOUND THEN + RETURN 1; + ELSE + RETURN 0; + END IF; + +END; +' +language plpgsql ; + + +Is it still slow? + +I don't know if you could get crazy with something like: + +select 1 where exist(select from transbatch where botnumber = '1-7' +limit 1); + +Just some thoughts about where *I've* found performance to change +between functions versus raw SQL. + +You probably should also mention what version of postgres you are +running (and possibly what your hardware is) + +John +=:-> + +--------------enig14D8A891B7D53A803E849F3A +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBe/OtJdeBCYSNAAMRAp7GAKCorGfd2EOHXy1WplWCYrQ4B6LeRQCgiXzq +QMz9AdKW8Ali61i+xQd0fVk= +=UMbP +-----END PGP SIGNATURE----- + +--------------enig14D8A891B7D53A803E849F3A-- + +From pgsql-performance-owner@postgresql.org Sun Oct 24 20:09:09 2004 +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 4FB973A3B60 + for ; + Sun, 24 Oct 2004 20:09:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01845-07 + for ; + Sun, 24 Oct 2004 19:08:32 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DF983A2BE5 + for ; + Sun, 24 Oct 2004 20:08:58 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.12.9/8.12.9) with ESMTP id + i9OJ92Mq027718; (envelope-from ) Sun, + 24 Oct 2004 14:09:02 -0500 (CDT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by server11.icaen.uiowa.edu (8.12.9/smtp-service-1.6) with ESMTP id + i9OJ91BN028283; (envelope-from ) Sun, + 24 Oct 2004 14:09:01 -0500 (CDT) +Message-ID: <417BFDCB.3040404@johnmeinel.com> +Date: Sun, 24 Oct 2004 14:08:59 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rod Dutton , pgsql-performance@postgresql.org +Subject: Re: Queries slow using stored procedures +References: <20041024184053.9819240619B@mra02.ex.eclipse.net.uk> +In-Reply-To: <20041024184053.9819240619B@mra02.ex.eclipse.net.uk> +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigC39560A59387A6C5A347CC5D" +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.66n +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.75 + on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/397 +X-Sequence-Number: 8873 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigC39560A59387A6C5A347CC5D +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Rod Dutton wrote: +> Thank John, +> +> I am running Postgres 7.3.7 on a Dell PowerEdge 6600 Server with Quad Xeon +> 2.7GHz processors with 16GB RAM and 12 x 146GB drives in Raid 10 (OS, WAL, +> Data all on separate arrays). +> + +You might want think about upgraded to 7.4, as I know it is better at +quite a few things. But I'm not all that experienced (I just had a +similar problem). + +> I did try hard coding botnumber as you suggested and it was FAST. So it +> does look like the scenario that you have explained. +> + +There are 2 ways of doing it that I know of. First, you can make you +function create a query and execute it. Something like: + +EXECUTE ''SELECT 1 FROM transbatch WHERE botnumber = '' + || quote_literal(botnum) + || '' LIMIT 1''; + +That forces the database to redesign the query each time. The problem +you are having is a stored procedure has to prepare the query in advance. + +> +>>does the column "botnumber" have the same value repeated many, many times, +> +> but '1-7' only occurs a few? +> +> Yes, that could be the case, the table fluctuates massively from small to +> big to small regularly with a real mixture of occurrences of these values +> i.e. some values are repeated many times and some occur only a few times. +> +> I wonder if the answer is to: a) don't use a stored procedure b) up the +> statistics gathering for that column ? +> + +I don't believe increasing statistics will help, as prepared statements +require one-size-fits-all queries. + +> I will try your idea: select 1 where exist(select from transbatch where +> botnumber = '1-7' limit 1); +> +> Also, how can I get "EXPLAIN" output from the internals of the stored +> procedure as that would help me? +> + +I believe the only way to get explain is to use prepared statements +instead of stored procedures. For example: + +PREPARE my_plan(char(10)) AS SELECT 1 FROM transbatch + WHERE botnumber = $1 LIMIT 1; + +EXPLAIN ANALYZE EXECUTE my_plan('1-7'); + + +> Many thanks, +> +> Rod +> + +If you have to do the first thing I mentioned, I'm not sure if you are +getting much out of your function, so you might prefer to just ask the +question directly. + +What really surprises me is that it doesn't use the index even after the +LIMIT clause. But I just did a check on my machine where I had a column +with lots of repeated entries, and it didn't use the index. + +So a question for the true Guru's (like Tom Lane): + +Why doesn't postgres use an indexed query if you supply a LIMIT? + +John +=:-> + +--------------enigC39560A59387A6C5A347CC5D +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBe/3PJdeBCYSNAAMRAvjcAJ4l9eoNP1nU8Brgylbh5wIlB4gW2gCfVbNj +uBgQNBZ4m+ZhGFxzDuk2JUk= +=T1Dk +-----END PGP SIGNATURE----- + +--------------enigC39560A59387A6C5A347CC5D-- + +From pgsql-performance-owner@postgresql.org Sun Oct 24 20:11:53 2004 +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 29DD83A3B60 + for ; + Sun, 24 Oct 2004 20:11:52 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02189-07 + for ; + Sun, 24 Oct 2004 19:11:16 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FDFE3A2BE5 + for ; + Sun, 24 Oct 2004 20:11:43 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.12.9/8.12.9) with ESMTP id + i9OJBlMq027779; (envelope-from ) Sun, + 24 Oct 2004 14:11:47 -0500 (CDT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by server11.icaen.uiowa.edu (8.12.9/smtp-service-1.6) with ESMTP id + i9OJBkBN028623; (envelope-from ) Sun, + 24 Oct 2004 14:11:46 -0500 (CDT) +Message-ID: <417BFE75.4060006@johnmeinel.com> +Date: Sun, 24 Oct 2004 14:11:49 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rod Dutton , pgsql-performance@postgresql.org +Subject: Re: Queries slow using stored procedures +References: <20041024184536.2A841406474@mra02.ex.eclipse.net.uk> +In-Reply-To: <20041024184536.2A841406474@mra02.ex.eclipse.net.uk> +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig6ACE2FD04CAD41D0F1154357" +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.66n +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.75 + on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/398 +X-Sequence-Number: 8874 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig6ACE2FD04CAD41D0F1154357 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Rod Dutton wrote: +> I also should add that the sp is only slow when the table is big (probably +> obvious!). +> +> Rod + +Sure, the problem is it is switching to a sequential search, with a lot +of rows, versus doing an indexed search. + +It's all about trying to figure out how to fix that, especially for any +value of botnum. I would have hoped that using LIMIT 1 would have fixed +that. + +John +=:-> + +--------------enig6ACE2FD04CAD41D0F1154357 +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBe/51JdeBCYSNAAMRAj40AKCgWYbCednkxAXUfYYCAaThoxftIACgh7PB +x3Wkj4EmZzqicQtMgFgRaAc= +=5AfW +-----END PGP SIGNATURE----- + +--------------enig6ACE2FD04CAD41D0F1154357-- + +From pgsql-performance-owner@postgresql.org Sun Oct 24 20:28:00 2004 +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 A13FC3A3F88 + for ; + Sun, 24 Oct 2004 20:27:59 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07432-02 + for ; + Sun, 24 Oct 2004 19:27:23 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CF943A3F84 + for ; + Sun, 24 Oct 2004 20:27:50 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.12.9/8.12.9) with ESMTP id + i9OJRvMq028066 for ; + (envelope-from ) Sun, 24 Oct 2004 14:27:57 -0500 + (CDT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by server11.icaen.uiowa.edu (8.12.9/smtp-service-1.6) with ESMTP id + i9OJRvBN000968 for ; + (envelope-from ) Sun, 24 Oct 2004 14:27:57 -0500 + (CDT) +Message-ID: <417C023F.1080502@johnmeinel.com> +Date: Sun, 24 Oct 2004 14:27:59 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Sequential Scan with LIMIT +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigF85FC43A9A23B9D3A4C0F238" +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.66n +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.75 + on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/399 +X-Sequence-Number: 8875 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigF85FC43A9A23B9D3A4C0F238 +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit + +I was looking into another problem, and I found something that surprised +me. If I'm doing "SELECT * FROM mytable WHERE col = 'myval' LIMIT 1.". +Now "col" is indexed, by mytable has 500,000 rows, and 'myval' occurs +maybe 100,000 times. Without the LIMIT, this query should definitely do +a sequential scan. + +But with the LIMIT, doesn't it know that it will return at max 1 value, +and thus be able to use the index? + +It seems to be doing the LIMIT too late. + +The real purpose of this query is to check to see if a value exists in +the column, so there might be a better way of doing it. Here is the demo +info: + +# select count(*) from finst_t; +542315 + +# select count(*) from finst_t where store_id = 539960; +85076 + +# explain analyze select id from finst_t where store_id = 539960 limit 1; + QUERY PLAN + +------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..0.13 rows=1 width=4) (actual time=860.000..860.000 +rows=1 loops=1) + -> Seq Scan on finst_t (cost=0.00..11884.94 rows=88217 width=4) +(actual time=860.000..860.000 rows=1 loops=1) + Filter: (store_id = 539960) + Total runtime: 860.000 ms + +Notice that the "actual rows=1", meaning it is aware of the limit as it +is going through the table. But for some reason the planner thinks it is +going to return 88,217 rows. (This is close to the reality of 85076 if +it actually had to find all of the rows). + +Now, if I do a select on a value that *does* only have 1 value, it works +fine: + +# explain analyze select id from finst_t where store_id = 9605 limit 1; + QUERY PLAN + + +------------------------------------------------------------------------------------------------------------------------ + Limit (cost=0.00..3.96 rows=1 width=4) (actual time=0.000..0.000 +rows=1 loops=1) + -> Index Scan using finst_t_store_id_idx on finst_t +(cost=0.00..3.96 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1) + Index Cond: (store_id = 9605) + Total runtime: 0.000 ms + +And 1 further thing, I *can* force it to do a fast index scan if I +disable sequential scanning. + +# set enable_seqscan to off; +# explain analyze select id from finst_t where store_id = 539960 limit 1; + QUERY +PLAN + + +------------------------------------------------------------------------------------------------------------------------ + Limit (cost=0.00..1.59 rows=1 width=4) (actual time=0.000..0.000 +rows=1 loops=1) + -> Index Scan using finst_t_store_id_idx on finst_t +(cost=0.00..140417.22 rows=88217 width=4) (actual time=0.000..0.000 +rows=1 loops=1) + Index Cond: (store_id = 539960) + Total runtime: 0.000 ms + +Could being aware of LIMIT be added to the planner? Is there a better +way to check for existence? + +John +=:-> + +PS> I'm using postgres 8.0-beta3 on win32 (the latest installer). + + +--------------enigF85FC43A9A23B9D3A4C0F238 +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBfAI/JdeBCYSNAAMRAi+UAKDFkbJ9JSV6NIJjyii2oPDIMaWj+ACfV4Nv +NnPsyuCflirLpwD6pD7YxHs= +=UkRy +-----END PGP SIGNATURE----- + +--------------enigF85FC43A9A23B9D3A4C0F238-- + +From pgsql-performance-owner@postgresql.org Sun Oct 24 21:11:58 2004 +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 C31883A3FC3 + for ; + Sun, 24 Oct 2004 21:11:56 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11828-10 + for ; + Sun, 24 Oct 2004 20:11:20 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id EFF0C3A2BE5 + for ; + Sun, 24 Oct 2004 21:11:47 +0100 (BST) +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 i9OKBrIH017690; + Sun, 24 Oct 2004 16:11:53 -0400 (EDT) +To: John Meinel +Cc: pgsql-performance@postgresql.org +Subject: Re: Sequential Scan with LIMIT +In-reply-to: <417C023F.1080502@johnmeinel.com> +References: <417C023F.1080502@johnmeinel.com> +Comments: In-reply-to John Meinel + message dated "Sun, 24 Oct 2004 14:27:59 -0500" +Date: Sun, 24 Oct 2004 16:11:53 -0400 +Message-ID: <17689.1098648713@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/400 +X-Sequence-Number: 8876 + +John Meinel writes: +> I was looking into another problem, and I found something that surprised +> me. If I'm doing "SELECT * FROM mytable WHERE col = 'myval' LIMIT 1.". +> Now "col" is indexed, by mytable has 500,000 rows, and 'myval' occurs +> maybe 100,000 times. Without the LIMIT, this query should definitely do +> a sequential scan. + +> But with the LIMIT, doesn't it know that it will return at max 1 value, +> and thus be able to use the index? + +But the LIMIT will cut the cost of the seqscan case too. Given the +numbers you posit above, about one row in five will have 'myval', so a +seqscan can reasonably expect to hit the first matching row in the first +page of the table. This is still cheaper than doing an index scan +(which must require reading at least one index page plus at least one +table page). + +The test case you are showing is probably suffering from nonrandom +placement of this particular data value; which is something that the +statistics we keep are too crude to detect. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Oct 24 22:51:59 2004 +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 735523A3BFF + for ; + Sun, 24 Oct 2004 22:51:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37854-04 + for ; + Sun, 24 Oct 2004 21:51:21 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 6949B3A2BE5 + for ; + Sun, 24 Oct 2004 22:51:48 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.12.9/8.12.9) with ESMTP id + i9OLpuMq000340; (envelope-from ) Sun, + 24 Oct 2004 16:51:56 -0500 (CDT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by server11.icaen.uiowa.edu (8.12.9/smtp-service-1.6) with ESMTP id + i9OLpPBN019459; (envelope-from ) Sun, + 24 Oct 2004 16:51:56 -0500 (CDT) +Message-ID: <417C23DC.1090407@johnmeinel.com> +Date: Sun, 24 Oct 2004 16:51:24 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Sequential Scan with LIMIT +References: <417C023F.1080502@johnmeinel.com> <17689.1098648713@sss.pgh.pa.us> +In-Reply-To: <17689.1098648713@sss.pgh.pa.us> +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigFCA213021A1493416B41EFC0" +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.66n +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.75 + on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/401 +X-Sequence-Number: 8877 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigFCA213021A1493416B41EFC0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: +> John Meinel writes: +> +>>I was looking into another problem, and I found something that surprised +>>me. If I'm doing "SELECT * FROM mytable WHERE col = 'myval' LIMIT 1.". +>>Now "col" is indexed, by mytable has 500,000 rows, and 'myval' occurs +>>maybe 100,000 times. Without the LIMIT, this query should definitely do +>>a sequential scan. +> +> +>>But with the LIMIT, doesn't it know that it will return at max 1 value, +>>and thus be able to use the index? +> +> +> But the LIMIT will cut the cost of the seqscan case too. Given the +> numbers you posit above, about one row in five will have 'myval', so a +> seqscan can reasonably expect to hit the first matching row in the first +> page of the table. This is still cheaper than doing an index scan +> (which must require reading at least one index page plus at least one +> table page). +> +> The test case you are showing is probably suffering from nonrandom +> placement of this particular data value; which is something that the +> statistics we keep are too crude to detect. +> +> regards, tom lane + +You are correct about non-random placement. I'm a little surprised it +doesn't change with values, then. For instance, + +# select count(*) from finst_t where store_id = 52; +13967 + +Still does a sequential scan for the "select id from..." query. + +The only value it does an index query for is 9605 which only has 1 row. + +It estimates ~18,000 rows, but that is still < 3% of the total data. + +This row corresponds to disk location where files can be found. So when +a storage location fills up, generally a new one is created. This means +that *generally* the numbers will be increasing as you go further in the +table (not guaranteed, as there are multiple locations open at any one +time). + +Am I better off in this case just wrapping my query with: + +set enable_seqscan to off; +query +set enable_seqscan to on; + + +There is still the possibility that there is a better way to determine +existence of a value in a column. I was wondering about something like: + +SELECT 1 WHERE EXISTS + (SELECT id FROM finst_t WHERE store_id=52 LIMIT 1); + +Though the second part is the same, so it still does the sequential scan. + +This isn't critical, I was just trying to understand what's going on. +Thanks for your help. + +John +=:-> + +--------------enigFCA213021A1493416B41EFC0 +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBfCPgJdeBCYSNAAMRAgUkAJ9HPwhlnYuLWyDEcuukne0KL7TvsACghgPu +6vL+YolBeCgHTPMTfP/ldm4= +=NvTk +-----END PGP SIGNATURE----- + +--------------enigFCA213021A1493416B41EFC0-- + +From pgsql-performance-owner@postgresql.org Sun Oct 24 22:59:31 2004 +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 725ED3A2BE5 + for ; + Sun, 24 Oct 2004 22:59:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40073-02 + for ; + Sun, 24 Oct 2004 21:58:41 +0000 (GMT) +Received: from mra04.ex.eclipse.net.uk (mra04.ex.eclipse.net.uk + [212.104.129.139]) + by svr1.postgresql.org (Postfix) with ESMTP id EC6E03A3FEB + for ; + Sun, 24 Oct 2004 22:59:07 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mra04.ex.eclipse.net.uk (Postfix) with ESMTP id BBB89133AFE + for ; + Sun, 24 Oct 2004 22:54:00 +0100 (BST) +Received: from mra04.ex.eclipse.net.uk ([127.0.0.1]) + by localhost (mra04.ex.eclipse.net.uk [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 31190-01-33 for ; + Sun, 24 Oct 2004 22:54:00 +0100 (BST) +Received: from dev1 (unknown [82.152.145.238]) + by mra04.ex.eclipse.net.uk (Postfix) with ESMTP id ED668133D1E + for ; + Sun, 24 Oct 2004 22:53:59 +0100 (BST) +From: "Rod Dutton" +To: +Subject: Reindexdb and REINDEX +Date: Sun, 24 Oct 2004 23:00:42 +0100 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0012_01C4BA1D.49978060" +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +Thread-Index: AcS6EpNUyDmOSHB3T9GPkaaJa1R8cQAAkrug +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +Message-Id: <20041024215359.ED668133D1E@mra04.ex.eclipse.net.uk> +X-Virus-Scanned: by Eclipse VIRUSshield at eclipse.net.uk +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/402 +X-Sequence-Number: 8878 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0012_01C4BA1D.49978060 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +Hi, + +I have had some performance problems recently on very large tables (10s of +millions of rows). A vacuum full did make a large improvement and then +dropping & re-creating the indexes also was very beneficial. My performance +problem has now been solved. + +My question is: will using the contrib/reindexdb or REINDEX sql command do +essentially the same job as dropping and re-creating the indexes. I.E. do +you get a fully compacted and balanced index? If so then I could use +contrib/reindexdb or REINDEX instead of drop/recreate. + +How is concurrency handled by contrib/reindexdb and REINDEX (I know you can +create an index on the fly with no obvious lock outs)? + +Thanks, + +Rod + + +------=_NextPart_000_0012_01C4BA1D.49978060 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + +
Hi,
+
 
+
I have ha= +d some=20 +performance problems recently on very large tables (10s of millions of=20 +rows).  A vacuum full did make a large improvement and then dropping &= +amp;=20 +re-creating the indexes also was very beneficial.  My performance prob= +lem=20 +has now been solved.
+
 
+
My questi= +on is: will=20 +using the contrib/reindexdb or REINDEX sql command do essentially the same = +job=20 +as dropping and re-creating the indexes.  I.E. do you get a fully comp= +acted=20 +and balanced index?  If so then I could use contrib/reindexdb or REIND= +EX=20 +instead of drop/recreate. 
+
 
+
How is co= +ncurrency=20 +handled by contrib/reindexdb and REINDEX (I know you can create an index on= + the=20 +fly with no obvious lock outs)?
+
 
+
Thanks,
+
 
+
Rod
+
 
+ +------=_NextPart_000_0012_01C4BA1D.49978060-- + + +From pgsql-performance-owner@postgresql.org Mon Oct 25 01:16:21 2004 +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 300263A2016 + for ; + Mon, 25 Oct 2004 01:16:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65952-08 + for ; + Mon, 25 Oct 2004 00:15: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 0FEE23A201A + for ; + Mon, 25 Oct 2004 01:16:13 +0100 (BST) +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 i9P0GHJA028828; + Sun, 24 Oct 2004 20:16:17 -0400 (EDT) +To: "Rod Dutton" +Cc: pgsql-performance@postgresql.org +Subject: Re: Reindexdb and REINDEX +In-reply-to: <20041024215359.ED668133D1E@mra04.ex.eclipse.net.uk> +References: <20041024215359.ED668133D1E@mra04.ex.eclipse.net.uk> +Comments: In-reply-to "Rod Dutton" + message dated "Sun, 24 Oct 2004 23:00:42 +0100" +Date: Sun, 24 Oct 2004 20:16:17 -0400 +Message-ID: <28827.1098663377@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/403 +X-Sequence-Number: 8879 + +"Rod Dutton" writes: +> My question is: will using the contrib/reindexdb or REINDEX sql command do +> essentially the same job as dropping and re-creating the indexes. I.E. do +> you get a fully compacted and balanced index? + +Yes. + +> How is concurrency handled by contrib/reindexdb and REINDEX (I know you can +> create an index on the fly with no obvious lock outs)? + +In 8.0 they are almost equivalent, but in earlier releases +REINDEX takes an exclusive lock on the index's parent table. + +The details are: + +DROP INDEX: takes exclusive lock, but doesn't hold it long. +CREATE INDEX: takes ShareLock, which blocks writers but not readers. + +So when you do it that way, readers can use the table while CREATE INDEX +runs, but of course they have no use of the dropped index. Putting the +DROP and the CREATE in one transaction isn't a good idea if you want +concurrency, because then the exclusive lock persists till transaction +end. + +REINDEX before 8.0: takes exclusive lock for the duration. + +This of course is a dead loss for concurrency. + +REINDEX in 8.0: takes ShareLock on the table and exclusive lock on +the particular index. + +This means that writers are blocked, but readers can proceed *as long as +they don't try to use the index under reconstruction*. If they try, +they block. + +If you're rebuilding a popular index, you have a choice of making +readers do seqscans or having them block till the rebuild completes. + +One other point is that DROP/CREATE breaks any stored plans that use the +index, which can have negative effects on plpgsql functions and PREPAREd +statements. REINDEX doesn't break plans. We don't currently have any +automated way of rebuilding stored plans, so in the worst case you may +have to terminate open backend sessions after a DROP/CREATE. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 25 01:30:55 2004 +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 BBE413A4027 + for ; + Mon, 25 Oct 2004 01:30:53 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72904-04 + for ; + Mon, 25 Oct 2004 00:30:23 +0000 (GMT) +Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) + by svr1.postgresql.org (Postfix) with ESMTP id 456563A4024 + for ; + Mon, 25 Oct 2004 01:30:50 +0100 (BST) +Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net + [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP + id EE97DC145; Mon, 25 Oct 2004 09:30:57 +0900 (JST) +Received: from localhost (localhost [127.0.0.1]) + by angelic.cynic.net (Postfix) with ESMTP + id 568D18736; Mon, 25 Oct 2004 09:30:56 +0900 (JST) +Date: Mon, 25 Oct 2004 09:30:56 +0900 (JST) +From: Curt Sampson +X-X-Sender: cjs@angelic-vtfw.cvpn.cynic.net +To: Tom Lane +Cc: Kevin Brown , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +In-Reply-To: <8438.1098628775@sss.pgh.pa.us> +Message-ID: +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + + <26467.1098555064@sss.pgh.pa.us> + + <8438.1098628775@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/404 +X-Sequence-Number: 8880 + +On Sun, 24 Oct 2004, Tom Lane wrote: + +> > Well, one really can't know without testing, but memory copies are +> > extremely expensive if they go outside of the cache. +> +> Sure, but what about all the copying from write queue to page? + +There's a pretty big difference between few-hundred-bytes-on-write and +eight-kilobytes-with-every-read memory copy. + +As for the queue allocation, again, I have no data to back this up, but +I don't think it would be as bad as BufMgrLock. Not every page will have +a write queue, and a "hot" page is only going to get one once. (If a +page has a write queue, you might as well leave it with the page after +flushing it, and get rid of it only when the page leaves memory.) + +I see the OS issues related to mapping that much memory as a much bigger +potential problem. + +cjs +-- +Curt Sampson +81 90 7737 2974 http://www.NetBSD.org + Make up enjoying your city life...produced by BIC CAMERA + +From pgsql-performance-owner@postgresql.org Mon Oct 25 02:18:07 2004 +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 CA9D33A3AE0 + for ; + Mon, 25 Oct 2004 02:18:05 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84742-06 + for ; + Mon, 25 Oct 2004 01:17: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 05E733A2016 + for ; + Mon, 25 Oct 2004 02:18:00 +0100 (BST) +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 i9P1I7tV029891; + Sun, 24 Oct 2004 21:18:07 -0400 (EDT) +To: Curt Sampson +Cc: Kevin Brown , + pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +In-reply-to: +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + + <26467.1098555064@sss.pgh.pa.us> + + <8438.1098628775@sss.pgh.pa.us> + +Comments: In-reply-to Curt Sampson + message dated "Mon, 25 Oct 2004 09:30:56 +0900" +Date: Sun, 24 Oct 2004 21:18:07 -0400 +Message-ID: <29890.1098667087@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/405 +X-Sequence-Number: 8881 + +Curt Sampson writes: +> I see the OS issues related to mapping that much memory as a much bigger +> potential problem. + +I see potential problems everywhere I look ;-) + +Considering that the available numbers suggest we could win just a few +percent (and that's assuming that all this extra mechanism has zero +cost), I can't believe that the project is worth spending manpower on. +There is a lot of much more attractive fruit hanging at lower levels. +The bitmap-indexing stuff that was recently being discussed, for +instance, would certainly take less effort than this; it would create +no new portability issues; and at least for the queries where it helps, +it could offer integer-multiple speedups, not percentage points. + +My engineering professors taught me that you put large effort where you +have a chance at large rewards. Converting PG to mmap doesn't seem to +meet that test, even if I believed it would work. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 25 02:33:01 2004 +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 5D9A33A2019 + for ; + Mon, 25 Oct 2004 02:32:59 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86769-08 + for ; + Mon, 25 Oct 2004 01:32:21 +0000 (GMT) +Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) + by svr1.postgresql.org (Postfix) with ESMTP id 6FACC3A3AE0 + for ; + Mon, 25 Oct 2004 02:32:49 +0100 (BST) +Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net + [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP + id C838AC145; Mon, 25 Oct 2004 10:32:57 +0900 (JST) +Received: from localhost (localhost [127.0.0.1]) + by angelic.cynic.net (Postfix) with ESMTP + id 05DBA8736; Mon, 25 Oct 2004 10:32:55 +0900 (JST) +Date: Mon, 25 Oct 2004 10:32:55 +0900 (JST) +From: Curt Sampson +X-X-Sender: cjs@angelic-vtfw.cvpn.cynic.net +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +In-Reply-To: <29890.1098667087@sss.pgh.pa.us> +Message-ID: +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + + <26467.1098555064@sss.pgh.pa.us> + + <8438.1098628775@sss.pgh.pa.us> + + <29890.1098667087@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/406 +X-Sequence-Number: 8882 + +On Sun, 24 Oct 2004, Tom Lane wrote: + +> Considering that the available numbers suggest we could win just a few +> percent... + +I must confess that I was completely unaware of these "numbers." Where +do I find them? + +cjs +-- +Curt Sampson +81 90 7737 2974 http://www.NetBSD.org + Make up enjoying your city life...produced by BIC CAMERA + +From pgsql-performance-owner@postgresql.org Mon Oct 25 16:58:09 2004 +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 BB9E63A405A + for ; + Mon, 25 Oct 2004 02:49:05 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91342-06 + for ; + Mon, 25 Oct 2004 01:48: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 AA0943A2019 + for ; + Mon, 25 Oct 2004 02:48:55 +0100 (BST) +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 i9P1n3E8006099; + Sun, 24 Oct 2004 21:49:03 -0400 (EDT) +To: Curt Sampson +Cc: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +In-reply-to: +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + + <26467.1098555064@sss.pgh.pa.us> + + <8438.1098628775@sss.pgh.pa.us> + + <29890.1098667087@sss.pgh.pa.us> + +Comments: In-reply-to Curt Sampson + message dated "Mon, 25 Oct 2004 10:32:55 +0900" +Date: Sun, 24 Oct 2004 21:49:03 -0400 +Message-ID: <6097.1098668943@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/416 +X-Sequence-Number: 8892 + +Curt Sampson writes: +> On Sun, 24 Oct 2004, Tom Lane wrote: +>> Considering that the available numbers suggest we could win just a few +>> percent... + +> I must confess that I was completely unaware of these "numbers." Where +> do I find them? + +The only numbers I've seen that directly bear on the question is +the oprofile results that Josh recently put up for the DBT-3 benchmark, +which showed the kernel copy-to-userspace and copy-from-userspace +subroutines eating a percent or two apiece of the total runtime. +I don't have the URL at hand but it was posted just a few days ago. +(Now that covers all such copies and not only our datafile reads/writes, +but it's probably fair to assume that the datafile I/O is the bulk of it.) + +This is, of course, only one benchmark ... but lacking any measurements +in opposition, I'm inclined to believe it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 25 16:58:17 2004 +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 3C9063A4049 + for ; + Mon, 25 Oct 2004 02:50:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92335-05 + for ; + Mon, 25 Oct 2004 01:49: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 D082F3A4045 + for ; + Mon, 25 Oct 2004 02:50:27 +0100 (BST) +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 i9P1oZWd006277; + Sun, 24 Oct 2004 21:50:35 -0400 (EDT) +To: Curt Sampson +Cc: pgsql-performance@postgresql.org +Subject: Re: First set of OSDL Shared Mem scalability results, some +In-reply-to: <6097.1098668943@sss.pgh.pa.us> +References: <200410081443.16109.josh@agliodbs.com> + + <20041009112048.GA665@filer> <27696.1097334448@sss.pgh.pa.us> + <20041009203710.GB665@filer> <4859.1097363137@sss.pgh.pa.us> + + <26467.1098555064@sss.pgh.pa.us> + + <8438.1098628775@sss.pgh.pa.us> + + <29890.1098667087@sss.pgh.pa.us> + + <6097.1098668943@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Sun, 24 Oct 2004 21:49:03 -0400" +Date: Sun, 24 Oct 2004 21:50:34 -0400 +Message-ID: <6276.1098669034@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/418 +X-Sequence-Number: 8894 + +I wrote: +> I don't have the URL at hand but it was posted just a few days ago. + +... actually, it was the beginning of this here thread ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 25 08:17:22 2004 +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 B755F3A3B56 + for ; + Mon, 25 Oct 2004 08:17:21 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71174-08 + for ; + Mon, 25 Oct 2004 07:17:11 +0000 (GMT) +Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A63E3A3B14 + for ; + Mon, 25 Oct 2004 08:17:11 +0100 (BST) +Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net + [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP + id 4DD79BFFB; Mon, 25 Oct 2004 16:17:09 +0900 (JST) +Received: from localhost (localhost [127.0.0.1]) + by angelic.cynic.net (Postfix) with ESMTP + id BD8DC8736; Mon, 25 Oct 2004 16:17:07 +0900 (JST) +Date: Mon, 25 Oct 2004 16:17:07 +0900 (JST) +From: Curt Sampson +X-X-Sender: cjs@angelic-vtfw.cvpn.cynic.net +To: John Meinel +Cc: pgsql-performance@postgresql.org +Subject: Re: Sequential Scan with LIMIT +In-Reply-To: <417C023F.1080502@johnmeinel.com> +Message-ID: +References: <417C023F.1080502@johnmeinel.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/407 +X-Sequence-Number: 8883 + +On Sun, 24 Oct 2004, John Meinel wrote: + +> I was looking into another problem, and I found something that surprised +> me. If I'm doing "SELECT * FROM mytable WHERE col = 'myval' LIMIT 1.". +> Now "col" is indexed... +> The real purpose of this query is to check to see if a value exists in +> the column,... + +When you select all the columns, you're going to force it to go to the +table. If you select only the indexed column, it ought to be able to use +just the index, and never read the table at all. You could also use more +standard and more set-oriented SQL while you're at it: + + SELECT DISTINCT(col) FROM mytable WHERE col = 'myval' + +cjs +-- +Curt Sampson +81 90 7737 2974 http://www.NetBSD.org + Make up enjoying your city life...produced by BIC CAMERA + +From pgsql-performance-owner@postgresql.org Mon Oct 25 08:25:29 2004 +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 121093A40D0 + for ; + Mon, 25 Oct 2004 08:25:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76246-01 + for ; + Mon, 25 Oct 2004 07:25:17 +0000 (GMT) +Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) + by svr1.postgresql.org (Postfix) with ESMTP id BF5A93A40FB + for ; + Mon, 25 Oct 2004 08:25:17 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by sue.samurai.com (Postfix) with ESMTP id AEF70197F4; + Mon, 25 Oct 2004 03:25:17 -0400 (EDT) +Received: from sue.samurai.com ([127.0.0.1]) + by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 30709-01-9; Mon, 25 Oct 2004 03:25:14 -0400 (EDT) +Received: from [61.88.101.19] (unknown [61.88.101.19]) + by sue.samurai.com (Postfix) with ESMTP id 8514B197F1; + Mon, 25 Oct 2004 03:25:13 -0400 (EDT) +Subject: Re: Sequential Scan with LIMIT +From: Neil Conway +To: Curt Sampson +Cc: John Meinel , + pgsql-performance@postgresql.org +In-Reply-To: +References: <417C023F.1080502@johnmeinel.com> + +Content-Type: text/plain +Message-Id: <1098689094.13261.445.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 25 Oct 2004 17:24:54 +1000 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/408 +X-Sequence-Number: 8884 + +On Mon, 2004-10-25 at 17:17, Curt Sampson wrote: +> When you select all the columns, you're going to force it to go to the +> table. If you select only the indexed column, it ought to be able to use +> just the index, and never read the table at all. + +Perhaps in other database systems, but not in PostgreSQL. MVCC +information is only stored in the heap, not in indexes: therefore, +PostgreSQL cannot determine whether a given index entry refers to a +valid tuple. Therefore, it needs to check the heap even if the index +contains all the columns referenced by the query. + +While it would be nice to be able to do index-only scans, there is good +reason for this design decision. Check the archives for past discussion +about the tradeoffs involved. + +> You could also use more +> standard and more set-oriented SQL while you're at it: +> +> SELECT DISTINCT(col) FROM mytable WHERE col = 'myval' + +This is likely to be less efficient though. + +-Neil + + + +From pgsql-performance-owner@postgresql.org Mon Oct 25 14:51:39 2004 +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 267553A4052 + for ; + Mon, 25 Oct 2004 14:51:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91568-07 + for ; + Mon, 25 Oct 2004 13:51:30 +0000 (GMT) +Received: from smtp105.rog.mail.re2.yahoo.com (smtp105.rog.mail.re2.yahoo.com + [206.190.36.83]) + by svr1.postgresql.org (Postfix) with SMTP id BD5633A402C + for ; + Mon, 25 Oct 2004 14:51:32 +0100 (BST) +Received: from unknown (HELO phlogiston.dydns.org) + (a.sullivan@rogers.com@65.49.125.184 with login) + by smtp105.rog.mail.re2.yahoo.com with SMTP; 25 Oct 2004 13:51:33 -0000 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 7CAE44058; Mon, 25 Oct 2004 09:51:31 -0400 (EDT) +Date: Mon, 25 Oct 2004 09:51:31 -0400 +From: Andrew Sullivan +To: PgSQL - Performance +Subject: Re: Performance Anomalies in 7.4.5 +Message-ID: <20041025135131.GA2886@phlogiston.dyndns.org> +Mail-Followup-To: PgSQL - Performance +References: + <25228.1098395599@sss.pgh.pa.us> + <20041022194058.GC22395@phlogiston.dyndns.org> + <417977EE.8050207@zeut.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <417977EE.8050207@zeut.net> +User-Agent: Mutt/1.5.6+20040722i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/409 +X-Sequence-Number: 8885 + +On Fri, Oct 22, 2004 at 05:13:18PM -0400, Matthew T. O'Connor wrote: + +> Yes that is the long term goal, but the autovac in 8.0 is still all or +> nothing. + +Yes, which is why I couldn't use the current iteration for +production: the cost is too high. I think this re-inforces my +original point, which is that taking away the ability of DBAs to +thump the planner for certain tables -- even indirectly -- under +certain pathological conditions is crucial for production work. In +the ideal world, the wizards and genius planners and such like would +work perfectly, and the DBA would never have to intervene. In +practice, there are cases when you need to haul on a knob or two. +While this doesn't mean that we should adopt the Oracle approach of +having knobs which adjust the sensitivity of the knob that tunes the +main knob-tuner, I'm still pretty leery of anything which smacks of +completely locking the DBA's knowledge out of the system. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +The plural of anecdote is not data. + --Roger Brinner + +From pgsql-performance-owner@postgresql.org Mon Oct 25 15:33:52 2004 +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 710643A40CA + for ; + Mon, 25 Oct 2004 15:33:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08743-10 + for ; + Mon, 25 Oct 2004 14:33:42 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id C49723A40D0 + for ; + Mon, 25 Oct 2004 15:33:44 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.12.9/8.12.9) with ESMTP id + i9PEXbMq021211; (envelope-from ) Mon, + 25 Oct 2004 09:33:37 -0500 (CDT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by server11.icaen.uiowa.edu (8.12.9/smtp-service-1.6) with ESMTP id + i9PEXaJ9001445 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); + (envelope-from ) Mon, + 25 Oct 2004 09:33:36 -0500 (CDT) +Message-ID: <417D0EC2.5020206@johnmeinel.com> +Date: Mon, 25 Oct 2004 09:33:38 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Curt Sampson +Cc: pgsql-performance@postgresql.org +Subject: Re: Sequential Scan with LIMIT +References: <417C023F.1080502@johnmeinel.com> + +In-Reply-To: +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig1883AEDB77A4CC3971BEA57B" +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.66n +X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.75 + on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/410 +X-Sequence-Number: 8886 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig1883AEDB77A4CC3971BEA57B +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Curt Sampson wrote: +> On Sun, 24 Oct 2004, John Meinel wrote: +> +> +>>I was looking into another problem, and I found something that surprised +>>me. If I'm doing "SELECT * FROM mytable WHERE col = 'myval' LIMIT 1.". +>>Now "col" is indexed... +>>The real purpose of this query is to check to see if a value exists in +>>the column,... +> +> +> When you select all the columns, you're going to force it to go to the +> table. If you select only the indexed column, it ought to be able to use +> just the index, and never read the table at all. You could also use more +> standard and more set-oriented SQL while you're at it: +> +> SELECT DISTINCT(col) FROM mytable WHERE col = 'myval' +> +> cjs + +Well, what you wrote was actually much slower, as it had to scan the +whole table, grab all the rows, and then distinct them in the end. + +However, this query worked: + + + SELECT DISTINCT(col) FROM mytable WHERE col = 'myval' LIMIT 1; + + +Now, *why* that works differently from: + +SELECT col FROM mytable WHERE col = 'myval' LIMIT 1; +or +SELECT DISTINCT(col) FROM mytable WHERE col = 'myval'; + +I'm not sure. They all return the same information. + +What's also weird is stuff like: +SELECT DISTINCT(NULL) FROM mytable WHERE col = 'myval' LIMIT 1; + +Also searches the entire table, sorting that NULL == NULL wherever col = +'myval'. Which is as expensive as the non-limited case (I'm guessing +that the limit is occurring after the distinct, which is causing the +problem. SELECT NULL FROM ... still uses a sequential scan, but it stops +after finding the first one.) + + +Actually, in doing a little bit more testing, the working query only +works on some of the values. Probably it just increases the expense +enough that it switches over. It also has the downside that when it does +switch to seq scan, it is much more expensive as it has to do a sort and +a unique on all the entries. + +John +=:-> + +--------------enig1883AEDB77A4CC3971BEA57B +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBfQ7CJdeBCYSNAAMRAu0QAKDOWBXEP/2tshNMNTtGlr5fEPLuPQCeOURu +2Gsj++N4zoUmHhMJqnKvmFE= +=sJHL +-----END PGP SIGNATURE----- + +--------------enig1883AEDB77A4CC3971BEA57B-- + +From pgsql-hackers-owner@postgresql.org Mon Oct 25 16:38:38 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EB403A4147 + for ; + Mon, 25 Oct 2004 16:38:35 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33084-08 + for ; + Mon, 25 Oct 2004 15:38:29 +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 8CE643A4142 + for ; + Mon, 25 Oct 2004 16:38:28 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp104.mail.sc5.yahoo.com with SMTP; 25 Oct 2004 15:38:27 -0000 +Received: from [172.21.8.18] (ismtp.afilias.com [216.217.55.254]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9PFc994003184; Mon, 25 Oct 2004 11:38:13 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <417D1D01.3090401@Yahoo.com> +Date: Mon, 25 Oct 2004 11:34:25 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Kenneth Marshall +Cc: Simon Riggs , + pgsql-patches@postgresql.org, pgsql-hackers@postgresql.org, + josh@agliodbs.com +Subject: Re: ARC Memory Usage analysis +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> +In-Reply-To: <20041022200955.GC4382@it.is.rice.edu> +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.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200410/818 +X-Sequence-Number: 60321 + +On 10/22/2004 4:09 PM, Kenneth Marshall wrote: + +> On Fri, Oct 22, 2004 at 03:35:49PM -0400, Jan Wieck wrote: +>> On 10/22/2004 2:50 PM, Simon Riggs wrote: +>> +>> >I've been using the ARC debug options to analyse memory usage on the +>> >PostgreSQL 8.0 server. This is a precursor to more complex performance +>> >analysis work on the OSDL test suite. +>> > +>> >I've simplified some of the ARC reporting into a single log line, which +>> >is enclosed here as a patch on freelist.c. This includes reporting of: +>> >- the total memory in use, which wasn't previously reported +>> >- the cache hit ratio, which was slightly incorrectly calculated +>> >- a useful-ish value for looking at the "B" lists in ARC +>> >(This is a patch against cvstip, but I'm not sure whether this has +>> >potential for inclusion in 8.0...) +>> > +>> >The total memory in use is useful because it allows you to tell whether +>> >shared_buffers is set too high. If it is set too high, then memory usage +>> >will continue to grow slowly up to the max, without any corresponding +>> >increase in cache hit ratio. If shared_buffers is too small, then memory +>> >usage will climb quickly and linearly to its maximum. +>> > +>> >The last one I've called "turbulence" in an attempt to ascribe some +>> >useful meaning to B1/B2 hits - I've tried a few other measures though +>> >without much success. Turbulence is the hit ratio of B1+B2 lists added +>> >together. By observation, this is zero when ARC gives smooth operation, +>> >and goes above zero otherwise. Typically, turbulence occurs when +>> >shared_buffers is too small for the working set of the database/workload +>> >combination and ARC repeatedly re-balances the lengths of T1/T2 as a +>> >result of "near-misses" on the B1/B2 lists. Turbulence doesn't usually +>> >cut in until the cache is fully utilized, so there is usually some delay +>> >after startup. +>> > +>> >We also recently discussed that I would add some further memory analysis +>> >features for 8.1, so I've been trying to figure out how. +>> > +>> >The idea that B1, B2 represent something really useful doesn't seem to +>> >have been borne out - though I'm open to persuasion there. +>> > +>> >I originally envisaged a "shadow list" operating in extension of the +>> >main ARC list. This will require some re-coding, since the variables and +>> >macros are all hard-coded to a single set of lists. No complaints, just +>> >it will take a little longer than we all thought (for me, that is...) +>> > +>> >My proposal is to alter the code to allow an array of memory linked +>> >lists. The actual list would be [0] - other additional lists would be +>> >created dynamically as required i.e. not using IFDEFs, since I want this +>> >to be controlled by a SIGHUP GUC to allow on-site tuning, not just lab +>> >work. This will then allow reporting against the additional lists, so +>> >that cache hit ratios can be seen with various other "prototype" +>> >shared_buffer settings. +>> +>> All the existing lists live in shared memory, so that dynamic approach +>> suffers from the fact that the memory has to be allocated during ipc_init. +>> +>> What do you think about my other theory to make C actually 2x effective +>> cache size and NOT to keep T1 in shared buffers but to assume T1 lives +>> in the OS buffer cache? +>> +>> +>> Jan +>> +> Jan, +> +>>From the articles that I have seen on the ARC algorithm, I do not think +> that using the effective cache size to set C would be a win. The design +> of the ARC process is to allow the cache to optimize its use in response +> to the actual workload. It may be the best use of the cache in some cases +> to have the entire cache allocated to T1 and similarly for T2. If fact, +> the ability to alter the behavior as needed is one of the key advantages. + +Only the "working set" of the database, that is the pages that are very +frequently used, are worth holding in shared memory at all. The rest +should be copied in and out of the OS disc buffers. + +The problem is, with a too small directory ARC cannot guesstimate what +might be in the kernel buffers. Nor can it guesstimate what recently was +in the kernel buffers and got pushed out from there. That results in a +way too small B1 list, and therefore we don't get B1 hits when in fact +the data was found in memory. B1 hits is what increases the T1target, +and since we are missing them with a too small directory size, our +implementation of ARC is propably using a T2 size larger than the +working set. That is not optimal. + +If we would replace the dynamic T1 buffers with a max_backends*2 area of +shared buffers, use a C value representing the effective cache size and +limit the T1target on the lower bound to effective cache size - shared +buffers, then we basically moved the T1 cache into the OS buffers. + +This all only holds water, if the OS is allowed to swap out shared +memory. And that was my initial question, how likely is it to find this +to be true these days? + + +Jan + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-hackers-owner@postgresql.org Mon Oct 25 17:06:45 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D1D2B3A4142 + for ; + Mon, 25 Oct 2004 17:03:37 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43775-10 + for ; + Mon, 25 Oct 2004 16:03: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 0F9923A4147 + for ; + Mon, 25 Oct 2004 17:03:31 +0100 (BST) +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 i9PG3D7t020652; + Mon, 25 Oct 2004 12:03:13 -0400 (EDT) +To: Jan Wieck +Cc: Kenneth Marshall , + Simon Riggs , pgsql-patches@postgresql.org, + pgsql-hackers@postgresql.org, josh@agliodbs.com +Subject: Re: [PATCHES] ARC Memory Usage analysis +In-reply-to: <417D1D01.3090401@Yahoo.com> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> +Comments: In-reply-to Jan Wieck + message dated "Mon, 25 Oct 2004 11:34:25 -0400" +Date: Mon, 25 Oct 2004 12:03:12 -0400 +Message-ID: <20651.1098720192@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/821 +X-Sequence-Number: 60324 + +Jan Wieck writes: +> This all only holds water, if the OS is allowed to swap out shared +> memory. And that was my initial question, how likely is it to find this +> to be true these days? + +I think it's more likely that not that the OS will consider shared +memory to be potentially swappable. On some platforms there is a shmctl +call you can make to lock your shmem in memory, but (a) we don't use it +and (b) it may well require privileges we haven't got anyway. + +This has always been one of the arguments against making shared_buffers +really large, of course --- if the buffers aren't all heavily used, and +the OS decides to swap them to disk, you are worse off than you would +have been with a smaller shared_buffers setting. + + +However, I'm still really nervous about the idea of using +effective_cache_size to control the ARC algorithm. That number is +usually entirely bogus. Right now it is only a second-order influence +on certain planner estimates, and I am afraid to rely on it any more +heavily than that. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 25 17:34:05 2004 +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 901453A412E + for ; + Mon, 25 Oct 2004 17:34:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60797-01 + for ; + Mon, 25 Oct 2004 16:33:57 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B7E33A3AEC + for ; + Mon, 25 Oct 2004 17:33:57 +0100 (BST) +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 6553324; Mon, 25 Oct 2004 09:35:21 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +Date: Mon, 25 Oct 2004 09:33:07 -0700 +User-Agent: KMail/1.6.2 +Cc: Manfred Spraul , + Mark Wong , Tom Lane , neilc@samurai.com +References: <417221B5.1050704@colorfullife.com> + <20041020150528.B7838@osdl.org> + <41774D11.1030906@colorfullife.com> +In-Reply-To: <41774D11.1030906@colorfullife.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410250933.07550.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/420 +X-Sequence-Number: 8896 + +Manfred, + +> How complicated are Tom's test scripts? His immediate reply was that I +> should retest with Fedora, to rule out any gentoo bugs. + +We've done some testing on other Linux. Linking in pthreads reduced CSes by +< 15%, which was no appreciable impact on real performance. + +Gavin/Neil's full futex patch was of greater benefit; while it did not reduce +CSes very much (25%) somehow the real performance benefit was greater. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Oct 25 17:45:23 2004 +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 A51B13A4176 + for ; + Mon, 25 Oct 2004 17:45:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61378-09 + for ; + Mon, 25 Oct 2004 16:45:16 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B5643A415D + for ; + Mon, 25 Oct 2004 17:45:15 +0100 (BST) +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 i9PGj6P7021094; + Mon, 25 Oct 2004 12:45:06 -0400 (EDT) +To: Manfred Spraul +Cc: neilc@samurai.com, markw@osdl.org, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +In-reply-to: <4176A2C1.3070205@colorfullife.com> +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <417697A5.1050600@colorfullife.com> <7178.1098292535@sss.pgh.pa.us> + <4176A2C1.3070205@colorfullife.com> +Comments: In-reply-to Manfred Spraul + message dated "Wed, 20 Oct 2004 19:39:13 +0200" +Date: Mon, 25 Oct 2004 12:45:06 -0400 +Message-ID: <21093.1098722706@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/421 +X-Sequence-Number: 8897 + +Manfred Spraul writes: +> But: According to the descriptions the problem is a context switch +> storm. I don't see that cache line bouncing can cause a context switch +> storm. What causes the context switch storm? + +As best I can tell, the CS storm arises because the backends get into +some sort of lockstep timing that makes it far more likely than you'd +expect for backend A to try to enter the bufmgr when backend B is already +holding the BufMgrLock. In the profiles we were looking at back in +April, it seemed that about 10% of the time was spent inside bufmgr +(which is bad enough in itself) but the odds of LWLock collision were +much higher than 10%, leading to many context swaps. + +This is not totally surprising given that they are running identical +queries and so are running through loops of the same length, but still +it seems like there must be some effect driving their timing to converge +instead of diverge away from the point of conflict. + +What I think (and here is where it's a leap of logic, cause I can't +prove it) is that the excessive time spent passing the spinlock cache +line back and forth is exactly the factor causing that convergence. +Somehow, the delay caused when a processor has to wait to get the cache +line contributes to keeping the backend loops in lockstep. + +It is critical to understand that the CS storm is associated with LWLock +contention not spinlock contention: what we saw was a lot of semop()s +not a lot of select()s. + +> If it's the pg_usleep in s_lock, then my patch should help a lot: with +> pthread_rwlock locks, this line doesn't exist anymore. + +The profiles showed that s_lock() is hardly entered at all, and the +select() delay is reached even more seldom. So changes in that area +will make exactly zero difference. This is the surprising and +counterintuitive thing: oprofile clearly shows that very large fractions +of the CPU time are being spent at the initial TAS instructions in +LWLockAcquire and LWLockRelease, and yet those TASes hardly ever fail, +as proven by the fact that oprofile shows s_lock() is seldom entered. +So as far as the Postgres code can tell, there isn't any contention +worth mentioning for the spinlock. This is indeed the way it was +designed to be, but when so much time is going to the TAS instructions, +you'd think there'd be more software-visible contention for the +spinlock. + +It could be that I'm all wet and there is no relationship between the +cache line thrashing and the seemingly excessive BufMgrLock contention. +They are after all occurring at two very different levels of abstraction. +But I think there is some correlation that we just don't understand yet. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 25 18:07:12 2004 +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 7A4863A4174 + for ; + Mon, 25 Oct 2004 18:07:09 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67142-10 + for ; + Mon, 25 Oct 2004 17:07:07 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 12EC83A4052 + for ; + Mon, 25 Oct 2004 18:07:07 +0100 (BST) +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 6553462; Mon, 25 Oct 2004 10:08:33 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: different io elevators in linux +Date: Mon, 25 Oct 2004 10:09:17 -0700 +User-Agent: KMail/1.6.2 +Cc: Bjorn Bength +References: <1098546845.7754.8.camel@localhost> +In-Reply-To: <1098546845.7754.8.camel@localhost> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: 7bit +Message-Id: <200410251009.17575.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/422 +X-Sequence-Number: 8898 + +Bjorn, + +> I haven't read much FAQs but has anyone done some benchmarks with +> different io schedulers in linux with postgresql? + +According to OSDL, using the "deadline" scheduler sometimes results in a +roughly 5% boost to performance, and sometimes none, depending on the +application. We use it for all testing, though, just in case. + +--Josh + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-hackers-owner@postgresql.org Mon Oct 25 18:14:46 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3639F3A4143 + for ; + Mon, 25 Oct 2004 18:14:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72181-08 + for ; + Mon, 25 Oct 2004 17:14:42 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FCE73A3AEC + for ; + Mon, 25 Oct 2004 18:14:42 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CM8QZ-0001sm-00; Mon, 25 Oct 2004 13:14:39 -0400 +To: pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> +In-Reply-To: <20651.1098720192@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 25 Oct 2004 13:14:39 -0400 +Message-ID: <87mzyavhxc.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/829 +X-Sequence-Number: 60332 + + +Tom Lane writes: + +> However, I'm still really nervous about the idea of using +> effective_cache_size to control the ARC algorithm. That number is +> usually entirely bogus. + +It wouldn't be too hard to have a port-specific function that tries to guess +the total amount of memory. That isn't always right but it's at least a better +ballpark default than a fixed arbitrary value. + +However I wonder about another approach entirely. If postgres timed how long +reads took it shouldn't find it very hard to distinguish between a cached +buffer being copied and an actual i/o operation. It should be able to track +the percentage of time that buffers requested are in the kernel's cache and +use that directly instead of the estimated cache size. + +Adding two gettimeofdays to every read call would be annoyingly expensive. But +a port-specific function to check the cpu instruction counter could be useful. +It doesn't have to be an accurate measurement of time (such as on some +multi-processor machines) as long as it's possible to distinguish when a slow +disk operation has occurred from when no disk operation has occurred. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun Oct 31 05:24:29 2004 +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 664D93A3AC7 + for ; + Mon, 25 Oct 2004 18:31:01 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79206-05 + for ; + Mon, 25 Oct 2004 17:30:58 +0000 (GMT) +Received: from dbl.q-ag.de (dbl.q-ag.de [213.172.117.3]) + by svr1.postgresql.org (Postfix) with ESMTP id BC03D3A415D + for ; + Mon, 25 Oct 2004 18:30:55 +0100 (BST) +Received: from [127.0.0.2] (dbl [127.0.0.1]) + by dbl.q-ag.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i9PHUfSL030207; + Mon, 25 Oct 2004 19:30:42 +0200 +Message-ID: <417D383E.1010807@colorfullife.com> +Date: Mon, 25 Oct 2004 19:30:38 +0200 +From: Manfred Spraul +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.7.3) Gecko/20040922 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: neilc@samurai.com, markw@osdl.org, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <417697A5.1050600@colorfullife.com> <7178.1098292535@sss.pgh.pa.us> + <4176A2C1.3070205@colorfullife.com> + <21093.1098722706@sss.pgh.pa.us> +In-Reply-To: <21093.1098722706@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/472 +X-Sequence-Number: 8948 + +Tom Lane wrote: + +>It could be that I'm all wet and there is no relationship between the +>cache line thrashing and the seemingly excessive BufMgrLock contention. +> +> +Is it important? The fix is identical in both cases: per-bucket locks +for the hash table and a buffer aging strategy that doesn't need one +global lock that must be acquired for every lookup. + +-- + Manfred + +From pgsql-performance-owner@postgresql.org Mon Oct 25 18:45:38 2004 +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 C916D3A4188 + for ; + Mon, 25 Oct 2004 18:45:37 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84185-09 + for ; + Mon, 25 Oct 2004 17:45: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 605553A4165 + for ; + Mon, 25 Oct 2004 18:45:35 +0100 (BST) +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 i9PHjTkY021744; + Mon, 25 Oct 2004 13:45:29 -0400 (EDT) +To: Manfred Spraul +Cc: neilc@samurai.com, markw@osdl.org, + pgsql-performance@postgresql.org +Subject: Re: futex results with dbt-3 +In-reply-to: <417D383E.1010807@colorfullife.com> +References: <417221B5.1050704@colorfullife.com> + <20151.1098222733@sss.pgh.pa.us> + <417697A5.1050600@colorfullife.com> <7178.1098292535@sss.pgh.pa.us> + <4176A2C1.3070205@colorfullife.com> + <21093.1098722706@sss.pgh.pa.us> + <417D383E.1010807@colorfullife.com> +Comments: In-reply-to Manfred Spraul + message dated "Mon, 25 Oct 2004 19:30:38 +0200" +Date: Mon, 25 Oct 2004 13:45:28 -0400 +Message-ID: <21743.1098726328@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/423 +X-Sequence-Number: 8899 + +Manfred Spraul writes: +> Tom Lane wrote: +>> It could be that I'm all wet and there is no relationship between the +>> cache line thrashing and the seemingly excessive BufMgrLock contention. +>> +> Is it important? The fix is identical in both cases: per-bucket locks +> for the hash table and a buffer aging strategy that doesn't need one +> global lock that must be acquired for every lookup. + +Reducing BufMgrLock contention is a good idea, but it's not really my +idea of a fix for this issue. In the absence of a full understanding, +we may be fixing the wrong thing. It's worth remembering that when we +first hit this issue, I made some simple changes that approximately +halved the number of BufMgrLock acquisitions by joining ReleaseBuffer +and ReadBuffer calls into ReleaseAndReadBuffer in all the places in the +test case's loop. This made essentially no change in the CS storm +behavior :-(. So I do not know how much contention we have to get rid +of to get the problem to go away, or even whether this is the right path +to take. + +(I am unconvinced that either of those specific suggestions is The Right +Way to break up the bufmgrlock, either, but that's a different thread.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Oct 25 21:53:32 2004 +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 94D753A3C35 + for ; + Mon, 25 Oct 2004 21:53:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78858-01 + for ; + Mon, 25 Oct 2004 20:53:23 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com + [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 43B623A3B16 + for ; + Mon, 25 Oct 2004 21:53:23 +0100 (BST) +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_01C4BAD4.AAC1D4BF" +Subject: can't handle large number of INSERT/UPDATEs +Date: Mon, 25 Oct 2004 16:53:23 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985D5@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: can't handle large number of INSERT/UPDATEs +Thread-Index: AcS61KspcGsLLkbcT7etdP20bnwpiQ== +From: "Anjan Dave" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=HTML_60_70, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/424 +X-Sequence-Number: 8900 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C4BAD4.AAC1D4BF +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Hi, + +=20 + +I am dealing with an app here that uses pg to handle a few thousand +concurrent web users. It seems that under heavy load, the INSERT and +UPDATE statements to one or two specific tables keep queuing up, to the +count of 150+ (one table has about 432K rows, other has about 2.6Million +rows), resulting in 'wait's for other queries, and then everything piles +up, with the load average shooting up to 10+.=20 + +=20 + +We (development) have gone through the queries/explain analyzes and made +sure the appropriate indexes exist among other efforts put in. + +=20 + +I would like to know if there is anything that can be changed for better +from the systems perspective. Here's what I have done and some recent +changes from the system side: + +=20 + +-Upgraded from 7.4.0 to 7.4.1 sometime ago + +-Upgraded from RH8 to RHEL 3.0 + +-The settings from postgresql.conf (carried over, basically) are: + + shared_buffers =3D 10240 (80MB) + + max_connections =3D 400 + + sort_memory =3D 1024 + + effective_cache_size =3D 262144 (2GB) + + checkpoint_segments =3D 15 + +stats_start_collector =3D true + +stats_command_string =3D true=20 + +Rest everything is at default + +=20 + +In /etc/sysctl.conf (512MB shared mem) + +kernel.shmall =3D 536870912 + +kernel.shmmax =3D 536870912 + +=20 + +-This is a new Dell 6650 (quad XEON 2.2GHz, 8GB RAM, Internal HW +RAID10), RHEL 3.0 (2.4.21-20.ELsmp), PG 7.4.1 + +-Vaccum Full run everyday + +-contrib/Reindex run everyday + +-Disabled HT in BIOS + +=20 + +I would greatly appreciate any helpful ideas. + +=20 + +Thanks in advance, + +=20 + +Anjan + + +------_=_NextPart_001_01C4BAD4.AAC1D4BF +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hi,

+ +

 

+ +

I am dealing with an app here that uses pg to handle a f= +ew +thousand concurrent web users. It seems that under heavy load, the INSERT a= +nd +UPDATE statements to one or two specific tables keep queuing up, to the cou= +nt +of 150+ (one table has about 432K rows, other has about 2.6Million rows), r= +esulting +in ‘wait’s for other queries, and then everything piles up, wit= +h the +load average shooting up to 10+.

+ +

 

+ +

We (development) have gone through the queries/explain +analyzes and made sure the appropriate indexes exist among other efforts put +in.

+ +

 

+ +

I would like to know if there is anything that can be +changed for better from the systems perspective. Here’s what I have d= +one and +some recent changes from the system side:

+ +

 

+ +

-Upgraded from 7.4.0 to 7.4.1 sometime ago

+ +

-Upgraded from RH8 to RHEL 3.0<= +/p> + +

-The settings from postgresql.conf (carried over, basica= +lly) +are:

+ +

         &n= +bsp;  shared_buffers +=3D 10240 (80MB)

+ +

         &n= +bsp;  max_connections +=3D 400

+ +

         &n= +bsp;  sort_memory +=3D 1024

+ +

         &n= +bsp;  effective_cache_size +=3D 262144 (2GB)

+ +

         &n= +bsp;  checkpoint_segments +=3D 15

+ +

stats_start_collector =3D true= +

+ +

stats_command_string =3D true = +

+ +

Rest everything is at default<= +o:p>

+ +

 

+ +

In /etc/sysctl.conf (512MB sha= +red +mem)

+ +

kernel.shmall =3D 536870912

+ +

kernel.shmmax =3D 536870912

+ +

 

+ +

-This is a new Dell 6650 (quad XEON 2.2GHz, 8GB RAM, +Internal HW RAID10), RHEL 3.0 (2.4.21-20.ELsmp), PG 7.4.1= +

+ +

-Vaccum Full run everyday

+ +

-contrib/Reindex run everyday + +

-Disabled HT in BIOS

+ +

 

+ +

I would greatly appreciate any helpful ideas.= +

+ +

 

+ +

Thanks in advance,

+ +

 

+ +

Anjan

+ +
+ + + + + +------_=_NextPart_001_01C4BAD4.AAC1D4BF-- + +From pgsql-performance-owner@postgresql.org Mon Oct 25 22:20:14 2004 +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 19DD03A3BF2 + for ; + Mon, 25 Oct 2004 22:20:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86237-04 + for ; + Mon, 25 Oct 2004 21:20:02 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 192C33A3B16 + for ; + Mon, 25 Oct 2004 22:20:01 +0100 (BST) +Received: from [134.22.69.212] (dyn-69-212.tor.dsl.tht.net [134.22.69.212]) + by tht.net (Postfix) with ESMTP + id AB24676B17; Mon, 25 Oct 2004 17:19:59 -0400 (EDT) +Subject: Re: can't handle large number of INSERT/UPDATEs +From: Rod Taylor +To: Anjan Dave +Cc: Postgresql Performance +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985D5@vt-pe2550-001.vantage.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985D5@vt-pe2550-001.vantage.vantage.com> +Content-Type: text/plain; charset=iso-8859-7 +Message-Id: <1098739153.8557.333.camel@home> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 25 Oct 2004 17:19:14 -0400 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/425 +X-Sequence-Number: 8901 + +On Mon, 2004-10-25 at 16:53, Anjan Dave wrote: +> Hi, +> +> +> +> I am dealing with an app here that uses pg to handle a few thousand +> concurrent web users. It seems that under heavy load, the INSERT and +> UPDATE statements to one or two specific tables keep queuing up, to +> the count of 150+ (one table has about 432K rows, other has about +> 2.6Million rows), resulting in �wait�s for other queries, and then + +This isn't an index issue, it's a locking issue. Sounds like you have a +bunch of inserts and updates hitting the same rows over and over again. + +Eliminate that contention point, and you will have solved your problem. + +Free free to describe the processes involved, and we can help you do +that. + + + +From pgsql-hackers-owner@postgresql.org Mon Oct 25 22:31:03 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5214B3A421A + for ; + Mon, 25 Oct 2004 22:31:02 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89626-07 + for ; + Mon, 25 Oct 2004 21:30:56 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id D5DD63A4211 + for ; + Mon, 25 Oct 2004 22:30:56 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CMCQX-0004qr-00; Mon, 25 Oct 2004 17:30:53 -0400 +To: Greg Stark +Cc: pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> +In-Reply-To: <87mzyavhxc.fsf@stark.xeocode.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 25 Oct 2004 17:30:52 -0400 +Message-ID: <87hdoiv62b.fsf@stark.xeocode.com> +Lines: 51 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="=BATF-Ruby-Ridge-Europol-USDOJ-Vince-Foster-FIPS140-Albright-Baranyi-" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/850 +X-Sequence-Number: 60353 + +--=BATF-Ruby-Ridge-Europol-USDOJ-Vince-Foster-FIPS140-Albright-Baranyi- + +Greg Stark writes: + +> However I wonder about another approach entirely. If postgres timed how long +> reads took it shouldn't find it very hard to distinguish between a cached +> buffer being copied and an actual i/o operation. It should be able to track +> the percentage of time that buffers requested are in the kernel's cache and +> use that directly instead of the estimated cache size. + +I tested this with a program that times seeking to random locations in a file. +It's pretty easy to spot the break point. There are very few fetches that take +between 50us and 1700us, probably they come from the drive's onboard cache. + +The 1700us bound probably would be lower for high end server equipment with +10k RPM drives and RAID arrays. But I doubt it will ever come close to the +100us edge, not without features like cache ram that Postgres would be better +off considering to be part of "effective_cache" anyways. + +So I would suggest using something like 100us as the threshold for determining +whether a buffer fetch came from cache. + +Here are two graphs, one showing a nice curve showing how disk seek times are +distributed. It's neat to look at for that alone: + + +--=BATF-Ruby-Ridge-Europol-USDOJ-Vince-Foster-FIPS140-Albright-Baranyi- +Content-Type: image/png +Content-Disposition: inline; filename=plot1.png +Content-Transfer-Encoding: base64 + +iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAMAAAACDyzWAAABKVBMVEX///8A +AACgoKD/AAAAwAAAgP/AAP8A7u7AQADu7gAgIMD/wCAAgECggP+AQAD/gP8A +wGAAwMAAYIDAYIAAgABA/4AwYICAYABAQEBAgAAAAICAYBCAYGCAYIAAAMAA +AP8AYADjsMBAwIBgoMBgwABgwKCAAACAAIBgIIBgYGAgICAgQEAgQIBggCBg +gGBggICAgEAggCCAgICgoKCg0ODAICAAgIDAYACAwODAYMDAgADAgGD/QAD/ +QECAwP//gGD/gIDAoADAwMDA/8D/AAD/AP//gKDAwKD/YGAA/wD/gAD/oACA +4OCg4OCg/yDAAADAAMCgICCgIP+AIACAICCAQCCAQICAYMCAYP+AgADAwAD/ +gED/oED/oGD/oHD/wMD//wD//4D//8BUJrxzAAAKoklEQVR4nO3djY7iNgCF +UVDe/53bMuG3JMTGyY3DOdKKroRJ2PlqDxkGn04AAAAAAAA/5Xzxd3uauIHV +jIX9Nfj+BtZzmwAFSMK9tfPUze2esFRphOeZCK/3qk1802FOs+m4bQ43tfY+ +L8GHfOpfj+vkNPf79ObKE+DuDnfApzcu2HM3m51Lg2FOs+m4rU9z68fkoATI +g9tCNvfqdPxxxNtx5UesHLf1Y7KJpwCnohq/6Rrvf34a98Ywf8SKs/xEgN16 +mgAnoromd3rIdG4CFCBL3Tq6/tD/8SLHdZZ7E+DsAixASj00dn0Tyutk99Tq +tOHPzKEanO4Wj8mGXqa6pwBfXqUsePVhBqTQ/9bayQCXvPgVIGUeGnv8Ydf5 +6bu9j689bgRImYfIzk8z4Olx5T1fq/zuyy1AFlnr7Z4CZBEBckgCJEqARAmQ +KAESJUCiBEiUAIkSIFECJEqARAmQKAGSMwzDefYN+3UEyGJmQKIESJQAiRIg +UQIkSoBECZAoARIlQKIESFRZLA+fxrDCh5Tzg4piOT9/RkjrbRr4QSWx3D+P +RoA0UhDLy6d1XefDh5vbHb/9yCR+QlkoD7Pc2/rMgFQoCfDxY6otwTRR8SpY +gLRTHOD76y8uw1DHhWiiBEiUAIkSIFECJEqARAmQKAESJUCiBEiUAIkSIFEC +JEqARAmQKAESJUCiBEiUAIkSIFECJEqARAmQKAESJUCiBEiUAIkSIFECJEqA +RAmQKAGSMwzD+d8/rR9WgCxmBiRKgEQJkCgfUk5U1V5xtmmglYq94gRIOzV7 +xb3dpstecZSq2itusj4zIBWK94qzBNOSveKIchmGKBeiiRIgUQIkSoBECZAo +ARIlQKIESJQAiRIgUQIkSoBECZAoARIlQKIESJQAiRIgUQIkSoBECZAoARIl +QKIESJQAiRIgUQIkxzYNpJkBiRIgUQIkSoBECZAoARIlQKIESFTRRjXXzyif +/Kzy4sfk11VsVPP6N9s0UK9in5DzNTcB8rWKJfi+a5y94vhGeSj39ddecTRR +H6AlmAaqXoQIkCbK3g84t0mcyzDUcSGaKAESJUCiBEiUAIkSIFECJEqARAmQ +KAESJUCiBEiUAIkSIFECJEqARAmQKAESJUCiBEiUAIkSIFECJEqARAmQKAES +JUCiBEiUAIkSIFECJEqARAmQKAESJUCiBEhU8UY1PqSclmzTQFTFXnECpJ2a +veLebtNlrzhKVe0VN1mfGZAKlmCivAghymUYolyIJkqARAmQKAESJUCiBEiU +AIkSIFECJEqARAmQKAESJUCiBEiUAIkSIFECJEqARAmQKAESJUCiBEiUAIkS +IFECJEqARAmQKAESJUCiBEiUAMkZhuH875/WDytAFjMDEiVAogRIlACJqtio +5n57er0pfkx+XdU2Dc9/s00D9SoCvO7YJUC+98VOSfaK4zulodzuba84Wil6 +EfLwX5Zgvlf0o7i5Vx8CpFLJi5CZ6y8uw1DHhWhyvBuGsMEMSJIACbIEkzQI +kDBLMFECJGdcgps/rgBZygxIlACJEiBRAiRKgEQJkByXYUgzAxIlQKIESJYA +iRIgUQIkSoBECZAoAZLkMgxRAiRKgOR4MwJpZkCiBEiUAMkSIFECJEqARAmQ +qOK94nxIOQ0VvAqe25/BNg3UESBRhdcBpzaJs1ccFUp/Fnzdp8ZecTRRGOBf +YZZgGir8HvAkQJoqCtBecTTl/YCkeTcMUQIkxxJMlABJswQTJUByLMFECZA0 +SzBRAiRKgGQJkCgBkmQJJkqARAmQHBeiSTMDEiVAogRIlACJEiA5XgUTJUDS +LMFECZAoARIlQKIESJQAyXEZhjQzIDlmQMIGMyA5ZkCShvJ9Qk4fPqt8vF/z +U+Wgipbga2rjX2zTwHfGGXDp3c8PM6AAaaLsRchtBrRXHC2cz0NRKLc72yuO +BgqX4NcALcF8py5Ae8XRzlAQi73iaKt4BlxKgCwhQKIESJQASRoESNIY4AqP +LEA+GwRIzjAIkJhbfiUXopcTIHOGh/4EyKaGJycBsqFh+F9/AmQjr/WNvwsi +QDbw//quv4skQNb2rr7bzz8EyIretjc8/iamAFnJVHzPvwgsQFawLL7/CJDG +puN798YXAdLOTHtTn8AhQNqYjW/6TX8C5Gvz7c1/+pAA+cY37V0IkEqf2lv2 +XnsBUqFNfP8RIGU+tlf2W0YCZLHG7V0IkCU+t1f565UC5IPV2rsQINPWbe9C +gLyzIL02H2kgQF5s1t6FALlZkl7rfWUEyH8S7V0I8NctS2+N9i4E+LMWlrde +excC/EGL01u3vYvyfUJ8SHm/lpe3QXp/qvaKs01DdwrS26y9i4JtGuwT0qOS +8rZN70/NXnFvt+myV9zeFKWXaK84lOt3e/aK27ey8iLp3X2xW6YleG+6Km8k +wEPosLyRveL61uOk98SF6E4VlrfD9P4IsDdHKW8kwH4cLL0/AuzBEcsbCXDf +jlveSIA7deBJ74kAd+dHyhsJcE9+qbyRAHfi58obCTDt9ya9JwKM+cH19g0B +BkjvToCbUt4rAW5Eeu8JcG0l6+1vtXchwPUUpfeD7V0IcA3KW0yAbSmvkAAb +MenVEWAD0qsnwG8o72sCrCS9NgRYTHotCbCA9NoT4BLLy5NeIQHOU97KBDih +YNIT3xcE+Ep5mxLgXVF62mtDgKff+R3cPfr1AKUX9rsBKm8XfjJA6e3HjwWo +vL35nQCVt0u/EaD0dqs4ltnPKq98zFUpb9cqArzd7H+bBu3tXt0M2EWA0utB +1QzYwV5x2utAdSh73ytOev2oD3C3S7D2evLFErzLALXXmfJY9rxXnPq6c6AL +0eLr0WECVF+fDhKg+np1iADV168jBKi+jvUfoPy61n2A8utb7wGqr3OdByi/ +3nUdoPz613OA8juAjgPU3xH0G6D8DqHbAPV3DL0GqL+D6D3ADQ7FmjoNUH9H +0WeA+juMrgNc/TisrssATYDH0XOAax+GDQiQqB4DtAIfSMcBrnwUNiFAonoM +8PRfg+sfgy30GuD6h2ATAiRKgEQJkKgeA/Qq+EB6DPBkBjyOPgM0/R1GlwFa +f4+jxwB9D3ggewpw4bjX9yKsfLhW4zo5zV6e3uvDPH1I+bCFr5/Cwb9CB396 +L4/yvE3Dpv35Cu1i3K8F2OApHPwrdPCn9/Io973i/o3jDIs1CvBxr7hN5z94 +XYL1x8YESFazxRwAAAA6U/ia+O/O46Dnm88HKR1WPe50vdpUNO56tX+r00wc +r3jYzBe8yeWU56uCC+5+vg96vvl8kNJh1eNO95/3lJ5mxbP75jS3/GepGjbz +BS9MZ/6slt77tGmA49iKcee6AM/XOxUHMfUsPz+7XQc49wVvFmDRRHo9n/EL +/HCz5EClw25FFI+rOd79H7bscOfa03w45Ab/LHVPb/oLXprO5HMpyng8nzcn +8/EwFcNO08/900nWjNv8cHX/mrXHO4/rQtGw6VMsTWf2yRTd/+H/pYebj6PK +h42DKg5XtQTXH67+O4Wp4escr2LY9CmWpjP7ZIruX3wi58pvkr553hXjag9X +fZqV/19WHq9u2NoBnopeS1deOKgcNjFg2RnXHK/2cPXjpoevcLyKYbNfuaJ0 +AAAAAACgzj9lVEYweskfcwAAAABJRU5ErkJggg== + +--=BATF-Ruby-Ridge-Europol-USDOJ-Vince-Foster-FIPS140-Albright-Baranyi- + + +This is the 1000 fastest data points zoomed to the range under 1800us: + + +--=BATF-Ruby-Ridge-Europol-USDOJ-Vince-Foster-FIPS140-Albright-Baranyi- +Content-Type: image/png +Content-Disposition: inline; filename=plot2.png +Content-Transfer-Encoding: base64 + +iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAMAAAACDyzWAAABKVBMVEX///8A +AACgoKD/AAAAwAAAgP/AAP8A7u7AQADu7gAgIMD/wCAAgECggP+AQAD/gP8A +wGAAwMAAYIDAYIAAgABA/4AwYICAYABAQEBAgAAAAICAYBCAYGCAYIAAAMAA +AP8AYADjsMBAwIBgoMBgwABgwKCAAACAAIBgIIBgYGAgICAgQEAgQIBggCBg +gGBggICAgEAggCCAgICgoKCg0ODAICAAgIDAYACAwODAYMDAgADAgGD/QAD/ +QECAwP//gGD/gIDAoADAwMDA/8D/AAD/AP//gKDAwKD/YGAA/wD/gAD/oACA +4OCg4OCg/yDAAADAAMCgICCgIP+AIACAICCAQCCAQICAYMCAYP+AgADAwAD/ +gED/oED/oGD/oHD/wMD//wD//4D//8BUJrxzAAAILklEQVR4nO3di1baSgBA +UbL8/3+uiiCoWJMZPTz2XsXcW0sY09OZJNjV3Q4AAAAAAODBLMv+4+v2fAO/ +7lDc6+N8A79uX5sAyRwCXPblnWyOvwBWWh/gx/pOApxY+zCDueRmB/PfJfhm +v7JfZzCXCPBPGMwlPx/MYcV+W7fPN2t39gcM5pL7HcxVfWXcBAFy4riefXd1 ++rYOfvm89a+48Xm/vzMCZwFeiup4LfB+BvZdgE/fv+KGUf7NzgicTYAXojok +tzvJ9LsJUID81LGjw9Xm6b2Owyz3RYDfLsACZK2Txg53Pz5OdmetXva0981L +TRju7+yMzIep7izAD1cpP7j6MAOy0qe19mKAP7n4FSDrnDR2+p7Xcna2999r +jyMBss5JZMvZDLg7XXmXQ5Vjv+sC5Ed+67s+BciPCJC7JEBSAiQlQFICJCVA +UgIkJUBSAiQlQFICJCVAUgIkJUBSAiQlQFICJCVAUgIkJUBSAiQlQFICJCVA +UgIkJUBSAiQlQFICJCVAUgIkJUBSAiQlQFICJCVAUgIkJUBSAiQlQFICJCVA +UgIkJUBSAiQlQFICJCVAUgIkJUBSAiQlQFICJCVAUgIkJUBSAiQlQFICJCVA +UgIkJUBSAiQlQFICJCVAUgIkJUBS65tZnn3abN0Zj251My+9PT/ON1t3xsMT +IKmtS/BrfMthc/IpEfJTm3r5XJ8ZkO0swaQESMptGFJuRJMSICkBkhIgKQGS +EiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGS +EiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGS +EiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGS +EiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGS +EiApAZISIKn1zSzPPm227oxHt7qZl96eH+ebrTvj4W0KcPexw6074+FtCHA5 +xrccNuefgx/Z1Mvn+syAbOcckJQASbkNQ8qNaFICJCVAUgIkJUBSAiQlQFIC +JCVAUgIkJUBSAiQlQFICJCVAUgIkJUBSAiQlQFICJCVAUgIkJUBSAiQlQFIC +JCVAUgIkJUBGPY08WYCMEiApAdJ52tv8fAEyygxISoCkBMjtEiApATJoaAUW +IKMESEqAdEbvQwuQUWZAUgIkJUBumAAZZAYkJUBSAqTjPiA1MyApAVIaWX93 +AmTUWH8CZJAA6QxfBAuQQWZAUgIkJUBSAiQlQFICpOM2DLHBd+IEyBgBErIE +UxrvT4AMGcxPgIwRICFLMKUJ/QmQ7QRIbfQUUIBsZwakNjoBCpAhAiQlQErD +1yACZDsXIbSG34gTINvNmAC3NbMsL4+Xj4fNwM64UU9ZgC/N7Rs8bAZ2xq2a +0t+WZhYBsjd+CrihmX12rz+Om+OnThdk7t7oFfCWXo5T32mEh88NDYebMz4B +rm9mWSzB7E1YgTdfBQuQNEC3YR5edhX8Rzvjus3pT4BsJEBSAiQ24xpEgGwz +aQIUINsIkJQAKc35XqydANlqRn07AbKVAEkJkM60U0ABstGcCVCAbCRAUgIk +Nac/AbKRAOlMuwgWIBuZAUkJkJQASQmQjosQamZASpPeCBEgW1iCiZkB6cyb +AAXIBgKkNmkFFiDbCJCUAEkJkJQA6bgKJjbrPrQA2USApARIZ+IpoABZT4DU +Zq3AAmQTAZISIKVp/QmQLQRISoB0Zt6FESCrCZDYtDfiBMh6ZkBiZkA6UydA +AbKBGZDUvP4EyAYC5F4IkJQASQmQlABJCZCUAEkJkJQAWc+NaFICJCVAOr4d +i5oZkJQASQmQeyFAUgIkJUDWcw5ISoCUJv6tTAGylndCiJkB6cydAAXIeu0M +uDz7tNm6M27RxP7WN/PS2/PjfLN1Z9yeegkW4IOrA3x90rL/cdwcf/50QeZe +TbsFs62XZT/tnUZ4+MykgXHd0nPAt94swQ8svwjZCfChxQEuhzXYbZhHdA0X +IX+yM67VzPvQAmQ1AdKZvAILkNVmToACZDUBkhIgHeeA1MyAdMyA1MyApARI +SoDcDwGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkB +khIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkB +khIgKQGSEiApAbLS1H8mRICsJUBSAqQz+x/LFCBrmQFJCZCUALkjAiQlQFIC +ZCXngKQESEqAdLwTQs0MSEqApARISoCUZl6B7ATIOq6CSQmQ0vT+BMjPPT0J +kMrTiYm7FSAXPF0081UEeLUuB1Cb+VVeW4D1seW/xn+TT80NsD42/L6ZwewE +yFozg9mNB7g8e/+f+uDwqwZb+Tqgwacv+8fu9exNgPdsQm1fFTT49PcAd2bA +OzPa1s8KGnz6sjtZgxdYazTA5WQGvJk/dtyL8yUY/pgAaY2v4gAAAHCbruKa ++HCD/W0w6Zj2L30+kmxAx1e/gqPz5SEZHsx13BV8G8HbYNIxHY7r6UiyAb0P +5tOYgrF8cUjGB3MtAS6HgcQBLrsrCvA4mGs4Or8X4BWswe9fzvK+CcfyYSTd +gD78aaiPzqdRjA/m/FsTSp++sm4cuy+OcRjg239cwWCW+UfmOpbgF/2KdxzH +tSzBHwOsT0gPH+/xHPAqDvFxLFczoCsazPLVpdCEwVzFbZjDKOq7HpdueUQD +MhgAAAAAAHjzD9bGNv6j2lw6AAAAAElFTkSuQmCC + +--=BATF-Ruby-Ridge-Europol-USDOJ-Vince-Foster-FIPS140-Albright-Baranyi- + + +This is the program I wrote to test this: + + +--=BATF-Ruby-Ridge-Europol-USDOJ-Vince-Foster-FIPS140-Albright-Baranyi- +Content-Type: text/x-csrc +Content-Disposition: attachment; filename=timing.c + +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int rep = atoi(argv[1]); + int i; + char *filename; + int fd; + struct stat statbuf; + off_t filesize; + unsigned blocksize; + void *blockbuf; + + filename = argv[2]; + fd = open(filename, O_RDONLY); + + fstat(fd, &statbuf); + filesize = statbuf.st_size; + blocksize = statbuf.st_blksize; + blockbuf = malloc(blocksize); + + srandom(getpid()^clock()); + + for (i=0;i /tmp/l +$ gnuplot +gnuplot> set terminal png +gnuplot> set output "/tmp/plot1.png" +gnuplot> plot '/tmp/l2' with points pointtype 1 pointsize 1 +gnuplot> set output "/tmp/plot2.png" +gnuplot> plot [0:2000] [0:1000] '/tmp/l2' with points pointtype 1 pointsize 1 + + + +-- +greg + +--=BATF-Ruby-Ridge-Europol-USDOJ-Vince-Foster-FIPS140-Albright-Baranyi--- + + +From pgsql-hackers-owner@postgresql.org Mon Oct 25 22:53:45 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2390B3A3C35 + for ; + Mon, 25 Oct 2004 22:53:43 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95841-08 + for ; + Mon, 25 Oct 2004 21:53: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 2DFF13A422C + for ; + Mon, 25 Oct 2004 22:53:32 +0100 (BST) +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 i9PLrQWC000791; + Mon, 25 Oct 2004 17:53:26 -0400 (EDT) +To: Greg Stark +Cc: pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +In-reply-to: <87hdoiv62b.fsf@stark.xeocode.com> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> + <87hdoiv62b.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "25 Oct 2004 17:30:52 -0400" +Date: Mon, 25 Oct 2004 17:53:25 -0400 +Message-ID: <790.1098741205@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/853 +X-Sequence-Number: 60356 + +Greg Stark writes: +> So I would suggest using something like 100us as the threshold for +> determining whether a buffer fetch came from cache. + +I see no reason to hardwire such a number. On any hardware, the +distribution is going to be double-humped, and it will be pretty easy to +determine a cutoff after minimal accumulation of data. The real question +is whether we can afford a pair of gettimeofday() calls per read(). +This isn't a big issue if the read actually results in I/O, but if it +doesn't, the percentage overhead could be significant. + +If we assume that the effective_cache_size value isn't changing very +fast, maybe it would be good enough to instrument only every N'th read +(I'm imagining N on the order of 100) for this purpose. Or maybe we +need only instrument reads that are of blocks that are close to where +the ARC algorithm thinks the cache edge is. + +One small problem is that the time measurement gives you only a lower +bound on the time the read() actually took. In a heavily loaded system +you might not get the CPU back for long enough to fool you about whether +the block came from cache or not. + +Another issue is what we do with the effective_cache_size value once we +have a number we trust. We can't readily change the size of the ARC +lists on the fly. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Wed Oct 27 18:09:25 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ECE523A424A + for ; + Mon, 25 Oct 2004 23:48:43 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12603-04 + for ; + Mon, 25 Oct 2004 22:48:32 +0000 (GMT) +Received: from is.rice.edu (is.rice.edu [128.42.42.24]) + by svr1.postgresql.org (Postfix) with ESMTP id E4A493A4230 + for ; + Mon, 25 Oct 2004 23:48:34 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by localhost.is.rice.edu (Postfix) with ESMTP + id E04AC4191D; Mon, 25 Oct 2004 17:48:33 -0500 (CDT) +Received: from is.rice.edu ([127.0.0.1]) + by localhost (it.is.rice.edu [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 28089-10; Mon, 25 Oct 2004 17:48:30 -0500 (CDT) +Received: by is.rice.edu (Postfix, from userid 18612) + id 87D0C418C9; Mon, 25 Oct 2004 17:48:30 -0500 (CDT) +Date: Mon, 25 Oct 2004 17:48:30 -0500 +From: Kenneth Marshall +To: Tom Lane +Cc: Greg Stark , pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +Message-ID: <20041025224830.GQ12041@it.is.rice.edu> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> + <87hdoiv62b.fsf@stark.xeocode.com> <790.1098741205@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <790.1098741205@sss.pgh.pa.us> +User-Agent: Mutt/1.4.2i +X-Virus-Scanned: by amavis-20030314-p2 at is.rice.edu +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/942 +X-Sequence-Number: 60445 + +On Mon, Oct 25, 2004 at 05:53:25PM -0400, Tom Lane wrote: +> Greg Stark writes: +> > So I would suggest using something like 100us as the threshold for +> > determining whether a buffer fetch came from cache. +> +> I see no reason to hardwire such a number. On any hardware, the +> distribution is going to be double-humped, and it will be pretty easy to +> determine a cutoff after minimal accumulation of data. The real question +> is whether we can afford a pair of gettimeofday() calls per read(). +> This isn't a big issue if the read actually results in I/O, but if it +> doesn't, the percentage overhead could be significant. +> +How invasive would reading the "CPU counter" be, if it is available? +A read operation should avoid flushing a cache line and we can throw +out the obvious outliers since we only need an estimate and not the +actual value. + +--Ken + + +From pgsql-hackers-owner@postgresql.org Tue Oct 26 00:11:54 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8850A3A3AC2 + for ; + Tue, 26 Oct 2004 00:11:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17224-05 + for ; + Mon, 25 Oct 2004 23:11: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 E425D3A4235 + for ; + Tue, 26 Oct 2004 00:11:09 +0100 (BST) +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 i9PNB6lF002047; + Mon, 25 Oct 2004 19:11:06 -0400 (EDT) +To: Kenneth Marshall +Cc: Greg Stark , pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +In-reply-to: <20041025224830.GQ12041@it.is.rice.edu> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> + <87hdoiv62b.fsf@stark.xeocode.com> <790.1098741205@sss.pgh.pa.us> + <20041025224830.GQ12041@it.is.rice.edu> +Comments: In-reply-to Kenneth Marshall + message dated "Mon, 25 Oct 2004 17:48:30 -0500" +Date: Mon, 25 Oct 2004 19:11:05 -0400 +Message-ID: <2046.1098745865@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/860 +X-Sequence-Number: 60363 + +Kenneth Marshall writes: +> How invasive would reading the "CPU counter" be, if it is available? + +Invasive or not, this is out of the question; too unportable. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 26 03:29:24 2004 +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 1A7903A3BBE + for ; + Tue, 26 Oct 2004 03:29:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67283-03 + for ; + Tue, 26 Oct 2004 02:29:17 +0000 (GMT) +Received: from purple.west.spy.net (mail.west.spy.net [66.149.231.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 239B83A3B33 + for ; + Tue, 26 Oct 2004 03:29:17 +0100 (BST) +Received: from [192.168.1.50] (dustinti.west.spy.net [192.168.1.50]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (Client did not present a certificate) + by purple.west.spy.net (Postfix) with ESMTP + id CAB19127; Mon, 25 Oct 2004 19:29:16 -0700 (PDT) +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985D5@vt-pe2550-001.vantage.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985D5@vt-pe2550-001.vantage.vantage.com> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=WINDOWS-1252; format=flowed +Message-Id: +Content-Transfer-Encoding: quoted-printable +Cc: +From: Dustin Sallings +Subject: Re: can't handle large number of INSERT/UPDATEs +Date: Mon, 25 Oct 2004 19:29:19 -0700 +To: "Anjan Dave" +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/426 +X-Sequence-Number: 8902 + + +On Oct 25, 2004, at 13:53, Anjan Dave wrote: + +> I am dealing with an app here that uses pg to handle a few thousand=20 +> concurrent web users. It seems that under heavy load, the INSERT and=20 +> UPDATE statements to one or two specific tables keep queuing up, to=20 +> the count of 150+ (one table has about 432K rows, other has about=20 +> 2.6Million rows), resulting in =91wait=92s for other queries, and then=20 +> everything piles up, with the load average shooting up to 10+. + + Depending on your requirements and all that, but I had a similar issue=20 +in one of my applications and made the problem disappear entirely by=20 +serializing the transactions into a separate thread (actually, a thread=20 +pool) responsible for performing these transactions. This reduced the=20 +load on both the application server and the DB server. + + Not a direct answer to your question, but I've found that a lot of=20 +times when someone has trouble scaling a database application, much of=20 +the performance win can be in trying to be a little smarter about how=20 +and when the database is accessed. + +-- +SPY My girlfriend asked me which one I like better. +pub 1024/3CAE01D5 1994/11/03 Dustin Sallings +| Key fingerprint =3D 87 02 57 08 02 D0 DA D6 C8 0F 3E 65 51 98 D8 BE +L_______________________ I hope the answer won't upset her. ____________ + + +From pgsql-hackers-owner@postgresql.org Tue Oct 26 06:18:05 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 65B863A3C7F + for ; + Tue, 26 Oct 2004 06:18:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09697-01 + for ; + Tue, 26 Oct 2004 05:17:48 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 36A403A3AC4 + for ; + Tue, 26 Oct 2004 06:17:48 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CMJiH-0000Yt-00; Tue, 26 Oct 2004 01:17:41 -0400 +To: Tom Lane +Cc: Greg Stark , pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> <87hdoiv62b.fsf@stark.xeocode.com> + <790.1098741205@sss.pgh.pa.us> +In-Reply-To: <790.1098741205@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 26 Oct 2004 01:17:40 -0400 +Message-ID: <878y9uukgb.fsf@stark.xeocode.com> +Lines: 49 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/875 +X-Sequence-Number: 60378 + + +Tom Lane writes: + +> I see no reason to hardwire such a number. On any hardware, the +> distribution is going to be double-humped, and it will be pretty easy to +> determine a cutoff after minimal accumulation of data. + +Well my stats-fu isn't up to the task. My hunch is that the wide range that +the disk reads are spread out over will throw off more sophisticated +algorithms. Eliminating hardwired numbers is great, but practically speaking +it's not like any hardware is ever going to be able to fetch the data within +100us. If it does it's because it's really a solid state drive or pulling the +data from disk cache and therefore really ought to be considered part of +effective_cache_size anyways. + +> The real question is whether we can afford a pair of gettimeofday() calls +> per read(). This isn't a big issue if the read actually results in I/O, but +> if it doesn't, the percentage overhead could be significant. + +My thinking was to use gettimeofday by default but allow individual ports to +provide a replacement function that uses the cpu TSC counter (via rdtsc) or +equivalent. Most processors provide such a feature. If it's not there then we +just fall back to gettimeofday. + +Your idea to sample only 1% of the reads is a fine idea too. + +My real question is different. Is it worth heading down this alley at all? Or +will postgres eventually opt to use O_DIRECT and boost the size of its buffer +cache? If it goes the latter route, and I suspect it will one day, then all of +this is a waste of effort. + +I see mmap or O_DIRECT being the only viable long-term stable states. My +natural inclination was the former but after the latest thread on the subject +I suspect it'll be forever out of reach. That makes O_DIRECT And a Postgres +managed cache the only real choice. Having both caches is just a waste of +memory and a waste of cpu cycles. + +> Another issue is what we do with the effective_cache_size value once we +> have a number we trust. We can't readily change the size of the ARC +> lists on the fly. + +Huh? I thought effective_cache_size was just used as an factor the cost +estimation equation. My general impression was that a higher +effective_cache_size effectively lowered your random page cost by making the +system think that fewer nonsequential block reads would really incur the cost. +Is that wrong? Is it used for anything else? + +-- +greg + + +From pgsql-hackers-owner@postgresql.org Tue Oct 26 06:27:48 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 50E803A3B90 + for ; + Tue, 26 Oct 2004 06:27:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11241-03 + for ; + Tue, 26 Oct 2004 05:27:32 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C2C83A430C + for ; + Tue, 26 Oct 2004 06:27:33 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CMJrm-0000d7-00; Tue, 26 Oct 2004 01:27:30 -0400 +To: Greg Stark , pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> <87hdoiv62b.fsf@stark.xeocode.com> + <790.1098741205@sss.pgh.pa.us> +In-Reply-To: <790.1098741205@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 26 Oct 2004 01:27:29 -0400 +Message-ID: <873c02ujzy.fsf@stark.xeocode.com> +Lines: 12 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/876 +X-Sequence-Number: 60379 + + +Is something broken with the list software? I'm receiving other emails from +the list but I haven't received any of the mails in this thread. I'm only able +to follow the thread based on the emails people are cc'ing to me directly. + +I think I've caught this behaviour in the past as well. Is it a misguided list +software feature trying to avoid duplicates or something like that? It makes +it really hard to follow threads in MUAs with good filtering since they're +fragmented between two mailboxes. + +-- +greg + + +From pgsql-hackers-owner@postgresql.org Tue Oct 26 06:54:16 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CBC0E3A3C10 + for ; + Tue, 26 Oct 2004 06:54:14 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15216-08 + for ; + Tue, 26 Oct 2004 05:54: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 713393A3B33 + for ; + Tue, 26 Oct 2004 06:53:59 +0100 (BST) +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 i9Q5rtRE004889; + Tue, 26 Oct 2004 01:53:55 -0400 (EDT) +To: Greg Stark +Cc: pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +In-reply-to: <878y9uukgb.fsf@stark.xeocode.com> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> + <87hdoiv62b.fsf@stark.xeocode.com> <790.1098741205@sss.pgh.pa.us> + <878y9uukgb.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "26 Oct 2004 01:17:40 -0400" +Date: Tue, 26 Oct 2004 01:53:55 -0400 +Message-ID: <4887.1098770035@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/877 +X-Sequence-Number: 60380 + +Greg Stark writes: +> Tom Lane writes: +>> Another issue is what we do with the effective_cache_size value once we +>> have a number we trust. We can't readily change the size of the ARC +>> lists on the fly. + +> Huh? I thought effective_cache_size was just used as an factor the cost +> estimation equation. + +Today, that is true. Jan is speculating about using it as a parameter +of the ARC cache management algorithm ... and that worries me. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Tue Oct 26 07:05:14 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E85E3A3C10 + for ; + Tue, 26 Oct 2004 07:05:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19796-04 + for ; + Tue, 26 Oct 2004 06:05:06 +0000 (GMT) +Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) + by svr1.postgresql.org (Postfix) with ESMTP id 1986F3A3B28 + for ; + Tue, 26 Oct 2004 07:05:04 +0100 (BST) +Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net + [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP + id 2472EC003; Tue, 26 Oct 2004 15:05:02 +0900 (JST) +Received: from localhost (localhost [127.0.0.1]) + by angelic.cynic.net (Postfix) with ESMTP + id 6737B8736; Tue, 26 Oct 2004 15:04:58 +0900 (JST) +Date: Tue, 26 Oct 2004 15:04:58 +0900 (JST) +From: Curt Sampson +X-X-Sender: cjs@angelic-vtfw.cvpn.cynic.net +To: Greg Stark +Cc: pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +In-Reply-To: <878y9uukgb.fsf@stark.xeocode.com> +Message-ID: +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> <87hdoiv62b.fsf@stark.xeocode.com> + <790.1098741205@sss.pgh.pa.us> <878y9uukgb.fsf@stark.xeocode.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/878 +X-Sequence-Number: 60381 + +On Tue, 26 Oct 2004, Greg Stark wrote: + +> I see mmap or O_DIRECT being the only viable long-term stable states. My +> natural inclination was the former but after the latest thread on the subject +> I suspect it'll be forever out of reach. That makes O_DIRECT And a Postgres +> managed cache the only real choice. Having both caches is just a waste of +> memory and a waste of cpu cycles. + +I don't see why mmap is any more out of reach than O_DIRECT; it's not +all that much harder to implement, and mmap (and madvise!) is more +widely available. + +But if using two caches is only costing us 1% in performance, there's +not really much point.... + +cjs +-- +Curt Sampson +81 90 7737 2974 http://www.NetBSD.org + Make up enjoying your city life...produced by BIC CAMERA + +From pgsql-performance-owner@postgresql.org Tue Oct 26 09:18:31 2004 +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 BF00D3A3C24 + for ; + Tue, 26 Oct 2004 09:18:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52214-10 + for ; + Tue, 26 Oct 2004 08:18:14 +0000 (GMT) +Received: from mra02.ex.eclipse.net.uk (mra02.ex.eclipse.net.uk + [212.104.129.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 042813A3B28 + for ; + Tue, 26 Oct 2004 09:18:13 +0100 (BST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mra02.ex.eclipse.net.uk (Postfix) with ESMTP id 740E840639F; + Tue, 26 Oct 2004 09:12:03 +0100 (BST) +Received: from mra02.ex.eclipse.net.uk ([127.0.0.1]) + by localhost (mra02.ex.eclipse.net.uk [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 11507-01-42; Tue, 26 Oct 2004 09:12:01 +0100 (BST) +Received: from dev1 (unknown [82.152.145.238]) + by mra02.ex.eclipse.net.uk (Postfix) with ESMTP id 6C5494070A9; + Tue, 26 Oct 2004 09:11:55 +0100 (BST) +From: "Rod Dutton" +To: "'Anjan Dave'" +Cc: +Subject: FW: can't handle large number of INSERT/UPDATEs +Date: Tue, 26 Oct 2004 09:19:33 +0100 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +Thread-Index: AcS62HV8K9yQuVetTcSgq4oyu4L6aAAWftkw +Message-Id: <20041026081155.6C5494070A9@mra02.ex.eclipse.net.uk> +X-Virus-Scanned: by Eclipse VIRUSshield at eclipse.net.uk +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/427 +X-Sequence-Number: 8903 + +>>Eliminate that contention point, and you will have solved your problem. + +I agree, If your updates are slow then you will get a queue building up. + +Make sure that:- +1) all your indexing is optimised. +2) you are doing regular vacuuming (bloated tables will cause a slow down +due to swapping). +3) your max_fsm_pages setting is large enough - it needs to be big enough to +hold all the transactions between vacuums (+ some spare for good measure). +4) do a full vacuum - do one to start and then do one after you have had 2&3 +(above) in place for a while - if the full vacuum handles lots of dead +tuples then your max_fsm_pages setting is too low. +5) Also try reindexing or drop/recreate the indexes in question as... +"PostgreSQL is unable to reuse B-tree index pages in certain cases. The +problem is that if indexed rows are deleted, those index pages can only be +reused by rows with similar values. For example, if indexed rows are deleted +and newly inserted/updated rows have much higher values, the new rows can't +use the index space made available by the deleted rows. Instead, such new +rows must be placed on new index pages. In such cases, disk space used by +the index will grow indefinitely, even if VACUUM is run frequently. " + +Are your updates directly executed or do you use stored procs? We had a +recent problem with stored procs as they store a "one size fits all" query +plan when compiled - this can be less than optimum in some cases. + +We have a similar sounding app to yours and if tackled correctly then all +the above will make a massive difference in performance. + +Rod + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Rod Taylor +Sent: 25 October 2004 22:19 +To: Anjan Dave +Cc: Postgresql Performance +Subject: Re: [PERFORM] can't handle large number of INSERT/UPDATEs + +On Mon, 2004-10-25 at 16:53, Anjan Dave wrote: +> Hi, +> +> +> +> I am dealing with an app here that uses pg to handle a few thousand +> concurrent web users. It seems that under heavy load, the INSERT and +> UPDATE statements to one or two specific tables keep queuing up, to +> the count of 150+ (one table has about 432K rows, other has about +> 2.6Million rows), resulting in ?wait?s for other queries, and then + +This isn't an index issue, it's a locking issue. Sounds like you have a +bunch of inserts and updates hitting the same rows over and over again. + +Eliminate that contention point, and you will have solved your problem. + +Free free to describe the processes involved, and we can help you do +that. + + + +---------------------------(end of broadcast)--------------------------- +TIP 3: if posting/reading through Usenet, please send an appropriate + subscribe-nomail command to majordomo@postgresql.org so that your + message can get through to the mailing list cleanly + + +From pgsql-hackers-owner@postgresql.org Tue Oct 26 09:51:48 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 19A443A3B18; + Tue, 26 Oct 2004 09:51:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68108-02; Tue, 26 Oct 2004 08:51:38 +0000 (GMT) +Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CAAE3A3B1B; + Tue, 26 Oct 2004 09:51:38 +0100 (BST) +Received: from modem-1194.llama.dialup.pol.co.uk ([217.135.180.170] + helo=[192.168.0.102]) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) + id 1CMN3B-0005kz-31; Tue, 26 Oct 2004 09:51:29 +0100 +Subject: Re: [PATCHES] ARC Memory Usage analysis +From: Simon Riggs +To: Tom Lane , Jan Wieck +Cc: Kenneth Marshall , pgsql-patches@postgresql.org, + pgsql-hackers@postgresql.org, josh@agliodbs.com +In-Reply-To: <20651.1098720192@sss.pgh.pa.us> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Message-Id: <1098780555.6807.136.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 26 Oct 2004 09:49:15 +0100 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/880 +X-Sequence-Number: 60383 + +On Mon, 2004-10-25 at 16:34, Jan Wieck wrote: +> The problem is, with a too small directory ARC cannot guesstimate what +> might be in the kernel buffers. Nor can it guesstimate what recently was +> in the kernel buffers and got pushed out from there. That results in a +> way too small B1 list, and therefore we don't get B1 hits when in fact +> the data was found in memory. B1 hits is what increases the T1target, +> and since we are missing them with a too small directory size, our +> implementation of ARC is propably using a T2 size larger than the +> working set. That is not optimal. + +I think I have seen that the T1 list shrinks "too much", but need more +tests...with some good test results + +The effectiveness of ARC relies upon the balance between the often +conflicting requirements of "recency" and "frequency". It seems +possible, even likely, that pgsql's version of ARC may need some subtle +changes to rebalance it - if we are unlikely enough to find cases where +it genuinely is out of balance. Many performance tests are required, +together with a few ideas on extra parameters to include....hence my +support of Jan's ideas. + +That's also why I called the B1+B2 hit ratio "turbulence" because it +relates to how much oscillation is happening between T1 and T2. In +physical systems, we expect the oscillations to be damped, but there is +no guarantee that we have a nearly critically damped oscillator. (Note +that the absence of turbulence doesn't imply that T1+T2 is optimally +sized, just that is balanced). + +[...and all though the discussion has wandered away from my original +patch...would anybody like to commit, or decline the patch?] + +> If we would replace the dynamic T1 buffers with a max_backends*2 area of +> shared buffers, use a C value representing the effective cache size and +> limit the T1target on the lower bound to effective cache size - shared +> buffers, then we basically moved the T1 cache into the OS buffers. + +Limiting the minimum size of T1len to be 2* maxbackends sounds like an +easy way to prevent overbalancing of T2, but I would like to follow up +on ways to have T1 naturally stay larger. I'll do a patch with this idea +in, for testing. I'll call this "T1 minimum size" so we can discuss it. + +Any other patches are welcome... + +It could be that B1 is too small and so we could use a larger value of C +to keep track of more blocks. I think what is being suggested is two +GUCs: shared_buffers (as is), plus another one, larger, which would +allow us to track what is in shared_buffers and what is in OS cache. + +I have comments on "effective cache size" below.... + +On Mon, 2004-10-25 at 17:03, Tom Lane wrote: +> Jan Wieck writes: +> > This all only holds water, if the OS is allowed to swap out shared +> > memory. And that was my initial question, how likely is it to find this +> > to be true these days? +> +> I think it's more likely that not that the OS will consider shared +> memory to be potentially swappable. On some platforms there is a shmctl +> call you can make to lock your shmem in memory, but (a) we don't use it +> and (b) it may well require privileges we haven't got anyway. + +Are you saying we shouldn't, or we don't yet? I simply assumed that we +did use that function - surely it must be at least an option? RHEL +supports this at least.... + +It may well be that we don't have those privileges, in which case we +turn off the option. Often, we (or I?) will want to install a dedicated +server, so we should have all the permissions we need, in which case... + +> This has always been one of the arguments against making shared_buffers +> really large, of course --- if the buffers aren't all heavily used, and +> the OS decides to swap them to disk, you are worse off than you would +> have been with a smaller shared_buffers setting. + +Not really, just an argument against making them *too* large. Large +*and* utilised is OK, so we need ways of judging optimal sizing. + +> However, I'm still really nervous about the idea of using +> effective_cache_size to control the ARC algorithm. That number is +> usually entirely bogus. Right now it is only a second-order influence +> on certain planner estimates, and I am afraid to rely on it any more +> heavily than that. + +...ah yes, effective_cache_size. + +The manual describes effective_cache_size as if it had something to do +with the OS, and some of this discussion has picked up on that. + +effective_cache_size is used in only two places in the code (both in the +planner), as an estimate for calculating the cost of a) nonsequential +access and b) index access, mainly as a way of avoiding overestimates of +access costs for small tables. + +There is absolutely no implication in the code that effective_cache_size +measures anything in the OS; what it gives is an estimate of the number +of blocks that will be available from *somewhere* in memory (i.e. in +shared_buffers OR OS cache) for one particular table (the one currently +being considered by the planner). + +Crucially, the "size" referred to is the size of the *estimate*, not the +size of the OS cache (nor the size of the OS cache + shared_buffers). So +setting effective_cache_size = total memory available or setting +effective_cache_size = total memory - shared_buffers are both wildly +irrelevant things to do, or any assumption that directly links memory +size to that parameter. So talking about "effective_cache_size" as if it +were the OS cache isn't the right thing to do. + +...It could be that we use a very high % of physical memory as +shared_buffers - in which case the effective_cache_size would represent +the contents of shared_buffers. + +Note also that the planner assumes that all tables are equally likely to +be in cache. Increasing effective_cache_size in postgresql.conf seems +destined to give the wrong answer in planning unless you absolutely +understand what it does. + +I will submit a patch to correct the description in the manual. + +Further comments: +The two estimates appear to use effective_cache_size differently: +a) assumes that a table of size effective_cache_size will be 50% in +cache +b) assumes that effective_cache_size blocks are available, so for a +table of size == effective_cache_size, then it will be 100% available + +IMHO the GUC should be renamed "estimated_cached_blocks", with the old +name deprecated to force people to re-read the manual description of +what effective_cache_size means and then set accordingly.....all of that +in 8.0.... + +-- +Best Regards, Simon Riggs + + +From pgsql-hackers-owner@postgresql.org Tue Oct 26 10:53:25 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BBAA3A3ADB + for ; + Tue, 26 Oct 2004 10:53:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86970-04 + for ; + Tue, 26 Oct 2004 09:53:13 +0000 (GMT) +Received: from cmailm4.svr.pol.co.uk (cmailm4.svr.pol.co.uk [195.92.193.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 9511D3A4350 + for ; + Tue, 26 Oct 2004 10:53:15 +0100 (BST) +Received: from modem-757.monkey.dialup.pol.co.uk ([217.135.210.245] + helo=[192.168.0.102]) by cmailm4.svr.pol.co.uk with esmtp (Exim 4.41) + id 1CMO0u-0006Kz-JM; Tue, 26 Oct 2004 10:53:12 +0100 +Subject: Re: [PATCHES] ARC Memory Usage analysis +From: Simon Riggs +To: Tom Lane +Cc: Greg Stark , pgsql-hackers@postgresql.org +In-Reply-To: <4887.1098770035@sss.pgh.pa.us> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> <87hdoiv62b.fsf@stark.xeocode.com> + <790.1098741205@sss.pgh.pa.us> <878y9uukgb.fsf@stark.xeocode.com> + <4887.1098770035@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Message-Id: <1098784258.6807.155.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 26 Oct 2004 10:50:58 +0100 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/881 +X-Sequence-Number: 60384 + +On Tue, 2004-10-26 at 06:53, Tom Lane wrote: +> Greg Stark writes: +> > Tom Lane writes: +> >> Another issue is what we do with the effective_cache_size value once we +> >> have a number we trust. We can't readily change the size of the ARC +> >> lists on the fly. +> +> > Huh? I thought effective_cache_size was just used as an factor the cost +> > estimation equation. +> +> Today, that is true. Jan is speculating about using it as a parameter +> of the ARC cache management algorithm ... and that worries me. +> + +ISTM that we should be optimizing the use of shared_buffers, not whats +outside. Didn't you (Tom) already say that? + +BTW, very good ideas on how to proceed, but why bother? + +For me, if the sysadmin didn't give shared_buffers to PostgreSQL, its +because the memory is intended for use by something else and so not +available at all. At least not dependably. The argument against large +shared_buffers because of swapping applies to that assumption also...the +OS cache is too volatile to attempt to gauge sensibly. + +There's an argument for improving performance for people that haven't +set their parameters correctly, but thats got to be a secondary +consideration anyhow. + +-- +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Oct 26 12:37:43 2004 +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 87C823A3B8F + for ; + Tue, 26 Oct 2004 12:37:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21196-03 + for ; + Tue, 26 Oct 2004 11:37:24 +0000 (GMT) +Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) + by svr1.postgresql.org (Postfix) with ESMTP id 363353A4398 + for ; + Tue, 26 Oct 2004 12:37:25 +0100 (BST) +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Measuring server performance with psql and pgAdmin +Date: Tue, 26 Oct 2004 13:37:24 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Measuring server performance with psql and pgAdmin +Thread-Index: AcS7UCpCaV53rTi/QIeL+Pxdb9gpCQ== +From: "Joost Kraaijeveld" +To: "Pgsql-Performance (E-mail)" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/428 +X-Sequence-Number: 8904 + +Hi all, + +I am (stilll) converting a database from a Clarion Topspeed database to Pos= +tgresql 7.4.5 on Debian Linux 2.6.6-1. The program that uses the database u= +ses a query like "select * from table" to show the user the contents of a t= +able. This query cannot be changed (it is generated by Clarion and the pers= +on in charge of the program cannot alter that behaviour). + +Now I have a big performance problem with reading a large table ( 96713 row= +s). The query that is send to the database is "select * from table". + +"explain" and "explain analyze", using psql on cygwin: + +munt=3D# explain select * from klt_alg; + QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20 +-----------------------------------------------------------------=20 +Seq Scan on klt_alg (cost=3D0.00..10675.13 rows=3D96713 width=3D729)=20 + + +munt=3D# explain analyze select * from klt_alg; + QUERY PLAN=20 +---------------------------------------------------------------------------= +---------------------------------------- +Seq Scan on klt_alg (cost=3D0.00..10675.13 rows=3D96713 width=3D729) (actu= +al time=3D13.172..2553.328 rows=3D96713 loops=3D1) +Total runtime: 2889.109 ms +(2 rows)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20 + +Running the query (with pgAdmin III): +-- Executing query: +select * from klt_alg; + +Total query runtime: 21926 ms. +Data retrieval runtime: 72841 ms. +96713 rows retrieved. + +QUESTIONS: + +GENERAL: +1. The manual says about "explain analyze" : "The ANALYZE option causes the= + statement to be actually executed, not only planned. The total elapsed tim= +e expended within each plan node (in milliseconds) and total number of rows= + it actually returned are added to the display." Does this time include dat= +atransfer or just the time the database needs to collect the data, without = +any data transfer? +2. If the time is without data transfer to the client, is there a reliable = +way to measure the time needed to run the query and get the data (without t= +he overhead of a program that does something with the data)? + +PGADMIN: +1. What does the "Total query runtime" really mean? (It was my understandin= +g that it was the time the database needs to collect the data, without any = +data transfer). +2. What does the "Data retrieval runtime" really mean? (Is this including t= +he filling of the datagrid/GUI, or just the datatransfer?) + +TIA + +Groeten, + +Joost Kraaijeveld +Askesis B.V. +Molukkenstraat 14 +6524NB Nijmegen +tel: 024-3888063 / 06-51855277 +fax: 024-3608416 +e-mail: J.Kraaijeveld@Askesis.nl +web: www.askesis.nl=20 + +From pgsql-hackers-owner@postgresql.org Tue Oct 26 13:21:01 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 25C463A43D4; + Tue, 26 Oct 2004 13:20:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34860-09; Tue, 26 Oct 2004 12:20:45 +0000 (GMT) +Received: from cmailg2.svr.pol.co.uk (cmailg2.svr.pol.co.uk [195.92.195.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 761533A43BB; + Tue, 26 Oct 2004 13:20:47 +0100 (BST) +Received: from modem-2767.lynx.dialup.pol.co.uk ([217.135.202.207] + helo=[192.168.0.102]) by cmailg2.svr.pol.co.uk with esmtp (Exim 4.14) + id 1CMQJb-0003OT-Pz; Tue, 26 Oct 2004 13:20:40 +0100 +Subject: Re: [PATCHES] ARC Memory Usage analysis +From: Simon Riggs +To: Tom Lane , Jan Wieck +Cc: Kenneth Marshall , pgsql-patches@postgresql.org, + pgsql-hackers@postgresql.org, josh@agliodbs.com +In-Reply-To: <1098780555.6807.136.camel@localhost.localdomain> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <1098780555.6807.136.camel@localhost.localdomain> +Content-Type: text/plain +Organization: 2nd Quadrant +Message-Id: <1098793105.6807.193.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 26 Oct 2004 13:18:25 +0100 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/886 +X-Sequence-Number: 60389 + +On Tue, 2004-10-26 at 09:49, Simon Riggs wrote: +> On Mon, 2004-10-25 at 16:34, Jan Wieck wrote: +> > The problem is, with a too small directory ARC cannot guesstimate what +> > might be in the kernel buffers. Nor can it guesstimate what recently was +> > in the kernel buffers and got pushed out from there. That results in a +> > way too small B1 list, and therefore we don't get B1 hits when in fact +> > the data was found in memory. B1 hits is what increases the T1target, +> > and since we are missing them with a too small directory size, our +> > implementation of ARC is propably using a T2 size larger than the +> > working set. That is not optimal. +> +> I think I have seen that the T1 list shrinks "too much", but need more +> tests...with some good test results +> +> > If we would replace the dynamic T1 buffers with a max_backends*2 area of +> > shared buffers, use a C value representing the effective cache size and +> > limit the T1target on the lower bound to effective cache size - shared +> > buffers, then we basically moved the T1 cache into the OS buffers. +> +> Limiting the minimum size of T1len to be 2* maxbackends sounds like an +> easy way to prevent overbalancing of T2, but I would like to follow up +> on ways to have T1 naturally stay larger. I'll do a patch with this idea +> in, for testing. I'll call this "T1 minimum size" so we can discuss it. +> + +Don't know whether you've seen this latest update on the ARC idea: +Sorav Bansal and Dharmendra S. Modha, +CAR: Clock with Adaptive Replacement, + in Proceedings of the USENIX Conference on File and Storage Technologies + (FAST), pages 187--200, March 2004. +[I picked up the .pdf here http://citeseer.ist.psu.edu/bansal04car.html] + +In that paper Bansal and Modha introduce an update to ARC called CART +which they say is more appropriate for databases. Their idea is to +introduce a "temporal locality window" as a way of making sure that +blocks called twice within a short period don't fall out of T1, though +don't make it into T2 either. Strangely enough the "temporal locality +window" is made by increasing the size of T1... in an adpative way, of +course. + +If we were going to put a limit on the minimum size of T1, then this +would put a minimal "temporal locality window" in place....rather than +the increased complexity they go to in order to make T1 larger. I note +test results from both the ARC and CAR papers that show that T2 usually +represents most of C, so the observations that T1 is very small is not +atypical. That implies that the cost of managing the temporal locality +window in CART is usually wasted, even though it does cut in as an +overall benefit: The results show that CART is better than ARC over the +whole range of cache sizes tested (16MB to 4GB) and workloads (apart +from 1 out 22). + +If we were to implement a minimum size of T1, related as suggested to +number of users, then this would provide a reasonable approximation of +the temporal locality window. This wouldn't prevent the adaptation of T1 +to be higher than this when required. + +Jan has already optimised ARC for PostgreSQL by the addition of a +special lookup on transactionId required to optimise for the double +cache lookup of select/update that occurs on a T1 hit. That seems likely +to be able to be removed as a result of having a larger T1. + +I'd suggest limiting T1 to be a value of: +shared_buffers <= 1000 T1limit = max_backends *0.75 +shared_buffers <= 2000 T1limit = max_backends +shared_buffers <= 5000 T1limit = max_backends *1.5 +shared_buffers > 5000 T1limit = max_backends *2 + +I'll try some tests with both +- minimum size of T1 +- update optimisation removed + +Thoughts? + +-- +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Oct 26 16:24:27 2004 +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 154393A3B5B + for ; + Tue, 26 Oct 2004 16:24:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02649-10 + for ; + Tue, 26 Oct 2004 15:24:15 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.207]) + by svr1.postgresql.org (Postfix) with ESMTP id C6AD73A441E + for ; + Tue, 26 Oct 2004 16:24:10 +0100 (BST) +Received: by wproxy.gmail.com with SMTP id 64so184259wri + for ; + Tue, 26 Oct 2004 08:24:08 -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:references; + b=a+ihlMJSJkFnekI36iXo6EUGtNjvyfvcBGMrpqe/rQ97eDt4LoPQbrb/8NhrydOU7ezm/j7kl6GMeK4QlzdxKuiTnyVCjuyZkbAQmb3QKwPnHNG+kvGjMBFmrUsfLEsT/GXcjFv/1xK8Xwnyr3WB8/+O71ZbqjKuAgcskcS5o9Y= +Received: by 10.38.77.65 with SMTP id z65mr511397rna; + Tue, 26 Oct 2004 08:24:08 -0700 (PDT) +Received: by 10.38.77.73 with HTTP; Tue, 26 Oct 2004 08:24:08 -0700 (PDT) +Message-ID: <38242de904102608246d060f7d@mail.gmail.com> +Date: Tue, 26 Oct 2004 09:24:08 -0600 +From: Joshua Marsh +Reply-To: Joshua Marsh +To: pg@fastcrypt.com +Subject: Re: Large Database Performance suggestions +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4178F149.9090408@fastcrypt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <38242de904102120143c55ba34@mail.gmail.com> + <4178F149.9090408@fastcrypt.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/429 +X-Sequence-Number: 8905 + +Thanks for all of your help so far. Here is some of the information +you guys were asking for: + +Test System: +2x AMD Opteron 244 (1.8Ghz) +8GB RAM +7x 72GB SCSI HDD (Raid 5) + +postrgesql.conf information: +#--------------------------------------------------------------------------- +# RESOURCE USAGE (except WAL) +#--------------------------------------------------------------------------- + +# - Memory - + +shared_buffers = 1000 # min 16, at least max_connections*2, 8KB each +#sort_mem = 1024 # min 64, size in KB +#vacuum_mem = 8192 # min 1024, size in KB +sort_mem = 4096000 +vacuum_mem = 1024000 + +# - Free Space Map - + +#max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each +#max_fsm_relations = 1000 # min 100, ~50 bytes each + +# - Kernel Resource Usage - + +#max_files_per_process = 1000 # min 25 +#preload_libraries = '' + +#--------------------------------------------------------------------------- +# WRITE AHEAD LOG +#--------------------------------------------------------------------------- + +# - Settings - + +#fsync = true # turns forced synchronization on or off +#wal_sync_method = fsync # the default varies across platforms: + # fsync, fdatasync, open_sync, or open_datasync +#wal_buffers = 8 # min 4, 8KB each + +# - Checkpoints - + +#checkpoint_segments = 3 # 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 + +Everything else are at their defaults. I actually think the WAL +options are set to defaults as well, but I don't recall exactly :) + +As for the queries and table, The data we store is confidential, but +it is essentially an account number with a bunch of boolean fields +that specify if a person applies to criteria. So a query may look +something like: + +SELECT acctno FROM view_of_data WHERE has_name AND is_active_member +AND state = 'OH'; + +which is explained as something like this: + QUERY PLAN +----------------------------------------------------------------- + Seq Scan on view_of_data (cost=0.00..25304.26 rows=22054 width=11) + Filter: (has_name AND is_active_member AND ((state)::text = 'OH'::text)) +(2 rows) + +Occasionally, because we store data from several sources, we will have +requests for data from several sources. We simply intersect the +view_of_data table with a sources table that lists what acctno belong +to what source. This query would look something like this: + +SELECT acctno FROM view_of_data WHERE has_name AND is_active_member +AND state = 'OH' INTERSECT SELECT acctno FROM sources_data WHERE +source = 175; + +which is explained as follows: + QUERY PLAN +------------------------------------------------------------------------------------------- + SetOp Intersect (cost=882226.14..885698.20 rows=69441 width=11) + -> Sort (cost=882226.14..883962.17 rows=694411 width=11) + Sort Key: acctno + -> Append (cost=0.00..814849.42 rows=694411 width=11) + -> Subquery Scan "*SELECT* 1" (cost=0.00..25524.80 +rows=22054 width=11) + -> Seq Scan on view_of_data +(cost=0.00..25304.26 rows=22054 width=11) + Filter: (has_name AND is_active_member AND +((state)::text = 'OH'::text)) + -> Subquery Scan "*SELECT* 2" (cost=0.00..789324.62 +rows=672357 width=11) + -> Seq Scan on sources_data +(cost=0.00..782601.05 rows=672357 width=11) + Filter: (source = 23) + + +Again, we see our biggest bottlenecks when we get over about 50 +million records. The time to execute grows exponentially from that +point. + +Thanks again for all of your help! + +-Josh + + +On Fri, 22 Oct 2004 07:38:49 -0400, Dave Cramer wrote: +> Josh, +> +> Your hardware setup would be useful too. It's surprising how slow some +> big name servers really are. +> If you are seriously considering memory sizes over 4G you may want to +> look at an opteron. +> +> Dave +> +> +> +> Joshua Marsh wrote: +> +> >Hello everyone, +> > +> >I am currently working on a data project that uses PostgreSQL +> >extensively to store, manage and maintain the data. We haven't had +> >any problems regarding database size until recently. The three major +> >tables we use never get bigger than 10 million records. With this +> >size, we can do things like storing the indexes or even the tables in +> >memory to allow faster access. +> > +> >Recently, we have found customers who are wanting to use our service +> >with data files between 100 million and 300 million records. At that +> >size, each of the three major tables will hold between 150 million and +> >700 million records. At this size, I can't expect it to run queries +> >in 10-15 seconds (what we can do with 10 million records), but would +> >prefer to keep them all under a minute. +> > +> >We did some original testing and with a server with 8GB or RAM and +> >found we can do operations on data file up to 50 million fairly well, +> >but performance drop dramatically after that. Does anyone have any +> >suggestions on a good way to improve performance for these extra large +> >tables? Things that have come to mind are Replication and Beowulf +> >clusters, but from what I have recently studied, these don't do so wel +> >with singular processes. We will have parallel process running, but +> >it's more important that the speed of each process be faster than +> >several parallel processes at once. +> > +> >Any help would be greatly appreciated! +> > +> >Thanks, +> > +> >Joshua Marsh +> > +> >P.S. Off-topic, I have a few invitations to gmail. If anyone would +> >like one, let me know. +> > +> >---------------------------(end of broadcast)--------------------------- +> >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> > +> > +> > +> > +> +> -- +> Dave Cramer +> http://www.postgresintl.com +> 519 939 0336 +> ICQ#14675561 +> +> + +From pgsql-hackers-owner@postgresql.org Tue Oct 26 16:30:32 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D1483A4448 + for ; + Tue, 26 Oct 2004 16:30:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07638-03 + for ; + Tue, 26 Oct 2004 15:30:28 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 57EEF3A442F + for ; + Tue, 26 Oct 2004 16:30:27 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1CMTHE-0003uU-00; Tue, 26 Oct 2004 11:30:24 -0400 +To: Curt Sampson +Cc: Greg Stark , pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> <87hdoiv62b.fsf@stark.xeocode.com> + <790.1098741205@sss.pgh.pa.us> <878y9uukgb.fsf@stark.xeocode.com> + +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 26 Oct 2004 11:30:23 -0400 +Message-ID: <87r7nlts34.fsf@stark.xeocode.com> +Lines: 39 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/892 +X-Sequence-Number: 60395 + + +Curt Sampson writes: + +> On Tue, 26 Oct 2004, Greg Stark wrote: +> +> > I see mmap or O_DIRECT being the only viable long-term stable states. My +> > natural inclination was the former but after the latest thread on the subject +> > I suspect it'll be forever out of reach. That makes O_DIRECT And a Postgres +> > managed cache the only real choice. Having both caches is just a waste of +> > memory and a waste of cpu cycles. +> +> I don't see why mmap is any more out of reach than O_DIRECT; it's not +> all that much harder to implement, and mmap (and madvise!) is more +> widely available. + +Because there's no way to prevent a write-out from occurring and no way to be +notified by mmap before a write-out occurs, and Postgres wants to do its WAL +logging at that time if it hasn't already happened. + +> But if using two caches is only costing us 1% in performance, there's +> not really much point.... + +Well firstly it depends on the work profile. It can probably get much higher +than we saw in that profile if your work load is causing more fresh buffers to +be fetched. + +Secondly it also reduces the amount of cache available. If you have 256M of +ram with about 200M free, and 40Mb of ram set aside for Postgres's buffer +cache then you really only get 160Mb. It's costing you 20% of your cache, and +reducing the cache hit rate accordingly. + +Thirdly the kernel doesn't know as much as Postgres about the load. Postgres +could optimize its use of cache based on whether it knows the data is being +loaded by a vacuum or sequential scan rather than an index lookup. In practice +Postgres has gone with ARC which I suppose a kernel could implement anyways, +but afaik neither linux nor BSD choose to do anything like it. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Oct 26 17:39:51 2004 +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 862F13A4449 + for ; + Tue, 26 Oct 2004 17:39:50 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35967-08 + for ; + Tue, 26 Oct 2004 16:39: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 4352C3A442F + for ; + Tue, 26 Oct 2004 17:39:47 +0100 (BST) +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 i9QGdiRV010370; + Tue, 26 Oct 2004 12:39:44 -0400 (EDT) +To: Joshua Marsh +Cc: pg@fastcrypt.com, pgsql-performance@postgresql.org +Subject: Re: Large Database Performance suggestions +In-reply-to: <38242de904102608246d060f7d@mail.gmail.com> +References: <38242de904102120143c55ba34@mail.gmail.com> + <4178F149.9090408@fastcrypt.com> + <38242de904102608246d060f7d@mail.gmail.com> +Comments: In-reply-to Joshua Marsh + message dated "Tue, 26 Oct 2004 09:24:08 -0600" +Date: Tue, 26 Oct 2004 12:39:44 -0400 +Message-ID: <10369.1098808784@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/430 +X-Sequence-Number: 8906 + +Joshua Marsh writes: +> shared_buffers = 1000 # min 16, at least max_connections*2, 8KB each + +This is on the small side for an 8G machine. I'd try 10000 or so. + +> sort_mem = 4096000 + +Yikes. You do realize you just said that *each sort operation* can use 4G? +(Actually, it's probably overflowing internally; I dunno what amount of +sort space you are really ending up with but it could be small.) Try +something saner, maybe in the 10 to 100MB range. + +> vacuum_mem = 1024000 + +This is probably excessive as well. + +> #max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each +> #max_fsm_relations = 1000 # min 100, ~50 bytes each + +You will need to bump these up a good deal to avoid database bloat. + +> Occasionally, because we store data from several sources, we will have +> requests for data from several sources. We simply intersect the +> view_of_data table with a sources table that lists what acctno belong +> to what source. This query would look something like this: + +> SELECT acctno FROM view_of_data WHERE has_name AND is_active_member +> AND state = 'OH' INTERSECT SELECT acctno FROM sources_data WHERE +> source = 175; + +IMHO you need to rethink your table layout. There is simply no way that +that query is going to be fast. Adding a source column to view_of_data +would work much better. + +If you're not in a position to redo the tables, you might try it as a +join: + +SELECT acctno FROM view_of_data JOIN sources_data USING (acctno) +WHERE has_name AND is_active_member AND state = 'OH' + AND source = 175; + +but I'm not really sure if that will be better or not. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 26 18:42:32 2004 +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 953C13A3B12 + for ; + Tue, 26 Oct 2004 18:42:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60110-02 + for ; + Tue, 26 Oct 2004 17:42:22 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com + [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A4D023A3BA9 + for ; + Tue, 26 Oct 2004 18:42:22 +0100 (BST) +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-7" +Content-Transfer-Encoding: quoted-printable +Subject: Re: can't handle large number of INSERT/UPDATEs +Date: Tue, 26 Oct 2004 13:42:21 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DC@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] can't handle large number of INSERT/UPDATEs +Thread-Index: AcS62GKSkO7EAKXVQ/SkOGeKYyw6rwAqfKFQ +From: "Anjan Dave" +To: "Rod Taylor" +Cc: "Postgresql Performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/431 +X-Sequence-Number: 8907 + +It probably is locking issue. I got a long list of locks held when we ran s= +elect * from pg_locks during a peak time. + +relation | database | transaction | pid | mode | granted=20 +----------+----------+-------------+-------+------------------+--------- + 17239 | 17142 | | 3856 | AccessShareLock | t + | | 21196323 | 3875 | ExclusiveLock | t + 16390 | 17142 | | 3911 | AccessShareLock | t + 16595 | 17142 | | 3782 | AccessShareLock | t + 17227 | 17142 | | 3840 | AccessShareLock | t + 17227 | 17142 | | 3840 | RowExclusiveLock | t +... +... + + +Vmstat would show a lot of disk IO at the same time. + +Is this pointing towards a disk IO issue? (to that end, other than a higher= + CPU speed, and disabling HT, only thing changed is that it's RAID5 volume = +now, instead of a RAID10) + +-anjan + + +-----Original Message----- +From: Rod Taylor [mailto:pg@rbt.ca]=20 +Sent: Monday, October 25, 2004 5:19 PM +To: Anjan Dave +Cc: Postgresql Performance +Subject: Re: [PERFORM] can't handle large number of INSERT/UPDATEs + +On Mon, 2004-10-25 at 16:53, Anjan Dave wrote: +> Hi, +>=20 +>=20=20 +>=20 +> I am dealing with an app here that uses pg to handle a few thousand +> concurrent web users. It seems that under heavy load, the INSERT and +> UPDATE statements to one or two specific tables keep queuing up, to +> the count of 150+ (one table has about 432K rows, other has about +> 2.6Million rows), resulting in =A1wait=A2s for other queries, and then + +This isn't an index issue, it's a locking issue. Sounds like you have a +bunch of inserts and updates hitting the same rows over and over again. + +Eliminate that contention point, and you will have solved your problem. + +Free free to describe the processes involved, and we can help you do +that. + + + + +From pgsql-performance-owner@postgresql.org Tue Oct 26 18:49:36 2004 +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 B12D53A3B1F + for ; + Tue, 26 Oct 2004 18:49:35 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62689-07 + for ; + Tue, 26 Oct 2004 17:49:25 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BDEE43A3B12 + for ; + Tue, 26 Oct 2004 18:49:25 +0100 (BST) +Received: from [134.22.69.212] (dyn-69-212.tor.dsl.tht.net [134.22.69.212]) + by tht.net (Postfix) with ESMTP + id C9A5676A41; Tue, 26 Oct 2004 13:49:25 -0400 (EDT) +Subject: Re: can't handle large number of INSERT/UPDATEs +From: Rod Taylor +To: Anjan Dave +Cc: Postgresql Performance +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DC@vt-pe2550-001.vantage.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DC@vt-pe2550-001.vantage.vantage.com> +Content-Type: text/plain +Message-Id: <1098812922.8557.485.camel@home> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 26 Oct 2004 13:48:42 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/432 +X-Sequence-Number: 8908 + +On Tue, 2004-10-26 at 13:42, Anjan Dave wrote: +> It probably is locking issue. I got a long list of locks held when we ran select * from pg_locks during a peak time. +> +> relation | database | transaction | pid | mode | granted +> ----------+----------+-------------+-------+------------------+--------- +> 17239 | 17142 | | 3856 | AccessShareLock | t + +How many have granted = false? + +> Vmstat would show a lot of disk IO at the same time. +> +> Is this pointing towards a disk IO issue? + +Not necessarily. Is your IO reaching the limit or is it just heavy? + + +From pgsql-performance-owner@postgresql.org Tue Oct 26 18:56:35 2004 +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 B06E73A3B40 + for ; + Tue, 26 Oct 2004 18:56:33 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63376-10 + for ; + Tue, 26 Oct 2004 17:56:25 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com + [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B8733A3B2E + for ; + Tue, 26 Oct 2004 18:56:25 +0100 (BST) +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: can't handle large number of INSERT/UPDATEs +Date: Tue, 26 Oct 2004 13:56:25 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DD@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] can't handle large number of INSERT/UPDATEs +Thread-Index: AcS7hCF8Kgl2bmRDTBGmU2oCxry/JwAABxVQ +From: "Anjan Dave" +To: "Rod Taylor" +Cc: "Postgresql Performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/433 +X-Sequence-Number: 8909 + +None of the locks are in state false actually. + +I don't have iostat on that machine, but vmstat shows a lot of writes to +the drives, and the runnable processes are more than 1: + +procs memory swap io system +cpu + r b swpd free buff cache si so bi bo in cs us sy +wa id + 1 2 0 3857568 292936 2791876 0 0 0 44460 1264 2997 23 +13 22 41 + 2 2 0 3824668 292936 2791884 0 0 0 25262 1113 4797 28 +12 29 31 + 2 3 0 3784772 292936 2791896 0 0 0 38988 1468 6677 28 +12 48 12 + 2 4 0 3736256 292936 2791904 0 0 0 50970 1530 5217 19 +12 49 20 + 4 2 0 3698056 292936 2791908 0 0 0 43576 1369 7316 20 +15 35 30 + 2 1 0 3667124 292936 2791920 0 0 0 39174 1444 4659 25 +16 35 24 + 6 1 0 3617652 292936 2791928 0 0 0 52430 1347 4681 25 +19 20 37 + 1 3 0 3599992 292936 2790868 0 0 0 40156 1439 4394 20 +14 29 37 + 6 0 0 3797488 292936 2568648 0 0 0 17706 2272 21534 28 +23 19 30 + 0 0 0 3785396 292936 2568736 0 0 0 1156 1237 14057 33 +8 0 59 + 0 0 0 3783568 292936 2568736 0 0 0 704 512 1537 5 +2 1 92 + 1 0 0 3783188 292936 2568752 0 0 0 842 613 1919 6 +1 1 92 + +-anjan + +-----Original Message----- +From: Rod Taylor [mailto:pg@rbt.ca]=20 +Sent: Tuesday, October 26, 2004 1:49 PM +To: Anjan Dave +Cc: Postgresql Performance +Subject: RE: [PERFORM] can't handle large number of INSERT/UPDATEs + +On Tue, 2004-10-26 at 13:42, Anjan Dave wrote: +> It probably is locking issue. I got a long list of locks held when we +ran select * from pg_locks during a peak time. +>=20 +> relation | database | transaction | pid | mode | granted + +> +----------+----------+-------------+-------+------------------+--------- +> 17239 | 17142 | | 3856 | AccessShareLock | t + +How many have granted =3D false? + +> Vmstat would show a lot of disk IO at the same time. +>=20 +> Is this pointing towards a disk IO issue? + +Not necessarily. Is your IO reaching the limit or is it just heavy? + + + +From pgsql-performance-owner@postgresql.org Tue Oct 26 19:25:06 2004 +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 BEF903A3AC9 + for ; + Tue, 26 Oct 2004 19:25:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71841-08 + for ; + Tue, 26 Oct 2004 18:24:55 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 350DD3A3D68 + for ; + Tue, 26 Oct 2004 19:24:53 +0100 (BST) +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 6558564; Tue, 26 Oct 2004 11:26:17 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: can't handle large number of INSERT/UPDATEs +Date: Tue, 26 Oct 2004 11:27:02 -0700 +User-Agent: KMail/1.6.2 +Cc: "Anjan Dave" , "Rod Taylor" +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DC@vt-pe2550-001.vantage.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DC@vt-pe2550-001.vantage.vantage.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-7" +Content-Transfer-Encoding: 7bit +Message-Id: <200410261127.02656.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/434 +X-Sequence-Number: 8910 + +Anjan, + +> It probably is locking issue. I got a long list of locks held when we ran +> select * from pg_locks during a peak time. + +Do the back-loaded tables have FKs on them? This would be a likely cause +of lock contention, and thus serializing inserts/updates to the tables. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Oct 26 19:29:05 2004 +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 B38333A448B + for ; + Tue, 26 Oct 2004 19:29:01 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72958-09 + for ; + Tue, 26 Oct 2004 18:28:51 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 962C03A3B12 + for ; + Tue, 26 Oct 2004 19:28:51 +0100 (BST) +Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk + [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP + id C4026A3637; Tue, 26 Oct 2004 19:28:49 +0100 (BST) +Message-ID: <417E9752.5050506@ymogen.net> +Date: Tue, 26 Oct 2004 19:28:34 +0100 +From: Matt Clark +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Anjan Dave +Cc: Rod Taylor , + Postgresql Performance +Subject: Re: can't handle large number of INSERT/UPDATEs +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DD@vt-pe2550-001.vantage.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DD@vt-pe2550-001.vantage.vantage.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/435 +X-Sequence-Number: 8911 + + +>I don't have iostat on that machine, but vmstat shows a lot of writes to +>the drives, and the runnable processes are more than 1: +> +> 6 1 0 3617652 292936 2791928 0 0 0 52430 1347 4681 25 +>19 20 37 +> +> +Assuming that's the output of 'vmstat 1' and not some other delay, +50MB/second of sustained writes is usually considered 'a lot'. + +From pgsql-performance-owner@postgresql.org Tue Oct 26 20:18:15 2004 +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 C09B23A3D09 + for ; + Tue, 26 Oct 2004 20:18:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96533-03 + for ; + Tue, 26 Oct 2004 19:18:10 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 51CF43A3B5B + for ; + Tue, 26 Oct 2004 20:18:11 +0100 (BST) +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 6558784; Tue, 26 Oct 2004 12:19:36 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Measuring server performance with psql and pgAdmin +Date: Tue, 26 Oct 2004 12:20:21 -0700 +User-Agent: KMail/1.6.2 +Cc: "Joost Kraaijeveld" +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410261220.21435.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/436 +X-Sequence-Number: 8912 + +Joost, + +> 1. The manual says about "explain analyze" : "The ANALYZE option causes the +> statement to be actually executed, not only planned. The total elapsed time +> expended within each plan node (in milliseconds) and total number of rows +> it actually returned are added to the display." Does this time include +> datatransfer or just the time the database needs to collect the data, +> without any data transfer? + +Correct. It's strictly backend time. + +> 2. If the time is without data transfer to the +> client, is there a reliable way to measure the time needed to run the query +> and get the data (without the overhead of a program that does something +> with the data)? + +in PSQL, you can use \timing + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Oct 26 21:19:15 2004 +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 CFA023A4479 + for ; + Tue, 26 Oct 2004 21:19:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20616-05 + for ; + Tue, 26 Oct 2004 20:19:07 +0000 (GMT) +Received: from web50001.mail.yahoo.com (web50001.mail.yahoo.com + [206.190.38.16]) + by svr1.postgresql.org (Postfix) with SMTP id 560CE3A3BAA + for ; + Tue, 26 Oct 2004 21:19:07 +0100 (BST) +Message-ID: <20041026201906.30736.qmail@web50001.mail.yahoo.com> +Received: from [200.93.192.137] by web50001.mail.yahoo.com via HTTP; + Tue, 26 Oct 2004 15:19:06 CDT +Date: Tue, 26 Oct 2004 15:19:06 -0500 (CDT) +From: Jaime Casanova +Subject: Re: Sequential Scan with LIMIT +To: pgsql-performance@postgresql.org +In-Reply-To: <417D0EC2.5020206@johnmeinel.com> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/437 +X-Sequence-Number: 8913 + + --- John Meinel escribi�: +> Curt Sampson wrote: +> > On Sun, 24 Oct 2004, John Meinel wrote: +> > +> > +> >>I was looking into another problem, and I found +> something that surprised +> >>me. If I'm doing "SELECT * FROM mytable WHERE col +> = 'myval' LIMIT 1.". +> >>Now "col" is indexed... +> >>The real purpose of this query is to check to see +> if a value exists in +> >>the column,... +> > +> > +> > When you select all the columns, you're going to +> force it to go to the +> > table. If you select only the indexed column, it +> ought to be able to use +> > just the index, and never read the table at all. +> You could also use more +> > standard and more set-oriented SQL while you're at +> it: +> > +> > SELECT DISTINCT(col) FROM mytable WHERE col = +> 'myval' +> > +> > cjs +> +> Well, what you wrote was actually much slower, as it +> had to scan the +> whole table, grab all the rows, and then distinct +> them in the end. +> +> However, this query worked: +> +> +> SELECT DISTINCT(col) FROM mytable WHERE col = +> 'myval' LIMIT 1; +> +> +> Now, *why* that works differently from: +> +> SELECT col FROM mytable WHERE col = 'myval' LIMIT 1; +> or +> SELECT DISTINCT(col) FROM mytable WHERE col = +> 'myval'; +> +> I'm not sure. They all return the same information. + +of course, both queries will return the same but +that's just because you forced it. + +LIMIT and DISTINCT are different things so they behave +and are plenned different. + + +> +> What's also weird is stuff like: +> SELECT DISTINCT(NULL) FROM mytable WHERE col = +> 'myval' LIMIT 1; + +why do you want to do such a thing? + +regards, +Jaime Casanova + +_________________________________________________________ +Do You Yahoo!? +Informaci�n de Estados Unidos y Am�rica Latina, en Yahoo! Noticias. +Vis�tanos en http://noticias.espanol.yahoo.com + +From pgsql-performance-owner@postgresql.org Tue Oct 26 21:51:00 2004 +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 95ABB3A3C59 + for ; + Tue, 26 Oct 2004 21:50:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36060-03 + for ; + Tue, 26 Oct 2004 20:50:55 +0000 (GMT) +Received: from mail1.catalyst.net.nz (godel.catalyst.net.nz [202.49.159.12]) + by svr1.postgresql.org (Postfix) with ESMTP id 98E143A3AFF + for ; + Tue, 26 Oct 2004 21:50:53 +0100 (BST) +Received: from leibniz.catalyst.net.nz ([202.49.159.7] + helo=lamb.mcmillan.net.nz) by mail1.catalyst.net.nz with asmtp + (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) + id 1CMYHK-0000aP-VK; Wed, 27 Oct 2004 09:50:51 +1300 +Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) + by lamb.mcmillan.net.nz (Postfix) with ESMTP id 97FB7AC21B39; + Wed, 27 Oct 2004 09:50:50 +1300 (NZDT) +Subject: Re: can't handle large number of INSERT/UPDATEs +From: Andrew McMillan +To: Anjan Dave +Cc: pgsql-performance@postgresql.org +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985D5@vt-pe2550-001.vantage.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985D5@vt-pe2550-001.vantage.vantage.com> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-tIJWZPEUWnLHsT0/hc/i" +Date: Wed, 27 Oct 2004 09:50:50 +1300 +Message-Id: <1098823850.6440.89.camel@lamb.mcmillan.net.nz> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/438 +X-Sequence-Number: 8914 + +--=-tIJWZPEUWnLHsT0/hc/i +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +On Mon, 2004-10-25 at 16:53 -0400, Anjan Dave wrote: +> Hi, +>=20 +>=20=20 +>=20 +> I am dealing with an app here that uses pg to handle a few thousand +> concurrent web users. It seems that under heavy load, the INSERT and +> UPDATE statements to one or two specific tables keep queuing up, to +> the count of 150+ (one table has about 432K rows, other has about +> 2.6Million rows), resulting in =E2=80=98wait=E2=80=99s for other queries,= + and then +> everything piles up, with the load average shooting up to 10+.=20 + +Hi, + +We saw a similar problem here that was related to the locking that can +happen against referred tables for referential integrity. + +In our case we had referred tables with very few rows (i.e. < 10) which +caused the insert and update on the large tables to be effectively +serialised due to the high contention on the referred tables. + +We changed our app to implement those referential integrity checks +differently and performance was hugely boosted. + +Regards, + Andrew. +------------------------------------------------------------------------- +Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington +WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St +DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 + Chicken Little was right. +------------------------------------------------------------------------- + + +--=-tIJWZPEUWnLHsT0/hc/i +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (GNU/Linux) + +iD8DBQBBfripjJA0f48GgBIRAqKAAJ0esyvcdqOaBIK+gYL+D7Ql6MOUDwCgvOgO +4Fuwb8gBnPHOHrLZGBFJlMU= +=8UWV +-----END PGP SIGNATURE----- + +--=-tIJWZPEUWnLHsT0/hc/i-- + + +From pgsql-performance-owner@postgresql.org Tue Oct 26 22:13:15 2004 +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 3CC503A44AB + for ; + Tue, 26 Oct 2004 22:13:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44291-04 + for ; + Tue, 26 Oct 2004 21:13:03 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com + [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 9722C3A4495 + for ; + Tue, 26 Oct 2004 22:13:04 +0100 (BST) +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: can't handle large number of INSERT/UPDATEs +Date: Tue, 26 Oct 2004 17:13:04 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78501B2751F@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] can't handle large number of INSERT/UPDATEs +Thread-Index: AcS7nXxiYanz2kOaQBuW7IrC0zVnhQAAuFnw +From: "Anjan Dave" +To: "Andrew McMillan" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/439 +X-Sequence-Number: 8915 + +Andrew/Josh, + +Josh also suggested to check for any FK/referential integrity checks, +but I am told that we don't have any foreign key constraints. + +Thanks, +anjan + +-----Original Message----- +From: Andrew McMillan [mailto:andrew@catalyst.net.nz]=20 +Sent: Tuesday, October 26, 2004 4:51 PM +To: Anjan Dave +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] can't handle large number of INSERT/UPDATEs + +On Mon, 2004-10-25 at 16:53 -0400, Anjan Dave wrote: +> Hi, +>=20 +>=20=20 +>=20 +> I am dealing with an app here that uses pg to handle a few thousand +> concurrent web users. It seems that under heavy load, the INSERT and +> UPDATE statements to one or two specific tables keep queuing up, to +> the count of 150+ (one table has about 432K rows, other has about +> 2.6Million rows), resulting in 'wait's for other queries, and then +> everything piles up, with the load average shooting up to 10+.=20 + +Hi, + +We saw a similar problem here that was related to the locking that can +happen against referred tables for referential integrity. + +In our case we had referred tables with very few rows (i.e. < 10) which +caused the insert and update on the large tables to be effectively +serialised due to the high contention on the referred tables. + +We changed our app to implement those referential integrity checks +differently and performance was hugely boosted. + +Regards, + Andrew. +------------------------------------------------------------------------ +- +Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington +WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St +DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 + Chicken Little was right. +------------------------------------------------------------------------ +- + + + +From pgsql-performance-owner@postgresql.org Tue Oct 26 22:15:57 2004 +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 DFCE03A3C59 + for ; + Tue, 26 Oct 2004 22:15:53 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45725-04 + for ; + Tue, 26 Oct 2004 21:15:50 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com + [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 811113A4491 + for ; + Tue, 26 Oct 2004 22:15:50 +0100 (BST) +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: can't handle large number of INSERT/UPDATEs +Date: Tue, 26 Oct 2004 17:15:49 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DE@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] can't handle large number of INSERT/UPDATEs +Thread-Index: AcS7iaSIf5PL3zKfTs2Cep9/+HyB1AAFU4Hg +From: "Anjan Dave" +To: "Matt Clark" +Cc: "Rod Taylor" , + "Postgresql Performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/440 +X-Sequence-Number: 8916 + +That is 1 or maybe 2 second interval. + +One thing I am not sure is why 'bi' (disk writes) stays at 0 mostly, +it's the 'bo' column that shows high numbers (reads from disk). With so +many INSERT/UPDATEs, I would expect it the other way around... + +-anjan + + + +-----Original Message----- +From: Matt Clark [mailto:matt@ymogen.net]=20 +Sent: Tuesday, October 26, 2004 2:29 PM +To: Anjan Dave +Cc: Rod Taylor; Postgresql Performance +Subject: Re: [PERFORM] can't handle large number of INSERT/UPDATEs + + +>I don't have iostat on that machine, but vmstat shows a lot of writes +to +>the drives, and the runnable processes are more than 1: +> +> 6 1 0 3617652 292936 2791928 0 0 0 52430 1347 4681 25 +>19 20 37 +>=20=20 +> +Assuming that's the output of 'vmstat 1' and not some other delay,=20 +50MB/second of sustained writes is usually considered 'a lot'.=20 + + +From pgsql-performance-owner@postgresql.org Tue Oct 26 22:53:26 2004 +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 A208C3A44A8 + for ; + Tue, 26 Oct 2004 22:53:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59001-04 + for ; + Tue, 26 Oct 2004 21:53: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 C92BE3A44CE + for ; + Tue, 26 Oct 2004 22:53:14 +0100 (BST) +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 i9QLrE4h013824; + Tue, 26 Oct 2004 17:53:14 -0400 (EDT) +To: "Anjan Dave" +Cc: "Rod Taylor" , + "Postgresql Performance" +Subject: Re: can't handle large number of INSERT/UPDATEs +In-reply-to: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DD@vt-pe2550-001.vantage.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DD@vt-pe2550-001.vantage.vantage.com> +Comments: In-reply-to "Anjan Dave" + message dated "Tue, 26 Oct 2004 13:56:25 -0400" +Date: Tue, 26 Oct 2004 17:53:14 -0400 +Message-ID: <13823.1098827594@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/441 +X-Sequence-Number: 8917 + +"Anjan Dave" writes: +> None of the locks are in state false actually. + +In that case you don't have a locking problem. + +> I don't have iostat on that machine, but vmstat shows a lot of writes to +> the drives, and the runnable processes are more than 1: + +I get the impression that you are just saturating the write bandwidth of +your disk :-( + +It's fairly likely that this happens during checkpoints. Look to see if +the postmaster has a child that shows itself as a checkpointer in "ps" +when the saturation is occurring. You might be able to improve matters +by altering the checkpoint frequency parameters (though beware that +either too small or too large will likely make matters even worse). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 26 23:14:36 2004 +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 B90593A44CB + for ; + Tue, 26 Oct 2004 23:14:19 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65906-07 + for ; + Tue, 26 Oct 2004 22:14:09 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com + [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 568833A3B04 + for ; + Tue, 26 Oct 2004 23:14:10 +0100 (BST) +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: can't handle large number of INSERT/UPDATEs +Date: Tue, 26 Oct 2004 18:14:10 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DF@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] can't handle large number of INSERT/UPDATEs +Thread-Index: AcS7pjPajROyB3T2QBiskTifN/yDSQAAQ+9g +From: "Anjan Dave" +To: "Tom Lane" +Cc: "Rod Taylor" , + "Postgresql Performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/442 +X-Sequence-Number: 8918 + +It just seems that the more activity there is (that is when there's a +lot of disk activity) the checkpoints happen quicker too. + +Here's a snapshot from the /var/log/messages -=20 + +Oct 26 17:21:22 vl-pe6650-003 postgres[13978]: [2-1] LOG: recycled +transaction +log file "0000000B0000007E" +Oct 26 17:21:22 vl-pe6650-003 postgres[13978]: [3-1] LOG: recycled +transaction +log file "0000000B0000007F" +... +Oct 26 17:26:25 vl-pe6650-003 postgres[14273]: [2-1] LOG: recycled +transaction +log file "0000000B00000080" +Oct 26 17:26:25 vl-pe6650-003 postgres[14273]: [3-1] LOG: recycled +transaction +log file "0000000B00000081" +Oct 26 17:26:25 vl-pe6650-003 postgres[14273]: [4-1] LOG: recycled +transaction +log file "0000000B00000082" +... +Oct 26 17:31:27 vl-pe6650-003 postgres[14508]: [2-1] LOG: recycled +transaction +log file "0000000B00000083" +Oct 26 17:31:27 vl-pe6650-003 postgres[14508]: [3-1] LOG: recycled +transaction +log file "0000000B00000084" +Oct 26 17:31:27 vl-pe6650-003 postgres[14508]: [4-1] LOG: recycled +transaction +log file "0000000B00000085" +... + +I have increased them from default 3 to 15. Haven't altered the +frequency though.... + +Thanks, +Anjan=20 + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Tuesday, October 26, 2004 5:53 PM +To: Anjan Dave +Cc: Rod Taylor; Postgresql Performance +Subject: Re: [PERFORM] can't handle large number of INSERT/UPDATEs=20 + +"Anjan Dave" writes: +> None of the locks are in state false actually. + +In that case you don't have a locking problem. + +> I don't have iostat on that machine, but vmstat shows a lot of writes +to +> the drives, and the runnable processes are more than 1: + +I get the impression that you are just saturating the write bandwidth of +your disk :-( + +It's fairly likely that this happens during checkpoints. Look to see if +the postmaster has a child that shows itself as a checkpointer in "ps" +when the saturation is occurring. You might be able to improve matters +by altering the checkpoint frequency parameters (though beware that +either too small or too large will likely make matters even worse). + + regards, tom lane + + +From pgsql-performance-owner@postgresql.org Tue Oct 26 23:21:50 2004 +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 C66593A43E1 + for ; + Tue, 26 Oct 2004 23:21:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67579-08 + for ; + Tue, 26 Oct 2004 22:21:41 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id DF2CE3A3B4B + for ; + Tue, 26 Oct 2004 23:21:42 +0100 (BST) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id i9QMLe322290; + Tue, 26 Oct 2004 17:21:40 -0500 +Message-ID: <417ECDEF.8030108@johnmeinel.com> +Date: Tue, 26 Oct 2004 17:21:35 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jaime Casanova +Cc: pgsql-performance@postgresql.org +Subject: Re: Sequential Scan with LIMIT +References: <20041026201906.30736.qmail@web50001.mail.yahoo.com> +In-Reply-To: <20041026201906.30736.qmail@web50001.mail.yahoo.com> +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigBA86A89DE219113FA5129D77" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/443 +X-Sequence-Number: 8919 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigBA86A89DE219113FA5129D77 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Jaime Casanova wrote: +[...] +>> +>>I'm not sure. They all return the same information. +> +> +> of course, both queries will return the same but +> that's just because you forced it. +> +> LIMIT and DISTINCT are different things so they behave +> and are plenned different. +> +> +> +>>What's also weird is stuff like: +>>SELECT DISTINCT(NULL) FROM mytable WHERE col = +>>'myval' LIMIT 1; +> +> +> why do you want to do such a thing? +> +> regards, +> Jaime Casanova +> + +I was trying to see if selecting a constant would change things. +I could have done SELECT DISTINCT(1) or just SELECT 1 FROM ... +The idea of the query is that if 'myval' exists in the table, return +something different than if 'myval' does not exist. If you are writing a +function, you can use: + +SELECT something... +IF FOUND THEN + do a +ELSE + do b +END IF; + +The whole point of this exercise was just to find what the cheapest +query is when you want to test for the existence of a value in a column. +The only thing I've found for my column is: + +SET enable_seq_scan TO off; +SELECT col FROM mytable WHERE col = 'myval' LIMIT 1; +SET enable_seq_scan TO on; + +My column is not distributed well (larger numbers occur later in the +dataset, but may occur many times.) In total there are something like +500,000 rows, the number 555647 occurs 100,000 times, but not until row +300,000 or so. + +The analyzer looks at the data and says "1/5th of the time it is 555647, +so I can just do a sequential scan as the odds are I don't have to look +for very long, then I don't have to load the index". It turns out this +is very bad, where with an index you just have to do 2 page loads, +instead of reading 300,000 rows. + +Obviously this isn't a general-case solution. But if you have a +situation similar to mine, it might be useful. + +(That's one thing with DB tuning. It seems to be very situation +dependent, and it's hard to plan without a real dataset.) + +John +=:-> + +--------------enigBA86A89DE219113FA5129D77 +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBfs3vJdeBCYSNAAMRAij1AKCzucvN+dDXptIwmK5hsjX9cx2JPwCgsUe1 +l5eetHEBY79tw2F3IcY7Qx8= +=yeOQ +-----END PGP SIGNATURE----- + +--------------enigBA86A89DE219113FA5129D77-- + +From pgsql-performance-owner@postgresql.org Tue Oct 26 23:37:47 2004 +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 1F9EF3A44EF + for ; + Tue, 26 Oct 2004 23:37:43 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75465-01 + for ; + Tue, 26 Oct 2004 22:37: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 229FC3A44D2 + for ; + Tue, 26 Oct 2004 23:37:34 +0100 (BST) +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 i9QMbX0d014216; + Tue, 26 Oct 2004 18:37:33 -0400 (EDT) +To: "Anjan Dave" +Cc: "Matt Clark" , "Rod Taylor" , + "Postgresql Performance" +Subject: Re: can't handle large number of INSERT/UPDATEs +In-reply-to: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DE@vt-pe2550-001.vantage.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DE@vt-pe2550-001.vantage.vantage.com> +Comments: In-reply-to "Anjan Dave" + message dated "Tue, 26 Oct 2004 17:15:49 -0400" +Date: Tue, 26 Oct 2004 18:37:32 -0400 +Message-ID: <14215.1098830252@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/444 +X-Sequence-Number: 8920 + +"Anjan Dave" writes: +> One thing I am not sure is why 'bi' (disk writes) stays at 0 mostly, +> it's the 'bo' column that shows high numbers (reads from disk). With so +> many INSERT/UPDATEs, I would expect it the other way around... + +Er ... it *is* the other way around. bi is blocks in (to the CPU), +bo is blocks out (from the CPU). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Oct 26 23:46:14 2004 +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 129DD3A44F9 + for ; + Tue, 26 Oct 2004 23:45:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76678-04 + for ; + Tue, 26 Oct 2004 22:45:37 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com + [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id CEFC23A44E9 + for ; + Tue, 26 Oct 2004 23:45:37 +0100 (BST) +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: can't handle large number of INSERT/UPDATEs +Date: Tue, 26 Oct 2004 18:45:37 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985E1@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] can't handle large number of INSERT/UPDATEs +Thread-Index: AcS7rGXbY+5WynAORYeAsNy4i70odAAAP5XE +From: "Anjan Dave" +To: "Tom Lane" +Cc: "Matt Clark" , "Rod Taylor" , + "Postgresql Performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/445 +X-Sequence-Number: 8921 + +T2ssIGkgd2FzIHRoaW5raW5nIGZyb20gdGhlIGRpc2sgcGVyc3BlY3RpdmUu +IFRoYW5rcyENCg0KCS0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tIA0KCUZy +b206IFRvbSBMYW5lIFttYWlsdG86dGdsQHNzcy5wZ2gucGEudXNdIA0KCVNl +bnQ6IFR1ZSAxMC8yNi8yMDA0IDY6MzcgUE0gDQoJVG86IEFuamFuIERhdmUg +DQoJQ2M6IE1hdHQgQ2xhcms7IFJvZCBUYXlsb3I7IFBvc3RncmVzcWwgUGVy +Zm9ybWFuY2UgDQoJU3ViamVjdDogUmU6IFtQRVJGT1JNXSBjYW4ndCBoYW5k +bGUgbGFyZ2UgbnVtYmVyIG9mIElOU0VSVC9VUERBVEVzIA0KCQ0KCQ0KDQoJ +IkFuamFuIERhdmUiIDxhZGF2ZUB2YW50YWdlLmNvbT4gd3JpdGVzOiANCgk+ +IE9uZSB0aGluZyBJIGFtIG5vdCBzdXJlIGlzIHdoeSAnYmknIChkaXNrIHdy +aXRlcykgc3RheXMgYXQgMCBtb3N0bHksIA0KCT4gaXQncyB0aGUgJ2JvJyBj +b2x1bW4gdGhhdCBzaG93cyBoaWdoIG51bWJlcnMgKHJlYWRzIGZyb20gZGlz +aykuIFdpdGggc28gDQoJPiBtYW55IElOU0VSVC9VUERBVEVzLCBJIHdvdWxk +IGV4cGVjdCBpdCB0aGUgb3RoZXIgd2F5IGFyb3VuZC4uLiANCg0KCUVyIC4u +LiBpdCAqaXMqIHRoZSBvdGhlciB3YXkgYXJvdW5kLiAgYmkgaXMgYmxvY2tz +IGluICh0byB0aGUgQ1BVKSwgDQoJYm8gaXMgYmxvY2tzIG91dCAoZnJvbSB0 +aGUgQ1BVKS4gDQoNCgkgICAgICAgICAgICAgICAgICAgICAgICByZWdhcmRz +LCB0b20gbGFuZSANCg0K + +From pgsql-performance-owner@postgresql.org Wed Oct 27 00:00:35 2004 +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 80E533A4507 + for ; + Wed, 27 Oct 2004 00:00:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81736-02 + for ; + Tue, 26 Oct 2004 23:00:18 +0000 (GMT) +Received: from mailman.norchemlab.com (unknown [12.164.217.51]) + by svr1.postgresql.org (Postfix) with ESMTP id D465F3A43E1 + for ; + Wed, 27 Oct 2004 00:00:19 +0100 (BST) +Received: from hyperion2.norchemlab.com (fireman.norchemlab.com + [12.164.217.50]) by mailman.norchemlab.com (Postfix) with ESMTP + id E840C8C8043; Tue, 26 Oct 2004 16:07:16 -0700 (MST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by hyperion2.norchemlab.com (8.12.8/8.12.8) with ESMTP id + i9QN4ZS5021668; Tue, 26 Oct 2004 16:04:35 -0700 +Date: Tue, 26 Oct 2004 16:04:35 -0700 (MST) +From: Curtis Zinzilieta +To: Tom Lane +Cc: Anjan Dave , Matt Clark , + Rod Taylor , + Postgresql Performance +Subject: Re: can't handle large number of INSERT/UPDATEs +In-Reply-To: <14215.1098830252@sss.pgh.pa.us> +Message-ID: + +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/446 +X-Sequence-Number: 8922 + + +On Tue, 26 Oct 2004, Tom Lane wrote: + +> "Anjan Dave" writes: +> > One thing I am not sure is why 'bi' (disk writes) stays at 0 mostly, +> > it's the 'bo' column that shows high numbers (reads from disk). With so +> > many INSERT/UPDATEs, I would expect it the other way around... +> +> Er ... it *is* the other way around. bi is blocks in (to the CPU), +> bo is blocks out (from the CPU). +> +> regards, tom lane + +Ummm..... + +[curtisz@labsoft T2]$ man vmstat + +FIELD DESCRIPTIONS + + IO + bi: Blocks sent to a block device (blocks/s). + bo: Blocks received from a block device (blocks/s). + +And on my read-heavy 7.4.2 system (running on rh8 at the moment....) +(truncated for readability...) + +[root@labsoft T2]# vmstat 1 + procs memory swap io system + r b w swpd free buff cache si so bi bo in cs us + 0 0 0 127592 56832 365496 2013788 0 1 3 6 4 0 4 + 2 0 0 127592 56868 365496 2013788 0 0 0 0 363 611 1 + 1 0 0 127592 57444 365508 2013788 0 0 8 972 1556 3616 11 + 0 0 1 127592 57408 365512 2013800 0 0 0 448 614 1216 5 + 0 0 0 127592 56660 365512 2013800 0 0 0 0 666 1150 6 + 0 3 1 127592 56680 365512 2013816 0 0 16 180 1280 2050 2 + 0 0 0 127592 56864 365516 2013852 0 0 20 728 2111 4360 11 + 0 0 0 127592 57952 365544 2013824 0 0 0 552 1153 2002 10 + 0 0 0 127592 57276 365544 2013824 0 0 0 504 718 1111 5 + 1 0 0 127592 57244 365544 2013824 0 0 0 436 1495 2366 7 + 0 0 0 127592 57252 365544 2013824 0 0 0 0 618 1380 5 + 0 0 0 127592 57276 365556 2014192 0 0 360 1240 2418 5056 14 + 2 0 0 127592 56664 365564 2014176 0 0 0 156 658 1349 5 + 1 0 0 127592 55864 365568 2014184 0 0 0 1572 1388 3598 9 + 2 0 0 127592 56160 365572 2014184 0 0 0 536 4860 6621 13 + +Which seems appropriate for both the database and the man page.... + +-Curtis + + + +From pgsql-performance-owner@postgresql.org Wed Oct 27 01:09:45 2004 +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 D04313A3AFE + for ; + Wed, 27 Oct 2004 01:09:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96778-08 + for ; + Wed, 27 Oct 2004 00:09:23 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id F22D73A1D9E + for ; + Wed, 27 Oct 2004 01:09:24 +0100 (BST) +Received: (qmail 16708 invoked from network); 27 Oct 2004 00:09:24 -0000 +Received: from pcp02680095pcs.nash01.tn.comcast.net (HELO ?192.168.0.114?) + (68.52.121.245) by 0 with SMTP; 27 Oct 2004 00:09:24 -0000 +In-Reply-To: <1098780555.6807.136.camel@localhost.localdomain> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <1098780555.6807.136.camel@localhost.localdomain> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <74778BDA-27AC-11D9-B369-000D93AE0944@sitening.com> +Content-Transfer-Encoding: 7bit +Cc: PgSQL - Performance +From: Thomas F.O'Connell +Subject: Re: [PATCHES] [HACKERS] ARC Memory Usage analysis +Date: Tue, 26 Oct 2004 19:09:22 -0500 +To: Simon Riggs +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/447 +X-Sequence-Number: 8923 + +Simon, + +As a postgres DBA, I find your comments about how not to use +effective_cache_size instructive, but I'm still not sure how I should +arrive at a target value for it. + +On most of the machines on which I admin postgres, I generally set +shared_buffers to 10,000 (using what seems to have been the recent +conventional wisdom of the lesser of 10,000 or 10% of RAM). I haven't +really settled on an optimal value for effective_cache_size, and now +I'm again confused as to how I might even benchmark it. + +Here are the documents on which I've based my knowledge: + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html#effcache +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html +http://www.ca.postgresql.org/docs/momjian/hw_performance/node8.html + + From Bruce's document, I gather that effective_cache_size would assume +that either shared buffers or unused RAM were valid sources of cached +pages for the purposes of assessing plans. + +As a result, I was intending to inflate the value of +effective_cache_size to closer to the amount of unused RAM on some of +the machines I admin (once I've verified that they all have a unified +buffer cache). Is that correct? + +-tfo + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-260-0005 + +On Oct 26, 2004, at 3:49 AM, Simon Riggs wrote: + +> On Mon, 2004-10-25 at 16:34, Jan Wieck wrote: +>> The problem is, with a too small directory ARC cannot guesstimate what +>> might be in the kernel buffers. Nor can it guesstimate what recently +>> was +>> in the kernel buffers and got pushed out from there. That results in a +>> way too small B1 list, and therefore we don't get B1 hits when in fact +>> the data was found in memory. B1 hits is what increases the T1target, +>> and since we are missing them with a too small directory size, our +>> implementation of ARC is propably using a T2 size larger than the +>> working set. That is not optimal. +> +> I think I have seen that the T1 list shrinks "too much", but need more +> tests...with some good test results +> +> The effectiveness of ARC relies upon the balance between the often +> conflicting requirements of "recency" and "frequency". It seems +> possible, even likely, that pgsql's version of ARC may need some subtle +> changes to rebalance it - if we are unlikely enough to find cases where +> it genuinely is out of balance. Many performance tests are required, +> together with a few ideas on extra parameters to include....hence my +> support of Jan's ideas. +> +> That's also why I called the B1+B2 hit ratio "turbulence" because it +> relates to how much oscillation is happening between T1 and T2. In +> physical systems, we expect the oscillations to be damped, but there is +> no guarantee that we have a nearly critically damped oscillator. (Note +> that the absence of turbulence doesn't imply that T1+T2 is optimally +> sized, just that is balanced). +> +> [...and all though the discussion has wandered away from my original +> patch...would anybody like to commit, or decline the patch?] +> +>> If we would replace the dynamic T1 buffers with a max_backends*2 area +>> of +>> shared buffers, use a C value representing the effective cache size +>> and +>> limit the T1target on the lower bound to effective cache size - shared +>> buffers, then we basically moved the T1 cache into the OS buffers. +> +> Limiting the minimum size of T1len to be 2* maxbackends sounds like an +> easy way to prevent overbalancing of T2, but I would like to follow up +> on ways to have T1 naturally stay larger. I'll do a patch with this +> idea +> in, for testing. I'll call this "T1 minimum size" so we can discuss it. +> +> Any other patches are welcome... +> +> It could be that B1 is too small and so we could use a larger value of +> C +> to keep track of more blocks. I think what is being suggested is two +> GUCs: shared_buffers (as is), plus another one, larger, which would +> allow us to track what is in shared_buffers and what is in OS cache. +> +> I have comments on "effective cache size" below.... +> +> On Mon, 2004-10-25 at 17:03, Tom Lane wrote: +>> Jan Wieck writes: +>>> This all only holds water, if the OS is allowed to swap out shared +>>> memory. And that was my initial question, how likely is it to find +>>> this +>>> to be true these days? +>> +>> I think it's more likely that not that the OS will consider shared +>> memory to be potentially swappable. On some platforms there is a +>> shmctl +>> call you can make to lock your shmem in memory, but (a) we don't use +>> it +>> and (b) it may well require privileges we haven't got anyway. +> +> Are you saying we shouldn't, or we don't yet? I simply assumed that we +> did use that function - surely it must be at least an option? RHEL +> supports this at least.... +> +> It may well be that we don't have those privileges, in which case we +> turn off the option. Often, we (or I?) will want to install a dedicated +> server, so we should have all the permissions we need, in which case... +> +>> This has always been one of the arguments against making +>> shared_buffers +>> really large, of course --- if the buffers aren't all heavily used, +>> and +>> the OS decides to swap them to disk, you are worse off than you would +>> have been with a smaller shared_buffers setting. +> +> Not really, just an argument against making them *too* large. Large +> *and* utilised is OK, so we need ways of judging optimal sizing. +> +>> However, I'm still really nervous about the idea of using +>> effective_cache_size to control the ARC algorithm. That number is +>> usually entirely bogus. Right now it is only a second-order influence +>> on certain planner estimates, and I am afraid to rely on it any more +>> heavily than that. +> +> ...ah yes, effective_cache_size. +> +> The manual describes effective_cache_size as if it had something to do +> with the OS, and some of this discussion has picked up on that. +> +> effective_cache_size is used in only two places in the code (both in +> the +> planner), as an estimate for calculating the cost of a) nonsequential +> access and b) index access, mainly as a way of avoiding overestimates +> of +> access costs for small tables. +> +> There is absolutely no implication in the code that +> effective_cache_size +> measures anything in the OS; what it gives is an estimate of the number +> of blocks that will be available from *somewhere* in memory (i.e. in +> shared_buffers OR OS cache) for one particular table (the one currently +> being considered by the planner). +> +> Crucially, the "size" referred to is the size of the *estimate*, not +> the +> size of the OS cache (nor the size of the OS cache + shared_buffers). +> So +> setting effective_cache_size = total memory available or setting +> effective_cache_size = total memory - shared_buffers are both wildly +> irrelevant things to do, or any assumption that directly links memory +> size to that parameter. So talking about "effective_cache_size" as if +> it +> were the OS cache isn't the right thing to do. +> +> ...It could be that we use a very high % of physical memory as +> shared_buffers - in which case the effective_cache_size would represent +> the contents of shared_buffers. +> +> Note also that the planner assumes that all tables are equally likely +> to +> be in cache. Increasing effective_cache_size in postgresql.conf seems +> destined to give the wrong answer in planning unless you absolutely +> understand what it does. +> +> I will submit a patch to correct the description in the manual. +> +> Further comments: +> The two estimates appear to use effective_cache_size differently: +> a) assumes that a table of size effective_cache_size will be 50% in +> cache +> b) assumes that effective_cache_size blocks are available, so for a +> table of size == effective_cache_size, then it will be 100% available +> +> IMHO the GUC should be renamed "estimated_cached_blocks", with the old +> name deprecated to force people to re-read the manual description of +> what effective_cache_size means and then set accordingly.....all of +> that +> in 8.0.... +> +> -- +> Best Regards, Simon Riggs +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to +> majordomo@postgresql.org) + + +From pgsql-hackers-owner@postgresql.org Wed Oct 27 01:37:53 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9AB353A4521; + Wed, 27 Oct 2004 01:37:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05354-10; Wed, 27 Oct 2004 00:37:47 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id EA2653A4523; + Wed, 27 Oct 2004 01:37:49 +0100 (BST) +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 6560124; Tue, 26 Oct 2004 17:39:16 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] [PATCHES] ARC Memory Usage analysis +Date: Tue, 26 Oct 2004 17:39:59 -0700 +User-Agent: KMail/1.6.2 +Cc: Thomas F.O'Connell , + Simon Riggs , + PgSQL - Performance +References: <1098471059.20926.49.camel@localhost.localdomain> + <1098780555.6807.136.camel@localhost.localdomain> + <74778BDA-27AC-11D9-B369-000D93AE0944@sitening.com> +In-Reply-To: <74778BDA-27AC-11D9-B369-000D93AE0944@sitening.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410261739.59814.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/917 +X-Sequence-Number: 60420 + +Thomas, + +> As a result, I was intending to inflate the value of +> effective_cache_size to closer to the amount of unused RAM on some of +> the machines I admin (once I've verified that they all have a unified +> buffer cache). Is that correct? + +Currently, yes. Right now, e_c_s is used just to inform the planner and make +index vs. table scan and join order decisions. + +The problem which Simon is bringing up is part of a discussion about doing +*more* with the information supplied by e_c_s. He points out that it's not +really related to the *real* probability of any particular table being +cached. At least, if I'm reading him right. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Oct 27 01:40:53 2004 +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 60ED93A4514 + for ; + Wed, 27 Oct 2004 01:40:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09554-03 + for ; + Wed, 27 Oct 2004 00:40:39 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B8753A44FD + for ; + Wed, 27 Oct 2004 01:40:42 +0100 (BST) +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 6560143; Tue, 26 Oct 2004 17:42:09 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: can't handle large number of INSERT/UPDATEs +Date: Tue, 26 Oct 2004 17:42:53 -0700 +User-Agent: KMail/1.6.2 +Cc: "Anjan Dave" , "Tom Lane" , + "Rod Taylor" +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DF@vt-pe2550-001.vantage.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985DF@vt-pe2550-001.vantage.vantage.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200410261742.53345.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/449 +X-Sequence-Number: 8925 + +Anjan, + +> Oct 26 17:26:25 vl-pe6650-003 postgres[14273]: [4-1] LOG: =A0recycled +> transaction +> log file "0000000B00000082" +> ... +> Oct 26 17:31:27 vl-pe6650-003 postgres[14508]: [2-1] LOG: =A0recycled +> transaction +> log file "0000000B00000083" +> Oct 26 17:31:27 vl-pe6650-003 postgres[14508]: [3-1] LOG: =A0recycled +> transaction +> log file "0000000B00000084" +> Oct 26 17:31:27 vl-pe6650-003 postgres[14508]: [4-1] LOG: =A0recycled +> transaction +> log file "0000000B00000085" + +Looks like you're running out of disk space for pending transactions. Can = +you=20 +afford more checkpoint_segments? Have you considered checkpoint_siblings? + +--=20 +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-hackers-owner@postgresql.org Wed Oct 27 02:32:30 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AAF93A4534 + for ; + Wed, 27 Oct 2004 02:32:27 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26646-01 + for ; + Wed, 27 Oct 2004 01:32:15 +0000 (GMT) +Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) + by svr1.postgresql.org (Postfix) with ESMTP id 73E753A4533 + for ; + Wed, 27 Oct 2004 02:32:17 +0100 (BST) +Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net + [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP + id E7ABAC125; Wed, 27 Oct 2004 10:32:15 +0900 (JST) +Received: from localhost (localhost [127.0.0.1]) + by angelic.cynic.net (Postfix) with ESMTP + id C7FAA8736; Wed, 27 Oct 2004 10:32:13 +0900 (JST) +Date: Wed, 27 Oct 2004 10:32:13 +0900 (JST) +From: Curt Sampson +X-X-Sender: cjs@angelic-vtfw.cvpn.cynic.net +To: Greg Stark +Cc: pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +In-Reply-To: <87r7nlts34.fsf@stark.xeocode.com> +Message-ID: +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> <87hdoiv62b.fsf@stark.xeocode.com> + <790.1098741205@sss.pgh.pa.us> <878y9uukgb.fsf@stark.xeocode.com> + + <87r7nlts34.fsf@stark.xeocode.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/919 +X-Sequence-Number: 60422 + +On Wed, 26 Oct 2004, Greg Stark wrote: + +> > I don't see why mmap is any more out of reach than O_DIRECT; it's not +> > all that much harder to implement, and mmap (and madvise!) is more +> > widely available. +> +> Because there's no way to prevent a write-out from occurring and no way to be +> notified by mmap before a write-out occurs, and Postgres wants to do its WAL +> logging at that time if it hasn't already happened. + +I already described a solution to that problem in a post earlier in this +thread (a write queue on the block). I may even have described it on +this list a couple of years ago, that being about the time I thought +it up. (The mmap idea just won't die, but at least I wasn't the one to +bring it up this time. :-)) + +> Well firstly it depends on the work profile. It can probably get much higher +> than we saw in that profile.... + +True, but 1% was is much, much lower than I'd expected. That tells me +that my intuitive idea of the performance model is wrong, which means, +for me at least, it's time to shut up or put up some benchmarks. + +> Secondly it also reduces the amount of cache available. If you have 256M of +> ram with about 200M free, and 40Mb of ram set aside for Postgres's buffer +> cache then you really only get 160Mb. It's costing you 20% of your cache, and +> reducing the cache hit rate accordingly. + +Yeah, no question about that. + +> Thirdly the kernel doesn't know as much as Postgres about the load. Postgres +> could optimize its use of cache based on whether it knows the data is being +> loaded by a vacuum or sequential scan rather than an index lookup. In practice +> Postgres has gone with ARC which I suppose a kernel could implement anyways, +> but afaik neither linux nor BSD choose to do anything like it. + +madvise(). + +cjs +-- +Curt Sampson +81 90 7737 2974 http://www.NetBSD.org + Make up enjoying your city life...produced by BIC CAMERA + +From pgsql-hackers-owner@postgresql.org Wed Oct 27 03:28:18 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D20BA3A3BF4 + for ; + Wed, 27 Oct 2004 03:28:16 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41904-03 + for ; + Wed, 27 Oct 2004 02:28:11 +0000 (GMT) +Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net + [63.231.195.112]) + by svr1.postgresql.org (Postfix) with SMTP id 498FD3A3BE5 + for ; + Wed, 27 Oct 2004 03:28:15 +0100 (BST) +Received: (qmail 83001 invoked by uid 0); 27 Oct 2004 02:28:16 -0000 +Received: from unknown (63.231.195.9) + by mpls-qmqp-01.inet.qwest.net with QMQP; 27 Oct 2004 02:28:16 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-09.inet.qwest.net with SMTP; 27 Oct 2004 02:28:15 -0000 +Date: Tue, 26 Oct 2004 20:30:34 -0600 +Message-Id: <1098844234.31930.45.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Tom Lane" +Cc: "Greg Stark" , pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +In-Reply-To: <4887.1098770035@sss.pgh.pa.us> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> <87hdoiv62b.fsf@stark.xeocode.com> + <790.1098741205@sss.pgh.pa.us> <878y9uukgb.fsf@stark.xeocode.com> + <4887.1098770035@sss.pgh.pa.us> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/921 +X-Sequence-Number: 60424 + +On Mon, 2004-10-25 at 23:53, Tom Lane wrote: +> Greg Stark writes: +> > Tom Lane writes: +> >> Another issue is what we do with the effective_cache_size value once we +> >> have a number we trust. We can't readily change the size of the ARC +> >> lists on the fly. +> +> > Huh? I thought effective_cache_size was just used as an factor the cost +> > estimation equation. +> +> Today, that is true. Jan is speculating about using it as a parameter +> of the ARC cache management algorithm ... and that worries me. + +Because it's so often set wrong I take it. But if it's set right, and +it makes the the database faster to pay attention to it, then I'd be in +favor of it. Or at least having a switch to turn on the ARC buffer's +ability to look at it. + +Or is it some other issue, having to do with the idea of knowing +effective cache size cause a positive effect overall on the ARC +algorhythm? + + +From pgsql-performance-owner@postgresql.org Wed Oct 27 04:13:33 2004 +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 AE2843A450B + for ; + Wed, 27 Oct 2004 04:12:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54129-09 + for ; + Wed, 27 Oct 2004 03:12:23 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com + [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id E4F533A3BA3 + for ; + Wed, 27 Oct 2004 04:12:21 +0100 (BST) +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: can't handle large number of INSERT/UPDATEs +Date: Tue, 26 Oct 2004 23:12:20 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985E5@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] can't handle large number of INSERT/UPDATEs +Thread-Index: AcS7vZgKuirAFby8QOm+KwPcNK4glgACydNC +From: "Anjan Dave" +To: , +Cc: "Tom Lane" , "Rod Taylor" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/450 +X-Sequence-Number: 8926 + +Sm9zaCwNCiANCkkgaGF2ZSBpbmNyZWFzZWQgdGhlbSB0byAzMCwgd2lsbCBz +ZWUgaWYgdGhhdCBoZWxwcy4gU3BhY2UgaXMgbm90IGEgY29uY2Vybi4gc2xp +Z2h0bHkgbG9uZ2VyIHJlY292ZXJ5IHRpbWUgY291bGQgYmUgZmluZSB0b28u +IFdvbmRlciB3aGF0IHBlb3BsZSB1c2UgKGV4YW1wbGVzKSBmb3IgdGhpcyB2 +YWx1ZSBmb3IgaGlnaCB2b2x1bWUgZGF0YWJhc2VzIChleGNlcHQgZm9yIGR1 +bXAvcmVzdG9yZSkuLi4/DQogDQpJIGRvbid0IGtub3cgd2hhdCBpcyBjaGVj +a3BvaW50X3NpYmxpbmcuIEknbGwgcmVhZCBhYm91dCBpdCBpZiB0aGVyZSdz +IHNvbWUgaW5mbyBvbiBpdCBzb21ld2hlcmUuDQogDQpUaGFua3MsDQpBbmph +bg0KIA0KLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0gDQpGcm9tOiBKb3No +IEJlcmt1cyBbbWFpbHRvOmpvc2hAYWdsaW9kYnMuY29tXSANClNlbnQ6IFR1 +ZSAxMC8yNi8yMDA0IDg6NDIgUE0gDQpUbzogcGdzcWwtcGVyZm9ybWFuY2VA +cG9zdGdyZXNxbC5vcmcgDQpDYzogQW5qYW4gRGF2ZTsgVG9tIExhbmU7IFJv +ZCBUYXlsb3IgDQpTdWJqZWN0OiBSZTogW1BFUkZPUk1dIGNhbid0IGhhbmRs +ZSBsYXJnZSBudW1iZXIgb2YgSU5TRVJUL1VQREFURXMNCg0KDQoNCglBbmph +biwgDQoNCgk+IE9jdCAyNiAxNzoyNjoyNSB2bC1wZTY2NTAtMDAzIHBvc3Rn +cmVzWzE0MjczXTogWzQtMV0gTE9HOiAgcmVjeWNsZWQgDQoJPiB0cmFuc2Fj +dGlvbiANCgk+IGxvZyBmaWxlICIwMDAwMDAwQjAwMDAwMDgyIiANCgk+IC4u +LiANCgk+IE9jdCAyNiAxNzozMToyNyB2bC1wZTY2NTAtMDAzIHBvc3RncmVz +WzE0NTA4XTogWzItMV0gTE9HOiAgcmVjeWNsZWQgDQoJPiB0cmFuc2FjdGlv +biANCgk+IGxvZyBmaWxlICIwMDAwMDAwQjAwMDAwMDgzIiANCgk+IE9jdCAy +NiAxNzozMToyNyB2bC1wZTY2NTAtMDAzIHBvc3RncmVzWzE0NTA4XTogWzMt +MV0gTE9HOiAgcmVjeWNsZWQgDQoJPiB0cmFuc2FjdGlvbiANCgk+IGxvZyBm +aWxlICIwMDAwMDAwQjAwMDAwMDg0IiANCgk+IE9jdCAyNiAxNzozMToyNyB2 +bC1wZTY2NTAtMDAzIHBvc3RncmVzWzE0NTA4XTogWzQtMV0gTE9HOiAgcmVj +eWNsZWQgDQoJPiB0cmFuc2FjdGlvbiANCgk+IGxvZyBmaWxlICIwMDAwMDAw +QjAwMDAwMDg1IiANCg0KCUxvb2tzIGxpa2UgeW91J3JlIHJ1bm5pbmcgb3V0 +IG9mIGRpc2sgc3BhY2UgZm9yIHBlbmRpbmcgdHJhbnNhY3Rpb25zLiAgQ2Fu +IHlvdSANCglhZmZvcmQgbW9yZSBjaGVja3BvaW50X3NlZ21lbnRzPyAgIEhh +dmUgeW91IGNvbnNpZGVyZWQgY2hlY2twb2ludF9zaWJsaW5ncz8gDQoNCgkt +LSANCgktLUpvc2ggDQoNCglKb3NoIEJlcmt1cyANCglBZ2xpbyBEYXRhYmFz +ZSBTb2x1dGlvbnMgDQoJU2FuIEZyYW5jaXNjbyANCg0K + +From pgsql-performance-owner@postgresql.org Wed Oct 27 04:21:56 2004 +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 A14BD3A3D49 + for ; + Wed, 27 Oct 2004 04:21:38 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55937-10 + for ; + Wed, 27 Oct 2004 03:21: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 570293A3BA3 + for ; + Wed, 27 Oct 2004 04:21:32 +0100 (BST) +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 i9R3LVs4015813; + Tue, 26 Oct 2004 23:21:31 -0400 (EDT) +To: Curtis Zinzilieta +Cc: Anjan Dave , Matt Clark , + Rod Taylor , + Postgresql Performance +Subject: Re: can't handle large number of INSERT/UPDATEs +In-reply-to: + +References: + +Comments: In-reply-to Curtis Zinzilieta + message dated "Tue, 26 Oct 2004 16:04:35 -0700" +Date: Tue, 26 Oct 2004 23:21:31 -0400 +Message-ID: <15812.1098847291@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/451 +X-Sequence-Number: 8927 + +Curtis Zinzilieta writes: +> On Tue, 26 Oct 2004, Tom Lane wrote: +>> Er ... it *is* the other way around. bi is blocks in (to the CPU), +>> bo is blocks out (from the CPU). + +> Ummm..... +> [curtisz@labsoft T2]$ man vmstat +> bi: Blocks sent to a block device (blocks/s). +> bo: Blocks received from a block device (blocks/s). + +You might want to have a word with your OS vendor. My vmstat +man page says + + IO + bi: Blocks received from a block device (blocks/s). + bo: Blocks sent to a block device (blocks/s). + +and certainly anyone who's been around a computer more than a week or +two knows which direction "in" and "out" are customarily seen from. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Oct 27 05:18:35 2004 +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 40D683A458E + for ; + Wed, 27 Oct 2004 05:18:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74517-07 + for ; + Wed, 27 Oct 2004 04:18:25 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id CA89A3A4583 + for ; + Wed, 27 Oct 2004 05:18:24 +0100 (BST) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id i9R4IF324293; + Tue, 26 Oct 2004 23:18:15 -0500 +Message-ID: <417F2181.4000801@johnmeinel.com> +Date: Tue, 26 Oct 2004 23:18:09 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Curtis Zinzilieta , + Anjan Dave , Matt Clark , + Rod Taylor , + Postgresql Performance +Subject: Re: can't handle large number of INSERT/UPDATEs +References: + + <15812.1098847291@sss.pgh.pa.us> +In-Reply-To: <15812.1098847291@sss.pgh.pa.us> +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig8A306CDFFF6456D3531A6069" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/452 +X-Sequence-Number: 8928 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig8A306CDFFF6456D3531A6069 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: +> Curtis Zinzilieta writes: +> +>>On Tue, 26 Oct 2004, Tom Lane wrote: +>> +>>>Er ... it *is* the other way around. bi is blocks in (to the CPU), +>>>bo is blocks out (from the CPU). +> +> +>>Ummm..... +>>[curtisz@labsoft T2]$ man vmstat +>> bi: Blocks sent to a block device (blocks/s). +>> bo: Blocks received from a block device (blocks/s). +> +> +> You might want to have a word with your OS vendor. My vmstat +> man page says +> +> IO +> bi: Blocks received from a block device (blocks/s). +> bo: Blocks sent to a block device (blocks/s). +> +> and certainly anyone who's been around a computer more than a week or +> two knows which direction "in" and "out" are customarily seen from. +> +> regards, tom lane +> + +Interesting. I checked this on several machines. They actually say +different things. + +Redhat 9- bi: Blocks sent to a block device (blocks/s). +Latest Cygwin- bi: Blocks sent to a block device (blocks/s). +Redhat 7.x- bi: Blocks sent to a block device (blocks/s). +Redhat AS3- bi: blocks sent out to a block device (in blocks/s) + +I would say that I probably agree, things should be relative to the cpu. +However, it doesn't seem to be something that was universally agreed +upon. Or maybe the man-pages were all wrong, and only got updated recently. + +John +=:-> + + + +--------------enig8A306CDFFF6456D3531A6069 +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBfyGBJdeBCYSNAAMRAvI1AJ4i1AzY5iwlsQXVpUy6oUw1+jd/kACguWgx +67UY50j8yjXcHoSo6vdXGrE= +=VNsc +-----END PGP SIGNATURE----- + +--------------enig8A306CDFFF6456D3531A6069-- + +From pgsql-performance-owner@postgresql.org Wed Oct 27 06:03:17 2004 +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 46AB43A4593 + for ; + Wed, 27 Oct 2004 06:03:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84634-09 + for ; + Wed, 27 Oct 2004 05:03:02 +0000 (GMT) +Received: from millenium.mst.co.jp (unknown [210.230.185.241]) + by svr1.postgresql.org (Postfix) with ESMTP id 21BC33A458D + for ; + Wed, 27 Oct 2004 06:03:01 +0100 (BST) +Received: from mst1x5r347kymb (lc12114 [192.168.1.114]) + by millenium.mst.co.jp (8.11.6p2/3.7W) with SMTP id i9R52Pq30474; + Wed, 27 Oct 2004 14:02:25 +0900 +Message-ID: <003a01c4bbe2$36ffe700$7201a8c0@mst1x5r347kymb> +From: "Iain" +To: "Curtis Zinzilieta" , + "Tom Lane" +Cc: "Anjan Dave" , "Matt Clark" , + "Rod Taylor" , + "Postgresql Performance" +References: + + <15812.1098847291@sss.pgh.pa.us> +Subject: Re: can't handle large number of INSERT/UPDATEs +Date: Wed, 27 Oct 2004 14:02:48 +0900 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-2022-jp"; + 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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/453 +X-Sequence-Number: 8929 + +Turbo linux 7 sems to be agreeing with Curtis, + +bi: $B%V%m%C%/%G%P%$%9$KAw$i$l$?%V%m%C%/(B (blocks/s)$B!#(B +bo: $B%V%m%C%/%G%P%$%9$+$i +To: "Curtis Zinzilieta" +Cc: "Anjan Dave" ; "Matt Clark" ; "Rod +Taylor" ; "Postgresql Performance" + +Sent: Wednesday, October 27, 2004 12:21 PM +Subject: Re: [PERFORM] can't handle large number of INSERT/UPDATEs + + +> Curtis Zinzilieta writes: +>> On Tue, 26 Oct 2004, Tom Lane wrote: +>>> Er ... it *is* the other way around. bi is blocks in (to the CPU), +>>> bo is blocks out (from the CPU). +> +>> Ummm..... +>> [curtisz@labsoft T2]$ man vmstat +>> bi: Blocks sent to a block device (blocks/s). +>> bo: Blocks received from a block device (blocks/s). +> +> You might want to have a word with your OS vendor. My vmstat +> man page says +> +> IO +> bi: Blocks received from a block device (blocks/s). +> bo: Blocks sent to a block device (blocks/s). +> +> and certainly anyone who's been around a computer more than a week or +> two knows which direction "in" and "out" are customarily seen from. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Wed Oct 27 07:09:58 2004 +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 994193A3CED + for ; + Wed, 27 Oct 2004 07:09:49 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02209-09 + for ; + Wed, 27 Oct 2004 06:09:39 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 921283A3AE6 + for ; + Wed, 27 Oct 2004 07:09:39 +0100 (BST) +Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk + [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP + id CE6C5A387F; Wed, 27 Oct 2004 07:09:37 +0100 (BST) +Message-ID: <417F3B91.9080002@ymogen.net> +Date: Wed, 27 Oct 2004 07:09:21 +0100 +From: Matt Clark +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John Meinel +Cc: Tom Lane , Curtis Zinzilieta , + Anjan Dave , Rod Taylor , + Postgresql Performance +Subject: Re: can't handle large number of INSERT/UPDATEs +References: + + <15812.1098847291@sss.pgh.pa.us> <417F2181.4000801@johnmeinel.com> +In-Reply-To: <417F2181.4000801@johnmeinel.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/454 +X-Sequence-Number: 8930 + + +>> and certainly anyone who's been around a computer more than a week or +>> two knows which direction "in" and "out" are customarily seen from. +>> +>> regards, tom lane +>> +> +Apparently not whoever wrote the man page that everyone copied ;-) + +> Interesting. I checked this on several machines. They actually say +> different things. +> +> Redhat 9- bi: Blocks sent to a block device (blocks/s). +> Latest Cygwin- bi: Blocks sent to a block device (blocks/s). +> Redhat 7.x- bi: Blocks sent to a block device (blocks/s). +> Redhat AS3- bi: blocks sent out to a block device (in blocks/s) +> +> I would say that I probably agree, things should be relative to the +> cpu. However, it doesn't seem to be something that was universally +> agreed upon. Or maybe the man-pages were all wrong, and only got +> updated recently. +> +Looks like the man pages are wrong, for RH7.3 at least. It says bi is +'blocks written', but an actual test like 'dd if=/dev/zero of=/tmp/test +bs=1024 count=16384' on an otherwise nearly idle RH7.3 box gives: + procs memory swap io +system cpu + r b w swpd free buff cache si so bi bo in cs us +sy id +0 0 0 75936 474704 230452 953580 0 0 0 0 106 2527 0 +0 99 + 0 0 0 75936 474704 230452 953580 0 0 0 16512 376 2572 +0 2 98 + 0 0 0 75936 474704 230452 953580 0 0 0 0 105 2537 +0 0 100 + +Which is in line with bo being 'blocks written'. + +M + +From pgsql-performance-owner@postgresql.org Sun Oct 31 05:42:58 2004 +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 45CC93A44E5 + for ; + Wed, 27 Oct 2004 02:08:26 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16559-06 + for ; + Wed, 27 Oct 2004 01:08:12 +0000 (GMT) +Received: from ciar.org (45-97-229-216.sr2.pon.net [216.229.97.45]) + by svr1.postgresql.org (Postfix) with SMTP id 201B13A4534 + for ; + Wed, 27 Oct 2004 02:08:14 +0100 (BST) +Received: (qmail 8829 invoked from network); 27 Oct 2004 07:57:49 -0000 +Received: from localhost (HELO hardpoint.hardpointi.com) (1004@127.0.0.1) + by localhost with SMTP; 27 Oct 2004 07:57:49 -0000 +Received: (from ttk2@localhost) + by hardpoint.hardpointi.com (8.12.10/8.12.10/Submit) id i9R7vmKE008825 + for pgsql-performance@postgresql.org; Wed, 27 Oct 2004 00:57:48 -0700 +Date: Wed, 27 Oct 2004 00:57:48 -0700 +From: TTK Ciar +To: pgsql-performance@postgresql.org +Subject: psql large RSS (1.6GB) +Message-ID: <20041027075748.GA8355@hardpoint.ciar.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/473 +X-Sequence-Number: 8949 + +Hello! + + My name is TTK, and I'm a software engineer at the Internet Archive's +Data Repository department. We have recently started using postgresql +for a couple of projects (we have historically been a MySQL outfit), +and today my co-worker noticed psql eating memory like mad when invoked +with a simple select statement incorporating a join of two tables. + + The platform is a heavily modified RedHat 7.3 Linux. We are using +version 7.4.5 of postgresql. + + The invocation was via sh script: + +#!/bin/bash + +outfile=$1 +if [ -z "$outfile" ]; then + outfile=/0/brad/all_arcs.txt +fi + +/usr/lib/postgresql/bin/psql -c 'select ServerDisks.servername,ServerDisks.diskserial,ServerDisks.diskmountpoint,DiskFiles.name,DiskFiles.md5 from DiskFiles,ServerDisks where DiskFiles.diskserial=ServerDisks.diskserial;' -F ' ' -A -t -o $outfile + +.. and the tables in question are somewhat large (hundreds of GB's +of data), though we didn't expect that to be an issue as far as the +psql process was concerned. + + We monitored server load via 'top -i -d 0.5' and watched the output +file for data. Over the course of about 200 seconds, psql's RSS +climbed to about 1.6 GB, and stayed there, while no data was written +to the output file. Eventually 10133194 lines were written to the +output file, all at once, about 1.2GB's worth of data. + + I re-ran the select query using psql in interactive mode, and saw +the same results. + + I re-ran it again, using "explain analyse", and this time psql's +RSS did *not* increase significantly. The result is here, if it +helps: + +brad=# explain analyse select ServerDisks.servername,ServerDisks.diskserial,ServerDisks.diskmountpoint,DiskFiles.name,DiskFiles.md5 from DiskFiles,ServerDisks where DiskFiles.diskserial=ServerDisks.diskserial; + QUERY PLAN +------------------------------------------------------------------ + Hash Join (cost=22.50..65.00 rows=1000 width=274) (actual time=118.584..124653.729 rows=10133349 loops=1) + Hash Cond: (("outer".diskserial)::text = ("inner".diskserial)::text) + -> Seq Scan on diskfiles (cost=0.00..20.00 rows=1000 width=198) (actual time=7.201..31336.063 rows=10133349 loops=1) + -> Hash (cost=20.00..20.00 rows=1000 width=158) (actual time=90.821..90.821 rows=0 loops=1) + -> Seq Scan on serverdisks (cost=0.00..20.00 rows=1000 width=158) (actual time=9.985..87.364 rows=2280 loops=1) + Total runtime: 130944.586 ms + + At a guess, it looks like the data set is being buffered in its +entirety by psql, before any data is written to the output file, +which is surprising. I would have expected it to grab data as it +appeared on the socket from postmaster and write it to disk. Is +there something we can do to stop psql from buffering results? +Does anyone know what's going on here? + + If the solution is to just write a little client that uses perl +DBI to fetch rows one at a time and write them out, that's doable, +but it would be nice if psql could be made to "just work" without +the monster RSS. + + I'd appreciate any feedback. If you need any additional info, +please let me know and I will provide it. + + -- TTK + ttk2@ciar.org + ttk@archive.org + + +From pgsql-performance-owner@postgresql.org Wed Oct 27 12:24:03 2004 +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 1085F3A3B3E + for ; + Wed, 27 Oct 2004 12:23:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01371-04 + for ; + Wed, 27 Oct 2004 11:23:50 +0000 (GMT) +Received: from druid.net (druid.net [216.126.72.98]) + by svr1.postgresql.org (Postfix) with ESMTP id 2AB1A3A3B2D + for ; + Wed, 27 Oct 2004 12:23:52 +0100 (BST) +Received: from imp.druid.net (imp [216.126.72.111]) + by druid.net (Postfix) with SMTP id D8C041A93; + Wed, 27 Oct 2004 07:23:54 -0400 (EDT) +Date: Wed, 27 Oct 2004 07:23:46 -0400 +From: "D'Arcy J.M. Cain" +To: Aaron Mulder +Cc: pgsql-performance@postgresql.org +Subject: Re: Free PostgreSQL Training, Philadelphia, Oct 30 +Message-Id: <20041027072346.6e9cd42a.darcy@druid.net> +In-Reply-To: +References: +X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; i386--netbsdelf) +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/455 +X-Sequence-Number: 8931 + +On Wed, 13 Oct 2004 12:21:27 -0400 (EDT) +Aaron Mulder wrote: +> All, +> My company (Chariot Solutions) is sponsoring a day of free +> PostgreSQL training by Bruce Momjian (one of the core PostgreSQL +> developers). The day is split into 2 sessions (plus a Q&A session): + +Is there anyone else from the Toronto area going down that would like to +share the driving? I am planning to drive down Friday morning and drive +back Sunday. I'm not looking for expense sharing. I just don't want to +drive for eight hours straight. + +-- +D'Arcy J.M. Cain | Democracy is three wolves +http://www.druid.net/darcy/ | and a sheep voting on ++1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. + +From pgsql-performance-owner@postgresql.org Wed Oct 27 18:16:29 2004 +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 2D72A3A46C2 + for ; + Wed, 27 Oct 2004 18:16:25 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40394-07 + for ; + Wed, 27 Oct 2004 17:16:22 +0000 (GMT) +Received: from web50006.mail.yahoo.com (web50006.mail.yahoo.com + [206.190.38.21]) + by svr1.postgresql.org (Postfix) with SMTP id 832023A4696 + for ; + Wed, 27 Oct 2004 18:16:21 +0100 (BST) +Message-ID: <20041027171621.60824.qmail@web50006.mail.yahoo.com> +Received: from [69.65.137.210] by web50006.mail.yahoo.com via HTTP; + Wed, 27 Oct 2004 12:16:21 CDT +Date: Wed, 27 Oct 2004 12:16:21 -0500 (CDT) +From: Jaime Casanova +Subject: Re: Sequential Scan with LIMIT +To: pgsql-performance@postgresql.org +In-Reply-To: <417ECDEF.8030108@johnmeinel.com> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/456 +X-Sequence-Number: 8932 + + --- John Meinel escribi�: +> Jaime Casanova wrote: +> [...] +> >> +> >>I'm not sure. They all return the same +> information. +> > +> > +> > of course, both queries will return the same but +> > that's just because you forced it. +> > +> > LIMIT and DISTINCT are different things so they +> behave +> > and are plenned different. +> > +> > +> > +> >>What's also weird is stuff like: +> >>SELECT DISTINCT(NULL) FROM mytable WHERE col = +> >>'myval' LIMIT 1; +> > +> > +> > why do you want to do such a thing? +> > +> > regards, +> > Jaime Casanova +> > +> +> I was trying to see if selecting a constant would +> change things. +> I could have done SELECT DISTINCT(1) or just SELECT +> 1 FROM ... +> The idea of the query is that if 'myval' exists in +> the table, return +> something different than if 'myval' does not exist. +> If you are writing a +> function, you can use: +> +> SELECT something... +> IF FOUND THEN +> do a +> ELSE +> do b +> END IF; +> +> The whole point of this exercise was just to find +> what the cheapest +> query is when you want to test for the existence of +> a value in a column. +> The only thing I've found for my column is: +> +> SET enable_seq_scan TO off; +> SELECT col FROM mytable WHERE col = 'myval' LIMIT 1; +> SET enable_seq_scan TO on; +> +> My column is not distributed well (larger numbers +> occur later in the +> dataset, but may occur many times.) In total there +> are something like +> 500,000 rows, the number 555647 occurs 100,000 +> times, but not until row +> 300,000 or so. +> +> The analyzer looks at the data and says "1/5th of +> the time it is 555647, +> so I can just do a sequential scan as the odds are I +> don't have to look +> for very long, then I don't have to load the index". +> It turns out this +> is very bad, where with an index you just have to do +> 2 page loads, +> instead of reading 300,000 rows. +> +> Obviously this isn't a general-case solution. But if +> you have a +> situation similar to mine, it might be useful. +> +> (That's one thing with DB tuning. It seems to be +> very situation +> dependent, and it's hard to plan without a real +> dataset.) +> +> John +> =:-> +> + +In http://www.postgresql.org/docs/faqs/FAQ.html under +"4.8) My queries are slow or don't make use of the +indexes. Why?" says: + +"However, LIMIT combined with ORDER BY often will use +an index because only a small portion of the table is +returned. In fact, though MAX() and MIN() don't use +indexes, it is possible to retrieve such values using +an index with ORDER BY and LIMIT: + SELECT col + FROM tab + ORDER BY col [ DESC ] + LIMIT 1;" + +So, maybe you can try your query as + +SELECT col FROM mytable +WHERE col = 'myval' +ORDER BY col +LIMIT 1; + +regards, +Jaime Casanova + + +_________________________________________________________ +Do You Yahoo!? +Informaci�n de Estados Unidos y Am�rica Latina, en Yahoo! Noticias. +Vis�tanos en http://noticias.espanol.yahoo.com + +From pgsql-hackers-owner@postgresql.org Wed Oct 27 22:35:06 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D80153A4760; + Wed, 27 Oct 2004 22:35:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14404-03; Wed, 27 Oct 2004 21:34:52 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 4345F3A3C1E; + Wed, 27 Oct 2004 22:34:53 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9RLYMM10488; + Wed, 27 Oct 2004 14:34:22 -0700 +Date: Wed, 27 Oct 2004 14:34:22 -0700 +From: Mark Wong +To: Jan Wieck +Cc: Kenneth Marshall , + Simon Riggs , pgsql-patches@postgresql.org, + pgsql-hackers@postgresql.org, josh@agliodbs.com +Subject: Re: ARC Memory Usage analysis +Message-ID: <20041027143422.A6199@osdl.org> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +In-Reply-To: <417D1D01.3090401@Yahoo.com>; + from JanWieck@Yahoo.com on Mon, Oct 25, 2004 at 11:34:25AM -0400 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/955 +X-Sequence-Number: 60458 + +On Mon, Oct 25, 2004 at 11:34:25AM -0400, Jan Wieck wrote: +> On 10/22/2004 4:09 PM, Kenneth Marshall wrote: +> +> > On Fri, Oct 22, 2004 at 03:35:49PM -0400, Jan Wieck wrote: +> >> On 10/22/2004 2:50 PM, Simon Riggs wrote: +> >> +> >> >I've been using the ARC debug options to analyse memory usage on the +> >> >PostgreSQL 8.0 server. This is a precursor to more complex performance +> >> >analysis work on the OSDL test suite. +> >> > +> >> >I've simplified some of the ARC reporting into a single log line, which +> >> >is enclosed here as a patch on freelist.c. This includes reporting of: +> >> >- the total memory in use, which wasn't previously reported +> >> >- the cache hit ratio, which was slightly incorrectly calculated +> >> >- a useful-ish value for looking at the "B" lists in ARC +> >> >(This is a patch against cvstip, but I'm not sure whether this has +> >> >potential for inclusion in 8.0...) +> >> > +> >> >The total memory in use is useful because it allows you to tell whether +> >> >shared_buffers is set too high. If it is set too high, then memory usage +> >> >will continue to grow slowly up to the max, without any corresponding +> >> >increase in cache hit ratio. If shared_buffers is too small, then memory +> >> >usage will climb quickly and linearly to its maximum. +> >> > +> >> >The last one I've called "turbulence" in an attempt to ascribe some +> >> >useful meaning to B1/B2 hits - I've tried a few other measures though +> >> >without much success. Turbulence is the hit ratio of B1+B2 lists added +> >> >together. By observation, this is zero when ARC gives smooth operation, +> >> >and goes above zero otherwise. Typically, turbulence occurs when +> >> >shared_buffers is too small for the working set of the database/workload +> >> >combination and ARC repeatedly re-balances the lengths of T1/T2 as a +> >> >result of "near-misses" on the B1/B2 lists. Turbulence doesn't usually +> >> >cut in until the cache is fully utilized, so there is usually some delay +> >> >after startup. +> >> > +> >> >We also recently discussed that I would add some further memory analysis +> >> >features for 8.1, so I've been trying to figure out how. +> >> > +> >> >The idea that B1, B2 represent something really useful doesn't seem to +> >> >have been borne out - though I'm open to persuasion there. +> >> > +> >> >I originally envisaged a "shadow list" operating in extension of the +> >> >main ARC list. This will require some re-coding, since the variables and +> >> >macros are all hard-coded to a single set of lists. No complaints, just +> >> >it will take a little longer than we all thought (for me, that is...) +> >> > +> >> >My proposal is to alter the code to allow an array of memory linked +> >> >lists. The actual list would be [0] - other additional lists would be +> >> >created dynamically as required i.e. not using IFDEFs, since I want this +> >> >to be controlled by a SIGHUP GUC to allow on-site tuning, not just lab +> >> >work. This will then allow reporting against the additional lists, so +> >> >that cache hit ratios can be seen with various other "prototype" +> >> >shared_buffer settings. +> >> +> >> All the existing lists live in shared memory, so that dynamic approach +> >> suffers from the fact that the memory has to be allocated during ipc_init. +> >> +> >> What do you think about my other theory to make C actually 2x effective +> >> cache size and NOT to keep T1 in shared buffers but to assume T1 lives +> >> in the OS buffer cache? +> >> +> >> +> >> Jan +> >> +> > Jan, +> > +> >>From the articles that I have seen on the ARC algorithm, I do not think +> > that using the effective cache size to set C would be a win. The design +> > of the ARC process is to allow the cache to optimize its use in response +> > to the actual workload. It may be the best use of the cache in some cases +> > to have the entire cache allocated to T1 and similarly for T2. If fact, +> > the ability to alter the behavior as needed is one of the key advantages. +> +> Only the "working set" of the database, that is the pages that are very +> frequently used, are worth holding in shared memory at all. The rest +> should be copied in and out of the OS disc buffers. +> +> The problem is, with a too small directory ARC cannot guesstimate what +> might be in the kernel buffers. Nor can it guesstimate what recently was +> in the kernel buffers and got pushed out from there. That results in a +> way too small B1 list, and therefore we don't get B1 hits when in fact +> the data was found in memory. B1 hits is what increases the T1target, +> and since we are missing them with a too small directory size, our +> implementation of ARC is propably using a T2 size larger than the +> working set. That is not optimal. +> +> If we would replace the dynamic T1 buffers with a max_backends*2 area of +> shared buffers, use a C value representing the effective cache size and +> limit the T1target on the lower bound to effective cache size - shared +> buffers, then we basically moved the T1 cache into the OS buffers. +> +> This all only holds water, if the OS is allowed to swap out shared +> memory. And that was my initial question, how likely is it to find this +> to be true these days? +> +> +> Jan +> + +I've asked our linux kernel guys some quick questions and they say +you can lock mmapped memory and sys v shared memory with mlock and +SHM_LOCK, resp. Otherwise the OS will swap out memory as it sees +fit, whether or not it's shared. + +Mark + +From pgsql-performance-owner@postgresql.org Wed Oct 27 22:41:05 2004 +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 128573A474B + for ; + Wed, 27 Oct 2004 22:40:57 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14404-07 + for ; + Wed, 27 Oct 2004 21:40:48 +0000 (GMT) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP id DA4D13A4758 + for ; + Wed, 27 Oct 2004 22:40:49 +0100 (BST) +Received: (from markw@localhost) + by mail.osdl.org (8.11.6/8.11.6) id i9RLem511952; + Wed, 27 Oct 2004 14:40:48 -0700 +Date: Wed, 27 Oct 2004 14:40:48 -0700 +From: Mark Wong +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, + Bjorn Bength +Subject: Re: different io elevators in linux +Message-ID: <20041027144048.A11433@osdl.org> +References: <1098546845.7754.8.camel@localhost> + <200410251009.17575.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.2.5i +In-Reply-To: <200410251009.17575.josh@agliodbs.com>; + from josh@agliodbs.com on Mon, Oct 25, 2004 at 10:09:17AM -0700 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/457 +X-Sequence-Number: 8933 + +On Mon, Oct 25, 2004 at 10:09:17AM -0700, Josh Berkus wrote: +> Bjorn, +> +> > I haven't read much FAQs but has anyone done some benchmarks with +> > different io schedulers in linux with postgresql? +> +> According to OSDL, using the "deadline" scheduler sometimes results in a +> roughly 5% boost to performance, and sometimes none, depending on the +> application. We use it for all testing, though, just in case. +> +> --Josh +> + +Yes, we found with an OLTP type workload, the as scheduler performs +about 5% worse than the deadline scheduler, where in a DSS type +workload there really isn't much difference. The former doing a +mix of reading/writing, where the latter is doing mostly reading. + +Mark + +From pgsql-hackers-owner@postgresql.org Thu Oct 28 04:19:05 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CC5AB3A2BBB + for ; + Thu, 28 Oct 2004 04:18:48 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07867-03 + for ; + Thu, 28 Oct 2004 03:18:39 +0000 (GMT) +Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EF163A1D8B + for ; + Thu, 28 Oct 2004 04:18:38 +0100 (BST) +Received: from sysexperts.com + (c-24-6-183-218.client.comcast.net[24.6.183.218]) + by comcast.net (rwcrmhc12) with ESMTP + id <2004102803183601400085mie>; Thu, 28 Oct 2004 03:18:36 +0000 +Received: from localhost (localhost [127.0.0.1]) (uid 1000) + by filer with local; Wed, 27 Oct 2004 20:20:45 -0700 + id 000055D4.4180658D.00006A59 +Date: Wed, 27 Oct 2004 20:20:45 -0700 +From: Kevin Brown +To: pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +Message-ID: <20041028032044.GA17583@filer> +Mail-Followup-To: Kevin Brown , + pgsql-hackers@postgresql.org +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> + <87hdoiv62b.fsf@stark.xeocode.com> <790.1098741205@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +In-Reply-To: <790.1098741205@sss.pgh.pa.us> +Organization: Frobozzco International +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/960 +X-Sequence-Number: 60463 + +Tom Lane wrote: +> Greg Stark writes: +> > So I would suggest using something like 100us as the threshold for +> > determining whether a buffer fetch came from cache. +> +> I see no reason to hardwire such a number. On any hardware, the +> distribution is going to be double-humped, and it will be pretty easy to +> determine a cutoff after minimal accumulation of data. The real question +> is whether we can afford a pair of gettimeofday() calls per read(). +> This isn't a big issue if the read actually results in I/O, but if it +> doesn't, the percentage overhead could be significant. +> +> If we assume that the effective_cache_size value isn't changing very +> fast, maybe it would be good enough to instrument only every N'th read +> (I'm imagining N on the order of 100) for this purpose. Or maybe we +> need only instrument reads that are of blocks that are close to where +> the ARC algorithm thinks the cache edge is. + +If it's decided to instrument reads, then perhaps an even better use +of it would be to tune random_page_cost. If the storage manager knows +the difference between a sequential scan and a random scan, then it +should easily be able to measure the actual performance it gets for +each and calculate random_page_cost based on the results. + +While the ARC lists can't be tuned on the fly, random_page_cost can. + +> One small problem is that the time measurement gives you only a lower +> bound on the time the read() actually took. In a heavily loaded system +> you might not get the CPU back for long enough to fool you about whether +> the block came from cache or not. + +True, but that's information that you'd want to factor into the +performance measurements anyway. The database needs to know how much +wall clock time it takes for it to fetch a page under various +circumstances from disk via the OS. For determining whether or not +the read() hit the disk instead of just OS cache, what would matter is +the average difference between the two. That's admittedly a problem +if the difference is less than the noise, though, but at the same time +that would imply that given the circumstances it really doesn't matter +whether or not the page was fetched from disk: the difference is small +enough that you could consider them equivalent. + + +You don't need 100% accuracy for this stuff, just statistically +significant accuracy. + + +> Another issue is what we do with the effective_cache_size value once +> we have a number we trust. We can't readily change the size of the +> ARC lists on the fly. + +Compare it with the current value, and notify the DBA if the values +are significantly different? Perhaps write the computed value to a +file so the DBA can look at it later? + +Same with other values that are computed on the fly. In fact, it +might make sense to store them in a table that gets periodically +updated, and load their values from that table, and then the values in +postgresql.conf or the command line would be the default that's used +if there's nothing in the table (and if you really want fine-grained +control of this process, you could stick a boolean column in the table +to indicate whether or not to load the value from the table at startup +time). + + +-- +Kevin Brown kevin@sysexperts.com + +From pgsql-performance-owner@postgresql.org Thu Oct 28 09:01:15 2004 +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 5A3FC3A4859 + for ; + Thu, 28 Oct 2004 09:01:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81756-04 + for ; + Thu, 28 Oct 2004 08:01:09 +0000 (GMT) +Received: from mailer.unicite.fr.netcentrex.net (unknown [62.161.167.249]) + by svr1.postgresql.org (Postfix) with ESMTP id E47A83A4828 + for ; + Thu, 28 Oct 2004 09:01:09 +0100 (BST) +Received: from akira ([192.168.101.228]) by mailer.unicite.fr.netcentrex.net + with SMTP (Microsoft Exchange Internet Mail Service Version + 5.5.2657.72) id 42CYBH0S; Thu, 28 Oct 2004 10:01:08 +0200 +From: "Alban Medici (NetCentrex)" +To: "'Tom Lane'" , + "'Thomas F.O'Connell'" +Cc: "'PgSQL - Performance'" +Subject: Re: Performance Anomalies in 7.4.5 +Date: Thu, 28 Oct 2004 10:01:02 +0200 +Organization: NetCentrex +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: AcS3uchEuW6rOf5GT3yhEH+DktOYswFCiwAw +In-Reply-To: <25228.1098395599@sss.pgh.pa.us> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Message-Id: <20041028080109.E47A83A4828@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/458 +X-Sequence-Number: 8934 + +This topic probably available in 8.x will be very usefull for people just +using postgresql as a "normal" Database user. + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tom Lane +Sent: jeudi 21 octobre 2004 23:53 +To: Thomas F.O'Connell +Cc: PgSQL - Performance +Subject: Re: [PERFORM] Performance Anomalies in 7.4.5 + +"Thomas F.O'Connell" writes: +> -> Nested Loop (cost=0.00..0.01 rows=1 width=8) (actual +> time=1.771..298305.531 rows=2452 loops=1) +> Join Filter: ("inner".id = "outer".id) +> -> Seq Scan on userdata u (cost=0.00..0.00 rows=1 width=8) +> (actual time=0.026..11.869 rows=2452 loops=1) +> -> Seq Scan on userdata_history h (cost=0.00..0.00 rows=1 +> width=8) (actual time=0.005..70.519 rows=41631 loops=2452) +> Filter: (id = 18181::bigint) +> Total runtime: 298321.926 ms +> (7 rows) + +What's killing you here is that the planner thinks these tables are +completely empty (notice the zero cost estimates, which implies the table +has zero blocks --- the fact that the rows estimate is 1 and not 0 is the +result of sanity-check clamping inside costsize.c). This leads it to choose +a nestloop, which would be the best plan if there were only a few rows +involved, but it degenerates rapidly when there are not. + +It's easy to fall into this trap when truncating and reloading tables; all +you need is an "analyze" while the table is empty. The rule of thumb is to +analyze just after you reload the table, not just before. + +I'm getting more and more convinced that we need to drop the reltuples and +relpages entries in pg_class, in favor of checking the physical table size +whenever we make a plan. We could derive the tuple count estimate by having +ANALYZE store a tuples-per-page estimate in pg_class and then multiply by +the current table size; tuples-per-page should be a much more stable figure +than total tuple count. + +One drawback to this is that it would require an additional lseek per table +while planning, but that doesn't seem like a huge penalty. + +Probably the most severe objection to doing things this way is that the +selected plan could change unexpectedly as a result of the physical table +size changing. Right now the DBA can keep tight rein on actions that might +affect plan selection (ie, VACUUM and ANALYZE), but that would go by the +board with this. OTOH, we seem to be moving towards autovacuum, which also +takes away any guarantees in this department. + +In any case this is speculation for 8.1; I think it's too late for 8.0. + + regards, tom lane + +---------------------------(end of broadcast)--------------------------- +TIP 2: you can get off all lists at once with the unregister command + (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + + +From pgsql-performance-owner@postgresql.org Thu Oct 28 16:27:30 2004 +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 4F20E3A4915 + for ; + Thu, 28 Oct 2004 16:27:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33533-01 + for ; + Thu, 28 Oct 2004 15:27:20 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F4363A490E + for ; + Thu, 28 Oct 2004 16:27:19 +0100 (BST) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id i9SFRF303897; + Thu, 28 Oct 2004 10:27:16 -0500 +Message-ID: <41810FC7.6070501@johnmeinel.com> +Date: Thu, 28 Oct 2004 10:27:03 -0500 +From: John Meinel +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jaime Casanova +Cc: pgsql-performance@postgresql.org +Subject: Re: Sequential Scan with LIMIT +References: <20041027171621.60824.qmail@web50006.mail.yahoo.com> +In-Reply-To: <20041027171621.60824.qmail@web50006.mail.yahoo.com> +X-Enigmail-Version: 0.86.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig17E31C0633DD7D3107A1AF65" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/459 +X-Sequence-Number: 8935 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig17E31C0633DD7D3107A1AF65 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Jaime Casanova wrote: +[...] +> +> In http://www.postgresql.org/docs/faqs/FAQ.html under +> "4.8) My queries are slow or don't make use of the +> indexes. Why?" says: +> +> "However, LIMIT combined with ORDER BY often will use +> an index because only a small portion of the table is +> returned. In fact, though MAX() and MIN() don't use +> indexes, it is possible to retrieve such values using +> an index with ORDER BY and LIMIT: +> SELECT col +> FROM tab +> ORDER BY col [ DESC ] +> LIMIT 1;" +> +> So, maybe you can try your query as +> +> SELECT col FROM mytable +> WHERE col = 'myval' +> ORDER BY col +> LIMIT 1; +> +> regards, +> Jaime Casanova + +Thanks for the heads up. This actually worked. All queries against that +table have turned into index scans instead of sequential. + +John +=:-> + +--------------enig17E31C0633DD7D3107A1AF65 +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.4 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBgQ/OJdeBCYSNAAMRApqrAJ4p9MtARog1Loz4zx2h+cRZ1iTGhQCfQeSu +pbf0rEN1a+c6NUF72t/7xyE= +=RcJj +-----END PGP SIGNATURE----- + +--------------enig17E31C0633DD7D3107A1AF65-- + +From pgsql-performance-owner@postgresql.org Thu Oct 28 16:38:37 2004 +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 8FA2C3A3E5E + for ; + Thu, 28 Oct 2004 16:38:35 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37681-01 + for ; + Thu, 28 Oct 2004 15:38:29 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com + [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AF693A48BD + for ; + Thu, 28 Oct 2004 16:38:26 +0100 (BST) +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_01C4BD04.2A95B409" +Subject: Re: Summary: can't handle large number of INSERT/UPDATEs +Date: Thu, 28 Oct 2004 11:38:26 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850985F8@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Summary: can't handle large number of INSERT/UPDATEs +Thread-Index: AcS61KspcGsLLkbcT7etdP20bnwpiQCLj6bw +From: "Anjan Dave" +To: +Cc: "Anjan Dave" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_60_70, + HTML_FONTCOLOR_UNKNOWN, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200410/460 +X-Sequence-Number: 8936 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C4BD04.2A95B409 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +I would like to thank everyone for their timely suggestions. + +=20 + +The problem appears to be resolved now. We verified/modified - +locking/indexes/vacuum/checkpoints/IO bottleneck/queries, etc. + +=20 + +Couple significant changes were the number of checkpoint segments were +increased, and we moved over the database to a new SAN RAID10 volume +(which was in plan anyway, just did it sooner). + +=20 + +=20 + +Thanks, +Anjan + +=20 + + _____ =20 + +From: Anjan Dave=20 +Sent: Monday, October 25, 2004 4:53 PM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] can't handle large number of INSERT/UPDATEs + +=20 + +Hi, + +=20 + +I am dealing with an app here that uses pg to handle a few thousand +concurrent web users. It seems that under heavy load, the INSERT and +UPDATE statements to one or two specific tables keep queuing up, to the +count of 150+ (one table has about 432K rows, other has about 2.6Million +rows), resulting in 'wait's for other queries, and then everything piles +up, with the load average shooting up to 10+.=20 + +=20 + +We (development) have gone through the queries/explain analyzes and made +sure the appropriate indexes exist among other efforts put in. + +=20 + +I would like to know if there is anything that can be changed for better +from the systems perspective. Here's what I have done and some recent +changes from the system side: + +=20 + +-Upgraded from 7.4.0 to 7.4.1 sometime ago + +-Upgraded from RH8 to RHEL 3.0 + +-The settings from postgresql.conf (carried over, basically) are: + + shared_buffers =3D 10240 (80MB) + + max_connections =3D 400 + + sort_memory =3D 1024 + + effective_cache_size =3D 262144 (2GB) + + checkpoint_segments =3D 15 + +stats_start_collector =3D true + +stats_command_string =3D true=20 + +Rest everything is at default + +=20 + +In /etc/sysctl.conf (512MB shared mem) + +kernel.shmall =3D 536870912 + +kernel.shmmax =3D 536870912 + +=20 + +-This is a new Dell 6650 (quad XEON 2.2GHz, 8GB RAM, Internal HW +RAID10), RHEL 3.0 (2.4.21-20.ELsmp), PG 7.4.1 + +-Vaccum Full run everyday + +-contrib/Reindex run everyday + +-Disabled HT in BIOS + +=20 + +I would greatly appreciate any helpful ideas. + +=20 + +Thanks in advance, + +=20 + +Anjan + + +------_=_NextPart_001_01C4BD04.2A95B409 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + +
+ +

I would like to thank everyone for = +their timely +suggestions.

+ +

 

+ +

The problem appears to be resolved = +now. We +verified/modified  - locking/indexes/vacuum/checkpoints/IO = +bottleneck/queries, +etc.

+ +

 

+ +

Couple significant changes were the = +number +of checkpoint segments were increased, and we moved over the database to = +a new +SAN RAID10 volume (which was in plan anyway, just did it = +sooner).

+ +

 

+ +

 

+ +

Thanks,
+Anjan

+ +

 

+ +
+ +
+ +
+ +
+ +

From: = +Anjan Dave
+Sent: Monday, October 25, = +2004 +4:53 PM
+To: +pgsql-performance@postgresql.org
+Subject: [PERFORM] can't = +handle +large number of INSERT/UPDATEs

+ +
+ +

 

+ +

Hi,

+ +

 

+ +

I am dealing with an app here that uses pg to handle = +a few +thousand concurrent web users. It seems that under heavy load, the = +INSERT and +UPDATE statements to one or two specific tables keep queuing up, to the = +count +of 150+ (one table has about 432K rows, other has about 2.6Million = +rows), +resulting in ‘wait’s for other queries, and then everything = +piles +up, with the load average shooting up to 10+. = +

+ +

 

+ +

We (development) have gone through the = +queries/explain +analyzes and made sure the appropriate indexes exist among other efforts = +put +in.

+ +

 

+ +

I would like to know if there is anything that can be +changed for better from the systems perspective. Here’s what I = +have done +and some recent changes from the system = +side:

+ +

 

+ +

-Upgraded from 7.4.0 to 7.4.1 sometime = +ago

+ +

-Upgraded from RH8 to RHEL = +3.0

+ +

-The settings from postgresql.conf (carried over, = +basically) +are:

+ +

         = +   +shared_buffers =3D 10240 (80MB)

+ +

         = +   +max_connections =3D 400

+ +

         = +   +sort_memory =3D 1024

+ +

         = +   +effective_cache_size =3D 262144 (2GB)

+ +

         = +   +checkpoint_segments =3D 15

+ +

stats_start_collector =3D = +true

+ +

stats_command_string =3D = +true

+ +

Rest everything is at = +default

+ +

 

+ +

In /etc/sysctl.conf (512MB = +shared +mem)

+ +

kernel.shmall =3D = +536870912

+ +

kernel.shmmax =3D = +536870912

+ +

 

+ +

-This is a new Dell 6650 (quad XEON 2.2GHz, 8GB RAM, +Internal HW RAID10), RHEL 3.0 (2.4.21-20.ELsmp), PG = +7.4.1

+ +

-Vaccum Full run = +everyday

+ +

-contrib/Reindex run = +everyday

+ +

-Disabled HT in BIOS

+ +

 

+ +

I would greatly appreciate any helpful = +ideas.

+ +

 

+ +

Thanks in advance,

+ +

 

+ +

Anjan

+ +
+ + + + + +------_=_NextPart_001_01C4BD04.2A95B409-- + +From pgsql-performance-owner@postgresql.org Thu Oct 28 17:07:45 2004 +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 A5F6E3A3C21 + for ; + Thu, 28 Oct 2004 17:07:42 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46741-03 + for ; + Thu, 28 Oct 2004 16:07:32 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id BA3933A2B4A + for ; + Thu, 28 Oct 2004 17:07:31 +0100 (BST) +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 6567953 for pgsql-performance@postgresql.org; + Thu, 28 Oct 2004 09:08:56 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Performance Anomalies in 7.4.5 +Date: Thu, 28 Oct 2004 09:07:00 -0700 +User-Agent: KMail/1.6.2 +References: <20041028080109.E47A83A4828@svr1.postgresql.org> +In-Reply-To: <20041028080109.E47A83A4828@svr1.postgresql.org> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200410280907.00445.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/461 +X-Sequence-Number: 8937 + +Tom, + +> One drawback to this is that it would require an additional lseek per table +> while planning, but that doesn't seem like a huge penalty. + +Hmmm ... would the additional lseek take longer for larger tables, or would it +be a fixed cost? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Oct 28 17:31:35 2004 +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 C41C33A4906 + for ; + Thu, 28 Oct 2004 17:31:33 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54390-05 + for ; + Thu, 28 Oct 2004 16:31: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 575F73A4921 + for ; + Thu, 28 Oct 2004 17:31:31 +0100 (BST) +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 i9SGVTdC002816; + Thu, 28 Oct 2004 12:31:29 -0400 (EDT) +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance Anomalies in 7.4.5 +In-reply-to: <200410280907.00445.josh@agliodbs.com> +References: <20041028080109.E47A83A4828@svr1.postgresql.org> + <200410280907.00445.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Thu, 28 Oct 2004 09:07:00 -0700" +Date: Thu, 28 Oct 2004 12:31:28 -0400 +Message-ID: <2815.1098981088@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/462 +X-Sequence-Number: 8938 + +Josh Berkus writes: +>> One drawback to this is that it would require an additional lseek per table +>> while planning, but that doesn't seem like a huge penalty. + +> Hmmm ... would the additional lseek take longer for larger tables, or would it +> be a fixed cost? + +Should be pretty much a fixed cost: one kernel call per table. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Oct 28 18:21:42 2004 +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 A360D3A4955 + for ; + Thu, 28 Oct 2004 18:21:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69862-10 + for ; + Thu, 28 Oct 2004 17:21:37 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4CF213A494A + for ; + Thu, 28 Oct 2004 18:21:37 +0100 (BST) +Received: from [134.22.69.212] (dyn-69-212.tor.dsl.tht.net [134.22.69.212]) + by tht.net (Postfix) with ESMTP + id 9F22F76A35; Thu, 28 Oct 2004 13:21:35 -0400 (EDT) +Subject: Re: Performance Anomalies in 7.4.5 +From: Rod Taylor +To: Tom Lane +Cc: Josh Berkus , + Postgresql Performance +In-Reply-To: <2815.1098981088@sss.pgh.pa.us> +References: <20041028080109.E47A83A4828@svr1.postgresql.org> + <200410280907.00445.josh@agliodbs.com> <2815.1098981088@sss.pgh.pa.us> +Content-Type: text/plain +Message-Id: <1098984056.8557.637.camel@home> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Thu, 28 Oct 2004 13:20:56 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/463 +X-Sequence-Number: 8939 + +On Thu, 2004-10-28 at 12:31, Tom Lane wrote: +> Josh Berkus writes: +> >> One drawback to this is that it would require an additional lseek per table +> >> while planning, but that doesn't seem like a huge penalty. +> +> > Hmmm ... would the additional lseek take longer for larger tables, or would it +> > be a fixed cost? +> +> Should be pretty much a fixed cost: one kernel call per table. + +Is this something that the bgwriter could periodically do and share the +data? Possibly in the future it could even force a function or prepared +statement recompile if the data has changed significantly? + + + +From pgsql-performance-owner@postgresql.org Thu Oct 28 18:50:44 2004 +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 ECF3E3A4906 + for ; + Thu, 28 Oct 2004 18:50:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82355-08 + for ; + Thu, 28 Oct 2004 17:50: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 5A1283A495A + for ; + Thu, 28 Oct 2004 18:50:33 +0100 (BST) +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 i9SHoTmo003473; + Thu, 28 Oct 2004 13:50:29 -0400 (EDT) +To: Rod Taylor +Cc: Josh Berkus , + Postgresql Performance +Subject: Re: Performance Anomalies in 7.4.5 +In-reply-to: <1098984056.8557.637.camel@home> +References: <20041028080109.E47A83A4828@svr1.postgresql.org> + <200410280907.00445.josh@agliodbs.com> + <2815.1098981088@sss.pgh.pa.us> <1098984056.8557.637.camel@home> +Comments: In-reply-to Rod Taylor + message dated "Thu, 28 Oct 2004 13:20:56 -0400" +Date: Thu, 28 Oct 2004 13:50:29 -0400 +Message-ID: <3472.1098985829@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/464 +X-Sequence-Number: 8940 + +Rod Taylor writes: +> On Thu, 2004-10-28 at 12:31, Tom Lane wrote: +>> Should be pretty much a fixed cost: one kernel call per table. + +> Is this something that the bgwriter could periodically do and share the +> data? + +I think a kernel call would be cheaper. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 29 00:47:11 2004 +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 EC5863A2B41 + for ; + Fri, 29 Oct 2004 00:47:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91701-04 + for ; + Thu, 28 Oct 2004 23:46:56 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with ESMTP id 2388D3A2B10 + for ; + Fri, 29 Oct 2004 00:46:58 +0100 (BST) +Received: by flake.decibel.org (Postfix, from userid 1001) + id A93A71C900; Thu, 28 Oct 2004 23:46:58 +0000 (GMT) +Date: Thu, 28 Oct 2004 18:46:58 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: John Meinel , + pgsql-performance@postgresql.org +Subject: Re: Sequential Scan with LIMIT +Message-ID: <20041028234658.GI55164@decibel.org> +References: <417C023F.1080502@johnmeinel.com> <17689.1098648713@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <17689.1098648713@sss.pgh.pa.us> +X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/465 +X-Sequence-Number: 8941 + +On Sun, Oct 24, 2004 at 04:11:53PM -0400, Tom Lane wrote: +> But the LIMIT will cut the cost of the seqscan case too. Given the +> numbers you posit above, about one row in five will have 'myval', so a +> seqscan can reasonably expect to hit the first matching row in the first +> page of the table. This is still cheaper than doing an index scan +> (which must require reading at least one index page plus at least one +> table page). +> +> The test case you are showing is probably suffering from nonrandom +> placement of this particular data value; which is something that the +> statistics we keep are too crude to detect. + +Isn't that exactly what pg_stats.correlation is? +-- +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 Fri Oct 29 00:49:44 2004 +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 E8E233A3BE8 + for ; + Fri, 29 Oct 2004 00:49:40 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89496-08 + for ; + Thu, 28 Oct 2004 23:49: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 4C61F3A2B41 + for ; + Fri, 29 Oct 2004 00:49:31 +0100 (BST) +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 i9SNnTOk009173; + Thu, 28 Oct 2004 19:49:29 -0400 (EDT) +To: "Jim C. Nasby" +Cc: John Meinel , + pgsql-performance@postgresql.org +Subject: Re: Sequential Scan with LIMIT +In-reply-to: <20041028234658.GI55164@decibel.org> +References: <417C023F.1080502@johnmeinel.com> <17689.1098648713@sss.pgh.pa.us> + <20041028234658.GI55164@decibel.org> +Comments: In-reply-to "Jim C. Nasby" + message dated "Thu, 28 Oct 2004 18:46:58 -0500" +Date: Thu, 28 Oct 2004 19:49:28 -0400 +Message-ID: <9172.1099007368@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/466 +X-Sequence-Number: 8942 + +"Jim C. Nasby" writes: +> On Sun, Oct 24, 2004 at 04:11:53PM -0400, Tom Lane wrote: +>> The test case you are showing is probably suffering from nonrandom +>> placement of this particular data value; which is something that the +>> statistics we keep are too crude to detect. + +> Isn't that exactly what pg_stats.correlation is? + +No. A far-from-zero correlation gives you a clue that on average, *all* +the data values are placed nonrandomly ... but it doesn't really tell +you much one way or the other about a single data value. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Oct 29 00:54:40 2004 +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 080253A49E7 + for ; + Fri, 29 Oct 2004 00:54:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92614-10 + for ; + Thu, 28 Oct 2004 23:54:27 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F63C3A49F8 + for ; + Fri, 29 Oct 2004 00:54:30 +0100 (BST) +Received: by flake.decibel.org (Postfix, from userid 1001) + id BBC521C902; Thu, 28 Oct 2004 23:54:30 +0000 (GMT) +Date: Thu, 28 Oct 2004 18:54:30 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: John Meinel , + pgsql-performance@postgresql.org +Subject: Re: Sequential Scan with LIMIT +Message-ID: <20041028235430.GJ55164@decibel.org> +References: <417C023F.1080502@johnmeinel.com> <17689.1098648713@sss.pgh.pa.us> + <20041028234658.GI55164@decibel.org> + <9172.1099007368@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <9172.1099007368@sss.pgh.pa.us> +X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/467 +X-Sequence-Number: 8943 + +On Thu, Oct 28, 2004 at 07:49:28PM -0400, Tom Lane wrote: +> "Jim C. Nasby" writes: +> > On Sun, Oct 24, 2004 at 04:11:53PM -0400, Tom Lane wrote: +> >> The test case you are showing is probably suffering from nonrandom +> >> placement of this particular data value; which is something that the +> >> statistics we keep are too crude to detect. +> +> > Isn't that exactly what pg_stats.correlation is? +> +> No. A far-from-zero correlation gives you a clue that on average, *all* +> the data values are placed nonrandomly ... but it doesn't really tell +> you much one way or the other about a single data value. + +Maybe I'm confused about what the original issue was then... it appeared +that you were suggesting PGSQL was doing a seq scan instead of an index +scan because it thought it would find it on the first page if the data +was randomly distributed. If the correlation is highly non-zero though, +shouldn't it 'play it safe' and assume that unless it's picking the min +or max value stored in statistics it will be better to do an index scan, +since the value it's looking for is probably in the middle of the table +somewhere? IE: if the values in the field are between 1 and 5 and the +table is clustered on that field then clearly an index scan would be +better to find a row with field=3 than a seq scan. +-- +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 Fri Oct 29 15:02:25 2004 +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 653723A4BCE + for ; + Fri, 29 Oct 2004 15:02:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39814-05 + for ; + Fri, 29 Oct 2004 14:02:15 +0000 (GMT) +Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [204.127.202.56]) + by svr1.postgresql.org (Postfix) with ESMTP id 133293A4BCB + for ; + Fri, 29 Oct 2004 15:02:18 +0100 (BST) +Received: from [127.0.0.1] (c-67-160-247-54.client.comcast.net[67.160.247.54]) + by comcast.net (sccrmhc12) with ESMTP id <20041029140217012009laume> + (Authid: pathat); Fri, 29 Oct 2004 14:02:18 +0000 +Message-ID: <41824E05.8000903@comcast.net> +Date: Fri, 29 Oct 2004 07:04:53 -0700 +From: Patrick Hatcher +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: determining max_fsm_pages +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/468 +X-Sequence-Number: 8944 + +Pg: 7.4.5 +8G ram +200G RAID5 + +I have my fsm set as such: +max_fsm_pages = 300000 # min max_fsm_relations*16, 6 bytes each +max_fsm_relations = 500 # min 100, ~50 bytes each + + +I just did a vacuum full on one table and saw this result: +INFO: analyzing "cdm.cdm_fed_agg_purch" +INFO: "cdm_fed_agg_purch": 667815 pages, 3000 rows sampled, 52089570 +estimated total rows + + +My question is this: I have about 8 databases running on this server. +When I do a vacuum full on each of these databases, there is a INFO +section that I assume is the total pages used for that database. Should +add ALL these individual pages together and pad the total and use this +as my new max_fsm_pages? Should I do the same thing with max_fsm_relations? + +TIA +Patrick + +From pgsql-performance-owner@postgresql.org Fri Oct 29 15:29:59 2004 +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 997D83A469A + for ; + Fri, 29 Oct 2004 15:29:57 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49078-05 + for ; + Fri, 29 Oct 2004 14:29:49 +0000 (GMT) +Received: from sraigw.sra.co.jp (sraigw.sra.co.jp [202.32.10.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 010893A4BD8 + for ; + Fri, 29 Oct 2004 15:29:51 +0100 (BST) +Received: from srascb.sra.co.jp (srascb [133.137.8.65]) + by sraigw.sra.co.jp (Postfix) with ESMTP + id B83F06278D; Fri, 29 Oct 2004 23:29:50 +0900 (JST) +Received: from srascb.sra.co.jp (localhost [127.0.0.1]) + by localhost.sra.co.jp (Postfix) with ESMTP + id A120710CD06; Fri, 29 Oct 2004 23:29:50 +0900 (JST) +Received: from sranhm.sra.co.jp (sranhm [133.137.44.16]) + by srascb.sra.co.jp (Postfix) with ESMTP + id 8695B10CD04; Fri, 29 Oct 2004 23:29:50 +0900 (JST) +Received: from localhost (sraihb-hub.sra.co.jp [133.137.8.6]) + by sranhm.sra.co.jp (8.9.3+3.2W/3.7W-srambox) with ESMTP id XAA23107; + Fri, 29 Oct 2004 23:29:50 +0900 +Date: Fri, 29 Oct 2004 23:31:51 +0900 (JST) +Message-Id: <20041029.233151.78703659.t-ishii@sra.co.jp> +To: pathat@comcast.net +Cc: pgsql-performance@postgresql.org +Subject: Re: determining max_fsm_pages +From: Tatsuo Ishii +In-Reply-To: <41824E05.8000903@comcast.net> +References: <41824E05.8000903@comcast.net> +X-Mailer: Mew version 2.3 on Emacs 20.7 / Mule 4.1 + =?iso-2022-jp?B?KBskQjAqGyhCKQ==?= +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/469 +X-Sequence-Number: 8945 + +> Pg: 7.4.5 +> 8G ram +> 200G RAID5 +> +> I have my fsm set as such: +> max_fsm_pages = 300000 # min max_fsm_relations*16, 6 bytes each +> max_fsm_relations = 500 # min 100, ~50 bytes each +> +> +> I just did a vacuum full on one table and saw this result: +> INFO: analyzing "cdm.cdm_fed_agg_purch" +> INFO: "cdm_fed_agg_purch": 667815 pages, 3000 rows sampled, 52089570 +> estimated total rows +> +> +> My question is this: I have about 8 databases running on this server. +> When I do a vacuum full on each of these databases, there is a INFO +> section that I assume is the total pages used for that database. Should +> add ALL these individual pages together and pad the total and use this +> as my new max_fsm_pages? Should I do the same thing with max_fsm_relations? + +I think that's too much and too big FSM affects performance in my +opinion. The easiest way to calculate appropreate FSM size is doing +vacuumdb -a -v and watching the message. At the very end, you would +see something like: + +INFO: free space map: 13 relations, 1447 pages stored; 1808 total pages needed +DETAIL: Allocated FSM size: 100 relations + 1600 pages = 19 kB shared memory. + +In this case 1808 is the minimum FSM size. Of course this number would +change depending on the frequency of VACUUM. Therefore you need some +room for the FSM size. +-- +Tatsuo Ishii + +From pgsql-performance-owner@postgresql.org Fri Oct 29 15:37:30 2004 +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 3DE323A1D9E + for ; + Fri, 29 Oct 2004 15:37:29 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48787-09 + for ; + Fri, 29 Oct 2004 14:37: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 25CD43A1D9C + for ; + Fri, 29 Oct 2004 15:37:24 +0100 (BST) +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 i9TEbOql015930; + Fri, 29 Oct 2004 10:37:24 -0400 (EDT) +To: Patrick Hatcher +Cc: pgsql-performance@postgresql.org +Subject: Re: determining max_fsm_pages +In-reply-to: <41824E05.8000903@comcast.net> +References: <41824E05.8000903@comcast.net> +Comments: In-reply-to Patrick Hatcher + message dated "Fri, 29 Oct 2004 07:04:53 -0700" +Date: Fri, 29 Oct 2004 10:37:23 -0400 +Message-ID: <15929.1099060643@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/470 +X-Sequence-Number: 8946 + +Patrick Hatcher writes: +> My question is this: I have about 8 databases running on this server. +> When I do a vacuum full on each of these databases, there is a INFO +> section that I assume is the total pages used for that database. Should +> add ALL these individual pages together and pad the total and use this +> as my new max_fsm_pages? Should I do the same thing with max_fsm_relations? + +No, the numbers shown at the end of a vacuum verbose printout reflect +the current cluster-wide FSM demand. BTW you do *not* want to use FULL +because that's not going to reflect the FSM requirements when you are +just running normal vacuums. + +I would vacuum all your databases (to make sure each one's FSM contents +are pretty up-to-date) and then take the numbers shown by the last one +as your targets. + +If you find yourself having to raise max_fsm_relations, it may be +necessary to repeat the vacuuming cycle before you can get a decent +total for max_fsm_pages. IIRC, the vacuum printout does include in +"needed" a count of pages that it would have stored if it'd had room; +but this is only tracked for relations that have an FSM relation entry. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Sat Oct 30 14:39:55 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 25AF23A3E71 + for ; + Sat, 30 Oct 2004 14:39:54 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80880-07 + for ; + Sat, 30 Oct 2004 13:39:48 +0000 (GMT) +Received: from smtp109.mail.sc5.yahoo.com (smtp109.mail.sc5.yahoo.com + [66.163.170.7]) + by svr1.postgresql.org (Postfix) with SMTP id 283043A3E9D + for ; + Sat, 30 Oct 2004 14:39:51 +0100 (BST) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp109.mail.sc5.yahoo.com with SMTP; 30 Oct 2004 13:39:51 -0000 +Received: from [172.21.8.18] (gv90209.gv.psu.edu [146.186.90.209]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i9UDdn94057594; Sat, 30 Oct 2004 09:39:49 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <418399D7.6090204@Yahoo.com> +Date: Sat, 30 Oct 2004 09:40:39 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Greg Stark , pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> + <87hdoiv62b.fsf@stark.xeocode.com> <790.1098741205@sss.pgh.pa.us> + <878y9uukgb.fsf@stark.xeocode.com> <4887.1098770035@sss.pgh.pa.us> +In-Reply-To: <4887.1098770035@sss.pgh.pa.us> +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.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200410/1001 +X-Sequence-Number: 60504 + +On 10/26/2004 1:53 AM, Tom Lane wrote: +> Greg Stark writes: +>> Tom Lane writes: +>>> Another issue is what we do with the effective_cache_size value once we +>>> have a number we trust. We can't readily change the size of the ARC +>>> lists on the fly. +> +>> Huh? I thought effective_cache_size was just used as an factor the cost +>> estimation equation. +> +> Today, that is true. Jan is speculating about using it as a parameter +> of the ARC cache management algorithm ... and that worries me. + +If we need another config option, it's not that we are running out of +possible names, is it? + + +Jan + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + +From pgsql-hackers-owner@postgresql.org Sat Oct 30 17:53:44 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 915A13A3EBC + for ; + Sat, 30 Oct 2004 17:53:42 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21298-10 + for ; + Sat, 30 Oct 2004 16:53:40 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4EAF83A3EAA + for ; + Sat, 30 Oct 2004 17:53:40 +0100 (BST) +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 i9UGraPG005986; + Sat, 30 Oct 2004 12:53:37 -0400 (EDT) +To: Jan Wieck +Cc: Greg Stark , pgsql-hackers@postgresql.org +Subject: Re: [PATCHES] ARC Memory Usage analysis +In-reply-to: <418399D7.6090204@Yahoo.com> +References: <1098471059.20926.49.camel@localhost.localdomain> + <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> + <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> + <87mzyavhxc.fsf@stark.xeocode.com> + <87hdoiv62b.fsf@stark.xeocode.com> <790.1098741205@sss.pgh.pa.us> + <878y9uukgb.fsf@stark.xeocode.com> + <4887.1098770035@sss.pgh.pa.us> <418399D7.6090204@Yahoo.com> +Comments: In-reply-to Jan Wieck + message dated "Sat, 30 Oct 2004 09:40:39 -0400" +Date: Sat, 30 Oct 2004 12:53:36 -0400 +Message-ID: <5985.1099155216@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/1002 +X-Sequence-Number: 60505 + +Jan Wieck writes: +> On 10/26/2004 1:53 AM, Tom Lane wrote: +>> Greg Stark writes: +> Tom Lane writes: +>>> Another issue is what we do with the effective_cache_size value once we +>>> have a number we trust. We can't readily change the size of the ARC +>>> lists on the fly. +>> +> Huh? I thought effective_cache_size was just used as an factor the cost +> estimation equation. +>> +>> Today, that is true. Jan is speculating about using it as a parameter +>> of the ARC cache management algorithm ... and that worries me. + +> If we need another config option, it's not that we are running out of +> possible names, is it? + +No, the point is that the value is not very trustworthy at the moment. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Oct 30 22:13:00 2004 +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 4D1A93A3F2C + for ; + Sat, 30 Oct 2004 22:12:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87255-01 + for ; + Sat, 30 Oct 2004 21:12:47 +0000 (GMT) +Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B23C3A2019 + for ; + Sat, 30 Oct 2004 22:12:48 +0100 (BST) +Received: from [192.168.0.1] (dsl-082-082-202-218.arcor-ip.net + [82.82.202.218]) + (authenticated) + by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id i9ULCPw23745; + Sat, 30 Oct 2004 23:12:25 +0200 +Subject: Re: can't handle large number of INSERT/UPDATEs +From: Markus Bertheau +To: Matt Clark +Cc: John Meinel , Tom Lane , + Curtis Zinzilieta , + Anjan Dave , Rod Taylor , + Postgresql Performance +In-Reply-To: <417F3B91.9080002@ymogen.net> +References: + + <15812.1098847291@sss.pgh.pa.us> <417F2181.4000801@johnmeinel.com> + <417F3B91.9080002@ymogen.net> +Content-Type: text/plain +Message-Id: <1099170744.2646.3.camel@teetnang> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Sat, 30 Oct 2004 23:12:25 +0200 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/471 +X-Sequence-Number: 8947 + +Turns out the man page of vmstat in procps was changed on Oct 8 2002: + +http://cvs.sourceforge.net/viewcvs.py/procps/procps/vmstat.8?r1=1.1&r2=1.2 + +in reaction to a debian bug report: + +http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=157935 + +-- +Markus Bertheau + + +From pgsql-performance-owner@postgresql.org Sun Oct 31 06:03:52 2004 +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 1738E3A4045 + for ; + Sun, 31 Oct 2004 06:03:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92972-04 + for ; + Sun, 31 Oct 2004 06:02:59 +0000 (GMT) +Received: from purple.west.spy.net (mail.west.spy.net [66.149.231.226]) + by svr1.postgresql.org (Postfix) with ESMTP id B9AD03A4023 + for ; + Sun, 31 Oct 2004 06:02:56 +0000 (GMT) +Received: from [192.168.1.50] (dustinti.west.spy.net [192.168.1.50]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (Client did not present a certificate) + by purple.west.spy.net (Postfix) with ESMTP + id 4378A11E; Sat, 30 Oct 2004 23:02:54 -0700 (PDT) +In-Reply-To: <20041027075748.GA8355@hardpoint.ciar.org> +References: <20041027075748.GA8355@hardpoint.ciar.org> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <8132EBC8-2B02-11D9-A2DE-000A957659CC@spy.net> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Dustin Sallings +Subject: Re: psql large RSS (1.6GB) +Date: Sat, 30 Oct 2004 23:02:54 -0700 +To: TTK Ciar +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200410/474 +X-Sequence-Number: 8950 + + +On Oct 27, 2004, at 0:57, TTK Ciar wrote: + +> At a guess, it looks like the data set is being buffered in its +> entirety by psql, before any data is written to the output file, +> which is surprising. I would have expected it to grab data as it +> appeared on the socket from postmaster and write it to disk. Is +> there something we can do to stop psql from buffering results? +> Does anyone know what's going on here? + + Yes, the result set is sent back to the client before it can be used. +An easy workaround when dealing with this much data is to use a cursor. + Something like this: + +db# start transaction; +START TRANSACTION +db# declare logcur cursor for select * from some_table; +DECLARE CURSOR +db# fetch 5 in logcur; +[...] +(5 rows) + + This will do approximately what you expected the select to do in the +first, place, but the fetch will decide how many rows to buffer into +the client at a time. + +> If the solution is to just write a little client that uses perl +> DBI to fetch rows one at a time and write them out, that's doable, +> but it would be nice if psql could be made to "just work" without +> the monster RSS. + + It wouldn't make a difference unless that driver implements the +underlying protocol on its own. + +-- +SPY My girlfriend asked me which one I like better. +pub 1024/3CAE01D5 1994/11/03 Dustin Sallings +| Key fingerprint = 87 02 57 08 02 D0 DA D6 C8 0F 3E 65 51 98 D8 BE +L_______________________ I hope the answer won't upset her. ____________ + + +From pgsql-performance-owner@postgresql.org Sun Oct 31 10:27:14 2004 +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 35E023A40E6 + for ; + Sun, 31 Oct 2004 10:27:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41598-08 + for ; + Sun, 31 Oct 2004 10:27:06 +0000 (GMT) +Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BC9F3A40E5 + for ; + Sun, 31 Oct 2004 10:27:07 +0000 (GMT) +Received: from [192.168.0.1] (dsl-082-082-203-101.arcor-ip.net + [82.82.203.101]) + (authenticated) + by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id i9VAQvw17192; + Sun, 31 Oct 2004 11:26:57 +0100 +Subject: Re: psql large RSS (1.6GB) +From: Markus Bertheau +To: TTK Ciar +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20041027075748.GA8355@hardpoint.ciar.org> +References: <20041027075748.GA8355@hardpoint.ciar.org> +Content-Type: text/plain; charset=UTF-8 +Message-Id: <1099218421.2636.0.camel@teetnang> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Sun, 31 Oct 2004 11:27:01 +0100 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_DSBL +X-Spam-Level: * +X-Archive-Number: 200410/475 +X-Sequence-Number: 8951 + +=D0=92 =D0=A1=D1=80=D0=B4, 27.10.2004, =D0=B2 09:57, TTK Ciar =D0=BF=D0=B8= +=D1=88=D0=B5=D1=82: + +> brad=3D# explain analyse select ServerDisks.servername,ServerDisks.diskse= +rial,ServerDisks.diskmountpoint,DiskFiles.name,DiskFiles.md5 from DiskFiles= +,ServerDisks where DiskFiles.diskserial=3DServerDisks.diskserial; +> QUERY PLAN = + =20 +> ------------------------------------------------------------------ +> Hash Join (cost=3D22.50..65.00 rows=3D1000 width=3D274) (actual time=3D= +118.584..124653.729 rows=3D10133349 loops=3D1) +> Hash Cond: (("outer".diskserial)::text =3D ("inner".diskserial)::text) +> -> Seq Scan on diskfiles (cost=3D0.00..20.00 rows=3D1000 width=3D198= +) (actual time=3D7.201..31336.063 rows=3D10133349 loops=3D1) +> -> Hash (cost=3D20.00..20.00 rows=3D1000 width=3D158) (actual time= +=3D90.821..90.821 rows=3D0 loops=3D1) +> -> Seq Scan on serverdisks (cost=3D0.00..20.00 rows=3D1000 wid= +th=3D158) (actual time=3D9.985..87.364 rows=3D2280 loops=3D1) +> Total runtime: 130944.586 ms + +You should run ANALYZE on your database once in a while. + +--=20 +Markus Bertheau + + +From pgsql-performance-owner@postgresql.org Sun Oct 31 18:39:07 2004 +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 852EA3A4253 + for ; + Sun, 31 Oct 2004 18:39:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50857-03 + for ; + Sun, 31 Oct 2004 18:38:57 +0000 (GMT) +Received: from themode.com (themode.com [161.58.169.198]) + by svr1.postgresql.org (Postfix) with ESMTP id 281C73A4248 + for ; + Sun, 31 Oct 2004 18:38:57 +0000 (GMT) +Received: from localhost (bde@localhost) + by themode.com (8.12.11/8.12.10) with ESMTP id i9VIctPR094972; + Sun, 31 Oct 2004 13:38:55 -0500 (EST) +Date: Sun, 31 Oct 2004 13:38:55 -0500 (EST) +From: brew@theMode.com +X-X-Sender: mode@themode.com +To: Aaron Mulder +Cc: pgsql-performance@postgresql.org +Subject: Thanks Chariot Solutions +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.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200410/476 +X-Sequence-Number: 8952 + + +Many thanks to Chariot Solutions, http://chariotsolutions.com, for hosting +Bruce Momjian giving one of his PostgreSQL seminars outside of +Philadelphia, PA yesterday. There were about sixty folks there, one person +driving from Toronto and another coming from California (!). + +I found it very enlightening and learned some new things about PostgreSQL, +even if I *did* doze off for a few minutes after lunch when all my energy +was concentrated in my stomach. + +But after I got back home I dreamt about PostgreSQL all night long!!! + +Thanks Bruce and Chariot Solutions. + +brew + + ========================================================================== + Strange Brew (brew@theMode.com) + Check out my Musician's Online Database Exchange (The MODE Pages) + http://www.TheMode.com + ========================================================================== + + +From pgsql-performance-owner@postgresql.org Sun Oct 31 21:10:52 2004 +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 F0D863A42C0 + for ; + Sun, 31 Oct 2004 21:10:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81124-08 + for ; + Sun, 31 Oct 2004 21:10:31 +0000 (GMT) +Received: from trade-india.com (unknown [203.101.29.52]) + by svr1.postgresql.org (Postfix) with SMTP id 00D213A4281 + for ; + Sun, 31 Oct 2004 21:10:30 +0000 (GMT) +Received: (qmail 26720 invoked from network); 31 Oct 2004 21:03:10 -0000 +Received: from unknown (HELO 192.168.0.66) (192.168.0.66) + by 192.168.0.66 with SMTP; 31 Oct 2004 21:03:10 -0000 +Received: from 192.168.0.11 (proxying for 203.122.31.2) + (SquirrelMail authenticated user mallah) + by office1.trade-india.com with HTTP; + Mon, 1 Nov 2004 02:33:10 +0530 (IST) +Message-ID: <46946.192.168.0.11.1099256590.squirrel@office1.trade-india.com> +Date: Mon, 1 Nov 2004 02:33:10 +0530 (IST) +Subject: Speeding up Gist Index creations +From: mallah@trade-india.com +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.2 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.4 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, + PRIORITY_NO_NAME, RCVD_NUMERIC_HELO +X-Spam-Level: * +X-Archive-Number: 200410/477 +X-Sequence-Number: 8953 + + + +Hi , + +Gist indexes take a long time to create as compared +to normal indexes is there any way to speed them up ? + +(for example by modifying sort_mem or something temporarily ) + +Regds +Mallah. +