diff --git "a/pgsql-performance.200401" "b/pgsql-performance.200401" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200401" @@ -0,0 +1,29137 @@ +From pgsql-performance-owner@postgresql.org Thu Jan 1 13:15:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B5334D1BB71 + for ; + Thu, 1 Jan 2004 17:14:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 24547-04 + for ; + Thu, 1 Jan 2004 13:14:10 -0400 (AST) +Received: from mail2000-4.so-net.net.tw (mail2000-4.so-net.net.tw + [61.64.127.20]) + by svr1.postgresql.org (Postfix) with SMTP id 70590D1B498 + for ; + Thu, 1 Jan 2004 13:14:08 -0400 (AST) +Received: from 10.1.9.28 by mail2000-4.so-net.net.tw with Mail2000 ESMTP + Server + V2.71S(31478:0:AUTH_RELAY) Fri, 02 Jan 2004 01:14:06 +0800 (CST); + (envelope-from ) +Received: By OpenMail Mailer;Fri, 02 Jan 2004 01:14:02 +0800 (CST) +From: "cnliou" +Reply-To: cnliou@so-net.net.tw +Subject: pg_restore makes disk busy +Message-ID: <1072977242.87202.cnliou@so-net.net.tw> +To: "" +Date: Fri, 02 Jan 2004 01:14:02 +0800 (CST) +MIME-Version: 1.0 +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200401/1 +X-Sequence-Number: 5176 + +Happy new year! + +When performing +"pg_restore -L list --disable-triggers -d db1 -v my_archive" +, my hard disk for Linux box (with 96MB RAM) becomes +extremely busy. + +One example is that it takes more than 5 miniutes to restore + for a table from 7800 rows. Each row has less than 117 +bytes in length with total of 6 columns. Hence I think the +amount of the to-restore data is not the cause of +performance problem. + +The swap size is only 68K. Therefore, I don't think small +amount of RAM is a problem, either. + +kjournald uses 2% CPU and postmaster uses 10%. CPU is about +95% idle. + +What makes the restore so slow? How do I speed it up? + +Regards, +CN + +From pgsql-performance-owner@postgresql.org Thu Jan 1 23:34:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6ED80D1B436 + for ; + Fri, 2 Jan 2004 03:34:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90045-04 + for ; + Thu, 1 Jan 2004 23:34:01 -0400 (AST) +Received: from pomeray.duluoz.net (12-241-192-70.client.attbi.com + [12.241.192.70]) + by svr1.postgresql.org (Postfix) with ESMTP id A7B59D1B48E + for ; + Thu, 1 Jan 2004 23:33:56 -0400 (AST) +Received: (qmail 1976 invoked by uid 1000); 2 Jan 2004 03:34:01 -0000 +Date: Thu, 1 Jan 2004 19:34:01 -0800 +From: Mike Glover +To: pgsql-performance@postgresql.org +Subject: Very slow update + not using clustered index +Message-Id: <20040101193401.6640420b.mpg4@duluoz.net> +X-Mailer: Sylpheed version 0.9.0claws (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg="pgp-sha1"; boundary="=.lOrWFPH0Z)WqCU" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/2 +X-Sequence-Number: 5177 + +--=.lOrWFPH0Z)WqCU +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit + +I have these two tables: + + Table "de.summary" + Column | Type | Modifiers +--------------+-----------------------------+--------------- + isbn | character varying(10) | not null + source | character varying(20) | not null + condition | smallint | + availability | smallint | + price_list | numeric(11,2) | + price_min | numeric(11,2) | + last_update | timestamp without time zone | default now() +Indexes: + "summary_pkey" primary key, btree (isbn, source) + + Table "de.inventory" + Column | Type | Modifiers +--------------+-----------------------+----------- + isbn | character varying(10) | + condition | integer | + availability | integer | + price | numeric(9,2) | +Indexes: + "inventory_isbn_idx" btree (isbn) + + +Both tables are clustered on their respective indexes. The entire +database has been freshly VACUUM FULL'd and ANALYZE'd (after +clustering). + +I want to run the following query, but it takes a *very* long time. +Like this: + +bookshelf=> explain analyze update summary set price_min=0, +availability=2, condition=9 where isbn = inventory.isbn and price_min = +inventory.price; + QUERY PLAN +----------------------------------------------------------------- +----------------------------------------------------------- +Merge Join (cost=496170.66..517271.50 rows=5051 width=51) (actual +time=226940.723..292247.643 rows=419277 loops=1) + Merge Cond: (("outer".price_min = "inner".price) AND +("outer"."?column7?" = "inner"."?column3?")) + -> Sort (cost=366877.05..371990.05 rows=2045201 width=61) (actual +time=162681.929..177216.158 rows=2045200 loops=1) + Sort Key: summary.price_min, (summary.isbn)::text + -> Seq Scan on summary (cost=0.00..44651.01 rows=2045201 width=61) +(actual time=8.139..22179.379 rows=2045201 loops=1) + -> Sort(cost=129293.61..131499.09 rows=882192 width=25) (actual +time=64213.663..67563.175 rows=882192 loops=1) + Sort Key: inventory.price, (inventory.isbn)::text + -> Seq Scan on inventory(cost=0.00..16173.92 rows=882192 +width=25)(actual time=5.773..21548.942 rows=882192 loops=1) +Total runtime: 3162319.477 ms(9 rows) + +Running what I believe to be the comparable select query is more +reasonable: + +bookshelf=> explain analyze select s.* from summary s, inventory i where +s.isbn = i.isbn and s.price_min = i.price; + QUERY PLAN +----------------------------------------------------------------------- +Merge Join (cost=495960.66..517061.50 rows=5051 width=59) (actual +time=194048.974..215835.982 rows=419277 loops=1) + Merge Cond: (("outer".price_min = "inner".price) AND +("outer"."?column8?" ="inner"."?column3?")) + -> Sort (cost=366667.05..371780.05 rows=2045201 width=59) (actual +time=147678.109..149945.170 rows=2045200 loops=1) + Sort Key: s.price_min, (s.isbn)::text + -> Seq Scan on summary s (cost=0.00..49431.01 rows=2045201 +width=59) (actual time=0.056..9304.803 rows=2045201 loops=1) + -> Sort (cost=129293.61..131499.09 rows=882192 width=25) (actual +time=46338.696..47183.739 rows=882192 loops=1) + Sort Key: i.price, (i.isbn)::text + -> Seq Scan on inventory i (cost=0.00..16173.92 rows=882192 +width=25) (actual time=0.089..2419.187 rows=882192 loops=1) +Total runtime: 216324.171 ms + + +I had figured that the tables would get sorted on isbn, because of the +clustering. I understand why price might get chosen (fewer matches), +but the planner seems to be making the wrong choice: + +bookshelf=> explain analyze select s.* from summary s, inventory i where +s.isbn = i.isbn; + QUERY PLAN +----------------------------------------------------------------------- +Merge Join (cost=489500.66..512953.69 rows=882192 width=59) (actual +time=152247.741..174408.812 rows=882192 loops=1) + Merge Cond: ("outer"."?column8?" = "inner"."?column2?") + -> Sort (cost=366667.05..371780.05 rows=2045201 width=59) (actual +time=118562.097..120817.894 rows=2045146 loops=1) + Sort Key:(s.isbn)::text + -> Seq Scan on summary s (cost=0.00..49431.01 rows=2045201 +width=59) (actual time=0.062..8766.683 rows=2045201 loops=1) + -> Sort (cost=122833.61..125039.09 rows=882192 width=14)(actual +time=33685.455..34480.190 rows=882192 loops=1) + Sort Key:(i.isbn)::text + -> Seq Scan on inventory i (cost=0.00..16173.92 rows=882192 +width=14) (actual time=0.088..1942.173 rows=882192 loops=1) + Total runtime: 174926.115 ms + +So, my first question is: why is the planner still sorting on price when +isbn seems (considerably) quicker, and how can I force it to sort by +isbn(if I even should)? + +The second question is: why, oh why does the update take such and +obscenely long time to complete? The 175s (and even 216s) for the +select seems reasonable given the size of the tables, but not 3000s to +update the same rows. The processor (AMD 1.3GHz) is 90%+ utilization for +most of the execution time. + +I can post more information if it would be helpful, but this post is +long enough already. + +TIA, and happy new year. + +-mike + + +-- +Mike Glover +Key ID BFD19F2C + +--=.lOrWFPH0Z)WqCU +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQE/9OapZrNpxr/RnywRAqCnAJ9A70H01+oIh9mSldPhtpbliawQawCcD4lB +n9Tg01I8ywLkBeQFjiSIupk= +=VcSD +-----END PGP SIGNATURE----- + +--=.lOrWFPH0Z)WqCU-- + +From pgsql-performance-owner@postgresql.org Fri Jan 2 00:07:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CDBBED1B453 + for ; + Fri, 2 Jan 2004 04:07:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89890-08 + for ; + Fri, 2 Jan 2004 00:06:28 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B157D1B436 + for ; + Fri, 2 Jan 2004 00:06:28 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i0246B19002967; + Thu, 1 Jan 2004 23:06:11 -0500 (EST) +To: Mike Glover +Cc: pgsql-performance@postgresql.org +Subject: Re: Very slow update + not using clustered index +In-reply-to: <20040101193401.6640420b.mpg4@duluoz.net> +References: <20040101193401.6640420b.mpg4@duluoz.net> +Comments: In-reply-to Mike Glover + message dated "Thu, 01 Jan 2004 19:34:01 -0800" +Date: Thu, 01 Jan 2004 23:06:11 -0500 +Message-ID: <2966.1073016371@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/3 +X-Sequence-Number: 5178 + +Mike Glover writes: +> I want to run the following query, but it takes a *very* long time. +> Like this: +> bookshelf=> explain analyze update summary set price_min=0, +> availability=2, condition=9 where isbn = inventory.isbn and price_min = +> inventory.price; +> ... +> Total runtime: 3162319.477 ms(9 rows) + +> Running what I believe to be the comparable select query is more +> reasonable: + +> bookshelf=> explain analyze select s.* from summary s, inventory i where +> s.isbn = i.isbn and s.price_min = i.price; +> ... +> Total runtime: 216324.171 ms + +AFAICS these plans are identical, and therefore the difference in +runtime must be ascribed to the time spent actually doing the updates. +It seems unlikely that the raw row inserts and updating the single +index could be quite that slow --- perhaps you have a foreign key +or trigger performance problem? + +> So, my first question is: why is the planner still sorting on price when +> isbn seems (considerably) quicker, and how can I force it to sort by +> isbn(if I even should)? + +Is this PG 7.4? It looks to me like the planner *should* consider both +possible orderings of the mergejoin sort keys. I'm not sure that it +knows enough to realize that the key with more distinct values should be +put first, however. + +A quick experiment shows that if the planner does not have any reason to +prefer one ordering over another, the current coding will put the last +WHERE clause first: + +regression=# create table t1(f1 int, f2 int); +CREATE TABLE +regression=# create table t2(f1 int, f2 int); +CREATE TABLE +regression=# explain select * from t1,t2 where t1.f1=t2.f1 and t1.f2=t2.f2; + QUERY PLAN +------------------------------------------------------------------------- + Merge Join (cost=139.66..154.91 rows=25 width=16) + Merge Cond: (("outer".f2 = "inner".f2) AND ("outer".f1 = "inner".f1)) + -> Sort (cost=69.83..72.33 rows=1000 width=8) + Sort Key: t1.f2, t1.f1 + -> Seq Scan on t1 (cost=0.00..20.00 rows=1000 width=8) + -> Sort (cost=69.83..72.33 rows=1000 width=8) + Sort Key: t2.f2, t2.f1 + -> Seq Scan on t2 (cost=0.00..20.00 rows=1000 width=8) +(8 rows) + +regression=# explain select * from t1,t2 where t1.f2=t2.f2 and t1.f1=t2.f1; + QUERY PLAN +------------------------------------------------------------------------- + Merge Join (cost=139.66..154.91 rows=25 width=16) + Merge Cond: (("outer".f1 = "inner".f1) AND ("outer".f2 = "inner".f2)) + -> Sort (cost=69.83..72.33 rows=1000 width=8) + Sort Key: t1.f1, t1.f2 + -> Seq Scan on t1 (cost=0.00..20.00 rows=1000 width=8) + -> Sort (cost=69.83..72.33 rows=1000 width=8) + Sort Key: t2.f1, t2.f2 + -> Seq Scan on t2 (cost=0.00..20.00 rows=1000 width=8) +(8 rows) + +and so you could probably improve matters just by switching the order of +your WHERE clauses. Of course this answer will break as soon as anyone +touches any part of the related code, so I'd like to try to fix it so +that there is actually a principled choice made. Could you send along +the pg_stats rows for these columns? + +> The second question is: why, oh why does the update take such and +> obscenely long time to complete? + +See above --- the problem is not within the plan, but must be sought +elsewhere. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Jan 3 02:50:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DE1D4D1C956 + for ; + Sat, 3 Jan 2004 06:50:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31700-05 + for ; + Sat, 3 Jan 2004 02:49:47 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id C94C9D1C919 + for ; + Sat, 3 Jan 2004 02:49:45 -0400 (AST) +Received: from [203.221.247.106] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #2) + id 1AcHN3-0007wH-00; Fri, 02 Jan 2004 15:57:14 +1100 +Message-ID: <3FF4FA25.7050802@familyhealth.com.au> +Date: Fri, 02 Jan 2004 12:57:09 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Vivek Khera +Cc: pgsql-performance@postgresql.org +Subject: Re: deferred foreign keys +References: + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/15 +X-Sequence-Number: 5190 + +> One more question: does the FK checker know to skip checking a +> constraint if the column in question did not change during an update? +> +> That is, if I have a user table that references an owner_id in an +> owners table as a foreign key, but I update fields other than owner_id +> in the user table, will it still try to verify that owner_id is a +> valid value even though it did not change? +> +> I'm using PG 7.4. + +As of 7.4, yes the check is skipped. + +Chris + +From pgsql-performance-owner@postgresql.org Fri Jan 2 02:17:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D54DFD1B499 + for ; + Fri, 2 Jan 2004 06:17:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03672-04 + for ; + Fri, 2 Jan 2004 02:16:37 -0400 (AST) +Received: from pomeray.duluoz.net (12-241-192-70.client.attbi.com + [12.241.192.70]) + by svr1.postgresql.org (Postfix) with ESMTP id E8D3ED1B4A1 + for ; + Fri, 2 Jan 2004 02:16:35 -0400 (AST) +Received: (qmail 2133 invoked by uid 1000); 2 Jan 2004 06:16:34 -0000 +Date: Thu, 1 Jan 2004 22:16:30 -0800 +From: Mike Glover +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Very slow update + not using clustered index +Message-Id: <20040101221630.4b001c35.mpg4@duluoz.net> +In-Reply-To: <2966.1073016371@sss.pgh.pa.us> +References: <20040101193401.6640420b.mpg4@duluoz.net> + <2966.1073016371@sss.pgh.pa.us> +X-Mailer: Sylpheed version 0.9.0claws (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg="pgp-sha1"; boundary="=.:X5DcK3,R.IM5H" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/4 +X-Sequence-Number: 5179 + +--=.:X5DcK3,R.IM5H +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit + +Tom- + + Thanks for the quick response. More details are inline. + +-mike + +On Thu, 01 Jan 2004 23:06:11 -0500 +Tom Lane wrote: + +> Mike Glover writes: + +> AFAICS these plans are identical, and therefore the difference in +> runtime must be ascribed to the time spent actually doing the updates. +> It seems unlikely that the raw row inserts and updating the single +> index could be quite that slow --- perhaps you have a foreign key +> or trigger performance problem? + + There are no foreign keys or triggers for either of the tables. + +> Is this PG 7.4? + +Yes, PG 7.4 + +> +> A quick experiment shows that if the planner does not have any reason +> to prefer one ordering over another, the current coding will put the +> last WHERE clause first: +[snip]> +> and so you could probably improve matters just by switching the order +> of your WHERE clauses. Of course this answer will break as soon as +> anyone touches any part of the related code, so I'd like to try to fix +> it so that there is actually a principled choice made. Could you send +> along the pg_stats rows for these columns? +> + +It looks like the planner is already making a principled choice: + +bookshelf=> explain select s.* from summary s, inventory i where s.isbn += i.isbn and s.price_min = i.price; + QUERY PLAN +----------------------------------------------------------------------- +Merge Join (cost=491180.66..512965.72 rows=9237 width=58) + Merge Cond: (("outer".price_min = "inner".price) +AND ("outer"."?column8?" = "inner"."?column3?")) + -> Sort (cost=361887.05..367000.05 rows=2045201 width=58) + Sort Key: s.price_min, (s.isbn)::text + -> Seq Scan on summary s (cost=0.00..44651.01 rows=2045201 +width=58) + -> Sort (cost=129293.61..131499.09 rows=882192 width=25) + Sort Key: i.price, (i.isbn)::text + -> Seq Scan on inventory i (cost=0.00..16173.92 rows=882192 +width=25) +(8 rows) + +bookshelf=> explain select s.* from summary s, inventory i where +s.price_min = i.price and s.isbn = i.isbn; + QUERY PLAN +----------------------------------------------------------------------- +Merge Join (cost=491180.66..512965.72 rows=9237 width=58) + Merge Cond: (("outer".price_min = "inner".price) AND +("outer"."?column8?" ="inner"."?column3?")) + -> Sort (cost=361887.05..367000.05 rows=2045201 width=58) + Sort Key: s.price_min, (s.isbn)::text + -> Seq Scan on summary s (cost=0.00..44651.01 rows=2045201 +width=58) + -> Sort(cost=129293.61..131499.09 rows=882192 width=25) + Sort Key: i.price, (i.isbn)::text + -> Seq Scan on inventory i (cost=0.00..16173.92 rows=882192 +width=25) +(8 rows) + +Here are the pg_stats rows: +bookshelf=> select * from pg_stats where schemaname='de' and +tablename='inventory' and attname='isbn'; schemaname | tablename | +attname | null_frac | avg_width | n_distinct | most_common_vals | +most_common_freqs | +histogram_bounds | +correlation +------------+-----------+---------+-----------+-----------+------------ ++------------------+-------------------+------------------------------- +----------------------------------------------------------------------- +----------------------+------------- de | inventory | isbn | + 0 | 14 | -1 | | +| +{0002551543,0198268211,0375507299,0486231305,0673395197,0767901576,0810 +304430,0865738890,0931595029,1574160052,9971504014} | 1(1 row) + +bookshelf=> select * from pg_stats where schemaname='de' and +tablename='inventory' and attname='price'; schemaname | tablename | +attname | null_frac | avg_width | n_distinct | +most_common_vals | + most_common_freqs | + histogram_bounds | +correlation +------------+-----------+---------+-----------+-----------+------------ ++--------------------------------------------------------------+------- +----------------------------------------------------------------------- +-----------------------+----------------------------------------------- +--------------------------+------------- de | inventory | price + | 0 | 11 | 1628 | +{59.95,0.00,54.88,53.30,60.50,64.25,73.63,49.39,50.02,53.37} | +{0.259667,0.00633333,0.00533333,0.00466667,0.00466667,0.00466667,0.0046 +6667,0.00433333,0.004,0.004} | +{49.16,52.06,55.53,59.56,63.78,68.90,76.90,88.53,106.16,143.75,1538.88} +| 0.149342(1 row) + +bookshelf=> select * from pg_stats where schemaname='de' and +tablename='summary' and attname='isbn'; schemaname | tablename | attname +| null_frac | avg_width | n_distinct | most_common_vals | +most_common_freqs | +histogram_bounds | +correlation +------------+-----------+---------+-----------+-----------+------------ ++------------------+-------------------+------------------------------- +----------------------------------------------------------------------- +----------------------+------------- de | summary | isbn | + 0 | 14 | -1 | | +| +{0001984209,020801912X,0395287693,055214911X,0722525915,0787630896,0822 +218100,0883856263,1413900275,1843910381,9999955045} | 1(1 row) + +bookshelf=> select * from pg_stats where schemaname='de' and +tablename='summary' and attname='price_min'; schemaname | tablename | +attname | null_frac | avg_width | n_distinct | +most_common_vals | + most_common_freqs | + histogram_bounds | +correlation +------------+-----------+-----------+-----------+-----------+---------- +--+---------------------------------------------------------+---------- +----------------------------------------------------------------------- +-------------------+--------------------------------------------------- +------------------+------------- de | summary | price_min | + 0 | 10 | 1532 | +{0.00,59.95,6.95,6.00,4.07,10.17,11.53,10.85,4.75,8.81} | +{0.425333,0.029,0.0193333,0.00533333,0.00333333,0.00333333,0.00333333,0 +.003,0.00266667,0.00266667} | +{0.05,7.11,10.30,14.28,19.54,27.86,50.47,61.25,76.44,104.79,744.73} | +0.0546667(1 row) + +(mangled a bit by the auto-linewrap, I'm afraid) + +> > The second question is: why, oh why does the update take such and +> > obscenely long time to complete? +> +> See above --- the problem is not within the plan, but must be sought +> elsewhere. +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- TIP 5: Have you checked our +> extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html + + +-- +Mike Glover +Key ID BFD19F2C + +--=.:X5DcK3,R.IM5H +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQE/9QzCZrNpxr/RnywRAkdvAJ9IzbSx+3uybk/oivFH/fFKhPmyoACfTmKp +M8Ulg4+/e00DFg9+Ev3GsuM= +=kKHh +-----END PGP SIGNATURE----- + +--=.:X5DcK3,R.IM5H-- + +From pgsql-performance-owner@postgresql.org Fri Jan 2 05:44:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 459C2D1B499 + for ; + Fri, 2 Jan 2004 09:44:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23320-02 + for ; + Fri, 2 Jan 2004 05:43:15 -0400 (AST) +Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) + by svr1.postgresql.org (Postfix) with ESMTP id 87F7AD1B49B + for ; + Fri, 2 Jan 2004 05:43:12 -0400 (AST) +Received: from mailer.elma.loc (localhost [127.0.0.1]) + by localhost (Postfix) with ESMTP id 0E730EC018 + for ; + Fri, 2 Jan 2004 10:43:17 +0100 (CET) +Received: from zoot.elma.fr (herve.elma.fr [10.0.1.2]) + by mailer.elma.loc (Postfix) with ESMTP id E874BEC00F + for ; + Fri, 2 Jan 2004 10:43:16 +0100 (CET) +From: =?iso-8859-15?q?Herv=E9=20Piedvache?= +Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique +To: pgsql-performance@postgresql.org +Subject: Why memory is not used ? Why vacuum so slow ? +Date: Fri, 2 Jan 2004 10:42:57 +0100 +User-Agent: KMail/1.5.4 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline +Message-Id: <200401021042.57714.herve@elma.fr> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/5 +X-Sequence-Number: 5180 + +Hi, + +I have tried to tune a database that I'm using only for statistical access ... +I mean that I'm importing a dump of my production database each night, but +preserving some aggregat tables, and statistics ones ... (that I'm +calculating after the importation of the dump). This database is only used by +few people but make some big requests, tables have mixed sizes between 200 +000 rows up to 10 000 000 records. + +This server's got 2Gb memory, and 100 Gb RAID 5 Hard disk, is a woody Debian, +and I'm using a self compiled version of PotsgreSQL v7.3.4. + +My postgresql.conf file looks like this : + +# +# Shared Memory Size +# +shared_buffers = 31000 # min max_connections*2 or 16, 8KB each +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 = 32 # min 4, typically 8KB each + +# +# Non-shared Memory Sizes +# +sort_mem = 32768 # min 64, size in KB +vacuum_mem = 32768 # min 1024, size in KB + +#checkpoint_segments = 3 # in logfile segments, min 1, 16MB each +checkpoint_timeout = 160 # range 30-3600, in seconds +effective_cache_size = 400000 # typically 8KB each +random_page_cost = 1.5 # units are one sequential page fetch cost + +Before my effective_cache_size was 1000 ... and reading some tuning pages and +comments telling : "effective_cache_size: You should adjust this according to +the amount of free memory you have." ... I grow it to 400000 ... + +Then ... first point I'm only using 5% of my memory (all linux system,and +software) ... and no swap (good point for this) ... Why I don't use more +memory ... ?? + +Second point ... after importing my dump ... I make a vacuum full analyze of +my base (in same time because of my caculation of the day before for my +aggregats and stats tables about 200 000 row deleted and/or inserted for more +than 20 tables (each)) ... but It takes about 5 hours ... + +Example of a (for me) really slow vacuum ... more than 85 min for a table with +only 9105740 records ... + +INFO: �--Relation public.hebcnt-- +INFO: �Pages 175115: Changed 0, reaped 3309, Empty 0, New 0; Tup 9105740: Vac +175330, Keep/VTL 0/0, UnUsed 0, MinLen 148, MaxLen 148; Re-using: Free/Avail. +Space 46265980/26336600; EndEmpty/Avail. Pages 0/3310. +��������CPU 6.75s/1.67u sec elapsed 91.41 sec. +INFO: �Index ix_hebcnt_idc: Pages 40446; Tuples 9105740: Deleted 175330. +��������CPU 2.94s/6.17u sec elapsed 222.34 sec. +INFO: �Index ix_hebcnt_cweek: Pages 229977; Tuples 9105740: Deleted 175330. +��������CPU 9.64s/3.14u sec elapsed 1136.01 sec. +INFO: �Index ix_hebcnt_cpte: Pages 72939; Tuples 9105740: Deleted 175330. +��������CPU 4.86s/9.13u sec elapsed 398.73 sec. +INFO: �Index ix_hebcnt_idctweek: Pages 66014; Tuples 9105740: Deleted 175330. +��������CPU 3.87s/8.61u sec elapsed 163.26 sec. +INFO: �Rel hebcnt: Pages: 175115 --> 171807; Tuple(s) moved: 175330. +��������CPU 16.49s/52.04u sec elapsed 1406.34 sec. +INFO: �Index ix_hebcnt_idc: Pages 40446; Tuples 9105740: Deleted 175330. +��������CPU 1.76s/5.65u sec elapsed 124.98 sec. +INFO: �Index ix_hebcnt_cweek: Pages 230690; Tuples 9105740: Deleted 175330. +��������CPU 10.07s/2.60u sec elapsed 1095.17 sec. +INFO: �Index ix_hebcnt_cpte: Pages 72940; Tuples 9105740: Deleted 175330. +��������CPU 4.51s/8.90u sec elapsed 353.45 sec. +INFO: �Index ix_hebcnt_idcweek: Pages 66015; Tuples 9105740: Deleted 175330. +��������CPU 3.96s/8.58u sec elapsed 147.64 sec. +INFO: �--Relation pg_toast.pg_toast_76059978-- +INFO: �Pages 0: Changed 0, reaped 0, Empty 0, New 0; Tup 0: Vac 0, Keep/VTL +0/0, UnUsed 0, MinLen 0, MaxLen 0; Re-using: Free/Avail. Space 0/0; EndEmpty/ +Avail. Pages 0/0. +��������CPU 0.00s/0.00u sec elapsed 0.02 sec. +INFO: �Index pg_toast_76059978_index: Pages 1; Tuples 0. +��������CPU 0.00s/0.00u sec elapsed 0.00 sec. +INFO: �Analyzing public.hebcnt + +Structure of this table : +frstats=# \d hebcnt + Table "public.hebcnt" + Column | Type | Modifiers +------------------+-----------------------------+------------------------ + id_c | integer | not null + contrat | text | not null + arrete_week | text | not null + cpte | text | not null + is_active | boolean | not null + year | text | not null + use | integer | not null + use_priv | integer | not null + use_ind | integer | not null + passback | integer | not null + resa | integer | not null + noshow | integer | not null + nbc | integer | not null + dureecnt | integer | not null + dureecpt | integer | not null + anciennete2 | integer | not null + c_week | text | not null + blacklist | integer | not null + dcrea | timestamp without time zone | not null default now() + dmaj | timestamp without time zone | +Indexes: ix_hebcnt_cweek btree (c_week), + ix_hebcnt_cpte btree (cpte), + ix_hebcnt_idc btree (id_c), + ix_hebcnt_idcweek btree (id_c, c_week) + +Any idea ? + +Regards, +-- +Herv� Piedvache + +Elma Ing�nierie Informatique +6 rue du Faubourg Saint-Honor� +F-75008 - Paris - France +Pho. 33-144949901 +Fax. 33-144949902 + + +From pgsql-performance-owner@postgresql.org Fri Jan 2 09:04:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 37955D1B43D + for ; + Fri, 2 Jan 2004 13:04:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38807-05 + for ; + Fri, 2 Jan 2004 09:03:44 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D522D1B45C + for ; + Fri, 2 Jan 2004 09:03:41 -0400 (AST) +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 i02D3eU6031441 + for ; Fri, 2 Jan 2004 13:03:40 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i02Cb1Mn006567 + for pgsql-performance@postgresql.org; Fri, 2 Jan 2004 12:37:01 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Tuning Techniques To Avoid? +Date: Fri, 02 Jan 2004 07:33:46 -0500 +Organization: cbbrowne Computing Inc +Lines: 16 +Message-ID: +References: <200401021042.57714.herve@elma.fr> +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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:DmG7XsX4zLYDs85FtnMSIc7wiaw= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/6 +X-Sequence-Number: 5181 + +Here's a scheme for query optimization that probably needs to be +avoided in that it would run afoul of a patent held by Oracle... + + + +It looks like what they have patented is pretty much a "greedy search" +heuristic, starting by finding the table in a join that has the +greatest selectivity (e.g. - where the number of entries selected is +cut the most by the selection criteria), and then describes how to +search for the "best" approach to joining in the other tables. +-- +output = reverse("gro.mca" "@" "enworbbc") +http://www.ntlug.org/~cbbrowne/nonrdbms.html +"If I could find a way to get [Saddam Hussein] out of there, even +putting a contract out on him, if the CIA still did that sort of a +thing, assuming it ever did, I would be for it." -- Richard M. Nixon + +From pgsql-performance-owner@postgresql.org Fri Jan 2 10:43:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 75183D1B4A6 + for ; + Fri, 2 Jan 2004 14:43:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44686-10 + for ; + Fri, 2 Jan 2004 10:42:40 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id E4E09D1B4CE + for ; + Fri, 2 Jan 2004 10:42:30 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i02EgS19005631; + Fri, 2 Jan 2004 09:42:28 -0500 (EST) +To: =?iso-8859-15?q?Herv=E9=20Piedvache?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Why memory is not used ? Why vacuum so slow ? +In-reply-to: <200401021042.57714.herve@elma.fr> +References: <200401021042.57714.herve@elma.fr> +Comments: In-reply-to =?iso-8859-15?q?Herv=E9=20Piedvache?= + message dated "Fri, 02 Jan 2004 10:42:57 +0100" +Date: Fri, 02 Jan 2004 09:42:28 -0500 +Message-ID: <5630.1073054548@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/7 +X-Sequence-Number: 5182 + +=?iso-8859-15?q?Herv=E9=20Piedvache?= writes: +> Second point ... after importing my dump ... I make a vacuum full analyze of +> my base (in same time because of my caculation of the day before for my +> aggregats and stats tables about 200 000 row deleted and/or inserted for more +> than 20 tables (each)) ... but It takes about 5 hours ... + +Don't do vacuum full. You should not need it in ordinary circumstances, +if you are doing plain vacuums on a reasonable schedule and you have the +FSM parameters set high enough. (You do not BTW ... with 175000 pages in +this table alone, 10000 FSM pages for the whole database is surely too +low.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jan 2 12:52:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E41BCD1D988 + for ; + Fri, 2 Jan 2004 16:52:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49201-09 + for ; + Fri, 2 Jan 2004 12:52:03 -0400 (AST) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BB79D1D958 + for ; + Fri, 2 Jan 2004 12:51:54 -0400 (AST) +Received: from mailer.elma.loc (unknown [213.41.14.138]) + by www.postgresql.com (Postfix) with ESMTP id 3E3B9CF8A0D + for ; + Fri, 2 Jan 2004 12:47:58 -0400 (AST) +Received: from mailer.elma.loc (localhost [127.0.0.1]) + by localhost (Postfix) with ESMTP + id 10D56EC018; Fri, 2 Jan 2004 16:18:47 +0100 (CET) +Received: from zoot.elma.fr (herve.elma.fr [10.0.1.2]) + by mailer.elma.loc (Postfix) with ESMTP + id DBA3AEC00D; Fri, 2 Jan 2004 16:18:46 +0100 (CET) +From: =?iso-8859-15?q?Herv=E9=20Piedvache?= +Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique +To: Tom Lane +Subject: Re: Why memory is not used ? Why vacuum so slow ? +Date: Fri, 2 Jan 2004 16:18:28 +0100 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: <200401021042.57714.herve@elma.fr> <5630.1073054548@sss.pgh.pa.us> +In-Reply-To: <5630.1073054548@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline +Message-Id: <200401021618.28300.herve@elma.fr> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/8 +X-Sequence-Number: 5183 + +Hi Tom, + +Le Vendredi 2 Janvier 2004 15:42, Tom Lane a �crit : +> =?iso-8859-15?q?Herv=E9=20Piedvache?= writes: +> > Second point ... after importing my dump ... I make a vacuum full analyze +> > of my base (in same time because of my caculation of the day before for +> > my aggregats and stats tables about 200 000 row deleted and/or inserted +> > for more than 20 tables (each)) ... but It takes about 5 hours ... +> +> Don't do vacuum full. You should not need it in ordinary circumstances, +> if you are doing plain vacuums on a reasonable schedule and you have the +> FSM parameters set high enough. (You do not BTW ... with 175000 pages in +> this table alone, 10000 FSM pages for the whole database is surely too +> low.) + +Ok for this ... I have now configured the FSM pages to 300 000 ... then when I +have started the database I get a message about my SHMMAX too low ... it was +set to : +more /proc/sys/kernel/shmmax +262111232 + +Then I put 300000000 ... PostgreSQL accepted to start ... What can be maximum +value for this ? To be usufull to the entire configuration ... ? + +Like this during during the vacuum full this is my used memory ... + total used free shared buffers cached +Mem: 2069608 2059052 10556 0 8648 1950672 +-/+ buffers/cache: 99732 1969876 +Swap: 2097136 16080 2081056 + +Seems that's I'm really using 5% of my memory ??? no ? or I missed something ? + +Now difficult to test again ... I will have to wait tomorrow morning to see +the result ... because I have already vacuumed the base to day ... + +But I have done again a full vacuum to see if I have quick visible +difference ... and I have also saw that the full vacuum for pg_atribute seems +to be so slow ... more than 1 min for 7256 tupples ? Is this is normal ? + +INFO: --Relation pg_catalog.pg_attribute-- +INFO: Pages 119: Changed 0, reaped 1, Empty 0, New 0; Tup 7256: Vac 0, Keep/ +VTL 0/0, UnUsed 3, MinLen 128, MaxLen 128; Re-using: Free/Avail. Space +14664/504; EndEmpty/Avail. Pages 0/1. + CPU 0.00s/0.00u sec elapsed 0.08 sec. +INFO: Index pg_attribute_relid_attnam_index: Pages 21082; Tuples 7256: +Deleted 0. + CPU 0.83s/0.13u sec elapsed 59.32 sec. +INFO: Index pg_attribute_relid_attnum_index: Pages 5147; Tuples 7256: Deleted +0. + CPU 0.26s/0.03u sec elapsed 8.79 sec. +INFO: Rel pg_attribute: Pages: 119 --> 119; Tuple(s) moved: 0. + CPU 0.00s/0.00u sec elapsed 0.00 sec. +INFO: Analyzing pg_catalog.pg_attribute + +Thanks for your help ... + +Regards, +-- +Herv� Piedvache + +Elma Ing�nierie Informatique +6 rue du Faubourg Saint-Honor� +F-75008 - Paris - France +Pho. 33-144949901 +Fax. 33-144949902 + + +From pgsql-performance-owner@postgresql.org Fri Jan 2 18:29:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D6E8AD1D61F + for ; + Fri, 2 Jan 2004 22:29:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65442-01 + for ; + Fri, 2 Jan 2004 18:28:51 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A3BB6D1DE50 + for ; + Fri, 2 Jan 2004 18:16:15 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i02Fj719005887; + Fri, 2 Jan 2004 10:45:07 -0500 (EST) +To: Mike Glover +Cc: pgsql-performance@postgresql.org +Subject: Re: Very slow update + not using clustered index +In-reply-to: <20040101221630.4b001c35.mpg4@duluoz.net> +References: <20040101193401.6640420b.mpg4@duluoz.net> + <2966.1073016371@sss.pgh.pa.us> + <20040101221630.4b001c35.mpg4@duluoz.net> +Comments: In-reply-to Mike Glover + message dated "Thu, 01 Jan 2004 22:16:30 -0800" +Date: Fri, 02 Jan 2004 10:45:07 -0500 +Message-ID: <5886.1073058307@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/10 +X-Sequence-Number: 5185 + +Mike Glover writes: +> Tom Lane wrote: +>> It seems unlikely that the raw row inserts and updating the single +>> index could be quite that slow --- perhaps you have a foreign key +>> or trigger performance problem? + +> There are no foreign keys or triggers for either of the tables. + +Hmph. It's clear that it is the update overhead that's taking the time +(since you show 292 seconds actual time in the update's top plan node +--- that's the time to find the rows and compute their new values, and +all the rest of the elapsed 3162 sec has to be update overhead). Maybe +you just have a slow disk. + +Just out of curiosity, how much time does the update take if you don't +have any index on the summary table? Try + + create temp table tsummary as select * from summary; + vacuum analyze tsummary; + explain analyze update tsummary set ... ; + + +>> A quick experiment shows that if the planner does not have any reason +>> to prefer one ordering over another, the current coding will put the +>> last WHERE clause first: +> [snip]> + +> It looks like the planner is already making a principled choice: + +After a little bit of experimentation I was reminded that the planner +does account for the possibility that a merge join can stop short of +full execution when the first mergejoin columns have different data +ranges. In this case it's preferring to put price first because there +is a greater discrepancy in the ranges of s.price_min and i.price than +there is in the ranges of the isbn columns. I'm not sure that it's +wrong. You could try increasing the statistics target on the price +columns (and re-ANALYZing) to see if finer-grain data changes that +estimate at all. + +In any case, the fact that the chosen plan doesn't make use of your +index on isbn doesn't mean that such a plan wasn't considered. It was, +but this plan was estimated to be less expensive. You could check out +alternative plans and see if the estimate is accurate by fooling with +enable_seqscan and enable_sort. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jan 2 18:29:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CC0CD1D17D + for ; + Fri, 2 Jan 2004 22:29:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65516-02 + for ; + Fri, 2 Jan 2004 18:28:40 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A403CD1DE41 + for ; + Fri, 2 Jan 2004 18:16:12 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i02FpD19005931; + Fri, 2 Jan 2004 10:51:13 -0500 (EST) +To: =?iso-8859-15?q?Herv=E9=20Piedvache?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Why memory is not used ? Why vacuum so slow ? +In-reply-to: <200401021618.28300.herve@elma.fr> +References: <200401021042.57714.herve@elma.fr> <5630.1073054548@sss.pgh.pa.us> + <200401021618.28300.herve@elma.fr> +Comments: In-reply-to =?iso-8859-15?q?Herv=E9=20Piedvache?= + message dated "Fri, 02 Jan 2004 16:18:28 +0100" +Date: Fri, 02 Jan 2004 10:51:13 -0500 +Message-ID: <5930.1073058673@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/9 +X-Sequence-Number: 5184 + +=?iso-8859-15?q?Herv=E9=20Piedvache?= writes: +> and I have also saw that the full vacuum for pg_atribute seems +> to be so slow ... more than 1 min for 7256 tupples ? Is this is normal ? + +> INFO: --Relation pg_catalog.pg_attribute-- +> INFO: Pages 119: Changed 0, reaped 1, Empty 0, New 0; Tup 7256: Vac 0, Keep/ +> VTL 0/0, UnUsed 3, MinLen 128, MaxLen 128; Re-using: Free/Avail. Space +> 14664/504; EndEmpty/Avail. Pages 0/1. +> CPU 0.00s/0.00u sec elapsed 0.08 sec. +> INFO: Index pg_attribute_relid_attnam_index: Pages 21082; Tuples 7256: +> Deleted 0. +> CPU 0.83s/0.13u sec elapsed 59.32 sec. +> INFO: Index pg_attribute_relid_attnum_index: Pages 5147; Tuples 7256: Deleted +> 0. +> CPU 0.26s/0.03u sec elapsed 8.79 sec. + +You're suffering from index bloat (21000 pages in an index for a +119-page table!?). Updating to 7.4 would probably fix this, but +if that's not practical consider reindexing pg_attribute. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jan 2 22:54:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A76C2D1D0F2 + for ; + Sat, 3 Jan 2004 02:54:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94828-04 + for ; + Fri, 2 Jan 2004 22:53:36 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 130B9D1D450 + for ; + Fri, 2 Jan 2004 22:18:48 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 58B32375C3; Fri, 2 Jan 2004 21:18:45 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1AcbNF-0004fR-00; Fri, 02 Jan 2004 21:18:45 -0500 +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: Tuning Techniques To Avoid? +References: <200401021042.57714.herve@elma.fr> + +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 02 Jan 2004 21:18:45 -0500 +Message-ID: <8765ft22re.fsf@stark.dyndns.tv> +Lines: 11 +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 postgresql.org +X-Archive-Number: 200401/11 +X-Sequence-Number: 5186 + + +Christopher Browne writes: + +> Here's a scheme for query optimization that probably needs to be +> avoided in that it would run afoul of a patent held by Oracle... + +What does this have to do with Herv� Piedvache's post "Why memory is not +used?" ? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sat Jan 3 01:38:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BAE7D1B44E + for ; + Sat, 3 Jan 2004 05:38:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23222-08 + for ; + Sat, 3 Jan 2004 01:37:53 -0400 (AST) +Received: from ms-smtp-04.tampabay.rr.com (ms-smtp-04-smtplb.tampabay.rr.com + [65.32.5.134]) + by svr1.postgresql.org (Postfix) with ESMTP id AD6F4D1B446 + for ; + Sat, 3 Jan 2004 01:37:39 -0400 (AST) +Received: from unity.basin.cultured.net (24161231hfc249.tampabay.rr.com + [24.161.231.249]) + by ms-smtp-04.tampabay.rr.com (8.12.10/8.12.7) with ESMTP id + i035bWu7003598 for ; + Sat, 3 Jan 2004 00:37:33 -0500 (EST) +Subject: "fun with multipart primary keys" hobby kit +From: Chris Trawick +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Message-Id: <1073108262.733.27.camel@unity.basin.cultured.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Sat, 03 Jan 2004 00:37:43 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Symantec AntiVirus Scan Engine +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/12 +X-Sequence-Number: 5187 + +I tried searching the archives to find something like this. The search +function doesn't like me much, and believe me the feeling is mutual. So +I'm forced to pollute your inboxes with yet another "why the hell isn't +this thing using my index" email. I apologize in advance. + +I have a many-to-many relation table with a multipart primary key: + +siren=# \d listcontact + Table "public.listcontact" + Column | Type | Modifiers +----------------+---------+----------- + contactlistid | integer | not null + contactid | bigint | not null +Indexes: listcontact_pkey primary key btree (contactlistid, contactid) + +(There were some FKs in there too, but I stripped off everything I could +during my investigation and they didn't survive.) I'm doing some +performance testing so I loaded it with a few elephant piles: + +siren=# select count(*) from listcontact; + count +--------- + 1409196 +(1 row) + +And packed it down good: + +siren=# vacuum full analyze; +VACUUM + +I didn't get the performance I expected. I took one of our queries and +mutilated it and found some curious behavior on this table. I started +running queries on just this table and couldn't explain what I was +seeing. I tried this: + +siren=# EXPLAIN ANALYZE SELECT * FROM ListContact WHERE contactListID=-1 +AND contactID=91347; + + QUERY +PLAN +--------------------------------------------------------------------------------------------------------- + Seq Scan on listcontact (cost=0.00..29427.94 rows=1 width=12) (actual +time=893.15..5079.52 rows=1 loops=1) + Filter: ((contactlistid = -1) AND (contactid = 91347)) + Total runtime: 5079.74 msec +(3 rows) + +A seqscan... Fair enough, there's lots of memory on this box. I didn't +want to see a seqscan though, I wanted to see an index. So, I disabled +seqscan and tried it again: + + QUERY +PLAN +------------------------------------------------------------------------------------------------------------------------------ + Index Scan using listcontact_pkey on listcontact (cost=0.00..58522.64 +rows=1 width=12) (actual time=402.73..9419.77 rows=1 loops=1) + Index Cond: (contactlistid = -1) + Filter: (contactid = 91347) + Total runtime: 9419.97 msec +(4 rows) + +Am I reading this right? Is it only using half of the fully-qualified +pk index? How do I diagnose this? Has anyone seen this before? + +postgresql 7.3.1 +linux 2.6.0 +quad xeon 450 + +chris + + +From pgsql-performance-owner@postgresql.org Sat Jan 3 01:58:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8FCFDD1B45A + for ; + Sat, 3 Jan 2004 05:58:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28950-05 + for ; + Sat, 3 Jan 2004 01:58:04 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 38F68D1B4AE + for ; + Sat, 3 Jan 2004 01:58:03 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i035vs19019197; + Sat, 3 Jan 2004 00:57:54 -0500 (EST) +To: Chris Trawick +Cc: pgsql-performance@postgresql.org +Subject: Re: "fun with multipart primary keys" hobby kit +In-reply-to: <1073108262.733.27.camel@unity.basin.cultured.net> +References: <1073108262.733.27.camel@unity.basin.cultured.net> +Comments: In-reply-to Chris Trawick + message dated "Sat, 03 Jan 2004 00:37:43 -0500" +Date: Sat, 03 Jan 2004 00:57:54 -0500 +Message-ID: <19196.1073109474@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/13 +X-Sequence-Number: 5188 + +Chris Trawick writes: +> contactid | bigint | not null + ^^^^^^ + +> Am I reading this right? Is it only using half of the fully-qualified +> pk index? How do I diagnose this? Has anyone seen this before? + +Surely you've been around here long enough to remember the +must-cast-bigint-constants problem. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Jan 3 02:08:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CB81D1B45E + for ; + Sat, 3 Jan 2004 06:08:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31118-04 + for ; + Sat, 3 Jan 2004 02:07:11 -0400 (AST) +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 B0780D1B4CA + for ; + Sat, 3 Jan 2004 02:07:10 -0400 (AST) +Received: from unity.basin.cultured.net (24161231hfc249.tampabay.rr.com + [24.161.231.249]) + by ms-smtp-02.tampabay.rr.com (8.12.10/8.12.7) with ESMTP id + i03674qX005076; Sat, 3 Jan 2004 01:07:04 -0500 (EST) +Subject: Re: "fun with multipart primary keys" hobby kit +From: Chris Trawick +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <19196.1073109474@sss.pgh.pa.us> +References: <1073108262.733.27.camel@unity.basin.cultured.net> + <19196.1073109474@sss.pgh.pa.us> +Content-Type: text/plain +Message-Id: <1073110034.733.42.camel@unity.basin.cultured.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Sat, 03 Jan 2004 01:07:14 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Symantec AntiVirus Scan Engine +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/14 +X-Sequence-Number: 5189 + +Actually, it would appear that I was born yesterday. I had no idea. +Added the cast and it fell right in. Thanks! + +chris <-- feeling pretty dumb right now + + +On Sat, 2004-01-03 at 00:57, Tom Lane wrote: +> Chris Trawick writes: +> > contactid | bigint | not null +> ^^^^^^ +> +> > Am I reading this right? Is it only using half of the fully-qualified +> > pk index? How do I diagnose this? Has anyone seen this before? +> +> Surely you've been around here long enough to remember the +> must-cast-bigint-constants problem. +> +> regards, tom lane + + +From pgsql-performance-owner@postgresql.org Sat Jan 3 21:19:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 79172D1B442 + for ; + Sun, 4 Jan 2004 01:19:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 09025-05 + for ; + Sat, 3 Jan 2004 21:18:39 -0400 (AST) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 41A69D1B454 + for ; + Sat, 3 Jan 2004 21:18:27 -0400 (AST) +Received: from lorenso.com (c-24-1-26-144.client.comcast.net[24.1.26.144]) + by comcast.net (sccrmhc13) with ESMTP + id <20040104011835016008tgk8e>; Sun, 4 Jan 2004 01:18:35 +0000 +Message-ID: <3FF769EA.7090508@lorenso.com> +Date: Sat, 03 Jan 2004 19:18:34 -0600 +From: "D. Dante Lorenso" +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Indexing a Boolean or Null column? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/16 +X-Sequence-Number: 5191 + + +I've been debating with a collegue who argues that indexing a +boolean column is a BAD idea and that is will actually slow +down queries. + +My plan is to have a table with many rows sharing 'versions' +(version/archive/history) of data where the most current row +is the one where 'is_active' contains a true value. + +If the table begins to look like this: + +data_id(pk) | data_lookup_key | data_is_active | ... +------------+-----------------+----------------+-------- +1 | banana | false | ... +2 | banana | false | ... +3 | banana | false | ... +4 | banana | false | ... +5 | banana | false | ... +6 | banana | false | ... +7 | banana | false | ... +8 | banana | false | ... +9 | banana | true | ... +10 | apple | true | ... +11 | pear | false | ... +12 | pear | false | ... +13 | pear | false | ... +14 | pear | false | ... +15 | pear | false | ... +... +1000000 | pear | true | ... + +Will an index on the 'data_is_active' column be used or work +as I expect? I'm assuming that I may have a million entries +sharing the same 'data_lookup_key' and I'll be using that to +search for the active version of the row. + + SELECT * + FROM table + WHERE data_lookup_key = 'pear' + AND data_is_active IS TRUE; + +Does it make sense to have an index on data_is_active? + +Now, I've read that in some databases the index on a column that +has relatively even distribution of values over a small set of values +will not be efficient. + +I bet this is in a FAQ somewhere. Can you point me in the right +direction? + +Dante + + + + + +From pgsql-performance-owner@postgresql.org Sun Jan 4 00:27:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B4431D1C526 + for ; + Sun, 4 Jan 2004 04:27:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 34794-01 + for ; + Sun, 4 Jan 2004 00:26:56 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 499D3D1B4A7 + for ; + Sun, 4 Jan 2004 00:26:55 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i044Qq19017337; + Sat, 3 Jan 2004 23:26:53 -0500 (EST) +To: "D. Dante Lorenso" +Cc: pgsql-performance@postgresql.org +Subject: Re: Indexing a Boolean or Null column? +In-reply-to: <3FF769EA.7090508@lorenso.com> +References: <3FF769EA.7090508@lorenso.com> +Comments: In-reply-to "D. Dante Lorenso" + message dated "Sat, 03 Jan 2004 19:18:34 -0600" +Date: Sat, 03 Jan 2004 23:26:52 -0500 +Message-ID: <17336.1073190412@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/17 +X-Sequence-Number: 5192 + +"D. Dante Lorenso" writes: +> Does it make sense to have an index on data_is_active? + +Hard to say. You weren't very clear about what fraction of the table +rows you expect to have data_is_active = true. If that's a very small +fraction, then an index might be worthwhile. + +However, I'd suggest using a partial index that merges the is_active +test with some other useful behavior. For example, if this is a +common pattern: + +> SELECT * +> FROM table +> WHERE data_lookup_key = 'pear' +> AND data_is_active IS TRUE; + +then what you really want is + +CREATE INDEX myindex ON table (data_lookup_key) WHERE data_is_active IS TRUE; + +> I bet this is in a FAQ somewhere. Can you point me in the right +> direction? + +See the docs on partial indexes. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Jan 4 00:33:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D4E78D1B4BD + for ; + Sun, 4 Jan 2004 04:33:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31429-09 + for ; + Sun, 4 Jan 2004 00:32:45 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F4EED1B4AE + for ; + Sun, 4 Jan 2004 00:32:44 -0400 (AST) +Received: from [203.221.247.184] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #2) + id 1AczwP-0008AO-00; Sun, 04 Jan 2004 15:32:41 +1100 +Message-ID: <3FF79764.6060805@familyhealth.com.au> +Date: Sun, 04 Jan 2004 12:32:36 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "D. Dante Lorenso" +Cc: pgsql-performance@postgresql.org +Subject: Re: Indexing a Boolean or Null column? +References: <3FF769EA.7090508@lorenso.com> +In-Reply-To: <3FF769EA.7090508@lorenso.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/18 +X-Sequence-Number: 5193 + +> Will an index on the 'data_is_active' column be used or work +> as I expect? I'm assuming that I may have a million entries +> sharing the same 'data_lookup_key' and I'll be using that to +> search for the active version of the row. + +An index just on a boolean column won't be 'selective enough'. eg. The +index will only be able to choose 50% of the table - since it's faster +to do a full table scan in that case, the index won't get used. + +A multi keyed index, however will work a bit better, eg an index over +(data_lookup_key, data_is_active). + +That way, the index will first be able to find the correct key (which is +nicely selective) and then will be able to halve the resulting search +space to get the active ones. + +BTW, you shouldn't use 'banana', 'pear', etc as the data_lookup_key, you +should make another table like this: + +id name +1 banana +2 apple +3 pear + +And then replace the data_lookup_key col with a column of integers that +is a foreign key to the names table - waaaaay faster to process. + +Chris + + +From pgsql-performance-owner@postgresql.org Sun Jan 4 01:25:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EE7ED1B454 + for ; + Sun, 4 Jan 2004 05:25:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40461-02 + for ; + Sun, 4 Jan 2004 01:24:45 -0400 (AST) +Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [204.127.202.56]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E349D1B479 + for ; + Sun, 4 Jan 2004 01:24:44 -0400 (AST) +Received: from lorenso.com (c-24-1-26-144.client.comcast.net[24.1.26.144]) + by comcast.net (sccrmhc12) with ESMTP + id <2004010405244101200hrj9ce>; Sun, 4 Jan 2004 05:24:44 +0000 +Message-ID: <3FF7A395.4050106@lorenso.com> +Date: Sat, 03 Jan 2004 23:24:37 -0600 +From: "D. Dante Lorenso" +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Kings-Lynne +Cc: pgsql-performance@postgresql.org +Subject: Re: Indexing a Boolean or Null column? +References: <3FF769EA.7090508@lorenso.com> + <3FF79764.6060805@familyhealth.com.au> +In-Reply-To: <3FF79764.6060805@familyhealth.com.au> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/19 +X-Sequence-Number: 5194 + +Christopher Kings-Lynne wrote: + + > > Will an index on the 'data_is_active' column be used or work + > > as I expect? I'm assuming that I may have a million entries + > > sharing the same 'data_lookup_key' and I'll be using that to + > > search for the active version of the row. + + > An index just on a boolean column won't be 'selective enough'. + > eg. The index will only be able to choose 50% of the table - + > since it's faster to do a full table scan in that case, the + > index won't get used. + +Ok, so ...evenly distributed data on small set of values forces +sequential scan since that's faster. I expected that based on +what I've read so far. + + > A multi keyed index, however will work a bit better, eg an index + > over (data_lookup_key, data_is_active). + > + > That way, the index will first be able to find the correct + > key (which is nicely selective) and then will be able to + > halve the resulting ? search space to get the active ones. + +I'm not using the 50% TRUE / 50% FALSE model. My model will be +more like only ONE value IS TRUE for 'is_active' for each +'data_lookup_key' in my table. All the rest are FALSE. In +this case for 100 rows all having the same 'data_lookup_key' +we are looking at a 99% FALSE / 1% TRUE model ... and what I'll +be searching for is the ONE TRUE. + +In this case, it WILL pay off to have the index on a boolean +column, yes? Will I win my debate with my collegue? ;-) + +I think Tom Lanes suggestion of partial indexes is what I need to +look into. + + > BTW, you shouldn't use 'banana', 'pear', etc as the data_lookup_key, + > you should make another table like this: ... And then replace the + > data_lookup_key col with a column of integers that is a foreign + > key to the names table - waaaaay faster to process. + +Gotcha, yeah, I'm targeting as close to 3NF as I get get. Was just +trying to be generic for my example ... bad example, oops. + +Dante + + +From pgsql-performance-owner@postgresql.org Sun Jan 4 03:21:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E712D1B494 + for ; + Sun, 4 Jan 2004 07:21:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42671-10 + for ; + Sun, 4 Jan 2004 03:21:05 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id 33811D1BB71 + for ; + Sun, 4 Jan 2004 03:21:04 -0400 (AST) +Received: from [203.221.247.184] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #2) + id 1Ad2ZP-00057I-00; Sun, 04 Jan 2004 18:21:07 +1100 +Message-ID: <3FF7BEDD.7050208@familyhealth.com.au> +Date: Sun, 04 Jan 2004 15:21:01 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "D. Dante Lorenso" +Cc: pgsql-performance@postgresql.org +Subject: Re: Indexing a Boolean or Null column? +References: <3FF769EA.7090508@lorenso.com> + <3FF79764.6060805@familyhealth.com.au> + <3FF7A395.4050106@lorenso.com> +In-Reply-To: <3FF7A395.4050106@lorenso.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/20 +X-Sequence-Number: 5195 + +> In this case, it WILL pay off to have the index on a boolean +> column, yes? Will I win my debate with my collegue? ;-) +> +> I think Tom Lanes suggestion of partial indexes is what I need to +> look into. + +Yes, given that it will be highly skewed towards false entries, Tom's +suggestion is perfect. + +Chris + + +From pgsql-performance-owner@postgresql.org Sun Jan 4 03:23:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 124B7D1C919 + for ; + Sun, 4 Jan 2004 07:23:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45392-06 + for ; + Sun, 4 Jan 2004 03:22:21 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id D972CD1B590 + for ; + Sun, 4 Jan 2004 03:22:19 -0400 (AST) +Received: from [203.221.247.184] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #2) + id 1Ad2ac-00059i-00; Sun, 04 Jan 2004 18:22:23 +1100 +Message-ID: <3FF7BF29.8070401@familyhealth.com.au> +Date: Sun, 04 Jan 2004 15:22:17 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "D. Dante Lorenso" +Cc: pgsql-performance@postgresql.org +Subject: Re: Indexing a Boolean or Null column? +References: <3FF769EA.7090508@lorenso.com> + <3FF79764.6060805@familyhealth.com.au> + <3FF7A395.4050106@lorenso.com> +In-Reply-To: <3FF7A395.4050106@lorenso.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/21 +X-Sequence-Number: 5196 + +> Ok, so ...evenly distributed data on small set of values forces +> sequential scan since that's faster. I expected that based on +> what I've read so far. + +Actually, it's more a case of that fetching an item via and index is +considered, say, four times slower than fetching something off a +sequential scan (sort of). Hence, if you are selecting more than 25% of +the table, then a sequential scan will be faster, even though it has to +process more rows. + +Chris + + +From pgsql-performance-owner@postgresql.org Sun Jan 4 03:49:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6AFF7D1B46C + for ; + Sun, 4 Jan 2004 07:49:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47228-08 + for ; + Sun, 4 Jan 2004 03:49:00 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id C6122D1B4AE + for ; + Sun, 4 Jan 2004 03:48:24 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i047mI19019150; + Sun, 4 Jan 2004 02:48:18 -0500 (EST) +To: Christopher Kings-Lynne +Cc: "D. Dante Lorenso" , + pgsql-performance@postgresql.org +Subject: Re: Indexing a Boolean or Null column? +In-reply-to: <3FF7BF29.8070401@familyhealth.com.au> +References: <3FF769EA.7090508@lorenso.com> + <3FF79764.6060805@familyhealth.com.au> + <3FF7A395.4050106@lorenso.com> + <3FF7BF29.8070401@familyhealth.com.au> +Comments: In-reply-to Christopher Kings-Lynne + message dated "Sun, 04 Jan 2004 15:22:17 +0800" +Date: Sun, 04 Jan 2004 02:48:18 -0500 +Message-ID: <19149.1073202498@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/22 +X-Sequence-Number: 5197 + +Christopher Kings-Lynne writes: +>> Ok, so ...evenly distributed data on small set of values forces +>> sequential scan since that's faster. I expected that based on +>> what I've read so far. + +> Actually, it's more a case of that fetching an item via and index is +> considered, say, four times slower than fetching something off a +> sequential scan (sort of). Hence, if you are selecting more than 25% of +> the table, then a sequential scan will be faster, even though it has to +> process more rows. + +Actually it's worse than that: if an indexscan is going to fetch more +than a few percent of the table, the planner will think it slower than +a sequential scan --- and usually it'll be right. The four-to-one ratio +refers to the cost of fetching a whole page (8K) randomly versus +sequentially. In a seqscan, you can examine all the rows on a page +(dozens to hundreds usually) for the price of one page fetch. In an +indexscan, one page fetch might bring in just one row that you care +about. So the breakeven point is a lot worse than 4:1. + +There is constant debate about the values of these parameters; in +particular the 4:1 page fetch cost ratio breaks down if you are able +to cache a significant fraction of the table in RAM. See the list +archives for details. But it's certainly true that an indexscan has to +be a lot more selective than 25% before it's going to be a win over +a seqscan. I'd say 1% to 5% is the right ballpark. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Jan 4 18:05:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 39E7ED1B438 + for ; + Sun, 4 Jan 2004 22:05:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33052-07 + for ; + Sun, 4 Jan 2004 18:04:32 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id B983ED1B8EA + for ; + Sun, 4 Jan 2004 18:04:13 -0400 (AST) +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 i04M4DU6098633 + for ; Sun, 4 Jan 2004 22:04:13 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i04LiePq086489 + for pgsql-performance@postgresql.org; Sun, 4 Jan 2004 21:44:40 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Indexing a Boolean or Null column? +Date: Sun, 04 Jan 2004 16:39:37 -0500 +Organization: cbbrowne Computing Inc +Lines: 65 +Message-ID: +References: <3FF769EA.7090508@lorenso.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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:sQ6cN4j7q8GtV8LJbcJqdwlGnis= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/23 +X-Sequence-Number: 5198 + +After a long battle with technology, dante@lorenso.com ("D. Dante Lorenso"), an earthling, wrote: +> I've been debating with a collegue who argues that indexing a +> boolean column is a BAD idea and that is will actually slow +> down queries. + +No, it would be expected to slow down inserts, but not likely queries. + +> Will an index on the 'data_is_active' column be used or work +> as I expect? I'm assuming that I may have a million entries +> sharing the same 'data_lookup_key' and I'll be using that to +> search for the active version of the row. + +> SELECT * +> FROM table +> WHERE data_lookup_key = 'pear' +> AND data_is_active IS TRUE; +> +> Does it make sense to have an index on data_is_active? + +Not really. + +> Now, I've read that in some databases the index on a column that has +> relatively even distribution of values over a small set of values +> will not be efficient. + +The problem is (and this is likely to be true for just about any +database system that is 'page-based,' which is just about any of them, +these days) that what happens, with the elements being so pervasive, +throughout the table, queries will be quite likely to hit nearly every +page of the table. + +If you're hitting practically every page, then it is more efficient to +just walk thru the pages (Seq Scan) rather than to bother reading the +index. + +The only improvement that could (in theory) be made is to cluster all +the "true" values onto one set of pages, and all the "false" ones onto +another set of pages, and have a special sort of index that knows +which pages are "true" and "false". I _think_ that Oracle's notion of +"cluster tables" function rather like this; it is rather debatable +whether it would be worthwhile to do similar with PostgreSQL. + +A way of 'clustering' with PostgreSQL might be to have two tables + table_active + and + table_inactive +where a view, representing the 'join' of them, would throw in the +'data_is_active' value. By clever use of some rules/triggers, you +could insert into the view, and have values get shuffled into the +appropriate table. + +When doing a select on the view, if you asked for "data_is_active is +TRUE", the select would only draw data from table_inactive, or +vice-versa. + +Unfortunately, sometimes the query optimizer may not be clever enough +when working with the resulting joins, though that may just be a +Simple Matter Of Programming to make it more clever in future versions. +:-) +-- +output = reverse("gro.gultn" "@" "enworbbc") +http://www3.sympatico.ca/cbbrowne/spreadsheets.html +Rules of the Evil Overlord #136. "If I build a bomb, I will simply +remember which wire to cut if it has to be deactivated and make every +wire red." + +From pgsql-performance-owner@postgresql.org Sun Jan 4 19:37:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 124E7D1B444 + for ; + Sun, 4 Jan 2004 23:37:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50082-05 + for ; + Sun, 4 Jan 2004 19:36:20 -0400 (AST) +Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) + by svr1.postgresql.org (Postfix) with ESMTP id 69588D1B4A7 + for ; + Sun, 4 Jan 2004 19:36:17 -0400 (AST) +Received: from [10.0.1.3] (h000393e3ce55.ne.client2.attbi.com[24.91.235.158]) + by comcast.net (sccrmhc11) with SMTP + id <20040104233619011006cu21e>; Sun, 4 Jan 2004 23:36:19 +0000 +User-Agent: Microsoft-Entourage/10.1.1.2418 +Date: Sun, 04 Jan 2004 18:36:16 -0500 +Subject: Use my (date) index, darn it! +From: John Siracusa +To: +Message-ID: +Mime-version: 1.0 +Reply-To: siracusa@mindspring.com +Content-type: text/plain; charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/24 +X-Sequence-Number: 5199 + +I have a very large table (about a million rows) which I most frequently +want to select a subset of rows from base on a date field. That date field +is indexed, and when Postgres uses that index, queries are fast. But +sometimes it decides not to use the index, resorting to a sequential scan +instead. This is really, really slow. + +To try to convince it to use my date index, I turned off the sequential scan +strategy in the planner. That worked on one copy of the db, but not on +another, where it decided to use an index from another column entirely, +which didn't help performance. I dropped the other index, leaving only the +date index, and performance was good again. + +Obviously the planner is making some bad choices here. I know that it is +trying to avoid random seeks or other scary things implied by a +"correlation" statistic that is not close to 1 or -1, but it is massively +overestimating the hit caused by those seeks and seemingly not taking into +account the size of the table! This is Postgres 7.4 on Linux and Mac OS X, +BTW. + +Anyway, to "fix" the situation, I clustered the table on the date column. +But I fear that the data will slowly "drift" back to a state where the +planner decides again that a sequential scan is a good idea. Blah. + +So, my question: how can I prevent this? Ideally, the planner should be +smarter. Failing that, I'd like to be able to force it to use the index +that I know will result in the fastest queries (3 seconds vs. 30 seconds in +many cases). Suggestions? + +-John + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 02:56:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F2143D1B4CE + for ; + Mon, 5 Jan 2004 06:56:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15368-02 + for ; + Mon, 5 Jan 2004 02:55:46 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E5D7D1B456 + for ; + Mon, 5 Jan 2004 02:55:44 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i056th19022765; + Mon, 5 Jan 2004 01:55:43 -0500 (EST) +To: siracusa@mindspring.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Use my (date) index, darn it! +In-reply-to: +References: +Comments: In-reply-to John Siracusa + message dated "Sun, 04 Jan 2004 18:36:16 -0500" +Date: Mon, 05 Jan 2004 01:55:43 -0500 +Message-ID: <22764.1073285743@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/25 +X-Sequence-Number: 5200 + +John Siracusa writes: +> Obviously the planner is making some bad choices here. + +A fair conclusion ... + +> I know that it is trying to avoid random seeks or other scary things +> implied by a "correlation" statistic that is not close to 1 or -1, but +> it is massively overestimating the hit caused by those seeks and +> seemingly not taking into account the size of the table! + +You haven't given any evidence to support these conclusions, though. +Could we see some table schemas, EXPLAIN ANALYZE output, and relevant +pg_stats entries for the various cases? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jan 5 07:29:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 11B2AD1B48E + for ; + Mon, 5 Jan 2004 11:29:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56587-01 + for ; + Mon, 5 Jan 2004 07:28:39 -0400 (AST) +Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 972A1D1B47D + for ; + Mon, 5 Jan 2004 07:28:36 -0400 (AST) +Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) + id 1AdSuR-0006DM-CZ + for pgsql-performance@postgresql.org; Mon, 05 Jan 2004 12:28:35 +0100 +Received: from [195.135.143.205] (helo=[195.135.143.205]) + by emma.rox.net with asmtp (Exim 4.22) id 1AdSuQ-0006D0-Om + for pgsql-performance@postgresql.org; Mon, 05 Jan 2004 12:28:34 +0100 +Mime-Version: 1.0 (Apple Message framework v609) +Content-Transfer-Encoding: 7bit +Message-Id: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> +Content-Type: text/plain; charset=US-ASCII; format=flowed +To: pgsql-performance@postgresql.org +From: David Teran +Subject: optimizing Postgres queries +Date: Mon, 5 Jan 2004 12:28:32 +0100 +X-Mailer: Apple Mail (2.609) +X-Scanned-By: rockenstein AG +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/26 +X-Sequence-Number: 5201 + +Hi, + +we are new to Postgres and we are evaluating Postgres 7.4 on MacOS X as +an alternative to FrontBase 3.6.27. + + From the available features Postgres is the choice #1. + +We have some tests to check the performance and FrontBase is about 10 +times faster than Postgres. We already played around with explain +analyse select. It seems that for large tables Postgres does not use an +index. We often see the scan message in the query plan. Were can we +find more hints about tuning the performance? The database is about 350 +MB large, without BLOB's. We tried to define every important index for +the selects but it seems that something still goes wrong: FrontBase +needs about 23 seconds for about 4300 selects and Postgres needs 4 +minutes, 34 seconds. + +Any clues? + +regards David + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 07:37:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B859D1B4D7 + for ; + Mon, 5 Jan 2004 11:37:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48120-09 + for ; + Mon, 5 Jan 2004 07:36:59 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D230D1B48E + for ; + Mon, 5 Jan 2004 07:36:56 -0400 (AST) +Received: from daithan.intranet.pspl.co.in + shridhar_daithankar@smtp-send.myrealbox.com [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.47 $ on + Novell NetWare via secured & encrypted transport (TLS); + Mon, 05 Jan 2004 04:36:53 -0700 +From: Shridhar Daithankar +To: pgsql-performance@postgresql.org +Subject: Re: optimizing Postgres queries +Date: Mon, 5 Jan 2004 17:05:55 +0530 +User-Agent: KMail/1.5.4 +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> +In-Reply-To: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200401051705.55120.shridhar_daithankar@myrealbox.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/27 +X-Sequence-Number: 5202 + +On Monday 05 January 2004 16:58, David Teran wrote: +> We have some tests to check the performance and FrontBase is about 10 +> times faster than Postgres. We already played around with explain +> analyse select. It seems that for large tables Postgres does not use an +> index. We often see the scan message in the query plan. Were can we +> find more hints about tuning the performance? The database is about 350 +> MB large, without BLOB's. We tried to define every important index for +> the selects but it seems that something still goes wrong: FrontBase +> needs about 23 seconds for about 4300 selects and Postgres needs 4 +> minutes, 34 seconds. + +Check +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html + +Are you sure you are using correct data types on indexes? + +e.g. if field1 is an int2 field, then following query would not use an index. + +select * from table where field1=2; + +However following will + +select * from table where field1=2::int2; + +It is called as typecasting and postgresql is rather strict about it when it +comes to making a decision of index usage. + +I am sure above two tips could take care of some of the problems. + +Such kind of query needs more specific information. Can you post explain +analyze output for queries and database schema. + + HTH + + Shridhar + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 08:05:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 34E4CD1B4A2 + for ; + Mon, 5 Jan 2004 12:05:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56464-08 + for ; + Mon, 5 Jan 2004 08:05:05 -0400 (AST) +Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F1093D1B48E + for ; + Mon, 5 Jan 2004 08:05:01 -0400 (AST) +Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) + id 1AdTTm-0006Zi-9I; Mon, 05 Jan 2004 13:05:06 +0100 +Received: from [195.135.143.205] (helo=[195.135.143.205]) + by emma.rox.net with asmtp (Exim 4.22) + id 1AdTTl-0006ZT-M4; Mon, 05 Jan 2004 13:05:05 +0100 +In-Reply-To: <200401051705.55120.shridhar_daithankar@myrealbox.com> +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: David Teran +Subject: Re: optimizing Postgres queries +Date: Mon, 5 Jan 2004 13:05:03 +0100 +To: Shridhar Daithankar +X-Mailer: Apple Mail (2.609) +X-Scanned-By: rockenstein AG +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/28 +X-Sequence-Number: 5203 + +Hi Shridhar, + +> Are you sure you are using correct data types on indexes? +> +Did not know about this... + +> e.g. if field1 is an int2 field, then following query would not use an +> index. +> +our fk have the type bigint, when i try one simple select like this: + +explain analyze SELECT --columns-- FROM KEY_VALUE_META_DATA t0 WHERE +t0.ID_FOREIGN_TABLE = 21110; + +i see that no index is being used whereas when i use + +explain analyze SELECT --columns-- FROM KEY_VALUE_META_DATA t0 WHERE +t0.ID_FOREIGN_TABLE = 21110::bigint; + +an index is used. Very fine, the performance is about 10 to 100 times +faster for the single select. + +I am using WebObjects with JDBC. I will now create a DB with integer +instead of bigint and see how this performs. + +regards David + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 08:11:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 95820D1B473 + for ; + Mon, 5 Jan 2004 12:11:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55973-08 + for ; + Mon, 5 Jan 2004 08:11:02 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F3B4D1B44D + for ; + Mon, 5 Jan 2004 08:10:59 -0400 (AST) +Received: from daithan.intranet.pspl.co.in + shridhar_daithankar@smtp-send.myrealbox.com [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.47 $ on + Novell NetWare via secured & encrypted transport (TLS); + Mon, 05 Jan 2004 05:11:02 -0700 +From: Shridhar Daithankar +To: pgsql-performance@postgresql.org +Subject: Re: optimizing Postgres queries +Date: Mon, 5 Jan 2004 17:40:05 +0530 +User-Agent: KMail/1.5.4 +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> +In-Reply-To: <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200401051740.05006.shridhar_daithankar@myrealbox.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/29 +X-Sequence-Number: 5204 + +On Monday 05 January 2004 17:35, David Teran wrote: +> explain analyze SELECT --columns-- FROM KEY_VALUE_META_DATA t0 WHERE +> t0.ID_FOREIGN_TABLE = 21110; +> +> i see that no index is being used whereas when i use +> +> explain analyze SELECT --columns-- FROM KEY_VALUE_META_DATA t0 WHERE +> t0.ID_FOREIGN_TABLE = 21110::bigint; +> +> an index is used. Very fine, the performance is about 10 to 100 times +> faster for the single select. +> +> I am using WebObjects with JDBC. I will now create a DB with integer +> instead of bigint and see how this performs. + +The performance will likely to be the same. Its just that integer happens to +be default integer type and hence it does not need an explicit typecast. ( I +don't remember exactly which integer is default but it is either of int2,int4 +and int8...:-)) + +The performance diffference is likely due to use of index, which is in turn +due to typecasting. If you need bigint, you should use them. Just remember to +typecast whenever required. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 08:18:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 47D6CD1B49B + for ; + Mon, 5 Jan 2004 12:18:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60235-04 + for ; + Mon, 5 Jan 2004 08:18:07 -0400 (AST) +Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BA7A3D1B478 + for ; + Mon, 5 Jan 2004 08:18:04 -0400 (AST) +Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) + id 1AdTgP-0006o6-8n; Mon, 05 Jan 2004 13:18:09 +0100 +Received: from [195.135.143.205] (helo=[195.135.143.205]) + by emma.rox.net with asmtp (Exim 4.22) + id 1AdTgO-0006nf-Dl; Mon, 05 Jan 2004 13:18:08 +0100 +In-Reply-To: <200401051740.05006.shridhar_daithankar@myrealbox.com> +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: David Teran +Subject: Re: optimizing Postgres queries +Date: Mon, 5 Jan 2004 13:18:06 +0100 +To: Shridhar Daithankar +X-Mailer: Apple Mail (2.609) +X-Scanned-By: rockenstein AG +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/30 +X-Sequence-Number: 5205 + +Hi, + +> The performance will likely to be the same. Its just that integer +> happens to +> be default integer type and hence it does not need an explicit +> typecast. ( I +> don't remember exactly which integer is default but it is either of +> int2,int4 +> and int8...:-)) +> +The docs say int4 is much faster than int8, but i will check this. + +> The performance diffference is likely due to use of index, which is in +> turn +> due to typecasting. If you need bigint, you should use them. Just +> remember to +> typecast whenever required. + +This is my bigger problem: i am using EOF (OR mapping tool) which frees +me more or less form writing a lot of SQL. If i need to typecast to use +an index then i have to see how to do this with this framework. + +Regards David + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 08:39:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 61623D1B446 + for ; + Mon, 5 Jan 2004 12:39:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59036-09 + for ; + Mon, 5 Jan 2004 08:38:54 -0400 (AST) +Received: from smtp.pspl.co.in (www.pspl.co.in [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id C2195D1B43A + for ; + Mon, 5 Jan 2004 08:38:48 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id i05CcvOw011144 + for ; Mon, 5 Jan 2004 18:08:57 +0530 +Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in + [192.168.7.161]) (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id i05CcuJN011131 + for ; Mon, 5 Jan 2004 18:08:57 +0530 +From: Shridhar Daithankar +To: pgsql-performance@postgresql.org +Subject: Re: optimizing Postgres queries +Date: Mon, 5 Jan 2004 18:07:53 +0530 +User-Agent: KMail/1.5.4 +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> + <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> +In-Reply-To: <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> +MIME-Version: 1.0 +Content-Disposition: inline +Message-Id: <200401051806.27496.shridhar_daithankar@myrealbox.com> +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/31 +X-Sequence-Number: 5206 + +On Monday 05 January 2004 17:48, David Teran wrote: +> Hi, +> +> > The performance will likely to be the same. Its just that integer +> > happens to +> > be default integer type and hence it does not need an explicit +> > typecast. ( I +> > don't remember exactly which integer is default but it is either of +> > int2,int4 +> > and int8...:-)) +> +> The docs say int4 is much faster than int8, but i will check this. + +Well yes. That is correct as well. + +What I (really) meant to say that an index scan to pick few in4 tuples +wouldn't be hell much faster than an index scan to pick same number of tuples +with int8 definition. + +The initial boost you got from converting to index scan, would be probably +best you can beat out of it.. + +Of course if you are scanning a few million of them sequentially, then it is +different story. + +> This is my bigger problem: i am using EOF (OR mapping tool) which frees +> me more or less form writing a lot of SQL. If i need to typecast to use +> an index then i have to see how to do this with this framework. + +Well, you can direct your queries to a function rather than table, that would +cast the argument appropriately and select. Postgresql support function +overloading as well, in case you need different types of arguments with same +name. + +Or you can write an instead rule on server side which will perform casting +before touching the table. + +I am not sure of exact details it would take to make it work, but it should +work, at least in theory. That way you can preserve the efforts invested in +the mapping tool. + +Of course, converting everything to integer might be a simpler option after +all..:-) + + + Shridhar + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 11:16:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F0878D1B488 + for ; + Mon, 5 Jan 2004 15:16:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90977-06 + for ; + Mon, 5 Jan 2004 11:15:35 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A3DFD1B43D + for ; + Mon, 5 Jan 2004 11:15:31 -0400 (AST) +Received: from [203.221.247.78] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #2) + id 1AdWSA-00071I-00; Tue, 06 Jan 2004 02:15:39 +1100 +Message-ID: <3FF97F8F.6040305@familyhealth.com.au> +Date: Mon, 05 Jan 2004 23:15:27 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: David Teran +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org +Subject: Re: optimizing Postgres queries +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> +In-Reply-To: <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/32 +X-Sequence-Number: 5207 + + +> explain analyze SELECT --columns-- FROM KEY_VALUE_META_DATA t0 WHERE +> t0.ID_FOREIGN_TABLE = 21110::bigint; +> +> an index is used. Very fine, the performance is about 10 to 100 times +> faster for the single select. + +An alternative technique is to do this: + +... t0.ID_FOREIGN_TABLE = '21110'; + +Chris + +From pgsql-performance-owner@postgresql.org Mon Jan 5 11:23:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E8F17D1B4A2 + for ; + Mon, 5 Jan 2004 15:23:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95119-02 + for ; + Mon, 5 Jan 2004 11:22:45 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 79814D1B4AD + for ; + Mon, 5 Jan 2004 11:22:36 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i05FMW19009967; + Mon, 5 Jan 2004 10:22:32 -0500 (EST) +To: David Teran +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org +Subject: Re: optimizing Postgres queries +In-reply-to: <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> + <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> +Comments: In-reply-to David Teran + message dated "Mon, 05 Jan 2004 13:18:06 +0100" +Date: Mon, 05 Jan 2004 10:22:32 -0500 +Message-ID: <9966.1073316152@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/33 +X-Sequence-Number: 5208 + +David Teran writes: +> This is my bigger problem: i am using EOF (OR mapping tool) which frees +> me more or less form writing a lot of SQL. If i need to typecast to use +> an index then i have to see how to do this with this framework. + +It's worth pointing out that this problem is fixed (at long last) in +CVS tip. Ypu probably shouldn't expend large amounts of effort on +working around a problem that will go away in 7.5. + +If you don't anticipate going to production for six months or so, you +could adopt CVS tip as your development platform, with the expectation +that 7.5 will be released by the time you need a production system. +I wouldn't recommend running CVS tip as a production database but it +should be plenty stable enough for devel purposes. + +Another plan would be to use int4 columns for the time being with the +intention of widening them to int8 when you move to 7.5. This would +depend on how soon you anticipate needing values > 32 bits, of course. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jan 5 12:19:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0AA2FD1B4C7 + for ; + Mon, 5 Jan 2004 16:19:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07692-05 + for ; + Mon, 5 Jan 2004 12:18:59 -0400 (AST) +Received: from cayenne.palmdigitalmedia.com (cayenne.palmdigitalmedia.com + [63.110.43.230]) + by svr1.postgresql.org (Postfix) with SMTP id 33DCFD1B47C + for ; + Mon, 5 Jan 2004 12:19:00 -0400 (AST) +Received: (qmail 20440 invoked from network); 5 Jan 2004 16:18:54 -0000 +Received: from unknown (HELO ?192.168.124.23?) (63.110.43.226) + by 0 with SMTP; 5 Jan 2004 16:18:54 -0000 +User-Agent: Microsoft-Entourage/10.1.1.2418 +Date: Mon, 05 Jan 2004 11:19:04 -0500 +Subject: Re: Use my (date) index, darn it! +From: John Siracusa +To: Postgres Performance +Message-ID: +In-Reply-To: <22764.1073285743@sss.pgh.pa.us> +Mime-version: 1.0 +Reply-To: siracusa@mindspring.com +Content-type: text/plain; charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/34 +X-Sequence-Number: 5209 + +On 1/5/04 1:55 AM, Tom Lane wrote: +> John Siracusa writes: +>> Obviously the planner is making some bad choices here. +> +> A fair conclusion ... +> +>> I know that it is trying to avoid random seeks or other scary things +>> implied by a "correlation" statistic that is not close to 1 or -1, but +>> it is massively overestimating the hit caused by those seeks and +>> seemingly not taking into account the size of the table! +> +> You haven't given any evidence to support these conclusions, though. + +Well here's what I was basing that theory on: before clustering, the +correlation for the date column was around 0.3. After clustering, it was 1, +and the index was always used. Does clustering change any other statistics +other that correlation? I ran analyze immediately before and after the +cluster operation. + +> Could we see some table schemas, EXPLAIN ANALYZE output, and relevant +> pg_stats entries for the various cases? + +Well, the table is clustered now, so I can't reproduce the situation. Is +there any way to "uncluster" a table? Should I just cluster it on a +different column? + +-John + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 12:30:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2130ED1B458 + for ; + Mon, 5 Jan 2004 16:30:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05627-10 + for ; + Mon, 5 Jan 2004 12:29:52 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A55B0D1B531 + for ; + Mon, 5 Jan 2004 12:29:52 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i05GTo19010347; + Mon, 5 Jan 2004 11:29:50 -0500 (EST) +To: siracusa@mindspring.com +Cc: Postgres Performance +Subject: Re: Use my (date) index, darn it! +In-reply-to: +References: +Comments: In-reply-to John Siracusa + message dated "Mon, 05 Jan 2004 11:19:04 -0500" +Date: Mon, 05 Jan 2004 11:29:50 -0500 +Message-ID: <10346.1073320190@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/35 +X-Sequence-Number: 5210 + +John Siracusa writes: +> Is there any way to "uncluster" a table? Should I just cluster it on a +> different column? + +That should work, if you choose one that's uncorrelated with the +previous clustering attribute. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jan 5 12:34:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B7742D1B4BE + for ; + Mon, 5 Jan 2004 16:34:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15294-01 + for ; + Mon, 5 Jan 2004 12:33:42 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id B4AA5D1B511 + for ; + Mon, 5 Jan 2004 12:33:43 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 521DB3EA4 + for ; + Mon, 5 Jan 2004 11:33:42 -0500 (EST) +Received: from lorax.kcilink.com ([127.0.0.1]) + by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 08645-05 for ; + Mon, 5 Jan 2004 11:33:41 -0500 (EST) +Received: from lorax.kcilink.com (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 98CF43E0B + for ; + Mon, 5 Jan 2004 11:33:41 -0500 (EST) +Received: (from news@localhost) + by lorax.kcilink.com (8.12.9p2/8.12.9/Submit) id i05GXfxX021441 + for pgsql-performance@postgresql.org; + Mon, 5 Jan 2004 11:33:41 -0500 (EST) (envelope-from news) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: deferred foreign keys +Date: Mon, 05 Jan 2004 11:33:40 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 18 +Message-ID: +References: + + <3FF4FA25.7050802@familyhealth.com.au> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1073320421 5889 65.205.34.180 (5 Jan 2004 16:33:41 + GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Mon, 5 Jan 2004 16:33:41 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:EsrsYGpOQBiYOgOR8KaF8iTuglM= +X-Virus-Scanned: by amavisd-new at kciLink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/36 +X-Sequence-Number: 5211 + +>>>>> "CK" == Christopher Kings-Lynne writes: + +>> One more question: does the FK checker know to skip checking a +>> constraint if the column in question did not change during an update? + +CK> As of 7.4, yes the check is skipped. + + +Thanks. Then it sorta makes it moot for me to try deferred checks, +since the Pimary and Foreign keys never change once set. I wonder +what is making the transactions appear to run lockstep, then... + + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +Vivek Khera, Ph.D. Khera Communications, Inc. +Internet: khera@kciLink.com Rockville, MD +1-301-869-4449 x806 +AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ + +From pgsql-performance-owner@postgresql.org Mon Jan 5 13:05:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C8E37D1B43A + for ; + Mon, 5 Jan 2004 17:05:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15904-03 + for ; + Mon, 5 Jan 2004 13:04:25 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 98FCED1B432 + for ; + Mon, 5 Jan 2004 13:04:26 -0400 (AST) +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 i05H4PU6072488 + for ; Mon, 5 Jan 2004 17:04:26 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i05GkLsg066361 + for pgsql-performance@postgresql.org; Mon, 5 Jan 2004 16:46:21 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Use my (date) index, darn it! +Date: Mon, 05 Jan 2004 11:45:54 -0500 +Organization: cbbrowne Computing Inc +Lines: 49 +Message-ID: +References: <22764.1073285743@sss.pgh.pa.us> + +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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:mzQTwC+VNXYoITJceNozYJwAQpI= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/37 +X-Sequence-Number: 5212 + +After a long battle with technology, siracusa@mindspring.com (John Siracusa), an earthling, wrote: +> On 1/5/04 1:55 AM, Tom Lane wrote: +>> John Siracusa writes: +>>> Obviously the planner is making some bad choices here. +>> +>> A fair conclusion ... +>> +>>> I know that it is trying to avoid random seeks or other scary things +>>> implied by a "correlation" statistic that is not close to 1 or -1, but +>>> it is massively overestimating the hit caused by those seeks and +>>> seemingly not taking into account the size of the table! +>> +>> You haven't given any evidence to support these conclusions, though. +> +> Well here's what I was basing that theory on: before clustering, the +> correlation for the date column was around 0.3. After clustering, it was 1, +> and the index was always used. Does clustering change any other statistics +> other that correlation? I ran analyze immediately before and after the +> cluster operation. +> +>> Could we see some table schemas, EXPLAIN ANALYZE output, and relevant +>> pg_stats entries for the various cases? +> +> Well, the table is clustered now, so I can't reproduce the situation. Is +> there any way to "uncluster" a table? Should I just cluster it on a +> different column? + +That would presumably work... + +It sounds to me as though the statistics that are being collected +aren't "good enough." That tends to be a sign that the quantity of +statistics (e.g. - bins in the histogram) are insufficient. + +This would be resolved by changing the number of bins (default of 10) +via "ALTER TABLE FOO ALTER COLUMN BAR SET STATISTICS 100" (or some +other value higher than 10). + +Clustering would rearrange the contents of the table, and perhaps make +the histogram 'more representative.' Increasing the "SET STATISTICS" +value will quite likely be even more helpful, and is a lot less +expensive than clustering the table... +-- +If this was helpful, rate me +http://www.ntlug.org/~cbbrowne/nonrdbms.html +Rules of the Evil Overlord #158. "I will exchange the labels on my +folder of top-secret plans and my folder of family recipes. Imagine +the hero's surprise when he decodes the stolen plans and finds +instructions for Grandma's Potato Salad." + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 14:17:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A962BD1B43D + for ; + Mon, 5 Jan 2004 18:17:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27239-09 + for ; + Mon, 5 Jan 2004 14:16:20 -0400 (AST) +Received: from cayenne.palmdigitalmedia.com (cayenne.palmdigitalmedia.com + [63.110.43.230]) + by svr1.postgresql.org (Postfix) with SMTP id B4F55D1B444 + for ; + Mon, 5 Jan 2004 14:16:04 -0400 (AST) +Received: (qmail 31174 invoked from network); 5 Jan 2004 18:15:46 -0000 +Received: from unknown (HELO ?192.168.124.23?) (63.110.43.226) + by 0 with SMTP; 5 Jan 2004 18:15:46 -0000 +User-Agent: Microsoft-Entourage/10.1.1.2418 +Date: Mon, 05 Jan 2004 13:15:56 -0500 +Subject: Re: Use my (date) index, darn it! +From: John Siracusa +To: Postgres Performance +Message-ID: +In-Reply-To: +Mime-version: 1.0 +Reply-To: siracusa@mindspring.com +Content-type: text/plain; charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/38 +X-Sequence-Number: 5213 + +On 1/5/04 11:45 AM, Christopher Browne wrote: +> It sounds to me as though the statistics that are being collected +> aren't "good enough." That tends to be a sign that the quantity of +> statistics (e.g. - bins in the histogram) are insufficient. +> +> This would be resolved by changing the number of bins (default of 10) +> via "ALTER TABLE FOO ALTER COLUMN BAR SET STATISTICS 100" (or some +> other value higher than 10). + +I did that, but I wasn't sure what value to use and what column to increase. +I believe I increased the date column itself to 50 or something, but then I +wasn't sure what to do next. I re-analyzed the table with the date column +set to 50 but it didn't seem to help, so I resorted to clustering. + +> Clustering would rearrange the contents of the table, and perhaps make +> the histogram 'more representative.' Increasing the "SET STATISTICS" +> value will quite likely be even more helpful, and is a lot less +> expensive than clustering the table... + +What column(s) should I increase? Do I have to do anything after increasing +the statistics, or do I just wait for the stats collector to do its thing? + +-John + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 14:39:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FB35D1B45E + for ; + Mon, 5 Jan 2004 18:39:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36668-05 + for ; + Mon, 5 Jan 2004 14:38:38 -0400 (AST) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id C8525D1B44E + for ; + Mon, 5 Jan 2004 14:38:37 -0400 (AST) +Received: (qmail 11079 invoked by uid 500); 5 Jan 2004 18:38:59 -0000 +Date: Mon, 5 Jan 2004 12:38:59 -0600 +From: Bruno Wolff III +To: Vivek Khera +Cc: pgsql-performance@postgresql.org +Subject: Re: deferred foreign keys +Message-ID: <20040105183859.GA28448@wolff.to> +Mail-Followup-To: Vivek Khera , + pgsql-performance@postgresql.org +References: + + <3FF4FA25.7050802@familyhealth.com.au> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/39 +X-Sequence-Number: 5214 + +On Mon, Jan 05, 2004 at 11:33:40 -0500, + Vivek Khera wrote: +> +> Thanks. Then it sorta makes it moot for me to try deferred checks, +> since the Pimary and Foreign keys never change once set. I wonder +> what is making the transactions appear to run lockstep, then... + +I think this is probably the issue with foreign key checks needing an +exclusive lock, since there is no shared lock that will prevent deletes. +This problem has been discussed a number of times on the lists and you +should be able to find out more information from the archives if you +want to confirm that this is the root cause of your problems. + +From pgsql-performance-owner@postgresql.org Mon Jan 5 14:48:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BDDDD1B473 + for ; + Mon, 5 Jan 2004 18:48:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31306-09 + for ; + Mon, 5 Jan 2004 14:47:44 -0400 (AST) +Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B3FA0D1B43D + for ; + Mon, 5 Jan 2004 14:47:44 -0400 (AST) +Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) + id 1AdZlD-0004lC-FT; Mon, 05 Jan 2004 19:47:31 +0100 +Received: from [195.135.143.205] (helo=[195.135.143.205]) + by emma.rox.net with asmtp (Exim 4.22) + id 1AdZlC-0004l0-Rx; Mon, 05 Jan 2004 19:47:30 +0100 +In-Reply-To: <9966.1073316152@sss.pgh.pa.us> +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> + <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> + <9966.1073316152@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> +Content-Transfer-Encoding: 7bit +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org +From: David Teran +Subject: Re: optimizing Postgres queries +Date: Mon, 5 Jan 2004 19:47:28 +0100 +To: Tom Lane +X-Mailer: Apple Mail (2.609) +X-Scanned-By: rockenstein AG +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/40 +X-Sequence-Number: 5215 + +Hi Tom, + +> It's worth pointing out that this problem is fixed (at long last) in +> CVS tip. Ypu probably shouldn't expend large amounts of effort on +> working around a problem that will go away in 7.5. +> +We have now changed the definition to integer, this will work for some +time. We are currently evaluating and have several production database +we might switch in some time. + +What we found out now is that a query with a single 'where' works fine, +the query planer uses the index but when we have 'two' where clauses it +does not use the index anymore: + +EXPLAIN ANALYZE SELECT columns... FROM "KEY_VALUE_META_DATA" t0 WHERE +(t0."ID_VALUE" = 14542); performs fine, less than one millisecond. + +EXPLAIN ANALYZE SELECT columns... FROM "KEY_VALUE_META_DATA" t0 WHERE +(t0."ID_VALUE" = 14542 OR t0."ID_VALUE" = 14550); performs bad: about +235 milliseconds. + +I tried to change the second one to use IN but this did not help at +all. Am i doing something wrong? I have an index defined like this: + +CREATE INDEX key_value_meta_data__id_value__fk_index ON +"KEY_VALUE_META_DATA" USING btree ("ID_VALUE"); + +Regards David + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 14:54:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 718D1D1B4CC + for ; + Mon, 5 Jan 2004 18:54:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41752-02 + for ; + Mon, 5 Jan 2004 14:53:49 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A8791D1B433 + for ; + Mon, 5 Jan 2004 14:53:03 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i05Iqf19016231; + Mon, 5 Jan 2004 13:52:41 -0500 (EST) +To: David Teran +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org +Subject: Re: optimizing Postgres queries +In-reply-to: <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> + <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> + <9966.1073316152@sss.pgh.pa.us> + <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> +Comments: In-reply-to David Teran + message dated "Mon, 05 Jan 2004 19:47:28 +0100" +Date: Mon, 05 Jan 2004 13:52:40 -0500 +Message-ID: <16230.1073328760@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/41 +X-Sequence-Number: 5216 + +David Teran writes: +> What we found out now is that a query with a single 'where' works fine, +> the query planer uses the index but when we have 'two' where clauses it +> does not use the index anymore: + +> EXPLAIN ANALYZE SELECT columns... FROM "KEY_VALUE_META_DATA" t0 WHERE +> (t0."ID_VALUE" = 14542); performs fine, less than one millisecond. + +> EXPLAIN ANALYZE SELECT columns... FROM "KEY_VALUE_META_DATA" t0 WHERE +> (t0."ID_VALUE" = 14542 OR t0."ID_VALUE" = 14550); performs bad: about +> 235 milliseconds. + +Please, when you ask this sort of question, show the EXPLAIN ANALYZE +output. It is not a virtue to provide minimal information and see if +anyone can guess what's happening. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jan 5 14:58:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4BDA1D1B4D5 + for ; + Mon, 5 Jan 2004 18:58:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43054-01 + for ; + Mon, 5 Jan 2004 14:57:17 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 538EFD1B43A + for ; + Mon, 5 Jan 2004 14:57:17 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 7A15B354A9; Mon, 5 Jan 2004 10:57:02 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 74F803548C; Mon, 5 Jan 2004 10:57:02 -0800 (PST) +Date: Mon, 5 Jan 2004 10:57:02 -0800 (PST) +From: Stephan Szabo +To: Bruno Wolff III +Cc: Vivek Khera , pgsql-performance@postgresql.org +Subject: Re: deferred foreign keys +In-Reply-To: <20040105183859.GA28448@wolff.to> +Message-ID: <20040105105401.C72490@megazone.bigpanda.com> +References: + + <3FF4FA25.7050802@familyhealth.com.au> + + <20040105183859.GA28448@wolff.to> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/43 +X-Sequence-Number: 5218 + +On Mon, 5 Jan 2004, Bruno Wolff III wrote: + +> On Mon, Jan 05, 2004 at 11:33:40 -0500, +> Vivek Khera wrote: +> > +> > Thanks. Then it sorta makes it moot for me to try deferred checks, +> > since the Pimary and Foreign keys never change once set. I wonder +> > what is making the transactions appear to run lockstep, then... +> +> I think this is probably the issue with foreign key checks needing an +> exclusive lock, since there is no shared lock that will prevent deletes. + +But, if he's updating the fk table but not the keyed column, it should no +longer be doing the check and grabbing the locks. If he's seeing it grab +the row locks still a full test case would be handy because it'd probably +mean we missed something. + +From pgsql-performance-owner@postgresql.org Mon Jan 5 14:58:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 305B9D1B4D4 + for ; + Mon, 5 Jan 2004 18:58:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42052-04 + for ; + Mon, 5 Jan 2004 14:57:12 -0400 (AST) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id D51B1D1B43D + for ; + Mon, 5 Jan 2004 14:57:12 -0400 (AST) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 7693C2178C + for ; + Mon, 5 Jan 2004 13:57:07 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v609) +In-Reply-To: <20040105183859.GA28448@wolff.to> +References: + + <3FF4FA25.7050802@familyhealth.com.au> + + <20040105183859.GA28448@wolff.to> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: deferred foreign keys +Date: Mon, 5 Jan 2004 13:57:07 -0500 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.609) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/42 +X-Sequence-Number: 5217 + + +On Jan 5, 2004, at 1:38 PM, Bruno Wolff III wrote: + +> I think this is probably the issue with foreign key checks needing an +> exclusive lock, since there is no shared lock that will prevent +> deletes. +> + +That was my original thought upon reading all the discussion of late +regarding the FK checking locks. I figured if I deferred the checks to +commit, I could save some contention time. However, if FK checks are +skipped if the field in question is not updated, what locks would there +be? Are they taken even if the checks are not performed on some sort +of "be prepared" principle? + +Vivek Khera, Ph.D. ++1-301-869-4449 x806 + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 15:02:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DFD3AD1B496 + for ; + Mon, 5 Jan 2004 19:02:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43563-01 + for ; + Mon, 5 Jan 2004 15:01:59 -0400 (AST) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E111D1B45D + for ; + Mon, 5 Jan 2004 15:01:59 -0400 (AST) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 49E482178B + for ; + Mon, 5 Jan 2004 14:02:00 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v609) +In-Reply-To: <20040105105401.C72490@megazone.bigpanda.com> +References: + + <3FF4FA25.7050802@familyhealth.com.au> + + <20040105183859.GA28448@wolff.to> + <20040105105401.C72490@megazone.bigpanda.com> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: deferred foreign keys +Date: Mon, 5 Jan 2004 14:02:00 -0500 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.609) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/44 +X-Sequence-Number: 5219 + + +On Jan 5, 2004, at 1:57 PM, Stephan Szabo wrote: + +> But, if he's updating the fk table but not the keyed column, it should +> no +> longer be doing the check and grabbing the locks. If he's seeing it +> grab +> the row locks still a full test case would be handy because it'd +> probably +> mean we missed something. +> + +I'm not *sure* it is taking any locks. The transactions appear to be +running lock step (operating on different parts of the same pair of +tables) and I was going to see if deferring the locks made the +difference. It is my feeling now that it will not. However, if there +is a way to detect if locks are being taken, I'll do that. I'd like to +avoid dropping and recreating the foreign keys if I can since it takes +up some bit of time on the table with 20+ million rows. + +Vivek Khera, Ph.D. ++1-301-869-4449 x806 + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 15:02:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A1D7D1B4AD + for ; + Mon, 5 Jan 2004 19:02:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37454-09 + for ; + Mon, 5 Jan 2004 15:02:02 -0400 (AST) +Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A72CD1B477 + for ; + Mon, 5 Jan 2004 15:02:02 -0400 (AST) +Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) + id 1AdZzI-0004rm-0V; Mon, 05 Jan 2004 20:02:04 +0100 +Received: from [195.135.143.205] (helo=[195.135.143.205]) + by emma.rox.net with asmtp (Exim 4.22) + id 1AdZzH-0004rP-Ay; Mon, 05 Jan 2004 20:02:03 +0100 +In-Reply-To: <16230.1073328760@sss.pgh.pa.us> +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> + <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> + <9966.1073316152@sss.pgh.pa.us> + <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> + <16230.1073328760@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: quoted-printable +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org +From: David Teran +Subject: Re: optimizing Postgres queries +Date: Mon, 5 Jan 2004 20:02:01 +0100 +To: Tom Lane +X-Mailer: Apple Mail (2.609) +X-Scanned-By: rockenstein AG +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/45 +X-Sequence-Number: 5220 + +Hi Tom, + + +> David Teran writes: +>> What we found out now is that a query with a single 'where' works=20=20 +>> fine, +>> the query planer uses the index but when we have 'two' where clauses=20= +=20 +>> it +>> does not use the index anymore: +> +>> EXPLAIN ANALYZE SELECT columns... FROM "KEY_VALUE_META_DATA" t0 WHERE +>> (t0."ID_VALUE" =3D 14542); performs fine, less than one millisecond. +> +>> EXPLAIN ANALYZE SELECT columns... FROM "KEY_VALUE_META_DATA" t0 WHERE +>> (t0."ID_VALUE" =3D 14542 OR t0."ID_VALUE" =3D 14550); performs bad: about +>> 235 milliseconds. +> +> Please, when you ask this sort of question, show the EXPLAIN ANALYZE +> output. It is not a virtue to provide minimal information and see if +> anyone can guess what's happening. +> +Sorry for that, i thought this is such a trivial question that the=20=20 +answer is easy. + +explain result from first query: + +Index=A0Scan=A0using=A0key_value_meta_data__id_value__fk_index=A0on=A0"KEY_= +VALUE_M=20 +ETA_DATA"=A0t0=A0=A0(cost=3D0.00..1585.52=A0rows=3D467=A0width=3D1068)=A0(a= +ctual=A0time=3D0.42=20 +4..0.493=A0rows=3D13=A0loops=3D1) + +=A0=A0Index=A0Cond:=A0("ID_VALUE"=A0=3D=A021094) + +Total runtime: 0.608 ms + + + +explain result from second query: + +Seq=A0Scan=A0on=A0"KEY_VALUE_META_DATA"=A0t0=A0=A0(cost=3D0.00..2671.16=A0r= +ows=3D931=A0width=20 +=3D1068)=A0(actual=A0time=3D122.669..172.179=A0rows=3D25=A0loops=3D1) + +=A0=A0Filter:=A0(("ID_VALUE"=A0=3D=A021094)=A0OR=A0("ID_VALUE"=A0=3D=A02110= +3)) + +Total runtime: 172.354 ms + + + +I found out that its possible to disable seq scans with set=20=20 +enable_seqscan to off; then the second query result looks like this: + +Index=A0Scan=A0using=A0key_value_meta_data__id_value__fk_index,=A0key_value= +_meta=20 +_data__id_value__fk_index=A0on=A0"KEY_VALUE_META_DATA"=A0t0=A0=A0(cost=3D0.= +00..3173.=20 +35=A0rows=3D931=A0width=3D1068)=A0(actual=A0time=3D0.116..0.578=A0rows=3D25= +=A0loops=3D1) + +=A0=A0Index=A0Cond:=A0(("ID_VALUE"=A0=3D=A021094)=A0OR=A0("ID_VALUE"=A0=3D= +=A021103)) + +Total runtime: 0.716 ms + + +But i read in the docs that its not OK to turn this off by default. I=20=20 +really wonder if this is my fault or not, from my point of view this is=20= +=20 +such a simple select that the query plan should not result in a table=20=20 +scan. + +Regards David + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 15:03:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A175D1B45E + for ; + Mon, 5 Jan 2004 19:03:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41945-04 + for ; + Mon, 5 Jan 2004 15:03:02 -0400 (AST) +Received: from cayenne.palmdigitalmedia.com (cayenne.palmdigitalmedia.com + [63.110.43.230]) + by svr1.postgresql.org (Postfix) with SMTP id 88875D1B4C2 + for ; + Mon, 5 Jan 2004 15:03:01 -0400 (AST) +Received: (qmail 8356 invoked from network); 5 Jan 2004 19:03:02 -0000 +Received: from unknown (HELO ?192.168.124.23?) (63.110.43.226) + by 0 with SMTP; 5 Jan 2004 19:03:02 -0000 +User-Agent: Microsoft-Entourage/10.1.1.2418 +Date: Mon, 05 Jan 2004 14:03:12 -0500 +Subject: Select max(foo) and select count(*) optimization +From: John Siracusa +To: Postgres Performance +Message-ID: +Mime-version: 1.0 +Reply-To: siracusa@mindspring.com +Content-type: text/plain; charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/46 +X-Sequence-Number: 5221 + +Speaking of special cases (well, I was on the admin list) there are two +kinds that would really benefit from some attention. + +1. The query "select max(foo) from bar" where the column foo has an index. +Aren't indexes ordered? If not, an "ordered index" would be useful in this +situation so that this query, rather than doing a sequential scan of the +whole table, would just "ask the index" for the max value and return nearly +instantly. + +2. The query "select count(*) from bar" Surely the total number of rows in +a table is kept somewhere convenient. If not, it would be nice if it could +be :) Again, rather than doing a sequential scan of the entire table, this +type of query could return instantly. + +I believe MySQL does both of these optimizations (which are probably a lot +easier in that product, given its data storage system). These were the +first areas where I noticed a big performance difference between MySQL and +Postgres. + +Especially with very large tables, hearing the disks grind as Postgres scans +every single row in order to determine the number of rows in a table or the +max value of a column (even a primary key created from a sequence) is pretty +painful. If the implementation is not too horrendous, this is an area where +an orders-of-magnitude performance increase can be had. + +-John + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 15:06:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A3ABED1B531 + for ; + Mon, 5 Jan 2004 19:06:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38276-10 + for ; + Mon, 5 Jan 2004 15:06:05 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id F140BD1B478 + for ; + Mon, 5 Jan 2004 15:05:49 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i05J5m19020541; + Mon, 5 Jan 2004 14:05:48 -0500 (EST) +To: David Teran +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org +Subject: Re: optimizing Postgres queries +In-reply-to: +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> + <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> + <9966.1073316152@sss.pgh.pa.us> + <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> + <16230.1073328760@sss.pgh.pa.us> + +Comments: In-reply-to David Teran + message dated "Mon, 05 Jan 2004 20:02:01 +0100" +Date: Mon, 05 Jan 2004 14:05:48 -0500 +Message-ID: <20540.1073329548@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/47 +X-Sequence-Number: 5222 + +David Teran writes: +> explain result from second query: + +> Seq Scan on "KEY_VALUE_META_DATA" t0 (cost=0.00..2671.16 rows=931 width +> =1068) (actual time=122.669..172.179 rows=25 loops=1) +> Filter: (("ID_VALUE" = 21094) OR ("ID_VALUE" = 21103)) + +The problem is evidently that the row estimate is so far off (931 +estimate vs 25 actual). Have you done ANALYZE or VACUUM ANALYZE +on this table recently? If you have, I'd be interested to see the +pg_stats row for ID_VALUE. It might be that you need to increase +the statistics target for this table. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jan 5 15:21:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C1F5D1B44D + for ; + Mon, 5 Jan 2004 19:21:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45044-06 + for ; + Mon, 5 Jan 2004 15:20:50 -0400 (AST) +Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BC87ED1B4AF + for ; + Mon, 5 Jan 2004 15:20:49 -0400 (AST) +Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) + id 1AdaHT-000599-VE; Mon, 05 Jan 2004 20:20:52 +0100 +Received: from [195.135.143.205] (helo=[195.135.143.205]) + by emma.rox.net with asmtp (Exim 4.22) + id 1AdaHS-00058C-SQ; Mon, 05 Jan 2004 20:20:50 +0100 +In-Reply-To: <20540.1073329548@sss.pgh.pa.us> +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> + <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> + <9966.1073316152@sss.pgh.pa.us> + <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> + <16230.1073328760@sss.pgh.pa.us> + + <20540.1073329548@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed +Message-Id: <4530AF9E-3FB4-11D8-A528-000A95A6F0DC@cluster9.com> +Content-Transfer-Encoding: quoted-printable +Cc: pgsql-performance@postgresql.org +From: David Teran +Subject: Re: optimizing Postgres queries +Date: Mon, 5 Jan 2004 20:20:49 +0100 +To: Tom Lane +X-Mailer: Apple Mail (2.609) +X-Scanned-By: rockenstein AG +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/48 +X-Sequence-Number: 5223 + +Hi Tom, + +first of all thanks for your help! I really appreciate your fast=20=20 +response and if you ever have a question about WebObjects, just drop me=20= +=20 +line ;-) + +>> Seq Scan on "KEY_VALUE_META_DATA" t0 (cost=3D0.00..2671.16 rows=3D931= +=20=20 +>> width +>> =3D1068) (actual time=3D122.669..172.179 rows=3D25 loops=3D1) +>> Filter: (("ID_VALUE" =3D 21094) OR ("ID_VALUE" =3D 21103)) +> +> The problem is evidently that the row estimate is so far off (931 +> estimate vs 25 actual). Have you done ANALYZE or VACUUM ANALYZE +> on this table recently? If you have, I'd be interested to see the +> pg_stats row for ID_VALUE. It might be that you need to increase +> the statistics target for this table. +> +I am absolutely new to PostgreSQL. OK, after VACUUM ANALYZE i get: + +Index=A0Scan=A0using=A0key_value_meta_data__id_value__fk_index,=A0key_value= +_meta=20 +_data__id_value__fk_index=A0on=A0"KEY_VALUE_META_DATA"=A0t0=A0=A0(cost=3D0.= +00..19.94=20 +=A0rows=3D14=A0width=3D75)=A0(actual=A0time=3D0.615..1.017=A0rows=3D25=A0lo= +ops=3D1) +=A0=A0Index=A0Cond:=A0(("ID_VALUE"=A0=3D=A021094)=A0OR=A0("ID_VALUE"=A0=3D= +=A021103)) +Total runtime: 2.565 ms + +and the second time i invoke this i get + + +Index=A0Scan=A0using=A0key_value_meta_data__id_value__fk_index,=A0key_value= +_meta=20 +_data__id_value__fk_index=A0on=A0"KEY_VALUE_META_DATA"=A0t0=A0=A0(cost=3D0.= +00..19.94=20 +=A0rows=3D14=A0width=3D75)=A0(actual=A0time=3D0.112..0.296=A0rows=3D25=A0lo= +ops=3D1) +=A0=A0Index=A0Cond:=A0(("ID_VALUE"=A0=3D=A021094)=A0OR=A0("ID_VALUE"=A0=3D= +=A021103)) +Total runtime: 0.429 ms + +Much better. So i think i will first read more about this optimization=20= +=20 +stuff and regular maintenance things. This is something i like very=20=20 +much from FrontBase: no need for such things, simply start and run. But=20= +=20 +other things were not so fine ;-). + +Is there any hint where to start to understand more about this=20=20 +optimization problem? + +regards David + +=09=09 + +From pgsql-performance-owner@postgresql.org Thu Jan 8 22:51:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D023D1B8C8 + for ; + Mon, 5 Jan 2004 19:25:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45144-08 + for ; + Mon, 5 Jan 2004 15:24:43 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 533E2D1B472 + for ; + Mon, 5 Jan 2004 15:23:46 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i05JNj19020760; + Mon, 5 Jan 2004 14:23:45 -0500 (EST) +To: David Teran +Cc: pgsql-performance@postgresql.org +Subject: Re: optimizing Postgres queries +In-reply-to: <4530AF9E-3FB4-11D8-A528-000A95A6F0DC@cluster9.com> +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> + <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> + <9966.1073316152@sss.pgh.pa.us> + <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> + <16230.1073328760@sss.pgh.pa.us> + + <20540.1073329548@sss.pgh.pa.us> + <4530AF9E-3FB4-11D8-A528-000A95A6F0DC@cluster9.com> +Comments: In-reply-to David Teran + message dated "Mon, 05 Jan 2004 20:20:49 +0100" +Date: Mon, 05 Jan 2004 14:23:45 -0500 +Message-ID: <20759.1073330625@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/90 +X-Sequence-Number: 5265 + +David Teran writes: +> Much better. So i think i will first read more about this optimization +> stuff and regular maintenance things. + +See http://www.postgresql.org/docs/7.4/static/maintenance.html + +> Is there any hint where to start to understand more about this +> optimization problem? + +http://www.postgresql.org/docs/7.4/static/performance-tips.html + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jan 5 15:49:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DA3FD1B446 + for ; + Mon, 5 Jan 2004 19:49:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48421-06 + for ; + Mon, 5 Jan 2004 15:48:25 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E367D1B44B + for ; + Mon, 5 Jan 2004 15:48:25 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 8352B3563A; Mon, 5 Jan 2004 11:48:26 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 822A235632; Mon, 5 Jan 2004 11:48:26 -0800 (PST) +Date: Mon, 5 Jan 2004 11:48:26 -0800 (PST) +From: Stephan Szabo +To: Vivek Khera +Cc: pgsql-performance@postgresql.org +Subject: Re: deferred foreign keys +In-Reply-To: +Message-ID: <20040105114730.U73612@megazone.bigpanda.com> +References: + + <3FF4FA25.7050802@familyhealth.com.au> + + <20040105183859.GA28448@wolff.to> + <20040105105401.C72490@megazone.bigpanda.com> + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/49 +X-Sequence-Number: 5224 + +On Mon, 5 Jan 2004, Vivek Khera wrote: + +> +> On Jan 5, 2004, at 1:57 PM, Stephan Szabo wrote: +> +> > But, if he's updating the fk table but not the keyed column, it should +> > no +> > longer be doing the check and grabbing the locks. If he's seeing it +> > grab +> > the row locks still a full test case would be handy because it'd +> > probably +> > mean we missed something. +> > +> +> I'm not *sure* it is taking any locks. The transactions appear to be +> running lock step (operating on different parts of the same pair of +> tables) and I was going to see if deferring the locks made the +> difference. It is my feeling now that it will not. However, if there +> is a way to detect if locks are being taken, I'll do that. I'd like to +> avoid dropping and recreating the foreign keys if I can since it takes +> up some bit of time on the table with 20+ million rows. + +The only way I can think of to see the locks is to do just one of the +operations and then manually attempting to select for update the +associated pk row. + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 15:53:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D0F5D1B45F + for ; + Mon, 5 Jan 2004 19:53:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47404-09 + for ; + Mon, 5 Jan 2004 15:52:24 -0400 (AST) +Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) + by svr1.postgresql.org (Postfix) with SMTP id 71CA3D1B44B + for ; + Mon, 5 Jan 2004 15:52:08 -0400 (AST) +Received: (qmail 10697 invoked from network); 5 Jan 2004 19:51:56 -0000 +Received: from unknown (HELO ?10.0.2.16?) (216.208.117.7) + by 205.178.180.9 with SMTP; 5 Jan 2004 19:51:56 -0000 +Subject: Re: Select max(foo) and select count(*) optimization +From: Rod Taylor +To: siracusa@mindspring.com +Cc: Postgresql Performance +In-Reply-To: +References: +Content-Type: text/plain +Message-Id: <1073332325.8958.8.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 05 Jan 2004 14:52:06 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/50 +X-Sequence-Number: 5225 + +> Especially with very large tables, hearing the disks grind as Postgres scans +> every single row in order to determine the number of rows in a table or the +> max value of a column (even a primary key created from a sequence) is pretty +> painful. If the implementation is not too horrendous, this is an area where +> an orders-of-magnitude performance increase can be had. + +Actually, it's very painful. For MySQL, they've accepted the concurrancy +hit in order to accomplish it -- PostgreSQL would require a more subtle +approach. + +Anyway, with Rules you can force this: + +ON INSERT UPDATE counter SET tablecount = tablecount + 1; + +ON DELETE UPDATE counter SET tablecount = tablecount - 1; + + +You need to create a table "counter" with a single row that will keep +track of the number of rows in the table. Just remember, you've now +serialized all writes to the table, but in your situation it may be +worth while. + +max(foo) optimizations requires an extension to the aggregates system. +It will likely happen within a few releases. A work around can be +accomplished today through the use of LIMIT and ORDER BY. + + +From pgsql-performance-owner@postgresql.org Thu Jan 8 22:50:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E9EAD1B472 + for ; + Mon, 5 Jan 2004 19:58:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48699-07 + for ; + Mon, 5 Jan 2004 15:57:47 -0400 (AST) +Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 29C77D1B437 + for ; + Mon, 5 Jan 2004 15:57:47 -0400 (AST) +Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) + id 1AdarF-0001dX-Fv; Mon, 05 Jan 2004 20:57:49 +0100 +Received: from [195.135.143.205] (helo=[195.135.143.205]) + by emma.rox.net with asmtp (Exim 4.22) + id 1AdarE-0001c1-GY; Mon, 05 Jan 2004 20:57:48 +0100 +In-Reply-To: <20759.1073330625@sss.pgh.pa.us> +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> + <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> + <9966.1073316152@sss.pgh.pa.us> + <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> + <16230.1073328760@sss.pgh.pa.us> + + <20540.1073329548@sss.pgh.pa.us> + <4530AF9E-3FB4-11D8-A528-000A95A6F0DC@cluster9.com> + <20759.1073330625@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <6F2414E8-3FB9-11D8-A528-000A95A6F0DC@cluster9.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: David Teran +Subject: Re: optimizing Postgres queries +Date: Mon, 5 Jan 2004 20:57:47 +0100 +To: Tom Lane +X-Mailer: Apple Mail (2.609) +X-Scanned-By: rockenstein AG +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/87 +X-Sequence-Number: 5262 + +... wow: + +executing a batch file with about 4250 selects, including lots of joins +other things PostgreSQL 7.4 is about 2 times faster than FrontBase +3.6.27. OK, we will start to make larger tests but this is quite +interesting already: we did not optimize a lot, just invoked VACUUM +ANALYZE and then the selects ;-) + +Thanks to all who answered to this thread. + +cheers David + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 16:01:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4903FD1B433 + for ; + Mon, 5 Jan 2004 20:01:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49271-05 + for ; + Mon, 5 Jan 2004 16:01:08 -0400 (AST) +Received: from cayenne.palmdigitalmedia.com (cayenne.palmdigitalmedia.com + [63.110.43.230]) + by svr1.postgresql.org (Postfix) with SMTP id 55634D1B444 + for ; + Mon, 5 Jan 2004 16:01:06 -0400 (AST) +Received: (qmail 21093 invoked from network); 5 Jan 2004 20:01:07 -0000 +Received: from unknown (HELO ?192.168.124.23?) (63.110.43.226) + by 0 with SMTP; 5 Jan 2004 20:01:07 -0000 +User-Agent: Microsoft-Entourage/10.1.1.2418 +Date: Mon, 05 Jan 2004 15:01:18 -0500 +Subject: Re: Select max(foo) and select count(*) optimization +From: John Siracusa +To: Postgres Performance +Message-ID: +In-Reply-To: <1073332325.8958.8.camel@jester> +Mime-version: 1.0 +Reply-To: siracusa@mindspring.com +Content-type: text/plain; charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/51 +X-Sequence-Number: 5226 + +On 1/5/04 2:52 PM, Rod Taylor wrote: +> max(foo) optimizations requires an extension to the aggregates system. +> It will likely happen within a few releases. + +Looking forward to it. + +> A work around can be accomplished today through the use of LIMIT and ORDER BY. + +Wowzers, I never imagined that that'd be so much faster. Thanks! :) + +-John + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 16:15:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B103D1B444 + for ; + Mon, 5 Jan 2004 20:15:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49537-08 + for ; + Mon, 5 Jan 2004 16:14:12 -0400 (AST) +Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) + by svr1.postgresql.org (Postfix) with SMTP id 58323D1B47F + for ; + Mon, 5 Jan 2004 16:14:11 -0400 (AST) +Received: (qmail 25534 invoked from network); 5 Jan 2004 20:12:48 -0000 +Received: from unknown (HELO ?10.0.2.16?) (216.208.117.7) + by 205.178.180.9 with SMTP; 5 Jan 2004 20:12:48 -0000 +Subject: Re: deferred foreign keys +From: Rod Taylor +To: Stephan Szabo +Cc: Vivek Khera , + Postgresql Performance +In-Reply-To: <20040105114730.U73612@megazone.bigpanda.com> +References: + + <3FF4FA25.7050802@familyhealth.com.au> + + <20040105183859.GA28448@wolff.to> + <20040105105401.C72490@megazone.bigpanda.com> + + <20040105114730.U73612@megazone.bigpanda.com> +Content-Type: text/plain +Message-Id: <1073333664.8958.36.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 05 Jan 2004 15:14:24 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/52 +X-Sequence-Number: 5227 + +On Mon, 2004-01-05 at 14:48, Stephan Szabo wrote: +> On Mon, 5 Jan 2004, Vivek Khera wrote: +> +> > +> > On Jan 5, 2004, at 1:57 PM, Stephan Szabo wrote: +> > +> > > But, if he's updating the fk table but not the keyed column, it should +> > > no +> > > longer be doing the check and grabbing the locks. If he's seeing it +> > > grab +> > > the row locks still a full test case would be handy because it'd +> > > probably +> > > mean we missed something. +> > > +> > +> > I'm not *sure* it is taking any locks. The transactions appear to be +> > running lock step (operating on different parts of the same pair of +> > tables) and I was going to see if deferring the locks made the +> > difference. It is my feeling now that it will not. However, if there +> > is a way to detect if locks are being taken, I'll do that. I'd like to +> > avoid dropping and recreating the foreign keys if I can since it takes +> > up some bit of time on the table with 20+ million rows. +> +> The only way I can think of to see the locks is to do just one of the +> operations and then manually attempting to select for update the +> associated pk row. + +When a locker runs into a row lock held by another transaction, the +locker will show a pending lock on the transaction id in pg_locks. + + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 16:24:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BBD80D1B4BD + for ; + Mon, 5 Jan 2004 20:24:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49267-09 + for ; + Mon, 5 Jan 2004 16:23:34 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 876A8D1B495 + for ; + Mon, 5 Jan 2004 16:23:33 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 0C9C31F94; Mon, 5 Jan 2004 15:23:18 -0500 (EST) +To: siracusa@mindspring.com +Cc: Postgres Performance +Subject: Re: Select max(foo) and select count(*) optimization +From: Neil Conway +In-Reply-To: (John Siracusa's + message of "Mon, 05 Jan 2004 14:03:12 -0500") +References: +Date: Mon, 05 Jan 2004 15:23:16 -0500 +Message-ID: <87k746p2kr.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/53 +X-Sequence-Number: 5228 + +John Siracusa writes: +> 1. The query "select max(foo) from bar" where the column foo has an index. +> Aren't indexes ordered? If not, an "ordered index" would be useful in this +> situation so that this query, rather than doing a sequential scan of the +> whole table, would just "ask the index" for the max value and return nearly +> instantly. + +http://www.postgresql.org/docs/current/static/functions-aggregate.html + +-Neil + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 16:35:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8FE10D1B4C7 + for ; + Mon, 5 Jan 2004 20:35:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57507-05 + for ; + Mon, 5 Jan 2004 16:34:26 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 8DF00D1B444 + for ; + Mon, 5 Jan 2004 16:34:26 -0400 (AST) +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 i05KYQU6065368 + for ; Mon, 5 Jan 2004 20:34:26 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i05KStnw062330 + for pgsql-performance@postgresql.org; Mon, 5 Jan 2004 20:28:55 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Select max(foo) and select count(*) optimization +Date: Mon, 05 Jan 2004 15:26:15 -0500 +Organization: cbbrowne Computing Inc +Lines: 50 +Message-ID: +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:gy8BOild0Jka8eTJbKw2gIJDnBI= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/55 +X-Sequence-Number: 5230 + +Oops! siracusa@mindspring.com (John Siracusa) was seen spray-painting on a wall: +> Speaking of special cases (well, I was on the admin list) there are two +> kinds that would really benefit from some attention. +> +> 1. The query "select max(foo) from bar" where the column foo has an +> index. Aren't indexes ordered? If not, an "ordered index" would be +> useful in this situation so that this query, rather than doing a +> sequential scan of the whole table, would just "ask the index" for +> the max value and return nearly instantly. +> +> 2. The query "select count(*) from bar" Surely the total number of +> rows in a table is kept somewhere convenient. If not, it would be +> nice if it could be :) Again, rather than doing a sequential scan of +> the entire table, this type of query could return instantly. +> +> I believe MySQL does both of these optimizations (which are probably +> a lot easier in that product, given its data storage system). These +> were the first areas where I noticed a big performance difference +> between MySQL and Postgres. +> +> Especially with very large tables, hearing the disks grind as +> Postgres scans every single row in order to determine the number of +> rows in a table or the max value of a column (even a primary key +> created from a sequence) is pretty painful. If the implementation +> is not too horrendous, this is an area where an orders-of-magnitude +> performance increase can be had. + +These are both VERY frequently asked questions. + +In the case of question #1, the optimization you suggest could be +accomplished via some Small Matter Of Programming. None of the people +that have wanted the optimization have, however, offered to actually +DO the programming. + +In the case of #2, the answer is "surely NOT." In MVCC databases, +that information CANNOT be stored anywhere convenient because queries +requested by transactions started at different points in time must get +different answers. + +I think we need to add these questions and their answers to the FAQ so +that the answer can be "See FAQ Item #17" rather than people having to +gratuitously explain it over and over and over again. +-- +(reverse (concatenate 'string "moc.enworbbc" "@" "enworbbc")) +http://www.ntlug.org/~cbbrowne/finances.html +Rules of the Evil Overlord #127. "Prison guards will have their own +cantina featuring a wide variety of tasty treats that will deliver +snacks to the guards while on duty. The guards will also be informed +that accepting food or drink from any other source will result in +execution." + +From pgsql-performance-owner@postgresql.org Mon Jan 5 16:35:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 75B0DD1B4C4 + for ; + Mon, 5 Jan 2004 20:35:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51665-08 + for ; + Mon, 5 Jan 2004 16:34:26 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id A0CEDD1B49B + for ; + Mon, 5 Jan 2004 16:34:26 -0400 (AST) +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 i05KYQU8065368 + for ; Mon, 5 Jan 2004 20:34:26 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i05KStLQ062342 + for pgsql-performance@postgresql.org; Mon, 5 Jan 2004 20:28:55 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Use my (date) index, darn it! +Date: Mon, 05 Jan 2004 15:27:43 -0500 +Organization: cbbrowne Computing Inc +Lines: 14 +Message-ID: +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:fBD9OABaBFlG3B8g2r62ovVmWqk= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/54 +X-Sequence-Number: 5229 + +In the last exciting episode, siracusa@mindspring.com (John Siracusa) wrote: +> What column(s) should I increase? Do I have to do anything after increasing +> the statistics, or do I just wait for the stats collector to do its thing? + +You have to ANALYZE the table again, to force in new statistics. + +And if the index in question is on _just_ the date column, then it is +probably only that date column where the "SET STATISTICS" needs to be +increased. +-- +let name="cbbrowne" and tld="cbbrowne.com" in name ^ "@" ^ tld;; +http://www.ntlug.org/~cbbrowne/sap.html +Faith is the quality that enables you to eat blackberry jam on a +picnic without looking to see whether the seeds move. -- DeMara Cabrera + +From pgsql-performance-owner@postgresql.org Mon Jan 5 18:34:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 58FAED1B438 + for ; + Mon, 5 Jan 2004 22:34:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82907-02 + for ; + Mon, 5 Jan 2004 18:33:16 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B95AD1B43A + for ; + Mon, 5 Jan 2004 18:33:15 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 3787D35471; Mon, 5 Jan 2004 14:33:17 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 364173532E; Mon, 5 Jan 2004 14:33:17 -0800 (PST) +Date: Mon, 5 Jan 2004 14:33:17 -0800 (PST) +From: Stephan Szabo +To: Rod Taylor +Cc: Vivek Khera , + Postgresql Performance +Subject: Re: deferred foreign keys +In-Reply-To: <1073333664.8958.36.camel@jester> +Message-ID: <20040105143127.I76870@megazone.bigpanda.com> +References: + + <3FF4FA25.7050802@familyhealth.com.au> + + <20040105183859.GA28448@wolff.to> + <20040105105401.C72490@megazone.bigpanda.com> + + <20040105114730.U73612@megazone.bigpanda.com> + <1073333664.8958.36.camel@jester> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/56 +X-Sequence-Number: 5231 + +On Mon, 5 Jan 2004, Rod Taylor wrote: + +> On Mon, 2004-01-05 at 14:48, Stephan Szabo wrote: +> > On Mon, 5 Jan 2004, Vivek Khera wrote: +> > +> > > +> > > On Jan 5, 2004, at 1:57 PM, Stephan Szabo wrote: +> > > +> > > > But, if he's updating the fk table but not the keyed column, it should +> > > > no +> > > > longer be doing the check and grabbing the locks. If he's seeing it +> > > > grab +> > > > the row locks still a full test case would be handy because it'd +> > > > probably +> > > > mean we missed something. +> > > > +> > > +> > > I'm not *sure* it is taking any locks. The transactions appear to be +> > > running lock step (operating on different parts of the same pair of +> > > tables) and I was going to see if deferring the locks made the +> > > difference. It is my feeling now that it will not. However, if there +> > > is a way to detect if locks are being taken, I'll do that. I'd like to +> > > avoid dropping and recreating the foreign keys if I can since it takes +> > > up some bit of time on the table with 20+ million rows. +> > +> > The only way I can think of to see the locks is to do just one of the +> > operations and then manually attempting to select for update the +> > associated pk row. +> +> When a locker runs into a row lock held by another transaction, the +> locker will show a pending lock on the transaction id in pg_locks. + +Yeah, but AFAIR that won't let you know if it's blocking on the particular +row lock you're expecting. + +From pgsql-performance-owner@postgresql.org Mon Jan 5 20:22:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 797B4D1B4C4 + for ; + Tue, 6 Jan 2004 00:22:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01245-06 + for ; + Mon, 5 Jan 2004 20:21:45 -0400 (AST) +Received: from monsoon.he.net (monsoon.he.net [64.62.221.2]) + by svr1.postgresql.org (Postfix) with SMTP id 53882D1B484 + for ; + Mon, 5 Jan 2004 20:21:43 -0400 (AST) +Received: from [10.244.40.247] ([216.113.168.128]) by monsoon.he.net for + ; Mon, 5 Jan 2004 16:21:40 -0800 +Subject: Re: Select max(foo) and select count(*) optimization +From: Paul Tuckfield +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: + +Content-Type: text/plain +Organization: +Message-Id: <1073348666.19994.3.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) +Date: 05 Jan 2004 16:24:26 -0800 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/57 +X-Sequence-Number: 5232 + +Not that I'm offering to do the porgramming mind you, :) but . . + + +In the case of select count(*), one optimization is to do a scan of the +primary key, not the table itself, if the table has a primary key. In a +certain commercial, lesser database, this is called an "index fast full +scan". It would be important to scan the index in physical order +(sequential physical IO) and not in key order (random physical IO) + +I'm guessing the payoff as well as real-world-utility of a max(xxx) +optimization are much higher than a count(*) optimization tho + + +On Mon, 2004-01-05 at 12:26, Christopher Browne wrote: +> Oops! siracusa@mindspring.com (John Siracusa) was seen spray-painting on a wall: +> > Speaking of special cases (well, I was on the admin list) there are two +> > kinds that would really benefit from some attention. +> > +> > 1. The query "select max(foo) from bar" where the column foo has an +> > index. Aren't indexes ordered? If not, an "ordered index" would be +> > useful in this situation so that this query, rather than doing a +> > sequential scan of the whole table, would just "ask the index" for +> > the max value and return nearly instantly. +> > +> > 2. The query "select count(*) from bar" Surely the total number of +> > rows in a table is kept somewhere convenient. If not, it would be +> > nice if it could be :) Again, rather than doing a sequential scan of +> > the entire table, this type of query could return instantly. +> > +> > I believe MySQL does both of these optimizations (which are probably +> > a lot easier in that product, given its data storage system). These +> > were the first areas where I noticed a big performance difference +> > between MySQL and Postgres. +> > +> > Especially with very large tables, hearing the disks grind as +> > Postgres scans every single row in order to determine the number of +> > rows in a table or the max value of a column (even a primary key +> > created from a sequence) is pretty painful. If the implementation +> > is not too horrendous, this is an area where an orders-of-magnitude +> > performance increase can be had. +> +> These are both VERY frequently asked questions. +> +> In the case of question #1, the optimization you suggest could be +> accomplished via some Small Matter Of Programming. None of the people +> that have wanted the optimization have, however, offered to actually +> DO the programming. +> +> In the case of #2, the answer is "surely NOT." In MVCC databases, +> that information CANNOT be stored anywhere convenient because queries +> requested by transactions started at different points in time must get +> different answers. +> +> I think we need to add these questions and their answers to the FAQ so +> that the answer can be "See FAQ Item #17" rather than people having to +> gratuitously explain it over and over and over again. + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 20:41:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C3730D1B44B + for ; + Tue, 6 Jan 2004 00:41:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05126-02 + for ; + Mon, 5 Jan 2004 20:40:28 -0400 (AST) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id E02B0D1B45D + for ; + Mon, 5 Jan 2004 20:40:25 -0400 (AST) +Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1AdfGW-0005bM-00 + for ; Tue, 06 Jan 2004 01:40:12 +0100 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +Received: from sea.gmane.org ([80.91.224.252]) + by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) + id 1Adf6a-0005X2-00 + for ; + Tue, 06 Jan 2004 01:29:56 +0100 +Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1Adf6a-0000oh-00 + for ; + Tue, 06 Jan 2004 01:29:56 +0100 +From: Doug McNaught +Subject: Re: Select max(foo) and select count(*) optimization +Date: Mon, 05 Jan 2004 19:29:56 -0500 +Lines: 12 +Message-ID: <87oeth537f.fsf@asmodeus.mcnaught.org> +References: + + <1073348666.19994.3.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@sea.gmane.org +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +Cancel-Lock: sha1:7WUavIegZvZvtd1zN4AttylaUro= +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/58 +X-Sequence-Number: 5233 + +Paul Tuckfield writes: + +> In the case of select count(*), one optimization is to do a scan of the +> primary key, not the table itself, if the table has a primary key. In a +> certain commercial, lesser database, this is called an "index fast full +> scan". It would be important to scan the index in physical order +> (sequential physical IO) and not in key order (random physical IO) + +That won't work because you still have to hit the actual tuple to +determine visibility. + +-Doug + + +From pgsql-performance-owner@postgresql.org Mon Jan 5 22:05:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 12236D1B436 + for ; + Tue, 6 Jan 2004 02:05:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15271-07 + for ; + Mon, 5 Jan 2004 22:04:29 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 15386D1B4AF + for ; + Mon, 5 Jan 2004 22:04:27 -0400 (AST) +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 i0624QU6061594 + for ; Tue, 6 Jan 2004 02:04:26 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i061rUi0054163 + for pgsql-performance@postgresql.org; Tue, 6 Jan 2004 01:53:30 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Select max(foo) and select count(*) optimization +Date: Mon, 05 Jan 2004 20:46:00 -0500 +Organization: cbbrowne Computing Inc +Lines: 29 +Message-ID: +References: + + <1073348666.19994.3.camel@localhost.localdomain> +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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:CGrCaeE+coVOy09ohrN8ktqXNRI= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/59 +X-Sequence-Number: 5234 + +Martha Stewart called it a Good Thing when paul@tuckfield.com (Paul Tuckfield) wrote: +> Not that I'm offering to do the porgramming mind you, :) but . . +> +> In the case of select count(*), one optimization is to do a scan of the +> primary key, not the table itself, if the table has a primary key. In a +> certain commercial, lesser database, this is called an "index fast full +> scan". It would be important to scan the index in physical order +> (sequential physical IO) and not in key order (random physical IO) + +The problem is that this "optimization" does not actually work. The +index does not contain transaction visibility information, so you have +to go to the pages of tuples in order to determine if any given tuple +is visible. + +> I'm guessing the payoff as well as real-world-utility of a max(xxx) +> optimization are much higher than a count(*) optimization tho + +That's probably so. + +In many cases, approximations, such as page counts, may be good +enough, and pray consider, that ("an approximation") is probably all +you were getting from the database systems that had an "optimization" +to store the count in a counter. +-- +let name="cbbrowne" and tld="ntlug.org" in name ^ "@" ^ tld;; +http://www3.sympatico.ca/cbbrowne/linuxxian.html +"No, you misunderstand. Microsoft asked some hackers how they could +make their system secure - the hackers replied "Turn it off.". So they +did." -- Anthony Ord + +From pgsql-performance-owner@postgresql.org Mon Jan 5 22:35:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EDFAD1B511 + for ; + Tue, 6 Jan 2004 02:35:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21009-06 + for ; + Mon, 5 Jan 2004 22:34:29 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id EC6BBD1B49B + for ; + Mon, 5 Jan 2004 22:34:26 -0400 (AST) +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 i062YQU6078269 + for ; Tue, 6 Jan 2004 02:34:26 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i062VhL0076928 + for pgsql-performance@postgresql.org; Tue, 6 Jan 2004 02:31:43 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Select max(foo) and select count(*) optimization +Date: Mon, 05 Jan 2004 21:31:29 -0500 +Organization: cbbrowne Computing Inc +Lines: 64 +Message-ID: +References: + <1073332325.8958.8.camel@jester> +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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:5NnaKoa0P3JZKv1s3Qp8O/Vhdn0= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/60 +X-Sequence-Number: 5235 + +pg@rbt.ca (Rod Taylor) wrote: +>> Especially with very large tables, hearing the disks grind as Postgres scans +>> every single row in order to determine the number of rows in a table or the +>> max value of a column (even a primary key created from a sequence) is pretty +>> painful. If the implementation is not too horrendous, this is an area where +>> an orders-of-magnitude performance increase can be had. +> +> Actually, it's very painful. For MySQL, they've accepted the concurrancy +> hit in order to accomplish it -- PostgreSQL would require a more subtle +> approach. +> +> Anyway, with Rules you can force this: +> +> ON INSERT UPDATE counter SET tablecount = tablecount + 1; +> +> ON DELETE UPDATE counter SET tablecount = tablecount - 1; +> +> You need to create a table "counter" with a single row that will keep +> track of the number of rows in the table. Just remember, you've now +> serialized all writes to the table, but in your situation it may be +> worth while. + +There's a still more subtle approach that relieves the serialization +constraint, at some cost... + +- You add rules that _insert_ a row each time there is an + insert/delete + ON INSERT insert into counts(table, value) values ('our_table', 1); + ON DELETE insert into counts(table, value) values ('our_table', -1); + +- The "select count(*) from our_table" is replaced by "select + sum(value) from counts where table = 'our_table'" + +- Periodically, a "compression" process goes through and either: + + a) Deletes the rows for 'our_table' and replaces them with one + row with a conventionally-scanned 'count(*)' value, or + + b) Computes "select table, sum(value) as value from counts group + by table", deletes all the existing rows in counts, and replaces + them by the preceding selection, or + + c) Perhaps does something incremental that's like b), but which + only processes parts of the "count" table at once. Process + 500 rows, then COMMIT, or something of the sort... + +Note that this "counts" table can potentially grow _extremely_ large. +The "win" comes when it gets compressed, so that instead of scanning +through 500K items, it index-scans through 27, the 1 that has the +"497000" that was the state of the table at the last compression, and +then 26 singletons. + +A win comes in if an INSERT that adds in 50 rows can lead to +inserting ('our_table', 50) into COUNTS, or a delete that eliminates +5000 rows puts in ('our_table', -5000). + +It's vital to run the "compression" reasonably often (much like VACUUM +:-)) in order that the COUNTS summary table stays relatively small. +-- +let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];; +http://www3.sympatico.ca/cbbrowne/wp.html +Debugging is twice as hard as writing the code in the first place. +Therefore, if you write the code as cleverly as possible, you are, by +definition, not smart enough to debug it. -- Brian W. Kernighan + +From pgsql-performance-owner@postgresql.org Tue Jan 6 01:26:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D139D1B48A + for ; + Tue, 6 Jan 2004 05:26:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55905-04 + for ; + Tue, 6 Jan 2004 01:25:54 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 89CF2D1B471 + for ; + Tue, 6 Jan 2004 01:25:44 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i065PW915257; + Tue, 6 Jan 2004 00:25:32 -0500 (EST) +From: Bruce Momjian +Message-Id: <200401060525.i065PW915257@candle.pha.pa.us> +Subject: Re: optimizing Postgres queries +In-Reply-To: <4530AF9E-3FB4-11D8-A528-000A95A6F0DC@cluster9.com> +To: David Teran +Date: Tue, 6 Jan 2004 00:25:32 -0500 (EST) +Cc: Tom Lane , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/61 +X-Sequence-Number: 5236 + +David Teran wrote: +> Index?Scan?using?key_value_meta_data__id_value__fk_index,?key_value_meta +> _data__id_value__fk_index?on?"KEY_VALUE_META_DATA"?t0??(cost=0.00..19.94 +> ?rows=14?width=75)?(actual?time=0.112..0.296?rows=25?loops=1) +> ??Index?Cond:?(("ID_VALUE"?=?21094)?OR?("ID_VALUE"?=?21103)) +> Total runtime: 0.429 ms +> +> Much better. So i think i will first read more about this optimization +> stuff and regular maintenance things. This is something i like very +> much from FrontBase: no need for such things, simply start and run. But +> other things were not so fine ;-). +> +> Is there any hint where to start to understand more about this +> optimization problem? + +Read the FAQ. There is an item about slow queries and indexes. + +-- + 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 Jan 6 02:33:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 36BA7D1B472 + for ; + Tue, 6 Jan 2004 06:33:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07027-07 + for ; + Tue, 6 Jan 2004 02:32:51 -0400 (AST) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id D6888D1B52A + for ; + Tue, 6 Jan 2004 02:32:43 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id i066WsdJ025621 + for ; Tue, 6 Jan 2004 12:02:54 +0530 +Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in + [192.168.7.161]) (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id i066WsJN025608 + for ; Tue, 6 Jan 2004 12:02:54 +0530 +From: Shridhar Daithankar +To: pgsql-performance@postgresql.org +Subject: Re: Select max(foo) and select count(*) optimization +Date: Tue, 6 Jan 2004 12:01:53 +0530 +User-Agent: KMail/1.5.4 +References: + <1073348666.19994.3.camel@localhost.localdomain> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200401061201.53978.shridhar_daithankar@persistent.co.in> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/62 +X-Sequence-Number: 5237 + +On Tuesday 06 January 2004 07:16, Christopher Browne wrote: +> Martha Stewart called it a Good Thing when paul@tuckfield.com (Paul +Tuckfield) wrote: +> > Not that I'm offering to do the porgramming mind you, :) but . . +> > +> > In the case of select count(*), one optimization is to do a scan of the +> > primary key, not the table itself, if the table has a primary key. In a +> > certain commercial, lesser database, this is called an "index fast full +> > scan". It would be important to scan the index in physical order +> > (sequential physical IO) and not in key order (random physical IO) +> +> The problem is that this "optimization" does not actually work. The +> index does not contain transaction visibility information, so you have +> to go to the pages of tuples in order to determine if any given tuple +> is visible. + +It was rejected as an idea to add transaction visibility information to +indexes. The time I proposed, my idea was to vacuum tuples on page level +while postgresql pushes buffers out of shared cache. If indexes had +visibility information, they could be cleaned out of order than heap tuples. + +This wouldn't have eliminated vacuum entirely but at least frequently hit data +would be clean. + +But it was rejected because of associated overhead. + +Just thought worh a mention.. + + Shridhar + + + +From pgsql-performance-owner@postgresql.org Tue Jan 6 02:44:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2943FD1B484 + for ; + Tue, 6 Jan 2004 06:44:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07249-10 + for ; + Tue, 6 Jan 2004 02:43:18 -0400 (AST) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id 4CA28D1B483 + for ; + Tue, 6 Jan 2004 02:43:11 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id i066hMU6028871 + for ; Tue, 6 Jan 2004 12:13:22 +0530 +Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in + [192.168.7.161]) (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id i066hLJN028849 + for ; Tue, 6 Jan 2004 12:13:22 +0530 +From: Shridhar Daithankar +To: Postgresql Performance +Subject: Re: Select max(foo) and select count(*) optimization +Date: Tue, 6 Jan 2004 12:12:21 +0530 +User-Agent: KMail/1.5.4 +References: + <1073332325.8958.8.camel@jester> +In-Reply-To: <1073332325.8958.8.camel@jester> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200401061212.21344.shridhar_daithankar@persistent.co.in> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/63 +X-Sequence-Number: 5238 + +On Tuesday 06 January 2004 01:22, Rod Taylor wrote: +> Anyway, with Rules you can force this: +> +> ON INSERT UPDATE counter SET tablecount = tablecount + 1; +> +> ON DELETE UPDATE counter SET tablecount = tablecount - 1; + +That would generate lot of dead tuples in counter table. How about + +select relpages,reltuples from pg_class where relname=; + +Assuming the stats are recent enough, it would be much faster and accurate.. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Thu Jan 8 22:51:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 55B1CD1B4C7 + for ; + Tue, 6 Jan 2004 12:05:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62414-02 + for ; + Tue, 6 Jan 2004 08:04:36 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F76DD1B449 + for ; + Tue, 6 Jan 2004 08:04:28 -0400 (AST) +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 i06C4WU6092633 + for ; Tue, 6 Jan 2004 12:04:32 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i06BogVQ085444 + for pgsql-performance@postgresql.org; Tue, 6 Jan 2004 11:50:42 GMT +From: CoL +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Select max(foo) and select count(*) optimization +Date: Tue, 06 Jan 2004 12:51:13 +0100 +Organization: Hub.Org Networking Services +Lines: 13 +Message-ID: +References: + <1073332325.8958.8.camel@jester> + <200401061212.21344.shridhar_daithankar@persistent.co.in> +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.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +In-Reply-To: <200401061212.21344.shridhar_daithankar@persistent.co.in> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/88 +X-Sequence-Number: 5263 + +Hi, + +Shridhar Daithankar wrote: + +> +> select relpages,reltuples from pg_class where relname=; +> +> Assuming the stats are recent enough, it would be much faster and accurate.. + +this needs an analyze ; before select from pg_class, cause +only after analyze will update pg the pg_class + +C. + +From pgsql-performance-owner@postgresql.org Tue Jan 6 08:18:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D15DCD1B446 + for ; + Tue, 6 Jan 2004 12:18:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62220-06 + for ; + Tue, 6 Jan 2004 08:18:13 -0400 (AST) +Received: from druid.net (druid.net [216.126.72.98]) + by svr1.postgresql.org (Postfix) with ESMTP id 61406D1B465 + for ; + Tue, 6 Jan 2004 08:18:04 -0400 (AST) +Received: by druid.net (Postfix, from userid 1000) + id A26C31A9E; Tue, 6 Jan 2004 07:18:09 -0500 (EST) +From: "D'Arcy J.M. Cain" +To: Shridhar Daithankar , + Postgresql Performance +Subject: Re: Select max(foo) and select count(*) optimization +Date: Tue, 6 Jan 2004 07:18:08 -0500 +User-Agent: KMail/1.5.4 +References: + <1073332325.8958.8.camel@jester> + <200401061212.21344.shridhar_daithankar@persistent.co.in> +In-Reply-To: <200401061212.21344.shridhar_daithankar@persistent.co.in> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200401060718.08444.darcy@druid.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/64 +X-Sequence-Number: 5239 + +On January 6, 2004 01:42 am, Shridhar Daithankar wrote: +> On Tuesday 06 January 2004 01:22, Rod Taylor wrote: +> > Anyway, with Rules you can force this: +> > +> > ON INSERT UPDATE counter SET tablecount = tablecount + 1; +> > +> > ON DELETE UPDATE counter SET tablecount = tablecount - 1; +> +> That would generate lot of dead tuples in counter table. How about +> +> select relpages,reltuples from pg_class where relname=; +> +> Assuming the stats are recent enough, it would be much faster and +> accurate.. + +Well, I did this: + +cert=# select relpages,reltuples from pg_class where relname= 'certificate'; + relpages | reltuples +----------+------------- + 399070 | 2.48587e+07 +(1 row) + +Casting seemed to help: + +cert=# select relpages,reltuples::bigint from pg_class where relname= +'certificate'; + relpages | reltuples +----------+----------- + 399070 | 24858736 +(1 row) + +But: + +cert=# select count(*) from certificate; +[*Crunch* *Crunch* *Crunch*] + count +---------- + 19684668 +(1 row) + +Am I missing something? Max certificate_id is 20569544 btw. + +-- +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 Tue Jan 6 08:21:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 15583D1B465 + for ; + Tue, 6 Jan 2004 12:21:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60378-07 + for ; + Tue, 6 Jan 2004 08:21:11 -0400 (AST) +Received: from smtp.pspl.co.in (www.pspl.co.in [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id 90F1DD1B440 + for ; + Tue, 6 Jan 2004 08:20:58 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id i06CLEQR019820 + for ; Tue, 6 Jan 2004 17:51:14 +0530 +Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in + [192.168.7.161]) (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id i06CLEJN019806 + for ; Tue, 6 Jan 2004 17:51:14 +0530 +From: Shridhar Daithankar +To: Postgresql Performance +Subject: Re: Select max(foo) and select count(*) optimization +Date: Tue, 6 Jan 2004 17:50:09 +0530 +User-Agent: KMail/1.5.4 +References: + <200401061212.21344.shridhar_daithankar@persistent.co.in> + <200401060718.08444.darcy@druid.net> +In-Reply-To: <200401060718.08444.darcy@druid.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200401061750.09530.shridhar_daithankar@persistent.co.in> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/65 +X-Sequence-Number: 5240 + +On Tuesday 06 January 2004 17:48, D'Arcy J.M. Cain wrote: +> On January 6, 2004 01:42 am, Shridhar Daithankar wrote: +> cert=# select relpages,reltuples::bigint from pg_class where relname= +> 'certificate'; +> relpages | reltuples +> ----------+----------- +> 399070 | 24858736 +> (1 row) +> +> But: +> +> cert=# select count(*) from certificate; +> [*Crunch* *Crunch* *Crunch*] +> count +> ---------- +> 19684668 +> (1 row) +> +> Am I missing something? Max certificate_id is 20569544 btw. + +Do 'vacuum analyze certificate' and try..:-) + +The numbers from pg_class are estimates updated by vacuum /analyze. Of course +you need to run vacuum frequent enough for that statistics to be updated all +the time or run autovacuum daemon.. + +Ran into same problem on my machine till I remembered about vacuum..:-) + + Shridhar + + +From pgsql-performance-owner@postgresql.org Tue Jan 6 11:41:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EAB1BD1B45D + for ; + Tue, 6 Jan 2004 15:41:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00842-01 + for ; + Tue, 6 Jan 2004 11:40:48 -0400 (AST) +Received: from apollo.le.ac.uk (apollo.le.ac.uk [143.210.16.125]) + by svr1.postgresql.org (Postfix) with ESMTP id CB715D1B47D + for ; + Tue, 6 Jan 2004 11:40:38 -0400 (AST) +Received: from [143.210.8.56] (helo=harrier.le.ac.uk) + by apollo.le.ac.uk with esmtp (Exim 4.24) id 1AdtK4-0001mv-Kr + for pgsql-performance@postgresql.org; Tue, 06 Jan 2004 15:40:48 +0000 +Received: from localhost (cgp@localhost) + by harrier.le.ac.uk (SGI-8.12.5/8.12.5/Submit) with ESMTP id + i06FemsA10409716 + for ; Tue, 6 Jan 2004 15:40:48 GMT +X-Authentication-Warning: harrier.le.ac.uk: cgp owned process doing -bs +Date: Tue, 6 Jan 2004 15:40:48 +0000 +From: Clive Page +To: pgsql-performance@postgresql.org +Subject: Inefficient SELECT with OFFSET and LIMIT +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/66 +X-Sequence-Number: 5241 + +I have just discovered that if one does a SELECT with a LIMIT and OFFSET + values, say + +SELECT myfunc(mycol) FROM table LIMIT 50 OFFSET 10000 ; + +Then the whole of the selection expressions, including the function calls, +are actuall executed for every record, not just those being selected but +also those being skipped, i.e. 10050 in this case. +Actually it's even odder, as the number is that plus one, as the next +record in sequence is also passed to the function. + +I discovered this by accident, since I was using a user-defined function +in pl/pgsql and included by mistake some debug code using RAISE INFO, so +this diagnostic output gave the game away (and all of it came out before +any of the results of the selection, which was another surprise). + +It looks as if OFFSET is implemented just be throwing away the results, +until the OFFSET has been reached. + +It would be nice if OFFSET could be implemented in some more efficient +way. + + + +-- +Clive Page, +Dept of Physics & Astronomy, +University of Leicester, U.K. + + +From pgsql-performance-owner@postgresql.org Tue Jan 6 12:04:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 91114D1B554 + for ; + Tue, 6 Jan 2004 16:04:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05279-07 + for ; + Tue, 6 Jan 2004 12:03:52 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A907D1B8EA + for ; + Tue, 6 Jan 2004 12:03:51 -0400 (AST) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id i06FLJcM013644; + Tue, 6 Jan 2004 10:21:20 -0500 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i06G3Nl08025; + Tue, 6 Jan 2004 11:03:28 -0500 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id XT879Y02; Tue, 6 Jan 2004 11:03:21 -0500 +Subject: Re: Select max(foo) and select count(*) optimization +From: Robert Treat +To: Shridhar Daithankar +Cc: Postgresql Performance +In-Reply-To: <200401061750.09530.shridhar_daithankar@persistent.co.in> +References: + <200401061212.21344.shridhar_daithankar@persistent.co.in> + <200401060718.08444.darcy@druid.net> + <200401061750.09530.shridhar_daithankar@persistent.co.in> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 06 Jan 2004 11:03:23 -0500 +Message-Id: <1073405003.20751.2.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/67 +X-Sequence-Number: 5242 + +On Tue, 2004-01-06 at 07:20, Shridhar Daithankar wrote: +> On Tuesday 06 January 2004 17:48, D'Arcy J.M. Cain wrote: +> > On January 6, 2004 01:42 am, Shridhar Daithankar wrote: +> > cert=# select relpages,reltuples::bigint from pg_class where relname= +> > 'certificate'; +> > relpages | reltuples +> > ----------+----------- +> > 399070 | 24858736 +> > (1 row) +> > +> > But: +> > +> > cert=# select count(*) from certificate; +> > [*Crunch* *Crunch* *Crunch*] +> > count +> > ---------- +> > 19684668 +> > (1 row) +> > +> > Am I missing something? Max certificate_id is 20569544 btw. +> +> Do 'vacuum analyze certificate' and try..:-) +> +> The numbers from pg_class are estimates updated by vacuum /analyze. Of course +> you need to run vacuum frequent enough for that statistics to be updated all +> the time or run autovacuum daemon.. +> +> Ran into same problem on my machine till I remembered about vacuum..:-) +> + +Actually you only need to run analyze to update the statistics. + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Tue Jan 6 12:34:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 02B83D1CA94 + for ; + Tue, 6 Jan 2004 16:34:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10147-07 + for ; + Tue, 6 Jan 2004 12:33:18 -0400 (AST) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id 362EBD1CA8E + for ; + Tue, 6 Jan 2004 12:31:27 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id i06GVYNo016310 + for ; Tue, 6 Jan 2004 22:01:34 +0530 +Received: from persistent.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) + (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id i06GVXJN016283 + for ; Tue, 6 Jan 2004 22:01:33 +0530 +Message-ID: <3FFAE2D8.6080301@persistent.co.in> +Date: Tue, 06 Jan 2004 22:01:20 +0530 +From: Shridhar Daithankar +Organization: Persistent Systems Pvt. Ltd. +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +Cc: Postgresql Performance +Subject: Re: Select max(foo) and select count(*) optimization +References: + <200401061212.21344.shridhar_daithankar@persistent.co.in> + <200401060718.08444.darcy@druid.net> + <200401061750.09530.shridhar_daithankar@persistent.co.in> + <1073405003.20751.2.camel@camel> +In-Reply-To: <1073405003.20751.2.camel@camel> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/68 +X-Sequence-Number: 5243 + +Robert Treat wrote: +> On Tue, 2004-01-06 at 07:20, Shridhar Daithankar wrote: + +>>The numbers from pg_class are estimates updated by vacuum /analyze. Of course +>>you need to run vacuum frequent enough for that statistics to be updated all +>>the time or run autovacuum daemon.. +>>Ran into same problem on my machine till I remembered about vacuum..:-) +> Actually you only need to run analyze to update the statistics. + +Old habits die hard..:-) + + shridhar + +From pgsql-performance-owner@postgresql.org Tue Jan 6 14:13:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 73097D1B44B + for ; + Tue, 6 Jan 2004 18:13:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37697-03 + for ; + Tue, 6 Jan 2004 14:12:34 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 03EE9D1B48A + for ; + Tue, 6 Jan 2004 14:12:33 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id B793436BFD; Tue, 6 Jan 2004 13:12:17 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1Advgf-0000CU-00; Tue, 06 Jan 2004 13:12:17 -0500 +To: Clive Page +Cc: pgsql-performance@postgresql.org +Subject: Re: Inefficient SELECT with OFFSET and LIMIT +References: +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 06 Jan 2004 13:12:17 -0500 +Message-ID: <878ykl0wvy.fsf@stark.dyndns.tv> +Lines: 21 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/69 +X-Sequence-Number: 5244 + + +Clive Page writes: + +> SELECT myfunc(mycol) FROM table LIMIT 50 OFFSET 10000 ; + +> It looks as if OFFSET is implemented just be throwing away the results, +> until the OFFSET has been reached. +> +> It would be nice if OFFSET could be implemented in some more efficient +> way. + +You could do something like: + +select myfunc(mycol) from (select mycol from table limit 50 offset 10000) as x; + +I think it's not easy for the optimizer to do it because there are lots of +cases where it can't. Consider if you had an ORDER BY clause on the myfunc +output column for example. Or if myfunc was a set-returning function. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Jan 6 14:37:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D21DD1B511 + for ; + Tue, 6 Jan 2004 18:37:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39670-07 + for ; + Tue, 6 Jan 2004 14:36:50 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B1E87D1B43A + for ; + Tue, 6 Jan 2004 14:36:48 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i06Iaj19022306; + Tue, 6 Jan 2004 13:36:45 -0500 (EST) +To: Greg Stark +Cc: Clive Page , + pgsql-performance@postgresql.org +Subject: Re: Inefficient SELECT with OFFSET and LIMIT +In-reply-to: <878ykl0wvy.fsf@stark.dyndns.tv> +References: + <878ykl0wvy.fsf@stark.dyndns.tv> +Comments: In-reply-to Greg Stark + message dated "06 Jan 2004 13:12:17 -0500" +Date: Tue, 06 Jan 2004 13:36:44 -0500 +Message-ID: <22305.1073414204@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/70 +X-Sequence-Number: 5245 + +Greg Stark writes: +> Clive Page writes: +>> It would be nice if OFFSET could be implemented in some more efficient +>> way. + +> You could do something like: + +> select myfunc(mycol) from (select mycol from table limit 50 offset 10000) as x; + +Note that this won't eliminate the major inefficiency, which is having +to read 10000+50 rows from the table. But if myfunc() has side-effects +or is very expensive to run, it'd probably be worth doing. + +> I think it's not easy for the optimizer to do it because there are lots of +> cases where it can't. + +I don't actually know of any cases where it could do much of anything to +avoid fetching the OFFSET rows. The problems are basically the same as +with COUNT(*) optimization: without examining each row, you don't know +if it would have been returned or not. We could possibly postpone +evaluation of the SELECT output list until after the OFFSET step (thus +automating the above hack), but even that only works if there are no +set-returning functions in the output list ... + + regards, tom lane + +PS: BTW, the one-extra-row effect that Clive noted is gone in 7.4. + +From pgsql-performance-owner@postgresql.org Tue Jan 6 15:29:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4817AD1B438 + for ; + Tue, 6 Jan 2004 19:29:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53128-06 + for ; + Tue, 6 Jan 2004 15:28:30 -0400 (AST) +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) + by svr1.postgresql.org (Postfix) with ESMTP id F2FCAD1B4D4 + for ; + Tue, 6 Jan 2004 15:28:14 -0400 (AST) +Received: from smtp-3.paradise.net.nz (smtp-3a.paradise.net.nz [202.0.32.196]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HR300A9022WT0@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 07 Jan 2004 08:28:09 +1300 (NZDT) +Received: from paradise.net.nz (218-101-13-98.paradise.net.nz [218.101.13.98]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id D2943ADF4A; Wed, + 07 Jan 2004 08:28:07 +1300 (NZDT) +Date: Wed, 07 Jan 2004 08:28:45 +1300 +From: Mark Kirkwood +Subject: Re: Select max(foo) and select count(*) optimization +In-reply-to: <200401060718.08444.darcy@druid.net> +To: "D'Arcy J.M. Cain" +Cc: Shridhar Daithankar , + Postgresql Performance +Message-id: <3FFB0C6D.9020704@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.5) Gecko/20031213 +References: + <1073332325.8958.8.camel@jester> + <200401061212.21344.shridhar_daithankar@persistent.co.in> + <200401060718.08444.darcy@druid.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/71 +X-Sequence-Number: 5246 + +if this situation persists after 'analyze certificate', then you need to: + +increase the statistics target 'alter table certificate alter column +certificate_id set statistics 100' + +or + +'vacuum full certificate' + +i.e : there are lots of (dead) updated or deleted tuples in the +relation, distributed in such a way as to throw off analyze's estimate. + +regards + +Mark + +D'Arcy J.M. Cain wrote: + +> +>Well, I did this: +> +>cert=# select relpages,reltuples from pg_class where relname= 'certificate'; +> relpages | reltuples +>----------+------------- +> 399070 | 2.48587e+07 +>(1 row) +> +>Casting seemed to help: +> +>cert=# select relpages,reltuples::bigint from pg_class where relname= +>'certificate'; +> relpages | reltuples +>----------+----------- +> 399070 | 24858736 +>(1 row) +> +>But: +> +>cert=# select count(*) from certificate; +>[*Crunch* *Crunch* *Crunch*] +> count +>---------- +> 19684668 +>(1 row) +> +>Am I missing something? Max certificate_id is 20569544 btw. +> +> +> + + +From pgsql-performance-owner@postgresql.org Tue Jan 6 16:50:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 981F9D1B45B + for ; + Tue, 6 Jan 2004 20:50:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72403-03 + for ; + Tue, 6 Jan 2004 16:49:25 -0400 (AST) +Received: from mail.ncsa.uiuc.edu (mail.ncsa.uiuc.edu [141.142.2.28]) + by svr1.postgresql.org (Postfix) with ESMTP id F3BF9D1B436 + for ; + Tue, 6 Jan 2004 16:49:20 -0400 (AST) +X-Envelope-From: mshapiro@ncsa.edu +X-Envelope-To: +Received: from kalika.ncsa.edu (kalika.ncsa.uiuc.edu [141.142.97.63]) + by mail.ncsa.uiuc.edu (8.11.6p2/8.11.6) with ESMTP id i06KnHC26086 + for ; Tue, 6 Jan 2004 14:49:17 -0600 +Message-Id: <5.2.0.9.2.20040106144745.00bcfe30@pop.ncsa.uiuc.edu> +X-Sender: mshapiro@pop.ncsa.uiuc.edu (Unverified) +X-Mailer: QUALCOMM Windows Eudora Version 5.2.0.9 +Date: Tue, 06 Jan 2004 14:49:16 -0600 +To: pgsql-performance@postgresql.org +From: Michael Shapiro +Subject: PgAdmin startup query VERY slow +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="=====================_15580593==_" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/72 +X-Sequence-Number: 5247 + +--=====================_15580593==_ +Content-Type: text/plain; charset="us-ascii"; format=flowed + +I have reported this on the pgadmin-support mailing list, but Andreas Pflug +has asked me to post it here. + +With a particular database, PgAdmin3 takes a very long time to connect to a +database. this is not a general problem with PgAdmin, but only with one +database out of many. Other databases do not have the problem. And only +with one particular server. The exact same database on a different server +does not have the problem. + +The server in question is running PostgreSQL 7.3.2 on +sparc-sun-solaris2.8, compiled by GCC 2.95.2 + +The other server which has the same database is running Postgres 7.3.4 on +i386-redhat-linux-gnu, complied by GCC i386-redhat-linux-gcc 3.2.2. + +I have attached the query that Andreas says is the one that is run when +PgAdmin first connects to a database as well as the output from running the +query with explain turned on. + +Both Andreas and I would be every interested if this group might have any +ideas why the query is so slow. + +NOTE: I have vacuumed the database, but that did not affect the timing at all. +NOTE: The startup on the sparc server is 44 seconds, The startup on the +linux server is 5 seconds. + +Andreas writes: +I can't see too much from this query plan, it just seems you have 321 +triggers an 4750 dependencies which isn't too extraordinary much. But 48 +seconds execution time *is* much. + +Please repost this to pgsql-performance, including the query, backend +version, and modified server settings. I'm not deep enough in planner items +to analyze this sufficiently. +Please let me CCd on this topic so I can see what I should change in +pgAdmin3 (if any). + + + +--- +Michael + + +--- +Michael +--=====================_15580593==_ +Content-Type: text/plain; charset="us-ascii" +Content-Disposition: attachment; filename="query.txt" + +SELECT COUNT(*) FROM +(SELECT tgargs from pg_trigger tr +LEFT JOIN pg_depend dep ON dep.objid=tr.oid AND deptype = 'i' +LEFT JOIN pg_constraint co ON refobjid = co.oid AND contype = 'f' +WHERE co.oid IS NULL +GROUP BY tgargs +HAVING count(1) = 3) AS foo + +--=====================_15580593==_ +Content-Type: text/plain; name="expalin.txt"; + x-mac-type="42494E41"; x-mac-creator="74747874" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="expalin.txt" + +UVVFUlkgUExBTgogICB7IEFHRyAKICAgOnN0YXJ0dXBfY29zdCAxODMuMzYg +CiAgIDp0b3RhbF9jb3N0IDE4My4zNiAKICAgOnJvd3MgMSAKICAgOndpZHRo +IDIyIAogICA6cXB0YXJnZXRsaXN0ICgKICAgICAgeyBUQVJHRVRFTlRSWSAK +ICAgICAgOnJlc2RvbSAKICAgICAgICAgeyBSRVNET00gCiAgICAgICAgIDpy +ZXNubyAxIAogICAgICAgICA6cmVzdHlwZSAyMCAKICAgICAgICAgOnJlc3R5 +cG1vZCAtMSAKICAgICAgICAgOnJlc25hbWUgY291bnQgCiAgICAgICAgIDpy +ZXNrZXkgMCAKICAgICAgICAgOnJlc2tleW9wIDAgCiAgICAgICAgIDpyZXNz +b3J0Z3JvdXByZWYgMCAKICAgICAgICAgOnJlc2p1bmsgZmFsc2UgCiAgICAg +ICAgIH0KICAgICAgIAogICAgICA6ZXhwciAKICAgICAgICAgeyBBR0dSRUcg +CiAgICAgICAgIDphZ2dmbm9pZCAyMTQ3IAogICAgICAgICA6YWdndHlwZSAy +MCAKICAgICAgICAgOnRhcmdldCAKICAgICAgICAgICAgeyBDT05TVCAKICAg +ICAgICAgICAgOmNvbnN0dHlwZSAyMyAKICAgICAgICAgICAgOmNvbnN0bGVu +IDQgCiAgICAgICAgICAgIDpjb25zdGJ5dmFsIHRydWUgCiAgICAgICAgICAg +IDpjb25zdGlzbnVsbCBmYWxzZSAKICAgICAgICAgICAgOmNvbnN0dmFsdWUg +IDQgWyAwIDAgMCAxIF0gCiAgICAgICAgICAgIH0KICAgICAgICAgIAogICAg +ICAgICA6YWdnc3RhciB0cnVlIAogICAgICAgICA6YWdnZGlzdGluY3QgZmFs +c2UgCiAgICAgICAgIH0KICAgICAgfQogICApCiAgICAKICAgOnFwcXVhbCA8 +PiAKICAgOmxlZnR0cmVlIAogICAgICB7IFNVQlFVRVJZU0NBTiAKICAgICAg +OnN0YXJ0dXBfY29zdCAxODMuMzQgCiAgICAgIDp0b3RhbF9jb3N0IDE4My4z +NiAKICAgICAgOnJvd3MgMSAKICAgICAgOndpZHRoIDIyIAogICAgICA6cXB0 +YXJnZXRsaXN0IDw+IAogICAgICA6cXBxdWFsIDw+IAogICAgICA6bGVmdHRy +ZWUgPD4gCiAgICAgIDpyaWdodHRyZWUgPD4gCiAgICAgIDpleHRwcm0gKCkK +ICAgICAgIAogICAgICA6bG9jcHJtICgpCiAgICAgICAKICAgICAgOmluaXRw +bGFuIDw+IAogICAgICA6bnBybSAwICAKICAgICAgOnNjYW5yZWxpZCAxIAog +ICAgICA6c3VicGxhbiAKICAgICAgICAgeyBBR0cgCiAgICAgICAgIDpzdGFy +dHVwX2Nvc3QgMTgzLjM0IAogICAgICAgICA6dG90YWxfY29zdCAxODMuMzYg +CiAgICAgICAgIDpyb3dzIDEgCiAgICAgICAgIDp3aWR0aCAyMiAKICAgICAg +ICAgOnFwdGFyZ2V0bGlzdCAoCiAgICAgICAgICAgIHsgVEFSR0VURU5UUlkg +CiAgICAgICAgICAgIDpyZXNkb20gCiAgICAgICAgICAgICAgIHsgUkVTRE9N +IAogICAgICAgICAgICAgICA6cmVzbm8gMSAKICAgICAgICAgICAgICAgOnJl +c3R5cGUgMTcgCiAgICAgICAgICAgICAgIDpyZXN0eXBtb2QgLTEgCiAgICAg +ICAgICAgICAgIDpyZXNuYW1lIHRnYXJncyAKICAgICAgICAgICAgICAgOnJl +c2tleSAwIAogICAgICAgICAgICAgICA6cmVza2V5b3AgMCAKICAgICAgICAg +ICAgICAgOnJlc3NvcnRncm91cHJlZiAxIAogICAgICAgICAgICAgICA6cmVz +anVuayBmYWxzZSAKICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgCiAg +ICAgICAgICAgIDpleHByIAogICAgICAgICAgICAgICB7IFZBUiAKICAgICAg +ICAgICAgICAgOnZhcm5vIDAgCiAgICAgICAgICAgICAgIDp2YXJhdHRubyAx +IAogICAgICAgICAgICAgICA6dmFydHlwZSAxNyAKICAgICAgICAgICAgICAg +OnZhcnR5cG1vZCAtMSAgCiAgICAgICAgICAgICAgIDp2YXJsZXZlbHN1cCAw +IAogICAgICAgICAgICAgICA6dmFybm9vbGQgMSAKICAgICAgICAgICAgICAg +OnZhcm9hdHRubyAxMwogICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0K +ICAgICAgICAgKQogICAgICAgICAgCiAgICAgICAgIDpxcHF1YWwgKAogICAg +ICAgICAgICB7IEVYUFIgCiAgICAgICAgICAgIDp0eXBlT2lkIDE2ICAKICAg +ICAgICAgICAgOm9wVHlwZSBvcCAKICAgICAgICAgICAgOm9wZXIgCiAgICAg +ICAgICAgICAgIHsgT1BFUiAKICAgICAgICAgICAgICAgOm9wbm8gNDE2IAog +ICAgICAgICAgICAgICA6b3BpZCA0NzQgCiAgICAgICAgICAgICAgIDpvcHJl +c3VsdHR5cGUgMTYgCiAgICAgICAgICAgICAgIDpvcHJldHNldCBmYWxzZSAK +ICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgCiAgICAgICAgICAgIDph +cmdzICgKICAgICAgICAgICAgICAgeyBBR0dSRUcgCiAgICAgICAgICAgICAg +IDphZ2dmbm9pZCAyMTQ3IAogICAgICAgICAgICAgICA6YWdndHlwZSAyMCAK +ICAgICAgICAgICAgICAgOnRhcmdldCAKICAgICAgICAgICAgICAgICAgeyBD +T05TVCAKICAgICAgICAgICAgICAgICAgOmNvbnN0dHlwZSAyMyAKICAgICAg +ICAgICAgICAgICAgOmNvbnN0bGVuIDQgCiAgICAgICAgICAgICAgICAgIDpj +b25zdGJ5dmFsIHRydWUgCiAgICAgICAgICAgICAgICAgIDpjb25zdGlzbnVs +bCBmYWxzZSAKICAgICAgICAgICAgICAgICAgOmNvbnN0dmFsdWUgIDQgWyAw +IDAgMCAxIF0gCiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAg +IAogICAgICAgICAgICAgICA6YWdnc3RhciBmYWxzZSAKICAgICAgICAgICAg +ICAgOmFnZ2Rpc3RpbmN0IGZhbHNlIAogICAgICAgICAgICAgICB9CiAgICAg +ICAgICAgICAKICAgICAgICAgICAgICAgeyBDT05TVCAKICAgICAgICAgICAg +ICAgOmNvbnN0dHlwZSAyMyAKICAgICAgICAgICAgICAgOmNvbnN0bGVuIDQg +CiAgICAgICAgICAgICAgIDpjb25zdGJ5dmFsIHRydWUgCiAgICAgICAgICAg +ICAgIDpjb25zdGlzbnVsbCBmYWxzZSAKICAgICAgICAgICAgICAgOmNvbnN0 +dmFsdWUgIDQgWyAwIDAgMCAzIF0gCiAgICAgICAgICAgICAgIH0KICAgICAg +ICAgICAgKQogICAgICAgICAgICB9CiAgICAgICAgICkKICAgICAgICAgIAog +ICAgICAgICA6bGVmdHRyZWUgCiAgICAgICAgICAgIHsgR1JQIAogICAgICAg +ICAgICA6c3RhcnR1cF9jb3N0IDE4My4zNCAKICAgICAgICAgICAgOnRvdGFs +X2Nvc3QgMTgzLjM1IAogICAgICAgICAgICA6cm93cyAyIAogICAgICAgICAg +ICA6d2lkdGggMjIgCiAgICAgICAgICAgIDpxcHRhcmdldGxpc3QgKAogICAg +ICAgICAgICAgICB7IFRBUkdFVEVOVFJZIAogICAgICAgICAgICAgICA6cmVz +ZG9tIAogICAgICAgICAgICAgICAgICB7IFJFU0RPTSAKICAgICAgICAgICAg +ICAgICAgOnJlc25vIDEgCiAgICAgICAgICAgICAgICAgIDpyZXN0eXBlIDE3 +IAogICAgICAgICAgICAgICAgICA6cmVzdHlwbW9kIC0xIAogICAgICAgICAg +ICAgICAgICA6cmVzbmFtZSA8PiAKICAgICAgICAgICAgICAgICAgOnJlc2tl +eSAwIAogICAgICAgICAgICAgICAgICA6cmVza2V5b3AgMCAKICAgICAgICAg +ICAgICAgICAgOnJlc3NvcnRncm91cHJlZiAwIAogICAgICAgICAgICAgICAg +ICA6cmVzanVuayBmYWxzZSAKICAgICAgICAgICAgICAgICAgfQogICAgICAg +ICAgICAgICAgCiAgICAgICAgICAgICAgIDpleHByIAogICAgICAgICAgICAg +ICAgICB7IFZBUiAKICAgICAgICAgICAgICAgICAgOnZhcm5vIDAgCiAgICAg +ICAgICAgICAgICAgIDp2YXJhdHRubyAxIAogICAgICAgICAgICAgICAgICA6 +dmFydHlwZSAxNyAKICAgICAgICAgICAgICAgICAgOnZhcnR5cG1vZCAtMSAg +CiAgICAgICAgICAgICAgICAgIDp2YXJsZXZlbHN1cCAwIAogICAgICAgICAg +ICAgICAgICA6dmFybm9vbGQgMSAKICAgICAgICAgICAgICAgICAgOnZhcm9h +dHRubyAxMwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgIH0K +ICAgICAgICAgICAgKQogICAgICAgICAgICAgCiAgICAgICAgICAgIDpxcHF1 +YWwgPD4gCiAgICAgICAgICAgIDpsZWZ0dHJlZSAKICAgICAgICAgICAgICAg +eyBTT1JUIAogICAgICAgICAgICAgICA6c3RhcnR1cF9jb3N0IDE4My4zNCAK +ICAgICAgICAgICAgICAgOnRvdGFsX2Nvc3QgMTgzLjM1IAogICAgICAgICAg +ICAgICA6cm93cyAyIAogICAgICAgICAgICAgICA6d2lkdGggMjIgCiAgICAg +ICAgICAgICAgIDpxcHRhcmdldGxpc3QgKAogICAgICAgICAgICAgICAgICB7 +IFRBUkdFVEVOVFJZIAogICAgICAgICAgICAgICAgICA6cmVzZG9tIAogICAg +ICAgICAgICAgICAgICAgICB7IFJFU0RPTSAKICAgICAgICAgICAgICAgICAg +ICAgOnJlc25vIDEgCiAgICAgICAgICAgICAgICAgICAgIDpyZXN0eXBlIDE3 +IAogICAgICAgICAgICAgICAgICAgICA6cmVzdHlwbW9kIC0xIAogICAgICAg +ICAgICAgICAgICAgICA6cmVzbmFtZSA8PiAKICAgICAgICAgICAgICAgICAg +ICAgOnJlc2tleSAxIAogICAgICAgICAgICAgICAgICAgICA6cmVza2V5b3Ag +MTk1NyAKICAgICAgICAgICAgICAgICAgICAgOnJlc3NvcnRncm91cHJlZiAw +IAogICAgICAgICAgICAgICAgICAgICA6cmVzanVuayBmYWxzZSAKICAgICAg +ICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgCiAgICAgICAg +ICAgICAgICAgIDpleHByIAogICAgICAgICAgICAgICAgICAgICB7IFZBUiAK +ICAgICAgICAgICAgICAgICAgICAgOnZhcm5vIDEgCiAgICAgICAgICAgICAg +ICAgICAgIDp2YXJhdHRubyAxMyAKICAgICAgICAgICAgICAgICAgICAgOnZh +cnR5cGUgMTcgCiAgICAgICAgICAgICAgICAgICAgIDp2YXJ0eXBtb2QgLTEg +IAogICAgICAgICAgICAgICAgICAgICA6dmFybGV2ZWxzdXAgMCAKICAgICAg +ICAgICAgICAgICAgICAgOnZhcm5vb2xkIDEgCiAgICAgICAgICAgICAgICAg +ICAgIDp2YXJvYXR0bm8gMTMKICAgICAgICAgICAgICAgICAgICAgfQogICAg +ICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICkKICAgICAgICAgICAg +ICAgIAogICAgICAgICAgICAgICA6cXBxdWFsIDw+IAogICAgICAgICAgICAg +ICA6bGVmdHRyZWUgCiAgICAgICAgICAgICAgICAgIHsgSEFTSEpPSU4gCiAg +ICAgICAgICAgICAgICAgIDpzdGFydHVwX2Nvc3QgMC4wMCAKICAgICAgICAg +ICAgICAgICAgOnRvdGFsX2Nvc3QgMTgzLjMzIAogICAgICAgICAgICAgICAg +ICA6cm93cyAyIAogICAgICAgICAgICAgICAgICA6d2lkdGggMjIgCiAgICAg +ICAgICAgICAgICAgIDpxcHRhcmdldGxpc3QgKAogICAgICAgICAgICAgICAg +ICAgICB7IFRBUkdFVEVOVFJZIAogICAgICAgICAgICAgICAgICAgICA6cmVz +ZG9tIAogICAgICAgICAgICAgICAgICAgICAgICB7IFJFU0RPTSAKICAgICAg +ICAgICAgICAgICAgICAgICAgOnJlc25vIDEgCiAgICAgICAgICAgICAgICAg +ICAgICAgIDpyZXN0eXBlIDE3IAogICAgICAgICAgICAgICAgICAgICAgICA6 +cmVzdHlwbW9kIC0xIAogICAgICAgICAgICAgICAgICAgICAgICA6cmVzbmFt +ZSA8PiAKICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2tleSAwIAogICAg +ICAgICAgICAgICAgICAgICAgICA6cmVza2V5b3AgMCAKICAgICAgICAgICAg +ICAgICAgICAgICAgOnJlc3NvcnRncm91cHJlZiAwIAogICAgICAgICAgICAg +ICAgICAgICAgICA6cmVzanVuayBmYWxzZSAKICAgICAgICAgICAgICAgICAg +ICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAg +ICAgICAgIDpleHByIAogICAgICAgICAgICAgICAgICAgICAgICB7IFZBUiAK +ICAgICAgICAgICAgICAgICAgICAgICAgOnZhcm5vIDY1MDAxIAogICAgICAg +ICAgICAgICAgICAgICAgICA6dmFyYXR0bm8gMSAKICAgICAgICAgICAgICAg +ICAgICAgICAgOnZhcnR5cGUgMTcgCiAgICAgICAgICAgICAgICAgICAgICAg +IDp2YXJ0eXBtb2QgLTEgIAogICAgICAgICAgICAgICAgICAgICAgICA6dmFy +bGV2ZWxzdXAgMCAKICAgICAgICAgICAgICAgICAgICAgICAgOnZhcm5vb2xk +IDEgCiAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJvYXR0bm8gMTMKICAg +ICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICB9 +CiAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgICAgIAogICAg +ICAgICAgICAgICAgICA6cXBxdWFsICgKICAgICAgICAgICAgICAgICAgICAg +eyBOVUxMVEVTVCAKICAgICAgICAgICAgICAgICAgICAgOmFyZyAKICAgICAg +ICAgICAgICAgICAgICAgICAgeyBWQVIgCiAgICAgICAgICAgICAgICAgICAg +ICAgIDp2YXJubyA2NTAwMCAKICAgICAgICAgICAgICAgICAgICAgICAgOnZh +cmF0dG5vIDEgCiAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJ0eXBlIDI2 +IAogICAgICAgICAgICAgICAgICAgICAgICA6dmFydHlwbW9kIC0xICAKICAg +ICAgICAgICAgICAgICAgICAgICAgOnZhcmxldmVsc3VwIDAgCiAgICAgICAg +ICAgICAgICAgICAgICAgIDp2YXJub29sZCA0IAogICAgICAgICAgICAgICAg +ICAgICAgICA6dmFyb2F0dG5vIC0yCiAgICAgICAgICAgICAgICAgICAgICAg +IH0KICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAg +ICA6bnVsbHRlc3R0eXBlIDAgCiAgICAgICAgICAgICAgICAgICAgIH0KICAg +ICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgICAgCiAgICAgICAg +ICAgICAgICAgIDpsZWZ0dHJlZSAKICAgICAgICAgICAgICAgICAgICAgeyBO +RVNUTE9PUCAKICAgICAgICAgICAgICAgICAgICAgOnN0YXJ0dXBfY29zdCAw +LjAwIAogICAgICAgICAgICAgICAgICAgICA6dG90YWxfY29zdCAxODMuMzIg +CiAgICAgICAgICAgICAgICAgICAgIDpyb3dzIDIgCiAgICAgICAgICAgICAg +ICAgICAgIDp3aWR0aCAxNyAKICAgICAgICAgICAgICAgICAgICAgOnFwdGFy +Z2V0bGlzdCAoCiAgICAgICAgICAgICAgICAgICAgICAgIHsgVEFSR0VURU5U +UlkgCiAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNkb20gCiAgICAgICAg +ICAgICAgICAgICAgICAgICAgIHsgUkVTRE9NIAogICAgICAgICAgICAgICAg +ICAgICAgICAgICA6cmVzbm8gMSAKICAgICAgICAgICAgICAgICAgICAgICAg +ICAgOnJlc3R5cGUgMTcgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpy +ZXN0eXBtb2QgLTEgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNu +YW1lIDw+IAogICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVza2V5IDAg +CiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNrZXlvcCAwIAogICAg +ICAgICAgICAgICAgICAgICAgICAgICA6cmVzc29ydGdyb3VwcmVmIDAgCiAg +ICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNqdW5rIGZhbHNlIAogICAg +ICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAg +ICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgOmV4cHIgCiAgICAgICAg +ICAgICAgICAgICAgICAgICAgIHsgVkFSIAogICAgICAgICAgICAgICAgICAg +ICAgICAgICA6dmFybm8gNjUwMDEgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgIDp2YXJhdHRubyAxIAogICAgICAgICAgICAgICAgICAgICAgICAgICA6 +dmFydHlwZSAxNyAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcnR5 +cG1vZCAtMSAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJsZXZl +bHN1cCAwIAogICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFybm9vbGQg +MSAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcm9hdHRubyAxMwog +ICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAg +ICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAg +ICAgICAgICAgICB7IFRBUkdFVEVOVFJZIAogICAgICAgICAgICAgICAgICAg +ICAgICA6cmVzZG9tIAogICAgICAgICAgICAgICAgICAgICAgICAgICB7IFJF +U0RPTSAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc25vIDIgCiAg +ICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXN0eXBlIDI2IAogICAgICAg +ICAgICAgICAgICAgICAgICAgICA6cmVzdHlwbW9kIC0xIAogICAgICAgICAg +ICAgICAgICAgICAgICAgICA6cmVzbmFtZSA8PiAKICAgICAgICAgICAgICAg +ICAgICAgICAgICAgOnJlc2tleSAwIAogICAgICAgICAgICAgICAgICAgICAg +ICAgICA6cmVza2V5b3AgMCAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +OnJlc3NvcnRncm91cHJlZiAwIAogICAgICAgICAgICAgICAgICAgICAgICAg +ICA6cmVzanVuayBmYWxzZSAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +fQogICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAg +ICAgICAgIDpleHByIAogICAgICAgICAgICAgICAgICAgICAgICAgICB7IFZB +UiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcm5vIDY1MDAxIAog +ICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFyYXR0bm8gMiAKICAgICAg +ICAgICAgICAgICAgICAgICAgICAgOnZhcnR5cGUgMjYgCiAgICAgICAgICAg +ICAgICAgICAgICAgICAgIDp2YXJ0eXBtb2QgLTEgIAogICAgICAgICAgICAg +ICAgICAgICAgICAgICA6dmFybGV2ZWxzdXAgMCAKICAgICAgICAgICAgICAg +ICAgICAgICAgICAgOnZhcm5vb2xkIDEgCiAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDp2YXJvYXR0bm8gLTIKICAgICAgICAgICAgICAgICAgICAgICAg +ICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAg +ICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgeyBUQVJHRVRFTlRS +WSAKICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2RvbSAKICAgICAgICAg +ICAgICAgICAgICAgICAgICAgeyBSRVNET00gCiAgICAgICAgICAgICAgICAg +ICAgICAgICAgIDpyZXNubyAzIAogICAgICAgICAgICAgICAgICAgICAgICAg +ICA6cmVzdHlwZSAyNiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJl +c3R5cG1vZCAtMSAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc25h +bWUgPD4gCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNrZXkgMCAK +ICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2tleW9wIDAgCiAgICAg +ICAgICAgICAgICAgICAgICAgICAgIDpyZXNzb3J0Z3JvdXByZWYgMCAKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2p1bmsgZmFsc2UgCiAgICAg +ICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAg +ICAgIAogICAgICAgICAgICAgICAgICAgICAgICA6ZXhwciAKICAgICAgICAg +ICAgICAgICAgICAgICAgICAgeyBWQVIgCiAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDp2YXJubyA2NTAwMCAKICAgICAgICAgICAgICAgICAgICAgICAg +ICAgOnZhcmF0dG5vIDEgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2 +YXJ0eXBlIDI2IAogICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFydHlw +bW9kIC0xICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcmxldmVs +c3VwIDAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJub29sZCAy +IAogICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFyb2F0dG5vIDIKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAg +ICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAg +ICAgICAgICAgeyBUQVJHRVRFTlRSWSAKICAgICAgICAgICAgICAgICAgICAg +ICAgOnJlc2RvbSAKICAgICAgICAgICAgICAgICAgICAgICAgICAgeyBSRVNE +T00gCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNubyA0IAogICAg +ICAgICAgICAgICAgICAgICAgICAgICA6cmVzdHlwZSAxOCAKICAgICAgICAg +ICAgICAgICAgICAgICAgICAgOnJlc3R5cG1vZCAtMSAKICAgICAgICAgICAg +ICAgICAgICAgICAgICAgOnJlc25hbWUgPD4gCiAgICAgICAgICAgICAgICAg +ICAgICAgICAgIDpyZXNrZXkgMCAKICAgICAgICAgICAgICAgICAgICAgICAg +ICAgOnJlc2tleW9wIDAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpy +ZXNzb3J0Z3JvdXByZWYgMCAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +OnJlc2p1bmsgZmFsc2UgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIH0K +ICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAg +ICAgICA6ZXhwciAKICAgICAgICAgICAgICAgICAgICAgICAgICAgeyBWQVIg +CiAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJubyA2NTAwMCAKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgOnZhcmF0dG5vIDIgCiAgICAgICAg +ICAgICAgICAgICAgICAgICAgIDp2YXJ0eXBlIDE4IAogICAgICAgICAgICAg +ICAgICAgICAgICAgICA6dmFydHlwbW9kIC0xICAKICAgICAgICAgICAgICAg +ICAgICAgICAgICAgOnZhcmxldmVsc3VwIDAgCiAgICAgICAgICAgICAgICAg +ICAgICAgICAgIDp2YXJub29sZCAyIAogICAgICAgICAgICAgICAgICAgICAg +ICAgICA6dmFyb2F0dG5vIDcKICAgICAgICAgICAgICAgICAgICAgICAgICAg +fQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAg +ICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgeyBUQVJHRVRFTlRSWSAK +ICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2RvbSAKICAgICAgICAgICAg +ICAgICAgICAgICAgICAgeyBSRVNET00gCiAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDpyZXNubyA1IAogICAgICAgICAgICAgICAgICAgICAgICAgICA6 +cmVzdHlwZSAyNiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc3R5 +cG1vZCAtMSAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc25hbWUg +PD4gCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNrZXkgMCAKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2tleW9wIDAgCiAgICAgICAg +ICAgICAgICAgICAgICAgICAgIDpyZXNzb3J0Z3JvdXByZWYgMCAKICAgICAg +ICAgICAgICAgICAgICAgICAgICAgOnJlc2p1bmsgZmFsc2UgCiAgICAgICAg +ICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAg +IAogICAgICAgICAgICAgICAgICAgICAgICA6ZXhwciAKICAgICAgICAgICAg +ICAgICAgICAgICAgICAgeyBWQVIgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgIDp2YXJubyA2NTAwMCAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +OnZhcmF0dG5vIDMgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJ0 +eXBlIDI2IAogICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFydHlwbW9k +IC0xICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcmxldmVsc3Vw +IDAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJub29sZCAyIAog +ICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFyb2F0dG5vIDUKICAgICAg +ICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAg +ICB9CiAgICAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgICAg +ICAgIAogICAgICAgICAgICAgICAgICAgICA6cXBxdWFsIDw+IAogICAgICAg +ICAgICAgICAgICAgICA6bGVmdHRyZWUgCiAgICAgICAgICAgICAgICAgICAg +ICAgIHsgU0VRU0NBTiAKICAgICAgICAgICAgICAgICAgICAgICAgOnN0YXJ0 +dXBfY29zdCAwLjAwIAogICAgICAgICAgICAgICAgICAgICAgICA6dG90YWxf +Y29zdCAxLjAyIAogICAgICAgICAgICAgICAgICAgICAgICA6cm93cyAyIAog +ICAgICAgICAgICAgICAgICAgICAgICA6d2lkdGggOCAKICAgICAgICAgICAg +ICAgICAgICAgICAgOnFwdGFyZ2V0bGlzdCAoCiAgICAgICAgICAgICAgICAg +ICAgICAgICAgIHsgVEFSR0VURU5UUlkgCiAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDpyZXNkb20gCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +IHsgUkVTRE9NIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVz +bm8gMSAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc3R5cGUg +MTcgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXN0eXBtb2Qg +LTEgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNuYW1lIDw+ +IAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVza2V5IDAgCiAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNrZXlvcCAwIAogICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVzc29ydGdyb3VwcmVmIDAg +CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNqdW5rIGZhbHNl +IAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +OmV4cHIgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsgVkFSIAog +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFybm8gMSAKICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgOnZhcmF0dG5vIDEzIAogICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICA6dmFydHlwZSAxNyAKICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgOnZhcnR5cG1vZCAtMSAgCiAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgIDp2YXJsZXZlbHN1cCAwIAogICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICA6dmFybm9vbGQgMSAKICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgOnZhcm9hdHRubyAxMwogICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAg +ICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAg +ICAgICAgICAgICAgICB7IFRBUkdFVEVOVFJZIAogICAgICAgICAgICAgICAg +ICAgICAgICAgICA6cmVzZG9tIAogICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICB7IFJFU0RPTSAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +OnJlc25vIDIgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXN0 +eXBlIDI2IAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVzdHlw +bW9kIC0xIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVzbmFt +ZSA8PiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2tleSAw +IAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVza2V5b3AgMCAK +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc3NvcnRncm91cHJl +ZiAwIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVzanVuayBm +YWxzZSAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAg +ICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgIDpleHByIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7IFZB +UiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcm5vIDEgCiAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJhdHRubyAtMiAKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcnR5cGUgMjYgCiAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJ0eXBtb2QgLTEgIAogICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFybGV2ZWxzdXAgMCAKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcm5vb2xkIDEgCiAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJvYXR0bm8gLTIKICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAg +ICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICkKICAgICAgICAg +ICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICA6cXBx +dWFsIDw+IAogICAgICAgICAgICAgICAgICAgICAgICA6bGVmdHRyZWUgPD4g +CiAgICAgICAgICAgICAgICAgICAgICAgIDpyaWdodHRyZWUgPD4gCiAgICAg +ICAgICAgICAgICAgICAgICAgIDpleHRwcm0gKCkKICAgICAgICAgICAgICAg +ICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICA6bG9jcHJtICgp +CiAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAg +ICAgICAgOmluaXRwbGFuIDw+IAogICAgICAgICAgICAgICAgICAgICAgICA6 +bnBybSAwICAKICAgICAgICAgICAgICAgICAgICAgICAgOnNjYW5yZWxpZCAx +IAogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAg +ICAgICAKICAgICAgICAgICAgICAgICAgICAgOnJpZ2h0dHJlZSAKICAgICAg +ICAgICAgICAgICAgICAgICAgeyBTRVFTQ0FOIAogICAgICAgICAgICAgICAg +ICAgICAgICA6c3RhcnR1cF9jb3N0IDAuMDAgCiAgICAgICAgICAgICAgICAg +ICAgICAgIDp0b3RhbF9jb3N0IDQ5LjA2IAogICAgICAgICAgICAgICAgICAg +ICAgICA6cm93cyAyODA2IAogICAgICAgICAgICAgICAgICAgICAgICA6d2lk +dGggOSAKICAgICAgICAgICAgICAgICAgICAgICAgOnFwdGFyZ2V0bGlzdCAo +CiAgICAgICAgICAgICAgICAgICAgICAgICAgIHsgVEFSR0VURU5UUlkgCiAg +ICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNkb20gCiAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgIHsgUkVTRE9NIAogICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICA6cmVzbm8gMSAKICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgOnJlc3R5cGUgMjYgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDpyZXN0eXBtb2QgLTEgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDpyZXNuYW1lIDw+IAogICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICA6cmVza2V5IDAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +IDpyZXNrZXlvcCAwIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6 +cmVzc29ydGdyb3VwcmVmIDAgCiAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgIDpyZXNqdW5rIGZhbHNlIAogICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAg +ICAgICAgICAgICAgICAgICAgOmV4cHIgCiAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgIHsgVkFSIAogICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICA6dmFybm8gMiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZh +cmF0dG5vIDIgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJ0 +eXBlIDI2IAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFydHlw +bW9kIC0xICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcmxl +dmVsc3VwIDAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJu +b29sZCAyIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFyb2F0 +dG5vIDIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAg +ICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAg +ICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgeyBUQVJHRVRFTlRSWSAK +ICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2RvbSAKICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgeyBSRVNET00gCiAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgIDpyZXNubyAyIAogICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICA6cmVzdHlwZSAxOCAKICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgOnJlc3R5cG1vZCAtMSAKICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgOnJlc25hbWUgPD4gCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDpyZXNrZXkgMCAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgOnJlc2tleW9wIDAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +IDpyZXNzb3J0Z3JvdXByZWYgMCAKICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgOnJlc2p1bmsgZmFsc2UgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAg +ICAgICAgICAgICAgICAgICAgICA6ZXhwciAKICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgeyBWQVIgCiAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgIDp2YXJubyAyIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6 +dmFyYXR0bm8gNyAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZh +cnR5cGUgMTggCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJ0 +eXBtb2QgLTEgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFy +bGV2ZWxzdXAgMCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZh +cm5vb2xkIDIgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJv +YXR0bm8gNwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAg +ICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAg +ICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICB7IFRBUkdFVEVOVFJZ +IAogICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVzZG9tIAogICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICB7IFJFU0RPTSAKICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgOnJlc25vIDMgCiAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgIDpyZXN0eXBlIDI2IAogICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICA6cmVzdHlwbW9kIC0xIAogICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICA6cmVzbmFtZSA8PiAKICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgOnJlc2tleSAwIAogICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICA6cmVza2V5b3AgMCAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgOnJlc3NvcnRncm91cHJlZiAwIAogICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICA6cmVzanVuayBmYWxzZSAKICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAg +ICAgICAgICAgICAgICAgICAgICAgIDpleHByIAogICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICB7IFZBUiAKICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgOnZhcm5vIDIgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +IDp2YXJhdHRubyA1IAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6 +dmFydHlwZSAyNiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZh +cnR5cG1vZCAtMSAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2 +YXJsZXZlbHN1cCAwIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6 +dmFybm9vbGQgMiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZh +cm9hdHRubyA1CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAg +ICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAg +ICAgICApCiAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAg +ICAgICAgICAgICAgOnFwcXVhbCA8PiAKICAgICAgICAgICAgICAgICAgICAg +ICAgOmxlZnR0cmVlIDw+IAogICAgICAgICAgICAgICAgICAgICAgICA6cmln +aHR0cmVlIDw+IAogICAgICAgICAgICAgICAgICAgICAgICA6ZXh0cHJtICgp +CiAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAg +ICAgICAgOmxvY3BybSAoKQogICAgICAgICAgICAgICAgICAgICAgICAgCiAg +ICAgICAgICAgICAgICAgICAgICAgIDppbml0cGxhbiA8PiAKICAgICAgICAg +ICAgICAgICAgICAgICAgOm5wcm0gMCAgCiAgICAgICAgICAgICAgICAgICAg +ICAgIDpzY2FucmVsaWQgMiAKICAgICAgICAgICAgICAgICAgICAgICAgfQog +ICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgIDpl +eHRwcm0gKCkKICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAg +ICAgICAgICA6bG9jcHJtICgpCiAgICAgICAgICAgICAgICAgICAgICAKICAg +ICAgICAgICAgICAgICAgICAgOmluaXRwbGFuIDw+IAogICAgICAgICAgICAg +ICAgICAgICA6bnBybSAwICAKICAgICAgICAgICAgICAgICAgICAgOmpvaW50 +eXBlIDEgCiAgICAgICAgICAgICAgICAgICAgIDpqb2lucXVhbCAoCiAgICAg +ICAgICAgICAgICAgICAgICAgIHsgRVhQUiAKICAgICAgICAgICAgICAgICAg +ICAgICAgOnR5cGVPaWQgMTYgIAogICAgICAgICAgICAgICAgICAgICAgICA6 +b3BUeXBlIG9wIAogICAgICAgICAgICAgICAgICAgICAgICA6b3BlciAKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgeyBPUEVSIAogICAgICAgICAgICAg +ICAgICAgICAgICAgICA6b3BubyA2MDcgCiAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDpvcGlkIDE4NCAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +Om9wcmVzdWx0dHlwZSAxNiAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +Om9wcmV0c2V0IGZhbHNlIAogICAgICAgICAgICAgICAgICAgICAgICAgICB9 +CiAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAg +ICAgICAgOmFyZ3MgKAogICAgICAgICAgICAgICAgICAgICAgICAgICB7IFZB +UiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcm5vIDY1MDAwIAog +ICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFyYXR0bm8gMSAKICAgICAg +ICAgICAgICAgICAgICAgICAgICAgOnZhcnR5cGUgMjYgCiAgICAgICAgICAg +ICAgICAgICAgICAgICAgIDp2YXJ0eXBtb2QgLTEgIAogICAgICAgICAgICAg +ICAgICAgICAgICAgICA6dmFybGV2ZWxzdXAgMCAKICAgICAgICAgICAgICAg +ICAgICAgICAgICAgOnZhcm5vb2xkIDIgCiAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDp2YXJvYXR0bm8gMgogICAgICAgICAgICAgICAgICAgICAgICAg +ICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAg +ICAgICAgICAgICAgeyBWQVIgCiAgICAgICAgICAgICAgICAgICAgICAgICAg +IDp2YXJubyA2NTAwMSAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZh +cmF0dG5vIDIgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJ0eXBl +IDI2IAogICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFydHlwbW9kIC0x +ICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcmxldmVsc3VwIDAg +CiAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJub29sZCAxIAogICAg +ICAgICAgICAgICAgICAgICAgICAgICA6dmFyb2F0dG5vIC0yCiAgICAgICAg +ICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAg +KQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAg +ICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgeyBFWFBSIAogICAgICAg +ICAgICAgICAgICAgICAgICA6dHlwZU9pZCAxNiAgCiAgICAgICAgICAgICAg +ICAgICAgICAgIDpvcFR5cGUgb3AgCiAgICAgICAgICAgICAgICAgICAgICAg +IDpvcGVyIAogICAgICAgICAgICAgICAgICAgICAgICAgICB7IE9QRVIgCiAg +ICAgICAgICAgICAgICAgICAgICAgICAgIDpvcG5vIDkyIAogICAgICAgICAg +ICAgICAgICAgICAgICAgICA6b3BpZCA2MSAKICAgICAgICAgICAgICAgICAg +ICAgICAgICAgOm9wcmVzdWx0dHlwZSAxNiAKICAgICAgICAgICAgICAgICAg +ICAgICAgICAgOm9wcmV0c2V0IGZhbHNlIAogICAgICAgICAgICAgICAgICAg +ICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAg +ICAgICAgICAgICAgICAgOmFyZ3MgKAogICAgICAgICAgICAgICAgICAgICAg +ICAgICB7IFZBUiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcm5v +IDY1MDAwIAogICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFyYXR0bm8g +MiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcnR5cGUgMTggCiAg +ICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJ0eXBtb2QgLTEgIAogICAg +ICAgICAgICAgICAgICAgICAgICAgICA6dmFybGV2ZWxzdXAgMCAKICAgICAg +ICAgICAgICAgICAgICAgICAgICAgOnZhcm5vb2xkIDIgCiAgICAgICAgICAg +ICAgICAgICAgICAgICAgIDp2YXJvYXR0bm8gNwogICAgICAgICAgICAgICAg +ICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAg +ICAgICAgICAgICAgICAgICAgICAgeyBDT05TVCAKICAgICAgICAgICAgICAg +ICAgICAgICAgICAgOmNvbnN0dHlwZSAxOCAKICAgICAgICAgICAgICAgICAg +ICAgICAgICAgOmNvbnN0bGVuIDEgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgIDpjb25zdGJ5dmFsIHRydWUgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgIDpjb25zdGlzbnVsbCBmYWxzZSAKICAgICAgICAgICAgICAgICAgICAg +ICAgICAgOmNvbnN0dmFsdWUgIDEgWyAwIDAgMCAxMDUgXSAKICAgICAgICAg +ICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAp +CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAg +ICAgKQogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAg +ICAKICAgICAgICAgICAgICAgICAgOnJpZ2h0dHJlZSAKICAgICAgICAgICAg +ICAgICAgICAgeyBIQVNIIAogICAgICAgICAgICAgICAgICAgICA6c3RhcnR1 +cF9jb3N0IDAuMDAgCiAgICAgICAgICAgICAgICAgICAgIDp0b3RhbF9jb3N0 +IDAuMDAgCiAgICAgICAgICAgICAgICAgICAgIDpyb3dzIDEgCiAgICAgICAg +ICAgICAgICAgICAgIDp3aWR0aCA1IAogICAgICAgICAgICAgICAgICAgICA6 +cXB0YXJnZXRsaXN0ICgKICAgICAgICAgICAgICAgICAgICAgICAgeyBUQVJH +RVRFTlRSWSAKICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2RvbSAKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgeyBSRVNET00gCiAgICAgICAgICAg +ICAgICAgICAgICAgICAgIDpyZXNubyAxIAogICAgICAgICAgICAgICAgICAg +ICAgICAgICA6cmVzdHlwZSAyNiAKICAgICAgICAgICAgICAgICAgICAgICAg +ICAgOnJlc3R5cG1vZCAtMSAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +OnJlc25hbWUgPD4gCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNr +ZXkgMCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2tleW9wIDAg +CiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNzb3J0Z3JvdXByZWYg +MCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc2p1bmsgZmFsc2Ug +CiAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAg +ICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICA6ZXhwciAKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgeyBWQVIgCiAgICAgICAgICAgICAg +ICAgICAgICAgICAgIDp2YXJubyA0IAogICAgICAgICAgICAgICAgICAgICAg +ICAgICA6dmFyYXR0bm8gLTIgCiAgICAgICAgICAgICAgICAgICAgICAgICAg +IDp2YXJ0eXBlIDI2IAogICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFy +dHlwbW9kIC0xICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgOnZhcmxl +dmVsc3VwIDAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJub29s +ZCA0IAogICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFyb2F0dG5vIC0y +CiAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAg +ICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAg +ICAgICAgICAgICAgIHsgVEFSR0VURU5UUlkgCiAgICAgICAgICAgICAgICAg +ICAgICAgIDpyZXNkb20gCiAgICAgICAgICAgICAgICAgICAgICAgICAgIHsg +UkVTRE9NIAogICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVzbm8gMiAK +ICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc3R5cGUgMTggCiAgICAg +ICAgICAgICAgICAgICAgICAgICAgIDpyZXN0eXBtb2QgLTEgCiAgICAgICAg +ICAgICAgICAgICAgICAgICAgIDpyZXNuYW1lIDw+IAogICAgICAgICAgICAg +ICAgICAgICAgICAgICA6cmVza2V5IDAgCiAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDpyZXNrZXlvcCAwIAogICAgICAgICAgICAgICAgICAgICAgICAg +ICA6cmVzc29ydGdyb3VwcmVmIDAgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgIDpyZXNqdW5rIGZhbHNlIAogICAgICAgICAgICAgICAgICAgICAgICAg +ICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAg +ICAgICAgICAgOmV4cHIgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIHsg +VkFSIAogICAgICAgICAgICAgICAgICAgICAgICAgICA6dmFybm8gNCAKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgOnZhcmF0dG5vIDMgCiAgICAgICAg +ICAgICAgICAgICAgICAgICAgIDp2YXJ0eXBlIDE4IAogICAgICAgICAgICAg +ICAgICAgICAgICAgICA6dmFydHlwbW9kIC0xICAKICAgICAgICAgICAgICAg +ICAgICAgICAgICAgOnZhcmxldmVsc3VwIDAgCiAgICAgICAgICAgICAgICAg +ICAgICAgICAgIDp2YXJub29sZCA0IAogICAgICAgICAgICAgICAgICAgICAg +ICAgICA6dmFyb2F0dG5vIDMKICAgICAgICAgICAgICAgICAgICAgICAgICAg +fQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAg +ICAgICkKICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAg +ICAgICA6cXBxdWFsIDw+IAogICAgICAgICAgICAgICAgICAgICA6bGVmdHRy +ZWUgCiAgICAgICAgICAgICAgICAgICAgICAgIHsgU0VRU0NBTiAKICAgICAg +ICAgICAgICAgICAgICAgICAgOnN0YXJ0dXBfY29zdCAwLjAwIAogICAgICAg +ICAgICAgICAgICAgICAgICA6dG90YWxfY29zdCAwLjAwIAogICAgICAgICAg +ICAgICAgICAgICAgICA6cm93cyAxIAogICAgICAgICAgICAgICAgICAgICAg +ICA6d2lkdGggNSAKICAgICAgICAgICAgICAgICAgICAgICAgOnFwdGFyZ2V0 +bGlzdCAoCiAgICAgICAgICAgICAgICAgICAgICAgICAgIHsgVEFSR0VURU5U +UlkgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpyZXNkb20gCiAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgIHsgUkVTRE9NIAogICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICA6cmVzbm8gMSAKICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgOnJlc3R5cGUgMjYgCiAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgIDpyZXN0eXBtb2QgLTEgCiAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgIDpyZXNuYW1lIDw+IAogICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICA6cmVza2V5IDAgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDpyZXNrZXlvcCAwIAogICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICA6cmVzc29ydGdyb3VwcmVmIDAgCiAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgIDpyZXNqdW5rIGZhbHNlIAogICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAg +ICAgICAgICAgICAgICAgICAgICAgICAgOmV4cHIgCiAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgIHsgVkFSIAogICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICA6dmFybm8gNCAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgOnZhcmF0dG5vIC0yIAogICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICA6dmFydHlwZSAyNiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +OnZhcnR5cG1vZCAtMSAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +IDp2YXJsZXZlbHN1cCAwIAogICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICA6dmFybm9vbGQgNCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +OnZhcm9hdHRubyAtMgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9 +CiAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAg +ICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICB7IFRBUkdF +VEVOVFJZIAogICAgICAgICAgICAgICAgICAgICAgICAgICA6cmVzZG9tIAog +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7IFJFU0RPTSAKICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgOnJlc25vIDIgCiAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgIDpyZXN0eXBlIDE4IAogICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICA6cmVzdHlwbW9kIC0xIAogICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICA6cmVzbmFtZSA8PiAKICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgOnJlc2tleSAwIAogICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICA6cmVza2V5b3AgMCAKICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgOnJlc3NvcnRncm91cHJlZiAwIAogICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICA6cmVzanVuayBmYWxzZSAKICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAg +CiAgICAgICAgICAgICAgICAgICAgICAgICAgIDpleHByIAogICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICB7IFZBUiAKICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgOnZhcm5vIDQgCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgIDp2YXJhdHRubyAzIAogICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICA6dmFydHlwZSAxOCAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgOnZhcnR5cG1vZCAtMSAgCiAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgIDp2YXJsZXZlbHN1cCAwIAogICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICA6dmFybm9vbGQgNCAKICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgOnZhcm9hdHRubyAzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +IH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAg +ICAgICAgICAgICApCiAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAg +ICAgICAgICAgICAgICAgICAgOnFwcXVhbCA8PiAKICAgICAgICAgICAgICAg +ICAgICAgICAgOmxlZnR0cmVlIDw+IAogICAgICAgICAgICAgICAgICAgICAg +ICA6cmlnaHR0cmVlIDw+IAogICAgICAgICAgICAgICAgICAgICAgICA6ZXh0 +cHJtICgpCiAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAg +ICAgICAgICAgICAgOmxvY3BybSAoKQogICAgICAgICAgICAgICAgICAgICAg +ICAgCiAgICAgICAgICAgICAgICAgICAgICAgIDppbml0cGxhbiA8PiAKICAg +ICAgICAgICAgICAgICAgICAgICAgOm5wcm0gMCAgCiAgICAgICAgICAgICAg +ICAgICAgICAgIDpzY2FucmVsaWQgNCAKICAgICAgICAgICAgICAgICAgICAg +ICAgfQogICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAg +ICAgIDpyaWdodHRyZWUgPD4gCiAgICAgICAgICAgICAgICAgICAgIDpleHRw +cm0gKCkKICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAg +ICAgICA6bG9jcHJtICgpCiAgICAgICAgICAgICAgICAgICAgICAKICAgICAg +ICAgICAgICAgICAgICAgOmluaXRwbGFuIDw+IAogICAgICAgICAgICAgICAg +ICAgICA6bnBybSAwICAKICAgICAgICAgICAgICAgICAgICAgOmhhc2hrZXkg +CiAgICAgICAgICAgICAgICAgICAgICAgIHsgVkFSIAogICAgICAgICAgICAg +ICAgICAgICAgICA6dmFybm8gNjUwMDAgCiAgICAgICAgICAgICAgICAgICAg +ICAgIDp2YXJhdHRubyAxIAogICAgICAgICAgICAgICAgICAgICAgICA6dmFy +dHlwZSAyNiAKICAgICAgICAgICAgICAgICAgICAgICAgOnZhcnR5cG1vZCAt +MSAgCiAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJsZXZlbHN1cCAwIAog +ICAgICAgICAgICAgICAgICAgICAgICA6dmFybm9vbGQgNCAKICAgICAgICAg +ICAgICAgICAgICAgICAgOnZhcm9hdHRubyAtMgogICAgICAgICAgICAgICAg +ICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAg +ICAgICAgIAogICAgICAgICAgICAgICAgICA6ZXh0cHJtICgpCiAgICAgICAg +ICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgOmxvY3BybSAoKQogICAg +ICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgIDppbml0cGxhbiA8 +PiAKICAgICAgICAgICAgICAgICAgOm5wcm0gMCAgCiAgICAgICAgICAgICAg +ICAgIDpqb2ludHlwZSAxIAogICAgICAgICAgICAgICAgICA6am9pbnF1YWwg +KAogICAgICAgICAgICAgICAgICAgICB7IEVYUFIgCiAgICAgICAgICAgICAg +ICAgICAgIDp0eXBlT2lkIDE2ICAKICAgICAgICAgICAgICAgICAgICAgOm9w +VHlwZSBvcCAKICAgICAgICAgICAgICAgICAgICAgOm9wZXIgCiAgICAgICAg +ICAgICAgICAgICAgICAgIHsgT1BFUiAKICAgICAgICAgICAgICAgICAgICAg +ICAgOm9wbm8gOTIgCiAgICAgICAgICAgICAgICAgICAgICAgIDpvcGlkIDYx +IAogICAgICAgICAgICAgICAgICAgICAgICA6b3ByZXN1bHR0eXBlIDE2IAog +ICAgICAgICAgICAgICAgICAgICAgICA6b3ByZXRzZXQgZmFsc2UgCiAgICAg +ICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgIAog +ICAgICAgICAgICAgICAgICAgICA6YXJncyAoCiAgICAgICAgICAgICAgICAg +ICAgICAgIHsgVkFSIAogICAgICAgICAgICAgICAgICAgICAgICA6dmFybm8g +NjUwMDAgCiAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJhdHRubyAyIAog +ICAgICAgICAgICAgICAgICAgICAgICA6dmFydHlwZSAxOCAKICAgICAgICAg +ICAgICAgICAgICAgICAgOnZhcnR5cG1vZCAtMSAgCiAgICAgICAgICAgICAg +ICAgICAgICAgIDp2YXJsZXZlbHN1cCAwIAogICAgICAgICAgICAgICAgICAg +ICAgICA6dmFybm9vbGQgNCAKICAgICAgICAgICAgICAgICAgICAgICAgOnZh +cm9hdHRubyAzCiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAg +ICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICB7IENPTlNU +IAogICAgICAgICAgICAgICAgICAgICAgICA6Y29uc3R0eXBlIDE4IAogICAg +ICAgICAgICAgICAgICAgICAgICA6Y29uc3RsZW4gMSAKICAgICAgICAgICAg +ICAgICAgICAgICAgOmNvbnN0Ynl2YWwgdHJ1ZSAKICAgICAgICAgICAgICAg +ICAgICAgICAgOmNvbnN0aXNudWxsIGZhbHNlIAogICAgICAgICAgICAgICAg +ICAgICAgICA6Y29uc3R2YWx1ZSAgMSBbIDAgMCAwIDEwMiBdIAogICAgICAg +ICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICkKICAg +ICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICApCiAgICAg +ICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgOmhhc2hjbGF1c2Vz +ICgKICAgICAgICAgICAgICAgICAgICAgeyBFWFBSIAogICAgICAgICAgICAg +ICAgICAgICA6dHlwZU9pZCAxNiAgCiAgICAgICAgICAgICAgICAgICAgIDpv +cFR5cGUgb3AgCiAgICAgICAgICAgICAgICAgICAgIDpvcGVyIAogICAgICAg +ICAgICAgICAgICAgICAgICB7IE9QRVIgCiAgICAgICAgICAgICAgICAgICAg +ICAgIDpvcG5vIDYwNyAKICAgICAgICAgICAgICAgICAgICAgICAgOm9waWQg +MTg0IAogICAgICAgICAgICAgICAgICAgICAgICA6b3ByZXN1bHR0eXBlIDE2 +IAogICAgICAgICAgICAgICAgICAgICAgICA6b3ByZXRzZXQgZmFsc2UgCiAg +ICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAg +IAogICAgICAgICAgICAgICAgICAgICA6YXJncyAoCiAgICAgICAgICAgICAg +ICAgICAgICAgIHsgVkFSIAogICAgICAgICAgICAgICAgICAgICAgICA6dmFy +bm8gNjUwMDEgCiAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJhdHRubyA1 +IAogICAgICAgICAgICAgICAgICAgICAgICA6dmFydHlwZSAyNiAKICAgICAg +ICAgICAgICAgICAgICAgICAgOnZhcnR5cG1vZCAtMSAgCiAgICAgICAgICAg +ICAgICAgICAgICAgIDp2YXJsZXZlbHN1cCAwIAogICAgICAgICAgICAgICAg +ICAgICAgICA6dmFybm9vbGQgMiAKICAgICAgICAgICAgICAgICAgICAgICAg +OnZhcm9hdHRubyA1CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAg +ICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICB7IFZB +UiAKICAgICAgICAgICAgICAgICAgICAgICAgOnZhcm5vIDY1MDAwIAogICAg +ICAgICAgICAgICAgICAgICAgICA6dmFyYXR0bm8gMSAKICAgICAgICAgICAg +ICAgICAgICAgICAgOnZhcnR5cGUgMjYgCiAgICAgICAgICAgICAgICAgICAg +ICAgIDp2YXJ0eXBtb2QgLTEgIAogICAgICAgICAgICAgICAgICAgICAgICA6 +dmFybGV2ZWxzdXAgMCAKICAgICAgICAgICAgICAgICAgICAgICAgOnZhcm5v +b2xkIDQgCiAgICAgICAgICAgICAgICAgICAgICAgIDp2YXJvYXR0bm8gLTIK +ICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAg +ICApCiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAg +KQogICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgIDpoYXNo +am9pbm9wIDAgCiAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAg +IAogICAgICAgICAgICAgICA6cmlnaHR0cmVlIDw+IAogICAgICAgICAgICAg +ICA6ZXh0cHJtICgpCiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAg +OmxvY3BybSAoKQogICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgIDpp +bml0cGxhbiA8PiAKICAgICAgICAgICAgICAgOm5wcm0gMCAgCiAgICAgICAg +ICAgICAgIDprZXljb3VudCAxIAogICAgICAgICAgICAgICB9CiAgICAgICAg +ICAgICAKICAgICAgICAgICAgOnJpZ2h0dHJlZSA8PiAKICAgICAgICAgICAg +OmV4dHBybSAoKQogICAgICAgICAgICAgCiAgICAgICAgICAgIDpsb2Nwcm0g +KCkKICAgICAgICAgICAgIAogICAgICAgICAgICA6aW5pdHBsYW4gPD4gCiAg +ICAgICAgICAgIDpucHJtIDAgIAogICAgICAgICAgICA6bnVtQ29scyAxIAog +ICAgICAgICAgICA6dHVwbGVQZXJHcm91cCB0cnVlIAogICAgICAgICAgICB9 +CiAgICAgICAgICAKICAgICAgICAgOnJpZ2h0dHJlZSA8PiAKICAgICAgICAg +OmV4dHBybSAoKQogICAgICAgICAgCiAgICAgICAgIDpsb2Nwcm0gKCkKICAg +ICAgICAgIAogICAgICAgICA6aW5pdHBsYW4gPD4gCiAgICAgICAgIDpucHJt +IDAgCiAgICAgICAgIH0KICAgICAgfQogICAgCiAgIDpyaWdodHRyZWUgPD4g +CiAgIDpleHRwcm0gKCkKICAgIAogICA6bG9jcHJtICgpCiAgICAKICAgOmlu +aXRwbGFuIDw+IAogICA6bnBybSAwIAogICB9CgpBZ2dyZWdhdGUgIChjb3N0 +PTE4My4zNi4uMTgzLjM2IHJvd3M9MSB3aWR0aD0yMikgKGFjdHVhbCB0aW1l +PTQzNTg5LjczLi40MzU4OS43MyByb3dzPTEgbG9vcHM9MSkKICAtPiAgU3Vi +cXVlcnkgU2NhbiBmb28gIChjb3N0PTE4My4zNC4uMTgzLjM2IHJvd3M9MSB3 +aWR0aD0yMikgKGFjdHVhbCB0aW1lPTQzNTg5LjcxLi40MzU4OS43MSByb3dz +PTAgbG9vcHM9MSkKICAgICAgICAtPiAgQWdncmVnYXRlICAoY29zdD0xODMu +MzQuLjE4My4zNiByb3dzPTEgd2lkdGg9MjIpIChhY3R1YWwgdGltZT00MzU4 +OS43MC4uNDM1ODkuNzAgcm93cz0wIGxvb3BzPTEpCiAgICAgICAgICAgICAg +RmlsdGVyOiAoY291bnQoMSkgPSAzKQogICAgICAgICAgICAgIC0+ICBHcm91 +cCAgKGNvc3Q9MTgzLjM0Li4xODMuMzUgcm93cz0yIHdpZHRoPTIyKSAoYWN0 +dWFsIHRpbWU9NDM1ODkuMzIuLjQzNTg5LjUzIHJvd3M9MTUgbG9vcHM9MSkK +ICAgICAgICAgICAgICAgICAgICAtPiAgU29ydCAgKGNvc3Q9MTgzLjM0Li4x +ODMuMzUgcm93cz0yIHdpZHRoPTIyKSAoYWN0dWFsIHRpbWU9NDM1ODkuMzEu +LjQzNTg5LjMyIHJvd3M9MTUgbG9vcHM9MSkKICAgICAgICAgICAgICAgICAg +ICAgICAgICBTb3J0IEtleTogdHIudGdhcmdzCiAgICAgICAgICAgICAgICAg +ICAgICAgICAgLT4gIEhhc2ggSm9pbiAgKGNvc3Q9MC4wMC4uMTgzLjMzIHJv +d3M9MiB3aWR0aD0yMikgKGFjdHVhbCB0aW1lPTE0My41My4uNDM1ODguMjIg +cm93cz0xNSBsb29wcz0xKQogICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgIEhhc2ggQ29uZDogKCJvdXRlciIucmVmb2JqaWQgPSAiaW5uZXIiLm9p +ZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBKb2luIEZpbHRl +cjogKCJpbm5lciIuY29udHlwZSA9ICdmJzo6ImNoYXIiKQogICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgIEZpbHRlcjogKCJpbm5lciIub2lkIElT +IE5VTEwpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIE5l +c3RlZCBMb29wICAoY29zdD0wLjAwLi4xODMuMzIgcm93cz0yIHdpZHRoPTE3 +KSAoYWN0dWFsIHRpbWU9MTM4LjE3Li40MzU3My4yNCByb3dzPTMyMSBsb29w +cz0xKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEpv +aW4gRmlsdGVyOiAoKCJpbm5lciIub2JqaWQgPSAib3V0ZXIiLm9pZCkgQU5E +ICgiaW5uZXIiLmRlcHR5cGUgPSAnaSc6OiJjaGFyIikpCiAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIHBn +X3RyaWdnZXIgdHIgIChjb3N0PTAuMDAuLjEuMDIgcm93cz0yIHdpZHRoPTgp +IChhY3R1YWwgdGltZT0wLjExLi4xMC4yMSByb3dzPTMyMSBsb29wcz0xKQog +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEg +U2NhbiBvbiBwZ19kZXBlbmQgZGVwICAoY29zdD0wLjAwLi40OS4wNiByb3dz +PTI4MDYgd2lkdGg9OSkgKGFjdHVhbCB0aW1lPTAuMDMuLjg3Ljc4IHJvd3M9 +NDU3MCBsb29wcz0zMjEpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgLT4gIEhhc2ggIChjb3N0PTAuMDAuLjAuMDAgcm93cz0xIHdpZHRoPTUp +IChhY3R1YWwgdGltZT00Ljg5Li40Ljg5IHJvd3M9MCBsb29wcz0xKQogICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2Nh +biBvbiBwZ19jb25zdHJhaW50IGNvICAoY29zdD0wLjAwLi4wLjAwIHJvd3M9 +MSB3aWR0aD01KSAoYWN0dWFsIHRpbWU9MC4xMy4uMy40MSByb3dzPTE4MyBs +b29wcz0xKQpUb3RhbCBydW50aW1lOiA0MzU5My42MiBtc2VjCg== + +--=====================_15580593==_-- + + +From pgsql-performance-owner@postgresql.org Tue Jan 6 17:30:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 34D36D1B4AC + for ; + Tue, 6 Jan 2004 21:30:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81950-05 + for ; + Tue, 6 Jan 2004 17:29:34 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id CB2EBD1C9CE + for ; + Tue, 6 Jan 2004 17:25:07 -0400 (AST) +Received: from [63.195.55.98] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4212837; Tue, 06 Jan 2004 13:26:08 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Michael Shapiro , + pgsql-performance@postgresql.org +Subject: Re: PgAdmin startup query VERY slow +Date: Tue, 6 Jan 2004 13:01:43 -0800 +User-Agent: KMail/1.4.3 +References: <5.2.0.9.2.20040106144745.00bcfe30@pop.ncsa.uiuc.edu> +In-Reply-To: <5.2.0.9.2.20040106144745.00bcfe30@pop.ncsa.uiuc.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200401061301.43954.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/73 +X-Sequence-Number: 5248 + +Michael, + +> With a particular database, PgAdmin3 takes a very long time to connect to= + a=20 +> database. this is not a general problem with PgAdmin, but only with one= +=20 +> database out of many. Other databases do not have the problem. And only= +=20 +> with one particular server. The exact same database on a different server= +=20 +> does not have the problem. + +Have you run VACUUM ANALYZE *as the superuser* on the faulty server recentl= +y?=20=20 +>From the look of the explain, PG is grossly underestimating the number of= +=20 +items in the pg_trigger and pg_depend tables, and thus choosing an=20 +inappropriate nested loop execution. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Jan 6 17:42:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 55CAED1B433 + for ; + Tue, 6 Jan 2004 21:42:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82664-08 + for ; + Tue, 6 Jan 2004 17:41:25 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id D80BBD1B4D4 + for ; + Tue, 6 Jan 2004 17:40:54 -0400 (AST) +Received: from [63.195.55.98] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4212926; Tue, 06 Jan 2004 13:41:55 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Michael Shapiro , + pgsql-performance@postgresql.org +Subject: Re: PgAdmin startup query VERY slow +Date: Tue, 6 Jan 2004 13:17:30 -0800 +User-Agent: KMail/1.4.3 +References: <5.2.0.9.2.20040106144745.00bcfe30@pop.ncsa.uiuc.edu> + <5.2.0.9.2.20040106152859.02a17ea8@pop.ncsa.uiuc.edu> +In-Reply-To: <5.2.0.9.2.20040106152859.02a17ea8@pop.ncsa.uiuc.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200401061317.30877.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/75 +X-Sequence-Number: 5250 + +Mark, + +> That seemed to fix it. What does VACUUM ANALYZE do that VACUUM FULL does= +=20 +> not? What causes a database to need vacuuming? + +See the Online Docs: +http://www.postgresql.org/docs/current/static/maintenance.html + +Incidentally, just ANALYZE would probably have fixed your problem. Please= + do=20 +suggest to the PGAdmin team that they add a FAQ item about this. + + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Jan 6 17:33:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B229D1B465 + for ; + Tue, 6 Jan 2004 21:33:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81670-08 + for ; + Tue, 6 Jan 2004 17:32:31 -0400 (AST) +Received: from mail.ncsa.uiuc.edu (mail.ncsa.uiuc.edu [141.142.2.28]) + by svr1.postgresql.org (Postfix) with ESMTP id 83C26D1C957 + for ; + Tue, 6 Jan 2004 17:31:28 -0400 (AST) +X-Envelope-From: mshapiro@ncsa.edu +X-Envelope-To: +Received: from kalika.ncsa.edu (kalika.ncsa.uiuc.edu [141.142.97.63]) + by mail.ncsa.uiuc.edu (8.11.6p2/8.11.6) with ESMTP id i06LVUC29113 + for ; Tue, 6 Jan 2004 15:31:30 -0600 +Message-Id: <5.2.0.9.2.20040106152859.02a17ea8@pop.ncsa.uiuc.edu> +X-Sender: mshapiro@pop.ncsa.uiuc.edu (Unverified) +X-Mailer: QUALCOMM Windows Eudora Version 5.2.0.9 +Date: Tue, 06 Jan 2004 15:31:29 -0600 +To: pgsql-performance@postgresql.org +From: Michael Shapiro +Subject: Re: PgAdmin startup query VERY slow +In-Reply-To: <200401061301.43954.josh@agliodbs.com> +References: <5.2.0.9.2.20040106144745.00bcfe30@pop.ncsa.uiuc.edu> + <5.2.0.9.2.20040106144745.00bcfe30@pop.ncsa.uiuc.edu> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/74 +X-Sequence-Number: 5249 + +That seemed to fix it. What does VACUUM ANALYZE do that VACUUM FULL does +not? What causes a database to need vacuuming? + + + +At 01:01 PM 1/6/2004 -0800, Josh Berkus wrote: +>Michael, +> +> > With a particular database, PgAdmin3 takes a very long time to connect +> to a +> > database. this is not a general problem with PgAdmin, but only with one +> > database out of many. Other databases do not have the problem. And only +> > with one particular server. The exact same database on a different server +> > does not have the problem. +> +>Have you run VACUUM ANALYZE *as the superuser* on the faulty server +>recently? +> >From the look of the explain, PG is grossly underestimating the number of +>items in the pg_trigger and pg_depend tables, and thus choosing an +>inappropriate nested loop execution. +> +>-- +>-Josh Berkus +> Aglio Database Solutions +> San Francisco + +--- +Michael + + +From pgsql-performance-owner@postgresql.org Tue Jan 6 18:57:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 88D22D1B46E + for ; + Tue, 6 Jan 2004 22:57:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 93225-06 + for ; + Tue, 6 Jan 2004 18:57:01 -0400 (AST) +Received: from druid.net (druid.net [216.126.72.98]) + by svr1.postgresql.org (Postfix) with ESMTP id 142B1D1B433 + for ; + Tue, 6 Jan 2004 18:56:59 -0400 (AST) +Received: by druid.net (Postfix, from userid 1000) + id 661BE1A92; Tue, 6 Jan 2004 17:57:07 -0500 (EST) +From: "D'Arcy J.M. Cain" +To: Shridhar Daithankar , + Postgresql Performance +Subject: Re: Select max(foo) and select count(*) optimization +Date: Tue, 6 Jan 2004 17:57:05 -0500 +User-Agent: KMail/1.5.4 +References: + <200401060718.08444.darcy@druid.net> + <200401061750.09530.shridhar_daithankar@persistent.co.in> +In-Reply-To: <200401061750.09530.shridhar_daithankar@persistent.co.in> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200401061757.05278.darcy@druid.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/76 +X-Sequence-Number: 5251 + +On January 6, 2004 07:20 am, Shridhar Daithankar wrote: +> On Tuesday 06 January 2004 17:48, D'Arcy J.M. Cain wrote: +> > On January 6, 2004 01:42 am, Shridhar Daithankar wrote: +> > cert=# select relpages,reltuples::bigint from pg_class where relname= +> > 'certificate'; +> > relpages | reltuples +> > ----------+----------- +> > 399070 | 24858736 +> > (1 row) +> > +> > But: +> > +> > cert=# select count(*) from certificate; +> > [*Crunch* *Crunch* *Crunch*] +> > count +> > ---------- +> > 19684668 +> > (1 row) +> > +> > Am I missing something? Max certificate_id is 20569544 btw. +> +> Do 'vacuum analyze certificate' and try..:-) + +Kind of invalidates the part about being accurate then, don't it? Besides, I +vacuum that table every day (*) and we have reorganized the schema so that we +never update it except in exceptional cases. I would be less surprised if +the result was less than the real count since we only insert into that table. + +In any case, if I have to vacuum a 20,000,000 row table to get an accurate +count then I may as well run count(*) on it. + +(*): Actually I only analyze but I understand that that should be sufficient. + +-- +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 Tue Jan 6 19:13:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5ED51D1B49B + for ; + Tue, 6 Jan 2004 23:13:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92307-10 + for ; + Tue, 6 Jan 2004 19:12:39 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A502DD1B47D + for ; + Tue, 6 Jan 2004 19:12:36 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i06NCZ19001688; + Tue, 6 Jan 2004 18:12:35 -0500 (EST) +To: josh@agliodbs.com +Cc: Michael Shapiro , + pgsql-performance@postgresql.org +Subject: Re: PgAdmin startup query VERY slow +In-reply-to: <200401061317.30877.josh@agliodbs.com> +References: <5.2.0.9.2.20040106144745.00bcfe30@pop.ncsa.uiuc.edu> + <5.2.0.9.2.20040106152859.02a17ea8@pop.ncsa.uiuc.edu> + <200401061317.30877.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Tue, 06 Jan 2004 13:17:30 -0800" +Date: Tue, 06 Jan 2004 18:12:35 -0500 +Message-ID: <1687.1073430755@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/77 +X-Sequence-Number: 5252 + +Josh Berkus writes: +> Incidentally, just ANALYZE would probably have fixed your problem. + +... or just VACUUM; that would have updated the row count which is all +that was really needed here. The main point is that you do have to do +that as superuser, since the same commands issued as a non-superuser +won't touch the system tables (or any table you do not own). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jan 6 19:20:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B8113D1B4C2 + for ; + Tue, 6 Jan 2004 23:20:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02715-03 + for ; + Tue, 6 Jan 2004 19:20:03 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 56807D1B438 + for ; + Tue, 6 Jan 2004 19:20:00 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i06NJt19002699; + Tue, 6 Jan 2004 18:19:56 -0500 (EST) +To: "D'Arcy J.M. Cain" +Cc: Shridhar Daithankar , + Postgresql Performance +Subject: Re: Select max(foo) and select count(*) optimization +In-reply-to: <200401061757.05278.darcy@druid.net> +References: + <200401060718.08444.darcy@druid.net> + <200401061750.09530.shridhar_daithankar@persistent.co.in> + <200401061757.05278.darcy@druid.net> +Comments: In-reply-to "D'Arcy J.M. Cain" + message dated "Tue, 06 Jan 2004 17:57:05 -0500" +Date: Tue, 06 Jan 2004 18:19:55 -0500 +Message-ID: <2698.1073431195@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/78 +X-Sequence-Number: 5253 + +"D'Arcy J.M. Cain" writes: +> In any case, if I have to vacuum a 20,000,000 row table to get an accurate +> count then I may as well run count(*) on it. +> (*): Actually I only analyze but I understand that that should be sufficient. + +ANALYZE without VACUUM will deliver a not-very-accurate estimate, since it +only looks at a sample of the table's pages and doesn't grovel through +every one. Any of the VACUUM variants, on the other hand, will set +pg_class.reltuples reasonably accurately (as the number of rows actually +seen and left undeleted by the VACUUM pass). + +There are pathological cases where ANALYZE's estimate of the overall row +count can be horribly bad --- mainly, when the early pages of the table +are empty or nearly so, but there are well-filled pages out near the +end. I have a TODO item to try to make ANALYZE less prone to getting +fooled that way... + + regards, tom lane + +From pgsql-general-owner@postgresql.org Wed Jan 7 13:18:26 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5EB3CD1E1C7; Wed, 7 Jan 2004 17:18:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45900-09; Wed, 7 Jan 2004 13:17:39 -0400 (AST) +Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) + by svr1.postgresql.org (Postfix) with ESMTP + id C5A3FD1E1FE; Wed, 7 Jan 2004 13:15:03 -0400 (AST) +Received: from lorenso.com (c-24-1-26-144.client.comcast.net[24.1.26.144]) + by comcast.net (rwcrmhc11) with ESMTP + id <2004010716573001300797rke>; Wed, 7 Jan 2004 16:57:30 +0000 +Message-ID: <3FFC3A82.4000401@lorenso.com> +Date: Wed, 07 Jan 2004 10:57:38 -0600 +From: "D. Dante Lorenso" +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-general@postgresql.org" , + pgsql-performance@postgresql.org +Subject: Find original number of rows before applied LIMIT/OFFSET? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/268 +X-Sequence-Number: 55296 + + +I need to know that original number of rows that WOULD have been returned +by a SELECT statement if the LIMIT / OFFSET where not present in the +statement. +Is there a way to get this data from PG ? + + SELECT + ... ; + + ----> returns 100,000 rows + +but, + + SELECT + ... + LIMIT x + OFFSET y; + + ----> returns at most x rows + +In order to build a list pager on a web site, I want to select 'pages' of a +result set at a time. However, I need to know the original select +result set +size because I still have to draw the 'page numbers' to display what +pages are +available. + +I've done this TWO ways in the past: + + 1) TWO queries. The first query will perform a SELECT COUNT(*) ...; and + the second query performs the actualy SELECT ... LIMIT x OFFSET y; + + 2) Using PHP row seek and only selecting the number of rows I need. + +Here is an example of method number 2 in PHP: + + //---------------------------------------------------------------------- + function query_assoc_paged ($sql, $limit=0, $offset=0) { + $this->num_rows = false; + + // open a result set for this query... + $result = $this->query($sql); + if (! $result) return (false); + + // save the number of rows we are working with + $this->num_rows = @pg_num_rows($result); + + // moves the internal row pointer of the result to point to our + // desired offset. The next call to pg_fetch_assoc() would return + // that row. + if (! empty($offset)) { + if (! @pg_result_seek($result, $offset)) { + return (array()); + }; + } + + // gather the results together in an array of arrays... + $data = array(); + while (($row = pg_fetch_assoc($result)) !== false) { + $data[] = $row; + + // After reading N rows from this result set, free our memory + // and return the rows we fetched... + if (! empty($limit) && count($data) >= $limit) { + pg_free_result($result); + return ($data); + } + } + + pg_free_result($result); + return($data); + } + + //---------------------------------------------------------------------- + +In this approach, I am 'emulating' the LIMIT / OFFSET features in PostgreSQL +by just seeking forward in the result set (offset) and only fetching the +number of rows that match my needs (LIMIT). + +QUESTION: Is this the best way to do this, or is there a more efficient way +to get at the data I want? Is there a variable set in PG that tells me the +original number of rows in the query? Something like: + + SELECT ORIG_RESULT_SIZE, ... + ... + LIMIT x + OFFSET y; + +Or can I run another select right afterwards...like: + + SELECT ... + ... + LIMIT x + OFFSET y; + + SELECT unfiltered_size_of_last_query(); + +Any thoughts? Sure, the PHP function I'm using above 'works', but is it +the most efficient? I hope I'm not actually pulling all 100,000 records +across the wire when I only intend to show 10 at a time. See what I'm +getting at? + +TIA, + +Dante + +--------- +D. Dante Lorenso +dante@lorenso.com + + +From pgsql-performance-owner@postgresql.org Wed Jan 7 13:15:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BAC8D1B491 + for ; + Wed, 7 Jan 2004 17:15:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45804-06 + for ; + Wed, 7 Jan 2004 13:14:51 -0400 (AST) +Received: from expasy-ng.isb-sib.ch (expasy-f.unige.ch [192.33.215.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 58975D1B4B3 + for ; + Wed, 7 Jan 2004 13:12:28 -0400 (AST) +Received: from caliente (router.isb-sib.ch [192.33.215.254]) + (authenticated bits=0) + by expasy-ng.isb-sib.ch (8.12.10/8.12.8) with ESMTP id i07H80is030931 + for ; Wed, 7 Jan 2004 18:08:04 +0100 +Message-ID: <001101c3d540$d3ea8090$c300000a@caliente> +From: "Eric Jain" +To: "pgsql-performance" +Subject: Index creation +Date: Wed, 7 Jan 2004 18:08:06 +0100 +Organization: Swiss Institute of Bioinformatics +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-sib-MailScanner-Information: Please contact the ISP for more information +X-sib-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200401/79 +X-Sequence-Number: 5254 + +Any tips for speeding up index creation? + +I need to bulk load a large table with 100M rows and several indexes, +some of which span two columns. + +By dropping all indexes prior to issuing the 'copy from' command, the +operation completes 10x as fast (1.5h vs 15h). + +Unfortunately, recreating a single index takes nearly as long as loading +all of the data into the table; this more or less eliminates the time +gained by dropping the index in the first place. + +Also, there doesn't seem to be a simple way to disable/recreate all +indexes for a specific table short of explicitely dropping and later +recreating each index? + +-- +Eric Jain + + +From pgsql-performance-owner@postgresql.org Wed Jan 7 13:27:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 24A76D1E20A + for ; + Wed, 7 Jan 2004 17:21:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48514-02 + for ; + Wed, 7 Jan 2004 13:20:38 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 51AFCD1E1EA + for ; + Wed, 7 Jan 2004 13:19:42 -0400 (AST) +Received: (qmail 42047 invoked from network); 7 Jan 2004 17:19:51 -0000 +Received: from localhost (HELO squeegit) (threshar@127.0.0.1) + by localhost with SMTP; 7 Jan 2004 17:19:51 -0000 +Date: Wed, 7 Jan 2004 12:20:15 -0500 +From: Jeff +To: "Eric Jain" +Cc: pgsql-performance@postgresql.org +Subject: Re: Index creation +Message-Id: <20040107122015.1466a8c4.threshar@torgo.978.org> +In-Reply-To: <001101c3d540$d3ea8090$c300000a@caliente> +References: <001101c3d540$d3ea8090$c300000a@caliente> +X-Mailer: Sylpheed version 0.9.7 (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 postgresql.org +X-Archive-Number: 200401/81 +X-Sequence-Number: 5256 + +On Wed, 7 Jan 2004 18:08:06 +0100 +"Eric Jain" wrote: + +> Any tips for speeding up index creation? +> +> I need to bulk load a large table with 100M rows and several indexes, +> some of which span two columns. +> +> By dropping all indexes prior to issuing the 'copy from' command, the +> operation completes 10x as fast (1.5h vs 15h). +> +> Unfortunately, recreating a single index takes nearly as long as +> loading all of the data into the table; this more or less eliminates +> the time gained by dropping the index in the first place. +> +> Also, there doesn't seem to be a simple way to disable/recreate all +> indexes for a specific table short of explicitely dropping and later +> recreating each index? + +Before creating your index bump up your sort_mem high. + +set sort_mem = 64000 +create index foo on baz(a, b); + +BIG increases. +[This also helps on FK creation] + + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + +From pgsql-general-owner@postgresql.org Wed Jan 7 15:42:23 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id C0E3DD1CA7D; Wed, 7 Jan 2004 19:42:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82634-08; Wed, 7 Jan 2004 15:41:36 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP + id 0A560D1B4AC; Wed, 7 Jan 2004 15:40:58 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 80E1E36C88; Wed, 7 Jan 2004 14:41:04 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1AeJY8-0005gj-00; Wed, 07 Jan 2004 14:41:04 -0500 +To: "D. Dante Lorenso" +Cc: "pgsql-general@postgresql.org" , + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Find original number of rows before applied + LIMIT/OFFSET? +References: <3FFC3A82.4000401@lorenso.com> +In-Reply-To: <3FFC3A82.4000401@lorenso.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 07 Jan 2004 14:41:04 -0500 +Message-ID: <873carwnqn.fsf@stark.dyndns.tv> +Lines: 22 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/280 +X-Sequence-Number: 55308 + + +"D. Dante Lorenso" writes: + +> Any thoughts? Sure, the PHP function I'm using above 'works', but is it +> the most efficient? I hope I'm not actually pulling all 100,000 records +> across the wire when I only intend to show 10 at a time. See what I'm +> getting at? + +I tend to do it using a separate select count(*). My thinking is that the +count(*) query can be simplified and exclude things like the ORDER BY clause +and any select list entries that require extra work. It can often even exclude +whole joins. + +By doing a separate query I can do that extra work only for the rows that i +actually need for display. Hopefully using an index to pull up those rows. And +do the count(*) in the most efficient way possible, probably a sequential scan +with no joins for foreign keys etc. + +But I suspect the two methods both work out to suck about equally. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Jan 7 15:47:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E897D1B481 + for ; + Wed, 7 Jan 2004 19:47:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85709-03 + for ; + Wed, 7 Jan 2004 15:46:36 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 81972D1B4D3 + for ; + Wed, 7 Jan 2004 15:46:27 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 18E2C36D05; Wed, 7 Jan 2004 14:45:25 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1AeJcK-0005i7-00; Wed, 07 Jan 2004 14:45:25 -0500 +To: pgsql-performance@postgresql.org +Subject: RAID array stripe sizes +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 07 Jan 2004 14:45:24 -0500 +Message-ID: <87wu83v8yz.fsf@stark.dyndns.tv> +Lines: 7 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/83 +X-Sequence-Number: 5258 + + +Does anyone have any data to support arguing for a particular stripe size in +RAID-0? Do large stripe sizes allow drives to stream data more efficiently or +defeat read-ahead? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Jan 7 16:10:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5779BD1B450 + for ; + Wed, 7 Jan 2004 20:10:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91809-01 + for ; + Wed, 7 Jan 2004 16:09:47 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FD6CD1C957 + for ; + Wed, 7 Jan 2004 16:09:35 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i07K8DCs007136; + Wed, 7 Jan 2004 13:08:14 -0700 (MST) +Date: Wed, 7 Jan 2004 12:51:30 -0700 (MST) +From: "scott.marlowe" +To: Eric Jain +Cc: pgsql-performance +Subject: Re: Index creation +In-Reply-To: <001101c3d540$d3ea8090$c300000a@caliente> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/84 +X-Sequence-Number: 5259 + +On Wed, 7 Jan 2004, Eric Jain wrote: + +> Any tips for speeding up index creation? +> +> I need to bulk load a large table with 100M rows and several indexes, +> some of which span two columns. +> +> By dropping all indexes prior to issuing the 'copy from' command, the +> operation completes 10x as fast (1.5h vs 15h). +> +> Unfortunately, recreating a single index takes nearly as long as loading +> all of the data into the table; this more or less eliminates the time +> gained by dropping the index in the first place. +> +> Also, there doesn't seem to be a simple way to disable/recreate all +> indexes for a specific table short of explicitely dropping and later +> recreating each index? + +Note that you can issue the following command to see all the index +definitions for a table: + +select * from pg_indexes where tablename='sometable'; + +And store those elsewhere to be reused when you need to recreate the +index. + + +From pgsql-performance-owner@postgresql.org Wed Jan 7 19:06:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C8C27D1B472 + for ; + Wed, 7 Jan 2004 23:06:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14758-10 + for ; + Wed, 7 Jan 2004 19:06:08 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 47896D1B4D3 + for ; + Wed, 7 Jan 2004 19:06:00 -0400 (AST) +Received: from [10.1.2.146] (helo=dba3.int.libertyrms.info) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AeI4K-0005vM-00 + for ; Wed, 07 Jan 2004 13:06:12 -0500 +Received: by dba3.int.libertyrms.info (Postfix, from userid 1019) + id 7596F1390B; Wed, 7 Jan 2004 18:06:08 -0500 (EST) +Date: Wed, 7 Jan 2004 18:06:08 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: failures on machines using jfs +Message-ID: <20040107230608.GN12531@libertyrms.info> +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.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/85 +X-Sequence-Number: 5260 + +Hi all, + +Chris Browne (one of my colleagues here) has posted some tests in the +past indicating that jfs may be the fastest filesystem for Postgres +use on Linux. + +We have lately had a couple of cases where machines either locked up, +slowed down to the point of complete unusability, or died completely +while using jfs. We are _not_ sure that jfs is in fact the culprit. +In one case, a kernel panic appeared to be referring to the jfs +kernel module, but I can't be sure as I lost the output immediately +thereafter. Yesterday, we had a problem of data corruption on a +failed jfs volume. + +None of this is to say that jfs is in fact to blame, nor even that, +if it is, it does not have something to do with the age of our +installations, &c. (these are all RH 8). In fact, I suspect hardware +in both cases. But I thought I'd mention it just in case other +people are seeing strange behaviour, on the principle of "better +safe than sorry." + +A +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Thu Jan 8 22:51:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BCE4D1B45D + for ; + Thu, 8 Jan 2004 05:53:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78638-04 + for ; + Thu, 8 Jan 2004 01:52:24 -0400 (AST) +Received: from mail01.objectmastery.net (mail01.objectmastery.net + [203.34.143.230]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D838D1B44C + for ; + Thu, 8 Jan 2004 01:52:22 -0400 (AST) +Received: from objectmastery.com (rev.objectmastery.net [203.34.143.18]) + by mail01.objectmastery.net (Postfix) with ESMTP id 0951F3FA5 + for ; + Thu, 8 Jan 2004 16:52:06 +1100 (EST) +Message-ID: <3FFCF005.70108@objectmastery.com> +Date: Thu, 08 Jan 2004 16:52:05 +1100 +From: Bradley Tate +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Slow query problem +X-Enigmail-Version: 0.76.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/89 +X-Sequence-Number: 5264 + +Hi, + +We've set up a little test box (1GHz Athlon, 40G IDE drive, 256M RAM, +Redhat 9) to do some basic comparisons between postgresql and firebird +1.0.3 and 1.5rc8. Mostly the results are comparable, with one +significant exception. + +QUERY +select invheadref, invprodref, sum(units) +from invtran +group by invheadref, invprodref + +RESULTS +pg 7.3.4 - 5.5 min +pg 7.4.0 - 10 min +fb 1.0.3 - 64 sec +fb 1.5 - 44 sec + +* The invtran table has about 2.5 million records, invheadref and +invprodref are both char(10) and indexed. +* shared_buffers = 12000 and sort_mem = 8192 are the only changes I've +made to postgresql.conf, with relevant changes to shmall and shmmax. + +This is an explain analyse plan from postgresql 7.4: + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------ + +GroupAggregate (cost=572484.23..601701.15 rows=1614140 width=39) +(actual time=500091.171..554203.189 rows=147621 loops=1) + -> Sort (cost=572484.23..578779.62 rows=2518157 width=39) (actual +time=500090.939..527500.940 rows=2521530 loops=1) + Sort Key: invheadref, invprodref + -> Seq Scan on invtran (cost=0.00..112014.57 rows=2518157 +width=39) (actual time=16.002..25516.917 rows=2521530 loops=1) + Total runtime: 554826.827 ms +(5 rows) + +Am I correct in interpreting that most time was spent doing the sorting? +Explain confuses the heck out of me and any help on how I could make +this run faster would be gratefully received. + +Cheers, + +Bradley. + + +From pgsql-performance-owner@postgresql.org Thu Jan 8 15:17:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 67404D1B439 + for ; + Thu, 8 Jan 2004 19:17:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38006-03 + for ; + Thu, 8 Jan 2004 15:16:15 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 22479D1B43D + for ; + Thu, 8 Jan 2004 15:16:14 -0400 (AST) +Received: from [63.195.55.98] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4222151; Thu, 08 Jan 2004 11:17:12 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Andrew Sullivan , pgsql-performance@postgresql.org +Subject: Re: failures on machines using jfs +Date: Thu, 8 Jan 2004 10:52:40 -0800 +User-Agent: KMail/1.4.3 +References: <20040107230608.GN12531@libertyrms.info> +In-Reply-To: <20040107230608.GN12531@libertyrms.info> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200401081052.40807.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/86 +X-Sequence-Number: 5261 + +Andrew, + +> None of this is to say that jfs is in fact to blame, nor even that, +> if it is, it does not have something to do with the age of our +> installations, &c. (these are all RH 8). In fact, I suspect hardware +> in both cases. But I thought I'd mention it just in case other +> people are seeing strange behaviour, on the principle of "better +> safe than sorry." + +Always useful. Actually, I just fielded on IRC a report of poor I/O=20 +utilization with XFS during checkpointing. Not sure if the problem is XF= +S=20 +or PostgreSQL, but the fact that XFS (alone among filesystems) does its own= +=20 +cache management instead of using the kernel cache makes me suspicious. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Sun Jan 11 15:16:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FE96D1B450 + for ; + Fri, 9 Jan 2004 03:23:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28314-06 + for ; + Thu, 8 Jan 2004 23:23:05 -0400 (AST) +Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) + by svr1.postgresql.org (Postfix) with SMTP id 082E7D1B482 + for ; + Thu, 8 Jan 2004 23:17:04 -0400 (AST) +Received: (qmail 16135 invoked from network); 9 Jan 2004 03:17:34 -0000 +Received: from unknown (HELO ?192.168.1.199?) (134.22.68.14) + by 205.178.180.9 with SMTP; 9 Jan 2004 03:17:34 -0000 +Subject: Re: optimizing Postgres queries +From: Rod Taylor +To: David Teran +Cc: Tom Lane , + Postgresql Performance +In-Reply-To: <6F2414E8-3FB9-11D8-A528-000A95A6F0DC@cluster9.com> +References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> + <200401051705.55120.shridhar_daithankar@myrealbox.com> + <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> + <200401051740.05006.shridhar_daithankar@myrealbox.com> + <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> + <9966.1073316152@sss.pgh.pa.us> + <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> + <16230.1073328760@sss.pgh.pa.us> + + <20540.1073329548@sss.pgh.pa.us> + <4530AF9E-3FB4-11D8-A528-000A95A6F0DC@cluster9.com> + <20759.1073330625@sss.pgh.pa.us> + <6F2414E8-3FB9-11D8-A528-000A95A6F0DC@cluster9.com> +Content-Type: text/plain +Message-Id: <1073618208.322.18.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 08 Jan 2004 22:16:49 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/109 +X-Sequence-Number: 5284 + +On Mon, 2004-01-05 at 14:57, David Teran wrote: +> ... wow: +> +> executing a batch file with about 4250 selects, including lots of joins +> other things PostgreSQL 7.4 is about 2 times faster than FrontBase +> 3.6.27. OK, we will start to make larger tests but this is quite +> interesting already: we did not optimize a lot, just invoked VACUUM +> ANALYZE and then the selects ;-) +> +> Thanks to all who answered to this thread. + +I presume that batch file was executed linearly -- no parallelism? +You're actually testing one of PostgreSQL's shortcomings. + +PostgreSQL (in my experience) does much better in such comparisons with +a parallel load -- multiple connections executing varied work (short +selects, complex selects, inserts, updates, deletes). + +Anyway, just a tip that you will want to test your actual load. If you +do batch work with a single thread, what you have is fine. But if you +have a website with tens or hundreds of simultaneous connections then +your non-parallel testing will not reflect that work load. + + +From pgsql-performance-owner@postgresql.org Thu Jan 8 23:29:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CB31CD1B44C + for ; + Fri, 9 Jan 2004 03:29:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27922-09 + for ; + Thu, 8 Jan 2004 23:28:59 -0400 (AST) +Received: from pomeray.duluoz.net (12-241-192-70.client.attbi.com + [12.241.192.70]) + by svr1.postgresql.org (Postfix) with ESMTP id 89B5FD1B4D4 + for ; + Thu, 8 Jan 2004 23:27:17 -0400 (AST) +Received: (qmail 6232 invoked by uid 1000); 9 Jan 2004 03:27:20 -0000 +Date: Thu, 8 Jan 2004 19:27:16 -0800 +From: Mike Glover +To: Bradley Tate +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow query problem +Message-Id: <20040108192716.26c4b369.mpg4@duluoz.net> +In-Reply-To: <3FFCF005.70108@objectmastery.com> +References: <3FFCF005.70108@objectmastery.com> +X-Mailer: Sylpheed version 0.9.0claws (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg="pgp-sha1"; boundary="=.U(0Zldy2q1+SH7" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/91 +X-Sequence-Number: 5266 + +--=.U(0Zldy2q1+SH7 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit + +On Thu, 08 Jan 2004 16:52:05 +1100 +Bradley Tate wrote: +> Am I correct in interpreting that most time was spent doing the +> sorting? + +looks so. your table is about 70MB total size, and its getting loaded +completely into memory (you have 12000 * 8k = 96M available). 26s to +load 70MB from disk seems reasonable. The rest of the time is used for +sorting. + +> Explain confuses the heck out of me and any help on how I could make +> this run faster would be gratefully received. +> + +You should bump sort_mem as high as you can stand. with only 8MB sort +memory available, you're swapping intermediate sort pages to disk -- +a lot. Try the query with sort_mem set to 75MB (to do the entire sort in +memory). + +-mike + +> Cheers, +> +> Bradley. +> +> +> ---------------------------(end of +> broadcast)--------------------------- TIP 8: explain analyze is your +> friend + + +-- +Mike Glover +Key ID BFD19F2C + +--=.U(0Zldy2q1+SH7 +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQE//h+YZrNpxr/RnywRAqFgAJ940IieUUxhaZesAzC4Rv933yVCDACdH3DU +4ylBJp0SmxnCdnuks1v54Jg= +=VDUZ +-----END PGP SIGNATURE----- + +--=.U(0Zldy2q1+SH7-- + +From pgsql-performance-owner@postgresql.org Fri Jan 9 00:19:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F0F43D1B443 + for ; + Fri, 9 Jan 2004 04:19:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31524-09 + for ; + Fri, 9 Jan 2004 00:18:44 -0400 (AST) +Received: from slgan.com (c-67-163-28-202.client.comcast.net [67.163.28.202]) + by svr1.postgresql.org (Postfix) with ESMTP id E85A6D1B468 + for ; + Fri, 9 Jan 2004 00:18:42 -0400 (AST) +Received: from [192.168.10.154] ([192.168.10.154]) + by slgan.com (8.10.2/8.10.2) with ESMTP id i095KCL04308 + for ; Thu, 8 Jan 2004 23:20:12 -0600 +Mime-Version: 1.0 +X-Sender: slgan@192.168.10.10 +Message-Id: +Date: Thu, 8 Jan 2004 22:19:53 -0600 +To: pgsql-performance@postgresql.org +From: Seum-Lim Gan +Subject: PostgreSQL vs. Oracle disk space usage +Content-Type: text/plain; charset="us-ascii" ; format="flowed" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/92 +X-Sequence-Number: 5267 + +Hi, + +I searched through the archive and could not find any conclusive +discussion of results on this. + +Has anyone compared the disk space usage between PostgreSQL +and Oracle ? + +I am interested in knowing for the same tuple (i.e same +dictionary), the disk usage between the two. + +Thanks. + +Gan +-- ++--------------------------------------------------------+ +| Seum-Lim GAN email : slgan@lucent.com | +| Lucent Technologies | +| 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | +| Naperville, IL 60566, USA. fax : (630)-713-7272 | +| web : http://inuweb.ih.lucent.com/~slgan | ++--------------------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Fri Jan 9 00:24:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A7815D1B49E + for ; + Fri, 9 Jan 2004 04:23:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38596-01 + for ; + Fri, 9 Jan 2004 00:23:09 -0400 (AST) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id EB9E6D1B44F + for ; + Fri, 9 Jan 2004 00:23:08 -0400 (AST) +Received: (qmail 7165 invoked by uid 500); 9 Jan 2004 04:23:38 -0000 +Date: Thu, 8 Jan 2004 22:23:38 -0600 +From: Bruno Wolff III +To: Mike Glover +Cc: Bradley Tate , + pgsql-performance@postgresql.org +Subject: Re: Slow query problem +Message-ID: <20040109042338.GD31586@wolff.to> +Mail-Followup-To: Mike Glover , + Bradley Tate , + pgsql-performance@postgresql.org +References: <3FFCF005.70108@objectmastery.com> + <20040108192716.26c4b369.mpg4@duluoz.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20040108192716.26c4b369.mpg4@duluoz.net> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/93 +X-Sequence-Number: 5268 + +On Thu, Jan 08, 2004 at 19:27:16 -0800, + Mike Glover wrote: +> +> You should bump sort_mem as high as you can stand. with only 8MB sort +> memory available, you're swapping intermediate sort pages to disk -- +> a lot. Try the query with sort_mem set to 75MB (to do the entire sort in +> memory). + +Postgres also might be able to switch to a hash aggregate instead of +using a sort if sortmem is made large enough to hold the results for +all of the (estimated) groups. + +From pgsql-performance-owner@postgresql.org Fri Jan 9 01:13:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E7CED1B551 + for ; + Fri, 9 Jan 2004 05:13:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45965-02 + for ; + Fri, 9 Jan 2004 01:12:30 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 171B1D1B4D4 + for ; + Fri, 9 Jan 2004 01:12:20 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i095C719020724; + Fri, 9 Jan 2004 00:12:08 -0500 (EST) +To: Mike Glover +Cc: Bradley Tate , + pgsql-performance@postgresql.org +Subject: Re: Slow query problem +In-reply-to: <20040108192716.26c4b369.mpg4@duluoz.net> +References: <3FFCF005.70108@objectmastery.com> + <20040108192716.26c4b369.mpg4@duluoz.net> +Comments: In-reply-to Mike Glover + message dated "Thu, 08 Jan 2004 19:27:16 -0800" +Date: Fri, 09 Jan 2004 00:12:07 -0500 +Message-ID: <20723.1073625127@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/94 +X-Sequence-Number: 5269 + +Mike Glover writes: +> You should bump sort_mem as high as you can stand. with only 8MB sort +> memory available, you're swapping intermediate sort pages to disk -- +> a lot. Try the query with sort_mem set to 75MB (to do the entire sort in +> memory). + +7.4 will probably flip over to a hash-based aggregation method, and not +sort at all, once you make sort_mem large enough that it thinks the hash +table will fit in sort_mem. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jan 9 03:30:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 88677D1B479 + for ; + Fri, 9 Jan 2004 07:30:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60758-02 + for ; + Fri, 9 Jan 2004 03:29:57 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 67161D1B457 + for ; + Fri, 9 Jan 2004 03:29:56 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 0F90E8E0D; Fri, 9 Jan 2004 08:29:57 +0100 (CET) +Date: Fri, 9 Jan 2004 08:29:57 +0100 (CET) +From: =?ISO-8859-1?Q?Dennis_Bj=F6rklund?= +To: Bradley Tate +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow query problem +In-Reply-To: <3FFCF005.70108@objectmastery.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/95 +X-Sequence-Number: 5270 + +On Thu, 8 Jan 2004, Bradley Tate wrote: + +> We've set up a little test box (1GHz Athlon, 40G IDE drive, 256M RAM, +> Redhat 9) to do some basic comparisons between postgresql and firebird +> 1.0.3 and 1.5rc8. Mostly the results are comparable, with one +> significant exception. +> +> QUERY +> select invheadref, invprodref, sum(units) +> from invtran +> group by invheadref, invprodref +> +> RESULTS +> pg 7.3.4 - 5.5 min +> pg 7.4.0 - 10 min +> fb 1.0.3 - 64 sec +> fb 1.5 - 44 sec +> +> * The invtran table has about 2.5 million records, invheadref and +> invprodref are both char(10) and indexed. + +For the above query, shouldn't you have one index for both columns +(invheadref, invprodref). Then it should not need to sort at all to do the +grouping and it should all be fast. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Fri Jan 9 04:55:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D3D01D1B473 + for ; + Fri, 9 Jan 2004 08:55:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72653-09 + for ; + Fri, 9 Jan 2004 04:54:50 -0400 (AST) +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 A1AEED1B477 + for ; + Fri, 9 Jan 2004 04:54:48 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AesPp-000MeW-0W; Fri, 09 Jan 2004 08:54:49 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id ADF3517942; Fri, 9 Jan 2004 08:54:48 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 12008178D5; Fri, 9 Jan 2004 08:54:47 +0000 (GMT) +From: Richard Huxton +To: Dennis =?iso-8859-1?q?Bj=F6rklund?= , + Bradley Tate +Subject: Re: Slow query problem +Date: Fri, 9 Jan 2004 08:54:46 +0000 +User-Agent: KMail/1.5 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200401090854.46480.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/96 +X-Sequence-Number: 5271 + +On Friday 09 January 2004 07:29, Dennis Bj=F6rklund wrote: +> On Thu, 8 Jan 2004, Bradley Tate wrote: +> > +> > select invheadref, invprodref, sum(units) +> > from invtran +> > group by invheadref, invprodref + +> For the above query, shouldn't you have one index for both columns +> (invheadref, invprodref). Then it should not need to sort at all to do the +> grouping and it should all be fast. + +Not sure if that would make a difference here, since the whole table is bei= +ng=20 +read.=20 + +--=20 + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Jan 9 04:57:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 417A6D1B450 + for ; + Fri, 9 Jan 2004 08:57:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75877-03 + for ; + Fri, 9 Jan 2004 04:57:10 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 12C94D1B457 + for ; + Fri, 9 Jan 2004 04:57:08 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 526FA8E0D; Fri, 9 Jan 2004 09:57:09 +0100 (CET) +Date: Fri, 9 Jan 2004 09:57:09 +0100 (CET) +From: =?ISO-8859-1?Q?Dennis_Bj=F6rklund?= +To: Richard Huxton +Cc: Bradley Tate , +Subject: Re: Slow query problem +In-Reply-To: <200401090854.46480.dev@archonet.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/97 +X-Sequence-Number: 5272 + +On Fri, 9 Jan 2004, Richard Huxton wrote: + +> > > select invheadref, invprodref, sum(units) +> > > from invtran +> > > group by invheadref, invprodref +> +> > For the above query, shouldn't you have one index for both columns +> > (invheadref, invprodref). Then it should not need to sort at all to do the +> > grouping and it should all be fast. +> +> Not sure if that would make a difference here, since the whole table is being +> read. + +The goal was to avoid the sorting which should not be needed with that +index (I hope). So I still think that it would help in this case. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Fri Jan 9 05:19:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A6A2FD1B454 + for ; + Fri, 9 Jan 2004 09:19:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76501-06 + for ; + Fri, 9 Jan 2004 05:19:09 -0400 (AST) +Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net + [194.217.242.92]) + by svr1.postgresql.org (Postfix) with ESMTP id 202EAD1B466 + for ; + Fri, 9 Jan 2004 05:19:07 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AesnM-0002bV-0Y; Fri, 09 Jan 2004 09:19:08 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 3579217972; Fri, 9 Jan 2004 09:19:07 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 4F6EA17969; Fri, 9 Jan 2004 09:19:05 +0000 (GMT) +From: Richard Huxton +To: Dennis =?iso-8859-1?q?Bj=F6rklund?= +Subject: Re: Slow query problem +Date: Fri, 9 Jan 2004 09:19:04 +0000 +User-Agent: KMail/1.5 +Cc: Bradley Tate , +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200401090919.04718.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/98 +X-Sequence-Number: 5273 + +On Friday 09 January 2004 08:57, Dennis Bj=F6rklund wrote: +> On Fri, 9 Jan 2004, Richard Huxton wrote: +> > > > select invheadref, invprodref, sum(units) +> > > > from invtran +> > > > group by invheadref, invprodref +> > > +> > > For the above query, shouldn't you have one index for both columns +> > > (invheadref, invprodref). Then it should not need to sort at all to do +> > > the grouping and it should all be fast. +> > +> > Not sure if that would make a difference here, since the whole table is +> > being read. +> +> The goal was to avoid the sorting which should not be needed with that +> index (I hope). So I still think that it would help in this case. + +Sorry - not being clear. I can see how it _might_ help, but will the planne= +r=20 +take into account the fact that even though: + index-cost > seqscan-cost +that + (index-cost + no-sorting) < (seqscan-cost + sort-cost) +assuming of course, that the costs turn out that way. + +--=20 + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Sun Jan 11 15:20:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A502D1B495 + for ; + Fri, 9 Jan 2004 14:13:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43217-01 + for ; + Fri, 9 Jan 2004 10:12:49 -0400 (AST) +Received: from localhost.net (cust.89.121.adsl.cistron.nl [195.64.89.121]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E599D1B537 + for ; + Fri, 9 Jan 2004 10:12:45 -0400 (AST) +Received: from trust-factory.com (localhost [127.0.0.1]) + by localhost.net (Postfix) with ESMTP id 9B70083C80 + for ; + Fri, 9 Jan 2004 15:12:43 +0100 (CET) +Message-ID: <3FFEB6DA.8000905@trust-factory.com> +Date: Fri, 09 Jan 2004 15:12:42 +0100 +From: Richard van den Berg +Organization: Trust Factory +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 +X-Accept-Language: en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Explain not accurate +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/110 +X-Sequence-Number: 5285 + +Hi there, + +I am quite new to postgresql, and love the explain feature. It enables +us to predict which SQL queries needs to be optimized before we see any +problems. However, I've run into an issue where explain tells us a the +costs of a quiry are tremendous (105849017586), but the query actually +runs quite fast. Even "explain analyze" shows these costs. + +This makes me wonder: can the estimates explain shows be dead wrong? + +I can explain in more detail (including the query and output of explain) +if needed. I'm using 7.4 on Solaris 8. + +Sincerely, + +-- +Richard van den Berg, CISSP + +Trust Factory B.V. | http://www.trust-factory.com/ +Bazarstraat 44a | Phone: +31 70 3620684 +NL-2518AK The Hague | Fax : +31 70 3603009 +The Netherlands | + +Visit us at Lotusphere 2004 http://www.trust-factory.com/lotusphere + + + +From pgsql-performance-owner@postgresql.org Fri Jan 9 12:26:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 08DB2D1B4BD + for ; + Fri, 9 Jan 2004 16:26:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04103-09 + for ; + Fri, 9 Jan 2004 12:25:33 -0400 (AST) +Received: from mail012.syd.optusnet.com.au (mail012.syd.optusnet.com.au + [211.29.132.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C3ECD1DB76 + for ; + Fri, 9 Jan 2004 10:53:50 -0400 (AST) +Received: from objectmastery.com (c211-28-197-254.eburwd1.vic.optusnet.com.au + [211.28.197.254]) + by mail012.syd.optusnet.com.au (8.11.6p2/8.11.6) with ESMTP id + i09Erfr07771; Sat, 10 Jan 2004 01:53:42 +1100 +Message-ID: <3FFEC075.2090001@objectmastery.com> +Date: Sat, 10 Jan 2004 01:53:41 +1100 +From: Bradley Tate +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-1?Q?Dennis_Bj=F6rklund?= +Cc: Richard Huxton , + pgsql-performance@postgresql.org +Subject: Re: Slow query problem +References: +In-Reply-To: +X-Enigmail-Version: 0.76.7.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/99 +X-Sequence-Number: 5274 + +Dennis Bj�rklund wrote: + +>On Fri, 9 Jan 2004, Richard Huxton wrote: +> +> +> +>>>>select invheadref, invprodref, sum(units) +>>>>from invtran +>>>>group by invheadref, invprodref +>>>> +>>>> +>>>For the above query, shouldn't you have one index for both columns +>>>(invheadref, invprodref). Then it should not need to sort at all to do the +>>>grouping and it should all be fast. +>>> +>>> +>>Not sure if that would make a difference here, since the whole table is being +>>read. +>> +>> +> +>The goal was to avoid the sorting which should not be needed with that +>index (I hope). So I still think that it would help in this case. +> +> +> +Thanks for the advice. I tried creating a compound index along with +clustering the invtran table on it, adding another 512MB RAM, increasing +shared_buffers to 60000 and increasing sort_mem to 100MB, playing with +effective cache size in postgresql.conf. This cut the execution time +down to 4 minutes, which was helpful but still way behind firebird. +There was still an awful lot of disk activity while it was happening +which seems to imply lots of sorting going on (?) + +Invtran is a big table but it is clustered and static i.e. no updates, +select statements only. + +Mostly my performance problems are with sorts - group by, order by. I +was hoping for better results than I've been getting so far. + +Thanks. + +p.s. +Can someone confirm whether this should work from pgadmin3? i.e. will +the size of the sort_mem be changed for the duration of the query or +session? + +set sort_mem to 100000; +select ....etc....; + + + + +From pgsql-performance-owner@postgresql.org Fri Jan 9 12:42:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 803BED1B478 + for ; + Fri, 9 Jan 2004 16:42:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 30156-10 + for ; + Fri, 9 Jan 2004 12:42:08 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 0625BD1DC76 + for ; + Fri, 9 Jan 2004 11:07:11 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i09F7919023793; + Fri, 9 Jan 2004 10:07:09 -0500 (EST) +To: Richard Huxton +Cc: Dennis =?iso-8859-1?q?Bj=F6rklund?= , + Bradley Tate , pgsql-performance@postgresql.org +Subject: Re: Slow query problem +In-reply-to: <200401090919.04718.dev@archonet.com> +References: + <200401090919.04718.dev@archonet.com> +Comments: In-reply-to Richard Huxton + message dated "Fri, 09 Jan 2004 09:19:04 +0000" +Date: Fri, 09 Jan 2004 10:07:09 -0500 +Message-ID: <23792.1073660829@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/100 +X-Sequence-Number: 5275 + +Richard Huxton writes: +>> The goal was to avoid the sorting which should not be needed with that +>> index (I hope). So I still think that it would help in this case. + +> Sorry - not being clear. I can see how it _might_ help, but will the planner +> take into account the fact that even though: +> index-cost > seqscan-cost +> that +> (index-cost + no-sorting) < (seqscan-cost + sort-cost) + +Yes, it would. + +> assuming of course, that the costs turn out that way. + +That I'm less sure about. A sort frequently looks cheaper than a full +indexscan, unless the table is pretty well clustered on that index, +or you knock random_page_cost way down. + +With no stats at all, CVS tip has these preferences: + +regression=# create table fooey (f1 int, f2 int, unique(f1,f2)); +NOTICE: CREATE TABLE / UNIQUE will create implicit index "fooey_f1_key" for table "fooey" +CREATE TABLE +regression=# explain select * from fooey group by f1,f2; + QUERY PLAN +--------------------------------------------------------------- + HashAggregate (cost=25.00..25.00 rows=1000 width=8) + -> Seq Scan on fooey (cost=0.00..20.00 rows=1000 width=8) +(2 rows) + +regression=# set enable_hashagg TO 0; +SET +regression=# explain select * from fooey group by f1,f2; + QUERY PLAN +------------------------------------------------------------------------------------ + Group (cost=0.00..57.00 rows=1000 width=8) + -> Index Scan using fooey_f1_key on fooey (cost=0.00..52.00 rows=1000 width=8) +(2 rows) + +regression=# set enable_indexscan TO 0; +SET +regression=# explain select * from fooey group by f1,f2; + QUERY PLAN +--------------------------------------------------------------------- + Group (cost=69.83..77.33 rows=1000 width=8) + -> Sort (cost=69.83..72.33 rows=1000 width=8) + Sort Key: f1, f2 + -> Seq Scan on fooey (cost=0.00..20.00 rows=1000 width=8) +(4 rows) + +but remember this is for a relatively small (estimated size of) table. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jan 9 13:16:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 16871D1BB71 + for ; + Fri, 9 Jan 2004 17:16:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38574-08 + for ; + Fri, 9 Jan 2004 13:15:34 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id AB644D1DDA8 + for ; + Fri, 9 Jan 2004 11:38:12 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id E36E335566; Fri, 9 Jan 2004 07:38:01 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id E1DB23539B; Fri, 9 Jan 2004 07:38:01 -0800 (PST) +Date: Fri, 9 Jan 2004 07:38:01 -0800 (PST) +From: Stephan Szabo +To: Richard Huxton +Cc: Dennis =?iso-8859-1?q?Bj=F6rklund?= , + Bradley Tate , pgsql-performance@postgresql.org +Subject: Re: Slow query problem +In-Reply-To: <200401090919.04718.dev@archonet.com> +Message-ID: <20040109073400.D69748@megazone.bigpanda.com> +References: + <200401090919.04718.dev@archonet.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=X-UNKNOWN +Content-Transfer-Encoding: QUOTED-PRINTABLE +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/101 +X-Sequence-Number: 5276 + +On Fri, 9 Jan 2004, Richard Huxton wrote: + +> On Friday 09 January 2004 08:57, Dennis Bj=F6rklund wrote: +> > On Fri, 9 Jan 2004, Richard Huxton wrote: +> > > > > select invheadref, invprodref, sum(units) +> > > > > from invtran +> > > > > group by invheadref, invprodref +> > > > +> > > > For the above query, shouldn't you have one index for both columns +> > > > (invheadref, invprodref). Then it should not need to sort at all to= + do +> > > > the grouping and it should all be fast. +> > > +> > > Not sure if that would make a difference here, since the whole table = +is +> > > being read. +> > +> > The goal was to avoid the sorting which should not be needed with that +> > index (I hope). So I still think that it would help in this case. +> +> Sorry - not being clear. I can see how it _might_ help, but will the plan= +ner +> take into account the fact that even though: +> index-cost > seqscan-cost +> that +> (index-cost + no-sorting) < (seqscan-cost + sort-cost) +> assuming of course, that the costs turn out that way. + +AFAICS, yes it does take that effect into account (as best +it can with the estimates). + + +From pgsql-performance-owner@postgresql.org Fri Jan 9 23:30:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CAD6D1B4D3 + for ; + Sat, 10 Jan 2004 03:29:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 30346-08 + for ; + Fri, 9 Jan 2004 23:29:18 -0400 (AST) +Received: from srvr3.iniquinet.com (srvr2.iniquinet.com [64.240.87.12]) + by svr1.postgresql.org (Postfix) with SMTP id AA72CD1B46B + for ; + Fri, 9 Jan 2004 23:29:13 -0400 (AST) +Received: (qmail 8682 invoked by uid 104); 10 Jan 2004 03:22:07 -0000 +Received: from Robert_Creager@LogicalChaos.org by srvr3.iniquinet.com by uid + 101 with qmail-scanner-1.15 + (clamscan: 0.54. spamassassin: 2.55. Clear:SA:0(-7.8/6.0):. + Processed in 34.927623 secs); 10 Jan 2004 03:22:07 -0000 +Received: from vsat-148-64-8-86.c119.t7.mrt.starband.net (HELO + chaos.mshome.net) (148.64.8.86) + by srvr3.iniquinet.com with SMTP; 10 Jan 2004 03:21:32 -0000 +Received: from localhost.localdomain (thunder.mshome.net [192.168.0.250]) + by chaos.mshome.net (Postfix) with ESMTP + id C701A172966; Fri, 9 Jan 2004 20:28:24 -0700 (MST) +Received: from logicalchaos.org (thunder.mshome.net [192.168.0.250]) + by chaos.mshome.net (Postfix) with SMTP + id A5C51172966; Fri, 9 Jan 2004 20:28:22 -0700 (MST) +Date: Fri, 9 Jan 2004 20:28:16 -0700 +From: Robert Creager +To: Andrew Sullivan +Cc: pgsql-performance@postgresql.org +Subject: Re: failures on machines using jfs +Message-Id: <20040109202816.38072cf8.Robert_Creager@LogicalChaos.org> +In-Reply-To: <20040107230608.GN12531@libertyrms.info> +References: <20040107230608.GN12531@libertyrms.info> +Organization: Starlight Vision, LLC. +X-Mailer: Sylpheed version 0.9.5claws (GTK+ 1.2.10; i586-mandrake-linux-gnu) +Mime-Version: 1.0 +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg="pgp-sha1"; + boundary="Multipart_Fri__9_Jan_2004_20_28_16_-0700_A.V)I+=.HNNonbC." +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/102 +X-Sequence-Number: 5277 + +--Multipart_Fri__9_Jan_2004_20_28_16_-0700_A.V)I+=.HNNonbC. +Content-Type: text/plain; charset=US-ASCII +Content-Disposition: inline +Content-Transfer-Encoding: 7bit + +When grilled further on (Wed, 7 Jan 2004 18:06:08 -0500), +Andrew Sullivan confessed: + +> +> We have lately had a couple of cases where machines either locked up, +> slowed down to the point of complete unusability, or died completely +> while using jfs. We are _not_ sure that jfs is in fact the culprit. +> In one case, a kernel panic appeared to be referring to the jfs +> kernel module, but I can't be sure as I lost the output immediately +> thereafter. Yesterday, we had a problem of data corruption on a +> failed jfs volume. +> +> None of this is to say that jfs is in fact to blame, nor even that, +> if it is, it does not have something to do with the age of our +> installations, &c. (these are all RH 8). In fact, I suspect hardware +> in both cases. But I thought I'd mention it just in case other +> people are seeing strange behaviour, on the principle of "better +> safe than sorry." +> + +Interestingly enough, I'm using JFS on a new scsi disk with Mandrake 9.1 and +was having similar problems. I was generating heavy disk usage through database +and astronomical data reductions. My machine (dual AMD) would suddenly hang. +No new jobs would run, just increase the load, until I reboot the machine. + +I solved my problems by creating a 128Mb ram disk (using EXT2) for the temp +data produced my reduction runs. + +I believe JFS was to blame, not hardware, but you never know... + +Cheers, +Rob + +-- + 20:22:27 up 12 days, 10:13, 4 users, load average: 2.00, 2.01, 2.03 + +--Multipart_Fri__9_Jan_2004_20_28_16_-0700_A.V)I+=.HNNonbC. +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.2 (GNU/Linux) + +iEYEARECAAYFAj//cVYACgkQLQ/DKuwDYzkAygCffjpZt3eIcb1eTlUCZU3rAbCF +XBAAnimY+oRBTwhe7aXkQWxTIC2W53bP +=EdCh +-----END PGP SIGNATURE----- + +--Multipart_Fri__9_Jan_2004_20_28_16_-0700_A.V)I+=.HNNonbC.-- + + +From pgsql-performance-owner@postgresql.org Sat Jan 10 22:36:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EB0F3D1D56A + for ; + Sun, 11 Jan 2004 02:36:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85381-03 + for ; + Sat, 10 Jan 2004 22:35:35 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DCC1D1D643 + for ; + Sat, 10 Jan 2004 22:35:32 -0400 (AST) +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 i0B2ZVU6099942 + for ; Sun, 11 Jan 2004 02:35:31 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i0B2A1gH065715 + for pgsql-performance@postgresql.org; Sun, 11 Jan 2004 02:10:01 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: failures on machines using jfs +Date: Sat, 10 Jan 2004 21:08:50 -0500 +Organization: Hub.Org Networking Services +Lines: 56 +Message-ID: <60k73zck3x.fsf@dev6.int.libertyrms.info> +References: <20040107230608.GN12531@libertyrms.info> + <20040109202816.38072cf8.Robert_Creager@LogicalChaos.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1004 (Gnus v5.10.4) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:WSkb524vYimex3rYkNGK2HYPAYI= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/103 +X-Sequence-Number: 5278 + +Robert_Creager@LogicalChaos.org (Robert Creager) writes: +> When grilled further on (Wed, 7 Jan 2004 18:06:08 -0500), +> Andrew Sullivan confessed: +> +>> We have lately had a couple of cases where machines either locked +>> up, slowed down to the point of complete unusability, or died +>> completely while using jfs. We are _not_ sure that jfs is in fact +>> the culprit. In one case, a kernel panic appeared to be referring +>> to the jfs kernel module, but I can't be sure as I lost the output +>> immediately thereafter. Yesterday, we had a problem of data +>> corruption on a failed jfs volume. +>> +>> None of this is to say that jfs is in fact to blame, nor even that, +>> if it is, it does not have something to do with the age of our +>> installations, &c. (these are all RH 8). In fact, I suspect +>> hardware in both cases. But I thought I'd mention it just in case +>> other people are seeing strange behaviour, on the principle of +>> "better safe than sorry." +> +> Interestingly enough, I'm using JFS on a new scsi disk with Mandrake +> 9.1 and was having similar problems. I was generating heavy disk +> usage through database and astronomical data reductions. My machine +> (dual AMD) would suddenly hang. No new jobs would run, just +> increase the load, until I reboot the machine. +> +> I solved my problems by creating a 128Mb ram disk (using EXT2) for +> the temp data produced my reduction runs. +> +> I believe JFS was to blame, not hardware, but you never know... + +Interesting. + +The set of concurrent factors that came together to appear when this +happened "consistently" were thus: + + 1. Heavy DB updates taking place on JFS filesystems; + + 2. SMP (we suspected Xeon hyperthreading as a possible factor, but + shut it off and still saw the same problem...) + + 3. The third factor that appeared a catalyst was copying, via scp, a + file > 2GB in size onto the system. + +The third piece was a particularly interesting aspect; the file would +get copied over successfully, and the scp process would hang (to the +point of "kill -9" being unable to touch it) immediately thereafter. + +At that point, processes on the system that were accessing files on +the hung-up filesystem were locked, also unkillable by "kill 9." +That's certainly consistent with JFS being at the root of the problem, +whether it was the cause or not... +-- +let name="cbbrowne" and tld="libertyrms.info" in String.concat "@" [name;tld];; + +Christopher Browne +(416) 646 3304 x124 (land) + +From pgsql-performance-owner@postgresql.org Sun Jan 11 11:54:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 565B6D1D56B + for ; + Sun, 11 Jan 2004 15:54:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62380-07 + for ; + Sun, 11 Jan 2004 11:53:48 -0400 (AST) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 66C05D1D561 + for ; + Sun, 11 Jan 2004 11:53:39 -0400 (AST) +Received: from lorenso.com (c-24-1-26-144.client.comcast.net[24.1.26.144]) + by comcast.net (sccrmhc13) with ESMTP + id <2004011115533801600nikgte>; Sun, 11 Jan 2004 15:53:38 +0000 +Message-ID: <40017182.1090801@lorenso.com> +Date: Sun, 11 Jan 2004 09:53:38 -0600 +From: "D. Dante Lorenso" +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Postgresql on Quad CPU machine +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/104 +X-Sequence-Number: 5279 + +I'm running PostgreSQL 7.4 on a quad Xeon attached to a +beefy disk array. However, I am begining to wonder if this is +a waste of CPU power. + +I think I read somewhere that PostgreSQL is NOT multi-threaded. +But, will it be able to take advantage of multiple CPUs? Will +I have to run separate postmaster instances to get the advantage? + +I'm not running a high load on that machine yet, So I can't tell +if the load is being balanced across the CPUs. I expect that as +some of the newly launched sites grow it will require more resources +but maybe some of you could share your results of this type of +deployment setup. + +Dante + + +From pgsql-performance-owner@postgresql.org Sun Jan 11 12:08:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F1DACD1B519 + for ; + Sun, 11 Jan 2004 16:08:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64273-07 + for ; + Sun, 11 Jan 2004 12:07:36 -0400 (AST) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 98E20D1D552 + for ; + Sun, 11 Jan 2004 12:07:35 -0400 (AST) +Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1Afi7b-0000XA-00 + for ; Sun, 11 Jan 2004 17:07:27 +0100 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +Received: from sea.gmane.org ([80.91.224.252]) + by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) + id 1Afi7a-0000X2-00 + for ; + Sun, 11 Jan 2004 17:07:26 +0100 +Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1Afi7a-0005cd-00 + for ; + Sun, 11 Jan 2004 17:07:26 +0100 +From: Doug McNaught +Subject: Re: Postgresql on Quad CPU machine +Date: Sun, 11 Jan 2004 11:07:25 -0500 +Lines: 15 +Message-ID: <87wu7y5v0i.fsf@asmodeus.mcnaught.org> +References: <40017182.1090801@lorenso.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@sea.gmane.org +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +Cancel-Lock: sha1:9ZwWNdwZdg0oHwf0jkdAnM3l0gY= +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/105 +X-Sequence-Number: 5280 + +"D. Dante Lorenso" writes: + +> I'm running PostgreSQL 7.4 on a quad Xeon attached to a +> beefy disk array. However, I am begining to wonder if this is +> a waste of CPU power. +> +> I think I read somewhere that PostgreSQL is NOT multi-threaded. +> But, will it be able to take advantage of multiple CPUs? Will +> I have to run separate postmaster instances to get the advantage? + +PG uses a separate backend process for each connection, so if you have +multiple simultaneous connections they will use different CPUs. +Single queries will not be split across CPUs. + +-Doug + + +From pgsql-performance-owner@postgresql.org Sun Jan 11 12:18:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1178ED1B498 + for ; + Sun, 11 Jan 2004 16:18:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65207-08 + for ; + Sun, 11 Jan 2004 12:17:39 -0400 (AST) +Received: from COLSWEEPER.cranel.com (newmail.cranel.com [12.32.71.147]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F683D1B436 + for ; + Sun, 11 Jan 2004 12:17:38 -0400 (AST) +Received: from colmail01.cranel.com (colmail01.cranel.com) by + COLSWEEPER.cranel.com (Content Technologies SMTPRS 4.3.12) with ESMTP + id ; + Sun, 11 Jan 2004 11:16:28 -0500 +Received: by colmail01.cranel.com with Internet Mail Service (5.5.2657.72) id + ; Sun, 11 Jan 2004 11:21:15 -0500 +Message-ID: <387C22290D3FD71195D300508BF7DB5238AE92@colmail01.cranel.com> +From: "Spiegelberg, Greg" +To: 'Christopher Browne ' , + "'pgsql-performance@postgresql.org '" +Subject: Re: failures on machines using jfs +Date: Sun, 11 Jan 2004 11:21:14 -0500 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain; charset="iso-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/106 +X-Sequence-Number: 5281 + +It would seem we're experiencing somthing similiar with our scratch +volume (JFS mounted with noatime). It is still much faster than our +experiments with ext2, ext3, and reiserfs but occasionally during +large loads it will hiccup for a couple seconds but no crashes yet. + +I'm reluctant to switch back to any other file system because the +data import took a little over 1.5 hours but now takes just under +20 minutes and we haven't crashed yet. + +For future reference: + + RedHat 7.3 w/2.4.18-18.7smp + PostgreSQL 7.3.3 from source + jfsutils 1.0.17-1 + Dual PIII Intel 1.4GHz & 2GB ECC + Internal disk: 2xU160 SCSI, mirrored, location of our JFS file system + External disk Qlogic 2310 attached to FC-SW @2Gbps with ext3 on those LUNs + +Greg + + +-----Original Message----- +From: Christopher Browne +To: pgsql-performance@postgresql.org +Sent: 1/10/04 9:08 PM +Subject: Re: [PERFORM] failures on machines using jfs + +Robert_Creager@LogicalChaos.org (Robert Creager) writes: +> When grilled further on (Wed, 7 Jan 2004 18:06:08 -0500), +> Andrew Sullivan confessed: +> +>> We have lately had a couple of cases where machines either locked +>> up, slowed down to the point of complete unusability, or died +>> completely while using jfs. We are _not_ sure that jfs is in fact +>> the culprit. In one case, a kernel panic appeared to be referring +>> to the jfs kernel module, but I can't be sure as I lost the output +>> immediately thereafter. Yesterday, we had a problem of data +>> corruption on a failed jfs volume. +>> +>> None of this is to say that jfs is in fact to blame, nor even that, +>> if it is, it does not have something to do with the age of our +>> installations, &c. (these are all RH 8). In fact, I suspect +>> hardware in both cases. But I thought I'd mention it just in case +>> other people are seeing strange behaviour, on the principle of +>> "better safe than sorry." +> +> Interestingly enough, I'm using JFS on a new scsi disk with Mandrake +> 9.1 and was having similar problems. I was generating heavy disk +> usage through database and astronomical data reductions. My machine +> (dual AMD) would suddenly hang. No new jobs would run, just +> increase the load, until I reboot the machine. +> +> I solved my problems by creating a 128Mb ram disk (using EXT2) for +> the temp data produced my reduction runs. +> +> I believe JFS was to blame, not hardware, but you never know... + +Interesting. + +The set of concurrent factors that came together to appear when this +happened "consistently" were thus: + + 1. Heavy DB updates taking place on JFS filesystems; + + 2. SMP (we suspected Xeon hyperthreading as a possible factor, but + shut it off and still saw the same problem...) + + 3. The third factor that appeared a catalyst was copying, via scp, a + file > 2GB in size onto the system. + +The third piece was a particularly interesting aspect; the file would +get copied over successfully, and the scp process would hang (to the +point of "kill -9" being unable to touch it) immediately thereafter. + +At that point, processes on the system that were accessing files on +the hung-up filesystem were locked, also unkillable by "kill 9." +That's certainly consistent with JFS being at the root of the problem, +whether it was the cause or not... +-- +let name="cbbrowne" and tld="libertyrms.info" in String.concat "@" +[name;tld];; + +Christopher Browne +(416) 646 3304 x124 (land) + +---------------------------(end of broadcast)--------------------------- +TIP 8: explain analyze is your friend + + +********************************************************************** +This email and any files transmitted with it are confidential and +intended solely for the use of the individual or entity to whom they +are addressed. If you have received this email in error please notify +the system manager. + +This footnote also confirms that this email message has been swept by +MIMEsweeper for the presence of computer viruses. + +www.mimesweeper.com +********************************************************************** + + +From pgsql-performance-owner@postgresql.org Sun Jan 11 13:05:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AE45ED1D236 + for ; + Sun, 11 Jan 2004 17:05:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73790-07 + for ; + Sun, 11 Jan 2004 13:04:54 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B27CAD1B85F + for ; + Sun, 11 Jan 2004 13:04:53 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i0BH4l19016863; + Sun, 11 Jan 2004 12:04:47 -0500 (EST) +To: "Spiegelberg, Greg" +Cc: "'Christopher Browne '" , + "'pgsql-performance@postgresql.org '" +Subject: Re: failures on machines using jfs +In-reply-to: <387C22290D3FD71195D300508BF7DB5238AE92@colmail01.cranel.com> +References: <387C22290D3FD71195D300508BF7DB5238AE92@colmail01.cranel.com> +Comments: In-reply-to "Spiegelberg, Greg" + message dated "Sun, 11 Jan 2004 11:21:14 -0500" +Date: Sun, 11 Jan 2004 12:04:47 -0500 +Message-ID: <16862.1073840687@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/107 +X-Sequence-Number: 5282 + +"Spiegelberg, Greg" writes: +> PostgreSQL 7.3.3 from source + +*Please* update to 7.3.4 or 7.3.5 before you get bitten by the +WAL-page-boundary bug ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Jan 11 14:11:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BBD0D1D27E + for ; + Sun, 11 Jan 2004 18:11:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83282-04 + for ; + Sun, 11 Jan 2004 14:11:07 -0400 (AST) +Received: from swan.mail.pas.earthlink.net (swan.mail.pas.earthlink.net + [207.217.120.123]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F5EFD1B495 + for ; + Sun, 11 Jan 2004 14:11:06 -0400 (AST) +Received: from user-11204mn.dsl.mindspring.com ([66.32.18.215] + helo=shadovitzcmptr) + by swan.mail.pas.earthlink.net with smtp (Exim 3.33 #1) + id 1Afk3F-0000U2-00 + for pgsql-performance@postgresql.org; Sun, 11 Jan 2004 10:11:05 -0800 +Received: by localhost with Microsoft MAPI; Sun, 11 Jan 2004 10:11:04 -0800 +Message-ID: <01C3D82B.388A7FE0.david@shadovitz.com> +From: David Shadovitz +Reply-To: "david@shadovitz.com" +To: "pgsql-performance@postgresql.org" +Subject: COUNT & Pagination +Date: Sun, 11 Jan 2004 10:10:52 -0800 +X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/108 +X-Sequence-Number: 5283 + +I understand that COUNT queries are expensive. So I'm looking for advice on +displaying paginated query results. + +I display my query results like this: + + Displaying 1 to 50 of 2905. + 1-50 | 51-100 | 101-150 | etc. + +I do this by executing two queries. One is of the form: + + SELECT FROM WHERE LIMIT m OFFSET n +> +> The other is identical except that I replace the select list with COUNT(*). +yes, you need 2 query. Or select it from one: +select *, (select count(*) from table) as count from table... + +pg will optimize this query, and do the count only once + +> +> And an unrelated question: +> I'm running PG 7.2.2 and want to upgrade to 7.4.1. I've never upgraded PG +> before and I'm nervous. Can I simply run pg_dumpall, install 7.4.1, and then +> feed the dump into psql? I'm planning to use pg_dumpall rather than pg_dump +> because I want to preserve the users I've defined. My database is the only one +> on the system. + +yes. But check tha faq and the manual for a better explain. + +C. + +From pgsql-performance-owner@postgresql.org Sun Jan 11 17:00:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D569DD1DA85 + for ; + Sun, 11 Jan 2004 21:00:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23446-04 + for ; + Sun, 11 Jan 2004 17:00:03 -0400 (AST) +Received: from avocet.mail.pas.earthlink.net (avocet.mail.pas.earthlink.net + [207.217.120.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 5BE94D1D9EE + for ; + Sun, 11 Jan 2004 17:00:01 -0400 (AST) +Received: from user-v8ldv2j.dsl.mindspring.com ([209.86.252.83]) + by avocet.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) + id 1Afmgc-0006pt-00; Sun, 11 Jan 2004 12:59:54 -0800 +In-Reply-To: <01C3D82B.388A7FE0.david@shadovitz.com> +References: <01C3D82B.388A7FE0.david@shadovitz.com> +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <107436B6-4479-11D8-BE00-000A959C6000@cloverpub.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Jeff Fitzmyers +Subject: Re: COUNT & Pagination +Date: Sun, 11 Jan 2004 12:59:36 -0800 +To: "david@shadovitz.com" +X-Mailer: Apple Mail (2.609) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/112 +X-Sequence-Number: 5287 + +> So I'm looking for advice on displaying paginated query results. +> Displaying 1 to 50 of 2905. +> 1-50 | 51-100 | 101-150 | etc. +> +> I do this by executing two queries. One is of the form: +> SELECT FROM WHERE LIMIT m OFFSET n +> +> The other is identical except that I replace the select list with COUNT(*). +> +> I'm looking for suggestions to replace that COUNT query. I cannot use the +> method of storing the number of records in a separate table because my queries +> (a) involve joins, and (b) have a WHERE clause. + +Well, on all my sites, I do what you do and just live with it :P You +can investigate using cursors however (DECLARE, MOVE & FETCH) + +> And an unrelated question: +> I'm running PG 7.2.2 and want to upgrade to 7.4.1. I've never upgraded PG +> before and I'm nervous. Can I simply run pg_dumpall, install 7.4.1, and then +> feed the dump into psql? I'm planning to use pg_dumpall rather than pg_dump +> because I want to preserve the users I've defined. My database is the only one +> on the system. + +I recommend something like this: + +-- disable access to your database to make sure you have a complete dump + +-- run dump as database owner account +su pgsql (or whatever your postgres user is) + +-- do compressed dump +pg_dumpall > backup.sql + +-- backup old data dir +mv /usr/local/pgsql/data /usr/local/pgsql/data.7.2 + +-- remove old postgres, install new +-- run NEW initdb. replace latin1 with your encoding +-- -W specifies a superuser password +initdb -D /usr/local/pgsql/data -E LATIN1 -W + +-- restore dump, watching output VERY CAREFULLY: +-- (run as pgsql user again) +psql template1 < backup.sql > log.txt +-- Watch stderr very carefully to check any errors that might occur. + +-- If restore fails, re-initdb and re-restore + +Chris + + +From pgsql-performance-owner@postgresql.org Sun Jan 11 22:56:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 589F6D1B46A + for ; + Mon, 12 Jan 2004 02:56:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 63726-04 + for ; + Sun, 11 Jan 2004 22:55:32 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 6610FD1D576 + for ; + Sun, 11 Jan 2004 22:55:28 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id EC9B436AA6; Sun, 11 Jan 2004 21:55:26 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com ident=foobar) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1AfsEg-0006J8-00; Sun, 11 Jan 2004 21:55:26 -0500 +To: Richard van den Berg +Cc: pgsql-performance@postgresql.org +Subject: Re: Explain not accurate +References: <3FFEB6DA.8000905@trust-factory.com> +In-Reply-To: <3FFEB6DA.8000905@trust-factory.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 11 Jan 2004 21:55:26 -0500 +Message-ID: <87smil3mg1.fsf@stark.xeocode.com> +Lines: 27 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/115 +X-Sequence-Number: 5290 + + +Richard van den Berg writes: + +> Hi there, +> +> I am quite new to postgresql, and love the explain feature. It enables us to +> predict which SQL queries needs to be optimized before we see any problems. +> However, I've run into an issue where explain tells us a the costs of a quiry +> are tremendous (105849017586), but the query actually runs quite fast. Even +> "explain analyze" shows these costs. + +Do you have any of the optimization parameters off, enable_seqscan perhaps? + +enable_seqscan works by penalizing plans that use sequential plans, but there +are still lots of queries that cannot be done any other way. I'm not sure +whether the same holds for all the other parameters. + +If your tables are all going to grow drastically then this may still indicate +a problem, probably a missing index. But if one of them is a reference table +that will never grow then perhaps the index will never be necessary. + + +Or perhaps you just need to run analyze. Send the "EXPLAIN ANALYZE" output for +the query for starters. You might also send the output of "SHOW ALL". + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun Jan 11 23:04:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 512AAD1B46A + for ; + Mon, 12 Jan 2004 03:04:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65384-02 + for ; + Sun, 11 Jan 2004 23:04:16 -0400 (AST) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F879D1B55D + for ; + Sun, 11 Jan 2004 23:04:11 -0400 (AST) +Received: from [10.4.3.100] (unknown [10.4.3.100]) + by steelhead.ravensfield.com (Postfix) with ESMTP id 8E5C866148 + for ; + Sun, 11 Jan 2004 22:04:15 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v609) +Content-Transfer-Encoding: 7bit +Message-Id: <22837C75-44AC-11D8-8262-000393A47FCC@ravensfield.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Andrew Rawnsley +Subject: annoying query/planner choice +Date: Sun, 11 Jan 2004 22:05:11 -0500 +X-Mailer: Apple Mail (2.609) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/116 +X-Sequence-Number: 5291 + + +I have a situation that is giving me small fits, and would like to see +if anyone can shed any light on it. + +I have a modest table (@1.4 million rows, and growing), that has a +variety of queries run against it. One is +a very straightforward one - pull a set of distinct rows out based on +two columns, with a simple where clause +based on one of the indexed columns. For illustration here, I've +removed the distinct and order-by clauses, as +they are not the culprits. + +Before I go on - v7.4.1, currently on a test box, dual P3, 1G ram, 10K +scsi, Slackware 9 or so. The table has been +vacuumed and analyzed. Even offered pizza and beer. Production box will +be a dual Xeon with 2G ram and RAID 5. + +When the query is run with a where clause that returns small number of +rows, the query uses the index and is quite speedy: + +rav=# explain analyze select casno, parameter from hai.results where +site_id = 9982; + QUERY PLAN +------------------------------------------------------------------------ +-------------------------------------------------------------- + Index Scan using hai_res_siteid_ndx on results (cost=0.00..7720.87 +rows=2394 width=30) (actual time=12.118..12.933 rows=50 loops=1) + Index Cond: (site_id = 9982) + Total runtime: 13.145 ms + +When a query is run that returns a much larger set, the index is not +used, I assume because the planner thinks that a sequential scan +would work just as well with a large result set: + +rav=# explain analyze select casno, parameter from hai.results where +site_id = 18; + QUERY PLAN +------------------------------------------------------------------------ +---------------------------------------------- + Seq Scan on results (cost=0.00..73396.39 rows=211205 width=30) +(actual time=619.020..15012.807 rows=186564 loops=1) + Filter: (site_id = 18) + Total runtime: 15279.789 ms +(3 rows) + + +Unfortunately, its way off: + +rav=# set enable_seqscan=off; +SET +rav=# explain analyze select casno, parameter from hai.results where +site_id = 18; + QUERY +PLAN +------------------------------------------------------------------------ +----------------------------------------------------------------------- + Index Scan using hai_res_siteid_ndx on results (cost=0.00..678587.01 +rows=211205 width=30) (actual time=9.575..3569.387 rows=186564 loops=1) + Index Cond: (site_id = 18) + Total runtime: 3872.292 ms +(3 rows) + + +I would like, of course, for it to use the index, given that it takes +20-25% of the time. Fiddling with CPU_TUPLE_COST doesn't do anything +until I exceed +0.5, which strikes me as a bit high (though please correct me if I am +assuming too much...). RANDOM_PAGE_COST seems to have no effect. I +suppose I could +cluster it, but it is constantly being added to, and would have to be +re-done on a daily basis (if not more). + +Any suggestions? + + + + +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Sun Jan 11 23:50:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9216FD1DA1E + for ; + Mon, 12 Jan 2004 03:50:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72705-07 + for ; + Sun, 11 Jan 2004 23:50:26 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 610ADD1D56B + for ; + Sun, 11 Jan 2004 23:50:21 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 6CE968E0D; Mon, 12 Jan 2004 04:50:25 +0100 (CET) +Date: Mon, 12 Jan 2004 04:50:25 +0100 (CET) +From: Dennis Bjorklund +To: Andrew Rawnsley +Cc: pgsql-performance@postgresql.org +Subject: Re: annoying query/planner choice +In-Reply-To: <22837C75-44AC-11D8-8262-000393A47FCC@ravensfield.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/117 +X-Sequence-Number: 5292 + +On Sun, 11 Jan 2004, Andrew Rawnsley wrote: + +> 20-25% of the time. Fiddling with CPU_TUPLE_COST doesn't do anything +> until I exceed 0.5, which strikes me as a bit high (though please +> correct me if I am assuming too much...). RANDOM_PAGE_COST seems to have +> no effect. + +What about the effective cache size, is that set properly? + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Mon Jan 12 00:06:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AC660D1B49F + for ; + Mon, 12 Jan 2004 04:06:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75261-02 + for ; + Mon, 12 Jan 2004 00:05:51 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A2BCD1B7ED + for ; + Mon, 12 Jan 2004 00:05:51 -0400 (AST) +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 i0C45nU8038339 + for ; Mon, 12 Jan 2004 04:05:50 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i0C44ref037187 + for pgsql-performance@postgresql.org; Mon, 12 Jan 2004 04:04:53 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: annoying query/planner choice +Date: Sun, 11 Jan 2004 22:56:59 -0500 +Organization: cbbrowne Computing Inc +Lines: 42 +Message-ID: +References: <22837C75-44AC-11D8-8262-000393A47FCC@ravensfield.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 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:kVlrcw0iF1ckQouIwioUuVc8GL0= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/119 +X-Sequence-Number: 5294 + +Centuries ago, Nostradamus foresaw when ronz@ravensfield.com (Andrew Rawnsley) would write: +> I would like, of course, for it to use the index, given that it +> takes 20-25% of the time. Fiddling with CPU_TUPLE_COST doesn't do +> anything until I exceed 0.5, which strikes me as a bit high (though +> please correct me if I am assuming too much...). RANDOM_PAGE_COST +> seems to have no effect. I suppose I could cluster it, but it is +> constantly being added to, and would have to be re-done on a daily +> basis (if not more). +> +> Any suggestions? + +The apparent problem is a bad query plan, and for clustering to "fix" +it seems a disturbing answer. + +A problem I saw last week with some query plans pointed to the issue +that the statistics were inadequate. + +We had some queries where indexing on "customer" is extremely +worthwhile in nearly all cases, but it often wasn't happening. The +problem was that the 10 "bins" in the default stats table would +collect up stats about a few _highly_ active customers, and pretty +much ignore the less active ones. Because the "bins" were highly +dominated by the few common values, stats for the others were missing +and pretty useless. + +I upped the size of the histogram from 10 to 100, and that allowed +stats to be kept for less active customers, GREATLY improving the +quality of the queries. + +The point that falls out is that if you have a column which has a +bunch of discrete values (rather more than 10) that aren't near-unique +(e.g. - on a table with a million transactions, you have a only few +hundred customers), that's a good candidate for upping column stats. + +Thus, you might try: + ALTER TABLE MY_TABLE ALTER COLUMN SOME_COLUMN SET STATISTICS 50; + ANALYZE MY_TABLE; +-- +let name="cbbrowne" and tld="ntlug.org" in name ^ "@" ^ tld;; +http://www.ntlug.org/~cbbrowne/postgresql.html +"There's no longer a boycott of Apple. But MacOS is still a +proprietary OS." -- RMS - June 13, 1998 + +From pgsql-performance-owner@postgresql.org Mon Jan 12 00:04:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 739F6D1B7E7 + for ; + Mon, 12 Jan 2004 04:04:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73502-05 + for ; + Mon, 12 Jan 2004 00:04:15 -0400 (AST) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E6DAD1B7ED + for ; + Mon, 12 Jan 2004 00:04:15 -0400 (AST) +Received: from [10.4.3.100] (unknown [10.4.3.100]) + by steelhead.ravensfield.com (Postfix) with ESMTP + id AD8B766148; Sun, 11 Jan 2004 23:04:14 -0500 (EST) +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Message-Id: <83C6D7BA-44B4-11D8-8262-000393A47FCC@ravensfield.com> +Content-Transfer-Encoding: quoted-printable +Cc: pgsql-performance@postgresql.org +From: Andrew Rawnsley +Subject: Re: annoying query/planner choice +Date: Sun, 11 Jan 2004 23:05:10 -0500 +To: Dennis Bjorklund +X-Mailer: Apple Mail (2.609) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/118 +X-Sequence-Number: 5293 + + +Low (1000). I'll fiddle with that. I just noticed that the machine only=20 +has 512MB of ram in it, and not 1GB. I must +have raided it for some other machine... + +On Jan 11, 2004, at 10:50 PM, Dennis Bjorklund wrote: + +> On Sun, 11 Jan 2004, Andrew Rawnsley wrote: +> +>> 20-25% of the time. Fiddling with CPU_TUPLE_COST doesn't do anything +>> until I exceed 0.5, which strikes me as a bit high (though please +>> correct me if I am assuming too much...). RANDOM_PAGE_COST seems to=20 +>> have +>> no effect. +> +> What about the effective cache size, is that set properly? +> +> --=20 +> /Dennis Bj=F6rklund +> +> +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to=20 +> majordomo@postgresql.org +> +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Mon Jan 12 01:40:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B6CBD1B499 + for ; + Mon, 12 Jan 2004 05:40:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85187-06 + for ; + Mon, 12 Jan 2004 01:40:15 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 21E55D1B519 + for ; + Mon, 12 Jan 2004 01:40:14 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i0C5eD19021521; + Mon, 12 Jan 2004 00:40:13 -0500 (EST) +To: Andrew Rawnsley +Cc: pgsql-performance@postgresql.org +Subject: Re: annoying query/planner choice +In-reply-to: <22837C75-44AC-11D8-8262-000393A47FCC@ravensfield.com> +References: <22837C75-44AC-11D8-8262-000393A47FCC@ravensfield.com> +Comments: In-reply-to Andrew Rawnsley + message dated "Sun, 11 Jan 2004 22:05:11 -0500" +Date: Mon, 12 Jan 2004 00:40:13 -0500 +Message-ID: <21520.1073886013@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/120 +X-Sequence-Number: 5295 + +Andrew Rawnsley writes: +> I have a situation that is giving me small fits, and would like to see +> if anyone can shed any light on it. + +In general, pulling 10% of a table *should* be faster as a seqscan than +an indexscan, except under the most extreme assumptions about clustering +(is the table clustered on site_id, by any chance?). What I suspect is +that the table is a bit larger than your available RAM, so that a +seqscan ends up flushing all of the kernel's cache and forcing a lot of +I/O, whereas an indexscan avoids the cache flush by not touching (quite) +all of the table. The trouble with this is that the index only looks +that good under test conditions, ie, when you repeat it just after an +identical query that pulled all of the needed pages into RAM. Under +realistic load conditions where different site_ids are being hit, the +indexscan is not going to be as good as you think, because it will incur +substantial I/O. + +You should try setting up a realistic test load hitting different random +site_ids, and see whether it's really a win to force seqscan off for +this query or not. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jan 12 06:17:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 81DA5D1B432 + for ; + Mon, 12 Jan 2004 10:17:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28168-02 + for ; + Mon, 12 Jan 2004 06:16:44 -0400 (AST) +Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net + [194.217.242.89]) + by svr1.postgresql.org (Postfix) with ESMTP id B52ADD1DA6C + for ; + Mon, 12 Jan 2004 06:16:41 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) + id 1Afz7g-0002gY-0V; Mon, 12 Jan 2004 10:16:41 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id C08A016E2D; Mon, 12 Jan 2004 10:16:39 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 4A98816DC9; Mon, 12 Jan 2004 10:16:38 +0000 (GMT) +From: Richard Huxton +To: "david@shadovitz.com" , + "pgsql-performance@postgresql.org" +Subject: Re: COUNT & Pagination +Date: Mon, 12 Jan 2004 10:16:37 +0000 +User-Agent: KMail/1.5 +References: <01C3D82B.388A7FE0.david@shadovitz.com> +In-Reply-To: <01C3D82B.388A7FE0.david@shadovitz.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200401121016.37918.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/121 +X-Sequence-Number: 5296 + +On Sunday 11 January 2004 18:10, David Shadovitz wrote: +> I understand that COUNT queries are expensive. So I'm looking for advice +> on displaying paginated query results. +> +> I display my query results like this: +> +> Displaying 1 to 50 of 2905. +> 1-50 | 51-100 | 101-150 | etc. +> +> I do this by executing two queries. + +If you only need the count when you've got the results, most PG client +interfaces will tell you how many rows you've got. What language is your app +in? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Jan 12 11:01:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DF875D1D541 + for ; + Mon, 12 Jan 2004 15:01:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78667-05 + for ; + Mon, 12 Jan 2004 11:01:15 -0400 (AST) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 370E5D1DA1E + for ; + Mon, 12 Jan 2004 11:01:09 -0400 (AST) +Received: from [10.1.1.7] (smallmouth.oh.ia [10.1.1.7]) + by steelhead.ravensfield.com (Postfix) with ESMTP + id 4A9FC66148; Mon, 12 Jan 2004 10:01:12 -0500 (EST) +In-Reply-To: <21520.1073886013@sss.pgh.pa.us> +References: <22837C75-44AC-11D8-8262-000393A47FCC@ravensfield.com> + <21520.1073886013@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <4B2B3053-4510-11D8-BF17-000393A47FCC@ravensfield.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Andrew Rawnsley +Subject: Re: annoying query/planner choice +Date: Mon, 12 Jan 2004 10:02:09 -0500 +To: Tom Lane +X-Mailer: Apple Mail (2.609) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/122 +X-Sequence-Number: 5297 + + +Probably my best solution is to find a better way to produce the +information, or cache it on the +application side, as it doesn't actually change that much across client +sessions. + +Clustering it occurred to me - it would have to be done on a frequent +basis, as the contents +of the table change constantly. What I am getting out of it with this +operation doesn't change +much, so caching in a separate table, in the application layer, or both +would probably shortcut +the whole problem. + +Always amazing what occurs to you when you sleep on it...if only I +could take a good nap in the +middle of the afternoon I would have no problems at all. + + +On Jan 12, 2004, at 12:40 AM, Tom Lane wrote: + +> Andrew Rawnsley writes: +>> I have a situation that is giving me small fits, and would like to see +>> if anyone can shed any light on it. +> +> In general, pulling 10% of a table *should* be faster as a seqscan than +> an indexscan, except under the most extreme assumptions about +> clustering +> (is the table clustered on site_id, by any chance?). What I suspect is +> that the table is a bit larger than your available RAM, so that a +> seqscan ends up flushing all of the kernel's cache and forcing a lot of +> I/O, whereas an indexscan avoids the cache flush by not touching +> (quite) +> all of the table. The trouble with this is that the index only looks +> that good under test conditions, ie, when you repeat it just after an +> identical query that pulled all of the needed pages into RAM. Under +> realistic load conditions where different site_ids are being hit, the +> indexscan is not going to be as good as you think, because it will +> incur +> substantial I/O. +> +> You should try setting up a realistic test load hitting different +> random +> site_ids, and see whether it's really a win to force seqscan off for +> this query or not. +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Mon Jan 12 11:39:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 05C76D1D27C + for ; + Mon, 12 Jan 2004 15:39:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89483-01 + for ; + Mon, 12 Jan 2004 11:38:48 -0400 (AST) +Received: from pintail.mail.pas.earthlink.net (pintail.mail.pas.earthlink.net + [207.217.120.122]) + by svr1.postgresql.org (Postfix) with ESMTP id E9A0BD1B43F + for ; + Mon, 12 Jan 2004 11:38:43 -0400 (AST) +Received: from hsa201.pool031.at101.earthlink.net ([216.249.100.201] + helo=shadovitzcmptr) + by pintail.mail.pas.earthlink.net with smtp (Exim 3.33 #1) + id 1Ag49L-0003wd-00; Mon, 12 Jan 2004 07:38:43 -0800 +Received: by localhost with Microsoft MAPI; Mon, 12 Jan 2004 07:39:04 -0800 +Message-ID: <01C3D8DF.271378C0.david@shadovitz.com> +From: David Shadovitz +Reply-To: "david@shadovitz.com" +To: "pgsql-performance@postgresql.org" +Cc: 'Richard Huxton' +Subject: Re: COUNT & Pagination +Date: Mon, 12 Jan 2004 07:37:36 -0800 +X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/123 +X-Sequence-Number: 5298 + +> If you only need the count when you've got the results, most PG client +> interfaces will tell you how many rows you've got. What language is your app +> in? + +PHP. +But I have only a subset of the results, retrieved via a query with a "LIMIT +" clause, so $pg_numrows is m. +And retrieving all results (i.e. no LIMIT) is at least as expensive as +COUNT(*). + +-David + +From pgsql-performance-owner@postgresql.org Mon Jan 12 12:13:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9438AD1B55D + for ; + Mon, 12 Jan 2004 16:13:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97380-01 + for ; + Mon, 12 Jan 2004 12:12:32 -0400 (AST) +Received: from fuji.krosing.net (silmet.estpak.ee [194.126.97.78]) + by svr1.postgresql.org (Postfix) with ESMTP id EAF3DD1D9F2 + for ; + Mon, 12 Jan 2004 12:12:15 -0400 (AST) +Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) + by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id i0CGCApI002889; + Mon, 12 Jan 2004 18:12:10 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.8/8.12.8/Submit) id i0CGC9R0002887; + Mon, 12 Jan 2004 18:12:09 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: failures on machines using jfs +From: Hannu Krosing +To: "Spiegelberg, Greg" +Cc: "'Christopher Browne '" , + "'pgsql-performance@postgresql.org '" +In-Reply-To: <387C22290D3FD71195D300508BF7DB5238AE92@colmail01.cranel.com> +References: <387C22290D3FD71195D300508BF7DB5238AE92@colmail01.cranel.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1073923929.2365.22.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 12 Jan 2004 18:12:09 +0200 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/124 +X-Sequence-Number: 5299 + +Spiegelberg, Greg kirjutas P, 11.01.2004 kell 18:21: +> It would seem we're experiencing somthing similiar with our scratch +> volume (JFS mounted with noatime). + +Which files/directories do you keep on "scratch" volume ? + +All postgres files or just some (WAL, tmp) ? + +------------- +Hannu + + +From pgsql-performance-owner@postgresql.org Mon Jan 12 13:04:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 43019D1B43F + for ; + Mon, 12 Jan 2004 17:04:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05966-07 + for ; + Mon, 12 Jan 2004 13:03:55 -0400 (AST) +Received: from COLSWEEPER.cranel.com (newmail.cranel.com [12.32.71.147]) + by svr1.postgresql.org (Postfix) with ESMTP id DDC75D1B432 + for ; + Mon, 12 Jan 2004 13:03:53 -0400 (AST) +Received: from colmail01.cranel.com (colmail01.cranel.com) by + COLSWEEPER.cranel.com (Content Technologies SMTPRS 4.3.12) with ESMTP + id ; + Mon, 12 Jan 2004 12:02:43 -0500 +Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by + colmail01.cranel.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id + CZTCJWT0; Mon, 12 Jan 2004 12:07:30 -0500 +Message-ID: <4002D375.8040807@cranel.com> +Date: Mon, 12 Jan 2004 12:03:49 -0500 +From: Greg Spiegelberg +Organization: Cranel, Inc. +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Hannu Krosing +Cc: 'Christopher Browne ' , + "'pgsql-performance@postgresql.org '" +Subject: Re: failures on machines using jfs +References: <387C22290D3FD71195D300508BF7DB5238AE92@colmail01.cranel.com> + <1073923929.2365.22.camel@fuji.krosing.net> +In-Reply-To: <1073923929.2365.22.camel@fuji.krosing.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/125 +X-Sequence-Number: 5300 + +Hannu Krosing wrote: +> Spiegelberg, Greg kirjutas P, 11.01.2004 kell 18:21: +> +>>It would seem we're experiencing somthing similiar with our scratch +>>volume (JFS mounted with noatime). +> +> +> Which files/directories do you keep on "scratch" volume ? +> +> All postgres files or just some (WAL, tmp) ? + +No Postgres files are kept in scratch only the files being loaded +into the database via COPY or lo_import. + +My WAL logs are kept on a separate ext3 file system. + +Greg + +-- +Greg Spiegelberg + Sr. Product Development Engineer + Cranel, Incorporated. + Phone: 614.318.4314 + Fax: 614.431.8388 + Email: gspiegelberg@Cranel.com +Cranel. Technology. Integrity. Focus. + + + + +********************************************************************** +This email and any files transmitted with it are confidential and +intended solely for the use of the individual or entity to whom they +are addressed. If you have received this email in error please notify +the system manager. + +This footnote also confirms that this email message has been swept by +MIMEsweeper for the presence of computer viruses. + +www.mimesweeper.com +********************************************************************** + + +From pgsql-performance-owner@postgresql.org Mon Jan 12 17:47:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DD8DAD1B486 + for ; + Mon, 12 Jan 2004 21:47:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70224-06 + for ; + Mon, 12 Jan 2004 17:47:20 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id E5AC5D1B47A + for ; + Mon, 12 Jan 2004 17:47:15 -0400 (AST) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id i0CL1ZcM031493; + Mon, 12 Jan 2004 16:01:36 -0500 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i0CLgCl26901; + Mon, 12 Jan 2004 16:42:15 -0500 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id XT870T8W; Mon, 12 Jan 2004 16:42:10 -0500 +Subject: Re: COUNT & Pagination +From: Robert Treat +To: "david@shadovitz.com" +Cc: "pgsql-performance@postgresql.org" , + "'Richard Huxton'" +In-Reply-To: <01C3D8DF.271378C0.david@shadovitz.com> +References: <01C3D8DF.271378C0.david@shadovitz.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 12 Jan 2004 16:42:12 -0500 +Message-Id: <1073943732.29178.153.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/126 +X-Sequence-Number: 5301 + +On Mon, 2004-01-12 at 10:37, David Shadovitz wrote: +> > If you only need the count when you've got the results, most PG client +> > interfaces will tell you how many rows you've got. What language is your app +> > in? +> +> PHP. +> But I have only a subset of the results, retrieved via a query with a "LIMIT +> " clause, so $pg_numrows is m. +> And retrieving all results (i.e. no LIMIT) is at least as expensive as +> COUNT(*). +> + +Depending on frequency of updates and need for real time info, you could +cache the count in session as long as the user stays within the given +piece of your app. + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-admin-owner@postgresql.org Fri Jan 16 12:51:58 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 19D91D1B449 + for ; + Mon, 12 Jan 2004 21:46:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70483-06 + for ; + Mon, 12 Jan 2004 17:45:46 -0400 (AST) +Received: from web21106.mail.yahoo.com (web21106.mail.yahoo.com + [216.136.227.108]) + by svr1.postgresql.org (Postfix) with SMTP id E4EB4D1B462 + for ; Mon, 12 Jan 2004 17:45:43 -0400 (AST) +Message-ID: <20040112214545.35952.qmail@web21106.mail.yahoo.com> +Received: from [65.206.239.222] by web21106.mail.yahoo.com via HTTP; + Mon, 12 Jan 2004 13:45:45 PST +Date: Mon, 12 Jan 2004 13:45:45 -0800 (PST) +From: Shankar K +Subject: Postgres on Netapp +To: pgsql-admin@postgresql.org +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/141 +X-Sequence-Number: 12004 + +Hi There, + +We are considering to use NetApp filer for a highly +busy 24*7 postgres database and the reason we chose +netapp, mostly being the "snapshot" functionality for +backing up database online. The filer would be mounted +on a rh linux server (7.3), 4g RAM, dual cpu with a +dedicated card for filer. + +I'd appreciate if anyone could share your experience +in configuring things on the filer for optimal +performance or any recomendataion that i should be +aware of. + +Thanks, +Shankar + +__________________________________ +Do you Yahoo!? +Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes +http://hotjobs.sweepstakes.yahoo.com/signingbonus + +From pgsql-performance-owner@postgresql.org Mon Jan 12 23:08:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0865CD1B44A + for ; + Tue, 13 Jan 2004 03:08:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27894-06 + for ; + Mon, 12 Jan 2004 23:07:32 -0400 (AST) +Received: from mail2000-4.so-net.net.tw (mail2000-4.so-net.net.tw + [61.64.127.20]) + by svr1.postgresql.org (Postfix) with SMTP id 86419D1B52F + for ; + Mon, 12 Jan 2004 23:07:27 -0400 (AST) +Received: from 10.1.9.27 by mail2000-4.so-net.net.tw with Mail2000 ESMTP + Server + V2.71S(79708:0:AUTH_RELAY) Tue, 13 Jan 2004 11:07:28 +0800 (CST); + (envelope-from ) +Received: By OpenMail Mailer;Tue, 13 Jan 2004 11:07:24 +0800 (CST) +From: "cnliou" +Reply-To: cnliou@so-net.net.tw +Subject: Ignore Some Updates +Message-ID: <1073963244.78843.cnliou@so-net.net.tw> +To: "" +Date: Tue, 13 Jan 2004 11:07:24 +0800 (CST) +MIME-Version: 1.0 +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/127 +X-Sequence-Number: 5302 + +Dear developers, + +I wonder it happens to systems where inefficient update +SQL's are used like this: + +UPDATE MyTable SET MyColumn=1234 + +Question arises when the value of MyColumn is already 1234 +before the update. + +If I am right, even when the to-be-updated column values +equal to the new values, the core never hates to update that +row anyway. If so, is it wise or not to adjust the core for +lazy SQL users to ignore such "meaningless" updates in order +to reduce some disk load and prevent some "holes" resulted +from the delete (a consequence of update) in that table? + +Regards, +CN + +From pgsql-performance-owner@postgresql.org Tue Jan 13 01:00:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 201F0D1B55D + for ; + Tue, 13 Jan 2004 05:00:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44847-06 + for ; + Tue, 13 Jan 2004 00:59:36 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 192EDD1B494 + for ; + Tue, 13 Jan 2004 00:59:36 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i0D4xZ19008022; + Mon, 12 Jan 2004 23:59:35 -0500 (EST) +To: cnliou@so-net.net.tw +Cc: "" +Subject: Re: Ignore Some Updates +In-reply-to: <1073963244.78843.cnliou@so-net.net.tw> +References: <1073963244.78843.cnliou@so-net.net.tw> +Comments: In-reply-to "cnliou" + message dated "Tue, 13 Jan 2004 11:07:24 +0800" +Date: Mon, 12 Jan 2004 23:59:35 -0500 +Message-ID: <8021.1073969975@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/128 +X-Sequence-Number: 5303 + +"cnliou" writes: +> I wonder it happens to systems where inefficient update +> SQL's are used like this: +> UPDATE MyTable SET MyColumn=1234 +> Question arises when the value of MyColumn is already 1234 +> before the update. + +We have to fire UPDATE triggers in any case. + +> If I am right, even when the to-be-updated column values +> equal to the new values, the core never hates to update that +> row anyway. If so, is it wise or not to adjust the core for +> lazy SQL users to ignore such "meaningless" updates in order + +Seems like penalizing the intelligent people (by adding useless +comparisons) in order to reward the "lazy" ones. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jan 13 08:46:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FED9D1D8A0 + for ; + Tue, 13 Jan 2004 12:46:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 19360-08 + for ; + Tue, 13 Jan 2004 08:46:11 -0400 (AST) +Received: from fuji.krosing.net (silmet.estpak.ee [194.126.97.78]) + by svr1.postgresql.org (Postfix) with ESMTP id 71C1DD1D889 + for ; + Tue, 13 Jan 2004 08:46:07 -0400 (AST) +Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) + by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id i0DCk8nj002638; + Tue, 13 Jan 2004 14:46:08 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.8/8.12.8/Submit) id i0DCk8XV002636; + Tue, 13 Jan 2004 14:46:08 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: failures on machines using jfs +From: Hannu Krosing +To: Greg Spiegelberg +Cc: "'Christopher Browne '" , + "'pgsql-performance@postgresql.org '" +In-Reply-To: <4002D375.8040807@cranel.com> +References: <387C22290D3FD71195D300508BF7DB5238AE92@colmail01.cranel.com> + <1073923929.2365.22.camel@fuji.krosing.net> + <4002D375.8040807@cranel.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1073997967.2528.12.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 13 Jan 2004 14:46:08 +0200 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/129 +X-Sequence-Number: 5304 + +Greg Spiegelberg kirjutas E, 12.01.2004 kell 19:03: +> Hannu Krosing wrote: +> > Spiegelberg, Greg kirjutas P, 11.01.2004 kell 18:21: +> > +> >>It would seem we're experiencing somthing similiar with our scratch +> >>volume (JFS mounted with noatime). +> > +> > +> > Which files/directories do you keep on "scratch" volume ? +> > +> > All postgres files or just some (WAL, tmp) ? +> +> No Postgres files are kept in scratch only the files being loaded +> into the database via COPY or lo_import. + +then the speedup does not make any sense ! + +Is reading from jfs filesystem also 5 times faster than reading from +ext3 ? + +The only explanation I can give to filling database from jfs volume to +be so much faster could be some strange filesystem cache interactions. + +---------------- +Hannu + + + +From pgsql-performance-owner@postgresql.org Tue Jan 13 08:59:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2995ED1D876 + for ; + Tue, 13 Jan 2004 12:59:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 19445-08 + for ; + Tue, 13 Jan 2004 08:59:10 -0400 (AST) +Received: from mta11.adelphia.net (mta11.adelphia.net [68.168.78.205]) + by svr1.postgresql.org (Postfix) with ESMTP id B673AD1B440 + for ; + Tue, 13 Jan 2004 08:59:06 -0400 (AST) +Received: from potentialtech.com ([68.68.113.33]) by mta11.adelphia.net + (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP + id <20040113125909.CXQJ21134.mta11.adelphia.net@potentialtech.com>; + Tue, 13 Jan 2004 07:59:09 -0500 +Message-ID: <4003EB9C.30406@potentialtech.com> +Date: Tue, 13 Jan 2004 07:59:08 -0500 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Hannu Krosing +Cc: Greg Spiegelberg , + 'Christopher Browne ' , + "'pgsql-performance@postgresql.org '" +Subject: Re: failures on machines using jfs +References: <387C22290D3FD71195D300508BF7DB5238AE92@colmail01.cranel.com> + <1073923929.2365.22.camel@fuji.krosing.net> + <4002D375.8040807@cranel.com> + <1073997967.2528.12.camel@fuji.krosing.net> +In-Reply-To: <1073997967.2528.12.camel@fuji.krosing.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/130 +X-Sequence-Number: 5305 + +Hannu Krosing wrote: +> Greg Spiegelberg kirjutas E, 12.01.2004 kell 19:03: +> +>>Hannu Krosing wrote: +>> +>>>Spiegelberg, Greg kirjutas P, 11.01.2004 kell 18:21: +>>> +>>> +>>>>It would seem we're experiencing somthing similiar with our scratch +>>>>volume (JFS mounted with noatime). +>>> +>>> +>>>Which files/directories do you keep on "scratch" volume ? +>>> +>>>All postgres files or just some (WAL, tmp) ? +>> +>>No Postgres files are kept in scratch only the files being loaded +>>into the database via COPY or lo_import. +> +> +> then the speedup does not make any sense ! +> +> Is reading from jfs filesystem also 5 times faster than reading from +> ext3 ? +> +> The only explanation I can give to filling database from jfs volume to +> be so much faster could be some strange filesystem cache interactions. + +http://www.potentialtech.com/wmoran/postgresql.php + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Tue Jan 13 11:04:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BA21D1B43F + for ; + Tue, 13 Jan 2004 15:04:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54046-04 + for ; + Tue, 13 Jan 2004 11:04:26 -0400 (AST) +Received: from COLSWEEPER.cranel.com (newmail.cranel.com [12.32.71.147]) + by svr1.postgresql.org (Postfix) with ESMTP id 21EB4D1B519 + for ; + Tue, 13 Jan 2004 11:04:22 -0400 (AST) +Received: from colmail01.cranel.com (colmail01.cranel.com) by + COLSWEEPER.cranel.com (Content Technologies SMTPRS 4.3.12) with ESMTP + id ; + Tue, 13 Jan 2004 10:03:14 -0500 +Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by + colmail01.cranel.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id + CZTCJ5KW; Tue, 13 Jan 2004 10:08:01 -0500 +Message-ID: <400408F4.5030504@cranel.com> +Date: Tue, 13 Jan 2004 10:04:20 -0500 +From: Greg Spiegelberg +Organization: Cranel, Inc. +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Hannu Krosing +Cc: 'Christopher Browne ' , + "'pgsql-performance@postgresql.org '" +Subject: Re: failures on machines using jfs +References: <387C22290D3FD71195D300508BF7DB5238AE92@colmail01.cranel.com> + <1073923929.2365.22.camel@fuji.krosing.net> + <4002D375.8040807@cranel.com> + <1073997967.2528.12.camel@fuji.krosing.net> +In-Reply-To: <1073997967.2528.12.camel@fuji.krosing.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/131 +X-Sequence-Number: 5306 + +Hannu Krosing wrote: +> Greg Spiegelberg kirjutas E, 12.01.2004 kell 19:03: +> +>>Hannu Krosing wrote: +>> +>>>Spiegelberg, Greg kirjutas P, 11.01.2004 kell 18:21: +>>> +>>> +>>>>It would seem we're experiencing somthing similiar with our scratch +>>>>volume (JFS mounted with noatime). +>>> +>>> +>>>Which files/directories do you keep on "scratch" volume ? +>>> +>>>All postgres files or just some (WAL, tmp) ? +>> +>>No Postgres files are kept in scratch only the files being loaded +>>into the database via COPY or lo_import. +> +> +> then the speedup does not make any sense ! + +We do a lot of preprocessing before the data gets loaded. It's that +process that experiences the hiccups I mentioned. + +-- +Greg Spiegelberg + Sr. Product Development Engineer + Cranel, Incorporated. + Phone: 614.318.4314 + Fax: 614.431.8388 + Email: gspiegelberg@Cranel.com +Cranel. Technology. Integrity. Focus. + + + + +********************************************************************** +This email and any files transmitted with it are confidential and +intended solely for the use of the individual or entity to whom they +are addressed. If you have received this email in error please notify +the system manager. + +This footnote also confirms that this email message has been swept by +MIMEsweeper for the presence of computer viruses. + +www.mimesweeper.com +********************************************************************** + + +From pgsql-performance-owner@postgresql.org Tue Jan 13 12:05:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C943D1D8B9 + for ; + Tue, 13 Jan 2004 16:05:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66791-08 + for ; + Tue, 13 Jan 2004 12:04:42 -0400 (AST) +Received: from wind.mindcry.org (nat-gr.wmis.net [216.109.194.252]) + by svr1.postgresql.org (Postfix) with ESMTP id 39926D1B469 + for ; + Tue, 13 Jan 2004 12:04:26 -0400 (AST) +Received: by wind.mindcry.org (Postfix, from userid 1001) + id 068E0417B; Tue, 13 Jan 2004 11:04:14 -0500 (EST) +Date: Tue, 13 Jan 2004 11:04:13 -0500 +From: David Hill +To: pgsql-performance@postgresql.org +Subject: freebsd 5.2 and max_connections +Message-ID: <20040113160413.GB1554@phobia.ms> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.5.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/132 +X-Sequence-Number: 5307 + +Hello - +I am using postgresql to hold aliases, users, and relay_domains for postfix and courier to do lookups from. I am not storing mail in sql. + +I need postgresql to have fast read performance, so i setup index's on the tables. Also, the queries are basically "select blah from table where domain='domain.com'";, so i dont need to be able to support large results. + +I will have a lot of mail servers connecting to this postgresql db, so i need to support a lot of connections... but dont need to support large results. + +I am using FreeBSD 5.2. + +What are some tuning options and formulas I can use to get good values? + +Thanks! +David + + +From pgsql-performance-owner@postgresql.org Tue Jan 13 13:14:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B3C3D1DAA8 + for ; + Tue, 13 Jan 2004 17:14:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86424-07 + for ; + Tue, 13 Jan 2004 13:13:48 -0400 (AST) +Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net + [194.217.242.86]) + by svr1.postgresql.org (Postfix) with ESMTP id C1776D1DB3F + for ; + Tue, 13 Jan 2004 13:13:47 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AgS6s-000IGD-0b; Tue, 13 Jan 2004 17:13:46 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id BABE81717D; Tue, 13 Jan 2004 17:13:45 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 4B88817177; Tue, 13 Jan 2004 17:13:43 +0000 (GMT) +From: Richard Huxton +To: David Hill , pgsql-performance@postgresql.org +Subject: Re: freebsd 5.2 and max_connections +Date: Tue, 13 Jan 2004 17:13:42 +0000 +User-Agent: KMail/1.5 +References: <20040113160413.GB1554@phobia.ms> +In-Reply-To: <20040113160413.GB1554@phobia.ms> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200401131713.42682.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200401/133 +X-Sequence-Number: 5308 + +On Tuesday 13 January 2004 16:04, David Hill wrote: +> Hello - +> I am using postgresql to hold aliases, users, and relay_domains for postfix +> and courier to do lookups from. I am not storing mail in sql. +> +> I need postgresql to have fast read performance, so i setup index's on the +> tables. Also, the queries are basically "select blah from table where +> domain='domain.com'";, so i dont need to be able to support large results. +> +> I will have a lot of mail servers connecting to this postgresql db, so i +> need to support a lot of connections... but dont need to support large +> results. + +Firstly - if you don't know about the tuning guidelines/annotated config file, +you should go here: +http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php + +Hmm - small result sets accessed directly via indexed fields, so sort_mem +probably isn't important to you. + +Make sure your effective cache setting is accurate though, so PG can estimate +whether it'll need to access the disks. + +Not sure if clustering one or more tables will help - I'm guessing not. What +might help is to increase the statistics gathered on important columns. That +should give the planner a more accurate estimate of value distribution and +shouldn't cost you too much to keep accurate, since I'm guessing a low rate +of updating. + +You might want to play with the random page cost (?or is it random access +cost?) but more RAM for a bigger disk cache is probably the simplest tweak. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Jan 13 13:33:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 69CF4D1DB13 + for ; + Tue, 13 Jan 2004 17:33:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92593-05 + for ; + Tue, 13 Jan 2004 13:32:37 -0400 (AST) +Received: from trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id 94E43D1DF7E + for ; + Tue, 13 Jan 2004 13:32:33 -0400 (AST) +Received: (qmail 12359 invoked from network); 13 Jan 2004 17:31:37 -0000 +Received: from system66.trade-india-local.com (HELO office1.trade-india.com) + (192.168.0.66) + by system66.trade-india-local.com with SMTP; 13 Jan 2004 17:31:37 -0000 +Received: from 192.168.0.100 (SquirrelMail authenticated user mallah) + by system67.trade-india-local.com with HTTP; + Tue, 13 Jan 2004 23:01:37 +0530 (IST) +Message-ID: + <1157.192.168.0.100.1074015097.squirrel@system67.trade-india-local.com> +In-Reply-To: <01C3D82B.388A7FE0.david@shadovitz.com> +References: <01C3D82B.388A7FE0.david@shadovitz.com> +Date: Tue, 13 Jan 2004 23:01:37 +0530 (IST) +Subject: Re: COUNT & Pagination +From: mallah@trade-india.com +To: "david@shadovitz.com" +Cc: "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 postgresql.org +X-Archive-Number: 200401/134 +X-Sequence-Number: 5309 + +> I understand that COUNT queries are expensive. So I'm looking for advice +> on +> displaying paginated query results. +> +> I display my query results like this: +> +> Displaying 1 to 50 of 2905. +> 1-50 | 51-100 | 101-150 | etc. +> +> I do this by executing two queries. One is of the form: +> +> SELECT