diff --git "a/pgsql-performance.200604" "b/pgsql-performance.200604" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200604" @@ -0,0 +1,69529 @@ +From pgsql-performance-owner@postgresql.org Fri Mar 31 21:09:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8A0FD11F6AC5 + for ; + Fri, 31 Mar 2006 21:09:23 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68540-05 + for ; + Fri, 31 Mar 2006 21:09:22 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 7059D11F6665 + for ; + Fri, 31 Mar 2006 21:09:20 -0400 (AST) +Received: from [192.168.0.239] ([207.148.169.40]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Fri, 31 Mar 2006 18:09:18 -0700 +In-Reply-To: <20060331155911.GP49405@pervasive.com> +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-3-190317486; + protocol="application/pkcs7-signature" +Message-Id: +Cc: PostgreSQL Performance +From: Brendan Duddridge +Subject: Re: Query using SeqScan instead of IndexScan +Date: Fri, 31 Mar 2006 18:09:18 -0700 +To: Jim C. Nasby +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200603/645 +X-Sequence-Number: 18082 + + +--Apple-Mail-3-190317486 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Hi Jim, + +I'm not quite sure what you mean by the correlation of category_id? +The category_id is part of a compound primary key in the +category_product +table. The primary key on category_product is (category_id, product_id). + +Here's the definitions of the two tables involved in the join: + + Table "public.category_product" + Column | Type | Modifiers +---------------------+----------------------+----------- +category_id | integer | not null +product_id | integer | not null +en_name_sort_order | integer | +fr_name_sort_order | integer | +merchant_sort_order | integer | +price_sort_order | integer | +merchant_count | integer | +is_active | character varying(5) | +Indexes: + "x_category_product_pk" PRIMARY KEY, btree (category_id, +product_id) + "category_product__is_active_idx" btree (is_active) + "category_product__merchant_sort_order_idx" btree +(merchant_sort_order) + "x_category_product__category_id_fk_idx" btree (category_id) +CLUSTER + "x_category_product__product_id_fk_idx" btree (product_id) +Foreign-key constraints: + "x_category_product_category_fk" FOREIGN KEY (category_id) +REFERENCES category(category_id) DEFERRABLE INITIALLY DEFERRED + "x_category_product_product_fk" FOREIGN KEY (product_id) +REFERENCES product(product_id) DEFERRABLE INITIALLY DEFERRED + + + + Table "public.product_attribute_value" + Column | Type | Modifiers +----------------------------+-----------------------+----------- +attribute_id | integer | not null +attribute_unit_id | integer | +attribute_value_id | integer | +boolean_value | character varying(5) | +decimal_value | numeric(30,10) | +product_attribute_value_id | integer | not null +product_id | integer | not null +product_reference_id | integer | +status_code | character varying(32) | +Indexes: + "product_attribute_value_pk" PRIMARY KEY, btree +(product_attribute_value_id) + "product_attribute_value__attribute_id_fk_idx" btree (attribute_id) + "product_attribute_value__attribute_unit_id_fk_idx" btree +(attribute_unit_id) + "product_attribute_value__attribute_value_id_fk_idx" btree +(attribute_value_id) + "product_attribute_value__product_id_fk_idx" btree (product_id) + "product_attribute_value__product_reference_id_fk_idx" btree +(product_reference_id) +Foreign-key constraints: + "product_attribute_value_attribute_fk" FOREIGN KEY +(attribute_id) REFERENCES attribute(attribute_id) DEFERRABLE +INITIALLY DEFERRED + "product_attribute_value_attributeunit_fk" FOREIGN KEY +(attribute_unit_id) REFERENCES attribute_unit(attribute_unit_id) +DEFERRABLE INITIALLY DEFERRED + "product_attribute_value_attributevalue_fk" FOREIGN KEY +(attribute_value_id) REFERENCES attribute_value(attribute_value_id) +DEFERRABLE INITIALLY DEFERRED + "product_attribute_value_product_fk" FOREIGN KEY (product_id) +REFERENCES product(product_id) DEFERRABLE INITIALLY DEFERRED + "product_attribute_value_productreference_fk" FOREIGN KEY +(product_reference_id) REFERENCES product(product_id) DEFERRABLE +INITIALLY DEFERRED + + +Not sure if that helps answer your question, but the query is pretty +slow. Sometimes it takes 5 - 15 seconds depending on the category_id +specified. + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Mar 31, 2006, at 8:59 AM, Jim C. Nasby wrote: + +> What's the correlation of category_id? The current index scan cost +> estimator places a heavy penalty on anything with a correlation much +> below about 90%. +> +> On Wed, Mar 29, 2006 at 08:12:28PM -0700, Brendan Duddridge wrote: +>> Hi, +>> +>> I have a query that is using a sequential scan instead of an index +>> scan. I've turned off sequential scans and it is in fact faster with +>> the index scan. +>> +>> Here's my before and after. +>> +>> Before: +>> +>> ssdev=# SET enable_seqscan TO DEFAULT; +>> ssdev=# explain analyze select cp.product_id +>> from category_product cp, product_attribute_value pav +>> where cp.category_id = 1001082 and cp.product_id = +>> pav.product_id; +>> +>> +>> QUERY PLAN +>> --------------------------------------------------------------------- +>> --- +>> --------------------------------------------------------------------- +>> --- +>> ------------------------------ +>> Hash Join (cost=25.52..52140.59 rows=5139 width=4) (actual +>> time=4.521..2580.520 rows=19695 loops=1) +>> Hash Cond: ("outer".product_id = "inner".product_id) +>> -> Seq Scan on product_attribute_value pav (cost=0.00..40127.12 +>> rows=2387312 width=4) (actual time=0.039..1469.295 rows=2385846 +>> loops=1) +>> -> Hash (cost=23.10..23.10 rows=970 width=4) (actual +>> time=2.267..2.267 rows=1140 loops=1) +>> -> Index Scan using x_category_product__category_id_fk_idx +>> on category_product cp (cost=0.00..23.10 rows=970 width=4) (actual +>> time=0.122..1.395 rows=1140 loops=1) +>> Index Cond: (category_id = 1001082) +>> Total runtime: 2584.221 ms +>> (7 rows) +>> +>> +>> After: +>> +>> ssdev=# SET enable_seqscan TO false; +>> ssdev=# explain analyze select cp.product_id +>> from category_product cp, product_attribute_value pav +>> where cp.category_id = 1001082 and cp.product_id = +>> pav.product_id; +>> +>> +>> QUERY PLAN +>> --------------------------------------------------------------------- +>> --- +>> --------------------------------------------------------------------- +>> --- +>> ------------------------------------- +>> Nested Loop (cost=0.00..157425.22 rows=5139 width=4) (actual +>> time=0.373..71.177 rows=19695 loops=1) +>> -> Index Scan using x_category_product__category_id_fk_idx on +>> category_product cp (cost=0.00..23.10 rows=970 width=4) (actual +>> time=0.129..1.438 rows=1140 loops=1) +>> Index Cond: (category_id = 1001082) +>> -> Index Scan using product_attribute_value__product_id_fk_idx +>> on product_attribute_value pav (cost=0.00..161.51 rows=61 width=4) +>> (actual time=0.016..0.053 rows=17 loops=1140) +>> Index Cond: ("outer".product_id = pav.product_id) +>> Total runtime: 74.747 ms +>> (6 rows) +>> +>> There's quite a big difference in speed there. 2584.221 ms vs. 74.747 +>> ms. +>> +>> Any ideas what I can do to improve this without turning sequential +>> scanning off? +>> +>> Thanks, +>> +>> ____________________________________________________________________ +>> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +>> +>> ClickSpace Interactive Inc. +>> Suite L100, 239 - 10th Ave. SE +>> Calgary, AB T2G 0V9 +>> +>> http://www.clickspace.com +>> +> +> +> +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that +> your +> message can get through to the mailing list cleanly +> + + +--Apple-Mail-3-190317486 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIDCCAtkw +ggJCoAMCAQICAw84ujANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0EwHhcNMDUwNzI5MjAxMTQzWhcNMDYwNzI5MjAxMTQzWjBIMR8wHQYDVQQD +ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSUwIwYJKoZIhvcNAQkBFhZicmVuZGFuQGNsaWNrc3Bh +Y2UuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqWfMCdFgKzXroGNqJuU3eyDC +K/Gxts3mtmIdgcHGmUjRKdlBSfkmcCBUDPJIt4QQc91sY3h8Itg0EAsF+1yFECU6afn/1SEAHSDK +6Q86PclF58/Dux2FYNGpeIAw/lisZ2UCyIYoUiWtEDKCBq5jDuYzcGkFS5Csz+/rEL+BHTXQVqnS +nUdUaXu9xdZn4wgjB/n65UEYRqr0LGN53CGsFcA9uC+ViS7WyBtzJcP02LMNT+cAZ7TKHw4Q/ZeG +5ptPgQHLTD2wza3GMbPQ4fYK6aNPA+lVzslLSCjyQpg55gVyQQlV0k/5zU5Q5m48ZtqwOqN+fPYd +eIB7H5y1SFLd/wIDAQABozMwMTAhBgNVHREEGjAYgRZicmVuZGFuQGNsaWNrc3BhY2UuY29tMAwG +A1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEEBQADgYEAT+6hGvStHoRO0OCHlJev31BpUlvPSpbYVKJN +i5kCMF164sSX7j0IRvcyU6DfUuW7samTluXJbANyuX1ZIpXulGen5EEc2NV7eU/rMz6ExklMShTh +++azcvmMjOzTuqXi3ZsIjwzBBhqCB0U++kYlMlHEYla2qKLFbXY6PiH0a8swggM/MIICqKADAgEC +AgENMA0GCSqGSIb3DQEBBQUAMIHRMQswCQYDVQQGEwJaQTEVMBMGA1UECBMMV2VzdGVybiBDYXBl +MRIwEAYDVQQHEwlDYXBlIFRvd24xGjAYBgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQL +Ex9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMSQwIgYDVQQDExtUaGF3dGUgUGVyc29u +YWwgRnJlZW1haWwgQ0ExKzApBgkqhkiG9w0BCQEWHHBlcnNvbmFsLWZyZWVtYWlsQHRoYXd0ZS5j +b20wHhcNMDMwNzE3MDAwMDAwWhcNMTMwNzE2MjM1OTU5WjBiMQswCQYDVQQGEwJaQTElMCMGA1UE +ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFs +IEZyZWVtYWlsIElzc3VpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMSmPFVzVftO +ucqZWh5owHUEcJ3f6f+jHuy9zfVb8hp2vX8MOmHyv1HOAdTlUAow1wJjWiyJFXCO3cnwK4Vaqj9x +VsuvPAsH5/EfkTYkKhPPK9Xzgnc9A74r/rsYPge/QIACZNenprufZdHFKlSFD0gEf6e20TxhBEAe +ZBlyYLf7AgMBAAGjgZQwgZEwEgYDVR0TAQH/BAgwBgEB/wIBADBDBgNVHR8EPDA6MDigNqA0hjJo +dHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhhd3RlUGVyc29uYWxGcmVlbWFpbENBLmNybDALBgNVHQ8E +BAMCAQYwKQYDVR0RBCIwIKQeMBwxGjAYBgNVBAMTEVByaXZhdGVMYWJlbDItMTM4MA0GCSqGSIb3 +DQEBBQUAA4GBAEiM0VCD6gsuzA2jZqxnD3+vrL7CF6FDlpSdf0whuPg2H6otnzYvwPQcUCCTcDz9 +reFhYsPZOhl+hLGZGwDFGguCdJ4lUJRix9sncVcljd2pnDmOjCBPZV+V2vf3h9bGCE6u9uo05RAa +WzVNd+NWIXiC3CEZNd4ksdMdRv9dX2VPMYIC5zCCAuMCAQEwaTBiMQswCQYDVQQGEwJaQTElMCMG +A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv +bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujAJBgUrDgMCGgUAoIIBUzAYBgkqhkiG9w0BCQMx +CwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA0MDEwMTA5MThaMCMGCSqGSIb3DQEJBDEW +BBSGLrSHEp9LWDZMoFTpDUNpH9QV2zB4BgkrBgEEAYI3EAQxazBpMGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDDzi6MHoGCyqGSIb3DQEJEAILMWugaTBiMQswCQYD +VQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMj +VGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujANBgkqhkiG9w0BAQEFAASC +AQAyx6QTWD42FWIp5SNZyXiiBZ7RoJlY1gMf1Rq1xEc3rmn8L6Eu6dMjyvLZA8tpwexbA2jqL7Q4 +tsfTEupMT3VE/k+AAGW3D5Idt/T2geNKqjk7S33aiQgSO2lkW27r881tNeU95RAfYKRXaZHRQygC +TVDedzAHUaYpqeuGCfP3NUykKAaS0XhHeJWDR5ZVUuVzVLHTrE7apD+yTR32mUFTo0caW0vyv+Tu +2yy71xloRuTi7zPFgG/5kGn0j7z9Uh9ojTRrVqKoKORbagvas6dscObehDovnvq9QospRamk7GJs +tCaL+u2cM/OkhHhfOxa8D5007hgy0tn1/PwnbEYeAAAAAAAA + +--Apple-Mail-3-190317486-- + + +From pgsql-performance-owner@postgresql.org Fri Mar 31 21:23:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3EC7911F66F5 + for ; + Fri, 31 Mar 2006 21:23:39 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70969-07 + for ; + Fri, 31 Mar 2006 21:23:38 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.193]) + by postgresql.org (Postfix) with ESMTP id DADB211F660F + for ; + Fri, 31 Mar 2006 21:23:36 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id m7so83426nzf + for ; + Fri, 31 Mar 2006 17:23:37 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=Jaw9EIHwvY9zn5ElYr9q1LToY6PHAk2t2J94w3WCWUqbMylz1BWLjcr3a+tTyQtQM/AhtQFkDEbl0u2NLlSJ3m6Txg6ockgSqMRgXUy1q9KmKeN6Zm583SVXC1/XEwCWZq2tWH14UK7rSVMHKOOyLMpURFBYqWzOVOnaKLtlvzM= +Received: by 10.37.18.44 with SMTP id v44mr1371203nzi; + Fri, 31 Mar 2006 17:23:37 -0800 (PST) +Received: by 10.36.196.1 with HTTP; Fri, 31 Mar 2006 17:23:37 -0800 (PST) +Message-ID: <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> +Date: Sat, 1 Apr 2006 11:23:37 +1000 +From: "chris smith" +To: "Brendan Duddridge" +Subject: Re: Query using SeqScan instead of IndexScan +Cc: "Jim C. Nasby" , + "PostgreSQL Performance" +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.13 required=5 tests=[AWL=0.130] +X-Spam-Score: 0.13 +X-Spam-Level: +X-Archive-Number: 200603/646 +X-Sequence-Number: 18083 + +On 4/1/06, Brendan Duddridge wrote: +> Hi Jim, +> +> I'm not quite sure what you mean by the correlation of category_id? + +It means how many distinct values does it have (at least that's my +understanding of it ;) ). + +select category_id, count(*) from category_product group by category_id; + +will show you how many category_id's there are and how many products +are in each category. + +Having a lot of products in one category (or having a small amount of +categories) can slow things down because the db can't use the index +effectively.. which might be what you're seeing (hence why it's fast +for some categories, slow for others). + + +> On Mar 31, 2006, at 8:59 AM, Jim C. Nasby wrote: +> +> > What's the correlation of category_id? The current index scan cost +> > estimator places a heavy penalty on anything with a correlation much +> > below about 90%. +> > +> > On Wed, Mar 29, 2006 at 08:12:28PM -0700, Brendan Duddridge wrote: +> >> Hi, +> >> +> >> I have a query that is using a sequential scan instead of an index +> >> scan. I've turned off sequential scans and it is in fact faster with +> >> the index scan. +> >> +> >> Here's my before and after. +> >> +> >> Before: +> >> +> >> ssdev=3D# SET enable_seqscan TO DEFAULT; +> >> ssdev=3D# explain analyze select cp.product_id +> >> from category_product cp, product_attribute_value pav +> >> where cp.category_id =3D 1001082 and cp.product_id =3D +> >> pav.product_id; +> >> +> >> +> >> QUERY PLAN +> >> --------------------------------------------------------------------- +> >> --- +> >> --------------------------------------------------------------------- +> >> --- +> >> ------------------------------ +> >> Hash Join (cost=3D25.52..52140.59 rows=3D5139 width=3D4) (actual +> >> time=3D4.521..2580.520 rows=3D19695 loops=3D1) +> >> Hash Cond: ("outer".product_id =3D "inner".product_id) +> >> -> Seq Scan on product_attribute_value pav (cost=3D0.00..40127.12 +> >> rows=3D2387312 width=3D4) (actual time=3D0.039..1469.295 rows=3D238584= +6 +> >> loops=3D1) +> >> -> Hash (cost=3D23.10..23.10 rows=3D970 width=3D4) (actual +> >> time=3D2.267..2.267 rows=3D1140 loops=3D1) +> >> -> Index Scan using x_category_product__category_id_fk_idx +> >> on category_product cp (cost=3D0.00..23.10 rows=3D970 width=3D4) (act= +ual +> >> time=3D0.122..1.395 rows=3D1140 loops=3D1) +> >> Index Cond: (category_id =3D 1001082) +> >> Total runtime: 2584.221 ms +> >> (7 rows) +> >> +> >> +> >> After: +> >> +> >> ssdev=3D# SET enable_seqscan TO false; +> >> ssdev=3D# explain analyze select cp.product_id +> >> from category_product cp, product_attribute_value pav +> >> where cp.category_id =3D 1001082 and cp.product_id =3D +> >> pav.product_id; +> >> +> >> +> >> QUERY PLAN +> >> --------------------------------------------------------------------- +> >> --- +> >> --------------------------------------------------------------------- +> >> --- +> >> ------------------------------------- +> >> Nested Loop (cost=3D0.00..157425.22 rows=3D5139 width=3D4) (actual +> >> time=3D0.373..71.177 rows=3D19695 loops=3D1) +> >> -> Index Scan using x_category_product__category_id_fk_idx on +> >> category_product cp (cost=3D0.00..23.10 rows=3D970 width=3D4) (actual +> >> time=3D0.129..1.438 rows=3D1140 loops=3D1) +> >> Index Cond: (category_id =3D 1001082) +> >> -> Index Scan using product_attribute_value__product_id_fk_idx +> >> on product_attribute_value pav (cost=3D0.00..161.51 rows=3D61 width= +=3D4) +> >> (actual time=3D0.016..0.053 rows=3D17 loops=3D1140) +> >> Index Cond: ("outer".product_id =3D pav.product_id) +> >> Total runtime: 74.747 ms +> >> (6 rows) +> >> +> >> There's quite a big difference in speed there. 2584.221 ms vs. 74.747 +> >> ms. +> >> +> >> Any ideas what I can do to improve this without turning sequential +> >> scanning off? +> >> +> >> Thanks, +> >> +> >> ____________________________________________________________________ +> >> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +> >> +> >> ClickSpace Interactive Inc. +> >> Suite L100, 239 - 10th Ave. SE +> >> Calgary, AB T2G 0V9 +> >> +> >> http://www.clickspace.com +> >> +> > +> > +> > +> > -- +> > Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> > Pervasive Software http://pervasive.com work: 512-231-6117 +> > vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> > +> > ---------------------------(end of +> > broadcast)--------------------------- +> > TIP 1: if posting/reading through Usenet, please send an appropriate +> > subscribe-nomail command to majordomo@postgresql.org so that +> > your +> > message can get through to the mailing list cleanly +> > +> +> +> +> + + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Fri Mar 31 21:31:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D6CF111F6C29 + for ; + Fri, 31 Mar 2006 21:31:52 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72593-04 + for ; + Fri, 31 Mar 2006 21:31:52 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id E9A6411F6C21 + for ; + Fri, 31 Mar 2006 21:31:49 -0400 (AST) +Received: from [192.168.0.239] ([207.148.169.40]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Fri, 31 Mar 2006 18:31:49 -0700 +In-Reply-To: <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> + + <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-4-191667260; + protocol="application/pkcs7-signature" +Message-Id: +Cc: "Jim C. Nasby" , + "PostgreSQL Performance" +From: Brendan Duddridge +Subject: Re: Query using SeqScan instead of IndexScan +Date: Fri, 31 Mar 2006 18:31:47 -0700 +To: chris smith +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200603/647 +X-Sequence-Number: 18084 + + +--Apple-Mail-4-191667260 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Ah I see. Ok, well we have a very wide variety here... + +category_id | count +-------------+------- + 1000521 | 31145 + 1001211 | 22991 + 1001490 | 22019 + 1001628 | 12472 + 1000046 | 10480 + 1000087 | 10338 + 1001223 | 10020 + 1001560 | 9532 + 1000954 | 8633 + 1001314 | 8191 + 1001482 | 8140 + 1001556 | 7959 + 1001481 | 7850 +[snip...] + 1001133 | 1 + 1000532 | 1 + 1000691 | 1 + 1000817 | 1 + 1000783 | 1 + 1000689 | 1 + +(1157 rows) + +So what's the best kind of query to handle this kind of data to make +it fast in all cases? I'd like get down to sub-second response times. + +currently we have: + +select cp.product_id + from category_product cp, product_attribute_value pav + where cp.category_id = 1001082 and cp.product_id = + pav.product_id; + + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Mar 31, 2006, at 6:23 PM, chris smith wrote: + +> On 4/1/06, Brendan Duddridge wrote: +>> Hi Jim, +>> +>> I'm not quite sure what you mean by the correlation of category_id? +> +> It means how many distinct values does it have (at least that's my +> understanding of it ;) ). +> +> select category_id, count(*) from category_product group by +> category_id; +> +> will show you how many category_id's there are and how many products +> are in each category. +> +> Having a lot of products in one category (or having a small amount of +> categories) can slow things down because the db can't use the index +> effectively.. which might be what you're seeing (hence why it's fast +> for some categories, slow for others). +> +> +>> On Mar 31, 2006, at 8:59 AM, Jim C. Nasby wrote: +>> +>>> What's the correlation of category_id? The current index scan cost +>>> estimator places a heavy penalty on anything with a correlation much +>>> below about 90%. +>>> +>>> On Wed, Mar 29, 2006 at 08:12:28PM -0700, Brendan Duddridge wrote: +>>>> Hi, +>>>> +>>>> I have a query that is using a sequential scan instead of an index +>>>> scan. I've turned off sequential scans and it is in fact faster +>>>> with +>>>> the index scan. +>>>> +>>>> Here's my before and after. +>>>> +>>>> Before: +>>>> +>>>> ssdev=# SET enable_seqscan TO DEFAULT; +>>>> ssdev=# explain analyze select cp.product_id +>>>> from category_product cp, product_attribute_value pav +>>>> where cp.category_id = 1001082 and cp.product_id = +>>>> pav.product_id; +>>>> +>>>> +>>>> QUERY PLAN +>>>> ------------------------------------------------------------------- +>>>> -- +>>>> --- +>>>> ------------------------------------------------------------------- +>>>> -- +>>>> --- +>>>> ------------------------------ +>>>> Hash Join (cost=25.52..52140.59 rows=5139 width=4) (actual +>>>> time=4.521..2580.520 rows=19695 loops=1) +>>>> Hash Cond: ("outer".product_id = "inner".product_id) +>>>> -> Seq Scan on product_attribute_value pav +>>>> (cost=0.00..40127.12 +>>>> rows=2387312 width=4) (actual time=0.039..1469.295 rows=2385846 +>>>> loops=1) +>>>> -> Hash (cost=23.10..23.10 rows=970 width=4) (actual +>>>> time=2.267..2.267 rows=1140 loops=1) +>>>> -> Index Scan using +>>>> x_category_product__category_id_fk_idx +>>>> on category_product cp (cost=0.00..23.10 rows=970 width=4) (actual +>>>> time=0.122..1.395 rows=1140 loops=1) +>>>> Index Cond: (category_id = 1001082) +>>>> Total runtime: 2584.221 ms +>>>> (7 rows) +>>>> +>>>> +>>>> After: +>>>> +>>>> ssdev=# SET enable_seqscan TO false; +>>>> ssdev=# explain analyze select cp.product_id +>>>> from category_product cp, product_attribute_value pav +>>>> where cp.category_id = 1001082 and cp.product_id = +>>>> pav.product_id; +>>>> +>>>> +>>>> QUERY PLAN +>>>> ------------------------------------------------------------------- +>>>> -- +>>>> --- +>>>> ------------------------------------------------------------------- +>>>> -- +>>>> --- +>>>> ------------------------------------- +>>>> Nested Loop (cost=0.00..157425.22 rows=5139 width=4) (actual +>>>> time=0.373..71.177 rows=19695 loops=1) +>>>> -> Index Scan using x_category_product__category_id_fk_idx on +>>>> category_product cp (cost=0.00..23.10 rows=970 width=4) (actual +>>>> time=0.129..1.438 rows=1140 loops=1) +>>>> Index Cond: (category_id = 1001082) +>>>> -> Index Scan using product_attribute_value__product_id_fk_idx +>>>> on product_attribute_value pav (cost=0.00..161.51 rows=61 width=4) +>>>> (actual time=0.016..0.053 rows=17 loops=1140) +>>>> Index Cond: ("outer".product_id = pav.product_id) +>>>> Total runtime: 74.747 ms +>>>> (6 rows) +>>>> +>>>> There's quite a big difference in speed there. 2584.221 ms vs. +>>>> 74.747 +>>>> ms. +>>>> +>>>> Any ideas what I can do to improve this without turning sequential +>>>> scanning off? +>>>> +>>>> Thanks, +>>>> +>>>> ___________________________________________________________________ +>>>> _ +>>>> Brendan Duddridge | CTO | 403-277-5591 x24 | +>>>> brendan@clickspace.com +>>>> +>>>> ClickSpace Interactive Inc. +>>>> Suite L100, 239 - 10th Ave. SE +>>>> Calgary, AB T2G 0V9 +>>>> +>>>> http://www.clickspace.com +>>>> +>>> +>>> +>>> +>>> -- +>>> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +>>> Pervasive Software http://pervasive.com work: 512-231-6117 +>>> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +>>> +>>> ---------------------------(end of +>>> broadcast)--------------------------- +>>> TIP 1: if posting/reading through Usenet, please send an appropriate +>>> subscribe-nomail command to majordomo@postgresql.org so that +>>> your +>>> message can get through to the mailing list cleanly +>>> +>> +>> +>> +>> +> +> +> -- +> Postgresql & php tutorials +> http://www.designmagick.com/ +> + + +--Apple-Mail-4-191667260 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIDCCAtkw +ggJCoAMCAQICAw84ujANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0EwHhcNMDUwNzI5MjAxMTQzWhcNMDYwNzI5MjAxMTQzWjBIMR8wHQYDVQQD +ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSUwIwYJKoZIhvcNAQkBFhZicmVuZGFuQGNsaWNrc3Bh +Y2UuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqWfMCdFgKzXroGNqJuU3eyDC +K/Gxts3mtmIdgcHGmUjRKdlBSfkmcCBUDPJIt4QQc91sY3h8Itg0EAsF+1yFECU6afn/1SEAHSDK +6Q86PclF58/Dux2FYNGpeIAw/lisZ2UCyIYoUiWtEDKCBq5jDuYzcGkFS5Csz+/rEL+BHTXQVqnS +nUdUaXu9xdZn4wgjB/n65UEYRqr0LGN53CGsFcA9uC+ViS7WyBtzJcP02LMNT+cAZ7TKHw4Q/ZeG +5ptPgQHLTD2wza3GMbPQ4fYK6aNPA+lVzslLSCjyQpg55gVyQQlV0k/5zU5Q5m48ZtqwOqN+fPYd +eIB7H5y1SFLd/wIDAQABozMwMTAhBgNVHREEGjAYgRZicmVuZGFuQGNsaWNrc3BhY2UuY29tMAwG +A1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEEBQADgYEAT+6hGvStHoRO0OCHlJev31BpUlvPSpbYVKJN +i5kCMF164sSX7j0IRvcyU6DfUuW7samTluXJbANyuX1ZIpXulGen5EEc2NV7eU/rMz6ExklMShTh +++azcvmMjOzTuqXi3ZsIjwzBBhqCB0U++kYlMlHEYla2qKLFbXY6PiH0a8swggM/MIICqKADAgEC +AgENMA0GCSqGSIb3DQEBBQUAMIHRMQswCQYDVQQGEwJaQTEVMBMGA1UECBMMV2VzdGVybiBDYXBl +MRIwEAYDVQQHEwlDYXBlIFRvd24xGjAYBgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQL +Ex9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMSQwIgYDVQQDExtUaGF3dGUgUGVyc29u +YWwgRnJlZW1haWwgQ0ExKzApBgkqhkiG9w0BCQEWHHBlcnNvbmFsLWZyZWVtYWlsQHRoYXd0ZS5j +b20wHhcNMDMwNzE3MDAwMDAwWhcNMTMwNzE2MjM1OTU5WjBiMQswCQYDVQQGEwJaQTElMCMGA1UE +ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFs +IEZyZWVtYWlsIElzc3VpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMSmPFVzVftO +ucqZWh5owHUEcJ3f6f+jHuy9zfVb8hp2vX8MOmHyv1HOAdTlUAow1wJjWiyJFXCO3cnwK4Vaqj9x +VsuvPAsH5/EfkTYkKhPPK9Xzgnc9A74r/rsYPge/QIACZNenprufZdHFKlSFD0gEf6e20TxhBEAe +ZBlyYLf7AgMBAAGjgZQwgZEwEgYDVR0TAQH/BAgwBgEB/wIBADBDBgNVHR8EPDA6MDigNqA0hjJo +dHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhhd3RlUGVyc29uYWxGcmVlbWFpbENBLmNybDALBgNVHQ8E +BAMCAQYwKQYDVR0RBCIwIKQeMBwxGjAYBgNVBAMTEVByaXZhdGVMYWJlbDItMTM4MA0GCSqGSIb3 +DQEBBQUAA4GBAEiM0VCD6gsuzA2jZqxnD3+vrL7CF6FDlpSdf0whuPg2H6otnzYvwPQcUCCTcDz9 +reFhYsPZOhl+hLGZGwDFGguCdJ4lUJRix9sncVcljd2pnDmOjCBPZV+V2vf3h9bGCE6u9uo05RAa +WzVNd+NWIXiC3CEZNd4ksdMdRv9dX2VPMYIC5zCCAuMCAQEwaTBiMQswCQYDVQQGEwJaQTElMCMG +A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv +bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujAJBgUrDgMCGgUAoIIBUzAYBgkqhkiG9w0BCQMx +CwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA0MDEwMTMxNDhaMCMGCSqGSIb3DQEJBDEW +BBQXNcwjs2XaFwLJ/I4cBTIOSlPFtTB4BgkrBgEEAYI3EAQxazBpMGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDDzi6MHoGCyqGSIb3DQEJEAILMWugaTBiMQswCQYD +VQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMj +VGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujANBgkqhkiG9w0BAQEFAASC +AQBWPhoA9saofNZfkHvr5DfQAIFElixmk0OFwoGlySbKHeIjJiO237csFMRaePBK57OiZbAHyoGz +lXSNW2NIkTci2FWJ7uUkMj34qDA4hqC87zhjoGFR30N9QOa0YS/XYLEtKoiBy7gJ4hMFjLB7s+3e +1EohuEPDYzFx98T6SFWM6FARMKkzRLN73IsayTPWoTLxH+bdohQvNS+d6UzqXEbZdmjiF796XRrY +sJuYumWmlFU3Iwbp/WH0zOMUD7wPD9tEtqqVwCY79EyC2pTm4UJvcutiel2BALR2f0C1yTRODkPI +eSnCe8jry1rsSi7TkwQ7fynfZPjTapp4lquWk7PEAAAAAAAA + +--Apple-Mail-4-191667260-- + + +From pgsql-performance-owner@postgresql.org Sat Apr 1 05:54:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3585911F61C3 + for ; + Sat, 1 Apr 2006 05:54:03 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20247-03 + for ; + Sat, 1 Apr 2006 05:54:02 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.202]) + by postgresql.org (Postfix) with ESMTP id C143711F6B22 + for ; + Sat, 1 Apr 2006 05:54:00 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id m7so163944nzf + for ; + Sat, 01 Apr 2006 01:54:00 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=SDkPft0oqYX5RQUUVGzhk7SRsMFakb3A7TkWiAzrIeDArJkaMaeHjXNi5YqT3kv2cFtka6aEEvEG/vI1xdytOe2oOauqBoHIP5Vvln/Z2bBU/iIJxsh4lvr9SPZmADtPnWdpH6ZHNsOPSD5KupdssYSmkLt81jDkemyhkk3j8Rs= +Received: by 10.35.121.2 with SMTP id y2mr345607pym; + Sat, 01 Apr 2006 01:54:00 -0800 (PST) +Received: by 10.35.37.10 with HTTP; Sat, 1 Apr 2006 01:54:00 -0800 (PST) +Message-ID: <92d3a4950604010154h4bf30eb1i244be3b0e848be07@mail.gmail.com> +Date: Sat, 1 Apr 2006 11:54:00 +0200 +From: Antoine +To: "Magnus Hagander" +Subject: Re: [Solved] Slow performance on Windows .NET and OleDb +Cc: "Dave Dutcher" , "Greg Quinn" , + pgsql-performance@postgresql.org +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCEA0F8C7@algol.sollentuna.se> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <6BCB9D8A16AC4241919521715F4D8BCEA0F8C7@algol.sollentuna.se> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.27 required=5 tests=[AWL=0.270] +X-Spam-Score: 0.27 +X-Spam-Level: +X-Archive-Number: 200604/1 +X-Sequence-Number: 18085 + +On 01/04/06, Magnus Hagander wrote: +> > This is a blatant thread steal... but here we go... +> > Do people have any opinions on the pgsql driver? +> +> It's very nice. +... + +Thanks for the tips - i'll try a couple of test apps soon. +Cheers +Antoine + + + + +-- +This is where I should put some witty comment. + +From pgsql-performance-owner@postgresql.org Sat Apr 1 11:32:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8A8B311F6C5C + for ; + Sat, 1 Apr 2006 11:32:50 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75357-01 + for ; + Sat, 1 Apr 2006 11:32:50 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 28F5111F66AC + for ; + Sat, 1 Apr 2006 11:32:47 -0400 (AST) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 9FEFC56423; Sat, 1 Apr 2006 09:32:48 -0600 (CST) +Received: (hashcash-sendmail, from uid 1001); + Sat, 1 Apr 2006 09:32:47 -0600 +Date: Sat, 1 Apr 2006 09:32:47 -0600 +From: "Jim C. Nasby" +To: chris smith +Cc: Brendan Duddridge , + PostgreSQL Performance +Subject: Re: Query using SeqScan instead of IndexScan +Message-ID: <20060401153247.GI49405@pervasive.com> +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> + + <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060401:dmagick@gmail.com::gU0tVAmheXwFhBm/:00000000000000000000 + 0000000000000000000000008j9Z +X-Hashcash: + 1:20:060401:brendan@clickspace.com::+/1/Q9Cd0xZ+jFu3:000000000000000 + 0000000000000000000000002q0h +X-Hashcash: + 1:20:060401:pgsql-performance@postgresql.org::vctwFvHBoLySTmqv:00000 + 0000000000000000000000000AaY +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.108 required=5 tests=[AWL=0.108] +X-Spam-Score: 0.108 +X-Spam-Level: +X-Archive-Number: 200604/2 +X-Sequence-Number: 18086 + +On Sat, Apr 01, 2006 at 11:23:37AM +1000, chris smith wrote: +> On 4/1/06, Brendan Duddridge wrote: +> > Hi Jim, +> > +> > I'm not quite sure what you mean by the correlation of category_id? +> +> It means how many distinct values does it have (at least that's my +> understanding of it ;) ). + +Your understanding is wrong. :) What you're discussing is n_distinct. + +http://www.postgresql.org/docs/8.1/interactive/view-pg-stats.html + +correlation: "Statistical correlation between physical row ordering and +logical ordering of the column values. This ranges from -1 to +1. When +the value is near -1 or +1, an index scan on the column will be +estimated to be cheaper than when it is near zero, due to reduction of +random access to the disk. (This column is NULL if the column data type +does not have a < operator.)" + +In other words, the following will have a correlation of 1: + +1 +2 +3 +... +998 +999 +1000 + +And this is -1... + +1000 +999 +... +2 +1 + +While this would have a very low correlation: + +1 +1000 +2 +999 +... + +The lower the correlation, the more expensive an index scan is, because +it's more random. As I mentioned, I believe that the current index scan +cost estimator is flawed though, because it will bias heavily against +correlations that aren't close to 1 or -1. + +So, what does + +SELECT * FROM pg_stats WHERE tablename='table' AND attname='category_id'; + +show? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Sat Apr 1 13:51:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 280F811F6CE0 + for ; + Sat, 1 Apr 2006 13:51:22 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12213-03 + for ; + Sat, 1 Apr 2006 13:51:20 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 9701911F6C6F + for ; + Sat, 1 Apr 2006 13:51:19 -0400 (AST) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Sat, 1 Apr 2006 10:51:15 -0700 +In-Reply-To: <20060401153247.GI49405@pervasive.com> +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> + + <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> + <20060401153247.GI49405@pervasive.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-1-250431641; + protocol="application/pkcs7-signature" +Message-Id: <95C1A48B-A76F-4F9B-B5EE-0BFAF8873067@clickspace.com> +Cc: chris smith , + PostgreSQL Performance +From: Brendan Duddridge +Subject: Re: Query using SeqScan instead of IndexScan +Date: Sat, 1 Apr 2006 10:51:12 -0700 +To: "Jim C. Nasby" +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.108 required=5 tests=[AWL=0.108] +X-Spam-Score: 0.108 +X-Spam-Level: +X-Archive-Number: 200604/3 +X-Sequence-Number: 18087 + + +--Apple-Mail-1-250431641 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Hi Jim, + +from SELECT * FROM pg_stats WHERE tablename='table' AND +attname='category_id' + +I find correlation on category_product for category_id is 0.643703 + +Would setting the index on category_id to be clustered help with this? + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 1, 2006, at 8:32 AM, Jim C. Nasby wrote: + +> On Sat, Apr 01, 2006 at 11:23:37AM +1000, chris smith wrote: +>> On 4/1/06, Brendan Duddridge wrote: +>>> Hi Jim, +>>> +>>> I'm not quite sure what you mean by the correlation of category_id? +>> +>> It means how many distinct values does it have (at least that's my +>> understanding of it ;) ). +> +> Your understanding is wrong. :) What you're discussing is n_distinct. +> +> http://www.postgresql.org/docs/8.1/interactive/view-pg-stats.html +> +> correlation: "Statistical correlation between physical row ordering +> and +> logical ordering of the column values. This ranges from -1 to +1. When +> the value is near -1 or +1, an index scan on the column will be +> estimated to be cheaper than when it is near zero, due to reduction of +> random access to the disk. (This column is NULL if the column data +> type +> does not have a < operator.)" +> +> In other words, the following will have a correlation of 1: +> +> 1 +> 2 +> 3 +> ... +> 998 +> 999 +> 1000 +> +> And this is -1... +> +> 1000 +> 999 +> ... +> 2 +> 1 +> +> While this would have a very low correlation: +> +> 1 +> 1000 +> 2 +> 999 +> ... +> +> The lower the correlation, the more expensive an index scan is, +> because +> it's more random. As I mentioned, I believe that the current index +> scan +> cost estimator is flawed though, because it will bias heavily against +> correlations that aren't close to 1 or -1. +> +> So, what does +> +> SELECT * FROM pg_stats WHERE tablename='table' AND +> attname='category_id'; +> +> show? +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + +--Apple-Mail-1-250431641 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIDCCAtkw +ggJCoAMCAQICAw84ujANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0EwHhcNMDUwNzI5MjAxMTQzWhcNMDYwNzI5MjAxMTQzWjBIMR8wHQYDVQQD +ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSUwIwYJKoZIhvcNAQkBFhZicmVuZGFuQGNsaWNrc3Bh +Y2UuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqWfMCdFgKzXroGNqJuU3eyDC +K/Gxts3mtmIdgcHGmUjRKdlBSfkmcCBUDPJIt4QQc91sY3h8Itg0EAsF+1yFECU6afn/1SEAHSDK +6Q86PclF58/Dux2FYNGpeIAw/lisZ2UCyIYoUiWtEDKCBq5jDuYzcGkFS5Csz+/rEL+BHTXQVqnS +nUdUaXu9xdZn4wgjB/n65UEYRqr0LGN53CGsFcA9uC+ViS7WyBtzJcP02LMNT+cAZ7TKHw4Q/ZeG +5ptPgQHLTD2wza3GMbPQ4fYK6aNPA+lVzslLSCjyQpg55gVyQQlV0k/5zU5Q5m48ZtqwOqN+fPYd +eIB7H5y1SFLd/wIDAQABozMwMTAhBgNVHREEGjAYgRZicmVuZGFuQGNsaWNrc3BhY2UuY29tMAwG +A1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEEBQADgYEAT+6hGvStHoRO0OCHlJev31BpUlvPSpbYVKJN +i5kCMF164sSX7j0IRvcyU6DfUuW7samTluXJbANyuX1ZIpXulGen5EEc2NV7eU/rMz6ExklMShTh +++azcvmMjOzTuqXi3ZsIjwzBBhqCB0U++kYlMlHEYla2qKLFbXY6PiH0a8swggM/MIICqKADAgEC +AgENMA0GCSqGSIb3DQEBBQUAMIHRMQswCQYDVQQGEwJaQTEVMBMGA1UECBMMV2VzdGVybiBDYXBl +MRIwEAYDVQQHEwlDYXBlIFRvd24xGjAYBgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQL +Ex9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMSQwIgYDVQQDExtUaGF3dGUgUGVyc29u +YWwgRnJlZW1haWwgQ0ExKzApBgkqhkiG9w0BCQEWHHBlcnNvbmFsLWZyZWVtYWlsQHRoYXd0ZS5j +b20wHhcNMDMwNzE3MDAwMDAwWhcNMTMwNzE2MjM1OTU5WjBiMQswCQYDVQQGEwJaQTElMCMGA1UE +ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFs +IEZyZWVtYWlsIElzc3VpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMSmPFVzVftO +ucqZWh5owHUEcJ3f6f+jHuy9zfVb8hp2vX8MOmHyv1HOAdTlUAow1wJjWiyJFXCO3cnwK4Vaqj9x +VsuvPAsH5/EfkTYkKhPPK9Xzgnc9A74r/rsYPge/QIACZNenprufZdHFKlSFD0gEf6e20TxhBEAe +ZBlyYLf7AgMBAAGjgZQwgZEwEgYDVR0TAQH/BAgwBgEB/wIBADBDBgNVHR8EPDA6MDigNqA0hjJo +dHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhhd3RlUGVyc29uYWxGcmVlbWFpbENBLmNybDALBgNVHQ8E +BAMCAQYwKQYDVR0RBCIwIKQeMBwxGjAYBgNVBAMTEVByaXZhdGVMYWJlbDItMTM4MA0GCSqGSIb3 +DQEBBQUAA4GBAEiM0VCD6gsuzA2jZqxnD3+vrL7CF6FDlpSdf0whuPg2H6otnzYvwPQcUCCTcDz9 +reFhYsPZOhl+hLGZGwDFGguCdJ4lUJRix9sncVcljd2pnDmOjCBPZV+V2vf3h9bGCE6u9uo05RAa +WzVNd+NWIXiC3CEZNd4ksdMdRv9dX2VPMYIC5zCCAuMCAQEwaTBiMQswCQYDVQQGEwJaQTElMCMG +A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv +bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujAJBgUrDgMCGgUAoIIBUzAYBgkqhkiG9w0BCQMx +CwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA0MDExNzUxMTJaMCMGCSqGSIb3DQEJBDEW +BBTZ20a8WFs7mfgEB2ASPvvVivN1rjB4BgkrBgEEAYI3EAQxazBpMGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDDzi6MHoGCyqGSIb3DQEJEAILMWugaTBiMQswCQYD +VQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMj +VGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujANBgkqhkiG9w0BAQEFAASC +AQBCn5nLmjB+3q0zHFnVCkgRrM8OoE+ojC2aZKXc7467oviNBwCXiN3lfLRwbRDBu42U2UvZUkJX +n2c8s+uB1QkBVYKqdkjRAzmTLrs+l8/lgC6CzBcziYCyJCHLTAF92K1Sc9vw/N2VPYiFfRyC11Z7 +nfAZq5qgZXDJREQiaEV/qXG/Ne/VZ+pkNjHeCDrYxQezZBRbOVdGmpLENskNEJ/aARfyArafEmzo +A9m8nIpcGRy1AaEuWhjDQtSvXm0gN5GJ8g+SD2OrX7XO59K2WyJ4uR3AOKGjWyFfD29u+wXwJmd4 +jlE2wgEu21Y7Kl8A1bpkW/+xpVGqMo9uXYCCTxRmAAAAAAAA + +--Apple-Mail-1-250431641-- + + +From pgsql-performance-owner@postgresql.org Sat Apr 1 15:23:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2E04811F6B3D + for ; + Sat, 1 Apr 2006 15:23:23 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24406-07 + for ; + Sat, 1 Apr 2006 15:23:22 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.176]) + by postgresql.org (Postfix) with ESMTP id 28EF411F6782 + for ; + Sat, 1 Apr 2006 15:23:21 -0400 (AST) +Received: by pproxy.gmail.com with SMTP id s49so15787pyc + for ; + Sat, 01 Apr 2006 11:23:20 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=QOgoMpYJBwYIuxCwoaBXQgFe3vmdWq1GzAk1b/Ll3nn2s9Pwp1K1Vb4284dTmOj5oUM2mCFAqKH9wewIaBOIUo0z+sBdfJiamjOPHAF4eCX5y7PrTnxeSGD1b9wEWjLdqGXwMlvKnU7Pg5xN75b4wEAF9mSQMkbpAtCfhtYdqS8= +Received: by 10.65.116.9 with SMTP id t9mr87457qbm; + Sat, 01 Apr 2006 11:23:20 -0800 (PST) +Received: by 10.65.135.6 with HTTP; Sat, 1 Apr 2006 11:23:20 -0800 (PST) +Message-ID: +Date: Sat, 1 Apr 2006 14:23:20 -0500 +From: "Merlin Moncure" +To: "Magnus Hagander" +Subject: Re: [Solved] Slow performance on Windows .NET and OleDb +Cc: Antoine , "Dave Dutcher" , + "Greg Quinn" , pgsql-performance@postgresql.org +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCEA0F8C7@algol.sollentuna.se> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <6BCB9D8A16AC4241919521715F4D8BCEA0F8C7@algol.sollentuna.se> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.154 required=5 tests=[AWL=0.154] +X-Spam-Score: 0.154 +X-Spam-Level: +X-Archive-Number: 200604/4 +X-Sequence-Number: 18088 + +On 3/31/06, Magnus Hagander wrote: +> > This is a blatant thread steal... but here we go... +> > Do people have any opinions on the pgsql driver? + +> I beleive so. I've been using it for a long time with zero problems. +> While I don't use many of the exotic features in it, I doubt most people +> do ;-) Don't get scared by the claim it's in beta - IIRC there's an RC +> out any day now, and it's been stable long before 1.0. But it's always a +> good idea to browse through the list of known bugs and see if one will +> likely hit you... + +Up until a few months ago the npgsql driver was missing a few features +that made it easier to work with typed datasets in the IDE...I would +use the odbc driver to create the dataset at design time and work with +it at run time with the npgsql driver. + +Lately though, it seems there is no reason not use the npgsql driver. + +Merlin + +From pgsql-performance-owner@postgresql.org Sat Apr 1 20:50:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2530E11F6C52 + for ; + Sat, 1 Apr 2006 20:50:47 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00925-03 + for ; + Sat, 1 Apr 2006 20:50:46 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.205]) + by postgresql.org (Postfix) with ESMTP id C3C1911F6C50 + for ; + Sat, 1 Apr 2006 20:50:44 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id m7so309984nzf + for ; + Sat, 01 Apr 2006 16:50:45 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=E1A2NbnDyvh7xKiNG90oh/MhQQmxrNvgZhc/76rydVpVrSYa4xtojmw3zai9XRvasNGlbwfPJoWrjLbORS5SBriIuWNkJ/QVkfCLXOlIEeqX+SNMEnEv+Cr6VaFKlDzAG9zF6otd+LUUBd/x8w9BiMgjKQYLaL5BmYHkmQJ71u4= +Received: by 10.36.138.9 with SMTP id l9mr595445nzd; + Sat, 01 Apr 2006 16:50:44 -0800 (PST) +Received: by 10.36.196.1 with HTTP; Sat, 1 Apr 2006 16:50:44 -0800 (PST) +Message-ID: <3c1395330604011650r61c793a7td3e8be58ab023c7b@mail.gmail.com> +Date: Sun, 2 Apr 2006 10:50:44 +1000 +From: "chris smith" +To: "Jim C. Nasby" +Subject: Re: Query using SeqScan instead of IndexScan +Cc: "PostgreSQL Performance" +In-Reply-To: <20060401153247.GI49405@pervasive.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> + + <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> + <20060401153247.GI49405@pervasive.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +X-Spam-Score: 0.127 +X-Spam-Level: +X-Archive-Number: 200604/5 +X-Sequence-Number: 18089 + +On 4/2/06, Jim C. Nasby wrote: +> On Sat, Apr 01, 2006 at 11:23:37AM +1000, chris smith wrote: +> > On 4/1/06, Brendan Duddridge wrote: +> > > Hi Jim, +> > > +> > > I'm not quite sure what you mean by the correlation of category_id? +> > +> > It means how many distinct values does it have (at least that's my +> > understanding of it ;) ). +> +> Your understanding is wrong. :) What you're discussing is n_distinct. + +Geez, I'm going well this week ;) + +Thanks for the detailed info. + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Sat Apr 1 21:32:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 101EF11F6C33 + for ; + Sat, 1 Apr 2006 21:32:15 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54072-08 + for ; + Sat, 1 Apr 2006 21:32:14 -0400 (AST) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.195]) + by postgresql.org (Postfix) with ESMTP id 9C89511F6B6A + for ; + Sat, 1 Apr 2006 21:32:12 -0400 (AST) +Received: by zproxy.gmail.com with SMTP id m7so315213nzf + for ; + Sat, 01 Apr 2006 17:32:13 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=OmxXkilY+pLYcbGIfvzXuPYSO7nuFKTltsqKC7fk5TpEm/dRcD2JIEgG1EkGj5QbzQE45zxEwXbcDYPlCZZ5BnddhjndSkrGDvd6asPKtHb9L9ZhwZEcuVduvYHT2KRdkAVJL0QlVLGs9hiEhPV98s5uEr73J8Comajh+rMr++k= +Received: by 10.36.106.10 with SMTP id e10mr2821624nzc; + Sat, 01 Apr 2006 17:32:12 -0800 (PST) +Received: by 10.36.196.1 with HTTP; Sat, 1 Apr 2006 17:32:12 -0800 (PST) +Message-ID: <3c1395330604011732n4cd523c3gf7c1e4c346630aad@mail.gmail.com> +Date: Sun, 2 Apr 2006 11:32:12 +1000 +From: "chris smith" +To: "Jim C. Nasby" +Subject: Re: Query using SeqScan instead of IndexScan +Cc: "PostgreSQL Performance" +In-Reply-To: <3c1395330604011650r61c793a7td3e8be58ab023c7b@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> + + <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> + <20060401153247.GI49405@pervasive.com> + <3c1395330604011650r61c793a7td3e8be58ab023c7b@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] +X-Spam-Score: 0.126 +X-Spam-Level: +X-Archive-Number: 200604/6 +X-Sequence-Number: 18090 + +On 4/2/06, chris smith wrote: +> On 4/2/06, Jim C. Nasby wrote: +> > On Sat, Apr 01, 2006 at 11:23:37AM +1000, chris smith wrote: +> > > On 4/1/06, Brendan Duddridge wrote: +> > > > Hi Jim, +> > > > +> > > > I'm not quite sure what you mean by the correlation of category_id? +> > > +> > > It means how many distinct values does it have (at least that's my +> > > understanding of it ;) ). +> > +> > Your understanding is wrong. :) What you're discussing is n_distinct. + + +It'd be nice if the database developers agreed on what terms meant. + +http://dev.mysql.com/doc/refman/5.1/en/myisam-index-statistics.html + +The SHOW INDEX statement displays a cardinality value based on N/S, +where N is the number of rows in the table and S is the average value +group size. That ratio yields an approximate number of value groups in +the table. + + +A work colleague found that information a few weeks ago so that's +where my misunderstanding came from - if I'm reading that right they +use n_distinct as their "cardinality" basis.. then again I could be +reading that completely wrong too. + +I believe postgres (because it's a lot more standards compliant).. but +sheesh - what a difference! + +This week's task - stop reading mysql documentation. + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Sun Apr 2 00:26:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ACD8911F6B3C + for ; + Sun, 2 Apr 2006 00:26:49 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95420-03 + for ; + Sun, 2 Apr 2006 00:26:47 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by postgresql.org (Postfix) with ESMTP id 0134E11F6B52 + for ; + Sun, 2 Apr 2006 00:26:46 -0400 (AST) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx2.surnet.cl with ESMTP; 02 Apr 2006 00:26:46 -0400 +X-IronPort-AV: i="4.02,198,1139194800"; + d="scan'208"; a="40171685:sNHT18376328" +Received: from alvh.no-ip.org (201.221.200.233) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD00D04D39; Sun, 2 Apr 2006 00:26:45 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id A46B9C37116; Sun, 2 Apr 2006 00:26:45 -0400 (CLT) +Date: Sun, 2 Apr 2006 00:26:45 -0400 +From: Alvaro Herrera +To: chris smith +Cc: "Jim C. Nasby" , + PostgreSQL Performance +Subject: Re: Query using SeqScan instead of IndexScan +Message-ID: <20060402042645.GA9711@surnet.cl> +Mail-Followup-To: chris smith , + "Jim C. Nasby" , + PostgreSQL Performance +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> + + <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> + <20060401153247.GI49405@pervasive.com> + <3c1395330604011650r61c793a7td3e8be58ab023c7b@mail.gmail.com> + <3c1395330604011732n4cd523c3gf7c1e4c346630aad@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3c1395330604011732n4cd523c3gf7c1e4c346630aad@mail.gmail.com> +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.605 required=5 tests=[AWL=-0.314, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +X-Spam-Score: 1.605 +X-Spam-Level: * +X-Archive-Number: 200604/7 +X-Sequence-Number: 18091 + +chris smith wrote: + +> I believe postgres (because it's a lot more standards compliant).. but +> sheesh - what a difference! +> +> This week's task - stop reading mysql documentation. + +You don't _have_ to believe Postgres -- this is stuff taught in any +statistics course. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +PostgreSQL Replication, Consulting, Custom Development, 24x7 support + +From pgsql-performance-owner@postgresql.org Sun Apr 2 00:31:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 984BB11F6B3C + for ; + Sun, 2 Apr 2006 00:31:39 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94602-06 + for ; + Sun, 2 Apr 2006 00:31:37 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz + [203.96.152.183]) + by postgresql.org (Postfix) with ESMTP id 2646711F6B52 + for ; + Sun, 2 Apr 2006 00:31:37 -0400 (AST) +Received: from smtp-3.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-4.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IX200FJGV8N34@linda-4.paradise.net.nz> for + pgsql-performance@postgresql.org; Sun, 02 Apr 2006 16:31:35 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-28-188.dsl.clear.net.nz [218.101.28.188]) by + smtp-3.paradise.net.nz (Postfix) with ESMTP id BB35716982C9; + Sun, 02 Apr 2006 16:31:34 +1200 (NZST) +Date: Sun, 02 Apr 2006 16:31:34 +1200 +From: Mark Kirkwood +Subject: Re: Query using SeqScan instead of IndexScan +In-reply-to: <3c1395330604011732n4cd523c3gf7c1e4c346630aad@mail.gmail.com> +To: chris smith +Cc: "Jim C. Nasby" , + PostgreSQL Performance +Message-id: <442F53A6.9090707@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20051106) +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> + + <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> + <20060401153247.GI49405@pervasive.com> + <3c1395330604011650r61c793a7td3e8be58ab023c7b@mail.gmail.com> + <3c1395330604011732n4cd523c3gf7c1e4c346630aad@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.169 required=5 tests=[AWL=0.169] +X-Spam-Score: 0.169 +X-Spam-Level: +X-Archive-Number: 200604/8 +X-Sequence-Number: 18092 + +chris smith wrote: + +> +> It'd be nice if the database developers agreed on what terms meant. +> +> http://dev.mysql.com/doc/refman/5.1/en/myisam-index-statistics.html +> +> The SHOW INDEX statement displays a cardinality value based on N/S, +> where N is the number of rows in the table and S is the average value +> group size. That ratio yields an approximate number of value groups in +> the table. +> +> +> A work colleague found that information a few weeks ago so that's +> where my misunderstanding came from - if I'm reading that right they +> use n_distinct as their "cardinality" basis.. then again I could be +> reading that completely wrong too. +> + +Yeah that's right - e.g using the same table in postgres and mysql: + +pgsql> SELECT attname,n_distinct,correlation + FROM pg_stats + WHERE tablename='fact0' + AND attname LIKE 'd%key'; + attname | n_distinct | correlation +---------+------------+------------- + d0key | 10000 | -0.0211169 + d1key | 100 | 0.124012 + d2key | 10 | 0.998393 +(3 rows) + + +mysql> SHOW INDEX FROM fact0 + -> ; ++-------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ +| Table | Non_unique | Key_name | Seq_in_index | Column_name | +Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | ++-------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ +| fact0 | 1 | fact0_d0key | 1 | d0key | A + | 10000 | NULL | NULL | | BTREE | | +| fact0 | 1 | fact0_d1key | 1 | d1key | A + | 100 | NULL | NULL | | BTREE | | +| fact0 | 1 | fact0_d2key | 1 | d2key | A + | 10 | NULL | NULL | | BTREE | | ++-------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ +3 rows in set (0.00 sec) + + +It is a bit confusing - '(distinct) cardinality' might be a better +heading for their 'cardinality' column! + +On the correlation business - I don't think Mysql calculates it (or if +it does, its not displayed). + + +> I believe postgres (because it's a lot more standards compliant).. but +> sheesh - what a difference! +> + +Well yes - however, to be fair to the Mysql guys, AFAICS the capture and +display of index stats (and any other optimizer related data) is not +part of any standard. + + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Sun Apr 2 00:46:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 95E3311F6B1D + for ; + Sun, 2 Apr 2006 00:46:17 -0400 (AST) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96291-05 + for ; + Sun, 2 Apr 2006 00:46:15 -0400 (AST) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 7022411F6AFA + for ; + Sun, 2 Apr 2006 00:46:15 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k324k9LW018073; + Sat, 1 Apr 2006 23:46:09 -0500 (EST) +To: Mark Kirkwood +cc: chris smith , "Jim C. Nasby" , + PostgreSQL Performance +Subject: Re: Query using SeqScan instead of IndexScan +In-reply-to: <442F53A6.9090707@paradise.net.nz> +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> + + <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> + <20060401153247.GI49405@pervasive.com> + <3c1395330604011650r61c793a7td3e8be58ab023c7b@mail.gmail.com> + <3c1395330604011732n4cd523c3gf7c1e4c346630aad@mail.gmail.com> + <442F53A6.9090707@paradise.net.nz> +Comments: In-reply-to Mark Kirkwood + message dated "Sun, 02 Apr 2006 16:31:34 +1200" +Date: Sat, 01 Apr 2006 23:46:09 -0500 +Message-ID: <18072.1143953169@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] +X-Spam-Score: 0.114 +X-Spam-Level: +X-Archive-Number: 200604/9 +X-Sequence-Number: 18093 + +Mark Kirkwood writes: +> It is a bit confusing - '(distinct) cardinality' might be a better +> heading for their 'cardinality' column! + +The usual mathematical meaning of "cardinality" is "the number of +members in a set". That isn't real helpful for the point at hand, +because the mathematical definition of a set disallows duplicate +members, so if you're dealing with non-unique values you could argue it +either way about whether to count duplicates or not. However, I read in +the SQL99 spec (3.1 Definitions) + + d) cardinality (of a value of a collection type): The number of + elements in that value. Those elements need not necessarily have + distinct values. + +so ... as all too often ... the mysql boys have not got a clue about +standards compliance. They are using this term in the opposite way +from how the SQL committee uses it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 2 05:32:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5829D11F6C76 + for ; + Sun, 2 Apr 2006 05:32:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30999-08 + for ; + Sun, 2 Apr 2006 05:31:59 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 6120711F6C70 + for ; + Sun, 2 Apr 2006 05:31:58 -0300 (ADT) +Received: from analytic.local (analytic.yun5.7winds.ru [81.176.142.130]) + by svr4.postgresql.org (Postfix) with ESMTP id 235965AF678 + for ; + Sun, 2 Apr 2006 08:31:56 +0000 (GMT) +Received: from analytic.local (localhost [127.0.0.1]) + by analytic.local (8.13.6/8.13.4) with ESMTP id k328VnLB062264 + for ; + Sun, 2 Apr 2006 12:31:49 +0400 (MSD) + (envelope-from alexs@analytic.local) +Received: (from alexs@localhost) + by analytic.local (8.13.6/8.13.1/Submit) id k328Vna7062263 + for pgsql-performance@postgresql.org; + Sun, 2 Apr 2006 12:31:49 +0400 (MSD) (envelope-from alexs) +Date: Sun, 2 Apr 2006 12:31:49 +0400 +From: =?utf-8?B?0JrQu9GO0YfQvdC40LrQvtCyINCQLtChLg==?= +To: pgsql-performance@postgresql.org +Subject: Trigger vs Rule +Message-ID: <20060402083149.GA62166@mail.analytic.mv.ru> +Mail-Followup-To: pgsql-performance@postgresql.org +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/10 +X-Sequence-Number: 18094 + +Hi all. + +There are two tables: + +create table device_types ( +id int, +name varchar +); +about 1000 rows + +create table devices ( +id int, +type int REFERENCES device_types(id), +name varchar, +data float +); +about 200000 rows + +And about 1000 functions: +create function device_type1(int) returns .. +create function device_type2(int) returns .. +... +create function device_type1000(int) returns .. + + +What is faster? + +One trigger with 1000 ELSE IF +if old.type=1 then + select device_type1(old.id); +else if old.type=2 then + select device_type2(old.id); +... +else if old.type=1000 then + select device_type1000(old.id); +end if; + +Or 1000 rules +create rule device_type1 AS ON update to devices + where old.type=1 + DO select device_type1(old.id); +create rule device_type2 AS ON update to devices + where old.type=2 + DO select device_type2(old.id); +... +create rule device_type1000 AS ON update to devices + where old.type=1000 + DO select device_type1000(old.id); + +thx. + +-- +С уважением, +Ключников А.С. + +From pgsql-performance-owner@postgresql.org Sun Apr 2 11:33:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A323A11F6C57 + for ; + Sun, 2 Apr 2006 11:33:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80386-08 + for ; + Sun, 2 Apr 2006 11:33:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id A2CEC11F602F + for ; + Sun, 2 Apr 2006 11:33:13 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id EF14130CF1; Sun, 2 Apr 2006 16:33:13 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: statistics buffer is full +Date: Sun, 2 Apr 2006 22:33:05 +0800 +Organization: Hub.Org Networking Services +Lines: 16 +Message-ID: +References: <442A7C08.3020206@i-logic.hu> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-RFC2646: Format=Flowed; Response +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.172 required=5 tests=[AWL=0.172] +X-Spam-Score: 0.172 +X-Spam-Level: +X-Archive-Number: 200604/11 +X-Sequence-Number: 18095 + + +""G�briel �kos"" wrote +> +> I've got this message while heavily inserting into a database. What should +> I tune and how? It is postgresql 8.1.3. +> +> 2006-03-29 14:16:57.513 CEST:LOG: statistics buffer is full +> + +Since your server is in a heavy load, so the common trick is to increase +PGSTAT_RECVBUFFERSZ in include/pgstat.h and recompile your server. + +Regards, +Qingqing + + + +From pgsql-performance-owner@postgresql.org Sun Apr 2 11:36:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AAF9611F61EF + for ; + Sun, 2 Apr 2006 11:36:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81876-03 + for ; + Sun, 2 Apr 2006 11:36:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id A06D311F602F + for ; + Sun, 2 Apr 2006 11:36:26 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 0122C30D0A; Sun, 2 Apr 2006 16:36:26 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: Large Binary Objects Middleware +Date: Sun, 2 Apr 2006 22:36:17 +0800 +Organization: Hub.Org Networking Services +Lines: 16 +Message-ID: +References: <3cf983d0603271216x6d4a4614ye6dc48e31e8b5cb6@mail.gmail.com> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.171 required=5 tests=[AWL=0.171] +X-Spam-Score: 0.171 +X-Spam-Level: +X-Archive-Number: 200604/12 +X-Sequence-Number: 18096 + + +""Rodrigo Madera"" wrote +> +> The database is holding large ammounts of digital video, and I am +> wanting to put these directly into the database. What performance +> guidelines would you all give seeing my position today? +> + +IMHO, if you don't need transaction semantics, don't put these big things +into database. Instead, add a field in your table and put the link to the +big things in it. + +Regards, +Qingqing + + + +From pgsql-performance-owner@postgresql.org Sun Apr 2 11:45:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E80CD11F68D4 + for ; + Sun, 2 Apr 2006 11:45:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82526-05 + for ; + Sun, 2 Apr 2006 11:45:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id CF53811F6710 + for ; + Sun, 2 Apr 2006 11:45:42 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 3CD8E30D0A; Sun, 2 Apr 2006 16:45:43 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: Logging SQL queries to optimize them ? +Date: Sun, 2 Apr 2006 22:45:34 +0800 +Organization: Hub.Org Networking Services +Lines: 16 +Message-ID: +References: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-RFC2646: Format=Flowed; Response +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.171 required=5 tests=[AWL=0.171] +X-Spam-Score: 0.171 +X-Spam-Level: +X-Archive-Number: 200604/13 +X-Sequence-Number: 18097 + + +"Bruno Baguette" wrote +> +> +> Is there a way to log all SQL queries, with the date/time when they were +> launched, and the cost of that query (if this is possible) in order to see +> which queries need to be optimized ? +> + +See if log_statement, log_statement_stats parameters can help you. Also, +EXPLAIN ANALYZE can help you more on the target query. + +Regards, +Qingqing + + + +From pgsql-performance-owner@postgresql.org Sun Apr 2 13:20:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7353E11F709E + for ; + Sun, 2 Apr 2006 13:20:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96930-01 + for ; + Sun, 2 Apr 2006 13:20:24 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 762B411F6F4C + for ; + Sun, 2 Apr 2006 13:20:24 -0300 (ADT) +Received: from h6608.serverkompetenz.net (h6608.serverkompetenz.net + [81.169.179.29]) + by svr4.postgresql.org (Postfix) with ESMTP id 12F5A5AF8A8 + for ; + Sun, 2 Apr 2006 16:20:23 +0000 (GMT) +Received: from dslc-082-082-104-253.pools.arcor-ip.net ([82.82.104.253] + helo=[192.168.0.60]) + by h6608.serverkompetenz.net with esmtpa (Exim 4.60) + (envelope-from ) id 1FQ5JL-0001HK-Ni + for pgsql-performance@postgresql.org; Sun, 02 Apr 2006 18:20:20 +0200 +Message-ID: <442FF9C0.2070702@web.de> +Date: Sun, 02 Apr 2006 18:20:16 +0200 +From: Jan Kesten +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: index not used again +References: <442CF375.2080903@web.de> + <20060331064252.J61282@megazone.bigpanda.com> +In-Reply-To: <20060331064252.J61282@megazone.bigpanda.com> +X-Enigmail-Version: 0.94.0.0 +OpenPGP: id=82201FC4; + url=http://gpg-keyserver.de +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig73D473C4F4EAA40FB404890A" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/14 +X-Sequence-Number: 18098 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig73D473C4F4EAA40FB404890A +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable + +Stephan Szabo schrieb: + +> Did you reset the table contents between these two (remember that +> explain analyze actually runs the query)? The second appears to be +> changing no rows from the output. + +I for myself did not, but as there are runnig automatic jobs +periodically I can't tell, if one ran in the time while I was testing +(but I guess not). At starting my tests all rows contained a zero for +all tokens and there should be no ones at all. + +In my case rows with token set to one are really rare, about one of a +thousand rows. I looked for fast way to find therse rows. + +I'll try again after a successful run - not resetting the token (not +using analyse this time). + +Cheers, +Jan + + + + +--------------enig73D473C4F4EAA40FB404890A +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.3-cvs (MingW32) +Comment: GnuPT 2.7.6 +Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org + +iD8DBQFEL/nCvvmCkIIgH8QRAn5kAKC2UqgyBKZeH19Ot8htLrJA4kwingCeLTgR +y+PvfErLkni+B6kW5TZ7PeQ= +=JTgs +-----END PGP SIGNATURE----- + +--------------enig73D473C4F4EAA40FB404890A-- + +From pgsql-performance-owner@postgresql.org Sun Apr 2 16:47:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 66A4111F7DAE + for ; + Sun, 2 Apr 2006 16:46:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27534-03 + for ; + Sun, 2 Apr 2006 16:46:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by postgresql.org (Postfix) with ESMTP id 7F7DC11F7D8A + for ; + Sun, 2 Apr 2006 16:46:56 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id E02AA350AD; Sun, 2 Apr 2006 12:46:55 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id DB005350A3; Sun, 2 Apr 2006 12:46:55 -0700 (PDT) +Date: Sun, 2 Apr 2006 12:46:55 -0700 (PDT) +From: Stephan Szabo +To: Jan Kesten +Cc: pgsql-performance@postgresql.org +Subject: Re: index not used again +In-Reply-To: <442FF9C0.2070702@web.de> +Message-ID: <20060402124047.X46838@megazone.bigpanda.com> +References: <442CF375.2080903@web.de> + <20060331064252.J61282@megazone.bigpanda.com> + <442FF9C0.2070702@web.de> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.137 required=5 tests=[AWL=0.137] +X-Spam-Score: 0.137 +X-Spam-Level: +X-Archive-Number: 200604/15 +X-Sequence-Number: 18099 + +On Sun, 2 Apr 2006, Jan Kesten wrote: + +> Stephan Szabo schrieb: +> +> > Did you reset the table contents between these two (remember that +> > explain analyze actually runs the query)? The second appears to be +> > changing no rows from the output. +> +> I for myself did not, but as there are runnig automatic jobs +> periodically I can't tell, if one ran in the time while I was testing +> (but I guess not). At starting my tests all rows contained a zero for +> all tokens and there should be no ones at all. + +The reason I asked is that the explain analyze output for the first query +on fak6 (using a seqscan) seemed to imply 24k rows actually matched the +condition and were updated, so comparisons to the later times may be +skewed. + + +From pgsql-performance-owner@postgresql.org Sun Apr 2 18:11:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 231BA11F695D + for ; + Sun, 2 Apr 2006 18:11:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41906-05 + for ; + Sun, 2 Apr 2006 18:11:10 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id E32E811F68DA + for ; + Sun, 2 Apr 2006 18:11:08 -0300 (ADT) +Received: from alimail.net (potatis.alimail.net [84.19.131.11]) + by svr4.postgresql.org (Postfix) with ESMTP id 363255AF876 + for ; + Sun, 2 Apr 2006 21:11:08 +0000 (GMT) +Received: from [192.168.1.10] ([84.19.128.181]) + by alimail.net (alimail.net [10.1.8.71]) (MDaemon.PRO.v8.0.4.R) + with ESMTP id md50000573591.msg + for ; Sun, 02 Apr 2006 23:09:07 +0200 +In-Reply-To: <20060402083149.GA62166@mail.analytic.mv.ru> +References: <20060402083149.GA62166@mail.analytic.mv.ru> +Mime-Version: 1.0 (Apple Message framework v746.3) +Content-Type: text/plain; charset=UTF-8; delsp=yes; format=flowed +Message-Id: <2EE594DC-5F83-4381-9045-CB2A10180023@tele2.se> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: quoted-printable +From: Niklas Johansson +Subject: Re: Trigger vs Rule +Date: Sun, 2 Apr 2006 23:08:44 +0200 +To: =?UTF-8?B?0JrQu9GO0YfQvdC40LrQvtCyINCQLtChLg==?= +X-Mailer: Apple Mail (2.746.3) +X-Spam-Processed: alimail.net, Sun, 02 Apr 2006 23:09:07 +0200 + (not processed: message from trusted or authenticated source) +X-MDRemoteIP: 84.19.128.181 +X-Return-Path: spot@tele2.se +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +Reply-To: spot@tele2.se +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.455 required=5 tests=[AWL=-0.024, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.455 +X-Spam-Level: +X-Archive-Number: 200604/16 +X-Sequence-Number: 18100 + + +On 2 apr 2006, at 10.31, =D0=9A=D0=BB=D1=8E=D1=87=D0=BD=D0=B8=D0=BA=D0=BE=D0= +=B2 =D0=90.=D0=A1. wrote: +> What is faster? +> One trigger with 1000 ELSE IF +> Or 1000 rules + +Faster to write and easier to maintain would be to write a trigger =20 +function in pl/pgsql which executes the right function dynamically: + +CREATE OR REPLACE FUNCTION exec_device_type() RETURNS trigger AS $$ + EXECUTE "SELECT device_type" || OLD.type || "(OLD.id)"; +$$ LANGUAGE plpgsql; + +Best would probably be to refactor your device_typeN() functions into =20= + +one, that would take N as an argument. + + +Sincerely, + +Niklas Johansson + + + + + +From pgsql-performance-owner@postgresql.org Sun Apr 2 19:30:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5919E11F66EC + for ; + Sun, 2 Apr 2006 19:30:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74476-03 + for ; + Sun, 2 Apr 2006 19:30:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id 4813E11F65C5 + for ; + Sun, 2 Apr 2006 19:30:23 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO + spooky.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9201005 for pgsql-performance@postgresql.org; + Sun, 02 Apr 2006 15:33:22 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Query using SeqScan instead of IndexScan +Date: Sun, 2 Apr 2006 15:30:55 -0700 +User-Agent: KMail/1.8.2 +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <200603292118.50033.josh@agliodbs.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200604021530.55251.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] +X-Spam-Score: 0.104 +X-Spam-Level: +X-Archive-Number: 200604/17 +X-Sequence-Number: 18101 + +Brendan, + +> But just as a follow up question to your #1 suggestion, I have 8 GB +> of ram in my production server. You're saying to set the +> effective_cache_size then to 5 GB roughly? Somewhere around 655360? +> Currently it is set to 65535. Is that something that's OS dependent? +> I'm not sure how much memory my server sets aside for disk caching. + +Yes, about. =C2=A0It's really a judgement call; you're looking for the appr= +oximate=20 +combined RAM available for disk caching and shared mem. =C2=A0However, this= + is=20 +just used as a way of estimating the probability that the data you want is= +=20 +cached in memory, so you're just trying to be order-of-magnitude accurate,= +=20 +not to-the-MB accurate. + +=2D-=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Apr 3 01:20:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3D17311F603C + for ; + Mon, 3 Apr 2006 01:20:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17919-04 + for ; + Mon, 3 Apr 2006 01:20:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id A600111F6006 + for ; + Mon, 3 Apr 2006 01:20:05 -0300 (ADT) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Sun, 2 Apr 2006 22:20:04 -0600 +In-Reply-To: <200604021530.55251.josh@agliodbs.com> +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <200603292118.50033.josh@agliodbs.com> + + <200604021530.55251.josh@agliodbs.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-3-374559521; + protocol="application/pkcs7-signature" +Message-Id: +Cc: pgsql-performance@postgresql.org +From: Brendan Duddridge +Subject: Re: Query using SeqScan instead of IndexScan +Date: Sun, 2 Apr 2006 22:20:00 -0600 +To: Josh Berkus +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] +X-Spam-Score: 0.111 +X-Spam-Level: +X-Archive-Number: 200604/18 +X-Sequence-Number: 18102 + + +--Apple-Mail-3-374559521 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Hi Josh, + +Thanks. I've adjusted my effective_cache_size to 5 GB, so we'll see +how that goes. + +I'm also doing some query and de-normalization optimizations so we'll +see how those go too. + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 2, 2006, at 4:30 PM, Josh Berkus wrote: + +> Brendan, +> +>> But just as a follow up question to your #1 suggestion, I have 8 GB +>> of ram in my production server. You're saying to set the +>> effective_cache_size then to 5 GB roughly? Somewhere around 655360? +>> Currently it is set to 65535. Is that something that's OS dependent? +>> I'm not sure how much memory my server sets aside for disk caching. +> +> Yes, about. It's really a judgement call; you're looking for the +> approximate +> combined RAM available for disk caching and shared mem. However, +> this is +> just used as a way of estimating the probability that the data you +> want is +> cached in memory, so you're just trying to be order-of-magnitude +> accurate, +> not to-the-MB accurate. +> +> -- +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + +--Apple-Mail-3-374559521 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIDCCAtkw +ggJCoAMCAQICAw84ujANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0EwHhcNMDUwNzI5MjAxMTQzWhcNMDYwNzI5MjAxMTQzWjBIMR8wHQYDVQQD +ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSUwIwYJKoZIhvcNAQkBFhZicmVuZGFuQGNsaWNrc3Bh +Y2UuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqWfMCdFgKzXroGNqJuU3eyDC +K/Gxts3mtmIdgcHGmUjRKdlBSfkmcCBUDPJIt4QQc91sY3h8Itg0EAsF+1yFECU6afn/1SEAHSDK +6Q86PclF58/Dux2FYNGpeIAw/lisZ2UCyIYoUiWtEDKCBq5jDuYzcGkFS5Csz+/rEL+BHTXQVqnS +nUdUaXu9xdZn4wgjB/n65UEYRqr0LGN53CGsFcA9uC+ViS7WyBtzJcP02LMNT+cAZ7TKHw4Q/ZeG +5ptPgQHLTD2wza3GMbPQ4fYK6aNPA+lVzslLSCjyQpg55gVyQQlV0k/5zU5Q5m48ZtqwOqN+fPYd +eIB7H5y1SFLd/wIDAQABozMwMTAhBgNVHREEGjAYgRZicmVuZGFuQGNsaWNrc3BhY2UuY29tMAwG +A1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEEBQADgYEAT+6hGvStHoRO0OCHlJev31BpUlvPSpbYVKJN +i5kCMF164sSX7j0IRvcyU6DfUuW7samTluXJbANyuX1ZIpXulGen5EEc2NV7eU/rMz6ExklMShTh +++azcvmMjOzTuqXi3ZsIjwzBBhqCB0U++kYlMlHEYla2qKLFbXY6PiH0a8swggM/MIICqKADAgEC +AgENMA0GCSqGSIb3DQEBBQUAMIHRMQswCQYDVQQGEwJaQTEVMBMGA1UECBMMV2VzdGVybiBDYXBl +MRIwEAYDVQQHEwlDYXBlIFRvd24xGjAYBgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQL +Ex9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMSQwIgYDVQQDExtUaGF3dGUgUGVyc29u +YWwgRnJlZW1haWwgQ0ExKzApBgkqhkiG9w0BCQEWHHBlcnNvbmFsLWZyZWVtYWlsQHRoYXd0ZS5j +b20wHhcNMDMwNzE3MDAwMDAwWhcNMTMwNzE2MjM1OTU5WjBiMQswCQYDVQQGEwJaQTElMCMGA1UE +ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFs +IEZyZWVtYWlsIElzc3VpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMSmPFVzVftO +ucqZWh5owHUEcJ3f6f+jHuy9zfVb8hp2vX8MOmHyv1HOAdTlUAow1wJjWiyJFXCO3cnwK4Vaqj9x +VsuvPAsH5/EfkTYkKhPPK9Xzgnc9A74r/rsYPge/QIACZNenprufZdHFKlSFD0gEf6e20TxhBEAe +ZBlyYLf7AgMBAAGjgZQwgZEwEgYDVR0TAQH/BAgwBgEB/wIBADBDBgNVHR8EPDA6MDigNqA0hjJo +dHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhhd3RlUGVyc29uYWxGcmVlbWFpbENBLmNybDALBgNVHQ8E +BAMCAQYwKQYDVR0RBCIwIKQeMBwxGjAYBgNVBAMTEVByaXZhdGVMYWJlbDItMTM4MA0GCSqGSIb3 +DQEBBQUAA4GBAEiM0VCD6gsuzA2jZqxnD3+vrL7CF6FDlpSdf0whuPg2H6otnzYvwPQcUCCTcDz9 +reFhYsPZOhl+hLGZGwDFGguCdJ4lUJRix9sncVcljd2pnDmOjCBPZV+V2vf3h9bGCE6u9uo05RAa +WzVNd+NWIXiC3CEZNd4ksdMdRv9dX2VPMYIC5zCCAuMCAQEwaTBiMQswCQYDVQQGEwJaQTElMCMG +A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv +bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujAJBgUrDgMCGgUAoIIBUzAYBgkqhkiG9w0BCQMx +CwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA0MDMwNDIwMDBaMCMGCSqGSIb3DQEJBDEW +BBQQ5rrFzGdyBsXH2zeRYgZreZshCzB4BgkrBgEEAYI3EAQxazBpMGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDDzi6MHoGCyqGSIb3DQEJEAILMWugaTBiMQswCQYD +VQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMj +VGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujANBgkqhkiG9w0BAQEFAASC +AQBU4mDIh04Sob1vYa+mxjP0LDZW9+rH3gkiZkNlyVa2fKK34/Ik0HsGJOaF6fkrxqIxliJRj17j +rHAZj/FD8bqK/Eo9DwKWx4Naphl6IcnlQELWrtETWiqdTSjGTziRxp70oIp1priNVzuiweNExD+D ++KKV5RbjgyFKt1LdfiNRmPhKg07yi0MX/i00WrWh+uEeS5m0RMrvB4YgQ/D0RSH4JG3SpWt5z0vI +SWQUlvBRDEVgXYfwocoNqF9ZdPTPR8kn9QnhuZA/1FMHoZWE7vDFqatcqEPy2rrbUQHC1HLFNmGb +LAVB509sFVaIq589qcZLMPLK5OvkS5spk/1VJHs7AAAAAAAA + +--Apple-Mail-3-374559521-- + + +From pgsql-performance-owner@postgresql.org Mon Apr 3 06:04:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1ED6511F7DEF + for ; + Mon, 3 Apr 2006 06:04:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57626-05 + for ; + Mon, 3 Apr 2006 06:04:49 -0300 (ADT) +X-Greylist: delayed 11:53:42.222369 by SQLgrey- +Received: from alimail.net (potatis.alimail.net [84.19.131.11]) + by postgresql.org (Postfix) with ESMTP id 0C41611F72A6 + for ; + Mon, 3 Apr 2006 06:04:47 -0300 (ADT) +Received: from [192.168.1.10] ([84.19.128.181]) + by alimail.net (alimail.net [10.1.8.71]) (MDaemon.PRO.v8.0.4.R) + with ESMTP id md50000574296.msg + for ; Mon, 03 Apr 2006 11:04:49 +0200 +In-Reply-To: <2EE594DC-5F83-4381-9045-CB2A10180023@tele2.se> +References: <20060402083149.GA62166@mail.analytic.mv.ru> + <2EE594DC-5F83-4381-9045-CB2A10180023@tele2.se> +Mime-Version: 1.0 (Apple Message framework v746.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <5DEF8AEF-9FBD-4C6E-88BD-FA90CB1BDF31@tele2.se> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Niklas Johansson +Subject: Re: Trigger vs Rule +Date: Mon, 3 Apr 2006 11:04:25 +0200 +To: =?UTF-8?B?ItCa0LvRjtGH0L3QuNC60L7QsiDQkC7QoS4i?= +X-Mailer: Apple Mail (2.746.3) +X-Spam-Processed: alimail.net, Mon, 03 Apr 2006 11:04:49 +0200 + (not processed: message from trusted or authenticated source) +X-MDRemoteIP: 84.19.128.181 +X-Return-Path: spot@tele2.se +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +Reply-To: spot@tele2.se +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.459 required=5 tests=[AWL=-0.020, + DNS_FROM_RFC_ABUSE=0.479, UPPERCASE_25_50=0] +X-Spam-Score: 0.459 +X-Spam-Level: +X-Archive-Number: 200604/19 +X-Sequence-Number: 18103 + + +On 2 apr 2006, at 23.08, Niklas Johansson wrote: + +> CREATE OR REPLACE FUNCTION exec_device_type() RETURNS trigger AS $$ +> EXECUTE "SELECT device_type" || OLD.type || "(OLD.id)"; +> $$ LANGUAGE plpgsql; + + +Sorry, I was bitten by the bedbug there: a plpgsql function needs a +little more than that to be functional :) + +CREATE OR REPLACE FUNCTION exec_device_type() RETURNS trigger AS $$ +BEGIN + EXECUTE 'SELECT device_type' || OLD.type || '(OLD.id)'; + RETURN NEW/OLD/NULL; -- Depending on your application. +END; +$$ LANGUAGE plpgsql; + +But really, you should consider reworking your schema structure. +Having a thousand functions doing almost the same thing is neither +efficient, nor maintainable. + + + +Sincerely, + +Niklas Johansson + + + + + +From pgsql-performance-owner@postgresql.org Mon Apr 3 06:17:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9384A11F8AE5 + for ; + Mon, 3 Apr 2006 06:17:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60366-03 + for ; + Mon, 3 Apr 2006 06:17:44 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 3456711F8A4A + for ; + Mon, 3 Apr 2006 06:17:43 -0300 (ADT) +Received: from analytic.local (analytic.yun5.7winds.ru [81.176.142.130]) + by svr4.postgresql.org (Postfix) with ESMTP id 057EC5AF88D + for ; + Mon, 3 Apr 2006 09:17:42 +0000 (GMT) +Received: from analytic.local (localhost [127.0.0.1]) + by analytic.local (8.13.6/8.13.4) with ESMTP id k339HaTY001293 + for ; + Mon, 3 Apr 2006 13:17:36 +0400 (MSD) + (envelope-from alexs@analytic.local) +Received: (from alexs@localhost) + by analytic.local (8.13.6/8.13.1/Submit) id k339HaXU001292 + for pgsql-performance@postgresql.org; + Mon, 3 Apr 2006 13:17:36 +0400 (MSD) (envelope-from alexs) +Date: Mon, 3 Apr 2006 13:17:36 +0400 +From: =?utf-8?B?0JrQu9GO0YfQvdC40LrQvtCyINCQLtChLg==?= +To: pgsql-performance@postgresql.org +Subject: Re: Trigger vs Rule +Message-ID: <20060403091736.GB366@mail.analytic.mv.ru> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20060402083149.GA62166@mail.analytic.mv.ru> + <2EE594DC-5F83-4381-9045-CB2A10180023@tele2.se> + <5DEF8AEF-9FBD-4C6E-88BD-FA90CB1BDF31@tele2.se> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <5DEF8AEF-9FBD-4C6E-88BD-FA90CB1BDF31@tele2.se> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/20 +X-Sequence-Number: 18104 + +* Niklas Johansson [2006-04-03 11:04:25 +0200]: + +> +> On 2 apr 2006, at 23.08, Niklas Johansson wrote: +> +> >CREATE OR REPLACE FUNCTION exec_device_type() RETURNS trigger AS $$ +> > EXECUTE "SELECT device_type" || OLD.type || "(OLD.id)"; +> >$$ LANGUAGE plpgsql; +> +> +> Sorry, I was bitten by the bedbug there: a plpgsql function needs a +> little more than that to be functional :) +> +> CREATE OR REPLACE FUNCTION exec_device_type() RETURNS trigger AS $$ +> BEGIN +> EXECUTE 'SELECT device_type' || OLD.type || '(OLD.id)'; +> RETURN NEW/OLD/NULL; -- Depending on your application. +> END; +> $$ LANGUAGE plpgsql; +> +> But really, you should consider reworking your schema structure. +> Having a thousand functions doing almost the same thing is neither +> efficient, nor maintainable. +Things are very diferent. +For many types functions not needed, jast update. + +I.e. This is a way One trigger with ~1000 else if. +Here was a diametral opinion. +> +> +> +> Sincerely, +> +> Niklas Johansson +> +> +> +> + +-- +С уважением, +Ключников А.С. +Ведущий инженер ПРП "Аналитприбор" +432030 г.Ульяновск, а/я 3117 +тел./факс +7 (8422) 43-44-78 +mailto: alexs@analytic.mv.ru + +From pgsql-performance-owner@postgresql.org Mon Apr 3 06:42:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7232B11F8CDF + for ; + Mon, 3 Apr 2006 06:42:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64099-02 + for ; + Mon, 3 Apr 2006 06:42:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) + by postgresql.org (Postfix) with ESMTP id 70F6911F8CDD + for ; + Mon, 3 Apr 2006 06:42:25 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by pjetlic.mobart.hr (Postfix) with ESMTP id C020317ABF + for ; + Mon, 3 Apr 2006 11:42:23 +0200 (CEST) +Received: from pjetlic.mobart.hr ([127.0.0.1]) + by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 21431-04-2 for ; + Mon, 3 Apr 2006 11:42:23 +0200 (CEST) +Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by pjetlic.mobart.hr (Postfix) with ESMTP id A86A617ABA + for ; + Mon, 3 Apr 2006 11:42:23 +0200 (CEST) +Subject: Measuring the execution time of functions within functions... +From: Mario Splivalo +Reply-To: mario.splivalo@mobart.hr +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: Mob-Art +Date: Mon, 03 Apr 2006 11:42:19 +0200 +Message-Id: <1144057339.20123.18.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by OpenSource AV+AS Mail Server +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.136 required=5 tests=[AWL=0.136] +X-Spam-Score: 0.136 +X-Spam-Level: +X-Archive-Number: 200604/21 +X-Sequence-Number: 18105 + +I have asked this before, but haven't noticed any response, so if there +were any, I appologize for asking this again... + +I have a function that is called by middle-tier (java trough JDBC), and +in postgres log I can see only the execution time of that function. I +have no idea how long are functions insde taking time to execute. + +Since the function is written in plpgsql I tried to calculate the +durations by using now() function, but realized that within the +transaction now() always retunrs the same value. + +The good thing is that those RAISE NOTICE calls from within my function +are logged as they're encountered, so, with carefully placed RAISE +NOTICE calls I could see how much time are the -inside- functions +taking. + +For instance: + +CREATE FUNCTION test_outer() RETURNS void +AS +$$BODY$$BEGIN + RAISE NOTICE 'We start here' + PERFORM SELECT someInternalFunction1(); + RAISE NOTICE 'InternalFunction1 is done now.'; + PERFORM SELECT someInternalFunction2(); + RAISE NOTICE 'InternalFunction2 is done now.'; + -- ... more code here +END$$BODY$$ +LANGUAGE 'plpgsql' + +Is there any other, maybe more convinient way to measure the 'inside' +function performance? I also have a problem if the outer function is +written in SQL, like this, for instance: + +CREATE FUNCTION getSomeData(param1, param2, param3) +RETURN SETOF someType +AS +$$BODY$$SELECT + * +FROM + someTable + JOIN someOtherFunction($1, $2, $3) ON someTable.col = +someOtherFunction.col +WHERE + someCondition +$$BODY$$ +LANGUAGE 'sql'. + +Thank you in advance, + + Mario +-- +Mario Splivalo +Mob-Art +mario.splivalo@mobart.hr + +"I can do it quick, I can do it cheap, I can do it well. Pick any two." + + + +From pgsql-performance-owner@postgresql.org Mon Apr 3 09:50:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DF09211F6D4D + for ; + Mon, 3 Apr 2006 09:50:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92312-02 + for ; + Mon, 3 Apr 2006 09:50:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by postgresql.org (Postfix) with ESMTP id 4605A11F6D1A + for ; + Mon, 3 Apr 2006 09:50:50 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx2.surnet.cl with ESMTP; 03 Apr 2006 08:50:48 -0400 +X-IronPort-AV: i="4.02,198,1139194800"; + d="scan'208"; a="40448668:sNHT19922984" +Received: from alvh.no-ip.org (201.220.123.224) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD00D241B3; Mon, 3 Apr 2006 08:50:48 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 0CE23C2DC4F; Mon, 3 Apr 2006 08:50:48 -0400 (CLT) +Date: Mon, 3 Apr 2006 08:50:47 -0400 +From: Alvaro Herrera +To: Mario Splivalo +Cc: pgsql-performance@postgresql.org +Subject: Re: Measuring the execution time of functions within functions... +Message-ID: <20060403125047.GA7276@surnet.cl> +Mail-Followup-To: Mario Splivalo , + pgsql-performance@postgresql.org +References: <1144057339.20123.18.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1144057339.20123.18.camel@localhost.localdomain> +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.732 required=5 tests=[AWL=0.732] +X-Spam-Score: 0.732 +X-Spam-Level: +X-Archive-Number: 200604/22 +X-Sequence-Number: 18106 + +Mario Splivalo wrote: + +> Since the function is written in plpgsql I tried to calculate the +> durations by using now() function, but realized that within the +> transaction now() always retunrs the same value. + +Maybe you can use timeofday(). + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +PostgreSQL Replication, Consulting, Custom Development, 24x7 support + +From pgsql-performance-owner@postgresql.org Mon Apr 3 13:32:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C5D1911F693D + for ; + Mon, 3 Apr 2006 13:32:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25677-10 + for ; + Mon, 3 Apr 2006 13:32:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from prod01.jerrysievers.com (adsl-64-118-249-70.netrox.net + [64.118.249.70]) + by postgresql.org (Postfix) with ESMTP id BBA0711F696C + for ; + Mon, 3 Apr 2006 13:32:23 -0300 (ADT) +Received: (from gsievers@localhost) + by prod01.jerrysievers.com (8.11.0/8.11.0) id k33GWAr10633; + Mon, 3 Apr 2006 12:32:10 -0400 +To: mario.splivalo@mobart.hr +Cc: pgsql-performance@postgresql.org +Subject: Re: Measuring the execution time of functions within functions... +References: <1144057339.20123.18.camel@localhost.localdomain> +From: Jerry Sievers +Date: 03 Apr 2006 12:32:09 -0400 +In-Reply-To: Mario Splivalo's message of "Mon, 03 Apr 2006 11:42:19 +0200" +Message-ID: +Lines: 46 +X-Mailer: Gnus v5.7/Emacs 20.7 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.094 required=5 tests=[AWL=0.094] +X-Spam-Score: 0.094 +X-Spam-Level: +X-Archive-Number: 200604/23 +X-Sequence-Number: 18107 + +Mario Splivalo writes: + +> I have asked this before, but haven't noticed any response, so if there +> were any, I appologize for asking this again... +> +> I have a function that is called by middle-tier (java trough JDBC), and +> in postgres log I can see only the execution time of that function. I +> have no idea how long are functions insde taking time to execute. +> +> Since the function is written in plpgsql I tried to calculate the +> durations by using now() function, but realized that within the +> transaction now() always retunrs the same value. +> +> The good thing is that those RAISE NOTICE calls from within my function +> are logged as they're encountered, so, with carefully placed RAISE +> NOTICE calls I could see how much time are the -inside- functions +> taking. +> +> For instance: +> +> CREATE FUNCTION test_outer() RETURNS void +> AS +> $$BODY$$BEGIN +> RAISE NOTICE 'We start here' +> PERFORM SELECT someInternalFunction1(); +> RAISE NOTICE 'InternalFunction1 is done now.'; +> PERFORM SELECT someInternalFunction2(); +> RAISE NOTICE 'InternalFunction2 is done now.'; +> -- ... more code here +> END$$BODY$$ +> LANGUAGE 'plpgsql' +> +> Is there any other, maybe more convinient way to measure the 'inside' +> function performance? I also have a problem if the outer function is +> written in SQL, like this, for instance: + +See the timeofday() func which returns the actual time and is not +frozen in the current transaction. You'll need to cast it to +timestamp or other if wishing to do time arithmetic deltas on it. + +HTH + +-- +------------------------------------------------------------------------------- +Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant + 305 321-1144 (mobile http://www.JerrySievers.com/ + +From pgsql-performance-owner@postgresql.org Mon Apr 3 15:24:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CAFE311F626F + for ; + Mon, 3 Apr 2006 15:24:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51551-06 + for ; + Mon, 3 Apr 2006 15:24:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from colo-dns-ext1.juniper.net (colo-dns-ext1.juniper.net + [207.17.137.57]) + by postgresql.org (Postfix) with ESMTP id D65BE11F6243 + for ; + Mon, 3 Apr 2006 15:24:10 -0300 (ADT) +Received: from merlot.juniper.net (merlot.juniper.net [172.17.27.10]) + by colo-dns-ext1.juniper.net (8.11.3/8.9.3) with ESMTP id k33IO9X91861 + for ; + Mon, 3 Apr 2006 11:24:09 -0700 (PDT) + (envelope-from kenjim@juniper.net) +Received: from kenjim-lnx.juniper.net (kenjim-lnx.juniper.net [172.17.58.60]) + by merlot.juniper.net (8.11.3/8.11.3) with ESMTP id k33IO4501008; + Mon, 3 Apr 2006 11:24:04 -0700 (PDT) + (envelope-from kenjim@juniper.net) +Received: from kenjim-lnx.juniper.net (kenjim-lnx.juniper.net [127.0.0.1]) + by kenjim-lnx.juniper.net (8.13.4/8.13.4) with ESMTP id k33IO4iL012811; + Mon, 3 Apr 2006 11:24:04 -0700 +Received: (from kenjim@localhost) + by kenjim-lnx.juniper.net (8.13.4/8.13.4/Submit) id k33IO3pm012810; + Mon, 3 Apr 2006 11:24:03 -0700 +Date: Mon, 3 Apr 2006 11:24:03 -0700 +From: Kenji Morishige +To: pgsql-performance@postgresql.org +Cc: kenjim@juniper.net +Subject: optimizing db for small table with tons of updates +Message-ID: <20060403182403.GA12257@juniper.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/24 +X-Sequence-Number: 18108 + +I am using postgresql to be the central database for a variety of tools for +our testing infrastructure. We have web tools and CLI tools that require access +to machine configuration and other states for automation. We have one tool that +uses a table that looks like this: + +systest_live=# \d cuty + Table "public.cuty" + Column | Type | Modifiers +-------------+--------------------------+----------- + resource_id | integer | not null + lock_start | timestamp with time zone | + lock_by | character varying(12) | + frozen | timestamp with time zone | + freeze_end | timestamp with time zone | + freeze_by | character varying(12) | + state | character varying(15) | +Indexes: + "cuty_pkey" PRIMARY KEY, btree (resource_id) + "cuty_main_idx" btree (resource_id, lock_start) +Foreign-key constraints: + "cuty_resource_id_fkey" FOREIGN KEY (resource_id) REFERENCES resource(resource_id) ON UPDATE CASCADE ON DELETE CASCADE + +Various users run a tool that updates this table to determine if the particular +resource is available or not. Within a course of a few days, this table can +be updated up to 200,000 times. There are only about 3500 records in this +table, but the update and select queries against this table start to slow +down considerablly after a few days. Ideally, this table doesn't even need +to be stored and written to the filesystem. After I run a vacuum against this +table, the overall database performance seems to rise again. When database +is running with recent vacuum the average server load is about .40, but after +this table is updated 200,000+ times, the server load can go up to 5.0. + +here is a typical update query: +2006-04-03 10:53:39 PDT testtool systest_live kyoto.englab.juniper.net(4888) LOG: duration: 2263.741 ms statement: UPDATE cuty SET + lock_start = NOW(), + lock_by = 'tlim' + WHERE resource_id='2262' and (lock_start IS NULL OR lock_start < (NOW() - interval '3600 second')) + +We used to use MySQL for these tools and we never had any issues, but I believe +it is due to the transactional nature of Postgres that is adding an overhead +to this problem. Are there any table options that enables the table contents +to be maintained in ram only or have delayed writes for this particular table? + +Thanks in advance, +Kenji + +From pgsql-performance-owner@postgresql.org Mon Apr 3 15:31:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B3FE611F6608 + for ; + Mon, 3 Apr 2006 15:31:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53865-04 + for ; + Mon, 3 Apr 2006 15:31:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id 1E4F611F65D9 + for ; + Mon, 3 Apr 2006 15:31:15 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO [192.168.1.27]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9204925; Mon, 03 Apr 2006 11:34:14 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: optimizing db for small table with tons of updates +Date: Mon, 3 Apr 2006 11:29:42 -0700 +User-Agent: KMail/1.8 +Cc: Kenji Morishige +References: <20060403182403.GA12257@juniper.net> +In-Reply-To: <20060403182403.GA12257@juniper.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200604031129.42194.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.081 required=5 tests=[AWL=0.081] +X-Spam-Score: 0.081 +X-Spam-Level: +X-Archive-Number: 200604/25 +X-Sequence-Number: 18109 + +Kenji, + +> We used to use MySQL for these tools and we never had any issues, but I +> believe it is due to the transactional nature of Postgres that is adding +> an overhead to this problem. =A0 + +You're correct. + +> Are there any table options that enables=20 +> the table contents to be maintained in ram only or have delayed writes +> for this particular table? + +No. That's not really the right solution anyway; if you want=20 +non-transactional data, why not just use a flat file? Or Memcached? + +Possible solutions: +1) if the data is non-transactional, consider using pgmemcached. +2) if you want to maintain transactions, use a combination of autovacuum=20 +and vacuum delay to do more-or-less continuous low-level vacuuming of the=20 +table. Using Postgres 8.1 will help you to be able to manage this. + +=2D-=20 +=2D-Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Apr 3 15:36:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D8B7911F6614 + for ; + Mon, 3 Apr 2006 15:36:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53378-10 + for ; + Mon, 3 Apr 2006 15:36:49 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.191]) + by postgresql.org (Postfix) with ESMTP id F3A0011F6611 + for ; + Mon, 3 Apr 2006 15:36:47 -0300 (ADT) +Received: by nproxy.gmail.com with SMTP id g2so1191470nfe + for ; + Mon, 03 Apr 2006 11:36:46 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=muStpgAY7LP5y7gdsXiW85b0hd4crws4cIub5kDrH8jY4C49fgozJtG/FZNyKaqIxEn0mJHI8422Dbty5awA7DPjLPbOhV6FjqirVFldk6z8XQEKwYdYLjB4eksGBanS7wP76xpk6ptWAjPph+m49/po5VwK+lis55DMxh0DSgY= +Received: by 10.48.212.13 with SMTP id k13mr1602914nfg; + Mon, 03 Apr 2006 11:36:45 -0700 (PDT) +Received: by 10.49.26.20 with HTTP; Mon, 3 Apr 2006 11:36:45 -0700 (PDT) +Message-ID: +Date: Tue, 4 Apr 2006 00:06:45 +0530 +From: "Rajesh Kumar Mallah" +To: "Kenji Morishige" +Subject: Re: optimizing db for small table with tons of updates +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060403182403.GA12257@juniper.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <20060403182403.GA12257@juniper.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.141 required=5 tests=[AWL=-0.191, + RCVD_IN_BL_SPAMCOP_NET=1.332] +X-Spam-Score: 1.141 +X-Spam-Level: * +X-Archive-Number: 200604/26 +X-Sequence-Number: 18110 + +Dear Kenji, + +we had similar issuse with a banner impression update system, +that had high concurrency. we modfied the system to use insert +instead of update of the same row. performance wise things are +much better , but you have to keep deleting old data. + +hope you extrapolate what i mean if its applicable to your case. + +Regds +Rajesh Kumar Mallah + +On 4/3/06, Kenji Morishige wrote: +> I am using postgresql to be the central database for a variety of tools f= +or +> our testing infrastructure. We have web tools and CLI tools that require = +access +> to machine configuration and other states for automation. We have one to= +ol that +> uses a table that looks like this: +> +> systest_live=3D# \d cuty +> Table "public.cuty" +> Column | Type | Modifiers +> -------------+--------------------------+----------- +> resource_id | integer | not null +> lock_start | timestamp with time zone | +> lock_by | character varying(12) | +> frozen | timestamp with time zone | +> freeze_end | timestamp with time zone | +> freeze_by | character varying(12) | +> state | character varying(15) | +> Indexes: +> "cuty_pkey" PRIMARY KEY, btree (resource_id) +> "cuty_main_idx" btree (resource_id, lock_start) +> Foreign-key constraints: +> "cuty_resource_id_fkey" FOREIGN KEY (resource_id) REFERENCES resource= +(resource_id) ON UPDATE CASCADE ON DELETE CASCADE +> +> Various users run a tool that updates this table to determine if the part= +icular +> resource is available or not. Within a course of a few days, this table = +can +> be updated up to 200,000 times. There are only about 3500 records in thi= +s +> table, but the update and select queries against this table start to slow +> down considerablly after a few days. Ideally, this table doesn't even ne= +ed +> to be stored and written to the filesystem. After I run a vacuum against= + this +> table, the overall database performance seems to rise again. When databa= +se +> is running with recent vacuum the average server load is about .40, but a= +fter +> this table is updated 200,000+ times, the server load can go up to 5.0. +> +> here is a typical update query: +> 2006-04-03 10:53:39 PDT testtool systest_live kyoto.englab.juniper.net(48= +88) LOG: duration: 2263.741 ms statement: UPDATE cuty SET +> lock_start =3D NOW(), +> lock_by =3D 'tlim' +> WHERE resource_id=3D'2262' and (lock_start IS NULL OR lock_start = +< (NOW() - interval '3600 second')) +> +> We used to use MySQL for these tools and we never had any issues, but I b= +elieve +> it is due to the transactional nature of Postgres that is adding an overh= +ead +> to this problem. Are there any table options that enables the table cont= +ents +> to be maintained in ram only or have delayed writes for this particular t= +able? +> +> Thanks in advance, +> Kenji +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + +From pgsql-performance-owner@postgresql.org Mon Apr 3 15:39:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2AF6411F6C47 + for ; + Mon, 3 Apr 2006 15:39:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59219-02 + for ; + Mon, 3 Apr 2006 15:39:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id A683311F6C35 + for ; + Mon, 3 Apr 2006 15:39:11 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k33IdA8L015522; + Mon, 3 Apr 2006 14:39:10 -0400 (EDT) +To: Kenji Morishige +cc: pgsql-performance@postgresql.org +Subject: Re: optimizing db for small table with tons of updates +In-reply-to: <20060403182403.GA12257@juniper.net> +References: <20060403182403.GA12257@juniper.net> +Comments: In-reply-to Kenji Morishige + message dated "Mon, 03 Apr 2006 11:24:03 -0700" +Date: Mon, 03 Apr 2006 14:39:10 -0400 +Message-ID: <15521.1144089550@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] +X-Spam-Score: 0.114 +X-Spam-Level: +X-Archive-Number: 200604/27 +X-Sequence-Number: 18111 + +Kenji Morishige writes: +> Various users run a tool that updates this table to determine if the particular +> resource is available or not. Within a course of a few days, this table can +> be updated up to 200,000 times. There are only about 3500 records in this +> table, but the update and select queries against this table start to slow +> down considerablly after a few days. Ideally, this table doesn't even need +> to be stored and written to the filesystem. After I run a vacuum against this +> table, the overall database performance seems to rise again. + +You should never have let such a table go that long without vacuuming. + +You might consider using autovac to take care of it for you. If you +don't want to use autovac, set up a cron job that will vacuum the table +at least once per every few thousand updates. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 3 16:02:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AF8D211F6625 + for ; + Mon, 3 Apr 2006 16:02:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62728-04 + for ; + Mon, 3 Apr 2006 16:02:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from colo-dns-ext1.juniper.net (colo-dns-ext1.juniper.net + [207.17.137.57]) + by postgresql.org (Postfix) with ESMTP id A88DE11F65EC + for ; + Mon, 3 Apr 2006 16:02:19 -0300 (ADT) +Received: from merlot.juniper.net (merlot.juniper.net [172.17.27.10]) + by colo-dns-ext1.juniper.net (8.11.3/8.9.3) with ESMTP id k33J2IX92457; + Mon, 3 Apr 2006 12:02:18 -0700 (PDT) + (envelope-from kenjim@juniper.net) +Received: from kenjim-lnx.juniper.net (kenjim-lnx.juniper.net [172.17.58.60]) + by merlot.juniper.net (8.11.3/8.11.3) with ESMTP id k33J2D510489; + Mon, 3 Apr 2006 12:02:13 -0700 (PDT) + (envelope-from kenjim@juniper.net) +Received: from kenjim-lnx.juniper.net (kenjim-lnx.juniper.net [127.0.0.1]) + by kenjim-lnx.juniper.net (8.13.4/8.13.4) with ESMTP id k33J2D5Z014436; + Mon, 3 Apr 2006 12:02:13 -0700 +Received: (from kenjim@localhost) + by kenjim-lnx.juniper.net (8.13.4/8.13.4/Submit) id k33J2D7C014435; + Mon, 3 Apr 2006 12:02:13 -0700 +Date: Mon, 3 Apr 2006 12:02:13 -0700 +From: Kenji Morishige +To: Tom Lane +Cc: pgsql-performance@postgresql.org, kenjim@juniper.net +Subject: Re: optimizing db for small table with tons of updates +Message-ID: <20060403190213.GA14328@juniper.net> +References: <20060403182403.GA12257@juniper.net> + <15521.1144089550@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <15521.1144089550@sss.pgh.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/28 +X-Sequence-Number: 18112 + +I've been stumped as to how to call psql from the command line without it +prompting me for a password. Is there a enviornoment variable I can specify for +the password or something I can place in .pgsql? I could write a perl wrapper +around it, but I've been wondering how I can call psql -c without it prompting +me. Is it possible? + +-Kenji + +On Mon, Apr 03, 2006 at 02:39:10PM -0400, Tom Lane wrote: +> Kenji Morishige writes: +> > Various users run a tool that updates this table to determine if the particular +> > resource is available or not. Within a course of a few days, this table can +> > be updated up to 200,000 times. There are only about 3500 records in this +> > table, but the update and select queries against this table start to slow +> > down considerablly after a few days. Ideally, this table doesn't even need +> > to be stored and written to the filesystem. After I run a vacuum against this +> > table, the overall database performance seems to rise again. +> +> You should never have let such a table go that long without vacuuming. +> +> You might consider using autovac to take care of it for you. If you +> don't want to use autovac, set up a cron job that will vacuum the table +> at least once per every few thousand updates. +> +> regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 3 16:04:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7F69C11F66D3 + for ; + Mon, 3 Apr 2006 16:03:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61976-07 + for ; + Mon, 3 Apr 2006 16:03:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by postgresql.org (Postfix) with ESMTP id 0E6A111F65F8 + for ; + Mon, 3 Apr 2006 16:03:55 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx2.surnet.cl with ESMTP; 03 Apr 2006 15:03:54 -0400 +X-IronPort-AV: i="4.02,198,1139194800"; + d="scan'208"; a="40533745:sNHT18984012" +Received: from alvh.no-ip.org (201.220.123.224) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD00D31E23; Mon, 3 Apr 2006 15:03:54 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 51C25C2DC4F; Mon, 3 Apr 2006 15:03:54 -0400 (CLT) +Date: Mon, 3 Apr 2006 15:03:54 -0400 +From: Alvaro Herrera +To: Kenji Morishige +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: optimizing db for small table with tons of updates +Message-ID: <20060403190354.GC15756@surnet.cl> +Mail-Followup-To: Kenji Morishige , + Tom Lane , pgsql-performance@postgresql.org +References: <20060403182403.GA12257@juniper.net> + <15521.1144089550@sss.pgh.pa.us> + <20060403190213.GA14328@juniper.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060403190213.GA14328@juniper.net> +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.689 required=5 tests=[AWL=-0.230, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +X-Spam-Score: 1.689 +X-Spam-Level: * +X-Archive-Number: 200604/29 +X-Sequence-Number: 18113 + +Kenji Morishige wrote: +> I've been stumped as to how to call psql from the command line without it +> prompting me for a password. Is there a enviornoment variable I can specify for +> the password or something I can place in .pgsql? I could write a perl wrapper +> around it, but I've been wondering how I can call psql -c without it prompting +> me. Is it possible? + +Sure it is. Set up a .pgpass file. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Mon Apr 3 16:08:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 49D0711F65F8 + for ; + Mon, 3 Apr 2006 16:08:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62654-09 + for ; + Mon, 3 Apr 2006 16:08:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from colo-dns-ext2.juniper.net (colo-dns-ext2.juniper.net + [207.17.137.64]) + by postgresql.org (Postfix) with ESMTP id 294F011F6614 + for ; + Mon, 3 Apr 2006 16:08:37 -0300 (ADT) +Received: from merlot.juniper.net (merlot.juniper.net [172.17.27.10]) + by colo-dns-ext2.juniper.net (8.12.3/8.12.3) with ESMTP id + k33J8a1Z080578; Mon, 3 Apr 2006 12:08:36 -0700 (PDT) + (envelope-from kenjim@juniper.net) +Received: from kenjim-lnx.juniper.net (kenjim-lnx.juniper.net [172.17.58.60]) + by merlot.juniper.net (8.11.3/8.11.3) with ESMTP id k33J8a511624; + Mon, 3 Apr 2006 12:08:36 -0700 (PDT) + (envelope-from kenjim@juniper.net) +Received: from kenjim-lnx.juniper.net (kenjim-lnx.juniper.net [127.0.0.1]) + by kenjim-lnx.juniper.net (8.13.4/8.13.4) with ESMTP id k33J8avl014699; + Mon, 3 Apr 2006 12:08:36 -0700 +Received: (from kenjim@localhost) + by kenjim-lnx.juniper.net (8.13.4/8.13.4/Submit) id k33J8ajO014698; + Mon, 3 Apr 2006 12:08:36 -0700 +Date: Mon, 3 Apr 2006 12:08:36 -0700 +From: Kenji Morishige +To: Tom Lane , pgsql-performance@postgresql.org +Cc: kenjim@juniper.net +Subject: Re: optimizing db for small table with tons of updates +Message-ID: <20060403190836.GB14328@juniper.net> +References: <20060403182403.GA12257@juniper.net> + <15521.1144089550@sss.pgh.pa.us> + <20060403190213.GA14328@juniper.net> + <20060403190354.GC15756@surnet.cl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060403190354.GC15756@surnet.cl> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/30 +X-Sequence-Number: 18114 + +Sweet! Thanks. +-Kenji + +On Mon, Apr 03, 2006 at 03:03:54PM -0400, Alvaro Herrera wrote: +> Kenji Morishige wrote: +> > I've been stumped as to how to call psql from the command line without it +> > prompting me for a password. Is there a enviornoment variable I can specify for +> > the password or something I can place in .pgsql? I could write a perl wrapper +> > around it, but I've been wondering how I can call psql -c without it prompting +> > me. Is it possible? +> +> Sure it is. Set up a .pgpass file. +> +> -- +> Alvaro Herrera http://www.CommandPrompt.com/ +> The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Mon Apr 3 16:23:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 315E011F6625 + for ; + Mon, 3 Apr 2006 16:23:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64578-07 + for ; + Mon, 3 Apr 2006 16:23:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 1200311F60A9 + for ; + Mon, 3 Apr 2006 16:23:52 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k33JNo2k015872; + Mon, 3 Apr 2006 15:23:50 -0400 (EDT) +To: Alvaro Herrera +cc: Kenji Morishige , pgsql-performance@postgresql.org +Subject: Re: optimizing db for small table with tons of updates +In-reply-to: <20060403190354.GC15756@surnet.cl> +References: <20060403182403.GA12257@juniper.net> + <15521.1144089550@sss.pgh.pa.us> + <20060403190213.GA14328@juniper.net> + <20060403190354.GC15756@surnet.cl> +Comments: In-reply-to Alvaro Herrera + message dated "Mon, 03 Apr 2006 15:03:54 -0400" +Date: Mon, 03 Apr 2006 15:23:50 -0400 +Message-ID: <15871.1144092230@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] +X-Spam-Score: 0.114 +X-Spam-Level: +X-Archive-Number: 200604/31 +X-Sequence-Number: 18115 + +Alvaro Herrera writes: +> Kenji Morishige wrote: +>> I've been stumped as to how to call psql from the command line without it +>> prompting me for a password. Is there a enviornoment variable I can specify for +>> the password or something I can place in .pgsql? I could write a perl wrapper +>> around it, but I've been wondering how I can call psql -c without it prompting +>> me. Is it possible? + +> Sure it is. Set up a .pgpass file. + +Also, consider whether a non-password-based auth method (eg, ident) +might work for you. Personally, I wouldn't trust ident over TCP, but +if your kernel supports it on unix-socket connections it is secure. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 3 16:29:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 631D011F6B04 + for ; + Mon, 3 Apr 2006 16:29:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64845-07 + for ; + Mon, 3 Apr 2006 16:29:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from colo-dns-ext2.juniper.net (colo-dns-ext2.juniper.net + [207.17.137.64]) + by postgresql.org (Postfix) with ESMTP id AB29B11F6AFE + for ; + Mon, 3 Apr 2006 16:29:00 -0300 (ADT) +Received: from merlot.juniper.net (merlot.juniper.net [172.17.27.10]) + by colo-dns-ext2.juniper.net (8.12.3/8.12.3) with ESMTP id + k33JSu1Z080781; Mon, 3 Apr 2006 12:28:56 -0700 (PDT) + (envelope-from kenjim@juniper.net) +Received: from kenjim-lnx.juniper.net (kenjim-lnx.juniper.net [172.17.58.60]) + by merlot.juniper.net (8.11.3/8.11.3) with ESMTP id k33JSt515627; + Mon, 3 Apr 2006 12:28:55 -0700 (PDT) + (envelope-from kenjim@juniper.net) +Received: from kenjim-lnx.juniper.net (kenjim-lnx.juniper.net [127.0.0.1]) + by kenjim-lnx.juniper.net (8.13.4/8.13.4) with ESMTP id k33JStFi015610; + Mon, 3 Apr 2006 12:28:55 -0700 +Received: (from kenjim@localhost) + by kenjim-lnx.juniper.net (8.13.4/8.13.4/Submit) id k33JSpB7015605; + Mon, 3 Apr 2006 12:28:51 -0700 +Date: Mon, 3 Apr 2006 12:28:51 -0700 +From: Kenji Morishige +To: Tom Lane +Cc: Alvaro Herrera , + pgsql-performance@postgresql.org, kenjim@juniper.net +Subject: Re: optimizing db for small table with tons of updates +Message-ID: <20060403192851.GB15302@juniper.net> +References: <20060403182403.GA12257@juniper.net> + <15521.1144089550@sss.pgh.pa.us> + <20060403190213.GA14328@juniper.net> + <20060403190354.GC15756@surnet.cl> <15871.1144092230@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <15871.1144092230@sss.pgh.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/32 +X-Sequence-Number: 18116 + +Cool, looks like I had tried the .pgpass thing a while back and wasn't working, +I realized I had a typo or something in there. It works like a charm. Security +in our intranet is not a big issue at the moment. Thanks for the help! +-Kenji + +On Mon, Apr 03, 2006 at 03:23:50PM -0400, Tom Lane wrote: +> Alvaro Herrera writes: +> > Kenji Morishige wrote: +> >> I've been stumped as to how to call psql from the command line without it +> >> prompting me for a password. Is there a enviornoment variable I can specify for +> >> the password or something I can place in .pgsql? I could write a perl wrapper +> >> around it, but I've been wondering how I can call psql -c without it prompting +> >> me. Is it possible? +> +> > Sure it is. Set up a .pgpass file. +> +> Also, consider whether a non-password-based auth method (eg, ident) +> might work for you. Personally, I wouldn't trust ident over TCP, but +> if your kernel supports it on unix-socket connections it is secure. +> +> regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 3 18:25:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 01CE811F66EA + for ; + Mon, 3 Apr 2006 18:25:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09623-10 + for ; + Mon, 3 Apr 2006 18:25:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ismail.co.merced.ca.us (ismail.co.merced.ca.us [66.124.46.190]) + by postgresql.org (Postfix) with ESMTP id B5C5B11F638E + for ; + Mon, 3 Apr 2006 18:25:11 -0300 (ADT) +Message-Id: <44313030020000E5000001DA@dp_mail.co.merced.ca.us> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Mon, 03 Apr 2006 14:24:48 -0700 +From: "Mike Quinn" +To: +Subject: The order of fields around the "=" in the WHERE conditions +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Received-SPF: none +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/33 +X-Sequence-Number: 18117 + + version + +------------------------------------------------------------------------ + PostgreSQL 8.1.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) +3.3.6 +(1 row) + + +-- The order of fields around the "=" in the WHERE conditions +-- affects the query plan. I would rather not have to worry about +-- that. It seems that it puts me back in the place of having to +-- figure what join order is best. Here are two sql statements and +-- the query plan that is generated for each. The worst of the two +-- is first and the best one is second. +-- Mike Quinn + +-- the worst way -- + +EXPLAIN ANALYZE +SELECT +Locts.id, +Commtypes.name +FROM +Growers +, +Locts +, +Crops +, +Commtypes +WHERE +Growers.id = '0401606' +AND +-- Commtypes.number = Crops.Commtype +Crops.Commtype = Commtypes.number +AND +Locts.number = Crops.Loct +-- Crops.Loct = Locts.number +AND +Growers.number = Locts.Grower +-- Locts.Grower = Growers.number +; + QUERY +PLAN +--------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=18934.81..647002.69 rows=1045 width=20) (actual +time=525.267..4079.051 rows=69 loops=1) + Join Filter: ("outer".commtype = "inner".number) + -> Nested Loop (cost=18923.21..631988.31 rows=1310 width=18) +(actual time=523.867..4036.005 rows=69 loops=1) + Join Filter: ("inner".number = "outer".loct) + -> Seq Scan on crops (cost=0.00..7599.46 rows=258746 +width=24) (actual time=0.006..278.656 rows=258746 loops=1) + -> Materialize (cost=18923.21..18924.25 rows=104 width=18) +(actual time=0.001..0.007 rows=9 loops=258746) + -> Nested Loop (cost=5503.02..18923.11 rows=104 +width=18) (actual time=0.061..523.703 rows=9 loops=1) + Join Filter: ("outer".number = "inner".grower) + -> Index Scan using growers_id on growers +(cost=0.00..3.05 rows=4 width=12) (actual time=0.016..0.024 rows=1 +loops=1) + Index Cond: ((id)::text = '0401606'::text) + -> Materialize (cost=5503.02..7451.58 +rows=112456 width=30) (actual time=0.007..433.970 rows=112456 loops=1) + -> Seq Scan on locts (cost=0.00..4566.56 +rows=112456 width=30) (actual time=0.003..176.771 rows=112456 loops=1) + -> Materialize (cost=11.60..16.69 rows=509 width=26) (actual +time=0.001..0.287 rows=509 loops=69) + -> Seq Scan on commtypes (cost=0.00..11.09 rows=509 +width=26) (actual time=0.021..0.672 rows=509 loops=1) + Total runtime: 4081.766 ms +(15 rows) + +-- the best way -- + +EXPLAIN ANALYZE +SELECT +Locts.id, +Commtypes.name +FROM +Growers +, +Locts +, +Crops +, +Commtypes +WHERE +Growers.id = '0401606' +AND +Commtypes.number = Crops.Commtype +-- Crops.Commtype = Commtypes.number +AND +-- Locts.number = Crops.Loct +Crops.Loct = Locts.number +AND +-- Growers.number = Locts.Grower +Locts.Grower = Growers.number +; + QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..11224.18 rows=1045 width=20) (actual +time=0.259..1.172 rows=69 loops=1) + -> Nested Loop (cost=0.00..5717.09 rows=1310 width=18) (actual +time=0.205..0.466 rows=69 loops=1) + -> Nested Loop (cost=0.00..31.90 rows=104 width=18) (actual +time=0.141..0.171 rows=9 loops=1) + -> Index Scan using growers_id on growers +(cost=0.00..3.05 rows=4 width=12) (actual time=0.078..0.080 rows=1 +loops=1) + Index Cond: ((id)::text = '0401606'::text) + -> Index Scan using locts_grower on locts +(cost=0.00..6.15 rows=85 width=30) (actual time=0.058..0.070 rows=9 +loops=1) + Index Cond: (locts.grower = "outer".number) + -> Index Scan using crops_loct on crops (cost=0.00..54.13 +rows=43 width=24) (actual time=0.012..0.022 rows=8 loops=9) + Index Cond: (crops.loct = "outer".number) + -> Index Scan using commtypes_number_key on commtypes +(cost=0.00..4.19 rows=1 width=26) (actual time=0.006..0.007 rows=1 +loops=69) + Index Cond: (commtypes.number = "outer".commtype) + Total runtime: 1.308 ms +(12 rows) + + + +From pgsql-performance-owner@postgresql.org Mon Apr 3 18:35:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4714F11F6619 + for ; + Mon, 3 Apr 2006 18:35:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34874-02 + for ; + Mon, 3 Apr 2006 18:35:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id F3E3C11F638E + for ; + Mon, 3 Apr 2006 18:35:15 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k33LZ7pq016937; + Mon, 3 Apr 2006 17:35:07 -0400 (EDT) +To: "Mike Quinn" +cc: pgsql-performance@postgresql.org +Subject: Re: The order of fields around the "=" in the WHERE conditions +In-reply-to: <44313030020000E5000001DA@dp_mail.co.merced.ca.us> +References: <44313030020000E5000001DA@dp_mail.co.merced.ca.us> +Comments: In-reply-to "Mike Quinn" + message dated "Mon, 03 Apr 2006 14:24:48 -0700" +Date: Mon, 03 Apr 2006 17:35:07 -0400 +Message-ID: <16936.1144100107@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] +X-Spam-Score: 0.114 +X-Spam-Level: +X-Archive-Number: 200604/34 +X-Sequence-Number: 18118 + +"Mike Quinn" writes: +> -- The order of fields around the "=" in the WHERE conditions +> -- affects the query plan. + +That absolutely should not be happening. Could we see a complete test +case? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 3 18:58:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BAFEC11F732A + for ; + Mon, 3 Apr 2006 18:58:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64059-03 + for ; + Mon, 3 Apr 2006 18:58:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 65D5411F7329 + for ; + Mon, 3 Apr 2006 18:58:11 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k33Lw294017163; + Mon, 3 Apr 2006 17:58:02 -0400 (EDT) +To: "Mike Quinn" +cc: pgsql-performance@postgresql.org +Subject: Re: The order of fields around the "=" in the WHERE conditions +In-reply-to: <44313030020000E5000001DA@dp_mail.co.merced.ca.us> +References: <44313030020000E5000001DA@dp_mail.co.merced.ca.us> +Comments: In-reply-to "Mike Quinn" + message dated "Mon, 03 Apr 2006 14:24:48 -0700" +Date: Mon, 03 Apr 2006 17:58:02 -0400 +Message-ID: <17162.1144101482@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] +X-Spam-Score: 0.114 +X-Spam-Level: +X-Archive-Number: 200604/35 +X-Sequence-Number: 18119 + +"Mike Quinn" writes: +> -- The order of fields around the "=" in the WHERE conditions +> -- affects the query plan. + +BTW, what's the datatype(s) of the join columns? The behavior looks +consistent with the idea that the planner doesn't think it can commute +the join conditions, which would be a bug/omission in the set of +operators existing for the datatype(s). I believe we've got commutators +for all the standard '=' operators, but a contrib or third-party +datatype might be missing this. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 3 21:39:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E011311F670B + for ; + Mon, 3 Apr 2006 21:39:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54557-08 + for ; + Mon, 3 Apr 2006 21:39:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id 008A511F670D + for ; + Mon, 3 Apr 2006 21:39:39 -0300 (ADT) +Received: from dell.home.lan (host163-44.pool8256.interbusiness.it + [82.56.44.163]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k341gMr23851; + Tue, 4 Apr 2006 03:42:22 +0200 +Subject: bad performance on Solaris 10 +From: Chris Mair +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Date: Tue, 04 Apr 2006 02:39:38 +0200 +Message-Id: <1144111178.3723.80.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/36 +X-Sequence-Number: 18120 + +Hi, + +I've got a somewhat puzzling performance problem here. + +I'm trying to do a few tests with PostgreSQL 8.1.3 under Solaris +(an OS I'm sort of a newbie in). + +The machine is a X4100 and the OS is Solaris 10 1/06 fresh install +according to manual. It's got two SAS disks in RAID 1, 4GB of RAM. + +Now the problem is: this box is *much* slower than I expect. + +I've got a libpg test program that happily inserts data +using PQputCopyData(). + +It performs an order of magnitude worse than the same thing +on a small Sun (Ultra20) running Linux. Or 4 times slower than +an iBook (sic!) running MacOS X. + +So, I've this very bad feeling that there is something basic +I'm missing here. + +Following are some stats: + +"sync; dd; sync" show these disks write at 53 MB/s => good. + +iostat 1 while my test is running says: + + tty sd0 sd1 sd2 sd5 +cpu + tin tout kps tps serv kps tps serv kps tps serv kps tps serv us sy +wt id + 1 57 0 0 0 0 0 0 0 0 0 1809 23 70 0 +1 0 99 + 0 235 0 0 0 0 0 0 0 0 0 2186 223 14 1 +1 0 99 + 0 81 0 0 0 0 0 0 0 0 0 2488 251 13 1 +1 0 98 + 0 81 0 0 0 0 0 0 0 0 0 2296 232 15 1 +0 0 99 + 0 81 0 0 0 0 0 0 0 0 0 2416 166 9 1 +0 0 98 + 0 81 0 0 0 0 0 0 0 0 0 2528 218 14 1 +1 0 99 + 0 81 0 0 0 0 0 0 0 0 0 2272 223 15 1 +0 0 99 + +If I interpret this correctly the disk writes at not more than 2.5 +MB/sec while the Opterons do nothing => this is bad. + +I've tried both, a hand compile with gcc and the solarispackages +from pgfoundry.org => same result. + +Eons ago PCs had those "turbo" switches (it was never totally clear +why they put them there in the first place, anyway). I've this bad +feeling there's a secret "turbo" switch I can't spot hidden somewhere +in Solaris :/ + + +Bye, Chris. + + +From pgsql-performance-owner@postgresql.org Mon Apr 3 21:51:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DA50011F61F0 + for ; + Mon, 3 Apr 2006 21:51:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88265-03 + for ; + Mon, 3 Apr 2006 21:51:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id 7D54B11F6009 + for ; + Mon, 3 Apr 2006 21:51:01 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO [192.168.1.27]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9206471; Mon, 03 Apr 2006 17:54:00 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: bad performance on Solaris 10 +Date: Mon, 3 Apr 2006 17:49:27 -0700 +User-Agent: KMail/1.8 +Cc: Chris Mair +References: <1144111178.3723.80.camel@dell.home.lan> +In-Reply-To: <1144111178.3723.80.camel@dell.home.lan> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604031749.27580.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.081 required=5 tests=[AWL=0.081] +X-Spam-Score: 0.081 +X-Spam-Level: +X-Archive-Number: 200604/37 +X-Sequence-Number: 18121 + +Chris, + +> Eons ago PCs had those "turbo" switches (it was never totally clear +> why they put them there in the first place, anyway). I've this bad +> feeling there's a secret "turbo" switch I can't spot hidden somewhere +> in Solaris :/ + +Yes. Check out Jignesh's configuration advice .... ach, this is down. +Hold on, I will get you instructions on how to turn on filesystem caching +and readahead in Solaris. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Apr 3 21:54:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8209A11F65F2 + for ; + Mon, 3 Apr 2006 21:54:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71656-04 + for ; + Mon, 3 Apr 2006 21:54:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from asgard1.americatelsal.com (asgard.americatelsal.com + [200.13.161.7]) + by postgresql.org (Postfix) with ESMTP id 3D23C11F65BC + for ; + Mon, 3 Apr 2006 21:54:33 -0300 (ADT) +Received: (qmail 59351 invoked from network); 4 Apr 2006 01:16:41 -0000 +Received: from unknown (HELO ?192.168.10.124?) (200.13.161.68) + by asgard1.americatelsal.com with SMTP; 4 Apr 2006 01:16:41 -0000 +Message-ID: <4431C4B4.4090300@123.com.sv> +Date: Mon, 03 Apr 2006 18:58:28 -0600 +From: Miguel +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: freebsd/softupdates for data dir +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.068 required=5 tests=[AWL=0.068] +X-Spam-Score: 0.068 +X-Spam-Level: +X-Archive-Number: 200604/38 +X-Sequence-Number: 18122 + +Hi, reading the archives i cant find a clear answer about softupdates in +freebsd, is it recommended to enable it for the data directory? + +--- +miguel + +From pgsql-performance-owner@postgresql.org Mon Apr 3 23:11:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3DC5811F6668 + for ; + Mon, 3 Apr 2006 23:11:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52208-03-2 + for ; + Mon, 3 Apr 2006 23:10:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz + [203.96.152.184]) + by postgresql.org (Postfix) with ESMTP id 75A8D11F665E + for ; + Mon, 3 Apr 2006 23:10:55 -0300 (ADT) +Received: from smtp-2.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-5.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IX600FBWE1K14@linda-5.paradise.net.nz> for + pgsql-performance@postgresql.org; Tue, 04 Apr 2006 14:10:32 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-132.dsl.clear.net.nz [218.101.29.132]) by + smtp-2.paradise.net.nz (Postfix) with ESMTP id 719AD15812AA; + Tue, 04 Apr 2006 14:10:32 +1200 (NZST) +Date: Tue, 04 Apr 2006 14:10:25 +1200 +From: Mark Kirkwood +Subject: Re: freebsd/softupdates for data dir +In-reply-to: <4431C4B4.4090300@123.com.sv> +To: Miguel +Cc: pgsql-performance@postgresql.org +Message-id: <4431D591.30500@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20051106) +References: <4431C4B4.4090300@123.com.sv> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.168 required=5 tests=[AWL=0.168] +X-Spam-Score: 0.168 +X-Spam-Level: +X-Archive-Number: 200604/39 +X-Sequence-Number: 18123 + +Miguel wrote: +> Hi, reading the archives i cant find a clear answer about softupdates in +> freebsd, is it recommended to enable it for the data directory? +> + +There is a pretty good article about softupdates and journelling here: + +http://www.usenix.org/publications/library/proceedings/usenix2000/general/full_papers/seltzer/seltzer_html/index.html + +and in the freebsd docs here: + +http://www.freebsd.org/doc/handbook/configtuning-disk.html + +Postgres does not do a lot of file meta-data operations (unless you do a +*lot* of CREATE/DROP INDEX/TABLE/DATABASE), so the performance gains +associated with softupdates will probably be minimal. + +I've always left them on, and never had any issues...(even after +unscheduled power loss - which happened here yesterday). As I understand +it, the softupdate code reorders *metadata* operations, and does not +alter data operations - so the effect of fysnc(2) on a preexisting file +is not changed by softupdates being on or off. + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Tue Apr 4 00:46:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9CE1711F66BF + for ; + Tue, 4 Apr 2006 00:46:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02401-06 + for ; + Tue, 4 Apr 2006 00:46:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by postgresql.org (Postfix) with ESMTP id 1282F11F6632 + for ; + Tue, 4 Apr 2006 00:46:36 -0300 (ADT) +Received: from 172.16.1.148 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Mon, 03 Apr 2006 23:46:30 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01HOST02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 3 Apr + 2006 23:46:29 -0400 +Received: from 69.181.100.71 ([69.181.100.71]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Tue, 4 Apr + 2006 03:46:29 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Mon, 03 Apr 2006 20:46:28 -0700 +Subject: Re: bad performance on Solaris 10 +From: "Luke Lonergan" +To: "Josh Berkus" , + pgsql-performance@postgresql.org +cc: "Chris Mair" +Message-ID: +Thread-Topic: [PERFORM] bad performance on Solaris 10 +Thread-Index: AcZXgfrvibtj36e5TR+PBPObekfkdQAGF97b +In-Reply-To: <200604031749.27580.josh@agliodbs.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 04 Apr 2006 03:46:29.0870 (UTC) + FILETIME=[5B8598E0:01C6579A] +X-WSS-ID: 682F339C20C38499773-01-01 +Content-Type: multipart/alternative; + boundary=B_3226941988_49453 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.352 required=5 tests=[AWL=0.098, + HTML_MESSAGE=0.001, RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.352 +X-Spam-Level: * +X-Archive-Number: 200604/40 +X-Sequence-Number: 18124 + +> This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--B_3226941988_49453 +Content-Type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + +Jignesh=B9s blog has some of the good stuff in it: + http://blogs.sun.com/roller/page/jkshah + +- Luke + + +On 4/3/06 5:49 PM, "Josh Berkus" wrote: + +> Chris, +>=20 +>> > Eons ago PCs had those "turbo" switches (it was never totally clear +>> > why they put them there in the first place, anyway). I've this bad +>> > feeling there's a secret "turbo" switch I can't spot hidden somewhere +>> > in Solaris :/ +>=20 +> Yes. Check out Jignesh's configuration advice .... ach, this is down. +> Hold on, I will get you instructions on how to turn on filesystem caching +> and readahead in Solaris. +>=20 +> -- +> --Josh +>=20 +> Josh Berkus +> Aglio Database Solutions +> San Francisco +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +>=20 +>=20 + + + +--B_3226941988_49453 +Content-Type: text/html; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + +Re: [PERFORM] bad performance on Solaris 10 + + +Jigne= +sh’s blog has some of the good stuff in it:
+  http://blogs.= +sun.com/roller/page/jkshah
+
+- Luke
+
+
+On 4/3/06 5:49 PM, "Josh Berkus" <josh@agliodbs.com> wrote:= +
+
+
Chris,
+
+> Eons ago PCs had those "turbo" switches (it was never totall= +y clear
+> why they put them there in the first place, anyway). I've this bad
+> feeling there's a secret "turbo" switch I can't spot hidden = +somewhere
+> in Solaris :/
+
+Yes.   Check out Jignesh's configuration advice .... ach, this is= + down.  
+Hold on, I will get you instructions on how to turn on filesystem caching +and readahead in Solaris.
+
+--
+--Josh
+
+Josh Berkus
+Aglio Database Solutions
+San Francisco
+
+---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings
+
+
+

+
+ + + + +--B_3226941988_49453-- + + +From pgsql-performance-owner@postgresql.org Tue Apr 4 02:12:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E8BC311F661A + for ; + Tue, 4 Apr 2006 02:12:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88062-09 + for ; + Tue, 4 Apr 2006 02:12:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz + [203.96.152.184]) + by postgresql.org (Postfix) with ESMTP id 2B3A211F6639 + for ; + Tue, 4 Apr 2006 02:12:13 -0300 (ADT) +Received: from smtp-2.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-5.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IX600JHTMGCXA@linda-5.paradise.net.nz> for + pgsql-performance@postgresql.org; Tue, 04 Apr 2006 17:12:12 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-132.dsl.clear.net.nz [218.101.29.132]) by + smtp-2.paradise.net.nz (Postfix) with ESMTP id 4D9D6B084F8; + Tue, 04 Apr 2006 17:12:12 +1200 (NZST) +Date: Tue, 04 Apr 2006 17:12:04 +1200 +From: Mark Kirkwood +Subject: Re: bad performance on Solaris 10 +In-reply-to: <1144111178.3723.80.camel@dell.home.lan> +To: Chris Mair +Cc: pgsql-performance@postgresql.org +Message-id: <44320024.60908@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20051106) +References: <1144111178.3723.80.camel@dell.home.lan> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.168 required=5 tests=[AWL=0.168] +X-Spam-Score: 0.168 +X-Spam-Level: +X-Archive-Number: 200604/41 +X-Sequence-Number: 18125 + +Chris Mair wrote: +> Hi, +> +> I've got a somewhat puzzling performance problem here. +> +> I'm trying to do a few tests with PostgreSQL 8.1.3 under Solaris +> (an OS I'm sort of a newbie in). +> +> The machine is a X4100 and the OS is Solaris 10 1/06 fresh install +> according to manual. It's got two SAS disks in RAID 1, 4GB of RAM. +> +> Now the problem is: this box is *much* slower than I expect. +> +> I've got a libpg test program that happily inserts data +> using PQputCopyData(). +> +> It performs an order of magnitude worse than the same thing +> on a small Sun (Ultra20) running Linux. Or 4 times slower than +> an iBook (sic!) running MacOS X. +> +> So, I've this very bad feeling that there is something basic +> I'm missing here. +> +> Following are some stats: +> +> "sync; dd; sync" show these disks write at 53 MB/s => good. +> +> iostat 1 while my test is running says: +> +> tty sd0 sd1 sd2 sd5 +> cpu +> tin tout kps tps serv kps tps serv kps tps serv kps tps serv us sy +> wt id +> 1 57 0 0 0 0 0 0 0 0 0 1809 23 70 0 +> 1 0 99 +> 0 235 0 0 0 0 0 0 0 0 0 2186 223 14 1 +> 1 0 99 +> 0 81 0 0 0 0 0 0 0 0 0 2488 251 13 1 +> 1 0 98 +> 0 81 0 0 0 0 0 0 0 0 0 2296 232 15 1 +> 0 0 99 +> 0 81 0 0 0 0 0 0 0 0 0 2416 166 9 1 +> 0 0 98 +> 0 81 0 0 0 0 0 0 0 0 0 2528 218 14 1 +> 1 0 99 +> 0 81 0 0 0 0 0 0 0 0 0 2272 223 15 1 +> 0 0 99 +> +> If I interpret this correctly the disk writes at not more than 2.5 +> MB/sec while the Opterons do nothing => this is bad. +> +> I've tried both, a hand compile with gcc and the solarispackages +> from pgfoundry.org => same result. +> +> Eons ago PCs had those "turbo" switches (it was never totally clear +> why they put them there in the first place, anyway). I've this bad +> feeling there's a secret "turbo" switch I can't spot hidden somewhere +> in Solaris :/ +> + +I ran across something like this on a Solaris 8, RAID1 system, and +switching off logging on filesystem containing postgres made a huge +difference! + +Now solaris 8 is ancient history, however see: + +http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6238533 + +Apparently there can still be issues with logging without forcedirectio +(which is the default I think). + +I suspect that making a *separate* filesystem for the pg_xlog directory +and mounting that logging + forcedirectio would be a nice way to also +get performance while keeping the advantages of logging + file +buffercache for the *rest* of the postgres components. +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Tue Apr 4 03:09:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1E52911F6C3E + for ; + Tue, 4 Apr 2006 03:09:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68325-04 + for ; + Tue, 4 Apr 2006 03:09:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id 5CB6811F6D0C + for ; + Tue, 4 Apr 2006 03:09:11 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO + spooky.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9207459; Mon, 03 Apr 2006 23:12:10 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: bad performance on Solaris 10 +Date: Mon, 3 Apr 2006 23:09:43 -0700 +User-Agent: KMail/1.8.2 +Cc: Mark Kirkwood , + Chris Mair +References: <1144111178.3723.80.camel@dell.home.lan> + <44320024.60908@paradise.net.nz> +In-Reply-To: <44320024.60908@paradise.net.nz> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604032309.44143.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200604/42 +X-Sequence-Number: 18126 + +Mark, + +> I suspect that making a *separate* filesystem for the pg_xlog directory +> and mounting that logging + forcedirectio would be a nice way to also +> get performance while keeping the advantages of logging + file +> buffercache for the *rest* of the postgres components. +> Cheers + +Yes, we tested this. It makes a huge difference in WAL speed. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Apr 10 23:29:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9423111F61FB + for ; + Tue, 4 Apr 2006 04:24:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61887-06 + for ; + Tue, 4 Apr 2006 04:24:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id DBE8D11F61C0 + for ; + Tue, 4 Apr 2006 04:24:51 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 3788C30F1B; Tue, 4 Apr 2006 09:24:51 +0200 (MET DST) +From: "C Storm" +X-Newsgroups: pgsql.performance +Subject: pgmemcache +Date: 4 Apr 2006 00:24:42 -0700 +Organization: http://groups.google.com +Lines: 11 +Message-ID: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; + en) AppleWebKit/417.9 (KHTML, like Gecko) + Safari/417.9.2,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: z34g2000cwc.googlegroups.com; posting-host=24.7.97.135; + posting-account=8cjn1A0AAABCEc9psZti4Q2gyhLtFgqt +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/223 +X-Sequence-Number: 18307 + +I was wondering if anyone on the list has a successful installation of +pgmemcache running +that uses LISTEN/NOTIFY to signal a successfully completed transaction, +i.e., to get around the fact +that TRIGGERS are transaction unaware. Or perhaps any other +information regarding a successful +deployment of pgmemcache. + +The information available on the web/groups is pretty scant. Any +information would be greatly appreciated! + + +From pgsql-performance-owner@postgresql.org Tue Apr 4 11:41:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EC18311F6D4A + for ; + Tue, 4 Apr 2006 11:41:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23079-07 + for ; + Tue, 4 Apr 2006 11:41:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 7293E11F6AAB + for ; + Tue, 4 Apr 2006 11:41:33 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 29D88B80C + for ; + Tue, 4 Apr 2006 10:41:33 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v746.3) +In-Reply-To: <4431D591.30500@paradise.net.nz> +References: <4431C4B4.4090300@123.com.sv> <4431D591.30500@paradise.net.nz> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: freebsd/softupdates for data dir +Date: Tue, 4 Apr 2006 10:41:32 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.746.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.085 required=5 tests=[AWL=0.085] +X-Spam-Score: 0.085 +X-Spam-Level: +X-Archive-Number: 200604/43 +X-Sequence-Number: 18127 + + +On Apr 3, 2006, at 10:10 PM, Mark Kirkwood wrote: + +> I've always left them on, and never had any issues...(even after +> unscheduled power loss - which happened here yesterday). As I +> understand it, the softupdate code reorders *metadata* operations, +> and does not alter data operations - so the effect of fysnc(2) on a +> preexisting file is not changed by softupdates being on or off. + +This is also my understanding, and I also leave softupdates on for +the data partition. Even if it doesn't improve performance, it will +not reduce it, and otherwise does no harm with respect to postgres' +disk usage. + + +From pgsql-performance-owner@postgresql.org Tue Apr 4 11:59:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6D43311F655B + for ; + Tue, 4 Apr 2006 11:59:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80696-01 + for ; + Tue, 4 Apr 2006 11:59:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by postgresql.org (Postfix) with ESMTP id 47EA011F6270 + for ; + Tue, 4 Apr 2006 11:59:52 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id A44B66441F6 + for ; + Tue, 4 Apr 2006 08:59:49 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 31191-02 for ; + Tue, 4 Apr 2006 08:59:47 -0600 (MDT) +Received: from [192.168.1.100] (c-67-165-220-189.hsd1.co.comcast.net + [67.165.220.189]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 7748E644109 + for ; + Tue, 4 Apr 2006 08:59:47 -0600 (MDT) +Message-ID: <443289E3.7020801@drivefaster.net> +Date: Tue, 04 Apr 2006 08:59:47 -0600 +From: Dan Harris +User-Agent: Thunderbird 1.5 (Macintosh/20060122) +MIME-Version: 1.0 +To: PostgreSQL Performance +Subject: vacuum full seems to hang on very small table +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/44 +X-Sequence-Number: 18128 + +I have a table with 1 live row that I found has 115000 dead rows in it ( +from a testing run ). I'm trying to VACUUM FULL the table and it has +run for over 18 hours without completion. Considering the hardware on +this box and the fact that performance seems reasonable in all other +aspects, I'm confused as to why this would happen. The database other +than this table is quite large ( 70 gigs on disk ) and I would expect to +take days to complete but I just did 'vacuum full table_stats'. That +should only do that table, correct? I'm running 8.0.3. + + Table "public.table_stats" + Column | Type | Modifiers +---------------------+-----------------------------+----------- + count_cfs | integer | + count_ncfs | integer | + count_unitactivity | integer | + count_eventactivity | integer | + min_eventmain | timestamp without time zone | + max_eventmain | timestamp without time zone | + min_eventactivity | timestamp without time zone | + max_eventactivity | timestamp without time zone | + geocoding_hitrate | double precision | + recent_load | timestamp without time zone | + count_eventmain | integer | + + +This is the table structure. + +Any ideas where to begin troubleshooting this? + +Thanks. + + +From pgsql-performance-owner@postgresql.org Tue Apr 4 12:08:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4661811F66C8 + for ; + Tue, 4 Apr 2006 12:07:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28977-02 + for ; + Tue, 4 Apr 2006 12:07:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.libertyrms.com (vgateway.libertyrms.info [207.219.45.62]) + by postgresql.org (Postfix) with ESMTP id 6214511F671A + for ; + Tue, 4 Apr 2006 12:07:53 -0300 (ADT) +Received: from dba5.int.libertyrms.com ([10.1.3.44]) + by mail.libertyrms.com with esmtp (Exim 4.22) + id 1FQn8K-0000MU-0U; Tue, 04 Apr 2006 11:07:52 -0400 +Message-ID: <44328BC7.1070208@ca.afilias.info> +Date: Tue, 04 Apr 2006 11:07:51 -0400 +From: Brad Nicholson +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Dan Harris +CC: PostgreSQL Performance +Subject: Re: vacuum full seems to hang on very small table +References: <443289E3.7020801@drivefaster.net> +In-Reply-To: <443289E3.7020801@drivefaster.net> +X-Enigmail-Version: 0.94.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-SA-Exim-Mail-From: bnichols@ca.afilias.info +X-SA-Exim-Scanned: No; SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.178 required=5 tests=[AWL=0.178] +X-Spam-Score: 0.178 +X-Spam-Level: +X-Archive-Number: 200604/45 +X-Sequence-Number: 18129 + +Dan Harris wrote: +> I have a table with 1 live row that I found has 115000 dead rows in it ( +> from a testing run ). I'm trying to VACUUM FULL the table and it has +> run for over 18 hours without completion. Considering the hardware on +> this box and the fact that performance seems reasonable in all other +> aspects, I'm confused as to why this would happen. The database other +> than this table is quite large ( 70 gigs on disk ) and I would expect to +> take days to complete but I just did 'vacuum full table_stats'. That +> should only do that table, correct? I'm running 8.0.3. + +VACUUM FULL requires an exclusive lock on the table that it's vacuuming. + Chances are something else has a lock on the table is blocking the +vacuum from obtaining the necessary lock. Check pg_locks for ungranted +locks, you'll probably find that the request from the vacuum is ungranted. +-- +Brad Nicholson 416-673-4106 +Database Administrator, Afilias Canada Corp. + + +From pgsql-performance-owner@postgresql.org Tue Apr 4 12:38:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F3F2C11F623F + for ; + Tue, 4 Apr 2006 12:37:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55095-08 + for ; + Tue, 4 Apr 2006 12:37:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) + by postgresql.org (Postfix) with ESMTP id 5842E11F6247 + for ; + Tue, 4 Apr 2006 12:37:53 -0300 (ADT) +Received: from [192.168.0.5] (unknown [84.12.155.199]) + by smtp.nildram.co.uk (Postfix) with ESMTP + id 67CD633B72B; Tue, 4 Apr 2006 16:35:20 +0100 (BST) +Subject: Re: vacuum full seems to hang on very small table +From: Simon Riggs +To: Dan Harris +Cc: PostgreSQL Performance +In-Reply-To: <443289E3.7020801@drivefaster.net> +References: <443289E3.7020801@drivefaster.net> +Content-Type: text/plain +Date: Tue, 04 Apr 2006 16:35:14 +0100 +Message-Id: <1144164914.13549.502.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.098 required=5 tests=[AWL=0.098] +X-Spam-Score: 0.098 +X-Spam-Level: +X-Archive-Number: 200604/46 +X-Sequence-Number: 18130 + +On Tue, 2006-04-04 at 08:59 -0600, Dan Harris wrote: +> I have a table with 1 live row that I found has 115000 dead rows in it ( +> from a testing run ). I'm trying to VACUUM FULL the table and it has +> run for over 18 hours without completion. Considering the hardware on +> this box and the fact that performance seems reasonable in all other +> aspects, I'm confused as to why this would happen. The database other +> than this table is quite large ( 70 gigs on disk ) and I would expect to +> take days to complete but I just did 'vacuum full table_stats'. That +> should only do that table, correct? I'm running 8.0.3. + +Read this http://www.postgresql.org/docs/8.0/static/release-8-0-5.html +and you'll probably decide to upgrade. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Apr 4 14:19:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0731D11F69EF + for ; + Tue, 4 Apr 2006 14:19:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85554-05 + for ; + Tue, 4 Apr 2006 14:19:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ismail.co.merced.ca.us (ismail.co.merced.ca.us [66.124.46.190]) + by postgresql.org (Postfix) with ESMTP id 5A0FA11F6958 + for ; + Tue, 4 Apr 2006 14:19:32 -0300 (ADT) +Message-Id: <443247F6020000E5000001E6@dp_mail.co.merced.ca.us> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Tue, 04 Apr 2006 10:18:30 -0700 +From: "Mike Quinn" +To: +Subject: Re: The order of fields around the "=" in the WHERE +References: + <44313030020000E5000001DA@dp_mail.co.merced.ca.us><44313030020000E5000001DA@dp_mail.co.merced.ca.us> + <17162.1144101482@sss.pgh.pa.us> +In-Reply-To: <17162.1144101482@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Received-SPF: none +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200604/47 +X-Sequence-Number: 18131 + +The datatype of the join columns is a user defined type and there are no +commutators defined. I will fix that and retest. Thanks for the +insight. + +Mike Quinn + +From pgsql-performance-owner@postgresql.org Tue Apr 4 16:39:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EE80C11F61C8 + for ; + Tue, 4 Apr 2006 16:39:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95133-07 + for ; + Tue, 4 Apr 2006 16:39:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id CB5B511F6106 + for ; + Tue, 4 Apr 2006 16:39:20 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 7B80130F1B; Tue, 4 Apr 2006 21:39:20 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: Query runs too long for indexed tables +Date: Tue, 4 Apr 2006 22:37:18 +0300 +Organization: Hub.Org Networking Services +Lines: 26 +Message-ID: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +X-Spam-Score: 0.128 +X-Spam-Level: +X-Archive-Number: 200604/48 +X-Sequence-Number: 18132 + +I have relatively small tables (toode and rid) in fast server. +Both tables are indexed on toode field. + +Following query takes long time to run. +toode field type is char(20). It is difficult to change this field type. + +Any idea how to speed up this query ? + +UPDATE firma1.rid SET toode=NULL + WHERE toode IS NOT NULL AND + toode NOT IN (SELECT TOODE FROM firma1.TOODE); + +Query returned successfully: 0 rows affected, 594813 ms execution time. + +explain window shows: + +Seq Scan on rid (cost=2581.07..20862553.77 rows=51848 width=1207) + Filter: ((toode IS NOT NULL) AND (NOT (subplan))) + SubPlan + -> Materialize (cost=2581.07..2944.41 rows=14734 width=84) + -> Seq Scan on toode (cost=0.00..2350.34 rows=14734 width=84) + + +Andrus. + + + +From pgsql-performance-owner@postgresql.org Tue Apr 4 16:48:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0FE1111F620D + for ; + Tue, 4 Apr 2006 16:48:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92867-06 + for ; + Tue, 4 Apr 2006 16:48:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id DA4BA11F61CE + for ; + Tue, 4 Apr 2006 16:48:48 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 4 Apr 2006 19:48:48 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 04 Apr 2006 14:48:48 -0500 +Subject: Re: Query runs too long for indexed tables +From: Scott Marlowe +To: Andrus +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1144180128.32266.56.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 04 Apr 2006 14:48:48 -0500 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.141 required=5 tests=[AWL=0.140, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.141 +X-Spam-Level: +X-Archive-Number: 200604/49 +X-Sequence-Number: 18133 + +On Tue, 2006-04-04 at 14:37, Andrus wrote: +> I have relatively small tables (toode and rid) in fast server. +> Both tables are indexed on toode field. +> +> Following query takes long time to run. +> toode field type is char(20). It is difficult to change this field type. +> +> Any idea how to speed up this query ? +> +> UPDATE firma1.rid SET toode=NULL +> WHERE toode IS NOT NULL AND +> toode NOT IN (SELECT TOODE FROM firma1.TOODE); +> +> Query returned successfully: 0 rows affected, 594813 ms execution time. +> +> explain window shows: +> +> Seq Scan on rid (cost=2581.07..20862553.77 rows=51848 width=1207) +> Filter: ((toode IS NOT NULL) AND (NOT (subplan))) +> SubPlan +> -> Materialize (cost=2581.07..2944.41 rows=14734 width=84) +> -> Seq Scan on toode (cost=0.00..2350.34 rows=14734 width=84) + +Let me guess, you've updated it a lot and aren't familiar with Vacuum? + +run a vacuum full on your database. schedule a vacuum (plain one) to +run every so often (hours or days are a good interval for most folks) + +If that's NOT your problem, then please, let us know. + +From pgsql-performance-owner@postgresql.org Tue Apr 4 17:00:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 66A8B11F695F + for ; + Tue, 4 Apr 2006 17:00:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96306-04 + for ; + Tue, 4 Apr 2006 17:00:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) + by postgresql.org (Postfix) with ESMTP id C77C011F603C + for ; + Tue, 4 Apr 2006 17:00:15 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Query runs too long for indexed tables +Date: Tue, 4 Apr 2006 16:00:13 -0400 +Message-ID: <2BCEB9A37A4D354AA276774EE13FB8C2BCC555@mailserver.sandvine.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Query runs too long for indexed tables +Thread-Index: AcZYIN6PaDIsCtJ2S1eZKpjBV1ElnQAAS1sA +From: "Marc Morin" +To: "Scott Marlowe" , + "Andrus" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/50 +X-Sequence-Number: 18134 + +Wondering if + +Update firma1.rid set toode=3Dnull where toode is not null and not +exists(select 1 from firma1.toode where toode=3Drid.toode);=20 + +Would be faster... Problem appears to be the seqscan of seqscan... No? + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org=20 +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 +> Scott Marlowe +> Sent: Tuesday, April 04, 2006 3:49 PM +> To: Andrus +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Query runs too long for indexed tables +>=20 +> On Tue, 2006-04-04 at 14:37, Andrus wrote: +> > I have relatively small tables (toode and rid) in fast server. +> > Both tables are indexed on toode field. +> >=20 +> > Following query takes long time to run. +> > toode field type is char(20). It is difficult to change=20 +> this field type. +> >=20 +> > Any idea how to speed up this query ? +> >=20 +> > UPDATE firma1.rid SET toode=3DNULL +> > WHERE toode IS NOT NULL AND +> > toode NOT IN (SELECT TOODE FROM firma1.TOODE); +> >=20 +> > Query returned successfully: 0 rows affected, 594813 ms=20 +> execution time. +> >=20 +> > explain window shows: +> >=20 +> > Seq Scan on rid (cost=3D2581.07..20862553.77 rows=3D51848 = +width=3D1207) +> > Filter: ((toode IS NOT NULL) AND (NOT (subplan))) +> > SubPlan +> > -> Materialize (cost=3D2581.07..2944.41 rows=3D14734 = +width=3D84) +> > -> Seq Scan on toode (cost=3D0.00..2350.34 rows=3D14734=20 +> > width=3D84) +>=20 +> Let me guess, you've updated it a lot and aren't familiar with Vacuum? +>=20 +> run a vacuum full on your database. schedule a vacuum (plain=20 +> one) to run every so often (hours or days are a good interval=20 +> for most folks) +>=20 +> If that's NOT your problem, then please, let us know. =20 +>=20 +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +>=20 + +From pgsql-performance-owner@postgresql.org Tue Apr 4 17:03:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C5A3011F61C0 + for ; + Tue, 4 Apr 2006 17:03:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38579-03 + for ; + Tue, 4 Apr 2006 17:03:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) + by postgresql.org (Postfix) with ESMTP id 7420911F6934 + for ; + Tue, 4 Apr 2006 17:03:31 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Query runs too long for indexed tables +Date: Tue, 4 Apr 2006 16:03:30 -0400 +Message-ID: <2BCEB9A37A4D354AA276774EE13FB8C2BCC556@mailserver.sandvine.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Query runs too long for indexed tables +Thread-Index: AcZYH5vRJ2+Lzo2dTJ+lq4jVSstShgAAzRYQ +From: "Marc Morin" +To: "Andrus" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/51 +X-Sequence-Number: 18135 + +Explain analyze would be nice ;-)=20 + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org=20 +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Andrus +> Sent: Tuesday, April 04, 2006 3:37 PM +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] Query runs too long for indexed tables +>=20 +> I have relatively small tables (toode and rid) in fast server. +> Both tables are indexed on toode field. +>=20 +> Following query takes long time to run. +> toode field type is char(20). It is difficult to change this=20 +> field type. +>=20 +> Any idea how to speed up this query ? +>=20 +> UPDATE firma1.rid SET toode=3DNULL +> WHERE toode IS NOT NULL AND +> toode NOT IN (SELECT TOODE FROM firma1.TOODE); +>=20 +> Query returned successfully: 0 rows affected, 594813 ms=20 +> execution time. +>=20 +> explain window shows: +>=20 +> Seq Scan on rid (cost=3D2581.07..20862553.77 rows=3D51848 = +width=3D1207) +> Filter: ((toode IS NOT NULL) AND (NOT (subplan))) +> SubPlan +> -> Materialize (cost=3D2581.07..2944.41 rows=3D14734 width=3D84) +> -> Seq Scan on toode (cost=3D0.00..2350.34=20 +> rows=3D14734 width=3D84) +>=20 +>=20 +> Andrus.=20 +>=20 +>=20 +>=20 +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +>=20 + +From pgsql-performance-owner@postgresql.org Tue Apr 4 17:26:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0DC9211F6227 + for ; + Tue, 4 Apr 2006 17:26:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07971-08 + for ; + Tue, 4 Apr 2006 17:26:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id ABA9511F61C9 + for ; + Tue, 4 Apr 2006 17:26:48 -0300 (ADT) +Received: from [172.30.3.138] (unknown [64.251.112.4]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by noel.decibel.org (Postfix) with ESMTP id F16D556408; + Tue, 4 Apr 2006 15:26:40 -0500 (CDT) +In-Reply-To: <200604021530.55251.josh@agliodbs.com> +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <200603292118.50033.josh@agliodbs.com> + + <200604021530.55251.josh@agliodbs.com> +Mime-Version: 1.0 (Apple Message framework v746.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <393CBC49-14DB-4CBE-B824-7541CBD7BACC@pervasive.com> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Jim Nasby +Subject: Re: Query using SeqScan instead of IndexScan +Date: Tue, 4 Apr 2006 16:26:37 -0400 +To: Josh Berkus +X-Mailer: Apple Mail (2.746.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/52 +X-Sequence-Number: 18136 + +On Apr 2, 2006, at 6:30 PM, Josh Berkus wrote: +>> But just as a follow up question to your #1 suggestion, I have 8 GB +>> of ram in my production server. You're saying to set the +>> effective_cache_size then to 5 GB roughly? Somewhere around 655360? +>> Currently it is set to 65535. Is that something that's OS dependent? +>> I'm not sure how much memory my server sets aside for disk caching. +> +> Yes, about. It's really a judgement call; you're looking for the +> approximate +> combined RAM available for disk caching and shared mem. However, +> this is +> just used as a way of estimating the probability that the data you +> want is +> cached in memory, so you're just trying to be order-of-magnitude +> accurate, +> not to-the-MB accurate. + +FWIW, I typically set effective_cache_size to the amount of memory in +the machine minus 1G for the OS and various other daemons, etc. But +as Josh said, as long as your somewhere in the ballpark it's probably +good enough. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + + + +From pgsql-performance-owner@postgresql.org Tue Apr 4 17:28:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B674E11F61C9 + for ; + Tue, 4 Apr 2006 17:28:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69596-03 + for ; + Tue, 4 Apr 2006 17:28:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id A18AD11F6106 + for ; + Tue, 4 Apr 2006 17:28:41 -0300 (ADT) +Received: from [172.30.3.138] (unknown [64.251.112.4]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by noel.decibel.org (Postfix) with ESMTP id 1908E56408; + Tue, 4 Apr 2006 15:28:34 -0500 (CDT) +In-Reply-To: <95C1A48B-A76F-4F9B-B5EE-0BFAF8873067@clickspace.com> +References: <2F1712F1-E5E2-455E-A291-06F300A66549@clickspace.com> + <20060331155911.GP49405@pervasive.com> + + <3c1395330603311723i368092f2jf0c2291ab033ae2a@mail.gmail.com> + <20060401153247.GI49405@pervasive.com> + <95C1A48B-A76F-4F9B-B5EE-0BFAF8873067@clickspace.com> +Mime-Version: 1.0 (Apple Message framework v746.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: chris smith , + PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Jim Nasby +Subject: Re: Query using SeqScan instead of IndexScan +Date: Tue, 4 Apr 2006 16:28:24 -0400 +To: Brendan Duddridge +X-Mailer: Apple Mail (2.746.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/53 +X-Sequence-Number: 18137 + +On Apr 1, 2006, at 12:51 PM, Brendan Duddridge wrote: +> from SELECT * FROM pg_stats WHERE tablename='table' AND +> attname='category_id' +> +> I find correlation on category_product for category_id is 0.643703 +> +> Would setting the index on category_id to be clustered help with this? + +It would absolutely help on the query in question. In my experience, +a correlation of 0.64 is too low to allow an index scan to be used +for anything but a tiny number of rows. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + + + +From pgsql-performance-owner@postgresql.org Tue Apr 4 19:07:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CED3C11F654C + for ; + Tue, 4 Apr 2006 19:07:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19317-09 + for ; + Tue, 4 Apr 2006 19:07:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ismail.co.merced.ca.us (ismail.co.merced.ca.us [66.124.46.190]) + by postgresql.org (Postfix) with ESMTP id 97C6E11F64E0 + for ; + Tue, 4 Apr 2006 19:07:42 -0300 (ADT) +Message-Id: <44328BAD020000E5000001EA@dp_mail.co.merced.ca.us> +X-Mailer: Novell GroupWise Internet Agent 7.0 +Date: Tue, 04 Apr 2006 15:07:25 -0700 +From: "Mike Quinn" +To: +Cc: +Subject: Re: The order of fields around the "=" in the WHERE +References: <44313030020000E5000001DA@dp_mail.co.merced.ca.us> + <44313030020000E5000001DA@dp_mail.co.merced.ca.us> + <17162.1144101482@sss.pgh.pa.us> + <443247F6020000E5000001E6@dp_mail.co.merced.ca.us> +In-Reply-To: <443247F6020000E5000001E6@dp_mail.co.merced.ca.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Received-SPF: none +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +X-Spam-Score: 0.096 +X-Spam-Level: +X-Archive-Number: 200604/54 +X-Sequence-Number: 18138 + + version + +------------------------------------------------------------------------ + PostgreSQL 8.1.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) +3.3.6 +(1 row) + +-- After commutator added to operators of user defined type, +-- the order of fields around the "=" in WHERE conditions +-- no longer affect the query plan. + +-- previously the worst way -- + +EXPLAIN ANALYZE +SELECT +Locts.id, +Commtypes.name +FROM +Growers +, +Locts +, +Crops +, +Commtypes +WHERE +Growers.id = '0401606' +AND +-- Commtypes.number = Crops.Commtype +Crops.Commtype = Commtypes.number +AND +Locts.number = Crops.Loct +-- Crops.Loct = Locts.number +AND +Growers.number = Locts.Grower +-- Locts.Grower = Growers.number +; + QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..17467.00 rows=954 width=20) (actual +time=0.253..1.155 rows=69 loops=1) + -> Nested Loop (cost=0.00..12413.93 rows=1202 width=18) (actual +time=0.191..0.472 rows=69 loops=1) + -> Nested Loop (cost=0.00..32.51 rows=104 width=18) (actual +time=0.142..0.171 rows=9 loops=1) + -> Index Scan using growers_id on growers +(cost=0.00..3.05 rows=4 width=12) (actual time=0.065..0.067 rows=1 +loops=1) + Index Cond: ((id)::text = '0401606'::text) + -> Index Scan using locts_grower on locts +(cost=0.00..6.23 rows=91 width=30) (actual time=0.070..0.085 rows=9 +loops=1) + Index Cond: ("outer".number = locts.grower) + -> Index Scan using crops_loct on crops (cost=0.00..118.53 +rows=42 width=24) (actual time=0.011..0.021 rows=8 loops=9) + Index Cond: ("outer".number = crops.loct) + -> Index Scan using commtypes_number_key on commtypes +(cost=0.00..4.19 rows=1 width=26) (actual time=0.006..0.007 rows=1 +loops=69) + Index Cond: ("outer".commtype = commtypes.number) + Total runtime: 1.299 ms +(12 rows) + +-- previously the best way -- + +EXPLAIN ANALYZE +SELECT +Locts.id, +Commtypes.name +FROM +Growers +, +Locts +, +Crops +, +Commtypes +WHERE +Growers.id = 0401606 +AND +Commtypes.number = Crops.Commtype +-- Crops.Commtype = Commtypes.number +AND +-- Locts.number = Crops.Loct +Crops.Loct = Locts.number +AND +-- Growers.number = Locts.Grower +Locts.Grower = Growers.number +; + QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..17467.00 rows=954 width=20) (actual +time=0.063..0.947 rows=69 loops=1) + -> Nested Loop (cost=0.00..12413.93 rows=1202 width=18) (actual +time=0.050..0.318 rows=69 loops=1) + -> Nested Loop (cost=0.00..32.51 rows=104 width=18) (actual +time=0.036..0.064 rows=9 loops=1) + -> Index Scan using growers_id on growers +(cost=0.00..3.05 rows=4 width=12) (actual time=0.018..0.020 rows=1 +loops=1) + Index Cond: ((id)::text = '0401606'::text) + -> Index Scan using locts_grower on locts +(cost=0.00..6.23 rows=91 width=30) (actual time=0.012..0.023 rows=9 +loops=1) + Index Cond: (locts.grower = "outer".number) + -> Index Scan using crops_loct on crops (cost=0.00..118.53 +rows=42 width=24) (actual time=0.007..0.018 rows=8 loops=9) + Index Cond: (crops.loct = "outer".number) + -> Index Scan using commtypes_number_key on commtypes +(cost=0.00..4.19 rows=1 width=26) (actual time=0.005..0.006 rows=1 +loops=69) + Index Cond: (commtypes.number = "outer".commtype) + Total runtime: 1.091 ms +(12 rows) + + + +>>> "Mike Quinn" 4/4/06 10:18:30 AM >>> +The datatype of the join columns is a user defined type and there are +no +commutators defined. I will fix that and retest. Thanks for the +insight. + +Mike Quinn + +---------------------------(end of +broadcast)--------------------------- +TIP 3: Have you checked our extensive FAQ? + + http://www.postgresql.org/docs/faq + +From pgsql-performance-owner@postgresql.org Wed Apr 5 06:40:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 55FFE11F8CBE + for ; + Wed, 5 Apr 2006 06:40:17 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30129-09 + for ; + Wed, 5 Apr 2006 06:40:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 148A711F8CBB + for ; + Wed, 5 Apr 2006 06:40:12 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 07CB430F1B; Wed, 5 Apr 2006 11:40:12 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: Re: Query runs too long for indexed tables +Date: Wed, 5 Apr 2006 12:39:46 +0300 +Organization: Hub.Org Networking Services +Lines: 53 +Message-ID: +References: + <1144180128.32266.56.camel@state.g2switchworks.com> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.129 required=5 tests=[AWL=0.129] +X-Spam-Score: 0.129 +X-Spam-Level: +X-Archive-Number: 200604/55 +X-Sequence-Number: 18139 + +> Let me guess, you've updated it a lot and aren't familiar with Vacuum? +> +> run a vacuum full on your database. schedule a vacuum (plain one) to +> run every so often (hours or days are a good interval for most folks) +> +> If that's NOT your problem, then please, let us know. + +Scot, thank you. Excellent. If database is created and VACUUM ANALYZE is +issued, this query runs fast. +However, I need to speed up it during running script. + +This is a database creation script. Script does the following: + +1. CREATE DATABASE foo; +2. START TRANSACTION; +3. Create 145 tables with primary keys. Add data to those tables. +4. Create some additional indexes +5. ANALYZE +6. Clear bad bad foreign keys fields using commands like + +UPDATE firma1.rid SET toode=NULL + WHERE toode IS NOT NULL AND + toode NOT IN (SELECT TOODE FROM firma1.TOODE); + +7. Create foreign key references +8. COMMIT + +This script runs about 1 hour in modern server with fsync off. +Largest table has 100000 records, few other tables have 15000 records and +remaining have fewer records. + +How to speed this up ? +Is'nt running ANALYZE sufficient to speed up foreign key clearing ? + +It seems that ANALYZE does'nt work. Should I isse COMMIT before running +ANALYZE or issue more commits? + +Server has 4 GB RAM + +postgres.conf file is default from 8.1.3 window zip file except the +following settings are added to end: + +fsync=off +shared_buffers = 30000 +redirect_stderr = on +log_min_error_statement = error +autovacuum = on +... also 2 stats settings from aurtovacuur +max_fsm_pages = 30000 + +Andrus. + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 07:22:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 640D211F6602 + for ; + Wed, 5 Apr 2006 07:22:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05867-08 + for ; + Wed, 5 Apr 2006 07:22:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 283FC11F6615 + for ; + Wed, 5 Apr 2006 07:22:32 -0300 (ADT) +Received: (qmail 10961 invoked from network); 5 Apr 2006 12:22:55 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 5 Apr 2006 12:22:55 +0200 +To: Andrus , pgsql-performance@postgresql.org +Subject: Re: Query runs too long for indexed tables +References: + <1144180128.32266.56.camel@state.g2switchworks.com> + +Message-ID: +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Date: Wed, 05 Apr 2006 12:22:53 +0200 +In-Reply-To: +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.113 required=5 tests=[AWL=0.113, UPPERCASE_25_50=0] +X-Spam-Score: 0.113 +X-Spam-Level: +X-Archive-Number: 200604/56 +X-Sequence-Number: 18140 + + + +> UPDATE firma1.rid SET toode=NULL +> WHERE toode IS NOT NULL AND +> toode NOT IN (SELECT TOODE FROM firma1.TOODE); + + Why not use a LEFT JOIN for this ? + +From pgsql-performance-owner@postgresql.org Wed Apr 5 07:40:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9B5FF11F623C + for ; + Wed, 5 Apr 2006 07:40:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55041-04 + for ; + Wed, 5 Apr 2006 07:40:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 7EFC811F6212 + for ; + Wed, 5 Apr 2006 07:40:40 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id F161530F1B; Wed, 5 Apr 2006 12:40:39 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: Re: Query runs too long for indexed tables +Date: Wed, 5 Apr 2006 13:40:25 +0300 +Organization: Hub.Org Networking Services +Lines: 15 +Message-ID: +References: + <1144180128.32266.56.camel@state.g2switchworks.com> + +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 +X-RFC2646: Format=Flowed; Response +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.129 required=5 tests=[AWL=0.129, UPPERCASE_25_50=0] +X-Spam-Score: 0.129 +X-Spam-Level: +X-Archive-Number: 200604/57 +X-Sequence-Number: 18141 + +> Why not use a LEFT JOIN for this ? + +UPDATE firma1.rid SET rid.toode=NULL +LEFT join firma1.toode using(toode) + WHERE rid.toode IS NOT NULL AND toode.toode IS NULL; + +Causes: + +ERROR: syntax error at or near "LEFT" at character 41 + +outer joins are not supported in Postgres UPDATE command. + +Andrus. + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 08:24:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AC6E211F6225 + for ; + Wed, 5 Apr 2006 08:24:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61096-02 + for ; + Wed, 5 Apr 2006 08:24:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id C458C11F623C + for ; + Wed, 5 Apr 2006 08:24:41 -0300 (ADT) +Received: (qmail 11304 invoked from network); 5 Apr 2006 13:25:06 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 5 Apr 2006 13:25:06 +0200 +To: Andrus , pgsql-performance@postgresql.org +Subject: Re: Query runs too long for indexed tables +References: + <1144180128.32266.56.camel@state.g2switchworks.com> + + +Message-ID: +Date: Wed, 05 Apr 2006 13:25:05 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.408 required=5 tests=[AWL=-0.183, + UPPERCASE_50_75=0.591] +X-Spam-Score: 0.408 +X-Spam-Level: +X-Archive-Number: 200604/58 +X-Sequence-Number: 18142 + +> outer joins are not supported in Postgres UPDATE command. + + True (and sad). + + You can try the following script to play with the various options : + + +DROP TABLE one; +DROP TABLE two; + +CREATE TABLE one (a SERIAL PRIMARY KEY, b INT NULL); +CREATE TABLE two (b INT NOT NULL PRIMARY KEY); +INSERT INTO two (b) SELECT x*2 FROM generate_series( 1, 50000 ) AS x; +INSERT INTO one (b) SELECT x FROM generate_series( 1, 100000 ) AS x; + +EXPLAIN ANALYZE SELECT count(*) FROM one LEFT JOIN two ON one.b=two.b +WHERE two.b IS NULL; + +--Try with and without... +--CREATE INDEX one_b ON one(b); + +VACUUM ANALYZE one; +VACUUM ANALYZE two; + +EXPLAIN ANALYZE SELECT count(*) FROM one LEFT JOIN two ON one.b=two.b +WHERE two.b IS NULL; + +BEGIN; +EXPLAIN ANALYZE UPDATE one SET b=NULL WHERE b NOT IN (SELECT b FROM two ); +SELECT * FROM one ORDER BY a LIMIT 5; +ROLLBACK; +VACUUM one; + +BEGIN; +EXPLAIN ANALYZE UPDATE one SET b=NULL WHERE b IN (SELECT one.b FROM one +LEFT JOIN two ON one.b=two.b WHERE two.b IS NULL); +SELECT * FROM one ORDER BY a LIMIT 5; +ROLLBACK; +VACUUM one; + +BEGIN; +EXPLAIN ANALYZE UPDATE one SET b=NULL FROM one x LEFT JOIN two ON +x.b=two.b WHERE two.b IS NULL AND one.a=x.a; +SELECT * FROM one ORDER BY a LIMIT 5; +ROLLBACK; +VACUUM one; + +BEGIN; +EXPLAIN ANALYZE UPDATE one SET b=NULL FROM one x LEFT JOIN two ON +x.b=two.b WHERE two.b IS NULL AND one.b=x.b; +SELECT * FROM one ORDER BY a LIMIT 5; +ROLLBACK; +VACUUM one; + +BEGIN; +EXPLAIN ANALYZE UPDATE one SET b=(SELECT two.b FROM two WHERE two.b=one.b); +SELECT * FROM one ORDER BY a LIMIT 5; +ROLLBACK; +VACUUM one; + +BEGIN; +EXPLAIN ANALYZE UPDATE one SET b=NULL WHERE NOT EXISTS (SELECT 1 FROM two +WHERE two.b = one.b); +SELECT * FROM one ORDER BY a LIMIT 5; +ROLLBACK; +VACUUM one; + +BEGIN; +CREATE TABLE tmp AS SELECT one.a, two.b FROM one LEFT JOIN two ON +one.b=two.b; +SELECT * FROM tmp ORDER BY a LIMIT 5; +DROP TABLE one; +ALTER TABLE tmp RENAME TO one; +ROLLBACK; + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 11:10:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E36CE11F65B8 + for ; + Wed, 5 Apr 2006 11:10:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98015-01 + for ; + Wed, 5 Apr 2006 11:10:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 4356811F621E + for ; + Wed, 5 Apr 2006 11:09:57 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k35E9t5N027544; + Wed, 5 Apr 2006 10:09:55 -0400 (EDT) +To: "Andrus" +cc: pgsql-performance@postgresql.org +Subject: Re: Query runs too long for indexed tables +In-reply-to: +References: + <1144180128.32266.56.camel@state.g2switchworks.com> + +Comments: In-reply-to "Andrus" + message dated "Wed, 05 Apr 2006 12:39:46 +0300" +Date: Wed, 05 Apr 2006 10:09:55 -0400 +Message-ID: <27543.1144246195@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114, UPPERCASE_25_50=0] +X-Spam-Score: 0.114 +X-Spam-Level: +X-Archive-Number: 200604/59 +X-Sequence-Number: 18143 + +"Andrus" writes: +> UPDATE firma1.rid SET toode=NULL +> WHERE toode IS NOT NULL AND +> toode NOT IN (SELECT TOODE FROM firma1.TOODE); + +> How to speed this up ? + +Increasing work_mem to the point where you get a hashed NOT-IN would +help, probably. Have you tried using EXPLAIN to see what the plan is +for the UPDATEs? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 5 15:14:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A695111F677A + for ; + Wed, 5 Apr 2006 15:14:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20579-09 + for ; + Wed, 5 Apr 2006 15:14:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp1.wholefoods.com (smtp1.wholefoods.com [64.132.0.20]) + by postgresql.org (Postfix) with ESMTP id C36B911F6600 + for ; + Wed, 5 Apr 2006 15:14:34 -0300 (ADT) +Received: from unknown (HELO wfm-exchprd2.wfm.pvt) ([10.2.2.22]) + by smtp1.wholefoods.com with ESMTP; 05 Apr 2006 13:15:06 -0500 +X-IronPort-AV: i="4.03,167,1141624800"; + d="scan'208,217"; a="23158151:sNHT37278094" +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C658DC.CA3F1D3D" +Subject: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Wed, 5 Apr 2006 13:12:54 -0500 +Message-ID: <7583B3F1891CC0429FA4A44952AA539C66FA2C@wfm-exchprd2.wfm.pvt> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZY2tjXfVRhB87QTyyEQXkYWR91JAAAagag +From: "Juan Casero \(FL FLC\)" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200604/60 +X-Sequence-Number: 18144 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C658DC.CA3F1D3D +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Greetings - +=20 +I am testing a Sun Microsystems Sun Fire T2000 demo server at our +company. I want to know if anyone here has any experience with this +hardware and postgresql 8.1.3. I installed the copy of postgresql 8.1.3 +from blastwave.org onto this demo box and loaded our production database +into it. This box has a single Ultrasparc T1 cpu with six execution +piplelines that can each handle 4 threads. With the Unix top utility +the postgresql server appears to bounce around between the available +threads on the system. For example I run a single large query and I can +see the postgresql server sometimes running on cpu/0, other times on +cpu/1, cpu/3,....etc up to cpu/23. However, never is the load for the +postgres server reported to be higher than 4.16%. I did the math and +4.16% x 24 threads =3D 98.84% cpu load. So I wonder if the Solaris 10 +kernel is somehow throttling the processes so that any single virtual +processor can do no more than 4.16% load. We got this server last week +and I was able to install it in our rack just yesterday. Now I need to +see how I can optimize the postgresql server to work on this box. Does +anyone have any suggestions? I know the postgresql server is not smp +aware but I believe parts of it are. In particular the buffer manager +is supposed to scale the performance almost linearly with the number of +cpu's (including virtual ones). I don't know however, if I need to +recompile the postgresql server myself to get those benefits. I am +using the version of postgresql 8.1.3 that is available on +blastwave.org. I am also working with the 64 bit version of the +database server. This machine has over 8GB of ram so I was thinking of +using the 64 bit version of the postgresql server so I can access ram +beyong the 4gb limit imposed by 32 bit addressing. Any help or +recommendations for performance tweaking of postgresql is very much +appreciated. +=20 +=20 +Thanks, +Juan + +------_=_NextPart_001_01C658DC.CA3F1D3D +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + +
Greetings -
+
 
+
I am = +testing a Sun=20 +Microsystems Sun Fire T2000 demo server at our company.   I = +want to=20 +know if anyone here has any experience with this hardware and postgresql = + +8.1.3.  I installed the copy of postgresql 8.1.3 from blastwave.org = +onto=20 +this demo box and loaded our production database into it.  This box = +has a=20 +single Ultrasparc T1 cpu with six execution piplelines that can each = +handle 4=20 +threads.  With the Unix top utility the postgresql server appears = +to bounce=20 +around between the available threads on the system.  For example I = +run a=20 +single large query and I can see the postgresql server sometimes running = +on=20 +cpu/0, other times on cpu/1, cpu/3,....etc up to cpu/23.   = +However,=20 +never is the load for the postgres server reported to be higher than=20 +4.16%.  I did the math and 4.16% x 24 threads =3D 98.84% cpu = +load.  So I=20 +wonder if the Solaris 10 kernel is somehow throttling the processes = +so that=20 +any single virtual processor can do no more than 4.16% load.  We = +got this=20 +server last week and I was able to install it in our rack just=20 +yesterday.   Now I need to see how I can optimize the = +postgresql=20 +server to work on this box.  Does anyone have any = +suggestions?  =20 +I know the postgresql server is not smp aware but I believe parts of it=20 +are.  In particular the buffer manager is supposed to scale the = +performance=20 +almost linearly with the number of cpu's (including virtual ones).  = +I don't=20 +know however, if I need to recompile the postgresql server myself to get = +those=20 +benefits.   I am using the version of postgresql 8.1.3 that is = + +available on blastwave.org.  I am also working with the 64 bit = +version of=20 +the database server.   This machine has over 8GB of ram so I = +was=20 +thinking of using the 64 bit version of the postgresql server so I = +can=20 +access ram beyong the 4gb limit imposed by 32 bit addressing.  Any = +help or=20 +recommendations for performance tweaking of postgresql is very much=20 +appreciated.
+
 
+
 
+
Thanks,
+
Juan
+ +------_=_NextPart_001_01C658DC.CA3F1D3D-- + +From pgsql-performance-owner@postgresql.org Wed Apr 5 16:04:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AA24411F6791 + for ; + Wed, 5 Apr 2006 16:04:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61346-03 + for ; + Wed, 5 Apr 2006 16:04:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 397C111F67D7 + for ; + Wed, 5 Apr 2006 16:04:05 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k35J443A012501; + Wed, 5 Apr 2006 15:04:04 -0400 (EDT) +To: "Juan Casero \(FL FLC\)" +cc: pgsql-performance@postgresql.org +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +In-reply-to: <7583B3F1891CC0429FA4A44952AA539C66FA2C@wfm-exchprd2.wfm.pvt> +References: <7583B3F1891CC0429FA4A44952AA539C66FA2C@wfm-exchprd2.wfm.pvt> +Comments: In-reply-to "Juan Casero \(FL FLC\)" + message dated "Wed, 05 Apr 2006 13:12:54 -0500" +Date: Wed, 05 Apr 2006 15:04:04 -0400 +Message-ID: <12500.1144263844@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] +X-Spam-Score: 0.114 +X-Spam-Level: +X-Archive-Number: 200604/61 +X-Sequence-Number: 18145 + +"Juan Casero \(FL FLC\)" writes: +> ... This box has a single Ultrasparc T1 cpu with six execution +> piplelines that can each handle 4 threads. With the Unix top utility +> the postgresql server appears to bounce around between the available +> threads on the system. + +Try sending it more than one query at a time? If you're testing with +just one client connection issuing queries, that's about what I'd expect. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 5 17:43:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BFC1611F655B + for ; + Wed, 5 Apr 2006 17:43:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25182-09 + for ; + Wed, 5 Apr 2006 17:43:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by postgresql.org (Postfix) with ESMTP id 24C0A11F6269 + for ; + Wed, 5 Apr 2006 17:43:43 -0300 (ADT) +Received: from 172.16.1.112 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Wed, 05 Apr 2006 16:43:32 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 5 Apr + 2006 16:43:31 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 5 Apr + 2006 20:43:31 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 05 Apr 2006 13:43:29 -0700 +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +From: "Luke Lonergan" +To: "Juan Casero (FL FLC)" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZY2tjXfVRhB87QTyyEQXkYWR91JAAAagagAAVFz+o= +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA2C@wfm-exchprd2.wfm.pvt> +MIME-Version: 1.0 +X-OriginalArrivalTime: 05 Apr 2006 20:43:31.0574 (UTC) + FILETIME=[99B47160:01C658F1] +X-WSS-ID: 682AF47E20C39709062-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.345 required=5 tests=[AWL=0.092, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.345 +X-Spam-Level: * +X-Archive-Number: 200604/62 +X-Sequence-Number: 18146 + +Juan, + +On 4/5/06 11:12 AM, "Juan Casero (FL FLC)" +wrote: + +> I know the postgresql server is not smp aware but I believe +> parts of it are. In particular the buffer manager is supposed to scale the +> performance almost linearly with the number of cpu's (including virtual ones). +> I don't know however, if I need to recompile the postgresql server myself to +> get those benefits. + +As Tom said, to get the benefits of parallelism on one query, you would need +a parallelizing database like Teradata, Oracle Parallel Query option, +Netezza, or Bizgres MPP. + +The announcement about Postgres linear scalability for SMP is only relevant +to statement throughput for highly concurrent environments (web sites, OLTP, +etc). + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 17:56:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6EA3611F6784 + for ; + Wed, 5 Apr 2006 17:56:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16549-04 + for ; + Wed, 5 Apr 2006 17:56:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp1.wholefoods.com (smtp1.wholefoods.com [64.132.0.20]) + by postgresql.org (Postfix) with ESMTP id 3C38B11F678B + for ; + Wed, 5 Apr 2006 17:56:32 -0300 (ADT) +Received: from unknown (HELO wfm-exchprd2.wfm.pvt) ([10.2.2.22]) + by smtp1.wholefoods.com with ESMTP; 05 Apr 2006 15:57:03 -0500 +X-IronPort-AV: i="4.04,91,1144040400"; d="scan'208"; a="23178678:sNHT30615333" +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Wed, 5 Apr 2006 15:54:49 -0500 +Message-ID: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZY2tjXfVRhB87QTyyEQXkYWR91JAAAagagAAVFz+oAAEdD8A== +From: "Juan Casero \(FL FLC\)" +To: "Luke Lonergan" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200604/63 +X-Sequence-Number: 18147 + +I am not sure about this. I mean I have postgresql 8.1.3 running on my +Windows XP P4 HT laptop that I use for testing my webapps. When I hit +this pgsql on this laptop with a large query I can see the load spike up +really high on both of my virtual processors. Whatever, pgsql is doing +it looks like both cpu's are being used indepently. The usage curve is +not identical on both of them that makes me think that parts of the +server are multithreaded. Admittedly I am not familiar with the source +code fo postgresql so I was hoping maybe one of the developers who is +could definitely answer this question. + +Thanks, +Juan + +-----Original Message----- +From: Luke Lonergan [mailto:llonergan@greenplum.com]=20 +Sent: Wednesday, April 05, 2006 4:43 PM +To: Juan Casero (FL FLC); pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 + +Juan, + +On 4/5/06 11:12 AM, "Juan Casero (FL FLC)" +wrote: + +> I know the postgresql server is not smp aware but I believe parts of=20 +> it are. In particular the buffer manager is supposed to scale the=20 +> performance almost linearly with the number of cpu's (including +virtual ones). +> I don't know however, if I need to recompile the postgresql server=20 +> myself to get those benefits. + +As Tom said, to get the benefits of parallelism on one query, you would +need a parallelizing database like Teradata, Oracle Parallel Query +option, Netezza, or Bizgres MPP. + +The announcement about Postgres linear scalability for SMP is only +relevant to statement throughput for highly concurrent environments (web +sites, OLTP, etc). + +- Luke + +From pgsql-performance-owner@postgresql.org Wed Apr 5 18:31:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3EB6F11F66CE + for ; + Wed, 5 Apr 2006 18:31:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98543-03 + for ; + Wed, 5 Apr 2006 18:31:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id 16BF411F66E5 + for ; + Wed, 5 Apr 2006 18:31:28 -0300 (ADT) +Received: from dell.home.lan (host14-128.pool8251.interbusiness.it + [82.51.128.14]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k35MYFr16778; + Thu, 6 Apr 2006 00:34:15 +0200 +Subject: Re: bad performance on Solaris 10 +From: Chris Mair +To: pgsql-performance@postgresql.org +Cc: markir@paradise.net.nz, josh@agliodbs.com, llonergan@greenplum.com +In-Reply-To: <1144111178.3723.80.camel@dell.home.lan> +References: <1144111178.3723.80.camel@dell.home.lan> +Content-Type: text/plain +Date: Wed, 05 Apr 2006 23:31:25 +0200 +Message-Id: <1144272685.4562.43.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/64 +X-Sequence-Number: 18148 + +Hi, + +thanks for all replys. + +I've done a few tests. + +Remounting the fs where $PGDATA lives with "forcedirectio" +(together with logging, that is default) did not help +(if not harm...) performance. + +Doing what http://blogs.sun.com/roller/page/jkshah suggests: + wal_sync_method = fsync (unchanged) + wal_buffers = 128 (was 8) + checkpoint_segments = 128 (was 3) + bgwriter_all_percent = 0 (was 0.333) + bgwriter_all_maxpages = 0 (was 5) +and leaving everything else default (solarispackages from pgfoundry) +increased performance ~ 7 times! + +Playing around with these modifications I find that it's +actually just the + wal_buffers = 128 +alone which makes all the difference! + +Quickly playing around with wal_buffers on Linux and Mac OS X +I see it influences the performance of my test a bit, maybe in the +10-20% range (I'm really doing quick tests, nothing systematic), +but nowhere near as spectacularly as on Solaris. + +I'm happy so far, but I find it very surprising that this single +parameter has such an impact (only on) Solaris 10. + +(my test program is a bulk inserts using PQputCopyData in large +transactions - all test were 8.1.3). + +Bye, Chris + + + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 18:37:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 277FA11F66D8 + for ; + Wed, 5 Apr 2006 18:37:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17234-08 + for ; + Wed, 5 Apr 2006 18:37:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id B3F8311F66CE + for ; + Wed, 5 Apr 2006 18:37:32 -0300 (ADT) +Received: from 172.16.1.148 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Wed, 05 Apr 2006 17:37:30 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01HOST02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 5 Apr + 2006 17:37:30 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 5 Apr + 2006 21:37:30 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 05 Apr 2006 14:37:28 -0700 +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +From: "Luke Lonergan" +To: "Juan Casero (FL FLC)" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZY2tjXfVRhB87QTyyEQXkYWR91JAAAagagAAVFz+oAAEdD8AABm2MG +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> +MIME-Version: 1.0 +X-OriginalArrivalTime: 05 Apr 2006 21:37:30.0238 (UTC) + FILETIME=[241959E0:01C658F9] +X-WSS-ID: 682AE7100NK2394430-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.345 required=5 tests=[AWL=0.092, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.345 +X-Spam-Level: * +X-Archive-Number: 200604/65 +X-Sequence-Number: 18149 + +Juan, + +On 4/5/06 1:54 PM, "Juan Casero (FL FLC)" +wrote: + +> I am not sure about this. I mean I have postgresql 8.1.3 running on my +> Windows XP P4 HT laptop that I use for testing my webapps. When I hit +> this pgsql on this laptop with a large query I can see the load spike up +> really high on both of my virtual processors. Whatever, pgsql is doing +> it looks like both cpu's are being used indepently. The usage curve is +> not identical on both of them that makes me think that parts of the +> server are multithreaded. Admittedly I am not familiar with the source +> code fo postgresql so I was hoping maybe one of the developers who is +> could definitely answer this question. + +There's no part of the Postgres backend that is threaded or multi-processed. +A reasonable explanation for your windows experience is that your web server +or the psql client may be taking some CPU cycles while the backend is +processing your query. Also, depending on how the CPU load is reported, if +the OS is doing prefetching of I/O, it might show up as load. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 18:40:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3B26F11F66CE + for ; + Wed, 5 Apr 2006 18:40:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94839-05 + for ; + Wed, 5 Apr 2006 18:40:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id 61C8911F66EB + for ; + Wed, 5 Apr 2006 18:40:24 -0300 (ADT) +Received: from 172.16.1.110 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Wed, 05 Apr 2006 17:40:16 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 5 Apr + 2006 17:40:16 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 5 Apr + 2006 21:40:15 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 05 Apr 2006 14:40:14 -0700 +Subject: Re: bad performance on Solaris 10 +From: "Luke Lonergan" +To: "Chris Mair" , + pgsql-performance@postgresql.org +cc: markir@paradise.net.nz, + "Josh Berkus" +Message-ID: +Thread-Topic: [PERFORM] bad performance on Solaris 10 +Thread-Index: AcZY+FrURFljMLR4SNKDeWRcbV2MogAASrjh +In-Reply-To: <1144272685.4562.43.camel@dell.home.lan> +MIME-Version: 1.0 +X-OriginalArrivalTime: 05 Apr 2006 21:40:16.0605 (UTC) + FILETIME=[8742F0D0:01C658F9] +X-WSS-ID: 682AE6CA0NK2395623-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.346 required=5 tests=[AWL=0.093, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.346 +X-Spam-Level: * +X-Archive-Number: 200604/66 +X-Sequence-Number: 18150 + +Chris, + +On 4/5/06 2:31 PM, "Chris Mair" wrote: + +> Doing what http://blogs.sun.com/roller/page/jkshah suggests: +> wal_sync_method = fsync (unchanged) +> wal_buffers = 128 (was 8) +> checkpoint_segments = 128 (was 3) +> bgwriter_all_percent = 0 (was 0.333) +> bgwriter_all_maxpages = 0 (was 5) +> and leaving everything else default (solarispackages from pgfoundry) +> increased performance ~ 7 times! + +In the recent past, Jignesh Shaw of Sun MDE discovered that changing the +bgwriter_* parameters to zero had a dramatic positive impact on performance. + +There are also some critical UFS kernel tuning parameters to set, you should +find those in his blog. + +We found and fixed some libpq issues with Solaris that were also critical - +they should be in 8.1.3 I think. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 18:46:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9E5FC11F66E5 + for ; + Wed, 5 Apr 2006 18:46:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03591-08 + for ; + Wed, 5 Apr 2006 18:46:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp1.wholefoods.com (smtp1.wholefoods.com [64.132.0.20]) + by postgresql.org (Postfix) with ESMTP id 6C2A311F66CA + for ; + Wed, 5 Apr 2006 18:46:45 -0300 (ADT) +Received: from unknown (HELO wfm-exchprd2.wfm.pvt) ([10.2.2.22]) + by smtp1.wholefoods.com with ESMTP; 05 Apr 2006 16:47:16 -0500 +X-IronPort-AV: i="4.04,91,1144040400"; + d="scan'208"; a="23183650:sNHT116236799" +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Wed, 5 Apr 2006 16:45:03 -0500 +Message-ID: <7583B3F1891CC0429FA4A44952AA539C66FA77@wfm-exchprd2.wfm.pvt> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZY2tjXfVRhB87QTyyEQXkYWR91JAAAagagAAVFz+oAAEdD8AABm2MGAAAzVGA= +From: "Juan Casero \(FL FLC\)" +To: "Luke Lonergan" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +X-Spam-Score: 0.096 +X-Spam-Level: +X-Archive-Number: 200604/67 +X-Sequence-Number: 18151 + +Luke (or anyone else who may be following this thread) + +Do you think bizgres might be a good choice of database server for the +Ultrasparc T1 based T2000? I have downloaded the source code but I was +hoping to find out if the potential performance gains were worth the +effort to compile and install the code. + +Thanks, +Juan=20 + +-----Original Message----- +From: Luke Lonergan [mailto:llonergan@greenplum.com]=20 +Sent: Wednesday, April 05, 2006 5:37 PM +To: Juan Casero (FL FLC); pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 + +Juan, + +On 4/5/06 1:54 PM, "Juan Casero (FL FLC)" +wrote: + +> I am not sure about this. I mean I have postgresql 8.1.3 running on=20 +> my Windows XP P4 HT laptop that I use for testing my webapps. When I=20 +> hit this pgsql on this laptop with a large query I can see the load=20 +> spike up really high on both of my virtual processors. Whatever,=20 +> pgsql is doing it looks like both cpu's are being used indepently. The + +> usage curve is not identical on both of them that makes me think that=20 +> parts of the server are multithreaded. Admittedly I am not familiar=20 +> with the source code fo postgresql so I was hoping maybe one of the=20 +> developers who is could definitely answer this question. + +There's no part of the Postgres backend that is threaded or +multi-processed. +A reasonable explanation for your windows experience is that your web +server or the psql client may be taking some CPU cycles while the +backend is processing your query. Also, depending on how the CPU load +is reported, if the OS is doing prefetching of I/O, it might show up as +load. + +- Luke + +From pgsql-performance-owner@postgresql.org Wed Apr 5 18:48:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C3EB311F66C1 + for ; + Wed, 5 Apr 2006 18:48:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39862-09 + for ; + Wed, 5 Apr 2006 18:48:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx3.surnet.cl (mx3.surnet.cl [216.155.73.182]) + by postgresql.org (Postfix) with ESMTP id 7D1D611F66CA + for ; + Wed, 5 Apr 2006 18:48:26 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx3.surnet.cl with ESMTP; 05 Apr 2006 17:48:24 -0400 +X-IronPort-AV: i="4.03,167,1141614000"; + d="scan'208"; a="2525055:sNHT206504616" +Received: from alvh.no-ip.org (201.220.123.5) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD00D8F31C; Wed, 5 Apr 2006 17:48:25 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id AD108C2DC22; Wed, 5 Apr 2006 17:48:24 -0400 (CLT) +Date: Wed, 5 Apr 2006 17:48:24 -0400 +From: Alvaro Herrera +To: Luke Lonergan +Cc: Chris Mair , pgsql-performance@postgresql.org, + markir@paradise.net.nz, Josh Berkus +Subject: Re: bad performance on Solaris 10 +Message-ID: <20060405214824.GB13673@surnet.cl> +Mail-Followup-To: Luke Lonergan , + Chris Mair , pgsql-performance@postgresql.org, + markir@paradise.net.nz, Josh Berkus +References: <1144272685.4562.43.camel@dell.home.lan> + +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.11+cvs20060330 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.679 required=5 tests=[AWL=-0.240, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +X-Spam-Score: 1.679 +X-Spam-Level: * +X-Archive-Number: 200604/68 +X-Sequence-Number: 18152 + +Luke Lonergan wrote: +> Chris, +> +> On 4/5/06 2:31 PM, "Chris Mair" wrote: +> +> > Doing what http://blogs.sun.com/roller/page/jkshah suggests: +> > wal_sync_method = fsync (unchanged) +> > wal_buffers = 128 (was 8) +> > checkpoint_segments = 128 (was 3) +> > bgwriter_all_percent = 0 (was 0.333) +> > bgwriter_all_maxpages = 0 (was 5) +> > and leaving everything else default (solarispackages from pgfoundry) +> > increased performance ~ 7 times! +> +> In the recent past, Jignesh Shaw of Sun MDE discovered that changing the +> bgwriter_* parameters to zero had a dramatic positive impact on performance. + +This essentially means stopping all bgwriter activity, thereby deferring +all I/O until checkpoint. Was this considered? With +checkpoint_segments to 128, it wouldn't surprise me that there wasn't +any checkpoint executed at all during the whole test ... + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Wed Apr 5 18:54:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8E17111F66F3 + for ; + Wed, 5 Apr 2006 18:54:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76988-10 + for ; + Wed, 5 Apr 2006 18:54:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id D37A211F66E8 + for ; + Wed, 5 Apr 2006 18:54:25 -0300 (ADT) +Received: from 172.16.1.148 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Wed, 05 Apr 2006 17:54:16 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01HOST02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 5 Apr + 2006 17:54:15 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 5 Apr + 2006 21:54:15 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 05 Apr 2006 14:54:13 -0700 +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +From: "Luke Lonergan" +To: "Juan Casero (FL FLC)" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: + AcZY2tjXfVRhB87QTyyEQXkYWR91JAAAagagAAVFz+oAAEdD8AABm2MGAAAzVGAAAGJtiA== +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA77@wfm-exchprd2.wfm.pvt> +MIME-Version: 1.0 +X-OriginalArrivalTime: 05 Apr 2006 21:54:15.0272 (UTC) + FILETIME=[7B255E80:01C658FB] +X-WSS-ID: 682AE3F32XS40480620-20-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.346 required=5 tests=[AWL=0.093, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.346 +X-Spam-Level: * +X-Archive-Number: 200604/69 +X-Sequence-Number: 18153 + +Juan, + +On 4/5/06 2:45 PM, "Juan Casero (FL FLC)" +wrote: + +> Do you think bizgres might be a good choice of database server for the +> Ultrasparc T1 based T2000? I have downloaded the source code but I was +> hoping to find out if the potential performance gains were worth the +> effort to compile and install the code. + +Bizgres (non-MPP) does not do any multi-CPU parallelism, so it won't use +more CPUs in your T2000. It does have the faster sort performance and an +on-disk bitmap index, both of which will make it run many times (3-6) faster +than 8.1 Postgres depending if your queries use larger data or involve +sorts. + +Bizgres MPP is closed source and unfortunately for your T2000 experiment it +doesn't currently support Solaris SPARC CPUs, only Solaris x86. It would +use all of your CPUs and I/O channels on one or more machines for every +query. Again, it's optimized for queries where that use a lot of data or +have a lot of complexity (sorts, aggregations, joins, etc). + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 18:56:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CFDA311F662B + for ; + Wed, 5 Apr 2006 18:56:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16463-04 + for ; + Wed, 5 Apr 2006 18:56:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id 95A2E11F6621 + for ; + Wed, 5 Apr 2006 18:56:52 -0300 (ADT) +Received: from 172.16.1.148 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Wed, 05 Apr 2006 17:56:43 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01HOST02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 5 Apr + 2006 17:56:42 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 5 Apr + 2006 21:56:42 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 05 Apr 2006 14:56:40 -0700 +Subject: Re: bad performance on Solaris 10 +From: "Luke Lonergan" +To: "Alvaro Herrera" +cc: "Chris Mair" , pgsql-performance@postgresql.org, + markir@paradise.net.nz, "Josh Berkus" +Message-ID: +Thread-Topic: [PERFORM] bad performance on Solaris 10 +Thread-Index: AcZY+rMPuviuQTXWSlCsqJfrhcTJsgAAR5Yd +In-Reply-To: <20060405214824.GB13673@surnet.cl> +MIME-Version: 1.0 +X-OriginalArrivalTime: 05 Apr 2006 21:56:42.0817 (UTC) + FILETIME=[D316F310:01C658FB] +X-WSS-ID: 682AE2912XS40481941-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.347 required=5 tests=[AWL=0.094, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.347 +X-Spam-Level: * +X-Archive-Number: 200604/70 +X-Sequence-Number: 18154 + +Alvaro, + +On 4/5/06 2:48 PM, "Alvaro Herrera" wrote: + +> This essentially means stopping all bgwriter activity, thereby deferring +> all I/O until checkpoint. Was this considered? With +> checkpoint_segments to 128, it wouldn't surprise me that there wasn't +> any checkpoint executed at all during the whole test ... + +Yes, many things about the Solaris UFS filesystem caused a great deal of +pain over the 10 months of experiments we ran with Sun MDE. Ultimately, the +conclusion was that ZFS is going to make all of the pain go away. + +In the meantime, all you can do is tweak up UFS and avoid I/O as much as +possible. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 18:58:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F278111F662B + for ; + Wed, 5 Apr 2006 18:58:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37948-01 + for ; + Wed, 5 Apr 2006 18:58:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 6146511F6621 + for ; + Wed, 5 Apr 2006 18:58:47 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 48A4E30F1A; Wed, 5 Apr 2006 23:58:47 +0200 (MET DST) +From: August Zajonc +X-Newsgroups: pgsql.performance +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Wed, 05 Apr 2006 14:58:49 -0700 +Organization: Hub.Org Networking Services +Lines: 25 +Message-ID: +References: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Thunderbird 1.5 (Windows/20051201) +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +X-Spam-Score: 0.096 +X-Spam-Level: +X-Archive-Number: 200604/71 +X-Sequence-Number: 18155 + +Juan Casero (FL FLC) wrote: +> When I hit +> this pgsql on this laptop with a large query I can see the load spike up +> really high on both of my virtual processors. Whatever, pgsql is doing +> it looks like both cpu's are being used indepently. + +Intel HT was partly a marketing thing, you don't really get two CPU's / +cores etc. The virtual CPU is really that, there is only one cpu doing +the actual work with some extra glue to help the "hyperthreading". + +As to how hyper intel's hyperthreading is, OSDL did some testing (I +think the dbt2 workload) and I remember HT reducing performance for +pgsql by about 15%. Worth looking up, benchmarks are subject to a lot of +issues but was interesting. + +There have been some seriously good recommendations in this newsgroup +for nice high powered servers, including good disk subsystems. + +Most involve some AMD Opertons, lots of spindles with a good raid +controller preferred to one or two large disks and a good helping of +ram. Be interesting to get some numbers on the sunfire machine. + +- August + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 19:03:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ED58C11F66CE + for ; + Wed, 5 Apr 2006 19:03:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14626-07 + for ; + Wed, 5 Apr 2006 19:03:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id 20EFD11F66EE + for ; + Wed, 5 Apr 2006 19:03:12 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO [192.168.1.27]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9217337; Wed, 05 Apr 2006 15:06:12 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Wed, 5 Apr 2006 15:01:39 -0700 +User-Agent: KMail/1.8 +Cc: "Juan Casero \(FL FLC\)" , + "Luke Lonergan" +References: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604051501.40109.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200604/72 +X-Sequence-Number: 18156 + +Juan, + +> When I hit +> this pgsql on this laptop with a large query I can see the load spike up +> really high on both of my virtual processors. Whatever, pgsql is doing +> it looks like both cpu's are being used indepently. + +Nope, sorry, you're being decieved. Postgres is strictly one process, one +query. + +You can use Bizgres MPP to achieve multithreading; it's proprietary and you +have to pay for it. It does work well, though. + +More importantly, though, you haven't really explained why you care about +multithreading. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Apr 5 19:07:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A3DEF11F6621 + for ; + Wed, 5 Apr 2006 19:07:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91125-01 + for ; + Wed, 5 Apr 2006 19:07:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 8835C11F60B5 + for ; + Wed, 5 Apr 2006 19:07:37 -0300 (ADT) +Received: from [10.180.0.159] (unknown [66.228.91.67]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by noel.decibel.org (Postfix) with ESMTP id 8209C56408; + Wed, 5 Apr 2006 17:07:33 -0500 (CDT) +In-Reply-To: +References: <4431C4B4.4090300@123.com.sv> <4431D591.30500@paradise.net.nz> + +Mime-Version: 1.0 (Apple Message framework v746.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: Postgresql Performance +Content-Transfer-Encoding: 7bit +From: Jim Nasby +Subject: Re: freebsd/softupdates for data dir +Date: Wed, 5 Apr 2006 18:07:30 -0400 +To: Vivek Khera +X-Mailer: Apple Mail (2.746.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.446 required=5 tests=[AWL=0.446] +X-Spam-Score: 0.446 +X-Spam-Level: +X-Archive-Number: 200604/73 +X-Sequence-Number: 18157 + +On Apr 4, 2006, at 10:41 AM, Vivek Khera wrote: +> On Apr 3, 2006, at 10:10 PM, Mark Kirkwood wrote: +> +>> I've always left them on, and never had any issues...(even after +>> unscheduled power loss - which happened here yesterday). As I +>> understand it, the softupdate code reorders *metadata* operations, +>> and does not alter data operations - so the effect of fysnc(2) on +>> a preexisting file is not changed by softupdates being on or off. +> +> This is also my understanding, and I also leave softupdates on for +> the data partition. Even if it doesn't improve performance, it +> will not reduce it, and otherwise does no harm with respect to +> postgres' disk usage. + +More importantly, it allows the system to come up and do fsck in the +background. If you've got a large database that's a pretty big benefit. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 19:08:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5704B11F66E8 + for ; + Wed, 5 Apr 2006 19:08:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65645-04 + for ; + Wed, 5 Apr 2006 19:08:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 1796811F66D8 + for ; + Wed, 5 Apr 2006 19:08:29 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 5 Apr 2006 22:08:29 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 05 Apr 2006 17:08:29 -0500 +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +From: Scott Marlowe +To: "Juan Casero (FL FLC)" +Cc: Luke Lonergan , pgsql-performance@postgresql.org +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> +References: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1144274909.32266.91.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 05 Apr 2006 17:08:29 -0500 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.14 required=5 tests=[AWL=0.139, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.14 +X-Spam-Level: +X-Archive-Number: 200604/74 +X-Sequence-Number: 18158 + +On Wed, 2006-04-05 at 15:54, Juan Casero (FL FLC) wrote: +> I am not sure about this. I mean I have postgresql 8.1.3 running on my +> Windows XP P4 HT laptop that I use for testing my webapps. When I hit +> this pgsql on this laptop with a large query I can see the load spike up +> really high on both of my virtual processors. Whatever, pgsql is doing +> it looks like both cpu's are being used indepently. The usage curve is +> not identical on both of them that makes me think that parts of the +> server are multithreaded. Admittedly I am not familiar with the source +> code fo postgresql so I was hoping maybe one of the developers who is +> could definitely answer this question. + +I think that really depends on your workload. + +Are you going to have a dozen or so transactions running at a time? +then regular postgresql is probably ok. + +If you're gonna be running only one or two big, fat, hairy reporting +queries, then you might wanna look at the bizgress mpp version. + +Note that some queries lend themselves to parallel processing more than +others. + +From pgsql-performance-owner@postgresql.org Wed Apr 5 20:04:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8E70711F670E + for ; + Wed, 5 Apr 2006 20:04:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49156-09 + for ; + Wed, 5 Apr 2006 20:04:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id DF5A011F6709 + for ; + Wed, 5 Apr 2006 20:04:03 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 9313A30D28; Thu, 6 Apr 2006 01:04:03 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Wed, 05 Apr 2006 18:11:54 -0400 +Organization: cbbrowne Computing Inc +Lines: 21 +Message-ID: <60k6a3n045.fsf@dba2.int.libertyrms.com> +References: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) +Cancel-Lock: sha1:X8I+/bsBqsj891Jej8LqXjM33I0= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.306 required=5 tests=[AWL=0.306] +X-Spam-Score: 0.306 +X-Spam-Level: +X-Archive-Number: 200604/76 +X-Sequence-Number: 18160 + +Juan.Casero@wholefoods.com ("Juan Casero \(FL FLC\)") writes: +> I am not sure about this. I mean I have postgresql 8.1.3 running on +> my Windows XP P4 HT laptop that I use for testing my webapps. When +> I hit this pgsql on this laptop with a large query I can see the +> load spike up really high on both of my virtual processors. +> Whatever, pgsql is doing it looks like both cpu's are being used +> indepently. The usage curve is not identical on both of them that +> makes me think that parts of the server are multithreaded. + +This is almost certainly a function of the fact that you're running +the single-threaded backend process, which then feeds a +single-threaded front end process, namely the application that is +being fed data. + +For a query that returns a large return set, that will indeed make +both processors get pretty busy; one for the DB server, one for +whatever program is processing the results. +-- +select 'cbbrowne' || '@' || 'acm.org'; +http://www.ntlug.org/~cbbrowne/rdbms.html +It's hard to tell if someone is inconspicuous. + +From pgsql-performance-owner@postgresql.org Wed Apr 5 20:04:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E932611F670F + for ; + Wed, 5 Apr 2006 20:04:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40204-02 + for ; + Wed, 5 Apr 2006 20:04:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 52F7911F6745 + for ; + Wed, 5 Apr 2006 20:04:04 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 52CFA30DB2; Thu, 6 Apr 2006 01:04:04 +0200 (MET DST) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Wed, 05 Apr 2006 18:12:43 -0400 +Organization: cbbrowne Computing Inc +Lines: 19 +Message-ID: <60fykrn02s.fsf@dba2.int.libertyrms.com> +References: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> + <200604051501.40109.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) +Cancel-Lock: sha1:1+gil8K/dDQuoMzAS/1GJ0x/81E= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.306 required=5 tests=[AWL=0.306] +X-Spam-Score: 0.306 +X-Spam-Level: +X-Archive-Number: 200604/77 +X-Sequence-Number: 18161 + +josh@agliodbs.com (Josh Berkus) writes: +> Juan, +> +>> When I hit +>> this pgsql on this laptop with a large query I can see the load spike up +>> really high on both of my virtual processors. Whatever, pgsql is doing +>> it looks like both cpu's are being used indepently. +> +> Nope, sorry, you're being decieved. Postgres is strictly one process, one +> query. + +It's not entirely deception; there is indeed independent use of both +CPUs, it's just that it isn't from multithreading... +-- +output = reverse("gro.mca" "@" "enworbbc") +http://www.ntlug.org/~cbbrowne/internet.html +"Don't use C; In my opinion, C is a library programming language not +an app programming language." -- Owen Taylor (GTK+ and ORBit +developer) + +From pgsql-performance-owner@postgresql.org Wed Apr 5 19:24:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 90FE111F6706 + for ; + Wed, 5 Apr 2006 19:24:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74697-09 + for ; + Wed, 5 Apr 2006 19:24:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id CC2AF11F66FE + for ; + Wed, 5 Apr 2006 19:24:54 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k35MOlx7012746; + Wed, 5 Apr 2006 18:24:47 -0400 (EDT) +To: josh@agliodbs.com +cc: pgsql-performance@postgresql.org, + "Juan Casero \(FL FLC\)" , + "Luke Lonergan" +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +In-reply-to: <200604051501.40109.josh@agliodbs.com> +References: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> + <200604051501.40109.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Wed, 05 Apr 2006 15:01:39 -0700" +Date: Wed, 05 Apr 2006 18:24:47 -0400 +Message-ID: <12745.1144275887@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] +X-Spam-Score: 0.114 +X-Spam-Level: +X-Archive-Number: 200604/75 +X-Sequence-Number: 18159 + +Josh Berkus writes: +> Juan, +>> When I hit +>> this pgsql on this laptop with a large query I can see the load spike up +>> really high on both of my virtual processors. Whatever, pgsql is doing +>> it looks like both cpu's are being used indepently. + +> Nope, sorry, you're being decieved. Postgres is strictly one process, one +> query. + +This is not strictly true: we have for instance pushed off some work +into a "background writer" process, and even just having both a client +and a server process active allows some small amount of parallelism. +But you're certainly not going to see effective use of more than about +two CPUs on a single query stream ... at least not without Bizgres or +some other add-on. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 5 20:14:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DC6CC11F6724 + for ; + Wed, 5 Apr 2006 20:14:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76713-10 + for ; + Wed, 5 Apr 2006 20:14:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id CCD8B11F66D9 + for ; + Wed, 5 Apr 2006 20:14:01 -0300 (ADT) +Received: from dell.home.lan (host14-128.pool8251.interbusiness.it + [82.51.128.14]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k360Gjr17862; + Thu, 6 Apr 2006 02:16:45 +0200 +Subject: Re: bad performance on Solaris 10 +From: Chris Mair +To: Alvaro Herrera +Cc: Luke Lonergan , pgsql-performance@postgresql.org, + markir@paradise.net.nz, Josh Berkus +In-Reply-To: <20060405214824.GB13673@surnet.cl> +References: <1144272685.4562.43.camel@dell.home.lan> + + <20060405214824.GB13673@surnet.cl> +Content-Type: text/plain +Date: Thu, 06 Apr 2006 01:13:55 +0200 +Message-Id: <1144278835.5133.11.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.06 required=5 tests=[AWL=0.060] +X-Spam-Score: 0.06 +X-Spam-Level: +X-Archive-Number: 200604/78 +X-Sequence-Number: 18162 + + +> > > Doing what http://blogs.sun.com/roller/page/jkshah suggests: +> > > wal_sync_method = fsync (unchanged) +> > > wal_buffers = 128 (was 8) +> > > checkpoint_segments = 128 (was 3) +> > > bgwriter_all_percent = 0 (was 0.333) +> > > bgwriter_all_maxpages = 0 (was 5) +> > > and leaving everything else default (solarispackages from pgfoundry) +> > > increased performance ~ 7 times! + +Ok, so I could quite believe my own benchmarks and I decided +to do a fresh initdb and retry everything. + +At first it looked like I coudn't reproduce the speed up I just saw. + +Then I realized it was the +wal_sync_method = fsync +line that makes all the difference! + +Normally parameters that are commented are default values, but for +wal_sync_method it actually says (note the comment): + +wal_sync_method = fsync # the default is the first option + # supported by the operating system: + # open_datasync + # fdatasync + # fsync + # fsync_writethrough + # open_sync + +So Im my last mail I drew the wrong conclusion, because i didn't comment +wal_sync_method to double check. + +To the point: the default wal_sync_method choosen on Solaris 10 appears +to be a very bad one - for me, picking fsync increases performance ~ +times 7, all other parameters unchanged! + +Would it be a good idea to change this in the default install? + +Bye, Chris. + +PS: yes I did a fresh initdb again to double check ;) + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 20:25:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B9E7F11F66D3 + for ; + Wed, 5 Apr 2006 20:25:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57934-10 + for ; + Wed, 5 Apr 2006 20:25:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz + [203.96.152.184]) + by postgresql.org (Postfix) with ESMTP id 793A511F662B + for ; + Wed, 5 Apr 2006 20:25:40 -0300 (ADT) +Received: from smtp-2.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-5.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IX900BXMVQPCH@linda-5.paradise.net.nz> for + pgsql-performance@postgresql.org; Thu, 06 Apr 2006 11:25:37 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-161.dsl.clear.net.nz [218.101.29.161]) by + smtp-2.paradise.net.nz (Postfix) with ESMTP id 13AA512E8D88; + Thu, 06 Apr 2006 11:25:37 +1200 (NZST) +Date: Thu, 06 Apr 2006 11:25:36 +1200 +From: Mark Kirkwood +Subject: Re: bad performance on Solaris 10 +In-reply-to: <1144272685.4562.43.camel@dell.home.lan> +To: Chris Mair +Cc: pgsql-performance@postgresql.org, josh@agliodbs.com, + llonergan@greenplum.com +Message-id: <443451F0.5060605@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20051106) +References: <1144111178.3723.80.camel@dell.home.lan> + <1144272685.4562.43.camel@dell.home.lan> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.166 required=5 tests=[AWL=0.166] +X-Spam-Score: 0.166 +X-Spam-Level: +X-Archive-Number: 200604/79 +X-Sequence-Number: 18163 + +Chris Mair wrote: +> Hi, +> +> thanks for all replys. +> +> I've done a few tests. +> +> Remounting the fs where $PGDATA lives with "forcedirectio" +> (together with logging, that is default) did not help +> (if not harm...) performance. +> +> + +Sure - forcedirectio on the entire $PGDATA is a definite loss, you only +want it on $PGDATA/pg_xlog. The usual way this is accomplished is by +making a separate filsystem for pg_xlog and symlinking from $PGDATA. + +Did you try the other option of remounting the fs for $PGDATA without +logging or forcedirectio? + +Cheers + +Mark + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 20:29:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9BFF111F662B + for ; + Wed, 5 Apr 2006 20:29:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71944-03 + for ; + Wed, 5 Apr 2006 20:29:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id EE7C411F6259 + for ; + Wed, 5 Apr 2006 20:29:43 -0300 (ADT) +Received: from dell.home.lan (host14-128.pool8251.interbusiness.it + [82.51.128.14]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k360WUr17984; + Thu, 6 Apr 2006 02:32:30 +0200 +Subject: Re: bad performance on Solaris 10 +From: Chris Mair +To: Mark Kirkwood +Cc: pgsql-performance@postgresql.org, josh@agliodbs.com, + llonergan@greenplum.com +In-Reply-To: <443451F0.5060605@paradise.net.nz> +References: <1144111178.3723.80.camel@dell.home.lan> + <1144272685.4562.43.camel@dell.home.lan> + <443451F0.5060605@paradise.net.nz> +Content-Type: text/plain +Date: Thu, 06 Apr 2006 01:29:40 +0200 +Message-Id: <1144279780.5133.19.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200604/80 +X-Sequence-Number: 18164 + + +> > I've done a few tests. +> > +> > Remounting the fs where $PGDATA lives with "forcedirectio" +> > (together with logging, that is default) did not help +> > (if not harm...) performance. +> > +> > +> +> Sure - forcedirectio on the entire $PGDATA is a definite loss, you only +> want it on $PGDATA/pg_xlog. The usual way this is accomplished is by +> making a separate filsystem for pg_xlog and symlinking from $PGDATA. +> +> Did you try the other option of remounting the fs for $PGDATA without +> logging or forcedirectio? + +not yet, I'm not on the final disk set yet. + +when I get there I'll have two separate filesystems for pg_xlog and base +and will try what you suggest. + +(but note the other mail about wal_sync_method = fsync) + +bye, chris. + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 20:33:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E13F711F676E + for ; + Wed, 5 Apr 2006 20:33:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98783-05 + for ; + Wed, 5 Apr 2006 20:33:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id 36AF111F6724 + for ; + Wed, 5 Apr 2006 20:33:07 -0300 (ADT) +Received: from dell.home.lan (host14-128.pool8251.interbusiness.it + [82.51.128.14]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k360Zvr18005 + for ; Thu, 6 Apr 2006 02:35:57 +0200 +Subject: Re: bad performance on Solaris 10 +From: Chris Mair +To: pgsql-performance@postgresql.org +In-Reply-To: <1144272685.4562.43.camel@dell.home.lan> +References: <1144111178.3723.80.camel@dell.home.lan> + <1144272685.4562.43.camel@dell.home.lan> +Content-Type: text/plain +Date: Thu, 06 Apr 2006 01:33:07 +0200 +Message-Id: <1144279987.5133.22.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +X-Spam-Score: 0.09 +X-Spam-Level: +X-Archive-Number: 200604/81 +X-Sequence-Number: 18165 + +appears this didn't make it to the list... resending to the list +directly... +--- + +> > > Doing what http://blogs.sun.com/roller/page/jkshah suggests: +> > > wal_sync_method = fsync (unchanged) +> > > wal_buffers = 128 (was 8) +> > > checkpoint_segments = 128 (was 3) +> > > bgwriter_all_percent = 0 (was 0.333) +> > > bgwriter_all_maxpages = 0 (was 5) +> > > and leaving everything else default (solarispackages from +pgfoundry) +> > > increased performance ~ 7 times! + +Ok, so I could quite believe my own benchmarks and I decided +to do a fresh initdb and retry everything. + +At first it looked like I coudn't reproduce the speed up I just saw. + +Then I realized it was the +wal_sync_method = fsync +line that makes all the difference! + +Normally parameters that are commented are default values, but for +wal_sync_method it actually says (note the comment): + +wal_sync_method = fsync # the default is the first option + # supported by the operating system: + # open_datasync + # fdatasync + # fsync + # fsync_writethrough + # open_sync + +So Im my last mail I drew the wrong conclusion, because i didn't comment +wal_sync_method to double check. + +To the point: the default wal_sync_method choosen on Solaris 10 appears +to be a very bad one - for me, picking fsync increases performance ~ +times 7, all other parameters unchanged! + +Would it be a good idea to change this in the default install? + +Bye, Chris. + +PS: yes I did a fresh initdb again to double check ;) + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 21:35:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7A36411F6647 + for ; + Wed, 5 Apr 2006 21:35:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02518-06 + for ; + Wed, 5 Apr 2006 21:35:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp1.wholefoods.com (smtp1.wholefoods.com [64.132.0.20]) + by postgresql.org (Postfix) with ESMTP id 7E7B011F663F + for ; + Wed, 5 Apr 2006 21:35:31 -0300 (ADT) +Received: from unknown (HELO wfm-exchprd2.wfm.pvt) ([10.2.2.22]) + by smtp1.wholefoods.com with ESMTP; 05 Apr 2006 19:36:03 -0500 +X-IronPort-AV: i="4.04,91,1144040400"; d="scan'208"; a="23198181:sNHT30402176" +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Wed, 5 Apr 2006 19:33:49 -0500 +Message-ID: <7583B3F1891CC0429FA4A44952AA539C66FA7D@wfm-exchprd2.wfm.pvt> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZY/L3SVmzGmQ1cR0evD3/CV8MclAAE+9mQ +From: "Juan Casero \(FL FLC\)" +To: , + +Cc: "Luke Lonergan" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200604/82 +X-Sequence-Number: 18166 + +I am evaluating this SunFire T2000 as a replacement for an Intel P3 1Ghz +postgresql server. This intel server runs a retail reporting database +on postgresql 8.1.3. I need to realize significant performance gains on +T2000 server to justify the expense. So I need to tune the postgresql +server as much as I can for it. Right now the operating system (solaris +10) sees each thread as a single cpu and only allows each thread 4.16% +of the available cpu resources for processing queries. Since postgresql +is not multithreaded and since I cannot apparently break past the +operating system imposed limits on a single thread I can't fully realize +the performance benefits of the T2000 server unless and until I start +getting lots of people hitting the database server with requests. This +doesn't happen right now. It may happen later on as I write more +applications for the server but I am looking to see if the performance +benefit we can get from this server is worth the price tag right now. +That is why I am looking for ways to tweak postgres on it.=20 + + +Thanks, +Juan=20 + +-----Original Message----- +From: Josh Berkus [mailto:josh@agliodbs.com]=20 +Sent: Wednesday, April 05, 2006 6:02 PM +To: pgsql-performance@postgresql.org +Cc: Juan Casero (FL FLC); Luke Lonergan +Subject: Re: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 + +Juan, + +> When I hit +> this pgsql on this laptop with a large query I can see the load spike=20 +> up really high on both of my virtual processors. Whatever, pgsql is=20 +> doing it looks like both cpu's are being used indepently. + +Nope, sorry, you're being decieved. Postgres is strictly one process, +one=20 +query. =20 + +You can use Bizgres MPP to achieve multithreading; it's proprietary and +you have to pay for it. It does work well, though. + +More importantly, though, you haven't really explained why you care +about multithreading. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Apr 5 21:49:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 77AF211F6602 + for ; + Wed, 5 Apr 2006 21:49:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36498-08 + for ; + Wed, 5 Apr 2006 21:49:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id 458AC11F6613 + for ; + Wed, 5 Apr 2006 21:49:29 -0300 (ADT) +Received: from 172.16.1.112 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Wed, 05 Apr 2006 20:49:23 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 5 Apr + 2006 20:49:23 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Thu, 6 Apr + 2006 00:49:23 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 05 Apr 2006 17:49:21 -0700 +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +From: "Luke Lonergan" +To: "Juan Casero (FL FLC)" , + "Josh Berkus" , pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZY/L3SVmzGmQ1cR0evD3/CV8MclAAE+9mQAADQ9Xo= +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA7D@wfm-exchprd2.wfm.pvt> +MIME-Version: 1.0 +X-OriginalArrivalTime: 06 Apr 2006 00:49:23.0894 (UTC) + FILETIME=[F2C5D560:01C65913] +X-WSS-ID: 682ABA190NK2459428-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.347 required=5 tests=[AWL=0.094, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.347 +X-Spam-Level: * +X-Archive-Number: 200604/83 +X-Sequence-Number: 18167 + +Juan, + +On 4/5/06 5:33 PM, "Juan Casero (FL FLC)" +wrote: + +> ... but I am looking to see if the performance +> benefit we can get from this server is worth the price tag right now. + +While many people here will look forward to performance results on the +T2000, I can guarantee that your server money will go much further for a +reporting application with an Opteron based system. Buy a Sun Galaxy with a +pair of Opteron 275s, run Linux on it, and I predict you will see +performance 4-5 times faster than the T2000 running Solaris for handling +single queries, and 2-3 times faster when handling multiple queries. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 22:18:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7564811F666B + for ; + Wed, 5 Apr 2006 22:18:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72969-04 + for ; + Wed, 5 Apr 2006 22:18:31 -0300 (ADT) +X-Greylist: delayed 00:06:37.306032 by SQLgrey- +Received: from smtp-01.mandic.com.br (smtp-01.mandic.com.br [200.225.81.132]) + by postgresql.org (Postfix) with ESMTP id AA8D811F6632 + for ; + Wed, 5 Apr 2006 22:18:27 -0300 (ADT) +Received: (qmail 12294 invoked from network); 6 Apr 2006 01:11:47 -0000 +Received: from 200227136145-dial-user-ecp.acessonet.com.br (HELO + [200.227.136.145]) + (18Xbxs2+15XbzMyvpdrclZZOlJ+gZpdy@[200.227.136.145]) + (envelope-sender ) + by smtp-01.mandic.com.br (qmail-ldap-1.03) with SMTP + for ; 6 Apr 2006 01:11:45 -0000 +Message-ID: <44346AC4.1070801@nube.com.br> +Date: Wed, 05 Apr 2006 22:11:32 -0300 +From: Marcelo Tada +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Juan Casero (FL FLC)" +CC: josh@agliodbs.com, pgsql-performance@postgresql.org, + Luke Lonergan +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +References: <7583B3F1891CC0429FA4A44952AA539C66FA7D@wfm-exchprd2.wfm.pvt> +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA7D@wfm-exchprd2.wfm.pvt> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/84 +X-Sequence-Number: 18168 + +Juan, I think that AMD Opteron is more flex (OS and Hardware Upgrade) +and then, the best solution.� + +What are you think about the Sun Fire X64 X4200 Server? + +Take a look in this analysis and performance benchmark�. + +Regards, +MTada + +� http://www.anandtech.com/systems/showdoc.aspx?i=2727&p=2 +� http://www.anandtech.com/systems/showdoc.aspx?i=2727&p=7 + +Juan Casero (FL FLC) wrote: + +>I am evaluating this SunFire T2000 as a replacement for an Intel P3 1Ghz +>postgresql server. This intel server runs a retail reporting database +>on postgresql 8.1.3. I need to realize significant performance gains on +>T2000 server to justify the expense. So I need to tune the postgresql +>server as much as I can for it. Right now the operating system (solaris +>10) sees each thread as a single cpu and only allows each thread 4.16% +>of the available cpu resources for processing queries. Since postgresql +>is not multithreaded and since I cannot apparently break past the +>operating system imposed limits on a single thread I can't fully realize +>the performance benefits of the T2000 server unless and until I start +>getting lots of people hitting the database server with requests. This +>doesn't happen right now. It may happen later on as I write more +>applications for the server but I am looking to see if the performance +>benefit we can get from this server is worth the price tag right now. +>That is why I am looking for ways to tweak postgres on it. +> +> +>Thanks, +>Juan +> +>-----Original Message----- +>From: Josh Berkus [mailto:josh@agliodbs.com] +>Sent: Wednesday, April 05, 2006 6:02 PM +>To: pgsql-performance@postgresql.org +>Cc: Juan Casero (FL FLC); Luke Lonergan +>Subject: Re: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +> +>Juan, +> +> +> +>>When I hit +>>this pgsql on this laptop with a large query I can see the load spike +>>up really high on both of my virtual processors. Whatever, pgsql is +>>doing it looks like both cpu's are being used indepently. +>> +>> +> +>Nope, sorry, you're being decieved. Postgres is strictly one process, +>one +>query. +> +>You can use Bizgres MPP to achieve multithreading; it's proprietary and +>you have to pay for it. It does work well, though. +> +>More importantly, though, you haven't really explained why you care +>about multithreading. +> +>-- +>--Josh +> +>Josh Berkus +>Aglio Database Solutions +>San Francisco +> +>---------------------------(end of broadcast)--------------------------- +>TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> +> + + +From pgsql-performance-owner@postgresql.org Wed Apr 5 22:24:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 63FF711F6BFF + for ; + Wed, 5 Apr 2006 22:23:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72575-06 + for ; + Wed, 5 Apr 2006 22:23:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz + [203.96.152.180]) + by postgresql.org (Postfix) with ESMTP id 5193A11F6BD9 + for ; + Wed, 5 Apr 2006 22:23:56 -0300 (ADT) +Received: from smtp-2.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-1.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IXA0029Y17WKC@linda-1.paradise.net.nz> for + pgsql-performance@postgresql.org; Thu, 06 Apr 2006 13:23:56 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-161.dsl.clear.net.nz [218.101.29.161]) by + smtp-2.paradise.net.nz (Postfix) with ESMTP id E11626F6880; + Thu, 06 Apr 2006 13:23:55 +1200 (NZST) +Date: Thu, 06 Apr 2006 13:23:54 +1200 +From: Mark Kirkwood +Subject: Re: bad performance on Solaris 10 +In-reply-to: <1144279780.5133.19.camel@dell.home.lan> +To: Chris Mair +Cc: pgsql-performance@postgresql.org, josh@agliodbs.com, + llonergan@greenplum.com +Message-id: <44346DAA.2080905@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20051106) +References: <1144111178.3723.80.camel@dell.home.lan> + <1144272685.4562.43.camel@dell.home.lan> + <443451F0.5060605@paradise.net.nz> + <1144279780.5133.19.camel@dell.home.lan> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.165 required=5 tests=[AWL=0.165] +X-Spam-Score: 0.165 +X-Spam-Level: +X-Archive-Number: 200604/85 +X-Sequence-Number: 18169 + +Chris Mair wrote: + +> +> (but note the other mail about wal_sync_method = fsync) +> + +Yeah - looks good! (is the default open_datasync still?). Might be worth +trying out the fdatasync method too (ISTR this being quite good... again +on Solaris 8, so things might have changed)! + +Cheers + +Mark + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 03:29:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0058411F6707 + for ; + Thu, 6 Apr 2006 03:29:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59397-03 + for ; + Thu, 6 Apr 2006 03:29:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp1.wholefoods.com (smtp1.wholefoods.com [64.132.0.20]) + by postgresql.org (Postfix) with ESMTP id 22BA811F68D0 + for ; + Thu, 6 Apr 2006 03:29:36 -0300 (ADT) +Received: from unknown (HELO wfm-exchprd2.wfm.pvt) ([10.2.2.22]) + by smtp1.wholefoods.com with ESMTP; 05 Apr 2006 21:16:59 -0500 +X-IronPort-AV: i="4.04,91,1144040400"; d="scan'208"; a="23204627:sNHT31409175" +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Wed, 5 Apr 2006 21:14:46 -0500 +Message-ID: <7583B3F1891CC0429FA4A44952AA539C66FA7E@wfm-exchprd2.wfm.pvt> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZY2tjXfVRhB87QTyyEQXkYWR91JAAAagagAAVFz+oAAEdD8AABm2MGAAl0qzA= +From: "Juan Casero \(FL FLC\)" +To: "Luke Lonergan" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/93 +X-Sequence-Number: 18177 + +Ok that is beginning to become clear to me. Now I need to determine if +this server is worth the investment for us. Maybe it is not a speed +daemon but to be honest the licensing costs of an SMP aware RDBMS is +outside our budget. When postgresql starts does it start up a super +server process and then forks copies of itself to handle incoming +requests? Or do I have to specify how many server processes should be +started up? I figured maybe I can take advantage of the multiple cpu's +on this system by starting up enough postgres server processes to handle +large numbers of incoming connections. I have this server available for +sixty days so I may as well explore the performance of postgresql on it. + + + +Thanks, +Juan=20 + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Luke +Lonergan +Sent: Wednesday, April 05, 2006 5:37 PM +To: Juan Casero (FL FLC); pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 + +Juan, + +On 4/5/06 1:54 PM, "Juan Casero (FL FLC)" +wrote: + +> I am not sure about this. I mean I have postgresql 8.1.3 running on=20 +> my Windows XP P4 HT laptop that I use for testing my webapps. When I=20 +> hit this pgsql on this laptop with a large query I can see the load=20 +> spike up really high on both of my virtual processors. Whatever,=20 +> pgsql is doing it looks like both cpu's are being used indepently. The + +> usage curve is not identical on both of them that makes me think that=20 +> parts of the server are multithreaded. Admittedly I am not familiar=20 +> with the source code fo postgresql so I was hoping maybe one of the=20 +> developers who is could definitely answer this question. + +There's no part of the Postgres backend that is threaded or +multi-processed. +A reasonable explanation for your windows experience is that your web +server or the psql client may be taking some CPU cycles while the +backend is processing your query. Also, depending on how the CPU load +is reported, if the OS is doing prefetching of I/O, it might show up as +load. + +- Luke + + + +---------------------------(end of broadcast)--------------------------- +TIP 9: In versions below 8.0, the planner will ignore your desire to + choose an index scan if your joining column's datatypes do not + match + +From pgsql-performance-owner@postgresql.org Thu Apr 6 05:02:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7412111F6ACB + for ; + Thu, 6 Apr 2006 05:02:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82090-05 + for ; + Thu, 6 Apr 2006 05:02:23 -0300 (ADT) +X-Greylist: delayed 01:26:37.687512 by SQLgrey- +Received: from web52305.mail.yahoo.com (web52305.mail.yahoo.com + [206.190.48.148]) + by postgresql.org (Postfix) with SMTP id DC52A11F6AC5 + for ; + Thu, 6 Apr 2006 05:02:24 -0300 (ADT) +Received: (qmail 37252 invoked by uid 60001); 6 Apr 2006 02:35:44 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=BzFb+d0xba9am57lPTyZH0qh8b/mcgKJWAtGy2F7+pAXuND8aUDN6lK8qWsUM9i2ksXNdX20YNMLFM8KawiGYcZrJSv1yiiS2aQDOgXFWc2XFekbkQB0sx6ECt9+t5VQVZpO0mGoTOipj7gq5cede430EU3Po7u8v9tbMTkCaf8= + ; +Message-ID: <20060406023544.37250.qmail@web52305.mail.yahoo.com> +Received: from [202.156.6.68] by web52305.mail.yahoo.com via HTTP; + Thu, 06 Apr 2006 12:35:44 EST +Date: Thu, 6 Apr 2006 12:35:44 +1000 (EST) +From: Brian Herlihy +Subject: Query planner is using wrong index. +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200604/101 +X-Sequence-Number: 18185 + +Hi, + +I have a problem with the choice of index made by the query planner. + +My table looks like this: + +CREATE TABLE t +( + p1 varchar not null, + p2 varchar not null, + p3 varchar not null, + i1 integer, + i2 integer, + i3 integer, + i4 integer, + i5 integer, + d1 date, + d2 date, + d3 date, + PRIMARY KEY (p1, p2, p3) +); + +I have also created an index on (p2, p3), as some of my lookups are on these +only. +All the integers and dates are data values. +The table has around 9 million rows. +I am using postgresl 7.4.7 + +I have set statistics to 1000 on the p1, p2 and p3 columns, and run vacuum full +analyse. However, I still see +query plans like this: + +db=# explain select * from t where p1 = 'something' and p2 = 'fairly_common' +and p3 = 'fairly_common'; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------- + Index Scan using p2p3 on t (cost=0.00..6.01 rows=1 width=102) + Index Cond: (((p2)::text = 'fairly_common'::text) AND ((p3)::text = +'fairly_common'::text)) + Filter: ((p1)::text = 'something'::text) +(3 rows) + +The problem appears to be this: + +db=# explain select * from t where p2 = 'fairly_common' and p3 = +'fairly_common'; +QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------- + Index Scan using p2p3 on t (cost=0.00..6.01 rows=1 width=102) + Index Cond: (((p2)::text = 'fairly_common'::text) AND ((p3)::text = +'fairly_common'::text)) +(3 rows) + +The query planner thinks that this will return only 1 row. +In fact, these index lookups sometimes return up to 500 rows, which then must +be filtered by p1. +This can take 2 or 3 seconds to execute for what should be a simple primary key +lookup. + +For VERY common values of p2 and p3, the query planner chooses the primary key, +because these values are stored +explicitly in the analyse results. For rare values there is no problem, +because the query runs quickly. +But for "fairly common" values, there is a problem. + +I would like the query planner to use the primary key for all of these lookups. + How can I enforce this? + +Thanks, +Brian + +From pgsql-performance-owner@postgresql.org Thu Apr 6 00:36:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4C66611F662C + for ; + Thu, 6 Apr 2006 00:36:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26562-04 + for ; + Thu, 6 Apr 2006 00:36:01 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id D180011F690C + for ; + Thu, 6 Apr 2006 00:36:00 -0300 (ADT) +Received: from smtp.sw.oz.au (alt.aurema.com [203.217.18.57]) + by svr4.postgresql.org (Postfix) with ESMTP id 162CD5AF94B + for ; + Thu, 6 Apr 2006 03:35:59 +0000 (GMT) +Received: from [192.41.203.74] (anthonyr.sw.oz.au [192.41.203.74]) + by smtp.sw.oz.au with ESMTP id k363ZlSU019781 + for ; + Thu, 6 Apr 2006 13:35:47 +1000 (EST) +Message-ID: <44348C93.2080106@aurema.com> +Date: Thu, 06 Apr 2006 13:35:47 +1000 +From: Anthony Ransley +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +References: <7583B3F1891CC0429FA4A44952AA539C66FA2C@wfm-exchprd2.wfm.pvt> +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA2C@wfm-exchprd2.wfm.pvt> +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Scanned-By: MIMEDefang 2.52 on 192.41.203.35 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.002 required=5 tests=[HTML_MESSAGE=0.001, + MIME_HTML_ONLY=0.001] +X-Spam-Score: 0.002 +X-Spam-Level: +X-Archive-Number: 200604/86 +X-Sequence-Number: 18170 + + + + + + + +Hi Juan Casero,
+
+I've found that serial query clients are best served by PostgreSQL +running on fast single or dual core processors, ( such as the Athlon +FX60 ) rather than expensive n-way systems. I was orginally using an +8-way Xeon computer for a similar serial throughput problem. and i +wasn't supprised to find that at least 6 of the 8 processors were idle. +The point is, for this type client, you are better off spending the +money on the fastest single or dual core processors than a multiway box.
+
+Anthony.
+
+Juan Casero (FL FLC) wrote: +
+ + +
Greetings -
+
 
+
I +am testing a Sun Microsystems Sun Fire T2000 demo server at our +company.   I want to know if anyone here has any experience with this +hardware and postgresql 8.1.3.  I installed the copy of postgresql +8.1.3 from blastwave.org onto this demo box and loaded our production +database into it.  This box has a single Ultrasparc T1 cpu with six +execution piplelines that can each handle 4 threads.  With the Unix top +utility the postgresql server appears to bounce around between the +available threads on the system.  For example I run a single large +query and I can see the postgresql server sometimes running on cpu/0, +other times on cpu/1, cpu/3,....etc up to cpu/23.   However, never is +the load for the postgres server reported to be higher than 4.16%.  I +did the math and 4.16% x 24 threads = 98.84% cpu load.  So I wonder if +the Solaris 10 kernel is somehow throttling the processes so that any +single virtual processor can do no more than 4.16% load.  We got this +server last week and I was able to install it in our rack just +yesterday.   Now I need to see how I can optimize the postgresql server +to work on this box.  Does anyone have any suggestions?   I know the +postgresql server is not smp aware but I believe parts of it are.  In +particular the buffer manager is supposed to scale the performance +almost linearly with the number of cpu's (including virtual ones).  I +don't know however, if I need to recompile the postgresql server myself +to get those benefits.   I am using the version of postgresql 8.1.3 +that is available on blastwave.org.  I am also working with the 64 bit +version of the database server.   This machine has over 8GB of ram so I +was thinking of using the 64 bit version of the postgresql server so I +can access ram beyong the 4gb limit imposed by 32 bit addressing.  Any +help or recommendations for performance tweaking of postgresql is very +much appreciated.
+
 
+
 
+
Thanks,
+
Juan
+
+
+ + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 00:41:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B20D411F666A + for ; + Thu, 6 Apr 2006 00:41:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25422-08 + for ; + Thu, 6 Apr 2006 00:41:51 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 7831711F665B + for ; + Thu, 6 Apr 2006 00:41:51 -0300 (ADT) +Received: from brmea-mail-1.sun.com (brmea-mail-1.Sun.COM [192.18.98.31]) + by svr4.postgresql.org (Postfix) with ESMTP id 0D0A55AF95E + for ; + Thu, 6 Apr 2006 03:41:50 +0000 (GMT) +Received: from phys-d3-ha21sca-1 ([129.145.155.163]) + by brmea-mail-1.sun.com (8.12.10/8.12.9) with ESMTP id k363fmGp016061 + for ; + Wed, 5 Apr 2006 21:41:48 -0600 (MDT) +Received: from conversion-daemon.ha21sca-mail1.sfbay.sun.com by + ha21sca-mail1.sfbay.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0IXA00A017CV16@ha21sca-mail1.sfbay.sun.com> + (original mail from Robert.Lor@Sun.COM) for + pgsql-performance@postgresql.org; + Wed, 05 Apr 2006 20:41:44 -0700 (PDT) +Received: from [129.150.12.119] + (vpn-129-150-12-119.SFBay.Sun.COM [129.150.12.119]) + by ha21sca-mail1.sfbay.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTP id <0IXA002BP7LKBA@ha21sca-mail1.sfbay.sun.com>; Wed, + 05 Apr 2006 20:41:44 -0700 (PDT) +Date: Wed, 05 Apr 2006 20:41:16 -0700 +From: Robert Lor +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +In-reply-to: <12500.1144263844@sss.pgh.pa.us> +To: Tom Lane +Cc: "Juan Casero (FL FLC)" , + pgsql-performance@postgresql.org +Message-id: <44348DDC.60505@sun.com> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7) Gecko/20050913 +References: <7583B3F1891CC0429FA4A44952AA539C66FA2C@wfm-exchprd2.wfm.pvt> + <12500.1144263844@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200604/87 +X-Sequence-Number: 18171 + +Tom is right. Unless your workload can generate lots of simultaneous +queries, you will not reap the full benefit of the Sun Fire T2000 +system. I have tested 8.1.3 with an OLTP workload on an 8 cores system. +With 1500-2000 client connections, the CPU was only about 30% utilized. +The UltraSPARC T1 processor was designed for throughput with many cores +running at lower frequency (1-1.2 GHz) to reduce power consumption. To +speed up a single big query, you'd be better off with a parallelize DB +or an Opteron system with higher clock speed like this one +http://www.sun.com/servers/entry/x4200/ + +Regards, +-Robert + +Tom Lane wrote: + +>"Juan Casero \(FL FLC\)" writes: +> +> +>>... This box has a single Ultrasparc T1 cpu with six execution +>>piplelines that can each handle 4 threads. With the Unix top utility +>>the postgresql server appears to bounce around between the available +>>threads on the system. +>> +>> +> +>Try sending it more than one query at a time? If you're testing with +>just one client connection issuing queries, that's about what I'd expect. +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 6: explain analyze is your friend +> +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 01:16:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E21EA11F621A + for ; + Thu, 6 Apr 2006 01:16:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31304-06 + for ; + Thu, 6 Apr 2006 01:16:40 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 6E22511F6267 + for ; + Thu, 6 Apr 2006 01:16:40 -0300 (ADT) +Received: from brmea-mail-1.sun.com (brmea-mail-1.Sun.COM [192.18.98.31]) + by svr4.postgresql.org (Postfix) with ESMTP id 325635AF88B + for ; + Thu, 6 Apr 2006 04:16:39 +0000 (GMT) +Received: from phys-d3-ha21sca-1 ([129.145.155.163]) + by brmea-mail-1.sun.com (8.12.10/8.12.9) with ESMTP id k364GJGv003035 + for ; + Wed, 5 Apr 2006 22:16:34 -0600 (MDT) +Received: from conversion-daemon.ha21sca-mail1.sfbay.sun.com by + ha21sca-mail1.sfbay.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0IXA00I018QOFR@ha21sca-mail1.sfbay.sun.com> + (original mail from Robert.Lor@Sun.COM) for + pgsql-performance@postgresql.org; + Wed, 05 Apr 2006 21:16:20 -0700 (PDT) +Received: from [129.150.12.119] + (vpn-129-150-12-119.SFBay.Sun.COM [129.150.12.119]) + by ha21sca-mail1.sfbay.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTP id <0IXA002H6971BA@ha21sca-mail1.sfbay.sun.com>; Wed, + 05 Apr 2006 21:16:13 -0700 (PDT) +Date: Wed, 05 Apr 2006 21:15:45 -0700 +From: Robert Lor +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +In-reply-to: <7583B3F1891CC0429FA4A44952AA539C66FA7D@wfm-exchprd2.wfm.pvt> +To: "Juan Casero (FL FLC)" +Cc: josh@agliodbs.com, pgsql-performance@postgresql.org, + Luke Lonergan +Message-id: <443495F1.2010302@sun.com> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7) Gecko/20050913 +References: <7583B3F1891CC0429FA4A44952AA539C66FA7D@wfm-exchprd2.wfm.pvt> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200604/88 +X-Sequence-Number: 18172 + +Juan Casero (FL FLC) wrote: + +>I can't fully realize +>the performance benefits of the T2000 server unless and until I start +>getting lots of people hitting the database server with requests. This +>doesn't happen right now. It may happen later on as I write more +>applications for the server but I am looking to see if the performance +>benefit we can get from this server is worth the price tag right now. +>That is why I am looking for ways to tweak postgres on it. +> +> +> +If you have a need to use the system for other purposes with the extra +CPU bandwidth, you can partition it using the Solaris Containers +feature. Doing this will give you room to grow your DB usage later and +make full use of the system now. + +Just a thought! + +Regards, +Robert + +From pgsql-performance-owner@postgresql.org Thu Apr 6 01:23:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 50CA611F625C + for ; + Thu, 6 Apr 2006 01:23:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30446-08 + for ; + Thu, 6 Apr 2006 01:23:28 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 3238011F621A + for ; + Thu, 6 Apr 2006 01:23:29 -0300 (ADT) +Received: from preston.office (mail.eclinic.com.au [203.202.134.251]) + by svr4.postgresql.org (Postfix) with ESMTP id 8CC815AF890 + for ; + Thu, 6 Apr 2006 04:23:28 +0000 (GMT) +Received: from preston.office (preston [127.0.0.1]) + by preston.office (Postfix) with ESMTP id BBCA310008A7; + Thu, 6 Apr 2006 14:23:03 +1000 (EST) +Received: from preston.office (preston [127.0.0.1]) + by preston.office (Postfix) with ESMTP id 5514C1001746; + Thu, 6 Apr 2006 14:23:03 +1000 (EST) +Received: from [192.168.1.28] (shawn.office [192.168.1.28]) + by preston.office (Postfix) with ESMTP id A698210008A7; + Thu, 6 Apr 2006 14:23:02 +1000 (EST) +Message-ID: <443497AB.4000309@eclinic.com.au> +Date: Thu, 06 Apr 2006 14:23:07 +1000 +From: Leigh Dyer +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Luke Lonergan +Cc: "Juan Casero (FL FLC)" , + Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/89 +X-Sequence-Number: 18173 + +Luke Lonergan wrote: +> Juan, +> +> On 4/5/06 5:33 PM, "Juan Casero (FL FLC)" +> wrote: +> +>> ... but I am looking to see if the performance +>> benefit we can get from this server is worth the price tag right now. +> +> While many people here will look forward to performance results on the +> T2000, I can guarantee that your server money will go much further for a +> reporting application with an Opteron based system. Buy a Sun Galaxy with a +> pair of Opteron 275s, run Linux on it, and I predict you will see +> performance 4-5 times faster than the T2000 running Solaris for handling +> single queries, and 2-3 times faster when handling multiple queries. + +We've got a Sun Fire V40z and it's quite a nice machine -- 6x 15krpm +drives, 4GB RAM, and a pair of Opteron 850s. This gives us more than +enough power now for what we need, but it's nice to know that we can +shoehorn a lot more RAM, and up it to eight CPU cores if needed. + +The newer Sun Opteron systems look nice too, but unless you're using +external storage, their little 2.5" hard drives may not be ideal. + +Thanks +Leigh + +> +> - Luke +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 01:27:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B5E8A11F6287 + for ; + Thu, 6 Apr 2006 01:27:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36747-06 + for ; + Thu, 6 Apr 2006 01:27:43 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 5A6C411F6282 + for ; + Thu, 6 Apr 2006 01:27:43 -0300 (ADT) +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by svr4.postgresql.org (Postfix) with ESMTP id DBF205AF886 + for ; + Thu, 6 Apr 2006 04:27:42 +0000 (GMT) +Received: from 172.16.1.148 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Thu, 06 Apr 2006 00:27:31 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01HOST02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 6 Apr + 2006 00:27:31 -0400 +Received: from 69.181.100.71 ([69.181.100.71]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Thu, 6 Apr + 2006 04:27:30 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 05 Apr 2006 21:27:27 -0700 +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +From: "Luke Lonergan" +To: "Leigh Dyer" +Cc: "Juan Casero (FL FLC)" , + "Josh Berkus" , pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZZMdhrVVZDDhFOQuKsSabTgXlr4wAAJB8+ +In-Reply-To: <443497AB.4000309@eclinic.com.au> +MIME-Version: 1.0 +X-OriginalArrivalTime: 06 Apr 2006 04:27:31.0129 (UTC) + FILETIME=[6B5F6A90:01C65932] +X-WSS-ID: 682A473920C39865938-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.253 required=5 tests=[RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.253 +X-Spam-Level: * +X-Archive-Number: 200604/90 +X-Sequence-Number: 18174 + +Leigh, + +On 4/5/06 9:23 PM, "Leigh Dyer" wrote: + +> We've got a Sun Fire V40z and it's quite a nice machine -- 6x 15krpm +> drives, 4GB RAM, and a pair of Opteron 850s. This gives us more than +> enough power now for what we need, but it's nice to know that we can +> shoehorn a lot more RAM, and up it to eight CPU cores if needed. + +We have one of these too - ours is signed by Scott McNealy. + +> The newer Sun Opteron systems look nice too, but unless you're using +> external storage, their little 2.5" hard drives may not be ideal. + +Yes - but they end-of-lifed the V20z and V40z! + +One big problem with the sun line in general is the tiny internal storage +capacity - already too small on the V40z at 5/6 drives, now ridiculous at 4 +SAS drives on the galaxy series. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 03:31:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 20A2611F68D5 + for ; + Thu, 6 Apr 2006 03:31:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60526-03 + for ; + Thu, 6 Apr 2006 03:31:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id 4CB3111F6709 + for ; + Thu, 6 Apr 2006 03:31:38 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO + spooky.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9218795; Wed, 05 Apr 2006 21:34:39 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: bad performance on Solaris 10 +Date: Wed, 5 Apr 2006 21:32:16 -0700 +User-Agent: KMail/1.8.2 +Cc: Chris Mair , markir@paradise.net.nz, + llonergan@greenplum.com +References: <1144111178.3723.80.camel@dell.home.lan> + <1144272685.4562.43.camel@dell.home.lan> +In-Reply-To: <1144272685.4562.43.camel@dell.home.lan> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604052132.16434.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/94 +X-Sequence-Number: 18178 + +Chris, + +> Remounting the fs where $PGDATA lives with "forcedirectio" +> (together with logging, that is default) did not help +> (if not harm...) performance. + +Not all of PG. JUST pg_xlog. forcedirectio is only a good idea for the xlog. + +> Quickly playing around with wal_buffers on Linux and Mac OS X +> I see it influences the performance of my test a bit, maybe in the +> 10-20% range (I'm really doing quick tests, nothing systematic), +> but nowhere near as spectacularly as on Solaris. +> +> I'm happy so far, but I find it very surprising that this single +> parameter has such an impact (only on) Solaris 10. + +That *is* interesting. I hadn't tested this previously specifically on +Solaris. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Apr 6 03:34:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CBD5D11F6709 + for ; + Thu, 6 Apr 2006 03:34:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61382-05 + for ; + Thu, 6 Apr 2006 03:34:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id 685B011F6708 + for ; + Thu, 6 Apr 2006 03:34:36 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO + spooky.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9218806; Wed, 05 Apr 2006 21:37:37 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Mark Kirkwood +Subject: Re: bad performance on Solaris 10 +Date: Wed, 5 Apr 2006 21:35:14 -0700 +User-Agent: KMail/1.8.2 +Cc: Chris Mair , pgsql-performance@postgresql.org, + llonergan@greenplum.com +References: <1144111178.3723.80.camel@dell.home.lan> + <1144279780.5133.19.camel@dell.home.lan> + <44346DAA.2080905@paradise.net.nz> +In-Reply-To: <44346DAA.2080905@paradise.net.nz> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604052135.14326.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.06 required=5 tests=[AWL=0.060] +X-Spam-Score: 0.06 +X-Spam-Level: +X-Archive-Number: 200604/95 +X-Sequence-Number: 18179 + +Mark, Chris, + +> Yeah - looks good! (is the default open_datasync still?). Might be worth +> trying out the fdatasync method too (ISTR this being quite good... again +> on Solaris 8, so things might have changed)! + +I was just talking to a member of the Solaris-UFS team who recommended that we +test fdatasync. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Apr 6 01:47:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6F35C11F6256 + for ; + Thu, 6 Apr 2006 01:47:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34430-07 + for ; + Thu, 6 Apr 2006 01:47:01 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 5B5B011F61DB + for ; + Thu, 6 Apr 2006 01:47:02 -0300 (ADT) +Received: from preston.office (mail.eclinic.com.au [203.202.134.251]) + by svr4.postgresql.org (Postfix) with ESMTP id EC9B55AF89F + for ; + Thu, 6 Apr 2006 04:47:01 +0000 (GMT) +Received: from preston.office (preston [127.0.0.1]) + by preston.office (Postfix) with ESMTP id 324D110008A7; + Thu, 6 Apr 2006 14:46:56 +1000 (EST) +Received: from preston.office (preston [127.0.0.1]) + by preston.office (Postfix) with ESMTP id C03CD1001746; + Thu, 6 Apr 2006 14:46:55 +1000 (EST) +Received: from [192.168.1.28] (shawn.office [192.168.1.28]) + by preston.office (Postfix) with ESMTP id 706D910008A7; + Thu, 6 Apr 2006 14:46:55 +1000 (EST) +Message-ID: <44349D44.10902@eclinic.com.au> +Date: Thu, 06 Apr 2006 14:47:00 +1000 +From: Leigh Dyer +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Luke Lonergan +Cc: "Juan Casero (FL FLC)" , + Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/91 +X-Sequence-Number: 18175 + +Luke Lonergan wrote: +> Leigh, +> +> On 4/5/06 9:23 PM, "Leigh Dyer" wrote: +> +>> We've got a Sun Fire V40z and it's quite a nice machine -- 6x 15krpm +>> drives, 4GB RAM, and a pair of Opteron 850s. This gives us more than +>> enough power now for what we need, but it's nice to know that we can +>> shoehorn a lot more RAM, and up it to eight CPU cores if needed. +> +> We have one of these too - ours is signed by Scott McNealy. +> +Nice :) + +>> The newer Sun Opteron systems look nice too, but unless you're using +>> external storage, their little 2.5" hard drives may not be ideal. +> +> Yes - but they end-of-lifed the V20z and V40z! +> +That's quite disappointing to hear -- our V40z isn't even six months +old! We're not a big company, so external storage solutions are outside +our price range, but we still wanted a nice brand-name box, and the V40z +was a great deal compared to smaller boxes like the HP DL385. + +> One big problem with the sun line in general is the tiny internal storage +> capacity - already too small on the V40z at 5/6 drives, now ridiculous at 4 +> SAS drives on the galaxy series. +I'm sure those little SAS drives would be great for web servers and +other non-IO-intensive tasks though -- I'd love to get some X4100s in to +replace our Poweredge 1750s for that. It's a smart move overall IMHO, +but it's certainly not great for database serving. + +Thanks +Leigh +> +> - Luke +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 03:01:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1BE4B11F6CEA + for ; + Thu, 6 Apr 2006 03:01:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52359-01-3 + for ; + Thu, 6 Apr 2006 03:01:30 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id 8734B11F6CE0 + for ; + Thu, 6 Apr 2006 03:01:30 -0300 (ADT) +Received: from dell.home.lan (host14-128.pool8251.interbusiness.it + [82.51.128.14]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k3673xr26806; + Thu, 6 Apr 2006 09:03:59 +0200 +Subject: Re: bad performance on Solaris 10 +From: Chris Mair +To: Josh Berkus +Cc: Mark Kirkwood , pgsql-performance@postgresql.org, + llonergan@greenplum.com +In-Reply-To: <200604052135.14326.josh@agliodbs.com> +References: <1144111178.3723.80.camel@dell.home.lan> + <1144279780.5133.19.camel@dell.home.lan> + <44346DAA.2080905@paradise.net.nz> + <200604052135.14326.josh@agliodbs.com> +Content-Type: text/plain +Date: Thu, 06 Apr 2006 08:01:09 +0200 +Message-Id: <1144303269.3718.4.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/92 +X-Sequence-Number: 18176 + + +> > Yeah - looks good! (is the default open_datasync still?). Might be worth +> > trying out the fdatasync method too (ISTR this being quite good... again +> > on Solaris 8, so things might have changed)! +> +> I was just talking to a member of the Solaris-UFS team who recommended that we +> test fdatasync. + +Ok, so I did a few runs for each of the sync methods, keeping all the +rest constant and got this: + +open_datasync 0.7 +fdatasync 4.6 +fsync 4.5 +fsync_writethrough not supported +open_sync 0.6 + +in arbitrary units - higher is faster. + +Quite impressive! + +Bye, Chris. + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 03:45:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 33E4211F6B30 + for ; + Thu, 6 Apr 2006 03:45:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63905-02 + for ; + Thu, 6 Apr 2006 03:44:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz + [203.96.152.183]) + by postgresql.org (Postfix) with ESMTP id 16B4C11F6B0D + for ; + Thu, 6 Apr 2006 03:44:57 -0300 (ADT) +Received: from smtp-3.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-4.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IXA001L5G2VYG@linda-4.paradise.net.nz> for + pgsql-performance@postgresql.org; Thu, 06 Apr 2006 18:44:55 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-161.dsl.clear.net.nz [218.101.29.161]) by + smtp-3.paradise.net.nz (Postfix) with ESMTP id 0EEF51128C3A; + Thu, 06 Apr 2006 18:44:54 +1200 (NZST) +Date: Thu, 06 Apr 2006 18:44:52 +1200 +From: Mark Kirkwood +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +In-reply-to: <44349D44.10902@eclinic.com.au> +To: Leigh Dyer +Cc: Luke Lonergan , + "Juan Casero (FL FLC)" , + Josh Berkus , pgsql-performance@postgresql.org +Message-id: <4434B8E4.8010208@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20051106) +References: + <44349D44.10902@eclinic.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/96 +X-Sequence-Number: 18180 + +Leigh Dyer wrote: +> Luke Lonergan wrote: +> +>> Leigh, +>> +>> On 4/5/06 9:23 PM, "Leigh Dyer" wrote: +>> +>>> We've got a Sun Fire V40z and it's quite a nice machine -- 6x 15krpm +>>> drives, 4GB RAM, and a pair of Opteron 850s. This gives us more than +>>> enough power now for what we need, but it's nice to know that we can +>>> shoehorn a lot more RAM, and up it to eight CPU cores if needed. +>> +>> +>> We have one of these too - ours is signed by Scott McNealy. +>> +> +> Nice :) +> +>>> The newer Sun Opteron systems look nice too, but unless you're using +>>> external storage, their little 2.5" hard drives may not be ideal. +>> +>> +>> Yes - but they end-of-lifed the V20z and V40z! +>> +> That's quite disappointing to hear -- our V40z isn't even six months +> old! We're not a big company, so external storage solutions are outside +> our price range, but we still wanted a nice brand-name box, and the V40z +> was a great deal compared to smaller boxes like the HP DL385. +> +>> One big problem with the sun line in general is the tiny internal storage +>> capacity - already too small on the V40z at 5/6 drives, now ridiculous +>> at 4 +>> SAS drives on the galaxy series. +> +> I'm sure those little SAS drives would be great for web servers and +> other non-IO-intensive tasks though -- I'd love to get some X4100s in to +> replace our Poweredge 1750s for that. It's a smart move overall IMHO, +> but it's certainly not great for database serving. +> +> + +I notice that Supermicro have recently brought out some Opteron systems, +they are hiding them here: + +http://www.supermicro.com/Aplus/system/ + + +The 4U's have 8 SATA/SCSI drive bays - maybe still not enough, but +better than 6! + +Cheers + +Mark + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 03:56:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 87DAF11F68D0 + for ; + Thu, 6 Apr 2006 03:56:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63726-08 + for ; + Thu, 6 Apr 2006 03:56:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id 0021611F678F + for ; + Thu, 6 Apr 2006 03:56:00 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO + spooky.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9219403; Wed, 05 Apr 2006 23:59:01 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Wed, 5 Apr 2006 23:56:35 -0700 +User-Agent: KMail/1.8.2 +Cc: "Juan Casero \(FL FLC\)" , + "Luke Lonergan" +References: <7583B3F1891CC0429FA4A44952AA539C66FA7E@wfm-exchprd2.wfm.pvt> +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA7E@wfm-exchprd2.wfm.pvt> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604052356.36288.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200604/97 +X-Sequence-Number: 18181 + +Juan, + +> Ok that is beginning to become clear to me. Now I need to determine if +> this server is worth the investment for us. Maybe it is not a speed +> daemon but to be honest the licensing costs of an SMP aware RDBMS is +> outside our budget. + +You still haven't explained why you want multi-threaded queries. This is +sounding like keeping up with the Joneses. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Apr 6 04:29:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ED2BB11F6AB1 + for ; + Thu, 6 Apr 2006 04:29:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73726-02 + for ; + Thu, 6 Apr 2006 04:28:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from asgard1.americatelsal.com (asgard2.americatelsal.com + [200.13.161.7]) + by postgresql.org (Postfix) with ESMTP id 5216411F6ABD + for ; + Thu, 6 Apr 2006 04:28:49 -0300 (ADT) +Received: (qmail 4705 invoked from network); 6 Apr 2006 07:50:45 -0000 +Received: from unknown (HELO ?192.168.10.124?) (200.13.161.68) + by asgard1.americatelsal.com with SMTP; 6 Apr 2006 07:50:45 -0000 +Message-ID: <4434C419.3080709@123.com.sv> +Date: Thu, 06 Apr 2006 01:32:41 -0600 +From: Miguel +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mark Kirkwood +CC: Leigh Dyer , + Luke Lonergan , + "Juan Casero (FL FLC)" , + Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +References: + <44349D44.10902@eclinic.com.au> <4434B8E4.8010208@paradise.net.nz> +In-Reply-To: <4434B8E4.8010208@paradise.net.nz> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.406 required=5 tests=[AWL=0.406] +X-Spam-Score: 0.406 +X-Spam-Level: +X-Archive-Number: 200604/98 +X-Sequence-Number: 18182 + +Mark Kirkwood wrote: + +>> +>>>> The newer Sun Opteron systems look nice too, but unless you're using +>>>> external storage, their little 2.5" hard drives may not be ideal. +>>> +>>> +>>> +>>> Yes - but they end-of-lifed the V20z and V40z! +>>> +>> That's quite disappointing to hear -- our V40z isn't even six months +>> old! We're not a big company, so external storage solutions are +>> outside our price range, but we still wanted a nice brand-name box, +>> and the V40z was a great deal compared to smaller boxes like the HP +>> DL385. +>> +>>> One big problem with the sun line in general is the tiny internal +>>> storage +>>> capacity - already too small on the V40z at 5/6 drives, now +>>> ridiculous at 4 +>>> SAS drives on the galaxy series. +>> +>> +>> I'm sure those little SAS drives would be great for web servers and +>> other non-IO-intensive tasks though -- I'd love to get some X4100s in +>> to replace our Poweredge 1750s for that. It's a smart move overall +>> IMHO, but it's certainly not great for database serving. +>> +>> +> + +Excuse me for this off topic, but i notice that you are very excited +about the sun's hardware, what os do you install on them , slowlaris?, +has that os improved in some espectacular way that i should take a look +again?, i used it until solaris 9 and the performance was horrible. +im a happy freebsd user now (using hp and dell hardware though) + +--- +Miguel + +From pgsql-performance-owner@postgresql.org Thu Apr 6 04:37:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9175C11F6983 + for ; + Thu, 6 Apr 2006 04:37:12 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76229-03 + for ; + Thu, 6 Apr 2006 04:37:08 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-1.sun.com (brmea-mail-1.Sun.COM [192.18.98.31]) + by postgresql.org (Postfix) with ESMTP id 1142411F6AB8 + for ; + Thu, 6 Apr 2006 04:37:09 -0300 (ADT) +Received: from phys-d3-ha21sca-1 ([129.145.155.163]) + by brmea-mail-1.sun.com (8.12.10/8.12.9) with ESMTP id k367b8Gx009283 + for ; + Thu, 6 Apr 2006 01:37:09 -0600 (MDT) +Received: from conversion-daemon.ha21sca-mail1.sfbay.sun.com by + ha21sca-mail1.sfbay.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0IXA00M01IGRTB@ha21sca-mail1.sfbay.sun.com> + (original mail from Robert.Lor@Sun.COM) for + pgsql-performance@postgresql.org; + Thu, 06 Apr 2006 00:37:05 -0700 (PDT) +Received: from [129.150.12.119] + (vpn-129-150-12-119.SFBay.Sun.COM [129.150.12.119]) + by ha21sca-mail1.sfbay.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTP id <0IXA00M2EIHSTI@ha21sca-mail1.sfbay.sun.com>; Thu, + 06 Apr 2006 00:37:05 -0700 (PDT) +Date: Thu, 06 Apr 2006 00:36:37 -0700 +From: Robert Lor +Subject: Re: bad performance on Solaris 10 +In-reply-to: <1144303269.3718.4.camel@dell.home.lan> +To: Chris Mair +Cc: Josh Berkus , Mark Kirkwood , + pgsql-performance@postgresql.org, llonergan@greenplum.com +Message-id: <4434C505.1000205@sun.com> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7) Gecko/20050913 +References: <1144111178.3723.80.camel@dell.home.lan> + <1144279780.5133.19.camel@dell.home.lan> + <44346DAA.2080905@paradise.net.nz> + <200604052135.14326.josh@agliodbs.com> + <1144303269.3718.4.camel@dell.home.lan> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200604/99 +X-Sequence-Number: 18183 + +Chris Mair wrote: + +>Ok, so I did a few runs for each of the sync methods, keeping all the +>rest constant and got this: +> +>open_datasync 0.7 +>fdatasync 4.6 +>fsync 4.5 +>fsync_writethrough not supported +>open_sync 0.6 +> +>in arbitrary units - higher is faster. +> +>Quite impressive! +> +> +> +> +Chris, +Just to make sure the x4100 config is similar to your Linux system, can +you verify the default setting for disk write cache and make sure they +are both enabled or disabled. Here's how to check in Solaris. +As root, run "format -e" -> pick a disk -> cache -> write_cache -> display + +Not sure how to do it on Linux though! + +Regards, +-Robert + +From pgsql-performance-owner@postgresql.org Thu Apr 6 04:42:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DCEE511F6981 + for ; + Thu, 6 Apr 2006 04:42:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76045-03 + for ; + Thu, 6 Apr 2006 04:42:28 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id A69D111F685A + for ; + Thu, 6 Apr 2006 04:42:29 -0300 (ADT) +Received: from preston.office (mail.eclinic.com.au [203.202.134.251]) + by svr4.postgresql.org (Postfix) with ESMTP id BC9705AF8DC + for ; + Thu, 6 Apr 2006 07:42:29 +0000 (GMT) +Received: from preston.office (preston [127.0.0.1]) + by preston.office (Postfix) with ESMTP id DDEF810008A7; + Thu, 6 Apr 2006 17:42:22 +1000 (EST) +Received: from preston.office (preston [127.0.0.1]) + by preston.office (Postfix) with ESMTP id 655631001746; + Thu, 6 Apr 2006 17:42:22 +1000 (EST) +Received: from [192.168.1.28] (shawn.office [192.168.1.28]) + by preston.office (Postfix) with ESMTP id 1683910008A7; + Thu, 6 Apr 2006 17:42:22 +1000 (EST) +Message-ID: <4434C663.9070702@eclinic.com.au> +Date: Thu, 06 Apr 2006 17:42:27 +1000 +From: Leigh Dyer +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Miguel +Cc: Mark Kirkwood , + Luke Lonergan , + "Juan Casero (FL FLC)" , + Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +References: + <44349D44.10902@eclinic.com.au> <4434B8E4.8010208@paradise.net.nz> + <4434C419.3080709@123.com.sv> +In-Reply-To: <4434C419.3080709@123.com.sv> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/100 +X-Sequence-Number: 18184 + +Miguel wrote: +> +> Excuse me for this off topic, but i notice that you are very excited +> about the sun's hardware, what os do you install on them , slowlaris?, +> has that os improved in some espectacular way that i should take a look +> again?, i used it until solaris 9 and the performance was horrible. +> im a happy freebsd user now (using hp and dell hardware though) + +I'm running Debian Sarge AMD64 on mine, and it works wonderfully. I'm +not a Solaris person, and I never plan on becoming one, but Sun's +Opteron hardware is quite nice. The remote management was one of the +features that sold me -- full control over power, etc. and +serial-over-LAN, through an SSH interface. + +Sun don't support Debian officially (but we don't have a software +support contract anyway, so I'm not too fussed), but I'm pretty sure +they support at least SLES and RHEL. + +Thanks +Leigh + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 05:50:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 507CE11F6677 + for ; + Thu, 6 Apr 2006 05:50:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89902-07 + for ; + Thu, 6 Apr 2006 05:50:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.ipf.is (benz.ipf.is [85.197.192.156]) + by postgresql.org (Postfix) with ESMTP id DB56511F663E + for ; + Thu, 6 Apr 2006 05:50:41 -0300 (ADT) +Received: (qmail 29492 invoked by uid 1010); 6 Apr 2006 08:49:43 +0000 +Received: from 85.197.216.186 by benz (envelope-from , + uid 1008) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1235. spamassassin: 3.1.1. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. + Processed in 0.327529 secs); 06 Apr 2006 08:49:43 -0000 +X-Antivirus-IPF-Mail-From: gnari@hive.is via benz +X-Antivirus-IPF: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. + Processed in 0.327529 secs Process 29485) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx1.ipf.is with SMTP; 6 Apr 2006 08:49:43 +0000 +Subject: Re: Query planner is using wrong index. +From: Ragnar +To: Brian Herlihy +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060406023544.37250.qmail@web52305.mail.yahoo.com> +References: <20060406023544.37250.qmail@web52305.mail.yahoo.com> +Content-Type: text/plain +Date: Thu, 06 Apr 2006 08:52:54 +0000 +Message-Id: <1144313574.32289.78.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/102 +X-Sequence-Number: 18186 + +On fim, 2006-04-06 at 12:35 +1000, Brian Herlihy wrote: + +> I have a problem with the choice of index made by the query planner. +> +> My table looks like this: +> +> CREATE TABLE t +> ( +> p1 varchar not null, +> p2 varchar not null, +> p3 varchar not null, +> i1 integer, +> i2 integer, +> i3 integer, +> i4 integer, +> i5 integer, +> d1 date, +> d2 date, +> d3 date, +> PRIMARY KEY (p1, p2, p3) +> ); +> +> I have also created an index on (p2, p3), as some of my lookups are on these +> only. + +> All the integers and dates are data values. +> The table has around 9 million rows. +> I am using postgresl 7.4.7 +> +> I have set statistics to 1000 on the p1, p2 and p3 columns, and run vacuum full +> analyse. However, I still see +> query plans like this: +> +... +> db=# explain select * from t where p2 = 'fairly_common' and p3 = +> 'fairly_common'; +> QUERY PLAN +> ----------------------------------------------------------------------------------------------------------------------------------- +> Index Scan using p2p3 on t (cost=0.00..6.01 rows=1 width=102) +> Index Cond: (((p2)::text = 'fairly_common'::text) AND ((p3)::text = +> 'fairly_common'::text)) +> (3 rows) + +please show us an actual EXPLAIN ANALYZE +this will show us more. + +> I would like the query planner to use the primary key for all of these lookups. +> How can I enforce this? + +How would that help? have you tested to see if it would +actualy be better? + +gnari + + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 05:57:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6278711F6602 + for ; + Thu, 6 Apr 2006 05:57:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92494-08 + for ; + Thu, 6 Apr 2006 05:57:42 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 1696911F6677 + for ; + Thu, 6 Apr 2006 05:57:45 -0300 (ADT) +Received: from smtp1.voila.fr (smtp2.voila.fr [193.252.22.175]) + by svr4.postgresql.org (Postfix) with ESMTP id 7FEBB5AF88B + for ; + Thu, 6 Apr 2006 08:57:45 +0000 (GMT) +Received: from me-wanadoo.net (localhost [127.0.0.1]) + by mwinf4104.voila.fr (SMTP Server) with ESMTP id 433021C0050E + for ; + Thu, 6 Apr 2006 10:57:41 +0200 (CEST) +Received: from wwinf4101 (wwinf4101 [172.22.152.28]) + by mwinf4104.voila.fr (SMTP Server) with ESMTP id 3E6EE1C0064F + for ; + Thu, 6 Apr 2006 10:57:41 +0200 (CEST) +X-ME-UUID: 20060406085741255.3E6EE1C0064F@mwinf4104.voila.fr +Message-ID: <14743652.1144313861246.JavaMail.www@wwinf4101> +From: luchot +Reply-To: luchot@voila.fr +To: pgsql-performance@postgresql.org +Subject: Maintenance_work_mem influence on queries +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_142242_16791070.1144313861245" +X-Originating-IP: [129.185.75.10] +X-Wum-Nature: EMAIL-NATURE +X-WUM-FROM: |~| +X-WUM-TO: |~| +X-WUM-REPLYTO: |~| +Date: Thu, 6 Apr 2006 10:57:41 +0200 (CEST) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.946 required=5 tests=[HTML_10_20=0.945, + HTML_MESSAGE=0.001] +X-Spam-Score: 0.946 +X-Spam-Level: +X-Archive-Number: 200604/103 +X-Sequence-Number: 18187 + +------=_Part_142242_16791070.1144313861245 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Hello, +I am doing some test with differents values for the parameter maintenance_work_mem in order to +ameliorate the time for the creation of index and and the use of vacuum and analyse. +I read in the doc that this parameter is just for create index, vacuum and analyse and foreign key . +But when i test 2 queries with differents values the result are twice big : +for mwm to 64 Mo the query 1 last 34 min and the query 2 41 min +for mwm to 512 mo the query 1 last 17 min and the query 2 21 min +So my question is in what condition the parameter maintenance_work_mem influence on the execution of queries. + Thanks , +------=_Part_142242_16791070.1144313861245 +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +

Hello,

+

I am doing some test with differents values for the parameter maintenance_work_mem in order to

+

ameliorate the time for the creation of index and and the use of vacuum and analyse.

+

I read in the doc that this parameter is just for create index, vacuum and analyse and foreign key .

+

But when i test 2 queries with differents values the result are twice big :

+

for mwm to 64 Mo   the query 1 last 34 min and the query 2   41 min

+

for mwm to 512 mo the query 1 last 17 min and the query 2 21 min

+

So my question is in what condition the parameter maintenance_work_mem influence on the execution of queries. 

+

  Thanks ,

+------=_Part_142242_16791070.1144313861245-- + + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 06:08:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 21FD711F674A + for ; + Thu, 6 Apr 2006 06:08:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92927-10 + for ; + Thu, 6 Apr 2006 06:08:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id C92DC11F6709 + for ; + Thu, 6 Apr 2006 06:08:01 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (Taa30.t.pppool.de + [89.55.170.48]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id E9410656C0; + Thu, 6 Apr 2006 11:08:48 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 9FC2F18167709; + Thu, 6 Apr 2006 11:08:14 +0200 (CEST) +Message-ID: <4434DA7E.1030307@logix-tt.com> +Date: Thu, 06 Apr 2006 11:08:14 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Juan Casero (FL FLC)" +Cc: pgsql-performance@postgresql.org +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +References: <7583B3F1891CC0429FA4A44952AA539C66FA7E@wfm-exchprd2.wfm.pvt> +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA7E@wfm-exchprd2.wfm.pvt> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/104 +X-Sequence-Number: 18188 + +Hi, Juan, + +Juan Casero (FL FLC) wrote: +> Ok that is beginning to become clear to me. Now I need to determine if +> this server is worth the investment for us. Maybe it is not a speed +> daemon but to be honest the licensing costs of an SMP aware RDBMS is +> outside our budget. When postgresql starts does it start up a super +> server process and then forks copies of itself to handle incoming +> requests? + +It starts a super server process (Postmaster) and some background +processes (background writer, stats collector). For each incoming +connection, the postmaster forks a single-threaded backend process, +which handles all queries and transactions on this connection, and +terminates when the connection terminates. + +So as a thumb-rule, each connection can utilize only a single CPU. You +can utilize a few more CPUs than you have simultaneous connections, due +to the background processes and the OS needing CPU for I/O, but thats +rather marginal. + +AFAIK, Bizgres MPP has extended the backend processes to be multi +threaded, so a single connection can utilize several CPUs for some types +of queries (large data sets, sorting/joining/hashing etc.). Btw, I +presume that they might offer you a free test license, and I also +presume their license fee is much lower than Oracle or DB/2. + +> Or do I have to specify how many server processes should be +> started up? + +You can limit the number of server processes by setting the maximum +connection limit. + +> I figured maybe I can take advantage of the multiple cpu's +> on this system by starting up enough postgres server processes to handle +> large numbers of incoming connections. I have this server available for +> sixty days so I may as well explore the performance of postgresql on it. + +Yes, you can take advantage if you have multiple clients (e. G. a wep +app, that's what the T2000 / Niagara were made for). You have a Tomcat +or Jboss sitting on it, each http connection forks its own thread. Each +customer has its own CPU :-) + +Then use a connection pool to PostgreSQL, and you're fine. The more +customers, the more CPUs are utilized. + +But beware, if you have floating point maths, it will be very slow. All +8 CPUs / 32 Threads share a single FPU. So if you need floating point +(e. G. Mapserver, PostGIS geoprocessing, Java2D chart drawing or +something), T2000 is not the right thing for you. + + +HTH, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Thu Apr 6 06:27:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1312711F6768 + for ; + Thu, 6 Apr 2006 06:27:17 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99981-04 + for ; + Thu, 6 Apr 2006 06:27:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from web52315.mail.yahoo.com (web52315.mail.yahoo.com + [206.190.48.158]) + by postgresql.org (Postfix) with SMTP id 5648311F66C4 + for ; + Thu, 6 Apr 2006 06:27:14 -0300 (ADT) +Received: (qmail 8727 invoked by uid 60001); 6 Apr 2006 09:27:11 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; + h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=tmPyqT71+Bj4VVHGF9+25W1NhD4lQm31STfnzZja81GwgTu/rREQU7hREzwiqzU+dMzHO7eVPWnpjEb2GLtMbcQQUnlnYZBX0jkjJ4UjSQPYLoleqB0UarkR6bCXSGonGJSUT8UWafDJo7xqQSDMTGXVCn9jz6Zcjqy+eOPJnPY= + ; +Message-ID: <20060406092711.8725.qmail@web52315.mail.yahoo.com> +Received: from [202.156.6.68] by web52315.mail.yahoo.com via HTTP; + Thu, 06 Apr 2006 19:27:11 EST +Date: Thu, 6 Apr 2006 19:27:11 +1000 (EST) +From: Brian Herlihy +Subject: Re: Query planner is using wrong index. +To: pgsql-performance@postgresql.org +In-Reply-To: <1144313574.32289.78.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200604/105 +X-Sequence-Number: 18189 + + +--- Ragnar wrote: + +> On fim, 2006-04-06 at 12:35 +1000, Brian Herlihy wrote: +> +> > I have a problem with the choice of index made by the query planner. +> > +> > My table looks like this: +> > +> > CREATE TABLE t +> > ( +> > p1 varchar not null, +> > p2 varchar not null, +> > p3 varchar not null, +> > i1 integer, +> > i2 integer, +> > i3 integer, +> > i4 integer, +> > i5 integer, +> > d1 date, +> > d2 date, +> > d3 date, +> > PRIMARY KEY (p1, p2, p3) +> > ); +> > +> > I have also created an index on (p2, p3), as some of my lookups are on +> these +> > only. +> +> > All the integers and dates are data values. +> > The table has around 9 million rows. +> > I am using postgresl 7.4.7 +> > +> > I have set statistics to 1000 on the p1, p2 and p3 columns, and run vacuum +> full +> > analyse. However, I still see +> > query plans like this: +> > +> ... +> > db=# explain select * from t where p2 = 'fairly_common' and p3 = +> > 'fairly_common'; +> +> > QUERY PLAN +> > +> +----------------------------------------------------------------------------------------------------------------------------------- +> > Index Scan using p2p3 on t (cost=0.00..6.01 rows=1 width=102) +> > Index Cond: (((p2)::text = 'fairly_common'::text) AND ((p3)::text = +> > 'fairly_common'::text)) +> > (3 rows) +> +> please show us an actual EXPLAIN ANALYZE +> this will show us more. +> +> > I would like the query planner to use the primary key for all of these +> lookups. +> > How can I enforce this? +> +> How would that help? have you tested to see if it would +> actualy be better? +> +> gnari +> + +Yes, the primary key is far better. I gave it the ultimate test - I dropped +the (p2, p3) index. It's blindingly fast when using the PK, which is what I +expect from Postgresql :) This query is part of an import process, which has +been getting increasingly slow as the table has grown. + +I first discovered the problem when I noticed queries which should be simple PK +lookups taking up to 2.5 seconds on an idle system. I discussed this problem +in the Postgres IRC channel, and it turns out to be due to an inaccurate +selectivity estimate. + +The columns p2 and p3 are highly correlated, which is why I often get hundreds +of rows even after specifying values for both these columns. However, the +query optimizer assumes the columns are not correlated. It calculates the +selectivity for each column seperately, then multiplies them to get the +combined selectivity for specifying both p2 and p3. This results in an +estimate of 1 row, which makes the (p2,p3) index look as good as the (p1,p2,p3) +index. + +I'm aware now that there is no way to force use of a particular index in +Postgres. I've also been told that there is no way to have the optimizer take +into account correlation between column values. + +My options seem to be + - Fudge the analysis results so that the selectivity estimate changes. I +have tested reducing n_distinct, but this doesn't seem to help. + - Combine the columns into one column, allowing postgres to calculate the +combined selectivity. + - Drop the (p2, p3) index. But I need this for other queries. + +None of these are good solutions. So I am hoping that there is a better way to +go about this! + +Thanks, +Brian + +From pgsql-performance-owner@postgresql.org Thu Apr 6 08:34:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E498C11F6780 + for ; + Thu, 6 Apr 2006 08:34:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26651-02 + for ; + Thu, 6 Apr 2006 08:34:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp1.wholefoods.com (smtp1.wholefoods.com [64.132.0.20]) + by postgresql.org (Postfix) with ESMTP id 0D4BA11F66C7 + for ; + Thu, 6 Apr 2006 08:34:25 -0300 (ADT) +Received: from unknown (HELO wfm-exchprd2.wfm.pvt) ([10.2.2.22]) + by smtp1.wholefoods.com with ESMTP; 06 Apr 2006 06:34:57 -0500 +X-IronPort-AV: i="4.04,93,1144040400"; d="scan'208"; a="23241502:sNHT30507911" +Content-class: urn:content-classes:message +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Date: Thu, 6 Apr 2006 06:32:45 -0500 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Message-ID: <7583B3F1891CC0429FA4A44952AA539C66FA8B@wfm-exchprd2.wfm.pvt> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZZRy3eCrB6JFP8SNiSFiH06Cx8WwAJHrSw +From: "Juan Casero \(FL FLC\)" +To: "Josh Berkus" , + +Cc: "Luke Lonergan" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/106 +X-Sequence-Number: 18190 + +Because I plan to develop a rather large (for us anyway) data warehouse +with PostgreSQL. I am looking for the right hardware that can handle +queries on a database that might grow to over a 100 gigabytes. Right +now our decision support system based on postgresql 8.1.3 stores retail +sales information for about 4 four years back *but* only as weekly +summaries. I want to build the system so it can handle daily sales +transactions also. You can imagine how many more records this will +involve so I am looking for hardware that can give me the performance I +need to make this project useable. In other words parsing and loading +the daily transaction logs for our stores is likely to take huge amounts +of effort. I need a machine that can complete the task in a reasonable +amount of time. As people start to query the database to find sales +related reports and information I need to make sure the queries will run +reasonably fast for them. I have already hand optimized all of my +queries on the current system. But currently I only have weekly sales +summaries. Other divisions in our company have done a similar project +using MS SQL Server on SMP hardware far outclassing the database server +I currently use and they report heavy loads on the server with less than +ideal query run times. I am sure I can do my part to optimize the +queries once I start this project but there is only so much you can do. +At some point you just need more powerful hardware. This is where I am +at right now. Apart from that since I will only get this one chance to +buy a new server for data processing I need to make sure that I buy +something that can grow over time as our needs change. I don't want to +buy a server only to find out later that it cannot meet our needs with +future database projects. I have to balance a limited budget, room for +future performance growth, and current system requirements. Trust me it +isn't easy. =20 + + +Juan + +-----Original Message----- +From: Josh Berkus [mailto:josh@agliodbs.com]=20 +Sent: Thursday, April 06, 2006 2:57 AM +To: pgsql-performance@postgresql.org +Cc: Juan Casero (FL FLC); Luke Lonergan +Subject: Re: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 + +Juan, + +> Ok that is beginning to become clear to me. Now I need to determine=20 +> if this server is worth the investment for us. Maybe it is not a=20 +> speed daemon but to be honest the licensing costs of an SMP aware=20 +> RDBMS is outside our budget. + +You still haven't explained why you want multi-threaded queries. This +is sounding like keeping up with the Joneses. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Apr 6 08:47:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E03E311F6936 + for ; + Thu, 6 Apr 2006 08:47:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28278-05 + for ; + Thu, 6 Apr 2006 08:47:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.ipf.is (benz.ipf.is [85.197.192.156]) + by postgresql.org (Postfix) with ESMTP id 5916B11F6972 + for ; + Thu, 6 Apr 2006 08:47:41 -0300 (ADT) +Received: (qmail 15705 invoked by uid 1010); 6 Apr 2006 11:46:43 +0000 +Received: from 85.197.216.186 by benz (envelope-from , + uid 1008) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1235. spamassassin: 3.1.1. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.1/4.5):. + Processed in 0.296651 secs); 06 Apr 2006 11:46:43 -0000 +X-Antivirus-IPF-Mail-From: gnari@hive.is via benz +X-Antivirus-IPF: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.1/4.5):. + Processed in 0.296651 secs Process 15698) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx1.ipf.is with SMTP; 6 Apr 2006 11:46:43 +0000 +Subject: Re: Query planner is using wrong index. +From: Ragnar +To: Brian Herlihy +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060406092711.8725.qmail@web52315.mail.yahoo.com> +References: <20060406092711.8725.qmail@web52315.mail.yahoo.com> +Content-Type: text/plain +Date: Thu, 06 Apr 2006 11:49:56 +0000 +Message-Id: <1144324196.32289.91.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/107 +X-Sequence-Number: 18191 + +On fim, 2006-04-06 at 19:27 +1000, Brian Herlihy wrote: +> --- Ragnar wrote: +> +> > On fim, 2006-04-06 at 12:35 +1000, Brian Herlihy wrote: +> > +... +> > > PRIMARY KEY (p1, p2, p3) +... +> > > +> > > I have also created an index on (p2, p3), as some of my lookups are on +> > > these only. +... +> > > db=# explain select * from t where p2 = 'fairly_common' and p3 = +> > > 'fairly_common'; + +> > please show us an actual EXPLAIN ANALYZE + +> > > I would like the query planner to use the primary key for all of these +> > lookups. +> > +> > have you tested to see if it would actualy be better? +> > + +> Yes, the primary key is far better. I gave it the ultimate test - I dropped +> the (p2, p3) index. It's blindingly fast when using the PK, + +I have problems understanding exactly how an index on +(p1,p2,p3) can be faster than and index on (p2,p3) for +a query not involving p1. +can you demonstrate this with actual EXPLAIN ANALYZES ? +something like: +EXPLAIN ANALYZE select * from t where p2 = ? and p3 = ?; +BEGIN; +DROP INDEX p2p3; +EXPLAIN ANALYZE select * from t where p2 = ? and p3 = ?; +ROLLBACK; + +maybe your p2p3 index needs REINDEX ? + + +> My options seem to be +> - Fudge the analysis results so that the selectivity estimate changes. I +> have tested reducing n_distinct, but this doesn't seem to help. +> - Combine the columns into one column, allowing postgres to calculate the +> combined selectivity. +> - Drop the (p2, p3) index. But I need this for other queries. +> +> None of these are good solutions. So I am hoping that there is a better way to +> go about this! + +I think we must detemine exactly what the problem is +before devising complex solutions + +gnari + + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 10:30:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2F8E311F6621 + for ; + Thu, 6 Apr 2006 10:30:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57346-01 + for ; + Thu, 6 Apr 2006 10:30:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 9B58911F61CE + for ; + Thu, 6 Apr 2006 10:30:31 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k36DUVG04472; + Thu, 6 Apr 2006 09:30:31 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200604061330.k36DUVG04472@candle.pha.pa.us> +Subject: Re: Intel C/C++ Compiler Tests (fwd) +In-Reply-To: <66602070604060345v3dbdd140w64f320897974f322@mail.gmail.com> +To: PostgreSQL Performance +Date: Thu, 6 Apr 2006 09:30:31 -0400 (EDT) +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/108 +X-Sequence-Number: 18192 + +> > On 3/22/06 5:56 AM, "Spiegelberg, Greg" wrote: +> > +> > > Has anyone tested PostgreSQL 8.1.x compiled with Intel's Linux C/C++ +> > > compiler? +> > +> > We used to compile 8.0 with icc and 7.x before that. We found very good +> > performance gains for Intel P4 architecture processors and some gains for +> > AMD Athlon. +> > +> > Lately, the gcc compilers have caught up with icc on pipelining +> > optimizations and they generate better code for Opteron than icc, so we +> > found that icc was significantly slower than gcc on Opteron and no +> > different +> > on P4/Xeon. +> > +> > Maybe things have changed in newer versions of icc, the last tests I did +> > were about 1 year ago. + +EnterpriseDB is seeing the same thing, that gcc4 now has the same +performance as icc, and is more flexible. + +-- + Bruce Momjian http://candle.pha.pa.us + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 10:45:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 193CB11F6AD0 + for ; + Thu, 6 Apr 2006 10:45:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58739-08 + for ; + Thu, 6 Apr 2006 10:45:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 5A00C11F6B1B + for ; + Thu, 6 Apr 2006 10:45:37 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id E959AB820 + for ; + Thu, 6 Apr 2006 09:45:34 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: +References: <4431C4B4.4090300@123.com.sv> <4431D591.30500@paradise.net.nz> + + +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <34268F66-1525-422E-8DEC-C1AA45C5853B@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: freebsd/softupdates for data dir +Date: Thu, 6 Apr 2006 09:45:34 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/109 +X-Sequence-Number: 18193 + + +On Apr 5, 2006, at 6:07 PM, Jim Nasby wrote: + +> +> More importantly, it allows the system to come up and do fsck in +> the background. If you've got a large database that's a pretty big +> benefit. + +That's a UFS2 feature, not a soft-updates feature. + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 11:01:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0DF8011F66BA + for ; + Thu, 6 Apr 2006 11:01:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64914-04 + for ; + Thu, 6 Apr 2006 11:01:43 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.199]) + by postgresql.org (Postfix) with ESMTP id 2F36E11F662D + for ; + Thu, 6 Apr 2006 11:01:46 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id h31so118998wxd + for ; + Thu, 06 Apr 2006 07:01:47 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=CLBmHnxT0o0jQi1H7NlRRVBoHnZPKey797U/mEtD7ONjJ+ut/6o5HrArRX2GmbvcSrZ/XGO+phPnz7QqPmi4QxUYpFSR0fXqigOH3rLHAN4PczUPfFjUANaOTSVGsOrrERN6dYSIFRodtxNUTs9IZ0K2+ZdfefLtypwEZN5PYFE= +Received: by 10.70.116.3 with SMTP id o3mr753196wxc; + Thu, 06 Apr 2006 07:01:45 -0700 (PDT) +Received: by 10.70.126.4 with HTTP; Thu, 6 Apr 2006 07:01:45 -0700 (PDT) +Message-ID: +Date: Thu, 6 Apr 2006 09:01:45 -0500 +From: "Matthew Nuzum" +Reply-To: newz@bearfruit.org +To: "Juan Casero (FL FLC)" +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Cc: pgsql-performance@postgresql.org +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA8B@wfm-exchprd2.wfm.pvt> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <7583B3F1891CC0429FA4A44952AA539C66FA8B@wfm-exchprd2.wfm.pvt> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/110 +X-Sequence-Number: 18194 + +On 4/6/06, Juan Casero (FL FLC) wrote: +> Because I plan to develop a rather large (for us anyway) data warehouse +> with PostgreSQL. I am looking for the right hardware that can handle +> queries on a database that might grow to over a 100 gigabytes. + +You need to look for a server that has fast I/O. 100 GB of data will +take a long time to scan through and won't fit in RAM. + +> Right +> now our decision support system based on postgresql 8.1.3 stores retail +> sales information for about 4 four years back *but* only as weekly +> summaries. I want to build the system so it can handle daily sales +> transactions also. You can imagine how many more records this will +> involve so I am looking for hardware that can give me the performance I +> need to make this project useable. + +Sounds like you need to be doing a few heavy queries when you do this, +not tons of small queries. That likely means you need fewer CPUs that +are very fast. + +> In other words parsing and loading +> the daily transaction logs for our stores is likely to take huge amounts +> of effort. I need a machine that can complete the task in a reasonable +> amount of time. + +See my previous comment + +> As people start to query the database to find sales +> related reports and information I need to make sure the queries will run +> reasonably fast for them. + +Get more than one CPU core and make sure you have a lot of drive +spindles. You will definately want to be able to ensure a long running +query doesn't hog your i/o system. I have a server with a single disk +and when we do a long query the server load will jump from about .2 to +10 until the long query finishes. More cpus won't help this because +the bottle neck is the disk. + +> I have already hand optimized all of my +> queries on the current system. But currently I only have weekly sales +> summaries. Other divisions in our company have done a similar project +> using MS SQL Server on SMP hardware far outclassing the database server +> I currently use and they report heavy loads on the server with less than +> ideal query run times. I am sure I can do my part to optimize the +> queries once I start this project but there is only so much you can do. +> At some point you just need more powerful hardware. This is where I am +> at right now. + +You say "this is where I am at right __now__" but where will you be in +9 months? Sounds like you will be i/o bound by the time you get above +10GB. + +> Apart from that since I will only get this one chance to +> buy a new server for data processing I need to make sure that I buy +> something that can grow over time as our needs change. I don't want to +> buy a server only to find out later that it cannot meet our needs with +> future database projects. I have to balance a limited budget, room for +> future performance growth, and current system requirements. Trust me it +> isn't easy. + +Isn't it about time we had our annual "what kind of server can I get +for $8k" thread? + +-- +Matthew Nuzum +www.bearfruit.org + +From pgsql-performance-owner@postgresql.org Thu Apr 6 11:01:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0F19011F662D + for ; + Thu, 6 Apr 2006 11:01:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64164-04 + for ; + Thu, 6 Apr 2006 11:01:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from web52310.mail.yahoo.com (web52310.mail.yahoo.com + [206.190.48.153]) + by postgresql.org (Postfix) with SMTP id 9019211F664C + for ; + Thu, 6 Apr 2006 11:01:51 -0300 (ADT) +Received: (qmail 83129 invoked by uid 60001); 6 Apr 2006 14:01:51 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; + h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=czQn9B5o7PEA27XzzCjAqKHiFqmJTdDkdfV5x6KrHalyUbVEBIP0WzP9e8KPDXRB72UDMvm+vch2vR+na1MDVW51ruTTkK0IbeAPf6OSAFqi5/j3utQfsO3YhsueIxZJ6DAlt63eBAceR4Qal/Rlli63U6P08ZRGNhOjlg6z//A= + ; +Message-ID: <20060406140151.83127.qmail@web52310.mail.yahoo.com> +Received: from [202.156.6.68] by web52310.mail.yahoo.com via HTTP; + Fri, 07 Apr 2006 00:01:51 EST +Date: Fri, 7 Apr 2006 00:01:51 +1000 (EST) +From: Brian Herlihy +Subject: Re: Query planner is using wrong index. +To: pgsql-performance@postgresql.org +In-Reply-To: <1144324196.32289.91.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200604/111 +X-Sequence-Number: 18195 + + +--- Ragnar wrote: + +> On fim, 2006-04-06 at 19:27 +1000, Brian Herlihy wrote: +> +> > Yes, the primary key is far better. I gave it the ultimate test - I +> dropped +> > the (p2, p3) index. It's blindingly fast when using the PK, +> +> I have problems understanding exactly how an index on +> (p1,p2,p3) can be faster than and index on (p2,p3) for +> a query not involving p1. +> can you demonstrate this with actual EXPLAIN ANALYZES ? +> something like: +> EXPLAIN ANALYZE select * from t where p2 = ? and p3 = ?; +> BEGIN; +> DROP INDEX p2p3; +> EXPLAIN ANALYZE select * from t where p2 = ? and p3 = ?; +> ROLLBACK; +> +> maybe your p2p3 index needs REINDEX ? +> + +Here's the output. The timings after caching are repeatable (varying only by +10% or so). + +Query before caching: + +db# explain analyze select * from t WHERE p1 = 'a' and p2 = 'uk.altavista.com' +AND p3 = 'web/results?itag=&q=&kgs=&kls='; + QUERY PLAN + +--------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using p2_p3_idx on t (cost=0.00..6.02 rows=1 width=102) (actual +time=2793.247..2793.247 rows=0 loops=1) + Index Cond: (((p2)::text = 'uk.altavista.com'::text) AND ((p3)::text = +'web/results?itag=&q=&kgs=&kls='::text)) + Filter: ((p1)::text = 'a'::text) + Total runtime: 2793.303 ms +(4 rows) + +Query after caching: + +db# explain analyze select * from t WHERE p1 = 'a' and p2 = 'uk.altavista.com' +AND p3 = 'web/results?itag=&q=&kgs=&kls='; + QUERY PLAN + +--------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using p2_p3_idx on t (cost=0.00..6.02 rows=1 width=102) (actual +time=0.617..0.617 rows=0 loops=1) + Index Cond: (((p2)::text = 'uk.altavista.com'::text) AND ((p3)::text = +'web/results?itag=&q=&kgs=&kls='::text)) + Filter: ((p1)::text = 'a'::text) + Total runtime: 0.665 ms +(4 rows) + +=== At this point I did "DROP INDEX p2_p3_idx" + +Query after dropping index: + +db# explain analyze select * from t WHERE p1 = 'a' and p2 = 'uk.altavista.com' +AND p3 = 'web/results?itag=&q=&kgs=&kls='; + +QUERY PLAN + +---------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using t_pkey on t (cost=0.00..6.02 rows=1 width=102) (actual +time=95.188..95.188 rows=0 loops=1) + Index Cond: (((p1)::text = 'a'::text) AND ((p2)::text = +'uk.altavista.com'::text) AND ((p3)::text = +'web/results?itag=&q=&kgs=&kls='::text)) + Total runtime: 95.239 ms +(3 rows) + +Query after dropping index, fully cached: + +db# explain analyze select * from t WHERE p1 = 'a' and p2 = 'uk.altavista.com' +AND p3 = 'web/results?itag=&q=&kgs=&kls='; + +QUERY PLAN + +---------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using t_pkey on t (cost=0.00..6.02 rows=1 width=102) (actual +time=0.030..0.030 rows=0 loops=1) + Index Cond: (((p1)::text = 'a'::text) AND ((p2)::text = +'uk.altavista.com'::text) AND ((p3)::text = +'web/results?itag=&q=&kgs=&kls='::text)) + Total runtime: 0.077 ms +(3 rows) + + + +And one where the query planner chooses the primary key instead. Both p2 and +p3 are present as Most Common Values in pg_statistics: + +Query before fully cached: + +db# explain analyze SELECT * FROM t WHERE p1 = 'b' AND p2 = 'www.google.com' +AND p3 = 'search?hl=&lr=&q='; + + +QUERY PLAN + +------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using t_pkey on t (cost=0.00..6.02 rows=1 width=102) (actual +time=212.092..212.100 rows=1 loops=1) + Index Cond: (((p1)::text = 'b'::text) AND ((p2)::text = +'www.google.com'::text) AND ((p3)::text = 'search?hl=&lr=&q='::text)) + Total runtime: 212.159 ms +(3 rows) + +Query after fully cached: + +db# explain analyze SELECT * FROM t WHERE p1 = 'b' AND p2 = 'www.google.com' +AND p3 = 'search?hl=&lr=&q='; + +QUERY PLAN + +------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using t_pkey on t (cost=0.00..6.02 rows=1 width=102) (actual +time=0.034..0.039 rows=1 loops=1) + Index Cond: (((p1)::text = 'b'::text) AND ((p2)::text = +'www.google.com'::text) AND ((p3)::text = 'search?hl=&lr=&q='::text)) + Total runtime: 0.094 ms +(3 rows) + + +I have set statistics to 1000 on all of p1, p2 and p3. The table was recently +vacuumed and analyzed, and the index was recreated (after being dropped) before +these tests were run. The tests are 100% reproducible, both in postgresql +7.4.7 and 8.1.3. + +The indexes are: + +t_pkey (p1, p2, p3) -- UNIQUE, PRIMARY KEY +p2_p3_idx (p2, p3) -- NOT UNIQUE + +The problem is that a lookup which specifies p2 and p3 can return as many as +500 rows. The optimizer assumes that such a lookup will return 1 row, and so +it chooses a bad plan. That sums it up. + +What I need is a way to make it choose the primary key. + +Thanks in advance, +Brian + +From pgsql-performance-owner@postgresql.org Thu Apr 6 11:48:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C847911F6621 + for ; + Thu, 6 Apr 2006 11:48:12 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76087-03-3 + for ; + Thu, 6 Apr 2006 11:48:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from danbo.digsys.bg (danbo.digsys.bg [192.92.129.13]) + by postgresql.org (Postfix) with ESMTP id E205911F665C + for ; + Thu, 6 Apr 2006 11:48:08 -0300 (ADT) +Received: from [193.68.6.22] (kaloyan@luke.digsys.bg [193.68.6.22]) + by danbo.digsys.bg (8.11.6/8.10.1) with ESMTP id k36Em8T04189 + for ; + Thu, 6 Apr 2006 17:48:08 +0300 (EEST) +Message-ID: <44352A25.7010107@faith.digsys.bg> +Date: Thu, 06 Apr 2006 17:48:05 +0300 +From: Kaloyan Iliev +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; + rv:1.7.12) Gecko/20060117 +X-Accept-Language: bg, en, en-us +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: CURSOR OR OFFSET/LIMIT +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.166 required=5 tests=[SUBJ_ALL_CAPS=1.166] +X-Spam-Score: 1.166 +X-Spam-Level: * +X-Archive-Number: 200604/112 +X-Sequence-Number: 18196 + +Hi, + +I am working on Web Based application using Perl and Apache. +I have to show to the users some query results by pages. +Some time the result can be over 1000 rows (but can be more). +The question is how to make this. + +The one way is to use OFFSET and LIMIT. That's OK but every time the +whole query must be parsed and executed. + +If I use cursors it's better but my problem is that cursors live only in +the current transaction. +So when the Web Server finish I've lost the transaction and the cursor. + +There is some software written from my coleagues that on every server +request open a transaction and cursor. Move to the requested +page and show the result(After that the script finishes, so is the +transaction). So my question is. +Should I rewrte this by using OFFSET/LIMIT or it is better every time to +create the cursor and use it to get the rows. +Is there a way to save the cursor between separe Browser request (and to +give it time to live)? Or After all OFFSET and LIMIT? + +Thanks in advance. + +Kaloyan Iliev + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 12:20:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 99F5011F6675 + for ; + Thu, 6 Apr 2006 12:20:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87262-03 + for ; + Thu, 6 Apr 2006 12:20:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id D793A11F666F + for ; + Thu, 6 Apr 2006 12:20:19 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id B877EB823 + for ; + Thu, 6 Apr 2006 11:20:18 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: +References: <7583B3F1891CC0429FA4A44952AA539C66FA6D@wfm-exchprd2.wfm.pvt> + +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <8A6B69C0-8136-4CA9-A5D9-A257C1E5F74A@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Thu, 6 Apr 2006 11:20:17 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/113 +X-Sequence-Number: 18197 + + +On Apr 5, 2006, at 5:58 PM, August Zajonc wrote: + +> Most involve some AMD Opertons, lots of spindles with a good raid +> controller preferred to one or two large disks and a good helping of +> ram. Be interesting to get some numbers on the sunfire machine. + +I can highly recommend the SunFire X4100, however the only dual- +channel RAID card that fits in the box is the Adaptec 2230SLP. It is +not quite as fast as the LSI 320-2x when running freebsd, but is +sufficient for my purpose. + + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 12:36:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 70C8D11F6B5F + for ; + Thu, 6 Apr 2006 12:36:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89529-05 + for ; + Thu, 6 Apr 2006 12:36:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 2C13F11F6B59 + for ; + Thu, 6 Apr 2006 12:36:43 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 8F2EFB823 + for ; + Thu, 6 Apr 2006 11:36:42 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <44346AC4.1070801@nube.com.br> +References: <7583B3F1891CC0429FA4A44952AA539C66FA7D@wfm-exchprd2.wfm.pvt> + <44346AC4.1070801@nube.com.br> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Thu, 6 Apr 2006 11:36:41 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/114 +X-Sequence-Number: 18198 + + +On Apr 5, 2006, at 9:11 PM, Marcelo Tada wrote: + +> What are you think about the Sun Fire X64 X4200 Server? + +I use the X4100 and like it a lot. I'm about to buy another. I see +no advantage to the X4200 unless you want the extra internal disks. +I use an external array. + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 12:39:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A189F11F6B61 + for ; + Thu, 6 Apr 2006 12:39:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91119-02 + for ; + Thu, 6 Apr 2006 12:39:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id A850F11F6453 + for ; + Thu, 6 Apr 2006 12:39:08 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 14A2FB823 + for ; + Thu, 6 Apr 2006 11:39:08 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <44349D44.10902@eclinic.com.au> +References: + <44349D44.10902@eclinic.com.au> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <12F0B58E-6764-4333-B412-A5D66DF6AAC7@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +Date: Thu, 6 Apr 2006 11:39:07 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/115 +X-Sequence-Number: 18199 + + +On Apr 6, 2006, at 12:47 AM, Leigh Dyer wrote: + +> I'm sure those little SAS drives would be great for web servers and +> other non-IO-intensive tasks though -- I'd love to get some X4100s +> in to replace our Poweredge 1750s for that. It's a smart move +> overall IMHO, + +For this purpose, bang for the buck would lead me to getting Dell +1850 with hardware RAID and U320 drives. The quick-n-dirty tests +i've seen on the FreeBSD mailing list shows the disks are much faster +on the 1850 than the X4100 with its SAS disks. + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 13:18:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7416F11F66CA + for ; + Thu, 6 Apr 2006 13:18:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99926-06 + for ; + Thu, 6 Apr 2006 13:18:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id E5DC511F66C1 + for ; + Thu, 6 Apr 2006 13:18:05 -0300 (ADT) +Received: from 172.16.1.148 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Thu, 06 Apr 2006 12:17:49 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01HOST02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 6 Apr + 2006 12:17:40 -0400 +Received: from 69.181.100.71 ([69.181.100.71]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Thu, 6 Apr + 2006 16:17:40 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 06 Apr 2006 09:17:39 -0700 +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +From: "Luke Lonergan" +To: newz@bearfruit.org, + "Juan Casero (FL FLC)" +cc: pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +Thread-Index: AcZZgs09F76VeQ92Q4y8YXLIANZEqQAEtJk4 +In-Reply-To: +MIME-Version: 1.0 +X-OriginalArrivalTime: 06 Apr 2006 16:17:40.0619 (UTC) + FILETIME=[A09B9DB0:01C65995] +X-WSS-ID: 682BE0942XS40889080-04-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.373 required=5 tests=[AWL=0.120, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.373 +X-Spam-Level: * +X-Archive-Number: 200604/116 +X-Sequence-Number: 18200 + +Juan, + +On 4/6/06 7:01 AM, "Matthew Nuzum" wrote: + +>> Apart from that since I will only get this one chance to +>> buy a new server for data processing I need to make sure that I buy +>> something that can grow over time as our needs change. I don't want to +>> buy a server only to find out later that it cannot meet our needs with +>> future database projects. I have to balance a limited budget, room for +>> future performance growth, and current system requirements. Trust me it +>> isn't easy. +> +> Isn't it about time we had our annual "what kind of server can I get +> for $8k" thread? + +Based on Juan's description, here's a config that will *definitely* be the +fastest possible in an $8K budget: + +Buy a dual opteron server with 8 x 400GB SATA II disks on a 3Ware 9550SX +RAID controller with 16GB of RAM pre-installed with Centos 4.3 for $6,000 +here: + http://www.asacomputers.com/ + +Download the *free* open source Bizgres here: + http://bgn.greenplum.com/ + +Use bitmap indexes for columns with less than 10,000 unique values, and your +system will fly through 100GB. + +This is the fastest OSS business intelligence kit for the money, guaranteed. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 13:18:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EDD5E11F66F1 + for ; + Thu, 6 Apr 2006 13:18:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01265-05 + for ; + Thu, 6 Apr 2006 13:18:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.ipf.is (scania.ipf.is [85.197.192.147]) + by postgresql.org (Postfix) with ESMTP id D6BFB11F6552 + for ; + Thu, 6 Apr 2006 13:18:17 -0300 (ADT) +Received: (qmail 19602 invoked by uid 1010); 6 Apr 2006 16:17:39 +0000 +Received: from 85.197.216.186 by scania (envelope-from , + uid 1008) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1235. spamassassin: 3.1.1. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.3/4.5):. + Processed in 2.997852 secs); 06 Apr 2006 16:17:39 -0000 +X-Antivirus-IPF-Mail-From: gnari@hive.is via scania +X-Antivirus-IPF: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.3/4.5):. + Processed in 2.997852 secs Process 19595) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx2.ipf.is with SMTP; 6 Apr 2006 16:17:36 +0000 +Subject: Re: Query planner is using wrong index. +From: Ragnar +To: Brian Herlihy +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060406140151.83127.qmail@web52310.mail.yahoo.com> +References: <20060406140151.83127.qmail@web52310.mail.yahoo.com> +Content-Type: text/plain; charset=ISO-8859-1 +Date: Thu, 06 Apr 2006 16:20:29 +0000 +Message-Id: <1144340430.32289.97.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.06 required=5 tests=[AWL=0.060] +X-Spam-Score: 0.06 +X-Spam-Level: +X-Archive-Number: 200604/117 +X-Sequence-Number: 18201 + +On f�s, 2006-04-07 at 00:01 +1000, Brian Herlihy wrote: +> --- Ragnar wrote: +> +> > On fim, 2006-04-06 at 19:27 +1000, Brian Herlihy wrote: +> > +> > > Yes, the primary key is far better. I gave it the ultimate test - I +> > dropped +> > > the (p2, p3) index. It's blindingly fast when using the PK, +> > +> > I have problems understanding exactly how an index on +> > (p1,p2,p3) can be faster than and index on (p2,p3) for +> > a query not involving p1. + +> db# explain analyze select * from t WHERE p1 = 'a' and p2 = 'uk.altavista.com' +> AND p3 = 'web/results?itag=&q=&kgs=&kls='; + +this is different from what you said earlier. in your +original post you showed a problem query without any +reference to p1 in the WHERE clause. this confused me. + +> Index Scan using p2_p3_idx on t (cost=0.00..6.02 rows=1 width=102) (actual +> time=2793.247..2793.247 rows=0 loops=1) +> Index Cond: (((p2)::text = 'uk.altavista.com'::text) AND ((p3)::text = +> 'web/results?itag=&q=&kgs=&kls='::text)) +> Filter: ((p1)::text = 'a'::text) +> Total runtime: 2793.303 ms +> (4 rows) + +try to add an ORDER BY clause: + +explain analyze + select * from t + WHERE p1 = 'a' + and p2 = 'uk.altavista.com' + AND p3 = 'web/results?itag=&q=&kgs=&kls=' + ORDER BY p1,p2,p3; + +this might push the planner into using the primary key + +gnari + + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 14:11:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CFC0011F6ACB + for ; + Thu, 6 Apr 2006 14:11:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18704-02 + for ; + Thu, 6 Apr 2006 14:11:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from a2s5.a2hosting.com (host-209-124-50-10.a2webhosting.com + [209.124.50.10]) + by postgresql.org (Postfix) with ESMTP id 682FA11F6ABE + for ; + Thu, 6 Apr 2006 14:11:46 -0300 (ADT) +Received: from adsl-6-40-137.tys.bellsouth.net ([65.6.40.137] + helo=[192.168.1.10]) + by a2s5.a2hosting.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.52) + id 1FRY1I-0007Lt-Sl; Thu, 06 Apr 2006 13:11:45 -0400 +In-Reply-To: <44352A25.7010107@faith.digsys.bg> +References: <44352A25.7010107@faith.digsys.bg> +Mime-Version: 1.0 (Apple Message framework v746.2) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: John DeSoi +Subject: Re: CURSOR OR OFFSET/LIMIT +Date: Thu, 6 Apr 2006 13:11:33 -0400 +To: Kaloyan Iliev +X-Mailer: Apple Mail (2.746.2) +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - a2s5.a2hosting.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] +X-AntiAbuse: Sender Address Domain - pgedit.com +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/118 +X-Sequence-Number: 18202 + + +On Apr 6, 2006, at 10:48 AM, Kaloyan Iliev wrote: + +> If I use cursors it's better but my problem is that cursors live +> only in the current transaction. +> So when the Web Server finish I've lost the transaction and the +> cursor. + + +Cursors can live outside the transaction if you declare them WITH +HOLD specified. But that still may not help you in a web environment +if you want to break the results into pages served on separate +requests (and possibly different connections). + +http://www.postgresql.org/docs/8.1/interactive/sql-declare.html + +> Is there a way to save the cursor between separe Browser request +> (and to give it time to live)? + +Sure, but you need to add a lot of connection management to do this. +You would need to keep track of the cursors and make sure a +subsequent request uses the right connection. + + + + + + +John DeSoi, Ph.D. +http://pgedit.com/ +Power Tools for PostgreSQL + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 18:55:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3C0DB11F65E4 + for ; + Thu, 6 Apr 2006 18:55:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47653-05 + for ; + Thu, 6 Apr 2006 18:55:31 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34]) + by postgresql.org (Postfix) with ESMTP id 1C19211F65DA + for ; + Thu, 6 Apr 2006 18:55:31 -0300 (ADT) +Received: from fe-amer-01.sun.com ([192.18.108.175]) + by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id k36LtVJO002746 + for ; + Thu, 6 Apr 2006 15:55:31 -0600 (MDT) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IXB00101M4VKG00@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Thu, 06 Apr 2006 15:55:31 -0600 (MDT) +Received: from [129.148.9.81] by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + with ESMTPSA id <0IXB00E3QM8IL8Y2@mail-amer.sun.com>; Thu, + 06 Apr 2006 15:55:31 -0600 (MDT) +Date: Thu, 06 Apr 2006 17:55:30 -0400 +From: "Jignesh K. Shah" +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +In-reply-to: <443497AB.4000309@eclinic.com.au> +To: Leigh Dyer +Cc: Luke Lonergan , + "Juan Casero (FL FLC)" , + Josh Berkus , pgsql-performance@postgresql.org +Message-id: <44358E52.4020706@sun.com> +Organization: Sun Microsystems +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: + <443497AB.4000309@eclinic.com.au> +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.001 required=5 tests=[UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.001 +X-Spam-Level: +X-Archive-Number: 200604/119 +X-Sequence-Number: 18203 + +Hi Leigh + +inline comments + + +Leigh Dyer wrote: + +> Luke Lonergan wrote: +> +>> Juan, +> +> We've got a Sun Fire V40z and it's quite a nice machine -- 6x 15krpm +> drives, 4GB RAM, and a pair of Opteron 850s. This gives us more than +> enough power now for what we need, but it's nice to know that we can +> shoehorn a lot more RAM, and up it to eight CPU cores if needed. +> +> The newer Sun Opteron systems look nice too, but unless you're using +> external storage, their little 2.5" hard drives may not be ideal. +> + +Thats because Sun Fire V40z had write cache turned on while the +4200/4100 has the write cache turned off. There is a religious belief +around the "write cache" on the disk in Sun :-) To really compare the +performance, you have to turn on the write cache (I believe it was +format -e and the cache option.. but that could have changed.. need to +verify that again.. Same goes for T2000 SAS disks too.. Write cache is +turned off on it so be careful before you compare benchmarks on internal +drives :-) + +-Jignesh + + + +> Thanks +> Leigh +> +>> +>> - Luke +>> +>> +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 2: Don't 'kill -9' the postmaster +>> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 19:13:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 446C011F66CC + for ; + Thu, 6 Apr 2006 19:13:12 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52718-01 + for ; + Thu, 6 Apr 2006 19:13:06 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-4.sun.com (brmea-mail-4.Sun.COM [192.18.98.36]) + by postgresql.org (Postfix) with ESMTP id 5512C11F66D9 + for ; + Thu, 6 Apr 2006 19:13:09 -0300 (ADT) +Received: from fe-amer-02.sun.com ([192.18.108.176]) + by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id k36MD8Ze028797 + for ; + Thu, 6 Apr 2006 16:13:08 -0600 (MDT) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IXB00801MVUH100@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Thu, 06 Apr 2006 16:13:08 -0600 (MDT) +Received: from [129.148.9.81] by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + with ESMTPSA id <0IXB00G2TN1VX4B3@mail-amer.sun.com>; Thu, + 06 Apr 2006 16:13:08 -0600 (MDT) +Date: Thu, 06 Apr 2006 18:13:07 -0400 +From: "Jignesh K. Shah" +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +In-reply-to: <7583B3F1891CC0429FA4A44952AA539C66FA8B@wfm-exchprd2.wfm.pvt> +To: "Juan Casero (FL FLC)" +Cc: Josh Berkus , pgsql-performance@postgresql.org, + Luke Lonergan +Message-id: <44359273.6020203@sun.com> +Organization: Sun Microsystems +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: <7583B3F1891CC0429FA4A44952AA539C66FA8B@wfm-exchprd2.wfm.pvt> +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200604/120 +X-Sequence-Number: 18204 + +For a DSS type workload with PostgreSQL where you end up with single +long running queries on postgresql with about 100GB, you better use +something like Sun Fire V40z with those fast Ultra320 internal drives. +This might be perfect low cost complete database in a box. + +Sun Fire T2000 is great for OLTP where you can end up with hundreds of +users doing quick and small lookups and T2000 can crank simple thread +executions far better than others. However when it comes to long running +queries you end up using 1/32 of the power and may not live up to your +expectations. For example consider your PostgreSQL talking to Apache +WebServer all on T2000... You can put them in separate zones if you have +different administrators for them. :-) + +As for PostgreSQL on Solaris, I already have the best parameters to use +on Solaris based on my tests, the default odatasync hurts performance on +Solaris, so does checkpoint segments, others are tweaked so that they +are set for bigger databases and hence may not show much difference on +performances... + +That said I will still be interested to see your app performance with +postgreSQL on Sun Fire T2000 as there are always ways of perseverence to +improve performance :-) + + +Regards, +Jignesh + + +Juan Casero (FL FLC) wrote: + +>Because I plan to develop a rather large (for us anyway) data warehouse +>with PostgreSQL. I am looking for the right hardware that can handle +>queries on a database that might grow to over a 100 gigabytes. Right +>now our decision support system based on postgresql 8.1.3 stores retail +>sales information for about 4 four years back *but* only as weekly +>summaries. I want to build the system so it can handle daily sales +>transactions also. You can imagine how many more records this will +>involve so I am looking for hardware that can give me the performance I +>need to make this project useable. In other words parsing and loading +>the daily transaction logs for our stores is likely to take huge amounts +>of effort. I need a machine that can complete the task in a reasonable +>amount of time. As people start to query the database to find sales +>related reports and information I need to make sure the queries will run +>reasonably fast for them. I have already hand optimized all of my +>queries on the current system. But currently I only have weekly sales +>summaries. Other divisions in our company have done a similar project +>using MS SQL Server on SMP hardware far outclassing the database server +>I currently use and they report heavy loads on the server with less than +>ideal query run times. I am sure I can do my part to optimize the +>queries once I start this project but there is only so much you can do. +>At some point you just need more powerful hardware. This is where I am +>at right now. Apart from that since I will only get this one chance to +>buy a new server for data processing I need to make sure that I buy +>something that can grow over time as our needs change. I don't want to +>buy a server only to find out later that it cannot meet our needs with +>future database projects. I have to balance a limited budget, room for +>future performance growth, and current system requirements. Trust me it +>isn't easy. +> +> +>Juan +> +>-----Original Message----- +>From: Josh Berkus [mailto:josh@agliodbs.com] +>Sent: Thursday, April 06, 2006 2:57 AM +>To: pgsql-performance@postgresql.org +>Cc: Juan Casero (FL FLC); Luke Lonergan +>Subject: Re: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +> +>Juan, +> +> +> +>>Ok that is beginning to become clear to me. Now I need to determine +>>if this server is worth the investment for us. Maybe it is not a +>>speed daemon but to be honest the licensing costs of an SMP aware +>>RDBMS is outside our budget. +>> +>> +> +>You still haven't explained why you want multi-threaded queries. This +>is sounding like keeping up with the Joneses. +> +>-- +>Josh Berkus +>Aglio Database Solutions +>San Francisco +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: don't forget to increase your free space map settings +> +> + +From pgsql-performance-owner@postgresql.org Thu Apr 6 20:56:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7B99411F676E + for ; + Thu, 6 Apr 2006 20:56:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92228-01 + for ; + Thu, 6 Apr 2006 20:56:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from web52307.mail.yahoo.com (web52307.mail.yahoo.com + [206.190.48.150]) + by postgresql.org (Postfix) with SMTP id 9899711F6765 + for ; + Thu, 6 Apr 2006 20:56:22 -0300 (ADT) +Received: (qmail 27530 invoked by uid 60001); 6 Apr 2006 23:56:22 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; + h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=TorDjPV550t9Bz178NWUSx5GTcowkQegQY1JsSdckP6iqBD7J49R9DzhfEUb363/7VvzaciQ+DCOb1UlbUksQC7FBCMmYClkoFbXaVK3qn5vOSO3iF91RYBnQLnn7sMUhiLtLBljKi/vL3w6YFdTTzkjZu0LNxVLVOTQCg9lte8= + ; +Message-ID: <20060406235622.27528.qmail@web52307.mail.yahoo.com> +Received: from [202.156.6.68] by web52307.mail.yahoo.com via HTTP; + Fri, 07 Apr 2006 09:56:21 EST +Date: Fri, 7 Apr 2006 09:56:21 +1000 (EST) +From: Brian Herlihy +Subject: Re: Query planner is using wrong index. +To: pgsql-performance@postgresql.org +In-Reply-To: <1144340430.32289.97.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[AWL=0.000, + DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200604/121 +X-Sequence-Number: 18205 + + +--- Ragnar wrote: + +> On f�s, 2006-04-07 at 00:01 +1000, Brian Herlihy wrote: +> > Index Scan using p2_p3_idx on t (cost=0.00..6.02 rows=1 width=102) +> (actual +> > time=2793.247..2793.247 rows=0 loops=1) +> > Index Cond: (((p2)::text = 'uk.altavista.com'::text) AND ((p3)::text = +> > 'web/results?itag=&q=&kgs=&kls='::text)) +> > Filter: ((p1)::text = 'a'::text) +> > Total runtime: 2793.303 ms +> > (4 rows) +> +> try to add an ORDER BY clause: +> +> explain analyze +> select * from t +> WHERE p1 = 'a' +> and p2 = 'uk.altavista.com' +> AND p3 = 'web/results?itag=&q=&kgs=&kls=' +> ORDER BY p1,p2,p3; +> +> this might push the planner into using the primary key +> +> gnari +> + +Thankyou very much, that works very well for select. However, I need it to +work for update as well. Is there an equivalent way to force use of an index +for updates? + +Here are the results for select: + +db# explain analyze select * from t WHERE p1 = 'a' and p2 = 'uk.altavista.com' +AND p3 = 'web/results?itag=&q=&kgs=&kls=' order by p1,p2,p3; + +QUERY PLAN + +---------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using t_pkey on t (cost=0.00..6.02 rows=1 width=102) (actual +time=32.519..32.519 rows=0 loops=1) + Index Cond: (((p1)::text = 'a'::text) AND ((p2)::text = +'uk.altavista.com'::text) AND ((p3)::text = +'web/results?itag=&q=&kgs=&kls='::text)) + Total runtime: 32.569 ms +(3 rows) + +db# explain analyze select * from t WHERE p1 = 'a' and p2 = 'uk.altavista.com' +AND p3 = 'web/results?itag=&q=&kgs=&kls='; + QUERY PLAN + +--------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using p2_p3_idx on t (cost=0.00..6.02 rows=1 width=102) (actual +time=2790.364..2790.364 rows=0 loops=1) + Index Cond: (((p2)::text = 'uk.altavista.com'::text) AND ((p3)::text = +'web/results?itag=&q=&kgs=&kls='::text)) + Filter: ((p1)::text = 'a'::text) + Total runtime: 2790.420 ms +(4 rows) + + +But I cannot add an "order by" to an update. + +The other idea I came up with last night was to change p2_p3_idx so it indexes +a value derived from p2 and p3, rather than p2 and p3 themselves. This would +"hide" this index from the optimizer, forcing it to use the primary key. + +I am really surprised that I have to go through such contortions just to use +the primary key! This area of Postgres needs improvement. + +Thanks, +Brian + +From pgsql-performance-owner@postgresql.org Thu Apr 6 21:09:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DAEC511F684E + for ; + Thu, 6 Apr 2006 21:09:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92296-07 + for ; + Thu, 6 Apr 2006 21:09:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 957D611F681A + for ; + Thu, 6 Apr 2006 21:09:34 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 87429787; Thu, 06 Apr 2006 17:09:33 -0700 +From: "Dave Dutcher" +To: "'Brian Herlihy'" , + +Subject: Re: Query planner is using wrong index. +Date: Thu, 6 Apr 2006 19:09:33 -0500 +Message-ID: <00c101c659d7$8cc26a70$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +In-reply-to: <20060406235622.27528.qmail@web52307.mail.yahoo.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/122 +X-Sequence-Number: 18206 + + + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance- +> owner@postgresql.org] On Behalf Of Brian Herlihy +> Sent: Thursday, April 06, 2006 6:56 PM +> To: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Query planner is using wrong index. +[Snip] +> I am really surprised that I have to go through such contortions just +to +> use +> the primary key! This area of Postgres needs improvement. +> + + +Of course you mentioned that you are using 7.4.7. You might want to try +upgrading to 8.1.3. There have been a lot of improvements to the +performance since 7.4. I don't know if your specific problem was fixed, +but it's worth a try. + +Also you might want to at least upgrade to 7.4.12 for the bug fixes. + + + +From pgsql-performance-owner@postgresql.org Thu Apr 6 21:15:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9347A11F681A + for ; + Thu, 6 Apr 2006 21:15:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92296-10 + for ; + Thu, 6 Apr 2006 21:15:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from web52308.mail.yahoo.com (web52308.mail.yahoo.com + [206.190.48.151]) + by postgresql.org (Postfix) with SMTP id 29FA211F6610 + for ; + Thu, 6 Apr 2006 21:15:39 -0300 (ADT) +Received: (qmail 89519 invoked by uid 60001); 7 Apr 2006 00:15:39 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; + h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=x9hroB2eAyg4p+lX6NiaRbgJpwNSid+diHzZuFJLtJbmtY5Qwhe5jFpWgOshn6ubjiZ/H/mGVTk+deiWRbIbyG6a07RLa6XgjkEL6MyJkYk/tdin6TbXPvCkS7gS5t8pUzgMktqMYNArXPh09Hig8OysgrgX1227H5kc6J+aKIQ= + ; +Message-ID: <20060407001538.89517.qmail@web52308.mail.yahoo.com> +Received: from [202.156.6.68] by web52308.mail.yahoo.com via HTTP; + Fri, 07 Apr 2006 10:15:38 EST +Date: Fri, 7 Apr 2006 10:15:38 +1000 (EST) +From: Brian Herlihy +Subject: Re: Query planner is using wrong index. +To: pgsql-performance@postgresql.org +In-Reply-To: <00c101c659d7$8cc26a70$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200604/123 +X-Sequence-Number: 18207 + + +--- Dave Dutcher wrote: +> > -----Original Message----- +> > To: pgsql-performance@postgresql.org +> > Subject: Re: [PERFORM] Query planner is using wrong index. +> [Snip] +> > I am really surprised that I have to go through such contortions just +> to +> > use +> > the primary key! This area of Postgres needs improvement. +> > +> +> +> Of course you mentioned that you are using 7.4.7. You might want to try +> upgrading to 8.1.3. There have been a lot of improvements to the +> performance since 7.4. I don't know if your specific problem was fixed, +> but it's worth a try. +> +> Also you might want to at least upgrade to 7.4.12 for the bug fixes. + +Thanks for the suggestions. I've verified the same problem in 8.1.3 as well, +after my initial post. It was actually in 8.1.3 that I first discovered the +problem. + +I noticed this item in the TODO list: + +- Allow accurate statistics to be collected on indexes with more than one +column or expression indexes, perhaps using per-index statistics + +This is what I need! But until that is added, I need a way to use the primary +key with the current version :) + +Thanks, +Brian + +From pgsql-performance-owner@postgresql.org Fri Apr 7 00:17:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9D55611F622C + for ; + Fri, 7 Apr 2006 00:17:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44078-01 + for ; + Fri, 7 Apr 2006 00:17:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 97C7611F622A + for ; + Fri, 7 Apr 2006 00:17:18 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k373HGU4003545; + Thu, 6 Apr 2006 23:17:17 -0400 (EDT) +To: Brian Herlihy +cc: pgsql-performance@postgresql.org +Subject: Re: Query planner is using wrong index. +In-reply-to: <20060406092711.8725.qmail@web52315.mail.yahoo.com> +References: <20060406092711.8725.qmail@web52315.mail.yahoo.com> +Comments: In-reply-to Brian Herlihy + message dated "Thu, 06 Apr 2006 19:27:11 +1000" +Date: Thu, 06 Apr 2006 23:17:16 -0400 +Message-ID: <3544.1144379836@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.135 required=5 tests=[AWL=0.135] +X-Spam-Score: 0.135 +X-Spam-Level: +X-Archive-Number: 200604/124 +X-Sequence-Number: 18208 + +Brian Herlihy writes: +> My options seem to be +> - Fudge the analysis results so that the selectivity estimate changes. I +> have tested reducing n_distinct, but this doesn't seem to help. +> - Combine the columns into one column, allowing postgres to calculate the +> combined selectivity. +> - Drop the (p2, p3) index. But I need this for other queries. + +Have you considered reordering the pkey to be (p2,p3,p1) and then +dropping the (p2,p3) index? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 03:41:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DF52511F61E3 + for ; + Fri, 7 Apr 2006 03:41:12 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32955-01 + for ; + Fri, 7 Apr 2006 03:41:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from web52315.mail.yahoo.com (web52315.mail.yahoo.com + [206.190.48.158]) + by postgresql.org (Postfix) with SMTP id EF44911F61DB + for ; + Fri, 7 Apr 2006 03:41:08 -0300 (ADT) +Received: (qmail 49534 invoked by uid 60001); 7 Apr 2006 06:41:08 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; + h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=MiTcPB5oHkUh0q4mapCJ3qsjyhpzfJPm4AKTCGlbk8h8vfupxeBKSnRtJ3rB8W3Vs7ZOPJ2ASTYexpNsSPMeytaT7m8Yw35kbC4f01B9JE9os1Gz7gpEwpcoDaMIcvAbsVqiEN3FeFnkT7eFG8X/yrrQQ3xCp6Q5eGV2+i5Ppzk= + ; +Message-ID: <20060407064108.49532.qmail@web52315.mail.yahoo.com> +Received: from [202.156.6.68] by web52315.mail.yahoo.com via HTTP; + Fri, 07 Apr 2006 16:41:08 EST +Date: Fri, 7 Apr 2006 16:41:08 +1000 (EST) +From: Brian Herlihy +Subject: Re: Query planner is using wrong index. +To: pgsql-performance@postgresql.org +In-Reply-To: <3544.1144379836@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] +X-Spam-Score: 0.479 +X-Spam-Level: +X-Archive-Number: 200604/125 +X-Sequence-Number: 18209 + +--- Tom Lane wrote: + +> Brian Herlihy writes: +> > My options seem to be +> > - Fudge the analysis results so that the selectivity estimate changes. I +> > have tested reducing n_distinct, but this doesn't seem to help. +> > - Combine the columns into one column, allowing postgres to calculate the +> > combined selectivity. +> > - Drop the (p2, p3) index. But I need this for other queries. +> +> Have you considered reordering the pkey to be (p2,p3,p1) and then +> dropping the (p2,p3) index? +> +> regards, tom lane + +Hi Tom, + +I've considered it. Unfortunately I need to do lookups on (p1) and (p1,p2) as +well as (p1, p2, p3). + +The solution I've gone with is to create an index on (p2 || '/' || p3). This +is unique for each p2/p3 combination, because p2 cannot contain the '/' +character. I'm assuming that this index will be no slower to generate than one +on (p2, p3), as concatenation is very cheap. Having the index on an expression +"hides" it from the optimizer, which is then forced to use the primary key +instead. + +It works perfectly now! There were only 2 queries in the system which need +this index, so it was no problem to change them. + +Thankyou very much for all your time and patience! + +Before I go, I have a question - From discussions on the Postgresql irc +channel, and from reading the TODO list on the website, I am under the +impression that there are no plans to allow optimizer hints, such as "use index +table_pkey". Is this really true? Such a feature would make life inestimably +easier for your end-users, particularly me :) + +Thanks, +Brian + +From pgsql-performance-owner@postgresql.org Fri Apr 7 09:45:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0D0DD11F65FC + for ; + Fri, 7 Apr 2006 09:45:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18983-02 + for ; + Fri, 7 Apr 2006 09:45:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pat.uio.no (pat.uio.no [129.240.10.6]) + by postgresql.org (Postfix) with ESMTP id 2C3AA11F65B5 + for ; + Fri, 7 Apr 2006 09:45:44 -0300 (ADT) +Received: from mail-mx4.uio.no ([129.240.10.45]) + by pat.uio.no with esmtp (Exim 4.43) id 1FRqLP-00065N-4u + for pgsql-performance@postgresql.org; Fri, 07 Apr 2006 14:45:43 +0200 +Received: from bbking.uio.no ([129.240.201.179]) + by mail-mx4.uio.no with esmtps (TLSv1:AES256-SHA:256) (Exim 4.43) + id 1FRqLG-00030u-Sh + for pgsql-performance@postgresql.org; Fri, 07 Apr 2006 14:45:34 +0200 +Subject: Same SQL, 104296ms of difference between 7.4.12 and 8.0.7 +From: Rafael Martinez Guerrero +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: University of Oslo +Message-Id: <1144413933.24060.253.camel@bbking.uio.no> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-17) +Date: Fri, 07 Apr 2006 14:45:33 +0200 +Content-Transfer-Encoding: 7bit +X-UiO-Spam-info: not spam, SpamAssassin (score=-5.398, required 12, + autolearn=disabled, AWL -0.40, UIO_MAIL_IS_INTERNAL -5.00) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/126 +X-Sequence-Number: 18210 + +Hello + +I have a sql statement that takes 108489.780 ms with 8.0.7 in a +RHEL4/amd64linux server with 2xAMD Opteron(tm) Processor 275 2.00GHz / +8GB RAM and only 4193.588 ms with 7.4.12 in a RHEL3/386linux server with +2xIntel(R) Xeon(TM) CPU 2.40GHz / 4GB RAM. + +Some information: + +- There is no IO when I am running the sql, but it uses 99% of the cpu. +- I run VACUUM VERBOSE ANALYZE in both databases before the test. +- The databases are identical. +- No other jobs running when testing. +- Some different parameters between 7.4.12 and 8.0.7 : + +7.4.12: +------- +shared_buffers = 114966 #(15% of ram) +sort_mem = 16384 +vacuum_mem = 524288 +wal_buffers = 64 +checkpoint_segments = 16 +effective_cache_size = 383220 #(50% ram) +random_page_cost = 3 +default_statistics_target = 100 + +8.0.7: +------ +shared_buffers = 250160 #(25% ram) +work_mem = 8192 +maintenance_work_mem = 131072 +wal_buffers = 128 +checkpoint_segments = 64 +effective_cache_size = 500321 #(50% ram) +random_page_cost = 3 +default_statistics_target = 100 + +Any ideas of what I can test/configurate to find out why this happens? +Thanks in advance. + + +******************* +With 7.4.12 +******************* +rtprod=# explain analyze SELECT DISTINCT main.* FROM Users main , +Principals Principals_1, ACL ACL_2, Groups Groups_3, CachedGroupMembers +CachedGroupMembers_4 WHERE ((ACL_2.RightName = 'OwnTicket')) AND +((CachedGroupMembers_4.MemberId = Principals_1.id)) AND ((Groups_3.id = +CachedGroupMembers_4.GroupId)) AND ((Principals_1.Disabled = +'0')OR(Principals_1.Disabled = '0')) AND ((Principals_1.id != '1')) AND +((main.id = Principals_1.id)) AND ( ( ACL_2.PrincipalId = +Groups_3.id AND ACL_2.PrincipalType = 'Group' AND ( Groups_3.Domain = +'SystemInternal' OR Groups_3.Domain = 'UserDefined' OR Groups_3.Domain = +'ACLEquivalence')) OR ( ( (Groups_3.Domain = 'RT::Queue-Role' ) ) AND +Groups_3.Type = ACL_2.PrincipalType) ) AND (ACL_2.ObjectType = +'RT::System' OR (ACL_2.ObjectType = 'RT::Queue') ) ORDER BY main.Name +ASC; + + QUERYPLAN + + Unique (cost=40250.00..40250.09 rows=1 width=695) (actual +time=3974.528..4182.343 rows=264 loops=1) + -> Sort (cost=40250.00..40250.00 rows=1 width=695) (actual +time=3974.522..3992.487 rows=24697 loops=1) + Sort Key: main.name, main.id, main."password", main.comments, +main.signature, main.emailaddress, main.freeformcontactinfo, +main.organization, main.realname, main.nickname, main.lang, +main.emailencoding, main.webencoding, main.externalcontactinfoid, +main.contactinfosystem, main.externalauthid, main.authsystem, +main.gecos, main.homephone, main.workphone, main.mobilephone, +main.pagerphone, main.address1, main.address2, main.city, main.state, +main.zip, main.country, main.timezone, main.pgpkey, main.creator, +main.created, main.lastupdatedby, main.lastupdated + -> Nested Loop (cost=33.67..40249.99 rows=1 width=695) +(actual time=37.793..3240.146 rows=24697 loops=1) + -> Nested Loop (cost=33.67..40246.95 rows=1 width=699) +(actual time=37.754..2635.812 rows=24697 loops=1) + -> Nested Loop (cost=33.67..40242.47 rows=1 +width=4) (actual time=37.689..2091.634 rows=24755 loops=1) + -> Nested Loop (cost=33.67..40225.72 rows=1 +width=4) (actual time=37.663..1967.388 rows=54 loops=1) + Join Filter: +(((("outer"."domain")::text = 'RT::Queue-Role'::text) OR +("inner".principalid = "outer".id)) AND ((("outer"."type")::text = +("inner".principaltype)::text) OR ("inner".principalid = "outer".id)) +AND ((("outer"."domain")::text = 'RT::Queue-Role'::text) OR +(("inner".principaltype)::text = 'Group'::text)) AND +((("outer"."type")::text = ("inner".principaltype)::text) OR +(("inner".principaltype)::text = 'Group'::text)) AND +((("outer"."type")::text = ("inner".principaltype)::text) OR +(("outer"."domain")::text = 'SystemInternal'::text) OR +(("outer"."domain")::text = 'UserDefined'::text) OR +(("outer"."domain")::text = 'ACLEquivalence'::text))) + -> Index Scan using groups4, groups4, +groups4, groups4 on groups groups_3 (cost=0.00..2164.05 rows=15845 +width=32) (actual time=0.041..43.636 rows=16160 loops=1) + Index Cond: ((("domain")::text = +'RT::Queue-Role'::text) OR (("domain")::text = 'SystemInternal'::text) +OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = +'ACLEquivalence'::text)) + -> Materialize (cost=33.67..34.15 +rows=48 width=13) (actual time=0.001..0.040 rows=54 loops=16160) + -> Seq Scan on acl acl_2 +(cost=0.00..33.67 rows=48 width=13) (actual time=0.016..0.989 rows=54 +loops=1) + Filter: (((rightname)::text += 'OwnTicket'::text) AND (((objecttype)::text = 'RT::System'::text) OR +((objecttype)::text = 'RT::Queue'::text))) + -> Index Scan using cachedgroupmembers3 on +cachedgroupmembers cachedgroupmembers_4 (cost=0.00..16.45 rows=23 +width=8) (actual time=0.015..1.296 rows=458 loops=54) + Index Cond: ("outer".id = +cachedgroupmembers_4.groupid) + -> Index Scan using users_pkey on users main +(cost=0.00..4.47 rows=1 width=695) (actual time=0.007..0.009 rows=1 +loops=24755) + Index Cond: (main.id = "outer".memberid) + -> Index Scan using principals_pkey on principals +principals_1 (cost=0.00..3.02 rows=1 width=4) (actual time=0.010..0.012 +rows=1 loops=24697) + Index Cond: ("outer".id = principals_1.id) + Filter: ((disabled = 0::smallint) AND (id <> 1)) + Total runtime: 4193.588 ms +(21 rows) + + +***************************** +With 8.0.7 +***************************** + +rtprod=# explain analyze SELECT DISTINCT main.* FROM Users main , +Principals Principals_1, ACL ACL_2, Groups Groups_3, CachedGroupMembers +CachedGroupMembers_4 WHERE ((ACL_2.RightName = 'OwnTicket')) AND +((CachedGroupMembers_4.MemberId = Principals_1.id)) AND ((Groups_3.id = +CachedGroupMembers_4.GroupId)) AND ((Principals_1.Disabled = +'0')OR(Principals_1.Disabled = '0')) AND ((Principals_1.id != '1')) AND +((main.id = Principals_1.id)) AND ( ( ACL_2.PrincipalId = +Groups_3.id AND ACL_2.PrincipalType = 'Group' AND ( Groups_3.Domain = +'SystemInternal' OR Groups_3.Domain = 'UserDefined' OR Groups_3.Domain = +'ACLEquivalence')) OR ( ( (Groups_3.Domain = 'RT::Queue-Role' ) ) AND +Groups_3.Type = ACL_2.PrincipalType) ) AND (ACL_2.ObjectType = +'RT::System' OR (ACL_2.ObjectType = 'RT::Queue') ) ORDER BY main.Name +ASC; + + + QUERYPLAN + Unique (cost=164248.03..164250.91 rows=33 width=695) (actual +time=108249.642..108479.808 rows=264 loops=1) + -> Sort (cost=164248.03..164248.11 rows=33 width=695) (actual +time=108249.637..108293.474 rows=24697 loops=1) + Sort Key: main.name, main.id, main."password", main.comments, +main.signature, main.emailaddress, main.freeformcontactinfo, +main.organization, main.realname, main.nickname, main.lang, +main.emailencoding, main.webencoding, main.externalcontactinfoid, +main.contactinfosystem, main.externalauthid, main.authsystem, +main.gecos, main.homephone, main.workphone, main.mobilephone, +main.pagerphone, main.address1, main.address2, main.city, main.state, +main.zip, main.country, main.timezone, main.pgpkey, main.creator, +main.created, main.lastupdatedby, main.lastupdated + -> Nested Loop (cost=4702.57..164247.19 rows=33 width=695) +(actual time=2949.010..107407.145 rows=24697 loops=1) + Join Filter: ((("inner".principalid = "outer".id) AND +(("inner".principaltype)::text = 'Group'::text) AND +((("outer"."domain")::text = 'SystemInternal'::text) OR +(("outer"."domain")::text = 'UserDefined'::text) OR +(("outer"."domain")::text = 'ACLEquivalence'::text))) OR +((("outer"."domain")::text = 'RT::Queue-Role'::text) AND +(("outer"."type")::text = ("inner".principaltype)::text))) + -> Hash Join (cost=4667.85..51078.88 rows=62852 +width=727) (actual time=649.028..13602.451 rows=513264 loops=1) + Hash Cond: ("outer".groupid = "inner".id) + -> Merge Join (cost=0.00..32353.73 rows=62852 +width=699) (actual time=0.809..6644.928 rows=513264 loops=1) + Merge Cond: ("outer".id = "inner".memberid) + -> Merge Join (cost=0.00..6379.54 +rows=15877 width=699) (actual time=0.118..911.395 rows=15866 loops=1) + Merge Cond: ("outer".id = "inner".id) + -> Index Scan using users_pkey on +users main (cost=0.00..1361.01 rows=15880 width=695) (actual +time=0.016..49.141 rows=15880 loops=1) + -> Index Scan using principals_pkey on +principals principals_1 (cost=0.00..4399.08 rows=168394 width=4) +(actual time=0.026..412.688 rows=168409 loops=1) + Filter: ((disabled = 0::smallint) +AND (id <> 1)) + -> Index Scan using cachedgroupmembers2 on +cachedgroupmembers cachedgroupmembers_4 (cost=0.00..18647.25 +rows=666758 width=8) (actual time=0.008..1513.877 rows=666754 loops=1) + -> Hash (cost=3094.48..3094.48 rows=152548 +width=32) (actual time=637.618..637.618 rows=0 loops=1) + -> Seq Scan on groups groups_3 +(cost=0.00..3094.48 rows=152548 width=32) (actual time=0.017..333.669 +rows=152548 loops=1) + -> Materialize (cost=34.72..35.20 rows=48 width=13) +(actual time=0.001..0.077 rows=54 loops=513264) + -> Seq Scan on acl acl_2 (cost=0.00..34.67 +rows=48 width=13) (actual time=0.013..0.850 rows=54 loops=1) + Filter: (((rightname)::text = +'OwnTicket'::text) AND (((objecttype)::text = 'RT::System'::text) OR +((objecttype)::text = 'RT::Queue'::text))) + Total runtime: 108486.306 ms +(21 rows) + + + + +-- +Rafael Martinez, +Center for Information Technology Services +University of Oslo, Norway + +PGP Public Key: http://folk.uio.no/rafael/ + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 10:31:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A8A8911F6B46 + for ; + Fri, 7 Apr 2006 10:31:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29538-02 + for ; + Fri, 7 Apr 2006 10:31:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) + by postgresql.org (Postfix) with ESMTP id 42DDB11F6B18 + for ; + Fri, 7 Apr 2006 10:31:21 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by ptb-relay02.plus.net with esmtp (Exim) id 1FRr3W-00011m-P1; + Fri, 07 Apr 2006 14:31:18 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id E6D8973709; + Fri, 7 Apr 2006 14:32:24 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 9FCF0FF04; + Fri, 7 Apr 2006 14:31:17 +0100 (BST) +Message-ID: <443669A5.2000603@archonet.com> +Date: Fri, 07 Apr 2006 14:31:17 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Rafael Martinez Guerrero +Cc: pgsql-performance@postgresql.org +Subject: Re: Same SQL, 104296ms of difference between 7.4.12 and +References: <1144413933.24060.253.camel@bbking.uio.no> +In-Reply-To: <1144413933.24060.253.camel@bbking.uio.no> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/127 +X-Sequence-Number: 18211 + +Rafael Martinez Guerrero wrote: +> Hello +> +> I have a sql statement that takes 108489.780 ms with 8.0.7 in a +> RHEL4/amd64linux server with 2xAMD Opteron(tm) Processor 275 2.00GHz / +> 8GB RAM and only 4193.588 ms with 7.4.12 in a RHEL3/386linux server with +> 2xIntel(R) Xeon(TM) CPU 2.40GHz / 4GB RAM. +> +> Some information: +> +> - There is no IO when I am running the sql, but it uses 99% of the cpu. +> - I run VACUUM VERBOSE ANALYZE in both databases before the test. +> - The databases are identical. +> - No other jobs running when testing. +> - Some different parameters between 7.4.12 and 8.0.7 : +> +> 7.4.12: +> ------- +> shared_buffers = 114966 #(15% of ram) +> sort_mem = 16384 +> vacuum_mem = 524288 +> wal_buffers = 64 +> checkpoint_segments = 16 +> effective_cache_size = 383220 #(50% ram) +> random_page_cost = 3 +> default_statistics_target = 100 +> +> 8.0.7: +> ------ +> shared_buffers = 250160 #(25% ram) +> work_mem = 8192 +> maintenance_work_mem = 131072 +> wal_buffers = 128 +> checkpoint_segments = 64 +> effective_cache_size = 500321 #(50% ram) +> random_page_cost = 3 +> default_statistics_target = 100 +> +> Any ideas of what I can test/configurate to find out why this happens? +> Thanks in advance. + +I haven't looked in detail at the plans, but what stands out to me is +that you've got a sort with a lot of columns and you've halved sort_mem +(work_mem). Try increasing it (perhaps to 32000 even). + set work_mem = 32000; + +Give that a quick go and see what happens. If it doesn't work, we'll +look at the plans in more detail. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Apr 7 11:00:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ED79A11F611E + for ; + Fri, 7 Apr 2006 11:00:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35133-06 + for ; + Fri, 7 Apr 2006 11:00:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pat.uio.no (pat.uio.no [129.240.10.6]) + by postgresql.org (Postfix) with ESMTP id 8C9A811F6026 + for ; + Fri, 7 Apr 2006 11:00:54 -0300 (ADT) +Received: from mail-mx2.uio.no ([129.240.10.30]) + by pat.uio.no with esmtp (Exim 4.43) + id 1FRrW9-0002Yy-JV; Fri, 07 Apr 2006 16:00:53 +0200 +Received: from bbking.uio.no ([129.240.201.179]) + by mail-mx2.uio.no with esmtps (TLSv1:AES256-SHA:256) (Exim 4.43) + id 1FRrW1-0006Fj-9o; Fri, 07 Apr 2006 16:00:45 +0200 +Subject: Re: Same SQL, 104296ms of difference between 7.4.12 and +From: Rafael Martinez Guerrero +To: Richard Huxton +Cc: pgsql-performance@postgresql.org +In-Reply-To: <443669A5.2000603@archonet.com> +References: <1144413933.24060.253.camel@bbking.uio.no> + <443669A5.2000603@archonet.com> +Content-Type: text/plain +Organization: University of Oslo +Message-Id: <1144418444.24060.269.camel@bbking.uio.no> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-17) +Date: Fri, 07 Apr 2006 16:00:44 +0200 +Content-Transfer-Encoding: 7bit +X-UiO-Spam-info: not spam, SpamAssassin (score=-5.377, required 12, + autolearn=disabled, AWL -0.38, UIO_MAIL_IS_INTERNAL -5.00) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/128 +X-Sequence-Number: 18212 + +On Fri, 2006-04-07 at 15:31, Richard Huxton wrote: +> Rafael Martinez Guerrero wrote: +> > Hello +> > +> > I have a sql statement that takes 108489.780 ms with 8.0.7 in a +> > RHEL4/amd64linux server with 2xAMD Opteron(tm) Processor 275 2.00GHz / +> > 8GB RAM and only 4193.588 ms with 7.4.12 in a RHEL3/386linux server with +> > 2xIntel(R) Xeon(TM) CPU 2.40GHz / 4GB RAM. +> > +> > Some information: +> > +> > - There is no IO when I am running the sql, but it uses 99% of the cpu. +> > - I run VACUUM VERBOSE ANALYZE in both databases before the test. +> > - The databases are identical. +> > - No other jobs running when testing. +> > - Some different parameters between 7.4.12 and 8.0.7 : +> > +> > 7.4.12: +> > ------- +> > shared_buffers = 114966 #(15% of ram) +> > sort_mem = 16384 +> > vacuum_mem = 524288 +> > wal_buffers = 64 +> > checkpoint_segments = 16 +> > effective_cache_size = 383220 #(50% ram) +> > random_page_cost = 3 +> > default_statistics_target = 100 +> > +> > 8.0.7: +> > ------ +> > shared_buffers = 250160 #(25% ram) +> > work_mem = 8192 +> > maintenance_work_mem = 131072 +> > wal_buffers = 128 +> > checkpoint_segments = 64 +> > effective_cache_size = 500321 #(50% ram) +> > random_page_cost = 3 +> > default_statistics_target = 100 +> > +> > Any ideas of what I can test/configurate to find out why this happens? +> > Thanks in advance. +> +> I haven't looked in detail at the plans, but what stands out to me is +> that you've got a sort with a lot of columns and you've halved sort_mem +> (work_mem). Try increasing it (perhaps to 32000 even). +> set work_mem = 32000; +> +> Give that a quick go and see what happens. If it doesn't work, we'll +> look at the plans in more detail. + +I know that this SQL could be done in a much better way, but I can not +change it at the moment. + +work_mem = 16384: +----------------- +After restarting the database and running the explain two times: +107911.229 ms + +work_mem = 32768: +----------------- +After restarting the database and running the explain two times: +103988.337 ms + + +-- +Rafael Martinez, +Center for Information Technology Services +University of Oslo, Norway + +PGP Public Key: http://folk.uio.no/rafael/ + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 11:34:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8408711F6B32 + for ; + Fri, 7 Apr 2006 11:34:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46185-03 + for ; + Fri, 7 Apr 2006 11:34:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 6F2BB11F6B0F + for ; + Fri, 7 Apr 2006 11:34:53 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37EYrKV011740; + Fri, 7 Apr 2006 10:34:53 -0400 (EDT) +To: Brian Herlihy +cc: pgsql-performance@postgresql.org +Subject: Re: Query planner is using wrong index. +In-reply-to: <20060407064108.49532.qmail@web52315.mail.yahoo.com> +References: <20060407064108.49532.qmail@web52315.mail.yahoo.com> +Comments: In-reply-to Brian Herlihy + message dated "Fri, 07 Apr 2006 16:41:08 +1000" +Date: Fri, 07 Apr 2006 10:34:53 -0400 +Message-ID: <11739.1144420493@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.132 required=5 tests=[AWL=0.132] +X-Spam-Score: 0.132 +X-Spam-Level: +X-Archive-Number: 200604/129 +X-Sequence-Number: 18213 + +Brian Herlihy writes: +> Before I go, I have a question - From discussions on the Postgresql irc +> channel, and from reading the TODO list on the website, I am under the +> impression that there are no plans to allow optimizer hints, such as "use index +> table_pkey". Is this really true? + +I personally don't think it's a good idea: the time spent in designing, +implementing, and maintaining a usable hint system would be significant, +and IMHO the effort is better spent on *fixing* the optimizer problems +than working around them. There are also good arguments about how hints +wouldn't be future-proof --- for instance, the recent addition of bitmap +indexscan capability would've obsoleted an awful lot of hints, had +anyone had any on their queries. We'd then be faced with either turning +off the hints or being forced by them to adopt inferior plans. + +The direction I'd like to see us go to solve your problem is maintaining +cross-column statistics. It's not practical to store joint stats for +every set of columns, but the existence of an index on (p2,p3) ought to +cue us that p2/p3 stats would be worth having. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 11:38:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A243B11F6AFA + for ; + Fri, 7 Apr 2006 11:37:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43559-09 + for ; + Fri, 7 Apr 2006 11:37:51 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.198]) + by postgresql.org (Postfix) with ESMTP id 0BFBD11F6B12 + for ; + Fri, 7 Apr 2006 11:37:55 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id 8so362143nzo + for ; + Fri, 07 Apr 2006 07:37:56 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=WXDlrZN2pgtOQcBlS5d460n6htBIU0mgaArLOJIC6lC6Yixm6XdbR5xoezMHnIcJfdsOJnHLG7GhYRsVoilQlrhOW+Q1M5dkS2bHwgmP+q4cI1mvn5fIh3zcz85/QseBiT7vH6/IfksC8zSpKpKMD1ulBYkUtw9fRVHWwKf6aoQ= +Received: by 10.65.126.19 with SMTP id d19mr2103224qbn; + Fri, 07 Apr 2006 07:37:34 -0700 (PDT) +Received: by 10.65.241.2 with HTTP; Fri, 7 Apr 2006 07:37:34 -0700 (PDT) +Message-ID: +Date: Fri, 7 Apr 2006 11:37:34 -0300 +From: "Charles A. Landemaine" +To: pgsql-performance@postgresql.org +Subject: Loading the entire DB into RAM +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/130 +X-Sequence-Number: 18214 + +I have a web server with PostgreSQL and RHEL. It hosts a search +engine, and each time some one makes a query, it uses the HDD Raid +array. The DB is not very big, it is less than a GB. I plan to add +more RAM anyway. + +What I'd like to do is find out how to keep the whole DB in RAM so +that each time some one does a query, it doesn't use the HDD. Is it +possible, if so, how? +Thanks, + +Charles. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 11:40:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CFA9011F6B15 + for ; + Fri, 7 Apr 2006 11:40:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48536-02 + for ; + Fri, 7 Apr 2006 11:40:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pih-relay05.plus.net (pih-relay05.plus.net [212.159.14.132]) + by postgresql.org (Postfix) with ESMTP id 6F75011F6B02 + for ; + Fri, 7 Apr 2006 11:40:53 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by pih-relay05.plus.net with esmtp (Exim) id 1FRs8q-0005DD-Sf; + Fri, 07 Apr 2006 15:40:53 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id CB60A7379A; + Fri, 7 Apr 2006 15:41:59 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 2BF10FF04; + Fri, 7 Apr 2006 15:40:52 +0100 (BST) +Message-ID: <443679F3.20907@archonet.com> +Date: Fri, 07 Apr 2006 15:40:51 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Rafael Martinez Guerrero +Cc: pgsql-performance@postgresql.org +Subject: Re: Same SQL, 104296ms of difference between 7.4.12 and +References: <1144413933.24060.253.camel@bbking.uio.no> + <443669A5.2000603@archonet.com> + <1144418444.24060.269.camel@bbking.uio.no> +In-Reply-To: <1144418444.24060.269.camel@bbking.uio.no> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/131 +X-Sequence-Number: 18215 + +Rafael Martinez Guerrero wrote: +>>> Any ideas of what I can test/configurate to find out why this happens? +>>> Thanks in advance. +>> I haven't looked in detail at the plans, but what stands out to me is +>> that you've got a sort with a lot of columns and you've halved sort_mem +>> (work_mem). Try increasing it (perhaps to 32000 even). +>> set work_mem = 32000; +>> +>> Give that a quick go and see what happens. If it doesn't work, we'll +>> look at the plans in more detail. +> +> I know that this SQL could be done in a much better way, but I can not +> change it at the moment. +> +> work_mem = 16384: +> ----------------- +> After restarting the database and running the explain two times: +> 107911.229 ms +> +> work_mem = 32768: +> ----------------- +> After restarting the database and running the explain two times: +> 103988.337 ms + +Damn! I hate it when I have to actually work at a problem :-) + + +Well, the first thing that strikes me is that the row estimates are +terrible for 7.4.12 (which runs quickly) and much better for 8.0.7 +(which runs slowly). Which suggests you were lucky before. + +The second thing I notice is the bit that goes: Materialize ... Seq Scan +on acl acl_2. If you compare the two you'll see that the 7.4 version +loops 16,160 times but 8.0 loops 513,264 times. + +This is a bad choice, and I'm guessing it's made because it gets the row +estimate wrong: +Hash Join (cost=4667.85..51078.88 rows=62852 width=727) (actual +time=649.028..13602.451 rows=513264 loops=1) + +That's the comparison Groups_3.id = CachedGroupMembers_4.GroupId if I'm +reading this correctly. Is there anything unusual about those two columns? +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Apr 7 11:51:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 709B211F6B3E + for ; + Fri, 7 Apr 2006 11:50:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50689-04 + for ; + Fri, 7 Apr 2006 11:50:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pat.uio.no (pat.uio.no [129.240.10.6]) + by postgresql.org (Postfix) with ESMTP id 4D80D11F6B0F + for ; + Fri, 7 Apr 2006 11:50:56 -0300 (ADT) +Received: from mail-mx4.uio.no ([129.240.10.45]) + by pat.uio.no with esmtp (Exim 4.43) + id 1FRsIZ-0007Iu-C7; Fri, 07 Apr 2006 16:50:55 +0200 +Received: from ti200710a080-3004.bb.online.no ([85.164.139.188] + helo=[10.1.1.101]) + by mail-mx4.uio.no with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.43) + id 1FRsIV-0002hC-8T; Fri, 07 Apr 2006 16:50:51 +0200 +Subject: Re: Same SQL, 104296ms of difference between 7.4.12 and +From: Rafael Martinez +To: =?ISO-8859-1?Q?G=E1briel_=C1kos?= +Cc: pgsql-performance@postgresql.org +In-Reply-To: <44367A1B.1090900@i-logic.hu> +References: <1144413933.24060.253.camel@bbking.uio.no> + <44367A1B.1090900@i-logic.hu> +Content-Type: text/plain; charset=UTF-8 +Organization: University of Oslo +Date: Fri, 07 Apr 2006 16:53:40 +0200 +Message-Id: <1144421620.6928.2.camel@linux.site> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.0 +Content-Transfer-Encoding: quoted-printable +X-UiO-Spam-info: not spam, SpamAssassin (score=-3.919, required 12, + autolearn=disabled, AWL 1.08, UIO_MAIL_IS_INTERNAL -5.00) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/132 +X-Sequence-Number: 18216 + +On Fri, 2006-04-07 at 16:41 +0200, G=C3=A1briel =C3=81kos wrote: + +> > =20 +> > Any ideas of what I can test/configurate to find out why this happens? +> > Thanks in advance. +>=20 +> Increase work_mem to 50% of memory, and don't care about=20 +> maintenance_work_mem and effective_cache_size, they don't matter in this=20 +> case. +>=20 + +The problem is not the amount of memory. It works much faster with only +16M and 7.4.12 than 8.0.7. + +--=20 +Rafael Martinez, +Center for Information Technology Services +University of Oslo, Norway + +PGP Public Key: http://folk.uio.no/rafael/ + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 12:01:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1876411F61EA + for ; + Fri, 7 Apr 2006 12:01:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53235-03 + for ; + Fri, 7 Apr 2006 12:01:07 -0300 (ADT) +X-Greylist: delayed 00:06:45.371873 by SQLgrey- +Received: from mx1.bastionits.com (65.105.157.222.ptr.us.xo.net + [65.105.157.222]) + by postgresql.org (Postfix) with SMTP id 3878811F6031 + for ; + Fri, 7 Apr 2006 12:01:07 -0300 (ADT) +Received: (qmail 83368 invoked from network); 7 Apr 2006 14:48:59 -0000 +Received: from unknown (HELO ?10.0.0.110?) (10.0.0.110) + by mx1.bastionits.com with SMTP; 7 Apr 2006 14:48:59 -0000 +Message-ID: <44367D22.9060007@mattdavies.net> +Date: Fri, 07 Apr 2006 08:54:26 -0600 +From: Matt Davies | Postgresql List +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: "Charles A. Landemaine" +CC: pgsql-performance@postgresql.org +Subject: Re: Loading the entire DB into RAM +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/134 +X-Sequence-Number: 18218 + +If memory serves me correctly I have seen several posts about this in +the past. + +I'll try to recall highlights. + +1. Create a md in linux sufficiently large enough to handle the data set +you are wanting to store. +2. Create a HD based copy somewhere as your permanent storage mechanism. +3. Start up your PostgreSQL instance with the MD as the data store +4. Load your data to the MD instance. +5. Figure out how you will change indexes _and_ ensure that your disk +storage is consistent with your MD instance. + +I haven't done so, but it would be interesting to have a secondary +database somewhere that is your primary storage. It needn't be +especially powerful, or even available. It serves as the place to +generate your indexing data. You could then use SLONY to propogate the +data to the MD production system. + +Of course, if you are updating your system that resides in ram, you +should be thinking the other way. Have SLONY replicate changes to the +other, permanent storage, system. + +Either way you do it, I can't think of an out of the box method to doing +it. Somehow one has to transfer data from permanent storage to the md +instance, and, likewise, back to permanent storage. + +Out of curiosity, what are you using as the search engine? + + +Charles A. Landemaine wrote: +> I have a web server with PostgreSQL and RHEL. It hosts a search +> engine, and each time some one makes a query, it uses the HDD Raid +> array. The DB is not very big, it is less than a GB. I plan to add +> more RAM anyway. +> +> What I'd like to do is find out how to keep the whole DB in RAM so +> that each time some one does a query, it doesn't use the HDD. Is it +> possible, if so, how? +> Thanks, +> +> Charles. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +> +> +> + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 12:01:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ABAAA11F6CD8 + for ; + Fri, 7 Apr 2006 12:01:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53162-06 + for ; + Fri, 7 Apr 2006 12:01:00 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.238]) + by postgresql.org (Postfix) with ESMTP id 61A3411F6CBD + for ; + Fri, 7 Apr 2006 12:01:00 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i12so398037wra + for ; + Fri, 07 Apr 2006 08:00:59 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=T/4HkC4JYGzfKskSxSOzpbtBb6Vj41qsjyeepIDvkuftHCogD4vg2or9WBLh3GVDSj6qIkl4iu8PqZi5hTpu7F3qF3OjOdjFLdtYSHk4SRBDqEbVnTFTM35REm01E8BbqQoxxXRqCbsxq8SKvVMxRCGEXTElZTHQgi40W7clbOw= +Received: by 10.65.105.11 with SMTP id h11mr1355793qbm; + Fri, 07 Apr 2006 08:00:59 -0700 (PDT) +Received: by 10.65.241.2 with HTTP; Fri, 7 Apr 2006 08:00:59 -0700 (PDT) +Message-ID: +Date: Fri, 7 Apr 2006 12:00:59 -0300 +From: "Charles A. Landemaine" +To: "Matt Davies | Postgresql List" +Subject: Re: Loading the entire DB into RAM +Cc: pgsql-performance@postgresql.org +In-Reply-To: <44367D22.9060007@mattdavies.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <44367D22.9060007@mattdavies.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/133 +X-Sequence-Number: 18217 + +On 4/7/06, Matt Davies | Postgresql List w= +rote: +> Out of curiosity, what are you using as the search engine? + +Thank you. We designed the search engine ourself (we didn't use a +ready-to-use solution). + +-- +Charles A. Landemaine. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 12:08:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5091711F6B08 + for ; + Fri, 7 Apr 2006 12:08:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55120-02 + for ; + Fri, 7 Apr 2006 12:08:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pih-relay06.plus.net (pih-relay06.plus.net [212.159.14.133]) + by postgresql.org (Postfix) with ESMTP id 99A8D11F61E0 + for ; + Fri, 7 Apr 2006 12:08:13 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by pih-relay06.plus.net with esmtp (Exim) id 1FRsZI-0000Ng-Fr; + Fri, 07 Apr 2006 16:08:12 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id E313D735D1; + Fri, 7 Apr 2006 16:09:18 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id C5290FF04; + Fri, 7 Apr 2006 16:08:10 +0100 (BST) +Message-ID: <4436805A.1040507@archonet.com> +Date: Fri, 07 Apr 2006 16:08:10 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Tom Lane +Cc: Brian Herlihy , + pgsql-performance@postgresql.org +Subject: Spotting planner errors (was Re: Query planner is using wrong index.) +References: <20060407064108.49532.qmail@web52315.mail.yahoo.com> + <11739.1144420493@sss.pgh.pa.us> +In-Reply-To: <11739.1144420493@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/135 +X-Sequence-Number: 18219 + +Tom Lane wrote: +> Brian Herlihy writes: +>> Before I go, I have a question - From discussions on the Postgresql irc +>> channel, and from reading the TODO list on the website, I am under the +>> impression that there are no plans to allow optimizer hints, such as "use index +>> table_pkey". Is this really true? +> +> I personally don't think it's a good idea: the time spent in designing, +> implementing, and maintaining a usable hint system would be significant, +> and IMHO the effort is better spent on *fixing* the optimizer problems +> than working around them. + +Tom - does the planner/executor know it's got row estimates wrong? That +is, if I'm not running an EXPLAIN ANALYSE is there a point at which we +could log "planner estimate for X out by factor of Y"? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Apr 7 12:12:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1AF0211F61EA + for ; + Fri, 7 Apr 2006 12:12:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54356-07 + for ; + Fri, 7 Apr 2006 12:12:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 4228B11F6031 + for ; + Fri, 7 Apr 2006 12:12:55 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37FCqWq012068; + Fri, 7 Apr 2006 11:12:52 -0400 (EDT) +To: Richard Huxton +cc: Brian Herlihy , pgsql-performance@postgresql.org +Subject: Re: Spotting planner errors (was Re: Query planner is using wrong + index.) +In-reply-to: <4436805A.1040507@archonet.com> +References: <20060407064108.49532.qmail@web52315.mail.yahoo.com> + <11739.1144420493@sss.pgh.pa.us> <4436805A.1040507@archonet.com> +Comments: In-reply-to Richard Huxton + message dated "Fri, 07 Apr 2006 16:08:10 +0100" +Date: Fri, 07 Apr 2006 11:12:52 -0400 +Message-ID: <12067.1144422772@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.131 required=5 tests=[AWL=0.131] +X-Spam-Score: 0.131 +X-Spam-Level: +X-Archive-Number: 200604/136 +X-Sequence-Number: 18220 + +Richard Huxton writes: +> Tom - does the planner/executor know it's got row estimates wrong? That +> is, if I'm not running an EXPLAIN ANALYSE is there a point at which we +> could log "planner estimate for X out by factor of Y"? + +Not at the moment, but you could certainly imagine changing the executor +to count rows even without EXPLAIN ANALYZE, and then complain during +plan shutdown. + +Not sure how helpful that would be; there would be a lot of noise from +common cases such as executing underneath a LIMIT node. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 12:25:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 386E211F6B93 + for ; + Fri, 7 Apr 2006 12:25:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60264-02-2 + for ; + Fri, 7 Apr 2006 12:25:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pih-relay05.plus.net (pih-relay05.plus.net [212.159.14.132]) + by postgresql.org (Postfix) with ESMTP id B661311F6B8F + for ; + Fri, 7 Apr 2006 12:25:00 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by pih-relay05.plus.net with esmtp (Exim) id 1FRspW-0003IN-9i; + Fri, 07 Apr 2006 16:24:58 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 6BFB07379E; + Fri, 7 Apr 2006 16:26:05 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 2047BFF04; + Fri, 7 Apr 2006 16:24:57 +0100 (BST) +Message-ID: <44368448.9090101@archonet.com> +Date: Fri, 07 Apr 2006 16:24:56 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Tom Lane +Cc: Brian Herlihy , + pgsql-performance@postgresql.org +Subject: Re: Spotting planner errors (was Re: Query planner is using +References: <20060407064108.49532.qmail@web52315.mail.yahoo.com> + <11739.1144420493@sss.pgh.pa.us> <4436805A.1040507@archonet.com> + <12067.1144422772@sss.pgh.pa.us> +In-Reply-To: <12067.1144422772@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/137 +X-Sequence-Number: 18221 + +Tom Lane wrote: +> Richard Huxton writes: +>> Tom - does the planner/executor know it's got row estimates wrong? That +>> is, if I'm not running an EXPLAIN ANALYSE is there a point at which we +>> could log "planner estimate for X out by factor of Y"? +> +> Not at the moment, but you could certainly imagine changing the executor +> to count rows even without EXPLAIN ANALYZE, and then complain during +> plan shutdown. +> +> Not sure how helpful that would be; there would be a lot of noise from +> common cases such as executing underneath a LIMIT node. + +Hmm - thinking about it you'd probably want to record it similarly to +stats too. It's the fact that the planner *repeatedly* gets an estimate +wrong that's of interest. + +Would it be prohibitive to total actions taken - to act as raw data for +random_page_cost / cpu_xxx_cost? If you could get a ratio of estimated +vs actual time vs the various page-fetches/index-fetches etc. we could +actually plug some meaningful numbers in. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Apr 7 12:25:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 387FE11F6B89 + for ; + Fri, 7 Apr 2006 12:25:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58030-08 + for ; + Fri, 7 Apr 2006 12:25:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 1B52011F6AF8 + for ; + Fri, 7 Apr 2006 12:25:17 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37FPE2n012192; + Fri, 7 Apr 2006 11:25:15 -0400 (EDT) +To: "Charles A. Landemaine" +cc: pgsql-performance@postgresql.org +Subject: Re: Loading the entire DB into RAM +In-reply-to: +References: +Comments: In-reply-to "Charles A. Landemaine" + message dated "Fri, 07 Apr 2006 11:37:34 -0300" +Date: Fri, 07 Apr 2006 11:25:14 -0400 +Message-ID: <12191.1144423514@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.131 required=5 tests=[AWL=0.131] +X-Spam-Score: 0.131 +X-Spam-Level: +X-Archive-Number: 200604/138 +X-Sequence-Number: 18222 + +"Charles A. Landemaine" writes: +> What I'd like to do is find out how to keep the whole DB in RAM so +> that each time some one does a query, it doesn't use the HDD. Is it +> possible, if so, how? + +That should happen essentially for free, if the kernel doesn't have any +better use for the memory --- anything read from disk once will stay in +kernel disk cache. Perhaps you need to take a closer look at your +kernel VM parameters. Or maybe you don't have enough RAM yet for both +the DB contents and the processes you need to run. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 12:29:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0D94A11F6774 + for ; + Fri, 7 Apr 2006 12:29:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61402-03 + for ; + Fri, 7 Apr 2006 12:29:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 0321C11F68CD + for ; + Fri, 7 Apr 2006 12:29:33 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37FTW04012252; + Fri, 7 Apr 2006 11:29:32 -0400 (EDT) +To: Rafael Martinez Guerrero +cc: pgsql-performance@postgresql.org +Subject: Re: Same SQL, 104296ms of difference between 7.4.12 and 8.0.7 +In-reply-to: <1144413933.24060.253.camel@bbking.uio.no> +References: <1144413933.24060.253.camel@bbking.uio.no> +Comments: In-reply-to Rafael Martinez Guerrero + message dated "Fri, 07 Apr 2006 14:45:33 +0200" +Date: Fri, 07 Apr 2006 11:29:32 -0400 +Message-ID: <12251.1144423772@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.131 required=5 tests=[AWL=0.131] +X-Spam-Score: 0.131 +X-Spam-Level: +X-Archive-Number: 200604/139 +X-Sequence-Number: 18223 + +Rafael Martinez Guerrero writes: +> I have a sql statement that takes 108489.780 ms with 8.0.7 in a +> RHEL4/amd64linux server with 2xAMD Opteron(tm) Processor 275 2.00GHz / +> 8GB RAM and only 4193.588 ms with 7.4.12 in a RHEL3/386linux server with +> 2xIntel(R) Xeon(TM) CPU 2.40GHz / 4GB RAM. + +I think you've discovered a planner regression. +Simplified test case using the regression database: + +explain select * from tenk1 a, tenk1 b +where (a.ten = b.ten and (a.unique1 = 100 or a.unique1 = 101)) + or (a.hundred = b.hundred and a.unique1 = 42); + +7.4: + Nested Loop (cost=0.00..2219.74 rows=4 width=488) + Join Filter: ((("outer".hundred = "inner".hundred) OR ("outer".ten = "inner".ten)) AND (("outer".unique1 = 42) OR ("outer".ten = "inner".ten)) AND (("outer".hundred = "inner".hundred) OR ("outer".unique1 = 100) OR ("outer".unique1 = 101))) + -> Index Scan using tenk1_unique1, tenk1_unique1, tenk1_unique1 on tenk1 a (cost=0.00..18.04 rows=3 width=244) + Index Cond: ((unique1 = 42) OR (unique1 = 100) OR (unique1 = 101)) + -> Seq Scan on tenk1 b (cost=0.00..458.24 rows=10024 width=244) +(5 rows) + +8.0: + Nested Loop (cost=810.00..6671268.00 rows=2103 width=488) + Join Filter: ((("outer".ten = "inner".ten) AND (("outer".unique1 = 100) OR ("outer".unique1 = 101))) OR (("outer".hundred = "inner".hundred) AND ("outer".unique1 = 42))) + -> Seq Scan on tenk1 a (cost=0.00..458.00 rows=10000 width=244) + -> Materialize (cost=810.00..1252.00 rows=10000 width=244) + -> Seq Scan on tenk1 b (cost=0.00..458.00 rows=10000 width=244) +(5 rows) + +Note the failure to pull out the unique1 conditions from the join clause +and use them with the index. I didn't bother to do EXPLAIN ANALYZE; +this plan obviously sucks compared to the other. + +8.1: +TRAP: FailedAssertion("!(!restriction_is_or_clause((RestrictInfo *) orarg))", File: "indxpath.c", Line: 479) +LOG: server process (PID 12201) was terminated by signal 6 +server closed the connection unexpectedly + +Oh dear. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 12:30:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C618A11F6913 + for ; + Fri, 7 Apr 2006 12:30:01 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61291-03 + for ; + Fri, 7 Apr 2006 12:29:58 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.233]) + by postgresql.org (Postfix) with ESMTP id 7C79A11F6774 + for ; + Fri, 7 Apr 2006 12:29:58 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 69so395615wri + for ; + Fri, 07 Apr 2006 08:29:57 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=P5TXd45QhHdHx9XYvuWxQh1Uhzubedm/sffCeBMR/k51Ivr0b+7v92QekEmqUoUctn++ehV/+v8+6m4Dy9g0dvb5psPyYcbz4tpIcTQreR0HvfmaF7EKQVuVnCWmmm4HXdeMvwlH5cCrHnf2Y7KlySbH5ukIX//HzMrWihnlCiA= +Received: by 10.65.204.17 with SMTP id g17mr2180697qbq; + Fri, 07 Apr 2006 08:29:57 -0700 (PDT) +Received: by 10.65.137.8 with HTTP; Fri, 7 Apr 2006 08:29:57 -0700 (PDT) +Message-ID: +Date: Fri, 7 Apr 2006 11:29:57 -0400 +From: "Merlin Moncure" +To: "Charles A. Landemaine" +Subject: Re: Loading the entire DB into RAM +Cc: pgsql-performance@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/140 +X-Sequence-Number: 18224 + +On 4/7/06, Charles A. Landemaine wrote: +> I have a web server with PostgreSQL and RHEL. It hosts a search +> engine, and each time some one makes a query, it uses the HDD Raid +> array. The DB is not very big, it is less than a GB. I plan to add +> more RAM anyway. +> +> What I'd like to do is find out how to keep the whole DB in RAM so +> that each time some one does a query, it doesn't use the HDD. Is it +> possible, if so, how? + +don't bother. + +If your database is smaller than ram on the box, the operating will +cache it quite effectively. All you should be worrying about is to +set fsync=3Don (you care about your data) or off (you don't). If your +data is truly static you might get better performance out of a +in-process data storage, like sqlite for example. + +Merlin + +From pgsql-performance-owner@postgresql.org Fri Apr 7 12:49:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 802CA11F6237 + for ; + Fri, 7 Apr 2006 12:49:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66263-05 + for ; + Fri, 7 Apr 2006 12:49:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 65DCB11F623B + for ; + Fri, 7 Apr 2006 12:49:16 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 7 Apr 2006 15:49:14 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 07 Apr 2006 10:49:14 -0500 +Subject: Re: Loading the entire DB into RAM +From: Scott Marlowe +To: Matt Davies | Postgresql List +Cc: "Charles A. Landemaine" , + pgsql-performance@postgresql.org +In-Reply-To: <44367D22.9060007@mattdavies.net> +References: + <44367D22.9060007@mattdavies.net> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1144424954.32266.129.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 07 Apr 2006 10:49:14 -0500 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200604/141 +X-Sequence-Number: 18225 + +On Fri, 2006-04-07 at 09:54, Matt Davies | Postgresql List wrote: +> If memory serves me correctly I have seen several posts about this in +> the past. +> +> I'll try to recall highlights. +> +> 1. Create a md in linux sufficiently large enough to handle the data set +> you are wanting to store. +> 2. Create a HD based copy somewhere as your permanent storage mechanism. +> 3. Start up your PostgreSQL instance with the MD as the data store +> 4. Load your data to the MD instance. +> 5. Figure out how you will change indexes _and_ ensure that your disk +> storage is consistent with your MD instance. + +SNIP + +> Either way you do it, I can't think of an out of the box method to doing +> it. Somehow one has to transfer data from permanent storage to the md +> instance, and, likewise, back to permanent storage. + +dd could do that. Just have a third partition that holds the drive +image. Start up the mirror set, dd the file system into place on the md +device. When you're ready to shut the machine down or back it up, shut +down the postmaster, sync the md drive, dd the filesystem back off to +the image backup drive. + +But I'd really just recommend getting a LOT of RAM and letting the +kernel do all the caching. If you've got a 2 gig database and 4 gigs of +ram, you should be gold. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 14:11:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BBB4511F60AF + for ; + Fri, 7 Apr 2006 14:11:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90598-05 + for ; + Fri, 7 Apr 2006 14:11:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 7C9C111F65C7 + for ; + Fri, 7 Apr 2006 14:11:40 -0300 (ADT) +Received: (qmail 4826 invoked from network); 7 Apr 2006 19:12:13 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 7 Apr 2006 19:12:13 +0200 +To: "Matt Davies | Postgresql List" , + "Charles A. Landemaine" +Cc: pgsql-performance@postgresql.org +Subject: Re: Loading the entire DB into RAM +References: + <44367D22.9060007@mattdavies.net> +Message-ID: +Date: Fri, 07 Apr 2006 19:12:12 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <44367D22.9060007@mattdavies.net> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/142 +X-Sequence-Number: 18226 + +** This has not been tested. + + Create a ramdisk of required size + Create a Linux software RAID mirror between the ramdisk, and a partition +of the same size. + Mark the physical-disk as write-mostly (reads will go to the ramdisk) + Format it and load data... + + On reboot you'll get a RAID1 mirror with 1 failed drive (because the +ramdisk is dead of course). Just recreate the ramdisk and resync. + + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 14:37:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A2EF011F6AB5 + for ; + Fri, 7 Apr 2006 14:37:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98663-06 + for ; + Fri, 7 Apr 2006 14:36:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id D25B011F6976 + for ; + Fri, 7 Apr 2006 14:36:59 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37HawKa014670; + Fri, 7 Apr 2006 13:36:59 -0400 (EDT) +To: Rafael Martinez Guerrero +cc: pgsql-performance@postgresql.org +Subject: Re: Same SQL, 104296ms of difference between 7.4.12 and 8.0.7 +In-reply-to: <12251.1144423772@sss.pgh.pa.us> +References: <1144413933.24060.253.camel@bbking.uio.no> + <12251.1144423772@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Fri, 07 Apr 2006 11:29:32 -0400" +Date: Fri, 07 Apr 2006 13:36:58 -0400 +Message-ID: <14669.1144431418@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.132 required=5 tests=[AWL=0.132] +X-Spam-Score: 0.132 +X-Spam-Level: +X-Archive-Number: 200604/143 +X-Sequence-Number: 18227 + +I wrote: +> Rafael Martinez Guerrero writes: +>> I have a sql statement that takes 108489.780 ms with 8.0.7 in a +>> RHEL4/amd64linux server with 2xAMD Opteron(tm) Processor 275 2.00GHz / +>> 8GB RAM and only 4193.588 ms with 7.4.12 in a RHEL3/386linux server with +>> 2xIntel(R) Xeon(TM) CPU 2.40GHz / 4GB RAM. + +> I think you've discovered a planner regression. +> Simplified test case using the regression database: + +> explain select * from tenk1 a, tenk1 b +> where (a.ten = b.ten and (a.unique1 = 100 or a.unique1 = 101)) +> or (a.hundred = b.hundred and a.unique1 = 42); + +I've repaired the assertion crash in 8.1/HEAD, but I don't think it's +practical to teach 8.0 to optimize queries like this nicely. The reason +7.4 can do it is that 7.4 forces the WHERE condition into CNF, ie + + (a.hundred = b.hundred OR a.ten = b.ten) AND + (a.unique1 = 42 OR a.ten = b.ten) AND + (a.hundred = b.hundred OR a.unique1 = 100 OR a.unique1 = 101) AND + (a.unique1 = 42 OR a.unique1 = 100 OR a.unique1 = 101) + +from which it's easy to extract the index condition for A. We decided +that forcing to CNF wasn't such a hot idea, so 8.0 and later don't do +it, but 8.0's logic for extracting index conditions from joinquals isn't +up to the problem of handling sub-ORs. Fixing that looks like a larger +change than I care to back-patch into an old release. + +My recommendation is to update to 8.1.4 when it comes out. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 15:29:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4128A11F6707 + for ; + Fri, 7 Apr 2006 15:29:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15173-01 + for ; + Fri, 7 Apr 2006 15:29:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (213-2-2-26.uk.vianw.net [213.2.2.26]) + by postgresql.org (Postfix) with ESMTP id EBB0011F6914 + for ; + Fri, 7 Apr 2006 14:58:28 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id 3262A13769F + for ; + Fri, 7 Apr 2006 18:58:27 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id DB22313769E + for ; + Fri, 7 Apr 2006 18:58:26 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id BD94475FE5 + for ; + Fri, 7 Apr 2006 18:58:28 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id ADACC75D0A + for ; + Fri, 7 Apr 2006 18:58:28 +0100 (BST) +Date: Fri, 7 Apr 2006 18:58:23 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: pg 8.1.3, AIX, huge box, painfully slow. +Message-Id: <20060407185823.abe93017.gdh@laterooms.com> +X-Mailer: Sylpheed version 2.1.1 (GTK+ 2.8.6; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/144 +X-Sequence-Number: 18228 + +Bing-bong, passenger announcement.. the panic train is now pulling into +platform 8.1.3. Bing-bong. =) + +OK, having moved from our quad-xeon to an 8-CPU IBM pSeries 650 +(8x1.45GHz POWER4 instead of 4 x 3GHz Xeon), our query times have shot +up and our website is next to unusable. The IBM is not swapping (not +with 16GB of RAM!), disk i/o is low, but there must be something +critically wrong for this monster to be performing so badly.. + +There is little IO (maybe 500KB/sec), but the CPUs are often at 100% +usage. + +VACUUM VERBOSE ANALYZE shows me 40000 page slots are needed to track +all free space. I have 160000 page slots configured, and this machine is +dedicated to pg. + +The thing that really winds me up about this, is that aside from all +the normal 'my postgres is slow l0lz!' troubleshooting is the previous +machine (Debian sarge on four 3GHz Xeons) is using 8.1.3 also, with an +inferior I/O subsystem, and it churns through the workload very +merrily, only reaching a full loadavg of 4 at peak times, and running +our main 'hotelsearch' function in ~1000ms.. + +This IBM on the other hand is often taking 5-10 seconds to do the same +thing - although just by watching the logs it's clear to see the +workload coming in waves, and then calming down again. (this +correlation is matched by watching the load-balancer's logs as it takes +unresponsive webservers out of the cluster) + +Here's the differences (I've removed obvious things like file/socket +paths) in "select name,setting from pg_catalog.pg_settings" between the +two: + +--- cayenne 2006-04-07 18:43:48.000000000 +0100 # quad xeon ++++ jalapeno 2006-04-07 18:44:08.000000000 +0100 # ibm 650 +- effective_cache_size | 320000 ++ effective_cache_size | 640000 +- integer_datetimes | on ++ integer_datetimes | off +- maintenance_work_mem | 262144 ++ maintenance_work_mem | 1048576 +- max_connections | 150 ++ max_connections | 100 +- max_fsm_pages | 66000 ++ max_fsm_pages | 160000 +- max_stack_depth | 2048 ++ max_stack_depth | 16384 +- tcp_keepalives_count | 0 +- tcp_keepalives_idle | 0 +- tcp_keepalives_interval | 0 +- temp_buffers | 1000 +- TimeZone | GB ++ tcp_keepalives_count | 8 ++ tcp_keepalives_idle | 7200 ++ tcp_keepalives_interval | 75 ++ temp_buffers | 4000 ++ TimeZone | GMT0BST,M3.5.0,M10.5.0 +- wal_sync_method | fdatasync +- work_mem | 4096 ++ wal_sync_method | open_datasync ++ work_mem | 16384 + +So, jalapeno really should have much more room to move. shared_buffers +is 60000 on both machines. + +I'm reaching the end of my tether here - our search functions are just +so extensive and my pg knowledge is so small that it's overwhelming to +try and step through it to find any bottlenecks :( + +Just to reiterate, it all runs great on cayenne since we trimmed a lot +of the fat out of the search, and I can't understand why the IBM box +isn't absolutely throwing queries out the door :) + +Cheers, +Gavin. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 15:41:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D53A311F6B99 + for ; + Fri, 7 Apr 2006 15:41:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19603-06 + for ; + Fri, 7 Apr 2006 15:41:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 8762111F6C57 + for ; + Fri, 7 Apr 2006 15:41:43 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37Ife4i015234; + Fri, 7 Apr 2006 14:41:40 -0400 (EDT) +To: Gavin Hamill +cc: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +In-reply-to: <20060407185823.abe93017.gdh@laterooms.com> +References: <20060407185823.abe93017.gdh@laterooms.com> +Comments: In-reply-to Gavin Hamill + message dated "Fri, 07 Apr 2006 18:58:23 +0100" +Date: Fri, 07 Apr 2006 14:41:39 -0400 +Message-ID: <15233.1144435299@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.131 required=5 tests=[AWL=0.131] +X-Spam-Score: 0.131 +X-Spam-Level: +X-Archive-Number: 200604/145 +X-Sequence-Number: 18229 + +Gavin Hamill writes: +> OK, having moved from our quad-xeon to an 8-CPU IBM pSeries 650 +> (8x1.45GHz POWER4 instead of 4 x 3GHz Xeon), our query times have shot +> up and our website is next to unusable. The IBM is not swapping (not +> with 16GB of RAM!), disk i/o is low, but there must be something +> critically wrong for this monster to be performing so badly.. + +Have you vacuumed/analyzed since reloading your data? Compare some +EXPLAIN ANALYZE outputs for identical queries on the two machines, +that usually helps figure out what's wrong. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 15:54:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5AE0E11F6A28 + for ; + Fri, 7 Apr 2006 15:54:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36665-01 + for ; + Fri, 7 Apr 2006 15:54:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 00EFA11F6959 + for ; + Fri, 7 Apr 2006 15:54:21 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 7 Apr 2006 18:54:21 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 07 Apr 2006 13:54:21 -0500 +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +From: Scott Marlowe +To: Gavin Hamill +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060407185823.abe93017.gdh@laterooms.com> +References: <20060407185823.abe93017.gdh@laterooms.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1144436060.32269.13.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 07 Apr 2006 13:54:21 -0500 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.121 +X-Spam-Level: +X-Archive-Number: 200604/146 +X-Sequence-Number: 18230 + +On Fri, 2006-04-07 at 12:58, Gavin Hamill wrote: +> Bing-bong, passenger announcement.. the panic train is now pulling into +> platform 8.1.3. Bing-bong. =) +> +> OK, having moved from our quad-xeon to an 8-CPU IBM pSeries 650 +> (8x1.45GHz POWER4 instead of 4 x 3GHz Xeon), our query times have shot +> up and our website is next to unusable. The IBM is not swapping (not +> with 16GB of RAM!), disk i/o is low, but there must be something +> critically wrong for this monster to be performing so badly.. +> +> There is little IO (maybe 500KB/sec), but the CPUs are often at 100% +> usage. + +Can you test your AIX box with linux on it? It may well be that +something in AIX is causing this performance problem. I know that on +the same SPARC hardware, a postgresql database is 2 or more times faster +on top of linux or BSD than it is on solaris, at least it was back a few +years ago when I tested it. + +Are the same queries getting the same basic execution plan on both +boxes? Turn on logging for slow queries, and explain analyze them on +both machines to see if they are. + +If they aren't, figure out why. + +I'd put the old 4 way Xeon back in production and do some serious +testing of this pSeries machine. IBM should be willing to help you, I +hope. + +My guess is that this is an OS issue. Maybe there are AIX tweaks that +will get it up to the same or higher level of performance as your four +way xeon. Maybe there aren't. + +Myself, I'd throw a spare drive in for the OS, put some flavor of linux +on it + +http://www-1.ibm.com/partnerworld/pwhome.nsf/weblook/pat_linux_learn_why_power.html + +and do some load testing there. If the machine can't perform up to +snuff with the same basic OS and a similar setup to your Xeon, send it +back to IBM and buy one of these: + +http://www.asaservers.com/system_dept.asp?dept_id=SD-002 + +or something similar. I can't imagine it costing more than a pSeries. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 16:02:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E8E7811F6D4A + for ; + Fri, 7 Apr 2006 16:02:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35135-07 + for ; + Fri, 7 Apr 2006 16:02:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pat.uio.no (pat.uio.no [129.240.10.6]) + by postgresql.org (Postfix) with ESMTP id CA43611F6959 + for ; + Fri, 7 Apr 2006 16:02:11 -0300 (ADT) +Received: from mail-mx6.uio.no ([129.240.10.47]) + by pat.uio.no with esmtp (Exim 4.43) + id 1FRwDg-0000e6-Qb; Fri, 07 Apr 2006 21:02:09 +0200 +Received: from ti200710a080-3004.bb.online.no ([85.164.139.188] + helo=[10.1.1.101]) + by mail-mx6.uio.no with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.43) + id 1FRwDZ-0004H1-P7; Fri, 07 Apr 2006 21:02:01 +0200 +Subject: Re: Same SQL, 104296ms of difference between 7.4.12 and +From: Rafael Martinez +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <14669.1144431418@sss.pgh.pa.us> +References: <1144413933.24060.253.camel@bbking.uio.no> + <12251.1144423772@sss.pgh.pa.us> <14669.1144431418@sss.pgh.pa.us> +Content-Type: text/plain +Organization: University of Oslo +Date: Fri, 07 Apr 2006 21:04:51 +0200 +Message-Id: <1144436691.6928.23.camel@linux.site> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.0 +Content-Transfer-Encoding: 7bit +X-UiO-Spam-info: not spam, SpamAssassin (score=-3.889, required 12, + autolearn=disabled, AWL 1.11, UIO_MAIL_IS_INTERNAL -5.00) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/147 +X-Sequence-Number: 18231 + +On Fri, 2006-04-07 at 13:36 -0400, Tom Lane wrote: +> I wrote: +> > Rafael Martinez Guerrero writes: +> >> I have a sql statement that takes 108489.780 ms with 8.0.7 in a +> >> RHEL4/amd64linux server with 2xAMD Opteron(tm) Processor 275 2.00GHz / +> >> 8GB RAM and only 4193.588 ms with 7.4.12 in a RHEL3/386linux server with +> >> 2xIntel(R) Xeon(TM) CPU 2.40GHz / 4GB RAM. +> +> > I think you've discovered a planner regression. +> > Simplified test case using the regression database: +> +> > explain select * from tenk1 a, tenk1 b +> > where (a.ten = b.ten and (a.unique1 = 100 or a.unique1 = 101)) +> > or (a.hundred = b.hundred and a.unique1 = 42); +> +> I've repaired the assertion crash in 8.1/HEAD, but I don't think it's +> practical to teach 8.0 to optimize queries like this nicely. The reason +> 7.4 can do it is that 7.4 forces the WHERE condition into CNF, ie +> +[..................] + +Tom, thank you very much for your help. As I suspected this was a more +complicated problem than the configuration of some parameters :( . Good +that we have found out this now and not after the upgrade. + +All our upgrade plans and testing for all our databases have been done +for/with 8.0.x (yes, I know 8.1.x is much better, but I am working in a +conservative place from the sysadm point of view). We will have to +change our plans and go for 8.1 if we want this to work. + +> My recommendation is to update to 8.1.4 when it comes out. + +Any idea about when 8.1.4 will be released? +Thanks again. + +-- +Rafael Martinez, +Center for Information Technology Services +University of Oslo, Norway + +PGP Public Key: http://folk.uio.no/rafael/ + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 16:29:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F32E411F6A9A + for ; + Fri, 7 Apr 2006 16:29:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78085-06 + for ; + Fri, 7 Apr 2006 16:29:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id BCDD811F677D + for ; + Fri, 7 Apr 2006 16:29:55 -0300 (ADT) +Received: from dell.home.lan (host14-128.pool8251.interbusiness.it + [82.51.128.14]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k37KWUr04532; + Fri, 7 Apr 2006 22:32:31 +0200 +Subject: Re: bad performance on Solaris 10 +From: Chris Mair +To: Robert Lor +Cc: Josh Berkus , Mark Kirkwood , + pgsql-performance@postgresql.org, llonergan@greenplum.com +In-Reply-To: <4434C505.1000205@sun.com> +References: <1144111178.3723.80.camel@dell.home.lan> + <1144279780.5133.19.camel@dell.home.lan> + <44346DAA.2080905@paradise.net.nz> + <200604052135.14326.josh@agliodbs.com> + <1144303269.3718.4.camel@dell.home.lan> <4434C505.1000205@sun.com> +Content-Type: text/plain +Date: Fri, 07 Apr 2006 21:29:34 +0200 +Message-Id: <1144438174.3729.20.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +X-Spam-Score: 0.12 +X-Spam-Level: +X-Archive-Number: 200604/148 +X-Sequence-Number: 18232 + + +> >Ok, so I did a few runs for each of the sync methods, keeping all the +> >rest constant and got this: +> > +> >open_datasync 0.7 +> >fdatasync 4.6 +> >fsync 4.5 +> >fsync_writethrough not supported +> >open_sync 0.6 +> > +> >in arbitrary units - higher is faster. +> > +> >Quite impressive! +> > +> > +> > +> > +> Chris, +> Just to make sure the x4100 config is similar to your Linux system, can +> you verify the default setting for disk write cache and make sure they +> are both enabled or disabled. Here's how to check in Solaris. +> As root, run "format -e" -> pick a disk -> cache -> write_cache -> display +> +> Not sure how to do it on Linux though! +> +> Regards, +> -Robert + +I don't have access to the machine for the next few days due to eh... +let's call it firewall accident ;), but it might very well be that it +was off on the x4100 (I know it's on the smaller Linux box). + +That together with the bad default sync method can definitely explain +the strangely slow out of box performance I got. + +So thanks again for explaining this to me :) + +Bye, Chris. + + + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 16:46:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E4A1811F6D3F + for ; + Fri, 7 Apr 2006 16:46:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00938-09-2 + for ; + Fri, 7 Apr 2006 16:46:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (213-2-2-26.uk.vianw.net [213.2.2.26]) + by postgresql.org (Postfix) with ESMTP id 18ACA11F6D4A + for ; + Fri, 7 Apr 2006 16:46:27 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id 73A601376B4 + for ; + Fri, 7 Apr 2006 20:45:30 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id 3C08313768C + for ; + Fri, 7 Apr 2006 20:45:30 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id 594C075FE5 + for ; + Fri, 7 Apr 2006 20:45:32 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id 4987675CA6 + for ; + Fri, 7 Apr 2006 20:45:32 +0100 (BST) +Date: Fri, 7 Apr 2006 20:45:26 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +Message-Id: <20060407204526.197afc19.gdh@laterooms.com> +In-Reply-To: <15233.1144435299@sss.pgh.pa.us> +References: <20060407185823.abe93017.gdh@laterooms.com> + <15233.1144435299@sss.pgh.pa.us> +X-Mailer: Sylpheed version 2.1.1 (GTK+ 2.8.6; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +X-Spam-Score: 0.08 +X-Spam-Level: +X-Archive-Number: 200604/149 +X-Sequence-Number: 18233 + +On Fri, 07 Apr 2006 14:41:39 -0400 +Tom Lane wrote: + +> Gavin Hamill writes: +> > OK, having moved from our quad-xeon to an 8-CPU IBM pSeries 650 +> > (8x1.45GHz POWER4 instead of 4 x 3GHz Xeon), our query times have shot +> > up and our website is next to unusable. The IBM is not swapping (not +> > with 16GB of RAM!), disk i/o is low, but there must be something +> > critically wrong for this monster to be performing so badly.. +> +> Have you vacuumed/analyzed since reloading your data? + +Absolutely - a VACUUM FULL was the first thing I did, and have VACUUM ANALYZE VERBOSE'd a couple of times since. I have plenty of overhead to keep the entire free space map in RAM. + +> Compare some +> EXPLAIN ANALYZE outputs for identical queries on the two machines, +> that usually helps figure out what's wrong. + +If only :) + +Since 90% of the db work is the 'hotelsearch' function (which is 350 lines-worth that I'm not permitted to share :(( ), an EXPLAIN ANALYZE reveals practically nothing: + +##### jalapeno (IBM) +laterooms=# EXPLAIN ANALYZE select * from hotelsearch(12.48333::numeric, 41.90000::numeric, 5::int4, '2006-04-13'::date, 5::int4, NULL::int4, 1::int4, NULL::int4, NULL::int4, TRUE::bool, FALSE::bool, FALSE::bool, 1::int2, 'GBP'::text, 'Roma'::text, 7::int4, NULL::int4, NULL::int4) limit 500; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..6.25 rows=500 width=1587) (actual time=2922.282..2922.908 rows=255 loops=1) + -> Function Scan on hotelsearch (cost=0.00..12.50 rows=1000 width=1587) (actual time=2922.277..2922.494 rows=255 loops=1) + Total runtime: 2923.296 ms +(3 rows) + +##### cayenne (xeon) +laterooms=# EXPLAIN ANALYZE select * from hotelsearch(12.48333::numeric, 41.90000::numeric, 5::int4, '2006-04-13'::date, 5::int4, NULL::int4, 1::int4, NULL::int4, NULL::int4, TRUE::bool, FALSE::bool, FALSE::bool, 1::int2, 'GBP'::text, 'Roma'::text, 7::int4, NULL::int4, NULL::int4) limit 500; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..6.25 rows=500 width=1587) (actual time=1929.483..1930.103 rows=255 loops=1) + -> Function Scan on hotelsearch (cost=0.00..12.50 rows=1000 width=1587) (actual time=1929.479..1929.693 rows=255 loops=1) + Total runtime: 1930.506 ms +(3 rows) + + +The 'LIMIT 500' is a red herring since the function body will get all data, so reducing the LIMIT in the call to hotelsearch doesn't reduce the amount of work being done. + +The killer in it all is tail'ing the postgres log (which I have set only to log queries at 1000ms or up) is things will be returning at 1000-2000ms.. then suddenly shoot up to 8000ms.. and if I try a few of those 8000ms queries on the xeon box, they exec in ~1500ms.. and if I try them again a few moments later on the ibm, they'll also exec in maybe ~2500ms. + +This is one hell of a moving target and I can't help but think I'm just missing something that's right in front of my nose, too close to see. + +Cheers, +Gavin. + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 16:59:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 232A111F66CE + for ; + Fri, 7 Apr 2006 16:59:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21878-09 + for ; + Fri, 7 Apr 2006 16:59:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (213-2-2-26.uk.vianw.net [213.2.2.26]) + by postgresql.org (Postfix) with ESMTP id 9D4E811F61E0 + for ; + Fri, 7 Apr 2006 16:59:23 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id 405511376AF + for ; + Fri, 7 Apr 2006 20:59:23 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id 05CEF13768E + for ; + Fri, 7 Apr 2006 20:59:23 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id 3268B75FE5 + for ; + Fri, 7 Apr 2006 20:59:25 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id 22AC375F8D + for ; + Fri, 7 Apr 2006 20:59:25 +0100 (BST) +Date: Fri, 7 Apr 2006 20:59:19 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +Message-Id: <20060407205919.a091da26.gdh@laterooms.com> +In-Reply-To: <1144436060.32269.13.camel@state.g2switchworks.com> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> +X-Mailer: Sylpheed version 2.1.1 (GTK+ 2.8.6; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +X-Spam-Score: 0.096 +X-Spam-Level: +X-Archive-Number: 200604/150 +X-Sequence-Number: 18234 + +On Fri, 07 Apr 2006 13:54:21 -0500 +Scott Marlowe wrote: + +> Are the same queries getting the same basic execution plan on both +> boxes? Turn on logging for slow queries, and explain analyze them on +> both machines to see if they are. + +See reply to Tom Lane :) + +> I'd put the old 4 way Xeon back in production and do some serious +> testing of this pSeries machine. IBM should be willing to help you, I +> hope. + +They probably would if this had been bought new - as it is, we have +rented the machine for a month from a 2nd-user dealer to see if it's +capable of taking the load. I'm now glad we did this. + +> My guess is that this is an OS issue. Maybe there are AIX tweaks that +> will get it up to the same or higher level of performance as your four +> way xeon. Maybe there aren't. + +The pSeries isn't much older than our Xeon machine, and I expected the +performance level to be exemplary out of the box.. we've enabled the +64-bit kernel+userspace, and compiled pg for 64-bitness with the gcc +flags as reccommended by Senica Cunningham on this very list.. + +> Myself, I'd throw a spare drive in for the OS, put some flavor of +> linux on it + +Terrifying given I know nothing about the pSeries boot system, but at +this stage I'm game for nearly anything. + +> http://www.asaservers.com/system_dept.asp?dept_id=SD-002 + +Multi-Opteron was the other thing we considered but decided to give +'Big Iron' UNIX a whirl... + +Cheers, +Gavin. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 17:06:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 54F2911F6797 + for ; + Fri, 7 Apr 2006 17:06:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24992-06 + for ; + Fri, 7 Apr 2006 17:06:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 7592411F6780 + for ; + Fri, 7 Apr 2006 17:06:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37K62Z0015773; + Fri, 7 Apr 2006 16:06:02 -0400 (EDT) +To: Gavin Hamill +cc: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +In-reply-to: <20060407205919.a091da26.gdh@laterooms.com> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> +Comments: In-reply-to Gavin Hamill + message dated "Fri, 07 Apr 2006 20:59:19 +0100" +Date: Fri, 07 Apr 2006 16:06:02 -0400 +Message-ID: <15772.1144440362@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.13 required=5 tests=[AWL=0.130] +X-Spam-Score: 0.13 +X-Spam-Level: +X-Archive-Number: 200604/151 +X-Sequence-Number: 18235 + +Gavin Hamill writes: +> Scott Marlowe wrote: +>> My guess is that this is an OS issue. Maybe there are AIX tweaks that +>> will get it up to the same or higher level of performance as your four +>> way xeon. Maybe there aren't. + +> The pSeries isn't much older than our Xeon machine, and I expected the +> performance level to be exemplary out of the box.. + +I'm fairly surprised too. One thing I note from your comparison of +settings is that the default WAL sync method is different on the two +operating systems. If the query load is update-heavy then it would be +very worth your while to experiment with the sync method. However, +if the bottleneck is pure-SELECT transactions then WAL sync should not +be a factor at all. + +Does AIX have anything comparable to oprofile or dtrace? It'd be +interesting to try to monitor things at that level and see what we can +learn. Failing a low-level profiler, there should at least be something +comparable to strace --- you should try watching some of the backends +with strace and see what their behavior is when the performance goes +south. Lots of delaying select()s or semop()s would be a red flag. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 17:16:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 41BB511F6AC0 + for ; + Fri, 7 Apr 2006 17:16:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26519-08 + for ; + Fri, 7 Apr 2006 17:16:10 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 83AA811F66D9 + for ; + Fri, 7 Apr 2006 17:16:12 -0300 (ADT) +Received: from druid.net (druid.net [66.96.28.249]) + by svr4.postgresql.org (Postfix) with ESMTP id 8D7FA5AF968 + for ; + Fri, 7 Apr 2006 20:16:12 +0000 (GMT) +Received: from dilbert (H245.C18.B96.tor.eicat.ca [66.96.18.245]) + by druid.net (Postfix) with SMTP id 78183B4B2; + Fri, 7 Apr 2006 16:16:04 -0400 (EDT) +Date: Fri, 7 Apr 2006 16:16:02 -0400 +From: "D'Arcy J.M. Cain" +To: Gavin Hamill +Cc: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +Message-Id: <20060407161602.7ed5f672.darcy@druid.net> +In-Reply-To: <20060407205919.a091da26.gdh@laterooms.com> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> +X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.12; i386--netbsdelf) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/152 +X-Sequence-Number: 18236 + +On Fri, 7 Apr 2006 20:59:19 +0100 +Gavin Hamill wrote: +> > I'd put the old 4 way Xeon back in production and do some serious +> > testing of this pSeries machine. IBM should be willing to help you, I +> > hope. +> +> They probably would if this had been bought new - as it is, we have +> rented the machine for a month from a 2nd-user dealer to see if it's +> capable of taking the load. I'm now glad we did this. + +We also had problems with a high end AIX system and we got no help from +IBM. They expected you to put Oracle on and if you used anything else +you were on your own. We had exactly the same issue. We expected to +get an order of magnitude improvement and instead the app bogged down. +It also got worse over time. We had to reboot every night to get +anything out of it. Needless to say, they got their system back. + +> +> > My guess is that this is an OS issue. Maybe there are AIX tweaks that +> > will get it up to the same or higher level of performance as your four +> > way xeon. Maybe there aren't. +> +> The pSeries isn't much older than our Xeon machine, and I expected the +> performance level to be exemplary out of the box.. we've enabled the +> 64-bit kernel+userspace, and compiled pg for 64-bitness with the gcc +> flags as reccommended by Senica Cunningham on this very list.. + +That's Seneca. + +We found that our money was better spent on multiple servers running +NetBSD with a home grown multi-master replication system. Need more +power? Just add more servers. + +-- +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 Fri Apr 7 17:24:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9A7E711F6600 + for ; + Fri, 7 Apr 2006 17:24:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34745-05 + for ; + Fri, 7 Apr 2006 17:24:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id CA16411F61E0 + for ; + Fri, 7 Apr 2006 17:24:18 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 7 Apr 2006 20:24:18 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 07 Apr 2006 15:24:18 -0500 +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +From: Scott Marlowe +To: Gavin Hamill +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060407205919.a091da26.gdh@laterooms.com> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1144441457.32269.29.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 07 Apr 2006 15:24:18 -0500 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.1 required=5 tests=[AWL=0.099, + UNPARSEABLE_RELAY=0.001] +X-Spam-Score: 0.1 +X-Spam-Level: +X-Archive-Number: 200604/153 +X-Sequence-Number: 18237 + +On Fri, 2006-04-07 at 14:59, Gavin Hamill wrote: +> On Fri, 07 Apr 2006 13:54:21 -0500 +> Scott Marlowe wrote: +> +> > Are the same queries getting the same basic execution plan on both +> > boxes? Turn on logging for slow queries, and explain analyze them on +> > both machines to see if they are. +> +> See reply to Tom Lane :) + +I didn't see one go by yet... Could be sitting in the queue. + +> They probably would if this had been bought new - as it is, we have +> rented the machine for a month from a 2nd-user dealer to see if it's +> capable of taking the load. I'm now glad we did this. + +Thank god. I had a picture of you sitting on top of a brand new very +expensive pSeries + +Let us know if changing the fsync setting helps. Hopefully that's all +the problem is. + +Off on a tangent. If the aggregate memory bandwidth of the pSeries is +no greater than you Xeon you might not see a big improvement if you were +memory bound before. If you were CPU bound, you may or may not see an +improvement. + +Can you describe the disc subsystems in the two machines for us? What +kind of read / write load you have? It could be the older box was +running on IDE drives with fake fsync responses which would lie, be +fast, but not reliable in case of a power outage. + +Do you have hardware RAID for your pSeries? how many discs, how much +battery backed cache, etc? + +> Multi-Opteron was the other thing we considered but decided to give +> 'Big Iron' UNIX a whirl... + +It still might be a good choice, if it's a simple misconfiguration +issue. + +But man, those new multiple core opterons can make some impressive +machines for very little money. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 17:30:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A77AA11F6716 + for ; + Fri, 7 Apr 2006 17:30:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35705-04 + for ; + Fri, 7 Apr 2006 17:30:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id BC13C11F66BA + for ; + Fri, 7 Apr 2006 17:30:20 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FRxax-0006lW-00; Fri, 07 Apr 2006 16:30:15 -0400 +To: Gavin Hamill +Cc: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +References: <20060407185823.abe93017.gdh@laterooms.com> + <15233.1144435299@sss.pgh.pa.us> + <20060407204526.197afc19.gdh@laterooms.com> +In-Reply-To: <20060407204526.197afc19.gdh@laterooms.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 07 Apr 2006 16:30:15 -0400 +Message-ID: <871ww9m8mg.fsf@stark.xeocode.com> +Lines: 20 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/154 +X-Sequence-Number: 18238 + + +Gavin Hamill writes: + +> This is one hell of a moving target and I can't help but think I'm just +> missing something that's right in front of my nose, too close to see. + +I'm assuming you compiled postgres yourself? Do you have the output from the +configure script? I'm wondering if it failed to find a good spinlock match for +the architecture. Not sure if that's really likely but it's a possibility. + +Also, I'm pretty sure IBM has tools that would let you disable some of the +processors to see if maybe it's a shared memory bus issue. If I understand you +right the machine isn't in production yet? In which case I would get timing +information for a single processor, two processors, four processors, and eight +processors. If you see it max out and start dropping then that would point +towards a hardware/low level postgres issue like spinlocks or shared memory +rather than a high level database issue like stats. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 17:39:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F2E2811F61E0 + for ; + Fri, 7 Apr 2006 17:39:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38110-09 + for ; + Fri, 7 Apr 2006 17:39:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smarty.gabriel.co.hu (smarty.gabriel.co.hu [195.70.37.16]) + by postgresql.org (Postfix) with ESMTP id 469EF11F6026 + for ; + Fri, 7 Apr 2006 17:39:47 -0300 (ADT) +Received: from localhost (smarty [127.0.0.1]) + by smarty.gabriel.co.hu (Postfix) with ESMTP id D72F142BB2; + Fri, 7 Apr 2006 22:39:41 +0200 (CEST) +Received: from smarty.gabriel.co.hu ([127.0.0.1]) + by localhost (smarty [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 25637-03; Fri, 7 Apr 2006 22:39:41 +0200 (CEST) +Received: from [192.168.100.182] (catv-5062cfe4.catv.broadband.hu + [80.98.207.228]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by smarty.gabriel.co.hu (Postfix) with ESMTP id AEE7042BAF; + Fri, 7 Apr 2006 22:39:41 +0200 (CEST) +Message-ID: <4436CE0D.6010702@i-logic.hu> +Date: Fri, 07 Apr 2006 22:39:41 +0200 +From: =?ISO-8859-1?Q?G=E1briel_=C1kos?= +Organization: I-Logic Kft +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Gavin Hamill +Cc: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +References: <20060407185823.abe93017.gdh@laterooms.com> +In-Reply-To: <20060407185823.abe93017.gdh@laterooms.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at gabriel.co.hu +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0 required=5 tests=[none] +X-Spam-Score: 0 +X-Spam-Level: +X-Archive-Number: 200604/155 +X-Sequence-Number: 18239 + +Gavin Hamill wrote: +> Bing-bong, passenger announcement.. the panic train is now pulling into +> platform 8.1.3. Bing-bong. =) +> +> OK, having moved from our quad-xeon to an 8-CPU IBM pSeries 650 +> (8x1.45GHz POWER4 instead of 4 x 3GHz Xeon), our query times have shot +> up and our website is next to unusable. The IBM is not swapping (not + +I would say running _one_ query at a time depends on the power of _one_ +cpu. PPCs aren't that fast, I'd say they are slower than Xeons. Moreover +I'm sure that AMD Opterons are faster than Xeons. I'd say you should go +and test an opteron-based configuration. You'll get much more power for +the same (much likely for less) money. + + +-- +�dv�zlettel, +G�briel �kos +-=E-Mail :akos.gabriel@i-logic.hu|Web: http://www.i-logic.hu=- +-=Tel/fax:+3612367353 |Mobil:+36209278894 =- + +From pgsql-performance-owner@postgresql.org Fri Apr 7 18:19:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id EAA8C11F60AF + for ; + Fri, 7 Apr 2006 18:19:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44622-09 + for ; + Fri, 7 Apr 2006 18:19:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (213-2-2-26.uk.vianw.net [213.2.2.26]) + by postgresql.org (Postfix) with ESMTP id 6DBA211F6026 + for ; + Fri, 7 Apr 2006 18:19:39 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id E94B9137594 + for ; + Fri, 7 Apr 2006 22:19:37 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id CF91C136CD9 + for ; + Fri, 7 Apr 2006 22:19:37 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id 3E48275FE5 + for ; + Fri, 7 Apr 2006 22:19:40 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id 2C1EA75D0A + for ; + Fri, 7 Apr 2006 22:19:40 +0100 (BST) +Date: Fri, 7 Apr 2006 22:19:34 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +Message-Id: <20060407221934.67cc2227.gdh@laterooms.com> +In-Reply-To: <20060407161602.7ed5f672.darcy@druid.net> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> + <20060407161602.7ed5f672.darcy@druid.net> +X-Mailer: Sylpheed version 2.1.1 (GTK+ 2.8.6; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +X-Spam-Score: 0.09 +X-Spam-Level: +X-Archive-Number: 200604/156 +X-Sequence-Number: 18240 + +On Fri, 7 Apr 2006 16:16:02 -0400 +"D'Arcy J.M. Cain" wrote: + +> We also had problems with a high end AIX system and we got no help +> from IBM. They expected you to put Oracle on and if you used +> anything else you were on your own. + +Urk, I thought IBM were supposedly Linux sycophants thesedays... + +> We had exactly the same issue. +> We expected to get an order of magnitude improvement and instead the +> app bogged down. + +That's kind of encouraging, I suppose - that it might not be something +mind-bogglingly stupid I'm doing. + +> It also got worse over time. We had to reboot every +> night to get anything out of it. Needless to say, they got their +> system back. + + + +> That's Seneca. + +Oops - meant to check the spelling before I sent that =) + +> We found that our money was better spent on multiple servers running +> NetBSD with a home grown multi-master replication system. Need more +> power? Just add more servers. + +Aye, I originally suggested multiple servers, but was talked round to +one giant db so that our devels didn't have to rewrite code to deal +with read/write + read-only db handles... + +Cheers, +Gavin. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 18:26:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 33DC811F65C0 + for ; + Fri, 7 Apr 2006 18:26:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54408-03-3 + for ; + Fri, 7 Apr 2006 18:25:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (213-2-2-26.uk.vianw.net [213.2.2.26]) + by postgresql.org (Postfix) with ESMTP id B6FC911F719C + for ; + Fri, 7 Apr 2006 18:25:54 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id A784713768F + for ; + Fri, 7 Apr 2006 22:24:47 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id 81883137666 + for ; + Fri, 7 Apr 2006 22:24:47 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id B42C775FE5 + for ; + Fri, 7 Apr 2006 22:24:49 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id 9A72A75D0A + for ; + Fri, 7 Apr 2006 22:24:49 +0100 (BST) +Date: Fri, 7 Apr 2006 22:24:43 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +Message-Id: <20060407222443.97ddf152.gdh@laterooms.com> +In-Reply-To: <1144441457.32269.29.camel@state.g2switchworks.com> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> + <1144441457.32269.29.camel@state.g2switchworks.com> +X-Mailer: Sylpheed version 2.1.1 (GTK+ 2.8.6; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +X-Spam-Score: 0.096 +X-Spam-Level: +X-Archive-Number: 200604/157 +X-Sequence-Number: 18241 + +On Fri, 07 Apr 2006 15:24:18 -0500 +Scott Marlowe wrote: + +> > See reply to Tom Lane :) +> +> I didn't see one go by yet... Could be sitting in the queue. + +If it's not arrived by now - EXPLAIN ANALYZE doesn't tell me +anything :) + +> Let us know if changing the fsync setting helps. Hopefully that's all +> the problem is. + +fsync's already off - yes a bit scary, but our I/O is only about +500KB/sec writing.. the whole db fits in RAM / kernel disk cache, and +I'd rather have performance than security at this exact moment.. + +> Off on a tangent. If the aggregate memory bandwidth of the pSeries is +> no greater than you Xeon you might not see a big improvement if you +> were memory bound before. If you were CPU bound, you may or may not +> see an improvement. + +I did look into the specs of the system, and the memory bw on the +pSeries was /much/ greater than the Xeon - it's one of the things that +really pushed me towards it in the end. I forget the figures, but it +was 3 or 4 times greater. + +> Can you describe the disc subsystems in the two machines for us? What +> kind of read / write load you have? It could be the older box was +> running on IDE drives with fake fsync responses which would lie, be +> fast, but not reliable in case of a power outage. + +Again, I'm confident that I/O's not the killer here.. the Xeon is a Dell +6850- hardware RAID1.. SCSI drives. + +> > Multi-Opteron was the other thing we considered but decided to give +> > 'Big Iron' UNIX a whirl... +> +> It still might be a good choice, if it's a simple misconfiguration +> issue. +> +> But man, those new multiple core opterons can make some impressive +> machines for very little money. + +So I see - we could buy two quad-opterons for the cost of renting this +pSeries for a month.... + +Cheers, +Gavin. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 18:36:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5524E11F663A + for ; + Fri, 7 Apr 2006 18:36:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97964-03 + for ; + Fri, 7 Apr 2006 18:36:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (213-2-2-26.uk.vianw.net [213.2.2.26]) + by postgresql.org (Postfix) with ESMTP id 6E4E211F60AF + for ; + Fri, 7 Apr 2006 18:36:39 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id 2D7A4137666 + for ; + Fri, 7 Apr 2006 22:36:39 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id 0F20C136CD9 + for ; + Fri, 7 Apr 2006 22:36:39 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id 7F54D75FE5 + for ; + Fri, 7 Apr 2006 22:36:41 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id 64E5975F8D + for ; + Fri, 7 Apr 2006 22:36:41 +0100 (BST) +Date: Fri, 7 Apr 2006 22:36:35 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +Message-Id: <20060407223635.9c4a0b38.gdh@laterooms.com> +In-Reply-To: <15772.1144440362@sss.pgh.pa.us> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> + <15772.1144440362@sss.pgh.pa.us> +X-Mailer: Sylpheed version 2.1.1 (GTK+ 2.8.6; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.1 required=5 tests=[AWL=0.100] +X-Spam-Score: 0.1 +X-Spam-Level: +X-Archive-Number: 200604/158 +X-Sequence-Number: 18242 + +On Fri, 07 Apr 2006 16:06:02 -0400 +Tom Lane wrote: + +> > The pSeries isn't much older than our Xeon machine, and I expected +> > the performance level to be exemplary out of the box.. +>=20 +> I'm fairly surprised too. One thing I note from your comparison of +> settings is that the default WAL sync method is different on the two +> operating systems. =20 + +We're very read-focussed.. there's update activity, sure, but the IO is +only pushing about 500KByte/sec on average, usually much less. I also +have fsync switched off - yes dangerous, but I just want to eliminate +IO completely as a contributing factor. + +> Does AIX have anything comparable to oprofile or dtrace? =20 + +I've used neither on Linux, but a quick google showed up a few articles +along the lines of 'in theory it shouldn't be hard to port to AIX....' +but nothing concrete. My guess is IBM sell a tool to do this. Hell, the +C++ compiler is =A31200... (hence our use of GCC 4.1 to compile pg) + + +> Failing a low-level profiler, there should at least be +> something comparable to strace --- you should try watching some of +> the backends with strace and see what their behavior is when the +> performance goes south. Lots of delaying select()s or semop()s would +> be a red flag. + +There's truss installed which seems to do the same as strace on +Linux... and here's a wildly non-scientific glance.. I watched the +'topas' output (top for AIX) , identified a PID that was doing a lot of +work, then attached truss to that pid. In addition to lots of send +(), recv() and lseek()s... about once a minute I saw hundreds of calls +to __semop() interspersed with _select(), followed by tons of lseek() ++kread()+__semop() and then I can see the kwrite() to the pg logfile + +246170: kwrite(2, " L O G : d u", 8) =3D 8 etc. + +Cheers, +Gavin. + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 18:50:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BAA1711F65E7 + for ; + Fri, 7 Apr 2006 18:50:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18155-10 + for ; + Fri, 7 Apr 2006 18:50:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id 8331311F65DD + for ; + Fri, 7 Apr 2006 18:50:44 -0300 (ADT) +Received: from 172.16.1.112 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Fri, 07 Apr 2006 17:50:34 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 7 Apr + 2006 17:50:33 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Fri, 7 Apr + 2006 21:50:33 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Fri, 07 Apr 2006 14:50:31 -0700 +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +From: "Luke Lonergan" +To: "Gavin Hamill" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] pg 8.1.3, AIX, huge box, painfully slow. +Thread-Index: AcZaifwE0OTb6cNaQtWkMccKrQ69PwAA05Gr +In-Reply-To: <20060407222443.97ddf152.gdh@laterooms.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 07 Apr 2006 21:50:33.0746 (UTC) + FILETIME=[4BEEAF20:01C65A8D] +X-WSS-ID: 682801202XS41658529-01-01 +Content-Type: multipart/alternative; + boundary=B_3227266232_639298 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.254 required=5 tests=[HTML_MESSAGE=0.001, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.254 +X-Spam-Level: * +X-Archive-Number: 200604/159 +X-Sequence-Number: 18243 + +> This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--B_3227266232_639298 +Content-Type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + +Gavin, + +On 4/7/06 2:24 PM, "Gavin Hamill" wrote: + +> I did look into the specs of the system, and the memory bw on the +> pSeries was /much/ greater than the Xeon - it's one of the things that +> really pushed me towards it in the end. I forget the figures, but it +> was 3 or 4 times greater. + + From the literature at: + =20 +http://www-03.ibm.com/servers/eserver/pseries/hardware/midrange/p650_desc.h= +t +ml + +=B3The pSeries 650 features a peak aggregate memory to L3 cache bandwidth of +25.6GB/second for an 8way configuration. In addition, aggregate I/O +bandwidth is up to 16GB/second. The result is a remarkable combination of +system architecture, speed and power that delivers efficient and +cost-effective data sharing and application throughput.=B2 + +That=B9s a total of 25.6GB/s for 8 CPUs, or 3.2GB/s per CPU. 3GHz P4 Xeons +typically have an 800MHz memory bus with double the speed at 6.4GB/s result +(800MHz x 8 bytes per L2 cache line =3D 6.4GB/s). Furthermore, the speed at +which the P4 Xeon can load data into L2 cache from memory is matched to the +bus because the L2 cache line width is 8 bytes wide and can stream data to +L2 at full bus speed. + +That said, I find typical memory bandwidth for the P4 in applications is +limited at about 2GB/s. See here for more detail: +http://www.cs.virginia.edu/stream/standard/Bandwidth.html + +In fact, looking at the results there, the IBM 650m2 only gets 6GB/s on all +8 CPUs. I wouldn=B9t be surprised if the strange L3 cache architecture of th= +e +IBM 650 is holding it back from streaming memory access efficiently. + +Whether this has anything to do with your problem or not, I have no idea! + +- Luke + +--B_3227266232_639298 +Content-Type: text/html; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + +Re: [PERFORM] pg 8.1.3, AIX, huge box, painfully slow. + + +Gavin= +,
+
+On 4/7/06 2:24 PM, "Gavin Hamill" <gdh@laterooms.com> wrote= +:
+
+> I did look into the specs of the system, and the= + memory bw on the
+> pSeries was /much/ greater than the Xeon - it's one of the things that= +
+> really pushed me towards it in the end. I forget the figures, but it +> was 3 or 4 times greater.
+

+ From the literature at:
+  http://www-03.ibm.com/servers/eserver/pseries/hard= +ware/midrange/p650_desc.html
+
+“The pSeries 650 features a peak aggregate memory to L3 cache bandwid= +th of 25.6GB/second for an 8way configuration. In addition, aggregate I/O ba= +ndwidth is up to 16GB/second. The result is a remarkable combination of syst= +em architecture, speed and power that delivers efficient and cost-effective = +data sharing and application throughput.”
+
+That’s a total of 25.6GB/s for 8 CPUs, or 3.2GB/s per CPU.  3GHz= + P4 Xeons typically have an 800MHz memory bus with double the speed at 6.4GB= +/s result (800MHz x 8 bytes per L2 cache line =3D 6.4GB/s).  Furthermore,= + the speed at which the P4 Xeon can load data into L2 cache from memory is m= +atched to the bus because the L2 cache line width is 8 bytes wide and can st= +ream data to L2 at full bus speed.
+
+That said, I find typical memory bandwidth for the P4 in applications is li= +mited at about 2GB/s.  See here for more detail: http://www.cs.virginia.edu/str= +eam/standard/Bandwidth.html
+
+In fact, looking at the results there, the IBM 650m2 only gets 6GB/s on all= + 8 CPUs.  I wouldn’t be surprised if the strange L3 cache archite= +cture of the IBM 650 is holding it back from streaming memory access efficie= +ntly.
+
+Whether this has anything to do with your problem or not, I have no = +idea!
+
+- Luke
+ + + + +--B_3227266232_639298-- + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 18:56:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0D2C911F676E + for ; + Fri, 7 Apr 2006 18:56:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19822-07 + for ; + Fri, 7 Apr 2006 18:56:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 59EC011F676D + for ; + Fri, 7 Apr 2006 18:56:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37Lunka017056; + Fri, 7 Apr 2006 17:56:49 -0400 (EDT) +To: Gavin Hamill +cc: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +In-reply-to: <20060407223635.9c4a0b38.gdh@laterooms.com> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> + <15772.1144440362@sss.pgh.pa.us> + <20060407223635.9c4a0b38.gdh@laterooms.com> +Comments: In-reply-to Gavin Hamill + message dated "Fri, 07 Apr 2006 22:36:35 +0100" +Date: Fri, 07 Apr 2006 17:56:49 -0400 +Message-ID: <17055.1144447009@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.13 required=5 tests=[AWL=0.130] +X-Spam-Score: 0.13 +X-Spam-Level: +X-Archive-Number: 200604/160 +X-Sequence-Number: 18244 + +Gavin Hamill writes: +> There's truss installed which seems to do the same as strace on +> Linux... and here's a wildly non-scientific glance.. I watched the +> 'topas' output (top for AIX) , identified a PID that was doing a lot of +> work, then attached truss to that pid. In addition to lots of send +> (), recv() and lseek()s... + +Those are good, they represent real work getting done. + +> about once a minute I saw hundreds of calls +> to __semop() interspersed with _select(), + +This is not good. Did the semop storms coincide with visible slowdown? +(I'd assume so, but you didn't actually say...) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 19:03:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B1C2311F65EA + for ; + Fri, 7 Apr 2006 19:03:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18365-09 + for ; + Fri, 7 Apr 2006 19:02:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 7730D11F65DD + for ; + Fri, 7 Apr 2006 19:02:59 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37M2tBL017109; + Fri, 7 Apr 2006 18:02:55 -0400 (EDT) +To: "Luke Lonergan" +cc: "Gavin Hamill" , pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +In-reply-to: +References: +Comments: In-reply-to "Luke Lonergan" + message dated "Fri, 07 Apr 2006 14:50:31 -0700" +Date: Fri, 07 Apr 2006 18:02:55 -0400 +Message-ID: <17108.1144447375@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.129 required=5 tests=[AWL=0.129] +X-Spam-Score: 0.129 +X-Spam-Level: +X-Archive-Number: 200604/161 +X-Sequence-Number: 18245 + +"Luke Lonergan" writes: +> That said, I find typical memory bandwidth for the P4 in applications is +> limited at about 2GB/s. See here for more detail: +> http://www.cs.virginia.edu/stream/standard/Bandwidth.html + +> In fact, looking at the results there, the IBM 650m2 only gets 6GB/s +> on all 8 CPUs. I wouldn't be surprised if the strange L3 cache +> architecture of the IBM 650 is holding it back from streaming memory +> access efficiently. + +Given Gavin's latest report, I'm wondering how much the IBM slows down +when a spinlock operation is involved. If the memory architecture isn't +good about supporting serialized access to memory, that gaudy sounding +bandwidth number might have little to do with PG's real-world behavior. +On the other hand, we already know that Xeons suck about as badly as +can be on that same measure; could the pSeries really be worse? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 19:07:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 863E611F67D7 + for ; + Fri, 7 Apr 2006 19:07:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69122-09 + for ; + Fri, 7 Apr 2006 19:06:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by postgresql.org (Postfix) with ESMTP id 78DCE11F6600 + for ; + Fri, 7 Apr 2006 19:07:01 -0300 (ADT) +Received: from 172.16.1.112 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Fri, 07 Apr 2006 18:06:50 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 7 Apr + 2006 18:06:50 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Fri, 7 Apr + 2006 22:06:49 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Fri, 07 Apr 2006 15:06:48 -0700 +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +From: "Luke Lonergan" +To: "Tom Lane" +cc: "Gavin Hamill" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] pg 8.1.3, AIX, huge box, painfully slow. +Thread-Index: AcZajwsQfQ1WAzPERHapihmxjFBp9gAAIWT7 +In-Reply-To: <17108.1144447375@sss.pgh.pa.us> +MIME-Version: 1.0 +X-OriginalArrivalTime: 07 Apr 2006 22:06:50.0321 (UTC) + FILETIME=[92043410:01C65A8F] +X-WSS-ID: 68283DF020C40930198-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.333 required=5 tests=[AWL=0.080, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.333 +X-Spam-Level: * +X-Archive-Number: 200604/162 +X-Sequence-Number: 18246 + +Tom, + +On 4/7/06 3:02 PM, "Tom Lane" wrote: + +> On the other hand, we already know that Xeons suck about as badly as +> can be on that same measure; could the pSeries really be worse? + +I wouldn't be too surprised, but it sounds like it needs a test. Do we have +a test for this? Is there a contention-prone query stream that we can think +up? + +- Luke + + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 19:12:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2E67911F678F + for ; + Fri, 7 Apr 2006 19:12:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83914-02 + for ; + Fri, 7 Apr 2006 19:12:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 9BE3811F66BA + for ; + Fri, 7 Apr 2006 19:12:42 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37MCdqU017238; + Fri, 7 Apr 2006 18:12:39 -0400 (EDT) +To: "Luke Lonergan" +cc: "Gavin Hamill" , pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +In-reply-to: +References: +Comments: In-reply-to "Luke Lonergan" + message dated "Fri, 07 Apr 2006 15:06:48 -0700" +Date: Fri, 07 Apr 2006 18:12:39 -0400 +Message-ID: <17237.1144447959@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.129 required=5 tests=[AWL=0.129] +X-Spam-Score: 0.129 +X-Spam-Level: +X-Archive-Number: 200604/163 +X-Sequence-Number: 18247 + +"Luke Lonergan" writes: +> On 4/7/06 3:02 PM, "Tom Lane" wrote: +>> On the other hand, we already know that Xeons suck about as badly as +>> can be on that same measure; could the pSeries really be worse? + +> I wouldn't be too surprised, but it sounds like it needs a test. Do we have +> a test for this? Is there a contention-prone query stream that we can think +> up? + +If you want you could install a pre-8.1 PG and then try one of the +queries that we were using as test cases a year ago for spinlock +investigations. I don't recall details right now but I remember +having posted a pretty trivial test case that would send a +multiprocessor machine into context-swap storm, which sounds a whole +lot like what Gavin is seeing. + +I think that 8.1 ought to be relatively free of buffer-manager spinlock +contention, which is why I doubt that test case would be interesting +against 8.1. The interesting question is what else is he seeing +contention for, if it's not the BufMgrLock? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 19:28:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8497611F66F4 + for ; + Fri, 7 Apr 2006 19:28:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83955-09 + for ; + Fri, 7 Apr 2006 19:28:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (213-2-2-26.uk.vianw.net [213.2.2.26]) + by postgresql.org (Postfix) with ESMTP id 6912611F66D9 + for ; + Fri, 7 Apr 2006 19:28:03 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id BE9CC137692 + for ; + Fri, 7 Apr 2006 23:28:03 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id 9E49C136CD9 + for ; + Fri, 7 Apr 2006 23:28:03 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id 353B475FE5 + for ; + Fri, 7 Apr 2006 23:28:06 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id 033F075F8D + for ; + Fri, 7 Apr 2006 23:28:05 +0100 (BST) +Date: Fri, 7 Apr 2006 23:27:59 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +Message-Id: <20060407232759.45581362.gdh@laterooms.com> +In-Reply-To: <17055.1144447009@sss.pgh.pa.us> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> + <15772.1144440362@sss.pgh.pa.us> + <20060407223635.9c4a0b38.gdh@laterooms.com> + <17055.1144447009@sss.pgh.pa.us> +X-Mailer: Sylpheed version 2.1.1 (GTK+ 2.8.6; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +X-Spam-Score: 0.103 +X-Spam-Level: +X-Archive-Number: 200604/164 +X-Sequence-Number: 18248 + +On Fri, 07 Apr 2006 17:56:49 -0400 +Tom Lane wrote: + +> This is not good. Did the semop storms coincide with visible +> slowdown? (I'd assume so, but you didn't actually say...) + +If I'd been able to tell, then I'd tell you =) I'll have another go... + +Yes, there's a definate correlation here.. I attached truss to the +main postmaster.. + +$ truss -Ff -p 340344 2>&1 | grep semop + +here's a snippet + +278774: __semop(15728650, 0x0FFFFFFFFFFF7E80, 1) = 0 +155712: __semop(15728650, 0x0FFFFFFFFFFF5920, 1) = 0 +278774: __semop(15728649, 0x0FFFFFFFFFFF6F10, 1) +114914: __semop(15728649, 0x0FFFFFFFFFFF6A40, 1) = 0 = 0 +114914: __semop(15728650, 0x0FFFFFFFFFFF61E0, 1) +155712: __semop(15728650, 0x0FFFFFFFFFFF6850, 1) = 0 = 0 +155712: __semop(15728650, 0x0FFFFFFFFFFF6890, 1) = 0 1 +55712: __semop(15728650, 0x0FFFFFFFFFFF5920, 1) +278774: __semop(15728650, 0x0FFFFFFFFFFF6F10, 1) +155712: __semop(15728650, 0x0FFFFFFFFFFF6850, 1) = 0 = 0 +278774: __semop(15728649, 0x0FFFFFFFFFFF7E40, 1) +114914: __semop(15728649, 0x0FFFFFFFFFFF6A80, 1) = 0 = 0 +278774: __semop(15728650, 0x0FFFFFFFFFFF7E80, 1) + +And when I saw a flood of semop's for any particular PID, a second later +in the 'topas' process list would show that PID at a 100% CPU ... + +Most intriguing :) + +Cheers, +Gavin. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 19:52:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 85FFD11F61F4 + for ; + Fri, 7 Apr 2006 19:52:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90511-06 + for ; + Fri, 7 Apr 2006 19:52:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id CD11111F6109 + for ; + Fri, 7 Apr 2006 19:52:22 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37MqKIn017516; + Fri, 7 Apr 2006 18:52:20 -0400 (EDT) +To: Gavin Hamill +cc: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +In-reply-to: <20060407232759.45581362.gdh@laterooms.com> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> + <15772.1144440362@sss.pgh.pa.us> + <20060407223635.9c4a0b38.gdh@laterooms.com> + <17055.1144447009@sss.pgh.pa.us> + <20060407232759.45581362.gdh@laterooms.com> +Comments: In-reply-to Gavin Hamill + message dated "Fri, 07 Apr 2006 23:27:59 +0100" +Date: Fri, 07 Apr 2006 18:52:20 -0400 +Message-ID: <17515.1144450340@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.129 required=5 tests=[AWL=0.129] +X-Spam-Score: 0.129 +X-Spam-Level: +X-Archive-Number: 200604/165 +X-Sequence-Number: 18249 + +Gavin Hamill writes: +> On Fri, 07 Apr 2006 17:56:49 -0400 +> Tom Lane wrote: +>> This is not good. Did the semop storms coincide with visible +>> slowdown? (I'd assume so, but you didn't actually say...) + +> Yes, there's a definate correlation here.. I attached truss to the +> main postmaster.. +> ... +> And when I saw a flood of semop's for any particular PID, a second later +> in the 'topas' process list would show that PID at a 100% CPU ... + +So apparently we've still got a problem with multiprocess contention for +an LWLock somewhere. It's not the BufMgrLock because that's gone in 8.1. +It could be one of the finer-grain locks that are still there, or it +could be someplace else. + +Are you in a position to try your workload using PG CVS tip? There's a +nontrivial possibility that we've already fixed this --- a couple months +ago I did some work to reduce contention in the lock manager: + +2005-12-11 16:02 tgl + + * src/: backend/access/transam/twophase.c, + backend/storage/ipc/procarray.c, backend/storage/lmgr/README, + backend/storage/lmgr/deadlock.c, backend/storage/lmgr/lock.c, + backend/storage/lmgr/lwlock.c, backend/storage/lmgr/proc.c, + include/storage/lock.h, include/storage/lwlock.h, + include/storage/proc.h: Divide the lock manager's shared state into + 'partitions', so as to reduce contention for the former single + LockMgrLock. Per my recent proposal. I set it up for 16 + partitions, but on a pgbench test this gives only a marginal + further improvement over 4 partitions --- we need to test more + scenarios to choose the number of partitions. + +This is unfortunately not going to help you as far as getting that +machine into production now (unless you're brave enough to run CVS tip +as production, which I certainly am not). I'm afraid you're most likely +going to have to ship that pSeries back at the end of the month, but +while you've got it it'd be awfully nice if we could use it as a testbed +... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 19:57:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A75EA11F6600 + for ; + Fri, 7 Apr 2006 19:57:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91020-06 + for ; + Fri, 7 Apr 2006 19:56:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id B16D111F662C + for ; + Fri, 7 Apr 2006 19:56:59 -0300 (ADT) +Received: from 172.16.1.110 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Fri, 07 Apr 2006 18:56:54 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 7 Apr + 2006 18:56:54 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Fri, 7 Apr + 2006 22:56:53 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Fri, 07 Apr 2006 15:56:52 -0700 +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +From: "Luke Lonergan" +To: "Gavin Hamill" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] pg 8.1.3, AIX, huge box, painfully slow. +Thread-Index: AcZakrRRJ4ZxhjkkROWmZZN4c+nUhwAA9rUM +In-Reply-To: <20060407232759.45581362.gdh@laterooms.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 07 Apr 2006 22:56:54.0226 (UTC) + FILETIME=[907BBB20:01C65A96] +X-WSS-ID: 682831BC2XS41684920-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=1.349 required=5 tests=[AWL=0.096, + RCVD_NUMERIC_HELO=1.253] +X-Spam-Score: 1.349 +X-Spam-Level: * +X-Archive-Number: 200604/166 +X-Sequence-Number: 18250 + +Gavin, + +On 4/7/06 3:27 PM, "Gavin Hamill" wrote: + +> 278774: __semop(15728650, 0x0FFFFFFFFFFF7E80, 1) = 0 +> 155712: __semop(15728650, 0x0FFFFFFFFFFF5920, 1) = 0 +> 278774: __semop(15728649, 0x0FFFFFFFFFFF6F10, 1) +> 114914: __semop(15728649, 0x0FFFFFFFFFFF6A40, 1) = 0 = 0 +> 114914: __semop(15728650, 0x0FFFFFFFFFFF61E0, 1) +> 155712: __semop(15728650, 0x0FFFFFFFFFFF6850, 1) = 0 = 0 +> 155712: __semop(15728650, 0x0FFFFFFFFFFF6890, 1) = 0 1 +> 55712: __semop(15728650, 0x0FFFFFFFFFFF5920, 1) +> 278774: __semop(15728650, 0x0FFFFFFFFFFF6F10, 1) +> 155712: __semop(15728650, 0x0FFFFFFFFFFF6850, 1) = 0 = 0 +> 278774: __semop(15728649, 0x0FFFFFFFFFFF7E40, 1) +> 114914: __semop(15728649, 0x0FFFFFFFFFFF6A80, 1) = 0 = 0 +> 278774: __semop(15728650, 0x0FFFFFFFFFFF7E80, 1) + +Seems like you're hitting a very small target in RAM with these semop calls. +I wonder what part of the code is doing this - Tom would know better how to +trace it, but the equivalent of oprofile output would be nice. + +The other thing that I'd like to see is an evaluation of the memory access +latency of this machine from Register to RAM. I couldn't find a +benchmarking tool that was UNIX friendly out there, maybe I'll write one +real quick. I suspect this machine has a heinous latency and a storm of +semops to the same spot of RAM might be a far worse performance problem on +this machine than on others... + +- Luke + + + + + +From pgsql-performance-owner@postgresql.org Fri Apr 7 20:05:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1B9D411F6252 + for ; + Fri, 7 Apr 2006 20:05:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94100-04 + for ; + Fri, 7 Apr 2006 20:05:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id A6F9811F6AFF + for ; + Fri, 7 Apr 2006 20:05:41 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k37N5c7H017614; + Fri, 7 Apr 2006 19:05:38 -0400 (EDT) +To: "Luke Lonergan" +cc: "Gavin Hamill" , pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +In-reply-to: +References: +Comments: In-reply-to "Luke Lonergan" + message dated "Fri, 07 Apr 2006 15:56:52 -0700" +Date: Fri, 07 Apr 2006 19:05:38 -0400 +Message-ID: <17613.1144451138@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.129 required=5 tests=[AWL=0.129] +X-Spam-Score: 0.129 +X-Spam-Level: +X-Archive-Number: 200604/167 +X-Sequence-Number: 18251 + +"Luke Lonergan" writes: +> On 4/7/06 3:27 PM, "Gavin Hamill" wrote: + +>> 278774: __semop(15728650, 0x0FFFFFFFFFFF7E80, 1) = 0 +>> 155712: __semop(15728650, 0x0FFFFFFFFFFF5920, 1) = 0 +>> 278774: __semop(15728649, 0x0FFFFFFFFFFF6F10, 1) + +> Seems like you're hitting a very small target in RAM with these semop calls. + +IIRC the address passed to semop() in our code is always a local struct +on the stack, so that's a bit of a red herring --- there won't be +cross-processor contention for that. + +It's plausible though that we are seeing contention across members of +the LWLock array, with the semop storm just being a higher-level symptom +of the real hardware-level problem. You might try increasing +LWLOCK_PADDED_SIZE to 64 or even 128, see +src/backend/storage/lmgr/lwlock.c (this is something that does exist in +8.1, so it'd be easy to try). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 7 20:39:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 77CD511F681D + for ; + Fri, 7 Apr 2006 20:39:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99758-07 + for ; + Fri, 7 Apr 2006 20:39:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (213-2-2-26.uk.vianw.net [213.2.2.26]) + by postgresql.org (Postfix) with ESMTP id 04F5D11F676E + for ; + Fri, 7 Apr 2006 20:39:24 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id A52E3137594 + for ; + Sat, 8 Apr 2006 00:39:24 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id 86A41136CD9 + for ; + Sat, 8 Apr 2006 00:39:24 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id 4267175FE5 + for ; + Sat, 8 Apr 2006 00:39:27 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id 19C8B75CA6 + for ; + Sat, 8 Apr 2006 00:39:27 +0100 (BST) +Date: Sat, 8 Apr 2006 00:39:19 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +Message-Id: <20060408003919.42b6f71a.gdh@laterooms.com> +In-Reply-To: <17515.1144450340@sss.pgh.pa.us> +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> + <15772.1144440362@sss.pgh.pa.us> + <20060407223635.9c4a0b38.gdh@laterooms.com> + <17055.1144447009@sss.pgh.pa.us> + <20060407232759.45581362.gdh@laterooms.com> + <17515.1144450340@sss.pgh.pa.us> +X-Mailer: Sylpheed version 2.1.1 (GTK+ 2.8.6; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.105] +X-Spam-Score: 0.105 +X-Spam-Level: +X-Archive-Number: 200604/168 +X-Sequence-Number: 18252 + +On Fri, 07 Apr 2006 18:52:20 -0400 +Tom Lane wrote: + +> Are you in a position to try your workload using PG CVS tip? There's +> a nontrivial possibility that we've already fixed this --- a couple +> months ago I did some work to reduce contention in the lock manager: + +Well, there's a question. At the moment it's still live - but I'll need +to swap back to the Xeon machine since I can't afford to have a Saturday +with the db firing on three cylinders (out of eight :) + +At that point you're welcome to twiddle, compile, throw anything you +want at it. If it helps us as much as the greater pg world, then that's +perfect. + +> This is unfortunately not going to help you as far as getting that +> machine into production now (unless you're brave enough to run CVS tip +> as production, which I certainly am not). + +.. if the problem can actually be boiled down to the locking/threading +issues, surely it should be straightforward to backport those changes +to 8.1.3 mainline? + +> I'm afraid you're most +> likely going to have to ship that pSeries back at the end of the +> month, but while you've got it it'd be awfully nice if we could use +> it as a testbed ... + +We have it for the next 2 weeks, and whilst I can't guarantee access for +all that time, you're welcome to hammer away at it over this weekend if +that's any help? Mail me privately and I'll sort out login details if +this is interesting. + +Cheers, +Gavin. + +From pgsql-performance-owner@postgresql.org Fri Apr 7 22:26:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0327811F6B4E + for ; + Fri, 7 Apr 2006 22:26:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36738-04 + for ; + Fri, 7 Apr 2006 22:26:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (213-2-2-26.uk.vianw.net [213.2.2.26]) + by postgresql.org (Postfix) with ESMTP id 077F311F6912 + for ; + Fri, 7 Apr 2006 22:26:17 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id 958E3137594 + for ; + Sat, 8 Apr 2006 02:26:17 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id 7AE90136CD9 + for ; + Sat, 8 Apr 2006 02:26:17 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id 7FC2175FE5 + for ; + Sat, 8 Apr 2006 02:26:20 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id 57F0875F8D + for ; + Sat, 8 Apr 2006 02:26:20 +0100 (BST) +Date: Sat, 8 Apr 2006 02:26:12 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +Message-Id: <20060408022612.f5918e25.gdh@laterooms.com> +In-Reply-To: +References: <20060407232759.45581362.gdh@laterooms.com> + +X-Mailer: Sylpheed version 2.1.1 (GTK+ 2.8.6; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, score=0.106 required=5 tests=[AWL=0.106] +X-Spam-Score: 0.106 +X-Spam-Level: +X-Archive-Number: 200604/169 +X-Sequence-Number: 18253 + +On Fri, 07 Apr 2006 15:56:52 -0700 +"Luke Lonergan" wrote: + +> Seems like you're hitting a very small target in RAM with these semop +> calls. I wonder what part of the code is doing this - Tom would know +> better how to trace it, but the equivalent of oprofile output would +> be nice. + +I'm happy to test whatever I can, but I simply don't know enough AIX to +be able to tell whether a similar kernel-level profiler is +available/possible. + +> The other thing that I'd like to see is an evaluation of the memory +> access latency of this machine from Register to RAM. I couldn't find +> a benchmarking tool that was UNIX friendly out there, maybe I'll +> write one real quick. I suspect this machine has a heinous latency +> and a storm of semops to the same spot of RAM might be a far worse +> performance problem on this machine than on others... + +Well, as I said to Tom, the machine is available for running tests +on :) If it helps us, and helps pg become more AIX friendly, then I'm +all for whatever needs done... + +Cheers, +Gavin. + +From pgsql-performance-owner@postgresql.org Sun Apr 9 00:27:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1D4F011F65F7 + for ; + Sun, 9 Apr 2006 00:27:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Xo7+ckM2UqBU + for ; + Sun, 9 Apr 2006 00:27:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 6873A11F6028 + for ; + Sun, 9 Apr 2006 00:27:28 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k393Qpm08170; + Sat, 8 Apr 2006 23:26:51 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200604090326.k393Qpm08170@candle.pha.pa.us> +Subject: Re: Indexes with descending date columns +In-Reply-To: <20060331155554.GO49405@pervasive.com> +To: "Jim C. Nasby" +Date: Sat, 8 Apr 2006 23:26:51 -0400 (EDT) +CC: Theo Kramer , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Archive-Number: 200604/170 +X-Sequence-Number: 18254 + +Jim C. Nasby wrote: +> On Wed, Mar 29, 2006 at 12:52:31PM +0200, Theo Kramer wrote: +> > On Fri, 2006-03-24 at 12:21, Jim C. Nasby wrote: +> > > On Thu, Mar 23, 2006 at 01:09:49PM +0200, Theo Kramer wrote: +> > > > ii If no to i, is it feasible to extend PostgreSQL to allow traversing +> > > > an index in column descending and column ascending order - assuming +> > > > an order by on more than one column with column order not +> > > > in the same direction and indexes existing? ... if that makes sense. +> > > +> > > Yes. +> > > +> > > stats=# explain select * from email_contrib order by project_id desc, id desc, date desc limit 10; +> > > QUERY PLAN +> > > ------------------------------------------------------------------------------------------------------------------------ +> > > Limit (cost=0.00..31.76 rows=10 width=24) +> > > -> Index Scan Backward using email_contrib_pkey on email_contrib (cost=0.00..427716532.18 rows=134656656 width=24) +> > > (2 rows) +> > +> > Not quite what I mean - redo the above as follows and then see what +> > explain returns +> > +> > explain select * from email_contrib order by project_id, id, date desc +> > limit 10; +> +> Ahh. There's a hack to do that by defining a new opclass that reverses < +> and >, and then doing ORDER BY project_id, id, date USING new_opclass. +> +> I think there's a TODO about this, but I'm not sure... + +Yes, and updated: + + * Allow the creation of indexes with mixed ascending/descending + specifiers + + This is possible now by creating an operator class with reversed sort + operators. One complexity is that NULLs would then appear at the start + of the result set, and this might affect certain sort types, like + merge join. + +-- + Bruce Momjian http://candle.pha.pa.us + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Sun Apr 9 02:49:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2343311F6620 + for ; + Sun, 9 Apr 2006 02:49:20 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.001 +X-Spam-Level: +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id xrTWTAZX+S2f + for ; + Sun, 9 Apr 2006 02:49:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 3857911F65EE + for ; + Sun, 9 Apr 2006 02:49:14 -0300 (ADT) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)) + for pgsql-performance@postgresql.org; Sat, 8 Apr 2006 23:49:13 -0600 +Mime-Version: 1.0 (Apple Message framework v749.3) +To: PostgreSQL Performance +Message-Id: +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-6-898310169; + protocol="application/pkcs7-signature" +From: Brendan Duddridge +Subject: OT: Data structure design question: How do they count so fast? +Date: Sat, 8 Apr 2006 23:49:10 -0600 +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/171 +X-Sequence-Number: 18255 + + +--Apple-Mail-6-898310169 +Content-Type: multipart/alternative; + boundary=Apple-Mail-5-898309898 + + +--Apple-Mail-5-898309898 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Hi, + +First of all, the reason I'm posting on the PostgreSQL Performance +list is we have a performance issue with one of our applications and +it's related to the speed at which PostgreSQL can do counts. But it's +also related to the data structure we've designed to develop our +comparison shopping engine. It's very normalized and the speed of our +queries are slowing down considerably as we add more and more data. + +So I've been looking at some of the other comparison shopping engines +and I'm trying to figure out how they manage to get the counts of +their products for a set of attributes and attribute values so quickly. + +For example, on the following page, they have 1,260,658 products: + +http://www.mysimon.com/Home-Furnishings/9000-10975_8-0.html?tag=glnav + +They display 3 attributes with values on the page: Price Range, Home +Furnishing Type, and Store. Plus there are a selection of other +attributes not displaying the value choices. + +For Price Range, they have the following values and product counts +(in brackets): + +# Below $20 (204,315) +# $20 - $50 (234,694) +# $50 - $80 (188,811) +# $80 - $130 (182,721) +# $130 - $240 (222,519) + +For Home Furnishing Type they have: + +# Wall Art and Decor (438,493) +# Lighting (243,098) +# Bathroom Furnishings (132,441) +# Rugs (113,216) +# Decorative Accents (65,418) + +And for Store they have: + +# Art.com (360,933) +# HomeAnnex (130,410) +# AllPosters.com (72,529) +# HomeClick.com (61,423) +# 1STOPlighting Superstore (32,074) + +Now, initially I thought they would just pre-compute these counts, +but the problem is, when you click on any of the above attribute +values, they reduce the remaining possible set of matching products +(and set of possible remaining attributes and attribute values) by +the amount displayed next to the attribute value selected. You can +click on any combination of attribute values to filter down the +remaining set of matching products, so there's a large combination of +paths you can take to arrive at a set of products you might be +interested in. + +Do you think they are pre-computed? Or do you think they might use a +query similar to the following?: + +select pav.attribute_value_id, count(p.product_id) +from product_attribute_value pav, + attribute a, + product p +where a.attribute_id in (some set of attribute ids) and +pav.product_id = p.product_id and +pav.attribute_id = a.attribute_id and p.product_id in + (select product_id + from category_product + where category_id = some category id) and +p.is_active = 'true' +group by pav.attribute_value_id; + +It would seem to me that although the above query suggests a +normalized database structure, that joining with 3 tables plus a 4th +table in the sub-query with an IN qualifier and grouping to get the +product counts would take a VERY long time, especially on a possible +result set of 1,260,658 products. + +The other issue is trying to figure out what the remaining set of +possible attribute and attribute values are in order to reach the +remaining set of products. + +Does anyone have any insights into what kind of data structures would +be necessary to accomplish such a feat? I know that PostgreSQL has +performance issues with counting rows, so I can't imagine being able +to use the above kind of query to get the results we need. I don't +know what kind of database backend mysimon is using either. It would +also seem to be logical that having a flattened data structure would +seem to be necessary in order to get the performance required. Their +pages seem to load pretty fast. + +We are possibly considering some kind of pre-computed decision-tree +type data structure to get the counts of the set of products that +could be reached by selecting any combination of attributes and +attribute values. Does this seem like a reasonable idea? + +Perhaps there's a better way? + +I also apologize if this isn't the appropriate list to publish this +kind of question to. The reason I posted here was because it is a +performance related question, but not necessarily directly related to +PostgreSQL. It's just that we are using PostgreSQL for our product +comparison engine so I thought there could be some PostgreSQL +specific optimizations that could be made. If not, please let me know +and I'll move it elsewhere. + + +Thanks very much, + + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +--Apple-Mail-5-898309898 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +Hi,

First of all, the reason = +I'm posting on the PostgreSQL Performance list is we have a performance = +issue with one of our applications and it's related to the speed at = +which PostgreSQL can do counts. But it's also related to the data = +structure we've designed to develop our comparison shopping engine. It's = +very normalized and the speed of our queries are slowing down = +considerably as we add more and more data.

So I've been looking at = +some of the other comparison shopping engines and I'm trying to figure = +out how they manage to get the counts of their products for a set of = +attributes and attribute values so quickly.

For example, on the = +following page, they have 1,260,658 products:


They display 3 attributes = +with values on the page: Price Range, Home Furnishing Type, and Store. = +Plus there are a selection of other attributes not displaying the value = +choices.

For Price Range, they have = +the following values and product counts (in = +brackets):

# = +Below $20 (204,315)
# $20 - $50 = +(234,694)
# $50 - $80 (188,811)
# = +$80 - $130 (182,721)
# $130 - $240 = +(222,519)

For Home Furnishing Type they have:

# = +Wall Art and Decor (438,493)
# Lighting = +(243,098)
# Bathroom Furnishings (132,441)
# = +Rugs (113,216)
# Decorative Accents = +(65,418)

And for Store they have:

# = +Art.com (360,933)
# HomeAnnex = +(130,410)
# AllPosters.com (72,529)
# = +HomeClick.com (61,423)
# 1STOPlighting Superstore = +(32,074)

Now, initially I thought = +they would just pre-compute these counts, but the problem is, when you = +click on any of the above attribute values, they reduce the remaining = +possible set of matching products (and set of possible remaining = +attributes and attribute values) by the amount displayed next to the = +attribute value selected. You can click on any combination of attribute = +values to filter down the remaining set of matching products, so there's = +a large combination of paths you can take to arrive at a set of products = +you might be interested in.

Do you think they are = +pre-computed? Or do you think they might use a query similar to the = +following?:

select = +pav.attribute_value_id, count(p.product_id)
from = +product_attribute_value pav,
= +=A0attribute a,
=A0product = +p
where a.attribute_id in (some set of attribute ids) = +and
pav.product_id =3D p.product_id = +and
pav.attribute_id =3D a.attribute_id and p.product_id = +in
(select = +product_id
=A0from = +category_product
=A0where category_id =3D some = +category id) and
p.is_active =3D 'true'
group by = +pav.attribute_value_id;

It would seem to me that = +although the above query suggests a normalized database structure, that = +joining with 3 tables plus a 4th table in the sub-query with an IN = +qualifier and grouping to get the product counts would take a VERY long = +time, especially on a possible result set of 1,260,658 = +products.=A0

The other issue is trying = +to figure out what the remaining set of possible attribute and attribute = +values are in order to reach the remaining set of = +products.

Does anyone have any = +insights into what kind of data structures would be necessary to = +accomplish such a feat? I know that PostgreSQL has performance issues = +with counting rows, so I can't imagine being able to use the above kind = +of query to get the results we need. I don't know what kind of database = +backend mysimon is using either. It would also seem to be logical that = +having a flattened data structure would seem to be necessary in order to = +get the performance required. Their pages seem to load pretty = +fast.

We are possibly = +considering some kind of pre-computed decision-tree type data structure = +to get the counts of the set of products that could be reached by = +selecting any combination of attributes and attribute values. Does this = +seem like a reasonable idea?

Perhaps there's a better = +way?

I also apologize if this = +isn't the appropriate list to publish this kind of question to. The = +reason I posted here was because it is a performance related question, = +but not necessarily directly related to PostgreSQL. It's just that we = +are using PostgreSQL for our product comparison engine so I thought = +there could be some PostgreSQL specific optimizations that could be = +made. If not, please let me know and I'll move it = +elsewhere.=A0


Thanks very = +much,


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

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

http://www.clickspace.com=A0
= +
= + +--Apple-Mail-5-898309898-- + +--Apple-Mail-6-898310169 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIDCCAtkw +ggJCoAMCAQICAw84ujANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0EwHhcNMDUwNzI5MjAxMTQzWhcNMDYwNzI5MjAxMTQzWjBIMR8wHQYDVQQD +ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSUwIwYJKoZIhvcNAQkBFhZicmVuZGFuQGNsaWNrc3Bh +Y2UuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqWfMCdFgKzXroGNqJuU3eyDC +K/Gxts3mtmIdgcHGmUjRKdlBSfkmcCBUDPJIt4QQc91sY3h8Itg0EAsF+1yFECU6afn/1SEAHSDK +6Q86PclF58/Dux2FYNGpeIAw/lisZ2UCyIYoUiWtEDKCBq5jDuYzcGkFS5Csz+/rEL+BHTXQVqnS +nUdUaXu9xdZn4wgjB/n65UEYRqr0LGN53CGsFcA9uC+ViS7WyBtzJcP02LMNT+cAZ7TKHw4Q/ZeG +5ptPgQHLTD2wza3GMbPQ4fYK6aNPA+lVzslLSCjyQpg55gVyQQlV0k/5zU5Q5m48ZtqwOqN+fPYd +eIB7H5y1SFLd/wIDAQABozMwMTAhBgNVHREEGjAYgRZicmVuZGFuQGNsaWNrc3BhY2UuY29tMAwG +A1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEEBQADgYEAT+6hGvStHoRO0OCHlJev31BpUlvPSpbYVKJN +i5kCMF164sSX7j0IRvcyU6DfUuW7samTluXJbANyuX1ZIpXulGen5EEc2NV7eU/rMz6ExklMShTh +++azcvmMjOzTuqXi3ZsIjwzBBhqCB0U++kYlMlHEYla2qKLFbXY6PiH0a8swggM/MIICqKADAgEC +AgENMA0GCSqGSIb3DQEBBQUAMIHRMQswCQYDVQQGEwJaQTEVMBMGA1UECBMMV2VzdGVybiBDYXBl +MRIwEAYDVQQHEwlDYXBlIFRvd24xGjAYBgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQL +Ex9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMSQwIgYDVQQDExtUaGF3dGUgUGVyc29u +YWwgRnJlZW1haWwgQ0ExKzApBgkqhkiG9w0BCQEWHHBlcnNvbmFsLWZyZWVtYWlsQHRoYXd0ZS5j +b20wHhcNMDMwNzE3MDAwMDAwWhcNMTMwNzE2MjM1OTU5WjBiMQswCQYDVQQGEwJaQTElMCMGA1UE +ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFs +IEZyZWVtYWlsIElzc3VpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMSmPFVzVftO +ucqZWh5owHUEcJ3f6f+jHuy9zfVb8hp2vX8MOmHyv1HOAdTlUAow1wJjWiyJFXCO3cnwK4Vaqj9x +VsuvPAsH5/EfkTYkKhPPK9Xzgnc9A74r/rsYPge/QIACZNenprufZdHFKlSFD0gEf6e20TxhBEAe +ZBlyYLf7AgMBAAGjgZQwgZEwEgYDVR0TAQH/BAgwBgEB/wIBADBDBgNVHR8EPDA6MDigNqA0hjJo +dHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhhd3RlUGVyc29uYWxGcmVlbWFpbENBLmNybDALBgNVHQ8E +BAMCAQYwKQYDVR0RBCIwIKQeMBwxGjAYBgNVBAMTEVByaXZhdGVMYWJlbDItMTM4MA0GCSqGSIb3 +DQEBBQUAA4GBAEiM0VCD6gsuzA2jZqxnD3+vrL7CF6FDlpSdf0whuPg2H6otnzYvwPQcUCCTcDz9 +reFhYsPZOhl+hLGZGwDFGguCdJ4lUJRix9sncVcljd2pnDmOjCBPZV+V2vf3h9bGCE6u9uo05RAa +WzVNd+NWIXiC3CEZNd4ksdMdRv9dX2VPMYIC5zCCAuMCAQEwaTBiMQswCQYDVQQGEwJaQTElMCMG +A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv +bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujAJBgUrDgMCGgUAoIIBUzAYBgkqhkiG9w0BCQMx +CwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA0MDkwNTQ5MTFaMCMGCSqGSIb3DQEJBDEW +BBTpE5VT1b3j98al9KOEaLA0cUwC6DB4BgkrBgEEAYI3EAQxazBpMGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDDzi6MHoGCyqGSIb3DQEJEAILMWugaTBiMQswCQYD +VQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMj +VGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujANBgkqhkiG9w0BAQEFAASC +AQAuM0JY883ZgJUUQq+sj3jJERomiRsEXZ8PD01femjd3sjZDnz6jDvqw6QoOieuXbWkRSMzIA3T +R1amqCEpZe8hBcCTZtKvL7inWsDreflSEmo7LnjH14s3DZUqYCSyZhDwlyEvUeEEPJRzwxTKc2xC +iOAaQ5ojxgY1E1yTUJbuCleotaDDM7G/v6B81DnV8SXffJrUuWPXrdXyj9fZnzTKtHrWJmdkXA6g +OyoWE9ukociR8cD71KetQQoQvDhfqWBOrFCVu548myjs3XnJ3QLjjZu7E/oURRk+2EvgMV58XObU +0EhOy0KW78B38figpFmjQZdyEzUr8H5U6V7mtf5+AAAAAAAA + +--Apple-Mail-6-898310169-- + + +From pgsql-performance-owner@postgresql.org Sun Apr 9 06:23:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A1DAE11F690E + for ; + Sun, 9 Apr 2006 06:23:45 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.816 +X-Spam-Level: +X-Spam-Status: No, score=0.816 required=5 tests=[EXTRA_MPART_TYPE=0.815, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 1WhK7GWY51Yv + for ; + Sun, 9 Apr 2006 06:23:38 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 8381411F691D + for ; + Sun, 9 Apr 2006 06:23:39 -0300 (ADT) +Received: from AZ18CN851.global.ds.honeywell.com (tmpnat1.honeywell.com + [199.64.0.252]) + by svr4.postgresql.org (Postfix) with ESMTP id D13AF5AF854 + for ; + Sun, 9 Apr 2006 09:23:37 +0000 (GMT) +Received: from AZ18EV805.global.ds.honeywell.com ([131.127.167.25]) by + AZ18CN851.global.ds.honeywell.com with Microsoft + SMTPSVC(6.0.3790.1830); Sun, 9 Apr 2006 02:23:35 -0700 +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/related; type="multipart/alternative"; + boundary="----_=_NextPart_001_01C65BB7.5050C050" +Subject: pls reply ASAP +Date: Sun, 9 Apr 2006 02:27:57 -0700 +Message-ID: + +X-MS-Has-Attach: yes +X-MS-TNEF-Correlator: +Thread-Topic: pls reply ASAP +Thread-Index: AcZbt+MnZm1jF8smTmWCiU2CoIs+7Q== +From: "Chethana, Rao (IE10)" +To: , "Richard Huxton" , + +X-OriginalArrivalTime: 09 Apr 2006 09:23:35.0014 (UTC) + FILETIME=[46B66860:01C65BB7] +X-Archive-Number: 200604/172 +X-Sequence-Number: 18256 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C65BB7.5050C050 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_002_01C65BB7.5050C050" + + +------_=_NextPart_002_01C65BB7.5050C050 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + =20 + +Hello! + +=20 + +Kindly go through the following , + +=20 + +=20 + +I wanted to know whether, the command line arguments(function arguments) +------ $1 $2 $3 -- can be used as in the following , like, ---- + +=20 + +=20 + +CREATE TYPE TT +AS(something,something,................................................. +.................etc..................); + +CREATE OR REPLACE FUNCTION f1(varchar,varchar,varchar,varchar) RETURNS +.......................(something)............. + +=20 + +BEGIN + + SELECT a1,a2,a3,a4,a5,a6 + + FROM (SELECT * FROM T1, T2......WHERE ............etc... Flag =3D 0 +$1 $2 $3 $4) + + ORDER BY ........................ + + +............................... + +RETURN NEXT .........; + + END LOOP; + + RETURN; + +END; + +' LANGUAGE 'plpgsql'; + +=20 + +NOTE : The values for $1 $2 $3 $4 will be passed when the function +is invoked(called) from the command prompt. + +=20 + +I tried implementing the above, but this type of usage is not +supported , how should use it? =20 + +=20 + + I am converting from (sprintf, "SELECT query stmts (which uses %s %s +%s %s ...... ) to functions. + +=20 + +=20 + +Any help will be deeply appreciated. Thank you. + +=20 + +=20 + +Kind regards, + + Chethana. + +=20 + +=20 + +=20 + + +------_=_NextPart_002_01C65BB7.5050C050 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + + + +
+ +

Hello!

+ +

 

+ +

Kindly go through the following = +,

+ +

 

+ +

 

+ +

I wanted to know whether, the command line = +arguments(function +arguments) ------  $1 $2 $3   --  can be used  = +as in +the following , like, ----

+ +

 

+ +

 

+ +

CREATE +TYPE TT = +AS(something,something,…………………&= +#8230;………………………R= +30;…………etc……………R= +30;);

+ +

CREATE OR REPLACE +FUNCTION f1(varchar,varchar,varchar,varchar) RETURNS = +…………………..(something)…R= +30;…….

+ +

 

+ +

BEGIN

+ +

 SELECT = +a1,a2,a3,a4,a5,a6

+ +

 FROM (SELECT +* FROM T1, T2……WHERE = +…………etc…   +Flag =3D 0   $1 $2 $3 = +$4)

+ +

 ORDER BY = +……………………   = +;            = +            &= +nbsp;           &n= +bsp;           &nb= +sp;           &nbs= +p;    +

+ +

………………R= +30;……….

+ +

RETURN +NEXT ………;

+ +

  +END LOOP;

+ +

  +RETURN;

+ +

END;

+ +

' +LANGUAGE 'plpgsql';

+ +

 

+ +

NOTE = +:   + The values for  $1 $2 $3 $4  will be passed when the = +function +is invoked(called)  from the command = +prompt.

+ +

 

+ +

I = + tried implementing +the above, but  this type of usage is not supported , how should = +use +it? 

+ +

 

+ +

 I am converting  +from (sprintf, “SELECT query stmts (which uses   %s %s = +%s %s  +…… )        to = +functions.

+ +

 

+ +

 

+ +

Any = +help will be +deeply appreciated.  Thank you.

+ +

 

+ +

 

+ +

Kind = +regards,

+ +

      +Chethana.

+ +

 

+ +

 

+ +

 

+ +
+ + + + + +------_=_NextPart_002_01C65BB7.5050C050-- + +------_=_NextPart_001_01C65BB7.5050C050 +Content-Type: image/jpeg; + name="image001.jpg" +Content-Transfer-Encoding: base64 +Content-ID: +Content-Description: image001.jpg +Content-Location: image001.jpg + +/9j/4AAQSkZJRgABAgEASABIAAD/7QVoUGhvdG9zaG9wIDMuMAA4QklNA+0AAAAAABAASAAAAAEA +AQBIAAAAAQABOEJJTQPzAAAAAAAIAAAAAAAAAAA4QklNBAoAAAAAAAEAADhCSU0nEAAAAAAACgAB +AAAAAAAAAAI4QklNA/UAAAAAAEgAL2ZmAAEAbGZmAAYAAAAAAAEAL2ZmAAEAoZmaAAYAAAAAAAEA +MgAAAAEAWgAAAAYAAAAAAAEANQAAAAEALQAAAAYAAAAAAAE4QklNA/gAAAAAAHAAAP////////// +//////////////////8D6AAAAAD/////////////////////////////A+gAAAAA//////////// +/////////////////wPoAAAAAP////////////////////////////8D6AAAOEJJTQQIAAAAAAAQ +AAAAAQAAAkAAAAJAAAAAADhCSU0ECQAAAAAD9wAAAAEAAACAAAAAgAAAAYAAAMAAAAAD2wAYAAH/ +2P/gABBKRklGAAECAQBIAEgAAP/+ACdGaWxlIHdyaXR0ZW4gYnkgQWRvYmUgUGhvdG9zaG9wqCA0 +LjAA/+4ADkFkb2JlAGSAAAAAAf/bAIQADAgICAkIDAkJDBELCgsRFQ8MDA8VGBMTFRMTGBEMDAwM +DAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAENCwsNDg0QDg4QFA4ODhQUDg4ODhQRDAwM +DAwREQwMDAwMDBEMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgAgACAAwEiAAIRAQMR +Af/dAAQACP/EAT8AAAEFAQEBAQEBAAAAAAAAAAMAAQIEBQYHCAkKCwEAAQUBAQEBAQEAAAAAAAAA +AQACAwQFBgcICQoLEAABBAEDAgQCBQcGCAUDDDMBAAIRAwQhEjEFQVFhEyJxgTIGFJGhsUIjJBVS +wWIzNHKC0UMHJZJT8OHxY3M1FqKygyZEk1RkRcKjdDYX0lXiZfKzhMPTdePzRieUpIW0lcTU5PSl +tcXV5fVWZnaGlqa2xtbm9jdHV2d3h5ent8fX5/cRAAICAQIEBAMEBQYHBwYFNQEAAhEDITESBEFR +YXEiEwUygZEUobFCI8FS0fAzJGLhcoKSQ1MVY3M08SUGFqKygwcmNcLSRJNUoxdkRVU2dGXi8rOE +w9N14/NGlKSFtJXE1OT0pbXF1eX1VmZ2hpamtsbW5vYnN0dXZ3eHl6e3x//aAAwDAQACEQMRAD8A +9LSS7JlWLMolMkkmpXSTpIqUnCinCQQySTSknWilJkpSQtKxSlJJBKk6ZOkFP//Q9LlJMnVZmVCY +qRUUCpSRKUpkErSpBRhOkClkCkmCcJ1rVQmUk0JKUm7p0kEqSTSkUrU//9H0kKQUU8qoCzlclRTy +opEqC6SSSSVwlokkihScJAJwEgEKCRTpiE6lLJJJkFLJJJJq5//S9JTJ0ypthcJJkpSUukklqipS +kmhSARAQVBJOE6ctWCdJIooYlRKkSok6ppXBSRSCcodEv//T9JSSThVGwxITKZTQhSrUE6QCdOCC +uEkySKF5Ugop0QgrpikSokokqCxTKSaEwrlBP8Eyfskh/9T0lSUSkCVUZ2SSYKSKFkkkgipSSdMU +lLpFMmJStVLykmlOhaVJJAJ4RQslKSZBL//V9JTwkkqjOunUU4KchSQTpJKWJSTEppQtNLkpkk8I +bqUAnSTIqZJSmSRQsmUlEoFIf//W9KCSSdVWdZIJQkkplKZNKSNopc6qMKSZBKycFOkB4pUq1JJ4 +CUI0i1kydMUClUpkkkEv/9kAOEJJTQQGAAAAAAAHAAMAAAABAQD//gAnRmlsZSB3cml0dGVuIGJ5 +IEFkb2JlIFBob3Rvc2hvcKggNC4wAP/uAA5BZG9iZQBkAAAAAAH/2wCEAAoHBwcIBwoICAoPCggK +DxINCgoNEhQQEBIQEBQRDAwMDAwMEQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwBCwwMFRMV +IhgYIhQODg4UFA4ODg4UEQwMDAwMEREMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM +DP/AABEIASwBLAMBEQACEQEDEQH/3QAEACb/xAGiAAAABwEBAQEBAAAAAAAAAAAEBQMCBgEABwgJ +CgsBAAICAwEBAQEBAAAAAAAAAAEAAgMEBQYHCAkKCxAAAgEDAwIEAgYHAwQCBgJzAQIDEQQABSES +MUFRBhNhInGBFDKRoQcVsUIjwVLR4TMWYvAkcoLxJUM0U5KismNzwjVEJ5OjszYXVGR0w9LiCCaD +CQoYGYSURUaktFbTVSga8uPzxNTk9GV1hZWltcXV5fVmdoaWprbG1ub2N0dXZ3eHl6e3x9fn9zhI +WGh4iJiouMjY6PgpOUlZaXmJmam5ydnp+So6SlpqeoqaqrrK2ur6EQACAgECAwUFBAUGBAgDA20B +AAIRAwQhEjFBBVETYSIGcYGRMqGx8BTB0eEjQhVSYnLxMyQ0Q4IWklMlomOywgdz0jXiRIMXVJMI +CQoYGSY2RRonZHRVN/Kjs8MoKdPj84SUpLTE1OT0ZXWFlaW1xdXl9UZWZnaGlqa2xtbm9kdXZ3eH +l6e3x9fn9zhIWGh4iJiouMjY6Pg5SVlpeYmZqbnJ2en5KjpKWmp6ipqqusra6vr/2gAMAwEAAhED +EQA/AOoZluG1hQ3TArqYpaxQ7fCrROKGtsVcadsVdthVvamBXYpcBgQ3TFk7FW8Vdtirgu+BV6rQ +1xSuGRZN0GKtU3+WFFOpirVBiq04UNYUOxVo4q49cVawoaritt1xVo4q7FDqHFLqHFW+ONpbpgta +f//Q6jmU4bRGFXVxQ1XFXVxVquFDVcVawq7FXYq3gVvFXDFK4YEuOKrcKG8VXLgKQvGRZN4Eurir +VcNIdXFXVxVrFDRwq7FWsULcKGjhQ1irWFXDFVwwJbxV2KXDArfbFX//0eo5lOI44ULcKHYqtOKH +YVaxV2KHYpbwK3irhilvFXYEuOKGsKt4quGBK4HAluuBLWFXYENYVdXFWq4obrilrFDROFWsKGiM +VawodTArsKuwKuGBLeKXYq3ir//S6kMynEaOKFuSQ7FVpxQ1hV2KHYpbwKuAxS7FXYq7FXYq1ire +KuxVsYEt1wJbrirsVarih2KtHCrVcUN1xS6uKtE4UNVxV1cVbxVrFXYq7FDhilcMCW8Vdir/AP/T +6l2zKcRo4oaOFWsKHUwKtIwodhV1MCt0xS2MCuwq7FXYq0cUNVxVuuKXVxVsHFW8CXDFW8CXYodi +rRwq1hQ7FXYq1ihrFWxilvFWsVdih2KtjAlvFLsVXYEv/9TqNcynDaJwq1hVvArqYq7FDVMVdhVr +FXYq3irsVccCrckhrFWq4otuuK2uU4GTeBLYxVdgS1ih2KuphVxGKVuFi7FWqYq6mKt4q7FVuKGx +ilumBXYVdgS4nCh1dq4rb//V6hXMtw2sKuxVsYFbwK6mKXEYoaOFVuFDWKG8Ut4q0Tiq3ChaThYt +YVbGBV4OBkurkUtg4pdXFXVxVcMCXYq44qtOFDWFDsUuxV2KuxQ1TFWwMVbGBLsVaOKHYUNUHjil +/9bp+Zjht4FdTFXYq2MCt4paOKrThQ1hQ7FDsUuJxVbhQ0ThQtwodireBV2BLsUrgcCW8VdilsHA +q7Al2KtHFDVMKupirqYq1hQ7FXYq7FXYq7FXHAq3Ch1Ril//1+nVzMcJvFW8CXYq2MCt4paOKrTh +YtYVdXFWq4odirWFWiMLFqmKupirsVbxS3gVvFK6uRS7CrYwJbwK3til2KupirWKGsKtYq6mKHYV +dirVcVdXFDsVaxVrCr//0OmVzNcFcMCW8VXDAlumBLsVaJwqsJwsWsKGsVdirsVdirsUOxV1MUup +irqYq7FW8CtnFXDFK4HAlvFXYFXDFLsCrTkkNYq7FXYq1hVo4oaxQ7FXYq7CrWKv/9HpmZrgNg4E +rsUrhkWTZxVrFC0nChbkkNYodirsUupirsVdireKtgYFbxS1ihrFXDFW8UuGKrhgS3irYGBLeBXH +Cqw4UNYq7CrsVdirsULcKGsVdirsVawof//S6Xmc69sYGS8ZFK7Al2FWq4qtOFC3ChrChvArsUt4 +FdirsVdireKXYq7FWjihwxVvFLeKrsCW6YEtjFXYEtHChacKHUxV1MVdTFWsKuxQtwoW4UOrirsV +bwK//9PpWZzr2wcCVwOBK6uBLq4q0ThVrChbXChquKGwcUt4FcMUt4FdireKt4pdirWKupirdMCu +pirdMUrhgS3gV2KW6Yq1TChaRirsUOxV2FVuKGicKrThQ7FDVMKt4Fdil//U6Xmc69rFW64Et1xW +3VxS6uKuOKFuFDsVdiq4YEuxV1cVcMUrsCWxgV2KtYVbxVsYEt0wK3TFLeBXYpbGKt4pdTAq0jJI +apihxxVZhQ7ChacUNYVdireKuxVrFX//1el5nOvdilo4odXFXVxVsHFLeBWqYVdih2KXYq7FXUxV +vAlvFWwcCW64FdhVsDAlsDAldgV2KXYq7FWxirYwJbxVojFWqYULSMKFpwoaOKFuFDsKuwK2Bilx +xVb3wsX/1ulkZnOA1ihxxVrCrsVbwK2MUt4EupirsVdihqmFW8CXYq7FDsUtjAq7FK4YEtjAlvAl +vFXYq6mKtgYFbxS7FXYq0cVWnChaRkkLTixW4UOxVwGKrsUtHFVtMLF//9fphzNcBrCho4q1hQ4Y +q3XAlsYpbwK6uKXYq7FDsUuxQ7FXYq7FVwwMlwwJbAwJXAYEt0xVumBXUxS6mKuGKt4q7FXYq0cV +W4ULTkmKwnChrCh1cCrhgS7Cl2KGu+KH/9DpmZrgOOKrDhQ1hQ3irhgS3irq4q6uKt1xVsYEuxS7 +FXYq3irYGBK4DAlumBVwxS2MCW8VdgS3irsVaxVvFXYq1XFWicKFhOFitOFC0nJIaxQ7FK8YEhdT +Alo4qt74WL//0emZmuC7FC0jChrCrsVbwK1XFXYVdihwwJXDFLeBLeKuxVcBgS3TAlvAlvFW8Cux +S2DirYwJbxV2KuxV2KuOKrScKFpOFC0nChaThQtwodireKrgMCV2RS474VW8TXrhtFP/0umHM1wG +jhV2KupirqYq0RihrCrWKHYq3ileMilsDAlcMCXYpbAxVdgS6mKuGKt4Fdirq4VXA5FLeKXYq3gV +2KWjhQsyTEqZOSYra4ocThVrFW8Ct0xSuGBLeBWiaYVW8sNIt//T6YRma4LsUOxV2KXYq0cUNEYU +NYVaxQuGBK7AyXDAlvAlvFW8VbGBLsVdirq4q1ihsYpXDAldgS7FXYq7FWicKrGwsSsOFitySGsV +bwK7FVwwJbril1cVccVW079sNof/1OmGtMzXAarhVvAlcBgV1MVawq1TFDVMK07jja06mKtjAlcM +CW8CW8Vdirq4q3XFXYFdirsVbxSuGBK7AlwxVxxVquKrSckxWnChbhVo4oapih2KuxVvFWxgS3TF +LqYFaoOnbwySH//V6Z45muA0BhVcBgSuGRS7CrRxVrCh2KuwK7CrgMCrsUuxV2KuxV1cCuxVdgS3 +il2KuxVcMCW8Ut1wK0Tiq2uFDRwoW4UNYVdih2KtUxQ6mKupirYwJXDAlvFKygrXvhYP/9bpmw+e +ZrguxVcMCW8VdirsVdTArVMKHYq7FW8UuxV2KuxVrFW6YFdhVdgS3gS7FW8CuxS6uKt1xVquFDVc +VW1woawodirsVdirsVdirhgV2KrhgS2TQVxSs2rywsX/1+m5muC1iq4YEt4q7FXYpdih2KupgV1M +VdhV2KuxV2KuxV2KW6YFbxV2BW8Ut4FdirRwq1XFDq4VarirWFDsVdTArsKt0wJdirWFDsVdilvA +rm3FBiFLu+Kv/9DpprXMxwGsKVwwK7FW8UuxV2Kt0wJbpirsVW4q7Ch2BLYxVumKtUxVvFXYFdhV +1cCt4pdirROKtYUNYUOxV2KuxV2KXYFXYq7ArVMKuxV2Ku7Yq1irt6e+KH//0emnrma4LWKuxVvF +W64FdilcMCVwwJccVawoaxVrFW8VbwK2MUuxV1MVaxQ1hVvFXVwK6uFVtcUNVwq1XFDYxS3irsCt +0xS3TFXUwK3ilrFDRwq1hQ7FXYq7FX//0um9zma4LsVaxV2Kt4FbGKVwwJbwK3ilo4oawq1hQ2MC +VwGBLsVdirsVaOFDWKt4q0cVW1woaJwoaxQ7FK4YEt4q3gS3irYwJbwK7FWjhVacKGsKGsVdXFXV +xV//0+m5muA1ilvArsVbxVvFLYwJXYEuxVo4oW5JXYobGBK4YEuxV1cVaxQ44VW4q3XFWicKFuFD +WKHYpdiq4YEt4q2MCW8Vb6YEt4EuOFC04oW4UOwq1irWKHdsVf/U6bma4LsVbwK6mKXAYq3irYwJ +XYEuxVo4oaphV1MVdTFVwwJcTiq2uFDq4q7FWsUNE4VawoaxV2Kt4FbAxS3irYwJdTFW8Ct1xS1X +FDq4pdhQtwoaxVonCh2Kt4Ff/9XpmZrgtjArYxS3irsVdirYwJbrirq4FbxS4jFWsUNjFLsVaOKF +pwoarhVuuBWicKtYUNYq7FW8VbpgS3irsVcDgVuuKW8VaxV1cVbrirWKupirVMULSMkhrFW8Vf/W +6Zma4LYwK3il2Kt4q7FXYq6uBWxilcMCW8CtEYVaxVvFWjhQsJwsVuFW8VdirsVdgVumKXUxV2Kt +4q7FWsVbxVvAlrFXYq7CrsUN1wJaxVo4ULcKHYof/9fpmZrgtjpgVvFLeKuxVrFXYq1ihcMCVwwJ +XYGTsUNYVdiq04QhZkmLWKHYpdirsVbwKuGBLsKuxV2KuxV2KtYq3irsUuxV2KHYq7FXYq1XFWsK +GsVf/9DpoGZjgt4q7FLq4odil2Kt4qtxQ2MUrxgSuyKXYqtrhV2KHHCq0jChbhQ7FWsVbxV2KuxV +sHAreKXYq7FXYq7FXYq7FLsCuwoaxVxOKGsKuxVrFXYq/wD/0emjpmY4LeKuxV2KuxS7FXVxVrFD +YxSuGBK6uBLVcUOwq7FWicVawoaOKtUxQ3TFWqYq7CrWKt4quGRS7ClsDArqYq7FWsKuwK3irRxQ +1hQtOFXYodirsUuxV//S6dmY4LsVdTFW6YEtHCrWKHYq7CrYwK3iybrgV1cVawq3gVrCh2KuxV2K +uxV2KtHFDWFXAYFXDAluhGLJvAh2KtHCrWFWxgVxxVaSMKGsKGsVdTFXHFDsVdil/9Pp1MzHCbAx +V2BXYVaOKtYodirsVcMVXVxS6uKuqMVdUYq7FXYq1irq4q7FWxgV2FLsUNEV2xQuQb79sBLIBcSS +SCMCW9sCt7YpawoWmlcVcAK4UNbYqtNKYUNbYodirsKuxV1MCXYUOxV//9TqG2ZbhuxV2BXYVccV +LWFDRxVrfFDsKtYq2OuKuHfFWx0wK75YpbFMCu2xV2KtbYVbxVv4cCW9sVb22wJbwJdhVoVxQ3ir +RxVw98Vawq12xQ44q0cKtHFDWKGsKt4EtiuKt4q//9k= + +------_=_NextPart_001_01C65BB7.5050C050-- + +From pgsql-performance-owner@postgresql.org Sun Apr 9 07:42:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4595E11F6D27 + for ; + Sun, 9 Apr 2006 07:42:40 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 2.452 +X-Spam-Level: ** +X-Spam-Status: No, score=2.452 required=5 tests=[AWL=0.120, + FROM_LOCAL_NOVOWEL=2.331, HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 1bxFyy3gNHpB + for ; + Sun, 9 Apr 2006 07:42:33 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.207]) + by postgresql.org (Postfix) with ESMTP id 3ECFC11F6D1C + for ; + Sun, 9 Apr 2006 07:42:36 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id m7so749872nzf + for ; + Sun, 09 Apr 2006 03:42:36 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=Yeh8szcvinQ+XjDfxeDkguHW3mF+9VPmIHzkEAa11NIFA7FiwLHS8wm4/tnkJcSaZ1ew2if8L5aM4p78D9uFtt2VazcUhFc/lJxJ4nFsWVj66fxyhvtix2aDBwGdAUXGvlFvjHWpfjvcYjf502UzjvY0kW/wIdIjWYuVHjsyOyU= +Received: by 10.36.60.13 with SMTP id i13mr191412nza; + Sun, 09 Apr 2006 03:42:36 -0700 (PDT) +Received: by 10.36.153.7 with HTTP; Sun, 9 Apr 2006 03:42:36 -0700 (PDT) +Message-ID: +Date: Sun, 9 Apr 2006 14:42:36 +0400 +From: Luckys +To: "Doron Baranes" +Subject: Re: +Cc: pgsql-performance@postgresql.org +In-Reply-To: <0BA77301DFF4B24C9C5DAA74138BF95001E1E7@exchange-1.dbnet.co.il> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_18802_18168350.1144579356332" +References: <0BA77301DFF4B24C9C5DAA74138BF95001E1E7@exchange-1.dbnet.co.il> +X-Archive-Number: 200604/174 +X-Sequence-Number: 18258 + +------=_Part_18802_18168350.1144579356332 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +It'd be helpful if posted with the EXPLAIN of the slow running queries on +the respective table. + +cool. +L. + + +On 4/9/06, Doron Baranes wrote: +> +> Hi +> +> +> +> I am new at postgres and I'm having performance issues. +> +> I am running on postgres 7.4.6 on a pineapp with 512MB RAM. +> +> I did a database vacuum analyze and rebuild my indexes. +> +> When I perform queries on tables of 2M-10M of rows it takes several +> minutes and +> +> I see at sar and top that the cpu and memory is heavily used. +> +> +> +> I would be glad for guidance on server parameters or other configurations +> which would help. +> +> +> +> 10x. +> +> +> Doron. +> + +------=_Part_18802_18168350.1144579356332 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
It'd be helpful if posted with the EXPLAIN of the slow running queries= + on the respective table.
+
 
+
cool.
+
L.
+

 
+
On 4/9/06, D= +oron Baranes <doron.bar= +anes@dbnet.co.il> wrote: +
+
+
+

Hi

+

 

+

I am new= + at postgres and I'm having performance issues.

+

I am run= +ning on postgres 7.4.6 on a pineapp with 512MB RAM.

+

I did a = +database vacuum analyze and rebuild my indexes.

+

When I p= +erform queries on tables of 2M-10M of rows it takes several minutes and +

+

I see at= + sar and top that the cpu and memory is heavily used.

+

 

+

I would = +be glad for guidance on server parameters or other configurations which wou= +ld help. +

+

 

+

10x.

+


Doro= +n.


+ +------=_Part_18802_18168350.1144579356332-- + +From pgsql-performance-owner@postgresql.org Sun Apr 9 06:47:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E337711F6B11 + for ; + Sun, 9 Apr 2006 06:47:39 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.346 +X-Spam-Level: * +X-Spam-Status: No, score=1.346 required=5 tests=[HTML_MESSAGE=0.001, + MISSING_SUBJECT=1.345] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id YhBFRq3dSsu8 + for ; + Sun, 9 Apr 2006 06:47:32 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id D568611F6AE4 + for ; + Sun, 9 Apr 2006 06:47:34 -0300 (ADT) +Received: from mailRelay.dbnet.co.il (mail.dbnet.co.il [212.143.51.17]) + by svr4.postgresql.org (Postfix) with ESMTP id 8AE085AF875 + for ; + Sun, 9 Apr 2006 09:47:34 +0000 (GMT) +Received: from mailRelay.dbnet.co.il (localhost [127.0.0.1]) + by localhost.dbnet.co.il (Postfix) with ESMTP id 251723C114 + for ; + Sun, 9 Apr 2006 13:11:41 +0300 (IDT) +Received: from exchange-1.dbnet.co.il (mail [172.16.2.1]) + by mailRelay.dbnet.co.il (Postfix) with ESMTP id 096E83C0E7 + for ; + Sun, 9 Apr 2006 13:11:41 +0300 (IDT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C65BC3.0CF94190" +Subject: +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Date: Sun, 9 Apr 2006 12:47:52 +0200 +Message-ID: <0BA77301DFF4B24C9C5DAA74138BF95001E1E7@exchange-1.dbnet.co.il> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-index: AcZbwwdZ18YMMOQZTkimW0uXoiqv9Q== +From: "Doron Baranes" +To: +X-Archive-Number: 200604/173 +X-Sequence-Number: 18257 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C65BC3.0CF94190 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + +Hi + +=20 + +I am new at postgres and I'm having performance issues. + +I am running on postgres 7.4.6 on a pineapp with 512MB RAM. + +I did a database vacuum analyze and rebuild my indexes. + +When I perform queries on tables of 2M-10M of rows it takes several +minutes and + +I see at sar and top that the cpu and memory is heavily used. + +=20 + +I would be glad for guidance on server parameters or other +configurations which would help. + +=20 + +10x. + + +Doron. + + +------_=_NextPart_001_01C65BC3.0CF94190 +Content-Type: text/html; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hi<= +/p> + +

 

+ +

I +am new at postgres and I'm having performance = +issues.

+ +

I +am running on postgres 7.4.6 on a pineapp with 512MB = +RAM.

+ +

I +did a database vacuum analyze and rebuild my = +indexes.

+ +

When +I perform queries on tables of 2M-10M of rows it takes several minutes = +and

+ +

I +see at sar and top that the cpu and memory is heavily = +used.

+ +

 

+ +

I +would be glad for guidance on server parameters or other configurations = +which +would help.

+ +

 

+ +

10x.

+ +


+Doron.

+ +
+ + + + + +------_=_NextPart_001_01C65BC3.0CF94190-- + +From pgsql-performance-owner@postgresql.org Sun Apr 9 08:07:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C39F811F6D1C + for ; + Sun, 9 Apr 2006 08:07:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.08 +X-Spam-Level: +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id LZ9zrDKtZ9cy + for ; + Sun, 9 Apr 2006 08:07:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.ipf.is (scania.ipf.is [85.197.192.147]) + by postgresql.org (Postfix) with ESMTP id 1EC0D11F66D2 + for ; + Sun, 9 Apr 2006 08:07:28 -0300 (ADT) +Received: (qmail 3067 invoked by uid 1010); 9 Apr 2006 11:06:48 +0000 +Received: from 85.197.216.186 by scania (envelope-from , + uid 1008) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1235. spamassassin: 3.1.1. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.3/4.5):. + Processed in 0.288507 secs); 09 Apr 2006 11:06:48 -0000 +X-Antivirus-IPF-Mail-From: gnari@hive.is via scania +X-Antivirus-IPF: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.3/4.5):. + Processed in 0.288507 secs Process 3060) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx2.ipf.is with SMTP; 9 Apr 2006 11:06:47 +0000 +Subject: Re: +From: Ragnar +To: Doron Baranes +Cc: pgsql-performance@postgresql.org +In-Reply-To: <0BA77301DFF4B24C9C5DAA74138BF95001E1E7@exchange-1.dbnet.co.il> +References: <0BA77301DFF4B24C9C5DAA74138BF95001E1E7@exchange-1.dbnet.co.il> +Content-Type: text/plain +Date: Sun, 09 Apr 2006 11:10:16 +0000 +Message-Id: <1144581016.32289.131.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/175 +X-Sequence-Number: 18259 + +On sun, 2006-04-09 at 12:47 +0200, Doron Baranes wrote: +> Hi +> + +> I am running on postgres 7.4.6 on a pineapp with 512MB RAM. +> +> I did a database vacuum analyze and rebuild my indexes. + +If you have previously done a lot of deletes or updates +without regular vacuums, you may have to do a + VACUUM FULL ANALYZE +once to get the table into normal state. + +After this, regular normal VACUUM ANALYZE should be +enough. + +> When I perform queries on tables of 2M-10M of rows it takes several +> minutes and + +We would need to see the output of EXPLAIN ANALYZE +for your query, along with some information about +the schema of the tables involved, such as what indexes +have been created. + +Also, let us know about any non-default configuration. + +gnari + + + +From pgsql-performance-owner@postgresql.org Sun Apr 9 12:34:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 43D5B11F60B3 + for ; + Sun, 9 Apr 2006 12:34:50 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.119, HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id GMZQLnToekS0 + for ; + Sun, 9 Apr 2006 12:34:44 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.188]) + by postgresql.org (Postfix) with ESMTP id B8F4511F60E6 + for ; + Sun, 9 Apr 2006 12:34:44 -0300 (ADT) +Received: by nproxy.gmail.com with SMTP id p77so486386nfc + for ; + Sun, 09 Apr 2006 08:34:43 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=ZdP+n4eoo9tRPsPTYes+QvYewmqYhFq3kAGz41VHfub3fGE9+qt3K9eD+a6LnuvUHN8M1JeoFGQF8G5hbAtE3Rw3CHwG1oL+mcAWk9wfyQg+hKmHChp66D2MWv03XTl5BlLSZ6UAR51nMxWJpwGuLCMIUyi/UFXhbVNrFmSbG5A= +Received: by 10.49.3.14 with SMTP id f14mr1001273nfi; + Sun, 09 Apr 2006 08:34:43 -0700 (PDT) +Received: by 10.49.27.16 with HTTP; Sun, 9 Apr 2006 08:34:43 -0700 (PDT) +Message-ID: +Date: Sun, 9 Apr 2006 21:04:43 +0530 +From: "Rajesh Kumar Mallah" +To: "Chethana, Rao (IE10)" +Subject: Re: pls reply ASAP +Cc: theodoreloscalzo@mac.com, "Richard Huxton" , + pgsql-performance@postgresql.org +In-Reply-To: + +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_15814_10119885.1144596883544" +References: + +X-Archive-Number: 200604/176 +X-Sequence-Number: 18260 + +------=_Part_15814_10119885.1144596883544 +Content-Type: text/plain; charset=WINDOWS-1252 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 4/9/06, Chethana, Rao (IE10) wrote: +> +> +> +> +> Hello! +> +> +> +> Kindly go through the following , +> +> +> +> +> +> I wanted to know whether, the command line arguments(function arguments) +------ $1 $2 $3 -- can be used as in the following , like, ---- +> +> +> +> +> +> CREATE TYPE TT AS(something,something,=85=85=85=85=85=85=85=85=85=85=85= +=85=85=85=85=85=85=85=85=85=85=85etc=85=85=85=85=85=85); +> +> CREATE OR REPLACE FUNCTION f1(varchar,varchar,varchar,varchar) RETURNS +=85=85=85=85=85=85=85..(something)=85=85=85=85. +> + +the overall idea expressed is doable. +following are comments + +1. you have to put RETURNS setof TT (if you plan to return TT) since you +used RETURN NEXT +2. you have to use SELECT INTO rec in the function where rec is rowtype T= +T + +hope it helps + +------- non technical comments +------------------------------------------------------ +3. its not a performance question , it shud have been marked more +appropriately to pgsql-sql i think. +4. its not a good etiquette to address email to someone and mark Cc to a +list. + +kind regds +mallah. + +> +> +> BEGIN +> +> SELECT a1,a2,a3,a4,a5,a6 +> +> FROM (SELECT * FROM T1, T2=85=85WHERE =85=85=85=85etc=85 Flag =3D 0 = +$1 $2 $3 $4) +> +> ORDER BY +=85=85=85=85=85=85=85=85 +> +> =85=85=85=85=85=85=85=85=85=85. +> +> RETURN NEXT =85=85=85; +> +> END LOOP; +> +> RETURN; +> +> END; +> +> ' LANGUAGE 'plpgsql'; +> +> +> +> NOTE : The values for $1 $2 $3 $4 will be passed when the function i= +s +invoked(called) from the command prompt. +> +> +> +> I tried implementing the above, but this type of usage is not supported +, how should use it? +> +> +> +> I am converting from (sprintf, "SELECT query stmts (which uses %s %s +%s %s =85=85 ) to functions. +> +> +> +> +> +> Any help will be deeply appreciated. Thank you. +> +> +> +> +> +> Kind regards, +> +> Chethana. +> +> +> +> +> +> + +------=_Part_15814_10119885.1144596883544 +Content-Type: text/html; charset=WINDOWS-1252 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 4/9/06, Chethana, Rao (IE10) <Chethana.Rao@honeywell.com> wrote:
>
>&n= +bsp;            = +;   
>  
>
> Hello! &nbs= +p;
>
>    
+>
> Kindly go through the following ,  
>
>= +;    
>
>    
> = +
> +I wanted to know whether, the command line arguments(function +arguments) ------  $1 $2 $3   --  can be +used  as in the following , like, ----  
>
&g= +t;    
>
>    
>= +
> CREATE TYPE TT AS(something,something,=85=85=85=85=85=85=85=85=85= +=85=85=85=85=85=85=85=85=85=85=85=85=85etc=85=85=85=85=85=85);  <= +br>>
> CREATE OR REPLACE FUNCTION f1(varchar,varchar,varchar,varc= +har) RETURNS =85=85=85=85=85=85=85..(something)=85=85=85=85.   +
>
+
+the overall idea expressed is doable.
+following are comments
+
+1. you have to put RETURNS setof TT (if you plan to return TT) since you us= +ed RETURN NEXT
+2.  you have to use SELECT INTO rec  in the function where rec is= + rowtype TT
+
+hope it helps
+
+------- non technical comments --------------------------------------------= +----------
+3. its not a performance question , it shud have been marked more appropria= +tely to pgsql-sql  i think.
+4. its not a good etiquette to address email to someone and mark Cc to a li= +st.
+
+kind regds
+mallah.
+
>    
>
> BEGIN  
>= +
>  SELECT a1,a2,a3,a4,a5,a6  
>
>&= +nbsp; FROM (SELECT * FROM T1, T2=85=85WHERE =85=85=85=85etc=85 &n= +bsp; Flag =3D 0   $1 $2 $3 $4)  
>
> = + ORDER +BY +=85=85=85=85=85=85=85=85        &nb= +sp;            = +            &nb= +sp;            = +            &nb= +sp;           
&g= +t;
> =85=85=85=85=85=85=85=85=85=85.  
>
> RE= +TURN NEXT =85=85=85;  
>
>   END LOOP;&nbs= +p; 
>
>   RETURN;  
>
> = +END;   +
>
> ' LANGUAGE 'plpgsql';  
>
> &= +nbsp;  
>
> +NOTE :    The values for  $1 $2 $3 +$4  will be passed when the function is +invoked(called)  from the command prompt.  
> >    
>
> +I  tried implementing the above, but  this type of +usage is not supported , how should use it?    
>= +
>    
>
>  I +am converting  from (sprintf, "SELECT query stmts (which +uses   %s %s %s %s  =85=85 +)        to +functions.  
>
>    
> >    
>
> Any help will be deeply appr= +eciated.  Thank you.  
>
>  &nbs= +p; 
>
>    
>
> Kind reg= +ards,  
>
>       Chet= +hana.   +
>
>    
>
>   = +; 
>
>        &nb= +sp; 

+ +------=_Part_15814_10119885.1144596883544-- + +From pgsql-performance-owner@postgresql.org Sun Apr 9 15:23:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 40D0511F68C3 + for ; + Sun, 9 Apr 2006 15:23:01 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id waH3PkEIUWl5 + for ; + Sun, 9 Apr 2006 15:22:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zeus.gigaweb.cz (zeus.gigaweb.cz [81.0.236.19]) + by postgresql.org (Postfix) with SMTP id C82C411F622F + for ; + Sun, 9 Apr 2006 15:22:55 -0300 (ADT) +Received: (qmail 4237 invoked from network); 9 Apr 2006 18:22:54 -0000 +Received: from unknown (HELO ?192.168.1.101?) (89.102.142.167) + by 0 with SMTP; 9 Apr 2006 18:22:54 -0000 +Message-ID: <443950FB.4050707@fuzzy.cz> +Date: Sun, 09 Apr 2006 20:22:51 +0200 +From: Tomas Vondra +User-Agent: Mail/News 1.5 (X11/20060131) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: serious problems with vacuuming databases +X-Enigmail-Version: 0.94.0.0 +Content-Type: text/plain; charset=ISO-8859-2 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/177 +X-Sequence-Number: 18261 + +Hello, + +we have some performance problems with postgres 8.0.4, more precisely +with vacuuming 'large' database with a lot of deleted rows. + +We had a 3.2 GB database, consisting mainly from 4 large tables, two of +them (say table A and B) having about 14.000.000 of rows and 1 GB of +size each, and two (say C and D) having about 4.000.000 of rows and 500 +MB each. The rest of the database is not important. + +We've decided to remove unneeded 'old' data, which means removing about +99.999% of rows from tables A, C and D (about 2 GB of data). At the +beginning, the B table (containing aggregated from A, C and D) was +emptied (dropped and created) and filled in with current data. Then, +before the deletion the data from tables A, C, D were backed up using +another tables (say A_old, C_old, D_old) filled in using + + INSERT INTO A SELECT * FROM A_old ... + +and fixed so there are no duplicities (rows both in A and A_old). Then +these data were deleted from A, C, D and tables A_old, C_old and D_old +were dumped, truncated and all the tables were vacuumed (with FULL +ANALYZE options). So the procedure was this + +1) drop, create and fill table B (aggregated data from A, C, D) +2) copy 'old' data from A, C and D to A_old, C_old a D_old +3) delete old data from A, C, D +4) dump data from A_old, C_old and D_old +5) truncate tables A, C, D +6) vacuum full analyze tables A, C, D, A_old, C_old and D_old + +So the dump of the fatabase has about 1.2 GB of data, from which about +1 GB is in the B table (the one rebuilt in step 1). This was done yesterday. + +The problem is this - today, we run a scheduled VACUUM FULL ANALYZE for +the whole database, and it runs for about 10 hours already, which is +much more than usual (and it is still running). + +The hardware is not too bad - it's Dell server with 2 x 3.0 GHz P4 HT, +4GB of RAM, 2x15k SCSI drives in hw RAID etc. + +The question is why this happens and how to get round that. I guess it's +caused by a huge amount of data deleted yesterday, but on the other side +all the modified tables were vacuumed at the end. But I guess dropping +and reloading the whole database would be much faster (at most 1.5 hour +including creating indexes etc.) + +thanks for your advices +Tomas + +From pgsql-performance-owner@postgresql.org Sun Apr 9 15:38:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E567011F602E + for ; + Sun, 9 Apr 2006 15:38:02 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.447 +X-Spam-Level: * +X-Spam-Status: No, score=1.447 required=5 tests=[AWL=-0.472, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 5bG9RkDhP-AA + for ; + Sun, 9 Apr 2006 15:37:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.surnet.cl (mx1.surnet.cl [216.155.73.180]) + by postgresql.org (Postfix) with ESMTP id 945B511F602A + for ; + Sun, 9 Apr 2006 15:37:56 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx1.surnet.cl with ESMTP; 09 Apr 2006 14:37:48 -0400 +X-IronPort-AV: i="4.04,104,1144036800"; + d="scan'208"; a="52379570:sNHT20020152" +Received: from alvh.no-ip.org (201.221.200.14) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD00E08DFD; Sun, 9 Apr 2006 14:37:48 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id DEAF8C2DC22; Sun, 9 Apr 2006 14:37:47 -0400 (CLT) +Date: Sun, 9 Apr 2006 14:37:47 -0400 +From: Alvaro Herrera +To: Tomas Vondra +Cc: pgsql-performance@postgresql.org +Subject: Re: serious problems with vacuuming databases +Message-ID: <20060409183747.GB15094@surnet.cl> +Mail-Followup-To: Tomas Vondra , pgsql-performance@postgresql.org +References: <443950FB.4050707@fuzzy.cz> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <443950FB.4050707@fuzzy.cz> +User-Agent: Mutt/1.5.11+cvs20060330 +X-Archive-Number: 200604/178 +X-Sequence-Number: 18262 + +Tomas Vondra wrote: + +Hi, + +> Then +> these data were deleted from A, C, D and tables A_old, C_old and D_old +> were dumped, truncated and all the tables were vacuumed (with FULL +> ANALYZE options). So the procedure was this +> +> 1) drop, create and fill table B (aggregated data from A, C, D) +> 2) copy 'old' data from A, C and D to A_old, C_old a D_old +> 3) delete old data from A, C, D +> 4) dump data from A_old, C_old and D_old +> 5) truncate tables A, C, D +> 6) vacuum full analyze tables A, C, D, A_old, C_old and D_old +> +> So the dump of the fatabase has about 1.2 GB of data, from which about +> 1 GB is in the B table (the one rebuilt in step 1). This was done yesterday. +> +> The problem is this - today, we run a scheduled VACUUM FULL ANALYZE for +> the whole database, and it runs for about 10 hours already, which is +> much more than usual (and it is still running). + +Probably the indexes are bloated after the vacuum full. I think the +best way to get rid of the "fat" is to recreate both tables and indexes +anew. For this the best tool would be to CLUSTER the tables on some +index, probably the primary key. This will be much faster than +VACUUMing the tables, and the indexes will be much smaller as result. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Sun Apr 9 15:54:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C7D5E11F61CF + for ; + Sun, 9 Apr 2006 15:54:03 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.126 +X-Spam-Level: +X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id tZodDwCCek4V + for ; + Sun, 9 Apr 2006 15:53:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id D4F1811F65E2 + for ; + Sun, 9 Apr 2006 15:53:59 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k39Irv76012735; + Sun, 9 Apr 2006 14:53:57 -0400 (EDT) +To: Tomas Vondra +cc: pgsql-performance@postgresql.org +Subject: Re: serious problems with vacuuming databases +In-reply-to: <443950FB.4050707@fuzzy.cz> +References: <443950FB.4050707@fuzzy.cz> +Comments: In-reply-to Tomas Vondra + message dated "Sun, 09 Apr 2006 20:22:51 +0200" +Date: Sun, 09 Apr 2006 14:53:57 -0400 +Message-ID: <12734.1144608837@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/179 +X-Sequence-Number: 18263 + +Tomas Vondra writes: +> 1) drop, create and fill table B (aggregated data from A, C, D) +> 2) copy 'old' data from A, C and D to A_old, C_old a D_old +> 3) delete old data from A, C, D +> 4) dump data from A_old, C_old and D_old +> 5) truncate tables A, C, D +> 6) vacuum full analyze tables A, C, D, A_old, C_old and D_old + +Steps 3/5/6 make no sense at all to me: why bother deleting data retail +when you are about to truncate the tables, and why bother vacuuming a +table you just truncated? Is the above *really* what you did? + +> The problem is this - today, we run a scheduled VACUUM FULL ANALYZE for +> the whole database, and it runs for about 10 hours already, which is +> much more than usual (and it is still running). + +Is it actually grinding the disk, or is it just blocked waiting for +someone's lock? If it's actually doing work, which table is it working +on? (You should be able to figure that out by looking in pg_locks, +or by strace'ing the process to see which files it's touching.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 9 17:25:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AD87311F6AE7 + for ; + Sun, 9 Apr 2006 17:24:59 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id X-IEVr4PZ8Hj + for ; + Sun, 9 Apr 2006 17:24:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 0A9A011F6922 + for ; + Sun, 9 Apr 2006 17:24:49 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k39KOjR15478; + Sun, 9 Apr 2006 16:24:45 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200604092024.k39KOjR15478@candle.pha.pa.us> +Subject: Re: Scaling up PostgreSQL in Multiple CPU / Dual Core +In-Reply-To: <60r74rskn2.fsf@dba2.int.libertyrms.com> +To: Chris Browne +Date: Sun, 9 Apr 2006 16:24:44 -0400 (EDT) +CC: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Archive-Number: 200604/180 +X-Sequence-Number: 18264 + + +Added to TODO: + + * Experiment with multi-threaded backend better resource utilization + This would allow a single query to make use of multiple CPU's or + multiple I/O channels simultaneously. + + +--------------------------------------------------------------------------- + +Chris Browne wrote: +> mstone+postgres@mathom.us (Michael Stone) writes: +> +> > On Fri, Mar 24, 2006 at 01:21:23PM -0500, Chris Browne wrote: +> >>A naive read on this is that you might start with one backend process, +> >>which then spawns 16 more. Each of those backends is scanning through +> >>one of those 16 files; they then throw relevant tuples into shared +> >>memory to be aggregated/joined by the central one. +> > +> > Of course, table scanning is going to be IO limited in most cases, and +> > having every query spawn 16 independent IO threads is likely to slow +> > things down in more cases than it speeds them up. It could work if you +> > have a bunch of storage devices, but at that point it's probably +> > easier and more direct to implement a clustered approach. +> +> All stipulated, yes. It obviously wouldn't be terribly useful to scan +> more aggressively than I/O bandwidth can support. The point is that +> this is one of the kinds of places where concurrent processing could +> do some good... +> -- +> let name="cbbrowne" and tld="acm.org" in name ^ "@" ^ tld;; +> http://cbbrowne.com/info/spiritual.html +> Save the whales. Collect the whole set. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + +-- + Bruce Momjian http://candle.pha.pa.us + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Sun Apr 9 17:34:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1B1FD11F65EE + for ; + Sun, 9 Apr 2006 17:34:10 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.214 +X-Spam-Level: +X-Spam-Status: No, score=0.214 required=5 tests=[AWL=0.025, + MISSING_HEADERS=0.189] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id FRc5omXH+vNC + for ; + Sun, 9 Apr 2006 17:34:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zeus.gigaweb.cz (zeus.gigaweb.cz [81.0.236.19]) + by postgresql.org (Postfix) with SMTP id 9DF0411F653F + for ; + Sun, 9 Apr 2006 17:34:01 -0300 (ADT) +Received: (qmail 27774 invoked from network); 9 Apr 2006 20:34:02 -0000 +Received: from unknown (HELO ?192.168.1.101?) (89.102.142.167) + by 0 with SMTP; 9 Apr 2006 20:34:02 -0000 +Message-ID: <44396FB6.6000900@fuzzy.cz> +Date: Sun, 09 Apr 2006 22:33:58 +0200 +From: Tomas Vondra +User-Agent: Mail/News 1.5 (X11/20060131) +MIME-Version: 1.0 +CC: pgsql-performance@postgresql.org +Subject: Re: serious problems with vacuuming databases +References: <443950FB.4050707@fuzzy.cz> <12734.1144608837@sss.pgh.pa.us> +In-Reply-To: <12734.1144608837@sss.pgh.pa.us> +X-Enigmail-Version: 0.94.0.0 +Content-Type: text/plain; charset=ISO-8859-2 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/181 +X-Sequence-Number: 18265 + +Tom Lane wrote: +> Tomas Vondra writes: +>> 1) drop, create and fill table B (aggregated data from A, C, D) +>> 2) copy 'old' data from A, C and D to A_old, C_old a D_old +>> 3) delete old data from A, C, D +>> 4) dump data from A_old, C_old and D_old +>> 5) truncate tables A, C, D +>> 6) vacuum full analyze tables A, C, D, A_old, C_old and D_old +> +> Steps 3/5/6 make no sense at all to me: why bother deleting data retail +> when you are about to truncate the tables, and why bother vacuuming a +> table you just truncated? Is the above *really* what you did? + +Yes, the above is exactly what I did with the exception that there's an +error in the step (5) - there should be truncation of the _old tables. +The reasons that led me to this particular steps are two: + +(a) I don't want to delete all the data, just data older than two days. + Until today we've kept all the data (containing two years access log + for one of our production websites), but now we've decided to remove + the data we don't need and leave just the aggregated version. That's + why I have used DELETE rather than TRUNCATE. + +(b) I want to create 'incremental' backups, so once I'll need the data + I can take several packages (dumps of _old tables) and import them + one after another. Using pg_dump doesn't allow me this - dumping the + whole tables A, C and D is not an option, because I want to leave + some of the data in the tables. + + From now on, the tables will be cleared on a daily (or maybe weekly) + basis, which means much smaller amount of data (about 50.000 rows + a day). +> +>> The problem is this - today, we run a scheduled VACUUM FULL ANALYZE for +>> the whole database, and it runs for about 10 hours already, which is +>> much more than usual (and it is still running). +> +> Is it actually grinding the disk, or is it just blocked waiting for +> someone's lock? If it's actually doing work, which table is it working +> on? (You should be able to figure that out by looking in pg_locks, +> or by strace'ing the process to see which files it's touching.) + +Thanks for the hint, I'll try to figure that in case the dump/reload +recommended by Alvaro Herrera doesn't help. But as far as I know the +disks are not grinded right now, so I guess it's the problem with indexes. + +t.v. + +From pgsql-performance-owner@postgresql.org Sun Apr 9 17:37:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C0B2911F65EE + for ; + Sun, 9 Apr 2006 17:37:15 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.167 +X-Spam-Level: +X-Spam-Status: No, score=0.167 required=5 tests=[AWL=0.167] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id YSc8kpa+zEEi + for ; + Sun, 9 Apr 2006 17:37:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zeus.gigaweb.cz (zeus.gigaweb.cz [81.0.236.19]) + by postgresql.org (Postfix) with SMTP id 53BDD11F660C + for ; + Sun, 9 Apr 2006 17:37:07 -0300 (ADT) +Received: (qmail 28411 invoked from network); 9 Apr 2006 20:37:08 -0000 +Received: from unknown (HELO ?192.168.1.101?) (89.102.142.167) + by 0 with SMTP; 9 Apr 2006 20:37:08 -0000 +Message-ID: <44397071.80008@fuzzy.cz> +Date: Sun, 09 Apr 2006 22:37:05 +0200 +From: Tomas Vondra +User-Agent: Mail/News 1.5 (X11/20060131) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: serious problems with vacuuming databases +References: <443950FB.4050707@fuzzy.cz> <20060409183747.GB15094@surnet.cl> +In-Reply-To: <20060409183747.GB15094@surnet.cl> +X-Enigmail-Version: 0.94.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/182 +X-Sequence-Number: 18266 + +> Probably the indexes are bloated after the vacuum full. I think the +> best way to get rid of the "fat" is to recreate both tables and indexes +> anew. For this the best tool would be to CLUSTER the tables on some +> index, probably the primary key. This will be much faster than +> VACUUMing the tables, and the indexes will be much smaller as result. + +I guess you're right. I forgot to mention there are 12 composed indexes +on the largest (and not deleted) table B, having about 14.000.000 rows +and 1 GB of data. I'll try to dump/reload the database ... + +t.v. + +From pgsql-performance-owner@postgresql.org Sun Apr 9 17:45:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1787211F653F + for ; + Sun, 9 Apr 2006 17:45:02 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.246 +X-Spam-Level: +X-Spam-Status: No, score=0.246 required=5 tests=[AWL=0.057, + MISSING_HEADERS=0.189] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id JKqS7BHYFN2w + for ; + Sun, 9 Apr 2006 17:44:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zeus.gigaweb.cz (zeus.gigaweb.cz [81.0.236.19]) + by postgresql.org (Postfix) with SMTP id 61F1111F6379 + for ; + Sun, 9 Apr 2006 17:44:54 -0300 (ADT) +Received: (qmail 29605 invoked from network); 9 Apr 2006 20:44:55 -0000 +Received: from unknown (HELO ?192.168.1.101?) (89.102.142.167) + by 0 with SMTP; 9 Apr 2006 20:44:55 -0000 +Message-ID: <44397243.6010208@fuzzy.cz> +Date: Sun, 09 Apr 2006 22:44:51 +0200 +From: Tomas Vondra +User-Agent: Mail/News 1.5 (X11/20060131) +MIME-Version: 1.0 +CC: pgsql-performance@postgresql.org +Subject: Re: serious problems with vacuuming databases +References: <443950FB.4050707@fuzzy.cz> <20060409183747.GB15094@surnet.cl> + <44397071.80008@fuzzy.cz> +In-Reply-To: <44397071.80008@fuzzy.cz> +X-Enigmail-Version: 0.94.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/183 +X-Sequence-Number: 18267 + +> I guess you're right. I forgot to mention there are 12 composed indexes +> on the largest (and not deleted) table B, having about 14.000.000 rows +> and 1 GB of data. I'll try to dump/reload the database ... + +Aaargh, the problem probably is not caused by the largest table, as it +was dropped, filled in with the data and after that all the indexes were +created. The problem could be caused by the tables with deleted data, of +course. + +t.v. + +From pgsql-performance-owner@postgresql.org Sun Apr 9 17:46:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CEED211F602E + for ; + Sun, 9 Apr 2006 17:46:07 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.439 +X-Spam-Level: * +X-Spam-Status: No, score=1.439 required=5 tests=[AWL=-0.480, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id KcX06uUeJrlt + for ; + Sun, 9 Apr 2006 17:45:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.surnet.cl (mx1.surnet.cl [216.155.73.180]) + by postgresql.org (Postfix) with ESMTP id B94D011F65F8 + for ; + Sun, 9 Apr 2006 17:45:55 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx1.surnet.cl with ESMTP; 09 Apr 2006 16:45:55 -0400 +X-IronPort-AV: i="4.04,104,1144036800"; + d="scan'208"; a="52394954:sNHT18074096" +Received: from alvh.no-ip.org (201.221.200.14) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD00E0AA76; Sun, 9 Apr 2006 16:45:55 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 69A5DC2DC22; Sun, 9 Apr 2006 16:45:55 -0400 (CLT) +Date: Sun, 9 Apr 2006 16:45:55 -0400 +From: Alvaro Herrera +To: Tomas Vondra +Cc: pgsql-performance@postgresql.org +Subject: Re: serious problems with vacuuming databases +Message-ID: <20060409204555.GB16673@surnet.cl> +Mail-Followup-To: Tomas Vondra , pgsql-performance@postgresql.org +References: <443950FB.4050707@fuzzy.cz> <20060409183747.GB15094@surnet.cl> + <44397071.80008@fuzzy.cz> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <44397071.80008@fuzzy.cz> +User-Agent: Mutt/1.5.11+cvs20060330 +X-Archive-Number: 200604/184 +X-Sequence-Number: 18268 + +Tomas Vondra wrote: +> > Probably the indexes are bloated after the vacuum full. I think the +> > best way to get rid of the "fat" is to recreate both tables and indexes +> > anew. For this the best tool would be to CLUSTER the tables on some +> > index, probably the primary key. This will be much faster than +> > VACUUMing the tables, and the indexes will be much smaller as result. +> +> I guess you're right. I forgot to mention there are 12 composed indexes +> on the largest (and not deleted) table B, having about 14.000.000 rows +> and 1 GB of data. I'll try to dump/reload the database ... + +Huh, I didn't suggest to dump/reload. I suggested CLUSTER. You need to +apply it only to tables where you have lots of dead tuples, which IIRC +are A, C and D. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Sun Apr 9 18:49:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4E35D11F6CB3 + for ; + Sun, 9 Apr 2006 18:49:31 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.167 +X-Spam-Level: +X-Spam-Status: No, score=0.167 required=5 tests=[AWL=0.167] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id UQ3x4a1F1ndh + for ; + Sun, 9 Apr 2006 18:49:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zeus.gigaweb.cz (zeus.gigaweb.cz [81.0.236.19]) + by postgresql.org (Postfix) with SMTP id 88AC511F6C6D + for ; + Sun, 9 Apr 2006 18:49:24 -0300 (ADT) +Received: (qmail 6879 invoked from network); 9 Apr 2006 21:49:25 -0000 +Received: from unknown (HELO ?192.168.1.101?) (89.102.142.167) + by 0 with SMTP; 9 Apr 2006 21:49:25 -0000 +Message-ID: <44398162.6060004@fuzzy.cz> +Date: Sun, 09 Apr 2006 23:49:22 +0200 +From: Tomas Vondra +User-Agent: Mail/News 1.5 (X11/20060131) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: serious problems with vacuuming databases +References: <443950FB.4050707@fuzzy.cz> <20060409183747.GB15094@surnet.cl> + <44397071.80008@fuzzy.cz> <20060409204555.GB16673@surnet.cl> +In-Reply-To: <20060409204555.GB16673@surnet.cl> +X-Enigmail-Version: 0.94.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/185 +X-Sequence-Number: 18269 + +> Huh, I didn't suggest to dump/reload. I suggested CLUSTER. You need to +> apply it only to tables where you have lots of dead tuples, which IIRC +> are A, C and D. + +Sorry, I should read more carefully. Will clustering a table according +to one index solve problems with all the indexes on the table (if the +table has for example two indexes?). + +t.v. + +From pgsql-performance-owner@postgresql.org Sun Apr 9 19:02:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A437811F61FA + for ; + Sun, 9 Apr 2006 19:02:00 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.445 +X-Spam-Level: * +X-Spam-Status: No, score=1.445 required=5 tests=[AWL=-0.474, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id vsKnZFEUCzia + for ; + Sun, 9 Apr 2006 19:01:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by postgresql.org (Postfix) with ESMTP id 116A911F60B3 + for ; + Sun, 9 Apr 2006 19:01:54 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx2.surnet.cl with ESMTP; 09 Apr 2006 18:01:55 -0400 +X-IronPort-AV: i="4.02,198,1139194800"; + d="scan'208"; a="41931943:sNHT19646540" +Received: from alvh.no-ip.org (201.221.200.14) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD00E0B9A5; Sun, 9 Apr 2006 18:01:54 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id BF6E7C2DC22; Sun, 9 Apr 2006 18:01:53 -0400 (CLT) +Date: Sun, 9 Apr 2006 18:01:53 -0400 +From: Alvaro Herrera +To: Tomas Vondra +Cc: pgsql-performance@postgresql.org +Subject: Re: serious problems with vacuuming databases +Message-ID: <20060409220153.GC16673@surnet.cl> +Mail-Followup-To: Tomas Vondra , pgsql-performance@postgresql.org +References: <443950FB.4050707@fuzzy.cz> <20060409183747.GB15094@surnet.cl> + <44397071.80008@fuzzy.cz> <20060409204555.GB16673@surnet.cl> + <44398162.6060004@fuzzy.cz> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <44398162.6060004@fuzzy.cz> +User-Agent: Mutt/1.5.11+cvs20060330 +X-Archive-Number: 200604/186 +X-Sequence-Number: 18270 + +Tomas Vondra wrote: +> > Huh, I didn't suggest to dump/reload. I suggested CLUSTER. You need to +> > apply it only to tables where you have lots of dead tuples, which IIRC +> > are A, C and D. +> +> Sorry, I should read more carefully. Will clustering a table according +> to one index solve problems with all the indexes on the table (if the +> table has for example two indexes?). + +Yes, it will rebuild all indexes. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Mon Apr 10 23:30:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E8B1111F66F2 + for ; + Mon, 10 Apr 2006 00:43:51 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.55 +X-Spam-Level: +X-Spam-Status: No, score=0.55 required=5 tests=[NO_REAL_NAME=0.55] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id i7Hw97pPToh1 + for ; + Mon, 10 Apr 2006 00:43:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id C418D11F621C + for ; + Mon, 10 Apr 2006 00:43:49 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 1ADA130D11; Mon, 10 Apr 2006 05:43:49 +0200 (MET DST) +From: FavoYang@gmail.com +X-Newsgroups: pgsql.performance +Subject: slow "IN" clause +Date: 9 Apr 2006 20:43:40 -0700 +Organization: http://groups.google.com +Lines: 10 +Message-ID: <1144640620.925899.274170@z34g2000cwc.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.7.12) Gecko/20050922 Firefox/1.0.7 (Debian package + 1.0.7-1),gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: z34g2000cwc.googlegroups.com; posting-host=221.122.43.98; + posting-account=WVvL5A0AAAD4eKbsP0Kalew21Vv8aQF8 +To: pgsql-performance@postgresql.org +X-Archive-Number: 200604/224 +X-Sequence-Number: 18308 + +I have a slow sql: +SELECT * FROM mytable WHERE id IN (1,3,5,7,....3k here...); +mytable is about 10k rows. + +if don't use the "IN" clause, it will cost 0,11 second, otherwise it +will cost 2.x second +I guess pg use linear search to deal with IN clause, is there any way +to let pg use other search method with IN clause? (ex.Binary Search or +hash Search) + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 01:48:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 60FC211F636B + for ; + Mon, 10 Apr 2006 01:48:25 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.137 +X-Spam-Level: +X-Spam-Status: No, score=0.137 required=5 tests=[AWL=0.137] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id cA+T+bYISso6 + for ; + Mon, 10 Apr 2006 01:48:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 849D611F628C + for ; + Mon, 10 Apr 2006 01:48:22 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 88B4A30D11; Mon, 10 Apr 2006 06:48:21 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: slow "IN" clause +Date: Mon, 10 Apr 2006 12:44:46 +0800 +Organization: Hub.Org Networking Services +Lines: 19 +Message-ID: +References: <1144640620.925899.274170@z34g2000cwc.googlegroups.com> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +To: pgsql-performance@postgresql.org +X-Archive-Number: 200604/187 +X-Sequence-Number: 18271 + + + wrote +> I have a slow sql: +> SELECT * FROM mytable WHERE id IN (1,3,5,7,....3k here...); +> mytable is about 10k rows. +> +> if don't use the "IN" clause, it will cost 0,11 second, otherwise it +> will cost 2.x second +> I guess pg use linear search to deal with IN clause, is there any way +> to let pg use other search method with IN clause? (ex.Binary Search or +> hash Search) +> + +If you can put (1, 3, .., 3k) in a table, PG may choose a hash join. + +Regards, +Qingqing + + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 02:50:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BD49611F65BE + for ; + Mon, 10 Apr 2006 02:50:48 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.001 +X-Spam-Level: +X-Spam-Status: No, score=0.001 required=5 tests=[AWL=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06Xzd2Dbhv-B + for ; + Mon, 10 Apr 2006 02:50:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 16D7611F602D + for ; + Mon, 10 Apr 2006 02:50:44 -0300 (ADT) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Sun, 9 Apr 2006 23:50:42 -0600 +In-Reply-To: <4439D778.10702@2i.com> +References: + <4439D778.10702@2i.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-9-984797853; + protocol="application/pkcs7-signature" +Message-Id: +Cc: PostgreSQL Performance +From: Brendan Duddridge +Subject: Re: OT: Data structure design question: How do they count so fast? +Date: Sun, 9 Apr 2006 23:50:38 -0600 +To: Brandon Hines +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/188 +X-Sequence-Number: 18272 + + +--Apple-Mail-9-984797853 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Hi Brandon, + +Thanks for your suggestion. I'll think about that one. Part of the +problem is also trying to figure out what the remaining set of +attributes and attribute values are, so that slows it down +considerably too. There are many many combinations of attribute +values that can be clicked on. + +More work to do! + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 9, 2006, at 9:56 PM, Brandon Hines wrote: + +> Brendan, +> +> I have a number of applications the require similar functionality. +> What I typically do is to create a count table that gets updated +> with a trigger. But instead of keeping absolute counts, I keep +> counts of the smallest necessary element. For example, I have a +> table with approx 12 million elements, each element belongs to one +> of a thousand classes of elements. The materialized view table +> with only about a thousand rows is small enough for sum() queries +> of various classes fast enough for web pages. +> +> -Brandon +> +> Brendan Duddridge wrote: +>> Hi, +>> First of all, the reason I'm posting on the PostgreSQL Performance +>> list is we have a performance issue with one of our applications +>> and it's related to the speed at which PostgreSQL can do counts. +>> But it's also related to the data structure we've designed to +>> develop our comparison shopping engine. It's very normalized and +>> the speed of our queries are slowing down considerably as we add +>> more and more data. +>> So I've been looking at some of the other comparison shopping +>> engines and I'm trying to figure out how they manage to get the +>> counts of their products for a set of attributes and attribute +>> values so quickly. +>> For example, on the following page, they have 1,260,658 products: +>> http://www.mysimon.com/Home-Furnishings/9000-10975_8-0.html?tag=glnav +>> They display 3 attributes with values on the page: Price Range, +>> Home Furnishing Type, and Store. Plus there are a selection of +>> other attributes not displaying the value choices. +>> For Price Range, they have the following values and product counts +>> (in brackets): +>> # Below $20 (204,315) +>> # $20 - $50 (234,694) +>> # $50 - $80 (188,811) +>> # $80 - $130 (182,721) +>> # $130 - $240 (222,519) +>> For Home Furnishing Type they have: +>> # Wall Art and Decor (438,493) +>> # Lighting (243,098) +>> # Bathroom Furnishings (132,441) +>> # Rugs (113,216) +>> # Decorative Accents (65,418) +>> And for Store they have: +>> # Art.com (360,933) +>> # HomeAnnex (130,410) +>> # AllPosters.com (72,529) +>> # HomeClick.com (61,423) +>> # 1STOPlighting Superstore (32,074) +>> Now, initially I thought they would just pre-compute these counts, +>> but the problem is, when you click on any of the above attribute +>> values, they reduce the remaining possible set of matching +>> products (and set of possible remaining attributes and attribute +>> values) by the amount displayed next to the attribute value +>> selected. You can click on any combination of attribute values to +>> filter down the remaining set of matching products, so there's a +>> large combination of paths you can take to arrive at a set of +>> products you might be interested in. +>> Do you think they are pre-computed? Or do you think they might use +>> a query similar to the following?: +>> select pav.attribute_value_id, count(p.product_id) +>> from product_attribute_value pav, +>> attribute a, +>> product p +>> where a.attribute_id in (some set of attribute ids) and +>> pav.product_id = p.product_id and +>> pav.attribute_id = a.attribute_id and p.product_id in +>> (select product_id +>> from category_product +>> where category_id = some category id) and +>> p.is_active = 'true' +>> group by pav.attribute_value_id; +>> It would seem to me that although the above query suggests a +>> normalized database structure, that joining with 3 tables plus a +>> 4th table in the sub-query with an IN qualifier and grouping to +>> get the product counts would take a VERY long time, especially on +>> a possible result set of 1,260,658 products. The other issue is +>> trying to figure out what the remaining set of possible attribute +>> and attribute values are in order to reach the remaining set of +>> products. +>> Does anyone have any insights into what kind of data structures +>> would be necessary to accomplish such a feat? I know that +>> PostgreSQL has performance issues with counting rows, so I can't +>> imagine being able to use the above kind of query to get the +>> results we need. I don't know what kind of database backend +>> mysimon is using either. It would also seem to be logical that +>> having a flattened data structure would seem to be necessary in +>> order to get the performance required. Their pages seem to load +>> pretty fast. +>> We are possibly considering some kind of pre-computed decision- +>> tree type data structure to get the counts of the set of products +>> that could be reached by selecting any combination of attributes +>> and attribute values. Does this seem like a reasonable idea? +>> Perhaps there's a better way? +>> I also apologize if this isn't the appropriate list to publish +>> this kind of question to. The reason I posted here was because it +>> is a performance related question, but not necessarily directly +>> related to PostgreSQL. It's just that we are using PostgreSQL for +>> our product comparison engine so I thought there could be some +>> PostgreSQL specific optimizations that could be made. If not, +>> please let me know and I'll move it elsewhere. Thanks very much, +>> * +>> *____________________________________________________________________ +>> *Brendan Duddridge* | CTO | 403-277-5591 x24 | +>> brendan@clickspace.com +>> * +>> *ClickSpace Interactive Inc. +>> Suite L100, 239 - 10th Ave. SE +>> Calgary, AB T2G 0V9 +>> http://www.clickspace.com +> +> + + +--Apple-Mail-9-984797853 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIDCCAtkw +ggJCoAMCAQICAw84ujANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh +d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt +YWlsIElzc3VpbmcgQ0EwHhcNMDUwNzI5MjAxMTQzWhcNMDYwNzI5MjAxMTQzWjBIMR8wHQYDVQQD +ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSUwIwYJKoZIhvcNAQkBFhZicmVuZGFuQGNsaWNrc3Bh +Y2UuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqWfMCdFgKzXroGNqJuU3eyDC +K/Gxts3mtmIdgcHGmUjRKdlBSfkmcCBUDPJIt4QQc91sY3h8Itg0EAsF+1yFECU6afn/1SEAHSDK +6Q86PclF58/Dux2FYNGpeIAw/lisZ2UCyIYoUiWtEDKCBq5jDuYzcGkFS5Csz+/rEL+BHTXQVqnS +nUdUaXu9xdZn4wgjB/n65UEYRqr0LGN53CGsFcA9uC+ViS7WyBtzJcP02LMNT+cAZ7TKHw4Q/ZeG +5ptPgQHLTD2wza3GMbPQ4fYK6aNPA+lVzslLSCjyQpg55gVyQQlV0k/5zU5Q5m48ZtqwOqN+fPYd +eIB7H5y1SFLd/wIDAQABozMwMTAhBgNVHREEGjAYgRZicmVuZGFuQGNsaWNrc3BhY2UuY29tMAwG +A1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEEBQADgYEAT+6hGvStHoRO0OCHlJev31BpUlvPSpbYVKJN +i5kCMF164sSX7j0IRvcyU6DfUuW7samTluXJbANyuX1ZIpXulGen5EEc2NV7eU/rMz6ExklMShTh +++azcvmMjOzTuqXi3ZsIjwzBBhqCB0U++kYlMlHEYla2qKLFbXY6PiH0a8swggM/MIICqKADAgEC +AgENMA0GCSqGSIb3DQEBBQUAMIHRMQswCQYDVQQGEwJaQTEVMBMGA1UECBMMV2VzdGVybiBDYXBl +MRIwEAYDVQQHEwlDYXBlIFRvd24xGjAYBgNVBAoTEVRoYXd0ZSBDb25zdWx0aW5nMSgwJgYDVQQL +Ex9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMSQwIgYDVQQDExtUaGF3dGUgUGVyc29u +YWwgRnJlZW1haWwgQ0ExKzApBgkqhkiG9w0BCQEWHHBlcnNvbmFsLWZyZWVtYWlsQHRoYXd0ZS5j +b20wHhcNMDMwNzE3MDAwMDAwWhcNMTMwNzE2MjM1OTU5WjBiMQswCQYDVQQGEwJaQTElMCMGA1UE +ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFs +IEZyZWVtYWlsIElzc3VpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMSmPFVzVftO +ucqZWh5owHUEcJ3f6f+jHuy9zfVb8hp2vX8MOmHyv1HOAdTlUAow1wJjWiyJFXCO3cnwK4Vaqj9x +VsuvPAsH5/EfkTYkKhPPK9Xzgnc9A74r/rsYPge/QIACZNenprufZdHFKlSFD0gEf6e20TxhBEAe +ZBlyYLf7AgMBAAGjgZQwgZEwEgYDVR0TAQH/BAgwBgEB/wIBADBDBgNVHR8EPDA6MDigNqA0hjJo +dHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhhd3RlUGVyc29uYWxGcmVlbWFpbENBLmNybDALBgNVHQ8E +BAMCAQYwKQYDVR0RBCIwIKQeMBwxGjAYBgNVBAMTEVByaXZhdGVMYWJlbDItMTM4MA0GCSqGSIb3 +DQEBBQUAA4GBAEiM0VCD6gsuzA2jZqxnD3+vrL7CF6FDlpSdf0whuPg2H6otnzYvwPQcUCCTcDz9 +reFhYsPZOhl+hLGZGwDFGguCdJ4lUJRix9sncVcljd2pnDmOjCBPZV+V2vf3h9bGCE6u9uo05RAa +WzVNd+NWIXiC3CEZNd4ksdMdRv9dX2VPMYIC5zCCAuMCAQEwaTBiMQswCQYDVQQGEwJaQTElMCMG +A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv +bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujAJBgUrDgMCGgUAoIIBUzAYBgkqhkiG9w0BCQMx +CwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA0MTAwNTUwMzlaMCMGCSqGSIb3DQEJBDEW +BBQ6cYugSBXllm6wsPN8f7j8+n8DFzB4BgkrBgEEAYI3EAQxazBpMGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDDzi6MHoGCyqGSIb3DQEJEAILMWugaTBiMQswCQYD +VQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMj +VGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAw84ujANBgkqhkiG9w0BAQEFAASC +AQBdutJRr8/MESN6nMAQhcJVe3wEmAVGI0YdRGpxLHLDa2FBMYcxAPXSsnqYlEWaU3pI6Mou3NGH +ciNv+Wqb+JIW3gF1QKzLCQXp/cRsXfj52UWarNgejths/rtsEUSrCBHbx5uXXzSl+NNHLUctqDRj +zKPqbZzfk9GKkE2eEWlmWKCz1PkkpB7FM7CsRmQSSbDHpXEL/2FP+qwsRhyUNJCk9J4tsRIm2QHG +AEl6Q0jhOjyrt21Fm9hIVoAwAxS6IVjs8m9UQjkjHAiSUMkx66QSOVoQ1YwgTmm00n0E0qrsx7jZ +Q9ME8+YhQm9p5pfav8E+THyYiGz5Ap7EUFyxh9D7AAAAAAAA + +--Apple-Mail-9-984797853-- + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 03:59:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0EC5811F8B7B + for ; + Mon, 10 Apr 2006 03:59:02 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id V2evnPKkthP8 + for ; + Mon, 10 Apr 2006 03:58:45 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 4EE4111F7A49 + for ; + Mon, 10 Apr 2006 03:55:08 -0300 (ADT) +Received: from ki-communication.com (unknown [202.147.194.21]) + by svr4.postgresql.org (Postfix) with ESMTP id 66B605AF83C + for ; + Mon, 10 Apr 2006 06:55:05 +0000 (GMT) +Received: from edp01wks ([192.168.0.127]) by ki-communication.com with + Microsoft SMTPSVC(6.0.3790.1830); Mon, 10 Apr 2006 13:54:56 +0700 +From: "Ahmad Fajar" +To: "'Tomas Vondra'" +Cc: +Subject: Re: serious problems with vacuuming databases +Date: Mon, 10 Apr 2006 13:54:56 +0700 +Keywords: Postgresql +Message-ID: <003101c65c6b$ad079850$7f00a8c0@kicommunication.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook 11 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcZcCvEJ3XbmTYlTRJSg/o3GxHkICwAXaavA +In-Reply-To: <443950FB.4050707@fuzzy.cz> +X-OriginalArrivalTime: 10 Apr 2006 06:54:56.0091 (UTC) + FILETIME=[AD0882B0:01C65C6B] +X-Archive-Number: 200604/189 +X-Sequence-Number: 18273 + +Hi Tomas, + +Tomas wrote: +We've decided to remove unneeded 'old' data, which means removing about +99.999% of rows from tables A, C and D (about 2 GB of data). At the +beginning, the B table (containing aggregated from A, C and D) was emptied +(dropped and created) and filled in with current data. Then, before the +deletion the data from tables A, C, D were backed up using another tables +(say A_old, C_old, D_old) filled in using +..... +1) drop, create and fill table B (aggregated data from A, C, D) +2) copy 'old' data from A, C and D to A_old, C_old a D_old +3) delete old data from A, C, D +4) dump data from A_old, C_old and D_old +5) truncate tables A, C, D +6) vacuum full analyze tables A, C, D, A_old, C_old and D_old +---- + +I think you do some difficult database maintainance. Why you do that, if you +just want to have some small piece of datas from your tables. Why don't you +try something like: +1. create table A with no index (don't fill data to this table), +2. create table A_week_year inherit table A, with index you want, and some +condition for insertion. (eg: table A1 you used for 1 week data of a year +and so on..) +3. do this step for table B, C and D +4. if you have relation, make the relation to inherit table (optional). + +I think you should read the postgresql help, for more information about +table inheritance. + +The impact is, you might have much table. But each table will only have +small piece of datas, example: just for one week. And you don't have to do a +difficult database maintainance like you have done. You just need to create +tables for every week of data, do vacuum/analyze and regular backup. + + +Best regards, +ahmad fajar, + + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 04:21:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DAE5D11F6C84 + for ; + Mon, 10 Apr 2006 04:21:29 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.946 +X-Spam-Level: +X-Spam-Status: No, score=0.946 required=5 tests=[HTML_10_20=0.945, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 0gS1Hb+xFrij + for ; + Mon, 10 Apr 2006 04:21:18 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.180]) + by postgresql.org (Postfix) with ESMTP id 9DAB011F6C7D + for ; + Mon, 10 Apr 2006 04:21:19 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so772118pye + for ; + Mon, 10 Apr 2006 00:21:19 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type; + b=ln+WvWPJK2Nwk0mR9TV/5YlosWDox6XiOzjlK2Swxt8dh8n9j4no2Wg5s/pmM55sMem8+bddusdEOCP4HKgm0gbxIXhDnaTy4fKdfHz14ljTB7q2zHR6aqnHRxuTmk/3G2m3l4MlgXyj+evUq24Q7iyCvnu881di2y+XcMcnNdY= +Received: by 10.35.99.14 with SMTP id b14mr222875pym; + Mon, 10 Apr 2006 00:21:19 -0700 (PDT) +Received: by 10.35.31.15 with HTTP; Mon, 10 Apr 2006 00:21:18 -0700 (PDT) +Message-ID: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> +Date: Mon, 10 Apr 2006 12:51:18 +0530 +From: "soni de" +To: pgsql-performance@postgresql.org +Subject: Takes too long to fetch the data from database +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_9316_26192319.1144653678977" +X-Archive-Number: 200604/190 +X-Sequence-Number: 18274 + +------=_Part_9316_26192319.1144653678977 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hello, + +I have difficulty in fetching the records from the database. +Database table contains more than 1 GB data. +For fetching the records it is taking more the 1 hour and that's why it is +slowing down the performance. +please provide some help regarding improving the performance and how do I +run query so that records will be fetched in a less time. + +------=_Part_9316_26192319.1144653678977 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
Hello,
+
 
+
I have difficulty in fetching the records from the database.
+
Database table contains more than 1 GB data.
+
For fetching the records it is taking more the 1 hour and that's why i= +t is slowing down the performance.
+
please provide some help regarding improving the performance and how d= +o I run query so that records will be fetched in a less time.
+ +------=_Part_9316_26192319.1144653678977-- + +From pgsql-performance-owner@postgresql.org Mon Apr 10 04:56:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7891611F627D + for ; + Mon, 10 Apr 2006 04:56:00 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id bqiwzLzBmMGj + for ; + Mon, 10 Apr 2006 04:55:54 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 10A4811F6C60 + for ; + Mon, 10 Apr 2006 04:55:56 -0300 (ADT) +Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) + by svr4.postgresql.org (Postfix) with ESMTP id 358E45AF1A2 + for ; + Mon, 10 Apr 2006 07:55:55 +0000 (GMT) +Received: from list by ciao.gmane.org with local (Exim 4.43) + id 1FSrFT-00030v-49 + for pgsql-performance@postgresql.org; Mon, 10 Apr 2006 09:55:47 +0200 +Received: from shrek.krogh.cc ([81.7.132.92]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Mon, 10 Apr 2006 09:55:47 +0200 +Received: from jesper by shrek.krogh.cc with local (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Mon, 10 Apr 2006 09:55:47 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Jesper Krogh +Subject: Restore performance? +Date: Mon, 10 Apr 2006 07:55:33 +0000 (UTC) +Lines: 17 +Message-ID: +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: shrek.krogh.cc +User-Agent: slrn/0.9.8.1pl1 (Debian) +X-Archive-Number: 200604/192 +X-Sequence-Number: 18276 + +Hi + +I'm currently upgrading a Posgresql 7.3.2 database to a +8.1. + +I'd run pg_dump | gzip > sqldump.gz on the old system. That took about +30 hours and gave me an 90GB zipped file. Running +cat sqldump.gz | gunzip | psql +into the 8.1 database seems to take about the same time. Are there +any tricks I can use to speed this dump+restore process up? + +The database contains quite alot of BLOB, thus the size. + +Jesper +-- +./Jesper Krogh, jesper@krogh.cc, Jabber ID: jesper@jabbernet.dk + + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 05:07:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 708E711F6AFE + for ; + Mon, 10 Apr 2006 05:07:01 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id z9JrRFi1JMcl + for ; + Mon, 10 Apr 2006 05:06:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id 506C911F6AE7 + for ; + Mon, 10 Apr 2006 05:06:56 -0300 (ADT) +Received: from 172.16.1.148 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Mon, 10 Apr 2006 04:06:43 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01HOST02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 10 Apr + 2006 04:05:56 -0400 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Subject: Re: Restore performance? +Date: Mon, 10 Apr 2006 04:04:40 -0400 +Message-ID: <3E37B936B592014B978C4415F90D662D01F475D5@MI8NYCMAIL06.Mi8.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Restore performance? +Thread-Index: AcZcdN2CyywaUh6sTZ2KgDRAp+2dHgAAI24E +References: +From: "Luke Lonergan" +To: "Jesper Krogh" , + pgsql-performance@postgresql.org +X-OriginalArrivalTime: 10 Apr 2006 08:05:56.0603 (UTC) + FILETIME=[987F0CB0:01C65C75] +X-WSS-ID: 6824CD982XS42705539-07-01 +Content-Type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable +X-Archive-Number: 200604/193 +X-Sequence-Number: 18277 + +Jesper, +=20 +If they both took the same amount of time, then you are almost certainly = +bottlenecked on gzip. +=20 +Try a faster CPU or use "gzip -fast". +=20 +- Luke + +________________________________ + +From: pgsql-performance-owner@postgresql.org on behalf of Jesper Krogh +Sent: Mon 4/10/2006 12:55 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] Restore performance? + + + +Hi + +I'm currently upgrading a Posgresql 7.3.2 database to a +8.1. + +I'd run pg_dump | gzip > sqldump.gz on the old system. That took about +30 hours and gave me an 90GB zipped file. Running +cat sqldump.gz | gunzip | psql +into the 8.1 database seems to take about the same time. Are there +any tricks I can use to speed this dump+restore process up? + +The database contains quite alot of BLOB, thus the size. + +Jesper +-- +./Jesper Krogh, jesper@krogh.cc, Jabber ID: jesper@jabbernet.dk + + + +---------------------------(end of broadcast)--------------------------- +TIP 6: explain analyze is your friend + + + + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 05:22:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C170F11F627D + for ; + Mon, 10 Apr 2006 05:22:39 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id nLH+s4AYk9Ni + for ; + Mon, 10 Apr 2006 05:22:34 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 5CE8D11F6D27 + for ; + Mon, 10 Apr 2006 05:22:36 -0300 (ADT) +Received: from mail.linuxnews.dk (shrek.krogh.cc [81.7.132.92]) + by svr4.postgresql.org (Postfix) with ESMTP id A00DD5AF83D + for ; + Mon, 10 Apr 2006 08:22:36 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.linuxnews.dk (Postfix) with ESMTP id 5AD383BEC2C + for ; + Mon, 10 Apr 2006 10:22:33 +0200 (CEST) +Received: from mail.linuxnews.dk ([127.0.0.1]) + by localhost (shrek.krogh.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 30860-07 for ; + Mon, 10 Apr 2006 10:22:31 +0200 (CEST) +Received: from mail.jabbernet.dk (localhost.localdomain [127.0.0.1]) + by mail.linuxnews.dk (Postfix) with ESMTP id 55B003BEC29 + for ; + Mon, 10 Apr 2006 10:22:31 +0200 (CEST) +Received: from 195.41.66.226 (SquirrelMail authenticated user jesper@krogh.cc) + by mail.jabbernet.dk with HTTP; + Mon, 10 Apr 2006 10:22:31 +0200 (CEST) +Message-ID: <27860.195.41.66.226.1144657351.squirrel@mail.jabbernet.dk> +Date: Mon, 10 Apr 2006 10:22:31 +0200 (CEST) +Subject: Dump restore performance 7.3 -> 8.1 +From: "Jesper Krogh" +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.5.1 [CVS] +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Debian amavisd-new at shrek.krogh.cc +X-Archive-Number: 200604/194 +X-Sequence-Number: 18278 + + +Hi + +I'm currently upgrading a Posgresql 7.3.2 database to a +8.1. + +I'd run pg_dump | gzip > sqldump.gz on the old system. That took about +30 hours and gave me an 90GB zipped file. Running +cat sqldump.gz | gunzip | psql +into the 8.1 database seems to take about the same time. Are there +any tricks I can use to speed this dump+restore process up? + +Neither disk-io (viewed using vmstat 1) or cpu (viewed using top) seems to +be the bottleneck. + +The database contains quite alot of BLOB's, thus the size. + +Jesper +-- +Jesper Krogh + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 04:30:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A94B511F6AFB + for ; + Mon, 10 Apr 2006 04:30:34 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.039 +X-Spam-Level: * +X-Spam-Status: No, score=1.039 required=5 tests=[AWL=-0.126, + SUBJ_ALL_CAPS=1.166] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 6aODv7ohK6mS + for ; + Mon, 10 Apr 2006 04:30:28 -0300 (ADT) +X-Greylist: delayed 21:42:52.130179 by SQLgrey- +Received: from mailRelay.dbnet.co.il (mail.dbnet.co.il [212.143.51.17]) + by postgresql.org (Postfix) with ESMTP id 54F7D11F6C60 + for ; + Mon, 10 Apr 2006 04:30:19 -0300 (ADT) +Received: from mailRelay.dbnet.co.il (localhost [127.0.0.1]) + by localhost.dbnet.co.il (Postfix) with ESMTP id 97A2F3C10C + for ; + Mon, 10 Apr 2006 10:54:22 +0300 (IDT) +Received: from exchange-1.dbnet.co.il (mail [172.16.2.1]) + by mailRelay.dbnet.co.il (Postfix) with ESMTP id 815103C109 + for ; + Mon, 10 Apr 2006 10:54:22 +0300 (IDT) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----_=_NextPart_001_01C65C79.0B2FB734" +Subject: Re: +Date: Mon, 10 Apr 2006 10:30:37 +0200 +Message-ID: <0BA77301DFF4B24C9C5DAA74138BF95001E202@exchange-1.dbnet.co.il> +X-MS-Has-Attach: yes +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] +Thread-index: AcZb2lYq0tS+L4kfQ+WFQsMun2Nm+AAm/TgA +From: "Doron Baranes" +To: +X-Archive-Number: 200604/191 +X-Sequence-Number: 18275 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C65C79.0B2FB734 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + +Hi, + +I Attached here a file with details about the tables, the queries and +the=20 +Explain analyze plans. +Hope this can be helpful to analyze my problem + +10x +Doron + +-----Original Message----- +From: Ragnar [mailto:gnari@hive.is]=20 +Sent: Sunday, April 09, 2006 2:37 PM +To: Doron Baranes +Subject: RE: [PERFORM] + +On sun, 2006-04-09 at 14:11 +0200, Doron Baranes wrote: + +Please reply to the list, not to me directly. this way +others can help you too. + +> I did vacuum database analyze a few days ago. + +yes, I saw that in your original post. I mentioned +VACUUM FULL ANALYZE , not just VACUUM ANALYZE + +> I'll attached a few explain plans. + +[explain plans deleted] + +These are useless. you must show us the output of=20 +EXPLAIN ANALYZE. these are output of EXPLAIN. +A plan is not much use without seeing the query itself. + +you still have not answered the question about +what indexes you have. + +gnari + + + +------_=_NextPart_001_01C65C79.0B2FB734 +Content-Type: text/plain; + name="explain_analyze.txt" +Content-Transfer-Encoding: base64 +Content-Description: explain_analyze.txt +Content-Disposition: attachment; + filename="explain_analyze.txt" + +VEFCTEVTDQoqKioqKioqKg0KDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgVGFibGUgImxvZy5tc2dfaW5mbyINCiAgIENvbHVtbiAgIHwgICAgICAgICAgICBUeXBlICAg +ICAgICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICBNb2RpZmllcnMNCi0tLS0tLS0tLS0t +LSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQogbXNnaWQgICAgICB8IGJpZ2ludCAg +ICAgICAgICAgICAgICAgICAgICB8IG5vdCBudWxsIGRlZmF1bHQgbmV4dHZhbCgnbG9nLm1zZ19p +bmZvX21zZ2lkX3NlcSc6OnRleHQpDQogc2VuZGVyICAgICB8IGNoYXJhY3RlciB2YXJ5aW5nKDI1 +NSkgICAgICB8DQogc3ViamVjdCAgICB8IHRleHQgICAgICAgICAgICAgICAgICAgICAgICB8DQog +c2l6ZSAgICAgICB8IGJpZ2ludCAgICAgICAgICAgICAgICAgICAgICB8DQogZW50cnlfdGltZSB8 +IHRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSB8IGRlZmF1bHQgbm93KCkNCiBzb3VyY2VfaXAg +IHwgY2lkciAgICAgICAgICAgICAgICAgICAgICAgIHwNCiBvcmlnaW4gICAgIHwgc21hbGxpbnQg +ICAgICAgICAgICAgICAgICAgIHwNCkluZGV4ZXM6DQogICAgIm1zZ19pbmZvX3BrZXkiIHByaW1h +cnkga2V5LCBidHJlZSAobXNnaWQpDQogICAgImRkaW5keCIgYnRyZWUgKGRhdGUoZW50cnlfdGlt +ZSkpDQogICAgIm1zZ19pbmZvX2VudHJ5X3RpbWUiIGJ0cmVlIChlbnRyeV90aW1lKQ0KICAgICJt +c2dfaW5mb19zZW5kZXJfaW5kZXgiIGJ0cmVlIChzZW5kZXIpDQogICAgIm1zZ19pbmZvX3NpemUi +IGJ0cmVlIChzaXplKQ0KICAgICJtc2dfaW5mb19zdWJqZWN0IiBidHJlZSAoc3ViamVjdCkNCg0K +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUYWJsZSAibG9nLm1zZ19m +YXRlIg0KICAgQ29sdW1uICAgIHwgICAgICAgICAgVHlwZSAgICAgICAgICB8ICAgICAgICAgICAg +ICAgICAgICAgICAgICAgTW9kaWZpZXJzDQotLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tDQogbXNnaWQgICAgICAgfCBiaWdpbnQgICAgICAgICAgICAgICAgIHwg +bm90IG51bGwgZGVmYXVsdCBuZXh0dmFsKCdsb2cubXNnX2ZhdGVfbXNnaWRfc2VxJzo6dGV4dCkN +CiBncnBfZmF0ZV9pZCB8IGJpZ2ludCAgICAgICAgICAgICAgICAgfCBub3QgbnVsbCBkZWZhdWx0 +IG5leHR2YWwoJ2xvZy5tc2dfZmF0ZV9ncnBfZmF0ZV9pZF9zZXEnOjp0ZXh0KQ0KIG1vZGlkICAg +ICAgIHwgaW50ZWdlciAgICAgICAgICAgICAgICB8DQogZGVzY3JpcHRpb24gfCBjaGFyYWN0ZXIg +dmFyeWluZygyNTUpIHwNCiBydWxlX29yaWdpbiB8IGJpZ2ludCAgICAgICAgICAgICAgICAgfA0K +IGFjdGlvbiAgICAgIHwgc21hbGxpbnQgICAgICAgICAgICAgICB8DQogcnVsZWlkICAgICAgfCBp +bnRlZ2VyICAgICAgICAgICAgICAgIHwNCkluZGV4ZXM6DQogICAgIm1zZ19mYXRlX3BrZXkiIHBy +aW1hcnkga2V5LCBidHJlZSAoZ3JwX2ZhdGVfaWQpDQogICAgIm1zZ19mYXRlX2FjdGlvbiIgYnRy +ZWUgKCJhY3Rpb24iKQ0KICAgICJtc2dfZmF0ZV9kZXNjcmlwdGlvbiIgYnRyZWUgKGRlc2NyaXB0 +aW9uKQ0KICAgICJtc2dfZmF0ZV9tb2RpZCIgYnRyZWUgKG1vZGlkKQ0KICAgICJtc2dfZmF0ZV9t +c2dpZCIgYnRyZWUgKG1zZ2lkKQ0KRm9yZWlnbi1rZXkgY29uc3RyYWludHM6DQogICAgIm1zZ2lk +X2ZrZXkiIEZPUkVJR04gS0VZIChtc2dpZCkgUkVGRVJFTkNFUyBsb2cubXNnX2luZm8obXNnaWQp +IE9OIFVQREFURSBDQVNDQURFIE9OIERFTEVURSBDQVNDQURFDQoNCiAgICAgICAgICAgICAgVGFi +bGUgImxvZy5tc2dfZmF0ZV9yZWNpcGllbnRzIg0KICAgQ29sdW1uICAgIHwgICAgICAgICAgICBU +eXBlICAgICAgICAgICAgIHwgICBNb2RpZmllcnMNCi0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tDQogZ3JwX2ZhdGVfaWQgfCBiaWdpbnQg +ICAgICAgICAgICAgICAgICAgICAgfA0KIHJlY2lwaWVudCAgIHwgY2hhcmFjdGVyIHZhcnlpbmco +MjU1KSAgICAgIHwNCiB1cGRhdGVfYXQgICB8IHRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSB8 +IGRlZmF1bHQgbm93KCkNCiBsYXN0X2FjdGlvbiB8IGludGVnZXIgICAgICAgICAgICAgICAgICAg +ICB8DQogem9uZV9pZCAgICAgfCBpbnRlZ2VyICAgICAgICAgICAgICAgICAgICAgfA0KIGRpcmVj +dGlvbiAgIHwgc21hbGxpbnQgICAgICAgICAgICAgICAgICAgIHwgZGVmYXVsdCA3DQpJbmRleGVz +Og0KICAgICJtc2dfZmF0ZV9yZWNpcGllbnRzX2dycF9mYXRlX2lkIiBidHJlZSAoZ3JwX2ZhdGVf +aWQpDQogICAgIm1zZ19mYXRlX3JlY2lwaWVudHNfbGFzdF9hY3Rpb25faWR4IiBidHJlZSAobGFz +dF9hY3Rpb24pDQogICAgIm1zZ19mYXRlX3JlY2lwaWVudHNfcmVjaXBpZW50X2lkeCIgYnRyZWUg +KHJlY2lwaWVudCkNCiAgICAibXNnX2ZhdGVfcmVjaXBpZW50c191cGRhdGVfYXQiIGJ0cmVlICh1 +cGRhdGVfYXQpDQogICAgIm1zZ19mYXRlX3JlY2lwaWVudHNfem9uZV9pZCIgYnRyZWUgKHpvbmVf +aWQpDQpUcmlnZ2VyczoNCiAgICBzdGF0c19mb3JfZG9tYWluIEFGVEVSIElOU0VSVCBPTiBsb2cu +bXNnX2ZhdGVfcmVjaXBpZW50cyBGT1IgRUFDSCBST1cgRVhFQ1VURSBQUk9DRURVUkUgbG9nLmNv +bGxlY3Rfc3RhdHNfZm9yX2RvbWFpbigpDQogICAgc3RhdHNfZm9yX29iamVjdCBBRlRFUiBJTlNF +UlQgT04gbG9nLm1zZ19mYXRlX3JlY2lwaWVudHMgRk9SIEVBQ0ggUk9XIEVYRUNVVEUgUFJPQ0VE +VVJFIGxvZy5jb2xsZWN0X3N0YXRzX2Zvcl9vYmplY3QoKQ0KICAgIHVwZGF0ZV90aW1lc3RhbXBf +bGFzdF9hY3Rpb24gQkVGT1JFIFVQREFURSBPTiBsb2cubXNnX2ZhdGVfcmVjaXBpZW50cyBGT1Ig +RUFDSCBST1cgRVhFQ1VURSBQUk9DRURVUkUgbG9nLnJlY2lwaWVudHNfc3RhdHVzX2NoYW5nZWRf +dXBkYXRlKCkNCg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUYWJsZSAi +cGluZWFwcC56b25lcyINCiAgQ29sdW1uICAgfCAgICAgICAgICBUeXBlICAgICAgICAgIHwgICAg +ICAgICAgICAgICAgICAgICAgICAgIE1vZGlmaWVycw0KLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0NCiB6b25lX2lkICAgfCBpbnRlZ2VyICAgICAgICAgICAgICAgIHwg +bm90IG51bGwgZGVmYXVsdCBuZXh0dmFsKCdwaW5lYXBwLnpvbmVzX3pvbmVfaWRfc2VxJzo6dGV4 +dCkNCiB6b25lX25hbWUgfCBjaGFyYWN0ZXIgdmFyeWluZygyMCkgIHwNCiB6b25lX2Rlc2MgfCBj +aGFyYWN0ZXIgdmFyeWluZygyNTUpIHwNCiB6b25lX3R5cGUgfCBzbWFsbGludCAgICAgICAgICAg +ICAgIHwNCkluZGV4ZXM6DQogICAgInpvbmVzX3BrZXkiIHByaW1hcnkga2V5LCBidHJlZSAoem9u +ZV9pZCkNCiAgICAiem9uZXNfem9uZV9pZCIgYnRyZWUgKHpvbmVfaWQpDQoNClFVRVJJRVMNCioq +KioqKioqKioqDQoNCg0KMSkNCmV4cGxhaW4gYW5hbHl6ZSBTRUxFQ1QgZGF0ZV90cnVuYygnaG91 +cic6OnRleHQsIGkuZW50cnlfdGltZSkgQVMgZGF0ZXRpbWUsDQpDT1VOVChmci5ncnBfZmF0ZV9p +ZCkgLA0KU1VNKGkuc2l6ZSkNCkZST00gbG9nLm1zZ19pbmZvIGFzIGksbG9nLm1zZ19mYXRlIGFz +IGYsIGxvZy5tc2dfZmF0ZV9yZWNpcGllbnRzIGFzIGZyDQpXSEVSRSBpLm9yaWdpbiA9IDENCkFO +RCBpLm1zZ2lkPWYubXNnaWQNCkFORCBpLmVudHJ5X3RpbWUgPiAnMjAwNi0wMS0yNScNCkFORCBm +LmdycF9mYXRlX2lkPWZyLmdycF9mYXRlX2lkDQpHUk9VUCBCWSBkYXRldGltZQ0Kb3JkZXIgYnkg +ZGF0ZXRpbWU7DQoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBRVUVSWSBQTEFOICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tDQogR3JvdXBBZ2dyZWdhdGUgIChjb3N0PTEzNTU5ODQuODQuLjE0MTcyNDMu +MjIgcm93cz0xNDg1MjMzIHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9MjU3NDMzLjc4NC4uMjY5MTAy +LjA4OCByb3dzPTYyMyBsb29wcz0xKQ0KICAgLT4gIFNvcnQgIChjb3N0PTEzNTU5ODQuODQuLjEz +Njg1MTQuNjIgcm93cz01MDExOTEzIHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9MjU3MzQ5LjAzOC4u +MjYxMDEyLjU5NSByb3dzPTUxNjAxODcgbG9vcHM9MSkNCiAgICAgICAgIFNvcnQgS2V5OiBkYXRl +X3RydW5jKCdob3VyJzo6dGV4dCwgaS5lbnRyeV90aW1lKQ0KICAgICAgICAgLT4gIEhhc2ggSm9p +biAgKGNvc3Q9MjU2NzI5LjUyLi42Njc0MDAuODYgcm93cz01MDExOTEzIHdpZHRoPTI0KSAoYWN0 +dWFsIHRpbWU9NjMxMzMuMTQwLi4yMDg5NjYuMzQyIHJvd3M9NTE2MDE4NyBsb29wcz0xKQ0KICAg +ICAgICAgICAgICAgSGFzaCBDb25kOiAoIm91dGVyIi5ncnBfZmF0ZV9pZCA9ICJpbm5lciIuZ3Jw +X2ZhdGVfaWQpDQogICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gbXNnX2ZhdGVfcmVjaXBp +ZW50cyBmciAgKGNvc3Q9MC4wMC4uMTc4MjMwLjcxIHJvd3M9OTAyMjc3MSB3aWR0aD04KSAoYWN0 +dWFsIHRpbWU9MzAuMzQ3Li41OTgyNi45Nzggcm93cz05MDIyNzcxIGxvb3BzPTEpDQogICAgICAg +ICAgICAgICAtPiAgSGFzaCAgKGNvc3Q9MjQzNzg3LjE3Li4yNDM3ODcuMTcgcm93cz0xNTQ4MTM5 +IHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9NjI3ODAuOTY0Li42Mjc4MC45NjQgcm93cz0wIGxvb3Bz +PTEpDQogICAgICAgICAgICAgICAgICAgICAtPiAgSGFzaCBKb2luICAoY29zdD05NTM3NS4yOC4u +MjQzNzg3LjE3IHJvd3M9MTU0ODEzOSB3aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTEzNzkxLjk1Mi4u +NjEwMjIuOTEzIHJvd3M9MTYwMTEyMSBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAg +ICAgSGFzaCBDb25kOiAoIm91dGVyIi5tc2dpZCA9ICJpbm5lciIubXNnaWQpDQogICAgICAgICAg +ICAgICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gbXNnX2ZhdGUgZiAgKGNvc3Q9MC4wMC4u +NTUyMDMuNjAgcm93cz0yNzg3MDYwIHdpZHRoPTE2KSAoYWN0dWFsIHRpbWU9MTUuNjkwLi4xNzQ3 +MC41MzEgcm93cz0yNzg3MDYwIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAt +PiAgSGFzaCAgKGNvc3Q9ODI5NTkuMjAuLjgyOTU5LjIwIHJvd3M9MTQ4NTIzMyB3aWR0aD0yNCkg +KGFjdHVhbCB0aW1lPTEzMTY2LjI3My4uMTMxNjYuMjczIHJvd3M9MCBsb29wcz0xKQ0KICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIG1zZ19pbmZvIGkgIChj +b3N0PTAuMDAuLjgyOTU5LjIwIHJvd3M9MTQ4NTIzMyB3aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTAu +MTMzLi4xMTQ1MC44NDYgcm93cz0xNDg3ODg2IGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICBGaWx0ZXI6ICgob3JpZ2luID0gMSkgQU5EIChlbnRyeV90aW1l +ID4gJzIwMDYtMDEtMjUgMDA6MDA6MDAnOjp0aW1lc3RhbXAgd2l0aG91dCB0aW1lIHpvbmUpKQ0K +IFRvdGFsIHJ1bnRpbWU6IDI2OTQ4Ni45NTIgbXMNCigxNCByb3dzKQ0KDQoNCg0KMikNCmV4cGxh +aW4gYW5hbHl6ZSBTRUxFQ1QgZGF0ZV90cnVuYygnaG91cic6OnRleHQsIGkuZW50cnlfdGltZSkg +QVMgZGF0ZXRpbWUsIA0KQ09VTlQoZnIuZ3JwX2ZhdGVfaWQpICwgDQpTVU0oaS5zaXplKSANCkZS +T00gbG9nLm1zZ19pbmZvIGFzIGksbG9nLm1zZ19mYXRlIGFzIGYsIGxvZy5tc2dfZmF0ZV9yZWNp +cGllbnRzIGFzIGZyIA0KV0hFUkUgaS5tc2dpZD1mLm1zZ2lkIA0KQU5EIGYuZ3JwX2ZhdGVfaWQ9 +ZnIuZ3JwX2ZhdGVfaWQNCkFORCBpLmVudHJ5X3RpbWUgPiAnMjAwNi0wMS0yNScNCkFORCBmLm1v +ZGlkID0gLTIgDQpBTkQgaS5vcmlnaW49MQ0KR1JPVVAgQlkgZGF0ZXRpbWUgb3JkZXIgYnkgZGF0 +ZXRpbWUNCg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICBRVUVSWSBQTEFOICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICANCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tDQogR3JvdXBBZ2dyZWdhdGUgIChjb3N0PTEzNTc3OTguMjAuLjE0MTg3NzIuNTgg +cm93cz0xNDg1MjMzIHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9MjQ0NDI0LjA2NC4uMjU1NjY2Ljg5 +OSByb3dzPTYyMyBsb29wcz0xKQ0KICAgLT4gIFNvcnQgIChjb3N0PTEzNTc3OTguMjAuLjEzNzAy +NTYuOTggcm93cz00OTgzNTEzIHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9MjQ0NDAwLjg1OC4uMjQ3 +OTUxLjg1NiByb3dzPTUxMzUwMzEgbG9vcHM9MSkNCiAgICAgICAgIFNvcnQgS2V5OiBkYXRlX3Ry +dW5jKCdob3VyJzo6dGV4dCwgaS5lbnRyeV90aW1lKQ0KICAgICAgICAgLT4gIEhhc2ggSm9pbiAg +KGNvc3Q9MjYzMTQ0LjYyLi42NzM0MDguOTggcm93cz00OTgzNTEzIHdpZHRoPTI0KSAoYWN0dWFs +IHRpbWU9NjE0ODYuNjA1Li4xOTQyMjkuOTg3IHJvd3M9NTEzNTAzMSBsb29wcz0xKQ0KICAgICAg +ICAgICAgICAgSGFzaCBDb25kOiAoIm91dGVyIi5ncnBfZmF0ZV9pZCA9ICJpbm5lciIuZ3JwX2Zh +dGVfaWQpDQogICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gbXNnX2ZhdGVfcmVjaXBpZW50 +cyBmciAgKGNvc3Q9MC4wMC4uMTc4MjMwLjcxIHJvd3M9OTAyMjc3MSB3aWR0aD04KSAoYWN0dWFs +IHRpbWU9MjkuMTA2Li40NzQxMS4zMTMgcm93cz05MDIyNzcxIGxvb3BzPTEpDQogICAgICAgICAg +ICAgICAtPiAgSGFzaCAgKGNvc3Q9MjUwMjc2LjIwLi4yNTAyNzYuMjAgcm93cz0xNTM5MzY3IHdp +ZHRoPTI0KSAoYWN0dWFsIHRpbWU9NjEyMTMuODQ3Li42MTIxMy44NDcgcm93cz0wIGxvb3BzPTEp +DQogICAgICAgICAgICAgICAgICAgICAtPiAgSGFzaCBKb2luICAoY29zdD05NTM3NS4yOC4uMjUw +Mjc2LjIwIHJvd3M9MTUzOTM2NyB3aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTEzNzU2LjQzMC4uNTk0 +ODYuOTk3IHJvd3M9MTU4NjQ3MiBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAg +SGFzaCBDb25kOiAoIm91dGVyIi5tc2dpZCA9ICJpbm5lciIubXNnaWQpDQogICAgICAgICAgICAg +ICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gbXNnX2ZhdGUgZiAgKGNvc3Q9MC4wMC4uNjIx +NzEuMjUgcm93cz0yNzcxMjY3IHdpZHRoPTE2KSAoYWN0dWFsIHRpbWU9MjMuNTUwLi4xMjg1My40 +Mjkgcm93cz0yNzY4MjEwIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICBGaWx0ZXI6IChtb2RpZCA9IC0yKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEhh +c2ggIChjb3N0PTgyOTU5LjIwLi44Mjk1OS4yMCByb3dzPTE0ODUyMzMgd2lkdGg9MjQpIChhY3R1 +YWwgdGltZT0xMzQwNS4yOTAuLjEzNDA1LjI5MCByb3dzPTAgbG9vcHM9MSkNCiAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBtc2dfaW5mbyBpICAoY29zdD0w +LjAwLi44Mjk1OS4yMCByb3dzPTE0ODUyMzMgd2lkdGg9MjQpIChhY3R1YWwgdGltZT00MS4wNzYu +LjExNzc3LjY5NCByb3dzPTE0ODc4ODYgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgIEZpbHRlcjogKChlbnRyeV90aW1lID4gJzIwMDYtMDEtMjUgMDA6MDA6 +MDAnOjp0aW1lc3RhbXAgd2l0aG91dCB0aW1lIHpvbmUpIEFORCAob3JpZ2luID0gMSkpDQogVG90 +YWwgcnVudGltZTogMjU1OTgxLjA5NiBtcw0KKDE1IHJvd3MpDQoNCg0KDQozKQ0KZXhwbGFpbiBh +bmFseXplIFNFTEVDVCBDT1VOVCgqKSANCkZST00gIGxvZy5tc2dfaW5mbyANCkxFRlQgSk9JTiBs +b2cubXNnX2ZhdGUgVVNJTkcgKG1zZ2lkKQ0KTEVGVCBKT0lOIGxvZy5tc2dfZmF0ZV9yZWNpcGll +bnRzIFVTSU5HIChncnBfZmF0ZV9pZCkgDQpMRUZUIEpPSU4gcGluZWFwcC56b25lcyBVU0lORyAo +em9uZV9pZCkgIA0KV0hFUkUgKDcgJiBkaXJlY3Rpb24pICE9IDA7DQoNCiAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +IFFVRVJZIFBMQU4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgDQot +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQogQWdncmVnYXRlICAoY29z +dD05Mzk0NzUuMDkuLjkzOTQ3NS4wOSByb3dzPTEgd2lkdGg9MCkgKGFjdHVhbCB0aW1lPTMyNzk3 +Mi4wNTMuLjMyNzk3Mi4wNTMgcm93cz0xIGxvb3BzPTEpDQogICAtPiAgSGFzaCBMZWZ0IEpvaW4g +IChjb3N0PTI2NzExOC40Mi4uOTE3MDMwLjk1IHJvd3M9ODk3NzY1OCB3aWR0aD0wKSAoYWN0dWFs +IHRpbWU9NzMwMjUuMTA5Li4zMjE5MjUuMTI4IHJvd3M9OTAyMjc1MiBsb29wcz0xKQ0KICAgICAg +ICAgSGFzaCBDb25kOiAoIm91dGVyIi56b25lX2lkID0gImlubmVyIi56b25lX2lkKQ0KICAgICAg +ICAgLT4gIEhhc2ggSm9pbiAgKGNvc3Q9MjY3MTE3LjQxLi44MjcyNTMuMzUgcm93cz04OTc3NjU4 +IHdpZHRoPTQpIChhY3R1YWwgdGltZT03Mjk3NS4yOTcuLjMwODAwNi4yOTEgcm93cz05MDIyNzUy +IGxvb3BzPTEpDQogICAgICAgICAgICAgICBIYXNoIENvbmQ6ICgib3V0ZXIiLmdycF9mYXRlX2lk +ID0gImlubmVyIi5ncnBfZmF0ZV9pZCkNCiAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBt +c2dfZmF0ZV9yZWNpcGllbnRzICAoY29zdD0wLjAwLi4yNDU5MDEuNDkgcm93cz04OTc3NjU4IHdp +ZHRoPTEyKSAoYWN0dWFsIHRpbWU9MjkuOTk5Li42MjE1Ni44NDcgcm93cz05MDIyNzcxIGxvb3Bz +PTEpDQogICAgICAgICAgICAgICAgICAgICBGaWx0ZXI6ICgoNyAmIChkaXJlY3Rpb24pOjppbnRl +Z2VyKSA8PiAwKQ0KICAgICAgICAgICAgICAgLT4gIEhhc2ggIChjb3N0PTI0OTI2Mi43Ni4uMjQ5 +MjYyLjc2IHJvd3M9Mjc4NzA2MCB3aWR0aD04KSAoYWN0dWFsIHRpbWU9NzI5MjguNTQ0Li43Mjky +OC41NDQgcm93cz0wIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAtPiAgSGFzaCBKb2lu +ICAoY29zdD04NjcxOS42Ni4uMjQ5MjYyLjc2IHJvd3M9Mjc4NzA2MCB3aWR0aD04KSAoYWN0dWFs +IHRpbWU9MTIzODAuMTc1Li42OTYzNi4zNjAgcm93cz0yNzg3MDYwIGxvb3BzPTEpDQogICAgICAg +ICAgICAgICAgICAgICAgICAgICBIYXNoIENvbmQ6ICgib3V0ZXIiLm1zZ2lkID0gImlubmVyIi5t +c2dpZCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBtc2dfZmF0 +ZSAgKGNvc3Q9MC4wMC4uNTUyMDMuNjAgcm93cz0yNzg3MDYwIHdpZHRoPTE2KSAoYWN0dWFsIHRp +bWU9MjQuMjAyLi4yMTUyMi44OTYgcm93cz0yNzg3MDYwIGxvb3BzPTEpDQogICAgICAgICAgICAg +ICAgICAgICAgICAgICAtPiAgSGFzaCAgKGNvc3Q9Njk1OTAuMTMuLjY5NTkwLjEzIHJvd3M9MjY3 +MzgxMyB3aWR0aD04KSAoYWN0dWFsIHRpbWU9MTIzNTUuMDk4Li4xMjM1NS4wOTggcm93cz0wIGxv +b3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24g +bXNnX2luZm8gIChjb3N0PTAuMDAuLjY5NTkwLjEzIHJvd3M9MjY3MzgxMyB3aWR0aD04KSAoYWN0 +dWFsIHRpbWU9MzEuNjg3Li45Njg1LjU5MSByb3dzPTI2NzM4MTMgbG9vcHM9MSkNCiAgICAgICAg +IC0+ICBIYXNoICAoY29zdD0xLjAxLi4xLjAxIHJvd3M9MSB3aWR0aD00KSAoYWN0dWFsIHRpbWU9 +MjYuNTA4Li4yNi41MDggcm93cz0wIGxvb3BzPTEpDQogICAgICAgICAgICAgICAtPiAgU2VxIFNj +YW4gb24gem9uZXMgIChjb3N0PTAuMDAuLjEuMDEgcm93cz0xIHdpZHRoPTQpIChhY3R1YWwgdGlt +ZT0yNi40NzguLjI2LjQ4MCByb3dzPTEgbG9vcHM9MSkNCiBUb3RhbCBydW50aW1lOiAzMjc5ODQu +Nzg0IG1zDQooMTYgcm93cykNCg== + +------_=_NextPart_001_01C65C79.0B2FB734-- + +From pgsql-performance-owner@postgresql.org Mon Apr 10 05:43:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DD0F511F6921 + for ; + Mon, 10 Apr 2006 05:43:42 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ye-QRavlyN9f + for ; + Mon, 10 Apr 2006 05:43:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.187]) + by postgresql.org (Postfix) with ESMTP id C4B3D11F6208 + for ; + Mon, 10 Apr 2006 05:43:35 -0300 (ADT) +Received: from [84.143.4.101] (helo=pse.dyndns.org) + by mrelayeu.kundenserver.de (node=mrelayeu4) with ESMTP (Nemesis), + id 0ML21M-1FSrzi1kIY-0003ja; Mon, 10 Apr 2006 10:43:35 +0200 +Received: from pse1 ([192.168.0.3]) by pse.dyndns.org with esmtp (Exim 4.44) + id 1FSrzf-0001bQ-ID; Mon, 10 Apr 2006 10:43:31 +0200 +Message-ID: <443A1AB3.2050707@pse-consulting.de> +Date: Mon, 10 Apr 2006 10:43:31 +0200 +From: Andreas Pflug +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jesper Krogh +CC: pgsql-performance@postgresql.org +Subject: Re: Restore performance? +References: +In-Reply-To: +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:0ce7ee5c3478b8d72edd8e05ccd40b70 +X-Archive-Number: 200604/195 +X-Sequence-Number: 18279 + +Jesper Krogh wrote: +> Hi +> +> I'm currently upgrading a Posgresql 7.3.2 database to a +> 8.1. +> +> I'd run pg_dump | gzip > sqldump.gz on the old system. That took about +> 30 hours and gave me an 90GB zipped file. Running +> cat sqldump.gz | gunzip | psql +> into the 8.1 database seems to take about the same time. Are there +> any tricks I can use to speed this dump+restore process up? + +If you can have both database systems up at the same time, you could +pg_dump | psql. + +Regards, +Andreas + +From pgsql-performance-owner@postgresql.org Mon Apr 10 05:46:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 372FC11F7DD3 + for ; + Mon, 10 Apr 2006 05:46:10 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id c76svwYqbiQx + for ; + Mon, 10 Apr 2006 05:45:16 -0300 (ADT) +X-Greylist: delayed 00:22:27.302587 by SQLgrey- +Received: from mail.linuxnews.dk (shrek.krogh.cc [81.7.132.92]) + by postgresql.org (Postfix) with ESMTP id CB21411F7DCF + for ; + Mon, 10 Apr 2006 05:45:01 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.linuxnews.dk (Postfix) with ESMTP id 5908C3BEC2C; + Mon, 10 Apr 2006 10:45:00 +0200 (CEST) +Received: from mail.linuxnews.dk ([127.0.0.1]) + by localhost (shrek.krogh.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 04152-02; Mon, 10 Apr 2006 10:44:59 +0200 (CEST) +Received: from mail.jabbernet.dk (localhost.localdomain [127.0.0.1]) + by mail.linuxnews.dk (Postfix) with ESMTP id 49A043BEC29; + Mon, 10 Apr 2006 10:44:59 +0200 (CEST) +Received: from 195.41.66.226 (SquirrelMail authenticated user jesper@krogh.cc) + by mail.jabbernet.dk with HTTP; + Mon, 10 Apr 2006 10:44:59 +0200 (CEST) +Message-ID: <53852.195.41.66.226.1144658699.squirrel@mail.jabbernet.dk> +In-Reply-To: <3E37B936B592014B978C4415F90D662D01F475D5@MI8NYCMAIL06.Mi8.com> +References: + <3E37B936B592014B978C4415F90D662D01F475D5@MI8NYCMAIL06.Mi8.com> +Date: Mon, 10 Apr 2006 10:44:59 +0200 (CEST) +Subject: Re: Restore performance? +From: "Jesper Krogh" +To: "Luke Lonergan" +Cc: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.5.1 [CVS] +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Debian amavisd-new at shrek.krogh.cc +X-Archive-Number: 200604/196 +X-Sequence-Number: 18280 + +> If they both took the same amount of time, then you are almost certainly +> bottlenecked on gzip. +> +> Try a faster CPU or use "gzip -fast". + +gzip does not seem to be the bottleneck, on restore is psql the nr. 1 +consumer on cpu-time. + +Jesper +Sorry for the double post. +-- +Jesper Krogh + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 06:01:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D30D211F7DB1 + for ; + Mon, 10 Apr 2006 06:01:46 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Sv-XnDVtqyZx + for ; + Mon, 10 Apr 2006 06:01:34 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.168]) + by postgresql.org (Postfix) with ESMTP id 38D6211F6D55 + for ; + Mon, 10 Apr 2006 06:01:35 -0300 (ADT) +Received: by uproxy.gmail.com with SMTP id c2so567273ugf + for ; + Mon, 10 Apr 2006 02:01:35 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:from:to:references:subject:date:mime-version:content-type:content-transfer-encoding:x-priority:x-msmail-priority:x-mailer:x-mimeole; + b=ODu40VPAf/Qtnu6cW3eykzTHzrZ2oVeQtEjBpLIlB5A80UlbOtvjKk1B9LExCyk4HuWQ9Qvzp/QPxkMs+Y9sHa2E5z6tv02dlBWCh1/AjSBQPXQLo4psvUkOdmBztGKzchdUutO/uq9N6hqbmT+nPv4BKP3y1PN8d6Ui4+HFz/I= +Received: by 10.66.222.15 with SMTP id u15mr3071382ugg; + Mon, 10 Apr 2006 02:01:35 -0700 (PDT) +Received: from maniek ( [62.148.95.123]) + by mx.gmail.com with ESMTP id c1sm31051ugf.2006.04.10.02.01.33; + Mon, 10 Apr 2006 02:01:35 -0700 (PDT) +Message-ID: <044d01c65c7d$875ffcc0$0c67a8c0@maniek> +From: =?iso-8859-2?Q?Marcin_Ma=F1k?= +To: , + "Jesper Krogh" +References: +Subject: Re: Restore performance? +Date: Mon, 10 Apr 2006 11:02:40 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-2" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +X-Archive-Number: 200604/197 +X-Sequence-Number: 18281 + +> I'd run pg_dump | gzip > sqldump.gz on the old system. That took about +> 30 hours and gave me an 90GB zipped file. Running +> cat sqldump.gz | gunzip | psql +> into the 8.1 database seems to take about the same time. Are there +> any tricks I can use to speed this dump+restore process up? +> +> The database contains quite alot of BLOB, thus the size. + +You could try slony - it can do almost-zero-downtime upgrades. + +Greetings +Marcin Mank + +From pgsql-performance-owner@postgresql.org Mon Apr 10 06:06:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C835711F6921 + for ; + Mon, 10 Apr 2006 06:06:46 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id kHqOqlyGw+sm + for ; + Mon, 10 Apr 2006 06:06:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) + by postgresql.org (Postfix) with ESMTP id DE5D111F6201 + for ; + Mon, 10 Apr 2006 06:06:42 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by ptb-relay03.plus.net with esmtp (Exim) id 1FSsM6-0005w8-8w; + Mon, 10 Apr 2006 10:06:42 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 1D7647368B; + Mon, 10 Apr 2006 10:08:12 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id C7BEA15EA4; + Mon, 10 Apr 2006 10:06:41 +0100 (BST) +Message-ID: <443A2021.5070105@archonet.com> +Date: Mon, 10 Apr 2006 10:06:41 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Gavin Hamill +Cc: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> + <1144441457.32269.29.camel@state.g2switchworks.com> + <20060407222443.97ddf152.gdh@laterooms.com> +In-Reply-To: <20060407222443.97ddf152.gdh@laterooms.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/198 +X-Sequence-Number: 18282 + +Gavin Hamill wrote: +> On Fri, 07 Apr 2006 15:24:18 -0500 +> Scott Marlowe wrote: +> +>>> See reply to Tom Lane :) +>> I didn't see one go by yet... Could be sitting in the queue. +> +> If it's not arrived by now - EXPLAIN ANALYZE doesn't tell me +> anything :) +> +>> Let us know if changing the fsync setting helps. Hopefully that's all +>> the problem is. +> +> fsync's already off - yes a bit scary, but our I/O is only about +> 500KB/sec writing.. the whole db fits in RAM / kernel disk cache, and +> I'd rather have performance than security at this exact moment.. + +>>> Multi-Opteron was the other thing we considered but decided to give +>>> 'Big Iron' UNIX a whirl... +>> It still might be a good choice, if it's a simple misconfiguration +>> issue. +>> +>> But man, those new multiple core opterons can make some impressive +>> machines for very little money. +> +> So I see - we could buy two quad-opterons for the cost of renting this +> pSeries for a month.... + +I don't know about the pSeries, but I had a client the other week with +the same usage pattern. They made the switch from a quad Xeon to dual +(+dual-core) Opteron and were extremely impressed. + +I can probably put you in touch with their sysadmin - contact me +off-list if you'd like that. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Apr 10 06:24:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 97A6011F6CE6 + for ; + Mon, 10 Apr 2006 06:24:05 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id hIoM7ZLuHGBY + for ; + Mon, 10 Apr 2006 06:23:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pih-relay05.plus.net (pih-relay05.plus.net [212.159.14.132]) + by postgresql.org (Postfix) with ESMTP id C33D511F6931 + for ; + Mon, 10 Apr 2006 06:23:59 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by pih-relay05.plus.net with esmtp (Exim) id 1FSsck-00023r-0O; + Mon, 10 Apr 2006 10:23:54 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id D413A736BE; + Mon, 10 Apr 2006 10:25:19 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 2ED4E15EA4; + Mon, 10 Apr 2006 10:23:49 +0100 (BST) +Message-ID: <443A2424.4020702@archonet.com> +Date: Mon, 10 Apr 2006 10:23:48 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Brendan Duddridge +Cc: PostgreSQL Performance +Subject: Re: OT: Data structure design question: How do they count +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/199 +X-Sequence-Number: 18283 + +Brendan Duddridge wrote: +> +> Now, initially I thought they would just pre-compute these counts, but +> the problem is, when you click on any of the above attribute values, +> they reduce the remaining possible set of matching products (and set of +> possible remaining attributes and attribute values) by the amount +> displayed next to the attribute value selected. You can click on any +> combination of attribute values to filter down the remaining set of +> matching products, so there's a large combination of paths you can take +> to arrive at a set of products you might be interested in. +> +> Do you think they are pre-computed? Or do you think they might use a +> query similar to the following?: + +Pre-computed almost certainly, but at what level of granularity? And +with application-level caching? + +> select pav.attribute_value_id, count(p.product_id) +> from product_attribute_value pav, +> attribute a, +> product p +> where a.attribute_id in (some set of attribute ids) and +> pav.product_id = p.product_id and +> pav.attribute_id = a.attribute_id and p.product_id in +> (select product_id +> from category_product +> where category_id = some category id) and +> p.is_active = 'true' +> group by pav.attribute_value_id; +> +> It would seem to me that although the above query suggests a normalized +> database structure, that joining with 3 tables plus a 4th table in the +> sub-query with an IN qualifier and grouping to get the product counts +> would take a VERY long time, especially on a possible result set of +> 1,260,658 products. + +Hmm - I'm not sure I'd say this was necessarily normalised. In the +example you gave there were three definite types of attribute: + 1. Price range (< 20, 20-50, ...) + 2. Product type (lighting, rugs, ...) + 3. Store (art.com, homeannex, ...) +Your example discards this type information. + +I'm also not sure it lets store A sell widgets for 19.99 and B for 25.99 + +So - let's look at how we might break this down into simple relations: + product_types (product_id, prod_type, prod_subtype) + product_availability (product_id, store_id, price_range) +and so on for each set of parameters. + +Then, if PG isn't calculating fast enough I'd be tempted to throw in a +summary table: + product_counts(store_id, price_range, prod_type, prod_subtype, ..., +num_products) +Then total over this for the top-level queries. + +I'd also cache common top-level queries at the applicaton level anyway. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Apr 10 06:27:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 637D311F7DA1 + for ; + Mon, 10 Apr 2006 06:27:04 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id zKA9mKaoFSKc + for ; + Mon, 10 Apr 2006 06:26:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) + by postgresql.org (Postfix) with ESMTP id E70C011F7DAF + for ; + Mon, 10 Apr 2006 06:26:59 -0300 (ADT) +Received: from [192.168.0.5] (unknown [84.12.155.199]) + by smtp.nildram.co.uk (Postfix) with ESMTP + id B019F334B4E; Mon, 10 Apr 2006 10:26:56 +0100 (BST) +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +From: Simon Riggs +To: Tom Lane +Cc: Luke Lonergan , + Gavin Hamill , pgsql-performance@postgresql.org +In-Reply-To: <17613.1144451138@sss.pgh.pa.us> +References: + <17613.1144451138@sss.pgh.pa.us> +Content-Type: text/plain +Date: Mon, 10 Apr 2006 10:26:49 +0100 +Message-Id: <1144661209.21409.131.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/200 +X-Sequence-Number: 18284 + +On Fri, 2006-04-07 at 19:05 -0400, Tom Lane wrote: + +> It's plausible though that we are seeing contention across members of +> the LWLock array, with the semop storm just being a higher-level symptom +> of the real hardware-level problem. You might try increasing +> LWLOCK_PADDED_SIZE to 64 or even 128, see +> src/backend/storage/lmgr/lwlock.c (this is something that does exist in +> 8.1, so it'd be easy to try). + +pSeries cache lines are 128 bytes wide, so I'd go straight to 128. + +If you're renting all 8 CPUs, I'd drop to 4 and try that instead. With 8 +CPUs the contention will vary according to what each CPU is doing at any +one time - when they all hit the contention spot, things will get worse. + +The pSeries has good CPUs and great caching, so I'd expect contention to +be somewhat more apparent as a bottleneck. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 06:44:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AA2AE11F6A9A + for ; + Mon, 10 Apr 2006 06:44:11 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45jKpAkVI7nh + for ; + Mon, 10 Apr 2006 06:44:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (213-2-2-26.uk.vianw.net [213.2.2.26]) + by postgresql.org (Postfix) with ESMTP id E60A411F73CF + for ; + Mon, 10 Apr 2006 06:44:03 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id 21B5D136CA5; + Mon, 10 Apr 2006 10:44:03 +0100 (BST) +Received: from [194.24.251.10] (bum.net [194.24.251.10]) + by fon.nation-net.com (Postfix) with ESMTP id 0EF921369F9; + Mon, 10 Apr 2006 10:44:03 +0100 (BST) +Message-ID: <443A2856.6050905@laterooms.com> +Date: Mon, 10 Apr 2006 10:41:42 +0100 +From: Gavin Hamill +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Simon Riggs +Cc: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +References: + <17613.1144451138@sss.pgh.pa.us> + <1144661209.21409.131.camel@localhost.localdomain> +In-Reply-To: <1144661209.21409.131.camel@localhost.localdomain> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AV-Checked: ClamAV using ClamSMTP +X-Archive-Number: 200604/201 +X-Sequence-Number: 18285 + +Simon Riggs wrote: + +> pSeries cache lines are 128 bytes wide, so I'd go straight to 128. +> +Hello :) + +OK, that line of code is: + +#define LWLOCK_PADDED_SIZE (sizeof(LWLock) <= 16 ? 16 : 32) + +What should I change this to? I don't understand the syntax of the <= 16 +? : stuff... + +would a simple "#define LWLOCK_PADDED_SIZE 128" be sufficient? + +>If you're renting all 8 CPUs, I'd drop to 4 and try that instead. With 8 +>CPUs the contention will vary according to what each CPU is doing at any +>one time - when they all hit the contention spot, things will get worse. +> +> +> +We have a physical machine installed in our rack at the data centre, +rather than renting a virtual partition of a real machine... I'm not +sure how to enable/disable CPUs even with the help of 'smitty' :) + +>The pSeries has good CPUs and great caching, so I'd expect contention to +>be somewhat more apparent as a bottleneck. +> +> +> +Yep, I expected 32MB of 'L3' cache would yield impressive results :) + +Cheers, +Gavin. + + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 08:56:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2F4AC11F6258 + for ; + Mon, 10 Apr 2006 08:56:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.09 +X-Spam-Level: +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id pdoA9lbeCN9l + for ; + Mon, 10 Apr 2006 08:56:29 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.ipf.is (scania.ipf.is [85.197.192.147]) + by postgresql.org (Postfix) with ESMTP id EC07211F6257 + for ; + Mon, 10 Apr 2006 08:56:30 -0300 (ADT) +Received: (qmail 11827 invoked by uid 1010); 10 Apr 2006 11:55:48 +0000 +Received: from 85.197.216.186 by scania (envelope-from , + uid 1008) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1235. spamassassin: 3.1.1. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. + Processed in 0.377684 secs); 10 Apr 2006 11:55:48 -0000 +X-Antivirus-IPF-Mail-From: gnari@hive.is via scania +X-Antivirus-IPF: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. + Processed in 0.377684 secs Process 11820) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx2.ipf.is with SMTP; 10 Apr 2006 11:55:48 +0000 +Subject: Re: +From: Ragnar +To: Doron Baranes +Cc: pgsql-performance@postgresql.org +In-Reply-To: <0BA77301DFF4B24C9C5DAA74138BF95001E202@exchange-1.dbnet.co.il> +References: <0BA77301DFF4B24C9C5DAA74138BF95001E202@exchange-1.dbnet.co.il> +Content-Type: text/plain; charset=ISO-8859-1 +Date: Mon, 10 Apr 2006 11:59:29 +0000 +Message-Id: <1144670369.32289.165.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 8bit +X-Archive-Number: 200604/202 +X-Sequence-Number: 18286 + +On m�n, 2006-04-10 at 10:30 +0200, Doron Baranes wrote: + +> I Attached here a file with details about the tables, the queries and +> the +> Explain analyze plans. +> Hope this can be helpful to analyze my problem + +first query: + +> explain analyze SELECT date_trunc('hour'::text, +> i.entry_time) AS datetime, +> COUNT(fr.grp_fate_id) , +> SUM(i.size) +> FROM log.msg_info as i,log.msg_fate as f, +> log.msg_fate_recipients as fr +> WHERE i.origin = 1 +> AND i.msgid=f.msgid +> AND i.entry_time > '2006-01-25' +> AND f.grp_fate_id=fr.grp_fate_id +> GROUP BY datetime +> order by datetime; + +if i.origin has high selectivity (if very +few rows in msg_info have origin=1 in this +case), an index on msg_info(orgin) can help. +unfortunately, as you are using 7.4 and this +is a smallint column, you would have to change +the query slightly to make use of that: + WHERE i.origin = 1::smallint +if more than a few % or the rows have this value, +then this will not help + +the index on msg_info(entry_time) is unlikely +to be used, because a simple '>' comparison +has little selectivity. try to add an upper limit +to the query to make it easier for the planner +so see that few rows would be returned (if that is +the case) +for example: + AND i.entry_time BETWEEN '2006-01-25' + AND '2006-05-01' +this might also improve the estimated number +of groups on datetime (notice: estimated rows=1485233, +real=623), although I am not sure if that will help you + +I do now know how good the planner is with dealing +with the date_trunc('hour'::text, i.entry_time), +so possibly you could get some improvement with +an indexed entry_hour column populated with trigger +or by your application, and change your query to: + +explain analyze SELECT i.entry_hour, +COUNT(fr.grp_fate_id) , +SUM(i.size) +FROM log.msg_info as i,log.msg_fate as f, log.msg_fate_recipients as fr +WHERE i.origin = 1 +AND i.msgid=f.msgid +AND i.entry_hour BETWEEN '2006-01-25:00:00' + AND '2006-05-01:00:00' +AND f.grp_fate_id=fr.grp_fate_id +GROUP BY entry_hour +order by entry_hour; + +(adjust the upper limit to your reality) + +do these suggestions help at all? + +gnari + + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 12:24:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6FD8A11F6225 + for ; + Mon, 10 Apr 2006 12:24:42 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.128 +X-Spam-Level: +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id DSEZbRugTK9a + for ; + Mon, 10 Apr 2006 12:24:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 658A311F61EF + for ; + Mon, 10 Apr 2006 12:24:37 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3AFOTTr026130; + Mon, 10 Apr 2006 11:24:29 -0400 (EDT) +To: "Jesper Krogh" +cc: "Luke Lonergan" , + pgsql-performance@postgresql.org +Subject: Re: Restore performance? +In-reply-to: <53852.195.41.66.226.1144658699.squirrel@mail.jabbernet.dk> +References: + <3E37B936B592014B978C4415F90D662D01F475D5@MI8NYCMAIL06.Mi8.com> + <53852.195.41.66.226.1144658699.squirrel@mail.jabbernet.dk> +Comments: In-reply-to "Jesper Krogh" + message dated "Mon, 10 Apr 2006 10:44:59 +0200" +Date: Mon, 10 Apr 2006 11:24:29 -0400 +Message-ID: <26129.1144682669@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/203 +X-Sequence-Number: 18287 + +"Jesper Krogh" writes: +> gzip does not seem to be the bottleneck, on restore is psql the nr. 1 +> consumer on cpu-time. + +Hm. We've seen some situations where readline mistakenly decides that +the input is interactive and wastes lots of cycles doing useless +processing (like keeping history). Try "psql -n" and see if that helps. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 10 12:36:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9988411F61EF + for ; + Mon, 10 Apr 2006 12:36:00 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.127 +X-Spam-Level: +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id GH5Cal6Elvh7 + for ; + Mon, 10 Apr 2006 12:35:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 0E26311F7CF3 + for ; + Mon, 10 Apr 2006 12:35:53 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3AFZj4r026245; + Mon, 10 Apr 2006 11:35:48 -0400 (EDT) +To: Gavin Hamill +cc: Simon Riggs , pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +In-reply-to: <443A2856.6050905@laterooms.com> +References: + <17613.1144451138@sss.pgh.pa.us> + <1144661209.21409.131.camel@localhost.localdomain> + <443A2856.6050905@laterooms.com> +Comments: In-reply-to Gavin Hamill + message dated "Mon, 10 Apr 2006 10:41:42 +0100" +Date: Mon, 10 Apr 2006 11:35:45 -0400 +Message-ID: <26244.1144683345@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/204 +X-Sequence-Number: 18288 + +Gavin Hamill writes: +> would a simple "#define LWLOCK_PADDED_SIZE 128" be sufficient? + +Yeah, that's fine. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 10 12:40:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7FE5511F6109 + for ; + Mon, 10 Apr 2006 12:40:35 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.119, HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id w3dP1y7daZ08 + for ; + Mon, 10 Apr 2006 12:40:20 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.188]) + by postgresql.org (Postfix) with ESMTP id DE89811F655D + for ; + Mon, 10 Apr 2006 12:39:54 -0300 (ADT) +Received: by nproxy.gmail.com with SMTP id p77so628305nfc + for ; + Mon, 10 Apr 2006 08:39:53 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=i+W2tnwP7a5gdR3zq2wSfQOyAPxfbLLUTvdHQRBeKnyWen6RxrP7y34CwaDwLHqfEPUkYzs1x8KrDTtf7M8dbTetdiZWnghgSAiKgyJln90DrcRCbFCnGBtK19baC6XgTzG/0W02+zm8NapHSODrkltGxyS6DfRkOov9a1k6hvw= +Received: by 10.49.10.15 with SMTP id n15mr242113nfi; + Mon, 10 Apr 2006 08:39:53 -0700 (PDT) +Received: by 10.49.27.16 with HTTP; Mon, 10 Apr 2006 08:39:53 -0700 (PDT) +Message-ID: +Date: Mon, 10 Apr 2006 21:09:53 +0530 +From: "Rajesh Kumar Mallah" +To: "Jesper Krogh" +Subject: Re: Restore performance? +Cc: pgsql-performance@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_24378_17542672.1144683593035" +References: +X-Archive-Number: 200604/205 +X-Sequence-Number: 18289 + +------=_Part_24378_17542672.1144683593035 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 4/10/06, Jesper Krogh wrote: +> +> Hi +> +> I'm currently upgrading a Posgresql 7.3.2 database to a +> 8.1. +> +> I'd run pg_dump | gzip > sqldump.gz on the old system. That took about +> 30 hours and gave me an 90GB zipped file. Running +> cat sqldump.gz | gunzip | psql +> into the 8.1 database seems to take about the same time. Are there +> any tricks I can use to speed this dump+restore process up? + + +was the last restore successfull ? +if so why do you want to repeat ? + +some tips + +1. run new version of postgres in a different port and pipe pg_dump to psql +this may save the CPU time of compression , there is no need for a temporar= +y +dump file. + +pg_dump | /path/to/psql813 -p 54XX newdb + +2. use new version of pg_dump to dump the old database as new version + is supposed to be wiser. + +3. make sure you are trapping the restore errors properly +psql newdb 2>&1 | cat | tee err works for me. + + + + +The database contains quite alot of BLOB, thus the size. +> +> Jesper +> -- +> ./Jesper Krogh, jesper@krogh.cc, Jabber ID: jesper@jabbernet.dk +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +> + +------=_Part_24378_17542672.1144683593035 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

On 4/10/06, Jesper Krogh <jesper@krog= +h.cc> wrote:
+Hi

I'm currently upgrading a Posgresql 7.3.2 database to a
8.1.&l= +t;something-good>

I'd run pg_dump | gzip > sqldump.gz &nb= +sp;on the old system. That took about
30 hours and gave me an 90GB zippe= +d file. Running +
cat sqldump.gz | gunzip | psql
into the 8.1 database seems to take a= +bout the same time. Are there
any tricks I can use to speed this dump+re= +store process up?

was the last restore successfull ?= +=20 +
if so why do you want to repeat ?

some tips

1. run new ve= +rsion of postgres in a different port and pipe pg_dump to psql
this may = +save the CPU time of compression , there is no need for a temporary
+dump file.

pg_dump | /path/to/psql813  -p 54XX newdb

2. = +use new version of pg_dump to dump the old database as new version
 = +;   is supposed to be wiser.

3. make sure you are trapping the = +restore errors properly +
psql newdb 2>&1 | cat | tee err works for me.


 <= +/div>
The data= +base contains quite alot of BLOB, thus the size. +

Jesper
--
./Jesper Krogh, = +jesper@krogh.cc, Jabber ID: jesp= +er@jabbernet.dk



---------------------------(end of broad= +cast)--------------------------- +
TIP 6: explain analyze is your friend

+ +------=_Part_24378_17542672.1144683593035-- + +From pgsql-performance-owner@postgresql.org Mon Apr 10 12:43:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 635B511F66F2 + for ; + Mon, 10 Apr 2006 12:43:24 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.119, HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ZrSCey0s4Zyb + for ; + Mon, 10 Apr 2006 12:42:29 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.184]) + by postgresql.org (Postfix) with ESMTP id AA57F11F68ED + for ; + Mon, 10 Apr 2006 12:42:07 -0300 (ADT) +Received: by nproxy.gmail.com with SMTP id p77so628666nfc + for ; + Mon, 10 Apr 2006 08:42:05 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=Pez2by/R9KgJ+0AI0PWzxC/byW7cDlJvsoz0lgrBpwN5kVpsWjBVYf0ZgVUdLIDHwsEmIGCsCJ9Av2VPMCFPLk5TV5FiXlibE2T3H/+SEIu6E0dZnVKYK/fFG9ZpGRPIQ02ZbCQ1+Y55w5OrtqgED6MhDgXt5t350hXybkVkWFM= +Received: by 10.49.15.4 with SMTP id s4mr1818938nfi; + Mon, 10 Apr 2006 08:42:03 -0700 (PDT) +Received: by 10.49.27.16 with HTTP; Mon, 10 Apr 2006 08:42:02 -0700 (PDT) +Message-ID: +Date: Mon, 10 Apr 2006 21:12:02 +0530 +From: "Rajesh Kumar Mallah" +To: "Jesper Krogh" +Subject: Re: Restore performance? +Cc: pgsql-performance@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_24390_12094072.1144683722990" +References: + +X-Archive-Number: 200604/206 +X-Sequence-Number: 18290 + +------=_Part_24390_12094072.1144683722990 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +sorry for the post , i didn' saw the other replies only after posting. + +On 4/10/06, Rajesh Kumar Mallah wrote: +> +> +> +> On 4/10/06, Jesper Krogh wrote: +> > +> > Hi +> > +> > I'm currently upgrading a Posgresql 7.3.2 database to a +> > 8.1. +> > +> > I'd run pg_dump | gzip > sqldump.gz on the old system. That took about +> > 30 hours and gave me an 90GB zipped file. Running +> > cat sqldump.gz | gunzip | psql +> > into the 8.1 database seems to take about the same time. Are there +> > any tricks I can use to speed this dump+restore process up? +> +> +> was the last restore successfull ? +> if so why do you want to repeat ? +> +> some tips +> +> 1. run new version of postgres in a different port and pipe pg_dump to +> psql +> this may save the CPU time of compression , there is no need for a +> temporary +> dump file. +> +> pg_dump | /path/to/psql813 -p 54XX newdb +> +> 2. use new version of pg_dump to dump the old database as new version +> is supposed to be wiser. +> +> 3. make sure you are trapping the restore errors properly +> psql newdb 2>&1 | cat | tee err works for me. +> +> +> +> +> The database contains quite alot of BLOB, thus the size. +> > +> > Jesper +> > -- +> > ./Jesper Krogh, jesper@krogh.cc, Jabber ID: jesper@jabbernet.dk +> > +> > +> > +> > ---------------------------(end of broadcast)--------------------------= +- +> > +> > TIP 6: explain analyze is your friend +> > +> +> + +------=_Part_24390_12094072.1144683722990 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +sorry for the post , i didn' saw the other replies only after posting.
<= +br>
On 4/10/06, Rajesh Kumar Mallah <m= +allah.rajesh@gmail.com +> wrote:


+On 4/10/06, Jesper Krogh <jesper= +@krogh.cc +> wrote:
+Hi

I'm currently upgrading a Posgresql 7.3.2 database to a
8.1.&l= +t;something-good>

I'd run pg_dump | gzip > sqldump.gz &nb= +sp;on the old system. That took about
30 hours and gave me an 90GB zippe= +d file. Running +
cat sqldump.gz | gunzip | psql
into the 8.1 database seems to take a= +bout the same time. Are there
any tricks I can use to speed this dump+re= +store process up?
+

was the last restore successfull ?=20 +
if so why do you want to repeat ?

some tips

1. run new ve= +rsion of postgres in a different port and pipe pg_dump to psql
this may = +save the CPU time of compression , there is no need for a temporary
+ +dump file.

pg_dump | /path/to/psql813  -p 54XX newdb

2. = +use new version of pg_dump to dump the old database as new version
 = +;   is supposed to be wiser.

3. make sure you are trapping the = +restore errors properly +
psql newdb 2>&1 | cat | tee err works for me.


 <= +/div>

+The database contains quite alot of BLOB, thus the size. +

Jesper
--
./Jesper Krogh, = +jesper@krogh.cc, Jabber ID: +jesper@jabbernet.dk



---------------------------(end of b= +roadcast)--------------------------- +
TIP 6: explain analyze is your friend

+ +
+ +------=_Part_24390_12094072.1144683722990-- + +From pgsql-performance-owner@postgresql.org Mon Apr 10 12:55:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B92C211F7DCF + for ; + Mon, 10 Apr 2006 12:55:29 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id dEasGWc8OnNp + for ; + Mon, 10 Apr 2006 12:55:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.linuxnews.dk (shrek.krogh.cc [81.7.132.92]) + by postgresql.org (Postfix) with ESMTP id 1CF9811F7DA1 + for ; + Mon, 10 Apr 2006 12:55:17 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.linuxnews.dk (Postfix) with ESMTP id C51223BEC47; + Mon, 10 Apr 2006 17:55:15 +0200 (CEST) +Received: from mail.linuxnews.dk ([127.0.0.1]) + by localhost (shrek.krogh.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 15073-09; Mon, 10 Apr 2006 17:54:56 +0200 (CEST) +Received: from [192.168.0.134] (0x50a0747b.bynxx16.adsl-dhcp.tele.dk + [80.160.116.123]) + by mail.linuxnews.dk (Postfix) with ESMTP id 656713BEC43; + Mon, 10 Apr 2006 17:54:55 +0200 (CEST) +Message-ID: <443A7FC7.2000001@krogh.cc> +Date: Mon, 10 Apr 2006 17:54:47 +0200 +From: Jesper Krogh +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Rajesh Kumar Mallah +CC: pgsql-performance@postgresql.org +Subject: Re: Restore performance? +References: + +In-Reply-To: +X-Enigmail-Version: 0.94.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Debian amavisd-new at shrek.krogh.cc +X-Archive-Number: 200604/207 +X-Sequence-Number: 18291 + +Rajesh Kumar Mallah wrote: +>> I'd run pg_dump | gzip > sqldump.gz on the old system. That took about +>> 30 hours and gave me an 90GB zipped file. Running +>> cat sqldump.gz | gunzip | psql +>> into the 8.1 database seems to take about the same time. Are there +>> any tricks I can use to speed this dump+restore process up? +> +> +> was the last restore successfull ? +> if so why do you want to repeat ? + +"about the same time" == Estimated guess from restoring a few tables +I was running a testrun, without disabling updates to the production +database, the real run is scheduled for easter where there hopefully is +no users on the system. So I need to repeat, I'm just trying to get a +feelingabout how long time I need to allocate for the operation. + +> 1. run new version of postgres in a different port and pipe pg_dump to psql +> this may save the CPU time of compression , there is no need for a temporary +> dump file. +> +> pg_dump | /path/to/psql813 -p 54XX newdb + +I'll do that. It is a completely different machine anyway. + +> 2. use new version of pg_dump to dump the old database as new version +> is supposed to be wiser. + +Check. + +> 3. make sure you are trapping the restore errors properly +> psql newdb 2>&1 | cat | tee err works for me. + +Thats noted. + +-- +Jesper Krogh, jesper@krogh.cc + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 12:58:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 024DD11F61B9 + for ; + Mon, 10 Apr 2006 12:58:40 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.119, HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id dFtevrlPa1dO + for ; + Mon, 10 Apr 2006 12:58:34 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.185]) + by postgresql.org (Postfix) with ESMTP id 1E4B211F60AF + for ; + Mon, 10 Apr 2006 12:58:33 -0300 (ADT) +Received: by nproxy.gmail.com with SMTP id p77so631503nfc + for ; + Mon, 10 Apr 2006 08:58:32 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=QWZH1b8nBuBVEezJEFe357VBhaXdbkaLVeOJbJhKXPuhgJu0N4T2xwMbNLdOhYh0u8Y69a8O7Tux39AZSJD/MLkZCpoawNN38iop/RAxs898MpzwXoTBbB5JnBHw8s1WHw5TjWEMoCAbt94KnWs+eqLzv2nZgGJZWvhfsSMjris= +Received: by 10.48.246.1 with SMTP id t1mr794689nfh; + Mon, 10 Apr 2006 08:58:31 -0700 (PDT) +Received: by 10.49.27.16 with HTTP; Mon, 10 Apr 2006 08:58:30 -0700 (PDT) +Message-ID: +Date: Mon, 10 Apr 2006 21:28:30 +0530 +From: "Rajesh Kumar Mallah" +To: "soni de" +Subject: Re: Takes too long to fetch the data from database +Cc: pgsql-performance@postgresql.org +In-Reply-To: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_24642_2233583.1144684710975" +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> +X-Archive-Number: 200604/208 +X-Sequence-Number: 18292 + +------=_Part_24642_2233583.1144684710975 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +what is the query ? +use LIMIT or a restricting where clause. + + +regds +mallah. + +On 4/10/06, soni de wrote: +> +> Hello, +> +> I have difficulty in fetching the records from the database. +> Database table contains more than 1 GB data. +> For fetching the records it is taking more the 1 hour and that's why it i= +s +> slowing down the performance. +> please provide some help regarding improving the performance and how do I +> run query so that records will be fetched in a less time. +> + +------=_Part_24642_2233583.1144684710975 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
what is the query ?
use LIMIT or a restricting where clause.

= +
regds
mallah.

On 4/10/06, soni de < +soni.de@gmail.com> wrote:
Hello,
+
 
+
I have difficulty in fetching the records from the database.
+
Database table contains more than 1 GB data.
+
For fetching the records it is taking more the 1 hour and that's why i= +t is slowing down the performance.
+
please provide some help regarding improving the performance and how d= +o I run query so that records will be fetched in a less time.
+ +

+ +------=_Part_24642_2233583.1144684710975-- + +From pgsql-performance-owner@postgresql.org Mon Apr 10 13:09:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2BB6E11F6237 + for ; + Mon, 10 Apr 2006 13:09:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.121 +X-Spam-Level: +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ZtRX6bO97Hg9 + for ; + Mon, 10 Apr 2006 13:08:53 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.187]) + by postgresql.org (Postfix) with ESMTP id 141F411F68E8 + for ; + Mon, 10 Apr 2006 13:08:50 -0300 (ADT) +Received: by nproxy.gmail.com with SMTP id o25so688334nfa + for ; + Mon, 10 Apr 2006 09:08:48 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=eA4SJIg9SefjCoMbePZvdiPzDW/VPhXxH4KcKu5OKfttgRfamjhEt3E7U/zyhwhAMpcdnwrgHI8gZZQw4fd+LN+RkJUewZB5oYZYcdAOsTQI9nspYREaaclYb2BBgkzyoGtEfLXyeTp6fQnOZVPtWGia7H69dnr23QlDHmcn9gQ= +Received: by 10.49.8.9 with SMTP id l9mr3917728nfi; + Mon, 10 Apr 2006 09:08:48 -0700 (PDT) +Received: by 10.49.27.16 with HTTP; Mon, 10 Apr 2006 09:08:48 -0700 (PDT) +Message-ID: +Date: Mon, 10 Apr 2006 21:38:48 +0530 +From: "Rajesh Kumar Mallah" +To: "Jesper Krogh" +Subject: Re: Restore performance? +Cc: pgsql-performance@postgresql.org +In-Reply-To: <443A7FC7.2000001@krogh.cc> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_24814_7308244.1144685328838" +References: + + <443A7FC7.2000001@krogh.cc> +X-Archive-Number: 200604/209 +X-Sequence-Number: 18293 + +------=_Part_24814_7308244.1144685328838 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +4. fsync can also be turned off while loading huge dataset , + but seek others comments too (as study docs) as i am not sure about th= +e + reliability. i think it can make a lot of difference. + + + +On 4/10/06, Jesper Krogh wrote: +> +> Rajesh Kumar Mallah wrote: +> >> I'd run pg_dump | gzip > sqldump.gz on the old system. That took abou= +t +> >> 30 hours and gave me an 90GB zipped file. Running +> >> cat sqldump.gz | gunzip | psql +> >> into the 8.1 database seems to take about the same time. Are there +> >> any tricks I can use to speed this dump+restore process up? +> > +> > +> > was the last restore successfull ? +> > if so why do you want to repeat ? +> +> "about the same time" =3D=3D Estimated guess from restoring a few tables +> I was running a testrun, without disabling updates to the production +> database, the real run is scheduled for easter where there hopefully is +> no users on the system. So I need to repeat, I'm just trying to get a +> feelingabout how long time I need to allocate for the operation. +> +> > 1. run new version of postgres in a different port and pipe pg_dump to +> psql +> > this may save the CPU time of compression , there is no need for a +> temporary +> > dump file. +> > +> > pg_dump | /path/to/psql813 -p 54XX newdb +> +> I'll do that. It is a completely different machine anyway. +> +> > 2. use new version of pg_dump to dump the old database as new version +> > is supposed to be wiser. +> +> Check. +> +> > 3. make sure you are trapping the restore errors properly +> > psql newdb 2>&1 | cat | tee err works for me. +> +> Thats noted. +> +> -- +> Jesper Krogh, jesper@krogh.cc +> +> + +------=_Part_24814_7308244.1144685328838 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
4. fsync can also be turned off while loading huge dataset ,
 &= +nbsp;  but seek others comments  too (as study docs) as i am not = +sure about the
    reliability. i think it can make a lot= + of difference.



+On 4/10/06, Jespe= +r Krogh <jesper@krogh.cc> = +wrote:
+Rajesh Kumar Mallah wrote:
>> I'd run pg_dump | gzip > sqldump.= +gz  on the old system. That took about
>> 30 hours and g= +ave me an 90GB zipped file. Running
>> cat sqldump.gz | gunzip | p= +sql
+>> into the 8.1 database seems to take about the same time. Are there= +
>> any tricks I can use to speed this dump+restore process up?>
>
> was the last restore successfull ?
> if so why = +do you want to repeat ? +

"about the same time" =3D=3D Estimated guess from restori= +ng a few tables
I was running a testrun, without disabling updates to th= +e production
database, the real run is scheduled for easter where there = +hopefully is +
no users on the system. So I need to repeat, I'm just trying to get afeelingabout how long time I need to allocate for the operation.

&= +gt; 1. run new version of postgres in a different port and pipe pg_dump to = +psql +
> this may save the CPU time of compression , there is no need for a= + temporary
> dump file.
>
> pg_dump | /path/to/psql813&nb= +sp; -p 54XX newdb

I'll do that. It is a completely different ma= +chine anyway. +

> 2. use new version of pg_dump to dump the old database as new = +version
>     is supposed to be wiser.

Che= +ck.

> 3. make sure you are trapping the restore errors properly> psql newdb 2>&1 | cat | tee err works for me. +

Thats noted.

--
Jesper Krogh, jesper@krogh.cc


+ +------=_Part_24814_7308244.1144685328838-- + +From pgsql-performance-owner@postgresql.org Mon Apr 10 13:24:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 58F9111F6AE1 + for ; + Mon, 10 Apr 2006 13:24:02 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.467 +X-Spam-Level: * +X-Spam-Status: No, score=1.467 required=5 tests=[AWL=-0.452, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id VwsH07eUB0cT + for ; + Mon, 10 Apr 2006 13:23:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by postgresql.org (Postfix) with ESMTP id ABFF411F6977 + for ; + Mon, 10 Apr 2006 13:23:47 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx2.surnet.cl with ESMTP; 10 Apr 2006 12:23:47 -0400 +X-IronPort-AV: i="4.02,198,1139194800"; + d="scan'208"; a="42085098:sNHT18396288" +Received: from alvh.no-ip.org (201.221.200.14) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 43A978FD00E233AC; Mon, 10 Apr 2006 12:23:46 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 86DB7C2DC22; Mon, 10 Apr 2006 12:23:45 -0400 (CLT) +Date: Mon, 10 Apr 2006 12:23:45 -0400 +From: Alvaro Herrera +To: Rajesh Kumar Mallah +Cc: Jesper Krogh , pgsql-performance@postgresql.org +Subject: Re: Restore performance? +Message-ID: <20060410162345.GA2461@surnet.cl> +Mail-Followup-To: Rajesh Kumar Mallah , + Jesper Krogh , pgsql-performance@postgresql.org +References: + + <443A7FC7.2000001@krogh.cc> + +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.11+cvs20060330 +X-Archive-Number: 200604/210 +X-Sequence-Number: 18294 + +Rajesh Kumar Mallah wrote: +> 4. fsync can also be turned off while loading huge dataset , +> but seek others comments too (as study docs) as i am not sure about the +> reliability. i think it can make a lot of difference. + +Also be sure to increase maintenance_work_mem so that index creation +goes faster. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +PostgreSQL Replication, Consulting, Custom Development, 24x7 support + +From pgsql-performance-owner@postgresql.org Mon Apr 10 13:59:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 55F9211F6006 + for ; + Mon, 10 Apr 2006 13:59:14 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.359 +X-Spam-Level: * +X-Spam-Status: No, score=1.359 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479, + DNS_FROM_RFC_WHOIS=0.879, HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id NkuZS1HGdIaw + for ; + Mon, 10 Apr 2006 13:58:59 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from web54705.mail.yahoo.com (web54705.mail.yahoo.com + [206.190.49.195]) + by postgresql.org (Postfix) with SMTP id 2859511F68ED + for ; + Mon, 10 Apr 2006 13:58:58 -0300 (ADT) +Received: (qmail 91473 invoked by uid 60001); 10 Apr 2006 16:58:57 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=YnA2AhUzHTCDsAeXWJuJzQknK+OUy0vwyH0dFwojTBiYZYNg1tm5SRHf9vzdNsf5Ufj5wFKntb+EF7XJmg/nFr5xuLbQ1zJxnww4EcAICV4ndla+OW9D2liSkAEXQEev50Crz6D4QR1HukjoWLXdOPwH8+9NLggLFR2+p4HTxSA= + ; +Message-ID: <20060410165857.91471.qmail@web54705.mail.yahoo.com> +Received: from [70.83.4.60] by web54705.mail.yahoo.com via HTTP; + Mon, 10 Apr 2006 09:58:57 PDT +Date: Mon, 10 Apr 2006 09:58:57 -0700 (PDT) +From: Oscar Picasso +Subject: Better index stategy for many fields with few values +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-459319516-1144688337=:91455" +Content-Transfer-Encoding: 8bit +X-Archive-Number: 200604/211 +X-Sequence-Number: 18295 + +--0-459319516-1144688337=:91455 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi, + +I want to optimize something like this. + +- My items table: +code int -- can take one of 100 values +property varchar(250) -- can take one of 5000 values +param01 char(10) -- can take one of 10 values +param02 char(10) -- can take one of 10 values +... +[ 20 similar columns } +... +parama20 char(10) -- can take one of 10 values + +- The kind of query I want to optimize: +select * from items +where code betwwen 5 and 22 +and param01 = 'P' +and param02 = 'G' +... +[ all the 20 paramXX columns are used in the query} +... +and param20 = 'C'; + + +How can I optimize this kind of query? + +I was thinking about using a multicolumns index, but I have read that we should limit multicolumns indice to at most 2 or 3 columns. + +If that's true then 22 columns for a multicolumn incdex seems way too much. Or maybe it is workable as every column uses only a very limited set of values? + +I was also thinking about about using a functional index. + +What do you think would be the best solution in such a case? + +Thanks. + +Oscar + + + +--------------------------------- +Blab-away for as little as 1�/min. Make PC-to-Phone Calls using Yahoo! Messenger with Voice. +--0-459319516-1144688337=:91455 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi,

I want to optimize something like this.

- My items table:
code int              -- can take one of 100 values
property varchar(250) -- can take one of 5000 values
param01 char(10)      -- can take one of 10 values
param02 char(10)      -- can take one of 10 values
...
[ 20 similar columns }
...
parama20 char(10)     -- can take one of 10 values

- The kind of query I want to optimize:
select * from items
where code betwwen 5 and 22
and param01 = 'P'
and param02 = 'G'
...
[ all the 20 paramXX columns are used in the query}
...
and param20 = 'C';


How can I optimize this kind of query?

I was thinking about using a multicolumns index, but I have read that we should limit multicolumns indice to at most 2 or 3 columns.

If that's true then 22 columns + for a multicolumn incdex seems way too much. Or maybe it is workable as every column uses only a very limited set of values?

I was also thinking about about using a functional index.

What do you think would be the best solution in such a case?

Thanks.

Oscar

+


Blab-away for as little as 1�/min. Make PC-to-Phone Calls using Yahoo! Messenger with Voice. +--0-459319516-1144688337=:91455-- + +From pgsql-performance-owner@postgresql.org Mon Apr 10 14:19:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 32EC011F61D9 + for ; + Mon, 10 Apr 2006 14:19:58 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id lCU7zeodjtbb + for ; + Mon, 10 Apr 2006 14:19:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id B7F0811F60E3 + for ; + Mon, 10 Apr 2006 14:19:51 -0300 (ADT) +Received: (qmail 1012 invoked from network); 10 Apr 2006 19:20:35 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 10 Apr 2006 19:20:35 +0200 +Date: Mon, 10 Apr 2006 19:20:33 +0200 +To: "Jesper Krogh" , pgsql-performance@postgresql.org +Subject: Re: Restore performance? +References: +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Archive-Number: 200604/212 +X-Sequence-Number: 18296 + + +> I'd run pg_dump | gzip > sqldump.gz on the old system. + + If the source and destination databases are on different machines, you +can pipe pg_dump on the source machine to pg_restore on the destination +machine by using netcat. + If you only have 100 Mbps ethernet, compressing the data will be faster. +If you have Gb Ethernet, maybe you don't need to compress, but it doesn't +hurt to test. + + use pg_restore instead of psql, and use a recent version of pg_dump which +can generate dumps in the latest format. + + If you need fast compression, use gzip -1 or even lzop, which is +incredibly fast. + + Turn off fsync during the restore and set maintenance_work_mem to use +most of your available RAM for index creation. + + I think that creating foreign key constraints uses large joins ; it might +be good to up work_mem also. + + Check the speed of your disks with dd beforehand. You might get a +surprise. + + Maybe you can also play with the bgwriter and checkpoint parameters. + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 14:25:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 11AD311F61C6 + for ; + Mon, 10 Apr 2006 14:25:34 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Rwzmkr5la9kk + for ; + Mon, 10 Apr 2006 14:25:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id E660A11F61DB + for ; + Mon, 10 Apr 2006 14:25:27 -0300 (ADT) +Received: (qmail 1041 invoked from network); 10 Apr 2006 19:26:14 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 10 Apr 2006 19:26:14 +0200 +To: "Oscar Picasso" , pgsql-performance@postgresql.org +Subject: Re: Better index stategy for many fields with few values +References: <20060410165857.91471.qmail@web54705.mail.yahoo.com> +Message-ID: +Date: Mon, 10 Apr 2006 19:26:13 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <20060410165857.91471.qmail@web54705.mail.yahoo.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Archive-Number: 200604/213 +X-Sequence-Number: 18297 + + +> - My items table: +> code int -- can take one of 100 values +> property varchar(250) -- can take one of 5000 values +> param01 char(10) -- can take one of 10 values +> param02 char(10) -- can take one of 10 values +> ... +> [ 20 similar columns } +> ... +> parama20 char(10) -- can take one of 10 values + + Instead of 20 columns, you could instead use a "param" field containing +an array of 20 TEXT fields. + Then create a simple index on (code, param) and SELECT WHERE code BETWEEN +... AND param = '{P,G,....,C}' + + If you don't want to modify your structure, you can create a functional +index on an array {param1...param20}, but your queries will be a bit +uglier. + +From pgsql-performance-owner@postgresql.org Mon Apr 10 16:40:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8974111F8D3B + for ; + Mon, 10 Apr 2006 16:40:15 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id fYdN+FL9TIDV + for ; + Mon, 10 Apr 2006 16:38:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id CBE9A11F8D48 + for ; + Mon, 10 Apr 2006 15:20:09 -0300 (ADT) +Received: from [192.168.15.100] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k3AIK7oi016902; Mon, 10 Apr 2006 11:20:07 -0700 +Message-ID: <443AA1D4.9010308@commandprompt.com> +Date: Mon, 10 Apr 2006 11:20:04 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Rajesh Kumar Mallah +CC: soni de , pgsql-performance@postgresql.org +Subject: Re: Takes too long to fetch the data from database +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Mon, 10 Apr 2006 11:20:08 -0700 (PDT) +X-Archive-Number: 200604/214 +X-Sequence-Number: 18298 + +Rajesh Kumar Mallah wrote: +> +> what is the query ? +> use LIMIT or a restricting where clause. + +You could also use a cursor. + +Joshua D. Drake +> +> +> regds +> mallah. +> +> On 4/10/06, *soni de* < soni.de@gmail.com > wrote: +> +> Hello, +> +> I have difficulty in fetching the records from the database. +> Database table contains more than 1 GB data. +> For fetching the records it is taking more the 1 hour and that's why +> it is slowing down the performance. +> please provide some help regarding improving the performance and how +> do I run query so that records will be fetched in a less time. +> +> + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 17:10:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E374411F6208 + for ; + Mon, 10 Apr 2006 17:10:16 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id n0xg744p+T69 + for ; + Mon, 10 Apr 2006 17:09:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id C58AA11F8E0F + for ; + Mon, 10 Apr 2006 15:48:14 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 190C5B80A + for ; + Mon, 10 Apr 2006 14:48:14 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: +References: +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <810F9DD5-22B1-4A6F-B76C-D7EA7B89035B@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Restore performance? +Date: Mon, 10 Apr 2006 14:48:13 -0400 +To: Postgresql Performance +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/215 +X-Sequence-Number: 18299 + + +On Apr 10, 2006, at 3:55 AM, Jesper Krogh wrote: + +> I'd run pg_dump | gzip > sqldump.gz on the old system. That took +> about +> 30 hours and gave me an 90GB zipped file. Running +> cat sqldump.gz | gunzip | psql +> into the 8.1 database seems to take about the same time. Are there +> any tricks I can use to speed this dump+restore process up? +> +> The database contains quite alot of BLOB, thus the size. + +Well, your pg_dump command lost your BLOBs since the plain text +format doesn't support them. + +But once you use the -Fc format on your dump and enable blob backups, +you can speed up reloads by increasing your checkpoint segments to a +big number like 256 and the checkpoint timeout to something like 10 +minutes. All other normal tuning parameters should be what you plan +to use for your normal operations, too. + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 17:21:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0DE6011F8773 + for ; + Mon, 10 Apr 2006 17:21:07 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id tv+JeQLSGp86 + for ; + Mon, 10 Apr 2006 17:20:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by postgresql.org (Postfix) with ESMTP id 5FC9411F8BD9 + for ; + Mon, 10 Apr 2006 16:04:13 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id EDC156442CB + for ; + Mon, 10 Apr 2006 13:04:09 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 20208-02 for ; + Mon, 10 Apr 2006 13:04:07 -0600 (MDT) +Received: from [192.168.1.100] (c-67-165-220-189.hsd1.co.comcast.net + [67.165.220.189]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 0AACC6442C9 + for ; + Mon, 10 Apr 2006 13:04:07 -0600 (MDT) +Message-ID: <443AAC26.4070802@drivefaster.net> +Date: Mon, 10 Apr 2006 13:04:06 -0600 +From: Dan Harris +User-Agent: Thunderbird 1.5 (Macintosh/20060122) +MIME-Version: 1.0 +To: PostgreSQL Performance +Subject: Encouraging multi-table join order +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Archive-Number: 200604/216 +X-Sequence-Number: 18300 + +I have a query that is intended to select from multiple "small tables" +to get a limited subset of "incidentid" and then join with a "very +large" table. One of the operations will require a sequential scan, but +the planner is doing the scan on the very large table before joining the +small ones, resulting in a huge amount of disk I/O. How would I make +this query join the large table only after narrowing down the possible +selections from the smaller tables? This is running on version 8.0.3. + +Thanks for any ideas. + +-Dan + + +QUERY +######################################## + explain analyze + select distinct + eventmain.incidentid, + eventmain.entrydate, + eventgeo.eventlocation, + recordtext as retdata + from + eventactivity + join ( + select + incidentid + from + k_h + where + id = 33396 and + k_h.entrydate >= '2006-1-1 00:00' and + k_h.entrydate < '2006-4-8 00:00' + ) id_keywords using ( incidentid ) , + + eventmain, + eventgeo + where + eventmain.incidentid = eventactivity.incidentid and + eventmain.incidentid = eventgeo.incidentid and + ( ' ' || recordtext || ' ' like '%HAL%' ) and + eventactivity.entrydate >= '2006-1-1 00:00' and + eventactivity.entrydate < '2006-4-8 00:00' + order by + eventmain.entrydate limit 10000; + + + +EXPLAIN ANALYZE OUTPUT +######################################## + Limit (cost=2521191.65..2521191.90 rows=6 width=187) (actual +time=1360935.787..1361072.277 rows=1400 loops=1) + -> Unique (cost=2521191.65..2521191.90 rows=6 width=187) (actual +time=1360935.779..1361067.853 rows=1400 loops=1) + -> Sort (cost=2521191.65..2521191.66 rows=6 width=187) +(actual time=1360935.765..1360958.258 rows=16211 loops=1) + Sort Key: eventmain.entrydate, eventmain.incidentid, +eventactivity.recordtext, eventgeo.eventlocation + -> Nested Loop (cost=219.39..2521191.57 rows=6 +width=187) (actual time=1123.115..1360579.798 rows=16211 loops=1) + -> Nested Loop (cost=219.39..2521173.23 rows=6 +width=154) (actual time=1105.773..1325907.716 rows=16211 loops=1) + -> Hash Join (cost=219.39..2521153.37 +rows=6 width=66) (actual time=1069.476..1289608.261 rows=16211 loops=1) + Hash Cond: (("outer".incidentid)::text += ("inner".incidentid)::text) + -> Seq Scan on eventactivity +(cost=0.00..2518092.06 rows=1532 width=52) (actual +time=57.205..1288514.530 rows=2621 loops=1) + Filter: ((((' '::text || +(recordtext)::text) || ' '::text) ~~ '%HAL%'::text) AND (entrydate >= +'2006-01-01 00:00:00'::timestamp without time zone) AND (entrydate < +'2006-04-08 00:00:00'::timestamp without time zone)) + -> Hash (cost=217.53..217.53 rows=741 +width=14) (actual time=899.128..899.128 rows=0 loops=1) + -> Index Scan using k_h_id_idx +on k_h (cost=0.00..217.53 rows=741 width=14) (actual +time=55.097..893.883 rows=1162 loops=1) + Index Cond: (id = 33396) + Filter: ((entrydate >= +'2006-01-01 00:00:00'::timestamp without time zone) AND (entrydate < +'2006-04-08 00:00:00'::timestamp without time zone)) + -> Index Scan using eventmain_incidentid_idx +on eventmain (cost=0.00..3.30 rows=1 width=88) (actual +time=1.866..2.227 rows=1 loops=16211) + Index Cond: +((eventmain.incidentid)::text = ("outer".incidentid)::text) + -> Index Scan using eventgeo_incidentid_idx on +eventgeo (cost=0.00..3.04 rows=1 width=75) (actual time=1.770..2.126 +rows=1 loops=16211) + Index Cond: ((eventgeo.incidentid)::text = +("outer".incidentid)::text) + Total runtime: 1361080.787 ms +(19 rows) + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 17:40:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9B28311F66C5 + for ; + Mon, 10 Apr 2006 17:40:15 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 4508f3V4m3CW + for ; + Mon, 10 Apr 2006 17:39:29 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.libertyrms.com (vgateway.libertyrms.info [207.219.45.62]) + by postgresql.org (Postfix) with ESMTP id 248FE11F8D3C + for ; + Mon, 10 Apr 2006 16:41:03 -0300 (ADT) +Received: from dba5.int.libertyrms.com ([10.1.3.44]) + by mail.libertyrms.com with esmtp (Exim 4.22) + id 1FT2Fu-0007NW-Nq; Mon, 10 Apr 2006 15:40:58 -0400 +Message-ID: <443AB4CA.1030907@ca.afilias.info> +Date: Mon, 10 Apr 2006 15:40:58 -0400 +From: Brad Nicholson +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Tom Lane +CC: Gavin Hamill , pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +References: <20060407185823.abe93017.gdh@laterooms.com> + <1144436060.32269.13.camel@state.g2switchworks.com> + <20060407205919.a091da26.gdh@laterooms.com> + <15772.1144440362@sss.pgh.pa.us> + <20060407223635.9c4a0b38.gdh@laterooms.com> + <17055.1144447009@sss.pgh.pa.us> + <20060407232759.45581362.gdh@laterooms.com> + <17515.1144450340@sss.pgh.pa.us> +In-Reply-To: <17515.1144450340@sss.pgh.pa.us> +X-Enigmail-Version: 0.94.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-SA-Exim-Mail-From: bnichols@ca.afilias.info +X-SA-Exim-Scanned: No; SAEximRunCond expanded to false +X-Archive-Number: 200604/217 +X-Sequence-Number: 18301 + +Tom Lane wrote: + +> This is unfortunately not going to help you as far as getting that +> machine into production now (unless you're brave enough to run CVS tip +> as production, which I certainly am not). I'm afraid you're most likely +> going to have to ship that pSeries back at the end of the month, but +> while you've got it it'd be awfully nice if we could use it as a testbed + +We have PSeries boxes here that won't be going away anytime soon. If +there are any specific test cases that need to run, I should be able to +find the time to do it. + +-- +Brad Nicholson 416-673-4106 +Database Administrator, Afilias Canada Corp. + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 18:04:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 28C8111F627A + for ; + Mon, 10 Apr 2006 18:04:27 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id fWc+OpwdWUlg + for ; + Mon, 10 Apr 2006 18:03:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 1A7C611F8BDD + for ; + Mon, 10 Apr 2006 17:34:09 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Mon, 10 Apr 2006 14:34:07 -0600 +In-Reply-To: <443A2424.4020702@archonet.com> +References: + <443A2424.4020702@archonet.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: OT: Data structure design question: How do they count so fast? +Date: Mon, 10 Apr 2006 14:34:02 -0600 +To: Richard Huxton +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/218 +X-Sequence-Number: 18302 + +Hi Richard (and anyone else who want's to comment!), + +I'm not sure it will really work pre-computed. At least not in an +obvious way (for me! :-)) It's fine to display a pre-computed list of +product counts for the initial set of attribute and attribute values, +but we need to be able to display the counts of products for any +combination of selected attribute values. + +Once an attribute value is picked that reduces the set of products to +a small enough set, the queries are fast, so, perhaps we just need to +pre-compute the counts for combinations of attribute values that lead +to a high count of products. Hence, our thought on building a +decision-tree type data structure. This would store the various +combinations of attributes and attribute values, along with the +product count, along with a list of attributes and attribute values +that are applicable for the current set of selected attribute values. +This sounds like it could get rather complicated, so we were hoping +someone might have an idea on a much simpler solution. + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 10, 2006, at 3:23 AM, Richard Huxton wrote: + +> Brendan Duddridge wrote: +>> Now, initially I thought they would just pre-compute these counts, +>> but the problem is, when you click on any of the above attribute +>> values, they reduce the remaining possible set of matching +>> products (and set of possible remaining attributes and attribute +>> values) by the amount displayed next to the attribute value +>> selected. You can click on any combination of attribute values to +>> filter down the remaining set of matching products, so there's a +>> large combination of paths you can take to arrive at a set of +>> products you might be interested in. +>> Do you think they are pre-computed? Or do you think they might use +>> a query similar to the following?: +> +> Pre-computed almost certainly, but at what level of granularity? +> And with application-level caching? +> +>> select pav.attribute_value_id, count(p.product_id) +>> from product_attribute_value pav, +>> attribute a, +>> product p +>> where a.attribute_id in (some set of attribute ids) and +>> pav.product_id = p.product_id and +>> pav.attribute_id = a.attribute_id and p.product_id in +>> (select product_id +>> from category_product +>> where category_id = some category id) and +>> p.is_active = 'true' +>> group by pav.attribute_value_id; +>> It would seem to me that although the above query suggests a +>> normalized database structure, that joining with 3 tables plus a +>> 4th table in the sub-query with an IN qualifier and grouping to +>> get the product counts would take a VERY long time, especially on +>> a possible result set of 1,260,658 products. +> +> Hmm - I'm not sure I'd say this was necessarily normalised. In the +> example you gave there were three definite types of attribute: +> 1. Price range (< 20, 20-50, ...) +> 2. Product type (lighting, rugs, ...) +> 3. Store (art.com, homeannex, ...) +> Your example discards this type information. +> +> I'm also not sure it lets store A sell widgets for 19.99 and B for +> 25.99 +> +> So - let's look at how we might break this down into simple relations: +> product_types (product_id, prod_type, prod_subtype) +> product_availability (product_id, store_id, price_range) +> and so on for each set of parameters. +> +> Then, if PG isn't calculating fast enough I'd be tempted to throw +> in a summary table: +> product_counts(store_id, price_range, prod_type, +> prod_subtype, ..., num_products) +> Then total over this for the top-level queries. +> +> I'd also cache common top-level queries at the applicaton level +> anyway. +> +> -- +> Richard Huxton +> Archonet Ltd +> + + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 18:12:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 96E5D11F6249 + for ; + Mon, 10 Apr 2006 18:12:24 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id EePiZo0-Bj8N + for ; + Mon, 10 Apr 2006 18:11:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id 76CDA11F628C + for ; + Mon, 10 Apr 2006 18:05:37 -0300 (ADT) +Received: from dell.home.lan (host14-128.pool8251.interbusiness.it + [82.51.128.14]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k3AM8Qr13524; + Tue, 11 Apr 2006 00:08:26 +0200 +Subject: Re: bad performance on Solaris 10 +From: Chris Mair +To: Robert Lor +Cc: Josh Berkus , Mark Kirkwood , + pgsql-performance@postgresql.org, llonergan@greenplum.com +In-Reply-To: <1144438174.3729.20.camel@dell.home.lan> +References: <1144111178.3723.80.camel@dell.home.lan> + <1144279780.5133.19.camel@dell.home.lan> + <44346DAA.2080905@paradise.net.nz> + <200604052135.14326.josh@agliodbs.com> + <1144303269.3718.4.camel@dell.home.lan> <4434C505.1000205@sun.com> + <1144438174.3729.20.camel@dell.home.lan> +Content-Type: text/plain +Date: Mon, 10 Apr 2006 23:05:22 +0200 +Message-Id: <1144703122.3686.7.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/219 +X-Sequence-Number: 18303 + + +> > Chris, +> > Just to make sure the x4100 config is similar to your Linux system, can +> > you verify the default setting for disk write cache and make sure they +> > are both enabled or disabled. Here's how to check in Solaris. +> > As root, run "format -e" -> pick a disk -> cache -> write_cache -> display +> > +> > Not sure how to do it on Linux though! +> > +> > Regards, +> > -Robert +> +> I don't have access to the machine for the next few days due to eh... +> let's call it firewall accident ;), but it might very well be that it +> was off on the x4100 (I know it's on the smaller Linux box). +> +> That together with the bad default sync method can definitely explain +> the strangely slow out of box performance I got. +> +> So thanks again for explaining this to me :) +> +> Bye, Chris. + +Just for completeness: +I checked now using the above commands and can confirm the write cache +was disabled on the x4100 and was on on Linux. + +Bye, Chris. + + + + + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 20:59:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8DEF611F6667 + for ; + Mon, 10 Apr 2006 20:59:55 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.126 +X-Spam-Level: +X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Do5hd7sNQvBO + for ; + Mon, 10 Apr 2006 20:59:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 8390F11F6931 + for ; + Mon, 10 Apr 2006 20:12:37 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3ANCaZH001544; + Mon, 10 Apr 2006 19:12:36 -0400 (EDT) +To: Dan Harris +cc: PostgreSQL Performance +Subject: Re: Encouraging multi-table join order +In-reply-to: <443AAC26.4070802@drivefaster.net> +References: <443AAC26.4070802@drivefaster.net> +Comments: In-reply-to Dan Harris + message dated "Mon, 10 Apr 2006 13:04:06 -0600" +Date: Mon, 10 Apr 2006 19:12:36 -0400 +Message-ID: <1543.1144710756@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/220 +X-Sequence-Number: 18304 + +Dan Harris writes: +> I have a query that is intended to select from multiple "small tables" +> to get a limited subset of "incidentid" and then join with a "very +> large" table. One of the operations will require a sequential scan, but +> the planner is doing the scan on the very large table before joining the +> small ones, resulting in a huge amount of disk I/O. How would I make +> this query join the large table only after narrowing down the possible +> selections from the smaller tables? This is running on version 8.0.3. + +That's very strange --- the estimated cost of the seqscan is high enough +that the planner should have chosen a nestloop with inner indexscan on +the big table. I'm not sure about the join-order point, but the hash +plan for the first join seems wrong in any case. + +Um, you do have an index on eventactivity.incidentid, right? What's the +datatype(s) of the incidentid columns? What happens to the plan if you +turn off enable_hashjoin and enable_mergejoin? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 10 21:49:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9B54811F7209 + for ; + Mon, 10 Apr 2006 21:49:15 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id z-1dXb2a-+SS + for ; + Mon, 10 Apr 2006 21:48:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by postgresql.org (Postfix) with ESMTP id DC57A11F8EC7 + for ; + Mon, 10 Apr 2006 20:52:20 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 0029F644316 + for ; + Mon, 10 Apr 2006 17:52:19 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 27451-09 for ; + Mon, 10 Apr 2006 17:51:55 -0600 (MDT) +Received: from [192.168.1.100] (c-67-165-220-189.hsd1.co.comcast.net + [67.165.220.189]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 2E243644318 + for ; + Mon, 10 Apr 2006 17:51:55 -0600 (MDT) +Message-ID: <443AEF9B.3000909@drivefaster.net> +Date: Mon, 10 Apr 2006 17:51:55 -0600 +From: Dan Harris +User-Agent: Thunderbird 1.5 (Macintosh/20060122) +MIME-Version: 1.0 +To: PostgreSQL Performance +Subject: Re: Encouraging multi-table join order +References: <443AAC26.4070802@drivefaster.net> <1543.1144710756@sss.pgh.pa.us> +In-Reply-To: <1543.1144710756@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Archive-Number: 200604/221 +X-Sequence-Number: 18305 + +Tom Lane wrote: +> That's very strange --- the estimated cost of the seqscan is high enough +> that the planner should have chosen a nestloop with inner indexscan on +> the big table. I'm not sure about the join-order point, but the hash +> plan for the first join seems wrong in any case. +> +> Um, you do have an index on eventactivity.incidentid, right? What's the +> datatype(s) of the incidentid columns? What happens to the plan if you +> turn off enable_hashjoin and enable_mergejoin? +> +> regards, tom lane +> +Yes, eventactivity.incidentid is indexed. The datatype is varchar(40). +Although, by checking this, I noticed that k_h.incidentid was +varchar(100). Perhaps the difference in length between the keys caused +the planner to not use the fastest method? I have no defense as to why +those aren't the same.. I will make them so and check. + +Here's the EXPLAIN analyze with enable_hashjoin = off and +enable_mergejoin = off : + +Limit (cost=4226535.73..4226544.46 rows=698 width=82) (actual +time=74339.016..74356.521 rows=888 loops=1) + -> Unique (cost=4226535.73..4226544.46 rows=698 width=82) (actual +time=74339.011..74354.073 rows=888 loops=1) + -> Sort (cost=4226535.73..4226537.48 rows=698 width=82) +(actual time=74339.003..74344.031 rows=3599 loops=1) + Sort Key: eventmain.entrydate, eventmain.incidentid, +eventgeo.eventlocation, eventactivity.recordtext + -> Nested Loop (cost=0.00..4226502.76 rows=698 +width=82) (actual time=921.325..74314.959 rows=3599 loops=1) + -> Nested Loop (cost=0.00..4935.61 rows=731 +width=72) (actual time=166.354..14638.308 rows=1162 loops=1) + -> Nested Loop (cost=0.00..2482.47 rows=741 +width=50) (actual time=150.396..7348.013 rows=1162 loops=1) + -> Index Scan using k_h_id_idx on k_h +(cost=0.00..217.55 rows=741 width=14) (actual time=129.540..1022.243 +rows=1162 loops=1) + Index Cond: (id = 33396) + Filter: ((entrydate >= +'2006-01-01 00:00:00'::timestamp without time zone) AND (entrydate < +'2006-04-08 00:00:00'::timestamp without time zone)) + -> Index Scan using +eventgeo_incidentid_idx on eventgeo (cost=0.00..3.04 rows=1 width=36) +(actual time=5.260..5.429 rows=1 loops=1162) + Index Cond: +((eventgeo.incidentid)::text = ("outer".incidentid)::text) + -> Index Scan using eventmain_incidentid_idx +on eventmain (cost=0.00..3.30 rows=1 width=22) (actual +time=5.976..6.259 rows=1 loops=1162) + Index Cond: +((eventmain.incidentid)::text = ("outer".incidentid)::text) + -> Index Scan using eventactivity1 on +eventactivity (cost=0.00..5774.81 rows=20 width=52) (actual +time=29.768..51.334 rows=3 loops=1162) + Index Cond: (("outer".incidentid)::text = +(eventactivity.incidentid)::text) + Filter: ((((' '::text || (recordtext)::text) +|| ' '::text) ~~ '%HAL%'::text) AND (entrydate >= '2006-01-01 +00:00:00'::timestamp without time zone) AND (entrydate < '2006-04-08 +00:00:00'::timestamp without time zone)) + + + +From pgsql-performance-owner@postgresql.org Mon Apr 10 23:05:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2182911F6B69 + for ; + Mon, 10 Apr 2006 23:05:14 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.126 +X-Spam-Level: +X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id WFOBD6h4T0op + for ; + Mon, 10 Apr 2006 23:03:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 6F2F211F662A + for ; + Mon, 10 Apr 2006 22:01:37 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3B11bR4002407; + Mon, 10 Apr 2006 21:01:37 -0400 (EDT) +To: Dan Harris +cc: PostgreSQL Performance +Subject: Re: Encouraging multi-table join order +In-reply-to: <443AEF9B.3000909@drivefaster.net> +References: <443AAC26.4070802@drivefaster.net> <1543.1144710756@sss.pgh.pa.us> + <443AEF9B.3000909@drivefaster.net> +Comments: In-reply-to Dan Harris + message dated "Mon, 10 Apr 2006 17:51:55 -0600" +Date: Mon, 10 Apr 2006 21:01:37 -0400 +Message-ID: <2406.1144717297@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/222 +X-Sequence-Number: 18306 + +Dan Harris writes: +> Yes, eventactivity.incidentid is indexed. The datatype is varchar(40). +> Although, by checking this, I noticed that k_h.incidentid was +> varchar(100). Perhaps the difference in length between the keys caused +> the planner to not use the fastest method? + +No, the planner wouldn't care about that. + +> Here's the EXPLAIN analyze with enable_hashjoin = off and +> enable_mergejoin = off : + +OK, so it does consider the "right" plan, but it's estimating it'll take +longer than the other one. One thing that's very strange is that the +estimated number of rows out has changed ... did you re-ANALYZE since +the previous message? + +> -> Index Scan using eventactivity1 on +> eventactivity (cost=0.00..5774.81 rows=20 width=52) (actual +> time=29.768..51.334 rows=3 loops=1162) +> Index Cond: (("outer".incidentid)::text = +> (eventactivity.incidentid)::text) +> Filter: ((((' '::text || (recordtext)::text) +> || ' '::text) ~~ '%HAL%'::text) AND (entrydate >= '2006-01-01 +> 00:00:00'::timestamp without time zone) AND (entrydate < '2006-04-08 +> 00:00:00'::timestamp without time zone)) + +So it's estimating 5775 cost units per probe into eventactivity, which +is pretty high --- it must think that a lot of rows will be retrieved by +the index (way more than the 20 or so it thinks will get past the filter +condition). What does the pg_stats entry for eventactivity.incidentid +contain? It might be worth increasing the statistics target for that +column to try to get a better estimate. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 11 02:02:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 72FA111F65E9 + for ; + Tue, 11 Apr 2006 02:02:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id CdY9jciz0DzM + for ; + Tue, 11 Apr 2006 02:02:33 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 536BA11F65E7 + for ; + Tue, 11 Apr 2006 02:02:34 -0300 (ADT) +Received: from kobe.cl (unknown [200.55.206.18]) + by svr4.postgresql.org (Postfix) with ESMTP id 50E5A5AF1A0 + for ; + Tue, 11 Apr 2006 05:02:32 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=localhost.localdomain) + by kobe.cl with esmtp (Exim 4.43) + id 1FTB1J-0005GL-7b; Tue, 11 Apr 2006 01:02:29 -0400 +Subject: Re: slow "IN" clause +From: Vinko Vrsalovic +Reply-To: el@vinko.cl +To: Qingqing Zhou +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: <1144640620.925899.274170@z34g2000cwc.googlegroups.com> + +Content-Type: text/plain +Date: Tue, 11 Apr 2006 01:02:28 -0400 +Message-Id: <1144731748.9011.2.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/225 +X-Sequence-Number: 18309 + +On lun, 2006-04-10 at 12:44 +0800, Qingqing Zhou wrote: +> wrote +> > I have a slow sql: +> > SELECT * FROM mytable WHERE id IN (1,3,5,7,....3k here...); +> > mytable is about 10k rows. +> > +> > if don't use the "IN" clause, it will cost 0,11 second, otherwise it +> > will cost 2.x second +> > I guess pg use linear search to deal with IN clause, is there any way +> > to let pg use other search method with IN clause? (ex.Binary Search or +> > hash Search) +> > +> +> If you can put (1, 3, .., 3k) in a table, PG may choose a hash join. + +And maybe using + +SELECT * FROM yourtable WHERE id < 6002 AND id % 2 = 1; + +turns out to be faster, if we are allowed to extrapolate from the +example. + +V. + + +From pgsql-performance-owner@postgresql.org Tue Apr 11 04:05:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C2D3311F76CB + for ; + Tue, 11 Apr 2006 04:05:55 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.593 +X-Spam-Level: +X-Spam-Status: No, score=0.593 required=5 tests=[AWL=0.592, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id yKw+6Oi5NOEj + for ; + Tue, 11 Apr 2006 04:05:27 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.180]) + by postgresql.org (Postfix) with ESMTP id 3F8F011F627B + for ; + Tue, 11 Apr 2006 04:05:27 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so1064860pye + for ; + Tue, 11 Apr 2006 00:05:27 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=rx6dyEc0X+BwW9nqhjFrdek3YAjeQSnzxZ9YgDh4A0PY1lfLubzxwAWalmwgG4iLKzntOz+tOCDLdGHO44kj9/DCci0JGTxgR/C/iQzbJI86VSwZEeFYjKQ5+N4vuIpkbxR+DUJQi2j5tFM/FfnM0IbmDkFqVWlFhdT5nzVhxv4= +Received: by 10.35.21.1 with SMTP id y1mr298156pyi; + Tue, 11 Apr 2006 00:05:27 -0700 (PDT) +Received: by 10.35.31.15 with HTTP; Tue, 11 Apr 2006 00:05:27 -0700 (PDT) +Message-ID: <9f2e40a90604110005o101fe98enec2f8ac8f757c770@mail.gmail.com> +Date: Tue, 11 Apr 2006 12:35:27 +0530 +From: "soni de" +To: "Joshua D. Drake" +Subject: Re: Takes too long to fetch the data from database +Cc: "Rajesh Kumar Mallah" , + pgsql-performance@postgresql.org +In-Reply-To: <443AA1D4.9010308@commandprompt.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_2509_16979380.1144739127476" +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <443AA1D4.9010308@commandprompt.com> +X-Archive-Number: 200604/226 +X-Sequence-Number: 18310 + +------=_Part_2509_16979380.1144739127476 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I have flushed the database, so currently records in the "lan" table are: +665280 + +but records can be increased more than 1GB and in that case it takes more +than 1 hour + + + +Below is explain analyze output taken from the table having 665280 records + + + +pdb=3D# explain analyze SELECT sdate, stime, rbts from lan WHERE ( + + ( bname =3D 'pluto' ) AND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( ( sdate + + >=3D '2004-07-21' ) AND ( sdate <=3D '2004-07-21' ) ) ) ORDER BY sdate, = +stime +; + +NOTICE: QUERY PLAN: + +Sort (cost=3D17.13..17.13 rows=3D1 width=3D16) (actual time=3D619140.18..6= +19140.29rows + +=3D288 loops=3D1) + + -> Index Scan using lan_pkey on lan (cost=3D0.00..17.12 rows=3D1 width= +=3D16) +(ac + +tual time=3D7564.44..619121.61 rows=3D288 loops=3D1) + +Total runtime: 619140.76 msec + + + +EXPLAIN + + + +bsdb=3D# explain analyze SELECT DISTINCT sdate, stime, rbts from lan + + WHERE ( ( bname =3D 'pluto' ) AND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( = +( sdate +>=3D '2004-07-21' ) AND ( sdate <=3D '2004-07-21' ) ) ) + + ORDER BY sdate, stime ; + +NOTICE: QUERY PLAN: + + + +Unique (cost=3D17.13..17.14 rows=3D1 width=3D16) (actual time=3D +610546.66..610564.31 rows=3D288 loops=3D1) + + -> Sort (cost=3D17.13..17.13 rows=3D1 width=3D16) (actual time=3D +610546.65..610546.75 rows=3D288 loops=3D1) + + -> Index Scan using lan_pkey on lan (cost=3D0.00..17.12 rows=3D1 +width=3D16) (actual time=3D7524.47..610533.50 rows=3D288 loops=3D1) + +Total runtime: 610565.51 msec + + + +EXPLAIN + + + +pdb=3D# explain analyze SELECT ALL sdate, stime, rbts from lan WHERE ( ( +bname =3D 'neptune' ) AND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( ( sdate >= +=3D +'2004-07-21' ) AND ( sdate <=3D '2004-07-21' ) ) ) ORDER BY sdate, stime = +; + +NOTICE: QUERY PLAN: + + + +Sort (cost=3D17.13..17.13 rows=3D1 width=3D16) (actual time=3D +1260756.66..1260756.76 rows=3D288 loops=3D1) + + -> Index Scan using lan_pkey on lan (cost=3D0.00..17.12 rows=3D1 width= +=3D16) +(actual time=3D7725.97..1260752.47 rows=3D288 loops=3D1) + +Total runtime: 1260757.09 msec + + + + + +pdb=3D# \d lan + + Table "lan" + + Column | Type | Modifiers + +------------------+-----------------------+----------- + + bname | character varying(64) | not null + + sdate | date | not null + + stime | integer | not null + + cno | smallint | not null + + pno | smallint | not null + + rbts | bigint | + + tbts | bigint | + + u_inpkt | bigint | + + u_outpkt | bigint | + + m_inpkt | bigint | + + m_outpkt | bigint | + + b_inpkt | bigint | + + b_outpkt | bigint | + +Primary key: lan_pkey + +Check constraints: "lan_stime" ((stime >=3D 0) AND (stime < 86400)) + + +On 4/10/06, Joshua D. Drake wrote: +> +> Rajesh Kumar Mallah wrote: +> > +> > what is the query ? +> > use LIMIT or a restricting where clause. +> +> You could also use a cursor. +> +> Joshua D. Drake +> > +> > +> > regds +> > mallah. +> > +> > On 4/10/06, *soni de* < soni.de@gmail.com > +> wrote: +> > +> > Hello, +> > +> > I have difficulty in fetching the records from the database. +> > Database table contains more than 1 GB data. +> > For fetching the records it is taking more the 1 hour and that's wh= +y +> > it is slowing down the performance. +> > please provide some help regarding improving the performance and ho= +w +> > do I run query so that records will be fetched in a less time. +> > +> > +> +> +> -- +> +> =3D=3D=3D The PostgreSQL Company: Command Prompt, Inc. =3D=3D= +=3D +> Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 +> Providing the most comprehensive PostgreSQL solutions since 1997 +> http://www.commandprompt.com/ +> +> +> + +------=_Part_2509_16979380.1144739127476 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

 

+

I have flushed the database, so currently r= +ecords in the "lan" table are: 665280

+

but records can be increased more than 1GB = +and in that case it takes more than 1 hour

+

 

+

Below is explain analyze output taken from = +the table having 665280 records

+

 

+

pdb=3D# explain analyze SELECT sdate, stime= +, rbts from lan WHERE (

+

 ( bname =3D 'pluto' ) AND ( cno =3D 1= +7 ) AND ( pno =3D 1 ) AND ( ( sdate

+

 >=3D '2004-07-21' ) AND ( sdate &l= +t;=3D '2004-07-21' ) )  )  ORDER BY sdate, stime ;<= +/p> +

NOTICE:  QUERY PLAN:

+

Sort  (cost=3D17.13..17.13 rows=3D1 wi= +dth=3D16) (actual time=3D619140.18..619140.29 rows

+

=3D288 loops=3D1)

+

  ->  Index Scan using lan_pke= +y on lan  (cost=3D0.00..17.12 rows=3D1 width=3D16) (ac +

tual time=3D7564.44..619121.61 rows=3D288 l= +oops=3D1)

+

Total runtime: 619140.76 msec= +

+

 

+

EXPLAIN

+

 

+

bsdb=3D# explain analyze SELECT DISTINCT sd= +ate, stime, rbts from lan

+

 WHERE (  ( bname =3D 'pluto' ) A= +ND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( ( sdate >=3D '2004-07-21' ) AN= +D ( sdate <=3D '2004-07-21' ) )  ) =20 +

+

 ORDER BY sdate, stime ;= +

+

NOTICE:  QUERY PLAN:

+

 

+

Unique  (cost=3D17.13..17.14 rows=3D1 = +width=3D16) (actual time=3D610546.66..610564.31 rows=3D288 loops=3D1)

+

  ->  Sort  (cost=3D17.13= +..17.13 rows=3D1 width=3D16) (actual time=3D610546.65..610546.75 rows=3D288= + loops=3D1)

+

        = +->  Index Scan using lan_pkey on lan  (cost=3D0.00..17.12 rows= +=3D1 width=3D16) (actual time=3D7524.47..610533.50 rows=3D288 loops=3D1) +

+

Total runtime: 610565.51 msec= +

+

 

+

EXPLAIN

+

 

+

pdb=3D# explain analyze SELECT ALL sdate, s= +time, rbts from lan WHERE (  ( bname =3D 'neptune' ) AND ( cno =3D 17 = +) AND ( pno =3D 1 ) AND ( ( sdate >=3D '2004-07-21' ) AND ( sdate <= +=3D '2004-07-21' ) )  )  ORDER BY sdate, stime ; +

+

NOTICE:  QUERY PLAN:

+

 

+

Sort  (cost=3D17.13..17.13 rows=3D1 wi= +dth=3D16) (actual time=3D1260756.66..1260756.76 rows=3D288 loops=3D1)

+

  ->  Index Scan using lan_pke= +y on lan  (cost=3D0.00..17.12 rows=3D1 width=3D16) (actual time=3D7725= +.97..1260752.47 rows=3D288 loops=3D1) +

+

Total runtime: 1260757.09 msec

+

 

+

 

+

pdb=3D# \d lan

+

       &= +nbsp;           &nbs= +p; Table "lan"

+

      Column = +     |         = +Type          | Modifiers

+

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

+

 bname     &n= +bsp;      | character varying(64) | not null

+

 sdate     &n= +bsp;      | date     &nbs= +p;            | not = +null

+

 stime     &n= +bsp;      | integer     &= +nbsp;         | not null

+

 cno     &nbs= +p;        | smallint   &n= +bsp;          | not null

+

 pno     &nbs= +p;        | smallint   &n= +bsp;          | not null

+

 rbts     &nb= +sp;       | bigint    &nb= +sp;           |

+

 tbts     &nb= +sp;       | bigint    &nb= +sp;           |

+

 u_inpkt     = +     | bigint       = +         |

+

 u_outpkt     = +;    | bigint        = +;        |

+

 m_inpkt      = +;    | bigint       = +         |

+

 m_outpkt     = +;    | bigint        = +;        |

+

 b_inpkt     = +     | bigint       = +         |

+

 b_outpkt     = +;    | bigint        = +;        |

+

Primary key: lan_pkey

+

Check constraints: "lan_stime" ((= +stime >=3D 0) AND (stime < 86400))



+
On 4/10/06, = +Joshua D. Drake <jd@commandp= +rompt.com> wrote: +
Rajesh Kumar Mallah wrote:
&g= +t;
> what is the query ?
> use LIMIT or a restricting where cla= +use. +

You could also use a cursor.

Joshua D. Drake
>
>= +
> regds
> mallah.
>
> On 4/10/06, *soni de* < <= +a href=3D"mailto:soni.de@gmail.com">soni.de@gmail.com <mailto: +soni.de@gmail.com>> wrote:
>
>    = +; Hello,
>
>     I have difficulty in fetch= +ing the records from the database.
>     Database= + table contains more than 1 GB data.
>     For fe= +tching the records it is taking more the 1 hour and that's why +
>     it is slowing down the performance.
>= +;     please provide some help regarding improving the = +performance and how
>     do I run query so that = +records will be fetched in a less time.
>
>
+

--

         &nb= +sp;  =3D=3D=3D The PostgreSQL Company: Command Prompt, Inc. =3D= +=3D=3D
      Sales/Support: +1.503.667.456= +4 || 24x7/Emergency: +1.800.492.2240
      = +;Providing the most comprehensive  PostgreSQL solutions since 199= +7 +
            = +;         http://www.commandprompt.com/


= +

+ +------=_Part_2509_16979380.1144739127476-- + +From pgsql-performance-owner@postgresql.org Tue Apr 11 04:19:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 30A3E11F6B3C + for ; + Tue, 11 Apr 2006 04:19:55 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.001 +X-Spam-Level: +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id x9ne3oysnRoW + for ; + Tue, 11 Apr 2006 04:19:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx0.ifl.net (mx0.nmh.ifl.net [194.238.48.13]) + by postgresql.org (Postfix) with ESMTP id 0B1FB11F6977 + for ; + Tue, 11 Apr 2006 04:19:46 -0300 (ADT) +Received: from ex-con1.internal.rmplc.net (hercules.rmplc.co.uk + [194.238.48.90]) + by mx0.ifl.net (8.13.6/8.13.6) with ESMTP id k3B7JeFE010720 + for ; Tue, 11 Apr 2006 07:19:40 GMT +X-MessageTextProcessor: DisclaimIt (2.00.200) on ex-con1.internal.rmplc.net +Received: from ex-mail2.internal.rmplc.net ([172.16.11.13]) by + ex-con1.internal.rmplc.net with Microsoft SMTPSVC(6.0.3790.211); + Tue, 11 Apr 2006 08:19:38 +0100 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.326 +Content-Class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C65D38.4B1D977B" +Subject: Stored Procedure Performance +Date: Tue, 11 Apr 2006 08:19:39 +0100 +Message-ID: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> +Content-Transfer-Encoding: 7bit +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Stored Procedure Performance +thread-index: AcZdOEtsr/LtEvwwRnKd0jLkZuMiOA== +From: "Simon Dale" +To: +Importance: normal +X-OriginalArrivalTime: 11 Apr 2006 07:19:38.0924 (UTC) + FILETIME=[4B489EC0:01C65D38] +X-IFL-MailScanner-Information: Please contact IFL support for more information +X-IFL-MailScanner: Found to be clean +X-IFL-MailScanner-From: sdale@rm.com +X-Archive-Number: 200604/227 +X-Sequence-Number: 18311 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C65D38.4B1D977B +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + +Hi, + +=20 + +I'm trying to evaluate PostgreSQL as a database that will have to store +a high volume of data and access that data frequently. One of the +features on our wish list is to be able to use stored procedures to +access the data and I was wondering if it is usual for stored procedures +to perform slower on PostgreSQL than raw SQL? + +=20 + +A simple example of this can be shown with the following commands: + +=20 + +First I created a test table: + +=20 + +CREATE TABLE test ( + +id int8, + +name varchar(128), + +description varchar(500), + +constraint "pk_test" primary key (id) + +); + +=20 + +Then the function I want to test: + +=20 + +CREATE OR REPLACE FUNCTION readTest() RETURNS SETOF test AS + +$$ + +DECLARE + + row test%ROWTYPE; + +BEGIN + + FOR row IN SELECT * FROM test LOOP + + RETURN NEXT row; + + END LOOP; + +=20 + + RETURN; + +END; + +$$ LANGUAGE plpgsql; + +=20 + +Firstly, I ran EXPLAIN on the raw SQL to see how long that takes to +access the database the results are as follows: + +=20 + +EXPLAIN ANALYZE SELECT * FROM test; + +Seq Scan on test (cost=3D0.00..10.90 rows=3D90 width=3D798) (actual +time=3D0.003..0.003 rows=3D0 loops=3D1) + +Total runtime: 0.074 ms + +(2 rows) + +=20 + +Secondly, I ran EXPLAIN on the function created above and the results +are as follows: + +=20 + +EXPLAIN ANALYZE SELECT * FROM readTest(); + +Function Scan on readtest (cost=3D0.00..12.50 rows=3D1000 width=3D798) +(actual time=3D0.870..0.870 rows=3D0 loops=3D1) + +Total runtime: 0.910 ms + +(2 rows) + +=20 + +I know that the function is planned the first time it is executed so I +ran the same command again to remove that processing from the timings +and the results are as follows: + +=20 + +EXPLAIN ANALYZE SELECT * FROM readTest(); + +Function Scan on readtest (cost=3D0.00..12.50 rows=3D1000 width=3D798) +(actual time=3D0.166..0.166 rows=3D0 loops=3D1) + +Total runtime: 0.217 ms + +(2 rows) + +=20 + +Event with the planning removed, the function still performs +significantly slower than the raw SQL. Is that normal or am I doing +something wrong with the creation or calling of the function? + +=20 + +Thanks for your help, + +=20 + +Simon + +=20 +Visit our Website at http://www.rm.com + +This message is confidential. You should not copy it or disclose its = +contents to anyone. You may use and apply the information for the = +intended purpose only. Internet communications are not secure; = +therefore, RM does not accept legal responsibility for the contents of = +this message. Any views or opinions presented are those of the author = +only and not of RM. If this email has come to you in error, please = +delete it, along with any attachments. Please note that RM may intercept = +incoming and outgoing email communications.=20 + +Freedom of Information Act 2000 +This email and any attachments may contain confidential information = +belonging to RM. Where the email and any attachments do contain = +information of a confidential nature, including without limitation = +information relating to trade secrets, special terms or prices these = +shall be deemed for the purpose of the Freedom of Information Act 2000 = +as information provided in confidence by RM and the disclosure of which = +would be prejudicial to RM's commercial interests. + +This email has been scanned for viruses by Trend ScanMail. + +------_=_NextPart_001_01C65D38.4B1D977B +Content-Type: text/html; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + +
+ +

Hi,

+ +

 

+ +

I’m trying to evaluate PostgreSQL as a database = +that +will have to store a high volume of data and access that data = +frequently. One +of the features on our wish list is to be able to use stored procedures = +to +access the data and I was wondering if it is usual for stored procedures = +to +perform slower on PostgreSQL than raw SQL?

+ +

 

+ +

A simple example of this can be shown with the = +following +commands:

+ +

 

+ +

First I created a test = +table:

+ +

 

+ +

CREATE TABLE test (

+ +

id = +int8,

+ +

name = +varchar(128),

+ +

description = +varchar(500),

+ +

constraint = +“pk_test” +primary key (id)

+ +

);

+ +

 

+ +

Then the function I want to = +test:

+ +

 

+ +

CREATE OR REPLACE FUNCTION readTest() RETURNS SETOF = +test AS

+ +

$$

+ +

DECLARE

+ +

         = +   row +test%ROWTYPE;

+ +

BEGIN

+ +

         = +   FOR +row IN SELECT * FROM test LOOP

+ +

         = +            &= +nbsp;  RETURN +NEXT row;

+ +

         = +   END +LOOP;

+ +

 

+ +

         = +   RETURN;

+ +

END;

+ +

$$ LANGUAGE plpgsql;

+ +

 

+ +

Firstly, I ran EXPLAIN on the raw SQL to see how long = +that +takes to access the database the results are as = +follows:

+ +

 

+ +

EXPLAIN ANALYZE SELECT * FROM = +test;

+ +

Seq Scan on test  (cost=3D0.00..10.90 rows=3D90 = +width=3D798) +(actual time=3D0.003..0.003 rows=3D0 = +loops=3D1)

+ +

Total runtime: 0.074 ms

+ +

(2 rows)

+ +

 

+ +

Secondly, I ran EXPLAIN on the function created above = +and +the results are as follows:

+ +

 

+ +

EXPLAIN ANALYZE SELECT * FROM = +readTest();

+ +

Function Scan on readtest  (cost=3D0.00..12.50 = +rows=3D1000 width=3D798) +(actual time=3D0.870..0.870 rows=3D0 = +loops=3D1)

+ +

Total runtime: 0.910 ms

+ +

(2 rows)

+ +

 

+ +

I know that the function is planned the first time it = +is +executed so I ran the same command again to remove that processing from = +the +timings and the results are as follows:

+ +

 

+ +

EXPLAIN ANALYZE SELECT * FROM = +readTest();

+ +

Function Scan on readtest  (cost=3D0.00..12.50 = +rows=3D1000 width=3D798) +(actual time=3D0.166..0.166 rows=3D0 = +loops=3D1)

+ +

Total runtime: 0.217 ms

+ +

(2 rows)

+ +

 

+ +

Event with the planning removed, the function still = +performs +significantly slower than the raw SQL. Is that normal or am I doing = +something wrong +with the creation or calling of the = +function?

+ +

 

+ +

Thanks for your help,

+ +

 

+ +

Simon

+ +

 

+ +
+ +
+

+Visit our Website at www.rm.com +
+
+This message is confidential. You should not copy it or disclose its = +contents to anyone. You may use and apply the information for the = +intended purpose only. Internet communications are not secure; = +therefore, RM does not accept legal responsibility for the contents of = +this message. Any views or opinions presented are those of the author = +only and not of RM. If this email has come to you in error, please = +delete it, along with any attachments. Please note that RM may intercept = +incoming and outgoing email communications.=20 +

+Freedom of Information Act 2000 +
+This email and any attachments may contain confidential information = +belonging to RM. Where the email and any attachments do contain = +information of a confidential nature, including without limitation = +information relating to trade secrets, special terms or prices these = +shall be deemed for the purpose of the Freedom of Information Act 2000 = +as information provided in confidence by RM and the disclosure of which = +would be prejudicial to RM's commercial interests. +

+This email has been scanned for viruses by Trend ScanMail.

+
+ + + +------_=_NextPart_001_01C65D38.4B1D977B-- + +From pgsql-performance-owner@postgresql.org Tue Apr 11 04:58:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2B05111F6C7D + for ; + Tue, 11 Apr 2006 04:58:39 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.121 +X-Spam-Level: +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id foPI+j9919nP + for ; + Tue, 11 Apr 2006 04:58:32 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.226]) + by postgresql.org (Postfix) with ESMTP id 3B48D11F6C74 + for ; + Tue, 11 Apr 2006 04:58:33 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i12so981944wra + for ; + Tue, 11 Apr 2006 00:58:34 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=MkTEBPh3T+6AD4rX+i4t2znrY/9VVnQfJHGjwUX+/E/26FGNGzz3XmzJNfLLBXRRYDYJx9Ik49c6SILB0SAL5uTy9hmbH5jK/ZyBBRqWSBzVxwi25hy8TOKkv9I6L4syPSFy/nr2wjvM4d9r0Qw6r0u6snGyy0bjmfMQQmOeNnI= +Received: by 10.65.61.13 with SMTP id o13mr254622qbk; + Tue, 11 Apr 2006 00:58:33 -0700 (PDT) +Received: by 10.65.61.19 with HTTP; Tue, 11 Apr 2006 00:58:33 -0700 (PDT) +Message-ID: <9e4684ce0604110058r371c5dbib531d5409a47a399@mail.gmail.com> +Date: Tue, 11 Apr 2006 09:58:33 +0200 +From: "hubert depesz lubaczewski" +To: "Simon Dale" +Subject: Re: Stored Procedure Performance +Cc: pgsql-performance@postgresql.org +In-Reply-To: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_1965_21816926.1144742313934" +References: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> +X-Archive-Number: 200604/228 +X-Sequence-Number: 18312 + +------=_Part_1965_21816926.1144742313934 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 4/11/06, Simon Dale wrote: +> +> I'm trying to evaluate PostgreSQL as a database that will have to store a +> high volume of data and access that data frequently. One of the features = +on +> our wish list is to be able to use stored procedures to access the data a= +nd +> I was wondering if it is usual for stored procedures to perform slower on +> PostgreSQL than raw SQL? +> + +worry but your benchmark is completelly flawed. +1st. the tables are empty. will you ever run the real code on empty tables? +2nd. do you really need a stored procedure for such a simple query? + +testing something that's far from real usage will not give you any good. +return next will of course show up as slower than standard select. the thin= +g +is - will the relative slowness of return next matter to you when you will +put more logic in the procedure? + +depesz + +------=_Part_1965_21816926.1144742313934 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 4/11/06, Simon Dale <sdale@rm.com> wrote:
+
+ + + + + + + + + + + + +

I'm trying to evaluate PostgreSQL as a database that +will have to store a high volume of data and access that data frequently. O= +ne +of the features on our wish list is to be able to use stored procedures to +access the data and I was wondering if it is usual for stored procedures to +perform slower on PostgreSQL than raw SQL?


worry but your benchmark is completelly flawed.
1st.= + the tables are empty. will you ever run the real code on empty tables? +
2nd. do you really need a stored procedure for such a simple query?
= +
testing something that's far from real usage will not give you any good= +.
return next will of course show up as slower than standard select. the= + thing is - will the relative slowness of return next matter to you when yo= +u will put more logic in the procedure? +

depesz
+ +------=_Part_1965_21816926.1144742313934-- + +From pgsql-performance-owner@postgresql.org Tue Apr 11 05:23:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0EC7B11F65B8 + for ; + Tue, 11 Apr 2006 05:22:54 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.778 +X-Spam-Level: +X-Spam-Status: No, score=0.778 required=5 tests=[AWL=-0.554, + RCVD_IN_BL_SPAMCOP_NET=1.332] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ZuVrB9Tz91wb + for ; + Tue, 11 Apr 2006 05:22:48 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.190]) + by postgresql.org (Postfix) with ESMTP id DB4A911F602E + for ; + Tue, 11 Apr 2006 05:22:49 -0300 (ADT) +Received: by nproxy.gmail.com with SMTP id p77so744172nfc + for ; + Tue, 11 Apr 2006 01:22:48 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=neB1jHi7Cf0fCGyMqpMOVb7KbLocX6KTQ6FWqbF5znolnGYf2dY64TSZPKqah2dzQVx2n2X8zeUIap2+iCfToQU2Lw8GNXkeX1hvsXwrZUMYvEii9abtPxtijv2wzTVPUkFCqHRxhvQZxthIN1ULuo5wB0zwv+IwVcNEXObhJdQ= +Received: by 10.49.75.19 with SMTP id c19mr290228nfl; + Tue, 11 Apr 2006 01:22:48 -0700 (PDT) +Received: by 10.49.27.16 with HTTP; Tue, 11 Apr 2006 01:22:48 -0700 (PDT) +Message-ID: +Date: Tue, 11 Apr 2006 13:52:48 +0530 +From: "Rajesh Kumar Mallah" +To: "Simon Dale" +Subject: Re: Stored Procedure Performance +Cc: pgsql-performance@postgresql.org +In-Reply-To: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> +X-Archive-Number: 200604/229 +X-Sequence-Number: 18313 + +On 4/11/06, Simon Dale wrote: +> +> +> +> Hi, +> +> +> +> I'm trying to evaluate PostgreSQL as a database that will have to store a +> high volume of data and access that data frequently. One of the features = +on +> our wish list is to be able to use stored procedures to access the data a= +nd +> I was wondering if it is usual for stored procedures to perform slower on +> PostgreSQL than raw SQL? + + +No. + +RETURN NEXT keeps accumulating the data before returning. +I am not sure if any optimisations have been done to that effect. + +In general functions are *NOT* slower than RAW SQL. + +Regds +mallah. + +From pgsql-performance-owner@postgresql.org Tue Apr 11 07:04:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 41B4211F712D + for ; + Tue, 11 Apr 2006 07:04:34 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.126 +X-Spam-Level: +X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id SCENuKMVNI7W + for ; + Tue, 11 Apr 2006 07:04:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pih-relay04.plus.net (pih-relay04.plus.net [212.159.14.131]) + by postgresql.org (Postfix) with ESMTP id E430111F70FB + for ; + Tue, 11 Apr 2006 07:04:27 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by pih-relay04.plus.net with esmtp (Exim) id 1FTFjW-0006CG-Oo; + Tue, 11 Apr 2006 11:04:26 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 1419973652; + Tue, 11 Apr 2006 11:06:05 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 697F715EA4; + Tue, 11 Apr 2006 11:04:26 +0100 (BST) +Message-ID: <443B7F29.80807@archonet.com> +Date: Tue, 11 Apr 2006 11:04:25 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Rajesh Kumar Mallah +Cc: Simon Dale , pgsql-performance@postgresql.org +Subject: Re: Stored Procedure Performance +References: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/230 +X-Sequence-Number: 18314 + +Rajesh Kumar Mallah wrote: +> On 4/11/06, Simon Dale wrote: +>> +>> I'm trying to evaluate PostgreSQL as a database that will have to store a +>> high volume of data and access that data frequently. One of the features on +>> our wish list is to be able to use stored procedures to access the data and +>> I was wondering if it is usual for stored procedures to perform slower on +>> PostgreSQL than raw SQL? +> +> No. +> +> RETURN NEXT keeps accumulating the data before returning. +> I am not sure if any optimisations have been done to that effect. +> +> In general functions are *NOT* slower than RAW SQL. + +Actually, in cases where there is a simple way to state the query in raw +SQL then I'd expect that a procedural solution IS slower. After all, +you're adding another layer of processing. + +Of course, you normally wouldn't write a procedural solution to a simple +query. + +Added to this is the difference that plpgsql is planned once whereas raw +sql will be planned on each query. This means you save planning costs +with the plpgsql but have the chance to get better plans with the raw sql. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Apr 11 07:17:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C91C511F719C + for ; + Tue, 11 Apr 2006 07:17:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.126 +X-Spam-Level: +X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id s+xt8JsP0cv7 + for ; + Tue, 11 Apr 2006 07:17:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) + by postgresql.org (Postfix) with ESMTP id 524CF11F6AAD + for ; + Tue, 11 Apr 2006 07:17:22 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by ptb-relay02.plus.net with esmtp (Exim) id 1FTFvo-00063Z-TI; + Tue, 11 Apr 2006 11:17:08 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id F31477364F; + Tue, 11 Apr 2006 11:18:40 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 060F415EA4; + Tue, 11 Apr 2006 11:17:02 +0100 (BST) +Message-ID: <443B821D.2000005@archonet.com> +Date: Tue, 11 Apr 2006 11:17:01 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: soni de +Cc: "Joshua D. Drake" , + Rajesh Kumar Mallah , + pgsql-performance@postgresql.org +Subject: Re: Takes too long to fetch the data from database +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <443AA1D4.9010308@commandprompt.com> + <9f2e40a90604110005o101fe98enec2f8ac8f757c770@mail.gmail.com> +In-Reply-To: <9f2e40a90604110005o101fe98enec2f8ac8f757c770@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/231 +X-Sequence-Number: 18315 + +soni de wrote: +> I have flushed the database, so currently records in the "lan" table are: +> 665280 +> +> but records can be increased more than 1GB and in that case it takes more +> than 1 hour +> +> Below is explain analyze output taken from the table having 665280 records +> +> pdb=# explain analyze SELECT sdate, stime, rbts from lan WHERE ( +> ( bname = 'pluto' ) AND ( cno = 17 ) AND ( pno = 1 ) AND ( ( sdate +> >= '2004-07-21' ) AND ( sdate <= '2004-07-21' ) ) ) ORDER BY sdate, stime +> ; +> +> NOTICE: QUERY PLAN: +> Sort (cost=17.13..17.13 rows=1 width=16) (actual time=619140.18..619140.29rows +> =288 loops=1) +> -> Index Scan using lan_pkey on lan (cost=0.00..17.12 rows=1 width=16) +> (actual time=7564.44..619121.61 rows=288 loops=1) +> +> Total runtime: 619140.76 msec + +OK - there is clearly something wrong here when you take 10 minutes to +fetch 288 rows from an index. + +1. VACUUM FULL VERBOSE lan; +2. test again, and if that doesn't work... +3. REINDEX TABLE lan; +4. test again + +I'm guessing you have a *lot* of dead rows in there. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Apr 11 09:05:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2B1B911F6271 + for ; + Tue, 11 Apr 2006 09:05:07 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id qDt-2WSzIYvl + for ; + Tue, 11 Apr 2006 09:04:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.linuxnews.dk (shrek.krogh.cc [81.7.132.92]) + by postgresql.org (Postfix) with ESMTP id A5AAC11F626A + for ; + Tue, 11 Apr 2006 09:05:02 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.linuxnews.dk (Postfix) with ESMTP id E9B983BEC1F; + Tue, 11 Apr 2006 14:05:00 +0200 (CEST) +Received: from mail.linuxnews.dk ([127.0.0.1]) + by localhost (shrek.krogh.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 12840-02; Tue, 11 Apr 2006 14:04:58 +0200 (CEST) +Received: from mail.jabbernet.dk (localhost.localdomain [127.0.0.1]) + by mail.linuxnews.dk (Postfix) with ESMTP id E2FAD3BEC1D; + Tue, 11 Apr 2006 14:04:57 +0200 (CEST) +Received: from 195.41.66.226 (SquirrelMail authenticated user jesper@krogh.cc) + by mail.jabbernet.dk with HTTP; + Tue, 11 Apr 2006 14:04:57 +0200 (CEST) +Message-ID: <38326.195.41.66.226.1144757097.squirrel@mail.jabbernet.dk> +In-Reply-To: <810F9DD5-22B1-4A6F-B76C-D7EA7B89035B@khera.org> +References: + <810F9DD5-22B1-4A6F-B76C-D7EA7B89035B@khera.org> +Date: Tue, 11 Apr 2006 14:04:57 +0200 (CEST) +Subject: Re: Restore performance? +From: "Jesper Krogh" +To: "Vivek Khera" +Cc: "Postgresql Performance" +User-Agent: SquirrelMail/1.5.1 [CVS] +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Debian amavisd-new at shrek.krogh.cc +X-Archive-Number: 200604/232 +X-Sequence-Number: 18316 + +> Well, your pg_dump command lost your BLOBs since the plain text +> format doesn't support them. + +Well, no.. they are stored as BYTEA not Large Objects.. They are encoded +in ASCII in the pg_dump output. + +> But once you use the -Fc format on your dump and enable blob backups, +> you can speed up reloads by increasing your checkpoint segments to a big +> number like 256 and the checkpoint timeout to something like 10 minutes. +> All other normal tuning parameters should be what you plan +> to use for your normal operations, too. + +Thanks. + +Jesper +-- +Jesper Krogh + + +From pgsql-performance-owner@postgresql.org Tue Apr 11 10:13:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DBB4011F6645 + for ; + Tue, 11 Apr 2006 10:13:30 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id WjnMpgtUVlq5 + for ; + Tue, 11 Apr 2006 10:13:20 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.225]) + by postgresql.org (Postfix) with ESMTP id 3987B11F65C6 + for ; + Tue, 11 Apr 2006 10:13:23 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so1116956wra + for ; + Tue, 11 Apr 2006 06:13:24 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=SXCAPOvu6wtc/lV2WFgeyTfb0OsMjCyPZ1jJakDZUqWm4qvYhTKwoQZU5MSPzHFAEpV1QSS1v+QXpjuIljt1dGoPknmsS1R+7uuA3I5fCpgzxRZzwUIy7IF+w27nCtC02zUQCoQXI2Tj1RkHkIWQm4DlHzWz80zdNSYoFzHiV/A= +Received: by 10.65.97.20 with SMTP id z20mr4980704qbl; + Tue, 11 Apr 2006 06:13:24 -0700 (PDT) +Received: by 10.65.137.8 with HTTP; Tue, 11 Apr 2006 06:13:24 -0700 (PDT) +Message-ID: +Date: Tue, 11 Apr 2006 09:13:24 -0400 +From: "Merlin Moncure" +To: "soni de" +Subject: Re: Takes too long to fetch the data from database +Cc: pgsql-performance@postgresql.org +In-Reply-To: <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> +X-Archive-Number: 200604/233 +X-Sequence-Number: 18317 + +> pdb=3D# explain analyze SELECT sdate, stime, rbts from lan WHERE ( +> +> ( bname =3D 'pluto' ) AND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( ( sdate +> +> >=3D '2004-07-21' ) AND ( sdate <=3D '2004-07-21' ) ) ) ORDER BY sdate= +, stime +> ; + +this query would benefit from an index on +pluto, cno, pno, sdate + +create index Ian_idx on Ian(bname, cno, pno, sdate); + + +> pdb=3D# explain analyze SELECT ALL sdate, stime, rbts from lan WHERE ( ( +> bname =3D 'neptune' ) AND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( ( sdate = +>=3D +> '2004-07-21' ) AND ( sdate <=3D '2004-07-21' ) ) ) ORDER BY sdate, stim= +e ; + +ditto above. Generally, the closer the fields in the where clause are +matched by the index, the it will speed up your query. + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Apr 11 10:50:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 24F4A11F62C7 + for ; + Tue, 11 Apr 2006 10:50:50 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.128 +X-Spam-Level: +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id R7x0ZFC5c6Pi + for ; + Tue, 11 Apr 2006 10:50:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id E66CC11F6297 + for ; + Tue, 11 Apr 2006 10:50:44 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3BDjaxN007302; + Tue, 11 Apr 2006 09:45:37 -0400 (EDT) +To: Richard Huxton +cc: soni de , "Joshua D. Drake" , + Rajesh Kumar Mallah , + pgsql-performance@postgresql.org +Subject: Re: Takes too long to fetch the data from database +In-reply-to: <443B821D.2000005@archonet.com> +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <443AA1D4.9010308@commandprompt.com> + <9f2e40a90604110005o101fe98enec2f8ac8f757c770@mail.gmail.com> + <443B821D.2000005@archonet.com> +Comments: In-reply-to Richard Huxton + message dated "Tue, 11 Apr 2006 11:17:01 +0100" +Date: Tue, 11 Apr 2006 09:45:36 -0400 +Message-ID: <7301.1144763136@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/235 +X-Sequence-Number: 18319 + +Richard Huxton writes: +> soni de wrote: +>> NOTICE: QUERY PLAN: +>> Sort (cost=17.13..17.13 rows=1 width=16) (actual time=619140.18..619140.29rows +>> =288 loops=1) +>> -> Index Scan using lan_pkey on lan (cost=0.00..17.12 rows=1 width=16) +>> (actual time=7564.44..619121.61 rows=288 loops=1) +>> +>> Total runtime: 619140.76 msec + +> OK - there is clearly something wrong here when you take 10 minutes to +> fetch 288 rows from an index. + +> I'm guessing you have a *lot* of dead rows in there. + +Yeah. The other small problem here is that EXPLAIN output hasn't looked +like that since PG 7.2 (unless Soni has just omitted the index-condition +lines). I'd recommend updating to something modern. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 11 10:50:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 919BC11F7B64 + for ; + Tue, 11 Apr 2006 10:50:07 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id FPOJZSQ2v3xe + for ; + Tue, 11 Apr 2006 10:49:45 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.229]) + by postgresql.org (Postfix) with ESMTP id 8FA0911F6C2F + for ; + Tue, 11 Apr 2006 10:49:48 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i7so1673084wra + for ; + Tue, 11 Apr 2006 06:49:49 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=drF1QCSqAub//rSX59UtlXw9ZouN6BpVhcfOyDOEn5Z587Jhqr3QJYOGSQNiGWstfWhyFZ8JbiE3bXUgsWq0M9fspf2K7vMBwleIVvSULOPbnR8YbQHdEVqeILofdzKSafC1GvjhUeFGlk7wIGaBngqGWPKl5seyf8c/PBUR5Gc= +Received: by 10.65.52.3 with SMTP id e3mr5040474qbk; + Tue, 11 Apr 2006 06:49:48 -0700 (PDT) +Received: by 10.65.137.8 with HTTP; Tue, 11 Apr 2006 06:49:48 -0700 (PDT) +Message-ID: +Date: Tue, 11 Apr 2006 09:49:48 -0400 +From: "Merlin Moncure" +To: "Simon Dale" +Subject: Re: Stored Procedure Performance +Cc: pgsql-performance@postgresql.org +In-Reply-To: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> +X-Archive-Number: 200604/234 +X-Sequence-Number: 18318 + +On 4/11/06, Simon Dale wrote: +> I'm trying to evaluate PostgreSQL as a database that will have to store a +> high volume of data and access that data frequently. One of the features = +on +> our wish list is to be able to use stored procedures to access the data a= +nd +> I was wondering if it is usual for stored procedures to perform slower on +> PostgreSQL than raw SQL? + +pl/pgsql procedures are a very thin layer over the query engine.=20 +Generally, they run about the same speed as SQL but you are not making +apples to apples comparison. One of the few but annoying limitations +of pl/pgsql procedures is that you can't return a select directly from +the query engine but have to go through the return/return next +paradigm which will be slower than raw query for obvious reasons. + +You can however return a refcursor and you may want to look at them in +situations where you want to return arbitrary sets outside the query +engine or between pl/pgsql functions. An example of using refcurors +in that way is on my blog at +http://people.planetpostgresql.org/merlin/index.php?/archives/2-Dealing-Wit= +h-Recursive-Sets-With-PLPGSQL.html + +Generally, in my opinion if you want to really unlock the power of +postgresql you have to master pl/pgsql. Go for it...it will work and +work well. + +merlin + +merlin + +From pgsql-performance-owner@postgresql.org Tue Apr 11 10:57:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 22D1311F6294 + for ; + Tue, 11 Apr 2006 10:57:11 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.99 +X-Spam-Level: +X-Spam-Status: No, score=0.99 required=5 tests=[AWL=0.177, INFO_TLD=0.813] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id tojmLGbKdEHM + for ; + Tue, 11 Apr 2006 10:56:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id C612411F65C2 + for ; + Tue, 11 Apr 2006 10:56:58 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id C9EDC30F62; Tue, 11 Apr 2006 15:56:58 +0200 (MET DST) +From: Christopher Browne +X-Newsgroups: pgsql.performance +Subject: Re: Stored Procedure Performance +Date: Tue, 11 Apr 2006 09:56:27 -0400 +Organization: cbbrowne Computing Inc +Lines: 43 +Message-ID: <87acasjjw4.fsf@wolfe.cbbrowne.com> +References: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) +Cancel-Lock: sha1:aD9HstEdscoyztktrJTH/TeUTfQ= +To: pgsql-performance@postgresql.org +X-Archive-Number: 200604/236 +X-Sequence-Number: 18320 + +sdale@rm.com ("Simon Dale") wrote: +>

Event with the planning removed, the function still performs +> significantly slower than the raw SQL. Is that normal or am I doing something wrong +> with the creation or calling of the +> function?

+ +I'd expect this, yes. + +You're doing something via "stored procedure logic" that would be done +more directly via straight SQL; of course it won't be faster. + +In effect, pl/pgsql involves (planning once) then running each line of +logic. In effect, you replaced one query (select * from some table) +into 90 queries. Yup, there's extra cost there. + +There's not some "magic" by which stored procedures provide results +faster as a natural "matter of course;" the performance benefits +generally fall out of two improvements: + + 1. You eliminate client-to-server round trips. + + A stored proc that runs 8 queries saves you 8 round trips over + submitting the 8 queries directly. Saving you latency time. + + 2. You can eliminate the marshalling and transmission of unnecessary + data. + + A stored proc that runs 8 queries, and only returns summarized + results that all come from the last table queried will eliminate + the need to marshall and transmit (possibly over a slow link) the + data for the 7 preceding queries. + +The case that you tried can benefit from neither of those effects; +your stored procedure eliminates NO round trips, and NO +marshalling/transmission. +-- +(format nil "~S@~S" "cbbrowne" "gmail.com") +http://linuxdatabases.info/info/rdbms.html +Rules of the Evil Overlord #228. "If the hero claims he wishes to +confess in public or to me personally, I will remind him that a +notarized deposition will serve just as well." + + +From pgsql-performance-owner@postgresql.org Tue Apr 11 11:02:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 92A2A11F6311 + for ; + Tue, 11 Apr 2006 11:02:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id x0ZpsFoaqe0m + for ; + Tue, 11 Apr 2006 11:02:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from michael.eatserver.nl (michael.eatserver.nl [212.203.14.103]) + by postgresql.org (Postfix) with ESMTP id C781411F638E + for ; + Tue, 11 Apr 2006 11:02:34 -0300 (ADT) +Received: from dvipc (82-170-251-187.dsl.ip.tiscali.nl [82.170.251.187]) + (authenticated bits=0) + by michael.eatserver.nl (8.12.10/8.12.10/SuSE Linux 0.7) with ESMTP id + k3BE2Wfv001561; Tue, 11 Apr 2006 16:02:32 +0200 +From: "H.J. Sanders" +To: "Merlin Moncure" , "Simon Dale" +Cc: +Subject: Re: Stored Procedure Performance +Date: Tue, 11 Apr 2006 16:02:51 +0200 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +In-Reply-To: +Importance: Normal +X-Virus-Scanned: by amavisd-new +X-Archive-Number: 200604/237 +X-Sequence-Number: 18321 + + +Hello + +At my little machine (pentium 4, 2.8 Ghz, 256 Mb RAM, Suse linux 9) +I can process about 100000 records a minute using the next setup: + +begin work + +begin for + processing + if 10.000 records processed: + commit work + begin work + end if +end for + +commit work (!) + +Regards + +Henk Sanders + + + + +> -----Oorspronkelijk bericht----- +> Van: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]Namens Merlin Moncure +> Verzonden: dinsdag 11 april 2006 15:50 +> Aan: Simon Dale +> CC: pgsql-performance@postgresql.org +> Onderwerp: Re: [PERFORM] Stored Procedure Performance +> +> +> On 4/11/06, Simon Dale wrote: +> > I'm trying to evaluate PostgreSQL as a database that will have to store a +> > high volume of data and access that data frequently. One of the features on +> > our wish list is to be able to use stored procedures to access the data and +> > I was wondering if it is usual for stored procedures to perform slower on +> > PostgreSQL than raw SQL? +> +> pl/pgsql procedures are a very thin layer over the query engine. +> Generally, they run about the same speed as SQL but you are not making +> apples to apples comparison. One of the few but annoying limitations +> of pl/pgsql procedures is that you can't return a select directly from +> the query engine but have to go through the return/return next +> paradigm which will be slower than raw query for obvious reasons. +> +> You can however return a refcursor and you may want to look at them in +> situations where you want to return arbitrary sets outside the query +> engine or between pl/pgsql functions. An example of using refcurors +> in that way is on my blog at +> http://people.planetpostgresql.org/merlin/index.php?/archives/2-Dealing-With-Recursive-Sets-With-PLPGSQL.html +> +> Generally, in my opinion if you want to really unlock the power of +> postgresql you have to master pl/pgsql. Go for it...it will work and +> work well. +> +> merlin +> +> merlin +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + +From pgsql-performance-owner@postgresql.org Tue Apr 11 11:09:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 70C9411F644F + for ; + Tue, 11 Apr 2006 11:09:03 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.467 +X-Spam-Level: * +X-Spam-Status: No, score=1.467 required=5 tests=[AWL=-0.452, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id MjbcsbxMrMo2 + for ; + Tue, 11 Apr 2006 11:08:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by postgresql.org (Postfix) with ESMTP id D1A3F11F6405 + for ; + Tue, 11 Apr 2006 11:08:58 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx2.surnet.cl with ESMTP; 11 Apr 2006 10:08:58 -0400 +X-IronPort-Anti-Spam-Filtered: true +X-IronPort-Anti-Spam-Result: AQAAAE6QIkSICgIC +X-IronPort-AV: i="4.02,198,1139194800"; + d="scan'208"; a="42322237:sNHT16884432" +Received: from alvh.no-ip.org (201.221.200.14) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 443B7DDC00009CB5; Tue, 11 Apr 2006 10:08:57 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 02A23C2DC22; Tue, 11 Apr 2006 10:08:58 -0400 (CLT) +Date: Tue, 11 Apr 2006 10:08:57 -0400 +From: Alvaro Herrera +To: Merlin Moncure +Cc: Simon Dale , pgsql-performance@postgresql.org +Subject: Re: Stored Procedure Performance +Message-ID: <20060411140857.GE11760@surnet.cl> +Mail-Followup-To: Merlin Moncure , + Simon Dale , pgsql-performance@postgresql.org +References: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> + +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.11+cvs20060330 +X-Archive-Number: 200604/238 +X-Sequence-Number: 18322 + +Merlin Moncure wrote: +> On 4/11/06, Simon Dale wrote: +> > I'm trying to evaluate PostgreSQL as a database that will have to store a +> > high volume of data and access that data frequently. One of the features on +> > our wish list is to be able to use stored procedures to access the data and +> > I was wondering if it is usual for stored procedures to perform slower on +> > PostgreSQL than raw SQL? +> +> pl/pgsql procedures are a very thin layer over the query engine. +> Generally, they run about the same speed as SQL but you are not making +> apples to apples comparison. One of the few but annoying limitations +> of pl/pgsql procedures is that you can't return a select directly from +> the query engine but have to go through the return/return next +> paradigm which will be slower than raw query for obvious reasons. + +There's one problem that hasn't been mentioned. For the optimizer a +PL/pgSQL function (really, a function in any language except SQL) is a +black box. If you have a complex join of two or three functions, and +they don't return 1000 rows, it's very likely that the optimizer is +going to get it wrong. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Tue Apr 11 14:59:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 779BF11F6006 + for ; + Tue, 11 Apr 2006 14:59:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id vBky-b1sBTaF + for ; + Tue, 11 Apr 2006 14:59:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 7FA3411F6717 + for ; + Tue, 11 Apr 2006 14:59:29 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (Tb349.t.pppool.de + [89.55.179.73]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 17AD1656CB + for ; + Tue, 11 Apr 2006 20:00:20 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id C170B181520C4 + for ; + Tue, 11 Apr 2006 19:59:39 +0200 (CEST) +Message-ID: <443BEE8B.4030301@logix-tt.com> +Date: Tue, 11 Apr 2006 19:59:39 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Indexes with descending date columns +References: <200604090326.k393Qpm08170@candle.pha.pa.us> +In-Reply-To: <200604090326.k393Qpm08170@candle.pha.pa.us> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/239 +X-Sequence-Number: 18323 + +Hi, Bruce, + +Bruce Momjian wrote: + +>>Ahh. There's a hack to do that by defining a new opclass that reverses < +>>and >, and then doing ORDER BY project_id, id, date USING new_opclass. +>> +>>I think there's a TODO about this, but I'm not sure... +> +> Yes, and updated: +> +> * Allow the creation of indexes with mixed ascending/descending +> specifiers +> +> This is possible now by creating an operator class with reversed sort +> operators. One complexity is that NULLs would then appear at the start +> of the result set, and this might affect certain sort types, like +> merge join. + +I think it would be better to allow "index zig-zag scans" for +multi-column index.[1] + +So it traverses in a given order on the higher order column, and the sub +trees for each specific high order value is traversed in reversed order. +>From my knowledge at least of BTrees, and given correct commutator +definitions, this should be not so complicated to implement.[2] + +This would allow the query planner to use the same index for arbitrary +ASC/DESC combinations of the given columns. + + +Just a thought, +Markus + + +[1] It may make sense to implement the mixed specifiers on indices as +well, to allow CLUSTERing on mixed search order. + +[2] But I admit that I currently don't have enough knowledge in +PostgreSQL index scan internals to know whether it really is easy to +implement. + + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Tue Apr 11 16:35:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 265C211F8B81 + for ; + Tue, 11 Apr 2006 16:35:47 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.001 +X-Spam-Level: +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id yCsSDIwcQ7Vk + for ; + Tue, 11 Apr 2006 16:33:06 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id ACF6A11F87D0 + for ; + Tue, 11 Apr 2006 16:13:30 -0300 (ADT) +Received: from mail.zanthus.com.br (mail.zanthus.com.br [200.212.65.85]) + by svr4.postgresql.org (Postfix) with ESMTP id 53F2F5AF18F + for ; + Tue, 11 Apr 2006 19:13:29 +0000 (GMT) +Received: from cprsakai ([192.168.0.71]) + by mail.zanthus.com.br (8.13.4/8.13.4/Debian-3) with SMTP id + k3BJEhB6005390 + for ; Tue, 11 Apr 2006 16:14:43 -0300 +Message-ID: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> +Reply-To: "Rodrigo Sakai" +From: "Rodrigo Sakai" +To: +Subject: FOREIGN KEYS vs PERFORMANCE +Date: Tue, 11 Apr 2006 16:13:34 -0300 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0010_01C65D82.E258A630" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +X-Zanthus-MailScanner: Found to be clean +X-Zanthus-MailScanner-From: rodrigo.sakai@zanthus.com.br +X-Archive-Number: 200604/240 +X-Sequence-Number: 18324 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0010_01C65D82.E258A630 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + Hi, + + I think this is an old question, but I want to know if it really is = +well worth to not create some foreign keys an deal with the referential = +integrity at application-level????? + Specifically, the system we are developing is a server/cliente = +architecture that the server is the database and the fat client is an = +application developed in DELPHI!!! + + Thanks in advance!! +------=_NextPart_000_0010_01C65D82.E258A630 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
  Hi,
+
 
+
  I think this is an old question, = +but I want=20 +to know if it really is well worth to not create some = +foreign=20 +keys an deal with the referential integrity at=20 +application-level?????
+
  Specifically, the system we are = +developing=20 +is a server/cliente architecture that the server is the database and the = +fat=20 +client is an application developed in DELPHI!!!
+
 
+
  Thanks in=20 +advance!!
+ +------=_NextPart_000_0010_01C65D82.E258A630-- + + +From pgsql-performance-owner@postgresql.org Tue Apr 11 17:26:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 619CA11F6C2F + for ; + Tue, 11 Apr 2006 17:26:12 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.118 +X-Spam-Level: +X-Spam-Status: No, score=0.118 required=5 tests=[AWL=0.117, + UNPARSEABLE_RELAY=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 1mPcq8+DLWoE + for ; + Tue, 11 Apr 2006 17:25:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 69D2B11F6C78 + for ; + Tue, 11 Apr 2006 16:48:47 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 11 Apr 2006 19:48:46 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 11 Apr 2006 14:48:46 -0500 +Subject: Re: FOREIGN KEYS vs PERFORMANCE +From: Scott Marlowe +To: Rodrigo Sakai +Cc: pgsql-performance@postgresql.org +In-Reply-To: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1144784926.32269.88.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 11 Apr 2006 14:48:46 -0500 +X-Archive-Number: 200604/241 +X-Sequence-Number: 18325 + +On Tue, 2006-04-11 at 14:13, Rodrigo Sakai wrote: +> Hi, +> +> I think this is an old question, but I want to know if it really is +> well worth to not create some foreign keys an deal with the +> referential integrity at application-level????? +> Specifically, the system we are developing is a server/cliente +> architecture that the server is the database and the fat client is an +> application developed in DELPHI!!! +> + +If ref integrity is important, you'll have to do it either in the app or +the database. + +Almost always, it's faster to let the database do it, as there's less +traffic across the wire required to maintain ref integrity, plus, the +guys who wrote the database have spent years making sure race conditions +won't scram your data. + +For simple, straight forward FK->PK relationships, you will likely NOT +be able to beat the database in terms of either reliability or +performance with your own code. + +From pgsql-performance-owner@postgresql.org Tue Apr 11 18:13:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D6C6D11F6C43 + for ; + Tue, 11 Apr 2006 18:13:22 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 7YOZ4DMx6pL4 + for ; + Tue, 11 Apr 2006 18:12:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by postgresql.org (Postfix) with ESMTP id D3CFC11F89F9 + for ; + Tue, 11 Apr 2006 17:59:27 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 70F71644441; + Tue, 11 Apr 2006 14:59:26 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 27417-02; Tue, 11 Apr 2006 14:59:23 -0600 (MDT) +Received: from [192.168.1.100] (c-67-165-220-189.hsd1.co.comcast.net + [67.165.220.189]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 75D8564443C; + Tue, 11 Apr 2006 14:59:22 -0600 (MDT) +Message-ID: <443C18AA.3000500@drivefaster.net> +Date: Tue, 11 Apr 2006 14:59:22 -0600 +From: Dan Harris +User-Agent: Thunderbird 1.5 (Macintosh/20060122) +MIME-Version: 1.0 +To: Tom Lane +Cc: PostgreSQL Performance +Subject: Re: Encouraging multi-table join order +References: <443AAC26.4070802@drivefaster.net> <1543.1144710756@sss.pgh.pa.us> + <443AEF9B.3000909@drivefaster.net> <2406.1144717297@sss.pgh.pa.us> +In-Reply-To: <2406.1144717297@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Archive-Number: 200604/242 +X-Sequence-Number: 18326 + +Tom Lane wrote: +> +> So it's estimating 5775 cost units per probe into eventactivity, which +> is pretty high --- it must think that a lot of rows will be retrieved by +> the index (way more than the 20 or so it thinks will get past the filter +> condition). + +> What does the pg_stats entry for eventactivity.incidentid +> contain? +select * from pg_stats where tablename = 'eventactivity' and +attname='incidentid'; + schemaname | tablename | attname | null_frac | avg_width | +n_distinct | +most_common_vals +| +most_common_freqs +| +histogram_bounds | +correlation +------------+---------------+------------+-----------+-----------+------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+------------- + public | eventactivity | incidentid | 0 | 14 | +8157 | +{P043190299,P051560740,P052581036,P052830218,P053100679,P053190889,P060370845,P042070391,P042690319,P043290117} +| +{0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00133333,0.00133333,0.00133333} +| +{P022140319,P030471058,P033090308,P041961082,P042910689,P050311006,P051350254,P052261148,P053270945,P060240316,P061000287} +| 0.241737 + +> It might be worth increasing the statistics target for that +> column to try to get a better estimate. +> +How high should I set this? I read the default is 10, but I'm not sure +if doubling this would make a difference or if I should be doing a much +larger number. There's approx 45 million rows in the table, if that matters. + + +Thanks again, +Dan + +From pgsql-performance-owner@postgresql.org Tue Apr 11 18:14:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D9EFB11F7D8A + for ; + Tue, 11 Apr 2006 18:14:18 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.103 +X-Spam-Level: +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id cb20AoSe0A9c + for ; + Tue, 11 Apr 2006 18:13:43 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.239]) + by postgresql.org (Postfix) with ESMTP id 9379F11F6C7D + for ; + Tue, 11 Apr 2006 18:02:01 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i27so1138378wra + for ; + Tue, 11 Apr 2006 14:02:00 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=KV7yQ0iGWjCwgeWwKWrmrThbuduMnZqnWTXWxg/1/LuOieKfNIlc7BXwuENcSwLTdWqsxa1X/ZkeF+qZ/us6BUk010GNY4/4uZrj9awIXvR3TDTXPEYnRyuQeFHAbM3ArImaqQR2dSa+YSzzgevz+s3cyfIwEMVQnZ29P088n6k= +Received: by 10.65.132.15 with SMTP id j15mr614859qbn; + Tue, 11 Apr 2006 14:02:00 -0700 (PDT) +Received: by 10.65.137.8 with HTTP; Tue, 11 Apr 2006 14:02:00 -0700 (PDT) +Message-ID: +Date: Tue, 11 Apr 2006 17:02:00 -0400 +From: "Merlin Moncure" +To: "Merlin Moncure" , "Simon Dale" , + pgsql-performance@postgresql.org +Subject: Re: Stored Procedure Performance +In-Reply-To: <20060411140857.GE11760@surnet.cl> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> + + <20060411140857.GE11760@surnet.cl> +X-Archive-Number: 200604/243 +X-Sequence-Number: 18327 + +On 4/11/06, Alvaro Herrera wrote: +> Merlin Moncure wrote: +> > pl/pgsql procedures are a very thin layer over the query engine. +> > Generally, they run about the same speed as SQL but you are not making +> > apples to apples comparison. One of the few but annoying limitations +> > of pl/pgsql procedures is that you can't return a select directly from +> > the query engine but have to go through the return/return next +> > paradigm which will be slower than raw query for obvious reasons. +> +> There's one problem that hasn't been mentioned. For the optimizer a +> PL/pgSQL function (really, a function in any language except SQL) is a +> black box. If you have a complex join of two or three functions, and +> they don't return 1000 rows, it's very likely that the optimizer is +> going to get it wrong. + +This doesn't bother me that much. Those cases usually have a high +overlap with views.You just have to plan on the function being fully +materialized before it is inovled further. What drives me crazy is I +have to do 'select * from plpgsql_srf()' but I am allowed to do the +much friendlier and more versatile 'select sql_srf()', even if they do +more or less the same thing. + +On the flip side, what drives me crazy about sql functions is that all +tables have to be in the search path for the validator. Since I +frequently use the trick of having multiple schemas with one set of +functions this is annoying. + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Apr 11 18:20:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C4B7A11F7DD4 + for ; + Tue, 11 Apr 2006 18:20:54 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.127 +X-Spam-Level: +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id dBAzRY+xa42I + for ; + Tue, 11 Apr 2006 18:19:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id AE86911F68FE + for ; + Tue, 11 Apr 2006 18:08:54 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3BL8r8E010771; + Tue, 11 Apr 2006 17:08:53 -0400 (EDT) +To: Dan Harris +cc: PostgreSQL Performance +Subject: Re: Encouraging multi-table join order +In-reply-to: <443C18AA.3000500@drivefaster.net> +References: <443AAC26.4070802@drivefaster.net> <1543.1144710756@sss.pgh.pa.us> + <443AEF9B.3000909@drivefaster.net> <2406.1144717297@sss.pgh.pa.us> + <443C18AA.3000500@drivefaster.net> +Comments: In-reply-to Dan Harris + message dated "Tue, 11 Apr 2006 14:59:22 -0600" +Date: Tue, 11 Apr 2006 17:08:53 -0400 +Message-ID: <10770.1144789733@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/244 +X-Sequence-Number: 18328 + +Dan Harris writes: +> Tom Lane wrote: +>> What does the pg_stats entry for eventactivity.incidentid +>> contain? + +> {P043190299,P051560740,P052581036,P052830218,P053100679,P053190889,P060370845,P042070391,P042690319,P043290117} +> | +> {0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00133333,0.00133333,0.00133333} + +> How high should I set this? I read the default is 10, but I'm not sure +> if doubling this would make a difference or if I should be doing a much +> larger number. There's approx 45 million rows in the table, if that matters. + +What the stats entry is saying is that the most common entries occur +about 75000 times apiece (0.00166667 * 45e6), which is what's scaring +the planner here ;-). I think those frequencies are artificially high +though. The default statistics sample size is 3000 rows (300 * +statistics target, actually), so those numbers correspond to 5 or 4 +rows in the sample, which is probably just random chance. + +Try increasing the stats targets for this table to 100, then re-ANALYZE +and see what you get. The most_common_freqs entries might drop as much +as a factor of 10. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 11 18:30:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0892611F7AF3 + for ; + Tue, 11 Apr 2006 18:30:08 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Iw6b3Je0OkpR + for ; + Tue, 11 Apr 2006 18:28:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by postgresql.org (Postfix) with ESMTP id E5D1411F6AB4 + for ; + Tue, 11 Apr 2006 18:21:54 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 8C94D644431; + Tue, 11 Apr 2006 15:21:54 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 28173-08; Tue, 11 Apr 2006 15:21:49 -0600 (MDT) +Received: from [192.168.1.100] (c-67-165-220-189.hsd1.co.comcast.net + [67.165.220.189]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 36689644419; + Tue, 11 Apr 2006 15:21:49 -0600 (MDT) +Message-ID: <443C1DEC.4080307@drivefaster.net> +Date: Tue, 11 Apr 2006 15:21:48 -0600 +From: Dan Harris +User-Agent: Thunderbird 1.5 (Macintosh/20060122) +MIME-Version: 1.0 +To: Tom Lane +Cc: PostgreSQL Performance +Subject: Re: Encouraging multi-table join order +References: <443AAC26.4070802@drivefaster.net> <1543.1144710756@sss.pgh.pa.us> + <443AEF9B.3000909@drivefaster.net> <2406.1144717297@sss.pgh.pa.us> + <443C18AA.3000500@drivefaster.net> <10770.1144789733@sss.pgh.pa.us> +In-Reply-To: <10770.1144789733@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Archive-Number: 200604/245 +X-Sequence-Number: 18329 + +Tom Lane wrote: +> What the stats entry is saying is that the most common entries occur +> about 75000 times apiece (0.00166667 * 45e6), which is what's scaring +> the planner here ;-). I think those frequencies are artificially high +> though. The default statistics sample size is 3000 rows (300 * +> statistics target, actually), so those numbers correspond to 5 or 4 +> rows in the sample, which is probably just random chance. +> +> Try increasing the stats targets for this table to 100, then re-ANALYZE +> and see what you get. The most_common_freqs entries might drop as much +> as a factor of 10. +> +> regards, tom lane +> + +Tom: + +I believe this was the problem. I upped the statistics to 100, for a +sample size of 30k and now the planner does the correct nested +loop/index scan and takes only 30 seconds! This is a HUGE performance +increase. + +I wonder why the estimates were so far off the first time? This table +has been ANALYZED regularly ever since creation. + +Once again, thank you and all of the developers for your hard work on +PostgreSQL. This is by far the most pleasant management experience of +any database I've worked on. + +-Dan + + +From pgsql-performance-owner@postgresql.org Tue Apr 11 19:13:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 28F7011F7CAF + for ; + Tue, 11 Apr 2006 19:13:19 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.002 +X-Spam-Level: +X-Spam-Status: No, score=-0.002 required=5 tests=[SPF_HELO_PASS=-0.001, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id G95nFiXu+bQN + for ; + Tue, 11 Apr 2006 19:13:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 47A1311F7ACD + for ; + Tue, 11 Apr 2006 18:29:27 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3BLTN5V011016; + Tue, 11 Apr 2006 17:29:23 -0400 (EDT) +To: Dan Harris +cc: PostgreSQL Performance +Subject: Re: Encouraging multi-table join order +In-reply-to: <443C1DEC.4080307@drivefaster.net> +References: <443AAC26.4070802@drivefaster.net> <1543.1144710756@sss.pgh.pa.us> + <443AEF9B.3000909@drivefaster.net> <2406.1144717297@sss.pgh.pa.us> + <443C18AA.3000500@drivefaster.net> <10770.1144789733@sss.pgh.pa.us> + <443C1DEC.4080307@drivefaster.net> +Comments: In-reply-to Dan Harris + message dated "Tue, 11 Apr 2006 15:21:48 -0600" +Date: Tue, 11 Apr 2006 17:29:23 -0400 +Message-ID: <11015.1144790963@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/246 +X-Sequence-Number: 18330 + +Dan Harris writes: +> I wonder why the estimates were so far off the first time? This table +> has been ANALYZED regularly ever since creation. + +Probably just that you need a bigger sample size for such a large table. +We've been arguing ever since 7.2 about what the default statistics +target ought to be --- a lot of people think 10 is too small. (It could +also be that the fixed 300X multiplier ought to depend on table size +instead. The math that told us 300X was OK was really about getting the +histogram right, not about whether the most-common-values stats would be +any good.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 11 19:32:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 73C3111F6793 + for ; + Tue, 11 Apr 2006 19:32:50 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Ok8Rj6rmO7SN + for ; + Tue, 11 Apr 2006 19:32:09 -0300 (ADT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 1384E11F8B94 + for ; + Tue, 11 Apr 2006 18:56:32 -0300 (ADT) +Received: from host130.twnc.com (host130.twnc.com [216.16.237.130]) + by svr4.postgresql.org (Postfix) with ESMTP id 6579E5AF034 + for ; + Tue, 11 Apr 2006 21:56:32 +0000 (GMT) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Sequencial scan instead of using index +Date: Tue, 11 Apr 2006 17:56:38 -0400 +Message-ID: + <6AD4F3A63B017C4FB074E2C895AD18541090C6@EXCHSRV.waterloonetworking.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Sequencial scan instead of using index +Thread-Index: AcZBpJc/R3jGHRpQRdOIAr7fcOHyfAcC7j3w +From: "Harry Hehl" +To: "Mark Kirkwood" +Cc: +X-Archive-Number: 200604/249 +X-Sequence-Number: 18333 + +Mark,=20 + +>If you can upgrade to 8.1.(3), then the planner can consider paths that + +>use *both* the indexes on srcobj and dstobj (which would probably be +the=20 +>business!). + +Yes, 8.1.3 resolved this issue. Thanks. + +However I am still getting seq scans on indexes for other queries + +For example: + +select * from omfile where ( objectid in ( select distinct(ref_oid) from +ts ) );=20 +objectid & ref_oid are non-unique indexes=20 +omimagefile & omclipfile inherit from omfile + +------------------------------------------------------------------------ +-------- + + Nested Loop IN Join (cost=3D21432.32..951981.42 rows=3D204910 = +width=3D217) + Join Filter: ("outer".objectid =3D "inner".ref_oid) + -> Append (cost=3D0.00..8454.10 rows=3D204910 width=3D217) + -> Seq Scan on omfile (cost=3D0.00..8428.20 rows=3D204320 +width=3D217) + -> Seq Scan on omimagefile omfile (cost=3D0.00..12.70 = +rows=3D270 +width=3D217) + -> Seq Scan on omclipfile omfile (cost=3D0.00..13.20 = +rows=3D320 +width=3D217) + -> Materialize (cost=3D21432.32..21434.32 rows=3D200 width=3D16) + -> Unique (cost=3D20614.91..21430.12 rows=3D200 width=3D16) + -> Sort (cost=3D20614.91..21022.52 rows=3D163041 = +width=3D16) + Sort Key: ts.ref_oid + -> Seq Scan on ts (cost=3D0.00..3739.41 = +rows=3D163041 +width=3D16) + +(11 rows)=20 +Time: 164.232 ms=20 + +BTW set enable_seqscan=3Doff has no affect i.e still uses seq scans. + +If I do a simple query, it is very quick, no sequencial scans.=20 +So how can I get index scans to work consistently with joins? + +explain select * from omfile where +objectid=3D'65ef0be3-bf02-46b6-bae9-5bd015ffdb79';=20 + +------------------------------------------------------------------------ +-------- + + Result (cost=3D2.00..7723.30 rows=3D102903 width=3D217) + -> Append (cost=3D2.00..7723.30 rows=3D102903 width=3D217) + -> Bitmap Heap Scan on omfile (cost=3D2.00..7697.60 = +rows=3D102608 +width=3D217) + Recheck Cond: (objectid =3D +'65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) + -> Bitmap Index Scan on omfile_objectid_idx +(cost=3D0.00..2.00 rows=3D102608 width=3D0) + Index Cond: (objectid =3D +'65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) + -> Bitmap Heap Scan on omimagefile omfile (cost=3D1.00..12.69 +rows=3D135 width=3D217) + Recheck Cond: (objectid =3D +'65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) + -> Bitmap Index Scan on omimagefile_objectid_idx +(cost=3D0.00..1.00 rows=3D135 width=3D0) + Index Cond: (objectid =3D +'65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) + -> Bitmap Heap Scan on omclipfile omfile (cost=3D1.00..13.00 +rows=3D160 width=3D217) + Recheck Cond: (objectid =3D +'65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) + -> Bitmap Index Scan on omclipfile_objectid_idx +(cost=3D0.00..1.00 rows=3D160 width=3D0) + Index Cond: (objectid =3D +'65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) + +(14 rows)=20 +Time: 5.164 + + + +-----Original Message----- +From: Mark Kirkwood [mailto:markir@paradise.net.nz]=20 +Sent: Tuesday, March 07, 2006 12:04 AM +To: Harry Hehl +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Sequencial scan instead of using index + +Harry Hehl wrote: +> There seems to be many posts on this issue but I not yet found an +answer to the seq scan issue. +>=20 +> I am having an issue with a joins. I am using 8.0.3 on FC4 +>=20 +> Query: select * from ommemberrelation where srcobj=3D'somevalue' and=20 +> dstobj in (select objectid from omfilesysentry where=20 +> name=3D'dir15_file80'); +>=20 +> Columns srcobj, dstobj & name are all indexed. +>=20 +>=20 + +The planner is over-estimating the number of rows here (33989 vs 100): + +-> Seq Scan on ommemberrelation (cost=3D0.00..2394.72 rows=3D33989 +width=3D177) (actual time=3D0.078..70.887 rows=3D100 loops=3D1) + +The usual way to attack this is to up the sample size for ANALYZE: + +ALTER TABLE ommemberrelation ALTER COLUMN srcobj SET STATISTICS 100; +ALTER TABLE ommemberrelation ALTER COLUMN dstobj SET STATISTICS 100; +-- or even 1000. +ANALYZE ommemberrelation; + +Then try EXPLAIN ANALYZE again. + + +If you can upgrade to 8.1.(3), then the planner can consider paths that=20 +use *both* the indexes on srcobj and dstobj (which would probably be the + +business!). + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Tue Apr 11 19:29:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BA39211F8773 + for ; + Tue, 11 Apr 2006 19:29:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.55 +X-Spam-Level: +X-Spam-Status: No, score=0.55 required=5 tests=[NO_REAL_NAME=0.55] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37mwwHytcpVO + for ; + Tue, 11 Apr 2006 19:28:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz + [203.96.152.182]) + by postgresql.org (Postfix) with ESMTP id 89D9C11F7171 + for ; + Tue, 11 Apr 2006 19:17:55 -0300 (ADT) +Received: from ux421.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-3.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IXK00IG0WLU00@linda-3.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 12 Apr 2006 10:17:54 +1200 (NZST) +Received: by ux421.paradise.net.nz (Postfix, from userid 30) id 79DE2CAF; Wed, + 12 Apr 2006 10:17:54 +1200 (NZST) +Date: Wed, 12 Apr 2006 10:17:54 +1200 (NZST) +From: markir@paradise.net.nz +Subject: Re: Sequencial scan instead of using index +In-reply-to: + <6AD4F3A63B017C4FB074E2C895AD18541090C6@EXCHSRV.waterloonetworking.net> +X-Originating-IP: 67.103.45.218 +To: Harry Hehl +Cc: Mark Kirkwood , + "pgsql-performance@postgresql.org" +Message-id: <1144793874.443c2b1272c80@www.paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1 +Content-transfer-encoding: 8bit +User-Agent: IMP/PHP IMAP webmail program 2.2.7 +References: + <6AD4F3A63B017C4FB074E2C895AD18541090C6@EXCHSRV.waterloonetworking.net> +X-Archive-Number: 200604/247 +X-Sequence-Number: 18331 + +Quoting Harry Hehl : + +> Mark, +> +> (snippage)However I am still getting seq scans on indexes for other queries +> +> For example: +> +> select * from omfile where ( objectid in ( select distinct(ref_oid) +> from +> ts ) ); +> objectid & ref_oid are non-unique indexes +> omimagefile & omclipfile inherit from omfile +> +> -------------------------------------------------------------- +> ---------- +> -------- +> +> Nested Loop IN Join (cost=21432.32..951981.42 rows=204910 width=217) +> Join Filter: ("outer".objectid = "inner".ref_oid) +> -> Append (cost=0.00..8454.10 rows=204910 width=217) +> -> Seq Scan on omfile (cost=0.00..8428.20 rows=204320 +> width=217) +> -> Seq Scan on omimagefile omfile (cost=0.00..12.70 rows=270 +> width=217) +> -> Seq Scan on omclipfile omfile (cost=0.00..13.20 rows=320 +> width=217) +> -> Materialize (cost=21432.32..21434.32 rows=200 width=16) +> -> Unique (cost=20614.91..21430.12 rows=200 width=16) +> -> Sort (cost=20614.91..21022.52 rows=163041 width=16) +> Sort Key: ts.ref_oid +> -> Seq Scan on ts (cost=0.00..3739.41 rows=163041 +> width=16) +> +> (11 rows) +> Time: 164.232 ms +> +> BTW set enable_seqscan=off has no affect i.e still uses seq scans. +> +> If I do a simple query, it is very quick, no sequencial scans. +> So how can I get index scans to work consistently with joins? +> +> explain select * from omfile where +> objectid='65ef0be3-bf02-46b6-bae9-5bd015ffdb79'; +> +> -------------------------------------------------------------------- +> ---- +> -------- +> +> Result (cost=2.00..7723.30 rows=102903 width=217) +> -> Append (cost=2.00..7723.30 rows=102903 width=217) +> -> Bitmap Heap Scan on omfile (cost=2.00..7697.60 rows=102608 +> width=217) +> Recheck Cond: (objectid = +> '65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) +> -> Bitmap Index Scan on omfile_objectid_idx +> (cost=0.00..2.00 rows=102608 width=0) +> Index Cond: (objectid = +> '65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) +> -> Bitmap Heap Scan on omimagefile omfile (cost=1.00..12.69 +> rows=135 width=217) +> Recheck Cond: (objectid = +> '65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) +> -> Bitmap Index Scan on omimagefile_objectid_idx +> (cost=0.00..1.00 rows=135 width=0) +> Index Cond: (objectid = +> '65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) +> -> Bitmap Heap Scan on omclipfile omfile (cost=1.00..13.00 +> rows=160 width=217) +> Recheck Cond: (objectid = +> '65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) +> -> Bitmap Index Scan on omclipfile_objectid_idx +> (cost=0.00..1.00 rows=160 width=0) +> Index Cond: (objectid = +> '65ef0be3-bf02-46b6-bae9-5bd015ffdb79'::capsa_sys.uuid) +> +> (14 rows) +> Time: 5.164 +> +> + +Hmm - that first query needs to do a sort, so you might want to experiment with +the sort_mem parameter. Could you show us output from explain analyze for both +the above queries? + +At face value, selecting 200000 rows (assuming the estimates are accurate) may +mean that a seqscan is the best plan! But we'll know more after seeing the +explain analyze... + +Cheers + + +Mark + +From pgsql-performance-owner@postgresql.org Tue Apr 11 19:30:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 788C911F66B7 + for ; + Tue, 11 Apr 2006 19:30:06 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.55 +X-Spam-Level: +X-Spam-Status: No, score=0.55 required=5 tests=[NO_REAL_NAME=0.55] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id y1dPfnE3dnbX + for ; + Tue, 11 Apr 2006 19:29:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz + [203.96.152.184]) + by postgresql.org (Postfix) with ESMTP id CA9ED11F6387 + for ; + Tue, 11 Apr 2006 19:20:57 -0300 (ADT) +Received: from ux421.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-5.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IXK00KSXWQVR2@linda-5.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 12 Apr 2006 10:20:56 +1200 (NZST) +Received: by ux421.paradise.net.nz (Postfix, from userid 30) id A2C0BCAF; Wed, + 12 Apr 2006 10:20:55 +1200 (NZST) +Date: Wed, 12 Apr 2006 10:20:55 +1200 (NZST) +From: markir@paradise.net.nz +Subject: Re: Sequencial scan instead of using index +In-reply-to: <1144793874.443c2b1272c80@www.paradise.net.nz> +X-Originating-IP: 67.103.45.218 +To: "markir@paradise.net.nz" +Cc: Harry Hehl , + Mark Kirkwood , + "pgsql-performance@postgresql.org" +Message-id: <1144794055.443c2bc79c75b@www.paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1 +Content-transfer-encoding: 8bit +User-Agent: IMP/PHP IMAP webmail program 2.2.7 +References: + <6AD4F3A63B017C4FB074E2C895AD18541090C6@EXCHSRV.waterloonetworking.net> + <1144793874.443c2b1272c80@www.paradise.net.nz> +X-Archive-Number: 200604/248 +X-Sequence-Number: 18332 + +Quoting "markir@paradise.net.nz" : + + +> Hmm - that first query needs to do a sort, so you might want to +> experiment with +> the sort_mem parameter + +Oops - I mean work_mem... + +From pgsql-performance-owner@postgresql.org Tue Apr 11 19:50:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7780B11F6247 + for ; + Tue, 11 Apr 2006 19:50:07 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.125 +X-Spam-Level: +X-Spam-Status: No, score=0.125 required=5 tests=[AWL=0.125] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 2Vh1U-ghBMTz + for ; + Tue, 11 Apr 2006 19:49:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 54E0111F61DE + for ; + Tue, 11 Apr 2006 19:50:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3BMnxGo011755; + Tue, 11 Apr 2006 18:49:59 -0400 (EDT) +To: "Harry Hehl" +cc: "Mark Kirkwood" , pgsql-performance@postgresql.org +Subject: Re: Sequencial scan instead of using index +In-reply-to: + <6AD4F3A63B017C4FB074E2C895AD18541090C6@EXCHSRV.waterloonetworking.net> +References: + <6AD4F3A63B017C4FB074E2C895AD18541090C6@EXCHSRV.waterloonetworking.net> +Comments: In-reply-to "Harry Hehl" + message dated "Tue, 11 Apr 2006 17:56:38 -0400" +Date: Tue, 11 Apr 2006 18:49:59 -0400 +Message-ID: <11754.1144795799@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/250 +X-Sequence-Number: 18334 + +"Harry Hehl" writes: +> Nested Loop IN Join (cost=21432.32..951981.42 rows=204910 width=217) +> Join Filter: ("outer".objectid = "inner".ref_oid) +> -> Append (cost=0.00..8454.10 rows=204910 width=217) +> -> Seq Scan on omfile (cost=0.00..8428.20 rows=204320 +> width=217) +> -> Seq Scan on omimagefile omfile (cost=0.00..12.70 rows=270 +> width=217) +> -> Seq Scan on omclipfile omfile (cost=0.00..13.20 rows=320 +> width=217) +> -> Materialize (cost=21432.32..21434.32 rows=200 width=16) +> -> Unique (cost=20614.91..21430.12 rows=200 width=16) +> -> Sort (cost=20614.91..21022.52 rows=163041 width=16) +> Sort Key: ts.ref_oid +> -> Seq Scan on ts (cost=0.00..3739.41 rows=163041 +> width=16) + +> (11 rows) +> Time: 164.232 ms + +> So how can I get index scans to work consistently with joins? + +It's not the join that's the problem, it's the inheritance. I recently +improved the planner so that it can consider appended indexscans for an +inheritance tree on the inside of a join, but no pre-8.2 release can do +it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 11 19:55:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2475111F6405 + for ; + Tue, 11 Apr 2006 19:55:26 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.538 +X-Spam-Level: +X-Spam-Status: No, score=0.538 required=5 tests=[AWL=0.538] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id vf9E7qQ-BJPj + for ; + Tue, 11 Apr 2006 19:55:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id EA9AE11F6294 + for ; + Tue, 11 Apr 2006 19:55:16 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 4C0F556431; Tue, 11 Apr 2006 17:55:16 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 11 Apr 2006 17:55:16 -0500 +Date: Tue, 11 Apr 2006 17:55:16 -0500 +From: "Jim C. Nasby" +To: C Storm +Cc: pgsql-performance@postgresql.org +Subject: Re: pgmemcache +Message-ID: <20060411225515.GZ49405@pervasive.com> +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060411:christian.storm@gmail.com::0zNAS9ktQ/2wqBnO:000000000000 + 0000000000000000000000001FMW +X-Hashcash: + 1:20:060411:pgsql-performance@postgresql.org::c6MbKHDuRbZJIJqh:00000 + 00000000000000000000000019JG +X-Archive-Number: 200604/251 +X-Sequence-Number: 18335 + +On Tue, Apr 04, 2006 at 12:24:42AM -0700, C Storm wrote: +> I was wondering if anyone on the list has a successful installation of +> pgmemcache running +> that uses LISTEN/NOTIFY to signal a successfully completed transaction, +> i.e., to get around the fact +> that TRIGGERS are transaction unaware. Or perhaps any other +> information regarding a successful +> deployment of pgmemcache. + +The problem with attempting that is that you'd have a window between +transaction commit and when the cache was invalidated. If that's +acceptable then it shouldn't be too difficult to set something up using +LISTEN/NOTIFY like you describe. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 11 19:59:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 1169F11F644E + for ; + Tue, 11 Apr 2006 19:59:23 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id BDB6gk9bb1t1 + for ; + Tue, 11 Apr 2006 19:59:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 9184211F6285 + for ; + Tue, 11 Apr 2006 19:59:15 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 974E656427; Tue, 11 Apr 2006 17:59:15 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 11 Apr 2006 17:59:14 -0500 +Date: Tue, 11 Apr 2006 17:59:14 -0500 +From: "Jim C. Nasby" +To: Vivek Khera +Cc: Postgresql Performance +Subject: Re: freebsd/softupdates for data dir +Message-ID: <20060411225914.GA49405@pervasive.com> +References: <4431C4B4.4090300@123.com.sv> <4431D591.30500@paradise.net.nz> + + + <34268F66-1525-422E-8DEC-C1AA45C5853B@khera.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <34268F66-1525-422E-8DEC-C1AA45C5853B@khera.org> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060411:vivek@khera.org::94IOep1sog//6iwb:007R+D +X-Hashcash: + 1:20:060411:pgsql-performance@postgresql.org::tYNKmJ2CopaiqVZl:00000 + 0000000000000000000000005/Fr +X-Archive-Number: 200604/252 +X-Sequence-Number: 18336 + +On Thu, Apr 06, 2006 at 09:45:34AM -0400, Vivek Khera wrote: +> +> On Apr 5, 2006, at 6:07 PM, Jim Nasby wrote: +> +> > +> >More importantly, it allows the system to come up and do fsck in +> >the background. If you've got a large database that's a pretty big +> >benefit. +> +> That's a UFS2 feature, not a soft-updates feature. + +It's both. You can't background fsck with softupdates disabled. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 11 20:06:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A2BC411F61DE + for ; + Tue, 11 Apr 2006 20:06:29 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.166 +X-Spam-Level: * +X-Spam-Status: No, score=1.166 required=5 tests=[AWL=-0.166, + RCVD_IN_BL_SPAMCOP_NET=1.332] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id f4GScmnu2Rdc + for ; + Tue, 11 Apr 2006 20:06:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [151.155.5.143]) + by postgresql.org (Postfix) with ESMTP id 208B311F653D + for ; + Tue, 11 Apr 2006 20:06:20 -0300 (ADT) +Received: from [172.16.1.180] grzm [61.197.227.146] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 1.6 $ on + Linux; Tue, 11 Apr 2006 17:06:19 -0600 +In-Reply-To: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> +Mime-Version: 1.0 (Apple Message framework v749.3) +X-Priority: 3 +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> +Cc: +Content-Transfer-Encoding: 7bit +From: Michael Glaesemann +Subject: Re: FOREIGN KEYS vs PERFORMANCE +Date: Wed, 12 Apr 2006 08:06:17 +0900 +To: "Rodrigo Sakai" +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/253 +X-Sequence-Number: 18337 + + +On Apr 12, 2006, at 4:13 , Rodrigo Sakai wrote: + +> I think this is an old question, but I want to know if it really +> is well worth to not create some foreign keys an deal with the +> referential integrity at application-level????? + +If I had to choose between one or the other, I'd leave all +referential integrity in the database and deal with the errors thrown +when referential integrity is violated in the application. PostgreSQL +is designed to handle these kinds of issues. Anything you code in +your application is more likely to contain bugs or miss corner cases +that would allow referential integrity to be violated. PostgreSQL has +been pounded on for years by a great many users and developers, +making the likelihood of bugs still remaining much smaller. + +Of course, you can add some referential integrity checks in your +application code, but those should be in addition to your database- +level checks. + +Michael Glaesemann +grzm myrealbox com + + + + +From pgsql-performance-owner@postgresql.org Tue Apr 11 20:38:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 78B4511F6611 + for ; + Tue, 11 Apr 2006 20:38:39 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.51 +X-Spam-Level: +X-Spam-Status: No, score=0.51 required=5 tests=[AWL=0.510] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 5Hei4ifxS7I6 + for ; + Tue, 11 Apr 2006 20:38:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 5826D11F65B3 + for ; + Tue, 11 Apr 2006 20:38:36 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 28B9856427; Tue, 11 Apr 2006 18:38:21 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 11 Apr 2006 18:38:20 -0500 +Date: Tue, 11 Apr 2006 18:38:20 -0500 +From: "Jim C. Nasby" +To: Michael Glaesemann +Cc: Rodrigo Sakai , + pgsql-performance@postgresql.org +Subject: Re: FOREIGN KEYS vs PERFORMANCE +Message-ID: <20060411233820.GB49405@pervasive.com> +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060411:grzm@myrealbox.com::kT7TVqH3MCb6vd9F:0000000000000000000 + 0000000000000000000000004VoI +X-Hashcash: + 1:20:060411:rodrigo.sakai@zanthus.com.br::f3yGTUM6VWMmP62H:000000000 + 000000000000000000000000095p +X-Hashcash: + 1:20:060411:pgsql-performance@postgresql.org::i1Kji4pFt7Puz1l1:00000 + 0000000000000000000000004Y6c +X-Archive-Number: 200604/254 +X-Sequence-Number: 18338 + +On Wed, Apr 12, 2006 at 08:06:17AM +0900, Michael Glaesemann wrote: +> +> On Apr 12, 2006, at 4:13 , Rodrigo Sakai wrote: +> +> > I think this is an old question, but I want to know if it really +> >is well worth to not create some foreign keys an deal with the +> >referential integrity at application-level????? +> +> If I had to choose between one or the other, I'd leave all +> referential integrity in the database and deal with the errors thrown +> when referential integrity is violated in the application. PostgreSQL +> is designed to handle these kinds of issues. Anything you code in +> your application is more likely to contain bugs or miss corner cases +> that would allow referential integrity to be violated. PostgreSQL has +> been pounded on for years by a great many users and developers, +> making the likelihood of bugs still remaining much smaller. + +It's also pretty unlikely that you can make RI in the application +perform better than in the database. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 11 23:05:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9A0EF11F6AE3 + for ; + Tue, 11 Apr 2006 23:05:30 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.439 +X-Spam-Level: +X-Spam-Status: No, score=0.439 required=5 tests=[AWL=0.439] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id MhPoTfk8okIW + for ; + Tue, 11 Apr 2006 23:05:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id 1CC4811F6AE0 + for ; + Tue, 11 Apr 2006 23:05:24 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 4766025073; + Wed, 12 Apr 2006 10:05:24 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id EC0712506F; + Wed, 12 Apr 2006 10:05:20 +0800 (WST) +Message-ID: <443C60B9.3080705@calorieking.com> +Date: Wed, 12 Apr 2006 10:06:49 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Jesper Krogh +Cc: Vivek Khera , + Postgresql Performance +Subject: Re: Restore performance? +References: + <810F9DD5-22B1-4A6F-B76C-D7EA7B89035B@khera.org> + <38326.195.41.66.226.1144757097.squirrel@mail.jabbernet.dk> +In-Reply-To: <38326.195.41.66.226.1144757097.squirrel@mail.jabbernet.dk> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chris.kings-lynne@calorieking.com +X-Archive-Number: 200604/255 +X-Sequence-Number: 18339 + +>> Well, your pg_dump command lost your BLOBs since the plain text +>> format doesn't support them. +> +> Well, no.. they are stored as BYTEA not Large Objects.. They are encoded +> in ASCII in the pg_dump output. + +As a side note: plain text dump format in 8.1 supprts LOBs + + +From pgsql-performance-owner@postgresql.org Tue Apr 11 23:56:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 50ECD11F6AF1 + for ; + Tue, 11 Apr 2006 23:56:53 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -1.121 +X-Spam-Level: +X-Spam-Status: No, score=-1.121 required=5 tests=[AWL=1.480, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id wRZ6Y7kDtLnY + for ; + Tue, 11 Apr 2006 23:56:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 9C0D611F6AE3 + for ; + Tue, 11 Apr 2006 23:56:45 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3C2uhHY013088; + Tue, 11 Apr 2006 22:56:43 -0400 (EDT) +To: "Jim C. Nasby" +cc: Michael Glaesemann , + Rodrigo Sakai , + pgsql-performance@postgresql.org +Subject: Re: FOREIGN KEYS vs PERFORMANCE +In-reply-to: <20060411233820.GB49405@pervasive.com> +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + <20060411233820.GB49405@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Tue, 11 Apr 2006 18:38:20 -0500" +Date: Tue, 11 Apr 2006 22:56:43 -0400 +Message-ID: <13087.1144810603@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/256 +X-Sequence-Number: 18340 + +"Jim C. Nasby" writes: +> On Wed, Apr 12, 2006 at 08:06:17AM +0900, Michael Glaesemann wrote: +>> ... Anything you code in +>> your application is more likely to contain bugs or miss corner cases +>> that would allow referential integrity to be violated. PostgreSQL has +>> been pounded on for years by a great many users and developers, +>> making the likelihood of bugs still remaining much smaller. + +> It's also pretty unlikely that you can make RI in the application +> perform better than in the database. + +I think the traditional assumption among the "you should do RI in the +application" crowd is that the application has higher-level knowledge +that lets it understand when it can skip doing an RI check entirely. +Skipping an RI check is always faster than doing it --- so that's right, +it's faster. As long as you don't make any mistakes. + +The question you have to ask yourself is whether you are really that +smart ... not just today, but every single time. To quote Clint +Eastwood: "Do you feel lucky punk? Well, do you?" + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 12 04:18:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DF68211F6635 + for ; + Wed, 12 Apr 2006 04:18:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ftPgQOfxGU47 + for ; + Wed, 12 Apr 2006 04:18:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id AAF0611F65F1 + for ; + Wed, 12 Apr 2006 04:18:29 -0300 (ADT) +Received: (qmail 27750 invoked from network); 12 Apr 2006 09:19:21 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 12 Apr 2006 09:19:21 +0200 +Date: Wed, 12 Apr 2006 09:19:18 +0200 +To: "Jim C. Nasby" , + "C Storm" +Subject: Re: pgmemcache +Cc: pgsql-performance@postgresql.org +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <20060411225515.GZ49405@pervasive.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Archive-Number: 200604/257 +X-Sequence-Number: 18341 + + + It would be nice to have ON COMMIT triggers for this use. + + However you can emulate ON COMMIT triggers with a modification of the +memcache update process : + + - A standard trigger sends the data to update to memcache + - The trigger also sends the PID + - Instead of being used immediately, this data is kept in a buffer + - Notify is issued + + On commit : + - postgres sends the NOTIFY signal + - the memcache updater reads the NOTIFY (which embeds the PID I believe) +; it finds the buffered data sent above and uses it to update memcached + + On rollback : + - Interesting problem ;))) + + OK, it's a kludge. When can we get ON COMMIT triggers ? + + + + +> On Tue, Apr 04, 2006 at 12:24:42AM -0700, C Storm wrote: +>> I was wondering if anyone on the list has a successful installation of +>> pgmemcache running +>> that uses LISTEN/NOTIFY to signal a successfully completed transaction, +>> i.e., to get around the fact +>> that TRIGGERS are transaction unaware. Or perhaps any other +>> information regarding a successful +>> deployment of pgmemcache. +> +> The problem with attempting that is that you'd have a window between +> transaction commit and when the cache was invalidated. If that's +> acceptable then it shouldn't be too difficult to set something up using +> LISTEN/NOTIFY like you describe. + + + +From pgsql-performance-owner@postgresql.org Wed Apr 12 04:22:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 4ECC611F66F6 + for ; + Wed, 12 Apr 2006 04:22:09 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.464 +X-Spam-Level: +X-Spam-Status: No, score=-2.464 required=5 tests=[BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id cZUGfAlNt29W + for ; + Wed, 12 Apr 2006 04:22:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 295B811F65F1 + for ; + Wed, 12 Apr 2006 04:22:00 -0300 (ADT) +Received: (qmail 27787 invoked from network); 12 Apr 2006 09:22:54 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 12 Apr 2006 09:22:54 +0200 +To: "Michael Glaesemann" , + "Rodrigo Sakai" +Cc: pgsql-performance@postgresql.org +Subject: Re: FOREIGN KEYS vs PERFORMANCE +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> +Message-ID: +Date: Wed, 12 Apr 2006 09:22:52 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Archive-Number: 200604/258 +X-Sequence-Number: 18342 + + +>> I think this is an old question, but I want to know if it really is +>> well worth to not create some foreign keys an deal with the referential +>> integrity at application-level????? + + Trust me : do it in the application and you'll enter a world of hurt. I'm +doing it with some mysql apps, and it's a nightmare ; doing cascaded +delete's by hand, etc, you always forget something, you have to modify a +million places in your code everytime you add a new table, your ORM +bloats, you get to write cleanup cron scripts which take forever to run, +your website crashes etc. + + +From pgsql-performance-owner@postgresql.org Wed Apr 12 09:59:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B730F11F606B + for ; + Wed, 12 Apr 2006 09:59:23 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id eVKj5-ytTDbq + for ; + Wed, 12 Apr 2006 09:59:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 95E6E11F6004 + for ; + Wed, 12 Apr 2006 09:59:19 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T9c8e.t.pppool.de + [89.55.156.142]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 8EA67656C1; + Wed, 12 Apr 2006 15:00:12 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id C4134181C1E89; + Wed, 12 Apr 2006 14:59:32 +0200 (CEST) +Message-ID: <443CF9B4.2080009@logix-tt.com> +Date: Wed, 12 Apr 2006 14:59:32 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Oscar Picasso +Cc: pgsql-performance@postgresql.org +Subject: Re: Better index stategy for many fields with few values +References: <20060410165857.91471.qmail@web54705.mail.yahoo.com> +In-Reply-To: <20060410165857.91471.qmail@web54705.mail.yahoo.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/259 +X-Sequence-Number: 18343 + +Hi, Oscar, + +Oscar Picasso wrote: + +> [ all the 20 paramXX columns are used in the query} + +> How can I optimize this kind of query? + +PostgreSQL 8.1 has so-called bitmap index scans, which can combine +several index scans before actually accessing the data. + +So I think it's best to create an index on each of the paramXX columns, +and see with EXPLAIN ANALYZE what it is doing. + +> I was thinking about using a multicolumns index, but I have read that +> we should limit multicolumns indice to at most 2 or 3 columns. + +Yes, that's true, the index overhead gets too high. + +> If that's true then 22 columns for a multicolumn incdex seems way too +> much. Or maybe it is workable as every column uses only a very limited +> set of values? + +Yes, I think that a 22 column index is way too much, especially with the +new bitmap index scans available. + +> I was also thinking about about using a functional index. + +If there's a logical relation between those values that they can easily +combined, that may be a good alternative. + + +I just had another weird idea: + +As your paramXX values can have only 10 parameters, it also might be +feasible to use a bunch of 10 conditional indices, like: + +CREATE INDEX foo1 ON table (param1, param2 WHERE param0='1st value'; +CREATE INDEX foo2 ON table (param1, param2 WHERE param0='2nd value'; +CREATE INDEX foo3 ON table (param1, param2 WHERE param0='3rd value'; +[...] + +This way, you don't have the index bloat of a 3-column index, but 10 +2-column indices that cover 1/10th of the table each. + +For 22 columns, you'd need a bunch of seven such indices plus a +single-column one, or can use some 3+1 and some 2+1 column index. + +I'd like to see the query plans from explain analyze. + +Btw, I expect query planning time to get rather significant for so much +columns, so gequo tuning, tuning work_mem (for the bitmap scans) and +prepared statements will pay off. + +HTH, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Wed Apr 12 10:04:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id A6E7311F606F + for ; + Wed, 12 Apr 2006 10:04:22 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id IbLua+L79trX + for ; + Wed, 12 Apr 2006 10:04:21 -0300 (ADT) +X-Greylist: delayed 15:07:53.845396 by SQLgrey- +Received: from host130.twnc.com (host130.twnc.com [216.16.237.130]) + by postgresql.org (Postfix) with ESMTP id 3D24111F6065 + for ; + Wed, 12 Apr 2006 10:04:18 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Sequencial scan instead of using index +Date: Wed, 12 Apr 2006 09:04:28 -0400 +Message-ID: + <6AD4F3A63B017C4FB074E2C895AD18541090FB@EXCHSRV.waterloonetworking.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Sequencial scan instead of using index +Thread-Index: AcZdtcjCSg457M7ZQTKUtpH52i3YPgAeigoA +From: "Harry Hehl" +To: +Cc: +X-Archive-Number: 200604/260 +X-Sequence-Number: 18344 + +Thanks Mark,=20 + +>Hmm - that first query needs to do a sort, so you might want to +experiment with the sort_mem parameter. Could you show us output from +explain analyze for >both the above queries? + +Not too concerned about the sort, more about the query performance with +seq scan as the tables size increases. + +>At face value, selecting 200000 rows (assuming the estimates are +accurate) may mean that a seqscan is the best plan! But we'll know more +after seeing the >explain analyze... + +200000 rows is about right. =20 + +I saw Tom's response on the planner improvement in 8.2 but I was still +going to send the explain analyze output. +However I can't show you explain analyze. The postmaster goes to 99% cpu +and stays there. The explain analyze command hangs... + +It is starting to look like inheritance does help in modeling the data, +but for searches parallel flat tables that don't use inheritance is +required to get optimum query performance.=20 + +Has anyone else come to this conclusion? + +Thanks + + + + +From pgsql-performance-owner@postgresql.org Wed Apr 12 10:18:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D32EB11F6632 + for ; + Wed, 12 Apr 2006 10:18:45 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id VYuqahP37JqU + for ; + Wed, 12 Apr 2006 10:18:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 182AB11F6065 + for ; + Wed, 12 Apr 2006 10:18:43 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T9c8e.t.pppool.de + [89.55.156.142]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 51E51657E1; + Wed, 12 Apr 2006 15:19:37 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 0786C181C1E89; + Wed, 12 Apr 2006 15:18:56 +0200 (CEST) +Message-ID: <443CFE3F.5090304@logix-tt.com> +Date: Wed, 12 Apr 2006 15:18:55 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: Rodrigo Sakai +Subject: Re: FOREIGN KEYS vs PERFORMANCE +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> +In-Reply-To: <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/261 +X-Sequence-Number: 18345 + +Hi, Michael, +Hi, Rodrigo, + +Michael Glaesemann wrote: + +> If I had to choose between one or the other, I'd leave all referential +> integrity in the database and deal with the errors thrown when +> referential integrity is violated in the application. PostgreSQL is +> designed to handle these kinds of issues. Anything you code in your +> application is more likely to contain bugs or miss corner cases that +> would allow referential integrity to be violated. PostgreSQL has been +> pounded on for years by a great many users and developers, making the +> likelihood of bugs still remaining much smaller. + +I strictly agree with Michael here. + +> Of course, you can add some referential integrity checks in your +> application code, but those should be in addition to your database- +> level checks. + +Agree. It does make sense to have reference checks in the UI or +application level for the sake of better error handling, but the +database should be the mandatory judge. + +There's another advantage of database based checking: Should there ever +be the need of a different application working on the same database (e. +G. an "expert level UI", or some connector that connects / synchronizes +to another software, or a data import tool), database based constraints +cannot be broken opposed to application based ones. + +HTH, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Wed Apr 12 11:50:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 967B911F68DF + for ; + Wed, 12 Apr 2006 11:50:20 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id fc1rrMugyS0R + for ; + Wed, 12 Apr 2006 11:50:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-68-15-5-150.sd.sd.cox.net + [68.15.5.150]) by postgresql.org (Postfix) with ESMTP id 69C0311F606B + for ; + Wed, 12 Apr 2006 11:50:14 -0300 (ADT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k3CEsNQt025002; Wed, 12 Apr 2006 07:54:23 -0700 +Message-ID: <443D127D.2070601@modgraph-usa.com> +Date: Wed, 12 Apr 2006 07:45:17 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PFC +CC: Michael Glaesemann , + Rodrigo Sakai , + pgsql-performance@postgresql.org +Subject: Re: FOREIGN KEYS vs PERFORMANCE +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + +In-Reply-To: +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/262 +X-Sequence-Number: 18346 + +>>> I think this is an old question, but I want to know if it really +>>> is well worth to not create some foreign keys an deal with the +>>> referential integrity at application-level????? +> +> +> Trust me : do it in the application and you'll enter a world of +> hurt. I'm doing it with some mysql apps, and it's a nightmare ; doing +> cascaded delete's by hand, etc, you always forget something, you have +> to modify a million places in your code everytime you add a new table, +> your ORM bloats, you get to write cleanup cron scripts which take +> forever to run, your website crashes etc. + +All good advice, but... there are no absolutes in this world. Application-enforced referential integrity makes sense if (and probably ONLY if): + +1. You have only one application that modifies the data. (Otherwise, you have to duplicate the rules across many applications, leading to a code-maintenance nightmare). + +2. If your application crashes and leaves a mess, it's not a catastrophe, and you have a good way to clean it up. For example, a bank shouldn't do this, but it might be OK for a computer-aided-design application, or the backend of a news web site. + +3. You have application-specific knowledge about when you can skip referential integrity and thereby greatly improve performance. For example, you may have batch operations where large numbers of rows are temporarily inconsistent. + +If your application doesn't meet ALL of these criteria, you probably should use the database for referential integrity. + +Craig + +From pgsql-performance-owner@postgresql.org Wed Apr 12 11:50:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5F2D511F692E + for ; + Wed, 12 Apr 2006 11:50:22 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id eOzoE2yvEbrG + for ; + Wed, 12 Apr 2006 11:50:14 -0300 (ADT) +X-Greylist: delayed 19:36:56.728041 by SQLgrey- +Received: from mail.zanthus.com.br (mail.zanthus.com.br [200.212.65.85]) + by postgresql.org (Postfix) with ESMTP id 80A2811F65C4 + for ; + Wed, 12 Apr 2006 11:50:17 -0300 (ADT) +Received: from cprsakai ([192.168.0.71]) + by mail.zanthus.com.br (8.13.4/8.13.4/Debian-3) with SMTP id + k3CEoxMA020904; Wed, 12 Apr 2006 11:50:59 -0300 +Message-ID: <000701c65e40$5a1ff700$4700a8c0@TREEZANTHUS> +Reply-To: "Rodrigo Sakai" +From: "Rodrigo Sakai" +To: "Markus Schaber" , +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + <443CFE3F.5090304@logix-tt.com> +Subject: Re: FOREIGN KEYS vs PERFORMANCE +Date: Wed, 12 Apr 2006 11:49:49 -0300 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +X-Zanthus-MailScanner: Found to be clean +X-Zanthus-MailScanner-From: rodrigo.sakai@zanthus.com.br +X-Archive-Number: 200604/263 +X-Sequence-Number: 18347 + + Thanks for all help!! But my problem is with performance, I agree with all +of you, the RI must be maintained by the database, because a bunch of +reasons that everyone knows! + But, I'm dealing with a very huge database that servers more than 200 +clientes at the same time, and because of it, each manipulation (delete, +insert, update, select) on the database have a poor performance. So, if we +deal with RI in each client station, we take this work off the database! + The application is an ERP developed with DELPHI + (postgresql or oracle or +sql server)!! + + Thanks again!! + +----- Original Message ----- +From: "Markus Schaber" +To: +Cc: "Rodrigo Sakai" +Sent: Wednesday, April 12, 2006 10:18 AM +Subject: Re: [PERFORM] FOREIGN KEYS vs PERFORMANCE + + +> Hi, Michael, +> Hi, Rodrigo, +> +> Michael Glaesemann wrote: +> +> > If I had to choose between one or the other, I'd leave all referential +> > integrity in the database and deal with the errors thrown when +> > referential integrity is violated in the application. PostgreSQL is +> > designed to handle these kinds of issues. Anything you code in your +> > application is more likely to contain bugs or miss corner cases that +> > would allow referential integrity to be violated. PostgreSQL has been +> > pounded on for years by a great many users and developers, making the +> > likelihood of bugs still remaining much smaller. +> +> I strictly agree with Michael here. +> +> > Of course, you can add some referential integrity checks in your +> > application code, but those should be in addition to your database- +> > level checks. +> +> Agree. It does make sense to have reference checks in the UI or +> application level for the sake of better error handling, but the +> database should be the mandatory judge. +> +> There's another advantage of database based checking: Should there ever +> be the need of a different application working on the same database (e. +> G. an "expert level UI", or some connector that connects / synchronizes +> to another software, or a data import tool), database based constraints +> cannot be broken opposed to application based ones. +> +> HTH, +> Markus +> -- +> Markus Schaber | Logical Tracking&Tracing International AG +> Dipl. Inf. | Software Development GIS +> +> Fight against software patents in EU! www.ffii.org +www.nosoftwarepatents.org +> + + +From pgsql-performance-owner@postgresql.org Wed Apr 12 12:03:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 25B6B11F663F + for ; + Wed, 12 Apr 2006 12:03:31 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.6 +X-Spam-Level: +X-Spam-Status: No, score=-2.6 required=5 tests=[BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 0FD-9p4I00ov + for ; + Wed, 12 Apr 2006 12:03:27 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.233]) + by postgresql.org (Postfix) with ESMTP id 4CE7B11F68DF + for ; + Wed, 12 Apr 2006 12:03:26 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 67so1180457wri + for ; + Wed, 12 Apr 2006 08:03:26 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=Qxq/zzjepkNTSXVOPXOkt2GEuNRR3hiZCW5X/4qVMogOK9BBMJTUlSrPyFVxTPPoWWNlsOIaNHE7J5siGTDur9oKpQifZYxX//xZPU0EDzuq6zQJgJxkUhFlZXlvF77OEwU6mnS4xlYadX/bPqih19Sxjw9RxAJIZMnM6D9iBXI= +Received: by 10.65.250.8 with SMTP id c8mr1117753qbs; + Wed, 12 Apr 2006 08:03:26 -0700 (PDT) +Received: by 10.65.137.8 with HTTP; Wed, 12 Apr 2006 08:03:26 -0700 (PDT) +Message-ID: +Date: Wed, 12 Apr 2006 11:03:26 -0400 +From: "Merlin Moncure" +To: "Rodrigo Sakai" +Subject: Re: FOREIGN KEYS vs PERFORMANCE +Cc: pgsql-performance@postgresql.org +In-Reply-To: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> +X-Archive-Number: 200604/264 +X-Sequence-Number: 18348 + +On 4/11/06, Rodrigo Sakai wrote: +> +> Hi, +> +> I think this is an old question, but I want to know if it really is wel= +l +> worth to not create some foreign keys an deal with the referential integr= +ity +> at application-level????? +> Specifically, the system we are developing is a server/cliente +> architecture that the server is the database and the fat client is an +> application developed in DELPHI!!! +> +> Thanks in advance!! + +Delphi IMO is the best RAD win32 IDE ever invented (especially when +paired the very excellent Zeos connection objects). However, for +purposes of data management ,imperative languages, Delphi included, +simply suck. Great form editor though. + +merlin + +From pgsql-performance-owner@postgresql.org Wed Apr 12 12:07:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id AC20811F6653 + for ; + Wed, 12 Apr 2006 12:07:04 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id pF5v6Q-40AzH + for ; + Wed, 12 Apr 2006 12:06:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [151.155.5.143]) + by postgresql.org (Postfix) with ESMTP id DDDD311F662E + for ; + Wed, 12 Apr 2006 12:06:54 -0300 (ADT) +Received: from [172.16.1.180] grzm [61.197.227.146] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 1.6 $ on + Linux; Wed, 12 Apr 2006 09:06:39 -0600 +In-Reply-To: <000701c65e40$5a1ff700$4700a8c0@TREEZANTHUS> +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + <443CFE3F.5090304@logix-tt.com> + <000701c65e40$5a1ff700$4700a8c0@TREEZANTHUS> +Mime-Version: 1.0 (Apple Message framework v749.3) +X-Priority: 3 +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <919DB481-053D-4C06-852C-44F19F381EA8@myrealbox.com> +Cc: "Markus Schaber" , +Content-Transfer-Encoding: 7bit +From: Michael Glaesemann +Subject: Re: FOREIGN KEYS vs PERFORMANCE +Date: Thu, 13 Apr 2006 00:06:27 +0900 +To: "Rodrigo Sakai" +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/265 +X-Sequence-Number: 18349 + + +On Apr 12, 2006, at 23:49 , Rodrigo Sakai wrote: + +> Thanks for all help!! But my problem is with performance, I agree +> with all +> of you, the RI must be maintained by the database, because a bunch of +> reasons that everyone knows! + +You've gotten a variety of good advice from a number of people. For +more specific advice (e.g., for your particular situation), it would +be very helpful if you could provide examples of queries that aren't +performing well for you (including table schema and explain analyze +output). + +Michael Glaesemann +grzm myrealbox com + + + + +From pgsql-performance-owner@postgresql.org Wed Apr 12 12:09:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id A2B3811F696C + for ; + Wed, 12 Apr 2006 12:08:57 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.414 +X-Spam-Level: +X-Spam-Status: No, score=-2.414 required=5 tests=[AWL=0.050, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 5A5fNm1QGbw2 + for ; + Wed, 12 Apr 2006 12:08:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 7267711F694F + for ; + Wed, 12 Apr 2006 12:08:46 -0300 (ADT) +Received: (qmail 30442 invoked from network); 12 Apr 2006 17:09:41 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 12 Apr 2006 17:09:41 +0200 +Date: Wed, 12 Apr 2006 17:09:37 +0200 +To: "Rodrigo Sakai" , + pgsql-performance@postgresql.org +Subject: Re: FOREIGN KEYS vs PERFORMANCE +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + <443CFE3F.5090304@logix-tt.com> + <000701c65e40$5a1ff700$4700a8c0@TREEZANTHUS> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <000701c65e40$5a1ff700$4700a8c0@TREEZANTHUS> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Archive-Number: 200604/266 +X-Sequence-Number: 18350 + + + What kinds of operations are made slow by foreign key checks ? Is it : + - Simple checks on INSERT ? + - Simple checks on UPDATE ? + - Cascaded deletes ? + - Cascaded updates ? + - Locks ? + - Something else ? + + Foreign keys are to ensure that the value in a column is always part of a +specific set (the referenced table). If this set changes very rarely, like +the list of countries in the world, or the list of states in a country, or +the various possible states an order can be in (received, processed, +shipped...) then it's alright to skip the check if you're sure your +application will insert a valid value. For some other situations, doing +the check in the application will need some queries and could be slower +(and certainly will be more complicated...) + + Are you sure you're not missing a few indexes, which would then force +fkey checks to use sequential scans ? + +> Thanks for all help!! But my problem is with performance, I agree with +> all +> of you, the RI must be maintained by the database, because a bunch of +> reasons that everyone knows! +> But, I'm dealing with a very huge database that servers more than 200 +> clientes at the same time, and because of it, each manipulation (delete, +> insert, update, select) on the database have a poor performance. So, if +> we +> deal with RI in each client station, we take this work off the database! +> The application is an ERP developed with DELPHI + (postgresql or +> oracle or +> sql server)!! + +From pgsql-performance-owner@postgresql.org Wed Apr 12 12:13:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C353D11F6933 + for ; + Wed, 12 Apr 2006 12:13:51 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.119 +X-Spam-Level: +X-Spam-Status: No, score=0.119 required=5 tests=[AWL=0.118, + UNPARSEABLE_RELAY=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ZNcBQTHvu1TG + for ; + Wed, 12 Apr 2006 12:13:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 2A8B111F6931 + for ; + Wed, 12 Apr 2006 12:13:47 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 12 Apr 2006 15:13:45 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 12 Apr 2006 10:13:45 -0500 +Subject: Re: FOREIGN KEYS vs PERFORMANCE +From: Scott Marlowe +To: Rodrigo Sakai +Cc: Markus Schaber , pgsql-performance@postgresql.org +In-Reply-To: <000701c65e40$5a1ff700$4700a8c0@TREEZANTHUS> +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + <443CFE3F.5090304@logix-tt.com> + <000701c65e40$5a1ff700$4700a8c0@TREEZANTHUS> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1144854825.23538.10.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 12 Apr 2006 10:13:45 -0500 +X-Archive-Number: 200604/267 +X-Sequence-Number: 18351 + +On Wed, 2006-04-12 at 09:49, Rodrigo Sakai wrote: +> Thanks for all help!! But my problem is with performance, I agree with all +> of you, the RI must be maintained by the database, because a bunch of +> reasons that everyone knows! +> But, I'm dealing with a very huge database that servers more than 200 +> clientes at the same time, and because of it, each manipulation (delete, +> insert, update, select) on the database have a poor performance. So, if we +> deal with RI in each client station, we take this work off the database! +> The application is an ERP developed with DELPHI + (postgresql or oracle or +> sql server)!! + +These are separate issues. + +One is performance of PostgreSQL handling FK->PK relationships. +PostgreSQL, in my experience, is quite fast at this. However, there are +ways you can set up FK->PK relationships that are non-optimal and will +result in poor performance. FK->PK relationships are generally fastest +when they are 1-1 and based on integer types. If there's a type +mismatch, or you use slower types, like large text fields, or numerics, +you may have poor performance. Give us a sample of your schema where +you're having problems, let us help you troubleshoot your performance. + +High parallel load is another issue. No matter where you put your +FK->PK relationship handling, having 200+ users connected at the same +time and manipulating your database is a heavy load. + +Handling FK->PK relationships in software often is vulnerable to race +conditions. Like so: (T1 and T2 are different "threads) + +T1: select id from mastertable where id=99; -- check for row +T2: delete from mastertable where id=99; -- delete a row +T1: insert into slavetable values (....); -- whoops! No master + +If we change the T1 to select for update, we now have the overhead that +most FK->PK relationships have. + +What version of PostgreSQL are you running. Older versions had much +poorer performance than newer versions when updating FK->PK +relationships. + +Don't assume that application level FK->PK relationships will be faster +AND as good as the ones at database level. It's quite possible that +they're faster for you because you're cutting corners, referentially +speaking, and your data will wind up incoherent over time. + +Also, you may be dealing with a database that is IO bound, and moving +the FK checks to software is only a short stop gap, and as the machine +hits the IO performance ceiling, you'll have the same problem again, +need a bigger machine, and have incoherent data. I.e. the same problem, +plus a few more, and have spent a lot of time spinning your wheels going +a short distance. + +From pgsql-performance-owner@postgresql.org Wed Apr 12 12:36:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id D336911F676B + for ; + Wed, 12 Apr 2006 12:36:31 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -1.22 +X-Spam-Level: +X-Spam-Status: No, score=-1.22 required=5 tests=[AWL=1.379, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id FOrtFIfLFRhi + for ; + Wed, 12 Apr 2006 12:36:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 7DDA111F6676 + for ; + Wed, 12 Apr 2006 12:36:23 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 4696056435; Wed, 12 Apr 2006 10:36:22 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 12 Apr 2006 10:36:20 -0500 +Date: Wed, 12 Apr 2006 10:36:20 -0500 +From: "Jim C. Nasby" +To: PFC +Cc: Michael Glaesemann , + Rodrigo Sakai , + pgsql-performance@postgresql.org +Subject: Re: FOREIGN KEYS vs PERFORMANCE +Message-ID: <20060412153619.GG49405@pervasive.com> +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060412:lists@peufeu.com::UfzQdRcOfRR5UwCm:00lpX +X-Hashcash: + 1:20:060412:grzm@myrealbox.com::bKjnMnlhosp3v+ui:0000000000000000000 + 0000000000000000000000008iEJ +X-Hashcash: + 1:20:060412:rodrigo.sakai@zanthus.com.br::JYZ9iVIXU6dh0Y3O:000000000 + 0000000000000000000000000HDV +X-Hashcash: + 1:20:060412:pgsql-performance@postgresql.org::kDOK0DhruzYVvIn/:00000 + 0000000000000000000000008r37 +X-Archive-Number: 200604/268 +X-Sequence-Number: 18352 + +On Wed, Apr 12, 2006 at 09:22:52AM +0200, PFC wrote: +> +> >> I think this is an old question, but I want to know if it really is +> >>well worth to not create some foreign keys an deal with the referential +> >>integrity at application-level????? +> +> Trust me : do it in the application and you'll enter a world of +> hurt. I'm doing it with some mysql apps, and it's a nightmare ; doing +> cascaded delete's by hand, etc, you always forget something, you have to +> modify a million places in your code everytime you add a new table, your +> ORM bloats, you get to write cleanup cron scripts which take forever to +> run, your website crashes etc. + +Well, yeah, thats typical for MySQL sites, but what's that have to do +with RI? + +Sorry, couldn't resist. :P + +From pgsql-performance-owner@postgresql.org Wed Apr 12 12:40:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0290E11F690F + for ; + Wed, 12 Apr 2006 12:40:00 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.465 +X-Spam-Level: +X-Spam-Status: No, score=0.465 required=5 tests=[AWL=0.465] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 5wXDi0H1ep1s + for ; + Wed, 12 Apr 2006 12:39:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id C367211F676B + for ; + Wed, 12 Apr 2006 12:39:53 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 2AF9856423; Wed, 12 Apr 2006 10:39:53 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 12 Apr 2006 10:39:51 -0500 +Date: Wed, 12 Apr 2006 10:39:51 -0500 +From: "Jim C. Nasby" +To: "Craig A. James" +Cc: PFC , Michael Glaesemann , + Rodrigo Sakai , + pgsql-performance@postgresql.org +Subject: Re: FOREIGN KEYS vs PERFORMANCE +Message-ID: <20060412153951.GH49405@pervasive.com> +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + <443D127D.2070601@modgraph-usa.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <443D127D.2070601@modgraph-usa.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060412:cjames@modgraph-usa.com::FXe4og9mh9SGcaLc:00000000000000 + 0000000000000000000000003MOA +X-Hashcash: 1:20:060412:lists@peufeu.com::Gk+smuipOYLGVDqH:00LSx +X-Hashcash: + 1:20:060412:grzm@myrealbox.com::7Fe0suc+6Gu0NpiD:0000000000000000000 + 0000000000000000000000009RN8 +X-Hashcash: + 1:20:060412:rodrigo.sakai@zanthus.com.br::H5ESVplF9GBZiJrq:000000000 + 0000000000000000000000000Zb5 +X-Hashcash: + 1:20:060412:pgsql-performance@postgresql.org::RvW9rDbEiB2ZlTQW:00000 + 0000000000000000000000001kIq +X-Archive-Number: 200604/269 +X-Sequence-Number: 18353 + +On Wed, Apr 12, 2006 at 07:45:17AM -0700, Craig A. James wrote: +> All good advice, but... there are no absolutes in this world. +> Application-enforced referential integrity makes sense if (and probably +> ONLY if): +> +> 1. You have only one application that modifies the data. (Otherwise, you +> have to duplicate the rules across many applications, leading to a +> code-maintenance nightmare). + +You forgot something: + +1a: You know that there will never, ever, ever, ever, be any other +application that wants to talk to the database. + +I know tons of people that get burned because they go with something +that's "good enough for now", and then regret that decision for years to +come. + +> 2. If your application crashes and leaves a mess, it's not a catastrophe, +> and you have a good way to clean it up. For example, a bank shouldn't do +> this, but it might be OK for a computer-aided-design application, or the +> backend of a news web site. +> +> 3. You have application-specific knowledge about when you can skip +> referential integrity and thereby greatly improve performance. For +> example, you may have batch operations where large numbers of rows are +> temporarily inconsistent. +> +> If your application doesn't meet ALL of these criteria, you probably should +> use the database for referential integrity. +> +> Craig +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 12 14:45:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id E36F011F6B2E + for ; + Wed, 12 Apr 2006 14:45:39 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.364 +X-Spam-Level: +X-Spam-Status: No, score=-2.364 required=5 tests=[AWL=0.100, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id x20Jh2zgikSP + for ; + Wed, 12 Apr 2006 14:45:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-68-15-5-150.sd.sd.cox.net + [68.15.5.150]) by postgresql.org (Postfix) with ESMTP id 9492511F6B06 + for ; + Wed, 12 Apr 2006 14:45:35 -0300 (ADT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k3CHjZO3028658; Wed, 12 Apr 2006 10:45:36 -0700 +Message-ID: <443D3A9C.40106@modgraph-usa.com> +Date: Wed, 12 Apr 2006 10:36:28 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Jim C. Nasby" +CC: PFC , Michael Glaesemann , + Rodrigo Sakai , + pgsql-performance@postgresql.org +Subject: Re: FOREIGN KEYS vs PERFORMANCE +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + <443D127D.2070601@modgraph-usa.com> + <20060412153951.GH49405@pervasive.com> +In-Reply-To: <20060412153951.GH49405@pervasive.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/270 +X-Sequence-Number: 18354 + +Jim C. Nasby wrote: +>>1. You have only one application that modifies the data. (Otherwise, you +>>have to duplicate the rules across many applications, leading to a +>>code-maintenance nightmare). +> +> You forgot something: +> +> 1a: You know that there will never, ever, ever, ever, be any other +> application that wants to talk to the database. +> +> I know tons of people that get burned because they go with something +> that's "good enough for now", and then regret that decision for years to +> come. + +No, I don't agree with this. Too many people waste time designing for "what if..." scenarios that never happen. You don't want to be dumb and design something that locks out a foreseeable and likely future need, but referential integrity doesn't meet this criterion. There's nothing to keep you from changing from app-managed to database-managed referential integrity if your needs change. + +Design for your current requirements. + + +Let us be of good cheer, remembering that the misfortunes hardest to bear are +those which never happen. - James Russell Lowell (1819-1891) + +Therefore do not be anxious about tomorrow, for tomorrow will be anxious for +itself. Let the day's own trouble be sufficient for the day. + - Matthew 6:34 + +Craig + +From pgsql-performance-owner@postgresql.org Wed Apr 12 16:56:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id E9E1E11F68E4 + for ; + Wed, 12 Apr 2006 16:56:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.526 +X-Spam-Level: +X-Spam-Status: No, score=-2.526 required=5 tests=[AWL=0.075, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id UCdRgkRnEwhY + for ; + Wed, 12 Apr 2006 16:56:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id D611511F663F + for ; + Wed, 12 Apr 2006 16:56:25 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k3CJuH717290; + Wed, 12 Apr 2006 15:56:17 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200604121956.k3CJuH717290@candle.pha.pa.us> +Subject: Re: bad performance on Solaris 10 +In-Reply-To: +To: Luke Lonergan +Date: Wed, 12 Apr 2006 15:56:17 -0400 (EDT) +CC: Alvaro Herrera , Chris Mair , + pgsql-performance@postgresql.org, markir@paradise.net.nz, + Josh Berkus +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Archive-Number: 200604/271 +X-Sequence-Number: 18355 + +Luke Lonergan wrote: +> Alvaro, +> +> On 4/5/06 2:48 PM, "Alvaro Herrera" wrote: +> +> > This essentially means stopping all bgwriter activity, thereby deferring +> > all I/O until checkpoint. Was this considered? With +> > checkpoint_segments to 128, it wouldn't surprise me that there wasn't +> > any checkpoint executed at all during the whole test ... +> +> Yes, many things about the Solaris UFS filesystem caused a great deal of +> pain over the 10 months of experiments we ran with Sun MDE. Ultimately, the +> conclusion was that ZFS is going to make all of the pain go away. +> +> In the meantime, all you can do is tweak up UFS and avoid I/O as much as +> possible. + +It is hard to imagine why people spend so much time modifying Sun +machines run with acceptable performance when non-Sun operating systems +work fine without such hurtles. + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Wed Apr 12 17:44:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F14DB11F6C38 + for ; + Wed, 12 Apr 2006 17:44:31 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.451 +X-Spam-Level: +X-Spam-Status: No, score=0.451 required=5 tests=[AWL=0.451] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id OrIsTx5osarI + for ; + Wed, 12 Apr 2006 17:44:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 8271111F6B55 + for ; + Wed, 12 Apr 2006 17:44:22 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 991E956427; Wed, 12 Apr 2006 15:44:22 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 12 Apr 2006 15:44:22 -0500 +Date: Wed, 12 Apr 2006 15:44:22 -0500 +From: "Jim C. Nasby" +To: Markus Schaber +Cc: Oscar Picasso , pgsql-performance@postgresql.org +Subject: Re: Better index stategy for many fields with few values +Message-ID: <20060412204421.GK49405@pervasive.com> +References: <20060410165857.91471.qmail@web54705.mail.yahoo.com> + <443CF9B4.2080009@logix-tt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <443CF9B4.2080009@logix-tt.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060412:schabi@logix-tt.com::a0oOP3skof/X3zxs:000000000000000000 + 0000000000000000000000001Ggt +X-Hashcash: + 1:20:060412:oscgoogle@yahoo.com::8IAmngb568b7I2c5:000000000000000000 + 0000000000000000000000001mJA +X-Hashcash: + 1:20:060412:pgsql-performance@postgresql.org::vdTeKlF9Jfsy8BCw:00000 + 0000000000000000000000000vrZ +X-Archive-Number: 200604/272 +X-Sequence-Number: 18356 + +On Wed, Apr 12, 2006 at 02:59:32PM +0200, Markus Schaber wrote: +> > I was thinking about using a multicolumns index, but I have read that +> > we should limit multicolumns indice to at most 2 or 3 columns. +> +> Yes, that's true, the index overhead gets too high. +> +> > I was also thinking about about using a functional index. +> +> If there's a logical relation between those values that they can easily +> combined, that may be a good alternative. + +How would that be any better than just doing a multi-column index? + +> I just had another weird idea: +> +> As your paramXX values can have only 10 parameters, it also might be +> feasible to use a bunch of 10 conditional indices, like: +> +> CREATE INDEX foo1 ON table (param1, param2 WHERE param0='1st value'; +> CREATE INDEX foo2 ON table (param1, param2 WHERE param0='2nd value'; +> CREATE INDEX foo3 ON table (param1, param2 WHERE param0='3rd value'; +> [...] + +Not all that weird; it's known as index partitioning. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 12 18:41:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 4307511F6961 + for ; + Wed, 12 Apr 2006 18:41:44 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -1.979 +X-Spam-Level: +X-Spam-Status: No, score=-1.979 required=5 tests=[AWL=0.620, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id dg+VSxU9pd1v + for ; + Wed, 12 Apr 2006 18:41:38 -0300 (ADT) +X-Greylist: delayed 00:08:17.643449 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 4A41411F6CA9 + for ; + Wed, 12 Apr 2006 18:41:07 -0300 (ADT) +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by svr4.postgresql.org (Postfix) with ESMTP id 515EE5AFAE6 + for ; + Wed, 12 Apr 2006 20:59:47 +0000 (GMT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id E803456423; Wed, 12 Apr 2006 15:59:15 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 12 Apr 2006 15:59:14 -0500 +Date: Wed, 12 Apr 2006 15:59:14 -0500 +From: "Jim C. Nasby" +To: "Craig A. James" +Cc: PFC , Michael Glaesemann , + Rodrigo Sakai , + pgsql-performance@postgresql.org +Subject: Re: FOREIGN KEYS vs PERFORMANCE +Message-ID: <20060412205914.GL49405@pervasive.com> +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + <443D127D.2070601@modgraph-usa.com> + <20060412153951.GH49405@pervasive.com> + <443D3A9C.40106@modgraph-usa.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <443D3A9C.40106@modgraph-usa.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060412:cjames@modgraph-usa.com::wHRpKp5zY8YN2b1P:00000000000000 + 0000000000000000000000003e73 +X-Hashcash: 1:20:060412:lists@peufeu.com::uiCM1cEdXzNsqRh5:03kzH +X-Hashcash: + 1:20:060412:grzm@myrealbox.com::KAAmCwKHblTHzLAv:0000000000000000000 + 0000000000000000000000005WMj +X-Hashcash: + 1:20:060412:rodrigo.sakai@zanthus.com.br::iLKS8GsqHQiZ7148:000000000 + 00000000000000000000000009JJ +X-Hashcash: + 1:20:060412:pgsql-performance@postgresql.org::/o80PIzmCzh+E7/Z:00000 + 0000000000000000000000003YqF +X-Archive-Number: 200604/273 +X-Sequence-Number: 18357 + +On Wed, Apr 12, 2006 at 10:36:28AM -0700, Craig A. James wrote: +> Jim C. Nasby wrote: +> >>1. You have only one application that modifies the data. (Otherwise, you +> >>have to duplicate the rules across many applications, leading to a +> >>code-maintenance nightmare). +> > +> >You forgot something: +> > +> >1a: You know that there will never, ever, ever, ever, be any other +> >application that wants to talk to the database. +> > +> >I know tons of people that get burned because they go with something +> >that's "good enough for now", and then regret that decision for years to +> >come. +> +> No, I don't agree with this. Too many people waste time designing for +> "what if..." scenarios that never happen. You don't want to be dumb and +> design something that locks out a foreseeable and likely future need, but +> referential integrity doesn't meet this criterion. There's nothing to keep +> you from changing from app-managed to database-managed referential +> integrity if your needs change. + +In this case your argument makes no sense, because you will spend far +more time re-creating RI capability inside an application than if you +just use what the database offers natively. + +It's certainly true that you don't want to over-engineer for no reason, +but many times choices are made to save a very small amount of time or +hassle up-front, and those choices become extremely painful later. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 12 19:35:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 814EA11F6009 + for ; + Wed, 12 Apr 2006 19:35:53 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.964 +X-Spam-Level: +X-Spam-Status: No, score=-0.964 required=5 tests=[BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, RCVD_NUMERIC_HELO=1.5] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id AkF+uCsHa8Kd + for ; + Wed, 12 Apr 2006 19:35:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id 9B3A811F610C + for ; + Wed, 12 Apr 2006 19:35:45 -0300 (ADT) +Received: from 172.16.1.25 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Wed, 12 Apr 2006 18:35:36 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01HOST03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 12 Apr + 2006 18:35:36 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 12 Apr + 2006 22:35:35 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 12 Apr 2006 15:35:33 -0700 +Subject: Re: bad performance on Solaris 10 +From: "Luke Lonergan" +To: "Bruce Momjian" +cc: "Alvaro Herrera" , + "Chris Mair" , pgsql-performance@postgresql.org, + markir@paradise.net.nz, "Josh Berkus" +Message-ID: +Thread-Topic: [PERFORM] bad performance on Solaris 10 +Thread-Index: AcZeazgLm1+9NlluTleUAj9c7eo9ogAFjDXb +In-Reply-To: <200604121956.k3CJuH717290@candle.pha.pa.us> +MIME-Version: 1.0 +X-OriginalArrivalTime: 12 Apr 2006 22:35:36.0175 (UTC) + FILETIME=[6AC55FF0:01C65E81] +X-WSS-ID: 68235F322XS44564762-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/274 +X-Sequence-Number: 18358 + +Bruce, + +On 4/12/06 12:56 PM, "Bruce Momjian" wrote: + +> It is hard to imagine why people spend so much time modifying Sun +> machines run with acceptable performance when non-Sun operating systems +> work fine without such hurtles. + +There are a lot of Solaris customers that we support and that we'd like to +support. To many of them, Solaris has many advantages other than speed, +though they expect a reasonably comparable performance, perhaps within a +factor of 2 of other options. + +Oracle has spent a great deal of time (a decade!) optimizing their software +for Solaris, and it shows. There are also some typical strategies that +Solaris people used to use to make Solaris perform better, like using VxFS +(Veritas Filesystem), or Oracle Raw IO to make their systems perform better. + +Lately I find people are not so receptive to VxFS, and Sun is promoting ZFS, +and we don't have a reasonable near term option for Raw IO in Postgres, so +we need to work to find a reasonable path for Solaris users IMO. The long +delays in ZFS production haven't helped us there, as the problems with UFS +are severe. + +We at Greenplum have worked hard over the last year to find options for +Postgres on Solaris and have the best configuration setup that we think is +possible now on UFS, and our customers benefit from that. However, Linux on +XFS or even ext3 is definitely the performance leader. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Apr 12 19:38:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 377D511F610C + for ; + Wed, 12 Apr 2006 19:38:54 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.964 +X-Spam-Level: +X-Spam-Status: No, score=-0.964 required=5 tests=[BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, RCVD_NUMERIC_HELO=1.5] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id pfZEur853ZbQ + for ; + Wed, 12 Apr 2006 19:38:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id 0F5DC11F605B + for ; + Wed, 12 Apr 2006 19:38:46 -0300 (ADT) +Received: from 172.16.1.148 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Wed, 12 Apr 2006 18:38:17 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by + D01HOST02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 12 Apr + 2006 18:38:16 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 12 Apr + 2006 22:38:16 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 12 Apr 2006 15:38:14 -0700 +Subject: Re: Better index stategy for many fields with few +From: "Luke Lonergan" +To: "Oscar Picasso" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Better index stategy for many fields with few + values +Thread-Index: AcZcwF1L2EOfzjN4Rtua5KXP6AcjRQBwWuOd +In-Reply-To: <20060410165857.91471.qmail@web54705.mail.yahoo.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 12 Apr 2006 22:38:16.0964 (UTC) + FILETIME=[CA9BD440:01C65E81] +X-WSS-ID: 68235ED30NK6238558-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/275 +X-Sequence-Number: 18359 + +Oscar, + +On 4/10/06 9:58 AM, "Oscar Picasso" wrote: + +> - My items table: +> code int -- can take one of 100 values +> property varchar(250) -- can take one of 5000 values +> param01 char(10) -- can take one of 10 values +> param02 char(10) -- can take one of 10 values +> ... +> [ 20 similar columns } +> ... +> parama20 char(10) -- can take one of 10 values +> +> - The kind of query I want to optimize: +> select * from items +> where code betwwen 5 and 22 +> and param01 = 'P' +> and param02 = 'G' +> ... +> [ all the 20 paramXX columns are used in the query} +> ... +> and param20 = 'C'; + +Bizgres 0.9 has an on-disk bitmap index which will likely improve this query +speed by a very large amount over normal Postgres 8.1. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Wed Apr 12 19:50:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AC23F11F670D + for ; + Wed, 12 Apr 2006 19:50:41 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.06 +X-Spam-Level: +X-Spam-Status: No, score=0.06 required=5 tests=[AWL=0.060] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id qNEt7usa4Nt9 + for ; + Wed, 12 Apr 2006 19:50:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id C7A8C11F6714 + for ; + Wed, 12 Apr 2006 19:50:38 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO [192.168.1.27]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9253911 for pgsql-performance@postgresql.org; + Wed, 12 Apr 2006 15:53:41 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +Subject: Re: bad performance on Solaris 10 +Date: Wed, 12 Apr 2006 15:49:14 -0700 +User-Agent: KMail/1.8 +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 +To: Undisclosed.Recipients: ; +Message-Id: <200604121549.14328.josh@agliodbs.com> +X-Archive-Number: 200604/276 +X-Sequence-Number: 18360 + +People, + +> Lately I find people are not so receptive to VxFS, and Sun is promoting +> ZFS, and we don't have a reasonable near term option for Raw IO in +> Postgres, so we need to work to find a reasonable path for Solaris users +> IMO. =A0The long delays in ZFS production haven't helped us there, as the +> problems with UFS are severe. + +=46WIW, I'm testing on ZFS now. But it's not stable yet. People are welco= +me=20 +to join the Solaris 11 beta program. + +In the near term, there are fixes to be made both in PostgreSQL=20 +configuration and in Solaris configuration. Also, some of the work being=20 +done for 8.2 ... the external sort work done by Simon and sponsored by=20 +GreenPlum, and the internal sort work which Jonah and others are doing ...= +=20 +will improve things on Solaris as our sort issues hit Solaris harder than=20 +other OSes. + +Expect lots more info on performance config for Solaris from me & Robert in= +=20 +the next few weeks.=20 + +=2D-=20 +=2D-Josh + +Josh Berkus +PostgreSQL @ Sun +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Apr 12 20:05:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 94C5711F6753 + for ; + Wed, 12 Apr 2006 20:05:17 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.425 +X-Spam-Level: +X-Spam-Status: No, score=-2.425 required=5 tests=[AWL=0.174, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id Ktn8TwpmUBsx + for ; + Wed, 12 Apr 2006 20:05:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id E432011F607B + for ; + Wed, 12 Apr 2006 20:05:08 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO [192.168.1.27]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9253969; Wed, 12 Apr 2006 16:08:10 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: pgmemcache +Date: Wed, 12 Apr 2006 16:03:43 -0700 +User-Agent: KMail/1.8 +Cc: PFC , "Jim C. Nasby" , + "C Storm" +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604121603.43986.josh@agliodbs.com> +X-Archive-Number: 200604/278 +X-Sequence-Number: 18362 + +PFC, + +> It would be nice to have ON COMMIT triggers for this use. +> +> However you can emulate ON COMMIT triggers with a modification of the +> memcache update process : + +Well, I'm back in touch with the GORDA project so possibly we can have +BEFORE COMMIT triggers after all. + +BTW, it's important to note that AFTER COMMIT triggers are logically +impossible, so please use BEFORE COMMIT so that it's clear what we're +talking about. + +-- +--Josh + +Josh Berkus +PostgreSQL @ Sun +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Apr 12 20:04:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9173411F674C + for ; + Wed, 12 Apr 2006 20:04:20 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.129 +X-Spam-Level: +X-Spam-Status: No, score=0.129 required=5 tests=[AWL=0.128, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id cFIz65GYqtRS + for ; + Wed, 12 Apr 2006 20:04:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ausimss.pervasive.com (ausimss.pervasive.com [66.45.103.246]) + by postgresql.org (Postfix) with ESMTP id AB16311F66FF + for ; + Wed, 12 Apr 2006 20:04:15 -0300 (ADT) +Received: from ausbayes2.aus.pervasive.com ([172.16.8.6]) by + ausimss.pervasive.com with InterScan Messaging Security Suite; + Wed, 12 Apr 2006 18:04:16 -0500 +Received: from AUSOWA.aus.pervasive.com ([172.16.4.8]) by + ausbayes2.aus.pervasive.com with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 12 Apr 2006 18:04:16 -0500 +Received: from ausmailid.aus.pervasive.com ([172.16.4.64]) by + AUSOWA.aus.pervasive.com with Microsoft SMTPSVC(6.0.3790.1830); + Wed, 12 Apr 2006 18:04:15 -0500 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C65E85.59766D41" +Subject: Re: Better index stategy for many fields with few values +Date: Wed, 12 Apr 2006 18:03:45 -0500 +Message-ID: + <4D27CB1096EF1C408F4BFAB0046EC7B6099EC4@ausmailid.aus.pervasive.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Better index stategy for many fields with few values +Thread-Index: AcZehGjK43fIQwifRjun3rereip+wQAAORaQ +From: "Jim Nasby" +To: "Oscar Picasso" +Cc: "Pgsql-Performance \(E-mail\)" +X-OriginalArrivalTime: 12 Apr 2006 23:04:15.0767 (UTC) + FILETIME=[6BBA4A70:01C65E85] +X-Archive-Number: 200604/277 +X-Sequence-Number: 18361 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C65E85.59766D41 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Adding -performance back in + +-----Original Message----- +From: Oscar Picasso [mailto:oscgoogle@yahoo.com] +Sent: Wednesday, April 12, 2006 5:51 PM +To: Jim Nasby +Subject: Re: [PERFORM] Better index stategy for many fields with few = +values + + +I would like to try it. + +However in an other post I added that contrary to what I stated = +initially all the paramXX columns are not mandatory in the query. So it = +seems that requirement make the problem more complexe. + +Doesn't this new requirement rule out this solution?=20 + +No, just group the columns logically. + + By the way I have test to index each column individually and check what = +happens in relation to bitscan map. My test table is 1 million rows. = +The explain analyze command shows that a bit scan is sometimes used but = +I still end up with queries that can take up to 10s which is way to = +much. + + +"Jim C. Nasby" wrote: + +On Wed, Apr 12, 2006 at 02:59:32PM +0200, Markus Schaber wrote: +> > I was thinking about using a multicolumns index, but I have read = +that +> > we should limit multicolumns indice to at most 2 or 3 columns. +>=20 +> Yes, that's true, the index overhead gets too high. +>=20 +> > I was also thinking about about using a functional index. +>=20 +> If there's a logical relation between those values that they can = +easily +> combined, that may be a good alternative. + +How would that be any better than just doing a multi-column index? + +> I just had another weird idea: +>=20 +> As your paramXX values can have only 10 parameters, it also might be +> feasible to use a bunch of 10 conditional indices, like: +>=20 +> CREATE INDEX foo1 ON table (param1, param2 WHERE param0=3D'1st value'; +> CREATE INDEX foo2 ON table (param1, param2 WHERE param0=3D'2nd value'; +> CREATE INDEX foo3 ON table (param1, param2 WHERE param0=3D'3rd value'; +> [...] + +Not all that weird; it's known as index partitioning. +--=20 +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +---------------------------(end of broadcast)--------------------------- +TIP 4: Have you searched our list archives? + +http://archives.postgresql.org + + + + + + _____ =20 + +Yahoo! = + Messenger with Voice. = +PC-to-Phone calls for ridiculously low rates. + + +------_=_NextPart_001_01C65E85.59766D41 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Adding=20 +-performance back in
+ +
-----Original Message-----
From: Oscar Picasso=20 + [mailto:oscgoogle@yahoo.com]
Sent: Wednesday, April 12, 2006 = +5:51=20 + PM
To: Jim Nasby
Subject: Re: [PERFORM] Better = +index=20 + stategy for many fields with few values

+
I would like to try it.

However in an other post I added = +that=20 + contrary to what I stated initially all the paramXX columns are not = +mandatory=20 + in the query. So it seems that requirement make the problem more=20 + complexe.

Doesn't this new requirement rule out this = +solution? 
+
No, just=20 +group the columns logically.
+ +
 By the way I have = +test to=20 + index each column individually and check what happens in relation to = +bitscan=20 + map. My test table  is 1 million  rows. The explain analyze = +command=20 + shows that a bit scan is sometimes used but I still end up with = +queries that=20 + can take up to 10s which is way to much.


"Jim C. = +Nasby"=20 + <jnasby@pervasive.com> wrote:
+
On=20 + Wed, Apr 12, 2006 at 02:59:32PM +0200, Markus Schaber wrote:
> = +> I=20 + was thinking about using a multicolumns index, but I have read = +that
>=20 + > we should limit multicolumns indice to at most 2 or 3 = +columns.
>=20 +
> Yes, that's true, the index overhead gets too high.
> = + +
> > I was also thinking about about using a functional=20 + index.
>
> If there's a logical relation between those = +values=20 + that they can easily
> combined, that may be a good=20 + alternative.

How would that be any better than just doing a=20 + multi-column index?

> I just had another weird = +idea:
>=20 +
> As your paramXX values can have only 10 parameters, it also = +might=20 + be
> feasible to use a bunch of 10 conditional indices, = +like:
>=20 +
> CREATE INDEX foo1 ON table (param1, param2 WHERE = +param0=3D'1st=20 + value';
> CREATE INDEX foo2 ON table (param1, param2 WHERE = +param0=3D'2nd=20 + value';
> CREATE INDEX foo3 ON table (param1, param2 WHERE = +param0=3D'3rd=20 + value';
> [...]

Not all that weird; it's known as index = + + partitioning.
--
Jim C. Nasby, Sr. Engineering Consultant=20 + jnasby@pervasive.com
Pervasive Software http://pervasive.com = +work:=20 + 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell:=20 + 512-569-9461

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

http://archives.postgresql.org

+

+


+ Yahoo!=20 + Messenger with Voice. PC-to-Phone calls for ridiculously low=20 +rates. + +------_=_NextPart_001_01C65E85.59766D41-- + +From pgsql-performance-owner@postgresql.org Wed Apr 12 21:10:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9E82A11F65DD + for ; + Wed, 12 Apr 2006 21:10:27 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.434 +X-Spam-Level: +X-Spam-Status: No, score=0.434 required=5 tests=[AWL=0.434] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id nViq28-jt9pL + for ; + Wed, 12 Apr 2006 21:10:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 81B9311F6069 + for ; + Wed, 12 Apr 2006 21:10:24 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 3A9E556435; Wed, 12 Apr 2006 19:10:26 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 12 Apr 2006 19:10:25 -0500 +Date: Wed, 12 Apr 2006 19:10:25 -0500 +From: "Jim C. Nasby" +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, PFC , + C Storm +Subject: Re: pgmemcache +Message-ID: <20060413001024.GP49405@pervasive.com> +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> + <200604121603.43986.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200604121603.43986.josh@agliodbs.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060413:josh@agliodbs.com::vVeUt/aWs9adZlc8:00000000000000000000 + 0000000000000000000000001lYE +X-Hashcash: + 1:20:060413:pgsql-performance@postgresql.org::kCf3vwcjBYzC82tg:00000 + 0000000000000000000000002LV9 +X-Hashcash: 1:20:060413:lists@peufeu.com::QtCpotrhVZMrBNPw:00x7r +X-Hashcash: + 1:20:060413:christian.storm@gmail.com::5ZLvkdjD3SkPM9Pq:000000000000 + 0000000000000000000000005t5a +X-Archive-Number: 200604/279 +X-Sequence-Number: 18363 + +On Wed, Apr 12, 2006 at 04:03:43PM -0700, Josh Berkus wrote: +> PFC, +> +> > It would be nice to have ON COMMIT triggers for this use. +> > +> > However you can emulate ON COMMIT triggers with a modification of the +> > memcache update process : +> +> Well, I'm back in touch with the GORDA project so possibly we can have +> BEFORE COMMIT triggers after all. +> +> BTW, it's important to note that AFTER COMMIT triggers are logically +> impossible, so please use BEFORE COMMIT so that it's clear what we're +> talking about. + +Why are AFTER COMMIT triggers impossible? ISTM they would be useful as a +means to indicate to some external process if a transaction succeeded or +not. And for some things you might only want to fire the trigger after +you knew that the transaction had committed. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 12 21:33:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 90A8311F66C2 + for ; + Wed, 12 Apr 2006 21:32:59 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.001 +X-Spam-Level: +X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id FTNUMwIQvXXu + for ; + Wed, 12 Apr 2006 21:32:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id 0736211F6AD7 + for ; + Wed, 12 Apr 2006 21:32:54 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Thu, 13 Apr 2006 00:32:53 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1144888373456; Wed, 12 Apr 2006 17:32:53 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Wed, 12 Apr 2006 17:32:53 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Wed, 12 Apr 2006 17:32:53 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1144888368209; Wed, 12 Apr 2006 17:32:48 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C65E91.CA17909E" +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: multi column query +Date: Wed, 12 Apr 2006 17:32:32 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF03EF488C@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: multi column query +Thread-Index: AcZekcEAs4myTbLzSTGTVVU00tlHEA== +From: "Sriram Dandapani" +To: +X-Archive-Number: 200604/280 +X-Sequence-Number: 18364 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C65E91.CA17909E +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Hi + +When I update a table that has 20 columns and the where clause includes +16 of the columns (this is a data warehousing type update on aggregate +fields), + +The bitmap scan is not used by the optimizer. The table is indexed on 3 +of the 20 fields. The update takes really long to finish (on a 6 million +row table) + +=20 + +Do I need to do some "magic" with configuration to turn on bitmap scans. + + +------_=_NextPart_001_01C65E91.CA17909E +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hi

+ +

When I update a table that has 20 columns and the = +where +clause includes 16 of the columns (this is a data warehousing type = +update on +aggregate fields),

+ +

The bitmap scan is not used by the optimizer. The = +table is +indexed on 3 of the 20 fields. The update takes really long to finish = +(on a 6 +million row table)

+ +

 

+ +

Do I need to do some “magic” with = +configuration +to turn on bitmap scans.

+ +
+ + + + + +------_=_NextPart_001_01C65E91.CA17909E-- + +From pgsql-performance-owner@postgresql.org Wed Apr 12 21:35:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 962A911F66C2 + for ; + Wed, 12 Apr 2006 21:35:20 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.241 +X-Spam-Level: +X-Spam-Status: No, score=-2.241 required=5 tests=[AWL=0.360, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 9in9ttjD0juL + for ; + Wed, 12 Apr 2006 21:35:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id B503E11F65FA + for ; + Wed, 12 Apr 2006 21:35:17 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3D0ZEj5006237; + Wed, 12 Apr 2006 20:35:14 -0400 (EDT) +To: "Jim C. Nasby" +cc: Josh Berkus , pgsql-performance@postgresql.org, + PFC , C Storm +Subject: Re: pgmemcache +In-reply-to: <20060413001024.GP49405@pervasive.com> +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> + <200604121603.43986.josh@agliodbs.com> + <20060413001024.GP49405@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Wed, 12 Apr 2006 19:10:25 -0500" +Date: Wed, 12 Apr 2006 20:35:14 -0400 +Message-ID: <6236.1144888514@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/281 +X-Sequence-Number: 18365 + +"Jim C. Nasby" writes: +> Why are AFTER COMMIT triggers impossible? + +What happens if such a trigger gets an error? You can't un-commit. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 12 22:11:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 2FF7111F6B15 + for ; + Wed, 12 Apr 2006 22:11:17 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -1.322 +X-Spam-Level: +X-Spam-Status: No, score=-1.322 required=5 tests=[BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_FAIL=1.142] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id h+WiSWo9Fs0Q + for ; + Wed, 12 Apr 2006 22:11:11 -0300 (ADT) +X-Greylist: delayed 00:32:05.748619 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 5CD0211F6B66 + for ; + Wed, 12 Apr 2006 22:11:04 -0300 (ADT) +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by svr4.postgresql.org (Postfix) with ESMTP id B977C5AF02D + for ; + Thu, 13 Apr 2006 00:39:01 +0000 (GMT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id EA532B825 + for ; + Wed, 12 Apr 2006 20:38:58 -0400 (EDT) +Received: from 35st-server.simplicato.com + (static-71-249-233-130.nycmny.east.verizon.net [71.249.233.130]) + by zoraida.natserv.net (Postfix) with ESMTP id AB88FB81D + for ; + Wed, 12 Apr 2006 20:38:58 -0400 (EDT) +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Pgsql performance +Subject: Inserts optimization? +Date: Wed, 12 Apr 2006 20:38:58 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/283 +X-Sequence-Number: 18367 + +Doing my first write heavy database. +What settings will help improve inserts? +Only a handfull of connections, but each doing up to 30 inserts/second. +Plan to have 2 to 3 clients which most of the time will not run at the +same time, but ocasionaly it's possible two of them may bump into each +other. + + +If anyone recalls a previous thread like this please suggest keywords to +search on. My search on this topic came back pretty empty. + +From pgsql-performance-owner@postgresql.org Wed Apr 12 21:43:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 858F411F6982 + for ; + Wed, 12 Apr 2006 21:43:46 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.196 +X-Spam-Level: +X-Spam-Status: No, score=-2.196 required=5 tests=[AWL=0.403, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id gqhan5Mrt9Ne + for ; + Wed, 12 Apr 2006 21:43:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 795AC11F60B1 + for ; + Wed, 12 Apr 2006 21:43:43 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 9230E56423; Wed, 12 Apr 2006 19:43:44 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 12 Apr 2006 19:43:42 -0500 +Date: Wed, 12 Apr 2006 19:43:41 -0500 +From: "Jim C. Nasby" +To: Sriram Dandapani +Cc: pgsql-performance@postgresql.org +Subject: Re: multi column query +Message-ID: <20060413004340.GQ49405@pervasive.com> +References: <6992E470F12A444BB787B5C937B9D4DF03EF488C@ca-mail1.cis.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF03EF488C@ca-mail1.cis.local> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060413:sdandapani@counterpane.com::eITQ4xOe/F/syoKd:00000000000 + 000000000000000000000000Fvxe +X-Hashcash: + 1:20:060413:pgsql-performance@postgresql.org::Y4mY13JSWcefcMgd:00000 + 0000000000000000000000002AfJ +X-Archive-Number: 200604/282 +X-Sequence-Number: 18366 + +On Wed, Apr 12, 2006 at 05:32:32PM -0700, Sriram Dandapani wrote: +> Hi +> +> When I update a table that has 20 columns and the where clause includes +> 16 of the columns (this is a data warehousing type update on aggregate +> fields), +> +> The bitmap scan is not used by the optimizer. The table is indexed on 3 +> of the 20 fields. The update takes really long to finish (on a 6 million +> row table) +> +> Do I need to do some "magic" with configuration to turn on bitmap scans. + +No. What's explain analyze of the query show? What's it doing now? +Seqscan? You might try set enable_seqscan=off and see what that does. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 12 22:19:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 76A0111F607D + for ; + Wed, 12 Apr 2006 22:19:25 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.6 +X-Spam-Level: +X-Spam-Status: No, score=-2.6 required=5 tests=[BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id OTf8RtWhtPcD + for ; + Wed, 12 Apr 2006 22:19:25 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.207]) + by postgresql.org (Postfix) with ESMTP id 4864C11F6B06 + for ; + Wed, 12 Apr 2006 22:19:21 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id m7so1573762nzf + for ; + Wed, 12 Apr 2006 18:19:22 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; + b=uBLYAo2WpOKvqRPpiLDq8VeJtcZucUldhH379c9n3raMYzzDtTeHEDGtpFYa7T/LZ1quW2XvnnUlifzAhW2SdywWkA4QBKMvd1vmdf23yC+m6QLJ+WHKU2khFUoTj87i8/wzcoHX9ZtTDx3OxtCOue5bAaMPQljn20C0cEzt86Y= +Received: by 10.36.36.6 with SMTP id j6mr1339631nzj; + Wed, 12 Apr 2006 18:19:21 -0700 (PDT) +Received: from ?10.1.1.24? ( [203.217.18.65]) + by mx.gmail.com with ESMTP id r9sm1182970nza.2006.04.12.18.19.20; + Wed, 12 Apr 2006 18:19:21 -0700 (PDT) +Message-ID: <443DA715.4060606@gmail.com> +Date: Thu, 13 Apr 2006 11:19:17 +1000 +From: Chris +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Francisco Reyes +CC: Pgsql performance +Subject: Re: Inserts optimization? +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/284 +X-Sequence-Number: 18368 + +Francisco Reyes wrote: +> Doing my first write heavy database. +> What settings will help improve inserts? +> Only a handfull of connections, but each doing up to 30 inserts/second. +> Plan to have 2 to 3 clients which most of the time will not run at the +> same time, but ocasionaly it's possible two of them may bump into each +> other. + +If you can, use copy instead: + +http://www.postgresql.org/docs/8.1/interactive/sql-copy.html + +MUCH quicker (and don't worry about using multiple clients). + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Wed Apr 12 22:26:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B378011F6B11 + for ; + Wed, 12 Apr 2006 22:26:48 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id WoXm0PND0vgg + for ; + Wed, 12 Apr 2006 22:26:43 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.234]) + by postgresql.org (Postfix) with ESMTP id A3AD811F6B0D + for ; + Wed, 12 Apr 2006 22:26:44 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 71so654318wra + for ; + Wed, 12 Apr 2006 18:26:46 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=Qttmh0T1qKkVYSL5Hw8NzM2fvBho9RvQSuLcvgiqFOHHzyYPMX7aplaRANUWMASeOkkgvO4Kbl6L51KIlAMJ5TJewt44nuNnW1ipjUbCPqrZRSzhj/KzHR0OsSAwdbXaTDiFp9Q7ZFfbFgNRLQZ/Ugv5b0H1nOTROllQMCpFQ5Q= +Received: by 10.54.103.7 with SMTP id a7mr82840wrc; + Wed, 12 Apr 2006 18:26:46 -0700 (PDT) +Received: by 10.54.157.2 with HTTP; Wed, 12 Apr 2006 18:26:10 -0700 (PDT) +Message-ID: <53b425b00604121826x213fe2fdmc793e22026469923@mail.gmail.com> +Date: Wed, 12 Apr 2006 18:26:10 -0700 +From: "patrick keshishian" +To: pgsql-performance@postgresql.org +Subject: pg 7.4.x - pg_restore impossibly slow +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Archive-Number: 200604/285 +X-Sequence-Number: 18369 + +Greetings, + +I have 395M pg_dump from a PostgreSQL 7.4.2 database. +This dump is from one of our customer's servers. There is +a web-based administration UI which has been reported to +be extremely slow and unusable. + +To see what's going on with their data I have grabbed a +copy of their nightly pg_dump output and attempting to +restore it on my development box, running PostgreSQL +7.4.12. + +My dev box is much slower hardware than the customer's +server. Even with that difference I expected to be able to +pg_restore the database within one day. But no. After +leaving pg_restore running for about 2 days, I ctrl-C'ed +out of it (see copy/paste below along with other info). + +I must say, that data was being restored, as I could do +select count(*) on tables which had their data restored and +I would get valid counts back. + +The database contains 34 tables. The pg_restore seems to +restore the first 13 tables pretty quickly, but they do not have +many records. The largest amongst them with ~ 17,000 rows. + +Then restore gets stuck on a table with 2,175,050 rows. +Following this table another table exists with 2,160,616 +rows. + +One thing worth mentioning is that the PostgreSQL package +that got deployed lacked compression, as in: + +$ pg_dump -Fc dbname > dbname.DUMP +pg_dump: [archiver] WARNING: requested compression not available in +this installation -- archive will be uncompressed + + +Any suggestions as to what may be the problem here? +I doubt that the minor version mis-match is what's causing +this problem. (I am try this test on another machine with the +same version of PostgreSQL installed on it, and right now, +it is stuck on the first of the two huge tables, and it has +already been going for more than 2 hrs). + +I'm open to any ideas and/or suggestions (within reason) :) + +Best regards, +--patrick + + +me@devbox:/tmp$ date +Mon Apr 10 15:13:19 PDT 2006 +me@devbox:/tmp$ pg_restore -ad dbname customer_db.DUMP ; date +^C +me@devbox:/tmp$ date +Wed Apr 12 10:40:19 PDT 2006 + +me@devbox:/tmp$ uname -a +Linux devbox 2.4.31 #6 Sun Jun 5 19:04:47 PDT 2005 i686 unknown +unknown GNU/Linux +me@devbox:/tmp$ cat /proc/cpuinfo +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 8 +model name : Pentium III (Coppermine) +stepping : 6 +cpu MHz : 731.477 +cache size : 256 KB +fdiv_bug : no +hlt_bug : no +f00f_bug : no +coma_bug : no +fpu : yes +fpu_exception : yes +cpuid level : 2 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge +mca cmov pat pse36 mmx fxsr sse +bogomips : 1461.45 + +me@devbox:/tmp/$ cat /proc/meminfo + total: used: free: shared: buffers: cached: +Mem: 527499264 523030528 4468736 0 10301440 384454656 +Swap: 1579204608 552960 1578651648 +MemTotal: 515136 kB +MemFree: 4364 kB +MemShared: 0 kB +Buffers: 10060 kB +Cached: 374984 kB +SwapCached: 460 kB +Active: 79004 kB +Inactive: 306560 kB +HighTotal: 0 kB +HighFree: 0 kB +LowTotal: 515136 kB +LowFree: 4364 kB +SwapTotal: 1542192 kB +SwapFree: 1541652 kB + + +postgresql.conf changes on devbox: +checkpoint_segments =3D 10 +log_pid =3D true +log_timestamp =3D true + +The checkpoint_segments was changed to 10 after +seeing many "HINT"s in PostgreSQL log file about it. +Doesn't seem to have affected pg_restore performance. + +From pgsql-performance-owner@postgresql.org Wed Apr 12 22:37:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5EFA911F66AC + for ; + Wed, 12 Apr 2006 22:37:31 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Swj9UAapqTsU + for ; + Wed, 12 Apr 2006 22:37:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-68-15-5-150.sd.sd.cox.net + [68.15.5.150]) by postgresql.org (Postfix) with ESMTP id D211D11F66B8 + for ; + Wed, 12 Apr 2006 22:37:28 -0300 (ADT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k3D1fow0014629; Wed, 12 Apr 2006 18:41:50 -0700 +Message-ID: <443DAA37.80902@modgraph-usa.com> +Date: Wed, 12 Apr 2006 18:32:39 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: FOREIGN KEYS vs PERFORMANCE +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + <443D127D.2070601@modgraph-usa.com> + <20060412153951.GH49405@pervasive.com> + <443D3A9C.40106@modgraph-usa.com> + <20060412205914.GL49405@pervasive.com> +In-Reply-To: <20060412205914.GL49405@pervasive.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/286 +X-Sequence-Number: 18370 + +Jim C. Nasby wrote: +>>No, I don't agree with this. Too many people waste time designing for +>>"what if..." scenarios that never happen. You don't want to be dumb and +>>design something that locks out a foreseeable and likely future need, but +>>referential integrity doesn't meet this criterion. There's nothing to keep +>>you from changing from app-managed to database-managed referential +>>integrity if your needs change. +> +> In this case your argument makes no sense, because you will spend far +> more time re-creating RI capability inside an application than if you +> just use what the database offers natively. + +But one of the specific conditions in my original response was, "You have application-specific knowledge about when you can skip referential integrity and thereby greatly improve performance." If you can't do that, I agree with you. + +Anyway, this discussion is probably going on too long, and I'm partly to blame. I think we all agree that in almost all situations, using the database to do referential integrity is the right choice, and that you should only violate this rule if you have a really, really good reason, and you've thought out the implications carefully, and you know you may have to pay a steep price later if your requirements change. + +Craig + +From pgsql-performance-owner@postgresql.org Wed Apr 12 22:53:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 510AC11F66DC + for ; + Wed, 12 Apr 2006 22:53:02 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.001 +X-Spam-Level: +X-Spam-Status: No, score=0.001 required=5 tests=[UNPARSEABLE_RELAY=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id jvAv4DEqgQie + for ; + Wed, 12 Apr 2006 22:52:56 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-2.sun.com (brmea-mail-2.Sun.COM [192.18.98.43]) + by postgresql.org (Postfix) with ESMTP id E286011F66C4 + for ; + Wed, 12 Apr 2006 22:52:53 -0300 (ADT) +Received: from fe-amer-05.sun.com ([192.18.108.179]) + by brmea-mail-2.sun.com (8.12.10/8.12.9) with ESMTP id k3D1qtmU017509 + for ; + Wed, 12 Apr 2006 19:52:55 -0600 (MDT) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IXN00L01079S400@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Wed, 12 Apr 2006 19:52:55 -0600 (MDT) +Received: from [129.150.33.52] by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + with ESMTPSA id <0IXN00DGW186OZR4@mail-amer.sun.com>; Wed, + 12 Apr 2006 19:52:55 -0600 (MDT) +Date: Wed, 12 Apr 2006 21:53:33 -0400 +From: "Jignesh K. Shah" +Subject: Re: bad performance on Solaris 10 +In-reply-to: <200604121956.k3CJuH717290@candle.pha.pa.us> +To: Bruce Momjian +Cc: Luke Lonergan , + Alvaro Herrera , + Chris Mair , pgsql-performance@postgresql.org, + markir@paradise.net.nz, Josh Berkus +Message-id: <443DAF1D.6090007@sun.com> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: <200604121956.k3CJuH717290@candle.pha.pa.us> +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Archive-Number: 200604/287 +X-Sequence-Number: 18371 + + +Bruce, + +Hard to answer that... People like me who know and love PostgreSQL and +Solaris finds this as an opportunity to make their favorite database +work best on their favorite operating system. + +Many times PostgreSQL has many things based on assumption that it will +run on Linux and it is left to Solaris to emulate that behavior.That +said there are ways to improve performance even on UFS on Solaris, it +just requires more tweaks. + +Hopefully this will lead to few Solaris friendly default values like +fsync/odatasync :-) + +Regards, +Jignesh + + +Bruce Momjian wrote: + +> +>It is hard to imagine why people spend so much time modifying Sun +>machines run with acceptable performance when non-Sun operating systems +>work fine without such hurtles. +> +> + +From pgsql-performance-owner@postgresql.org Wed Apr 12 23:55:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 90AE711F662E + for ; + Wed, 12 Apr 2006 23:55:56 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.113 +X-Spam-Level: +X-Spam-Status: No, score=0.113 required=5 tests=[AWL=0.113] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id TKV1beq2qrkI + for ; + Wed, 12 Apr 2006 23:55:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 7D23611F6627 + for ; + Wed, 12 Apr 2006 23:55:53 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k3D2tt219058; + Wed, 12 Apr 2006 22:55:55 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200604130255.k3D2tt219058@candle.pha.pa.us> +Subject: Re: Sun Fire T2000 and PostgreSQL 8.1.3 +In-Reply-To: <7583B3F1891CC0429FA4A44952AA539C66FA8B@wfm-exchprd2.wfm.pvt> +To: "Juan Casero (FL FLC)" +Date: Wed, 12 Apr 2006 22:55:55 -0400 (EDT) +CC: Josh Berkus , pgsql-performance@postgresql.org, + Luke Lonergan +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Archive-Number: 200604/288 +X-Sequence-Number: 18372 + + +I am thinking the most flexible solution would be to get a dual Operon +machine, and initially do both data loading and queries on the same +machine. When the load gets too high, buy a second machine and set it +up as a Slony slave and run your queries on that, and do the data loads +on the original machine as master. + +--------------------------------------------------------------------------- + +Juan Casero (FL FLC) wrote: +> Because I plan to develop a rather large (for us anyway) data warehouse +> with PostgreSQL. I am looking for the right hardware that can handle +> queries on a database that might grow to over a 100 gigabytes. Right +> now our decision support system based on postgresql 8.1.3 stores retail +> sales information for about 4 four years back *but* only as weekly +> summaries. I want to build the system so it can handle daily sales +> transactions also. You can imagine how many more records this will +> involve so I am looking for hardware that can give me the performance I +> need to make this project useable. In other words parsing and loading +> the daily transaction logs for our stores is likely to take huge amounts +> of effort. I need a machine that can complete the task in a reasonable +> amount of time. As people start to query the database to find sales +> related reports and information I need to make sure the queries will run +> reasonably fast for them. I have already hand optimized all of my +> queries on the current system. But currently I only have weekly sales +> summaries. Other divisions in our company have done a similar project +> using MS SQL Server on SMP hardware far outclassing the database server +> I currently use and they report heavy loads on the server with less than +> ideal query run times. I am sure I can do my part to optimize the +> queries once I start this project but there is only so much you can do. +> At some point you just need more powerful hardware. This is where I am +> at right now. Apart from that since I will only get this one chance to +> buy a new server for data processing I need to make sure that I buy +> something that can grow over time as our needs change. I don't want to +> buy a server only to find out later that it cannot meet our needs with +> future database projects. I have to balance a limited budget, room for +> future performance growth, and current system requirements. Trust me it +> isn't easy. +> +> +> Juan +> +> -----Original Message----- +> From: Josh Berkus [mailto:josh@agliodbs.com] +> Sent: Thursday, April 06, 2006 2:57 AM +> To: pgsql-performance@postgresql.org +> Cc: Juan Casero (FL FLC); Luke Lonergan +> Subject: Re: [PERFORM] Sun Fire T2000 and PostgreSQL 8.1.3 +> +> Juan, +> +> > Ok that is beginning to become clear to me. Now I need to determine +> > if this server is worth the investment for us. Maybe it is not a +> > speed daemon but to be honest the licensing costs of an SMP aware +> > RDBMS is outside our budget. +> +> You still haven't explained why you want multi-threaded queries. This +> is sounding like keeping up with the Joneses. +> +> -- +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 01:42:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0528B11F6671 + for ; + Thu, 13 Apr 2006 01:42:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.125 +X-Spam-Level: +X-Spam-Status: No, score=0.125 required=5 tests=[AWL=0.125] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id PY0qaUSM3Gc7 + for ; + Thu, 13 Apr 2006 01:42:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id D789611F6691 + for ; + Thu, 13 Apr 2006 01:42:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3D4gOJT009550; + Thu, 13 Apr 2006 00:42:24 -0400 (EDT) +To: Chris +cc: Francisco Reyes , + Pgsql performance +Subject: Re: Inserts optimization? +In-reply-to: <443DA715.4060606@gmail.com> +References: + <443DA715.4060606@gmail.com> +Comments: In-reply-to Chris + message dated "Thu, 13 Apr 2006 11:19:17 +1000" +Date: Thu, 13 Apr 2006 00:42:24 -0400 +Message-ID: <9549.1144903344@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/289 +X-Sequence-Number: 18373 + +Chris writes: +> Francisco Reyes wrote: +>> Doing my first write heavy database. +>> What settings will help improve inserts? +>> Only a handfull of connections, but each doing up to 30 inserts/second. + +> If you can, use copy instead: +> http://www.postgresql.org/docs/8.1/interactive/sql-copy.html + +Or at least try to do multiple inserts per transaction. + +Also, increasing checkpoint_segments and possibly wal_buffers helps a +lot for write-intensive loads. Try to get the WAL onto a separate disk +spindle if you can. (These things don't matter for SELECTs, but they +do matter for writes.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 13 01:46:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id A673B11F6654 + for ; + Thu, 13 Apr 2006 01:46:57 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.309 +X-Spam-Level: +X-Spam-Status: No, score=-2.309 required=5 tests=[AWL=0.292, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id mVVZJRx1Kbu7 + for ; + Thu, 13 Apr 2006 01:46:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 9E70711F65F5 + for ; + Thu, 13 Apr 2006 01:46:53 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3D4kpTC009586; + Thu, 13 Apr 2006 00:46:52 -0400 (EDT) +To: "patrick keshishian" +cc: pgsql-performance@postgresql.org +Subject: Re: pg 7.4.x - pg_restore impossibly slow +In-reply-to: <53b425b00604121826x213fe2fdmc793e22026469923@mail.gmail.com> +References: <53b425b00604121826x213fe2fdmc793e22026469923@mail.gmail.com> +Comments: In-reply-to "patrick keshishian" + message dated "Wed, 12 Apr 2006 18:26:10 -0700" +Date: Thu, 13 Apr 2006 00:46:51 -0400 +Message-ID: <9585.1144903611@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/290 +X-Sequence-Number: 18374 + +"patrick keshishian" writes: +> My dev box is much slower hardware than the customer's +> server. Even with that difference I expected to be able to +> pg_restore the database within one day. But no. + +Seems a bit odd. Can you narrow down more closely which step of the +restore is taking the time? (Try enabling log_statements.) + +One thought is that kicking up work_mem and vacuum_mem is likely to +help for some steps (esp. CREATE INDEX and foreign-key checking). +And be sure you've done the usual tuning for write-intensive activity, +such as bumping up checkpoint_segments. Turning off fsync wouldn't +be a bad idea either. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 13 01:52:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5349E11F624B + for ; + Thu, 13 Apr 2006 01:52:51 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.125 +X-Spam-Level: +X-Spam-Status: No, score=0.125 required=5 tests=[AWL=0.125] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id AIATK+jM3aJB + for ; + Thu, 13 Apr 2006 01:52:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 9AD9811F6085 + for ; + Thu, 13 Apr 2006 01:52:46 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3D4qUBE009623; + Thu, 13 Apr 2006 00:52:30 -0400 (EDT) +To: "Jignesh K. Shah" +cc: Bruce Momjian , + Luke Lonergan , + Alvaro Herrera , + Chris Mair , pgsql-performance@postgresql.org, + markir@paradise.net.nz, Josh Berkus +Subject: Re: bad performance on Solaris 10 +In-reply-to: <443DAF1D.6090007@sun.com> +References: <200604121956.k3CJuH717290@candle.pha.pa.us> + <443DAF1D.6090007@sun.com> +Comments: In-reply-to "Jignesh K. Shah" + message dated "Wed, 12 Apr 2006 21:53:33 -0400" +Date: Thu, 13 Apr 2006 00:52:30 -0400 +Message-ID: <9622.1144903950@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/291 +X-Sequence-Number: 18375 + +"Jignesh K. Shah" writes: +> Many times PostgreSQL has many things based on assumption that it will +> run on Linux and it is left to Solaris to emulate that behavior. + +Au contraire --- PG tries its best to be OS-agnostic. I've personally +resisted people trying to optimize it by putting in Linux-specific +behavior. The above sounds to me like making excuses for a poor OS. + +(And yes, I will equally much resist any requests to put in Solaris- +specific behavior...) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 13 05:39:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 1E83C11F655C + for ; + Thu, 13 Apr 2006 05:39:47 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.537 +X-Spam-Level: +X-Spam-Status: No, score=-2.537 required=5 tests=[AWL=0.064, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id slSAj0-k5OYi + for ; + Thu, 13 Apr 2006 05:39:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 4964A11F65C7 + for ; + Thu, 13 Apr 2006 05:39:38 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k3D8dZQ26118; + Thu, 13 Apr 2006 04:39:35 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200604130839.k3D8dZQ26118@candle.pha.pa.us> +Subject: Re: bad performance on Solaris 10 +In-Reply-To: <443DAF1D.6090007@sun.com> +To: "Jignesh K. Shah" +Date: Thu, 13 Apr 2006 04:39:35 -0400 (EDT) +CC: Luke Lonergan , + Alvaro Herrera , Chris Mair , + pgsql-performance@postgresql.org, markir@paradise.net.nz, + Josh Berkus +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Archive-Number: 200604/292 +X-Sequence-Number: 18376 + +Jignesh K. Shah wrote: +> +> Bruce, +> +> Hard to answer that... People like me who know and love PostgreSQL and +> Solaris finds this as an opportunity to make their favorite database +> work best on their favorite operating system. +> +> Many times PostgreSQL has many things based on assumption that it will +> run on Linux and it is left to Solaris to emulate that behavior.That +> said there are ways to improve performance even on UFS on Solaris, it +> just requires more tweaks. +> +> Hopefully this will lead to few Solaris friendly default values like +> fsync/odatasync :-) + +Yes, if someone wants to give us a clear answer on which wal_sync method +is best on all versions of Solaris, we can easily make that change. + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 06:33:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2F3E911F65DD + for ; + Thu, 13 Apr 2006 06:33:42 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.112 +X-Spam-Level: +X-Spam-Status: No, score=0.112 required=5 tests=[AWL=0.112] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ayY-sJO4g-GB + for ; + Thu, 13 Apr 2006 06:33:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 8545D11F65B3 + for ; + Thu, 13 Apr 2006 06:33:38 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T88a7.t.pppool.de + [89.55.136.167]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 61AE7656CB + for ; + Thu, 13 Apr 2006 11:34:32 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id CBBB0181C1DF1 + for ; + Thu, 13 Apr 2006 11:33:53 +0200 (CEST) +Message-ID: <443E1B01.5060804@logix-tt.com> +Date: Thu, 13 Apr 2006 11:33:53 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Better index stategy for many fields with few values +References: <20060410165857.91471.qmail@web54705.mail.yahoo.com> + <443CF9B4.2080009@logix-tt.com> + <20060412204421.GK49405@pervasive.com> +In-Reply-To: <20060412204421.GK49405@pervasive.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/293 +X-Sequence-Number: 18377 + +Hi, Jim, + +Jim C. Nasby wrote: + +>>>I was also thinking about about using a functional index. +>>If there's a logical relation between those values that they can easily +>>combined, that may be a good alternative. +> How would that be any better than just doing a multi-column index? + +10 different values per column, and 20 columns are 10^20 value combinations. + +Partitioning it for the first column gives 10^19 combinations which is +smaller than 2^64, and thus fits into a long value. + +And I just guess that a 10-partition functional index on a long value +could perform better than a multi-column index on 20 columns of +character(10), if only because it is approx. 1/25th in size. + +HTH, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Thu Apr 13 06:51:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DC72E11F6245 + for ; + Thu, 13 Apr 2006 06:51:12 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.105 +X-Spam-Level: +X-Spam-Status: No, score=0.105 required=5 tests=[AWL=0.105] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id KkTFIOu+Tpcf + for ; + Thu, 13 Apr 2006 06:51:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id BE44B11F65EE + for ; + Thu, 13 Apr 2006 06:51:06 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T88a7.t.pppool.de + [89.55.136.167]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 69DC3656CB; + Thu, 13 Apr 2006 11:52:01 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id AAD26181C1DF1; + Thu, 13 Apr 2006 11:51:22 +0200 (CEST) +Message-ID: <443E1F1A.2000106@logix-tt.com> +Date: Thu, 13 Apr 2006 11:51:22 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Pgsql-Performance (E-mail)" +Cc: Oscar Picasso +Subject: Re: Better index stategy for many fields with few values +References: + <4D27CB1096EF1C408F4BFAB0046EC7B6099EC4@ausmailid.aus.pervasive.com> +In-Reply-To: + <4D27CB1096EF1C408F4BFAB0046EC7B6099EC4@ausmailid.aus.pervasive.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/294 +X-Sequence-Number: 18378 + +Hi, Jim, + +Jim Nasby wrote: +> Adding -performance back in +> I would like to try it. +> +> However in an other post I added that contrary to what I stated +> initially all the paramXX columns are not mandatory in the query. So +> it seems that requirement make the problem more complexe. + +Okay, this rules out my functional index over 19 columns. + +> Doesn't this new requirement rule out this solution? +> +> No, just group the columns logically. + +Yes, that's the solution. + +If you have common groups of columns that appear and disappear +synchroneously, pack those together in an (possibly partitioned and/or +functional) index. + +Then rely on the query planner that the combines the appropriate indices +via index bitmap scan. + +> By the way I have test to index each column individually and check +> what happens in relation to bitscan map. My test table is 1 +> million rows. The explain analyze command shows that a bit scan is +> sometimes used but I still end up with queries that can take up to +> 10s which is way to much. + +Is it on the first query, or on repeated queries? + +It might be that you're I/O bound, and the backend has to fetch indices +and rows from Disk into RAM. + +I currently don't know whether the order of indices in a multi-index +bitmap scan is relevant, but I could imagine that it may be useful to +have the most selective index scanned first. + +And keep in mind that, assuming an equal distribution of your +parameters, every index bitmap hits 1/10th of the whole table on +average, so the selectivity generally is low. + +The selectivity of a partitioned 3-column index will be much better +(about 1/10000th of the whole table), and less index scans and bitmaps +have to be generated. + +A functional index may also make sense to CLUSTER the table to optimize +the locality of search results (and so reducing disk I/O). In case your +table has low write activity, but high read-only activity, the overhead +that comes with the additional index is neglible compared to the +performance improvement proper CLUSTERing can generate. + +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Mon Apr 17 09:10:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id E68C111F6B2F + for ; + Thu, 13 Apr 2006 07:25:52 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 2-T143hLMwEv + for ; + Thu, 13 Apr 2006 07:25:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id D46EF11F6B1E + for ; + Thu, 13 Apr 2006 07:25:43 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 78A9930CC7; Thu, 13 Apr 2006 12:25:43 +0200 (MET DST) +From: Cris Carampa +X-Newsgroups: pgsql.performance +Subject: index is not used if I include a function that returns current time + in my query +Date: Thu, 13 Apr 2006 12:25:02 +0200 +Organization: Hub.Org Networking Services +Lines: 74 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040114 +X-Accept-Language: it, en-us +To: pgsql-performance@postgresql.org +X-Archive-Number: 200604/354 +X-Sequence-Number: 18438 + +Hello, postgresql 7.4.8 on SuSE Linux here. + +I have a table called DMO with a column called ORA_RIF defined as=20 +"timestamp without time zone" ; + +I created an index on this table based on this column only. + +If I run a query against a text literal the index is used: + + > explain select * from dmo where ora_rif>'2006-01-01'; + QUERY PLAN +-------------------------------------------------------------------------= +---------------- + Index Scan using dmo_ndx02 on dmo (cost=3D0.00..1183.23 rows=3D736 wid= +th=3D156) + Index Cond: (ora_rif > '2006-01-01 00:00:00'::timestamp without time = + +zone) + +If I try to use a function that returns the current time instead, a=20 +sequential scan is always performed: + + > explain select * from dmo where ora_rif>localtimestamp; + QUERY PLAN +-------------------------------------------------------------------------= +----- + Seq Scan on dmo (cost=3D0.00..1008253.22 rows=3D2703928 width=3D156) + Filter: (ora_rif > ('now'::text)::timestamp(6) without time zone) + + > explain select * from dmo where ora_rif>localtimestamp::timestamp=20 +without time zone; + QUERY PLAN +-------------------------------------------------------------------------= +----- + Seq Scan on dmo (cost=3D0.00..1008253.22 rows=3D2703928 width=3D156) + Filter: (ora_rif > ('now'::text)::timestamp(6) without time zone) + +=2E.. etc. ... + +(tried with all datetime functions with and without cast) + +I even tried to write a function that explicitly returns a "timestamp=20 +without time zone" value: + +create or replace function f () returns timestamp without time zone +as ' +declare + x timestamp without time zone ; +begin + x :=3D ''2006-01-01 00:00:00''; + return x ; +end ; +' language plpgsql ; + +But the result is the same: + + > explain select * from dmo ora_rif>f(); + QUERY PLAN +-------------------------------------------------------------------------= +---- + Seq Scan on dmo (cost=3D0.00..987973.76 rows=3D2703928 width=3D156) + Filter: (ora_rif > f()) + +Any suggestion? + +Kind regards, + +--=20 +Cris Carampa (spamto:cris119@operamail.com) + +potevo chiedere come si chiama il vostro cane +il mio =E8 un po' di tempo che si chiama Libero + + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 09:34:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2215211F660B + for ; + Thu, 13 Apr 2006 09:34:28 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id l6-xhdRqgrZm + for ; + Thu, 13 Apr 2006 09:34:17 -0300 (ADT) +X-Greylist: delayed 00:28:43.068191 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 22C5C11F6613 + for ; + Thu, 13 Apr 2006 09:34:20 -0300 (ADT) +Received: from fon.nation-net.com (fon.nation-net.com [194.24.251.1]) + by svr4.postgresql.org (Postfix) with ESMTP id 69B855AF1B2 + for ; + Thu, 13 Apr 2006 12:05:36 +0000 (GMT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id F10D5136FBC + for ; + Thu, 13 Apr 2006 13:05:31 +0100 (BST) +Received: from [194.24.251.10] (bum.net [194.24.251.10]) + by fon.nation-net.com (Postfix) with ESMTP id E1C52136FBA + for ; + Thu, 13 Apr 2006 13:05:31 +0100 (BST) +Message-ID: <443E3DF5.4020207@laterooms.com> +Date: Thu, 13 Apr 2006 13:03:01 +0100 +From: Gavin Hamill +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Slow query - possible bug? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AV-Checked: ClamAV using ClamSMTP +X-Archive-Number: 200604/295 +X-Sequence-Number: 18379 + +laterooms=# explain analyze select allocation0_."ID" as y1_, +allocation0_."RoomID" as y2_, allocation0_."StatusID" as y4_, +allocation0_."Price" as y3_, allocation0_."Number" as y5_, +allocation0_."Date" as y6_ from "Allocation" allocation0_ where +(allocation0_."Date" between '2006-06-09 00:00:00.000000' and +'2006-06-09 00:00:00.000000')and(allocation0_."RoomID" in(4300591)); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using ix_date on "Allocation" allocation0_ (cost=0.00..4.77 +rows=1 width=34) (actual time=1411.325..1689.860 rows=1 loops=1) + Index Cond: (("Date" >= '2006-06-09'::date) AND ("Date" <= +'2006-06-09'::date)) + Filter: ("RoomID" = 4300591) + Total runtime: 1689.917 ms +(4 rows) + +Yep, the two dates are identical - yep I would change the client +software to do where "Date" = '2006-06-09 00:00:00.000000' if I could... + +However, it's clear to see why this simple query is taking so long - the +plan is selecting /all/ dates after 2006-06-09 and /all/ dates before +then, and only returning the union of the two - a large waste of effort, +surely? + +VACUUM ANALYZE hasn't improved matters... the schema for the table is + + "ID" int8 NOT NULL DEFAULT +nextval(('public."allocation_id_seq"'::text)::regclass), + "RoomID" int4, + "Price" numeric(10,2), + "StatusID" int4, + "Number" int4, + "Date" date, + +and there are indexes kept for 'RoomID' and 'Date' in this 4.3-million +row table. + +Is this a bug or a hidden feature in pg 8.1.3 ? :) + +Cheers, +Gavin. + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 09:46:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 86AA411F662C + for ; + Thu, 13 Apr 2006 09:46:10 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.6 +X-Spam-Level: +X-Spam-Status: No, score=-2.6 required=5 tests=[BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id JytaMaZbosCO + for ; + Thu, 13 Apr 2006 09:46:09 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.198]) + by postgresql.org (Postfix) with ESMTP id 999C311F6626 + for ; + Thu, 13 Apr 2006 09:46:05 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id m7so1664742nzf + for ; + Thu, 13 Apr 2006 05:46:06 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=bjMhtFf6SzQzwLBdLRDBo4AExUztJ90KnppQugPHM6fFVJMBMkXnXAI9OkJcjCfugwr55H4l4i9tw+m3hdGZlr2b8xB84Jt4Cy9BF2FCaEFL4ljA8CoCnGBvGwuN5s3G6T5M/zP5LDckjOKN80sEtvN+inmj6ofTqJMjmPlyxcQ= +Received: by 10.36.126.3 with SMTP id y3mr226945nzc; + Thu, 13 Apr 2006 05:46:06 -0700 (PDT) +Received: by 10.36.97.14 with HTTP; Thu, 13 Apr 2006 05:46:06 -0700 (PDT) +Message-ID: <3c1395330604130546g6b091f75x511955817fe65dcd@mail.gmail.com> +Date: Thu, 13 Apr 2006 22:46:06 +1000 +From: "chris smith" +To: "Gavin Hamill" +Subject: Re: Slow query - possible bug? +Cc: pgsql-performance@postgresql.org +In-Reply-To: <443E3DF5.4020207@laterooms.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <443E3DF5.4020207@laterooms.com> +X-Archive-Number: 200604/296 +X-Sequence-Number: 18380 + +On 4/13/06, Gavin Hamill wrote: +> laterooms=3D# explain analyze select allocation0_."ID" as y1_, +> allocation0_."RoomID" as y2_, allocation0_."StatusID" as y4_, +> allocation0_."Price" as y3_, allocation0_."Number" as y5_, +> allocation0_."Date" as y6_ from "Allocation" allocation0_ where +> (allocation0_."Date" between '2006-06-09 00:00:00.000000' and +> '2006-06-09 00:00:00.000000')and(allocation0_."RoomID" in(4300591)); +> QUERY PLA= +N +> -------------------------------------------------------------------------= +----------------------------------------------------------------- +> Index Scan using ix_date on "Allocation" allocation0_ (cost=3D0.00..4.7= +7 +> rows=3D1 width=3D34) (actual time=3D1411.325..1689.860 rows=3D1 loops=3D1= +) +> Index Cond: (("Date" >=3D '2006-06-09'::date) AND ("Date" <=3D +> '2006-06-09'::date)) +> Filter: ("RoomID" =3D 4300591) +> Total runtime: 1689.917 ms +> (4 rows) + +1.6secs isn't too bad on 4.3mill rows... + +How many entries are there for that date range? + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Thu Apr 13 10:08:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 586F711F68E9 + for ; + Thu, 13 Apr 2006 10:08:18 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.174 +X-Spam-Level: +X-Spam-Status: No, score=0.174 required=5 tests=[AWL=-0.015, + MISSING_HEADERS=0.189] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id IPzPl6WTfGsN + for ; + Thu, 13 Apr 2006 10:08:05 -0300 (ADT) +X-Greylist: delayed 01:02:34.988375 by SQLgrey- +Received: from fon.nation-net.com (fon.nation-net.com [194.24.251.1]) + by postgresql.org (Postfix) with ESMTP id 0BEE711F6767 + for ; + Thu, 13 Apr 2006 10:08:08 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id 90F0B136F9F + for ; + Thu, 13 Apr 2006 14:08:04 +0100 (BST) +Received: from [194.24.251.10] (bum.net [194.24.251.10]) + by fon.nation-net.com (Postfix) with ESMTP id 78922136D94 + for ; + Thu, 13 Apr 2006 14:08:04 +0100 (BST) +Message-ID: <443E4C9D.3090301@laterooms.com> +Date: Thu, 13 Apr 2006 14:05:33 +0100 +From: Gavin Hamill +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow query - possible bug? +References: <443E3DF5.4020207@laterooms.com> + <3c1395330604130546g6b091f75x511955817fe65dcd@mail.gmail.com> +In-Reply-To: <3c1395330604130546g6b091f75x511955817fe65dcd@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AV-Checked: ClamAV using ClamSMTP +X-Archive-Number: 200604/297 +X-Sequence-Number: 18381 + +chris smith wrote: + +>1.6secs isn't too bad on 4.3mill rows... +> +>How many entries are there for that date range? +> +> +1.7 secs /is/ good - it typically takes 5 or 6 seconds, which isn't so +good. My question is 'why does the planner choose such a bizarre range +request when both elements of the 'between' are identical? :)' + +If I replace the +(allocation0_."Date" between '2006-06-09 00:00:00.000000' and +'2006-06-09 00:00:00.000000') + +with + +allocation0_."Date" ='2006-04-09 00:00:00.000000' + +then the query comes back in a few milliseconds (as I'd expect :) - and +yup I've been using different dates for each test to avoid the query +being cached. + +For ref, there are typically 35000 rows per date :) + +Cheers, +Gavin. + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 11:00:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E412A11F6C6A + for ; + Thu, 13 Apr 2006 10:59:57 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.125 +X-Spam-Level: +X-Spam-Status: No, score=0.125 required=5 tests=[AWL=0.125] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id VWdObAgL2HxB + for ; + Thu, 13 Apr 2006 10:59:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pih-relay05.plus.net (pih-relay05.plus.net [212.159.14.132]) + by postgresql.org (Postfix) with ESMTP id CF0C811F6C39 + for ; + Thu, 13 Apr 2006 10:59:52 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by pih-relay05.plus.net with esmtp (Exim) id 1FU2MQ-0002eT-4P; + Thu, 13 Apr 2006 14:59:50 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 85A007360F; + Thu, 13 Apr 2006 15:01:39 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 0EB3D15EA4; + Thu, 13 Apr 2006 14:59:37 +0100 (BST) +Message-ID: <443E5948.4080105@archonet.com> +Date: Thu, 13 Apr 2006 14:59:36 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Gavin Hamill +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow query - possible bug? +References: <443E3DF5.4020207@laterooms.com> + <3c1395330604130546g6b091f75x511955817fe65dcd@mail.gmail.com> + <443E4C9D.3090301@laterooms.com> +In-Reply-To: <443E4C9D.3090301@laterooms.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/298 +X-Sequence-Number: 18382 + +Gavin Hamill wrote: +> chris smith wrote: +> +>> 1.6secs isn't too bad on 4.3mill rows... +>> +>> How many entries are there for that date range? +>> +>> +> 1.7 secs /is/ good - it typically takes 5 or 6 seconds, which isn't so +> good. My question is 'why does the planner choose such a bizarre range +> request when both elements of the 'between' are identical? :)' + +What's bizarre about the range request, and are you sure it's searching +doing the union of both conditions separately? It looks to me like it's +doing a standard range-search. If it was trying to fetch 4.3 million +rows via that index, I'd expect it to use a different index instead. + +If you've got stats turned on, look in pg_stat_user_indexes/tables +before and after the query to see. Here's an example of a similar query +against one of my log tables. It's small, but the clause is the same, +and I don't see any evidence of the whole table being selected. + +lamp=> SELECT * FROM pg_stat_user_indexes WHERE relname LIKE 'act%'; + relid | indexrelid | schemaname | relname | indexrelname | +idx_scan | idx_tup_read | idx_tup_fetch +---------+------------+------------+---------+----------------+----------+--------------+--------------- + 6124993 | 7519044 | public | act_log | act_log_ts_idx | +23 | 18 | 18 + 6124993 | 7371115 | public | act_log | act_log_pkey | +0 | 0 | 0 +(2 rows) + +lamp=> EXPLAIN ANALYSE SELECT * FROM act_log WHERE al_ts BETWEEN +'2006-04-05 14:10:23+00'::timestamptz AND '2006-04-05 +14:10:23+00'::timestamptz; + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using act_log_ts_idx on act_log (cost=0.00..3.02 rows=1 +width=102) (actual time=0.116..0.131 rows=1 loops=1) + Index Cond: ((al_ts >= '2006-04-05 15:10:23+01'::timestamp with time +zone) AND (al_ts <= '2006-04-05 15:10:23+01'::timestamp with time zone)) + Total runtime: 0.443 ms +(3 rows) + +lamp=> SELECT * FROM pg_stat_user_indexes WHERE relname LIKE 'act%'; + relid | indexrelid | schemaname | relname | indexrelname | +idx_scan | idx_tup_read | idx_tup_fetch +---------+------------+------------+---------+----------------+----------+--------------+--------------- + 6124993 | 7519044 | public | act_log | act_log_ts_idx | +24 | 19 | 19 + 6124993 | 7371115 | public | act_log | act_log_pkey | +0 | 0 | 0 +(2 rows) + + +1. vacuum full verbose your table (and post the output please) +2. perhaps reindex? +3. Try the explain analyse again and see what happens. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Apr 13 11:00:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id CBC4911F6C40 + for ; + Thu, 13 Apr 2006 11:00:55 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.364 +X-Spam-Level: +X-Spam-Status: No, score=-2.364 required=5 tests=[AWL=0.100, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id bI1U54rzA8Lh + for ; + Thu, 13 Apr 2006 11:00:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 3AF1111F6C54 + for ; + Thu, 13 Apr 2006 11:00:43 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T88a7.t.pppool.de + [89.55.136.167]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 21E3B656CB + for ; + Thu, 13 Apr 2006 16:01:38 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id A5401181C1DF1 + for ; + Thu, 13 Apr 2006 16:00:59 +0200 (CEST) +Message-ID: <443E599B.3080305@logix-tt.com> +Date: Thu, 13 Apr 2006 16:00:59 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL Performance List +Subject: Re: Better index stategy for many fields with few values +References: <20060413131206.97079.qmail@web54714.mail.yahoo.com> +In-Reply-To: <20060413131206.97079.qmail@web54714.mail.yahoo.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/299 +X-Sequence-Number: 18383 + +Hi, Oscar, + +Please reply to the list and not privately, so others can learn from +your replies, and possibly have better Ideas than me. + +Oscar Picasso wrote: + +> I cannot group the columns logically. Any column may or may not appear +> in a query. + +That's suboptimal. + +> Summrarizing what I have learned: +> - I cannot use multicolumn indexes because I cannot group the column +> logically. +> - I cannot use funtional indexes +> - I cannot use clustering. + +You still can have a set of partitioned multi-column indices, +overlapping enough that every combination of columns is covered (or risk +a sequential sub scan for the last two or three columns, this should not +hurt too much if the first 17 columns were selective enough). + +The main problem with indices is that they also decrease write performance. + +If disk costs are not limited, it will make sense to have WAL, table and +indices on different disks / raid arrays, to parallelize writes. + +Btw, I guess you have multiple, concurrent users? + +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Thu Apr 13 11:03:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id F092D11F6C45 + for ; + Thu, 13 Apr 2006 11:03:03 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.384 +X-Spam-Level: +X-Spam-Status: No, score=-2.384 required=5 tests=[AWL=0.080, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id aslLUZiLIekd + for ; + Thu, 13 Apr 2006 11:02:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 6EF7E11F6CA4 + for ; + Thu, 13 Apr 2006 11:02:56 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T88a7.t.pppool.de + [89.55.136.167]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id C5296656CB + for ; + Thu, 13 Apr 2006 16:03:51 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 8C9B4181C1DF1 + for ; + Thu, 13 Apr 2006 16:03:13 +0200 (CEST) +Message-ID: <443E5A21.7090807@logix-tt.com> +Date: Thu, 13 Apr 2006 16:03:13 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: pgmemcache +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> + <200604121603.43986.josh@agliodbs.com> + <20060413001024.GP49405@pervasive.com> + <6236.1144888514@sss.pgh.pa.us> +In-Reply-To: <6236.1144888514@sss.pgh.pa.us> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-15 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/300 +X-Sequence-Number: 18384 + +Hi, Tom, + +Tom Lane wrote: + +>>Why are AFTER COMMIT triggers impossible? +> +> What happens if such a trigger gets an error? You can't un-commit. + +Then it must be specified that those triggers are in their own +transaction, and cannot abort the transaction. + +Or use the 2-phase-commit infrastructure for them. + +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Thu Apr 13 11:48:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B49EF11F6661 + for ; + Thu, 13 Apr 2006 11:48:51 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.178 +X-Spam-Level: +X-Spam-Status: No, score=0.178 required=5 tests=[AWL=-0.011, + MISSING_HEADERS=0.189] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id zEQGax5FqwHz + for ; + Thu, 13 Apr 2006 11:48:30 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (fon.nation-net.com [194.24.251.1]) + by postgresql.org (Postfix) with ESMTP id 7C29D11F665F + for ; + Thu, 13 Apr 2006 11:48:14 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id 27C96136FC9 + for ; + Thu, 13 Apr 2006 15:48:14 +0100 (BST) +Received: from [194.24.251.10] (bum.net [194.24.251.10]) + by fon.nation-net.com (Postfix) with ESMTP id 13AF6136FBA + for ; + Thu, 13 Apr 2006 15:48:14 +0100 (BST) +Message-ID: <443E6416.3070900@laterooms.com> +Date: Thu, 13 Apr 2006 15:45:42 +0100 +From: Gavin Hamill +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +Cc: pgsql-performance@postgresql.org +Subject: Re: pg 8.1.3, AIX, huge box, painfully slow. +References: + <17613.1144451138@sss.pgh.pa.us> + <1144661209.21409.131.camel@localhost.localdomain> + <443A2856.6050905@laterooms.com> <26244.1144683345@sss.pgh.pa.us> +In-Reply-To: <26244.1144683345@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AV-Checked: ClamAV using ClamSMTP +X-Archive-Number: 200604/301 +X-Sequence-Number: 18385 + +Tom Lane wrote: + +>Gavin Hamill writes: +> +> +>>would a simple "#define LWLOCK_PADDED_SIZE 128" be sufficient? +>> +>> +> +>Yeah, that's fine. +> +> + +OK I tried that but noticed no real improvement... in the interim I've +installed Debian on the pSeries (using +http://debian.gonicus.de/debian/dists/sarge/main/disks-powerpc/current/pseries/install.txt +) and using a simple load-test script - it picks a 'hotelsearch' select +at random from a big file and just does a pg_query on that via PHP... + +Using apachebench with 10 clients gave a loadavg of about 10 after a few +minutes, and the logs showed typical query times of 8 seconds. Again, no +disk activity, normal context-switching, just full-out CPU usage... + +We're improving the quality + efficiency of the hotelsearch function all +the time (Simon will certainly be able to vouch for its complexity) - am +really uncertain what to do next tho! :/ + +Cheers, +Gavin. + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 12:21:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id E021611F6B4E + for ; + Thu, 13 Apr 2006 12:21:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.464 +X-Spam-Level: +X-Spam-Status: No, score=-2.464 required=5 tests=[BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id m5XnDLGlDpPU + for ; + Thu, 13 Apr 2006 12:21:30 -0300 (ADT) +X-Greylist: delayed 00:22:36.544925 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 63A1811F6ABC + for ; + Thu, 13 Apr 2006 12:21:16 -0300 (ADT) +Received: from mail.crpa.it (marconi.crpa.it [212.22.134.249]) + by svr4.postgresql.org (Postfix) with ESMTP id C99615AF8EF + for ; + Thu, 13 Apr 2006 14:58:47 +0000 (GMT) +Received: from galois.langroup.crpa.it (galois [212.22.134.9]) + by mail.crpa.it (8.13.4/8.13.3/1) with ESMTP id k3DExsQV029814 + for ; Thu, 13 Apr 2006 16:59:54 +0200 +Received: from crpa.it ([212.22.134.85]) + by galois.langroup.crpa.it (8.13.3/8.13.3/1) with ESMTP id + k3DF2j78009328 + for ; Thu, 13 Apr 2006 17:02:45 +0200 +Message-ID: <443E66F5.2010100@crpa.it> +Date: Thu, 13 Apr 2006 16:57:57 +0200 +From: Cristian Veronesi +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040114 +X-Accept-Language: it, en-us +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: index is not used if I include a function that returns current time + in my query +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Scanned-By: MIMEDefang 2.52 on 212.22.134.50 +X-Archive-Number: 200604/302 +X-Sequence-Number: 18386 + +Hello, postgresql 7.4.8 on SuSE Linux here. + +I have a table called DMO with a column called ORA_RIF defined as +"timestamp without time zone" ; + +I created an index on this table based on this column only. + +If I run a query against a text literal the index is used: + +> explain select * from dmo where ora_rif>'2006-01-01'; + QUERY PLAN +----------------------------------------------------------------------------------------- + Index Scan using dmo_ndx02 on dmo (cost=0.00..1183.23 rows=736 width=156) + Index Cond: (ora_rif > '2006-01-01 00:00:00'::timestamp without time +zone) + +If I try to use a function that returns the current time instead, a +sequential scan is always performed: + +> explain select * from dmo where ora_rif>localtimestamp; + QUERY PLAN +------------------------------------------------------------------------------ + Seq Scan on dmo (cost=0.00..1008253.22 rows=2703928 width=156) + Filter: (ora_rif > ('now'::text)::timestamp(6) without time zone) + +> explain select * from dmo where ora_rif>localtimestamp::timestamp +without time zone; + QUERY PLAN +------------------------------------------------------------------------------ + Seq Scan on dmo (cost=0.00..1008253.22 rows=2703928 width=156) + Filter: (ora_rif > ('now'::text)::timestamp(6) without time zone) + +... etc. ... + +(tried with all datetime functions with and without cast) + +I even tried to write a function that explicitly returns a "timestamp +without time zone" value: + +create or replace function f () returns timestamp without time zone +as ' +declare + x timestamp without time zone ; +begin + x := ''2006-01-01 00:00:00''; + return x ; +end ; +' language plpgsql ; + +But the result is the same: + +> explain select * from dmo ora_rif>f(); + QUERY PLAN +----------------------------------------------------------------------------- + Seq Scan on dmo (cost=0.00..987973.76 rows=2703928 width=156) + Filter: (ora_rif > f()) + +Any suggestion? + +Kind regards, + +-- +Cristian Veronesi - C.R.P.A. S.p.A. - Reggio Emilia, Italy + +The first thing you need to learn about databases is that +they are not just a fancy file system for storing data. + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 12:27:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id A04C511F65FE + for ; + Thu, 13 Apr 2006 12:27:03 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.326 +X-Spam-Level: +X-Spam-Status: No, score=-2.326 required=5 tests=[AWL=0.275, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 4OG2XeZvEYa3 + for ; + Thu, 13 Apr 2006 12:26:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 0ADAA11F6691 + for ; + Thu, 13 Apr 2006 12:26:53 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3DFQo1f020330; + Thu, 13 Apr 2006 11:26:50 -0400 (EDT) +To: Gavin Hamill +cc: pgsql-performance@postgresql.org +Subject: Re: Slow query - possible bug? +In-reply-to: <443E4C9D.3090301@laterooms.com> +References: <443E3DF5.4020207@laterooms.com> + <3c1395330604130546g6b091f75x511955817fe65dcd@mail.gmail.com> + <443E4C9D.3090301@laterooms.com> +Comments: In-reply-to Gavin Hamill + message dated "Thu, 13 Apr 2006 14:05:33 +0100" +Date: Thu, 13 Apr 2006 11:26:50 -0400 +Message-ID: <20329.1144942010@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/303 +X-Sequence-Number: 18387 + +Gavin Hamill writes: +> If I replace the +> (allocation0_."Date" between '2006-06-09 00:00:00.000000' and +> '2006-06-09 00:00:00.000000') +> with +> allocation0_."Date" ='2006-04-09 00:00:00.000000' +> then the query comes back in a few milliseconds (as I'd expect :) + +Could we see EXPLAIN ANALYZE for +* both forms of the date condition, with the roomid condition; +* both forms of the date condition, WITHOUT the roomid condition; +* just the roomid condition + +I'm thinking the planner is misestimating something, but it's hard +to tell what without breaking it down. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 13 12:40:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id B107111F678D + for ; + Thu, 13 Apr 2006 12:40:10 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.4 +X-Spam-Level: +X-Spam-Status: No, score=0.4 required=5 tests=[BAYES_00=-2.599, + DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_WHOIS=1.447, HTML_10_20=1.351, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id l3JV3VhhOta2 + for ; + Thu, 13 Apr 2006 12:40:07 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from web54710.mail.yahoo.com (web54710.mail.yahoo.com + [206.190.49.200]) + by postgresql.org (Postfix) with SMTP id 6301A11F6774 + for ; + Thu, 13 Apr 2006 12:40:07 -0300 (ADT) +Received: (qmail 46853 invoked by uid 60001); 13 Apr 2006 15:40:06 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=LJF0U017hKv1QPjF4QkUOo4E1fRQDgVyxmyxcDVlvQmchMWkZPzKAB5iS2+RYDlgs67MS1nFeTSALYI+bL66z4wiE053yRUCPhaSxAveic8qJonb/Lc2UqaJXt9g0lp05fT7OHq/OOYOzMfgpJG4+5rarVlGLNKC3HE8N0Xs/Ic= + ; +Message-ID: <20060413154006.46851.qmail@web54710.mail.yahoo.com> +Received: from [70.83.4.60] by web54710.mail.yahoo.com via HTTP; + Thu, 13 Apr 2006 08:40:06 PDT +Date: Thu, 13 Apr 2006 08:40:06 -0700 (PDT) +From: Oscar Picasso +Subject: Re: Better index stategy for many fields with few values +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-1643493875-1144942806=:44309" +Content-Transfer-Encoding: 8bit +X-Archive-Number: 200604/304 +X-Sequence-Number: 18388 + +--0-1643493875-1144942806=:44309 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi Markus, + +Markus Schaber wrote: + +>Hi, Oscar, +> +>Please reply to the list and not privately, so others can learn from +>your replies, and possibly have better Ideas than me. + +That was my intention. I made a mistake. + +>Oscar Picasso wrote: +> +>> I cannot group the columns logically. Any column may or may not appear +>> in a query. +> +>That's suboptimal. +> +>> Summrarizing what I have learned: +>> - I cannot use multicolumn indexes because I cannot group the column +>> logically. +>> - I cannot use funtional indexes +>> - I cannot use clustering. +> +>You still can have a set of partitioned multi-column indices, +>overlapping enough that every combination of columns is covered (or risk +>a sequential sub scan for the last two or three columns, this should not +>hurt too much if the first 17 columns were selective enough). +> +>The main problem with indices is that they also decrease write performance. +> +>If disk costs are not limited, it will make sense to have WAL, table and +>indices on different disks / raid arrays, to parallelize writes. +> +>Btw, I guess you have multiple, concurrent users? + +Yes I do. + +I have just made other tests with only the individual indexes and performance is much better than previously. Obviously there was an I/O problem during my initial test. + +Something interesting though. If I use few columns in the query the results come very quickly and pg does a sequential scan. + +When it reachs some threshold (4 or 5 columns) pg switches to bitmap scans. It then takes an almost constant time (~ 2500 ms) not matter how many more columns I add to the where clause. + +Interestingly enough, queries with many columns are less common. They also return less results and even many times no result at all. + + From the user point of view it would be nice to have a waiting time lower than 2500ms for these queries. Maybe I could achieve that goal simply by tuning postgresql. In a such case where should I look first in order to increase bitmap scanning? + +Maybe I could, that way, avoid the use of partitioned multi-column indexes. + +Oscar + + + + +--------------------------------- +Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min. +--0-1643493875-1144942806=:44309 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi Markus,

Markus Schaber <schabi@logix-tt.com> wrote:

>Hi, Oscar,
>
>Please reply to the list and not privately, so others can learn from
>your replies, and possibly have better Ideas than me.

That was my intention. I made a mistake.

>Oscar Picasso wrote:
>
>> I cannot group the columns logically. Any column may or may not appear
>> in a query.
>
>That's suboptimal.
>
>> Summrarizing what I have learned:
>> - I cannot use multicolumn indexes because I cannot group the column
>> logically.
>> - I cannot use funtional indexes
>> - I cannot use clustering.
>
>You still can have a set of partitioned multi-column indices,
>overlapping enough that every combination of columns is covered (or risk
>a sequential sub scan for the last two or three columns, this should not
>hurt too much if the first 17 columns + were selective enough).
>
>The main problem with indices is that they also decrease write performance.
>
>If disk costs are not limited, it will make sense to have WAL, table and
>indices on different disks / raid arrays, to parallelize writes.
>
>Btw, I guess you have multiple, concurrent users?

Yes I do.

I have just made other tests with only the individual indexes and performance is much better than previously. Obviously there was an I/O problem during my initial test.

Something interesting though. If I use few columns in the query the results come very quickly and pg does a sequential scan.

When it reachs some threshold (4 or 5 columns) pg switches to bitmap scans. It then takes an almost constant time (~ 2500 ms) not matter how many more columns I add to the where clause.

Interestingly enough, queries with many columns are less common. They also return less results and even many times no + result at all.

From the user point of view it would be nice to have a waiting time lower than 2500ms for these queries. Maybe I could achieve that goal simply by tuning postgresql. In a such case where should I look first in order to increase bitmap scanning?

Maybe I could, that way, avoid the use of partitioned multi-column indexes.

Oscar


+


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min. +--0-1643493875-1144942806=:44309-- + +From pgsql-performance-owner@postgresql.org Thu Apr 13 12:50:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 5E7DE11F6CAD + for ; + Thu, 13 Apr 2006 12:50:20 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.344 +X-Spam-Level: +X-Spam-Status: No, score=-2.344 required=5 tests=[AWL=0.257, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id ssZGv1rU8cG2 + for ; + Thu, 13 Apr 2006 12:50:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 3A79011F6CA9 + for ; + Thu, 13 Apr 2006 12:50:17 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3DFo8H2020559; + Thu, 13 Apr 2006 11:50:08 -0400 (EDT) +To: Cristian Veronesi +cc: pgsql-performance@postgresql.org +Subject: Re: index is not used if I include a function that returns current + time in my query +In-reply-to: <443E66F5.2010100@crpa.it> +References: <443E66F5.2010100@crpa.it> +Comments: In-reply-to Cristian Veronesi + message dated "Thu, 13 Apr 2006 16:57:57 +0200" +Date: Thu, 13 Apr 2006 11:50:08 -0400 +Message-ID: <20558.1144943408@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/305 +X-Sequence-Number: 18389 + +Cristian Veronesi writes: +> If I try to use a function that returns the current time instead, a +> sequential scan is always performed: +> ... +> Any suggestion? + +1. Use something newer than 7.4 ;-) + +2. Set up a dummy range constraint, ie + + select ... where ora_rif > localtimestamp and ora_rif < 'infinity'; + +The problem you have is that the planner doesn't know the value of the +function and falls back to a default assumption about the selectivity of +the '>' condition --- and that default discourages indexscans. (Note +the very large estimate of number of rows returned.) In the +range-constraint situation, the planner still doesn't know the value of +the function, but its default assumption for a range constraint is +tighter and it (probably) will choose an indexscan. + +Since PG 8.0, the planner understands that it's reasonable to +pre-evaluate certain functions like localtimestamp to obtain +better-than-guess values about selectivity, so updating would +be a better fix. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 13 13:43:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7ED5911F66BE + for ; + Thu, 13 Apr 2006 13:43:08 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.103 +X-Spam-Level: +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Uf2LqpqqIrMi + for ; + Thu, 13 Apr 2006 13:43:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ausimss.pervasive.com (ausimss.pervasive.com [66.45.103.246]) + by postgresql.org (Postfix) with ESMTP id 203F411F60A5 + for ; + Thu, 13 Apr 2006 13:43:03 -0300 (ADT) +Received: from ausbayes2.aus.pervasive.com ([172.16.8.6]) by + ausimss.pervasive.com with InterScan Messaging Security Suite; + Thu, 13 Apr 2006 11:43:00 -0500 +Received: from AUSOWA.aus.pervasive.com ([172.16.4.8]) by + ausbayes2.aus.pervasive.com with Microsoft SMTPSVC(5.0.2195.6713); + Thu, 13 Apr 2006 11:42:59 -0500 +Received: from ausmailid.aus.pervasive.com ([172.16.4.64]) by + AUSOWA.aus.pervasive.com with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 13 Apr 2006 11:42:57 -0500 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: multi column query +Date: Thu, 13 Apr 2006 11:42:25 -0500 +Message-ID: + <4D27CB1096EF1C408F4BFAB0046EC7B6099EC5@ausmailid.aus.pervasive.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] multi column query +Thread-Index: AcZek1yvb6Ri7m29TvG7TO2hvoi3bwAAFySAACFRyTA= +From: "Jim Nasby" +To: "Sriram Dandapani" +Cc: "Pgsql-Performance \(E-mail\)" +X-OriginalArrivalTime: 13 Apr 2006 16:42:57.0017 (UTC) + FILETIME=[5157D690:01C65F19] +X-Archive-Number: 200604/306 +X-Sequence-Number: 18390 + +You need to run EXPLAIN ANALYZE. Also, what's random_page_cost set to? = +And the output of \d chkpfw_tr_dy_dimension. The cost for that index = +scan looks way too high. + +And please reply-all so that the list is included. + +> -----Original Message----- +> From: Sriram Dandapani [mailto:sdandapani@counterpane.com] +> Sent: Wednesday, April 12, 2006 7:48 PM +> To: Jim Nasby +> Subject: RE: [PERFORM] multi column query +>=20 +>=20 +> I executed enable_seqscan=3Doff and then ran an explain plan on=20 +> the query +>=20 +> UPDATE chkpfw_tr_dy_dimension +> SET summcount =3D a.summcount + b.summcount, +> bytes =3D a.bytes + b.bytes, +> duration =3D a.duration + b.duration +> from chkpfw_tr_dy_dimension a, +> c_chkpfw_dy_tr_updates b +> WHERE a.firstoccurrence =3D b.firstoccurrence +> AND a.customerid_id =3D b.customerid_id +> AND a.sentryid_id =3D b.sentryid_id +> AND a.node_id =3D b.node_id +> AND a.interface_id =3D b.interface_id +> AND a.source_id =3D b.source_id +> AND a.destination_id =3D b.destination_id +> AND a.sourceport_id =3D b.sourceport_id +> AND a.destinationport_id =3D b.destinationport_id +> AND a.inoutbound_id =3D b.inoutbound_id +> AND a.action_id =3D b.action_id +> AND a.protocol_id =3D b.protocol_id +> AND a.service_id =3D b.service_id +> AND a.sourcezone_id =3D b.sourcezone_id +> AND a.destinationzone_id =3D +> b.destinationzone_id; +>=20 +>=20 +>=20 +> Here is the query plan +>=20 +>=20 +> "Nested Loop (cost=3D200000036.18..221851442.39 rows=3D1 = +width=3D166)" +> " -> Merge Join (cost=3D100000036.18..121620543.75 rows=3D1 = +width=3D96)" +> " Merge Cond: (("outer".firstoccurrence =3D +> "inner".firstoccurrence) AND ("outer".sentryid_id =3D=20 +> "inner".sentryid_id) +> AND ("outer".node_id =3D "inner".node_id))" +> " Join Filter: (("outer".customerid_id =3D = +"inner".customerid_id) +> AND ("outer".interface_id =3D "inner".interface_id) AND=20 +> ("outer".source_id +> =3D "inner".source_id) AND ("outer".destination_id =3D +> "inner".destination_id) AND ("outer".sourceport_id =3D "inner".s (..)" +> " -> Index Scan using chkpfw_tr_dy_idx1 on +> chkpfw_tr_dy_dimension a (cost=3D0.00..21573372.84 rows=3D6281981 +> width=3D88)" +> " -> Sort (cost=3D100000036.18..100000037.38 rows=3D480=20 +> width=3D136)" +> " Sort Key: b.firstoccurrence, b.sentryid_id, b.node_id" +> " -> Seq Scan on c_chkpfw_dy_tr_updates b +> (cost=3D100000000.00..100000014.80 rows=3D480 width=3D136)" +> " -> Seq Scan on chkpfw_tr_dy_dimension +> (cost=3D100000000.00..100168078.81 rows=3D6281981 width=3D70)" +>=20 +> -----Original Message----- +> From: Jim C. Nasby [mailto:jnasby@pervasive.com]=20 +> Sent: Wednesday, April 12, 2006 5:44 PM +> To: Sriram Dandapani +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] multi column query +>=20 +> On Wed, Apr 12, 2006 at 05:32:32PM -0700, Sriram Dandapani wrote: +> > Hi +> >=20 +> > When I update a table that has 20 columns and the where clause +> includes +> > 16 of the columns (this is a data warehousing type update=20 +> on aggregate +> > fields), +> >=20 +> > The bitmap scan is not used by the optimizer. The table is=20 +> indexed on +> 3 +> > of the 20 fields. The update takes really long to finish (on a 6 +> million +> > row table) +> >=20 +> > Do I need to do some "magic" with configuration to turn on bitmap +> scans. +>=20 +> No. What's explain analyze of the query show? What's it doing now? +> Seqscan? You might try set enable_seqscan=3Doff and see what that = +does. +> --=20 +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +>=20 + +From pgsql-performance-owner@postgresql.org Mon Apr 17 09:10:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 76E2C11F65FA + for ; + Thu, 13 Apr 2006 14:29:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.6 +X-Spam-Level: +X-Spam-Status: No, score=-2.6 required=5 tests=[BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id IT7X8LqwJe13 + for ; + Thu, 13 Apr 2006 14:29:28 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.194]) + by postgresql.org (Postfix) with ESMTP id 1FB2411F65DC + for ; + Thu, 13 Apr 2006 14:29:27 -0300 (ADT) +Received: by zproxy.gmail.com with SMTP id m7so1724544nzf + for ; + Thu, 13 Apr 2006 10:29:27 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; + b=TDlHIKAjMTRsb4GFXkcBK5xZ/GST2RZz4orXFPYLpdqTIAhXYSVimg4kZVD5v9XlBcWbUCWtJ+8r4xhH+PDjcnrbJkDSf2Ehep+/L+Jbg0xfqhDKSQK7ndO3KBbygBEf3Lovs/8kZmf8p5JGxkaXICTFtCxPQBxMeYu9Np/p1zg= +Received: by 10.36.75.18 with SMTP id x18mr877746nza; + Thu, 13 Apr 2006 10:29:27 -0700 (PDT) +Received: from ?192.168.51.41? ( [209.209.36.196]) + by mx.gmail.com with ESMTP id i5sm2007321nzi.2006.04.13.10.29.25; + Thu, 13 Apr 2006 10:29:26 -0700 (PDT) +In-Reply-To: <6236.1144888514@sss.pgh.pa.us> +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> + <200604121603.43986.josh@agliodbs.com> + <20060413001024.GP49405@pervasive.com> + <6236.1144888514@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <4D23826E-7325-4946-B79A-80E321E0E497@gmail.com> +Cc: "Jim C. Nasby" , Josh Berkus , + pgsql-performance@postgresql.org, PFC +Content-Transfer-Encoding: 7bit +From: Christian Storm +Subject: Re: pgmemcache +Date: Thu, 13 Apr 2006 10:29:28 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/355 +X-Sequence-Number: 18439 + +Not sure if I follow why this is a problem. Seems like it would be +beneficial to have both BEFORE and AFTER COMMIT triggers. +With the BEFORE COMMIT trigger you would have the ability to 'un- +commit' (rollback) the transaction. With +the AFTER COMMIT trigger you wouldn't have that option because the +commit has already been successful. However, +with an AFTER COMMIT you would be able to trigger other downstream +events that rely on a transaction successfully committing. +If the trigger fails it is the triggers problem, it isn't the +commit's problem, i.e., you wouldn't want to 'un-commit'. If the +trigger +gets an error it has to gracefully deal with that error programatically. + +Where have I gone astray with this logic? + +On Apr 12, 2006, at 5:35 PM, Tom Lane wrote: + +> "Jim C. Nasby" writes: +>> Why are AFTER COMMIT triggers impossible? +> +> What happens if such a trigger gets an error? You can't un-commit. +> +> regards, tom lane + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 14:38:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 51C3911F6613 + for ; + Thu, 13 Apr 2006 14:38:10 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.388 +X-Spam-Level: +X-Spam-Status: No, score=-2.388 required=5 tests=[AWL=0.213, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id XOoGpxICiYAo + for ; + Thu, 13 Apr 2006 14:38:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 6D4C011F6605 + for ; + Thu, 13 Apr 2006 14:38:06 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3DHc0FZ026793; + Thu, 13 Apr 2006 13:38:00 -0400 (EDT) +To: Christian Storm +cc: "Jim C. Nasby" , Josh Berkus , + pgsql-performance@postgresql.org, PFC +Subject: Re: pgmemcache +In-reply-to: <4D23826E-7325-4946-B79A-80E321E0E497@gmail.com> +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> + <200604121603.43986.josh@agliodbs.com> + <20060413001024.GP49405@pervasive.com> + <6236.1144888514@sss.pgh.pa.us> + <4D23826E-7325-4946-B79A-80E321E0E497@gmail.com> +Comments: In-reply-to Christian Storm + message dated "Thu, 13 Apr 2006 10:29:28 -0700" +Date: Thu, 13 Apr 2006 13:38:00 -0400 +Message-ID: <26792.1144949880@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/307 +X-Sequence-Number: 18391 + +Christian Storm writes: +> Not sure if I follow why this is a problem. Seems like it would be +> beneficial to have both BEFORE and AFTER COMMIT triggers. +> With the BEFORE COMMIT trigger you would have the ability to 'un- +> commit' (rollback) the transaction. With +> the AFTER COMMIT trigger you wouldn't have that option because the +> commit has already been successful. However, +> with an AFTER COMMIT you would be able to trigger other downstream +> events that rely on a transaction successfully committing. + +An AFTER COMMIT trigger would have to be in a separate transaction. +What happens if there's more than one, and one of them fails? Even +more to the point, if it's a separate transaction, don't you have +to fire all these triggers again when you commit that transaction? +The idea seems circular. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 13 14:40:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A149811F653E + for ; + Thu, 13 Apr 2006 14:40:25 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.001 +X-Spam-Level: +X-Spam-Status: No, score=0.001 required=5 tests=[UNPARSEABLE_RELAY=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id UkW5yEubZjiO + for ; + Thu, 13 Apr 2006 14:40:11 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-2.sun.com (brmea-mail-2.Sun.COM [192.18.98.43]) + by postgresql.org (Postfix) with ESMTP id B3AC611F6236 + for ; + Thu, 13 Apr 2006 14:40:11 -0300 (ADT) +Received: from phys-d3-ha21sca-1 ([129.145.155.163]) + by brmea-mail-2.sun.com (8.12.10/8.12.9) with ESMTP id k3DHe9mi013752 + for ; + Thu, 13 Apr 2006 11:40:10 -0600 (MDT) +Received: from conversion-daemon.ha21sca-mail1.sfbay.sun.com by + ha21sca-mail1.sfbay.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + id <0IXO00L018ZOZZ@ha21sca-mail1.sfbay.sun.com> + (original mail from Robert.Lor@Sun.COM) for + pgsql-performance@postgresql.org; + Thu, 13 Apr 2006 10:40:05 -0700 (PDT) +Received: from sun.com (sr1-usca-10.SFBay.Sun.COM [129.145.155.152]) + by ha21sca-mail1.sfbay.sun.com + (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) + with ESMTP id <0IXO00HIJ92TG4@ha21sca-mail1.sfbay.sun.com>; Thu, + 13 Apr 2006 10:40:05 -0700 (PDT) +Date: Thu, 13 Apr 2006 10:40:08 -0700 +From: Robert Lor +Subject: Re: bad performance on Solaris 10 +In-reply-to: <200604130839.k3D8dZQ26118@candle.pha.pa.us> +To: Bruce Momjian +Cc: "Jignesh K. Shah" , + Luke Lonergan , + Alvaro Herrera , + Chris Mair , pgsql-performance@postgresql.org, + markir@paradise.net.nz, Josh Berkus +Reply-to: Robert.Lor@Sun.COM +Message-id: <443E8CF8.2090108@sun.com> +Organization: Sun Microsystems +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.4) Gecko/20041214 +References: <200604130839.k3D8dZQ26118@candle.pha.pa.us> +X-Archive-Number: 200604/308 +X-Sequence-Number: 18392 + + +Bruce Momjian wrote On 04/13/06 01:39 AM,: +> +> Yes, if someone wants to give us a clear answer on which wal_sync method +> is best on all versions of Solaris, we can easily make that change. +> + +We're doing tests to see how various parameters in postgresql.conf +affect performance on Solaris and will share the results shortly. + +Regards, +-Robert + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 15:00:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 34D4911F653E + for ; + Thu, 13 Apr 2006 15:00:29 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -1.53 +X-Spam-Level: +X-Spam-Status: No, score=-1.53 required=5 tests=[BAYES_00=-2.599, + SPF_NEUTRAL=1.069] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id dSABqk1ID8Ng + for ; + Thu, 13 Apr 2006 15:00:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id C6C3711F6539 + for ; + Thu, 13 Apr 2006 15:00:25 -0300 (ADT) +Received: from [172.16.5.67] (64-132-13-2.gen.twtelecom.net [64.132.13.2]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by noel.decibel.org (Postfix) with ESMTP id 1DE1D56408 + for ; + Thu, 13 Apr 2006 13:00:09 -0500 (CDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Transfer-Encoding: 7bit +Message-Id: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: Postgresql Performance +From: Jim Nasby +Subject: Blocks read for index scans +Date: Thu, 13 Apr 2006 13:00:07 -0500 +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/309 +X-Sequence-Number: 18393 + +While working on determining a good stripe size for a database, I +realized it would be handy to know what the average request size is. +Getting this info is a simple matter of joining pg_stat_all_tables +and pg_statio_all_tables and doing some math, but there's one issue +I've found; it appears that there's no information on how many heap +blocks were read in by an index scan. Is there any way to get that info? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 15:29:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id DF17E11F6D5B + for ; + Thu, 13 Apr 2006 15:29:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -1.747 +X-Spam-Level: +X-Spam-Status: No, score=-1.747 required=5 tests=[AWL=-0.217, BAYES_00=-2.599, + SPF_NEUTRAL=1.069] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id jD21ZTkyvZpf + for ; + Thu, 13 Apr 2006 15:29:30 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 0010711F6CB3 + for ; + Thu, 13 Apr 2006 15:29:28 -0300 (ADT) +Received: from [172.16.5.67] (64-132-13-2.gen.twtelecom.net [64.132.13.2]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by noel.decibel.org (Postfix) with ESMTP id 1E56956423; + Thu, 13 Apr 2006 13:29:28 -0500 (CDT) +In-Reply-To: <26792.1144949880@sss.pgh.pa.us> +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> + <200604121603.43986.josh@agliodbs.com> + <20060413001024.GP49405@pervasive.com> + <6236.1144888514@sss.pgh.pa.us> + <4D23826E-7325-4946-B79A-80E321E0E497@gmail.com> + <26792.1144949880@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: Christian Storm , + Josh Berkus , pgsql-performance@postgresql.org, + PFC +Content-Transfer-Encoding: 7bit +From: Jim Nasby +Subject: Re: pgmemcache +Date: Thu, 13 Apr 2006 13:29:25 -0500 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/310 +X-Sequence-Number: 18394 + +On Apr 13, 2006, at 12:38 PM, Tom Lane wrote: + +> Christian Storm writes: +>> Not sure if I follow why this is a problem. Seems like it would be +>> beneficial to have both BEFORE and AFTER COMMIT triggers. +>> With the BEFORE COMMIT trigger you would have the ability to 'un- +>> commit' (rollback) the transaction. With +>> the AFTER COMMIT trigger you wouldn't have that option because the +>> commit has already been successful. However, +>> with an AFTER COMMIT you would be able to trigger other downstream +>> events that rely on a transaction successfully committing. +> +> An AFTER COMMIT trigger would have to be in a separate transaction. +> What happens if there's more than one, and one of them fails? Even +> more to the point, if it's a separate transaction, don't you have +> to fire all these triggers again when you commit that transaction? +> The idea seems circular. + +I suspect that in reality you'd probably want each on-commit trigger +to be it's own transaction, but it depends on what you're doing. +Also, I can't see any use for them where you'd actually be +interacting with the database, only if you were calling something +externally via a function. One example would be sending an email out +when a certain table changes; in many cases it's better to let the +change happen even if the email can't be sent, and you'd rather not +send an email if the transaction just ends up rolling back for some +reason. And yes, you'd have to ensure you didn't code yourself up a +trigger loop. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 15:46:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 1FCC811F6259 + for ; + Thu, 13 Apr 2006 15:46:51 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.129 +X-Spam-Level: +X-Spam-Status: No, score=-2.129 required=5 tests=[AWL=0.336, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id qy16HIgNp9Ve + for ; + Thu, 13 Apr 2006 15:45:42 -0300 (ADT) +X-Greylist: delayed 18:06:43.991125 by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 1A5B811F6204 + for ; + Thu, 13 Apr 2006 15:45:40 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id D6F14B81F; + Thu, 13 Apr 2006 14:45:39 -0400 (EDT) +Received: from 35st-server.simplicato.com + (static-71-249-233-130.nycmny.east.verizon.net [71.249.233.130]) + by zoraida.natserv.net (Postfix) with ESMTP id 9099AB81D; + Thu, 13 Apr 2006 14:45:39 -0400 (EDT) +References: + <443DA715.4060606@gmail.com> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Chris +Cc: Pgsql performance +Subject: Re: Inserts optimization? +Date: Thu, 13 Apr 2006 14:45:39 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/311 +X-Sequence-Number: 18395 + +Chris writes: + +> If you can, use copy instead: +> http://www.postgresql.org/docs/8.1/interactive/sql-copy.html + +I am familiar with copy. +Can't use it in this scenario. + +The data is coming from a program called Bacula (Backup server). +It is not static data. + +From pgsql-performance-owner@postgresql.org Thu Apr 13 15:49:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id E69A611F6256 + for ; + Thu, 13 Apr 2006 15:49:03 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.375 +X-Spam-Level: +X-Spam-Status: No, score=-2.375 required=5 tests=[AWL=0.225, BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id HMoL1Rz6lqCQ + for ; + Thu, 13 Apr 2006 15:48:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ausimss.pervasive.com (ausimss.pervasive.com [66.45.103.246]) + by postgresql.org (Postfix) with ESMTP id BC61F11F6254 + for ; + Thu, 13 Apr 2006 15:48:55 -0300 (ADT) +Received: from ausbayes2.aus.pervasive.com ([172.16.8.6]) by + ausimss.pervasive.com with InterScan Messaging Security Suite; + Thu, 13 Apr 2006 13:48:54 -0500 +Received: from AUSOWA.aus.pervasive.com ([172.16.4.8]) by + ausbayes2.aus.pervasive.com with Microsoft SMTPSVC(5.0.2195.6713); + Thu, 13 Apr 2006 13:48:53 -0500 +Received: from ausmailid.aus.pervasive.com ([172.16.4.64]) by + AUSOWA.aus.pervasive.com with Microsoft SMTPSVC(6.0.3790.1830); + Thu, 13 Apr 2006 13:48:53 -0500 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Blocks read for index scans +Date: Thu, 13 Apr 2006 13:48:22 -0500 +Message-ID: + <4D27CB1096EF1C408F4BFAB0046EC7B6099ED1@ausmailid.aus.pervasive.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Blocks read for index scans +Thread-Index: AcZfKdkaUpzKqAZAQiWynR0Bp6V5LgAAB37w +From: "Jim Nasby" +To: "Steve Poe" +Cc: "Pgsql-Performance \(E-mail\)" +X-OriginalArrivalTime: 13 Apr 2006 18:48:53.0407 (UTC) + FILETIME=[E94D72F0:01C65F2A] +X-Archive-Number: 200604/312 +X-Sequence-Number: 18396 + +Adding -performance back in... + +> From: Steve Poe [mailto:steve.poe@gmail.com] +> Jim, +>=20 +> I could be way off, but doesn't from pg_statio_user_tables=20 +> contain this +> information? + +http://www.postgresql.org/docs/8.1/interactive/monitoring-stats.html#MONI= +TORING-STATS-VIEWS states: + +"numbers of disk blocks read and buffer hits in all indexes of that = +table" + +That leads me to believe that it's only tracking index blocks read, and = +not heap blocks read. One could presume that each index row read as = +reported by pg_stat_all_tables would represent a heap block read, but a = +large number of those would (hopefully) have already been in = +shared_buffers. + +> On Thu, 2006-04-13 at 13:00 -0500, Jim Nasby wrote: +> > While working on determining a good stripe size for a database, I =20 +> > realized it would be handy to know what the average request=20 +> size is. =20 +> > Getting this info is a simple matter of joining pg_stat_all_tables =20 +> > and pg_statio_all_tables and doing some math, but there's=20 +> one issue =20 +> > I've found; it appears that there's no information on how=20 +> many heap =20 +> > blocks were read in by an index scan. Is there any way to=20 +> get that info? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Apr 13 15:59:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A495B11F6228 + for ; + Thu, 13 Apr 2006 15:59:41 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id fzOF+NeRM0Bl + for ; + Thu, 13 Apr 2006 15:59:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 7318C11F610C + for ; + Thu, 13 Apr 2006 15:59:25 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id C5DF1B81F; + Thu, 13 Apr 2006 14:59:24 -0400 (EDT) +Received: from 35st-server.simplicato.com + (static-71-249-233-130.nycmny.east.verizon.net [71.249.233.130]) + by zoraida.natserv.net (Postfix) with ESMTP id 4C149B81D; + Thu, 13 Apr 2006 14:59:24 -0400 (EDT) +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Tom Lane +Cc: Chris , + Pgsql performance +Subject: Re: Inserts optimization? +Date: Thu, 13 Apr 2006 14:59:23 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/313 +X-Sequence-Number: 18397 + +Tom Lane writes: + +> Or at least try to do multiple inserts per transaction. + +Will see if the program has an option like that. + + +> Also, increasing checkpoint_segments and possibly wal_buffers helps a + +Will try those. + +>Try to get the WAL onto a separate disk +>spindle if you can. (These things don't matter for SELECTs, but they +>do matter for writes.) + +This particular server is pretty much what I inherited for now for this +project.and its Raid 5. There is a new server I am setting up +soon... 8 disks which we are planning to setup +6 disks in RAID 10 +2 Hot spares + +In RAID 10 would it matter that WALL is in the same RAID set? +Would it be better: +4 disks in RAID10 Data +2 disks RAID 1 WALL +2 hot spares + +All in the same RAID controller + +From pgsql-performance-owner@postgresql.org Thu Apr 13 16:38:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id B33A511F61E1 + for ; + Thu, 13 Apr 2006 16:38:24 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.525 +X-Spam-Level: +X-Spam-Status: No, score=-2.525 required=5 tests=[AWL=0.075, BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id w8cP3jILvWGZ + for ; + Thu, 13 Apr 2006 16:38:23 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.225]) + by postgresql.org (Postfix) with ESMTP id EE05C11F610C + for ; + Thu, 13 Apr 2006 16:38:21 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 67so171106wri + for ; + Thu, 13 Apr 2006 12:38:21 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=q5+VfXZSS2a+d5T01AuHxNF5qwM9rqTPQ+549tFEkZTLBZi1/fvJ9WjqQEKv5+TZIgGzlnh3OJpj+jMhSpRzAkCwP81uIJPqC0ThoJsntEOl02HCH7604TlbDtNzYGm2DWUmId5Gs9BMa4STsT3tGWvUyQuGDfOJj2PmMmWbzYI= +Received: by 10.65.224.3 with SMTP id b3mr623541qbr; + Thu, 13 Apr 2006 12:38:21 -0700 (PDT) +Received: by 10.65.137.8 with HTTP; Thu, 13 Apr 2006 12:38:21 -0700 (PDT) +Message-ID: +Date: Thu, 13 Apr 2006 15:38:21 -0400 +From: "Merlin Moncure" +To: josh@agliodbs.com +Subject: Re: bad performance on Solaris 10 +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200604121549.14328.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <200604121549.14328.josh@agliodbs.com> +X-Archive-Number: 200604/314 +X-Sequence-Number: 18398 + +On 4/12/06, Josh Berkus wrote: +> People, +> +> > Lately I find people are not so receptive to VxFS, and Sun is promoting +> > ZFS, and we don't have a reasonable near term option for Raw IO in +> > Postgres, so we need to work to find a reasonable path for Solaris user= +s +> > IMO. The long delays in ZFS production haven't helped us there, as the +> > problems with UFS are severe. + +I just recently worked with sun solaris 10 and found it to be +reasonably performant without much tuning. This was on a dual sparc +sunblade workstation which i felt was very well engineered. I was +able (with zero solaris experience) to get postgresql up and crunching +away at some really data intensive tasks while running an application +compiled their very excellent fortran compiler. + +In the enterprise world I am finding that the only linux distrubutions +supported are redhat and suse, meaning if you have a problem with your +san running against your gentoo box you have a serious problem. +Solaris OTOH, is generally very well supported (especially on sun +hardware) and is free. So I give sun great credit for providing a +free if not necessarily completely open platform for developing open +source applications in an enterprise environment. + +Merlin + +From pgsql-performance-owner@postgresql.org Thu Apr 13 16:52:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 3C9D011F6CCB + for ; + Thu, 13 Apr 2006 16:52:24 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.316 +X-Spam-Level: +X-Spam-Status: No, score=-2.316 required=5 tests=[AWL=0.283, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id qoBM-osjERvN + for ; + Thu, 13 Apr 2006 16:52:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id 81E2D11F6001 + for ; + Thu, 13 Apr 2006 16:51:29 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Thu, 13 Apr 2006 19:51:28 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1144957887465; Thu, 13 Apr 2006 12:51:27 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Thu, 13 Apr 2006 12:51:27 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Thu, 13 Apr 2006 12:51:27 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1144957882535; Thu, 13 Apr 2006 12:51:22 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: multi column query +Date: Thu, 13 Apr 2006 12:51:19 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF03EF4A44@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] multi column query +Thread-Index: AcZek1yvb6Ri7m29TvG7TO2hvoi3bwAAFySAACFRyTAABp5L4A== +From: "Sriram Dandapani" +To: "Jim Nasby" +Cc: "Pgsql-Performance \(E-mail\)" +X-Archive-Number: 200604/315 +X-Sequence-Number: 18399 + +Hi Jim + +The problem is fixed. The destination table that was being updated had 3 +separate indexes. I combined them to a multi-column index and the effect +was amazing. +Thanks for your input + +Sriram + +-----Original Message----- +From: Jim Nasby [mailto:jnasby@pervasive.com]=20 +Sent: Thursday, April 13, 2006 9:42 AM +To: Sriram Dandapani +Cc: Pgsql-Performance (E-mail) +Subject: RE: [PERFORM] multi column query + +You need to run EXPLAIN ANALYZE. Also, what's random_page_cost set to? +And the output of \d chkpfw_tr_dy_dimension. The cost for that index +scan looks way too high. + +And please reply-all so that the list is included. + +> -----Original Message----- +> From: Sriram Dandapani [mailto:sdandapani@counterpane.com] +> Sent: Wednesday, April 12, 2006 7:48 PM +> To: Jim Nasby +> Subject: RE: [PERFORM] multi column query +>=20 +>=20 +> I executed enable_seqscan=3Doff and then ran an explain plan on=20 +> the query +>=20 +> UPDATE chkpfw_tr_dy_dimension +> SET summcount =3D a.summcount + b.summcount, +> bytes =3D a.bytes + b.bytes, +> duration =3D a.duration + b.duration +> from chkpfw_tr_dy_dimension a, +> c_chkpfw_dy_tr_updates b +> WHERE a.firstoccurrence =3D b.firstoccurrence +> AND a.customerid_id =3D b.customerid_id +> AND a.sentryid_id =3D b.sentryid_id +> AND a.node_id =3D b.node_id +> AND a.interface_id =3D b.interface_id +> AND a.source_id =3D b.source_id +> AND a.destination_id =3D b.destination_id +> AND a.sourceport_id =3D b.sourceport_id +> AND a.destinationport_id =3D b.destinationport_id +> AND a.inoutbound_id =3D b.inoutbound_id +> AND a.action_id =3D b.action_id +> AND a.protocol_id =3D b.protocol_id +> AND a.service_id =3D b.service_id +> AND a.sourcezone_id =3D b.sourcezone_id +> AND a.destinationzone_id =3D +> b.destinationzone_id; +>=20 +>=20 +>=20 +> Here is the query plan +>=20 +>=20 +> "Nested Loop (cost=3D200000036.18..221851442.39 rows=3D1 = +width=3D166)" +> " -> Merge Join (cost=3D100000036.18..121620543.75 rows=3D1 = +width=3D96)" +> " Merge Cond: (("outer".firstoccurrence =3D +> "inner".firstoccurrence) AND ("outer".sentryid_id =3D=20 +> "inner".sentryid_id) +> AND ("outer".node_id =3D "inner".node_id))" +> " Join Filter: (("outer".customerid_id =3D = +"inner".customerid_id) +> AND ("outer".interface_id =3D "inner".interface_id) AND=20 +> ("outer".source_id +> =3D "inner".source_id) AND ("outer".destination_id =3D +> "inner".destination_id) AND ("outer".sourceport_id =3D "inner".s (..)" +> " -> Index Scan using chkpfw_tr_dy_idx1 on +> chkpfw_tr_dy_dimension a (cost=3D0.00..21573372.84 rows=3D6281981 +> width=3D88)" +> " -> Sort (cost=3D100000036.18..100000037.38 rows=3D480=20 +> width=3D136)" +> " Sort Key: b.firstoccurrence, b.sentryid_id, b.node_id" +> " -> Seq Scan on c_chkpfw_dy_tr_updates b +> (cost=3D100000000.00..100000014.80 rows=3D480 width=3D136)" +> " -> Seq Scan on chkpfw_tr_dy_dimension +> (cost=3D100000000.00..100168078.81 rows=3D6281981 width=3D70)" +>=20 +> -----Original Message----- +> From: Jim C. Nasby [mailto:jnasby@pervasive.com]=20 +> Sent: Wednesday, April 12, 2006 5:44 PM +> To: Sriram Dandapani +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] multi column query +>=20 +> On Wed, Apr 12, 2006 at 05:32:32PM -0700, Sriram Dandapani wrote: +> > Hi +> >=20 +> > When I update a table that has 20 columns and the where clause +> includes +> > 16 of the columns (this is a data warehousing type update=20 +> on aggregate +> > fields), +> >=20 +> > The bitmap scan is not used by the optimizer. The table is=20 +> indexed on +> 3 +> > of the 20 fields. The update takes really long to finish (on a 6 +> million +> > row table) +> >=20 +> > Do I need to do some "magic" with configuration to turn on bitmap +> scans. +>=20 +> No. What's explain analyze of the query show? What's it doing now? +> Seqscan? You might try set enable_seqscan=3Doff and see what that = +does. +> --=20 +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +>=20 + +From pgsql-performance-owner@postgresql.org Thu Apr 13 17:22:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A556D11F623A + for ; + Thu, 13 Apr 2006 17:22:41 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.133 +X-Spam-Level: +X-Spam-Status: No, score=0.133 required=5 tests=[AWL=0.133] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Ktk8VOr3RT4q + for ; + Thu, 13 Apr 2006 17:22:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id ECE0C11F623B + for ; + Thu, 13 Apr 2006 17:22:34 -0300 (ADT) +Received: (qmail 29848 invoked from network); 13 Apr 2006 22:23:32 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 13 Apr 2006 22:23:32 +0200 +Date: Thu, 13 Apr 2006 22:23:31 +0200 +To: "Tom Lane" , + "Christian Storm" +Subject: Re: pgmemcache +Cc: "Jim C. Nasby" , "Josh Berkus" , + pgsql-performance@postgresql.org +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> + <200604121603.43986.josh@agliodbs.com> + <20060413001024.GP49405@pervasive.com> + <6236.1144888514@sss.pgh.pa.us> + <4D23826E-7325-4946-B79A-80E321E0E497@gmail.com> + <26792.1144949880@sss.pgh.pa.us> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <26792.1144949880@sss.pgh.pa.us> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Archive-Number: 200604/316 +X-Sequence-Number: 18400 + + +> An AFTER COMMIT trigger would have to be in a separate transaction. + + I guess AFTER COMMIT triggers would be like a NOTIFY, but more powerful. +While NOTIFY can't transmit information to another process, this trigger +could, and the other process could then view the results of the commited +transaction. + Also, implementing a long process (something involving network +roundtrips, for instance) in a BEFORE COMMIT trigger would delay the +transaction and any locks it holds with no benefit. + +> What happens if there's more than one, and one of them fails? + + Each one in its own transaction ? + +> Even more to the point, if it's a separate transaction, don't you have +> to fire all these triggers again when you commit that transaction? +> The idea seems circular. + + I guess AFTER COMMIT triggers are most useful when coupled to a trigger +on a modification to a table. So, the "before / after commit" could be an +attribute of an AFTER INSERT/UPDATE/DELETE trigger. If the AFTER COMMIT +trigger doesn't do any modifications to the target table, there will be no +infinite loop. + + The before/after commit could also be implemented not via triggers, but +via deferred actions, by telling postgres to execute a specific query just +before/after the transaction commits. This could be used to implement the +triggers, but would also be more generic : a trigger on INSERT could then +defer a call to memcache update once the transaction is commited. It gets +lisp-ish, but it would be really cool? + +From pgsql-performance-owner@postgresql.org Thu Apr 13 17:53:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F405511F6605 + for ; + Thu, 13 Apr 2006 17:52:51 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.127 +X-Spam-Level: +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id SE7IL4jzgx5q + for ; + Thu, 13 Apr 2006 17:52:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 6958A11F6603 + for ; + Thu, 13 Apr 2006 17:52:47 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FU8nt-00050x-00; Thu, 13 Apr 2006 16:52:37 -0400 +To: Tom Lane +Cc: Christian Storm , + "Jim C. Nasby" , + Josh Berkus , pgsql-performance@postgresql.org, + PFC +Subject: Re: pgmemcache +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> + <200604121603.43986.josh@agliodbs.com> + <20060413001024.GP49405@pervasive.com> <6236.1144888514@sss.pgh.pa.us> + <4D23826E-7325-4946-B79A-80E321E0E497@gmail.com> + <26792.1144949880@sss.pgh.pa.us> +In-Reply-To: <26792.1144949880@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 13 Apr 2006 16:52:37 -0400 +Message-ID: <87irpdgpuy.fsf@stark.xeocode.com> +Lines: 28 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Archive-Number: 200604/317 +X-Sequence-Number: 18401 + +Tom Lane writes: + +> Christian Storm writes: +> > Not sure if I follow why this is a problem. Seems like it would be +> > beneficial to have both BEFORE and AFTER COMMIT triggers. +> > With the BEFORE COMMIT trigger you would have the ability to 'un- +> > commit' (rollback) the transaction. With +> > the AFTER COMMIT trigger you wouldn't have that option because the +> > commit has already been successful. However, +> > with an AFTER COMMIT you would be able to trigger other downstream +> > events that rely on a transaction successfully committing. +> +> An AFTER COMMIT trigger would have to be in a separate transaction. +> What happens if there's more than one, and one of them fails? Even +> more to the point, if it's a separate transaction, don't you have +> to fire all these triggers again when you commit that transaction? +> The idea seems circular. + +Maybe it just means they would have to be limited to not making any database +modifications. Ie, all they can do is notify the outside world that the +transaction committed. + +Presumably if you wanted to make any database modifications you would just do +it in the transaction anyways since they wouldn't show up until the +transaction commits. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Apr 13 21:36:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 910D611F6003 + for ; + Thu, 13 Apr 2006 21:36:19 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.418 +X-Spam-Level: +X-Spam-Status: No, score=-2.418 required=5 tests=[AWL=0.183, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 62GuL4S9gOqN + for ; + Thu, 13 Apr 2006 21:36:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 88C5D11F60BF + for ; + Thu, 13 Apr 2006 21:36:11 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3E0aA4i002790; + Thu, 13 Apr 2006 20:36:10 -0400 (EDT) +To: Jim Nasby +cc: Postgresql Performance +Subject: Re: Blocks read for index scans +In-reply-to: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> +References: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> +Comments: In-reply-to Jim Nasby + message dated "Thu, 13 Apr 2006 13:00:07 -0500" +Date: Thu, 13 Apr 2006 20:36:09 -0400 +Message-ID: <2789.1144974969@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/318 +X-Sequence-Number: 18402 + +Jim Nasby writes: +> While working on determining a good stripe size for a database, I +> realized it would be handy to know what the average request size is. +> Getting this info is a simple matter of joining pg_stat_all_tables +> and pg_statio_all_tables and doing some math, but there's one issue +> I've found; it appears that there's no information on how many heap +> blocks were read in by an index scan. Is there any way to get that info? + +If the table is otherwise idle, the change in the table's entry in +pgstatio_all_tables should do, no? + +(This is as of 8.1 ... older versions acted a bit differently IIRC.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 13 21:44:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 89EE011F61D6 + for ; + Thu, 13 Apr 2006 21:44:02 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.126 +X-Spam-Level: +X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id QmvKGMWtsh+N + for ; + Thu, 13 Apr 2006 21:43:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 0234311F61BA + for ; + Thu, 13 Apr 2006 21:43:57 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3E0hsAc002848; + Thu, 13 Apr 2006 20:43:54 -0400 (EDT) +To: PFC +cc: "Christian Storm" , + "Jim C. Nasby" , + "Josh Berkus" , pgsql-performance@postgresql.org +Subject: Re: pgmemcache +In-reply-to: +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> + <200604121603.43986.josh@agliodbs.com> + <20060413001024.GP49405@pervasive.com> + <6236.1144888514@sss.pgh.pa.us> + <4D23826E-7325-4946-B79A-80E321E0E497@gmail.com> + <26792.1144949880@sss.pgh.pa.us> +Comments: In-reply-to PFC + message dated "Thu, 13 Apr 2006 22:23:31 +0200" +Date: Thu, 13 Apr 2006 20:43:54 -0400 +Message-ID: <2847.1144975434@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/319 +X-Sequence-Number: 18403 + +PFC writes: +> I guess AFTER COMMIT triggers would be like a NOTIFY, but more powerful. + +I'll let you in on a secret: NOTIFY is actually a before-commit +operation. This is good enough because it never, or hardly ever, +fails. I would argue that anything you want to do in an AFTER COMMIT +trigger could just as well be done in a BEFORE COMMIT trigger; if that's +not reliable enough then you need to fix your trigger. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 13 22:26:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8473911F6B58 + for ; + Thu, 13 Apr 2006 22:26:36 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id xj9WzMp1Mbzy + for ; + Thu, 13 Apr 2006 22:26:30 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.225]) + by postgresql.org (Postfix) with ESMTP id D2D4711F6ABD + for ; + Thu, 13 Apr 2006 22:26:33 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 71so747062wra + for ; + Thu, 13 Apr 2006 18:26:34 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=g/BmOtldR1mvbaDGv/F8wPEL6YfuvvEvjDEq+zGrUeIKKJXReNI9geE2UoftfdiQfOgO2bAQYeCp5wQe6boguKll4bB9qoXzfcgPh/7FMP50vfpGQrXxwjP3e1Ywnja4VcpYBdT2mRwQw0oTcg2GVAtjEmKB9k68t51cdDMp5nU= +Received: by 10.54.95.15 with SMTP id s15mr1043776wrb; + Thu, 13 Apr 2006 18:26:34 -0700 (PDT) +Received: by 10.54.157.2 with HTTP; Thu, 13 Apr 2006 18:26:00 -0700 (PDT) +Message-ID: <53b425b00604131826s2872bd49id2ac1ab99a5fade4@mail.gmail.com> +Date: Thu, 13 Apr 2006 18:26:00 -0700 +From: "patrick keshishian" +To: "Tom Lane" +Subject: Re: pg 7.4.x - pg_restore impossibly slow +Cc: pgsql-performance@postgresql.org +In-Reply-To: <9585.1144903611@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <53b425b00604121826x213fe2fdmc793e22026469923@mail.gmail.com> + <9585.1144903611@sss.pgh.pa.us> +X-Archive-Number: 200604/320 +X-Sequence-Number: 18404 + +Hi Tom, et.al., + +So I changed the following settings in postgresql.conf file and +restarted PostgreSQL and then proceeded with pg_restore: + +# new changes for this test-run +log_statement =3D true +sort_mem =3D 10240 # default 1024 +vacuum_mem =3D 20480 # default 8192 +# from before +checkpoint_segments =3D 10 +log_pid =3D true +log_timestamp =3D true + +With these settings and running: + +pg_restore -vaOd dbname dbname.DUMP + + +Things seem to progress better. The first of the large +tables got COPY'ed within 1 hr 40 min: + +start: 2006-04-13 11:44:19 +finish: 2006-04-13 13:25:36 + +I ended up ctrl-C'ing out of the pg_restore as the second +large table was taking over 3 hours and the last PostgreSQL +log entry was from over 2.5hrs ago, with message: + +2006-04-13 14:09:29 [3049] LOG: recycled transaction log file +"000000060000006B" + +Time for something different. Before attempting the same +procedure with fsync off, I ran the following sequence of +commands: + +$ dropdb dbname +$ createdb dbname +$ pg_restore -vsOd dbname dbname.DUMP +$ date > db.restore ; pg_restore -vcOd dbname \ + dbname.DUMP ; date >> db.restore +$ cat db.restore +Thu Apr 13 18:02:51 PDT 2006 +Thu Apr 13 18:17:16 PDT 2006 + +That's just over 14 minutes! + +Ideas? + +Is this because the -c option drops all foreign keys and +so the restore goes faster? Should this be the preferred, +recommended and documented method to run pg_restore? +Any drawbacks to this method? + +Thanks, +--patrick + + + + +On 4/12/06, Tom Lane wrote: +> "patrick keshishian" writes: +> > My dev box is much slower hardware than the customer's +> > server. Even with that difference I expected to be able to +> > pg_restore the database within one day. But no. +> +> Seems a bit odd. Can you narrow down more closely which step of the +> restore is taking the time? (Try enabling log_statements.) +> +> One thought is that kicking up work_mem and vacuum_mem is likely to +> help for some steps (esp. CREATE INDEX and foreign-key checking). +> And be sure you've done the usual tuning for write-intensive activity, +> such as bumping up checkpoint_segments. Turning off fsync wouldn't +> be a bad idea either. +> +> regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 14 00:15:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AFE8911F6C4F + for ; + Fri, 14 Apr 2006 00:15:21 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.125 +X-Spam-Level: +X-Spam-Status: No, score=0.125 required=5 tests=[AWL=0.125] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id KmRSv6xTxTai + for ; + Fri, 14 Apr 2006 00:15:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2C94311F6AFA + for ; + Fri, 14 Apr 2006 00:15:18 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3E3FH4s004414; + Thu, 13 Apr 2006 23:15:17 -0400 (EDT) +To: "patrick keshishian" +cc: pgsql-performance@postgresql.org +Subject: Re: pg 7.4.x - pg_restore impossibly slow +In-reply-to: <53b425b00604131826s2872bd49id2ac1ab99a5fade4@mail.gmail.com> +References: <53b425b00604121826x213fe2fdmc793e22026469923@mail.gmail.com> + <9585.1144903611@sss.pgh.pa.us> + <53b425b00604131826s2872bd49id2ac1ab99a5fade4@mail.gmail.com> +Comments: In-reply-to "patrick keshishian" + message dated "Thu, 13 Apr 2006 18:26:00 -0700" +Date: Thu, 13 Apr 2006 23:15:17 -0400 +Message-ID: <4413.1144984517@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/321 +X-Sequence-Number: 18405 + +"patrick keshishian" writes: +> With these settings and running: +> pg_restore -vaOd dbname dbname.DUMP + +If you had mentioned you were using random nondefault switches, we'd +have told you not to. -a in particular is a horrid idea performancewise +--- a standard schema-plus-data restore goes way faster because it's +doing index builds and foreign key checks wholesale instead of +incrementally. + +> Is this because the -c option drops all foreign keys and +> so the restore goes faster? Should this be the preferred, +> recommended and documented method to run pg_restore? + +It is documented in recent versions of the documentation: see +http://www.postgresql.org/docs/8.1/static/populate.html +particularly the last section. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 14 02:59:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5E04D11F6706 + for ; + Fri, 14 Apr 2006 02:59:27 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.398 +X-Spam-Level: +X-Spam-Status: No, score=0.398 required=5 tests=[AWL=0.398] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 4eVNvGf-L3eC + for ; + Fri, 14 Apr 2006 02:59:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id DCD9C11F670A + for ; + Fri, 14 Apr 2006 02:59:24 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 5122A56427; Fri, 14 Apr 2006 00:59:24 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 14 Apr 2006 00:59:23 -0500 +Date: Fri, 14 Apr 2006 00:59:23 -0500 +From: "Jim C. Nasby" +To: Francisco Reyes +Cc: Tom Lane , Chris , + Pgsql performance +Subject: Re: Inserts optimization? +Message-ID: <20060414055923.GX49405@pervasive.com> +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060414:lists@stringsutils.com::MkIZrL4Il3gObikK:000000000000000 + 0000000000000000000000002k/j +X-Hashcash: + 1:20:060414:tgl@sss.pgh.pa.us::zaD2WNEvY9WsUI+M:00000000000000000000 + 0000000000000000000000003JTD +X-Hashcash: + 1:20:060414:dmagick@gmail.com::m8DFdG6unaDIConA:00000000000000000000 + 0000000000000000000000001GxU +X-Hashcash: + 1:20:060414:pgsql-performance@postgresql.org::ng3hNsvMR40nwp43:00000 + 0000000000000000000000001hwt +X-Archive-Number: 200604/322 +X-Sequence-Number: 18406 + +On Thu, Apr 13, 2006 at 02:59:23PM -0400, Francisco Reyes wrote: +> In RAID 10 would it matter that WALL is in the same RAID set? +> Would it be better: +> 4 disks in RAID10 Data +> 2 disks RAID 1 WALL +> 2 hot spares + +Well, benchmark it with your app and find out, but generally speaking +unless your database is mostly read you'll see a pretty big benefit to +seperating WAL from table/index data. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri Apr 14 03:37:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 23B6E11F6CAF + for ; + Fri, 14 Apr 2006 03:37:51 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 6UN3jmr-amIJ + for ; + Fri, 14 Apr 2006 03:37:47 -0300 (ADT) +X-Greylist: delayed 00:25:01.743326 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 8513211F6CBE + for ; + Fri, 14 Apr 2006 03:37:44 -0300 (ADT) +Received: from smtp.elde.net (us.elde.net [66.246.223.215]) + by svr4.postgresql.org (Postfix) with ESMTP id C4BC85AF8A7 + for ; + Fri, 14 Apr 2006 06:12:41 +0000 (GMT) +Received: from smtp.elde.net (343006.ds.nac.net [127.0.0.1]) + by smtp.elde.net (Postfix) with ESMTP id DBC2B65007; + Fri, 14 Apr 2006 08:12:39 +0200 (CEST) +Received: from [127.0.0.1] (60.80-203-96.nextgentel.com [80.203.96.60]) + (Authenticated sender: terje@elde.net) + by smtp.elde.net (Postfix) with ESMTP id 2ACFB64F56; + Fri, 14 Apr 2006 08:12:39 +0200 (CEST) +Message-ID: <443F3BB3.30404@elde.net> +Date: Fri, 14 Apr 2006 08:05:39 +0200 +From: Terje Elde +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Jim Nasby +Cc: pgsql-performance@postgresql.org +Subject: Re: Blocks read for index scans +References: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> +In-Reply-To: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/325 +X-Sequence-Number: 18409 + +Jim Nasby wrote: +> While working on determining a good stripe size for a database, I +> realized it would be handy to know what the average request size is. +> Getting this info is a simple matter of joining pg_stat_all_tables and +> pg_statio_all_tables and doing some math, but there's one issue I've +> found; it appears that there's no information on how many heap blocks +> were read in by an index scan. Is there any way to get that info? + +RAID usually doesn't work the way most people think. ;) + +Not sure how well you know RAID, so I'm just mentioning some points just +in case, and for the archives. + +If your average request is for 16K, and you choose a 16K stripe size, +then that means half your request (assuming normal bell curve) would be +larger than a single stripe, and you've just succeeded in having half +your requests have to have two spindles seek instead of one. If that's +done sequentially, you're set for less than half the performance of a +flat disk. + +Knowing what the average stripe size is can be a good place to start, +but the real question is; which stripe size will allow the majority of +your transactions to be possible to satisfy without having to go to two +spindles? + +I've actually had good success with 2MB stripe sizes using software +raid. If the reads are fairly well distributed, all the drives are hit +equally, and very few small requests have to go to two spindles. + +Read speeds from modern drives are fast. It's usually the seeks that +kill performance, so making sure you reduce the number of seeks should +almost always be the priority. + +That said, it's the transactions against disk that typically matter. On +FreeBSD, you can get an impression of this using 'systat -vmstat', and +watch the KB/t column for your drives. + +A seek will take some time, the head has to settle down, find the right +place to start reading etc, so a seek will always take time. A seek +over a longer distance takes more time though, so even if your +transactions are pretty small, using a large stripe size can be a good +thing if your have lots of small transactions that are close by. The +head will be in the area, reducing seek time. + +This all depends on what types of load you have, and it's hard to +generalize too much on what makes things fast. As always, it pretty +much boils down to trying things while running as close to production +load as you can. + +Terje + + + +From pgsql-performance-owner@postgresql.org Fri Apr 14 03:14:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ECFE311F6C82 + for ; + Fri, 14 Apr 2006 03:14:21 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.388 +X-Spam-Level: +X-Spam-Status: No, score=0.388 required=5 tests=[AWL=0.388] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ISi+vI4yrBPW + for ; + Fri, 14 Apr 2006 03:14:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 0CC8F11F6C7C + for ; + Fri, 14 Apr 2006 03:14:18 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 4D3FB56423; Fri, 14 Apr 2006 01:14:16 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 14 Apr 2006 01:14:14 -0500 +Date: Fri, 14 Apr 2006 01:14:14 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Postgresql Performance +Subject: Re: Blocks read for index scans +Message-ID: <20060414061414.GY49405@pervasive.com> +References: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> + <2789.1144974969@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <2789.1144974969@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060414:tgl@sss.pgh.pa.us::drmyBQfMNsGyjaPL:00000000000000000000 + 000000000000000000000000AP83 +X-Hashcash: + 1:20:060414:pgsql-performance@postgresql.org::eXHIb5jJR8mAhwuL:00000 + 0000000000000000000000008IFg +X-Archive-Number: 200604/323 +X-Sequence-Number: 18407 + +On Thu, Apr 13, 2006 at 08:36:09PM -0400, Tom Lane wrote: +> Jim Nasby writes: +> > While working on determining a good stripe size for a database, I +> > realized it would be handy to know what the average request size is. +> > Getting this info is a simple matter of joining pg_stat_all_tables +> > and pg_statio_all_tables and doing some math, but there's one issue +> > I've found; it appears that there's no information on how many heap +> > blocks were read in by an index scan. Is there any way to get that info? +> +> If the table is otherwise idle, the change in the table's entry in +> pgstatio_all_tables should do, no? + +Ahh, ok, I see the heap blocks are counted. So I guess if you wanted to +know what the average number of blocks read from the heap per request +was you'd have to do heap_blks_read / ( seq_scan + idx_scan ), with the +last two comming from pg_stat_all_tables. + +In my case it would be helpful to break the heap access numbers out +between seqscans and index scans, since each of those represents very +different access patterns. Would adding that be a mess? + +> (This is as of 8.1 ... older versions acted a bit differently IIRC.) + +Yeah; I recall that it was pretty confusing exactly how things were +broken out and that you changed it as part of the bitmap scan work. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri Apr 14 03:20:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1CB3711F6C71 + for ; + Fri, 14 Apr 2006 03:20:16 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.38 +X-Spam-Level: +X-Spam-Status: No, score=0.38 required=5 tests=[AWL=0.380] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id sHMnGVOeE5ya + for ; + Fri, 14 Apr 2006 03:20:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 61AED11F6C76 + for ; + Fri, 14 Apr 2006 03:20:13 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id B6BC156423; Fri, 14 Apr 2006 01:20:12 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 14 Apr 2006 01:20:11 -0500 +Date: Fri, 14 Apr 2006 01:20:11 -0500 +From: "Jim C. Nasby" +To: patrick keshishian +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: pg 7.4.x - pg_restore impossibly slow +Message-ID: <20060414062010.GZ49405@pervasive.com> +References: <53b425b00604121826x213fe2fdmc793e22026469923@mail.gmail.com> + <9585.1144903611@sss.pgh.pa.us> + <53b425b00604131826s2872bd49id2ac1ab99a5fade4@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <53b425b00604131826s2872bd49id2ac1ab99a5fade4@mail.gmail.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060414:pkeshish@gmail.com::C4aHmPQL6UYmRnyr:0000000000000000000 + 00000000000000000000000006zm +X-Hashcash: + 1:20:060414:tgl@sss.pgh.pa.us::Za5qgIYFTT+XqD3e:00000000000000000000 + 0000000000000000000000002pu+ +X-Hashcash: + 1:20:060414:pgsql-performance@postgresql.org::EC8FYR0VTFw/nY2b:00000 + 000000000000000000000000HPgF +X-Archive-Number: 200604/324 +X-Sequence-Number: 18408 + +On Thu, Apr 13, 2006 at 06:26:00PM -0700, patrick keshishian wrote: +> $ dropdb dbname +> $ createdb dbname +> $ pg_restore -vsOd dbname dbname.DUMP + +That step is pointless, because the next pg_restore will create the +schema for you anyway. + +> $ date > db.restore ; pg_restore -vcOd dbname \ +> dbname.DUMP ; date >> db.restore +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri Apr 14 04:01:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1068611F62F8 + for ; + Fri, 14 Apr 2006 04:01:02 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.08 +X-Spam-Level: +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id tKw1iC8LCUpa + for ; + Fri, 14 Apr 2006 04:00:57 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.237]) + by postgresql.org (Postfix) with ESMTP id C9E4711F6CB7 + for ; + Fri, 14 Apr 2006 04:00:58 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 71so4535wra + for ; + Fri, 14 Apr 2006 00:00:56 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=g6LS3WGj58LJ/pyk6eGtkLS5rQeKDslBWa5JCkNQKmDU8KbjDjTmA4zZapJTIIssTkeRK5ulsppnJIDN5m3yu0Nv1HHcSISOKSpAp0arSRUD++r2h5vxl1heEDlkNhpH94Kyq4TTqwvqJnDoWv1PuNg1TnOA12nCWKLsCiQeQpY= +Received: by 10.54.139.4 with SMTP id m4mr1230295wrd; + Fri, 14 Apr 2006 00:00:55 -0700 (PDT) +Received: by 10.54.157.2 with HTTP; Thu, 13 Apr 2006 23:59:51 -0700 (PDT) +Message-ID: <53b425b00604132359w45019bfs276916d9e5d1b8d6@mail.gmail.com> +Date: Thu, 13 Apr 2006 23:59:51 -0700 +From: "patrick keshishian" +To: "Tom Lane" +Subject: Re: pg 7.4.x - pg_restore impossibly slow +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4413.1144984517@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <53b425b00604121826x213fe2fdmc793e22026469923@mail.gmail.com> + <9585.1144903611@sss.pgh.pa.us> + <53b425b00604131826s2872bd49id2ac1ab99a5fade4@mail.gmail.com> + <4413.1144984517@sss.pgh.pa.us> +X-Archive-Number: 200604/326 +X-Sequence-Number: 18410 + +On 4/13/06, Tom Lane wrote: +> "patrick keshishian" writes: +> > With these settings and running: +> > pg_restore -vaOd dbname dbname.DUMP +> +> If you had mentioned you were using random nondefault switches, we'd + +Random? + +With all due respect, I did. + +I specified the PostgreSQL version of the pg_dump source +server. I specified the version of my dev PostgreSQL server. + +I provided specific information about which postgresql.conf +entries I had changed and to what specific values they were +changed to. + +I pasted the _exact_ command used (including so called +"random nondefault switches") to do the dump and the +exact command used (again, with said "random nondefault +switches") to restore from the dump'ed data. + +I believe I tried my best to be as thorough as possible with +my post(s). + +archived at: http://archives.postgresql.org/pgsql-performance/2006-04/msg00= +287.php + + + +> have told you not to. -a in particular is a horrid idea performancewise +> --- a standard schema-plus-data restore goes way faster because it's +> doing index builds and foreign key checks wholesale instead of +> incrementally. + +Duly noted. Option "-a" bad. + + +> > Is this because the -c option drops all foreign keys and +> > so the restore goes faster? Should this be the preferred, +> > recommended and documented method to run pg_restore? +> +> It is documented in recent versions of the documentation: see +> http://www.postgresql.org/docs/8.1/static/populate.html +> particularly the last section. + +As a general rule of thumb, I have always assumed, +documentation for any software, from one major version +to another, would not necessarily apply cross revisions +(e.g., version 7.4 vs 8.1). + + +But thanks for your time and help, +--patrick + +From pgsql-performance-owner@postgresql.org Fri Apr 14 04:11:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5DAC711F6D4E + for ; + Fri, 14 Apr 2006 04:11:20 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.096 +X-Spam-Level: +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id jWjn5HII8JSq + for ; + Fri, 14 Apr 2006 04:11:12 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.234]) + by postgresql.org (Postfix) with ESMTP id 9367A11F6D35 + for ; + Fri, 14 Apr 2006 04:11:08 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id 71so4909wra + for ; + Fri, 14 Apr 2006 00:11:08 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=LxE4bWa3C1PoY3utu/39VqwZq3okv/X80oi3hC1BZHrku2I7C2MbFNeoA/ROoZb+uQ/6mOlJepyVGq6K9Ih7/k7WVYFIVuAe+fB7hqhAQvHp7J0Y+3uQgKbYHoeB1BNeoPNW73VgEVl0S2+N8gT5pFhiZZ6SkPddJ/xousbf7iQ= +Received: by 10.54.97.20 with SMTP id u20mr1211040wrb; + Fri, 14 Apr 2006 00:11:08 -0700 (PDT) +Received: by 10.54.157.2 with HTTP; Fri, 14 Apr 2006 00:10:57 -0700 (PDT) +Message-ID: <53b425b00604140010v718aa171p19d9253ce58d0006@mail.gmail.com> +Date: Fri, 14 Apr 2006 00:10:57 -0700 +From: "patrick keshishian" +To: "Jim C. Nasby" +Subject: Re: pg 7.4.x - pg_restore impossibly slow +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060414062010.GZ49405@pervasive.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <53b425b00604121826x213fe2fdmc793e22026469923@mail.gmail.com> + <9585.1144903611@sss.pgh.pa.us> + <53b425b00604131826s2872bd49id2ac1ab99a5fade4@mail.gmail.com> + <20060414062010.GZ49405@pervasive.com> +X-Archive-Number: 200604/327 +X-Sequence-Number: 18411 + +On 4/13/06, Jim C. Nasby wrote: +> On Thu, Apr 13, 2006 at 06:26:00PM -0700, patrick keshishian wrote: +> > $ dropdb dbname +> > $ createdb dbname +> > $ pg_restore -vsOd dbname dbname.DUMP +> +> That step is pointless, because the next pg_restore will create the +> schema for you anyway. + +Yes, I noticed this with the verbose output (random +non-standard option "-v"). + +I was providing all information (read: exact steps taken) +which may have been relevant to my post/question, so +that, I would avoid being guilty of omitting any possibly +significant, yet random information. + +Thanks for the insight, +--patrick + +From pgsql-performance-owner@postgresql.org Fri Apr 14 08:30:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 9EED411F6F8E + for ; + Fri, 14 Apr 2006 08:30:46 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.352 +X-Spam-Level: * +X-Spam-Status: No, score=1.352 required=5 tests=[BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_HELO_SOFTFAIL=2.432, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id R6gq1oTo8xHG + for ; + Fri, 14 Apr 2006 08:30:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 499FF11F66FD + for ; + Fri, 14 Apr 2006 08:30:26 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id 40E2FB81F; + Fri, 14 Apr 2006 07:30:26 -0400 (EDT) +Received: from zoraida.natserv.net (zoraida.natserv.net [66.114.65.147]) + by zoraida.natserv.net (Postfix) with ESMTP id E8BDFB81D; + Fri, 14 Apr 2006 07:30:25 -0400 (EDT) +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Jim =?ISO-8859-1?B?Qy4=?= Nasby +Cc: Chris , + Pgsql performance +Subject: Re: Inserts optimization? +Date: Fri, 14 Apr 2006 07:30:25 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/328 +X-Sequence-Number: 18412 + +Jim C. Nasby writes: + +> On Thu, Apr 13, 2006 at 02:59:23PM -0400, Francisco Reyes wrote: +>> In RAID 10 would it matter that WALL is in the same RAID set? +>> Would it be better: +>> 4 disks in RAID10 Data +>> 2 disks RAID 1 WALL +>> 2 hot spares +> +> Well, benchmark it with your app and find out, but generally speaking +> unless your database is mostly read you'll see a pretty big benefit to +> seperating WAL from table/index data. + +That will not be easy to compare.. it would mean setting up the machine.. +trashing it.. then redoing the whole setup.. + +I am leaning towards using pgbench against the current machine to see what +parameters affect inserts.. perhaps also doing dome tests with just inserts +from a file. Then using the same setups on the next machine and just go with +RAID10 on the 6 disks. Split the raid into 10 may give me space issues to +deal with. + +Will also find out if the app, Bacula, batches transactions or not. + +From pgsql-performance-owner@postgresql.org Fri Apr 14 08:49:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 9686111F6797 + for ; + Fri, 14 Apr 2006 08:49:45 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.217 +X-Spam-Level: * +X-Spam-Status: No, score=1.217 required=5 tests=[BAYES_00=-2.599, + SPF_HELO_SOFTFAIL=2.432, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 2v8srakVz89a + for ; + Fri, 14 Apr 2006 08:49:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by postgresql.org (Postfix) with ESMTP id 69B0711F6899 + for ; + Fri, 14 Apr 2006 08:49:21 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IXP00AT1NI5WFY3@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Fri, 14 Apr 2006 06:49:18 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 39B696E8D7 for + ; + Fri, 14 Apr 2006 07:49:16 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 32330-02 for ; Fri, + 14 Apr 2006 07:49:15 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 256DD6EACD; Fri, 14 Apr 2006 07:49:15 -0400 (EDT) +Date: Fri, 14 Apr 2006 07:49:14 -0400 +From: Michael Stone +Subject: Re: Inserts optimization? +In-reply-to: +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060414114911.GG32678@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + +User-Agent: Mutt/1.5.11+cvs20060126 +X-Archive-Number: 200604/329 +X-Sequence-Number: 18413 + +>On Thu, Apr 13, 2006 at 02:59:23PM -0400, Francisco Reyes wrote: +>>In RAID 10 would it matter that WALL is in the same RAID set? +>>Would it be better: +>>4 disks in RAID10 Data +>>2 disks RAID 1 WALL +>>2 hot spares + +I guess the first question is why 2 hot spares? You don't have many +spindles, so you don't want to waste them. It might turn out that a +larger array with more spindles with outperform a smaller one with +fewer, regardless of RAID level (assuming a decent battery-backed +cache). You might try +5 RAID5 +2 RAID1 +1 spare + +Mike Stone + +From pgsql-performance-owner@postgresql.org Fri Apr 14 09:00:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 8008511F6212 + for ; + Fri, 14 Apr 2006 09:00:58 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.217 +X-Spam-Level: * +X-Spam-Status: No, score=1.217 required=5 tests=[BAYES_00=-2.599, + SPF_HELO_SOFTFAIL=2.432, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 5VQGlwJUT-jQ + for ; + Fri, 14 Apr 2006 09:00:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mercure.sigma.fr (mercure.sigma.fr [195.25.81.9]) + by postgresql.org (Postfix) with ESMTP id 8140F11F68DD + for ; + Fri, 14 Apr 2006 09:00:40 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mercure.sigma.fr (Postfix) with ESMTP id 70D0C1649F; + Fri, 14 Apr 2006 14:00:39 +0200 (CEST) +Received: from mercure.sigma.fr ([127.0.0.1]) + by localhost (mercure-1 [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 09341-01; Fri, 14 Apr 2006 14:00:39 +0200 (CEST) +Received: from marc.sigma.fr (marc [89.195.0.5]) + by mercure.sigma.fr (Postfix) with ESMTP id 41D90163DE; + Fri, 14 Apr 2006 14:00:39 +0200 (CEST) +From: Marc Cousin +Organization: Sigma Informatique +To: "Francisco Reyes" +Subject: Re: Inserts optimization? +Date: Fri, 14 Apr 2006 14:00:38 +0200 +User-Agent: KMail/1.9.1 +Cc: "Chris" , + "Pgsql performance" +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604141400.38982.mcousin@sigma.fr> +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at sigma.fr +X-Archive-Number: 200604/330 +X-Sequence-Number: 18414 + +I hope I'm not going to say stupid things, but here's what i know (or i think +i know :) ) about bacula + postgresql + +If I remember correctly (I allready discussed this with Kern Sibbald a while +ago), bacula does each insert in its own transaction : that's how the program +is done, and of course it works ok with mysql and MyIsam tables, as mysql +doesn't have transactions with myisam... + +So, you'll probably end up being slowed down by WAL fsyncs ... and you won't +have a lot of solutions. Maybe you should start with trying to set fsync=no +as a test to confirm that (you should have a lot of iowaits right now if you +haven't disabled fsync). + +For now, I only could get good performance with bacula and postgresql when +disabling fsync... + + +On Thursday 13 April 2006 20:45, Francisco Reyes wrote: +> Chris writes: +> > If you can, use copy instead: +> > http://www.postgresql.org/docs/8.1/interactive/sql-copy.html +> +> I am familiar with copy. +> Can't use it in this scenario. +> +> The data is coming from a program called Bacula (Backup server). +> It is not static data. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster + +From pgsql-performance-owner@postgresql.org Fri Apr 14 10:34:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 48B7011F61C2 + for ; + Fri, 14 Apr 2006 10:34:41 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.386 +X-Spam-Level: * +X-Spam-Status: No, score=1.386 required=5 tests=[BAYES_50=0.001, + HTML_MESSAGE=0.001, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id OHdgCtW6DIHq + for ; + Fri, 14 Apr 2006 10:34:25 -0300 (ADT) +X-Greylist: delayed 00:19:15.843752 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id CA82711F61E3 + for ; + Fri, 14 Apr 2006 10:34:22 -0300 (ADT) +Received: from ankama.com (unknown [193.238.151.58]) + by svr4.postgresql.org (Postfix) with ESMTP id 586BF5AF93C + for ; + Fri, 14 Apr 2006 13:15:07 +0000 (GMT) +Received: from rogers (rsa59-2-82-233-195-195.fbx.proxad.net [82.233.195.195]) + by ankama.com (ankama.com) (MDaemon.PRO.v7.2.3.R) + with ESMTP id md50000792057.msg + for ; Fri, 14 Apr 2006 15:31:44 +0200 +Message-ID: <000c01c65fc5$41c78a70$0700a8c0@ankama.lan> +From: "Julien Drouard" +To: +Subject: pg_toast size +Date: Fri, 14 Apr 2006 15:13:43 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0009_01C65FD6.04E78680" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Spam-Processed: ankama.com, Fri, 14 Apr 2006 15:31:44 +0200 + (not processed: message from valid local sender) +X-MDRemoteIP: 82.233.195.195 +X-Return-Path: jdrouard@ankama.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-Archive-Number: 200604/331 +X-Sequence-Number: 18415 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0009_01C65FD6.04E78680 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi everyone, + +I've seen my pg_toast tables are becoming bigger and bigger. After = +googling I would like to modify my max_fsm_pages parameter to prevent = +that kind of problem. So I'm wondering if changing this parameter is = +enough and after that how can I reduce the size of these tables? By = +doing a full vacuum? + +Thanks in advance, + +Julien +------=_NextPart_000_0009_01C65FD6.04E78680 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi everyone,
+
 
+
I've seen my pg_toast tables are = +becoming bigger=20 +and bigger. After googling I would like to modify my max_fsm_pages = +parameter to=20 +prevent that kind of problem. So I'm wondering if changing this = +parameter is=20 +enough and after that how can I reduce the size of these tables? By = +doing a full=20 +vacuum?
+
 
+
Thanks in advance,
+
 
+
Julien
+ +------=_NextPart_000_0009_01C65FD6.04E78680-- + + + +From pgsql-performance-owner@postgresql.org Fri Apr 14 11:02:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 96E1111F61C6 + for ; + Fri, 14 Apr 2006 11:02:26 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.121 +X-Spam-Level: +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + UNPARSEABLE_RELAY=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id e36zwIGCcfvI + for ; + Fri, 14 Apr 2006 11:02:14 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34]) + by postgresql.org (Postfix) with ESMTP id 4BF1511F61E6 + for ; + Fri, 14 Apr 2006 11:02:11 -0300 (ADT) +Received: from fe-amer-02.sun.com ([192.18.108.176]) + by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id k3EE2CJO025338 + for ; + Fri, 14 Apr 2006 08:02:12 -0600 (MDT) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IXP00301SUQLC00@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Fri, 14 Apr 2006 08:02:12 -0600 (MDT) +Received: from [129.148.9.81] by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + with ESMTPSA id <0IXP00A41TNM9WM5@mail-amer.sun.com>; Fri, + 14 Apr 2006 08:02:12 -0600 (MDT) +Date: Fri, 14 Apr 2006 10:02:10 -0400 +From: "Jignesh K. Shah" +Subject: Re: bad performance on Solaris 10 +In-reply-to: <200604130839.k3D8dZQ26118@candle.pha.pa.us> +To: Bruce Momjian +Cc: Luke Lonergan , + Alvaro Herrera , + Chris Mair , pgsql-performance@postgresql.org, + markir@paradise.net.nz, Josh Berkus +Message-id: <443FAB62.7010307@sun.com> +Organization: Sun Microsystems +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: <200604130839.k3D8dZQ26118@candle.pha.pa.us> +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) +X-Archive-Number: 200604/332 +X-Sequence-Number: 18416 + +Hi Bruce, + + +I saw even on this alias also that people assumed that the default +wal_sync_method was fsync on Solaris. + +I would select fsync or fdsync as the default on Solaris. (I prefer +fsync as it is already highlighted as default in postgresql) + +Another thing to improve the defaults on Solaris will be to increase the +defaults of +wal_buffers +and +checkpoint_segments + +(I think in 8.1 checkpoint_segments have been already improved to a +default of 8 from the previous 3 and that may be already some help in +performance out there. ) + +These three changes improve out-of-box performance of PostgreSQL quite a +bit on Solaris (SPARC as well as x64 platforms). + +Then you will suddenly see decrease in the number of people PostgreSQL +community complaining about Solaris 10, as well as Solaris community +complaining about PostgreSQL. (The benefits are mutual) + +Don't get me wrong. As Luke mentioned it took a while to get the +potential of PostgreSQL on Solaris and people like me start doing other +complex workarounds in Solaris like "forcedirectio", etc. (Yeah I did a +test, if you force fsync as wal_sync_method while on Solaris, then +you may not even require to do forcedirectio of your $PGDATA/pg_xlogs to +get back the lost performance) + +If we had realized that fsync/odatasync difference was the culprit we +could have saved couple of months of efforts. + +Yes I agree that putting OS specific things in PostgreSQL hurts +community and sticking to POSIX standards help. + +Just my two cents. + +Regards, +Jignesh + + +Bruce Momjian wrote: + +>Jignesh K. Shah wrote: +> +> +>>Bruce, +>> +>>Hard to answer that... People like me who know and love PostgreSQL and +>>Solaris finds this as an opportunity to make their favorite database +>>work best on their favorite operating system. +>> +>>Many times PostgreSQL has many things based on assumption that it will +>>run on Linux and it is left to Solaris to emulate that behavior.That +>>said there are ways to improve performance even on UFS on Solaris, it +>>just requires more tweaks. +>> +>>Hopefully this will lead to few Solaris friendly default values like +>>fsync/odatasync :-) +>> +>> +> +>Yes, if someone wants to give us a clear answer on which wal_sync method +>is best on all versions of Solaris, we can easily make that change. +> +> +> + +From pgsql-performance-owner@postgresql.org Fri Apr 14 12:13:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 7DD6D11F6D56 + for ; + Fri, 14 Apr 2006 12:13:17 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.482 +X-Spam-Level: +X-Spam-Status: No, score=-0.482 required=5 tests=[AWL=-1.699, BAYES_00=-2.599, + SPF_HELO_SOFTFAIL=2.432, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 182YOHroMElT + for ; + Fri, 14 Apr 2006 12:12:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 3214E11F623A + for ; + Fri, 14 Apr 2006 12:12:56 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3EFCt6V009370; + Fri, 14 Apr 2006 11:12:55 -0400 (EDT) +To: "Jim C. Nasby" +cc: Postgresql Performance +Subject: Re: Blocks read for index scans +In-reply-to: <20060414061414.GY49405@pervasive.com> +References: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> + <2789.1144974969@sss.pgh.pa.us> + <20060414061414.GY49405@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Fri, 14 Apr 2006 01:14:14 -0500" +Date: Fri, 14 Apr 2006 11:12:55 -0400 +Message-ID: <9369.1145027575@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/333 +X-Sequence-Number: 18417 + +"Jim C. Nasby" writes: +> In my case it would be helpful to break the heap access numbers out +> between seqscans and index scans, since each of those represents very +> different access patterns. Would adding that be a mess? + +Yes; it'd require more counters-per-table than we now keep, thus +nontrivial bloat in the stats collector's tables. Not to mention +incompatible changes in the pgstats views and the underlying functions +(which some apps probably use directly). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 14 13:04:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id E78F111F6C47 + for ; + Fri, 14 Apr 2006 13:04:44 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -1.215 +X-Spam-Level: +X-Spam-Status: No, score=-1.215 required=5 tests=[BAYES_00=-2.599, + SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id t+ekWY+CJ4xf + for ; + Fri, 14 Apr 2006 13:04:30 -0300 (ADT) +X-Greylist: delayed 00:27:27.563451 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 8838911F6CA2 + for ; + Fri, 14 Apr 2006 13:04:24 -0300 (ADT) +Received: from mailhost.intellivid.com (mailhost.intellivid.com + [64.32.200.11]) + by svr4.postgresql.org (Postfix) with ESMTP id 8EA395AF0A1 + for ; + Fri, 14 Apr 2006 15:36:54 +0000 (GMT) +Received: from spectre.intellivid.com (spectre.intellivid.com [192.168.2.68]) + (using TLSv1 with cipher RC4-MD5 (128/128 bits)) + (Client did not present a certificate) + by newmail.intellivid.com (Postfix) with ESMTP id 435C6F1814F + for ; + Fri, 14 Apr 2006 11:36:49 -0400 (EDT) +Subject: merge>hash>loop +From: Ian Westmacott +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: IntelliVid Corp. +Date: Fri, 14 Apr 2006 11:36:48 -0400 +Message-Id: <1145029009.3422.31.camel@spectre.intellivid.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/334 +X-Sequence-Number: 18418 + +I have this query, where PG (8.1.2) prefers Merge Join over Hash Join +over Nested Loop. However, this order turns out to increase in +performance. I was hoping someone might be able to shed some light on +why PG chooses the plans in this order, and what I might do to +influence it otherwise. Thanks, + +itvtrackdata=> explain analyze SELECT mva,blob.* FROM +blobs00000000000033c3_c16010 AS blob NATURAL JOIN +objects00000000000033c3 WHERE +AREA(BOX(POINT(bbox_x1,bbox_y0),POINT(bbox_x0,bbox_y1))#BOX('(50,10),(10,50)'))/AREA(BOX(POINT(bbox_x1,bbox_y0),POINT(bbox_x0,bbox_y1)))>0 AND time>=1263627787-32768 AND time<1273458187 AND finish-start>=8738 ORDER BY time ASC; + +QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=47170.44..47184.46 rows=5607 width=28) (actual +time=2661.980..2663.642 rows=1687 loops=1) + Sort Key: blob."time" + -> Merge Join (cost=46547.88..46821.32 rows=5607 width=28) (actual +time=2645.685..2657.621 rows=1687 loops=1) + Merge Cond: ("outer".sva = "inner".sva) + -> Sort (cost=18003.31..18045.36 rows=16821 width=20) (actual +time=181.303..183.092 rows=1741 loops=1) + Sort Key: blob.sva + -> Bitmap Heap Scan on blobs00000000000033c3_c16010 blob +(cost=535.77..16822.65 rows=16821 width=20) (actual time=10.827..177.671 +rows=1741 loops=1) + Recheck Cond: (("time" >= 1263595019) AND ("time" < +1273458187)) + Filter: ((area((box(point((bbox_x1)::double +precision, (bbox_y0)::double precision), point((bbox_x0)::double +precision, (bbox_y1)::double precision)) # '(50,50),(10,10)'::box)) / +area(box(point((bbox_x1)::double precision, (bbox_y0)::double +precision), point((bbox_x0)::double precision, (bbox_y1)::double +precision)))) > 0::double precision) + -> Bitmap Index Scan on +idx_blobs00000000000033c3_c16010_time (cost=0.00..535.77 rows=50462 +width=0) (actual time=8.565..8.565 rows=50673 loops=1) + Index Cond: (("time" >= 1263595019) AND +("time" < 1273458187)) + -> Sort (cost=28544.56..28950.88 rows=162526 width=16) +(actual time=2387.726..2437.429 rows=29969 loops=1) + Sort Key: objects00000000000033c3.sva + -> Seq Scan on objects00000000000033c3 +(cost=0.00..14477.68 rows=162526 width=16) (actual time=0.085..826.125 +rows=207755 loops=1) + Filter: ((finish - "start") >= 8738) + Total runtime: 2675.037 ms +(16 rows) + +itvtrackdata=> set enable_mergejoin to false; +SET +itvtrackdata=> explain analyze SELECT mva,blob.* FROM +blobs00000000000033c3_c16010 AS blob NATURAL JOIN +objects00000000000033c3 WHERE +AREA(BOX(POINT(bbox_x1,bbox_y0),POINT(bbox_x0,bbox_y1))#BOX('(50,10),(10,50)'))/AREA(BOX(POINT(bbox_x1,bbox_y0),POINT(bbox_x0,bbox_y1)))>0 AND time>=1263627787-32768 AND time<1273458187 AND finish-start>=8738 ORDER BY time ASC; + +QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=65783.09..65797.10 rows=5607 width=28) (actual +time=1211.228..1212.671 rows=1687 loops=1) + Sort Key: blob."time" + -> Hash Join (cost=15419.77..65433.97 rows=5607 width=28) (actual +time=1067.514..1207.727 rows=1687 loops=1) + Hash Cond: ("outer".sva = "inner".sva) + -> Bitmap Heap Scan on blobs00000000000033c3_c16010 blob +(cost=535.77..16822.65 rows=16821 width=20) (actual time=14.720..149.179 +rows=1741 loops=1) + Recheck Cond: (("time" >= 1263595019) AND ("time" < +1273458187)) + Filter: ((area((box(point((bbox_x1)::double precision, +(bbox_y0)::double precision), point((bbox_x0)::double precision, +(bbox_y1)::double precision)) # '(50,50),(10,10)'::box)) / +area(box(point((bbox_x1)::double precision, (bbox_y0)::double +precision), point((bbox_x0)::double precision, (bbox_y1)::double +precision)))) > 0::double precision) + -> Bitmap Index Scan on +idx_blobs00000000000033c3_c16010_time (cost=0.00..535.77 rows=50462 +width=0) (actual time=12.880..12.880 rows=50673 loops=1) + Index Cond: (("time" >= 1263595019) AND ("time" < +1273458187)) + -> Hash (cost=14477.68..14477.68 rows=162526 width=16) +(actual time=1052.729..1052.729 rows=207755 loops=1) + -> Seq Scan on objects00000000000033c3 +(cost=0.00..14477.68 rows=162526 width=16) (actual time=0.028..684.047 +rows=207755 loops=1) + Filter: ((finish - "start") >= 8738) + Total runtime: 1217.938 ms +(13 rows) + +itvtrackdata=> set enable_hashjoin to false; +SET +itvtrackdata=> explain analyze SELECT mva,blob.* FROM +blobs00000000000033c3_c16010 AS blob NATURAL JOIN +objects00000000000033c3 WHERE +AREA(BOX(POINT(bbox_x1,bbox_y0),POINT(bbox_x0,bbox_y1))#BOX('(50,10),(10,50)'))/AREA(BOX(POINT(bbox_x1,bbox_y0),POINT(bbox_x0,bbox_y1)))>0 AND time>=1263627787-32768 AND time<1273458187 AND finish-start>=8738 ORDER BY time ASC; + +QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=118258.49..118272.51 rows=5607 width=28) (actual +time=197.204..198.871 rows=1687 loops=1) + Sort Key: blob."time" + -> Nested Loop (cost=535.77..117909.37 rows=5607 width=28) (actual +time=27.560..192.526 rows=1687 loops=1) + -> Bitmap Heap Scan on blobs00000000000033c3_c16010 blob +(cost=535.77..16822.65 rows=16821 width=20) (actual time=27.450..157.266 +rows=1741 loops=1) + Recheck Cond: (("time" >= 1263595019) AND ("time" < +1273458187)) + Filter: ((area((box(point((bbox_x1)::double precision, +(bbox_y0)::double precision), point((bbox_x0)::double precision, +(bbox_y1)::double precision)) # '(50,50),(10,10)'::box)) / +area(box(point((bbox_x1)::double precision, (bbox_y0)::double +precision), point((bbox_x0)::double precision, (bbox_y1)::double +precision)))) > 0::double precision) + -> Bitmap Index Scan on +idx_blobs00000000000033c3_c16010_time (cost=0.00..535.77 rows=50462 +width=0) (actual time=24.445..24.445 rows=50673 loops=1) + Index Cond: (("time" >= 1263595019) AND ("time" < +1273458187)) + -> Index Scan using idx_objects00000000000033c3_sva on +objects00000000000033c3 (cost=0.00..6.00 rows=1 width=16) (actual +time=0.013..0.015 rows=1 loops=1741) + Index Cond: ("outer".sva = objects00000000000033c3.sva) + Filter: ((finish - "start") >= 8738) + Total runtime: 200.719 ms +(12 rows) + +-- +Ian Westmacott +IntelliVid Corp. + + +From pgsql-performance-owner@postgresql.org Fri Apr 14 13:10:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 59F7E11F60AE + for ; + Fri, 14 Apr 2006 13:10:17 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.239 +X-Spam-Level: +X-Spam-Status: No, score=0.239 required=5 tests=[AWL=0.239] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id kn56yTqhSxEy + for ; + Fri, 14 Apr 2006 13:10:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 7634811F6CA2 + for ; + Fri, 14 Apr 2006 13:10:13 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id 8B160B81F; + Fri, 14 Apr 2006 12:10:12 -0400 (EDT) +Received: from zoraida.natserv.net (zoraida.natserv.net [66.114.65.147]) + by zoraida.natserv.net (Postfix) with ESMTP id 59BAAB81D; + Fri, 14 Apr 2006 12:10:12 -0400 (EDT) +References: + <200604141400.38982.mcousin@sigma.fr> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Marc Cousin +Cc: Chris , + Pgsql performance +Subject: Re: Inserts optimization? +Date: Fri, 14 Apr 2006 12:10:12 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/335 +X-Sequence-Number: 18419 + +Marc Cousin writes: + +> If I remember correctly (I allready discussed this with Kern Sibbald a while +> ago), bacula does each insert in its own transaction : that's how the program +> is done + +Thanks for the info. + +> For now, I only could get good performance with bacula and postgresql when +> disabling fsync... + + +Isn't that less safe? +I think I am going to try increasing wal_buffers +Specially was reading http://www.powerpostgresql.com. Towards the middle it +mentions improvements when increasing wal_buffers. So far performance, +against a single client was fair. + +How did you test your bacula setup with postgresql for time? +Doing full backups with lots of files? + + +Also planning to check commit_delay and see if that helps. +I will try to avoid 2 or more machines backing up at the same time.. plus in +a couple of weeks I should have a better machine for the DB anyways.. + + +The description of commit_delay sure sounds very promissing: + +--- +commit_delay (integer) + +Time delay between writing a commit record to the WAL buffer and flushing +the buffer out to disk, in microseconds. A nonzero delay can allow multiple +transactions to be committed with only one fsync() system call, if system +load is high enough that additional transactions become ready to commit +within the given interval. But the delay is just wasted if no other +transactions become ready to commit. Therefore, the delay is only performed +if at least commit_siblings other transactions are active at the instant +that a server process has written its commit record. The default is zero (no +delay). +--- + +I only wonder what is safer.. using a second or two in commit_delay or using +fsync = off.. Anyone cares to comment? + +I plan to re-read carefully the WALL docs on the site.. so I can better +decide.. however any field expierences would be much welcome. + +Marc are you on the Bacula list? I plan to join it later today and will +bring up the PostgreSQL issue there. + +From pgsql-performance-owner@postgresql.org Fri Apr 14 13:13:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id C2A0D11F60AE + for ; + Fri, 14 Apr 2006 13:13:42 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.354 +X-Spam-Level: +X-Spam-Status: No, score=-0.354 required=5 tests=[AWL=-1.571, BAYES_00=-2.599, + SPF_HELO_SOFTFAIL=2.432, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id s1JiessGCozd + for ; + Fri, 14 Apr 2006 13:13:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 4229711F61BA + for ; + Fri, 14 Apr 2006 13:13:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3EGDPe7010001; + Fri, 14 Apr 2006 12:13:25 -0400 (EDT) +To: Ian Westmacott +cc: pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +In-reply-to: <1145029009.3422.31.camel@spectre.intellivid.com> +References: <1145029009.3422.31.camel@spectre.intellivid.com> +Comments: In-reply-to Ian Westmacott + message dated "Fri, 14 Apr 2006 11:36:48 -0400" +Date: Fri, 14 Apr 2006 12:13:25 -0400 +Message-ID: <10000.1145031205@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/336 +X-Sequence-Number: 18420 + +Ian Westmacott writes: +> I have this query, where PG (8.1.2) prefers Merge Join over Hash Join +> over Nested Loop. However, this order turns out to increase in +> performance. I was hoping someone might be able to shed some light on +> why PG chooses the plans in this order, and what I might do to +> influence it otherwise. Thanks, + +Reducing random_page_cost would influence it to prefer the nestloop. +However, I doubt you're ever going to get really ideal results for +this query --- the estimated row counts are too far off, and the +WHERE conditions are sufficiently bizarre that there's not much hope +that they'd ever be much better. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 14 13:30:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id CE78B11F61BB + for ; + Fri, 14 Apr 2006 13:30:39 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.327 +X-Spam-Level: +X-Spam-Status: No, score=-0.327 required=5 tests=[AWL=-1.544, BAYES_00=-2.599, + SPF_HELO_SOFTFAIL=2.432, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id R92+fQxBMa3v + for ; + Fri, 14 Apr 2006 13:30:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 0331811F6243 + for ; + Fri, 14 Apr 2006 13:30:20 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3EGUKHi010152; + Fri, 14 Apr 2006 12:30:20 -0400 (EDT) +To: Francisco Reyes +cc: Marc Cousin , Chris , + Pgsql performance +Subject: Re: Inserts optimization? +In-reply-to: +References: + <200604141400.38982.mcousin@sigma.fr> + +Comments: In-reply-to Francisco Reyes + message dated "Fri, 14 Apr 2006 12:10:12 -0400" +Date: Fri, 14 Apr 2006 12:30:19 -0400 +Message-ID: <10151.1145032219@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/337 +X-Sequence-Number: 18421 + +Francisco Reyes writes: +> I think I am going to try increasing wal_buffers + +That will help not at all, if the problem is too-short transactions +as it sounds to be. You really need to pester the authors of bacula +to try to wrap multiple inserts per transaction. Or maybe find some +other software that can do that, if they are uninterested in supporting +anything but mysql. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 14 13:46:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 6A10B11F6CD1 + for ; + Fri, 14 Apr 2006 13:46:07 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.001 +X-Spam-Level: +X-Spam-Status: No, score=0.001 required=5 tests=[AWL=-1.216, BAYES_00=-2.599, + SPF_HELO_SOFTFAIL=2.432, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id maQuWtaPb4wZ + for ; + Fri, 14 Apr 2006 13:45:50 -0300 (ADT) +X-Greylist: delayed 01:08:56.153012 by SQLgrey- +Received: from mailhost.intellivid.com (mailhost.intellivid.com + [64.32.200.11]) + by postgresql.org (Postfix) with ESMTP id 1493A11F6BF4 + for ; + Fri, 14 Apr 2006 13:45:49 -0300 (ADT) +Received: from spectre.intellivid.com (spectre.intellivid.com [192.168.2.68]) + (using TLSv1 with cipher RC4-MD5 (128/128 bits)) + (Client did not present a certificate) + by newmail.intellivid.com (Postfix) with ESMTP id 6F41AF18150; + Fri, 14 Apr 2006 12:45:49 -0400 (EDT) +Subject: Re: merge>hash>loop +From: Ian Westmacott +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <10000.1145031205@sss.pgh.pa.us> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> +Content-Type: text/plain +Organization: IntelliVid Corp. +Date: Fri, 14 Apr 2006 12:45:48 -0400 +Message-Id: <1145033149.3422.41.camel@spectre.intellivid.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/338 +X-Sequence-Number: 18422 + +On Fri, 2006-04-14 at 12:13 -0400, Tom Lane wrote: +> Ian Westmacott writes: +> > I have this query, where PG (8.1.2) prefers Merge Join over Hash Join +> > over Nested Loop. However, this order turns out to increase in +> > performance. I was hoping someone might be able to shed some light on +> > why PG chooses the plans in this order, and what I might do to +> > influence it otherwise. Thanks, +> +> Reducing random_page_cost would influence it to prefer the nestloop. +> However, I doubt you're ever going to get really ideal results for +> this query --- the estimated row counts are too far off, and the +> WHERE conditions are sufficiently bizarre that there's not much hope +> that they'd ever be much better. + +That's what I feared, thanks. But then if I simplify things a bit, +such that the row counts are quite good, and PG still chooses a +worse plan, can I conclude anything about my configuration settings +(like random_page_cost)? + +itvtrackdata=> explain analyze SELECT mva,blob.* FROM +blobs00000000000033c3_c16010 AS blob NATURAL JOIN +objects00000000000033c3 WHERE time>=1263627787 AND time<1273458187 ORDER +BY time ASC; + +QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=75426.47..75552.21 rows=50295 width=28) (actual +time=2083.624..2146.654 rows=50472 loops=1) + Sort Key: blob."time" + -> Hash Join (cost=16411.51..70749.84 rows=50295 width=28) (actual +time=1790.746..1910.204 rows=50472 loops=1) + Hash Cond: ("outer".sva = "inner".sva) + -> Bitmap Heap Scan on blobs00000000000033c3_c16010 blob +(cost=533.77..14421.19 rows=50295 width=20) (actual time=12.533..78.284 +rows=50472 loops=1) + Recheck Cond: (("time" >= 1263627787) AND ("time" < +1273458187)) + -> Bitmap Index Scan on +idx_blobs00000000000033c3_c16010_time (cost=0.00..533.77 rows=50295 +width=0) (actual time=12.447..12.447 rows=50472 loops=1) + Index Cond: (("time" >= 1263627787) AND ("time" < +1273458187)) + -> Hash (cost=12039.79..12039.79 rows=487579 width=16) +(actual time=1618.128..1618.128 rows=487579 loops=1) + -> Seq Scan on objects00000000000033c3 +(cost=0.00..12039.79 rows=487579 width=16) (actual time=0.019..833.931 +rows=487579 loops=1) + Total runtime: 2194.492 ms +(11 rows) + +itvtrackdata=> set enable_hashjoin to false; +SET +itvtrackdata=> explain analyze SELECT mva,blob.* FROM +blobs00000000000033c3_c16010 AS blob NATURAL JOIN +objects00000000000033c3 WHERE time>=1263627787 AND time<1273458187 ORDER +BY time ASC; + +QUERY +PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=321096.91..321222.64 rows=50295 width=28) (actual +time=929.893..992.316 rows=50472 loops=1) + Sort Key: blob."time" + -> Nested Loop (cost=533.77..316420.28 rows=50295 width=28) (actual +time=16.780..719.140 rows=50472 loops=1) + -> Bitmap Heap Scan on blobs00000000000033c3_c16010 blob +(cost=533.77..14421.19 rows=50295 width=20) (actual time=16.693..84.299 +rows=50472 loops=1) + Recheck Cond: (("time" >= 1263627787) AND ("time" < +1273458187)) + -> Bitmap Index Scan on +idx_blobs00000000000033c3_c16010_time (cost=0.00..533.77 rows=50295 +width=0) (actual time=16.546..16.546 rows=50472 loops=1) + Index Cond: (("time" >= 1263627787) AND ("time" < +1273458187)) + -> Index Scan using idx_objects00000000000033c3_sva on +objects00000000000033c3 (cost=0.00..5.99 rows=1 width=16) (actual +time=0.006..0.008 rows=1 loops=50472) + Index Cond: ("outer".sva = objects00000000000033c3.sva) + Total runtime: 1039.725 ms +(10 rows) + +-- +Ian Westmacott +IntelliVid Corp. + + +From pgsql-performance-owner@postgresql.org Fri Apr 14 13:59:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 6280011F696D + for ; + Fri, 14 Apr 2006 13:59:09 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.276 +X-Spam-Level: +X-Spam-Status: No, score=-0.276 required=5 tests=[AWL=-1.493, BAYES_00=-2.599, + SPF_HELO_SOFTFAIL=2.432, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id x30S3hLZ2SNm + for ; + Fri, 14 Apr 2006 13:58:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id A7D4911F6260 + for ; + Fri, 14 Apr 2006 13:58:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3EGwnG7011036; + Fri, 14 Apr 2006 12:58:49 -0400 (EDT) +To: Ian Westmacott +cc: pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +In-reply-to: <1145033149.3422.41.camel@spectre.intellivid.com> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> +Comments: In-reply-to Ian Westmacott + message dated "Fri, 14 Apr 2006 12:45:48 -0400" +Date: Fri, 14 Apr 2006 12:58:49 -0400 +Message-ID: <11035.1145033929@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/339 +X-Sequence-Number: 18423 + +Ian Westmacott writes: +> That's what I feared, thanks. But then if I simplify things a bit, +> such that the row counts are quite good, and PG still chooses a +> worse plan, can I conclude anything about my configuration settings +> (like random_page_cost)? + +Well, the other thing that's going on here is that we know we are +overestimating the cost of nestloop-with-inner-indexscan plans. +The current estimation for that is basically "outer scan cost plus N +times inner scan cost" where N is the estimated number of outer tuples; +in other words the repeated indexscan probes are each assumed to happen +from a cold start. In reality, caching of the upper levels of the index +means that the later index probes are much cheaper than this model +thinks. We've known about this for some time but no one's yet proposed +a more reasonable cost model. + +In my mind this is tied into another issue, which is that the planner +always costs on the basis of each query starting from zero. In a real +environment it's much cheaper to use heavily-used indexes than this cost +model suggests, because they'll already be swapped in due to use by +previous queries. But we haven't got any infrastructure to keep track +of what's been heavily used, let alone a cost model that could make use +of the info. + +I think part of the reason that people commonly reduce random_page_cost +to values much lower than physical reality would suggest is that it +provides a crude way of partially compensating for this basic problem. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 14 14:50:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B863511F61C0 + for ; + Fri, 14 Apr 2006 14:50:35 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id cyguzdiGi2gl + for ; + Fri, 14 Apr 2006 14:50:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id F17A211F61BD + for ; + Fri, 14 Apr 2006 14:50:31 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id 6022FB81F; + Fri, 14 Apr 2006 13:50:31 -0400 (EDT) +Received: from 35st-server.simplicato.com + (static-71-249-233-130.nycmny.east.verizon.net [71.249.233.130]) + by zoraida.natserv.net (Postfix) with ESMTP id F1C05B81D; + Fri, 14 Apr 2006 13:50:30 -0400 (EDT) +References: + <200604141400.38982.mcousin@sigma.fr> + + <10151.1145032219@sss.pgh.pa.us> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Tom Lane +Cc: Marc Cousin , Chris , + Pgsql performance +Subject: Re: Inserts optimization? +Date: Fri, 14 Apr 2006 13:50:30 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/340 +X-Sequence-Number: 18424 + +Tom Lane writes: + +> That will help not at all, if the problem is too-short transactions +> as it sounds to be. + + +How about commit_delay? + +> You really need to pester the authors of bacula +> to try to wrap multiple inserts per transaction. + +Like any volunteer project I am sure it's more an issue of resources than an +issue of interest. + + +From pgsql-performance-owner@postgresql.org Mon Apr 17 09:10:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7141111F61C0 + for ; + Fri, 14 Apr 2006 15:01:30 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ph59A0RSFEFI + for ; + Fri, 14 Apr 2006 15:01:20 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.176]) + by postgresql.org (Postfix) with ESMTP id 7ADDC11F6CC6 + for ; + Fri, 14 Apr 2006 15:01:08 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so120090pye + for ; + Fri, 14 Apr 2006 11:01:08 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; + b=PDCtbXhUgRD/meeJ7kjBxWffchlwnuXI5vH28vbaWaz4I5KmRF6IPlhZM6usuorNxbEPPETJkRt9rAIGJu41vUZb9+ydyCs5dw044TEB2NrE3Q1JnK+nUMKeJAhuorllzisZM/yQweeQP8IEdzB60EiufG+xNtZ2jezoJKwsLIM= +Received: by 10.35.34.20 with SMTP id m20mr620246pyj; + Fri, 14 Apr 2006 11:01:08 -0700 (PDT) +Received: from ?192.168.51.41? ( [209.209.36.196]) + by mx.gmail.com with ESMTP id f20sm273989pyf.2006.04.14.11.01.07; + Fri, 14 Apr 2006 11:01:08 -0700 (PDT) +In-Reply-To: <2847.1144975434@sss.pgh.pa.us> +References: <1144135482.063425.33380@z34g2000cwc.googlegroups.com> + <20060411225515.GZ49405@pervasive.com> + <200604121603.43986.josh@agliodbs.com> + <20060413001024.GP49405@pervasive.com> + <6236.1144888514@sss.pgh.pa.us> + <4D23826E-7325-4946-B79A-80E321E0E497@gmail.com> + <26792.1144949880@sss.pgh.pa.us> + <2847.1144975434@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <79637789-3BD1-4450-BD72-C0025225E900@gmail.com> +Cc: PFC , "Jim C. Nasby" , + "Josh Berkus" , pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Christian Storm +Subject: Re: pgmemcache +Date: Fri, 14 Apr 2006 11:01:10 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/356 +X-Sequence-Number: 18440 + +> I'll let you in on a secret: NOTIFY is actually a before-commit +> operation. This is good enough because it never, or hardly ever, +> fails. I would argue that anything you want to do in an AFTER COMMIT +> trigger could just as well be done in a BEFORE COMMIT trigger; if +> that's +> not reliable enough then you need to fix your trigger. + +So, looping back to pgmemcache. It doesn't seem like it's about the +trigger failing; it's about +the transaction failing. How could I 'fix my trigger' so that if +the transaction fails +the cache wouldn't be updated? + +> An AFTER COMMIT trigger would have to be in a separate transaction. + +Agreed. Each trigger being in its own transaction. + +> What happens if there's more than one, and one of them fails? + +Each AFTER COMMIT trigger would be in its own transaction. So if it +fails, let it fail. It isn't the original transactions fault. If +you want it to bundled +with the original transaction then do a BEFORE COMMIT. + +If there is more than one, so be it. One may fail, another may not. +If that is not okay or the intended behavior, then create a new +trigger than +combines them into one transaction so that they are coupled. + +> Even +> more to the point, if it's a separate transaction, don't you have +> to fire all these triggers again when you commit that transaction? +> The idea seems circular. + +Why would it have to do this? Not sure if I follow. In my mind, +the only way this would happen is if the AFTER COMMIT trigger acted +upon the very same table it is triggered off of. Then you could +have a circular reference. However, this is true for the BEFORE COMMIT +situation too. I don't see the difference. What am I missing? + + +Cheers, + +Christian + + +From pgsql-performance-owner@postgresql.org Fri Apr 14 15:02:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 7165511F6109 + for ; + Fri, 14 Apr 2006 15:02:13 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.402 +X-Spam-Level: +X-Spam-Status: No, score=-0.402 required=5 tests=[AWL=-1.754, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_HELO_SOFTFAIL=2.432, + SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 9DFGDxcPypek + for ; + Fri, 14 Apr 2006 15:01:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 04B1F11F6C68 + for ; + Fri, 14 Apr 2006 15:01:57 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id 9E8E7B81F; + Fri, 14 Apr 2006 14:01:57 -0400 (EDT) +Received: from 35st-server.simplicato.com + (static-71-249-233-130.nycmny.east.verizon.net [71.249.233.130]) + by zoraida.natserv.net (Postfix) with ESMTP id 3A0D9B81D; + Fri, 14 Apr 2006 14:01:57 -0400 (EDT) +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + + <20060414114911.GG32678@mathom.us> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Michael Stone +Cc: pgsql-performance@postgresql.org +Subject: Re: Inserts optimization? +Date: Fri, 14 Apr 2006 14:01:56 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/341 +X-Sequence-Number: 18425 + +Michael Stone writes: + +> I guess the first question is why 2 hot spares? + + +Because we are using RAID 10 + +> larger array with more spindles with outperform a smaller one with +> fewer, regardless of RAID level (assuming a decent battery-backed +> cache). + +Based on what I have read RAID 10 is supposed to be better with lots of +random access. + + +> 5 RAID5 +> 2 RAID1 +> 1 spare + +That is certainly something worth considering... Still I wonder if 2 more +spindles will help enough to justify going to RAID 5. My understanding is +that RAID10 has simpler computations requirements which is partly what makes +it better for lots of random read/write. + +From pgsql-performance-owner@postgresql.org Fri Apr 14 16:03:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 89DCF11F65A2 + for ; + Fri, 14 Apr 2006 16:03:10 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.467 +X-Spam-Level: +X-Spam-Status: No, score=-0.467 required=5 tests=[AWL=-1.684, BAYES_00=-2.599, + SPF_HELO_SOFTFAIL=2.432, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id TzVkQSyqNAoC + for ; + Fri, 14 Apr 2006 16:02:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id 66F3211F655C + for ; + Fri, 14 Apr 2006 16:02:50 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO [192.168.1.27]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9263986; Fri, 14 Apr 2006 12:05:51 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Jignesh K. Shah" +Subject: Re: bad performance on Solaris 10 +Date: Fri, 14 Apr 2006 12:01:25 -0700 +User-Agent: KMail/1.8 +Cc: pgsql-performance@postgresql.org +References: <200604130839.k3D8dZQ26118@candle.pha.pa.us> + <443FAB62.7010307@sun.com> +In-Reply-To: <443FAB62.7010307@sun.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604141201.26080.josh@agliodbs.com> +X-Archive-Number: 200604/342 +X-Sequence-Number: 18426 + +Jignesh, + +> Don't get me wrong. As Luke mentioned it took a while to get the +> potential of PostgreSQL on Solaris and people like me start doing other +> complex workarounds in Solaris like "forcedirectio", etc. (Yeah I did a +> test, if you force fsync as wal_sync_method while on Solaris, then +> you may not even require to do forcedirectio of your $PGDATA/pg_xlogs to +> get back the lost performance) + +I didn't see these later test results. Can you link? + +Also, I presume this was on DW, and not on OLTP, yes? + +-- +--Josh + +Josh Berkus +PostgreSQL @ Sun +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Apr 14 16:06:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1399311F65A8 + for ; + Fri, 14 Apr 2006 16:06:46 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id HeeMZyE54uUx + for ; + Fri, 14 Apr 2006 16:06:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by postgresql.org (Postfix) with ESMTP id D495811F65A7 + for ; + Fri, 14 Apr 2006 16:06:29 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IXQ00AV27QSMRI5@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Fri, 14 Apr 2006 14:06:29 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 609A66E9B5 for + ; + Fri, 14 Apr 2006 15:06:26 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 03255-03-4 for ; Fri, + 14 Apr 2006 15:06:25 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id AA14C6EACD; Fri, 14 Apr 2006 15:06:25 -0400 (EDT) +Date: Fri, 14 Apr 2006 15:06:25 -0400 +From: Michael Stone +Subject: Re: Inserts optimization? +In-reply-to: +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060414190620.GH32678@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + + <20060414114911.GG32678@mathom.us> + +User-Agent: Mutt/1.5.11+cvs20060126 +X-Archive-Number: 200604/343 +X-Sequence-Number: 18427 + +On Fri, Apr 14, 2006 at 02:01:56PM -0400, Francisco Reyes wrote: +>Michael Stone writes: +>>I guess the first question is why 2 hot spares? +> +>Because we are using RAID 10 + +I still don't follow that. Why would the RAID level matter? IOW, are you +actually wanting 2 spares, or are you just stick with that because you +need a factor of two disks for your mirrors? + +>>larger array with more spindles with outperform a smaller one with +>>fewer, regardless of RAID level (assuming a decent battery-backed +>>cache). +> +>Based on what I have read RAID 10 is supposed to be better with lots of +>random access. + +Mmm, it's a bit more complicated than that. RAID 10 can be better if you +have lots of random writes (though a large RAID cache can mitigate +that). For small random reads the limiting factor is how fast you can +seek, and that number is based more on the number of disks than the RAID +level. + +>>5 RAID5 +>>2 RAID1 +>>1 spare +> +>That is certainly something worth considering... Still I wonder if 2 more +>spindles will help enough to justify going to RAID 5. My understanding is +>that RAID10 has simpler computations requirements which is partly what +>makes it better for lots of random read/write. + +If your RAID hardware notices a difference between the parity +calculations for RAID 5 and the mirroring of RAID 1 it's a fairly lousy +unit for 2006--those calculations are really trivial for modern +hardware. The reason that RAID 10 can give better random small block +write performance is that fewer disks need to be involved per write. +That's something that can be mitigated with a large cache to aggregate +the writes, but some controllers are much better than others in that +regard. This is really a case where you have to test with your +particular hardware & data, because the data access patterns are +critical in determining what kind of performance is required. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Fri Apr 14 17:09:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 1AA0D11F65D7 + for ; + Fri, 14 Apr 2006 17:09:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.11 +X-Spam-Level: +X-Spam-Status: No, score=-0.11 required=5 tests=[AWL=-1.462, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_HELO_SOFTFAIL=2.432, + SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id TbjWwOBVkwbF + for ; + Fri, 14 Apr 2006 17:09:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 64B9711F65C0 + for ; + Fri, 14 Apr 2006 17:09:19 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id 45BABB823; + Fri, 14 Apr 2006 16:09:19 -0400 (EDT) +Received: from 35st-server.simplicato.com + (static-71-249-233-130.nycmny.east.verizon.net [71.249.233.130]) + by zoraida.natserv.net (Postfix) with ESMTP id E89B3B81F; + Fri, 14 Apr 2006 16:09:18 -0400 (EDT) +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + + <20060414114911.GG32678@mathom.us> + + <20060414190620.GH32678@mathom.us> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Michael Stone +Cc: pgsql-performance@postgresql.org +Subject: Re: Inserts optimization? +Date: Fri, 14 Apr 2006 16:09:18 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/344 +X-Sequence-Number: 18428 + +Michael Stone writes: + +> I still don't follow that. Why would the RAID level matter? IOW, are you +> actually wanting 2 spares, or are you just stick with that because you +> need a factor of two disks for your mirrors? + +RAID 10 needs pairs.. so we can either have no spares or 2 spares. + +> Mmm, it's a bit more complicated than that. RAID 10 can be better if you +> have lots of random writes (though a large RAID cache can mitigate +> that). + +We are using a 3ware 9550SX with 128MB RAM (at least I believe that is what +that card has installed). + +>For small random reads the limiting factor is how +>fast you can seek, and that number is based more on the number of disks than the RAID +> level. + +I don't have any solid stats, but I would guess the machines will fairly +close split between reads and writes. + + +> hardware. The reason that RAID 10 can give better random small block +> write performance is that fewer disks need to be involved per write. + + +That makes sense. + +> That's something that can be mitigated with a large cache + +128MB enough in your opinion? + + +> the writes, but some controllers are much better than others in that +> regard. + +The controller we are using is 3Ware 9550SX. + +> This is really a case where you have to test with your +> particular hardware & data + + +That is obviously the ideal way to go, but it is very time consuming. :-( +To setup a machine with one set of raid setup.. test, then re-do with +different set of raid.. re test.. that's anywhere from 1 to 2 days worth of +testing. Unlikely I will be given that time to test. + +From pgsql-performance-owner@postgresql.org Fri Apr 14 17:15:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4B28111F6D2A + for ; + Fri, 14 Apr 2006 17:15:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.119 +X-Spam-Level: +X-Spam-Status: No, score=0.119 required=5 tests=[AWL=0.118, + UNPARSEABLE_RELAY=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id BqhXb1cJpFdY + for ; + Fri, 14 Apr 2006 17:15:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 3D94F11F7330 + for ; + Fri, 14 Apr 2006 17:15:33 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Fri, 14 Apr 2006 20:15:33 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 14 Apr 2006 15:15:33 -0500 +Subject: Re: Inserts optimization? +From: Scott Marlowe +To: Francisco Reyes +Cc: Michael Stone , + pgsql-performance@postgresql.org +In-Reply-To: +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + + <20060414114911.GG32678@mathom.us> + + <20060414190620.GH32678@mathom.us> + +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1145045732.23538.86.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Fri, 14 Apr 2006 15:15:33 -0500 +X-Archive-Number: 200604/345 +X-Sequence-Number: 18429 + +On Fri, 2006-04-14 at 15:09, Francisco Reyes wrote: +> Michael Stone writes: +> +> > I still don't follow that. Why would the RAID level matter? IOW, are you +> > actually wanting 2 spares, or are you just stick with that because you +> > need a factor of two disks for your mirrors? +> +> RAID 10 needs pairs.. so we can either have no spares or 2 spares. + +Spares are placed in service one at a time. You don't need 2 spares for +RAID 10, trust me. + + +From pgsql-performance-owner@postgresql.org Fri Apr 14 17:28:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 59C0411F65C0 + for ; + Fri, 14 Apr 2006 17:28:04 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.144 +X-Spam-Level: +X-Spam-Status: No, score=0.144 required=5 tests=[AWL=0.144] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id qQbvtwipQJPQ + for ; + Fri, 14 Apr 2006 17:27:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id F403111F65AA + for ; + Fri, 14 Apr 2006 17:28:00 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id B4D33B81F; + Fri, 14 Apr 2006 16:28:00 -0400 (EDT) +Received: from 35st-server.simplicato.com + (static-71-249-233-130.nycmny.east.verizon.net [71.249.233.130]) + by zoraida.natserv.net (Postfix) with ESMTP id 42883B81D; + Fri, 14 Apr 2006 16:28:00 -0400 (EDT) +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + + <20060414114911.GG32678@mathom.us> + + <20060414190620.GH32678@mathom.us> + + <1145045732.23538.86.camel@state.g2switchworks.com> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Scott Marlowe +Cc: Michael Stone , + pgsql-performance@postgresql.org +Subject: Re: Inserts optimization? +Date: Fri, 14 Apr 2006 16:27:59 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/346 +X-Sequence-Number: 18430 + +Scott Marlowe writes: + +> Spares are placed in service one at a time. + +Ah.. that's your point. I know that. :-) + +> You don't need 2 spares for +> RAID 10, trust me. + +We bought the machine with 8 drives. At one point we were considering RAID +5, then we decided to give RAID 10 a try. We have a simmilar machine with +raid 5 and less memory (2GB, vs 4GB on the new machine) and the old machine +was having some very serious issues handling the load. + +So far the RAID10 machine (twice the memory, newer disks, faster CPUs,.. +the previous machine was about 1 year old) has been performing very well. + +We are now looking to put our 3rd NFS machine into production with +identical specs as the machine we currently use with RAID10. This 3rd +machine with do NFS work (mail store) and also will be our database server +(until we can afford to buy a 4th.. dedicated DB machine). + +The whole reason I started the thread was because most PostgreSQL setups I +have done in the past were mostly read.. whereas now the Bacula backups plus +another app we will be developing.. will be doing considerable writes to the +DB. + +From pgsql-performance-owner@postgresql.org Sat Apr 15 05:33:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A567611F675A + for ; + Sat, 15 Apr 2006 05:33:01 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id znfiaWKdP7jq + for ; + Sat, 15 Apr 2006 05:32:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smarty.gabriel.co.hu (smarty.gabriel.co.hu [195.70.37.16]) + by postgresql.org (Postfix) with ESMTP id 7992B11F626B + for ; + Sat, 15 Apr 2006 05:32:58 -0300 (ADT) +Received: from localhost (smarty [127.0.0.1]) + by smarty.gabriel.co.hu (Postfix) with ESMTP id D8E35434CE; + Sat, 15 Apr 2006 10:32:55 +0200 (CEST) +Received: from smarty.gabriel.co.hu ([127.0.0.1]) + by localhost (smarty [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 04867-04; Sat, 15 Apr 2006 10:32:55 +0200 (CEST) +Received: from [192.168.100.182] (catv-5062cfe4.catv.broadband.hu + [80.98.207.228]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by smarty.gabriel.co.hu (Postfix) with ESMTP id A9310434B4; + Sat, 15 Apr 2006 10:32:55 +0200 (CEST) +Message-ID: <4440AFB8.4080806@i-logic.hu> +Date: Sat, 15 Apr 2006 10:32:56 +0200 +From: =?ISO-8859-1?Q?G=E1briel_=C1kos?= +Organization: I-Logic Kft +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Francisco Reyes +Cc: Michael Stone , + pgsql-performance@postgresql.org +Subject: Re: Inserts optimization? +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + + <20060414114911.GG32678@mathom.us> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at gabriel.co.hu +X-Archive-Number: 200604/347 +X-Sequence-Number: 18431 + +Francisco Reyes wrote: + +> That is certainly something worth considering... Still I wonder if 2 +> more spindles will help enough to justify going to RAID 5. My +> understanding is that RAID10 has simpler computations requirements which +> is partly what makes it better for lots of random read/write. + +you are right. raid5 is definitely not suitable for database activities. +it is good for file servers, though. + +-- +�dv�zlettel, +G�briel �kos +-=E-Mail :akos.gabriel@i-logic.hu|Web: http://www.i-logic.hu=- +-=Tel/fax:+3612367353 |Mobil:+36209278894 =- + +From pgsql-performance-owner@postgresql.org Sat Apr 15 05:35:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DBEA311F6ACB + for ; + Sat, 15 Apr 2006 05:35:43 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.08 +X-Spam-Level: +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id J3FhZRMnSVkp + for ; + Sat, 15 Apr 2006 05:35:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smarty.gabriel.co.hu (smarty.gabriel.co.hu [195.70.37.16]) + by postgresql.org (Postfix) with ESMTP id 4A47911F626B + for ; + Sat, 15 Apr 2006 05:35:41 -0300 (ADT) +Received: from localhost (smarty [127.0.0.1]) + by smarty.gabriel.co.hu (Postfix) with ESMTP id CC3ED434CE; + Sat, 15 Apr 2006 10:35:40 +0200 (CEST) +Received: from smarty.gabriel.co.hu ([127.0.0.1]) + by localhost (smarty [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 04867-04-3; Sat, 15 Apr 2006 10:35:40 +0200 (CEST) +Received: from [192.168.100.182] (catv-5062cfe4.catv.broadband.hu + [80.98.207.228]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by smarty.gabriel.co.hu (Postfix) with ESMTP id A95214345B; + Sat, 15 Apr 2006 10:35:40 +0200 (CEST) +Message-ID: <4440B05D.8070002@i-logic.hu> +Date: Sat, 15 Apr 2006 10:35:41 +0200 +From: =?ISO-8859-1?Q?G=E1briel_=C1kos?= +Organization: I-Logic Kft +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Francisco Reyes +Cc: Michael Stone , + pgsql-performance@postgresql.org +Subject: Re: Inserts optimization? +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + + <20060414114911.GG32678@mathom.us> + + <20060414190620.GH32678@mathom.us> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at gabriel.co.hu +X-Archive-Number: 200604/348 +X-Sequence-Number: 18432 + +Francisco Reyes wrote: +> Michael Stone writes: +> +>> I still don't follow that. Why would the RAID level matter? IOW, are +>> you actually wanting 2 spares, or are you just stick with that because +>> you need a factor of two disks for your mirrors? +> +> RAID 10 needs pairs.. so we can either have no spares or 2 spares. + +hm, interesting. I have recently set up a HP machine with smartarray 6i +controller, and it is able to handle 4 disks in raid10 plus 1 as spare. +with some scripting you can even use linux software raid in the same setup. + +-- +�dv�zlettel, +G�briel �kos +-=E-Mail :akos.gabriel@i-logic.hu|Web: http://www.i-logic.hu=- +-=Tel/fax:+3612367353 |Mobil:+36209278894 =- + +From pgsql-performance-owner@postgresql.org Sat Apr 15 10:16:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 7A2C111F7AB4 + for ; + Sat, 15 Apr 2006 10:16:18 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.557 +X-Spam-Level: +X-Spam-Status: No, score=-0.557 required=5 tests=[AWL=1.908, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id i6HSfcWRwQDk + for ; + Sat, 15 Apr 2006 10:16:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 83F4D11F6CD7 + for ; + Sat, 15 Apr 2006 10:16:15 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id B6D2CB81F; + Sat, 15 Apr 2006 09:16:15 -0400 (EDT) +Received: from zoraida.natserv.net (zoraida.natserv.net [66.114.65.147]) + by zoraida.natserv.net (Postfix) with ESMTP id 6EF1FB81D; + Sat, 15 Apr 2006 09:16:15 -0400 (EDT) +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + + <20060414114911.GG32678@mathom.us> + + <20060414190620.GH32678@mathom.us> + + <4440B05D.8070002@i-logic.hu> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: =?ISO-8859-1?B?Rz9icmllbCA/a29z?= +Cc: Michael Stone , + pgsql-performance@postgresql.org +Subject: Re: Inserts optimization? +Date: Sat, 15 Apr 2006 09:16:15 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="ISO-8859-1" +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/349 +X-Sequence-Number: 18433 + +G�briel �kos writes: + +>> RAID 10 needs pairs.. so we can either have no spares or 2 spares. +> +> hm, interesting. I have recently set up a HP machine with smartarray 6i +> controller, and it is able to handle 4 disks in raid10 plus 1 as spare. + +:-) +Ok so let me be a bit more clear... + +We have 6 disks in RAID10. +We can have the following with the remaining 2 disks +RAID1 +1 Spare, 1 for storage +2 spares + +Having at least 1 spare is a must.. which means that we can use the +remaining disk as spare or as data... using it to store ANY data means the +data will not be protected by the RAID. I can not think of almost any data +we would care so little that we would put it in the single disk. + +For a second I thought logs.. but even that is not good, because the +programs that write the logs may fail.. so even if we don't care about +loosing the logs, in theory it may cause problems to the operation of the +system. + +That's how we ended up with 2 hot spares. + +From pgsql-performance-owner@postgresql.org Sat Apr 15 10:26:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 411EC11F6B8A + for ; + Sat, 15 Apr 2006 10:26:48 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.18 +X-Spam-Level: +X-Spam-Status: No, score=0.18 required=5 tests=[AWL=0.180] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id sSkGSFV4Bb8N + for ; + Sat, 15 Apr 2006 10:26:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id ED93311F6230 + for ; + Sat, 15 Apr 2006 10:26:45 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id 7BE15B822; + Sat, 15 Apr 2006 09:26:46 -0400 (EDT) +Received: from zoraida.natserv.net (zoraida.natserv.net [66.114.65.147]) + by zoraida.natserv.net (Postfix) with ESMTP id 40010B81D; + Sat, 15 Apr 2006 09:26:46 -0400 (EDT) +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + + <20060414114911.GG32678@mathom.us> + + <4440AFB8.4080806@i-logic.hu> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: =?ISO-8859-1?B?Rz9icmllbCA/a29z?= +Cc: Michael Stone , + pgsql-performance@postgresql.org +Subject: Re: Inserts optimization? +Date: Sat, 15 Apr 2006 09:26:46 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="ISO-8859-1" +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/350 +X-Sequence-Number: 18434 + +G�briel �kos writes: + +> you are right. raid5 is definitely not suitable for database activities. + +That is not entirely true. :-) +Right now the new server is not ready and the ONLY place I could put the DB +for Bacula was a machine with RAID 5. So far it is holding fine. HOWEVER... +only one bacula job at a time so far and the machine doesn't do anything +else. :-) + + +> it is good for file servers, though. + +Even for a DB server, from what I have read and what I have experienced so +far for mostly read DBs RAID5 should be ok. Specially if you have enough +memory. + +As I add more clients to Bacula and the jobs bump into each other I will +better know how the DB holds up. I am doing each FULL backup at a time so +hopefully by the time I do multiple backups from multiple machines less +records will need to be inserted to the DB and there will be a more balanced +operation between reads and writes. Right now there are lots of inserts +going on. + +From pgsql-performance-owner@postgresql.org Sat Apr 15 10:34:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AD38D11F6B89 + for ; + Sat, 15 Apr 2006 10:34:47 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.144 +X-Spam-Level: +X-Spam-Status: No, score=0.144 required=5 tests=[AWL=0.144] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id KUdJq3mUJhRV + for ; + Sat, 15 Apr 2006 10:34:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 2A83A11F6B7D + for ; + Sat, 15 Apr 2006 10:34:45 -0300 (ADT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id A39B0B81F + for ; + Sat, 15 Apr 2006 09:34:45 -0400 (EDT) +Received: from zoraida.natserv.net (zoraida.natserv.net [66.114.65.147]) + by zoraida.natserv.net (Postfix) with ESMTP id 6AE33B81D + for ; + Sat, 15 Apr 2006 09:34:45 -0400 (EDT) +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Pgsql performance +Subject: Re: Inserts optimization? +Date: Sat, 15 Apr 2006 09:34:45 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/351 +X-Sequence-Number: 18435 + +Tom Lane writes: + +> Also, increasing checkpoint_segments and possibly wal_buffers helps a +> lot for write-intensive loads. + +Following up on those two recomendations from Tom. +Tom mentioned in a different message that if the inserst are small that +increasing wal_buffers would not help. + +How about checkpoint_segments? +Also commit_delays seems like may be helpfull. Is it too much a risk to set +commit_delays to 1 second? If the machine has any problems while having a +higher commit_delay will the end result simply be that a larger amount of +transactions will be rolled back? + +p.s. did not CC Tom because he uses an RBL which is rather "selective" about +what it lets through (one of the worst in my opinion). + +From pgsql-performance-owner@postgresql.org Sun Apr 16 20:23:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C557311F628B + for ; + Sun, 16 Apr 2006 20:23:44 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id lDEXRwgM0BxL + for ; + Sun, 16 Apr 2006 20:23:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.wirelesscar.com (mail.wirelesscar.com [212.209.35.30]) + by postgresql.org (Postfix) with ESMTP id 605DB11F6237 + for ; + Sun, 16 Apr 2006 20:23:39 -0300 (ADT) +Received: from sesrv12.wirelesscar.com ([192.168.10.17]) by + mail.wirelesscar.com with InterScan Messaging Security Suite; + Mon, 17 Apr 2006 01:23:38 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Migration study, step 2: rewriting queries +Date: Mon, 17 Apr 2006 01:24:20 +0200 +Message-ID: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3CF0@sesrv12.wirelesscar.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Migration study, step 2: rewriting queries +Thread-Index: AcZhrOM1A6HSHPVrSxmCkgpQiMYQuw== +From: "Mikael Carneholm" +To: "Pgsql performance" +X-Archive-Number: 200604/352 +X-Sequence-Number: 18436 + +Since my first post in this series, data has been successfully exported +from the proprietary db (in CSV format) and imported into postgres +(PostgreSQL 8.1.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.4 +20050721 (Red Hat 3.4.4-2)) using=20 +COPY. The tablespace holding the tables+indexes is now 60Gb, total time +for exporting+transfering over network+importing+indexing+vacuuming is +about 7 hours. + +I now have a query (originally using an analytical function) that +behaves strangely as soon as I go from 2 person_information__id:s to 3 +person_information__id:s (see below): + +// +// 2 PID:s=20 +// +mica@TEST=3D> explain analyze select distinct on +(driver_activity.person_information__id) +TEST-> driver_activity.person_information__id, +TEST-> driver_activity.end_time as prev_timestamp +TEST-> from +TEST-> driver_activity=20 +TEST-> where +TEST-> driver_activity.person_information__id in (5398,5399) +TEST-> and driver_activity.driver_activity_type__id =3D 5 +TEST-> and driver_activity.start_time < '2006-04-01' +TEST-> order by +TEST-> driver_activity.person_information__id, +driver_activity.start_time desc; + +=20 +QUERY PLAN + +------------------------------------------------------------------------ +------------------------------------------------------------------------ +---------------------------- + Unique (cost=3D1909.90..1912.32 rows=3D1 width=3D20) (actual +time=3D1.153..1.623 rows=3D2 loops=3D1) + -> Sort (cost=3D1909.90..1911.11 rows=3D485 width=3D20) (actual +time=3D1.151..1.389 rows=3D213 loops=3D1) + Sort Key: person_information__id, start_time + -> Bitmap Heap Scan on driver_activity (cost=3D6.91..1888.26 +rows=3D485 width=3D20) (actual time=3D0.141..0.677 rows=3D213 loops=3D1) + Recheck Cond: (((person_information__id =3D 5398) AND +(driver_activity_type__id =3D 5)) OR ((person_information__id =3D 5399) = +AND +(driver_activity_type__id =3D 5))) + Filter: (start_time < '2006-04-01 00:00:00'::timestamp +without time zone) + -> BitmapOr (cost=3D6.91..6.91 rows=3D485 width=3D0) = +(actual +time=3D0.102..0.102 rows=3D0 loops=3D1) + -> Bitmap Index Scan on xda_pi_dat +(cost=3D0.00..3.46 rows=3D243 width=3D0) (actual time=3D0.042..0.042 = +rows=3D56 +loops=3D1) + Index Cond: ((person_information__id =3D = +5398) +AND (driver_activity_type__id =3D 5)) + -> Bitmap Index Scan on xda_pi_dat +(cost=3D0.00..3.46 rows=3D243 width=3D0) (actual time=3D0.055..0.055 = +rows=3D157 +loops=3D1) + Index Cond: ((person_information__id =3D = +5399) +AND (driver_activity_type__id =3D 5)) + Total runtime: 1.693 ms +(12 rows) + +// +// 3 PID:s=20 +// +mica@TEST=3D> explain analyze select distinct on +(driver_activity.person_information__id) +TEST-> driver_activity.person_information__id, +TEST-> driver_activity.end_time as prev_timestamp +TEST-> from +TEST-> driver_activity=20 +TEST-> where +TEST-> driver_activity.person_information__id in (5398,5399,5400) +TEST-> and driver_activity.driver_activity_type__id =3D 5 +TEST-> and driver_activity.start_time < '2006-04-01' +TEST-> order by +TEST-> driver_activity.person_information__id, +driver_activity.start_time desc; +=09 +QUERY PLAN + +------------------------------------------------------------------------ +------------------------------------------------------------------------ +------------------------------------------------------------------------ +----------------------------------------------------------------- + Unique (cost=3D2808.35..2811.98 rows=3D1 width=3D20) (actual +time=3D5450.281..5450.948 rows=3D3 loops=3D1) + -> Sort (cost=3D2808.35..2810.17 rows=3D727 width=3D20) (actual +time=3D5450.278..5450.607 rows=3D305 loops=3D1) + Sort Key: person_information__id, start_time + -> Bitmap Heap Scan on driver_activity = +(cost=3D2713.82..2773.80 +rows=3D727 width=3D20) (actual time=3D5436.259..5449.043 rows=3D305 = +loops=3D1) + Recheck Cond: ((((person_information__id =3D 5398) AND +(driver_activity_type__id =3D 5)) OR ((person_information__id =3D 5399) = +AND +(driver_activity_type__id =3D 5)) OR ((person_information__id =3D 5400) = +AND +(driver_activity_type__id =3D 5))) AND (driver_activity_type__id =3D 5)) + Filter: (start_time < '2006-04-01 00:00:00'::timestamp +without time zone) + -> BitmapAnd (cost=3D2713.82..2713.82 rows=3D15 = +width=3D0) +(actual time=3D5436.148..5436.148 rows=3D0 loops=3D1) + -> BitmapOr (cost=3D10.37..10.37 rows=3D728 = +width=3D0) +(actual time=3D0.384..0.384 rows=3D0 loops=3D1) + -> Bitmap Index Scan on xda_pi_dat +(cost=3D0.00..3.46 rows=3D243 width=3D0) (actual time=3D0.135..0.135 = +rows=3D56 +loops=3D1) + Index Cond: ((person_information__id = +=3D +5398) AND (driver_activity_type__id =3D 5)) + -> Bitmap Index Scan on xda_pi_dat +(cost=3D0.00..3.46 rows=3D243 width=3D0) (actual time=3D0.115..0.115 = +rows=3D157 +loops=3D1) + Index Cond: ((person_information__id = +=3D +5399) AND (driver_activity_type__id =3D 5)) + -> Bitmap Index Scan on xda_pi_dat +(cost=3D0.00..3.46 rows=3D243 width=3D0) (actual time=3D0.126..0.126 = +rows=3D93 +loops=3D1) + Index Cond: ((person_information__id = +=3D +5400) AND (driver_activity_type__id =3D 5)) + -> Bitmap Index Scan on xda_dat +(cost=3D0.00..2703.21 rows=3D474916 width=3D0) (actual = +time=3D5435.431..5435.431 +rows=3D451541 loops=3D1) + Index Cond: (driver_activity_type__id =3D 5) + Total runtime: 5451.094 ms +(17 rows) + +Question: why is the extra step (Bitmap Index Scan on xda_dat) +introduced in the latter case? I can see it is originating from=20 + +((((person_information__id =3D 5398) AND (driver_activity_type__id =3D = +5)) +OR ((person_information__id =3D 5399) AND (driver_activity_type__id =3D = +5)) +OR ((person_information__id =3D 5400) AND (driver_activity_type__id =3D = +5))) +AND (driver_activity_type__id =3D 5)) + +..which, indented for readability, looks like this: + +( + ( + ( + (person_information__id =3D 5398) AND +(driver_activity_type__id =3D 5) + )=20 + OR=20 + ( + (person_information__id =3D 5399) AND +(driver_activity_type__id =3D 5) + )=20 + OR=20 + ( + (person_information__id =3D 5400) AND +(driver_activity_type__id =3D 5) + ) + )=20 + AND=20 + (driver_activity_type__id =3D 5) +) + +..and this last AND seems unnessecary, since the predicate on +(driver_activity_type__id =3D 5) is included in each of the above +conditions. + +Can this be a bug in the planner? + +/Mikael + +From pgsql-performance-owner@postgresql.org Sun Apr 16 22:35:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 6148011F660D + for ; + Sun, 16 Apr 2006 22:35:54 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.152 +X-Spam-Level: +X-Spam-Status: No, score=-2.152 required=5 tests=[AWL=0.449, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id r9qXd3M+t1DM + for ; + Sun, 16 Apr 2006 22:35:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 51AC311F65BF + for ; + Sun, 16 Apr 2006 22:35:51 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3H1ZovL020148; + Sun, 16 Apr 2006 21:35:51 -0400 (EDT) +To: "Mikael Carneholm" +cc: "Pgsql performance" +Subject: Re: Migration study, step 2: rewriting queries +In-reply-to: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3CF0@sesrv12.wirelesscar.com> +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3CF0@sesrv12.wirelesscar.com> +Comments: In-reply-to "Mikael Carneholm" + message dated "Mon, 17 Apr 2006 01:24:20 +0200" +Date: Sun, 16 Apr 2006 21:35:50 -0400 +Message-ID: <20147.1145237750@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/353 +X-Sequence-Number: 18437 + +"Mikael Carneholm" writes: +> ..and this last AND seems unnessecary, since the predicate on +> (driver_activity_type__id = 5) is included in each of the above +> conditions. + +This should be fixed by the changes I made recently in choose_bitmap_and +--- it wasn't being aggressive about pruning overlapping AND conditions +when a sub-OR was involved. It's possible the new coding is *too* +aggressive, and will reject indexes that it'd be profitable to include; +but at least it won't make this particular mistake. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 17 11:35:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 6E67811F65BF + for ; + Mon, 17 Apr 2006 11:35:01 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.41 +X-Spam-Level: +X-Spam-Status: No, score=-2.41 required=5 tests=[AWL=0.188, BAYES_00=-2.599, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 8oFDvwF4jadU + for ; + Mon, 17 Apr 2006 11:34:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id 14C5911F655C + for ; + Mon, 17 Apr 2006 11:34:53 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Mon, 17 Apr 2006 14:34:53 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145284491889; Mon, 17 Apr 2006 07:34:51 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Mon, 17 Apr 2006 07:34:51 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Mon, 17 Apr 2006 07:34:51 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145284486616; Mon, 17 Apr 2006 07:34:46 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C6622C.123EE846" +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: slow cursor +Date: Mon, 17 Apr 2006 07:34:38 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF0406A546@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: slow cursor +Thread-Index: AcZiLA5GaMOo54GDTAq4Dq1qUKNNHA== +From: "Sriram Dandapani" +To: "Pgsql-Performance \(E-mail\)" +X-Archive-Number: 200604/357 +X-Sequence-Number: 18441 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C6622C.123EE846 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Hi + +=20 + +I have a cursor that fetches 150K rows and updates or inserts a table +with 150K rows. + +=20 + +It takes several minutes for the process to complete (about 15 minutes). +The select by itself (without cursor) gets all rows in 15 seconds. + +=20 + +Is there a way to optimize the cursor to fetch all records and speed up +the process. I still need to do the record by record processing + +=20 + + +------_=_NextPart_001_01C6622C.123EE846 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hi

+ +

 

+ +

I have a cursor that fetches 150K rows and updates or +inserts a table with 150K rows.

+ +

 

+ +

It takes several minutes for the process to complete = +(about +15 minutes). The select by itself (without cursor) gets all rows in 15 = +seconds.

+ +

 

+ +

Is there a way to optimize the cursor to fetch all = +records +and speed up the process. I still need to do the record by record = +processing

+ +

 

+ +
+ + + + + +------_=_NextPart_001_01C6622C.123EE846-- + +From pgsql-performance-owner@postgresql.org Mon Apr 17 15:36:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 2764411F65DE + for ; + Mon, 17 Apr 2006 15:36:55 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.437 +X-Spam-Level: +X-Spam-Status: No, score=-2.437 required=5 tests=[AWL=0.161, BAYES_00=-2.599, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 1Md0+OjNoWoD + for ; + Mon, 17 Apr 2006 15:36:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id 2CAB011F65B4 + for ; + Mon, 17 Apr 2006 15:36:45 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Mon, 17 Apr 2006 18:36:42 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145299002561; Mon, 17 Apr 2006 11:36:42 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Mon, 17 Apr 2006 11:36:42 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Mon, 17 Apr 2006 11:36:42 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145298997512; Mon, 17 Apr 2006 11:36:37 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C6624D.DC39826D" +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: creating of temporary table takes very long +Date: Mon, 17 Apr 2006 11:36:32 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF0406A629@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: creating of temporary table takes very long +Thread-Index: AcZiTdk6W0MPG7GkTfe8tYyes6Z3Rg== +From: "Sriram Dandapani" +To: "Pgsql-Performance \(E-mail\)" +X-Archive-Number: 200604/358 +X-Sequence-Number: 18442 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C6624D.DC39826D +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +create temporary table c_chkpfw_hr_tr_updates as + + select * from c_chkpfw_hr_tr a + + where exists(select 1 from +chkpfw_tr_hr_dimension b + + WHERE a.firstoccurrence =3D +b.firstoccurrence + + AND a.sentryid_id =3D b.sentryid_id + + AND a.node_id =3D b.node_id + + + AND a.customerid_id =3D +b.customerid_id + + AND coalesce(a.interface_id,0) =3D +coalesce(b.interface_id,0) + + AND coalesce(a.source_id,0) =3D +coalesce(b.source_id,0) + + AND coalesce(a.destination_id,0) = +=3D +coalesce(b.destination_id,0) + + AND coalesce(a.sourceport_id,0) =3D +coalesce(b.sourceport_id,0) + + AND +coalesce(a.destinationport_id,0) =3D coalesce(b.destinationport_id,0) + + AND coalesce(a.inoutbound_id,0) =3D +coalesce(b.inoutbound_id,0) + + AND coalesce(a.action_id,0) =3D +coalesce(b.action_id,0) + + AND coalesce(a.protocol_id,0) =3D +coalesce(b.protocol_id,0) + + AND coalesce(a.service_id,0) =3D +coalesce(b.service_id,0) + + AND coalesce(a.sourcezone_id,0) =3D +coalesce(b.sourcezone_id,0) + + AND +coalesce(a.destinationzone_id,0) =3D coalesce(b.destinationzone_id,0)); + +=20 + +This takes forever (I have to cancel the statement each time) + +=20 + +c_chkpfw_hr_tr has about 20000 rows + +chkpfw_tr_hr_dimension has 150K rows + +=20 + +c_chkpfw_hr_tr has same indexes as chkpfw_tr_hr_dimension + +=20 + +For such a small data set, this seems like a mystery. The only other +alternative I have is to use cursors which are also very slow for row +sets of 10- 15K or more. + + +------_=_NextPart_001_01C6624D.DC39826D +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

create temporary table c_chkpfw_hr_tr_updates = +as

+ +

         = +            &= +nbsp;  select * from c_chkpfw_hr_tr a

+ +

         = +            &= +nbsp;  where exists(select 1 from +chkpfw_tr_hr_dimension b

+ +

         = +            &= +nbsp;           &n= +bsp;  WHERE a.firstoccurrence +=3D b.firstoccurrence

+ +

         = +            &= +nbsp;           &n= +bsp;   AND a.sentryid_id =3D +b.sentryid_id

+ +

         = +            &= +nbsp;           &n= +bsp;   AND a.node_id =3D +b.node_id        = +          = + 

+ +

         = +            &= +nbsp;           &n= +bsp;   AND a.customerid_id =3D +b.customerid_id

+ +

         = +            &= +nbsp;           &n= +bsp;   AND +coalesce(a.interface_id,0) =3D = +coalesce(b.interface_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;   AND +coalesce(a.source_id,0) =3D = +coalesce(b.source_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;   AND +coalesce(a.destination_id,0) =3D = +coalesce(b.destination_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;   AND coalesce(a.sourceport_id,0) +=3D coalesce(b.sourceport_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;   AND +coalesce(a.destinationport_id,0) =3D = +coalesce(b.destinationport_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;   AND +coalesce(a.inoutbound_id,0) =3D = +coalesce(b.inoutbound_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;   AND +coalesce(a.action_id,0) =3D = +coalesce(b.action_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;   AND coalesce(a.protocol_id,0) +=3D coalesce(b.protocol_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;   AND +coalesce(a.service_id,0) =3D = +coalesce(b.service_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;   AND +coalesce(a.sourcezone_id,0) =3D = +coalesce(b.sourcezone_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;   AND +coalesce(a.destinationzone_id,0) =3D = +coalesce(b.destinationzone_id,0));

+ +

 

+ +

This takes forever (I have to cancel the statement = +each +time)

+ +

 

+ +

c_chkpfw_hr_tr has about 20000 = +rows

+ +

chkpfw_tr_hr_dimension has 150K = +rows

+ +

 

+ +

c_chkpfw_hr_tr has same indexes as = +chkpfw_tr_hr_dimension

+ +

 

+ +

For such a small data set, this seems like a mystery. = +The +only other alternative I have is to use cursors which are also very slow = +for +row sets of 10- 15K or more.

+ +
+ + + + + +------_=_NextPart_001_01C6624D.DC39826D-- + +From pgsql-performance-owner@postgresql.org Mon Apr 17 15:52:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 1596511F623E + for ; + Mon, 17 Apr 2006 15:52:40 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.457 +X-Spam-Level: +X-Spam-Status: No, score=-2.457 required=5 tests=[AWL=0.141, BAYES_00=-2.599, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id Vzu8L-QgZztZ + for ; + Mon, 17 Apr 2006 15:52:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id 51E6C11F6A98 + for ; + Mon, 17 Apr 2006 15:52:29 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Mon, 17 Apr 2006 18:52:27 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145299946963; Mon, 17 Apr 2006 11:52:26 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Mon, 17 Apr 2006 11:52:26 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Mon, 17 Apr 2006 11:52:26 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145299941414; Mon, 17 Apr 2006 11:52:21 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C66250.0ED1C928" +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: creating of temporary table takes very long +Date: Mon, 17 Apr 2006 11:52:15 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF0406A633@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] creating of temporary table takes very long +Thread-Index: AcZiTdk6W0MPG7GkTfe8tYyes6Z3RgAAhskg +From: "Sriram Dandapani" +To: "Sriram Dandapani" , + "Pgsql-Performance \(E-mail\)" +X-Archive-Number: 200604/359 +X-Sequence-Number: 18443 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C66250.0ED1C928 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Explain analyze on the select statement that is the basis for temp table +data takes forever. I turned off enable_seqscan but it did not have an +effect + +=20 + +________________________________ + +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Sriram +Dandapani +Sent: Monday, April 17, 2006 11:37 AM +To: Pgsql-Performance (E-mail) +Subject: [PERFORM] creating of temporary table takes very long + +=20 + +create temporary table c_chkpfw_hr_tr_updates as + + select * from c_chkpfw_hr_tr a + + where exists(select 1 from +chkpfw_tr_hr_dimension b + + WHERE a.firstoccurrence =3D +b.firstoccurrence + + AND a.sentryid_id =3D b.sentryid_id + + AND a.node_id =3D b.node_id + + + AND a.customerid_id =3D +b.customerid_id + + AND coalesce(a.interface_id,0) =3D +coalesce(b.interface_id,0) + + AND coalesce(a.source_id,0) =3D +coalesce(b.source_id,0) + + AND coalesce(a.destination_id,0) = +=3D +coalesce(b.destination_id,0) + + AND coalesce(a.sourceport_id,0) =3D +coalesce(b.sourceport_id,0) + + AND +coalesce(a.destinationport_id,0) =3D coalesce(b.destinationport_id,0) + + AND coalesce(a.inoutbound_id,0) =3D +coalesce(b.inoutbound_id,0) + + AND coalesce(a.action_id,0) =3D +coalesce(b.action_id,0) + + AND coalesce(a.protocol_id,0) =3D +coalesce(b.protocol_id,0) + + AND coalesce(a.service_id,0) =3D +coalesce(b.service_id,0) + + AND coalesce(a.sourcezone_id,0) =3D +coalesce(b.sourcezone_id,0) + + AND +coalesce(a.destinationzone_id,0) =3D coalesce(b.destinationzone_id,0)); + +=20 + +This takes forever (I have to cancel the statement each time) + +=20 + +c_chkpfw_hr_tr has about 20000 rows + +chkpfw_tr_hr_dimension has 150K rows + +=20 + +c_chkpfw_hr_tr has same indexes as chkpfw_tr_hr_dimension + +=20 + +For such a small data set, this seems like a mystery. The only other +alternative I have is to use cursors which are also very slow for row +sets of 10- 15K or more. + + +------_=_NextPart_001_01C66250.0ED1C928 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + +
+ +

Explain analyze on the select = +statement +that is the basis for temp table data takes forever. I turned off = +enable_seqscan +but it did not have an effect

+ +

 

+ +
+ +
+ +
+ +
+ +

From: +pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Sriram Dandapani
+Sent: Monday, April 17, = +2006 11:37 +AM
+To: Pgsql-Performance = +(E-mail)
+Subject: [PERFORM] = +creating of +temporary table takes very long

+ +
+ +

 

+ +

create temporary table c_chkpfw_hr_tr_updates = +as

+ +

         = +            &= +nbsp;  +select * from c_chkpfw_hr_tr a

+ +

         = +            &= +nbsp;  +where exists(select 1 from chkpfw_tr_hr_dimension = +b

+ +

         = +            &= +nbsp;           &n= +bsp;  +WHERE a.firstoccurrence =3D = +b.firstoccurrence

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND a.sentryid_id =3D b.sentryid_id

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND a.node_id =3D b.node_id        +          = + 

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND a.customerid_id =3D = +b.customerid_id

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.interface_id,0) =3D = +coalesce(b.interface_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.source_id,0) =3D = +coalesce(b.source_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.destination_id,0) =3D = +coalesce(b.destination_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.sourceport_id,0) =3D = +coalesce(b.sourceport_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.destinationport_id,0) =3D = +coalesce(b.destinationport_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.inoutbound_id,0) =3D = +coalesce(b.inoutbound_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.action_id,0) =3D = +coalesce(b.action_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.protocol_id,0) =3D = +coalesce(b.protocol_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.service_id,0) =3D = +coalesce(b.service_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.sourcezone_id,0) =3D = +coalesce(b.sourcezone_id,0)

+ +

         = +            &= +nbsp;           &n= +bsp;  + AND coalesce(a.destinationzone_id,0) =3D = +coalesce(b.destinationzone_id,0));

+ +

 

+ +

This takes forever (I have to cancel the statement = +each +time)

+ +

 

+ +

c_chkpfw_hr_tr has about 20000 = +rows

+ +

chkpfw_tr_hr_dimension has 150K = +rows

+ +

 

+ +

c_chkpfw_hr_tr has same indexes as = +chkpfw_tr_hr_dimension

+ +

 

+ +

For such a small data set, this seems like a mystery. = +The +only other alternative I have is to use cursors which are also very slow = +for +row sets of 10- 15K or more.

+ +
+ + + + + +------_=_NextPart_001_01C66250.0ED1C928-- + +From pgsql-performance-owner@postgresql.org Mon Apr 17 16:28:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D4E6A11F6B63 + for ; + Mon, 17 Apr 2006 16:28:43 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.128 +X-Spam-Level: +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id IF34CwPLIfso + for ; + Mon, 17 Apr 2006 16:28:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 9B14811F6B1C + for ; + Mon, 17 Apr 2006 16:28:40 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3HJScrk004410; + Mon, 17 Apr 2006 15:28:38 -0400 (EDT) +To: "Sriram Dandapani" +cc: "Pgsql-Performance \(E-mail\)" +Subject: Re: creating of temporary table takes very long +In-reply-to: <6992E470F12A444BB787B5C937B9D4DF0406A629@ca-mail1.cis.local> +References: <6992E470F12A444BB787B5C937B9D4DF0406A629@ca-mail1.cis.local> +Comments: In-reply-to "Sriram Dandapani" + message dated "Mon, 17 Apr 2006 11:36:32 -0700" +Date: Mon, 17 Apr 2006 15:28:38 -0400 +Message-ID: <4409.1145302118@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/360 +X-Sequence-Number: 18444 + +"Sriram Dandapani" writes: +> [ query snipped ] +> This takes forever (I have to cancel the statement each time) + +How long did you wait? + +> c_chkpfw_hr_tr has same indexes as chkpfw_tr_hr_dimension + +Which would be what exactly? What does EXPLAIN show for that SELECT? +(I won't make you post EXPLAIN ANALYZE, if you haven't got the patience +to let it finish, but you should at least provide EXPLAIN results.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 17 16:49:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 2CB2311F6747 + for ; + Mon, 17 Apr 2006 16:49:23 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.473 +X-Spam-Level: +X-Spam-Status: No, score=-2.473 required=5 tests=[AWL=0.126, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id jgNEtN6P+kMf + for ; + Mon, 17 Apr 2006 16:49:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id 73BE111F6294 + for ; + Mon, 17 Apr 2006 16:49:13 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Mon, 17 Apr 2006 19:49:08 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145303348477; Mon, 17 Apr 2006 12:49:08 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Mon, 17 Apr 2006 12:49:08 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Mon, 17 Apr 2006 12:49:08 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145303343158; Mon, 17 Apr 2006 12:49:03 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: creating of temporary table takes very long +Date: Mon, 17 Apr 2006 12:48:57 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF0406A650@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] creating of temporary table takes very long +Thread-Index: AcZiVSuT1YQn7NYIRp6Zx+/XXcGD4AAArE2A +From: "Sriram Dandapani" +To: "Tom Lane" +Cc: "Pgsql-Performance \(E-mail\)" +X-Archive-Number: 200604/361 +X-Sequence-Number: 18445 + +Explain output. I tried explain analyze but pgadmin froze after 10 +minutes. + + +QUERY PLAN +"Seq Scan on c_chkpfw_hr_tr a (cost=3D0.00..225975659.89 rows=3D11000 +width=3D136)" +" Filter: (subplan)" +" SubPlan" +" -> Bitmap Heap Scan on chkpfw_tr_hr_dimension b +(cost=3D1474.64..10271.13 rows=3D1 width=3D0)" +" Recheck Cond: (($0 =3D firstoccurrence) AND ($1 =3D = +sentryid_id) +AND ($2 =3D node_id))" +" Filter: (($3 =3D customerid_id) AND (COALESCE($4, 0) =3D +COALESCE(interface_id, 0)) AND (COALESCE($5, 0) =3D COALESCE(source_id, +0)) AND (COALESCE($6, 0) =3D COALESCE(destination_id, 0)) AND +(COALESCE($7, 0) =3D COALESCE(sourceport_id, 0)) AND (COALESCE($8, 0) = +=3D +COALESCE(destinationport_id, 0)) AND (COALESCE($9, 0) =3D +COALESCE(inoutbound_id, 0)) AND (COALESCE($10, 0) =3D = +COALESCE(action_id, +0)) AND (COALESCE($11, 0) =3D COALESCE(protocol_id, 0)) AND = +(COALESCE($12, +0) =3D COALESCE(service_id, 0)) AND (COALESCE($13, 0) =3D +COALESCE(sourcezone_id, 0)) AND (COALESCE($14, 0) =3D +COALESCE(destinationzone_id, 0)))" +" -> Bitmap Index Scan on chkpfw_tr_hr_idx1 +(cost=3D0.00..1474.64 rows=3D38663 width=3D0)" +" Index Cond: (($0 =3D firstoccurrence) AND ($1 =3D +sentryid_id) AND ($2 =3D node_id))" + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Monday, April 17, 2006 12:29 PM +To: Sriram Dandapani +Cc: Pgsql-Performance (E-mail) +Subject: Re: [PERFORM] creating of temporary table takes very long=20 + +"Sriram Dandapani" writes: +> [ query snipped ] +> This takes forever (I have to cancel the statement each time) + +How long did you wait? + +> c_chkpfw_hr_tr has same indexes as chkpfw_tr_hr_dimension + +Which would be what exactly? What does EXPLAIN show for that SELECT? +(I won't make you post EXPLAIN ANALYZE, if you haven't got the patience +to let it finish, but you should at least provide EXPLAIN results.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 17 17:05:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 03A3911F670E + for ; + Mon, 17 Apr 2006 17:05:39 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.486 +X-Spam-Level: +X-Spam-Status: No, score=-2.486 required=5 tests=[AWL=0.113, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 5E-2OKBdI80k + for ; + Mon, 17 Apr 2006 17:05:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id C708C11F66F8 + for ; + Mon, 17 Apr 2006 17:05:31 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Mon, 17 Apr 2006 20:05:29 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145304328688; Mon, 17 Apr 2006 13:05:28 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Mon, 17 Apr 2006 13:05:28 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Mon, 17 Apr 2006 13:05:28 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145304323277; Mon, 17 Apr 2006 13:05:23 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: creating of temporary table takes very long +Date: Mon, 17 Apr 2006 13:05:17 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF0406A654@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] creating of temporary table takes very long +Thread-Index: AcZiVSuT1YQn7NYIRp6Zx+/XXcGD4AABRD1g +From: "Sriram Dandapani" +To: "Tom Lane" +Cc: "Pgsql-Performance \(E-mail\)" +X-Archive-Number: 200604/362 +X-Sequence-Number: 18446 + +Got an explain analyze output..Here it is + + +"Seq Scan on c_chkpfw_hr_tr a (cost=3D0.00..225975659.89 rows=3D11000 +width=3D136) (actual time=3D2.345..648070.474 rows=3D22001 loops=3D1)" +" Filter: (subplan)" +" SubPlan" +" -> Bitmap Heap Scan on chkpfw_tr_hr_dimension b +(cost=3D1474.64..10271.13 rows=3D1 width=3D0) (actual = +time=3D29.439..29.439 +rows=3D1 loops=3D22001)" +" Recheck Cond: (($0 =3D firstoccurrence) AND ($1 =3D = +sentryid_id) +AND ($2 =3D node_id))" +" Filter: (($3 =3D customerid_id) AND (COALESCE($4, 0) =3D +COALESCE(interface_id, 0)) AND (COALESCE($5, 0) =3D COALESCE(source_id, +0)) AND (COALESCE($6, 0) =3D COALESCE(destination_id, 0)) AND +(COALESCE($7, 0) =3D COALESCE(sourceport_id, 0)) AND (COALESCE($8 (..)" +" -> Bitmap Index Scan on chkpfw_tr_hr_idx1 +(cost=3D0.00..1474.64 rows=3D38663 width=3D0) (actual = +time=3D12.144..12.144 +rows=3D33026 loops=3D22001)" +" Index Cond: (($0 =3D firstoccurrence) AND ($1 =3D +sentryid_id) AND ($2 =3D node_id))" +"Total runtime: 648097.800 ms" + +Regards + +Sriram + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Monday, April 17, 2006 12:29 PM +To: Sriram Dandapani +Cc: Pgsql-Performance (E-mail) +Subject: Re: [PERFORM] creating of temporary table takes very long=20 + +"Sriram Dandapani" writes: +> [ query snipped ] +> This takes forever (I have to cancel the statement each time) + +How long did you wait? + +> c_chkpfw_hr_tr has same indexes as chkpfw_tr_hr_dimension + +Which would be what exactly? What does EXPLAIN show for that SELECT? +(I won't make you post EXPLAIN ANALYZE, if you haven't got the patience +to let it finish, but you should at least provide EXPLAIN results.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 01:55:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4A4EC11F7A7C + for ; + Tue, 18 Apr 2006 01:55:13 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 2.404 +X-Spam-Level: ** +X-Spam-Status: No, score=2.404 required=5 tests=[AWL=0.072, + FROM_LOCAL_NOVOWEL=2.331, HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id xwrDI+hUuasQ + for ; + Tue, 18 Apr 2006 01:55:08 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.201]) + by postgresql.org (Postfix) with ESMTP id 11EED11F66FF + for ; + Tue, 18 Apr 2006 01:55:08 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id m7so646837nzf + for ; + Mon, 17 Apr 2006 21:55:08 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=GfzVZZAQTJabbmhLp+YmL7q9ZTZKir2xbzamFy1jJhVRLO9zXKtuDMcYO2s0xafzS2bHV2RNK1QtCkHuB6Lx2lhmkN3WKgG0IlXeaBxLe6KsqB2XexqjZ2YcTuykMyGTOpEHYj1ZD0B8a7wOr852GcYcqHYuyctC6/xNGRAjOq0= +Received: by 10.36.80.5 with SMTP id d5mr2944367nzb; + Mon, 17 Apr 2006 21:55:08 -0700 (PDT) +Received: by 10.36.158.13 with HTTP; Mon, 17 Apr 2006 21:55:08 -0700 (PDT) +Message-ID: +Date: Tue, 18 Apr 2006 08:55:08 +0400 +From: Luckys +To: "Sriram Dandapani" +Subject: Re: slow cursor +Cc: "Pgsql-Performance (E-mail)" +In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF0406A546@ca-mail1.cis.local> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_481_2441224.1145336108522" +References: <6992E470F12A444BB787B5C937B9D4DF0406A546@ca-mail1.cis.local> +X-Archive-Number: 200604/363 +X-Sequence-Number: 18447 + +------=_Part_481_2441224.1145336108522 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +This is one thing that I always try to avoid, a single INSERT INTO...SELECT +...FROM or single UPDATE is always faster compared to looping the same +within a cursor, unless its inevitable. + +regards, +Luckys. + + +On 4/17/06, Sriram Dandapani wrote: +> +> Hi +> +> +> +> I have a cursor that fetches 150K rows and updates or inserts a table wit= +h +> 150K rows. +> +> +> +> It takes several minutes for the process to complete (about 15 minutes). +> The select by itself (without cursor) gets all rows in 15 seconds. +> +> +> +> Is there a way to optimize the cursor to fetch all records and speed up +> the process. I still need to do the record by record processing +> + +------=_Part_481_2441224.1145336108522 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
This is one thing that I always try to avoid, a single INSERT INTO...S= +ELECT ...FROM or single UPDATE is always faster compared to looping the sam= +e within a cursor, unless its inevitable.
+
 
+
regards,
+
Luckys.

 
+
On 4/17/06, = +Sriram Dandapani <sdan= +dapani@counterpane.com> wrote: +
+
+
+

Hi

+

 

+

I have a cursor that fetches 150K rows and updates or inserts a= + table with 150K rows.

+

 

+

It takes several minutes for the process to complete (about 15 = +minutes). The select by itself (without cursor) gets all rows in 15 seconds= +. +

+

 

+

Is there a way to optimize the cursor to fetch all records and = +speed up the process. I still need to do the record by record processing +

+
 
+
 

 
+ +------=_Part_481_2441224.1145336108522-- + +From pgsql-performance-owner@postgresql.org Tue Apr 18 05:10:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 31B5D11F6901 + for ; + Tue, 18 Apr 2006 05:10:41 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.5 +X-Spam-Level: +X-Spam-Status: No, score=-2.5 required=5 tests=[AWL=0.101, BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 6OznhzHyvHzt + for ; + Tue, 18 Apr 2006 05:10:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (fon.nation-net.com [194.24.251.1]) + by postgresql.org (Postfix) with ESMTP id 9F0AD11F6CC0 + for ; + Tue, 18 Apr 2006 05:10:30 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id 3E3411369F9 + for ; + Tue, 18 Apr 2006 09:10:28 +0100 (BST) +Received: from [194.24.251.10] (bum.net [194.24.251.10]) + by fon.nation-net.com (Postfix) with ESMTP id 2E58C13698E + for ; + Tue, 18 Apr 2006 09:10:28 +0100 (BST) +Message-ID: <44449E4C.7040804@laterooms.com> +Date: Tue, 18 Apr 2006 09:07:40 +0100 +From: Gavin Hamill +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Slow query - possible bug? +References: <443E3DF5.4020207@laterooms.com> + <3c1395330604130546g6b091f75x511955817fe65dcd@mail.gmail.com> + <443E4C9D.3090301@laterooms.com> <20329.1144942010@sss.pgh.pa.us> +In-Reply-To: <20329.1144942010@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AV-Checked: ClamAV using ClamSMTP +X-Archive-Number: 200604/364 +X-Sequence-Number: 18448 + +Tom Lane wrote: + +>Gavin Hamill writes: +> +> +>>If I replace the +>>(allocation0_."Date" between '2006-06-09 00:00:00.000000' and +>>'2006-06-09 00:00:00.000000') +>>with +>>allocation0_."Date" ='2006-04-09 00:00:00.000000' +>>then the query comes back in a few milliseconds (as I'd expect :) +>> +>> +> +>Could we see EXPLAIN ANALYZE for +>* both forms of the date condition, with the roomid condition; +>* both forms of the date condition, WITHOUT the roomid condition; +>* just the roomid condition +> +>I'm thinking the planner is misestimating something, but it's hard +>to tell what without breaking it down. +> +> + +Of course. In each case, I have changed the date by two weeks to try and +minimise the effect of any query caching. + +The base query is "explain analyse select allocation0_."ID" as y1_, +allocation0_."RoomID" as y2_, allocation0_."StatusID" as y4_, +allocation0_."Price" as y3_, allocation0_."Number" as y5_, +allocation0_."Date" as y6_ from "Allocation" allocation0_ where" + +now both forms of the Date condition + +a) + +(allocation0_."Date" between '2006-04-25 00:00:00.000000' and +'2006-04-25 00:00:00.000000')and(allocation0_."RoomID" in(211800)); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using ix_date on "Allocation" allocation0_ (cost=0.00..4.77 +rows=1 width=34) (actual time=3253.340..48040.396 rows=1 loops=1) + Index Cond: (("Date" >= '2006-04-25'::date) AND ("Date" <= +'2006-04-25'::date)) + Filter: ("RoomID" = 211800) + Total runtime: 48040.451 ms (ouch!) + + +b) + +(allocation0_."Date"= '2006-05-10 +00:00:00.000000'::date)and(allocation0_."RoomID" in(211800)); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using ix_dateroom on "Allocation" allocation0_ +(cost=0.00..5.01 rows=1 width=34) (actual time=0.033..0.035 rows=1 loops=1) + Index Cond: (("RoomID" = 211800) AND ("Date" = '2006-05-10'::date)) + Total runtime: 0.075 ms (whoosh!) + +And now without the RoomID condition: + +a) +(allocation0_."Date" between '2006-06-10 00:00:00.000000' and +'2006-06-10 00:00:00.000000'); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using ix_date on "Allocation" allocation0_ (cost=0.00..4.77 +rows=1 width=34) (actual time=0.035..6706.467 rows=34220 loops=1) + Index Cond: (("Date" >= '2006-06-10'::date) AND ("Date" <= +'2006-06-10'::date)) + Total runtime: 6728.743 ms + +b) +(allocation0_."Date"= '2006-05-25 00:00:00.000000'::date); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------- + Bitmap Heap Scan on "Allocation" allocation0_ (cost=87.46..25017.67 +rows=13845 width=34) (actual time=207.674..9702.656 rows=34241 loops=1) + Recheck Cond: ("Date" = '2006-05-25'::date) + -> Bitmap Index Scan on ix_date (cost=0.00..87.46 rows=13845 +width=0) (actual time=185.086..185.086 rows=42705 loops=1) + Index Cond: ("Date" = '2006-05-25'::date) + Total runtime: 9725.470 ms + + +Wow, I'm not really sure what that tells me... + +Cheers, +Gavin. + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 05:51:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 30BC311F61D9 + for ; + Tue, 18 Apr 2006 05:51:00 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id N8ovFrGFe7fh + for ; + Tue, 18 Apr 2006 05:50:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.wirelesscar.com (mail.wirelesscar.com [212.209.35.30]) + by postgresql.org (Postfix) with ESMTP id 217E211F61BF + for ; + Tue, 18 Apr 2006 05:50:55 -0300 (ADT) +Received: from sesrv12.wirelesscar.com ([192.168.10.17]) by + mail.wirelesscar.com with InterScan Messaging Security Suite; + Tue, 18 Apr 2006 10:50:43 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Migration study, step 2: rewriting queries +Date: Tue, 18 Apr 2006 10:51:26 +0200 +Message-ID: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3D30@sesrv12.wirelesscar.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Migration study, step 2: rewriting queries +Thread-Index: AcZhv18OspJ4tdZXRP2K2QQNNoCSIABBFXVw +From: "Mikael Carneholm" +To: "Tom Lane" +Cc: "Pgsql performance" +X-Archive-Number: 200604/365 +X-Sequence-Number: 18449 + +>This should be fixed by the changes I made recently in +choose_bitmap_and +>--- it wasn't being aggressive about pruning overlapping AND conditions +when a sub-OR was involved. It's possible the new coding is >*too* +aggressive, and will reject indexes that it'd be profitable to include; +but at least it won't make this particular mistake. + +Ok, cool. I don't have time to test this right now as the project has to +move on (and I guess testing the fix would require a dump+build CVS +version+restore), but as a temporary workaround I simly dropped the +xda_dat index (all queries on that table include the +person_information__id column anyway). + +- Mikael + + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 06:02:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6062211F621B + for ; + Tue, 18 Apr 2006 06:02:30 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.106 +X-Spam-Level: +X-Spam-Status: No, score=0.106 required=5 tests=[AWL=0.106] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id pvpqbVOzNkeP + for ; + Tue, 18 Apr 2006 06:02:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id B0DD211F61BC + for ; + Tue, 18 Apr 2006 06:02:26 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (Tba08.t.pppool.de + [89.55.186.8]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 7A7C9656CD; + Tue, 18 Apr 2006 11:03:21 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 91B64181C1F3F; + Tue, 18 Apr 2006 11:02:37 +0200 (CEST) +Message-ID: <4444AB2A.5080607@logix-tt.com> +Date: Tue, 18 Apr 2006 11:02:34 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Francisco Reyes +Cc: Pgsql performance +Subject: Re: Inserts optimization? +References: + <200604141400.38982.mcousin@sigma.fr> + +In-Reply-To: +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/366 +X-Sequence-Number: 18450 + +Hi, Francisco, + +Francisco Reyes wrote: + +> I only wonder what is safer.. using a second or two in commit_delay or +> using fsync = off.. Anyone cares to comment? + +It might be that you misunderstood commit_delay. It will not only delay +the disk write, but also block your connnection until the write actually +is performed. + +It will rise the throughput in multi-client scenarios, but will also +rise the latency, and it will absolutely bring no speedup in +single-client scenarios. + +It does not decrease safety (in opposite to fsync=off), data will be +consistent, and any application that has successfully finished a commit +can be shure their data is on the platters.[1] + +HTH, +Markus + +[1] As long as the platters don't lie, but that's another subject. + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Tue Apr 18 07:52:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 5283711F6250 + for ; + Tue, 18 Apr 2006 07:52:25 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.115 +X-Spam-Level: +X-Spam-Status: No, score=0.115 required=5 tests=[AWL=0.115] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 5VFXN8ZPUWeq + for ; + Tue, 18 Apr 2006 07:51:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id E9AA311F621A + for ; + Tue, 18 Apr 2006 07:51:42 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (Tba08.t.pppool.de + [89.55.186.8]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 053B8656CD + for ; + Tue, 18 Apr 2006 12:52:42 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 2B756181C1F3F + for ; + Tue, 18 Apr 2006 12:52:00 +0200 (CEST) +Message-ID: <4444C4CF.2000106@logix-tt.com> +Date: Tue, 18 Apr 2006 12:51:59 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> +In-Reply-To: <11035.1145033929@sss.pgh.pa.us> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-15 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/367 +X-Sequence-Number: 18451 + +Hi, Tom, + +Tom Lane wrote: + +> Well, the other thing that's going on here is that we know we are +> overestimating the cost of nestloop-with-inner-indexscan plans. +> The current estimation for that is basically "outer scan cost plus N +> times inner scan cost" where N is the estimated number of outer tuples; +> in other words the repeated indexscan probes are each assumed to happen +> from a cold start. In reality, caching of the upper levels of the index +> means that the later index probes are much cheaper than this model +> thinks. We've known about this for some time but no one's yet proposed +> a more reasonable cost model. + +My spontaneus guess would be to use log(N)*inner instead of N*inner. I +don't have any backings for that, it's just what my intuition tells me +as a first shot. + +> In my mind this is tied into another issue, which is that the planner +> always costs on the basis of each query starting from zero. In a real +> environment it's much cheaper to use heavily-used indexes than this cost +> model suggests, because they'll already be swapped in due to use by +> previous queries. But we haven't got any infrastructure to keep track +> of what's been heavily used, let alone a cost model that could make use +> of the info. + +An easy first approach would be to add a user tunable cache probability +value to each index (and possibly table) between 0 and 1. Then simply +multiply random_page_cost with (1-that value) for each scan. + +Later, this value could be automatically tuned by stats analysis or +other means. + +> I think part of the reason that people commonly reduce random_page_cost +> to values much lower than physical reality would suggest is that it +> provides a crude way of partially compensating for this basic problem. + +I totall agree with this, it's just what we did here from time to time. :-) + +Hmm, how does effective_cach_size correspond with it? Shouldn't a high +effective_cache_size have a similar effect? + +Thanks, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Tue Apr 18 08:56:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C1C5611F6C90 + for ; + Tue, 18 Apr 2006 08:56:56 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.11 +X-Spam-Level: +X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Mjlfd4G8rw94 + for ; + Tue, 18 Apr 2006 08:56:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by postgresql.org (Postfix) with ESMTP id 3431811F6639 + for ; + Tue, 18 Apr 2006 08:56:44 -0300 (ADT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 169898F287; Tue, 18 Apr 2006 13:56:45 +0200 (CEST) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: Inserts optimization? +Date: Tue, 18 Apr 2006 13:56:44 +0200 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Inserts optimization? +Thread-Index: AcZf3hCsxf4bgfqPS4+yfEoO2wWLAADABMGQ +From: "Magnus Hagander" +To: "Francisco Reyes" , + "Marc Cousin" +Cc: "Chris" , + "Pgsql performance" +X-Archive-Number: 200604/368 +X-Sequence-Number: 18452 + +> > For now, I only could get good performance with bacula and=20 +> postgresql=20 +> > when disabling fsync... +>=20 +>=20 +> Isn't that less safe? + +Most definitly. + +FWIW, I'm getting pretty good speeds with Bacula and PostgreSQL on a +reasonably small db (file table about 40 million rows, filename about +5.2 million and path 1.5 million).=20 + +Config changes are increasing shared mem and work mems, fsm pages, +wal_sync_method=3Dfdatasync, wal_buffers=3D16, checkpoint_segments=3D8, +default_with_oids=3Doff (before creating the bacula tables, so they = +don't +use oids). + +Used to run with full_pages_writes=3Doff, but not anymore since it's not +safe. + + +> Also planning to check commit_delay and see if that helps. +> I will try to avoid 2 or more machines backing up at the same=20 +> time.. plus in a couple of weeks I should have a better=20 +> machine for the DB anyways.. + +Bacula already serializes access to the database (they have to support +mysql/myisam), so this shouldn't help. Actually, it might well hurt by +introducing extra delays. + +> I only wonder what is safer.. using a second or two in=20 +> commit_delay or using=20 +> fsync =3D off.. Anyone cares to comment? + +Absolutely a commit_delay. + + +//Magnus + +From pgsql-performance-owner@postgresql.org Tue Apr 18 10:08:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4DD7F11F6927 + for ; + Tue, 18 Apr 2006 10:08:49 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 6KxWC6VgmPQb + for ; + Tue, 18 Apr 2006 10:08:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) + by postgresql.org (Postfix) with ESMTP id C27C711F670B + for ; + Tue, 18 Apr 2006 10:08:45 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by pjetlic.mobart.hr (Postfix) with ESMTP id 9AE241745F + for ; + Tue, 18 Apr 2006 15:08:41 +0200 (CEST) +Received: from pjetlic.mobart.hr ([127.0.0.1]) + by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 15522-01-5 for ; + Tue, 18 Apr 2006 15:08:41 +0200 (CEST) +Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by pjetlic.mobart.hr (Postfix) with ESMTP id 7F00E17443 + for ; + Tue, 18 Apr 2006 15:08:41 +0200 (CEST) +Subject: SELECT FOR UPDATE performance is bad +From: Mario Splivalo +Reply-To: mario.splivalo@mobart.hr +To: Pgsql performance +Content-Type: text/plain +Organization: Mob-Art +Date: Tue, 18 Apr 2006 15:08:39 +0200 +Message-Id: <1145365720.18469.35.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by OpenSource AV+AS Mail Server +X-Archive-Number: 200604/369 +X-Sequence-Number: 18453 + +For the purpose of the application I need to establish some form of +serialization, therefore I use FOR UPDATE. The query, inside the +function, is like this: + +pulitzer2=# explain analyze select id FROM messages JOIN +ticketing_codes_played ON id = message_id WHERE service_id = 1102 AND +receiving_time BETWEEN '2006-03-01' AND '2006-06-30' FOR UPDATE; + +QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=32131.04..34281.86 rows=627 width=16) (actual +time=742.806..1491.864 rows=58005 loops=1) + Hash Cond: ("outer".message_id = "inner".id) + -> Seq Scan on ticketing_codes_played (cost=0.00..857.17 rows=57217 +width=10) (actual time=0.024..209.331 rows=58005 loops=1) + -> Hash (cost=32090.60..32090.60 rows=16177 width=10) (actual +time=742.601..742.601 rows=65596 loops=1) + -> Bitmap Heap Scan on messages (cost=4153.51..32090.60 +rows=16177 width=10) (actual time=160.555..489.459 rows=65596 loops=1) + Recheck Cond: ((service_id = 1102) AND (receiving_time >= +'2006-03-01 00:00:00+01'::timestamp with time zone) AND (receiving_time +<= '2006-06-30 00:00:00+02'::timestamp with time zone)) + -> BitmapAnd (cost=4153.51..4153.51 rows=16177 width=0) +(actual time=156.900..156.900 rows=0 loops=1) + -> Bitmap Index Scan on idx_service_id +(cost=0.00..469.31 rows=68945 width=0) (actual time=16.661..16.661 +rows=66492 loops=1) + Index Cond: (service_id = 1102) + -> Bitmap Index Scan on +idx_messages_receiving_time (cost=0.00..3683.95 rows=346659 width=0) +(actual time=137.526..137.526 rows=360754 loops=1) + Index Cond: ((receiving_time >= '2006-03-01 +00:00:00+01'::timestamp with time zone) AND (receiving_time <= +'2006-06-30 00:00:00+02'::timestamp with time zone)) + Total runtime: 6401.954 ms +(12 rows) + + + +Now, this query takes between 8 and 30 seconds, wich is a lot, since +during the day we have almost 20 requests per minute. I notice that +during the execution of the above mentioned query i/o goes bezerk, +iostat tells me that load is around 60%. I tried playing with WAL +configuration parametars, even put the log on separate disk spindles, it +did nothing. + +Shall I reconsider the need for the exact lock I developed, or there is +something more I could do to speed the things up? + + Mario +-- +Mario Splivalo +Mob-Art +mario.splivalo@mobart.hr + +"I can do it quick, I can do it cheap, I can do it well. Pick any two." + + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 11:31:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 7140E11F6248 + for ; + Tue, 18 Apr 2006 11:31:09 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.25 +X-Spam-Level: +X-Spam-Status: No, score=-2.25 required=5 tests=[AWL=0.351, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id tHJWWbdjNmWd + for ; + Tue, 18 Apr 2006 11:31:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 6197811F60AB + for ; + Tue, 18 Apr 2006 11:31:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IEUw9m013038; + Tue, 18 Apr 2006 10:30:58 -0400 (EDT) +To: mario.splivalo@mobart.hr +cc: Pgsql performance +Subject: Re: SELECT FOR UPDATE performance is bad +In-reply-to: <1145365720.18469.35.camel@localhost.localdomain> +References: <1145365720.18469.35.camel@localhost.localdomain> +Comments: In-reply-to Mario Splivalo + message dated "Tue, 18 Apr 2006 15:08:39 +0200" +Date: Tue, 18 Apr 2006 10:30:58 -0400 +Message-ID: <13037.1145370658@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/370 +X-Sequence-Number: 18454 + +Mario Splivalo writes: +> For the purpose of the application I need to establish some form of +> serialization, therefore I use FOR UPDATE. The query, inside the +> function, is like this: + +> pulitzer2=# explain analyze select id FROM messages JOIN +> ticketing_codes_played ON id = message_id WHERE service_id = 1102 AND +> receiving_time BETWEEN '2006-03-01' AND '2006-06-30' FOR UPDATE; + +> Hash Join (cost=32131.04..34281.86 rows=627 width=16) (actual +> time=742.806..1491.864 rows=58005 loops=1) + ^^^^^ + +> Now, this query takes between 8 and 30 seconds, wich is a lot, since +> during the day we have almost 20 requests per minute. + +Acquiring a row lock separately for each of 58000 rows is not going to +be a cheap operation. Especially not if anyone else is locking any of +the same rows and thereby blocking you. If there is concurrent locking, +you're also running a big risk of deadlock because two processes might +try to lock the same rows in different orders. + +Are you really intending to update all 58000 rows? If not, what is +the serialization requirement exactly (ie, what are you trying to +accomplish)? Seems like something about this app needs to be +redesigned. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 11:32:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 633F111F66DF + for ; + Tue, 18 Apr 2006 11:32:16 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.128 +X-Spam-Level: +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id oH6bBe-m8njO + for ; + Tue, 18 Apr 2006 11:32:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 46AF711F65E8 + for ; + Tue, 18 Apr 2006 11:32:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IEW3Ia013056; + Tue, 18 Apr 2006 10:32:03 -0400 (EDT) +To: "Mikael Carneholm" +cc: "Pgsql performance" +Subject: Re: Migration study, step 2: rewriting queries +In-reply-to: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3D30@sesrv12.wirelesscar.com> +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3D30@sesrv12.wirelesscar.com> +Comments: In-reply-to "Mikael Carneholm" + message dated "Tue, 18 Apr 2006 10:51:26 +0200" +Date: Tue, 18 Apr 2006 10:32:03 -0400 +Message-ID: <13055.1145370723@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/371 +X-Sequence-Number: 18455 + +"Mikael Carneholm" writes: +> Ok, cool. I don't have time to test this right now as the project has to +> move on (and I guess testing the fix would require a dump+build CVS +> version+restore), but as a temporary workaround I simly dropped the +> xda_dat index (all queries on that table include the +> person_information__id column anyway). + +The patch is in the 8.1 branch so you don't need dump/restore anyway... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 11:38:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id F2CA511F66B8 + for ; + Tue, 18 Apr 2006 11:38:20 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id vuUD9F-1dRg2 + for ; + Tue, 18 Apr 2006 11:38:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mediaskill.de (destiny.mediaskill.de [212.91.236.1]) + by postgresql.org (Postfix) with ESMTP id 5176011F624E + for ; + Tue, 18 Apr 2006 11:38:08 -0300 (ADT) +Received: from localhost ([127.0.0.1]) + by mail.mediaskill.de (Merak 8.3.8) with SMTP id WSB56214 + for ; Tue, 18 Apr 2006 16:35:14 +0200 +Date: Tue, 18 Apr 2006 16:35:13 +0200 +From: "Tarabas (Manuel Rorarius)" +X-Mailer: The Bat! (v3.62.14) Professional +Reply-To: "Tarabas (Manuel Rorarius)" +Organization: mediaskill +X-Priority: 3 (Normal) +Message-ID: <341367953.20060418163513@tarabas.de> +To: pgsql-performance@postgresql.org +Subject: Problem with LIKE-Performance +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/372 +X-Sequence-Number: 18456 + +Hi! + + I am having trouble with like statements on one of my tables. + + I already tried a vacuum and analyze but with no success. + + The database is PostgreSQL Database Server 8.1.3 on i686-pc-mingw32 + +I get the following explain and I am troubled by the very high +"startup_cost" ... does anyone have any idea why that value is so +high? + +{SEQSCAN + :startup_cost 100000000.00 + :total_cost 100021432.33 + :plan_rows 1 + :plan_width 1311 + :targetlist ( + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 1 + } + :resno 1 + :resname image_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 1 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + :resno 2 + :resname customer_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 2 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 3 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + :resno 3 + :resname theme_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 3 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 4 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 4 + } + :resno 4 + :resname gallery_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 4 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 5 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 5 + } + :resno 5 + :resname event_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 5 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 6 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + :resno 6 + :resname width + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 6 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 7 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + :resno 7 + :resname height + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 7 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 8 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 8 + } + :resno 8 + :resname filesize + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 8 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 9 + :vartype 1114 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 9 + } + :resno 9 + :resname uploadtime + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 9 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 10 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 10 + } + :resno 10 + :resname filename + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 10 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 11 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 11 + } + :resno 11 + :resname originalfilename + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 11 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 12 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 12 + } + :resno 12 + :resname thumbname + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 12 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 13 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 13 + } + :resno 13 + :resname previewname + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 13 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 14 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 14 + } + :resno 14 + :resname title + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 14 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 15 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 15 + } + :resno 15 + :resname flags + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 15 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 16 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 16 + } + :resno 16 + :resname photographername + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 16 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 17 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 17 + } + :resno 17 + :resname colors + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 17 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 18 + :vartype 1043 + :vartypmod 68 + :varlevelsup 0 + :varnoold 1 + :varoattno 18 + } + :resno 18 + :resname compression + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 18 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 19 + :vartype 1043 + :vartypmod 68 + :varlevelsup 0 + :varnoold 1 + :varoattno 19 + } + :resno 19 + :resname resolution + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 19 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 20 + :vartype 1043 + :vartypmod 68 + :varlevelsup 0 + :varnoold 1 + :varoattno 20 + } + :resno 20 + :resname colortype + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 20 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 21 + :vartype 1043 + :vartypmod 68 + :varlevelsup 0 + :varnoold 1 + :varoattno 21 + } + :resno 21 + :resname colordepth + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 21 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 22 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 22 + } + :resno 22 + :resname sort + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 22 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 23 + :vartype 1114 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 23 + } + :resno 23 + :resname creationtime + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 23 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 24 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 24 + } + :resno 24 + :resname creationlocation + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 24 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 25 + :vartype 25 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 25 + } + :resno 25 + :resname description + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 25 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 26 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 26 + } + :resno 26 + :resname cameravendor_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 26 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 27 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 27 + } + :resno 27 + :resname cameramodel_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 27 + :resjunk false + } + ) + :qual ( + {OPEXPR + :opno 1209 + :opfuncid 850 + :opresulttype 16 + :opretset false + :args ( + {RELABELTYPE + :arg + {VAR + :varno 1 + :varattno 14 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 14 + } + :resulttype 25 + :resulttypmod -1 + :relabelformat 0 + } + {CONST + :consttype 25 + :constlen -1 + :constbyval false + :constisnull false + :constvalue 12 [ 12 0 0 0 68 97 118 111 114 107 97 37 ] + } + ) + } + ) + :lefttree <> + :righttree <> + :initPlan <> + :extParam (b) + :allParam (b) + :nParamExec 0 + :scanrelid 1 + } + +Seq Scan on image image0_ (cost=100000000.00..100021432.33 rows=1 width=1311) (actual time=11438.273..13668.300 rows=33 loops=1) + Filter: ((title)::text ~~ 'Davorka%'::text) +Total runtime: 13669.134 ms + + + here's my explain: + + {SEQSCAN + :startup_cost 100000000.00 + :total_cost 100021432.33 + :plan_rows 1 + :plan_width 1311 + :targetlist ( + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 1 + } + :resno 1 + :resname image_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 1 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + :resno 2 + :resname customer_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 2 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 3 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + :resno 3 + :resname theme_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 3 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 4 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 4 + } + :resno 4 + :resname gallery_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 4 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 5 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 5 + } + :resno 5 + :resname event_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 5 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 6 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + :resno 6 + :resname width + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 6 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 7 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + :resno 7 + :resname height + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 7 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 8 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 8 + } + :resno 8 + :resname filesize + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 8 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 9 + :vartype 1114 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 9 + } + :resno 9 + :resname uploadtime + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 9 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 10 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 10 + } + :resno 10 + :resname filename + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 10 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 11 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 11 + } + :resno 11 + :resname originalfilename + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 11 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 12 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 12 + } + :resno 12 + :resname thumbname + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 12 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 13 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 13 + } + :resno 13 + :resname previewname + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 13 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 14 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 14 + } + :resno 14 + :resname title + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 14 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 15 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 15 + } + :resno 15 + :resname flags + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 15 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 16 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 16 + } + :resno 16 + :resname photographername + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 16 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 17 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 17 + } + :resno 17 + :resname colors + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 17 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 18 + :vartype 1043 + :vartypmod 68 + :varlevelsup 0 + :varnoold 1 + :varoattno 18 + } + :resno 18 + :resname compression + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 18 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 19 + :vartype 1043 + :vartypmod 68 + :varlevelsup 0 + :varnoold 1 + :varoattno 19 + } + :resno 19 + :resname resolution + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 19 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 20 + :vartype 1043 + :vartypmod 68 + :varlevelsup 0 + :varnoold 1 + :varoattno 20 + } + :resno 20 + :resname colortype + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 20 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 21 + :vartype 1043 + :vartypmod 68 + :varlevelsup 0 + :varnoold 1 + :varoattno 21 + } + :resno 21 + :resname colordepth + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 21 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 22 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 22 + } + :resno 22 + :resname sort + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 22 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 23 + :vartype 1114 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 23 + } + :resno 23 + :resname creationtime + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 23 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 24 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 24 + } + :resno 24 + :resname creationlocation + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 24 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 25 + :vartype 25 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 25 + } + :resno 25 + :resname description + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 25 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 26 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 26 + } + :resno 26 + :resname cameravendor_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 26 + :resjunk false + } + {TARGETENTRY + :expr + {VAR + :varno 1 + :varattno 27 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 27 + } + :resno 27 + :resname cameramodel_id + :ressortgroupref 0 + :resorigtbl 29524 + :resorigcol 27 + :resjunk false + } + ) + :qual ( + {OPEXPR + :opno 1209 + :opfuncid 850 + :opresulttype 16 + :opretset false + :args ( + {RELABELTYPE + :arg + {VAR + :varno 1 + :varattno 14 + :vartype 1043 + :vartypmod 259 + :varlevelsup 0 + :varnoold 1 + :varoattno 14 + } + :resulttype 25 + :resulttypmod -1 + :relabelformat 0 + } + {CONST + :consttype 25 + :constlen -1 + :constbyval false + :constisnull false + :constvalue 12 [ 12 0 0 0 68 97 118 111 114 107 97 37 ] + } + ) + } + ) + :lefttree <> + :righttree <> + :initPlan <> + :extParam (b) + :allParam (b) + :nParamExec 0 + :scanrelid 1 + } + +Seq Scan on image image0_ (cost=100000000.00..100021432.33 rows=1 width=1311) (actual time=11438.273..13668.300 rows=33 loops=1) + Filter: ((title)::text ~~ 'Davorka%'::text) +Total runtime: 13669.134 ms + +The table looks like the following: + +CREATE TABLE image +( + image_id int4 NOT NULL, + customer_id int4 NOT NULL, + theme_id int4, + gallery_id int4, + event_id int4, + width int4 NOT NULL, + height int4 NOT NULL, + filesize int4 NOT NULL, + uploadtime timestamp NOT NULL, + filename varchar(255) NOT NULL, + originalfilename varchar(255), + thumbname varchar(255) NOT NULL, + previewname varchar(255) NOT NULL, + title varchar(255), + flags int4 NOT NULL, + photographername varchar(255), + colors int4, + compression varchar(64), + resolution varchar(64), + colortype varchar(64), + colordepth varchar(64), + sort int4, + creationtime timestamp, + creationlocation varchar(255), + description text, + cameravendor_id int4, + cameramodel_id int4, + CONSTRAINT image_pkey PRIMARY KEY (image_id), + CONSTRAINT rel_121 FOREIGN KEY (cameravendor_id) + REFERENCES cameravendor (cameravendor_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT rel_122 FOREIGN KEY (cameramodel_id) + REFERENCES cameramodel (cameramodel_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT rel_21 FOREIGN KEY (customer_id) + REFERENCES customer (customer_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT rel_23 FOREIGN KEY (theme_id) + REFERENCES theme (theme_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT rel_26 FOREIGN KEY (gallery_id) + REFERENCES gallery (gallery_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT rel_63 FOREIGN KEY (event_id) + REFERENCES event (event_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +) +WITHOUT OIDS; + +These are the indexes on the table: + +CREATE INDEX idx_image_customer + ON image + USING btree + (customer_id); + +CREATE INDEX idx_image_event + ON image + USING btree + (event_id); + +CREATE INDEX idx_image_flags + ON image + USING btree + (flags); + +CREATE INDEX idx_image_gallery + ON image + USING btree + (gallery_id); + +CREATE INDEX idx_image_id + ON image + USING btree + (image_id); + +CREATE INDEX idx_image_id_title + ON image + USING btree + (image_id, title); + +CREATE INDEX idx_image_theme + ON image + USING btree + (theme_id); + +CREATE INDEX idx_image_title + ON image + USING btree + (title); + + + +I would appreciate any hint what could be the problem here. + +Best regards +Manuel Rorarius + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 12:08:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E314A11F6BB5 + for ; + Tue, 18 Apr 2006 12:08:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id X69v81W06jt8 + for ; + Tue, 18 Apr 2006 12:08:30 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 3F88C11F61B9 + for ; + Tue, 18 Apr 2006 12:08:29 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 88107533; Tue, 18 Apr 2006 08:08:27 -0700 +From: "Dave Dutcher" +To: "'Tarabas \(Manuel Rorarius\)'" , + +Subject: Re: Problem with LIKE-Performance +Date: Tue, 18 Apr 2006 10:08:27 -0500 +Message-ID: <001a01c662f9$f2449f00$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +In-Reply-To: <341367953.20060418163513@tarabas.de> +X-Archive-Number: 200604/373 +X-Sequence-Number: 18457 + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance- +> owner@postgresql.org] On Behalf Of Tarabas (Manuel Rorarius) +> Subject: [PERFORM] Problem with LIKE-Performance +> +> Hi! +> +> I am having trouble with like statements on one of my tables. + + +It looks like you are getting a sequential scan instead of an index +scan. What is your locale setting? As far as I know Postgres doesn't +support using indexes with LIKE unless you are using the C locale. + +Also, in the future you only need to post EXPLAIN ANALYZE not EXPLAIN +ANALYZE VERBOSE. + +Dave + + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 12:16:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 0AB9D11F6C2F + for ; + Tue, 18 Apr 2006 12:16:36 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id SgXiAIKxXtd0 + for ; + Tue, 18 Apr 2006 12:16:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mediaskill.de (destiny.mediaskill.de [212.91.236.1]) + by postgresql.org (Postfix) with ESMTP id 928B911F6295 + for ; + Tue, 18 Apr 2006 12:16:23 -0300 (ADT) +Received: from localhost ([127.0.0.1]) + by mail.mediaskill.de (Merak 8.3.8) with SMTP id WTI26620; + Tue, 18 Apr 2006 17:16:20 +0200 +Date: Tue, 18 Apr 2006 17:16:18 +0200 +From: "Tarabas (Manuel Rorarius)" +X-Mailer: The Bat! (v3.62.14) Professional +Reply-To: "Tarabas (Manuel Rorarius)" +Organization: mediaskill +X-Priority: 3 (Normal) +Message-ID: <1043488152.20060418171618@tarabas.de> +To: "Dave Dutcher" , pgsql-performance@postgresql.org +Subject: Re: Problem with LIKE-Performance +In-Reply-To: <001a01c662f9$f2449f00$8300a8c0@tridecap.com> +References: <341367953.20060418163513@tarabas.de> + <001a01c662f9$f2449f00$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/374 +X-Sequence-Number: 18458 + +Hi Dave, + +DD> It looks like you are getting a sequential scan instead of an index +DD> scan. What is your locale setting? As far as I know Postgres doesn't +DD> support using indexes with LIKE unless you are using the C locale. + +Actually no, I am using de_DE as locale because I need the german +order-by support. But even for a seq-scan it seems pretty slow, but that's +just a feeling. The table currently has ~172.000 rows and is suposed to +rise to about 1 mio or more. + +Is there any way to speed the like's up with a different locale than C +or to get an order by in a different Locale although using the +default C locale? + +DD> Also, in the future you only need to post EXPLAIN ANALYZE not EXPLAIN +DD> ANALYZE VERBOSE. + +ok, i will keep that in mind :-) didn't know how verbose you would need +it *smile* + +Best regards +Manuel + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 12:38:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id C0EB511F60E9 + for ; + Tue, 18 Apr 2006 12:37:59 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id eN03KpLvsnS8 + for ; + Tue, 18 Apr 2006 12:37:51 -0300 (ADT) +X-Greylist: delayed 00:20:20.547717 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 3DDF511F608B + for ; + Tue, 18 Apr 2006 12:37:49 -0300 (ADT) +Received: from tigre.interieur.gouv.fr (tigre.interieur.gouv.fr + [212.234.218.76]) + by svr4.postgresql.org (Postfix) with ESMTP id 49AA95AF8D3 + for ; + Tue, 18 Apr 2006 15:17:27 +0000 (GMT) +Received: from puma20.interieur.gouv.fr (puma [10.253.20.7]) + by tigre.interieur.gouv.fr (8.13.6/8.13.6) with ESMTP id k3IFHK3b030673 + for ; Tue, 18 Apr 2006 17:17:20 +0200 +Message-Id: <444502FA.3000609@interieur.gouv.fr> +Date: Tue, 18 Apr 2006 17:17:14 +0200 +From: REISS Thomas DSIC DESP +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Dave Dutcher +Cc: "'Tarabas (Manuel Rorarius)'" , + pgsql-performance@postgresql.org +Subject: Re: Problem with LIKE-Performance +References: <001a01c662f9$f2449f00$8300a8c0@tridecap.com> +In-Reply-To: <001a01c662f9$f2449f00$8300a8c0@tridecap.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Archive-Number: 200604/379 +X-Sequence-Number: 18463 + + + +Dave Dutcher a �crit : +> It looks like you are getting a sequential scan instead of an index +> scan. What is your locale setting? As far as I know Postgres doesn't +> support using indexes with LIKE unless you are using the C locale. +> +It does if you create your index this way : + +CREATE INDEX idx_image_title + ON image + USING btree + (title varchar_pattern_ops); + +Please see http://www.postgresql.org/docs/8.1/interactive/indexes-opclass.html + + +Thomas + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 12:20:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 89DFF11F6549 + for ; + Tue, 18 Apr 2006 12:20:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.127 +X-Spam-Level: +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 9ynOVy1OVb0c + for ; + Tue, 18 Apr 2006 12:20:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 664F011F625D + for ; + Tue, 18 Apr 2006 12:20:21 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IFKK4r013459; + Tue, 18 Apr 2006 11:20:20 -0400 (EDT) +To: "Tarabas (Manuel Rorarius)" +cc: pgsql-performance@postgresql.org +Subject: Re: Problem with LIKE-Performance +In-reply-to: <341367953.20060418163513@tarabas.de> +References: <341367953.20060418163513@tarabas.de> +Comments: In-reply-to "Tarabas (Manuel Rorarius)" + message dated "Tue, 18 Apr 2006 16:35:13 +0200" +Date: Tue, 18 Apr 2006 11:20:20 -0400 +Message-ID: <13458.1145373620@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/375 +X-Sequence-Number: 18459 + +"Tarabas (Manuel Rorarius)" writes: +> I get the following explain and I am troubled by the very high +> "startup_cost" ... does anyone have any idea why that value is so +> high? + +> {SEQSCAN +> :startup_cost 100000000.00 + +You have enable_seqscan = off, no? + +Please refrain from posting EXPLAIN VERBOSE unless it's specifically +requested ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 12:33:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8859A11F602E + for ; + Tue, 18 Apr 2006 12:33:16 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.127 +X-Spam-Level: +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 7b4BlWlUXtrX + for ; + Tue, 18 Apr 2006 12:33:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 4EEBA11F605A + for ; + Tue, 18 Apr 2006 12:33:10 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IFX658013610; + Tue, 18 Apr 2006 11:33:06 -0400 (EDT) +To: mario.splivalo@mobart.hr +cc: pgsql-performance@postgreSQL.org +Subject: Re: SELECT FOR UPDATE performance is bad +In-reply-to: <1145371662.31555.10.camel@localhost.localdomain> +References: <1145365720.18469.35.camel@localhost.localdomain> + <13037.1145370658@sss.pgh.pa.us> + <1145371662.31555.10.camel@localhost.localdomain> +Comments: In-reply-to Mario Splivalo + message dated "Tue, 18 Apr 2006 16:47:42 +0200" +Date: Tue, 18 Apr 2006 11:33:06 -0400 +Message-ID: <13609.1145374386@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/376 +X-Sequence-Number: 18460 + +Mario Splivalo writes: +>> If there is concurrent locking, +>> you're also running a big risk of deadlock because two processes might +>> try to lock the same rows in different orders. + +> I think there is no risk of a deadlock, since that particular function +> is called from the middleware (functions are used as interface to the +> database), and the lock order is always the same. + +No, you don't even know what the order is, let alone that it's always +the same. + +> Now, I just need to have serialization, I need to have clients 'line up' +> in order to perform something in the database. Actually, users are +> sending codes from the newspaper, beer-cans, Cola-cans, and stuff, and +> database needs to check has the code allready been played. Since the +> system is designed so that it could run multiple code-games (and then +> there similair code could exists for coke-game and beer-game), I'm using +> messages table to see what code-game (i.e. service) that particular code +> belongs. + +I'd suggest using a table that has exactly one row per "code-game", and +doing a SELECT FOR UPDATE on that row to establish the lock you need. +This need not have anything to do with the tables/rows you are actually +intending to update --- although obviously such a convention is pretty +fragile if you have updates coming from a variety of code. I think it's +reasonably safe when you're funneling all the operations through a bit +of middleware. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 12:35:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 5E01511F6004 + for ; + Tue, 18 Apr 2006 12:35:22 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id zM4KTewGiWNF + for ; + Tue, 18 Apr 2006 12:35:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mediaskill.de (destiny.mediaskill.de [212.91.236.1]) + by postgresql.org (Postfix) with ESMTP id 56E1511F608B + for ; + Tue, 18 Apr 2006 12:35:05 -0300 (ADT) +Received: from localhost ([127.0.0.1]) + by mail.mediaskill.de (Merak 8.3.8) with SMTP id WTB45300; + Tue, 18 Apr 2006 17:35:00 +0200 +Date: Tue, 18 Apr 2006 17:34:59 +0200 +From: "Tarabas (Manuel Rorarius)" +X-Mailer: The Bat! (v3.62.14) Professional +Reply-To: "Tarabas (Manuel Rorarius)" +Organization: mediaskill +X-Priority: 3 (Normal) +Message-ID: <653249740.20060418173459@tarabas.de> +To: Tom Lane +CC: pgsql-performance@postgresql.org +Subject: Re: Problem with LIKE-Performance +In-Reply-To: <13458.1145373620@sss.pgh.pa.us> +References: <341367953.20060418163513@tarabas.de> + <13458.1145373620@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/377 +X-Sequence-Number: 18461 + +Hi Tom, + +TL> "Tarabas (Manuel Rorarius)" writes: +>> I get the following explain and I am troubled by the very high +>> "startup_cost" ... does anyone have any idea why that value is so +>> high? + +>> {SEQSCAN +>> :startup_cost 100000000.00 + +TL> You have enable_seqscan = off, no? + +You were right, I was testing this and had it removed, but somehow I +must have hit the wrong button in pgadmin and it was not successfully +removed from the database. + +After removing the enable_seqscan = off and making sure it was gone, +it is a lot faster again. + +Now it takes about 469.841 ms for the select. + +TL> Please refrain from posting EXPLAIN VERBOSE unless it's specifically +TL> requested ... + +mea culpa, i will not do that again :-) + +Best regards +Manuel + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 12:35:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8186511F6075 + for ; + Tue, 18 Apr 2006 12:35:42 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id iWjL-1oae7qH + for ; + Tue, 18 Apr 2006 12:35:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id C9F6111F6002 + for ; + Tue, 18 Apr 2006 12:35:34 -0300 (ADT) +Received: from mail.digame.de (mail.digame.de [80.148.11.250]) + by svr4.postgresql.org (Postfix) with SMTP id 895B95AF8B1 + for ; + Tue, 18 Apr 2006 15:35:33 +0000 (GMT) +Received: from ATLANTIK-CL.intern.digame.de ([192.168.10.180] RDNS failed) by + mail.digame.de with Microsoft SMTPSVC(6.0.3790.1830); + Tue, 18 Apr 2006 17:35:31 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +Subject: Re: Problem with LIKE-Performance +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Date: Tue, 18 Apr 2006 17:35:30 +0200 +Message-ID: + <84AAD313D71B1D4F9EE20E739CC3B6EDE96F24@ATLANTIK-CL.intern.digame.de> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Problem with LIKE-Performance +Thread-Index: AcZi9hJ75Vz3DPmmTw6B8qpls/tAcAABrIfA +From: "Hakan Kocaman" +To: "Tarabas (Manuel Rorarius)" , + +X-OriginalArrivalTime: 18 Apr 2006 15:35:31.0068 (UTC) + FILETIME=[B9D5C3C0:01C662FD] +X-Archive-Number: 200604/378 +X-Sequence-Number: 18462 + +Hi, + +i remember something that you need a special index with locales<>"C". + +You nned a different operator class for this index smth. like: +CREATE INDEX idx_image_title + ON image + USING btree + (title varchar_pattern_ops); + +You can find the details here: +http://www.postgresql.org/docs/8.1/interactive/indexes-opclass.html + +Best regards + +Hakan Kocaman +Software-Development + +digame.de GmbH +Richard-Byrd-Str. 4-8 +50829 K=F6ln + +Tel.: +49 (0) 221 59 68 88 31 +Fax: +49 (0) 221 59 68 88 98 +Email: hakan.kocaman@digame.de + + + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org=20 +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 +> Tarabas (Manuel Rorarius) +> Sent: Tuesday, April 18, 2006 4:35 PM +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] Problem with LIKE-Performance +>=20 +>=20 +> Hi! +>=20 +> I am having trouble with like statements on one of my tables. +>=20 +> I already tried a vacuum and analyze but with no success. +>=20 +> The database is PostgreSQL Database Server 8.1.3 on i686-pc-mingw32 +>=20 +> I get the following explain and I am troubled by the very high +> "startup_cost" ... does anyone have any idea why that value is so +> high? +>=20 +> {SEQSCAN +> :startup_cost 100000000.00=20 +> :total_cost 100021432.33=20 +> :plan_rows 1=20 +> :plan_width 1311=20 +> :targetlist ( +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 1=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 1 +> } +> :resno 1=20 +> :resname image_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 1=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 2=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 2 +> } +> :resno 2=20 +> :resname customer_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 2=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 3=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 3 +> } +> :resno 3=20 +> :resname theme_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 3=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 4=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 4 +> } +> :resno 4=20 +> :resname gallery_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 4=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 5=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 5 +> } +> :resno 5=20 +> :resname event_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 5=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 6=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 6 +> } +> :resno 6=20 +> :resname width=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 6=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 7=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 7 +> } +> :resno 7=20 +> :resname height=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 7=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 8=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 8 +> } +> :resno 8=20 +> :resname filesize=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 8=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 9=20 +> :vartype 1114=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 9 +> } +> :resno 9=20 +> :resname uploadtime=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 9=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 10=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 10 +> } +> :resno 10=20 +> :resname filename=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 10=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 11=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 11 +> } +> :resno 11=20 +> :resname originalfilename=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 11=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 12=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 12 +> } +> :resno 12=20 +> :resname thumbname=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 12=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 13=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 13 +> } +> :resno 13=20 +> :resname previewname=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 13=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 14=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 14 +> } +> :resno 14=20 +> :resname title=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 14=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 15=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 15 +> } +> :resno 15=20 +> :resname flags=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 15=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 16=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 16 +> } +> :resno 16=20 +> :resname photographername=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 16=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 17=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 17 +> } +> :resno 17=20 +> :resname colors=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 17=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 18=20 +> :vartype 1043=20 +> :vartypmod 68=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 18 +> } +> :resno 18=20 +> :resname compression=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 18=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 19=20 +> :vartype 1043=20 +> :vartypmod 68=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 19 +> } +> :resno 19=20 +> :resname resolution=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 19=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 20=20 +> :vartype 1043=20 +> :vartypmod 68=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 20 +> } +> :resno 20=20 +> :resname colortype=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 20=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 21=20 +> :vartype 1043=20 +> :vartypmod 68=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 21 +> } +> :resno 21=20 +> :resname colordepth=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 21=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 22=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 22 +> } +> :resno 22=20 +> :resname sort=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 22=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 23=20 +> :vartype 1114=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 23 +> } +> :resno 23=20 +> :resname creationtime=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 23=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 24=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 24 +> } +> :resno 24=20 +> :resname creationlocation=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 24=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 25=20 +> :vartype 25=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 25 +> } +> :resno 25=20 +> :resname description=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 25=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 26=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 26 +> } +> :resno 26=20 +> :resname cameravendor_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 26=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 27=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 27 +> } +> :resno 27=20 +> :resname cameramodel_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 27=20 +> :resjunk false +> } +> ) +> :qual ( +> {OPEXPR=20 +> :opno 1209=20 +> :opfuncid 850=20 +> :opresulttype 16=20 +> :opretset false=20 +> :args ( +> {RELABELTYPE=20 +> :arg=20 +> {VAR=20 +> :varno 1=20 +> :varattno 14=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 14 +> } +> :resulttype 25=20 +> :resulttypmod -1=20 +> :relabelformat 0 +> } +> {CONST=20 +> :consttype 25=20 +> :constlen -1=20 +> :constbyval false=20 +> :constisnull false=20 +> :constvalue 12 [ 12 0 0 0 68 97 118 111 114 107 97 37 ] +> } +> ) +> } +> ) +> :lefttree <>=20 +> :righttree <>=20 +> :initPlan <>=20 +> :extParam (b) +> :allParam (b) +> :nParamExec 0=20 +> :scanrelid 1 +> } +>=20 +> Seq Scan on image image0_ (cost=3D100000000.00..100021432.33=20 +> rows=3D1 width=3D1311) (actual time=3D11438.273..13668.300 rows=3D33 = +loops=3D1) +> Filter: ((title)::text ~~ 'Davorka%'::text) +> Total runtime: 13669.134 ms +>=20 +> =20 +> here's my explain: +>=20 +> {SEQSCAN +> :startup_cost 100000000.00=20 +> :total_cost 100021432.33=20 +> :plan_rows 1=20 +> :plan_width 1311=20 +> :targetlist ( +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 1=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 1 +> } +> :resno 1=20 +> :resname image_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 1=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 2=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 2 +> } +> :resno 2=20 +> :resname customer_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 2=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 3=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 3 +> } +> :resno 3=20 +> :resname theme_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 3=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 4=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 4 +> } +> :resno 4=20 +> :resname gallery_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 4=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 5=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 5 +> } +> :resno 5=20 +> :resname event_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 5=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 6=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 6 +> } +> :resno 6=20 +> :resname width=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 6=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 7=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 7 +> } +> :resno 7=20 +> :resname height=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 7=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 8=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 8 +> } +> :resno 8=20 +> :resname filesize=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 8=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 9=20 +> :vartype 1114=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 9 +> } +> :resno 9=20 +> :resname uploadtime=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 9=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 10=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 10 +> } +> :resno 10=20 +> :resname filename=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 10=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 11=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 11 +> } +> :resno 11=20 +> :resname originalfilename=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 11=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 12=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 12 +> } +> :resno 12=20 +> :resname thumbname=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 12=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 13=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 13 +> } +> :resno 13=20 +> :resname previewname=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 13=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 14=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 14 +> } +> :resno 14=20 +> :resname title=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 14=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 15=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 15 +> } +> :resno 15=20 +> :resname flags=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 15=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 16=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 16 +> } +> :resno 16=20 +> :resname photographername=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 16=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 17=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 17 +> } +> :resno 17=20 +> :resname colors=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 17=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 18=20 +> :vartype 1043=20 +> :vartypmod 68=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 18 +> } +> :resno 18=20 +> :resname compression=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 18=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 19=20 +> :vartype 1043=20 +> :vartypmod 68=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 19 +> } +> :resno 19=20 +> :resname resolution=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 19=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 20=20 +> :vartype 1043=20 +> :vartypmod 68=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 20 +> } +> :resno 20=20 +> :resname colortype=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 20=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 21=20 +> :vartype 1043=20 +> :vartypmod 68=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 21 +> } +> :resno 21=20 +> :resname colordepth=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 21=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 22=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 22 +> } +> :resno 22=20 +> :resname sort=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 22=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 23=20 +> :vartype 1114=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 23 +> } +> :resno 23=20 +> :resname creationtime=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 23=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 24=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 24 +> } +> :resno 24=20 +> :resname creationlocation=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 24=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 25=20 +> :vartype 25=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 25 +> } +> :resno 25=20 +> :resname description=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 25=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 26=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 26 +> } +> :resno 26=20 +> :resname cameravendor_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 26=20 +> :resjunk false +> } +> {TARGETENTRY=20 +> :expr=20 +> {VAR=20 +> :varno 1=20 +> :varattno 27=20 +> :vartype 23=20 +> :vartypmod -1=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 27 +> } +> :resno 27=20 +> :resname cameramodel_id=20 +> :ressortgroupref 0=20 +> :resorigtbl 29524=20 +> :resorigcol 27=20 +> :resjunk false +> } +> ) +> :qual ( +> {OPEXPR=20 +> :opno 1209=20 +> :opfuncid 850=20 +> :opresulttype 16=20 +> :opretset false=20 +> :args ( +> {RELABELTYPE=20 +> :arg=20 +> {VAR=20 +> :varno 1=20 +> :varattno 14=20 +> :vartype 1043=20 +> :vartypmod 259=20 +> :varlevelsup 0=20 +> :varnoold 1=20 +> :varoattno 14 +> } +> :resulttype 25=20 +> :resulttypmod -1=20 +> :relabelformat 0 +> } +> {CONST=20 +> :consttype 25=20 +> :constlen -1=20 +> :constbyval false=20 +> :constisnull false=20 +> :constvalue 12 [ 12 0 0 0 68 97 118 111 114 107 97 37 ] +> } +> ) +> } +> ) +> :lefttree <>=20 +> :righttree <>=20 +> :initPlan <>=20 +> :extParam (b) +> :allParam (b) +> :nParamExec 0=20 +> :scanrelid 1 +> } +>=20 +> Seq Scan on image image0_ (cost=3D100000000.00..100021432.33=20 +> rows=3D1 width=3D1311) (actual time=3D11438.273..13668.300 rows=3D33 = +loops=3D1) +> Filter: ((title)::text ~~ 'Davorka%'::text) +> Total runtime: 13669.134 ms +>=20 +> The table looks like the following: +>=20 +> CREATE TABLE image +> ( +> image_id int4 NOT NULL, +> customer_id int4 NOT NULL, +> theme_id int4, +> gallery_id int4, +> event_id int4, +> width int4 NOT NULL, +> height int4 NOT NULL, +> filesize int4 NOT NULL, +> uploadtime timestamp NOT NULL, +> filename varchar(255) NOT NULL, +> originalfilename varchar(255), +> thumbname varchar(255) NOT NULL, +> previewname varchar(255) NOT NULL, +> title varchar(255), +> flags int4 NOT NULL, +> photographername varchar(255), +> colors int4, +> compression varchar(64), +> resolution varchar(64), +> colortype varchar(64), +> colordepth varchar(64), +> sort int4, +> creationtime timestamp, +> creationlocation varchar(255), +> description text, +> cameravendor_id int4, +> cameramodel_id int4, +> CONSTRAINT image_pkey PRIMARY KEY (image_id), +> CONSTRAINT rel_121 FOREIGN KEY (cameravendor_id) +> REFERENCES cameravendor (cameravendor_id) MATCH SIMPLE +> ON UPDATE NO ACTION ON DELETE NO ACTION, +> CONSTRAINT rel_122 FOREIGN KEY (cameramodel_id) +> REFERENCES cameramodel (cameramodel_id) MATCH SIMPLE +> ON UPDATE NO ACTION ON DELETE NO ACTION, +> CONSTRAINT rel_21 FOREIGN KEY (customer_id) +> REFERENCES customer (customer_id) MATCH SIMPLE +> ON UPDATE NO ACTION ON DELETE NO ACTION, +> CONSTRAINT rel_23 FOREIGN KEY (theme_id) +> REFERENCES theme (theme_id) MATCH SIMPLE +> ON UPDATE NO ACTION ON DELETE NO ACTION, +> CONSTRAINT rel_26 FOREIGN KEY (gallery_id) +> REFERENCES gallery (gallery_id) MATCH SIMPLE +> ON UPDATE NO ACTION ON DELETE NO ACTION, +> CONSTRAINT rel_63 FOREIGN KEY (event_id) +> REFERENCES event (event_id) MATCH SIMPLE +> ON UPDATE NO ACTION ON DELETE NO ACTION +> )=20 +> WITHOUT OIDS; +>=20 +> These are the indexes on the table: +>=20 +> CREATE INDEX idx_image_customer +> ON image +> USING btree +> (customer_id); +>=20 +> CREATE INDEX idx_image_event +> ON image +> USING btree +> (event_id); +>=20 +> CREATE INDEX idx_image_flags +> ON image +> USING btree +> (flags); +>=20 +> CREATE INDEX idx_image_gallery +> ON image +> USING btree +> (gallery_id); +>=20 +> CREATE INDEX idx_image_id +> ON image +> USING btree +> (image_id); +>=20 +> CREATE INDEX idx_image_id_title +> ON image +> USING btree +> (image_id, title); +>=20 +> CREATE INDEX idx_image_theme +> ON image +> USING btree +> (theme_id); +>=20 +> CREATE INDEX idx_image_title +> ON image +> USING btree +> (title); +>=20 +>=20 +>=20 +> I would appreciate any hint what could be the problem here. +>=20 +> Best regards +> Manuel Rorarius +>=20 +>=20 +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 6: explain analyze is your friend +>=20 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 12:44:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id ACD0E11F603C + for ; + Tue, 18 Apr 2006 12:44:06 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id NN8Ozxzmt181 + for ; + Tue, 18 Apr 2006 12:43:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.pharmaline.de (mail.pharmaline.de [62.153.135.34]) + by postgresql.org (Postfix) with ESMTP id 7841B11F6081 + for ; + Tue, 18 Apr 2006 12:43:45 -0300 (ADT) +Received: from [192.168.2.121] (62.153.135.40) by mail.pharmaline.de with + ESMTP (Eudora Internet Mail Server 3.2.7); + Tue, 18 Apr 2006 17:43:44 +0200 +In-Reply-To: <1043488152.20060418171618@tarabas.de> +References: <341367953.20060418163513@tarabas.de> + <001a01c662f9$f2449f00$8300a8c0@tridecap.com> + <1043488152.20060418171618@tarabas.de> +Mime-Version: 1.0 (Apple Message framework v746.3) +X-Priority: 3 (Normal) +Content-Type: multipart/signed; micalg=sha1; + boundary=Apple-Mail-12--435892305; + protocol="application/pkcs7-signature" +Message-Id: +Cc: pgsql-performance@postgresql.org +From: Guido Neitzer +Subject: Re: Problem with LIKE-Performance +Date: Tue, 18 Apr 2006 17:43:51 +0200 +To: "Tarabas (Manuel Rorarius)" +X-Mailer: Apple Mail (2.746.3) +X-Archive-Number: 200604/380 +X-Sequence-Number: 18464 + + +--Apple-Mail-12--435892305 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +On 18.04.2006, at 17:16 Uhr, Tarabas (Manuel Rorarius) wrote: + +> Is there any way to speed the like's up with a different locale than C +> or to get an order by in a different Locale although using the +> default C locale? + +Sure. Just create the index with + +create index __index on ( +varchar_pattern_ops); + +Than you can use something like + +select * from where like 'Something%'; + +Remember that an index can't be used for queries with '%pattern%'. + +cug +--Apple-Mail-12--435892305 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGNzCCAvAw +ggJZoAMCAQICEB7tpxCHG7VYey3bP/Ou4e8wDQYJKoZIhvcNAQEEBQAwYjELMAkGA1UEBhMCWkEx +JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ +ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA2MDIxMTE3NDM1NFoXDTA3MDIxMTE3NDM1 +NFowTTEfMB0GA1UEAxMWVGhhd3RlIEZyZWVtYWlsIE1lbWJlcjEqMCgGCSqGSIb3DQEJARYbZ3Vp +ZG8ubmVpdHplckBwaGFybWFsaW5lLmRlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA +yLhNUnNv30/r+pFUHocoIWGm8AAwFbwAWqFRhEwZzxLPCMSZme3G7W/5hyK+SxeQoOK8PPCsNyvy +sLBqUVHB3nm5w/NzZKk1gfc2QlzjPtv2C7bUnigDJs+X0YlgdxTxs68RdHBn/rbjjaxl+SkiEcsz +kZhKsAnS6zhlWSX7zDCIRR5VD08M0/fYSTwEcX1j8lWb/3McY7bCcHbLd+762QQAn03A4cPco4OK +3KAMld0n6qFFMG23IKx7qDTonYtCzsDVspQ1Fk14yJYVdf62RLWGBJPF+RMXB9juFhgdUrHZY3mo +wamFF3qZ8HD9wb+G7lhL8F+d5khDuLBYFXCqdQIDAQABozgwNjAmBgNVHREEHzAdgRtndWlkby5u +ZWl0emVyQHBoYXJtYWxpbmUuZGUwDAYDVR0TAQH/BAIwADANBgkqhkiG9w0BAQQFAAOBgQCFnjZk +bGIY3sGlsEIn98cV+tX9xNTThIwN6jhu7mGuxzvX+hN86kdlhEgaPmaatH8KfXXyfnhpTK3KOk8O +zDsxJqQDVe1HEW8M/4MkORMlydbcxSRPL967pgMRNjAMafL/IlssFJ3kF7q/2AjRd4VhnyoA3Yl/ +sXF3WLOTJB5OzjCCAz8wggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpB +MRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhh +d3RlIENvbnN1bHRpbmcxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24x +JDAiBgNVBAMTG1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVy +c29uYWwtZnJlZW1haWxAdGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTla +MGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSww +KgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0B +AQEFAAOBjQAwgYkCgYEAxKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B +1OVQCjDXAmNaLIkVcI7dyfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk +16emu59l0cUqVIUPSAR/p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/ +AgEAMEMGA1UdHwQ8MDowOKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25h +bEZyZWVtYWlsQ0EuY3JsMAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJp +dmF0ZUxhYmVsMi0xMzgwDQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOW +lJ1/TCG4+DYfqi2fNi/A9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amc +OY6MIE9lX5Xa9/eH1sYITq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8xggMQMIIDDAIB +ATB2MGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQu +MSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIQHu2nEIcbtVh7 +Lds/867h7zAJBgUrDgMCGgUAoIIBbzAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3 +DQEJBTEPFw0wNjA0MTgxNTQzNTJaMCMGCSqGSIb3DQEJBDEWBBSqE3aOcEaP1Sv6XZWjlKNeiHzl +CTCBhQYJKwYBBAGCNxAEMXgwdjBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1 +bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3Vp +bmcgQ0ECEB7tpxCHG7VYey3bP/Ou4e8wgYcGCyqGSIb3DQEJEAILMXigdjBiMQswCQYDVQQGEwJa +QTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3Rl +IFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECEB7tpxCHG7VYey3bP/Ou4e8wDQYJKoZIhvcN +AQEBBQAEggEABeOCD4z6gDkvj4P//zbIkQkcHGnts82s8zIhNmkD6VwM6HfeIidUWs1irom/eou3 +aG6MTe9TP0hJHjfqaLeEhJu/bS1HZf4P8JI/MZB1OvNlSB1OqBudKcx667FhZJWcvNPgFpNYPw/V +gps4ZiQJDBdM8ikVtstA9e3fTgOsy+nDFrLsEjEMM+e9wwHIXff2/aEA5ztxe+2kjyRQGoHvsvuv +Zuq+aZrrsskeiJBdNc2SP85mJoUANv71jiJ5dWKKBnDAbaEKg74M7Za7wIzrG/XA0d2TepjgeaYR +kOTrQp0Cou9Kp8/2/fxlBIBzx+ZCzlv5Ulo/j7/pTPkUp3su+QAAAAAAAA== + +--Apple-Mail-12--435892305-- + +From pgsql-performance-owner@postgresql.org Tue Apr 18 12:44:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id AA71911F6004 + for ; + Tue, 18 Apr 2006 12:44:08 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[AWL=0.000, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id Zy06R6NuG+vz + for ; + Tue, 18 Apr 2006 12:43:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mediaskill.de (destiny.mediaskill.de [212.91.236.1]) + by postgresql.org (Postfix) with ESMTP id 7BB6511F607B + for ; + Tue, 18 Apr 2006 12:43:55 -0300 (ADT) +Received: from localhost ([127.0.0.1]) + by mail.mediaskill.de (Merak 8.3.8) with SMTP id WTJ32854; + Tue, 18 Apr 2006 17:43:54 +0200 +Date: Tue, 18 Apr 2006 17:43:53 +0200 +From: "Tarabas (Manuel Rorarius)" +X-Mailer: The Bat! (v3.62.14) Professional +Reply-To: "Tarabas (Manuel Rorarius)" +Organization: mediaskill +X-Priority: 3 (Normal) +Message-ID: <14334544.20060418174353@tarabas.de> +To: "Hakan Kocaman" +CC: pgsql-performance@postgresql.org +Subject: Re: [bulk] RE: Problem with LIKE-Performance +In-Reply-To: + <84AAD313D71B1D4F9EE20E739CC3B6EDE96F24@ATLANTIK-CL.intern.digame.de> +References: + <84AAD313D71B1D4F9EE20E739CC3B6EDE96F24@ATLANTIK-CL.intern.digame.de> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/381 +X-Sequence-Number: 18465 + +Hi Hakan, + +HK> i remember something that you need a special index with locales<>"C". +HK> You nned a different operator class for this index smth. like: +HK> CREATE INDEX idx_image_title +HK> ON image +HK> USING btree +HK> (title varchar_pattern_ops); + +I also forgot that, thanks a lot for the hint. that speeded up my +searches a lot! + +Best regards +Manuel + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 12:45:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 26F1B11F6089 + for ; + Tue, 18 Apr 2006 12:45:50 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.127 +X-Spam-Level: +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 2m1Crr31jV3r + for ; + Tue, 18 Apr 2006 12:45:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 9B6D711F608B + for ; + Tue, 18 Apr 2006 12:45:42 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IFjdkx013755; + Tue, 18 Apr 2006 11:45:39 -0400 (EDT) +To: "Tarabas (Manuel Rorarius)" +cc: pgsql-performance@postgresql.org +Subject: Re: Problem with LIKE-Performance +In-reply-to: <653249740.20060418173459@tarabas.de> +References: <341367953.20060418163513@tarabas.de> + <13458.1145373620@sss.pgh.pa.us> + <653249740.20060418173459@tarabas.de> +Comments: In-reply-to "Tarabas (Manuel Rorarius)" + message dated "Tue, 18 Apr 2006 17:34:59 +0200" +Date: Tue, 18 Apr 2006 11:45:39 -0400 +Message-ID: <13754.1145375139@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/382 +X-Sequence-Number: 18466 + +"Tarabas (Manuel Rorarius)" writes: +> After removing the enable_seqscan = off and making sure it was gone, +> it is a lot faster again. +> Now it takes about 469.841 ms for the select. + +Um, no, enable_seqscan would certainly not have had any effect on the +*actual* runtime of this query. All that enable_seqscan = off really +does is to add a large constant to the estimated cost of any seqscan, +so as to prevent the planner from selecting it unless there is no other +alternative plan available. But that has nothing to do with how long +the seqscan will really run. + +If you are seeing a speedup in repeated executions of the same seqscan +plan, it's probably just a caching effect. + +As already noted, it might be worth your while to add an index using the +pattern-ops opclass to help with queries like this. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 13:04:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id A575C11F625D + for ; + Tue, 18 Apr 2006 13:04:40 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[AWL=0.000, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id pOgvZFIvAR7C + for ; + Tue, 18 Apr 2006 13:04:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mediaskill.de (destiny.mediaskill.de [212.91.236.1]) + by postgresql.org (Postfix) with ESMTP id 2E16D11F6234 + for ; + Tue, 18 Apr 2006 13:04:36 -0300 (ADT) +Received: from localhost ([127.0.0.1]) + by mail.mediaskill.de (Merak 8.3.8) with SMTP id WUW35935; + Tue, 18 Apr 2006 18:04:35 +0200 +Date: Tue, 18 Apr 2006 18:04:34 +0200 +From: "Tarabas (Manuel Rorarius)" +X-Mailer: The Bat! (v3.62.14) Professional +Reply-To: "Tarabas (Manuel Rorarius)" +Organization: mediaskill +X-Priority: 3 (Normal) +Message-ID: <492687293.20060418180434@tarabas.de> +To: Tom Lane +CC: pgsql-performance@postgresql.org +Subject: Re: [bulk] Re: Problem with LIKE-Performance +In-Reply-To: <13754.1145375139@sss.pgh.pa.us> +References: <341367953.20060418163513@tarabas.de> + <13458.1145373620@sss.pgh.pa.us> <653249740.20060418173459@tarabas.de> + <13754.1145375139@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/383 +X-Sequence-Number: 18467 + +Hi Tom, + +TL> As already noted, it might be worth your while to add an index using the +TL> pattern-ops opclass to help with queries like this. + +I have done that now and it works very fine as supposed. + +The problem with the high startup_costs disappeared somehow after the +change of the enable_seqscan = off and a restart of pg-admin. + +first Time I ran the statement it showed 13 sec execution time. + +Seq Scan on image image0_ (cost=0.00..21414.21 rows=11 width=1311) +(actual time=10504.138..12857.127 rows=119 loops=1) + Filter: ((title)::text ~~ '%Davorka%'::text) +Total runtime: 12857.372 ms + +second time I ran the statement it dropped to ~500 msec , which is +pretty ok. :-) + +Seq Scan on image image0_ (cost=0.00..21414.21 rows=11 width=1311) +(actual time=270.289..552.144 rows=119 loops=1) + Filter: ((title)::text ~~ '%Davorka%'::text) +Total runtime: 552.708 ms + +Best regards +Manuel Rorarius + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 13:10:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 785A611F6004 + for ; + Tue, 18 Apr 2006 13:10:09 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.127 +X-Spam-Level: +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id wIt04t9mwPC0 + for ; + Tue, 18 Apr 2006 13:10:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 63C9111F6262 + for ; + Tue, 18 Apr 2006 13:10:00 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IG9vHs013998; + Tue, 18 Apr 2006 12:09:57 -0400 (EDT) +To: "Sriram Dandapani" +cc: "Pgsql-Performance \(E-mail\)" +Subject: Re: creating of temporary table takes very long +In-reply-to: <6992E470F12A444BB787B5C937B9D4DF0406A654@ca-mail1.cis.local> +References: <6992E470F12A444BB787B5C937B9D4DF0406A654@ca-mail1.cis.local> +Comments: In-reply-to "Sriram Dandapani" + message dated "Mon, 17 Apr 2006 13:05:17 -0700" +Date: Tue, 18 Apr 2006 12:09:57 -0400 +Message-ID: <13997.1145376597@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/384 +X-Sequence-Number: 18468 + +"Sriram Dandapani" writes: +> Got an explain analyze output..Here it is +> "Seq Scan on c_chkpfw_hr_tr a (cost=0.00..225975659.89 rows=11000 +> width=136) (actual time=2.345..648070.474 rows=22001 loops=1)" +> " Filter: (subplan)" +> " SubPlan" +> " -> Bitmap Heap Scan on chkpfw_tr_hr_dimension b +> (cost=1474.64..10271.13 rows=1 width=0) (actual time=29.439..29.439 +> rows=1 loops=22001)" +> " Recheck Cond: (($0 = firstoccurrence) AND ($1 = sentryid_id) +> AND ($2 = node_id))" +> " Filter: (($3 = customerid_id) AND (COALESCE($4, 0) = +> COALESCE(interface_id, 0)) AND (COALESCE($5, 0) = COALESCE(source_id, +> 0)) AND (COALESCE($6, 0) = COALESCE(destination_id, 0)) AND +> (COALESCE($7, 0) = COALESCE(sourceport_id, 0)) AND (COALESCE($8 (..)" +> " -> Bitmap Index Scan on chkpfw_tr_hr_idx1 +> (cost=0.00..1474.64 rows=38663 width=0) (actual time=12.144..12.144 +> rows=33026 loops=22001)" +> " Index Cond: (($0 = firstoccurrence) AND ($1 = +> sentryid_id) AND ($2 = node_id))" +> "Total runtime: 648097.800 ms" + +That's probably about as good a query plan as you can hope for given +the way the query is written. Those COALESCE comparisons are all +unindexable (unless you make functional indexes on the COALESCE +expressions). You might get somewhere by converting the EXISTS +to an IN, though. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 13:13:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8991511F621E + for ; + Tue, 18 Apr 2006 13:13:23 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.168 +X-Spam-Level: +X-Spam-Status: No, score=0.168 required=5 tests=[AWL=0.168] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 2vZiuHcKON+g + for ; + Tue, 18 Apr 2006 13:13:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id 56EB711F6081 + for ; + Tue, 18 Apr 2006 13:13:18 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Tue, 18 Apr 2006 16:13:15 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145376794600; Tue, 18 Apr 2006 09:13:14 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Tue, 18 Apr 2006 09:13:14 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Tue, 18 Apr 2006 09:13:14 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR1a P0803.345); + id 1145376789408; Tue, 18 Apr 2006 09:13:09 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: creating of temporary table takes very long +Date: Tue, 18 Apr 2006 09:13:04 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF0406A79C@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] creating of temporary table takes very long +Thread-Index: AcZjApJZ6r/0mx07QkmT95zff79ZHwAADS6A +From: "Sriram Dandapani" +To: "Tom Lane" +Cc: "Pgsql-Performance \(E-mail\)" +X-Archive-Number: 200604/385 +X-Sequence-Number: 18469 + +Thx Tom + +I guess I have to abandon the bulk update. The columns in the where +clause comprise 80% of the table columns..So indexing all may not help. +The target table will have on average 60-180 million rows. + +I will attempt the in instead of exist and let you know the result + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Tuesday, April 18, 2006 9:10 AM +To: Sriram Dandapani +Cc: Pgsql-Performance (E-mail) +Subject: Re: [PERFORM] creating of temporary table takes very long=20 + +"Sriram Dandapani" writes: +> Got an explain analyze output..Here it is +> "Seq Scan on c_chkpfw_hr_tr a (cost=3D0.00..225975659.89 rows=3D11000 +> width=3D136) (actual time=3D2.345..648070.474 rows=3D22001 loops=3D1)" +> " Filter: (subplan)" +> " SubPlan" +> " -> Bitmap Heap Scan on chkpfw_tr_hr_dimension b +> (cost=3D1474.64..10271.13 rows=3D1 width=3D0) (actual = +time=3D29.439..29.439 +> rows=3D1 loops=3D22001)" +> " Recheck Cond: (($0 =3D firstoccurrence) AND ($1 =3D +sentryid_id) +> AND ($2 =3D node_id))" +> " Filter: (($3 =3D customerid_id) AND (COALESCE($4, 0) =3D +> COALESCE(interface_id, 0)) AND (COALESCE($5, 0) =3D = +COALESCE(source_id, +> 0)) AND (COALESCE($6, 0) =3D COALESCE(destination_id, 0)) AND +> (COALESCE($7, 0) =3D COALESCE(sourceport_id, 0)) AND (COALESCE($8 = +(..)" +> " -> Bitmap Index Scan on chkpfw_tr_hr_idx1 +> (cost=3D0.00..1474.64 rows=3D38663 width=3D0) (actual = +time=3D12.144..12.144 +> rows=3D33026 loops=3D22001)" +> " Index Cond: (($0 =3D firstoccurrence) AND ($1 =3D +> sentryid_id) AND ($2 =3D node_id))" +> "Total runtime: 648097.800 ms" + +That's probably about as good a query plan as you can hope for given +the way the query is written. Those COALESCE comparisons are all +unindexable (unless you make functional indexes on the COALESCE +expressions). You might get somewhere by converting the EXISTS +to an IN, though. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 13:26:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 2FE7611F65E7 + for ; + Tue, 18 Apr 2006 13:26:22 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.421 +X-Spam-Level: +X-Spam-Status: No, score=-2.421 required=5 tests=[AWL=0.043, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id NPygItBCr9qZ + for ; + Tue, 18 Apr 2006 13:26:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) + by postgresql.org (Postfix) with ESMTP id B6E7311F65CA + for ; + Tue, 18 Apr 2006 13:26:07 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by ptb-relay01.plus.net with esmtp (Exim) id 1FVt1X-0008Cr-EJ; + Tue, 18 Apr 2006 17:25:55 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id DE0A1735C0; + Tue, 18 Apr 2006 17:28:22 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 211B615EA4; + Tue, 18 Apr 2006 17:25:44 +0100 (BST) +Message-ID: <44451307.2080706@archonet.com> +Date: Tue, 18 Apr 2006 17:25:43 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: "Tarabas (Manuel Rorarius)" +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: [bulk] Re: Problem with LIKE-Performance +References: <341367953.20060418163513@tarabas.de> + <13458.1145373620@sss.pgh.pa.us> + <653249740.20060418173459@tarabas.de> + <13754.1145375139@sss.pgh.pa.us> + <492687293.20060418180434@tarabas.de> +In-Reply-To: <492687293.20060418180434@tarabas.de> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/386 +X-Sequence-Number: 18470 + +Tarabas (Manuel Rorarius) wrote: +> Hi Tom, +> +> TL> As already noted, it might be worth your while to add an index using the +> TL> pattern-ops opclass to help with queries like this. +> +> I have done that now and it works very fine as supposed. +> +> The problem with the high startup_costs disappeared somehow after the +> change of the enable_seqscan = off and a restart of pg-admin. + +I'm not sure restarting pgAdmin would have had any effect. + +> first Time I ran the statement it showed 13 sec execution time. +> +> Seq Scan on image image0_ (cost=0.00..21414.21 rows=11 width=1311) +> (actual time=10504.138..12857.127 rows=119 loops=1) +> Filter: ((title)::text ~~ '%Davorka%'::text) +> Total runtime: 12857.372 ms +> +> second time I ran the statement it dropped to ~500 msec , which is +> pretty ok. :-) + +This will be because all the data is cached in the server's memory. + +> Seq Scan on image image0_ (cost=0.00..21414.21 rows=11 width=1311) +> (actual time=270.289..552.144 rows=119 loops=1) +> Filter: ((title)::text ~~ '%Davorka%'::text) +> Total runtime: 552.708 ms + +As you can see, the plan is still scanning all the rows. In any case, +you've changed the query - this has % at the beginning and end, which no +index will help you with. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Apr 18 13:39:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A848611F61FC + for ; + Tue, 18 Apr 2006 13:39:49 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ZelpSLdCgpcv + for ; + Tue, 18 Apr 2006 13:39:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mediaskill.de (destiny.mediaskill.de [212.91.236.1]) + by postgresql.org (Postfix) with ESMTP id E3AF911F6059 + for ; + Tue, 18 Apr 2006 13:39:44 -0300 (ADT) +Received: from localhost ([127.0.0.1]) + by mail.mediaskill.de (Merak 8.3.8) with SMTP id WUF87542; + Tue, 18 Apr 2006 18:39:42 +0200 +Date: Tue, 18 Apr 2006 18:39:42 +0200 +From: "Tarabas (Manuel Rorarius)" +X-Mailer: The Bat! (v3.62.14) Professional +Reply-To: "Tarabas (Manuel Rorarius)" +Organization: mediaskill +X-Priority: 3 (Normal) +Message-ID: <779212585.20060418183942@tarabas.de> +To: Richard Huxton +CC: pgsql-performance@postgresql.org +Subject: Re: [bulk] Re: [bulk] Re: Problem with LIKE-Performance +In-Reply-To: <44451307.2080706@archonet.com> +References: <341367953.20060418163513@tarabas.de> + <13458.1145373620@sss.pgh.pa.us> <653249740.20060418173459@tarabas.de> + <13754.1145375139@sss.pgh.pa.us> <492687293.20060418180434@tarabas.de> + <44451307.2080706@archonet.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/387 +X-Sequence-Number: 18471 + +Hi Richard, + +RH> As you can see, the plan is still scanning all the rows. In any case, +RH> you've changed the query - this has % at the beginning and end, which no +RH> index will help you with. + +I realize that, the index definately helped a lot with the query where +the % is just at the end. The time went down to 0.203 ms after I +changed the index to varchar_pattern_ops. + +Index Scan using idx_image_title on image (cost=0.00..6.01 rows=1 width=1311) (actual time=0.027..0.108 rows=33 loops=1) +Index Cond: (((title)::text ~>=~ 'Davorka'::character varying) AND ((title)::text ~<~ 'Davorkb'::character varying)) +Filter: ((title)::text ~~ 'Davorka%'::text) +Total runtime: 0.203 ms + +Although 13 sec. for the first select seems a bit odd, I think after +the Database-Cache on the Table kicks in, it should be fine with ~500 ms + +Best regards +Manuel + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 13:59:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 256D511F8BC0 + for ; + Tue, 18 Apr 2006 13:59:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.109 +X-Spam-Level: +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ByL3wrV8ywHX + for ; + Tue, 18 Apr 2006 13:59:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 9CD1311F8BDA + for ; + Tue, 18 Apr 2006 13:59:23 -0300 (ADT) +Received: (qmail 7294 invoked from network); 18 Apr 2006 19:00:42 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 18 Apr 2006 19:00:42 +0200 +To: "Tom Lane" , mario.splivalo@mobart.hr +Cc: pgsql-performance@postgresql.org +Subject: Re: SELECT FOR UPDATE performance is bad +References: <1145365720.18469.35.camel@localhost.localdomain> + <13037.1145370658@sss.pgh.pa.us> + <1145371662.31555.10.camel@localhost.localdomain> + <13609.1145374386@sss.pgh.pa.us> +Message-ID: +Date: Tue, 18 Apr 2006 19:00:40 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <13609.1145374386@sss.pgh.pa.us> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Archive-Number: 200604/388 +X-Sequence-Number: 18472 + + +Suppose you have a table codes : +( + game_id INT, + code TEXT, + used BOOL NOT NULL DEFAULT 'f', + prize ... + ... + PRIMARY KEY (game_id, code) +) + + Just UPDATE codes SET used='t' WHERE used='f' AND game_id=... AND code=... + + Then check the rowcount : if one row was updated, the code was not used +yet. If no row was updated, the code either did not exist, or was already +used. + +Another option : create a table used_codes like this : + +( + game_id INT, + code TEXT, + ... + PRIMARY KEY (game_id, code) +) + + Then, when trying to use a code, INSERT into this table. If you get a +constraint violation on the uniqueness of the primary key, your code has +already been used. + + Both solutions have a big advantage : they don't require messing with +locks and are extremely simple. The one with UPDATE is IMHO better, +because it doesn't abort the current transaction (although you could use a +savepoint in the INSERT case to intercept the error). + + + + + + + + +On Tue, 18 Apr 2006 17:33:06 +0200, Tom Lane wrote: + +> Mario Splivalo writes: +>>> If there is concurrent locking, +>>> you're also running a big risk of deadlock because two processes might +>>> try to lock the same rows in different orders. +> +>> I think there is no risk of a deadlock, since that particular function +>> is called from the middleware (functions are used as interface to the +>> database), and the lock order is always the same. +> +> No, you don't even know what the order is, let alone that it's always +> the same. +> +>> Now, I just need to have serialization, I need to have clients 'line up' +>> in order to perform something in the database. Actually, users are +>> sending codes from the newspaper, beer-cans, Cola-cans, and stuff, and +>> database needs to check has the code allready been played. Since the +>> system is designed so that it could run multiple code-games (and then +>> there similair code could exists for coke-game and beer-game), I'm using +>> messages table to see what code-game (i.e. service) that particular code +>> belongs. +> +> I'd suggest using a table that has exactly one row per "code-game", and +> doing a SELECT FOR UPDATE on that row to establish the lock you need. +> This need not have anything to do with the tables/rows you are actually +> intending to update --- although obviously such a convention is pretty +> fragile if you have updates coming from a variety of code. I think it's +> reasonably safe when you're funneling all the operations through a bit +> of middleware. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings + + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 14:19:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 250D911F6089 + for ; + Tue, 18 Apr 2006 14:19:16 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.499 +X-Spam-Level: +X-Spam-Status: No, score=-2.499 required=5 tests=[AWL=0.100, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id MFCMz84m7zGF + for ; + Tue, 18 Apr 2006 14:19:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.zanthus.com.br (mail.zanthus.com.br [200.212.65.85]) + by postgresql.org (Postfix) with ESMTP id 5F05311F674C + for ; + Tue, 18 Apr 2006 14:19:00 -0300 (ADT) +Received: from cprsakai ([192.168.0.71]) + by mail.zanthus.com.br (8.13.4/8.13.4/Debian-3) with SMTP id + k3IHKVUc019083 + for ; Tue, 18 Apr 2006 14:20:31 -0300 +Message-ID: <002601c6630c$403c9f70$4700a8c0@TREEZANTHUS> +Reply-To: "Rodrigo Sakai" +From: "Rodrigo Sakai" +To: +References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> + <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> + <443D127D.2070601@modgraph-usa.com> + <20060412153951.GH49405@pervasive.com> + <443D3A9C.40106@modgraph-usa.com> + <20060412205914.GL49405@pervasive.com> +Subject: Re: FOREIGN KEYS vs PERFORMANCE +Date: Tue, 18 Apr 2006 14:19:29 -0300 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +X-Zanthus-MailScanner: Found to be clean +X-Zanthus-MailScanner-From: rodrigo.sakai@zanthus.com.br +X-Archive-Number: 200604/389 +X-Sequence-Number: 18473 + + Thanks for all responses! I agree with most of you, and say that the RI is +best maintened by Database ! Performance must be improved in other ways +(indexes, hardware, etc)! + + +----- Original Message ----- +From: "Jim C. Nasby" +To: "Craig A. James" +Cc: "PFC" ; "Michael Glaesemann" ; +"Rodrigo Sakai" ; + +Sent: Wednesday, April 12, 2006 5:59 PM +Subject: Re: [PERFORM] FOREIGN KEYS vs PERFORMANCE + + +> On Wed, Apr 12, 2006 at 10:36:28AM -0700, Craig A. James wrote: +> > Jim C. Nasby wrote: +> > >>1. You have only one application that modifies the data. (Otherwise, +you +> > >>have to duplicate the rules across many applications, leading to a +> > >>code-maintenance nightmare). +> > > +> > >You forgot something: +> > > +> > >1a: You know that there will never, ever, ever, ever, be any other +> > >application that wants to talk to the database. +> > > +> > >I know tons of people that get burned because they go with something +> > >that's "good enough for now", and then regret that decision for years +to +> > >come. +> > +> > No, I don't agree with this. Too many people waste time designing for +> > "what if..." scenarios that never happen. You don't want to be dumb and +> > design something that locks out a foreseeable and likely future need, +but +> > referential integrity doesn't meet this criterion. There's nothing to +keep +> > you from changing from app-managed to database-managed referential +> > integrity if your needs change. +> +> In this case your argument makes no sense, because you will spend far +> more time re-creating RI capability inside an application than if you +> just use what the database offers natively. +> +> It's certainly true that you don't want to over-engineer for no reason, +> but many times choices are made to save a very small amount of time or +> hassle up-front, and those choices become extremely painful later. +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 14:31:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2410111F6243 + for ; + Tue, 18 Apr 2006 14:31:55 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.127 +X-Spam-Level: +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Ng8BuBrOt+fT + for ; + Tue, 18 Apr 2006 14:31:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id C171A11F625E + for ; + Tue, 18 Apr 2006 14:31:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IHVmcF014986; + Tue, 18 Apr 2006 13:31:48 -0400 (EDT) +To: Gavin Hamill +cc: pgsql-performance@postgresql.org +Subject: Re: Slow query - possible bug? +In-reply-to: <44449E4C.7040804@laterooms.com> +References: <443E3DF5.4020207@laterooms.com> + <3c1395330604130546g6b091f75x511955817fe65dcd@mail.gmail.com> + <443E4C9D.3090301@laterooms.com> <20329.1144942010@sss.pgh.pa.us> + <44449E4C.7040804@laterooms.com> +Comments: In-reply-to Gavin Hamill + message dated "Tue, 18 Apr 2006 09:07:40 +0100" +Date: Tue, 18 Apr 2006 13:31:48 -0400 +Message-ID: <14985.1145381508@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/390 +X-Sequence-Number: 18474 + +Gavin Hamill writes: +> Tom Lane wrote: +>> I'm thinking the planner is misestimating something, but it's hard +>> to tell what without breaking it down. + +> (allocation0_."Date" between '2006-06-10 00:00:00.000000' and +> '2006-06-10 00:00:00.000000'); +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------------- +> Index Scan using ix_date on "Allocation" allocation0_ (cost=0.00..4.77 +> rows=1 width=34) (actual time=0.035..6706.467 rows=34220 loops=1) +> Index Cond: (("Date" >= '2006-06-10'::date) AND ("Date" <= +> '2006-06-10'::date)) +> Total runtime: 6728.743 ms + +Bingo, there's our misestimation: estimated 1 row, actual 34220 :-( + +That's why it's choosing the wrong index: it thinks the condition on +RoomID isn't going to reduce the number of rows fetched any further, +and so the smaller index ought to be marginally cheaper to use. +In reality, it works way better when using the two-column index. + +I think this is the same problem recently discussed about how the +degenerate case for a range comparison is making an unreasonably small +estimate, where it probably ought to fall back to some equality estimate +instead. With the simple-equality form of the date condition, it does +get a reasonable estimate, and so it picks the right index. + +There should be a fix for this by the time PG 8.2 comes out, but in the +meantime you might find that it helps to write the range check in a way +that doesn't have identical bounds, eg + date >= '2006-06-10'::date AND date < '2006-06-11'::date + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 16:08:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C933C11F6238 + for ; + Tue, 18 Apr 2006 16:08:45 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.106 +X-Spam-Level: +X-Spam-Status: No, score=0.106 required=5 tests=[AWL=0.106] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 4L+aBbRIsIEs + for ; + Tue, 18 Apr 2006 16:08:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (fon.nation-net.com [194.24.251.1]) + by postgresql.org (Postfix) with ESMTP id 00FA511F60B9 + for ; + Tue, 18 Apr 2006 16:08:39 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id 525EA136CCB + for ; + Tue, 18 Apr 2006 20:08:38 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id 2DF11136C5B + for ; + Tue, 18 Apr 2006 20:08:38 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id 55C4C75A9A + for ; + Tue, 18 Apr 2006 20:08:40 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id 4348975A89 + for ; + Tue, 18 Apr 2006 20:08:40 +0100 (BST) +Date: Tue, 18 Apr 2006 20:08:39 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: Slow query - possible bug? +Message-Id: <20060418200839.1f948672.gdh@laterooms.com> +In-Reply-To: <14985.1145381508@sss.pgh.pa.us> +References: <443E3DF5.4020207@laterooms.com> + <3c1395330604130546g6b091f75x511955817fe65dcd@mail.gmail.com> + <443E4C9D.3090301@laterooms.com> <20329.1144942010@sss.pgh.pa.us> + <44449E4C.7040804@laterooms.com> <14985.1145381508@sss.pgh.pa.us> +X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.17; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Archive-Number: 200604/391 +X-Sequence-Number: 18475 + +On Tue, 18 Apr 2006 13:31:48 -0400 +Tom Lane wrote: + +> There should be a fix for this by the time PG 8.2 comes out, but in +> the meantime you might find that it helps to write the range check in +> a way that doesn't have identical bounds, eg +> date >= '2006-06-10'::date AND date < '2006-06-11'::date + +OK coolies - we've already had a code release for this (and other +stuff) planned for tomorrow morning checking on the client side +if a single date has been chosen, then do an equality test on that... +otherwise leave the between in place - seems to work like a charm, and +hopefully it'll mean we don't have a loadavg of 15 on our main pg +server tomorrow (!) :)) + +Basically, as long as I know it's a pg issue rather than something daft +I've done (or not done) then I'm happy enough. + +Cheers, +Gavin. + +From pgsql-performance-owner@postgresql.org Tue Apr 18 16:52:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C5F5011F8CA7 + for ; + Tue, 18 Apr 2006 16:52:03 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.128 +X-Spam-Level: +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Ywz1Uj+LdHoL + for ; + Tue, 18 Apr 2006 16:51:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 9EBD111F8CA2 + for ; + Tue, 18 Apr 2006 16:51:48 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IJpj2n018449; + Tue, 18 Apr 2006 15:51:45 -0400 (EDT) +To: Gavin Hamill +cc: pgsql-performance@postgresql.org +Subject: Re: Slow query - possible bug? +In-reply-to: <20060418200839.1f948672.gdh@laterooms.com> +References: <443E3DF5.4020207@laterooms.com> + <3c1395330604130546g6b091f75x511955817fe65dcd@mail.gmail.com> + <443E4C9D.3090301@laterooms.com> <20329.1144942010@sss.pgh.pa.us> + <44449E4C.7040804@laterooms.com> <14985.1145381508@sss.pgh.pa.us> + <20060418200839.1f948672.gdh@laterooms.com> +Comments: In-reply-to Gavin Hamill + message dated "Tue, 18 Apr 2006 20:08:39 +0100" +Date: Tue, 18 Apr 2006 15:51:44 -0400 +Message-ID: <18448.1145389904@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/392 +X-Sequence-Number: 18476 + +Gavin Hamill writes: +> On Tue, 18 Apr 2006 13:31:48 -0400 +> Tom Lane wrote: +>> There should be a fix for this by the time PG 8.2 comes out, but in +>> the meantime you might find that it helps to write the range check in +>> a way that doesn't have identical bounds, eg +>> date >= '2006-06-10'::date AND date < '2006-06-11'::date + +> OK coolies - we've already had a code release for this (and other +> stuff) planned for tomorrow morning checking on the client side +> if a single date has been chosen, then do an equality test on that... + +Fair enough, no reason to replace one workaround with another. But +would you try it on your test case, just to verify the diagnosis? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 16:56:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 58A3111F6106 + for ; + Tue, 18 Apr 2006 16:56:26 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.46 +X-Spam-Level: +X-Spam-Status: No, score=0.46 required=5 tests=[AWL=0.184, + MAILTO_TO_SPAM_ADDR=0.276] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 9IyXxmWCvjUC + for ; + Tue, 18 Apr 2006 16:56:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id AE16111F660E + for ; + Tue, 18 Apr 2006 16:56:02 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id B3F6956445; Tue, 18 Apr 2006 14:56:02 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 14:56:01 -0500 +Date: Tue, 18 Apr 2006 14:56:01 -0500 +From: "Jim C. Nasby" +To: Cris Carampa +Cc: pgsql-performance@postgresql.org +Subject: Re: index is not used if I include a function that returns current + time in my query +Message-ID: <20060418195601.GE49405@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060418:cris119@operamail.com::KKNY9TFNgVAiY26R:0000000000000000 + 0000000000000000000000009YP+ +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::0St+Dlb+gxgvtVlU:00000 + 0000000000000000000000006xNG +X-Archive-Number: 200604/393 +X-Sequence-Number: 18477 + +Interesting.... what's EXPLAIN ANALYZE show if you SET +enable_seqscan=off; ? + +You should also consider upgrading to 8.1... + +On Thu, Apr 13, 2006 at 12:25:02PM +0200, Cris Carampa wrote: +> Hello, postgresql 7.4.8 on SuSE Linux here. +> +> I have a table called DMO with a column called ORA_RIF defined as +> "timestamp without time zone" ; +> +> I created an index on this table based on this column only. +> +> If I run a query against a text literal the index is used: +> +> > explain select * from dmo where ora_rif>'2006-01-01'; +> QUERY PLAN +> ----------------------------------------------------------------------------------------- +> Index Scan using dmo_ndx02 on dmo (cost=0.00..1183.23 rows=736 width=156) +> Index Cond: (ora_rif > '2006-01-01 00:00:00'::timestamp without time +> zone) +> +> If I try to use a function that returns the current time instead, a +> sequential scan is always performed: +> +> > explain select * from dmo where ora_rif>localtimestamp; +> QUERY PLAN +> ------------------------------------------------------------------------------ +> Seq Scan on dmo (cost=0.00..1008253.22 rows=2703928 width=156) +> Filter: (ora_rif > ('now'::text)::timestamp(6) without time zone) +> +> > explain select * from dmo where ora_rif>localtimestamp::timestamp +> without time zone; +> QUERY PLAN +> ------------------------------------------------------------------------------ +> Seq Scan on dmo (cost=0.00..1008253.22 rows=2703928 width=156) +> Filter: (ora_rif > ('now'::text)::timestamp(6) without time zone) +> +> ... etc. ... +> +> (tried with all datetime functions with and without cast) +> +> I even tried to write a function that explicitly returns a "timestamp +> without time zone" value: +> +> create or replace function f () returns timestamp without time zone +> as ' +> declare +> x timestamp without time zone ; +> begin +> x := ''2006-01-01 00:00:00''; +> return x ; +> end ; +> ' language plpgsql ; +> +> But the result is the same: +> +> > explain select * from dmo ora_rif>f(); +> QUERY PLAN +> ----------------------------------------------------------------------------- +> Seq Scan on dmo (cost=0.00..987973.76 rows=2703928 width=156) +> Filter: (ora_rif > f()) +> +> Any suggestion? +> +> Kind regards, +> +> -- +> Cris Carampa (spamto:cris119@operamail.com) +> +> potevo chiedere come si chiama il vostro cane +> il mio ? un po' di tempo che si chiama Libero +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 17:01:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2A1D911F6004 + for ; + Tue, 18 Apr 2006 17:01:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.321 +X-Spam-Level: +X-Spam-Status: No, score=0.321 required=5 tests=[AWL=0.321] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id YXASIzqTLIaS + for ; + Tue, 18 Apr 2006 17:01:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id C316211F7DF9 + for ; + Tue, 18 Apr 2006 17:01:16 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 61BAD56447; Tue, 18 Apr 2006 15:01:16 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 15:01:16 -0500 +Date: Tue, 18 Apr 2006 15:01:15 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Postgresql Performance +Subject: Re: Blocks read for index scans +Message-ID: <20060418200115.GF49405@pervasive.com> +References: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> + <2789.1144974969@sss.pgh.pa.us> + <20060414061414.GY49405@pervasive.com> + <9369.1145027575@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <9369.1145027575@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060418:tgl@sss.pgh.pa.us::yjKd+gfL5HURCpib:00000000000000000000 + 0000000000000000000000004oYG +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::zKEjyFinyaIBjkI1:00000 + 0000000000000000000000000IiD +X-Archive-Number: 200604/394 +X-Sequence-Number: 18478 + +On Fri, Apr 14, 2006 at 11:12:55AM -0400, Tom Lane wrote: +> "Jim C. Nasby" writes: +> > In my case it would be helpful to break the heap access numbers out +> > between seqscans and index scans, since each of those represents very +> > different access patterns. Would adding that be a mess? +> +> Yes; it'd require more counters-per-table than we now keep, thus +> nontrivial bloat in the stats collector's tables. Not to mention + +ISTM it would only require two additional columns, which doesn't seem +unreasonable, especially considering the value of the information +collected. + +> incompatible changes in the pgstats views and the underlying functions +> (which some apps probably use directly). + +There's certainly ways around that issue, especially since this would +only be adding new information (though we would probably want to +consider the old info as depricated and eventually remove it). +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 17:06:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 51A0211F8BF7 + for ; + Tue, 18 Apr 2006 17:06:47 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.328 +X-Spam-Level: +X-Spam-Status: No, score=-2.328 required=5 tests=[AWL=0.271, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 6McMi4HWrHZN + for ; + Tue, 18 Apr 2006 17:06:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id F3D5A11F8BCE + for ; + Tue, 18 Apr 2006 17:06:43 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 0968C56445; Tue, 18 Apr 2006 15:06:43 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 15:06:42 -0500 +Date: Tue, 18 Apr 2006 15:06:41 -0500 +From: "Jim C. Nasby" +To: Terje Elde +Cc: pgsql-performance@postgresql.org +Subject: Re: Blocks read for index scans +Message-ID: <20060418200641.GG49405@pervasive.com> +References: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> + <443F3BB3.30404@elde.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <443F3BB3.30404@elde.net> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060418:terje@elde.net::E7MKv3VCUgfE3Blw:0008Sqr +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::e4X2sdlWF8wMkhTo:00000 + 0000000000000000000000003QYu +X-Archive-Number: 200604/395 +X-Sequence-Number: 18479 + +On Fri, Apr 14, 2006 at 08:05:39AM +0200, Terje Elde wrote: +> Jim Nasby wrote: +> >While working on determining a good stripe size for a database, I +> >realized it would be handy to know what the average request size is. +> >Getting this info is a simple matter of joining pg_stat_all_tables and +> >pg_statio_all_tables and doing some math, but there's one issue I've +> >found; it appears that there's no information on how many heap blocks +> >were read in by an index scan. Is there any way to get that info? + +> Knowing what the average stripe size is can be a good place to start, +> but the real question is; which stripe size will allow the majority of +> your transactions to be possible to satisfy without having to go to two +> spindles? + +And of course right now there's not a very good way to know that... +granted, I can look at the average request size on the machine, but that +will include any seqscans that are happening, and for stripe sizing I +think it's better to leave that out of the picture unless your workload +is heavily based on seqscans. + +> That said, it's the transactions against disk that typically matter. On +> FreeBSD, you can get an impression of this using 'systat -vmstat', and +> watch the KB/t column for your drives. + +On a related note, you know of any way to determine the breakdown +between read activity and write activity on FreeBSD? vmstat, systat, +iostat all only return aggregate info. :( +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 17:26:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 1AAC911F60E9 + for ; + Tue, 18 Apr 2006 17:26:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.365 +X-Spam-Level: +X-Spam-Status: No, score=-2.365 required=5 tests=[AWL=0.100, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 3qDB2dlNpD92 + for ; + Tue, 18 Apr 2006 17:26:30 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (fon.nation-net.com [194.24.251.1]) + by postgresql.org (Postfix) with ESMTP id 5ACC811F6B77 + for ; + Tue, 18 Apr 2006 17:26:28 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id E1B68136EA1 + for ; + Tue, 18 Apr 2006 21:26:26 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id B5B72136E8B + for ; + Tue, 18 Apr 2006 21:26:26 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id EF28F75A9A + for ; + Tue, 18 Apr 2006 21:26:28 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id BD57D75A85 + for ; + Tue, 18 Apr 2006 21:26:28 +0100 (BST) +Date: Tue, 18 Apr 2006 21:26:28 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: Slow query - possible bug? +Message-Id: <20060418212628.9aabc45a.gdh@laterooms.com> +In-Reply-To: <18448.1145389904@sss.pgh.pa.us> +References: <443E3DF5.4020207@laterooms.com> + <3c1395330604130546g6b091f75x511955817fe65dcd@mail.gmail.com> + <443E4C9D.3090301@laterooms.com> <20329.1144942010@sss.pgh.pa.us> + <44449E4C.7040804@laterooms.com> <14985.1145381508@sss.pgh.pa.us> + <20060418200839.1f948672.gdh@laterooms.com> + <18448.1145389904@sss.pgh.pa.us> +X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.17; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Archive-Number: 200604/396 +X-Sequence-Number: 18480 + +On Tue, 18 Apr 2006 15:51:44 -0400 +Tom Lane wrote: + +> Fair enough, no reason to replace one workaround with another. But +> would you try it on your test case, just to verify the diagnosis? + +Yup I can confirm it from testing earlier today - as soon as +the two dates are non-equal, an index scan is correctly selected and +returns results in just a few milliseconds: + +laterooms=# explain analyse select allocation0_."ID" as y1_, +allocation0_."RoomID" as y2_, allocation0_."StatusID" as y4_, +allocation0_."Price" as y3_, allocation0_."Number" as y5_, +allocation0_."Date" as y6_ from "Allocation" allocation0_ where +(allocation0_."Date" between '2006-04-25 00:00:00.000000' and +'2006-04-26 00:00:00.000000')and(allocation0_."RoomID" in(211800)); +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------- +Index Scan using ix_dateroom on "Allocation" allocation0_ +(cost=0.00..14.02 rows=4 width=34) (actual time=16.799..21.804 rows=2 +loops=1) Index Cond: (("RoomID" = 211800) AND ("Date" >= +'2006-04-25'::date) AND ("Date" <= '2006-04-26'::date)) +Total runtime: 21.910 ms + +which I ran first, versus the identical-date equivalent which turned +in a whopping... + + Index Scan using ix_date on "Allocation" allocation0_ +(cost=0.00..4.77 rows=1 width=34) (actual time=6874.272..69541.064 +rows=1 loops=1) Index Cond: (("Date" >= '2006-04-25'::date) AND ("Date" +<= '2006-04-25'::date)) Filter: ("RoomID" = 211800) Total runtime: +69541.113 ms (4 rows) + +Cheers, +Gavin. + +From pgsql-performance-owner@postgresql.org Tue Apr 18 18:04:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 67C6E11F714D + for ; + Tue, 18 Apr 2006 18:04:03 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.316 +X-Spam-Level: +X-Spam-Status: No, score=0.316 required=5 tests=[AWL=0.316] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id VmK132uenVih + for ; + Tue, 18 Apr 2006 18:03:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 3E03F11F712D + for ; + Tue, 18 Apr 2006 18:03:56 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 17A7B56427; Tue, 18 Apr 2006 16:03:57 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 16:03:56 -0500 +Date: Tue, 18 Apr 2006 16:03:56 -0500 +From: "Jim C. Nasby" +To: Scott Marlowe +Cc: Francisco Reyes , + Michael Stone , pgsql-performance@postgresql.org +Subject: Re: Inserts optimization? +Message-ID: <20060418210356.GH49405@pervasive.com> +References: <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + + <20060414055923.GX49405@pervasive.com> + + <20060414114911.GG32678@mathom.us> + + <20060414190620.GH32678@mathom.us> + + <1145045732.23538.86.camel@state.g2switchworks.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1145045732.23538.86.camel@state.g2switchworks.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060418:smarlowe@g2switchworks.com::rSV6qCi98LdsgO3i:00000000000 + 00000000000000000000000017LQ +X-Hashcash: + 1:20:060418:lists@stringsutils.com::ZaXwfD8ruwwKSxur:000000000000000 + 00000000000000000000000034ii +X-Hashcash: + 1:20:060418:mstone+postgres@mathom.us::bFlJNLP5YW1QJ6+N:000000000000 + 0000000000000000000000001Chd +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::59/+mQwCN0KWVa1l:00000 + 00000000000000000000000007J3 +X-Archive-Number: 200604/397 +X-Sequence-Number: 18481 + +On Fri, Apr 14, 2006 at 03:15:33PM -0500, Scott Marlowe wrote: +> On Fri, 2006-04-14 at 15:09, Francisco Reyes wrote: +> > Michael Stone writes: +> > +> > > I still don't follow that. Why would the RAID level matter? IOW, are you +> > > actually wanting 2 spares, or are you just stick with that because you +> > > need a factor of two disks for your mirrors? +> > +> > RAID 10 needs pairs.. so we can either have no spares or 2 spares. +> +> Spares are placed in service one at a time. You don't need 2 spares for +> RAID 10, trust me. + +Sadly, 3ware doesn't produce any controllers with the ability to do an +odd number of channels, so you end up burning through 2 slots to get a +hot spare (unless you spend substantially more money and go with the +next model up). +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 18:10:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 6E1FA11F73CF + for ; + Tue, 18 Apr 2006 18:10:13 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.344 +X-Spam-Level: +X-Spam-Status: No, score=-2.344 required=5 tests=[AWL=0.255, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id EE45L6L5xXgl + for ; + Tue, 18 Apr 2006 18:10:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 3DBD211F72B8 + for ; + Tue, 18 Apr 2006 18:10:06 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id F069356423; Tue, 18 Apr 2006 16:10:06 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 16:10:06 -0500 +Date: Tue, 18 Apr 2006 16:10:05 -0500 +From: "Jim C. Nasby" +To: Magnus Hagander +Cc: Francisco Reyes , + Marc Cousin , Chris , + Pgsql performance +Subject: Re: Inserts optimization? +Message-ID: <20060418211005.GI49405@pervasive.com> +References: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060418:mha@sollentuna.net::5f4bWPn4A73w2/o5:0000000000000000000 + 0000000000000000000000000g2y +X-Hashcash: + 1:20:060418:lists@stringsutils.com::+bpGXpuekq+L5+RY:000000000000000 + 0000000000000000000000002yzN +X-Hashcash: 1:20:060418:mcousin@sigma.fr::riu64ycJOaKQ9Mqc:03yKS +X-Hashcash: + 1:20:060418:dmagick@gmail.com::MzD4LqUfsku6uDuB:00000000000000000000 + 0000000000000000000000000hua +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::EKWbdrWeXElUXHCr:00000 + 0000000000000000000000002H7T +X-Archive-Number: 200604/398 +X-Sequence-Number: 18482 + +On Tue, Apr 18, 2006 at 01:56:44PM +0200, Magnus Hagander wrote: +> Bacula already serializes access to the database (they have to support +> mysql/myisam), so this shouldn't help. Actually, it might well hurt by +> introducing extra delays. + +You have any contact with the developers? Maybe they're a possibility +for our summer of code... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 18:34:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id D233111F7742 + for ; + Tue, 18 Apr 2006 18:34:48 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.353 +X-Spam-Level: +X-Spam-Status: No, score=-2.353 required=5 tests=[AWL=0.246, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id RlpkpT9LgFYR + for ; + Tue, 18 Apr 2006 18:34:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 3226111F644E + for ; + Tue, 18 Apr 2006 18:34:44 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 708FD56423; Tue, 18 Apr 2006 16:34:44 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 16:34:44 -0500 +Date: Tue, 18 Apr 2006 16:34:44 -0500 +From: "Jim C. Nasby" +To: Julien Drouard +Cc: pgsql-performance@postgresql.org +Subject: Re: pg_toast size +Message-ID: <20060418213443.GJ49405@pervasive.com> +References: <000c01c65fc5$41c78a70$0700a8c0@ankama.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <000c01c65fc5$41c78a70$0700a8c0@ankama.lan> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060418:jdrouard@ankama.com::JEHOqVa4tkBOjtao:000000000000000000 + 0000000000000000000000003JJp +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::O5TYjhqyv7qHUf2s:00000 + 0000000000000000000000000rjz +X-Archive-Number: 200604/399 +X-Sequence-Number: 18483 + +On Fri, Apr 14, 2006 at 03:13:43PM +0200, Julien Drouard wrote: +> Hi everyone, +> +> I've seen my pg_toast tables are becoming bigger and bigger. After googling I would like to modify my max_fsm_pages parameter to prevent that kind of problem. So I'm wondering if changing this parameter is enough and after that how can I reduce the size of these tables? By doing a full vacuum? + +A full vacuum would do it. CLUSTERing the table might rewrite the toast +tables as well. + +As for toast, if you do a vacuum verbose over the entire cluster, it +will tell you at the end how much space you need in the FSM. See also +http://www.pervasivepostgres.com/instantkb13/article.aspx?id=10087 +and http://www.pervasivepostgres.com/instantkb13/article.aspx?id=10116 +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 18:52:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 77C7611F6A9A + for ; + Tue, 18 Apr 2006 18:52:45 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.31 +X-Spam-Level: +X-Spam-Status: No, score=0.31 required=5 tests=[AWL=0.310] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id oLT3hetOvp62 + for ; + Tue, 18 Apr 2006 18:52:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 53C3111F6278 + for ; + Tue, 18 Apr 2006 18:52:38 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 852D156423; Tue, 18 Apr 2006 16:52:38 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 16:52:38 -0500 +Date: Tue, 18 Apr 2006 16:52:38 -0500 +From: "Jim C. Nasby" +To: Markus Schaber +Cc: pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +Message-ID: <20060418215238.GK49405@pervasive.com> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4444C4CF.2000106@logix-tt.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060418:schabi@logix-tt.com::z3ecxgRhEswvs+zK:000000000000000000 + 0000000000000000000000001XQ6 +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::SlxOpEoPScAG8EM9:00000 + 0000000000000000000000000FHW +X-Archive-Number: 200604/400 +X-Sequence-Number: 18484 + +On Tue, Apr 18, 2006 at 12:51:59PM +0200, Markus Schaber wrote: +> > In my mind this is tied into another issue, which is that the planner +> > always costs on the basis of each query starting from zero. In a real +> > environment it's much cheaper to use heavily-used indexes than this cost +> > model suggests, because they'll already be swapped in due to use by +> > previous queries. But we haven't got any infrastructure to keep track +> > of what's been heavily used, let alone a cost model that could make use +> > of the info. +> +> An easy first approach would be to add a user tunable cache probability +> value to each index (and possibly table) between 0 and 1. Then simply +> multiply random_page_cost with (1-that value) for each scan. +> +> Later, this value could be automatically tuned by stats analysis or +> other means. + +Actually, if you run with stats_block_level turned on you have a +first-order approximation of what is and isn't cached. Perhaps the +planner could make use of this information if it's available. + +> > I think part of the reason that people commonly reduce random_page_cost +> > to values much lower than physical reality would suggest is that it +> > provides a crude way of partially compensating for this basic problem. +> +> I totall agree with this, it's just what we did here from time to time. :-) +> +> Hmm, how does effective_cach_size correspond with it? Shouldn't a high +> effective_cache_size have a similar effect? + +Generally, effective_cache_size is used to determine the likelyhood that +something will be in-cache. random_page_cost tells us how expensive it +will be to get that information if it isn't in cache. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 19:34:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 4F7C311F6CFB + for ; + Tue, 18 Apr 2006 19:34:49 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id SkX-uKxp3Sgb + for ; + Tue, 18 Apr 2006 19:34:47 -0300 (ADT) +X-Greylist: delayed 00:25:59.458818 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id AC24F11F6CBA + for ; + Tue, 18 Apr 2006 19:34:33 -0300 (ADT) +Received: from mx1.vodamail.co.za (mx1.vodamail.co.za [196.11.146.148]) + by svr4.postgresql.org (Postfix) with ESMTP id 742145AF663 + for ; + Tue, 18 Apr 2006 22:08:33 +0000 (GMT) +Received: from localhost (localhost [127.0.0.1]) + by mx1.vodamail.co.za (Postfix) with ESMTP id A3AD267822 + for ; + Wed, 19 Apr 2006 00:08:24 +0200 (SAST) +Received: from mx1.vodamail.co.za ([127.0.0.1]) + by localhost (mx1.vodamail.co.za [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 08648-10 for ; + Wed, 19 Apr 2006 00:08:24 +0200 (SAST) +Received: from josh.flame2.flame.co.za (unknown [10.48.102.43]) + by mx1.vodamail.co.za (Postfix) with ESMTP id 6B3D8663C9 + for ; + Wed, 19 Apr 2006 00:08:20 +0200 (SAST) +Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) + by josh.flame2.flame.co.za (8.12.11/8.12.11) with ESMTP id + k3IM7tv4003083 + for ; Wed, 19 Apr 2006 00:07:59 +0200 +Subject: Multicolumn order by +From: Theo Kramer +Reply-To: theo@flame.co.za +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: Flame Computing Enterprises cc +Message-Id: <1145398075.3048.18.camel@josh> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 19 Apr 2006 00:07:55 +0200 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: amavisd-new at vodamail.co.za +X-Archive-Number: 200604/404 +X-Sequence-Number: 18488 + +Hi + +Apologies if this has already been raised... + +PostgreSQL 8.1.3 and prior versions. Vacuum done. + +Assuming a single table with columns named c1 to cn and a requirement to +select from a particular position in multiple column order. + +The column values in my simple example below denoted by 'cnv' a typical +query would look as follows + +select * from mytable where + (c1 = 'c1v' and c2 = 'c2v' and c3 >= 'c3v') or + (c1 = 'c1v' and c2 > 'c2v') or + (c1 > 'c1v') + order by c1, c2, c3; + +In real life with the table containing many rows (>9 Million) and +a single multicolumn index on the required columns existing I get the +following + +explain analyse + SELECT + tran_subledger, + tran_subaccount, + tran_mtch, + tran_self, + tran_Rflg FROM tran +WHERE ((tran_subledger = 2 AND tran_subaccount = 'ARM ' +AND tran_mtch = 0 AND tran_self >= 0 ) +OR (tran_subledger = 2 AND tran_subaccount = 'ARM ' AND +tran_mtch > 0 ) +OR (tran_subledger = 2 AND tran_subaccount > 'ARM ' ) +OR (tran_subledger > 2 )) +ORDER BY tran_subledger, + tran_subaccount, + tran_mtch, + tran_self +limit 10; + + Limit (cost=0.00..25.21 rows=10 width=36) (actual +time=2390271.832..2390290.305 rows=10 loops=1) + -> Index Scan using tran_mtc_idx on tran (cost=0.00..13777295.04 +rows=5465198 width=36) (actual time=2390271.823..2390290.252 rows=10 +loops=1) + Filter: (((tran_subledger = 2) AND (tran_subaccount = 'ARM +'::bpchar) AND (tran_mtch = 0) AND (tran_self >= 0)) OR ((tran_subledger += 2) AND (tran_subaccount = 'ARM '::bpchar) AND +(tran_mtch > 0)) OR ((tran_subledger = 2) AND (tran_subaccount > +'ARM '::bpchar)) OR (tran_subledger > 2)) + Total runtime: 2390290.417 ms + +Any suggestions/comments/ideas appreciated. +-- +Regards +Theo + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 19:22:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 8244C11F6964 + for ; + Tue, 18 Apr 2006 19:22:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.301 +X-Spam-Level: +X-Spam-Status: No, score=-2.301 required=5 tests=[AWL=0.300, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id T1nSRd5nBWbX + for ; + Tue, 18 Apr 2006 19:22:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id BC70811F6B16 + for ; + Tue, 18 Apr 2006 19:22:30 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IMMRYB019389; + Tue, 18 Apr 2006 18:22:27 -0400 (EDT) +To: "Jim C. Nasby" +cc: Markus Schaber , pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +In-reply-to: <20060418215238.GK49405@pervasive.com> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> + <20060418215238.GK49405@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Tue, 18 Apr 2006 16:52:38 -0500" +Date: Tue, 18 Apr 2006 18:22:26 -0400 +Message-ID: <19388.1145398946@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/401 +X-Sequence-Number: 18485 + +"Jim C. Nasby" writes: +> Actually, if you run with stats_block_level turned on you have a +> first-order approximation of what is and isn't cached. + +Only if those stats decayed (pretty fast) with time; which they don't. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 19:26:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 5E41511F6913 + for ; + Tue, 18 Apr 2006 19:26:55 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.303 +X-Spam-Level: +X-Spam-Status: No, score=-2.303 required=5 tests=[AWL=0.298, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id nJahHAdn4M3k + for ; + Tue, 18 Apr 2006 19:26:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id DFB7211F6B6D + for ; + Tue, 18 Apr 2006 19:26:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IMQmcQ019434; + Tue, 18 Apr 2006 18:26:49 -0400 (EDT) +To: Markus Schaber +cc: pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +In-reply-to: <4444C4CF.2000106@logix-tt.com> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> +Comments: In-reply-to Markus Schaber + message dated "Tue, 18 Apr 2006 12:51:59 +0200" +Date: Tue, 18 Apr 2006 18:26:48 -0400 +Message-ID: <19433.1145399208@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/402 +X-Sequence-Number: 18486 + +Markus Schaber writes: +> Hmm, how does effective_cach_size correspond with it? Shouldn't a high +> effective_cache_size have a similar effect? + +It seems reasonable to suppose that effective_cache_size ought to be +used as a number indicating how much "stuff" would hang around from +query to query. Right now it's not used that way... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 19:34:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id B5D6B11F6B65 + for ; + Tue, 18 Apr 2006 19:34:20 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.369 +X-Spam-Level: +X-Spam-Status: No, score=-2.369 required=5 tests=[AWL=0.230, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 231VCjgG0uC3 + for ; + Tue, 18 Apr 2006 19:34:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 4882411F6913 + for ; + Tue, 18 Apr 2006 19:34:11 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 1D57656427; Tue, 18 Apr 2006 17:34:12 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 17:34:11 -0500 +Date: Tue, 18 Apr 2006 17:34:11 -0500 +From: "Jim C. Nasby" +To: Sriram Dandapani +Cc: Tom Lane , + "Pgsql-Performance (E-mail)" +Subject: Re: creating of temporary table takes very long +Message-ID: <20060418223410.GL49405@pervasive.com> +References: <6992E470F12A444BB787B5C937B9D4DF0406A79C@ca-mail1.cis.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF0406A79C@ca-mail1.cis.local> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060418:sdandapani@counterpane.com::tPXNyEz5jLA7hpKT:00000000000 + 0000000000000000000000000OHF +X-Hashcash: + 1:20:060418:tgl@sss.pgh.pa.us::t176LGk040vSGFLB:00000000000000000000 + 0000000000000000000000005M6B +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::jssM8iyBTzgqv8xG:00000 + 0000000000000000000000006MVn +X-Archive-Number: 200604/403 +X-Sequence-Number: 18487 + +You might try rewriting the coalesces into a row comparison... + +WHERE row($4, $5, ...) IS NOT DISTINCT FROM row(interface_id, source_id, ...) + +See +http://www.postgresql.org/docs/8.1/interactive/functions-comparisons.html#AEN13408 + +Note that the docs only show IS DISTINCT FROM, so you might have to do + +WHERE NOT row(...) IS DISTINCT FROM row(...) + +On Tue, Apr 18, 2006 at 09:13:04AM -0700, Sriram Dandapani wrote: +> Thx Tom +> +> I guess I have to abandon the bulk update. The columns in the where +> clause comprise 80% of the table columns..So indexing all may not help. +> The target table will have on average 60-180 million rows. +> +> I will attempt the in instead of exist and let you know the result +> +> -----Original Message----- +> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +> Sent: Tuesday, April 18, 2006 9:10 AM +> To: Sriram Dandapani +> Cc: Pgsql-Performance (E-mail) +> Subject: Re: [PERFORM] creating of temporary table takes very long +> +> "Sriram Dandapani" writes: +> > Got an explain analyze output..Here it is +> > "Seq Scan on c_chkpfw_hr_tr a (cost=0.00..225975659.89 rows=11000 +> > width=136) (actual time=2.345..648070.474 rows=22001 loops=1)" +> > " Filter: (subplan)" +> > " SubPlan" +> > " -> Bitmap Heap Scan on chkpfw_tr_hr_dimension b +> > (cost=1474.64..10271.13 rows=1 width=0) (actual time=29.439..29.439 +> > rows=1 loops=22001)" +> > " Recheck Cond: (($0 = firstoccurrence) AND ($1 = +> sentryid_id) +> > AND ($2 = node_id))" +> > " Filter: (($3 = customerid_id) AND (COALESCE($4, 0) = +> > COALESCE(interface_id, 0)) AND (COALESCE($5, 0) = COALESCE(source_id, +> > 0)) AND (COALESCE($6, 0) = COALESCE(destination_id, 0)) AND +> > (COALESCE($7, 0) = COALESCE(sourceport_id, 0)) AND (COALESCE($8 (..)" +> > " -> Bitmap Index Scan on chkpfw_tr_hr_idx1 +> > (cost=0.00..1474.64 rows=38663 width=0) (actual time=12.144..12.144 +> > rows=33026 loops=22001)" +> > " Index Cond: (($0 = firstoccurrence) AND ($1 = +> > sentryid_id) AND ($2 = node_id))" +> > "Total runtime: 648097.800 ms" +> +> That's probably about as good a query plan as you can hope for given +> the way the query is written. Those COALESCE comparisons are all +> unindexable (unless you make functional indexes on the COALESCE +> expressions). You might get somewhere by converting the EXISTS +> to an IN, though. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 19:48:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 42DF711F6B86 + for ; + Tue, 18 Apr 2006 19:48:40 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.128 +X-Spam-Level: +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id VLt-gLNkcv2b + for ; + Tue, 18 Apr 2006 19:48:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 8DED411F6B6D + for ; + Tue, 18 Apr 2006 19:48:34 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IMmWXX019623; + Tue, 18 Apr 2006 18:48:32 -0400 (EDT) +To: "Jim C. Nasby" +cc: Sriram Dandapani , + "Pgsql-Performance (E-mail)" +Subject: Re: creating of temporary table takes very long +In-reply-to: <20060418223410.GL49405@pervasive.com> +References: <6992E470F12A444BB787B5C937B9D4DF0406A79C@ca-mail1.cis.local> + <20060418223410.GL49405@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Tue, 18 Apr 2006 17:34:11 -0500" +Date: Tue, 18 Apr 2006 18:48:32 -0400 +Message-ID: <19622.1145400512@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/405 +X-Sequence-Number: 18489 + +"Jim C. Nasby" writes: +> You might try rewriting the coalesces into a row comparison... +> WHERE row($4, $5, ...) IS NOT DISTINCT FROM row(interface_id, source_id, ...) + +That would be notationally nicer, but no help performance-wise; I'm +fairly sure that IS DISTINCT doesn't get optimized in any fashion +whatsoever :-( + +What might be worth trying is functional indexes on the COALESCE(foo,0) +expressions. Or if possible, consider revising your data schema to +avoid using NULLs in a way that requires assuming that NULL = NULL. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 20:08:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id B9ED111F6796 + for ; + Tue, 18 Apr 2006 20:08:42 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.306 +X-Spam-Level: +X-Spam-Status: No, score=-2.306 required=5 tests=[AWL=0.295, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id c45chBJiEecW + for ; + Tue, 18 Apr 2006 20:08:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id E557511F65E7 + for ; + Tue, 18 Apr 2006 20:08:39 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IN8Xcm019820; + Tue, 18 Apr 2006 19:08:33 -0400 (EDT) +To: theo@flame.co.za +cc: pgsql-performance@postgresql.org +Subject: Re: Multicolumn order by +In-reply-to: <1145398075.3048.18.camel@josh> +References: <1145398075.3048.18.camel@josh> +Comments: In-reply-to Theo Kramer + message dated "Wed, 19 Apr 2006 00:07:55 +0200" +Date: Tue, 18 Apr 2006 19:08:33 -0400 +Message-ID: <19819.1145401713@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/406 +X-Sequence-Number: 18490 + +Theo Kramer writes: +> select * from mytable where +> (c1 = 'c1v' and c2 = 'c2v' and c3 >= 'c3v') or +> (c1 = 'c1v' and c2 > 'c2v') or +> (c1 > 'c1v') +> order by c1, c2, c3; + +Yeah ... what you really want is the SQL-spec row comparison operator + +select ... where (c1,c2,c3) >= ('c1v','c2v','c3v') order by c1,c2,c3; + +This does not work properly in any current PG release :-( but it does +work and is optimized well in CVS HEAD. See eg this thread +http://archives.postgresql.org/pgsql-hackers/2006-02/msg00209.php + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 20:13:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C17D311F6B52 + for ; + Tue, 18 Apr 2006 20:13:56 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.306 +X-Spam-Level: +X-Spam-Status: No, score=0.306 required=5 tests=[AWL=0.306] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id rg0p86BIbgrI + for ; + Tue, 18 Apr 2006 20:13:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 84B3A11F6B37 + for ; + Tue, 18 Apr 2006 20:13:53 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 69BE756423; Tue, 18 Apr 2006 18:13:53 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 18:13:53 -0500 +Date: Tue, 18 Apr 2006 18:13:53 -0500 +From: "Jim C. Nasby" +To: Theo Kramer +Cc: pgsql-performance@postgresql.org +Subject: Re: Multicolumn order by +Message-ID: <20060418231352.GM49405@pervasive.com> +References: <1145398075.3048.18.camel@josh> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1145398075.3048.18.camel@josh> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060418:theo@flame.co.za::cCEeGT/GngXJXVTy:02i1B +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::W1n5/g8R/e0ZWMP2:00000 + 0000000000000000000000000tgM +X-Archive-Number: 200604/407 +X-Sequence-Number: 18491 + +Assuming stats are accurate, you're reading through 5.5M index rows in +order to run that limit query. You didn't say what the index was +actually on, but you might want to try giving each column it's own +index. That might make a bitmap scan feasable. + +I know this doesn't help right now, but 8.2 will also allow you to do +this using a row comparitor. You might want to compile cvs HEAD and see +how that does with this query (specifically if using a row comparitor +performs better than the query below). + +On Wed, Apr 19, 2006 at 12:07:55AM +0200, Theo Kramer wrote: +> Hi +> +> Apologies if this has already been raised... +> +> PostgreSQL 8.1.3 and prior versions. Vacuum done. +> +> Assuming a single table with columns named c1 to cn and a requirement to +> select from a particular position in multiple column order. +> +> The column values in my simple example below denoted by 'cnv' a typical +> query would look as follows +> +> select * from mytable where +> (c1 = 'c1v' and c2 = 'c2v' and c3 >= 'c3v') or +> (c1 = 'c1v' and c2 > 'c2v') or +> (c1 > 'c1v') +> order by c1, c2, c3; +> +> In real life with the table containing many rows (>9 Million) and +> a single multicolumn index on the required columns existing I get the +> following +> +> explain analyse +> SELECT +> tran_subledger, +> tran_subaccount, +> tran_mtch, +> tran_self, +> tran_Rflg FROM tran +> WHERE ((tran_subledger = 2 AND tran_subaccount = 'ARM ' +> AND tran_mtch = 0 AND tran_self >= 0 ) +> OR (tran_subledger = 2 AND tran_subaccount = 'ARM ' AND +> tran_mtch > 0 ) +> OR (tran_subledger = 2 AND tran_subaccount > 'ARM ' ) +> OR (tran_subledger > 2 )) +> ORDER BY tran_subledger, +> tran_subaccount, +> tran_mtch, +> tran_self +> limit 10; +> +> Limit (cost=0.00..25.21 rows=10 width=36) (actual +> time=2390271.832..2390290.305 rows=10 loops=1) +> -> Index Scan using tran_mtc_idx on tran (cost=0.00..13777295.04 +> rows=5465198 width=36) (actual time=2390271.823..2390290.252 rows=10 +> loops=1) +> Filter: (((tran_subledger = 2) AND (tran_subaccount = 'ARM +> '::bpchar) AND (tran_mtch = 0) AND (tran_self >= 0)) OR ((tran_subledger +> = 2) AND (tran_subaccount = 'ARM '::bpchar) AND +> (tran_mtch > 0)) OR ((tran_subledger = 2) AND (tran_subaccount > +> 'ARM '::bpchar)) OR (tran_subledger > 2)) +> Total runtime: 2390290.417 ms +> +> Any suggestions/comments/ideas appreciated. +> -- +> Regards +> Theo +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 20:15:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D634611F86B9 + for ; + Tue, 18 Apr 2006 20:15:57 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.301 +X-Spam-Level: +X-Spam-Status: No, score=0.301 required=5 tests=[AWL=0.301] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 0OpoqloxdLLD + for ; + Tue, 18 Apr 2006 20:15:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 34A7411F7DF9 + for ; + Tue, 18 Apr 2006 20:15:52 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 286DE56427; Tue, 18 Apr 2006 18:15:53 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 18:15:52 -0500 +Date: Tue, 18 Apr 2006 18:15:52 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Markus Schaber , pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +Message-ID: <20060418231552.GN49405@pervasive.com> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> + <20060418215238.GK49405@pervasive.com> + <19388.1145398946@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <19388.1145398946@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060418:tgl@sss.pgh.pa.us::cwE9a1oprI0FqnvH:00000000000000000000 + 0000000000000000000000002BFs +X-Hashcash: + 1:20:060418:schabi@logix-tt.com::Z2PzFFb/uEhX8RtI:000000000000000000 + 0000000000000000000000003Zy+ +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::/N/lzsroHLkoQ/0e:00000 + 0000000000000000000000001YGG +X-Archive-Number: 200604/408 +X-Sequence-Number: 18492 + +On Tue, Apr 18, 2006 at 06:22:26PM -0400, Tom Lane wrote: +> "Jim C. Nasby" writes: +> > Actually, if you run with stats_block_level turned on you have a +> > first-order approximation of what is and isn't cached. +> +> Only if those stats decayed (pretty fast) with time; which they don't. + +Good point. :/ I'm guessing there's no easy way to see how many blocks +for a given relation are in shared memory, either... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 20:22:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id A28E211F7DF9 + for ; + Tue, 18 Apr 2006 20:22:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.38 +X-Spam-Level: +X-Spam-Status: No, score=-2.38 required=5 tests=[AWL=0.219, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id loazuxuLacjZ + for ; + Tue, 18 Apr 2006 20:22:30 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id E674711F7DF4 + for ; + Tue, 18 Apr 2006 20:22:28 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id A447456423; Tue, 18 Apr 2006 18:22:28 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 18 Apr 2006 18:22:26 -0500 +Date: Tue, 18 Apr 2006 18:22:26 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Markus Schaber , pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +Message-ID: <20060418232226.GO49405@pervasive.com> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> + <19433.1145399208@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <19433.1145399208@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060418:tgl@sss.pgh.pa.us::j5bMirsmaCManfai:00000000000000000000 + 0000000000000000000000008dEr +X-Hashcash: + 1:20:060418:schabi@logix-tt.com::ORUGm7qkFE7wt3yN:000000000000000000 + 0000000000000000000000008rDX +X-Hashcash: + 1:20:060418:pgsql-performance@postgresql.org::xj0SEepZvrlhVR6b:00000 + 0000000000000000000000008SM0 +X-Archive-Number: 200604/409 +X-Sequence-Number: 18493 + +On Tue, Apr 18, 2006 at 06:26:48PM -0400, Tom Lane wrote: +> Markus Schaber writes: +> > Hmm, how does effective_cach_size correspond with it? Shouldn't a high +> > effective_cache_size have a similar effect? +> +> It seems reasonable to suppose that effective_cache_size ought to be +> used as a number indicating how much "stuff" would hang around from +> query to query. Right now it's not used that way... + +Maybe it would be a reasonable first pass to have estimators calculate +the cost if a node found everything it wanted in cache and then do a +linear interpolation between that and the costs we currently come up +with? Something like pg_class.relpages / sum(pg_class.relpages) would +give an idea of how much of a relation is likely to be cached, which +could be used for the linear interpolation. + +Of course having *any* idea as to how much of a relation was actually in +shared_buffers (or better yet, the OS cache) would be a lot more +accurate, but this simple method might be a good enough first-pass. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 20:38:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 1EEA111F61E9 + for ; + Tue, 18 Apr 2006 20:38:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.309 +X-Spam-Level: +X-Spam-Status: No, score=-2.309 required=5 tests=[AWL=0.292, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id E32h1IyKpyE3 + for ; + Tue, 18 Apr 2006 20:38:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id E3EAF11F6106 + for ; + Tue, 18 Apr 2006 20:38:34 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3INcXJu020065; + Tue, 18 Apr 2006 19:38:33 -0400 (EDT) +To: Markus Schaber +cc: pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +In-reply-to: <4444C4CF.2000106@logix-tt.com> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> +Comments: In-reply-to Markus Schaber + message dated "Tue, 18 Apr 2006 12:51:59 +0200" +Date: Tue, 18 Apr 2006 19:38:33 -0400 +Message-ID: <20064.1145403513@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/410 +X-Sequence-Number: 18494 + +Markus Schaber writes: +> An easy first approach would be to add a user tunable cache probability +> value to each index (and possibly table) between 0 and 1. Then simply +> multiply random_page_cost with (1-that value) for each scan. + +That's not the way you'd need to use it. But on reflection I do think +there's some merit in a "cache probability" parameter, ranging from zero +(giving current planner behavior) to one (causing the planner to assume +everything is already in cache from prior queries). We'd have to look +at exactly how such an assumption should affect the cost equations ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 22:02:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 4000C11F6263 + for ; + Tue, 18 Apr 2006 22:02:36 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.5 +X-Spam-Level: +X-Spam-Status: No, score=-2.5 required=5 tests=[AWL=0.101, BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id RD3hYtBTLZzA + for ; + Tue, 18 Apr 2006 22:02:29 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.226]) + by postgresql.org (Postfix) with ESMTP id F0A0B11F6227 + for ; + Tue, 18 Apr 2006 22:02:26 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so807351wra + for ; + Tue, 18 Apr 2006 18:02:27 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=dCuXkHVBvtEjZbZb96TOvH7ORS3qSwHxkPT/yG20NF5/2y8GOeAbQndcmOdxuWL1C+29iOBmDh4FijAat7LOnhxeWGsE/2CPs0ogf3AQ3If3E7/txdJhgEF7MaFZUXqHZr3NeBav5JN2PBDzq+Aykx3E3EWqz0DoxgXTa38jU9w= +Received: by 10.54.103.9 with SMTP id a9mr284909wrc; + Tue, 18 Apr 2006 17:59:55 -0700 (PDT) +Received: by 10.54.157.9 with HTTP; Tue, 18 Apr 2006 18:02:27 -0700 (PDT) +Message-ID: <53b425b00604181802v2cc259e1r59f9043b2cea3324@mail.gmail.com> +Date: Tue, 18 Apr 2006 18:02:27 -0700 +From: "patrick keshishian" +To: pgsql-performance@postgresql.org +Subject: Planner doesn't chose Index - (slow select) +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Archive-Number: 200604/411 +X-Sequence-Number: 18495 + +Hi all, + +I've been struggling with some performance issues with certain +SQL queries. I was prepping a long-ish overview of my problem +to submit, but I think I'll start out with a simple case of the +problem first, hopefully answers I receive will help me solve +my initial issue. + +Consider the following two queries which yield drastically different +run-time: + +db=3D# select count(*) from pk_c2 b0 where b0.offer_id=3D7141; + count +------- + 1 +(1 row) +Time: 5139.004 ms + +db=3D# select count(*) from pk_c2 b0 where b0.pending=3Dtrue and b0.offer_i= +d=3D7141; + count +------- + 1 +(1 row) +Time: 1.828 ms + + +That's 2811 times faster! + +Just to give you an idea of size of pk_c2 table: + +db=3D# select count(*) from pk_c2 ; + count +--------- + 2158094 +(1 row) +Time: 5275.782 ms + +db=3D# select count(*) from pk_c2 where pending=3Dtrue; + count +------- + 51 +(1 row) +Time: 5073.699 ms + + + +db=3D# explain select count(*) from pk_c2 b0 where b0.offer_id=3D7141; +QUERY PLAN +--------------------------------------------------------------------------- + Aggregate (cost=3D44992.78..44992.78 rows=3D1 width=3D0) + -> Seq Scan on pk_c2 b0 (cost=3D0.00..44962.50 rows=3D12109 width=3D0) + Filter: (offer_id =3D 7141) +(3 rows) +Time: 1.350 ms + +db=3D# explain select count(*) from pk_c2 b0 where b0.pending=3Dtrue and +b0.offer_id=3D7141; +QUERY PLAN +---------------------------------------------------------------------------= +------------- + Aggregate (cost=3D45973.10..45973.10 rows=3D1 width=3D0) + -> Index Scan using pk_boidx on pk_c2 b0 (cost=3D0.00..45973.09 +rows=3D1 width=3D0) + Index Cond: (offer_id =3D 7141) + Filter: (pending =3D true) +(4 rows) +Time: 1.784 ms + + + +The table has indexes for both 'offer_id' and '(pending=3Dtrue)': + +Indexes: + "pk_boidx" btree (offer_id) + "pk_bpidx" btree (((pending =3D true))) + +So, why would the planner chose to use the index on the second query +and not on the first? + + +Note that I am able to fool the planner into using an Index scan +on offer_id by adding a silly new condition in the where clause of +the first form of the query: + + +db=3D# explain select count(*) from pk_c2 b0 where b0.offer_id=3D7141 and o= +id > 1; +QUERY PLAN +---------------------------------------------------------------------------= +---------------- + Aggregate (cost=3D45983.19..45983.19 rows=3D1 width=3D0) + -> Index Scan using pk_boidx on pk_c2 b0 (cost=3D0.00..45973.09 +rows=3D4037 width=3D0) + Index Cond: (offer_id =3D 7141) + Filter: (oid > 1::oid) +(4 rows) +Time: 27.301 ms + +db=3D# select count(*) from pk_c2 b0 where b0.offer_id=3D7141 and oid > 1; + count +------- + 1 +(1 row) +Time: 1.900 ms + +What gives? + +This seems just too hokey for my taste. + +--patrick + + + +db=3D# select version(); + version +------------------------------------------------------------------------- + PostgreSQL 7.4.12 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.6 + +From pgsql-performance-owner@postgresql.org Tue Apr 18 23:19:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 92C3111F6BFF + for ; + Tue, 18 Apr 2006 23:19:48 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.128 +X-Spam-Level: +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id KMl+j7GdYWdt + for ; + Tue, 18 Apr 2006 23:19:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 45A8411F6B90 + for ; + Tue, 18 Apr 2006 23:19:44 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3J2JirE020958; + Tue, 18 Apr 2006 22:19:44 -0400 (EDT) +To: "patrick keshishian" +cc: pgsql-performance@postgresql.org +Subject: Re: Planner doesn't chose Index - (slow select) +In-reply-to: <53b425b00604181802v2cc259e1r59f9043b2cea3324@mail.gmail.com> +References: <53b425b00604181802v2cc259e1r59f9043b2cea3324@mail.gmail.com> +Comments: In-reply-to "patrick keshishian" + message dated "Tue, 18 Apr 2006 18:02:27 -0700" +Date: Tue, 18 Apr 2006 22:19:44 -0400 +Message-ID: <20957.1145413184@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/412 +X-Sequence-Number: 18496 + +"patrick keshishian" writes: +> I've been struggling with some performance issues with certain +> SQL queries. I was prepping a long-ish overview of my problem +> to submit, but I think I'll start out with a simple case of the +> problem first, hopefully answers I receive will help me solve +> my initial issue. + +Have you ANALYZEd this table lately? + +> db=# select count(*) from pk_c2 b0 where b0.offer_id=7141; +> count +> ------- +> 1 +> (1 row) + +The planner is evidently estimating that there are 12109 such rows, +not 1, which is the reason for its reluctance to use an indexscan. +Generally the only reason for it to be off that far on such a simple +statistical issue is if you haven't updated the stats in a long time. +(If you've got a really skewed data distribution for offer_id, you +might need to raise the statistics target for it.) + +> The table has indexes for both 'offer_id' and '(pending=true)': + +> Indexes: +> "pk_boidx" btree (offer_id) +> "pk_bpidx" btree (((pending = true))) + +The expression index on (pending = true) won't do you any good, +unless you spell your query in a weird way like + ... WHERE (pending = true) = true +I'd suggest a plain index on "pending" instead. + +> db=# select version(); +> PostgreSQL 7.4.12 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.6 + +You might want to think about an update, too. 7.4 is pretty long in the +tooth. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 18 23:20:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id D5F8311F8C2A + for ; + Tue, 18 Apr 2006 23:20:21 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.203 +X-Spam-Level: +X-Spam-Status: No, score=0.203 required=5 tests=[AWL=0.203] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id gy00EJT0OVMM + for ; + Tue, 18 Apr 2006 23:20:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id DFFBB11F8BFA + for ; + Tue, 18 Apr 2006 23:20:16 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 3E02825308; + Wed, 19 Apr 2006 10:20:14 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id E9CBF252E3; + Wed, 19 Apr 2006 10:20:11 +0800 (WST) +Message-ID: <44459EAF.2030601@calorieking.com> +Date: Wed, 19 Apr 2006 10:21:35 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: PFC +Cc: Tom Lane , mario.splivalo@mobart.hr, + pgsql-performance@postgresql.org +Subject: Re: SELECT FOR UPDATE performance is bad +References: <1145365720.18469.35.camel@localhost.localdomain> + <13037.1145370658@sss.pgh.pa.us> + <1145371662.31555.10.camel@localhost.localdomain> + <13609.1145374386@sss.pgh.pa.us> +In-Reply-To: +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chris.kings-lynne@calorieking.com +X-Archive-Number: 200604/413 +X-Sequence-Number: 18497 + +> Suppose you have a table codes : +> ( +> game_id INT, +> code TEXT, +> used BOOL NOT NULL DEFAULT 'f', +> prize ... +> ... +> PRIMARY KEY (game_id, code) +> ) +> +> Just UPDATE codes SET used='t' WHERE used='f' AND game_id=... AND +> code=... +> +> Then check the rowcount : if one row was updated, the code was not +> used yet. If no row was updated, the code either did not exist, or was +> already used. + +You can use a stored procedure with exceptions no? + +Try this: + +http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE + +Chris + + + +From pgsql-performance-owner@postgresql.org Tue Apr 18 23:41:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 9C3A711F6311 + for ; + Tue, 18 Apr 2006 23:41:42 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -1.322 +X-Spam-Level: +X-Spam-Status: No, score=-1.322 required=5 tests=[BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_FAIL=1.142] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id XD0Q4cCvIbbf + for ; + Tue, 18 Apr 2006 23:41:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 9498611F6376 + for ; + Tue, 18 Apr 2006 23:41:37 -0300 (ADT) +Received: from smtp.elde.net (us.elde.net [66.246.223.215]) + by svr4.postgresql.org (Postfix) with ESMTP id C782A5AF857 + for ; + Wed, 19 Apr 2006 02:41:38 +0000 (GMT) +Received: from smtp.elde.net (343006.ds.nac.net [127.0.0.1]) + by smtp.elde.net (Postfix) with ESMTP id 065F965003; + Wed, 19 Apr 2006 04:41:36 +0200 (CEST) +Received: from [127.0.0.1] (60.80-203-96.nextgentel.com [80.203.96.60]) + (Authenticated sender: terje@elde.net) + by smtp.elde.net (Postfix) with ESMTP id 02E1264F56; + Wed, 19 Apr 2006 04:41:33 +0200 (CEST) +Message-ID: <4445A1DF.6000705@elde.net> +Date: Wed, 19 Apr 2006 04:35:11 +0200 +From: Terje Elde +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: "Jim C. Nasby" +Cc: pgsql-performance@postgresql.org +Subject: Re: Blocks read for index scans +References: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> + <443F3BB3.30404@elde.net> <20060418200641.GG49405@pervasive.com> +In-Reply-To: <20060418200641.GG49405@pervasive.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-Archive-Number: 200604/414 +X-Sequence-Number: 18498 + +Jim C. Nasby wrote: +>> That said, it's the transactions against disk that typically matter. On +>> FreeBSD, you can get an impression of this using 'systat -vmstat', and +>> watch the KB/t column for your drives. +>> +> +> On a related note, you know of any way to determine the breakdown +> between read activity and write activity on FreeBSD? vmstat, systat, +> iostat all only return aggregate info. :( +> + + +Can't think of a right way to do this ATM, but for a lab-type setup to +get an idea, you could set up a gmirror volume, then choose a balancing +algorithm to only read from one of the disks. The effect should be that +writes go to both, while reads only go to one. Activity on the +write-only disk would give you an idea of the write activity, and +(read/write disk - write-only disk) would give you an idea of the +reads. I have to admit though, seems like quite a bit of hassle, and +I'm not sure how good the numbers would be, given that at least some of +the info (KB/transaction) are totals, it'd require a bit of math to get +decent numbers. But at least it's something. + +Terje + + + +From pgsql-performance-owner@postgresql.org Wed Apr 19 01:47:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 8151611F6AF6 + for ; + Wed, 19 Apr 2006 01:47:47 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id MEWmfq4w-+VH + for ; + Wed, 19 Apr 2006 01:47:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz + [203.96.152.183]) + by postgresql.org (Postfix) with ESMTP id 89E8411F69CB + for ; + Wed, 19 Apr 2006 01:47:43 -0300 (ADT) +Received: from smtp-1.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-4.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IXY00MSSDBH61@linda-4.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 19 Apr 2006 16:47:41 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-147.dsl.clear.net.nz [218.101.29.147]) by + smtp-1.paradise.net.nz (Postfix) with ESMTP id C3774FF8BF1; + Wed, 19 Apr 2006 16:47:40 +1200 (NZST) +Date: Wed, 19 Apr 2006 16:47:40 +1200 +From: Mark Kirkwood +Subject: Re: merge>hash>loop +In-reply-to: <20060418231552.GN49405@pervasive.com> +To: "Jim C. Nasby" +Cc: Tom Lane , Markus Schaber , + pgsql-performance@postgresql.org +Message-id: <4445C0EC.2060407@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Thunderbird 1.5 (X11/20060417) +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> + <20060418215238.GK49405@pervasive.com> <19388.1145398946@sss.pgh.pa.us> + <20060418231552.GN49405@pervasive.com> +X-Archive-Number: 200604/415 +X-Sequence-Number: 18499 + +Jim C. Nasby wrote: +> On Tue, Apr 18, 2006 at 06:22:26PM -0400, Tom Lane wrote: +>> "Jim C. Nasby" writes: +>>> Actually, if you run with stats_block_level turned on you have a +>>> first-order approximation of what is and isn't cached. +>> Only if those stats decayed (pretty fast) with time; which they don't. +> +> Good point. :/ I'm guessing there's no easy way to see how many blocks +> for a given relation are in shared memory, either... + +contrib/pg_buffercache will tell you this - what buffers from what +relation are in shared_buffers (if you want to interrogate the os file +buffer cache, that's a different story - tho I've been toying with doing +a utility for Freebsd that would do this). + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Wed Apr 19 02:13:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id C52CF11F662E + for ; + Wed, 19 Apr 2006 02:13:58 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.386 +X-Spam-Level: +X-Spam-Status: No, score=-2.386 required=5 tests=[AWL=0.213, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id LGJCQkMD6i0G + for ; + Wed, 19 Apr 2006 02:13:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id C2F1411F61D2 + for ; + Wed, 19 Apr 2006 02:13:50 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id DE4CF56423; Wed, 19 Apr 2006 00:13:47 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 19 Apr 2006 00:13:47 -0500 +Date: Wed, 19 Apr 2006 00:13:47 -0500 +From: "Jim C. Nasby" +To: Terje Elde +Cc: pgsql-performance@postgresql.org +Subject: Re: Blocks read for index scans +Message-ID: <20060419051346.GQ49405@pervasive.com> +References: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> + <443F3BB3.30404@elde.net> <20060418200641.GG49405@pervasive.com> + <4445A1DF.6000705@elde.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4445A1DF.6000705@elde.net> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060419:terje@elde.net::iXmy7Sd6+SguHEOE:0006DtM +X-Hashcash: + 1:20:060419:pgsql-performance@postgresql.org::YVPAmjxW3QeRHHJ2:00000 + 0000000000000000000000000Krv +X-Archive-Number: 200604/416 +X-Sequence-Number: 18500 + +On Wed, Apr 19, 2006 at 04:35:11AM +0200, Terje Elde wrote: +> Jim C. Nasby wrote: +> >>That said, it's the transactions against disk that typically matter. On +> >>FreeBSD, you can get an impression of this using 'systat -vmstat', and +> >>watch the KB/t column for your drives. +> >> +> > +> >On a related note, you know of any way to determine the breakdown +> >between read activity and write activity on FreeBSD? vmstat, systat, +> >iostat all only return aggregate info. :( +> > +> +> +> Can't think of a right way to do this ATM, but for a lab-type setup to +> get an idea, you could set up a gmirror volume, then choose a balancing +> algorithm to only read from one of the disks. The effect should be that +> writes go to both, while reads only go to one. Activity on the +> write-only disk would give you an idea of the write activity, and +> (read/write disk - write-only disk) would give you an idea of the +> reads. I have to admit though, seems like quite a bit of hassle, and +> I'm not sure how good the numbers would be, given that at least some of +> the info (KB/transaction) are totals, it'd require a bit of math to get +> decent numbers. But at least it's something. + +Yeah... not gonna happen... + +It's completely mind-boggling that FBSD doesn't track writes and reads +seperately. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 19 02:18:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 2F4A211F6279 + for ; + Wed, 19 Apr 2006 02:18:44 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.398 +X-Spam-Level: +X-Spam-Status: No, score=-2.398 required=5 tests=[AWL=0.201, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id TU9CGNTrZyaM + for ; + Wed, 19 Apr 2006 02:18:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id A19A211F6278 + for ; + Wed, 19 Apr 2006 02:18:36 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 72BB256427; Wed, 19 Apr 2006 00:18:36 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 19 Apr 2006 00:18:35 -0500 +Date: Wed, 19 Apr 2006 00:18:35 -0500 +From: "Jim C. Nasby" +To: Mark Kirkwood +Cc: Tom Lane , Markus Schaber , + pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +Message-ID: <20060419051835.GR49405@pervasive.com> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> + <20060418215238.GK49405@pervasive.com> + <19388.1145398946@sss.pgh.pa.us> + <20060418231552.GN49405@pervasive.com> + <4445C0EC.2060407@paradise.net.nz> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4445C0EC.2060407@paradise.net.nz> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060419:markir@paradise.net.nz::MjYy81ky3/XDY4UR:000000000000000 + 0000000000000000000000001tfE +X-Hashcash: + 1:20:060419:tgl@sss.pgh.pa.us::c+a/DJgT3joWhNUf:00000000000000000000 + 0000000000000000000000000kmb +X-Hashcash: + 1:20:060419:schabi@logix-tt.com::yAna6PjD8GxHdwyB:000000000000000000 + 0000000000000000000000004nAT +X-Hashcash: + 1:20:060419:pgsql-performance@postgresql.org::Dbw8GgcWLiwAfs31:00000 + 0000000000000000000000006UeQ +X-Archive-Number: 200604/417 +X-Sequence-Number: 18501 + +On Wed, Apr 19, 2006 at 04:47:40PM +1200, Mark Kirkwood wrote: +> Jim C. Nasby wrote: +> >On Tue, Apr 18, 2006 at 06:22:26PM -0400, Tom Lane wrote: +> >>"Jim C. Nasby" writes: +> >>>Actually, if you run with stats_block_level turned on you have a +> >>>first-order approximation of what is and isn't cached. +> >>Only if those stats decayed (pretty fast) with time; which they don't. +> > +> >Good point. :/ I'm guessing there's no easy way to see how many blocks +> >for a given relation are in shared memory, either... +> +> contrib/pg_buffercache will tell you this - what buffers from what +> relation are in shared_buffers (if you want to interrogate the os file + +So theoretically with that code we could make the cost estimator +functions more intelligent about actual query costs. Now, how you'd +actually see how those estimates improved... + +> buffer cache, that's a different story - tho I've been toying with doing +> a utility for Freebsd that would do this). + +Well, the problem is that I doubt anything that OS-specific would be +accepted into core. What we really need is some method that's +OS-agnostic... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 19 02:25:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4F37411F60A7 + for ; + Wed, 19 Apr 2006 02:25:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.128 +X-Spam-Level: +X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id VpdPdqCGMCvs + for ; + Wed, 19 Apr 2006 02:25:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id A570311F60AF + for ; + Wed, 19 Apr 2006 02:25:34 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3J5PSYS022251; + Wed, 19 Apr 2006 01:25:28 -0400 (EDT) +To: Mark Kirkwood +cc: "Jim C. Nasby" , + Markus Schaber , pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +In-reply-to: <4445C0EC.2060407@paradise.net.nz> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> + <20060418215238.GK49405@pervasive.com> + <19388.1145398946@sss.pgh.pa.us> + <20060418231552.GN49405@pervasive.com> + <4445C0EC.2060407@paradise.net.nz> +Comments: In-reply-to Mark Kirkwood + message dated "Wed, 19 Apr 2006 16:47:40 +1200" +Date: Wed, 19 Apr 2006 01:25:28 -0400 +Message-ID: <22250.1145424328@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/418 +X-Sequence-Number: 18502 + +Mark Kirkwood writes: +> Jim C. Nasby wrote: +>> Good point. :/ I'm guessing there's no easy way to see how many blocks +>> for a given relation are in shared memory, either... + +> contrib/pg_buffercache will tell you this - + +I think the key word in Jim's comment was "easy", ie, cheap. Grovelling +through many thousands of buffers to count the matches to a given +relation doesn't sound appetizing, especially not if it gets done over +again several times during each query-planning cycle. Trying to keep +centralized counts somewhere would be even worse (because of locking/ +contention issues). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 19 02:31:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3A7D811F66FE + for ; + Wed, 19 Apr 2006 02:31:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id z5TgQJdA7uzB + for ; + Wed, 19 Apr 2006 02:31:29 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz + [203.96.152.183]) + by postgresql.org (Postfix) with ESMTP id A9CAD11F66EA + for ; + Wed, 19 Apr 2006 02:31:29 -0300 (ADT) +Received: from smtp-2.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-4.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IXY001U1FCA9C@linda-4.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 19 Apr 2006 17:31:22 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-147.dsl.clear.net.nz [218.101.29.147]) by + smtp-2.paradise.net.nz (Postfix) with ESMTP id E2B8BD2841A; + Wed, 19 Apr 2006 17:31:21 +1200 (NZST) +Date: Wed, 19 Apr 2006 17:31:21 +1200 +From: Mark Kirkwood +Subject: Re: Blocks read for index scans +In-reply-to: <20060419051346.GQ49405@pervasive.com> +To: "Jim C. Nasby" +Cc: Terje Elde , pgsql-performance@postgresql.org +Message-id: <4445CB29.1010605@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Thunderbird 1.5 (X11/20060417) +References: <85979594-1CCA-43C5-A8F2-08685CF41ACE@pervasive.com> + <443F3BB3.30404@elde.net> <20060418200641.GG49405@pervasive.com> + <4445A1DF.6000705@elde.net> <20060419051346.GQ49405@pervasive.com> +X-Archive-Number: 200604/419 +X-Sequence-Number: 18503 + +Jim C. Nasby wrote: + +> +> Yeah... not gonna happen... +> +> It's completely mind-boggling that FBSD doesn't track writes and reads +> seperately. + +'iostat' does not tell you this, but 'gstat' does - its the "geom" +system monitor (a bit annoying that the standard tool is lacking in this +regard...). + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Wed Apr 19 02:33:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4008D11F608D + for ; + Wed, 19 Apr 2006 02:33:56 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ScYHfk92BNdS + for ; + Wed, 19 Apr 2006 02:33:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz + [203.96.152.183]) + by postgresql.org (Postfix) with ESMTP id B5B3611F6003 + for ; + Wed, 19 Apr 2006 02:33:47 -0300 (ADT) +Received: from smtp-3.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-4.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IXY000RRFF3NB@linda-4.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 19 Apr 2006 17:33:03 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-147.dsl.clear.net.nz [218.101.29.147]) by + smtp-3.paradise.net.nz (Postfix) with ESMTP id 16ABA7B0C4B; + Wed, 19 Apr 2006 17:33:03 +1200 (NZST) +Date: Wed, 19 Apr 2006 17:33:02 +1200 +From: Mark Kirkwood +Subject: Re: merge>hash>loop +In-reply-to: <22250.1145424328@sss.pgh.pa.us> +To: Tom Lane +Cc: "Jim C. Nasby" , + Markus Schaber , pgsql-performance@postgresql.org +Message-id: <4445CB8E.5020800@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Thunderbird 1.5 (X11/20060417) +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> + <20060418215238.GK49405@pervasive.com> <19388.1145398946@sss.pgh.pa.us> + <20060418231552.GN49405@pervasive.com> + <4445C0EC.2060407@paradise.net.nz> <22250.1145424328@sss.pgh.pa.us> +X-Archive-Number: 200604/420 +X-Sequence-Number: 18504 + +Tom Lane wrote: +> Mark Kirkwood writes: +>> Jim C. Nasby wrote: +>>> Good point. :/ I'm guessing there's no easy way to see how many blocks +>>> for a given relation are in shared memory, either... +> +>> contrib/pg_buffercache will tell you this - +> +> I think the key word in Jim's comment was "easy", ie, cheap. Grovelling +> through many thousands of buffers to count the matches to a given +> relation doesn't sound appetizing, especially not if it gets done over +> again several times during each query-planning cycle. Trying to keep +> centralized counts somewhere would be even worse (because of locking/ +> contention issues). +> + +Yeah - not sensible for a transaction oriented system - might be ok for +DSS tho. + +Cheers + +mark + +From pgsql-performance-owner@postgresql.org Wed Apr 19 03:01:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CA20711F6085 + for ; + Wed, 19 Apr 2006 03:01:10 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Ru3R+owde6rC + for ; + Wed, 19 Apr 2006 03:01:05 -0300 (ADT) +X-Greylist: delayed 07:52:39.434127 by SQLgrey- +Received: from mx1.vodamail.co.za (mx1.vodamail.co.za [196.11.146.148]) + by postgresql.org (Postfix) with ESMTP id 8A97A11F6700 + for ; + Wed, 19 Apr 2006 03:01:06 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by mx1.vodamail.co.za (Postfix) with ESMTP id 3CF1660B2E + for ; + Wed, 19 Apr 2006 08:01:03 +0200 (SAST) +Received: from mx1.vodamail.co.za ([127.0.0.1]) + by localhost (mx1.vodamail.co.za [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 00962-07 for ; + Wed, 19 Apr 2006 08:01:03 +0200 (SAST) +Received: from josh.flame2.flame.co.za (unknown [10.48.20.8]) + by mx1.vodamail.co.za (Postfix) with ESMTP id 6179667E23 + for ; + Wed, 19 Apr 2006 08:00:59 +0200 (SAST) +Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) + by josh.flame2.flame.co.za (8.12.11/8.12.11) with ESMTP id + k3J60dRi003936 + for ; Wed, 19 Apr 2006 08:00:42 +0200 +Subject: Re: Multicolumn order by +From: Theo Kramer +Reply-To: theo@flame.co.za +To: pgsql-performance@postgresql.org +In-Reply-To: <19819.1145401713@sss.pgh.pa.us> +References: <1145398075.3048.18.camel@josh> <19819.1145401713@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Flame Computing Enterprises cc +Message-Id: <1145426438.3048.25.camel@josh> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 19 Apr 2006 08:00:39 +0200 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: amavisd-new at vodamail.co.za +X-Archive-Number: 200604/421 +X-Sequence-Number: 18505 + +On Wed, 2006-04-19 at 01:08, Tom Lane wrote: +> Theo Kramer writes: +> > select * from mytable where +> > (c1 = 'c1v' and c2 = 'c2v' and c3 >= 'c3v') or +> > (c1 = 'c1v' and c2 > 'c2v') or +> > (c1 > 'c1v') +> > order by c1, c2, c3; +> +> Yeah ... what you really want is the SQL-spec row comparison operator +> +> select ... where (c1,c2,c3) >= ('c1v','c2v','c3v') order by c1,c2,c3; +> +> This does not work properly in any current PG release :-( but it does +> work and is optimized well in CVS HEAD. See eg this thread +> http://archives.postgresql.org/pgsql-hackers/2006-02/msg00209.php + +That is awesome - been fighting with porting my isam based stuff onto +sql for a long time and the row comparison operator is exactly what I +have been looking for. + +I tried this on my test system running 8.1.3 and appears to work fine. +Appreciate it if you could let me know in what cases it does not work +properly. + +-- +Regards +Theo + + +From pgsql-performance-owner@postgresql.org Wed Apr 19 05:20:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 4698611F6C25 + for ; + Wed, 19 Apr 2006 05:20:50 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id cxs1YJ8lQgwC + for ; + Wed, 19 Apr 2006 05:20:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) + by postgresql.org (Postfix) with ESMTP id 9695111F6B6E + for ; + Wed, 19 Apr 2006 05:20:46 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by pjetlic.mobart.hr (Postfix) with ESMTP id DA86617A67 + for ; + Wed, 19 Apr 2006 10:20:45 +0200 (CEST) +Received: from pjetlic.mobart.hr ([127.0.0.1]) + by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 02792-04-5 for ; + Wed, 19 Apr 2006 10:20:45 +0200 (CEST) +Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by pjetlic.mobart.hr (Postfix) with ESMTP id C31A117A3C + for ; + Wed, 19 Apr 2006 10:20:45 +0200 (CEST) +Subject: Re: SELECT FOR UPDATE performance is bad +From: Mario Splivalo +Reply-To: mario.splivalo@mobart.hr +To: Pgsql performance +In-Reply-To: <13609.1145374386@sss.pgh.pa.us> +References: <1145365720.18469.35.camel@localhost.localdomain> + <13037.1145370658@sss.pgh.pa.us> + <1145371662.31555.10.camel@localhost.localdomain> + <13609.1145374386@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Mob-Art +Date: Wed, 19 Apr 2006 10:20:43 +0200 +Message-Id: <1145434844.4458.10.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by OpenSource AV+AS Mail Server +X-Archive-Number: 200604/422 +X-Sequence-Number: 18506 + +On Tue, 2006-04-18 at 11:33 -0400, Tom Lane wrote: +> Mario Splivalo writes: +> >> If there is concurrent locking, +> >> you're also running a big risk of deadlock because two processes might +> >> try to lock the same rows in different orders. +> +> > I think there is no risk of a deadlock, since that particular function +> > is called from the middleware (functions are used as interface to the +> > database), and the lock order is always the same. +> +> No, you don't even know what the order is, let alone that it's always +> the same. + +You got me confused here! :) If I have just only one function that acts +as a interface to the middleware, and all the operations on the database +are done trough that one function, and I carefuly design that function +so that I first grab the lock, and then do the stuff, aint I pretty sure +that I won't be having any deadlocks? + +> +> > Now, I just need to have serialization, I need to have clients 'line up' +> > in order to perform something in the database. Actually, users are +> > sending codes from the newspaper, beer-cans, Cola-cans, and stuff, and +> > database needs to check has the code allready been played. Since the +> > system is designed so that it could run multiple code-games (and then +> > there similair code could exists for coke-game and beer-game), I'm using +> > messages table to see what code-game (i.e. service) that particular code +> > belongs. +> +> I'd suggest using a table that has exactly one row per "code-game", and +> doing a SELECT FOR UPDATE on that row to establish the lock you need. +> This need not have anything to do with the tables/rows you are actually +> intending to update --- although obviously such a convention is pretty +> fragile if you have updates coming from a variety of code. I think it's +> reasonably safe when you're funneling all the operations through a bit +> of middleware. + +I tend to design my applications so I don't have "flying SQL" in my +java/python/c#/php/whereever code, all the database stuff is done trough +the functions which are designed as interfaces. Those functions are also +designed so they don't stop each other. So, since I need the +serialization, I'll do as you suggested, using a lock-table with +exactley one row per "code-game". + +Just one more question here, it has to do with postgres internals, but +still I'd like to know why is postgres doing such huge i/o (in my log +file I see a lot of messages that say "LOG: archived transaction log +file" when performing that big FOR UPDATE. + + Mario +-- +Mario Splivalo +Mob-Art +mario.splivalo@mobart.hr + +"I can do it quick, I can do it cheap, I can do it well. Pick any two." + + + +From pgsql-performance-owner@postgresql.org Wed Apr 19 05:21:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 652A411F65FF + for ; + Wed, 19 Apr 2006 05:20:59 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ck1Xxz+jB8Ow + for ; + Wed, 19 Apr 2006 05:20:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) + by postgresql.org (Postfix) with ESMTP id 4A67411F60B4 + for ; + Wed, 19 Apr 2006 05:20:56 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by pjetlic.mobart.hr (Postfix) with ESMTP id 07A6817A67 + for ; + Wed, 19 Apr 2006 10:20:56 +0200 (CEST) +Received: from pjetlic.mobart.hr ([127.0.0.1]) + by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 02792-04-6 for ; + Wed, 19 Apr 2006 10:20:55 +0200 (CEST) +Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by pjetlic.mobart.hr (Postfix) with ESMTP id E252517A3C + for ; + Wed, 19 Apr 2006 10:20:55 +0200 (CEST) +Subject: Re: SELECT FOR UPDATE performance is bad +From: Mario Splivalo +Reply-To: mario.splivalo@mobart.hr +To: Pgsql performance +In-Reply-To: +References: <1145365720.18469.35.camel@localhost.localdomain> + <13037.1145370658@sss.pgh.pa.us> + <1145371662.31555.10.camel@localhost.localdomain> + <13609.1145374386@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Mob-Art +Date: Wed, 19 Apr 2006 10:20:54 +0200 +Message-Id: <1145434854.4458.12.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by OpenSource AV+AS Mail Server +X-Archive-Number: 200604/423 +X-Sequence-Number: 18507 + +On Tue, 2006-04-18 at 19:00 +0200, PFC wrote: +> Suppose you have a table codes : +> ( +> game_id INT, +> code TEXT, +> used BOOL NOT NULL DEFAULT 'f', +> prize ... +> ... +> PRIMARY KEY (game_id, code) +> ) +> +> Just UPDATE codes SET used='t' WHERE used='f' AND game_id=... AND code=... +> +> Then check the rowcount : if one row was updated, the code was not used +> yet. If no row was updated, the code either did not exist, or was already +> used. +> +> Another option : create a table used_codes like this : +> +> ( +> game_id INT, +> code TEXT, +> ... +> PRIMARY KEY (game_id, code) +> ) +> +> Then, when trying to use a code, INSERT into this table. If you get a +> constraint violation on the uniqueness of the primary key, your code has +> already been used. +> +> Both solutions have a big advantage : they don't require messing with +> locks and are extremely simple. The one with UPDATE is IMHO better, +> because it doesn't abort the current transaction (although you could use a +> savepoint in the INSERT case to intercept the error). +> +> + +This works perfectly, but sometimes the game has no codes, and I still +need to know exactley who came first, who was second, and so on... So a +locking table as Tom suggested is, I guess, a perfect solution for my +situation... + + Mario +-- +Mario Splivalo +Mob-Art +mario.splivalo@mobart.hr + +"I can do it quick, I can do it cheap, I can do it well. Pick any two." + + + +From pgsql-performance-owner@postgresql.org Wed Apr 19 06:26:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CAA5911F66F9 + for ; + Wed, 19 Apr 2006 06:26:08 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id vDB+4F6bAX0d + for ; + Wed, 19 Apr 2006 06:26:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from beth.coza.net.za (beth.coza.net.za [206.223.136.193]) + by postgresql.org (Postfix) with ESMTP id CA29A11F68D9 + for ; + Wed, 19 Apr 2006 06:26:03 -0300 (ADT) +Received: from theo-laptop.int.coza.net.za ([206.223.136.211]) + by beth.coza.net.za (8.11.6/8.11.2) with ESMTP id k3J9Q0110105 + for ; Wed, 19 Apr 2006 11:26:00 +0200 +Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) + by theo-laptop.int.coza.net.za (8.12.11/8.12.11) with ESMTP id + k3J9Q1im003351 + for ; Wed, 19 Apr 2006 11:26:01 +0200 +Subject: Re: Multicolumn order by +From: Theo Kramer +Reply-To: theo@flame.co.za +To: pgsql-performance@postgresql.org +In-Reply-To: <1145426438.3048.25.camel@josh> +References: <1145398075.3048.18.camel@josh> <19819.1145401713@sss.pgh.pa.us> + <1145426438.3048.25.camel@josh> +Content-Type: text/plain +Organization: Flame Computing Enterprises cc +Message-Id: <1145438760.2847.1.camel@theo-laptop.int.coza.net.za> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 19 Apr 2006 11:26:00 +0200 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/424 +X-Sequence-Number: 18508 + +On Wed, 2006-04-19 at 08:00, Theo Kramer wrote: + +> I tried this on my test system running 8.1.3 and appears to work fine. +> Appreciate it if you could let me know in what cases it does not work +> properly. + +Please ignore - 'Explain is your friend' - got to look at the tips :) +-- +Regards +Theo + + +From pgsql-performance-owner@postgresql.org Wed Apr 19 09:08:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2FC3D11F66B8 + for ; + Wed, 19 Apr 2006 09:08:30 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.112 +X-Spam-Level: +X-Spam-Status: No, score=0.112 required=5 tests=[AWL=0.112] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id d4Eh8fvTX6nN + for ; + Wed, 19 Apr 2006 09:08:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 0617911F6694 + for ; + Wed, 19 Apr 2006 09:08:25 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T8ebe.t.pppool.de + [89.55.142.190]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 6749E656CB; + Wed, 19 Apr 2006 14:09:24 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 77720181C1F45; + Wed, 19 Apr 2006 14:08:41 +0200 (CEST) +Message-ID: <44462849.3070209@logix-tt.com> +Date: Wed, 19 Apr 2006 14:08:41 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Magnus Hagander +Cc: Pgsql performance +Subject: Re: Inserts optimization? +References: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/425 +X-Sequence-Number: 18509 + +Hi, Magnus, + +Magnus Hagander wrote: + +> Bacula already serializes access to the database (they have to support +> mysql/myisam), so this shouldn't help. + +Ouch, that hurts. + +To support mysql, they break performance for _every other_ database system? + + +Now, I understand how the mysql people manage to spread the legend of +mysql being fast. They convince software developers to thwart all others. + + +Seriously: How can we convince developers to either fix MySQL or abandon +and replace it with a database, instead of crippling client software? + +> Actually, it might well hurt by introducing extra delays. + +Well, if you read the documentation, you will see that it will only wait +if there are at least commit_siblings other transactions active. So when +Bacula serializes access, there will be no delays, as there is only a +single transaction alive. + + +HTH +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Wed Apr 19 09:11:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 3375C11F6CEA + for ; + Wed, 19 Apr 2006 09:11:42 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.277 +X-Spam-Level: +X-Spam-Status: No, score=-2.277 required=5 tests=[AWL=0.188, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id GoPSwj7pZK3z + for ; + Wed, 19 Apr 2006 09:11:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by postgresql.org (Postfix) with ESMTP id 4491611F6691 + for ; + Wed, 19 Apr 2006 09:11:08 -0300 (ADT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 75FD18F288; Wed, 19 Apr 2006 14:11:07 +0200 (CEST) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: Inserts optimization? +Date: Wed, 19 Apr 2006 14:11:06 +0200 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCEA352C3@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Inserts optimization? +Thread-Index: AcZjqfo00EqASTJ+R+OLcdwG2c1sdgAABQow +From: "Magnus Hagander" +To: "Markus Schaber" +Cc: "Pgsql performance" +X-Archive-Number: 200604/426 +X-Sequence-Number: 18510 + +> > Bacula already serializes access to the database (they have=20 +> to support=20 +> > mysql/myisam), so this shouldn't help. +>=20 +> Ouch, that hurts. +>=20 +> To support mysql, they break performance for _every other_=20 +> database system? + +Actually, it probably helps on SQLite as well. And considering they only +support postgresql, mysql and sqlite, there is some merit to it from +their perspective. + +You can find a thread about it in the bacula archives from a month or +two back. + +> +> Now, I understand how the mysql people manage to spread the=20 +> legend of mysql being fast. They convince software developers=20 +> to thwart all others. +> + +Yes, same as the fact that most (at least FOSS) web project-du-jour are +"dumbed down" to the mysql featureset. (And not just mysql, but +mysql-lowest-common-factors, which means myisam etc) + + +> > Actually, it might well hurt by introducing extra delays. +>=20 +> Well, if you read the documentation, you will see that it=20 +> will only wait if there are at least commit_siblings other=20 +> transactions active. So when Bacula serializes access, there=20 +> will be no delays, as there is only a single transaction alive. + +Hm. Right. Well, it still won't help :-) + +//Magnus + +From pgsql-performance-owner@postgresql.org Wed Apr 19 09:50:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4D9EA11F6F93 + for ; + Wed, 19 Apr 2006 09:50:14 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.112 +X-Spam-Level: +X-Spam-Status: No, score=0.112 required=5 tests=[AWL=0.112] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 3dycNDIO85Mh + for ; + Wed, 19 Apr 2006 09:50:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id D551A11F6CB0 + for ; + Wed, 19 Apr 2006 09:50:09 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T8ebe.t.pppool.de + [89.55.142.190]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id E0DC1656CB; + Wed, 19 Apr 2006 14:51:09 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id D349C181C1F45; + Wed, 19 Apr 2006 14:50:26 +0200 (CEST) +Message-ID: <44463212.2010708@logix-tt.com> +Date: Wed, 19 Apr 2006 14:50:26 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Magnus Hagander +Cc: Pgsql performance +Subject: Re: Inserts optimization? +References: <6BCB9D8A16AC4241919521715F4D8BCEA352C3@algol.sollentuna.se> +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCEA352C3@algol.sollentuna.se> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/427 +X-Sequence-Number: 18511 + +Hi, Magnus, + +Magnus Hagander wrote: + +>>To support mysql, they break performance for _every other_ +>>database system? +> Actually, it probably helps on SQLite as well. + +AFAICS from the FAQ http://www.sqlite.org/faq.html#q7 and #q8, SQLite +does serialize itsself. + +> And considering they only +> support postgresql, mysql and sqlite, there is some merit to it from +> their perspective. + +Okay, I understand, but I hesitate to endorse it. + +IMHO, they should write their application in a "normal" way, and then +have the serialization etc. encapsulated in the database driver +interface (possibly a wrapper class or so). + +>> +>>Now, I understand how the mysql people manage to spread the +>>legend of mysql being fast. They convince software developers +>>to thwart all others. +>> +> Yes, same as the fact that most (at least FOSS) web project-du-jour are +> "dumbed down" to the mysql featureset. (And not just mysql, but +> mysql-lowest-common-factors, which means myisam etc) + +Well, most of those projects don't need a database, they need a bunch of +tables and a lock. + +Heck, they even use client-side SELECT-loops in PHP instead of a JOIN +because "I always confuse left and right". + + +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Wed Apr 19 12:15:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 68E5711F7DA4 + for ; + Wed, 19 Apr 2006 12:14:59 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.127 +X-Spam-Level: +X-Spam-Status: No, score=0.127 required=5 tests=[AWL=0.127] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id CFjqQPtCkf5u + for ; + Wed, 19 Apr 2006 12:14:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 76F0711F7D76 + for ; + Wed, 19 Apr 2006 12:14:55 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3JFEqHU026313; + Wed, 19 Apr 2006 11:14:52 -0400 (EDT) +To: "Magnus Hagander" +cc: "Markus Schaber" , + "Pgsql performance" +Subject: Re: Inserts optimization? +In-reply-to: <6BCB9D8A16AC4241919521715F4D8BCEA352C3@algol.sollentuna.se> +References: <6BCB9D8A16AC4241919521715F4D8BCEA352C3@algol.sollentuna.se> +Comments: In-reply-to "Magnus Hagander" + message dated "Wed, 19 Apr 2006 14:11:06 +0200" +Date: Wed, 19 Apr 2006 11:14:52 -0400 +Message-ID: <26312.1145459692@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/428 +X-Sequence-Number: 18512 + +"Magnus Hagander" writes: +>>> Actually, [commit_delay] might well hurt by introducing extra delays. +>> +>> Well, if you read the documentation, you will see that it +>> will only wait if there are at least commit_siblings other +>> transactions active. So when Bacula serializes access, there +>> will be no delays, as there is only a single transaction alive. + +> Hm. Right. Well, it still won't help :-) + +It could actually hurt, because nonzero time is required to go look +whether there are any other active transactions. I'm not sure whether +this overhead is enough to be measurable when there's only one backend +running, but it might be. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 19 12:22:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 15D7D11F6609 + for ; + Wed, 19 Apr 2006 12:22:18 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.119 +X-Spam-Level: +X-Spam-Status: No, score=0.119 required=5 tests=[AWL=0.118, + UNPARSEABLE_RELAY=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id R5X2Ct8hsWn2 + for ; + Wed, 19 Apr 2006 12:22:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id BD8C611F6296 + for ; + Wed, 19 Apr 2006 12:22:14 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 19 Apr 2006 15:22:11 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 19 Apr 2006 10:22:10 -0500 +Subject: Re: Inserts optimization? +From: Scott Marlowe +To: Markus Schaber +Cc: Magnus Hagander , + Pgsql performance +In-Reply-To: <44462849.3070209@logix-tt.com> +References: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> + <44462849.3070209@logix-tt.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1145460130.23538.119.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 19 Apr 2006 10:22:10 -0500 +X-Archive-Number: 200604/429 +X-Sequence-Number: 18513 + +On Wed, 2006-04-19 at 07:08, Markus Schaber wrote: +> Hi, Magnus, +> +> Magnus Hagander wrote: +> +> > Bacula already serializes access to the database (they have to support +> > mysql/myisam), so this shouldn't help. +> +> Ouch, that hurts. +> +> To support mysql, they break performance for _every other_ database system? + +Note that should be "to support MySQL with MyISAM tables". + +If they had written it for MySQL with innodb tables they would likely be +able to use the same basic methods for performance tuning MySQL as or +Oracle or PostgreSQL. + +It's the refusal of people to stop using MyISAM table types that's the +real issue. + +Of course, given the shakey ground MySQL is now on with Oracle owning +innodb... + +From pgsql-performance-owner@postgresql.org Wed Apr 19 12:31:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0A9B711F7DC0 + for ; + Wed, 19 Apr 2006 12:31:45 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.126 +X-Spam-Level: +X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id k39hn0tLAqBl + for ; + Wed, 19 Apr 2006 12:31:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 0823A11F732C + for ; + Wed, 19 Apr 2006 12:31:22 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3JFVJtk026520; + Wed, 19 Apr 2006 11:31:19 -0400 (EDT) +To: Scott Marlowe +cc: Markus Schaber , + Magnus Hagander , + Pgsql performance +Subject: Re: Inserts optimization? +In-reply-to: <1145460130.23538.119.camel@state.g2switchworks.com> +References: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> + <44462849.3070209@logix-tt.com> + <1145460130.23538.119.camel@state.g2switchworks.com> +Comments: In-reply-to Scott Marlowe + message dated "Wed, 19 Apr 2006 10:22:10 -0500" +Date: Wed, 19 Apr 2006 11:31:19 -0400 +Message-ID: <26519.1145460679@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/430 +X-Sequence-Number: 18514 + +Scott Marlowe writes: +> It's the refusal of people to stop using MyISAM table types that's the +> real issue. + +Isn't MyISAM still the default over there? It's hardly likely that the +average MySQL user would use anything but the default table type ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 19 12:42:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 723C011F66FE + for ; + Wed, 19 Apr 2006 12:42:30 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.1 +X-Spam-Level: +X-Spam-Status: No, score=0.1 required=5 tests=[AWL=0.100] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Bu0qPIcpv6Za + for ; + Wed, 19 Apr 2006 12:42:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 3A2DB11F66C4 + for ; + Wed, 19 Apr 2006 12:42:22 -0300 (ADT) +Received: (qmail 4755 invoked from network); 19 Apr 2006 17:42:21 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 19 Apr 2006 17:42:21 +0200 +To: "Pgsql performance" +Subject: Re: Inserts optimization? +References: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> + <44462849.3070209@logix-tt.com> + <1145460130.23538.119.camel@state.g2switchworks.com> + <26519.1145460679@sss.pgh.pa.us> +Message-ID: +Date: Wed, 19 Apr 2006 17:42:17 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <26519.1145460679@sss.pgh.pa.us> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Archive-Number: 200604/431 +X-Sequence-Number: 18515 + + +> Isn't MyISAM still the default over there? + + Yes, it's the default. + Personnally I compile MySQL without InnoDB... and for any new development +I use postgres. + +> It's hardly likely that the average MySQL user would use anything but +> the default table type ... + + Double yes ; also many hosts provide MySQL 4.0 or even 3.x, both of which +have no subquery support and are really brain-dead ; and most OSS PHP apps +have to be compatible... argh. + +From pgsql-performance-owner@postgresql.org Wed Apr 19 13:52:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 75E9311F6C7A + for ; + Wed, 19 Apr 2006 13:52:51 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.119 +X-Spam-Level: +X-Spam-Status: No, score=0.119 required=5 tests=[AWL=0.118, + UNPARSEABLE_RELAY=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id plUr+b1Wu+ao + for ; + Wed, 19 Apr 2006 13:52:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id E697811F6C77 + for ; + Wed, 19 Apr 2006 13:52:47 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 19 Apr 2006 16:52:46 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 19 Apr 2006 11:52:46 -0500 +Subject: Re: Inserts optimization? +From: Scott Marlowe +To: Tom Lane +Cc: Markus Schaber , + Magnus Hagander , + Pgsql performance +In-Reply-To: <26519.1145460679@sss.pgh.pa.us> +References: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> + <44462849.3070209@logix-tt.com> + <1145460130.23538.119.camel@state.g2switchworks.com> + <26519.1145460679@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1145465566.23538.122.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 19 Apr 2006 11:52:46 -0500 +X-Archive-Number: 200604/432 +X-Sequence-Number: 18516 + +On Wed, 2006-04-19 at 10:31, Tom Lane wrote: +> Scott Marlowe writes: +> > It's the refusal of people to stop using MyISAM table types that's the +> > real issue. +> +> Isn't MyISAM still the default over there? It's hardly likely that the +> average MySQL user would use anything but the default table type ... + +Sure. But bacula supplies its own setup scripts. and it's not that +hard to make them a requirement for the appication. Most versions of +MySQL that come with fedora core and other distros nowadays support +innodb. + + + +From pgsql-performance-owner@postgresql.org Wed Apr 19 16:28:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 0E2BB11F6795 + for ; + Wed, 19 Apr 2006 16:28:34 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.55 +X-Spam-Level: +X-Spam-Status: No, score=-2.55 required=5 tests=[AWL=0.050, BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id SVPu5s1FZ-Sg + for ; + Wed, 19 Apr 2006 16:28:29 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.225]) + by postgresql.org (Postfix) with ESMTP id 6C21211F6772 + for ; + Wed, 19 Apr 2006 16:28:27 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so996597wra + for ; + Wed, 19 Apr 2006 12:28:26 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=hwTT9XxEAfN8iOm5ehhgtcSLWAaAJG7ZIquAI0encexoedd3aVHCBZvnqzmdiUMP9gVnDnJJcQRPR53B0P1372fAdGl73s99du3y9xbNWPDdJH6QdloShvsdnf/n8QUFK3KiVMIylL62PSG0f+3DlPxBFOfFv8J7nrv8CEP4pYs= +Received: by 10.54.130.10 with SMTP id c10mr1221819wrd; + Wed, 19 Apr 2006 12:28:26 -0700 (PDT) +Received: by 10.54.157.9 with HTTP; Wed, 19 Apr 2006 12:28:26 -0700 (PDT) +Message-ID: <53b425b00604191228s356112d4n4a45dfc0846a679a@mail.gmail.com> +Date: Wed, 19 Apr 2006 12:28:26 -0700 +From: "patrick keshishian" +To: "Tom Lane" +Subject: Re: Planner doesn't chose Index - (slow select) +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20957.1145413184@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <53b425b00604181802v2cc259e1r59f9043b2cea3324@mail.gmail.com> + <20957.1145413184@sss.pgh.pa.us> +X-Archive-Number: 200604/433 +X-Sequence-Number: 18517 + +Tom, + +You are absolutely correct about not having run ANALYZE +on the particular table. + +In my attempt to create a simple "test case" I created that +table (pk_c2) from the original and had not run ANALYZE +on it, even though, ANALYZE had been run prior to building +that table. + +The problem on the test table and the simple select count(*) +is no longer there (after ANALYZE). + +The original issue, however, is still there. I'm stumped as +how to formulate my question without having to write a +lengthy essay. + +As to upgrading from 7.4, I hear you, but I'm trying to support +a deployed product. + +Thanks again for your input, +--patrick + + + + +On 4/18/06, Tom Lane wrote: +> "patrick keshishian" writes: +> > I've been struggling with some performance issues with certain +> > SQL queries. I was prepping a long-ish overview of my problem +> > to submit, but I think I'll start out with a simple case of the +> > problem first, hopefully answers I receive will help me solve +> > my initial issue. +> +> Have you ANALYZEd this table lately? +> +> > db=3D# select count(*) from pk_c2 b0 where b0.offer_id=3D7141; +> > count +> > ------- +> > 1 +> > (1 row) +> +> The planner is evidently estimating that there are 12109 such rows, +> not 1, which is the reason for its reluctance to use an indexscan. +> Generally the only reason for it to be off that far on such a simple +> statistical issue is if you haven't updated the stats in a long time. +> (If you've got a really skewed data distribution for offer_id, you +> might need to raise the statistics target for it.) +> +> > The table has indexes for both 'offer_id' and '(pending=3Dtrue)': +> +> > Indexes: +> > "pk_boidx" btree (offer_id) +> > "pk_bpidx" btree (((pending =3D true))) +> +> The expression index on (pending =3D true) won't do you any good, +> unless you spell your query in a weird way like +> ... WHERE (pending =3D true) =3D true +> I'd suggest a plain index on "pending" instead. +> +> > db=3D# select version(); +> > PostgreSQL 7.4.12 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.= +6 +> +> You might want to think about an update, too. 7.4 is pretty long in the +> tooth. +> +> regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 19 22:04:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 489F411F6AB7 + for ; + Wed, 19 Apr 2006 22:04:57 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.389 +X-Spam-Level: +X-Spam-Status: No, score=-2.389 required=5 tests=[AWL=0.075, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id LQZAr1WksJ1c + for ; + Wed, 19 Apr 2006 22:04:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id 2C49611F65A6 + for ; + Wed, 19 Apr 2006 22:04:48 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id A9F0D2550F; + Thu, 20 Apr 2006 09:04:46 +0800 (WST) +Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 5266A25505; + Thu, 20 Apr 2006 09:04:45 +0800 (WST) +Message-ID: <4446DED2.3040307@calorieking.com> +Date: Thu, 20 Apr 2006 09:07:30 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5 (Windows/20051201) +MIME-Version: 1.0 +To: Tom Lane +Cc: Scott Marlowe , + Markus Schaber , Magnus Hagander , + Pgsql performance +Subject: Re: Inserts optimization? +References: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> + <44462849.3070209@logix-tt.com> + <1145460130.23538.119.camel@state.g2switchworks.com> + <26519.1145460679@sss.pgh.pa.us> +In-Reply-To: <26519.1145460679@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chris.kings-lynne@calorieking.com +X-Archive-Number: 200604/434 +X-Sequence-Number: 18518 + +> Scott Marlowe writes: +>> It's the refusal of people to stop using MyISAM table types that's the +>> real issue. +> +> Isn't MyISAM still the default over there? It's hardly likely that the +> average MySQL user would use anything but the default table type ... + +Since MySQL 5, InnoDB tables are default I recall. + + +From pgsql-performance-owner@postgresql.org Wed Apr 19 22:33:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 057C011F71D5 + for ; + Wed, 19 Apr 2006 22:33:04 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.103 +X-Spam-Level: +X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id AE8Bsc+RQQAg + for ; + Wed, 19 Apr 2006 22:32:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz + [203.96.152.184]) + by postgresql.org (Postfix) with ESMTP id 6612611F7042 + for ; + Wed, 19 Apr 2006 22:33:00 -0300 (ADT) +Received: from smtp-2.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-5.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IXZ00HZXYYZK5@linda-5.paradise.net.nz> for + pgsql-performance@postgresql.org; Thu, 20 Apr 2006 13:33:00 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-147.dsl.clear.net.nz [218.101.29.147]) by + smtp-2.paradise.net.nz (Postfix) with ESMTP id 075CC145265; + Thu, 20 Apr 2006 13:32:58 +1200 (NZST) +Date: Thu, 20 Apr 2006 13:32:53 +1200 +From: Mark Kirkwood +Subject: Re: Inserts optimization? +In-reply-to: <4446DED2.3040307@calorieking.com> +To: Christopher Kings-Lynne +Cc: Tom Lane , Scott Marlowe , + Markus Schaber , Magnus Hagander , + Pgsql performance +Message-id: <4446E4C5.90400@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Thunderbird 1.5 (X11/20060417) +References: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> + <44462849.3070209@logix-tt.com> + <1145460130.23538.119.camel@state.g2switchworks.com> + <26519.1145460679@sss.pgh.pa.us> <4446DED2.3040307@calorieking.com> +X-Archive-Number: 200604/435 +X-Sequence-Number: 18519 + +Christopher Kings-Lynne wrote: +>> Scott Marlowe writes: +>>> It's the refusal of people to stop using MyISAM table types that's the +>>> real issue. +>> +>> Isn't MyISAM still the default over there? It's hardly likely that the +>> average MySQL user would use anything but the default table type ... +> +> Since MySQL 5, InnoDB tables are default I recall. + +Might be for the binaries from www.mysql.com - but if you build from +source, it still seems to be MYISAM (checked with 5.0.18 and 5.1.7 here). + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Tue Apr 25 02:27:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 9353211F66E4 + for ; + Wed, 19 Apr 2006 23:16:02 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.954 +X-Spam-Level: +X-Spam-Status: No, score=-0.954 required=5 tests=[BAYES_00=-2.599, + DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_WHOIS=1.447, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 0GJo4aVeCEMS + for ; + Wed, 19 Apr 2006 23:15:59 -0300 (ADT) +X-Greylist: delayed 00:07:03.017389 by SQLgrey- +Received: from mx1.ustc.edu.cn (ns.ustc.edu.cn [202.38.64.1]) + by postgresql.org (Postfix) with ESMTP id 83FA711F620D + for ; + Wed, 19 Apr 2006 23:15:55 -0300 (ADT) +Received: from localhost.localdomain ([210.45.75.70]) + by mx1.ustc.edu.cn (8.11.6/8.11.6) with ESMTP id k3K25Mw30971; + Thu, 20 Apr 2006 10:05:22 +0800 +Received: from wfg by localhost.localdomain with local (Exim 4.50) + id 1FWObF-0001a3-Pd; Thu, 20 Apr 2006 10:08:53 +0800 +Date: Thu, 20 Apr 2006 10:08:53 +0800 +From: Wu Fengguang +To: pgsql-performance@postgresql.org +Subject: Introducing a new linux readahead framework +Message-ID: <20060420020853.GA4979@mail.ustc.edu.cn> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.11+cvs20060126 +X-Archive-Number: 200604/536 +X-Sequence-Number: 18620 + +Greetings, + +I'd like to introduce a new readahead framework of the linux kernel: +http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1021.html + +HOW IT WORKS + +In adaptive readahead, the context based method may be of particular +interest to postgresql users. It works by peeking into the file cache +and check if there are any history pages present or accessed. In this +way it can detect almost all forms of sequential / semi-sequential read +patterns, e.g. + - parallel / interleaved sequential scans on one file + - sequential reads across file open/close + - mixed sequential / random accesses + - sparse / skimming sequential read + +It also have methods to detect some less common cases: + - reading backward + - seeking all over reading N pages + +WAYS TO BENEFIT FROM IT + +As we know, postgresql relies on the kernel to do proper readahead. +The adaptive readahead might help performance in the following cases: + - concurrent sequential scans + - sequential scan on a fragmented table + (some DBs suffer from this problem, not sure for pgsql) + - index scan with clustered matches + - index scan on majority rows (in case the planner goes wrong) + +TUNABLE PARAMETERS + +There are two parameters which are described in this email: +http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1024.html + +Here are the more oriented guidelines for postgresql users: + +- /proc/sys/vm/readahead_ratio +Since most DB servers are bounty of memory, the danger of readahead +thrashing is near to zero. In this case, you can set readahead_ratio to +100(or even 200:), which helps the readahead window to scale up rapidly. + +- /proc/sys/vm/readahead_hit_rate +Sparse sequential reads are read patterns like {0, 2, 4, 5, 8, 11, ...}. +In this case we might prefer to do readahead to get good I/O performance +with the overhead of some useless pages. But if you prefer not to do so, +set readahead_hit_rate to 1 will disable this feature. + +- /sys/block/sd/queue/read_ahead_kb +Set it to a large value(e.g. 4096) as you used to do. +RAID users might want to use a bigger number. + +TRYING IT OUT + +The latest patch for stable kernels can be downloaded here: +http://www.vanheusden.com/ara/ + +Before compiling, make sure that the following options are enabled: +Processor type and features -> Adaptive file readahead +Processor type and features -> Readahead debug and accounting + + +The patch is open to fine tuning advices. +Comments and benchmarking results are highly appreciated. + +Thanks, +Wu + +From pgsql-performance-owner@postgresql.org Thu Apr 20 02:37:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BB83111F7081 + for ; + Thu, 20 Apr 2006 02:37:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.023 +X-Spam-Level: * +X-Spam-Status: No, score=1.023 required=5 tests=[AWL=-0.310, + HTML_MESSAGE=0.001, RCVD_IN_BL_SPAMCOP_NET=1.332] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id zVPsCLnOiHCX + for ; + Thu, 20 Apr 2006 02:37:32 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.181]) + by postgresql.org (Postfix) with ESMTP id AA91A11F6D59 + for ; + Thu, 20 Apr 2006 02:37:31 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so77714pye + for ; + Wed, 19 Apr 2006 22:37:31 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; + b=PUckTOk+bPplsUuGjEaFcXgraBC/yIMPcvxfHaD8qNfYWyvU8g+2xzAsDkyh+Xb3T77//ndsw5xhd6YlIMYP2PgexzPgv0BeNmkewqSFEESRA/JWRHLFZdd637JrQ/CZnqtQd6b2ALOucUHFT8YMIgLdxuC5wD9em4b/cwEkKMY= +Received: by 10.35.36.13 with SMTP id o13mr318401pyj; + Wed, 19 Apr 2006 22:37:31 -0700 (PDT) +Received: by 10.35.31.15 with HTTP; Wed, 19 Apr 2006 22:37:31 -0700 (PDT) +Message-ID: <9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com> +Date: Thu, 20 Apr 2006 11:07:31 +0530 +From: "soni de" +To: "Merlin Moncure" , pgsql-performance@postgresql.org +Subject: Re: Takes too long to fetch the data from database +In-Reply-To: +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_10547_5146525.1145511451596" +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> + +X-Archive-Number: 200604/436 +X-Sequence-Number: 18520 + +------=_Part_10547_5146525.1145511451596 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Please provide me some help regarding how could I use cursor in following +cases? : + + + +I want to fetch 50 records at a time starting from largest stime. + + + +Total no. of records in the "wan" table: 82019 + + + +pdb=3D# \d wan + + Table "wan" + + Column | Type | Modifiers + +-------------+--------------------------+----------- + + stime | bigint | not null + + kname | character varying(64) | + + eid | smallint | + + rtpe | smallint | + + taddr | character varying(16) | + + ntime | bigint | + + Primary key: wan_pkey + + + +stime is the primary key. + + + +pdb=3D# + + + +SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET 81900; + + + +pdb=3D# explain analyze SELECT * FROM wan ORDER BY stime LIMIT 50 + + OFFSET 81900; + +NOTICE: QUERY PLAN: + + + +Limit (cost=3D17995.15..17995.15 rows=3D50 width=3D95) (actual time=3D +9842.92..9843.20 + +rows=3D50 loops=3D1) + + -> Sort (cost=3D17995.15..17995.15 rows=3D82016 width=3D95) (actual tim= +e=3D +9364.56.. + +9793.00 rows=3D81951 loops=3D1) + + -> Seq Scan on wan (cost=3D0.00..3281.16 rows=3D82016 width=3D95)= + (actu + +al time=3D0.11..3906.29 rows=3D82019 loops=3D1) + +Total runtime: 10010.76 msec + + + +EXPLAIN + +pdb=3D# + + + + + +SELECT * FROM wan where kname=3D'pluto' ORDER BY stime LIMIT 50 OFFSET 8190= +0; + + + +pdb=3D# explain analyze SELECT * from wan where kname=3D'pluto' order by st= +ime +limit 50 offset 81900; + +NOTICE: QUERY PLAN: + + + +Limit (cost=3D3494.13..3494.13 rows=3D1 width=3D95) (actual +time=3D9512.85..9512.85rows=3D0 loops=3D1) + + -> Sort (cost=3D3494.13..3494.13 rows=3D206 width=3D95) (actual time=3D +9330.74..9494.90 rows=3D27485 loops=3D1) + + -> Seq Scan on wan (cost=3D0.00..3486.20 rows=3D206 width=3D95) (= +actual +time=3D0.28..4951.76 rows=3D27485 loops=3D1) + +Total runtime: 9636.96 msec + + + +EXPLAIN + + + +SELECT * FROM wan where kname=3D'pluto' and rtpe=3D20 ORDER BY stime LIMIT = +50 +OFFSET 81900; + + + +pdb=3D# explain analyze SELECT * from wan where kname=3D'pluto' and rtpe = +=3D 20 +order by stime limit 50 offset 81900; + +NOTICE: QUERY PLAN: + + + +Limit (cost=3D3691.25..3691.25 rows=3D1 width=3D95) (actual +time=3D7361.50..7361.50rows=3D0 loops=3D1) + + -> Sort (cost=3D3691.25..3691.25 rows=3D1 width=3D95) (actual time=3D +7361.50..7361.50 rows=3D0 loops=3D1) + + -> Seq Scan on wan (cost=3D0.00..3691.24 rows=3D1 width=3D95) (ac= +tual +time=3D7361.30..7361.30 rows=3D0 loops=3D1) + +Total runtime: 7361.71 msec + + + +EXPLAIN + +pdb=3D# + + + +all the above queries taking around 7~10 sec. to fetch the last 50 records. +I want to reduce this time because table is growing and table can contain +more than 1 GB data then for 1 GB data above queries will take too much +time. + + + +I am not getting how to use cursor to fetch records starting from last +records in the above case offset can be any number (less than total no. of +records). + + + +I have use following cursor, but it is taking same time as query takes. + + + +BEGIN; + +DECLARE crs cursor FOR SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET +81900; + +FETCH ALL in crs; + +CLOSE crs; + +COMMIT; + + + + +On 4/11/06, Merlin Moncure wrote: +> +> > pdb=3D# explain analyze SELECT sdate, stime, rbts from lan WHERE ( +> > +> > ( bname =3D 'pluto' ) AND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( ( sda= +te +> > +> > >=3D '2004-07-21' ) AND ( sdate <=3D '2004-07-21' ) ) ) ORDER BY sda= +te, +> stime +> > ; +> +> this query would benefit from an index on +> pluto, cno, pno, sdate +> +> create index Ian_idx on Ian(bname, cno, pno, sdate); +> +> +> > pdb=3D# explain analyze SELECT ALL sdate, stime, rbts from lan WHERE ( = + ( +> > bname =3D 'neptune' ) AND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( ( sdat= +e >=3D +> > '2004-07-21' ) AND ( sdate <=3D '2004-07-21' ) ) ) ORDER BY sdate, st= +ime +> ; +> +> ditto above. Generally, the closer the fields in the where clause are +> matched by the index, the it will speed up your query. +> +> Merlin +> + +------=_Part_10547_5146525.1145511451596 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
 
+
+

Please provide me some help regarding how could I use cursor= + in following cases? : +

+

 

+

I want to fetch 50 records at a time starting from largest s= +time. +

+

 

+

Total no. of records in the "wan" table:82019

+

 

+

pdb=3D# \d wan

+

    &n= +bsp;            = +; Table "wan" +

+

  Column    |      = +     Type = +;            &n= +bsp;  | Modifiers

+

-------------+--------------------------+-----------<= +/font>

+ +

 stime +         | bigint        &nbs= +p;            &= +nbsp;      |  not null

+

 kname +       | character varying(64)      |

+

 eid +            |= + smallint     &n= +bsp;                  &n= +bsp;|

+

 rtpe +           | small= +int      &n= +bsp;            = +;      |

+

 taddr +         | character varying= +(16)      |

+

 ntime +        | bigint         &nbs= +p;            &= +nbsp;      |

+

 Primary key: = +wan_pkey +

+

 

+

stime is the primary key.

+

 

+

pdb=3D#

+

 

+

SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET 81900; +

+

 

+

pdb=3D# explain analyze SELECT * FROM wan ORDER BY stime LIM= +IT 50 +

+

 OFFSET 81900;= + +

+

NOTICE:  QUERY= + PLAN: +

+

 

+

Limit  (cost= +=3D17995.15..17995.15 + rows=3D50 width=3D95) (actual time=3D9842.92..9843.20

+

rows=3D50 loops=3D1)

+

  ->Sort  (cost=3D1= +7995.15..17995.15 rows=3D82016 width=3D95) (actual time=3D9364.56..<= +/font>

+

9793.00 rows=3D81951 loops=3D1)

+

    &n= +bsp;   ->Seq Scan on wan  (cost=3D0.00..3281.16 rows=3D82016 width=3D95) (actu

+

al time=3D0.11..3906.29 rows=3D82019 loops=3D1)

+

Total runtime: 10010.76 msec

+

 

+

EXPLAIN

+

pdb=3D#

+

 

+

 

+

SELECT * FROM wan where kname=3D'pluto' ORDER BY stime LIMIT= + 50 OFFSET 81900; +

+

 

+

pdb=3D# explain analyze SELECT * from wan where kname=3D'plu= +to' order by stime limit 50 offset 81900; +

+

NOTICE:  QUERY= + PLAN: +

+

 

+

Limit  (cost= +=3D3494.13..3494.13 + rows=3D1 width=3D95) (actual time=3D9512.85..9512.85 rows=3D0 loops=3D1)

+

  ->Sort  (cost=3D3= +494.13..3494.13 rows=3D206 width=3D95) (actual time=3D9330.74..9494.90 rows= +=3D27485 loops=3D1)

+

    &n= +bsp;   ->Seq Scan on wan  (cost=3D0.00..3486.20 rows=3D206 width=3D95) (actual time=3D0.28..4951.76= + rows=3D27485 loops=3D1)

+

Total runtime: 9636.96 msec

+

 

+

EXPLAIN

+

 

+

SELECT * FROM wan where kname=3D'pluto' and rtpe=3D20 ORDER = +BY stime LIMIT 50 OFFSET 81900; +

+

 

+

pdb=3D# explain analyze SELECT * from wan where kname=3D'plu= +to' and rtpe =3D 20 order by stime limit 50 offset 81900; +

+

NOTICE:  QUERY= + PLAN: +

+

 

+

Limit  (cost= +=3D3691.25..3691.25 + rows=3D1 width=3D95) (actual time=3D7361.50..7361.50 rows=3D0 loops=3D1)

+

  ->Sort  (cost=3D3= +691.25..3691.25 rows=3D1 width=3D95) (actual time=3D7361.50..7361.50 rows= +=3D0 loops=3D1)

+

    &n= +bsp;   ->Seq Scan on wan  (cost=3D0.00..3691.24 rows=3D1 width=3D95) (actual time=3D7361.30..7361.3= +0 rows=3D0 loops=3D1)

+

Total runtime: 7361.71 msec

+

 

+

EXPLAIN

+

pdb=3D#

+

 

+

all the above queries taking around 7~10 sec. to fetch the l= +ast 50 records. I want to reduce this time because table is growing and tab= +le can contain more than 1 GB data then for 1 GB data above queries will ta= +ke too much time. +

+

 

+

I am not getting how to use cursor to fetch records starting= + from last records in the above case offset can be any number (less than to= +tal no. of records).=20 +

+

 

+

I have use following cursor, but it is taking same time as q= +uery takes. +

+

 

+

BEGIN;

+

DECLARE crs cursor FOR SELECT * FROM wan ORDER BY stime LIMI= +T 50 OFFSET 81900; +

+

FETCH ALL in crs;

+

CLOSE crs;

+

COMMIT;

+
 
+


 
+
On 4/11/06, = +Merlin Moncure <mmoncure@gmail= +.com> wrote: +
> pdb=3D# explain analyze SEL= +ECT sdate, stime, rbts from lan WHERE (
>
>  ( bname = +=3D 'pluto' ) AND ( cno =3D 17 ) AND ( pno =3D 1 ) AND ( ( sdate +
>
>  >=3D '2004-07-21' ) AND ( sdate <=3D '200= +4-07-21' ) )  )  ORDER BY sdate, stime
> ;
this query would benefit from an index on
pluto, cno, pno, sdate
create index Ian_idx on Ian(bname, cno, pno, sdate); +


> pdb=3D# explain analyze SELECT ALL sdate, stime, rbts from= + lan WHERE (  (
> bname =3D 'neptune' ) AND ( cno =3D 17 ) = +AND ( pno =3D 1 ) AND ( ( sdate >=3D
> '2004-07-21' ) AND ( sdate = +<=3D '2004-07-21' ) )  )  ORDER BY sdate, stime ; +

ditto above.  Generally, the closer the fields in the whe= +re clause are
matched by the index, the it will speed up your query.
= +
Merlin

+ +------=_Part_10547_5146525.1145511451596-- + +From pgsql-performance-owner@postgresql.org Thu Apr 20 03:27:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id CC13E11F6B03 + for ; + Thu, 20 Apr 2006 03:27:36 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.08 +X-Spam-Level: +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 7uVowIpFixn5 + for ; + Thu, 20 Apr 2006 03:27:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id 40E7111F6AB2 + for ; + Thu, 20 Apr 2006 03:27:31 -0300 (ADT) +Received: (qmail 25526 invoked by uid 500); 20 Apr 2006 06:30:14 -0000 +Date: Thu, 20 Apr 2006 01:30:14 -0500 +From: Bruno Wolff III +To: soni de +Cc: Merlin Moncure , pgsql-performance@postgresql.org +Subject: Re: Takes too long to fetch the data from database +Message-ID: <20060420063014.GA25438@wolff.to> +Mail-Followup-To: Bruno Wolff III , + soni de , Merlin Moncure , + pgsql-performance@postgresql.org +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> + + <9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com> +User-Agent: Mutt/1.4.2.1i +X-Archive-Number: 200604/437 +X-Sequence-Number: 18521 + +On Thu, Apr 20, 2006 at 11:07:31 +0530, + soni de wrote: +> Please provide me some help regarding how could I use cursor in following +> cases? : +> +> I want to fetch 50 records at a time starting from largest stime. +> +> SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET 81900; + +Something like the following may be faster: +SELECT * FROM wan ORDER BY stime DESC LIMIT 50; + +From pgsql-performance-owner@postgresql.org Thu Apr 20 04:24:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 064A511F8D0E + for ; + Thu, 20 Apr 2006 04:24:22 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id slNIO4qOKtNH + for ; + Thu, 20 Apr 2006 04:24:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailRelay.dbnet.co.il (mail.dbnet.co.il [212.143.51.17]) + by postgresql.org (Postfix) with ESMTP id 6D9C211F8D0B + for ; + Thu, 20 Apr 2006 04:23:59 -0300 (ADT) +Received: from mailRelay.dbnet.co.il (localhost [127.0.0.1]) + by localhost.dbnet.co.il (Postfix) with ESMTP id 1B1DE3C148 + for ; + Thu, 20 Apr 2006 10:47:47 +0300 (IDT) +Received: from exchange-1.dbnet.co.il (mail [172.16.2.1]) + by mailRelay.dbnet.co.il (Postfix) with ESMTP id EB9923C12F + for ; + Thu, 20 Apr 2006 10:47:46 +0300 (IDT) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----_=_NextPart_001_01C66453.E1CC301A" +Subject: Perfrmance Problems (7.4.6) +Date: Thu, 20 Apr 2006 10:23:57 +0200 +Message-ID: <0BA77301DFF4B24C9C5DAA74138BF95001E231@exchange-1.dbnet.co.il> +X-MS-Has-Attach: yes +X-MS-TNEF-Correlator: +Thread-Topic: Perfrmance Problems (7.4.6) +Thread-index: AcZb2lYq0tS+L4kfQ+WFQsMun2Nm+AAm/TgAAfdNqwA= +From: "Doron Baranes" +To: +X-Archive-Number: 200604/438 +X-Sequence-Number: 18522 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C66453.E1CC301A +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + +Hi, + +I am running on postgres 7.4.6. +I did a vacuum analyze on the database but there was no change. +I Attached here a file with details about the tables, the queries and +the Explain analyze plans. +Hope this can be helpful to analyze my problem + +10x +Doron + +------_=_NextPart_001_01C66453.E1CC301A +Content-Type: text/plain; + name="explain_analyze.txt" +Content-Transfer-Encoding: base64 +Content-Description: explain_analyze.txt +Content-Disposition: attachment; + filename="explain_analyze.txt" + +VEFCTEVTDQoqKioqKioqKg0KDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgVGFibGUgImxvZy5tc2dfaW5mbyINCiAgIENvbHVtbiAgIHwgICAgICAgICAgICBUeXBlICAg +ICAgICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICBNb2RpZmllcnMNCi0tLS0tLS0tLS0t +LSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQogbXNnaWQgICAgICB8IGJpZ2ludCAg +ICAgICAgICAgICAgICAgICAgICB8IG5vdCBudWxsIGRlZmF1bHQgbmV4dHZhbCgnbG9nLm1zZ19p +bmZvX21zZ2lkX3NlcSc6OnRleHQpDQogc2VuZGVyICAgICB8IGNoYXJhY3RlciB2YXJ5aW5nKDI1 +NSkgICAgICB8DQogc3ViamVjdCAgICB8IHRleHQgICAgICAgICAgICAgICAgICAgICAgICB8DQog +c2l6ZSAgICAgICB8IGJpZ2ludCAgICAgICAgICAgICAgICAgICAgICB8DQogZW50cnlfdGltZSB8 +IHRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSB8IGRlZmF1bHQgbm93KCkNCiBzb3VyY2VfaXAg +IHwgY2lkciAgICAgICAgICAgICAgICAgICAgICAgIHwNCiBvcmlnaW4gICAgIHwgc21hbGxpbnQg +ICAgICAgICAgICAgICAgICAgIHwNCkluZGV4ZXM6DQogICAgIm1zZ19pbmZvX3BrZXkiIHByaW1h +cnkga2V5LCBidHJlZSAobXNnaWQpDQogICAgImRkaW5keCIgYnRyZWUgKGRhdGUoZW50cnlfdGlt +ZSkpDQogICAgIm1zZ19pbmZvX2VudHJ5X3RpbWUiIGJ0cmVlIChlbnRyeV90aW1lKQ0KICAgICJt +c2dfaW5mb19zZW5kZXJfaW5kZXgiIGJ0cmVlIChzZW5kZXIpDQogICAgIm1zZ19pbmZvX3NpemUi +IGJ0cmVlIChzaXplKQ0KICAgICJtc2dfaW5mb19zdWJqZWN0IiBidHJlZSAoc3ViamVjdCkNCg0K +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUYWJsZSAibG9nLm1zZ19m +YXRlIg0KICAgQ29sdW1uICAgIHwgICAgICAgICAgVHlwZSAgICAgICAgICB8ICAgICAgICAgICAg +ICAgICAgICAgICAgICAgTW9kaWZpZXJzDQotLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tDQogbXNnaWQgICAgICAgfCBiaWdpbnQgICAgICAgICAgICAgICAgIHwg +bm90IG51bGwgZGVmYXVsdCBuZXh0dmFsKCdsb2cubXNnX2ZhdGVfbXNnaWRfc2VxJzo6dGV4dCkN +CiBncnBfZmF0ZV9pZCB8IGJpZ2ludCAgICAgICAgICAgICAgICAgfCBub3QgbnVsbCBkZWZhdWx0 +IG5leHR2YWwoJ2xvZy5tc2dfZmF0ZV9ncnBfZmF0ZV9pZF9zZXEnOjp0ZXh0KQ0KIG1vZGlkICAg +ICAgIHwgaW50ZWdlciAgICAgICAgICAgICAgICB8DQogZGVzY3JpcHRpb24gfCBjaGFyYWN0ZXIg +dmFyeWluZygyNTUpIHwNCiBydWxlX29yaWdpbiB8IGJpZ2ludCAgICAgICAgICAgICAgICAgfA0K +IGFjdGlvbiAgICAgIHwgc21hbGxpbnQgICAgICAgICAgICAgICB8DQogcnVsZWlkICAgICAgfCBp +bnRlZ2VyICAgICAgICAgICAgICAgIHwNCkluZGV4ZXM6DQogICAgIm1zZ19mYXRlX3BrZXkiIHBy +aW1hcnkga2V5LCBidHJlZSAoZ3JwX2ZhdGVfaWQpDQogICAgIm1zZ19mYXRlX2FjdGlvbiIgYnRy +ZWUgKCJhY3Rpb24iKQ0KICAgICJtc2dfZmF0ZV9kZXNjcmlwdGlvbiIgYnRyZWUgKGRlc2NyaXB0 +aW9uKQ0KICAgICJtc2dfZmF0ZV9tb2RpZCIgYnRyZWUgKG1vZGlkKQ0KICAgICJtc2dfZmF0ZV9t +c2dpZCIgYnRyZWUgKG1zZ2lkKQ0KRm9yZWlnbi1rZXkgY29uc3RyYWludHM6DQogICAgIm1zZ2lk +X2ZrZXkiIEZPUkVJR04gS0VZIChtc2dpZCkgUkVGRVJFTkNFUyBsb2cubXNnX2luZm8obXNnaWQp +IE9OIFVQREFURSBDQVNDQURFIE9OIERFTEVURSBDQVNDQURFDQoNCiAgICAgICAgICAgICAgVGFi +bGUgImxvZy5tc2dfZmF0ZV9yZWNpcGllbnRzIg0KICAgQ29sdW1uICAgIHwgICAgICAgICAgICBU +eXBlICAgICAgICAgICAgIHwgICBNb2RpZmllcnMNCi0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tDQogZ3JwX2ZhdGVfaWQgfCBiaWdpbnQg +ICAgICAgICAgICAgICAgICAgICAgfA0KIHJlY2lwaWVudCAgIHwgY2hhcmFjdGVyIHZhcnlpbmco +MjU1KSAgICAgIHwNCiB1cGRhdGVfYXQgICB8IHRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSB8 +IGRlZmF1bHQgbm93KCkNCiBsYXN0X2FjdGlvbiB8IGludGVnZXIgICAgICAgICAgICAgICAgICAg +ICB8DQogem9uZV9pZCAgICAgfCBpbnRlZ2VyICAgICAgICAgICAgICAgICAgICAgfA0KIGRpcmVj +dGlvbiAgIHwgc21hbGxpbnQgICAgICAgICAgICAgICAgICAgIHwgZGVmYXVsdCA3DQpJbmRleGVz +Og0KICAgICJtc2dfZmF0ZV9yZWNpcGllbnRzX2dycF9mYXRlX2lkIiBidHJlZSAoZ3JwX2ZhdGVf +aWQpDQogICAgIm1zZ19mYXRlX3JlY2lwaWVudHNfbGFzdF9hY3Rpb25faWR4IiBidHJlZSAobGFz +dF9hY3Rpb24pDQogICAgIm1zZ19mYXRlX3JlY2lwaWVudHNfcmVjaXBpZW50X2lkeCIgYnRyZWUg +KHJlY2lwaWVudCkNCiAgICAibXNnX2ZhdGVfcmVjaXBpZW50c191cGRhdGVfYXQiIGJ0cmVlICh1 +cGRhdGVfYXQpDQogICAgIm1zZ19mYXRlX3JlY2lwaWVudHNfem9uZV9pZCIgYnRyZWUgKHpvbmVf +aWQpDQpUcmlnZ2VyczoNCiAgICBzdGF0c19mb3JfZG9tYWluIEFGVEVSIElOU0VSVCBPTiBsb2cu +bXNnX2ZhdGVfcmVjaXBpZW50cyBGT1IgRUFDSCBST1cgRVhFQ1VURSBQUk9DRURVUkUgbG9nLmNv +bGxlY3Rfc3RhdHNfZm9yX2RvbWFpbigpDQogICAgc3RhdHNfZm9yX29iamVjdCBBRlRFUiBJTlNF +UlQgT04gbG9nLm1zZ19mYXRlX3JlY2lwaWVudHMgRk9SIEVBQ0ggUk9XIEVYRUNVVEUgUFJPQ0VE +VVJFIGxvZy5jb2xsZWN0X3N0YXRzX2Zvcl9vYmplY3QoKQ0KICAgIHVwZGF0ZV90aW1lc3RhbXBf +bGFzdF9hY3Rpb24gQkVGT1JFIFVQREFURSBPTiBsb2cubXNnX2ZhdGVfcmVjaXBpZW50cyBGT1Ig +RUFDSCBST1cgRVhFQ1VURSBQUk9DRURVUkUgbG9nLnJlY2lwaWVudHNfc3RhdHVzX2NoYW5nZWRf +dXBkYXRlKCkNCg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUYWJsZSAi +cGluZWFwcC56b25lcyINCiAgQ29sdW1uICAgfCAgICAgICAgICBUeXBlICAgICAgICAgIHwgICAg +ICAgICAgICAgICAgICAgICAgICAgIE1vZGlmaWVycw0KLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0NCiB6b25lX2lkICAgfCBpbnRlZ2VyICAgICAgICAgICAgICAgIHwg +bm90IG51bGwgZGVmYXVsdCBuZXh0dmFsKCdwaW5lYXBwLnpvbmVzX3pvbmVfaWRfc2VxJzo6dGV4 +dCkNCiB6b25lX25hbWUgfCBjaGFyYWN0ZXIgdmFyeWluZygyMCkgIHwNCiB6b25lX2Rlc2MgfCBj +aGFyYWN0ZXIgdmFyeWluZygyNTUpIHwNCiB6b25lX3R5cGUgfCBzbWFsbGludCAgICAgICAgICAg +ICAgIHwNCkluZGV4ZXM6DQogICAgInpvbmVzX3BrZXkiIHByaW1hcnkga2V5LCBidHJlZSAoem9u +ZV9pZCkNCiAgICAiem9uZXNfem9uZV9pZCIgYnRyZWUgKHpvbmVfaWQpDQoNClFVRVJJRVMNCioq +KioqKioqKioqDQoNCg0KMSkNCmV4cGxhaW4gYW5hbHl6ZSBTRUxFQ1QgZGF0ZV90cnVuYygnaG91 +cic6OnRleHQsIGkuZW50cnlfdGltZSkgQVMgZGF0ZXRpbWUsDQpDT1VOVChmci5ncnBfZmF0ZV9p +ZCkgLA0KU1VNKGkuc2l6ZSkNCkZST00gbG9nLm1zZ19pbmZvIGFzIGksbG9nLm1zZ19mYXRlIGFz +IGYsIGxvZy5tc2dfZmF0ZV9yZWNpcGllbnRzIGFzIGZyDQpXSEVSRSBpLm9yaWdpbiA9IDENCkFO +RCBpLm1zZ2lkPWYubXNnaWQNCkFORCBpLmVudHJ5X3RpbWUgPiAnMjAwNi0wMS0yNScNCkFORCBm +LmdycF9mYXRlX2lkPWZyLmdycF9mYXRlX2lkDQpHUk9VUCBCWSBkYXRldGltZQ0Kb3JkZXIgYnkg +ZGF0ZXRpbWU7DQoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBRVUVSWSBQTEFOICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tDQogR3JvdXBBZ2dyZWdhdGUgIChjb3N0PTEzNTU5ODQuODQuLjE0MTcyNDMu +MjIgcm93cz0xNDg1MjMzIHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9MjU3NDMzLjc4NC4uMjY5MTAy +LjA4OCByb3dzPTYyMyBsb29wcz0xKQ0KICAgLT4gIFNvcnQgIChjb3N0PTEzNTU5ODQuODQuLjEz +Njg1MTQuNjIgcm93cz01MDExOTEzIHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9MjU3MzQ5LjAzOC4u +MjYxMDEyLjU5NSByb3dzPTUxNjAxODcgbG9vcHM9MSkNCiAgICAgICAgIFNvcnQgS2V5OiBkYXRl +X3RydW5jKCdob3VyJzo6dGV4dCwgaS5lbnRyeV90aW1lKQ0KICAgICAgICAgLT4gIEhhc2ggSm9p +biAgKGNvc3Q9MjU2NzI5LjUyLi42Njc0MDAuODYgcm93cz01MDExOTEzIHdpZHRoPTI0KSAoYWN0 +dWFsIHRpbWU9NjMxMzMuMTQwLi4yMDg5NjYuMzQyIHJvd3M9NTE2MDE4NyBsb29wcz0xKQ0KICAg +ICAgICAgICAgICAgSGFzaCBDb25kOiAoIm91dGVyIi5ncnBfZmF0ZV9pZCA9ICJpbm5lciIuZ3Jw +X2ZhdGVfaWQpDQogICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gbXNnX2ZhdGVfcmVjaXBp +ZW50cyBmciAgKGNvc3Q9MC4wMC4uMTc4MjMwLjcxIHJvd3M9OTAyMjc3MSB3aWR0aD04KSAoYWN0 +dWFsIHRpbWU9MzAuMzQ3Li41OTgyNi45Nzggcm93cz05MDIyNzcxIGxvb3BzPTEpDQogICAgICAg +ICAgICAgICAtPiAgSGFzaCAgKGNvc3Q9MjQzNzg3LjE3Li4yNDM3ODcuMTcgcm93cz0xNTQ4MTM5 +IHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9NjI3ODAuOTY0Li42Mjc4MC45NjQgcm93cz0wIGxvb3Bz +PTEpDQogICAgICAgICAgICAgICAgICAgICAtPiAgSGFzaCBKb2luICAoY29zdD05NTM3NS4yOC4u +MjQzNzg3LjE3IHJvd3M9MTU0ODEzOSB3aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTEzNzkxLjk1Mi4u +NjEwMjIuOTEzIHJvd3M9MTYwMTEyMSBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAg +ICAgSGFzaCBDb25kOiAoIm91dGVyIi5tc2dpZCA9ICJpbm5lciIubXNnaWQpDQogICAgICAgICAg +ICAgICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gbXNnX2ZhdGUgZiAgKGNvc3Q9MC4wMC4u +NTUyMDMuNjAgcm93cz0yNzg3MDYwIHdpZHRoPTE2KSAoYWN0dWFsIHRpbWU9MTUuNjkwLi4xNzQ3 +MC41MzEgcm93cz0yNzg3MDYwIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAt +PiAgSGFzaCAgKGNvc3Q9ODI5NTkuMjAuLjgyOTU5LjIwIHJvd3M9MTQ4NTIzMyB3aWR0aD0yNCkg +KGFjdHVhbCB0aW1lPTEzMTY2LjI3My4uMTMxNjYuMjczIHJvd3M9MCBsb29wcz0xKQ0KICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIG1zZ19pbmZvIGkgIChj +b3N0PTAuMDAuLjgyOTU5LjIwIHJvd3M9MTQ4NTIzMyB3aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTAu +MTMzLi4xMTQ1MC44NDYgcm93cz0xNDg3ODg2IGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICBGaWx0ZXI6ICgob3JpZ2luID0gMSkgQU5EIChlbnRyeV90aW1l +ID4gJzIwMDYtMDEtMjUgMDA6MDA6MDAnOjp0aW1lc3RhbXAgd2l0aG91dCB0aW1lIHpvbmUpKQ0K +IFRvdGFsIHJ1bnRpbWU6IDI2OTQ4Ni45NTIgbXMNCigxNCByb3dzKQ0KDQoNCg0KMikNCmV4cGxh +aW4gYW5hbHl6ZSBTRUxFQ1QgZGF0ZV90cnVuYygnaG91cic6OnRleHQsIGkuZW50cnlfdGltZSkg +QVMgZGF0ZXRpbWUsIA0KQ09VTlQoZnIuZ3JwX2ZhdGVfaWQpICwgDQpTVU0oaS5zaXplKSANCkZS +T00gbG9nLm1zZ19pbmZvIGFzIGksbG9nLm1zZ19mYXRlIGFzIGYsIGxvZy5tc2dfZmF0ZV9yZWNp +cGllbnRzIGFzIGZyIA0KV0hFUkUgaS5tc2dpZD1mLm1zZ2lkIA0KQU5EIGYuZ3JwX2ZhdGVfaWQ9 +ZnIuZ3JwX2ZhdGVfaWQNCkFORCBpLmVudHJ5X3RpbWUgPiAnMjAwNi0wMS0yNScNCkFORCBmLm1v +ZGlkID0gLTIgDQpBTkQgaS5vcmlnaW49MQ0KR1JPVVAgQlkgZGF0ZXRpbWUgb3JkZXIgYnkgZGF0 +ZXRpbWUNCg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICBRVUVSWSBQTEFOICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICANCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tDQogR3JvdXBBZ2dyZWdhdGUgIChjb3N0PTEzNTc3OTguMjAuLjE0MTg3NzIuNTgg +cm93cz0xNDg1MjMzIHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9MjQ0NDI0LjA2NC4uMjU1NjY2Ljg5 +OSByb3dzPTYyMyBsb29wcz0xKQ0KICAgLT4gIFNvcnQgIChjb3N0PTEzNTc3OTguMjAuLjEzNzAy +NTYuOTggcm93cz00OTgzNTEzIHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9MjQ0NDAwLjg1OC4uMjQ3 +OTUxLjg1NiByb3dzPTUxMzUwMzEgbG9vcHM9MSkNCiAgICAgICAgIFNvcnQgS2V5OiBkYXRlX3Ry +dW5jKCdob3VyJzo6dGV4dCwgaS5lbnRyeV90aW1lKQ0KICAgICAgICAgLT4gIEhhc2ggSm9pbiAg +KGNvc3Q9MjYzMTQ0LjYyLi42NzM0MDguOTggcm93cz00OTgzNTEzIHdpZHRoPTI0KSAoYWN0dWFs +IHRpbWU9NjE0ODYuNjA1Li4xOTQyMjkuOTg3IHJvd3M9NTEzNTAzMSBsb29wcz0xKQ0KICAgICAg +ICAgICAgICAgSGFzaCBDb25kOiAoIm91dGVyIi5ncnBfZmF0ZV9pZCA9ICJpbm5lciIuZ3JwX2Zh +dGVfaWQpDQogICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gbXNnX2ZhdGVfcmVjaXBpZW50 +cyBmciAgKGNvc3Q9MC4wMC4uMTc4MjMwLjcxIHJvd3M9OTAyMjc3MSB3aWR0aD04KSAoYWN0dWFs +IHRpbWU9MjkuMTA2Li40NzQxMS4zMTMgcm93cz05MDIyNzcxIGxvb3BzPTEpDQogICAgICAgICAg +ICAgICAtPiAgSGFzaCAgKGNvc3Q9MjUwMjc2LjIwLi4yNTAyNzYuMjAgcm93cz0xNTM5MzY3IHdp +ZHRoPTI0KSAoYWN0dWFsIHRpbWU9NjEyMTMuODQ3Li42MTIxMy44NDcgcm93cz0wIGxvb3BzPTEp +DQogICAgICAgICAgICAgICAgICAgICAtPiAgSGFzaCBKb2luICAoY29zdD05NTM3NS4yOC4uMjUw +Mjc2LjIwIHJvd3M9MTUzOTM2NyB3aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTEzNzU2LjQzMC4uNTk0 +ODYuOTk3IHJvd3M9MTU4NjQ3MiBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAg +SGFzaCBDb25kOiAoIm91dGVyIi5tc2dpZCA9ICJpbm5lciIubXNnaWQpDQogICAgICAgICAgICAg +ICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gbXNnX2ZhdGUgZiAgKGNvc3Q9MC4wMC4uNjIx +NzEuMjUgcm93cz0yNzcxMjY3IHdpZHRoPTE2KSAoYWN0dWFsIHRpbWU9MjMuNTUwLi4xMjg1My40 +Mjkgcm93cz0yNzY4MjEwIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +ICBGaWx0ZXI6IChtb2RpZCA9IC0yKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEhh +c2ggIChjb3N0PTgyOTU5LjIwLi44Mjk1OS4yMCByb3dzPTE0ODUyMzMgd2lkdGg9MjQpIChhY3R1 +YWwgdGltZT0xMzQwNS4yOTAuLjEzNDA1LjI5MCByb3dzPTAgbG9vcHM9MSkNCiAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBtc2dfaW5mbyBpICAoY29zdD0w +LjAwLi44Mjk1OS4yMCByb3dzPTE0ODUyMzMgd2lkdGg9MjQpIChhY3R1YWwgdGltZT00MS4wNzYu +LjExNzc3LjY5NCByb3dzPTE0ODc4ODYgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgIEZpbHRlcjogKChlbnRyeV90aW1lID4gJzIwMDYtMDEtMjUgMDA6MDA6 +MDAnOjp0aW1lc3RhbXAgd2l0aG91dCB0aW1lIHpvbmUpIEFORCAob3JpZ2luID0gMSkpDQogVG90 +YWwgcnVudGltZTogMjU1OTgxLjA5NiBtcw0KKDE1IHJvd3MpDQoNCg0KDQozKQ0KZXhwbGFpbiBh +bmFseXplIFNFTEVDVCBDT1VOVCgqKSANCkZST00gIGxvZy5tc2dfaW5mbyANCkxFRlQgSk9JTiBs +b2cubXNnX2ZhdGUgVVNJTkcgKG1zZ2lkKQ0KTEVGVCBKT0lOIGxvZy5tc2dfZmF0ZV9yZWNpcGll +bnRzIFVTSU5HIChncnBfZmF0ZV9pZCkgDQpMRUZUIEpPSU4gcGluZWFwcC56b25lcyBVU0lORyAo +em9uZV9pZCkgIA0KV0hFUkUgKDcgJiBkaXJlY3Rpb24pICE9IDA7DQoNCiAgICAgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +IFFVRVJZIFBMQU4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgDQot +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQogQWdncmVnYXRlICAoY29z +dD05Mzk0NzUuMDkuLjkzOTQ3NS4wOSByb3dzPTEgd2lkdGg9MCkgKGFjdHVhbCB0aW1lPTMyNzk3 +Mi4wNTMuLjMyNzk3Mi4wNTMgcm93cz0xIGxvb3BzPTEpDQogICAtPiAgSGFzaCBMZWZ0IEpvaW4g +IChjb3N0PTI2NzExOC40Mi4uOTE3MDMwLjk1IHJvd3M9ODk3NzY1OCB3aWR0aD0wKSAoYWN0dWFs +IHRpbWU9NzMwMjUuMTA5Li4zMjE5MjUuMTI4IHJvd3M9OTAyMjc1MiBsb29wcz0xKQ0KICAgICAg +ICAgSGFzaCBDb25kOiAoIm91dGVyIi56b25lX2lkID0gImlubmVyIi56b25lX2lkKQ0KICAgICAg +ICAgLT4gIEhhc2ggSm9pbiAgKGNvc3Q9MjY3MTE3LjQxLi44MjcyNTMuMzUgcm93cz04OTc3NjU4 +IHdpZHRoPTQpIChhY3R1YWwgdGltZT03Mjk3NS4yOTcuLjMwODAwNi4yOTEgcm93cz05MDIyNzUy +IGxvb3BzPTEpDQogICAgICAgICAgICAgICBIYXNoIENvbmQ6ICgib3V0ZXIiLmdycF9mYXRlX2lk +ID0gImlubmVyIi5ncnBfZmF0ZV9pZCkNCiAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBt +c2dfZmF0ZV9yZWNpcGllbnRzICAoY29zdD0wLjAwLi4yNDU5MDEuNDkgcm93cz04OTc3NjU4IHdp +ZHRoPTEyKSAoYWN0dWFsIHRpbWU9MjkuOTk5Li42MjE1Ni44NDcgcm93cz05MDIyNzcxIGxvb3Bz +PTEpDQogICAgICAgICAgICAgICAgICAgICBGaWx0ZXI6ICgoNyAmIChkaXJlY3Rpb24pOjppbnRl +Z2VyKSA8PiAwKQ0KICAgICAgICAgICAgICAgLT4gIEhhc2ggIChjb3N0PTI0OTI2Mi43Ni4uMjQ5 +MjYyLjc2IHJvd3M9Mjc4NzA2MCB3aWR0aD04KSAoYWN0dWFsIHRpbWU9NzI5MjguNTQ0Li43Mjky +OC41NDQgcm93cz0wIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAtPiAgSGFzaCBKb2lu +ICAoY29zdD04NjcxOS42Ni4uMjQ5MjYyLjc2IHJvd3M9Mjc4NzA2MCB3aWR0aD04KSAoYWN0dWFs +IHRpbWU9MTIzODAuMTc1Li42OTYzNi4zNjAgcm93cz0yNzg3MDYwIGxvb3BzPTEpDQogICAgICAg +ICAgICAgICAgICAgICAgICAgICBIYXNoIENvbmQ6ICgib3V0ZXIiLm1zZ2lkID0gImlubmVyIi5t +c2dpZCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBtc2dfZmF0 +ZSAgKGNvc3Q9MC4wMC4uNTUyMDMuNjAgcm93cz0yNzg3MDYwIHdpZHRoPTE2KSAoYWN0dWFsIHRp +bWU9MjQuMjAyLi4yMTUyMi44OTYgcm93cz0yNzg3MDYwIGxvb3BzPTEpDQogICAgICAgICAgICAg +ICAgICAgICAgICAgICAtPiAgSGFzaCAgKGNvc3Q9Njk1OTAuMTMuLjY5NTkwLjEzIHJvd3M9MjY3 +MzgxMyB3aWR0aD04KSAoYWN0dWFsIHRpbWU9MTIzNTUuMDk4Li4xMjM1NS4wOTggcm93cz0wIGxv +b3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24g +bXNnX2luZm8gIChjb3N0PTAuMDAuLjY5NTkwLjEzIHJvd3M9MjY3MzgxMyB3aWR0aD04KSAoYWN0 +dWFsIHRpbWU9MzEuNjg3Li45Njg1LjU5MSByb3dzPTI2NzM4MTMgbG9vcHM9MSkNCiAgICAgICAg +IC0+ICBIYXNoICAoY29zdD0xLjAxLi4xLjAxIHJvd3M9MSB3aWR0aD00KSAoYWN0dWFsIHRpbWU9 +MjYuNTA4Li4yNi41MDggcm93cz0wIGxvb3BzPTEpDQogICAgICAgICAgICAgICAtPiAgU2VxIFNj +YW4gb24gem9uZXMgIChjb3N0PTAuMDAuLjEuMDEgcm93cz0xIHdpZHRoPTQpIChhY3R1YWwgdGlt +ZT0yNi40NzguLjI2LjQ4MCByb3dzPTEgbG9vcHM9MSkNCiBUb3RhbCBydW50aW1lOiAzMjc5ODQu +Nzg0IG1zDQooMTYgcm93cykNCg== + +------_=_NextPart_001_01C66453.E1CC301A-- + +From pgsql-performance-owner@postgresql.org Thu Apr 20 07:48:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id A953511F6C80 + for ; + Thu, 20 Apr 2006 07:48:58 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.464 +X-Spam-Level: +X-Spam-Status: No, score=-2.464 required=5 tests=[BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 6Kr1v53KhfBr + for ; + Thu, 20 Apr 2006 07:48:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.rentalia.net (mail.rentalia.com [213.192.209.8]) + by postgresql.org (Postfix) with ESMTP id F111111F66C1 + for ; + Thu, 20 Apr 2006 07:48:47 -0300 (ADT) +Received: (qmail 13942 invoked by uid 514); 20 Apr 2006 13:49:58 +0200 +Received: from 62.37.217.76 by rigodon (envelope-from , + uid 512) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1284. spamassassin: 3.0.2. perlscan: 1.25-st-qms. + Clear:RC:0(62.37.217.76):SA:0(-2.1/5.0):. + Processed in 1.660478 secs); 20 Apr 2006 11:49:58 -0000 +X-Antivirus-MYDOMAIN-Mail-From: ruben@rentalia.com via rigodon +X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:0(62.37.217.76):SA:0(-2.1/5.0):. + Processed in 1.660478 secs Process 13929) +Received: from 62-37-217-76.mad1.adsl.uni2.es (HELO ?192.168.2.28?) + (ruben@rentalia.com@62.37.217.76) + by mail.rentalia.net with SMTP; 20 Apr 2006 13:49:56 +0200 +Message-ID: <44476706.90303@rentalia.com> +Date: Thu, 20 Apr 2006 12:48:38 +0200 +From: Ruben Rubio Rey +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051011) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Doron Baranes , + pgsql-performance@postgresql.org +Subject: Re: Perfrmance Problems (7.4.6) +References: <0BA77301DFF4B24C9C5DAA74138BF95001E231@exchange-1.dbnet.co.il> +In-Reply-To: <0BA77301DFF4B24C9C5DAA74138BF95001E231@exchange-1.dbnet.co.il> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/439 +X-Sequence-Number: 18523 + +I think that the problem is the GROUP BY (datetime) that is +date_trunc('hour'::text, i.entry_time) +You should create an indexe with this expression (if its possible). + +http://www.postgresql.org/docs/7.4/interactive/indexes-expressional.html + +If is not possible, I would create a column with value +date_trunc('hour'::text, i.entry_time) of each row and then index it. + +Hope this helps :) + +Doron Baranes wrote: + +>Hi, +> +>I am running on postgres 7.4.6. +>I did a vacuum analyze on the database but there was no change. +>I Attached here a file with details about the tables, the queries and +>the Explain analyze plans. +>Hope this can be helpful to analyze my problem +> +>10x +>Doron +> +> +>------------------------------------------------------------------------ +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 08:57:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 181F211F6274 + for ; + Thu, 20 Apr 2006 08:57:55 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id hsZ1gEMcaKA0 + for ; + Thu, 20 Apr 2006 08:57:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailRelay.dbnet.co.il (mail.dbnet.co.il [212.143.51.17]) + by postgresql.org (Postfix) with ESMTP id 5B67C11F8D21 + for ; + Thu, 20 Apr 2006 08:57:38 -0300 (ADT) +Received: from mailRelay.dbnet.co.il (localhost [127.0.0.1]) + by localhost.dbnet.co.il (Postfix) with ESMTP id CCC923C188; + Thu, 20 Apr 2006 15:21:25 +0300 (IDT) +Received: from exchange-1.dbnet.co.il (mail [172.16.2.1]) + by mailRelay.dbnet.co.il (Postfix) with ESMTP id A59F83C186; + Thu, 20 Apr 2006 15:21:25 +0300 (IDT) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Perfrmance Problems (7.4.6) +Date: Thu, 20 Apr 2006 14:57:50 +0200 +Message-ID: <0BA77301DFF4B24C9C5DAA74138BF95001E23C@exchange-1.dbnet.co.il> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Perfrmance Problems (7.4.6) +Thread-index: AcZkcIOAUgWKMmFHQ9+/MVmtSeHg1wACWngQ +From: "Doron Baranes" +To: "Ruben Rubio Rey" , +X-Archive-Number: 200604/440 +X-Sequence-Number: 18524 + +Ok. But that means I need a trigger on the original column to update the +new column on each insert/update and that overhead. + +-----Original Message----- +From: Ruben Rubio Rey [mailto:ruben@rentalia.com]=20 +Sent: Thursday, April 20, 2006 12:49 PM +To: Doron Baranes; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Perfrmance Problems (7.4.6) + +I think that the problem is the GROUP BY (datetime) that is=20 +date_trunc('hour'::text, i.entry_time) +You should create an indexe with this expression (if its possible). + +http://www.postgresql.org/docs/7.4/interactive/indexes-expressional.html + +If is not possible, I would create a column with value=20 +date_trunc('hour'::text, i.entry_time) of each row and then index it. + +Hope this helps :) + +Doron Baranes wrote: + +>Hi, +> +>I am running on postgres 7.4.6. +>I did a vacuum analyze on the database but there was no change. +>I Attached here a file with details about the tables, the queries and +>the Explain analyze plans. +>Hope this can be helpful to analyze my problem +> +>10x +>Doron +> =20 +> +>----------------------------------------------------------------------- +- +> +> +>---------------------------(end of +broadcast)--------------------------- +>TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> =20 +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 10:19:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 4FF7211F6CA7 + for ; + Thu, 20 Apr 2006 10:19:06 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.121 +X-Spam-Level: +X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Sk5a+aQwc48M + for ; + Thu, 20 Apr 2006 10:18:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx0.ifl.net (mx0.nmh.ifl.net [194.238.48.13]) + by postgresql.org (Postfix) with ESMTP id B43EA11F6274 + for ; + Thu, 20 Apr 2006 10:19:00 -0300 (ADT) +Received: from ex-con1.internal.rmplc.net (hercules.rmplc.co.uk + [194.238.48.90]) + by mx0.ifl.net (8.13.1/8.13.6) with ESMTP id k3KDIxUs025358 + for ; Thu, 20 Apr 2006 13:18:59 GMT +X-MessageTextProcessor: DisclaimIt (2.00.200) on ex-con1.internal.rmplc.net +Received: from ex-mail2.internal.rmplc.net ([172.16.11.13]) by + ex-con1.internal.rmplc.net with Microsoft SMTPSVC(6.0.3790.211); + Thu, 20 Apr 2006 14:18:57 +0100 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.326 +Content-Class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C6647C.FABD0728" +Subject: Quick Performance Poll +Date: Thu, 20 Apr 2006 14:18:58 +0100 +Content-Transfer-Encoding: 7bit +Message-ID: + <416F947BF5BA9E40B5F9AA649422212E0756199C@ex-mail2.internal.rmplc.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Quick Performance Poll +thread-index: AcZkfPtxoRadufVBRu+cbrZyF/vSVg== +Importance: normal +From: "Simon Dale" +To: +X-OriginalArrivalTime: 20 Apr 2006 13:18:57.0524 (UTC) + FILETIME=[FAEDAB40:01C6647C] +X-IFL-MailScanner-Information: Please contact IFL support for more information +X-IFL-MailScanner: Found to be clean +X-IFL-MailScanner-From: sdale@rm.com +X-Archive-Number: 200604/441 +X-Sequence-Number: 18525 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C6647C.FABD0728 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +Hi, + +=20 + +I was just wondering whether anyone has had success with storing more +than 1TB of data with PostgreSQL and how they have found the +performance. + +=20 + +We need a database that can store in excess of this amount and still +show good performance. We will probably be implementing several tables +with foreign keys and also indexes which will obviously impact on both +data size and performance too. + +=20 + +Many thanks in advance, + +=20 + +Simon +Visit our Website at http://www.rm.com + +This message is confidential. You should not copy it or disclose its = +contents to anyone. You may use and apply the information for the = +intended purpose only. Internet communications are not secure; = +therefore, RM does not accept legal responsibility for the contents of = +this message. Any views or opinions presented are those of the author = +only and not of RM. If this email has come to you in error, please = +delete it, along with any attachments. Please note that RM may intercept = +incoming and outgoing email communications.=20 + +Freedom of Information Act 2000 +This email and any attachments may contain confidential information = +belonging to RM. Where the email and any attachments do contain = +information of a confidential nature, including without limitation = +information relating to trade secrets, special terms or prices these = +shall be deemed for the purpose of the Freedom of Information Act 2000 = +as information provided in confidence by RM and the disclosure of which = +would be prejudicial to RM's commercial interests. + +This email has been scanned for viruses by Trend ScanMail. + +------_=_NextPart_001_01C6647C.FABD0728 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hi,

+ +

 

+ +

I was just wondering whether anyone has had success = +with +storing more than 1TB of data with PostgreSQL and how they have found = +the +performance.

+ +

 

+ +

We need a database that can store in excess of this = +amount +and still show good performance. We will probably be implementing = +several +tables with foreign keys and also indexes which will obviously impact on = +both +data size and performance too.

+ +

 

+ +

Many thanks in advance,

+ +

 

+ +

Simon

+ +
+ +
+

+Visit our Website at www.rm.com +
+
+This message is confidential. You should not copy it or disclose its = +contents to anyone. You may use and apply the information for the = +intended purpose only. Internet communications are not secure; = +therefore, RM does not accept legal responsibility for the contents of = +this message. Any views or opinions presented are those of the author = +only and not of RM. If this email has come to you in error, please = +delete it, along with any attachments. Please note that RM may intercept = +incoming and outgoing email communications.=20 +

+Freedom of Information Act 2000 +
+This email and any attachments may contain confidential information = +belonging to RM. Where the email and any attachments do contain = +information of a confidential nature, including without limitation = +information relating to trade secrets, special terms or prices these = +shall be deemed for the purpose of the Freedom of Information Act 2000 = +as information provided in confidence by RM and the disclosure of which = +would be prejudicial to RM's commercial interests. +

+This email has been scanned for viruses by Trend ScanMail.

+
+ + + +------_=_NextPart_001_01C6647C.FABD0728-- + +From pgsql-performance-owner@postgresql.org Thu Apr 20 10:36:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7C0C911F6CDB + for ; + Thu, 20 Apr 2006 10:36:30 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.096 +X-Spam-Level: +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id jwI-gtmxPLG5 + for ; + Thu, 20 Apr 2006 10:36:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 4637211F6CBF + for ; + Thu, 20 Apr 2006 10:36:26 -0300 (ADT) +Received: from amanda.contactbda.com (ipn36372-e65122.cidr.lightship.net + [216.204.66.226]) + by svr4.postgresql.org (Postfix) with ESMTP id 375D45AFA5B + for ; + Thu, 20 Apr 2006 13:36:27 +0000 (GMT) +Received: from amanda.contactbda.com (amanda.contactbda.com [192.168.1.2]) + by amanda.contactbda.com (8.12.11/8.12.11/Debian-3) with ESMTP id + k3KDaPpk018862; Thu, 20 Apr 2006 09:36:25 -0400 +From: "Jim Buttafuoco" +To: "Simon Dale" , +Reply-To: jim@contactbda.com +Subject: Re: Quick Performance Poll +Date: Thu, 20 Apr 2006 09:36:25 -0400 +Message-Id: <20060420133326.M88248@contactbda.com> +In-Reply-To: + <416F947BF5BA9E40B5F9AA649422212E0756199C@ex-mail2.internal.rmplc.net> +References: + <416F947BF5BA9E40B5F9AA649422212E0756199C@ex-mail2.internal.rmplc.net> +X-Mailer: Open WebMail 2.41 20040926 +X-OriginatingIP: 192.168.1.1 (jim) +MIME-Version: 1.0 +Content-Type: text/plain; + charset=iso-8859-1 +X-Archive-Number: 200604/442 +X-Sequence-Number: 18526 + + +Simon, + +I have many databases over 1T with the largest being ~6T. All of my databases store telecom data, such as call detail +records. The access is very fast when looking for a small subset of the data. For servers, I am using white box intel +XEON and P4 systems with SATA disks, 4G of memory. SCSI is out of our price range, but if I had unlimited $ I would go +with SCSI /SCSI raid instead. + +Jim + +---------- Original Message ----------- +From: "Simon Dale" +To: +Sent: Thu, 20 Apr 2006 14:18:58 +0100 +Subject: [PERFORM] Quick Performance Poll + +> Hi, +> +> I was just wondering whether anyone has had success with storing more +> than 1TB of data with PostgreSQL and how they have found the +> performance. +> +> We need a database that can store in excess of this amount and still +> show good performance. We will probably be implementing several tables +> with foreign keys and also indexes which will obviously impact on both +> data size and performance too. +> +> Many thanks in advance, +> +> Simon +> Visit our Website at http://www.rm.com +> +> This message is confidential. You should not copy it or disclose its contents to anyone. You may use and apply +> the information for the intended purpose only. Internet communications are not secure; therefore, RM does not +> accept legal responsibility for the contents of this message. Any views or opinions presented are those of the +> author only and not of RM. If this email has come to you in error, please delete it, along with any +> attachments. Please note that RM may intercept incoming and outgoing email communications. +> +> Freedom of Information Act 2000 +> This email and any attachments may contain confidential information belonging to RM. Where the email and any +> attachments do contain information of a confidential nature, including without limitation information relating +> to trade secrets, special terms or prices these shall be deemed for the purpose of the Freedom of Information +> Act 2000 as information provided in confidence by RM and the disclosure of which would be prejudicial to RM's +> commercial interests. +> +> This email has been scanned for viruses by Trend ScanMail. +------- End of Original Message ------- + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 10:52:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id C717011F6CC7 + for ; + Thu, 20 Apr 2006 10:52:02 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.144 +X-Spam-Level: +X-Spam-Status: No, score=0.144 required=5 tests=[AWL=0.144] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id RWe9oygbNmqy + for ; + Thu, 20 Apr 2006 10:51:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) + by postgresql.org (Postfix) with ESMTP id C723211F6CB5 + for ; + Thu, 20 Apr 2006 10:51:56 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by pjetlic.mobart.hr (Postfix) with ESMTP id 95A9B17ABC + for ; + Thu, 20 Apr 2006 15:51:54 +0200 (CEST) +Received: from pjetlic.mobart.hr ([127.0.0.1]) + by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 22876-01 for ; + Thu, 20 Apr 2006 15:51:54 +0200 (CEST) +Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by pjetlic.mobart.hr (Postfix) with ESMTP id 669AE17AB8 + for ; + Thu, 20 Apr 2006 15:51:54 +0200 (CEST) +Subject: Identical query on two machines, different plans.... +From: Mario Splivalo +Reply-To: mario.splivalo@mobart.hr +To: Pgsql performance +Content-Type: text/plain +Organization: Mob-Art +Date: Thu, 20 Apr 2006 15:51:53 +0200 +Message-Id: <1145541113.9373.9.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by OpenSource AV+AS Mail Server +X-Archive-Number: 200604/443 +X-Sequence-Number: 18527 + +I have copied the database from production server to my laptop (pg_dump, +etc...) to do some testing. + +While testing I have found out that one particular query is beeing much +slower on my machine than on the server (it's not just because my laptop +is much slower than the server), and found out that postgres is using +different plan on server than on my laptop. Both on server and on my +laptop is postgres-8.1.2, running on Debian (sarge on server, Ubuntu on +my laptop), with 2.6 kernel, I compiled postgres with gcc4 on both +machines. + +The query is like this: + +on the server: + +pulitzer2=# explain analyze select code_id from ticketing_codes where +code_group_id = 1000 and code_value = UPPER('C7ZP2U'); + +QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using ticketing_codes_uq_value_group_id on ticketing_codes +(cost=0.00..6.02 rows=1 width=4) (actual time=0.104..0.107 rows=1 +loops=1) + Index Cond: (((code_value)::text = 'C7ZP2U'::text) AND (code_group_id += 1000)) + Total runtime: 0.148 ms +(3 rows) + + +And, on my laptop: + +som_pulitzer2=# explain analyze select code_id from ticketing_codes +where code_group_id = 1000 and code_value = UPPER('C7ZP2U'); + QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------------- + Bitmap Heap Scan on ticketing_codes (cost=2.01..1102.05 rows=288 +width=4) (actual time=88.164..88.170 rows=1 loops=1) + Recheck Cond: (((code_value)::text = 'C7ZP2U'::text) AND +(code_group_id = 1000)) + -> Bitmap Index Scan on ticketing_codes_uq_value_group_id +(cost=0.00..2.01 rows=288 width=0) (actual time=54.397..54.397 rows=1 +loops=1) + Index Cond: (((code_value)::text = 'C7ZP2U'::text) AND +(code_group_id = 1000)) + Total runtime: 88.256 ms +(5 rows) + + + +This is the table ticketing_codes: +som_pulitzer2=# \d ticketing_codes; + Table "public.ticketing_codes" + Column | Type | +Modifiers +---------------+-----------------------+------------------------------------------------------------------- + code_id | integer | not null default +nextval('ticketing_codes_code_id_seq'::regclass) + code_value | character varying(10) | not null + code_group_id | integer | not null +Indexes: + "ticketing_codes_pk" PRIMARY KEY, btree (code_id) + "ticketing_codes_uq_value_group_id" UNIQUE, btree (code_value, +code_group_id) +Foreign-key constraints: + "ticketing_codes_fk__ticketing_code_groups" FOREIGN KEY +(code_group_id) REFERENCES ticketing_code_groups(group_id) + + +And the \d command produces the same result on both my server and +laptop. + +That query is beeing called from within function, the code is like this: + +codeId := code_id from ticketing_codes where code_group_id = 1000 and +code_value = UPPER('C7ZP2U'); + +codeId has been declared as int4. When that query is run inside the +function, it takes around 20 seconds (compared to 88 miliseconds when I +call it from psql). The query is that very same query, just the values +1000 and 'C7ZP2U' are parametars for the function. + +So, the second question would be why is that query much much slower when +run from within function? Is there a way to see an execution plan for +the query inside the function? + + Mike +-- +Mario Splivalo +Mob-Art +mario.splivalo@mobart.hr + +"I can do it quick, I can do it cheap, I can do it well. Pick any two." + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 11:00:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2F02011F6CD6 + for ; + Thu, 20 Apr 2006 11:00:10 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id PBeznBves5Rc + for ; + Thu, 20 Apr 2006 10:59:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) + by postgresql.org (Postfix) with ESMTP id 4F75911F6CC7 + for ; + Thu, 20 Apr 2006 10:59:59 -0300 (ADT) +Received: from deimos.muc.ecircle.de (deimos.muc.ecircle.de [192.168.1.4]) + by mail.ecircle.de (READY) with ESMTP id BDA1B55C013; + Thu, 20 Apr 2006 15:59:56 +0200 (CEST) +Received: from [192.168.1.91] ([192.168.1.91]) by deimos.muc.ecircle.de with + Microsoft SMTPSVC(5.0.2195.6713); Thu, 20 Apr 2006 15:59:56 +0200 +Subject: Re: Identical query on two machines, different plans.... +From: Csaba Nagy +To: mario.splivalo@mobart.hr +Cc: Pgsql performance +In-Reply-To: <1145541113.9373.9.camel@localhost.localdomain> +References: <1145541113.9373.9.camel@localhost.localdomain> +Content-Type: text/plain +Message-Id: <1145541587.3553.30.camel@coppola.muc.ecircle.de> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Thu, 20 Apr 2006 15:59:48 +0200 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 20 Apr 2006 13:59:56.0671 (UTC) + FILETIME=[B4B1B8F0:01C66482] +X-Archive-Number: 200604/444 +X-Sequence-Number: 18528 + +You very likely forgot to run ANALYZE on your laptop after copying the +data. Observe the different row count estimates in the 2 plans... + +HTH, +Csaba. + + +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------------------------------------- +> Index Scan using ticketing_codes_uq_value_group_id on ticketing_codes +> (cost=0.00..6.02 rows=1 width=4) (actual time=0.104..0.107 rows=1 + ^^^^^^ +> loops=1) +> Index Cond: (((code_value)::text = 'C7ZP2U'::text) AND (code_group_id +> = 1000)) +> Total runtime: 0.148 ms +> (3 rows) +> +> +> PLAN +> ---------------------------------------------------------------------------------------------------------------------------------------------- +> Bitmap Heap Scan on ticketing_codes (cost=2.01..1102.05 rows=288 + ^^^^^^^^ +> width=4) (actual time=88.164..88.170 rows=1 loops=1) +> Recheck Cond: (((code_value)::text = 'C7ZP2U'::text) AND +> (code_group_id = 1000)) +> -> Bitmap Index Scan on ticketing_codes_uq_value_group_id +> (cost=0.00..2.01 rows=288 width=0) (actual time=54.397..54.397 rows=1 +> loops=1) +> Index Cond: (((code_value)::text = 'C7ZP2U'::text) AND +> (code_group_id = 1000)) +> Total runtime: 88.256 ms +> (5 rows) +> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 11:04:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 46A6111F6CED + for ; + Thu, 20 Apr 2006 11:04:03 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.549 +X-Spam-Level: +X-Spam-Status: No, score=-2.549 required=5 tests=[AWL=0.050, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id xquA9c21Wqql + for ; + Thu, 20 Apr 2006 11:04:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) + by postgresql.org (Postfix) with ESMTP id 532C011F6CC7 + for ; + Thu, 20 Apr 2006 11:03:58 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by pjetlic.mobart.hr (Postfix) with ESMTP id 591FC17ABC; + Thu, 20 Apr 2006 16:03:59 +0200 (CEST) +Received: from pjetlic.mobart.hr ([127.0.0.1]) + by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 17218-05-3; Thu, 20 Apr 2006 16:03:59 +0200 (CEST) +Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by pjetlic.mobart.hr (Postfix) with ESMTP id 41B3217AB8; + Thu, 20 Apr 2006 16:03:59 +0200 (CEST) +Subject: Re: Identical query on two machines, different plans.... +From: Mario Splivalo +Reply-To: mario.splivalo@mobart.hr +To: Pgsql performance +Cc: Csaba Nagy +In-Reply-To: <1145541587.3553.30.camel@coppola.muc.ecircle.de> +References: <1145541113.9373.9.camel@localhost.localdomain> + <1145541587.3553.30.camel@coppola.muc.ecircle.de> +Content-Type: text/plain +Organization: Mob-Art +Date: Thu, 20 Apr 2006 16:03:58 +0200 +Message-Id: <1145541838.9373.11.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by OpenSource AV+AS Mail Server +X-Archive-Number: 200604/445 +X-Sequence-Number: 18529 + +On Thu, 2006-04-20 at 15:59 +0200, Csaba Nagy wrote: +> You very likely forgot to run ANALYZE on your laptop after copying the +> data. Observe the different row count estimates in the 2 plans... +> +> HTH, +> Csaba. + +Sometimes I wish I am Dumbo the Elephant, so I could cover myself with +me ears... + +Thnx :) + + Mike +-- +Mario Splivalo +Mob-Art +mario.splivalo@mobart.hr + +"I can do it quick, I can do it cheap, I can do it well. Pick any two." + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 11:06:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 9C34411F628C + for ; + Thu, 20 Apr 2006 11:06:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.6 +X-Spam-Level: +X-Spam-Status: No, score=-2.6 required=5 tests=[BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 5jgjWelNjTzL + for ; + Thu, 20 Apr 2006 11:06:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) + by postgresql.org (Postfix) with ESMTP id 5048D11F61EA + for ; + Thu, 20 Apr 2006 11:06:22 -0300 (ADT) +Received: from deimos.muc.ecircle.de (deimos.muc.ecircle.de [192.168.1.4]) + by mail.ecircle.de (READY) with ESMTP id C905755C00F; + Thu, 20 Apr 2006 16:06:19 +0200 (CEST) +Received: from [192.168.1.91] ([192.168.1.91]) by deimos.muc.ecircle.de with + Microsoft SMTPSVC(5.0.2195.6713); Thu, 20 Apr 2006 16:06:19 +0200 +Subject: Re: Identical query on two machines, different plans.... +From: Csaba Nagy +To: mario.splivalo@mobart.hr +Cc: Pgsql performance +In-Reply-To: <1145541587.3553.30.camel@coppola.muc.ecircle.de> +References: <1145541113.9373.9.camel@localhost.localdomain> + <1145541587.3553.30.camel@coppola.muc.ecircle.de> +Content-Type: text/plain +Message-Id: <1145541970.3553.36.camel@coppola.muc.ecircle.de> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Thu, 20 Apr 2006 16:06:11 +0200 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 20 Apr 2006 14:06:19.0734 (UTC) + FILETIME=[99047F60:01C66483] +X-Archive-Number: 200604/446 +X-Sequence-Number: 18530 + +OK, I marked the wrong row counts, but the conclusion is the same. + +Cheers, +Csaba. + + +> > QUERY PLAN +> > --------------------------------------------------------------------------------------------------------------------------------------------------- +> > Index Scan using ticketing_codes_uq_value_group_id on ticketing_codes +> > (cost=0.00..6.02 rows=1 width=4) (actual time=0.104..0.107 rows=1 +> ^^^^^^ +> > loops=1) +> > Index Cond: (((code_value)::text = 'C7ZP2U'::text) AND (code_group_id +> > = 1000)) +> > Total runtime: 0.148 ms +> > (3 rows) +> > +> > +> > PLAN +> > ---------------------------------------------------------------------------------------------------------------------------------------------- +> > Bitmap Heap Scan on ticketing_codes (cost=2.01..1102.05 rows=288 +> ^^^^^^^^ +> > width=4) (actual time=88.164..88.170 rows=1 loops=1) +> > Recheck Cond: (((code_value)::text = 'C7ZP2U'::text) AND +> > (code_group_id = 1000)) +> > -> Bitmap Index Scan on ticketing_codes_uq_value_group_id +> > (cost=0.00..2.01 rows=288 width=0) (actual time=54.397..54.397 rows=1 + ^^^^^^^^ +> > loops=1) +> > Index Cond: (((code_value)::text = 'C7ZP2U'::text) AND +> > (code_group_id = 1000)) +> > Total runtime: 88.256 ms +> > (5 rows) +> > +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 11:16:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BCB6411F6296 + for ; + Thu, 20 Apr 2006 11:16:31 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.114 +X-Spam-Level: +X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.113, + UNPARSEABLE_RELAY=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id a7hMt44TmKoS + for ; + Thu, 20 Apr 2006 11:16:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 447B711F62F8 + for ; + Thu, 20 Apr 2006 11:16:27 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Thu, 20 Apr 2006 14:16:27 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 20 Apr 2006 09:16:27 -0500 +Subject: Re: Inserts optimization? +From: Scott Marlowe +To: Christopher Kings-Lynne +Cc: Tom Lane , Markus Schaber , + Magnus Hagander , + Pgsql performance +In-Reply-To: <4446DED2.3040307@calorieking.com> +References: <6BCB9D8A16AC4241919521715F4D8BCEA352AE@algol.sollentuna.se> + <44462849.3070209@logix-tt.com> + <1145460130.23538.119.camel@state.g2switchworks.com> + <26519.1145460679@sss.pgh.pa.us> <4446DED2.3040307@calorieking.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1145542587.23538.131.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Thu, 20 Apr 2006 09:16:27 -0500 +X-Archive-Number: 200604/447 +X-Sequence-Number: 18531 + +On Wed, 2006-04-19 at 20:07, Christopher Kings-Lynne wrote: +> > Scott Marlowe writes: +> >> It's the refusal of people to stop using MyISAM table types that's the +> >> real issue. +> > +> > Isn't MyISAM still the default over there? It's hardly likely that the +> > average MySQL user would use anything but the default table type ... +> +> Since MySQL 5, InnoDB tables are default I recall. + +It gets built by default, but when you do a plain create table, it will +still default to myisam tables. + +Note that there is a setting somewhere in my.cnf that will make the +default table type anything you want. + +For Bacula though, what I was suggesting was that they simply declare +that you need innodb table type support if you want decent performance, +then coding to that, and if someone doesn't have innodb table support, +then they have no right to complain about poor performance. Seems a +fair compromise to me. The Bacula folks would get to program to a real +database model with proper serlialization and all that, and the people +who refuse to move up to a later model MySQL get crappy performance. + +From pgsql-performance-owner@postgresql.org Thu Apr 20 11:32:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id B917111F6106 + for ; + Thu, 20 Apr 2006 11:32:00 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.964 +X-Spam-Level: +X-Spam-Status: No, score=-0.964 required=5 tests=[BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, RCVD_NUMERIC_HELO=1.5] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id roKH-eqEb9CD + for ; + Thu, 20 Apr 2006 11:31:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by postgresql.org (Postfix) with ESMTP id 1429111F6558 + for ; + Thu, 20 Apr 2006 11:31:48 -0300 (ADT) +Received: from 172.16.1.112 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Thu, 20 Apr 2006 10:31:37 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 20 Apr + 2006 10:31:35 -0400 +Received: from 69.181.100.71 ([69.181.100.71]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Thu, 20 Apr + 2006 14:31:34 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 20 Apr 2006 07:31:33 -0700 +Subject: Re: Quick Performance Poll +From: "Luke Lonergan" +To: jim@contactbda.com, "Simon Dale" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Quick Performance Poll +Thread-Index: AcZkf612f9UYUtDBQT2OSMGGcRl8iwAB3GKr +In-Reply-To: <20060420133326.M88248@contactbda.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 20 Apr 2006 14:31:35.0523 (UTC) + FILETIME=[207F8B30:01C66487] +X-WSS-ID: 685944CD20C48462936-02-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/448 +X-Sequence-Number: 18532 + +Jim, + +On 4/20/06 6:36 AM, "Jim Buttafuoco" wrote: + +> The access is very fast when looking for a small subset of the data. + +I guess you are not using indexes because building a (non bitmap) index on +6TB on a single machine would take days if not weeks. + +So if you are using table partitioning, do you have to refer to each child +table separately in your queries? + +- Luke + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 11:41:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 221D611F6296 + for ; + Thu, 20 Apr 2006 11:41:01 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.08 +X-Spam-Level: +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id LLz5IHfUlX2J + for ; + Thu, 20 Apr 2006 11:40:51 -0300 (ADT) +X-Greylist: delayed 01:04:29.932351 by SQLgrey- +Received: from amanda.contactbda.com (ipn36372-e65122.cidr.lightship.net + [216.204.66.226]) + by postgresql.org (Postfix) with ESMTP id 5EF7A11F6095 + for ; + Thu, 20 Apr 2006 11:40:54 -0300 (ADT) +Received: from amanda.contactbda.com (amanda.contactbda.com [192.168.1.2]) + by amanda.contactbda.com (8.12.11/8.12.11/Debian-3) with ESMTP id + k3KEeoGa021817; Thu, 20 Apr 2006 10:40:50 -0400 +From: "Jim Buttafuoco" +To: "Luke Lonergan" , "Simon Dale" , + pgsql-performance@postgresql.org +Reply-To: jim@contactbda.com +Subject: Re: Quick Performance Poll +Date: Thu, 20 Apr 2006 10:40:50 -0400 +Message-Id: <20060420143830.M5360@contactbda.com> +In-Reply-To: +References: <20060420133326.M88248@contactbda.com> + +X-Mailer: Open WebMail 2.41 20040926 +X-OriginatingIP: 192.168.1.1 (jim) +MIME-Version: 1.0 +Content-Type: text/plain; + charset=iso-8859-1 +X-Archive-Number: 200604/449 +X-Sequence-Number: 18533 + +First of all this is NOT a single table and yes I am using partitioning and the constaint exclusion stuff. the largest +set of tables is over 2T. I have not had to rebuild the biggest database yet, but for a smaller one ~1T the restore +takes about 12 hours including many indexes on both large and small tables + +Jim + + + +---------- Original Message ----------- +From: "Luke Lonergan" +To: jim@contactbda.com, "Simon Dale" , pgsql-performance@postgresql.org +Sent: Thu, 20 Apr 2006 07:31:33 -0700 +Subject: Re: [PERFORM] Quick Performance Poll + +> Jim, +> +> On 4/20/06 6:36 AM, "Jim Buttafuoco" wrote: +> +> > The access is very fast when looking for a small subset of the data. +> +> I guess you are not using indexes because building a (non bitmap) index on +> 6TB on a single machine would take days if not weeks. +> +> So if you are using table partitioning, do you have to refer to each child +> table separately in your queries? +> +> - Luke +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +------- End of Original Message ------- + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 11:54:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 6B1D511F65A5 + for ; + Thu, 20 Apr 2006 11:54:36 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.414 +X-Spam-Level: +X-Spam-Status: No, score=-2.414 required=5 tests=[AWL=0.050, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 44bPR0Vng3gP + for ; + Thu, 20 Apr 2006 11:54:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.rentalia.net (mail.rentalia.com [213.192.209.8]) + by postgresql.org (Postfix) with ESMTP id BE3F811F6551 + for ; + Thu, 20 Apr 2006 11:54:28 -0300 (ADT) +Received: (qmail 2423 invoked by uid 514); 20 Apr 2006 17:55:41 +0200 +Received: from 62.37.217.76 by rigodon (envelope-from , + uid 512) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1284. spamassassin: 3.0.2. perlscan: 1.25-st-qms. + Clear:RC:0(62.37.217.76):SA:0(-2.2/5.0):. + Processed in 1.851807 secs); 20 Apr 2006 15:55:41 -0000 +X-Antivirus-MYDOMAIN-Mail-From: ruben@rentalia.com via rigodon +X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:0(62.37.217.76):SA:0(-2.2/5.0):. + Processed in 1.851807 secs Process 2406) +Received: from 62-37-217-76.mad1.adsl.uni2.es (HELO ?192.168.2.28?) + (ruben@rentalia.com@62.37.217.76) + by mail.rentalia.net with SMTP; 20 Apr 2006 17:55:39 +0200 +Message-ID: <4447A09D.9070600@rentalia.com> +Date: Thu, 20 Apr 2006 16:54:21 +0200 +From: Ruben Rubio Rey +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051011) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Doron Baranes , + pgsql-performance@postgresql.org +Subject: Re: Perfrmance Problems (7.4.6) +References: <0BA77301DFF4B24C9C5DAA74138BF95001E23C@exchange-1.dbnet.co.il> +In-Reply-To: <0BA77301DFF4B24C9C5DAA74138BF95001E23C@exchange-1.dbnet.co.il> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/450 +X-Sequence-Number: 18534 + +Did you tried to index the expression? +Did it work? + +Doron Baranes wrote: + +>Ok. But that means I need a trigger on the original column to update the +>new column on each insert/update and that overhead. +> +>-----Original Message----- +>From: Ruben Rubio Rey [mailto:ruben@rentalia.com] +>Sent: Thursday, April 20, 2006 12:49 PM +>To: Doron Baranes; pgsql-performance@postgresql.org +>Subject: Re: [PERFORM] Perfrmance Problems (7.4.6) +> +>I think that the problem is the GROUP BY (datetime) that is +>date_trunc('hour'::text, i.entry_time) +>You should create an indexe with this expression (if its possible). +> +>http://www.postgresql.org/docs/7.4/interactive/indexes-expressional.html +> +>If is not possible, I would create a column with value +>date_trunc('hour'::text, i.entry_time) of each row and then index it. +> +>Hope this helps :) +> +>Doron Baranes wrote: +> +> +> +>>Hi, +>> +>>I am running on postgres 7.4.6. +>>I did a vacuum analyze on the database but there was no change. +>>I Attached here a file with details about the tables, the queries and +>>the Explain analyze plans. +>>Hope this can be helpful to analyze my problem +>> +>>10x +>>Doron +>> +>> +>>----------------------------------------------------------------------- +>> +>> +>- +> +> +>>---------------------------(end of +>> +>> +>broadcast)--------------------------- +> +> +>>TIP 9: In versions below 8.0, the planner will ignore your desire to +>> choose an index scan if your joining column's datatypes do not +>> match +>> +>> +>> +>> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 2: Don't 'kill -9' the postmaster +> +> +> +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 12:03:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3D97111F65A2 + for ; + Thu, 20 Apr 2006 12:03:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.386 +X-Spam-Level: * +X-Spam-Status: No, score=1.386 required=5 tests=[AWL=0.133, + RCVD_NUMERIC_HELO=1.253] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 1JB6nUR++iOS + for ; + Thu, 20 Apr 2006 12:03:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id B555411F65A3 + for ; + Thu, 20 Apr 2006 12:03:31 -0300 (ADT) +Received: from 172.16.1.112 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Thu, 20 Apr 2006 11:03:11 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 20 Apr + 2006 11:03:11 -0400 +Received: from 69.181.100.71 ([69.181.100.71]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Thu, 20 Apr + 2006 15:03:11 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 20 Apr 2006 08:03:10 -0700 +Subject: Re: Quick Performance Poll +From: "Luke Lonergan" +To: jim@contactbda.com, "Simon Dale" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Quick Performance Poll +Thread-Index: AcZkiIhvZsN3K4XYSHOiuNMmMRaDoQAAwFAr +In-Reply-To: <20060420143830.M5360@contactbda.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 20 Apr 2006 15:03:11.0712 (UTC) + FILETIME=[8AB70600:01C6648B] +X-WSS-ID: 68597D254N02556228-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/451 +X-Sequence-Number: 18535 + +Jim, + +On 4/20/06 7:40 AM, "Jim Buttafuoco" wrote: + +> First of all this is NOT a single table and yes I am using partitioning and +> the constaint exclusion stuff. the largest +> set of tables is over 2T. I have not had to rebuild the biggest database yet, +> but for a smaller one ~1T the restore +> takes about 12 hours including many indexes on both large and small tables + +You would probably benefit greatly from the new on-disk bitmap index feature +in Bizgres Open Source. It's 8.1 plus the sort speed improvement and +on-disk bitmap index. + +Index creation and sizes for the binary version are in the table below (from +a performance report on bizgres network. The version in CVS tip on +pgfoundry is much faster on index creation as well. + +The current drawback to bitmap index is that it isn't very maintainable +under insert/update, although it is safe for those operations. For now, you +have to drop index, do inserts/updates, rebuild index. + +We'll have a version that is maintained for insert/update next. + +- Luke + + # Indexed Columns Create Time (seconds) Space Used (MBs) + BITMAP BTREE BITMAP BTREE + 1 L_SHIPMODE 454.8 2217.1 58 1804 + 2 L_QUANTITY 547.2 937.8 117 1804 + 3 L_LINENUMBER 374.5 412.4 59 1285 + 4 L_SHIPMODE, L_QUANTITY 948.7 2933.4 176 2845 + 5 O_ORDERSTATUS 83.5 241.3 5 321 + 6 O_ORDERPRIORITY 108.5 679.1 11 580 + 7 C_MKTSEGMENT 10.9 51.3 1 45 + 8 C_NATIONKEY 8.3 9.3 2 32 + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 12:06:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id E18F211F68DC + for ; + Thu, 20 Apr 2006 12:06:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -1.705 +X-Spam-Level: +X-Spam-Status: No, score=-1.705 required=5 tests=[AWL=-0.625, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 15H758mo6aSY + for ; + Thu, 20 Apr 2006 12:06:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from amanda.contactbda.com (ipn36372-e65122.cidr.lightship.net + [216.204.66.226]) + by postgresql.org (Postfix) with ESMTP id CA4B711F6551 + for ; + Thu, 20 Apr 2006 12:06:20 -0300 (ADT) +Received: from amanda.contactbda.com (amanda.contactbda.com [192.168.1.2]) + by amanda.contactbda.com (8.12.11/8.12.11/Debian-3) with ESMTP id + k3KF6E1L023404; Thu, 20 Apr 2006 11:06:14 -0400 +From: "Jim Buttafuoco" +To: "Luke Lonergan" , "Simon Dale" , + pgsql-performance@postgresql.org +Reply-To: jim@contactbda.com +Subject: Re: Quick Performance Poll +Date: Thu, 20 Apr 2006 11:06:14 -0400 +Message-Id: <20060420150533.M78785@contactbda.com> +In-Reply-To: +References: <20060420143830.M5360@contactbda.com> + +X-Mailer: Open WebMail 2.41 20040926 +X-OriginatingIP: 192.168.1.1 (jim) +MIME-Version: 1.0 +Content-Type: text/plain; + charset=iso-8859-1 +X-Archive-Number: 200604/452 +X-Sequence-Number: 18536 + + +I have been following your work with great interest. I believe I spoke to someone from Greenplum at linux world in +Boston a couple of weeks ago. + +---------- Original Message ----------- +From: "Luke Lonergan" +To: jim@contactbda.com, "Simon Dale" , pgsql-performance@postgresql.org +Sent: Thu, 20 Apr 2006 08:03:10 -0700 +Subject: Re: [PERFORM] Quick Performance Poll + +> Jim, +> +> On 4/20/06 7:40 AM, "Jim Buttafuoco" wrote: +> +> > First of all this is NOT a single table and yes I am using partitioning and +> > the constaint exclusion stuff. the largest +> > set of tables is over 2T. I have not had to rebuild the biggest database yet, +> > but for a smaller one ~1T the restore +> > takes about 12 hours including many indexes on both large and small tables +> +> You would probably benefit greatly from the new on-disk bitmap index feature +> in Bizgres Open Source. It's 8.1 plus the sort speed improvement and +> on-disk bitmap index. +> +> Index creation and sizes for the binary version are in the table below (from +> a performance report on bizgres network. The version in CVS tip on +> pgfoundry is much faster on index creation as well. +> +> The current drawback to bitmap index is that it isn't very maintainable +> under insert/update, although it is safe for those operations. For now, you +> have to drop index, do inserts/updates, rebuild index. +> +> We'll have a version that is maintained for insert/update next. +> +> - Luke +> +> # Indexed Columns Create Time (seconds) Space Used (MBs) +> BITMAP BTREE BITMAP BTREE +> 1 L_SHIPMODE 454.8 2217.1 58 1804 +> 2 L_QUANTITY 547.2 937.8 117 1804 +> 3 L_LINENUMBER 374.5 412.4 59 1285 +> 4 L_SHIPMODE, L_QUANTITY 948.7 2933.4 176 2845 +> 5 O_ORDERSTATUS 83.5 241.3 5 321 +> 6 O_ORDERPRIORITY 108.5 679.1 11 580 +> 7 C_MKTSEGMENT 10.9 51.3 1 45 +> 8 C_NATIONKEY 8.3 9.3 2 32 +------- End of Original Message ------- + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 12:11:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 7D16411F66E4 + for ; + Thu, 20 Apr 2006 12:11:22 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.187 +X-Spam-Level: +X-Spam-Status: No, score=-2.187 required=5 tests=[AWL=0.277, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id e+T932bKg8PJ + for ; + Thu, 20 Apr 2006 12:11:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 663C811F65A2 + for ; + Thu, 20 Apr 2006 12:11:10 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T96ed.t.pppool.de + [89.55.150.237]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id D2D7F656CD + for ; + Thu, 20 Apr 2006 17:12:08 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 6658D181C1F52 + for ; + Thu, 20 Apr 2006 17:11:25 +0200 (CEST) +Message-ID: <4447A49D.9080707@logix-tt.com> +Date: Thu, 20 Apr 2006 17:11:25 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Quick Performance Poll +References: +In-Reply-To: +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/453 +X-Sequence-Number: 18537 + +Hi, Luke, + +Luke Lonergan wrote: + +> The current drawback to bitmap index is that it isn't very maintainable +> under insert/update, although it is safe for those operations. For now, you +> have to drop index, do inserts/updates, rebuild index. + +So they effectively turn the table into a read-only table for now. + +Are they capable to index custom datatypes like the PostGIS geometries +that use the GIST mechanism? This could probably speed up our Geo +Databases for Map rendering, containing static data that is updated +approx. 2 times per year. + + +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Thu Apr 20 12:16:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 9873911F6770 + for ; + Thu, 20 Apr 2006 12:16:57 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.525 +X-Spam-Level: +X-Spam-Status: No, score=-2.525 required=5 tests=[AWL=0.075, BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id PrlDJNFYmmiR + for ; + Thu, 20 Apr 2006 12:16:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (fon.nation-net.com [194.24.251.1]) + by postgresql.org (Postfix) with ESMTP id 31A2511F663F + for ; + Thu, 20 Apr 2006 12:16:50 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id CE2631371E6 + for ; + Thu, 20 Apr 2006 16:16:44 +0100 (BST) +Received: from [194.24.251.10] (bum.net [194.24.251.10]) + by fon.nation-net.com (Postfix) with ESMTP id 95908136AA3 + for ; + Thu, 20 Apr 2006 16:16:44 +0100 (BST) +Message-ID: <4447A52D.90804@laterooms.com> +Date: Thu, 20 Apr 2006 16:13:49 +0100 +From: Gavin Hamill +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: IBM pSeries - overrated bucket of crud? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AV-Checked: ClamAV using ClamSMTP +X-Archive-Number: 200604/454 +X-Sequence-Number: 18538 + +Hi again :) + +This is a follow-up to the mega thread which made a Friday night more +interesting [1] - the summary is various people thought there was some +issue with shared memory access on AIX. + +I then installed Debian (kernel 2.6.11) on the 8-CPU p650 (native - no +LPAR) and saw just as woeful performance. + +Now I've had a chance to try a 2-CPU dualcore Opteron box, and it +*FLIES* - the 4-way machine sits churning through our heavy +'hotelsearch' function at ~400ms per call. + +Basically, this pSeries box is available until Monday lunchtime if any +pg devel wants to pop in, run tests, mess around since I am convinced +that the hardware itself cannot be this poor - it has to be some failing +of pg when mixed with our dataset / load pattern. + +e.g. If I run 'ab -n 200 -c 4 -k http://localhost/test.php [2] with +pg_connect pointed at the pSeries, it turns in search times of ~3500ms +with loadavg of 4. + +The same test with pg_connect pointed at the dual-Opteron turns in +~300ms searches, with loadavg of 3.5 .. something is very very wrong +with the pSeries setup :) + +If I crank up the heat and run apachebench with 10 hammering clients +instead of 4, the differences become even more stark.. pSeries: +5000-15000ms, loadavg 9.. Opteron ~3000ms, loadavg 8. 90% of queries on +the Opteron conclude in under 4000ms, which maxes out at 6.5 searches +per second. The pSeries manages 0.9 searches per second. (!) + +Databases on both machines have seen a VACUUM FULL and VACUUM ANALYZE +before testing, and have near-identical postgresql.conf's. (the pSeries +has twice the RAM) + +This post is not intended to be whining that 'pg is crap on pSeries!' - +I'm trying to make a resource available (albeit for a short time) to +help fix a problem that will doubtless affect others in future - for +certain we're never going midrange again! :O + +Cheers, +Gavin. + +[1] http://archives.postgresql.org/pgsql-performance/2006-04/msg00143.php +[2] Trivial script which does a pg_connect, runs a random hotelsearch +and exits. + +From pgsql-performance-owner@postgresql.org Thu Apr 20 12:17:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 94A7811F68C6 + for ; + Thu, 20 Apr 2006 12:17:10 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.385 +X-Spam-Level: * +X-Spam-Status: No, score=1.385 required=5 tests=[AWL=0.132, + RCVD_NUMERIC_HELO=1.253] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id rgDbJ67XfJmh + for ; + Thu, 20 Apr 2006 12:16:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.Mi8.com (d01gw01.mi8.com [63.240.6.47]) + by postgresql.org (Postfix) with ESMTP id 985C911F66E4 + for ; + Thu, 20 Apr 2006 12:16:57 -0300 (ADT) +Received: from 172.16.1.110 by mail.Mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D1)); Thu, 20 Apr 2006 11:16:43 -0400 +X-Server-Uuid: 241911D6-425B-44B9-A073-E3FE0F8FC774 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 20 Apr + 2006 11:16:37 -0400 +Received: from 69.181.100.71 ([69.181.100.71]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Thu, 20 Apr + 2006 15:16:36 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 20 Apr 2006 08:16:34 -0700 +Subject: Re: Quick Performance Poll +From: "Luke Lonergan" +To: "Markus Schaber" , + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] Quick Performance Poll +Thread-Index: AcZkjP+AZOTZE0eRRjCh9XsBHBqhrAAAGlqf +In-Reply-To: <4447A49D.9080707@logix-tt.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 20 Apr 2006 15:16:37.0504 (UTC) + FILETIME=[6B012000:01C6648D] +X-WSS-ID: 68597A454N02565566-13-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/455 +X-Sequence-Number: 18539 + +Markus, + +On 4/20/06 8:11 AM, "Markus Schaber" wrote: + +> Are they capable to index custom datatypes like the PostGIS geometries +> that use the GIST mechanism? This could probably speed up our Geo +> Databases for Map rendering, containing static data that is updated +> approx. 2 times per year. + +Should work fine - the other limitation is cardinality, or number of unique +values in the column being indexed. A reasonable limit is about 10,000 +unique values in the column. + +We're also going to improve this aspect of the implementation, but the +progress might take the useful limit to 300,000 or so. + +- Luke + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 12:21:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 00A0B11F65A3 + for ; + Thu, 20 Apr 2006 12:21:04 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id UzJOqQLU8c8g + for ; + Thu, 20 Apr 2006 12:20:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mta1.siol.net (mta1.siol.net [193.189.160.88]) + by postgresql.org (Postfix) with ESMTP id AD98D11F61BF + for ; + Thu, 20 Apr 2006 12:20:55 -0300 (ADT) +Received: from edge2.siol.net ([10.10.10.211]) by mta1.siol.net with ESMTP + id <20060420152053.QJJD21004.mta1.siol.net@edge2.siol.net> + for ; + Thu, 20 Apr 2006 17:20:53 +0200 +Received: from AR6 ([193.77.151.117]) by edge2.siol.net with SMTP + id <20060420152053.YSDC7870.edge2.siol.net@AR6> + for ; + Thu, 20 Apr 2006 17:20:53 +0200 +Message-ID: <011b01c6648e$067ee170$1e4ba8c0@AR6> +From: "Radovan Antloga" +To: +Subject: Performance decrease +Date: Thu, 20 Apr 2006 17:20:56 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="windows-1250"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2869 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-Archive-Number: 200604/456 +X-Sequence-Number: 18540 + +I'm new to PG and I'm testing default PG settings +for now. + +I have PG 8.1.3. installed with autovacuum=on. + +My test table has 15830 records with 190 fields. +I have different fields types (date, numeric, varchar, +integer, smallint,...). + +I decided to evaluate PG because I need to use schemas. + +First test I did is not very promising. + +I tried to update one fields in test table several times +to see how PG react on this. + +I do like this: + +update table +set field = null + +After first execute I get time 3 seconds. Then I repeat +this update. After each update time increase. I get +4 sec, 7 sec, 10 sec, 12 sec, 15 sec, 18 sec, 21 sec. + +Is this normal (default) behaviour or I must do something +to prevent this. + +Regards, +Radovan Antloga + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 12:41:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id DEBD411F8D28 + for ; + Thu, 20 Apr 2006 12:41:53 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.368 +X-Spam-Level: +X-Spam-Status: No, score=-2.368 required=5 tests=[AWL=0.233, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id wnx1I-oJ99x1 + for ; + Thu, 20 Apr 2006 12:41:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 05BE711F8D2C + for ; + Thu, 20 Apr 2006 12:41:45 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3KFffL6018974; + Thu, 20 Apr 2006 11:41:41 -0400 (EDT) +To: "Radovan Antloga" +cc: pgsql-performance@postgresql.org +Subject: Re: Performance decrease +In-reply-to: <011b01c6648e$067ee170$1e4ba8c0@AR6> +References: <011b01c6648e$067ee170$1e4ba8c0@AR6> +Comments: In-reply-to "Radovan Antloga" + message dated "Thu, 20 Apr 2006 17:20:56 +0200" +Date: Thu, 20 Apr 2006 11:41:41 -0400 +Message-ID: <18973.1145547701@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/457 +X-Sequence-Number: 18541 + +"Radovan Antloga" writes: +> My test table has 15830 records with 190 fields. + +190 fields in a table seems like rather a lot ... is that actually +representative of your intended applications? + +> I do like this: + +> update table +> set field = null + +Again, is that representative of something you'll be doing a lot in +practice? Most apps don't often update every row of a table, in my +experience. + +> After first execute I get time 3 seconds. Then I repeat +> this update. After each update time increase. I get +> 4 sec, 7 sec, 10 sec, 12 sec, 15 sec, 18 sec, 21 sec. + +There should be some increase because of the addition of dead rows, +but both the original 3 seconds and the rate of increase seem awfully +high for such a small table. What are you running this on? + +For comparison purposes, here's what I see on a full-table UPDATE +of a 10000-row table on a rather slow HP box: + +regression=# \timing +Timing is on. +regression=# create table t1 as select * from tenk1; +SELECT +Time: 1274.213 ms +regression=# update t1 set unique2 = null; +UPDATE 10000 +Time: 565.664 ms +regression=# update t1 set unique2 = null; +UPDATE 10000 +Time: 589.839 ms +regression=# update t1 set unique2 = null; +UPDATE 10000 +Time: 593.735 ms +regression=# update t1 set unique2 = null; +UPDATE 10000 +Time: 615.575 ms +regression=# update t1 set unique2 = null; +UPDATE 10000 +Time: 755.456 ms +regression=# + +Vacuuming brings the time back down: + +regression=# vacuum t1; +VACUUM +Time: 242.406 ms +regression=# update t1 set unique2 = null; +UPDATE 10000 +Time: 458.028 ms +regression=# + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 20 13:05:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6117E11F6D19 + for ; + Thu, 20 Apr 2006 13:05:18 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.09 +X-Spam-Level: +X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id C6hsgPCtmbBt + for ; + Thu, 20 Apr 2006 13:05:05 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.205]) + by postgresql.org (Postfix) with ESMTP id C8B0E11F6997 + for ; + Thu, 20 Apr 2006 13:05:05 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id z3so177772nzf + for ; + Thu, 20 Apr 2006 09:05:02 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=h5EvT+PBxkmrdQGBcCuRHAOZAlWoC31ZgCPceDJBRdTctuqcP0dH1kxqKu/z4L4LGrjhQ0SqdJtTx8yGO5fHVY4StUSaIzdcsY2zEbkuFuwBYYvmrxahVW8NHjZnWMSiVEIMXqTcc8RnnOTEx2zt2BZTj1MRBjSP2N9q+WJ82i8= +Received: by 10.65.124.5 with SMTP id b5mr439968qbn; + Thu, 20 Apr 2006 09:05:02 -0700 (PDT) +Received: by 10.65.137.8 with HTTP; Thu, 20 Apr 2006 09:05:02 -0700 (PDT) +Message-ID: +Date: Thu, 20 Apr 2006 12:05:02 -0400 +From: "Merlin Moncure" +To: "soni de" +Subject: Re: Takes too long to fetch the data from database +Cc: pgsql-performance@postgresql.org +In-Reply-To: <9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> + + <9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com> +X-Archive-Number: 200604/458 +X-Sequence-Number: 18542 + +> SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET 81900; + +you need to try and solve the problem without using 'offset'. you could do= +: +BEGIN; +DECLARE crs cursor FOR SELECT * FROM wan ORDER BY stime; +FETCH ABSOLUTE 81900 in crs; +FETCH 49 in crs; +CLOSE crs; +COMMIT; + +this may be a bit faster but will not solve the fundamental problem. + +the more interesting question is why you want to query exactly 81900 +rows into a set. This type of thinking will always get you into +trouble, absolute positioning will not really work in a true sql +sense. if you are browsing a table sequentially, there are much +better methods. + +merlin + +From pgsql-performance-owner@postgresql.org Thu Apr 20 13:10:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 595D011F6D19 + for ; + Thu, 20 Apr 2006 13:10:31 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.466 +X-Spam-Level: +X-Spam-Status: No, score=-2.466 required=5 tests=[AWL=-0.067, BAYES_00=-2.599, + DNS_FROM_RFC_ABUSE=0.2] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 10k-QPFSJ0YZ + for ; + Thu, 20 Apr 2006 13:10:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mta1.siol.net (mta1.siol.net [193.189.160.88]) + by postgresql.org (Postfix) with ESMTP id A448A11F6709 + for ; + Thu, 20 Apr 2006 13:10:20 -0300 (ADT) +Received: from edge2.siol.net ([10.10.10.211]) by mta1.siol.net with ESMTP + id <20060420161019.TCJB21004.mta1.siol.net@edge2.siol.net>; + Thu, 20 Apr 2006 18:10:19 +0200 +Received: from AR6 ([193.77.151.117]) by edge2.siol.net with SMTP + id <20060420161019.ZNPA7870.edge2.siol.net@AR6>; + Thu, 20 Apr 2006 18:10:19 +0200 +Message-ID: <015801c66494$ee3d25c0$1e4ba8c0@AR6> +From: "Radovan Antloga" +To: "Tom Lane" +Cc: +References: <011b01c6648e$067ee170$1e4ba8c0@AR6> + <18973.1145547701@sss.pgh.pa.us> +Subject: Re: Performance decrease +Date: Thu, 20 Apr 2006 18:10:21 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="windows-1250"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2869 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-Archive-Number: 200604/459 +X-Sequence-Number: 18543 + +>190 fields in a table seems like rather a lot ... is that actually +>representative of your intended applications? + +Test table is like table I use in production +with Firebird and Oracle db. Table has a lot of smallint +and integer fields. As you can see I have Firebird for +low cost projects (small companies) and Oracle medium +or large project. + +>Again, is that representative of something you'll be doing a lot in +>practice? Most apps don't often update every row of a table, in my +>experience. + +I agree with you ! +I have once or twice a month update on many records (~6000) but +not so many. I did not expect PG would have problems with +updating 15800 records. + +My test was on Windows XP SP2. +I have AMD 64 2.1 GHz cpu with +1GB ram. + +Regards, +Radovan Antloga + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 13:27:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id A9E0911F8D3C + for ; + Thu, 20 Apr 2006 13:27:39 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.406 +X-Spam-Level: +X-Spam-Status: No, score=-2.406 required=5 tests=[AWL=0.193, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 50yPnF-qIS9w + for ; + Thu, 20 Apr 2006 13:27:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 9C56B11F8D39 + for ; + Thu, 20 Apr 2006 13:27:34 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 708A656423; Thu, 20 Apr 2006 11:27:33 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 20 Apr 2006 11:27:32 -0500 +Date: Thu, 20 Apr 2006 11:27:32 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Mark Kirkwood , + Markus Schaber , pgsql-performance@postgresql.org +Subject: Re: merge>hash>loop +Message-ID: <20060420162732.GX49405@pervasive.com> +References: <1145029009.3422.31.camel@spectre.intellivid.com> + <10000.1145031205@sss.pgh.pa.us> + <1145033149.3422.41.camel@spectre.intellivid.com> + <11035.1145033929@sss.pgh.pa.us> <4444C4CF.2000106@logix-tt.com> + <20060418215238.GK49405@pervasive.com> + <19388.1145398946@sss.pgh.pa.us> + <20060418231552.GN49405@pervasive.com> + <4445C0EC.2060407@paradise.net.nz> <22250.1145424328@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <22250.1145424328@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060420:tgl@sss.pgh.pa.us::SJGoPJ6sKgO6tDNb:00000000000000000000 + 0000000000000000000000000rHI +X-Hashcash: + 1:20:060420:markir@paradise.net.nz::NmwQ3L4yVpZVjFMX:000000000000000 + 00000000000000000000000006dy +X-Hashcash: + 1:20:060420:schabi@logix-tt.com::dJS7wqgizaYEbrW1:000000000000000000 + 0000000000000000000000000Jaw +X-Hashcash: + 1:20:060420:pgsql-performance@postgresql.org::yX22HI0Rqo55/RHa:00000 + 0000000000000000000000004Zt1 +X-Archive-Number: 200604/460 +X-Sequence-Number: 18544 + +On Wed, Apr 19, 2006 at 01:25:28AM -0400, Tom Lane wrote: +> Mark Kirkwood writes: +> > Jim C. Nasby wrote: +> >> Good point. :/ I'm guessing there's no easy way to see how many blocks +> >> for a given relation are in shared memory, either... +> +> > contrib/pg_buffercache will tell you this - +> +> I think the key word in Jim's comment was "easy", ie, cheap. Grovelling +> through many thousands of buffers to count the matches to a given +> relation doesn't sound appetizing, especially not if it gets done over +> again several times during each query-planning cycle. Trying to keep +> centralized counts somewhere would be even worse (because of locking/ +> contention issues). + +Very true. OTOH, it might not be unreasonable to periodically slog +through the buffers and store that information, perhaps once a minute, +or every X number of transactions. + +I think a bigger issue is that we currently have no way to really +measure the effictiveness of the planner. Without that it's impossible +to come up with any real data on whether cost formula A is better or +worse than cost formula B. The only means I can think of for doing this +would be to measure estimated cost vs actual cost, but with the overhead +of EXPLAIN ANALYZE and other variables that might not prove terribly +practical. Maybe someone else has some ideas... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 25 02:27:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3848511F7BBA + for ; + Thu, 20 Apr 2006 14:21:26 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id v3UqCLbwe4tf + for ; + Thu, 20 Apr 2006 14:21:12 -0300 (ADT) +X-Greylist: delayed 00:32:34.326235 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id DCB9311F6D5A + for ; + Thu, 20 Apr 2006 14:21:10 -0300 (ADT) +Received: from mx.sat.rackspace.com (mx.sat.rackspace.com [64.39.1.214]) + by svr4.postgresql.org (Postfix) with ESMTP id 1D1945AF058 + for ; + Thu, 20 Apr 2006 16:48:36 +0000 (GMT) +Received: from mail.rackspace.com (mail.rackspace.com [64.39.2.181]) + by mx.sat.rackspace.com (8.13.6/8.13.6) with ESMTP id k3KGmXUg023264 + for ; Thu, 20 Apr 2006 11:48:34 -0500 + (envelope-from wreese@rackspace.com) +Received: from [10.6.104.60] (office104-60.sat4.rackspace.com [10.6.104.60]) + (authenticated bits=0) + by mail.rackspace.com (8.13.1/8.13.1) with ESMTP id k3KGmXkN010637 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) + for ; Thu, 20 Apr 2006 11:48:33 -0500 +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Transfer-Encoding: 7bit +Message-Id: <9EAB2F2F-0BC2-4685-96A1-A29D7872D068@rackspace.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Will Reese +Subject: Slow deletes in 8.1 when FKs are involved +Date: Thu, 20 Apr 2006 11:48:36 -0500 +X-Mailer: Apple Mail (2.749.3) +X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CP_URI_IN_BODY 0, + __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, + __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, + __SANE_MSGID 0, __STOCK_PHRASE_7 0' +X-Archive-Number: 200604/537 +X-Sequence-Number: 18621 + +I'm preparing for an upgrade from PostgreSQL 7.4.5 to 8.1.3, and I +noticed a potential performance issue. + +I have two servers, a dual proc Dell with raid 5 running PostgreSQL +7.4, and a quad proc Dell with a storage array running PostgreSQL +8.1. Both servers have identical postgresql.conf settings and were +restored from the same 7.4 backup. Almost everything is faster on the +8.1 server (mostly due to hardware), except one thing...deletes from +tables with foreign keys. + +I have table A with around 100,000 rows, that has foreign keys to +around 50 other tables. Some of these other tables (table B, for +example) have around 10 million rows. + +On the 7.4 server, I can delete a single row from a table A in well +under a second (as expected). On the 8.1 server, it takes over a +minute to delete. I tried all the usual stuff, recreating indexes, +vacuum analyzing, explain analyze. Everything is identical between +the systems. If I hit ctrl-c while the delete was running on 8.1, I +repeatedly got the following message... + +db=# delete from "A" where "ID" in ('6'); +Cancel request sent +ERROR: canceling statement due to user request +CONTEXT: SQL statement "SELECT 1 FROM ONLY "public"."B" x WHERE +"A_ID" = $1 FOR SHARE OF x" + +It looks to me like the "SELECT ... FOR SHARE" functionality in 8.1 +is the culprit. Has anyone else run into this issue? + + +Will Reese -- http://blog.rezra.com + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 13:50:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 326AE11F8D03 + for ; + Thu, 20 Apr 2006 13:50:18 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.41 +X-Spam-Level: +X-Spam-Status: No, score=-2.41 required=5 tests=[AWL=0.189, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id j9RhFVdC3DhQ + for ; + Thu, 20 Apr 2006 13:50:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 1078811F6C36 + for ; + Thu, 20 Apr 2006 13:50:04 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 015F656423; Thu, 20 Apr 2006 11:50:03 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 20 Apr 2006 11:50:02 -0500 +Date: Thu, 20 Apr 2006 11:50:02 -0500 +From: "Jim C. Nasby" +To: Mario Splivalo +Cc: Pgsql performance +Subject: Re: SELECT FOR UPDATE performance is bad +Message-ID: <20060420165002.GY49405@pervasive.com> +References: <1145365720.18469.35.camel@localhost.localdomain> + <13037.1145370658@sss.pgh.pa.us> + <1145371662.31555.10.camel@localhost.localdomain> + <13609.1145374386@sss.pgh.pa.us> + <1145434854.4458.12.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1145434854.4458.12.camel@localhost.localdomain> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060420:mario.splivalo@mobart.hr::mJRdkamWiSDDmQPz:0000000000000 + 00000000000000000000000032ZC +X-Hashcash: + 1:20:060420:pgsql-performance@postgresql.org::MNo/pupjhINAZ8cV:00000 + 0000000000000000000000001uRS +X-Archive-Number: 200604/461 +X-Sequence-Number: 18545 + +On Wed, Apr 19, 2006 at 10:20:54AM +0200, Mario Splivalo wrote: +> This works perfectly, but sometimes the game has no codes, and I still +> need to know exactley who came first, who was second, and so on... So a +> locking table as Tom suggested is, I guess, a perfect solution for my +> situation... + +Depending on your performance requirements, you should look at +contrib/userlock as well, since it will probably be much more performant +than locking a row in a table. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Apr 20 13:55:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id E7C0311F7D73 + for ; + Thu, 20 Apr 2006 13:55:39 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.419 +X-Spam-Level: +X-Spam-Status: No, score=-2.419 required=5 tests=[AWL=0.180, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id nA8vMERbE3wP + for ; + Thu, 20 Apr 2006 13:55:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 591E711F7C17 + for ; + Thu, 20 Apr 2006 13:55:34 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id C995356423; Thu, 20 Apr 2006 11:55:33 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 20 Apr 2006 11:55:32 -0500 +Date: Thu, 20 Apr 2006 11:55:32 -0500 +From: "Jim C. Nasby" +To: Jim Buttafuoco +Cc: Simon Dale , pgsql-performance@postgresql.org +Subject: Re: Quick Performance Poll +Message-ID: <20060420165532.GZ49405@pervasive.com> +References: + <416F947BF5BA9E40B5F9AA649422212E0756199C@ex-mail2.internal.rmplc.net> + <20060420133326.M88248@contactbda.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060420133326.M88248@contactbda.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060420:jim@contactbda.com::lyRzdp5Y9AFkAN4F:0000000000000000000 + 000000000000000000000000AY8G +X-Hashcash: 1:20:060420:sdale@rm.com::ApOz0wAlHhGBpQff:000000QlB +X-Hashcash: + 1:20:060420:pgsql-performance@postgresql.org::SRRJbhFZC+8NgSU1:00000 + 0000000000000000000000000KQD +X-Archive-Number: 200604/462 +X-Sequence-Number: 18546 + +Interested in doing a case study for the website? + +On Thu, Apr 20, 2006 at 09:36:25AM -0400, Jim Buttafuoco wrote: +> +> Simon, +> +> I have many databases over 1T with the largest being ~6T. All of my databases store telecom data, such as call detail +> records. The access is very fast when looking for a small subset of the data. For servers, I am using white box intel +> XEON and P4 systems with SATA disks, 4G of memory. SCSI is out of our price range, but if I had unlimited $ I would go +> with SCSI /SCSI raid instead. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Apr 20 14:00:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 212EE11F60AA + for ; + Thu, 20 Apr 2006 14:00:19 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.297 +X-Spam-Level: +X-Spam-Status: No, score=0.297 required=5 tests=[AWL=0.297] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 2rnrRS04HOkX + for ; + Thu, 20 Apr 2006 14:00:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 9573011F6224 + for ; + Thu, 20 Apr 2006 14:00:09 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id F25A056423; Thu, 20 Apr 2006 12:00:08 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 20 Apr 2006 12:00:07 -0500 +Date: Thu, 20 Apr 2006 12:00:07 -0500 +From: "Jim C. Nasby" +To: Radovan Antloga +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Performance decrease +Message-ID: <20060420170007.GA49405@pervasive.com> +References: <011b01c6648e$067ee170$1e4ba8c0@AR6> + <18973.1145547701@sss.pgh.pa.us> + <015801c66494$ee3d25c0$1e4ba8c0@AR6> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <015801c66494$ee3d25c0$1e4ba8c0@AR6> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060420:radovan.antloga@siol.net::6CFZ9w+qtQker2rJ:0000000000000 + 0000000000000000000000008VRx +X-Hashcash: + 1:20:060420:tgl@sss.pgh.pa.us::aheoylP2kiyNYiAg:00000000000000000000 + 0000000000000000000000006Di5 +X-Hashcash: + 1:20:060420:pgsql-performance@postgresql.org::IRdFs1jDYMU0IXS6:00000 + 0000000000000000000000000pXR +X-Archive-Number: 200604/463 +X-Sequence-Number: 18547 + +On Thu, Apr 20, 2006 at 06:10:21PM +0200, Radovan Antloga wrote: +> I have once or twice a month update on many records (~6000) but +> not so many. I did not expect PG would have problems with +> updating 15800 records. + +And generally speaking, it doesn't. But you do need to ensure that +you're vacuuming the database frequently enough. Autovacuum is a good +way to do that. + +> My test was on Windows XP SP2. +> I have AMD 64 2.1 GHz cpu with +> 1GB ram. + +One think to keep in mind is that the windows code is rather new, so it +is possible to find some performance issues there. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Apr 20 14:59:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 2EE8411F7825 + for ; + Thu, 20 Apr 2006 14:59:35 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.08 +X-Spam-Level: +X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id TxQ-v4k4xo4P + for ; + Thu, 20 Apr 2006 14:59:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.wirelesscar.com (mail.wirelesscar.com [212.209.35.30]) + by postgresql.org (Postfix) with ESMTP id 70B8D11F6756 + for ; + Thu, 20 Apr 2006 14:59:22 -0300 (ADT) +Received: from sesrv12.wirelesscar.com ([192.168.10.17]) by + mail.wirelesscar.com with InterScan Messaging Security Suite; + Thu, 20 Apr 2006 19:59:19 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Subject: Hardware: HP StorageWorks MSA 1500 +Content-Transfer-Encoding: quoted-printable +Date: Thu, 20 Apr 2006 20:00:03 +0200 +Message-ID: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3F4C@sesrv12.wirelesscar.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Hardware: HP StorageWorks MSA 1500 +Thread-Index: AcZkpD1m+JXlayWvQnWftyu5guA1aw== +From: "Mikael Carneholm" +To: "Pgsql performance" +X-Archive-Number: 200604/464 +X-Sequence-Number: 18548 + +We're going to get one for evaluation next week (equipped with dual +2Gbit HBA:s and 2x14 disks, iirc). Anyone with experience from them, +performance wise? + +Regards, +Mikael + +From pgsql-performance-owner@postgresql.org Thu Apr 20 15:43:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A1B9A11F653C + for ; + Thu, 20 Apr 2006 15:43:27 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.24 +X-Spam-Level: +X-Spam-Status: No, score=0.24 required=5 tests=[AWL=0.239, + UNPARSEABLE_RELAY=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 0WfKcrXUJ6O6 + for ; + Thu, 20 Apr 2006 15:43:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id 3587411F6538 + for ; + Thu, 20 Apr 2006 15:43:22 -0300 (ADT) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 20 Apr 2006 11:43:20 -0700 +Subject: Re: Hardware: HP StorageWorks MSA 1500 +From: Mark Lewis +To: Mikael Carneholm +Cc: Pgsql performance +In-Reply-To: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3F4C@sesrv12.wirelesscar.com> +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3F4C@sesrv12.wirelesscar.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Thu, 20 Apr 2006 11:43:20 -0700 +Message-Id: <1145558600.29754.152.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-22) +X-Archive-Number: 200604/465 +X-Sequence-Number: 18549 + +Hmmm. We use an MSA 1000 with Fibre Channel interconnects. No real +complaints, although I was a little bit disappointed by the RAID +controller's battery-backed write cache performance; tiny random writes +are only about 3 times as fast with write caching enabled as with it +disabled, I had (perhaps naively) hoped for more. Sequential scans from +our main DB (on a 5-pair RAID 10 set with 15k RPM drives) get roughly +80MB/sec. + +Getting the redundant RAID controllers to fail over correctly on Linux +was a big headache and required working the tech support phone all day +until we finally got to the deep guru who knew the proper undocumented +incantations. + +-- Mark Lewis + +On Thu, 2006-04-20 at 20:00 +0200, Mikael Carneholm wrote: +> We're going to get one for evaluation next week (equipped with dual +> 2Gbit HBA:s and 2x14 disks, iirc). Anyone with experience from them, +> performance wise? +> +> Regards, +> Mikael +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly + +From pgsql-performance-owner@postgresql.org Thu Apr 20 16:30:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 771E311F6786 + for ; + Thu, 20 Apr 2006 16:30:18 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id I7Tke9WXPvzb + for ; + Thu, 20 Apr 2006 16:29:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 2B30B11F6709 + for ; + Thu, 20 Apr 2006 16:29:52 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)) + for pgsql-performance@postgresql.org; Thu, 20 Apr 2006 13:29:50 -0600 +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Transfer-Encoding: 7bit +Message-Id: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: PostgreSQL Performance +From: Brendan Duddridge +Subject: Recovery will take 10 hours +Date: Thu, 20 Apr 2006 13:29:46 -0600 +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/466 +X-Sequence-Number: 18550 + +Hi, + +We had a database issue today that caused us to have to restore to +our most recent backup. We are using PITR so we have 3120 WAL files +that need to be applied to the database. + +After 45 minutes, it has restored only 230 WAL files. At this rate, +it's going to take about 10 hours to restore our database. + +Most of the time, the server is not using very much CPU time or I/O +time. So I'm wondering what can be done to speed up the process? + +The database is about 20 GB. The WAL files are compressed with gzip +to about 4 MB. Expanded, the WAL files would take 48 GB. + +We are using PostgreSQL 8.1.3 on OS X Server 10.4.6 connected to an +XServe RAID. The pg_xlog is on its own separate RAID and so are the +table spaces. + +Here's a representative sample of doing iostat: + +hulk1:/Library/PostgreSQL admin$ iostat 5 + disk1 disk2 disk0 cpu + KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us sy id +19.31 101 1.91 14.39 51 0.71 37.37 4 0.13 15 10 76 + 8.00 21 0.16 0.00 0 0.00 90.22 2 0.16 0 2 98 + 8.00 32 0.25 0.00 0 0.00 0.00 0 0.00 0 1 98 + 8.00 76 0.60 0.00 0 0.00 0.00 0 0.00 0 1 99 + 8.00 587 4.59 1024.00 4 4.00 0.00 0 0.00 4 7 88 + 8.00 675 5.27 956.27 6 5.60 0.00 0 0.00 6 6 88 +11.32 1705 18.84 5.70 1 0.01 16.36 7 0.12 1 6 93 + 8.00 79 0.62 1024.00 3 3.20 0.00 0 0.00 2 2 96 + 8.00 68 0.53 0.00 0 0.00 0.00 0 0.00 0 2 98 + 8.00 76 0.59 0.00 0 0.00 0.00 0 0.00 0 1 99 + 8.02 89 0.69 0.00 0 0.00 0.00 0 0.00 1 1 98 + 8.00 572 4.47 911.11 4 3.20 0.00 0 0.00 5 5 91 +13.53 1227 16.21 781.55 4 3.21 12.14 2 0.03 3 6 90 + 8.00 54 0.42 0.00 0 0.00 90.22 2 0.16 1 1 98 + 8.00 68 0.53 0.00 0 0.00 0.00 0 0.00 0 1 99 + 8.00 461 3.60 1024.00 3 3.20 0.00 0 0.00 3 6 91 + 8.00 671 5.24 964.24 7 6.40 0.00 0 0.00 6 8 86 + 7.99 248 1.94 0.00 0 0.00 0.00 0 0.00 1 3 96 +15.06 1050 15.44 911.11 4 3.20 12.12 3 0.03 2 5 93 +19.84 176 3.41 5.70 1 0.01 0.00 0 0.00 0 1 99 + + +disk1 is the RAID volume that has the table spaces on it. disk2 is +the pg_xlog and disk0 is the boot disk. + +So you can see the CPU is idle much of the time and the IO only +occurs in short bursts. Each line in the iostat results is 5 seconds +apart. + +If there were something we could do to speed up the process, would it +be possible to kill the postgres process, tweak some parameter +somewhere and then start it up again? Or would we have to restore our +base backup again and start over? + +How can I make this go faster? + + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 16:43:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 81EFC11F6285 + for ; + Thu, 20 Apr 2006 16:43:11 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 5XNImnwbrBQi + for ; + Thu, 20 Apr 2006 16:43:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 2A36B11F6266 + for ; + Thu, 20 Apr 2006 16:43:01 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 03A2EB80A + for ; + Thu, 20 Apr 2006 15:43:01 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: +References: + <443DA715.4060606@gmail.com> <9549.1144903344@sss.pgh.pa.us> + +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <59B70FCB-9AA5-4E46-ABFC-130D13F900CB@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Inserts optimization? +Date: Thu, 20 Apr 2006 15:43:00 -0400 +To: Pgsql performance +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/467 +X-Sequence-Number: 18551 + + +On Apr 13, 2006, at 2:59 PM, Francisco Reyes wrote: + +> This particular server is pretty much what I inherited for now for +> this project.and its Raid 5. There is a new server I am setting up +> soon... 8 disks which we are planning to setup +> 6 disks in RAID 10 +> 2 Hot spares +> +> In RAID 10 would it matter that WALL is in the same RAID set? +> Would it be better: +> 4 disks in RAID10 Data +> 2 disks RAID 1 WALL +> 2 hot spares + +why do you need two hot spares? + +I'd go with 6 disk RAID10 for data +2 disk RAID1 for WAL (and OS if you don't have other disks from which +to boot) + +and run nothing else but Postgres on that box. + +bump up checkpoint_segments to some huge number like 256 and use the +bg writer process. + +if a disk fails, just replace it quickly with a cold spare. + +and if your RAID controller has two channels, pair the mirrors across +channels. + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 16:45:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id CACAC11F628F + for ; + Thu, 20 Apr 2006 16:45:22 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.465 +X-Spam-Level: +X-Spam-Status: No, score=-2.465 required=5 tests=[BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id n+n6z1PBXUWv + for ; + Thu, 20 Apr 2006 16:45:14 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) + by postgresql.org (Postfix) with SMTP id 634FB11F6279 + for ; + Thu, 20 Apr 2006 16:45:11 -0300 (ADT) +Received: (qmail invoked by alias); 20 Apr 2006 19:45:10 -0000 +Received: from dslb-084-057-005-138.pools.arcor-ip.net (EHLO ltmku) + [84.57.5.138] + by mail.gmx.net (mp038) with SMTP; 20 Apr 2006 21:45:10 +0200 +X-Authenticated: #23352258 +From: "Milen Kulev" +To: "'Luke Lonergan'" +Cc: +Subject: Re: Quick Performance Poll +Date: Thu, 20 Apr 2006 21:45:09 +0200 +Message-ID: <000001c664b2$eef4ba50$0a00a8c0@trivadis.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +Importance: Normal +In-Reply-To: +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Y-GMX-Trusted: 0 +X-Archive-Number: 200604/469 +X-Sequence-Number: 18553 + +Hi Luke, +I (still) haven't tried Bizgres, but what do you mean with "The current drawback to bitmap index is that it isn't very +maintainable under insert/update, although it is safe for those operations"? + +Do you mean that INSERT/UPDATE operations against bitmap indexes are imperformant ? +If yes, to what extend ? + +Or you mean that bitmap index corruption is possible when issueing DML againts BMP indexes? +Or BMP indexes are growing too fast as a result of DML ? + +I am asking this question because Oracle needed 3 years to solve its BMP index problems (BMP index corruption/ space +usage explosion when several processes are performing DML operations ). + +Is Bizgres implementation suffering from this kind child deseases ? + +Regards . Milen + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Luke Lonergan +Sent: Thursday, April 20, 2006 5:03 PM +To: jim@contactbda.com; Simon Dale; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Quick Performance Poll + + +Jim, + +On 4/20/06 7:40 AM, "Jim Buttafuoco" wrote: + +> First of all this is NOT a single table and yes I am using +> partitioning and the constaint exclusion stuff. the largest set of +> tables is over 2T. I have not had to rebuild the biggest database +> yet, but for a smaller one ~1T the restore takes about 12 hours +> including many indexes on both large and small tables + +You would probably benefit greatly from the new on-disk bitmap index feature in Bizgres Open Source. It's 8.1 plus the +sort speed improvement and on-disk bitmap index. + +Index creation and sizes for the binary version are in the table below (from a performance report on bizgres network. +The version in CVS tip on pgfoundry is much faster on index creation as well. + +The current drawback to bitmap index is that it isn't very maintainable under insert/update, although it is safe for +those operations. For now, you have to drop index, do inserts/updates, rebuild index. + +We'll have a version that is maintained for insert/update next. + +- Luke + + # Indexed Columns Create Time (seconds) Space Used (MBs) + BITMAP BTREE BITMAP BTREE + 1 L_SHIPMODE 454.8 2217.1 58 1804 + 2 L_QUANTITY 547.2 937.8 117 1804 + 3 L_LINENUMBER 374.5 412.4 59 1285 + 4 L_SHIPMODE, L_QUANTITY 948.7 2933.4 176 2845 + 5 O_ORDERSTATUS 83.5 241.3 5 321 + 6 O_ORDERPRIORITY 108.5 679.1 11 580 + 7 C_MKTSEGMENT 10.9 51.3 1 45 + 8 C_NATIONKEY 8.3 9.3 2 32 + + + +---------------------------(end of broadcast)--------------------------- +TIP 9: In versions below 8.0, the planner will ignore your desire to + choose an index scan if your joining column's datatypes do not + match + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 16:45:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 7F5D411F6289 + for ; + Thu, 20 Apr 2006 16:45:22 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.109 +X-Spam-Level: +X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id XdIGsf14153A + for ; + Thu, 20 Apr 2006 16:45:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 1A1E311F627C + for ; + Thu, 20 Apr 2006 16:45:14 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id E47F1B80C + for ; + Thu, 20 Apr 2006 15:45:14 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <200604141400.38982.mcousin@sigma.fr> +References: + <200604141400.38982.mcousin@sigma.fr> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <4A92D044-F4C3-4B7B-B25A-E09575E66984@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Inserts optimization? +Date: Thu, 20 Apr 2006 15:45:14 -0400 +To: Pgsql performance +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/468 +X-Sequence-Number: 18552 + + +On Apr 14, 2006, at 8:00 AM, Marc Cousin wrote: + +> So, you'll probably end up being slowed down by WAL fsyncs ... and +> you won't +> have a lot of solutions. Maybe you should start with trying to set +> fsync=no +> as a test to confirm that (you should have a lot of iowaits right +> now if you +> haven't disabled fsync). + +Instead of doing that, why not use commit_delay to some nominal value +to try and group the fsyncs. If they're coming in at 30 per second, +this should help a bit, I suspect. + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 17:17:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id A2B0E11F6770 + for ; + Thu, 20 Apr 2006 17:17:09 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.123 +X-Spam-Level: +X-Spam-Status: No, score=0.123 required=5 tests=[AWL=0.123] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id XRvgDnAeeMrI + for ; + Thu, 20 Apr 2006 17:17:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id C332411F66DC + for ; + Thu, 20 Apr 2006 17:17:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3KKH0k7029440; + Thu, 20 Apr 2006 16:17:01 -0400 (EDT) +To: Brendan Duddridge +cc: PostgreSQL Performance +Subject: Re: Recovery will take 10 hours +In-reply-to: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> +Comments: In-reply-to Brendan Duddridge + message dated "Thu, 20 Apr 2006 13:29:46 -0600" +Date: Thu, 20 Apr 2006 16:17:00 -0400 +Message-ID: <29439.1145564220@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/470 +X-Sequence-Number: 18554 + +Brendan Duddridge writes: +> We had a database issue today that caused us to have to restore to +> our most recent backup. We are using PITR so we have 3120 WAL files +> that need to be applied to the database. +> After 45 minutes, it has restored only 230 WAL files. At this rate, +> it's going to take about 10 hours to restore our database. +> Most of the time, the server is not using very much CPU time or I/O +> time. So I'm wondering what can be done to speed up the process? + +That seems a bit odd --- should be eating one or the other, one would +think. Try strace'ing the recovery process to see what it's doing. + +> If there were something we could do to speed up the process, would it +> be possible to kill the postgres process, tweak some parameter +> somewhere and then start it up again? Or would we have to restore our +> base backup again and start over? + +You could start it up again, but it'd want to read through all the WAL +it's already looked at, so I'd not recommend this until/unless you're +pretty sure you've fixed the performance issue. Right at the moment, +I think this is a golden opportunity to study the performance of WAL +recovery --- it's not something we've tried to optimize particularly. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 20 18:13:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1A53111F6254 + for ; + Thu, 20 Apr 2006 18:13:51 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.06 +X-Spam-Level: +X-Spam-Status: No, score=0.06 required=5 tests=[AWL=0.060] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id vWR0Qy2Syt4P + for ; + Thu, 20 Apr 2006 18:13:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 10B6B11F628F + for ; + Thu, 20 Apr 2006 18:13:36 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Thu, 20 Apr 2006 15:13:35 -0600 +In-Reply-To: <29439.1145564220@sss.pgh.pa.us> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <29439.1145564220@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <47C1F053-EC91-4AEB-9F0B-B538716145D6@clickspace.com> +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Recovery will take 10 hours +Date: Thu, 20 Apr 2006 15:13:31 -0600 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/471 +X-Sequence-Number: 18555 + +Hi Tom, + +Do you mean do a kill -QUIT on the postgres process in order to +generate a stack trace? + +Will that affect the currently running process in any bad way? And +where would the output go? stdout? + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 20, 2006, at 2:17 PM, Tom Lane wrote: + +> Brendan Duddridge writes: +>> We had a database issue today that caused us to have to restore to +>> our most recent backup. We are using PITR so we have 3120 WAL files +>> that need to be applied to the database. +>> After 45 minutes, it has restored only 230 WAL files. At this rate, +>> it's going to take about 10 hours to restore our database. +>> Most of the time, the server is not using very much CPU time or I/O +>> time. So I'm wondering what can be done to speed up the process? +> +> That seems a bit odd --- should be eating one or the other, one would +> think. Try strace'ing the recovery process to see what it's doing. +> +>> If there were something we could do to speed up the process, would it +>> be possible to kill the postgres process, tweak some parameter +>> somewhere and then start it up again? Or would we have to restore our +>> base backup again and start over? +> +> You could start it up again, but it'd want to read through all the WAL +> it's already looked at, so I'd not recommend this until/unless you're +> pretty sure you've fixed the performance issue. Right at the moment, +> I think this is a golden opportunity to study the performance of WAL +> recovery --- it's not something we've tried to optimize particularly. +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 18:47:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 1E66311F675E + for ; + Thu, 20 Apr 2006 18:47:54 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id o4fy-1ouj7fv + for ; + Thu, 20 Apr 2006 18:47:46 -0300 (ADT) +X-Greylist: delayed 00:28:00.480377 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id AB7C011F6748 + for ; + Thu, 20 Apr 2006 18:47:46 -0300 (ADT) +Received: from glacier.frostconsultingllc.com (glacier.frostconsultingllc.com + [64.127.99.90]) + by svr4.postgresql.org (Postfix) with ESMTP id 260685AF945 + for ; + Thu, 20 Apr 2006 21:19:46 +0000 (GMT) +Received: from localhost ([127.0.0.1]:34744) + by glacier.frostconsultingllc.com with esmtp (Exim 4.61) + (envelope-from ) + id 1FWgYx-0000dh-1T; Thu, 20 Apr 2006 14:19:43 -0700 +Date: Thu, 20 Apr 2006 14:19:43 -0700 (PDT) +From: Jeff Frost +To: Brendan Duddridge +Cc: PostgreSQL Performance +Subject: Re: Recovery will take 10 hours +In-Reply-To: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> +Message-ID: +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-SA-Exim-Connect-IP: 127.0.0.1 +X-SA-Exim-Mail-From: jeff@frostconsultingllc.com +X-SA-Exim-Scanned: No (on glacier.frostconsultingllc.com); + SAEximRunCond expanded to false +X-Archive-Number: 200604/476 +X-Sequence-Number: 18560 + +On Thu, 20 Apr 2006, Brendan Duddridge wrote: + +> Hi, +> +> We had a database issue today that caused us to have to restore to our most +> recent backup. We are using PITR so we have 3120 WAL files that need to be +> applied to the database. +> +> After 45 minutes, it has restored only 230 WAL files. At this rate, it's +> going to take about 10 hours to restore our database. +> +> Most of the time, the server is not using very much CPU time or I/O time. So +> I'm wondering what can be done to speed up the process? + +Brendan, + +Where are the WAL files being stored and how are they being read back? + +-- +Jeff Frost, Owner +Frost Consulting, LLC http://www.frostconsultingllc.com/ +Phone: 650-780-7908 FAX: 650-649-1954 + +From pgsql-performance-owner@postgresql.org Thu Apr 20 18:19:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id B23F011F6262 + for ; + Thu, 20 Apr 2006 18:19:57 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.549 +X-Spam-Level: +X-Spam-Status: No, score=-2.549 required=5 tests=[AWL=0.050, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id UtvKZMbRo0Wt + for ; + Thu, 20 Apr 2006 18:19:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.pharmaline.de (mail.pharmaline.de [62.153.135.34]) + by postgresql.org (Postfix) with ESMTP id C659611F663B + for ; + Thu, 20 Apr 2006 18:19:46 -0300 (ADT) +Received: from [192.168.0.5] (84.60.144.20) by mail.pharmaline.de with + ESMTP (Eudora Internet Mail Server 3.2.7); + Thu, 20 Apr 2006 23:19:45 +0200 +In-Reply-To: <015801c66494$ee3d25c0$1e4ba8c0@AR6> +References: <011b01c6648e$067ee170$1e4ba8c0@AR6> + <18973.1145547701@sss.pgh.pa.us> + <015801c66494$ee3d25c0$1e4ba8c0@AR6> +Mime-Version: 1.0 (Apple Message framework v749.3) +X-Priority: 3 +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-9--242939701; + protocol="application/pkcs7-signature" +Message-Id: +Cc: pgsql-performance@postgresql.org +From: Guido Neitzer +Subject: Re: Performance decrease +Date: Thu, 20 Apr 2006 23:19:44 +0200 +To: Radovan Antloga +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/472 +X-Sequence-Number: 18556 + + +--Apple-Mail-9--242939701 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +On 20.04.2006, at 18:10 Uhr, Radovan Antloga wrote: + +> I have once or twice a month update on many records (~6000) but +> not so many. I did not expect PG would have problems with +> updating 15800 records. + +It has no problems with that. We have a database where we often +update/insert rows with about one hundred columns. No problem so far. +Performance is in the sub 10ms range. The whole table has about +100000 records. + +Do you wrap every update in a separate transaction? I do commits +every 200 updates for bulk updates. + +cug + +-- +PharmaLine, Essen, GERMANY +Software and Database Development + + + +--Apple-Mail-9--242939701 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGNzCCAvAw +ggJZoAMCAQICEB7tpxCHG7VYey3bP/Ou4e8wDQYJKoZIhvcNAQEEBQAwYjELMAkGA1UEBhMCWkEx +JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ +ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA2MDIxMTE3NDM1NFoXDTA3MDIxMTE3NDM1 +NFowTTEfMB0GA1UEAxMWVGhhd3RlIEZyZWVtYWlsIE1lbWJlcjEqMCgGCSqGSIb3DQEJARYbZ3Vp +ZG8ubmVpdHplckBwaGFybWFsaW5lLmRlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA +yLhNUnNv30/r+pFUHocoIWGm8AAwFbwAWqFRhEwZzxLPCMSZme3G7W/5hyK+SxeQoOK8PPCsNyvy +sLBqUVHB3nm5w/NzZKk1gfc2QlzjPtv2C7bUnigDJs+X0YlgdxTxs68RdHBn/rbjjaxl+SkiEcsz +kZhKsAnS6zhlWSX7zDCIRR5VD08M0/fYSTwEcX1j8lWb/3McY7bCcHbLd+762QQAn03A4cPco4OK +3KAMld0n6qFFMG23IKx7qDTonYtCzsDVspQ1Fk14yJYVdf62RLWGBJPF+RMXB9juFhgdUrHZY3mo +wamFF3qZ8HD9wb+G7lhL8F+d5khDuLBYFXCqdQIDAQABozgwNjAmBgNVHREEHzAdgRtndWlkby5u +ZWl0emVyQHBoYXJtYWxpbmUuZGUwDAYDVR0TAQH/BAIwADANBgkqhkiG9w0BAQQFAAOBgQCFnjZk +bGIY3sGlsEIn98cV+tX9xNTThIwN6jhu7mGuxzvX+hN86kdlhEgaPmaatH8KfXXyfnhpTK3KOk8O +zDsxJqQDVe1HEW8M/4MkORMlydbcxSRPL967pgMRNjAMafL/IlssFJ3kF7q/2AjRd4VhnyoA3Yl/ +sXF3WLOTJB5OzjCCAz8wggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpB +MRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhh +d3RlIENvbnN1bHRpbmcxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24x +JDAiBgNVBAMTG1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVy +c29uYWwtZnJlZW1haWxAdGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTla +MGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSww +KgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0B +AQEFAAOBjQAwgYkCgYEAxKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B +1OVQCjDXAmNaLIkVcI7dyfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk +16emu59l0cUqVIUPSAR/p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/ +AgEAMEMGA1UdHwQ8MDowOKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25h +bEZyZWVtYWlsQ0EuY3JsMAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJp +dmF0ZUxhYmVsMi0xMzgwDQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOW +lJ1/TCG4+DYfqi2fNi/A9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amc +OY6MIE9lX5Xa9/eH1sYITq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8xggMQMIIDDAIB +ATB2MGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQu +MSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIQHu2nEIcbtVh7 +Lds/867h7zAJBgUrDgMCGgUAoIIBbzAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3 +DQEJBTEPFw0wNjA0MjAyMTE5NDVaMCMGCSqGSIb3DQEJBDEWBBQPp0KhHytqLun6OnhibJiCK0O0 +JTCBhQYJKwYBBAGCNxAEMXgwdjBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1 +bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3Vp +bmcgQ0ECEB7tpxCHG7VYey3bP/Ou4e8wgYcGCyqGSIb3DQEJEAILMXigdjBiMQswCQYDVQQGEwJa +QTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3Rl +IFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECEB7tpxCHG7VYey3bP/Ou4e8wDQYJKoZIhvcN +AQEBBQAEggEAcEwzkYoIdbMN98kLtsWYAqLk0NDcETMxNRr2GzWG3zShEaS7KvYOZG0t3cdppmzB +gNG4792J2KK+R8lYAsz28++Nd46QWZ7vrIR2ehJdhIInh8Ec5KhZwSWokvCN6Tm3qZoXdE1faXNK +iS4MHA+U65bdS8Kmt4lnjNeh9YiVtPQDhROFe70RVt4DSH28Gk8u3xrl6tmBfRl2dQtVJu5EQpaP +IJxZt0UptqNY7x5T7rGhS8rUzUFPl2lPmjMQS3XuXnl1o7D9J0gx999gVR4juqfA+ZNEkJG6g6Om ++kenyMhLrc+DMEaYkRSFSMcNUtT9I1TGu2X1tNb4DjCuRdyWAgAAAAAAAA== + +--Apple-Mail-9--242939701-- + +From pgsql-performance-owner@postgresql.org Thu Apr 20 18:20:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id E43D011F629F + for ; + Thu, 20 Apr 2006 18:20:06 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.122 +X-Spam-Level: +X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id r9w+LUDMVfnv + for ; + Thu, 20 Apr 2006 18:19:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 00BF311F662D + for ; + Thu, 20 Apr 2006 18:19:49 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3KLJmLf000106; + Thu, 20 Apr 2006 17:19:48 -0400 (EDT) +To: Brendan Duddridge +cc: PostgreSQL Performance +Subject: Re: Recovery will take 10 hours +In-reply-to: <47C1F053-EC91-4AEB-9F0B-B538716145D6@clickspace.com> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <29439.1145564220@sss.pgh.pa.us> + <47C1F053-EC91-4AEB-9F0B-B538716145D6@clickspace.com> +Comments: In-reply-to Brendan Duddridge + message dated "Thu, 20 Apr 2006 15:13:31 -0600" +Date: Thu, 20 Apr 2006 17:19:48 -0400 +Message-ID: <105.1145567988@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/473 +X-Sequence-Number: 18557 + +Brendan Duddridge writes: +> Do you mean do a kill -QUIT on the postgres process in order to +> generate a stack trace? + +Not at all! I'm talking about tracing the kernel calls it's making. +Depending on your platform, the tool for this is called strace, +ktrace, truss, or maybe even just trace. With strace you'd do +something like + + strace -p PID-of-process 2>outfile + ... wait 30 sec or so ... + control-C + +Not sure about the APIs for the others but they're probably roughly +similar ... read the man page ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 20 18:21:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 335CE11F6623 + for ; + Thu, 20 Apr 2006 18:21:35 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.383 +X-Spam-Level: * +X-Spam-Status: No, score=1.383 required=5 tests=[AWL=0.129, + HTML_MESSAGE=0.001, RCVD_NUMERIC_HELO=1.253] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 1oT7Bq7kv9FN + for ; + Thu, 20 Apr 2006 18:21:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id D2F9211F662D + for ; + Thu, 20 Apr 2006 18:21:22 -0300 (ADT) +Received: from 172.16.1.110 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Thu, 20 Apr 2006 17:21:08 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 20 Apr + 2006 17:21:07 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Thu, 20 Apr + 2006 21:21:07 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 20 Apr 2006 14:21:05 -0700 +Subject: Re: Recovery will take 10 hours +From: "Luke Lonergan" +To: "Brendan Duddridge" , + "Tom Lane" +cc: "PostgreSQL Performance" +Message-ID: +Thread-Topic: [PERFORM] Recovery will take 10 hours +Thread-Index: AcZkv6DRK/IS0fnUST+mkuka7iLJsgAALQ7M +In-Reply-To: <47C1F053-EC91-4AEB-9F0B-B538716145D6@clickspace.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 20 Apr 2006 21:21:07.0966 (UTC) + FILETIME=[56D0C9E0:01C664C0] +X-WSS-ID: 685924BF2XS49388389-15-01 +Content-Type: multipart/alternative; + boundary=B_3228387665_3443491 +X-Archive-Number: 200604/474 +X-Sequence-Number: 18558 + +> This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--B_3228387665_3443491 +Content-Type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + +Brendan, + + strace =ADp -c + +Then do a =B3CTRL-C=B2 after a minute to get the stats of system calls. + +- Luke + +On 4/20/06 2:13 PM, "Brendan Duddridge" wrote: + +> Hi Tom, +>=20 +> Do you mean do a kill -QUIT on the postgres process in order to +> generate a stack trace? +>=20 +> Will that affect the currently running process in any bad way? And +> where would the output go? stdout? +>=20 +> Thanks, +>=20 +> ____________________________________________________________________ +> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +>=20 +> ClickSpace Interactive Inc. +> Suite L100, 239 - 10th Ave. SE +> Calgary, AB T2G 0V9 +>=20 +> http://www.clickspace.com +>=20 +> On Apr 20, 2006, at 2:17 PM, Tom Lane wrote: +>=20 +>> > Brendan Duddridge writes: +>>> >> We had a database issue today that caused us to have to restore to +>>> >> our most recent backup. We are using PITR so we have 3120 WAL files +>>> >> that need to be applied to the database. +>>> >> After 45 minutes, it has restored only 230 WAL files. At this rate, +>>> >> it's going to take about 10 hours to restore our database. +>>> >> Most of the time, the server is not using very much CPU time or I/O +>>> >> time. So I'm wondering what can be done to speed up the process? +>> > +>> > That seems a bit odd --- should be eating one or the other, one would +>> > think. Try strace'ing the recovery process to see what it's doing. +>> > +>>> >> If there were something we could do to speed up the process, would i= +t +>>> >> be possible to kill the postgres process, tweak some parameter +>>> >> somewhere and then start it up again? Or would we have to restore ou= +r +>>> >> base backup again and start over? +>> > +>> > You could start it up again, but it'd want to read through all the WAL +>> > it's already looked at, so I'd not recommend this until/unless you're +>> > pretty sure you've fixed the performance issue. Right at the moment, +>> > I think this is a golden opportunity to study the performance of WAL +>> > recovery --- it's not something we've tried to optimize particularly. +>> > +>> > regards, tom lane +>> > +>> > ---------------------------(end of +>> > broadcast)--------------------------- +>> > TIP 9: In versions below 8.0, the planner will ignore your desire to +>> > choose an index scan if your joining column's datatypes do not +>> > match +>> > +>=20 +>=20 +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +>=20 +>=20 + + + +--B_3228387665_3443491 +Content-Type: text/html; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + +Re: [PERFORM] Recovery will take 10 hours + + +Brend= +an,
+
+  strace –p <pid> -c
+
+Then do a “CTRL-C” after a minute to get the stats of system ca= +lls.
+
+- Luke
+
+On 4/20/06 2:13 PM, "Brendan Duddridge" <brendan@clickspace.co= +m> wrote:
+
+
Hi Tom,
+
+Do you mean do a kill -QUIT on the postgres process in order to
+generate a stack trace?
+
+Will that affect the currently running process in any bad way? And
+where would the output go? stdout?
+
+Thanks,
+
+____________________________________________________________________
+Brendan Duddridge | CTO | 403-277-5591 x24 |  brendan@clickspace.com +
+ClickSpace Interactive Inc.
+Suite L100, 239 - 10th Ave. SE
+Calgary, AB  T2G 0V9
+
+http://www.clickspace.com
+
+On Apr 20, 2006, at 2:17 PM, Tom Lane wrote:
+
+> Brendan Duddridge <brendan@clickspace.com> writes:
+>> We had a database issue today that caused us to have to restore to= +
+>> our most recent backup. We are using PITR so we have 3120 WAL file= +s
+>> that need to be applied to the database.
+>> After 45 minutes, it has restored only 230 WAL files. At this rate= +,
+>> it's going to take about 10 hours to restore our database.
+>> Most of the time, the server is not using very much CPU time or I/= +O
+>> time. So I'm wondering what can be done to speed up the process? +>
+> That seems a bit odd --- should be eating one or the other, one would<= +BR> +> think.  Try strace'ing the recovery process to see what it's doin= +g.
+>
+>> If there were something we could do to speed up the process, would= + it
+>> be possible to kill the postgres process, tweak some parameter
+>> somewhere and then start it up again? Or would we have to restore = +our
+>> base backup again and start over?
+>
+> You could start it up again, but it'd want to read through all the WAL= +
+> it's already looked at, so I'd not recommend this until/unless you're<= +BR> +> pretty sure you've fixed the performance issue.  Right at the mom= +ent,
+> I think this is a golden opportunity to study the performance of WAL +> recovery --- it's not something we've tried to optimize particularly.<= +BR> +>
+>            &nbs= +p;          regards, tom l= +ane
+>
+> ---------------------------(end of
+> broadcast)---------------------------
+> TIP 9: In versions below 8.0, the planner will ignore your desire to +>        choose an index scan if your= + joining column's datatypes do not
+>        match
+>
+
+
+
+---------------------------(end of broadcast)--------------------------- +TIP 1: if posting/reading through Usenet, please send an appropriate
+       subscribe-nomail command to major= +domo@postgresql.org so that your
+       message can get through to the ma= +iling list cleanly
+
+
+

+
+ + + + +--B_3228387665_3443491-- + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 18:28:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 02A2711F6D03 + for ; + Thu, 20 Apr 2006 18:28:33 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.358 +X-Spam-Level: * +X-Spam-Status: No, score=1.358 required=5 tests=[AWL=0.105, + RCVD_NUMERIC_HELO=1.253] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id BSK14Mt0E7eo + for ; + Thu, 20 Apr 2006 18:28:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by postgresql.org (Postfix) with ESMTP id 45E7D11F6D02 + for ; + Thu, 20 Apr 2006 18:28:23 -0300 (ADT) +Received: from 172.16.1.25 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Thu, 20 Apr 2006 17:28:02 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01HOST03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 20 Apr + 2006 17:28:01 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Thu, 20 Apr + 2006 21:28:01 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 20 Apr 2006 14:27:59 -0700 +Subject: Re: Quick Performance Poll +From: "Luke Lonergan" +To: "Milen Kulev" +cc: pgsql-performance@postgresql.org, + "bizgres-general" +Message-ID: +Thread-Topic: [PERFORM] Quick Performance Poll +Thread-Index: AcZksvRueuCu96KWTbGitKqFS/QC3wADldji +In-Reply-To: <000001c664b2$eef4ba50$0a00a8c0@trivadis.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 20 Apr 2006 21:28:01.0691 (UTC) + FILETIME=[4D6A36B0:01C664C1] +X-WSS-ID: 6859236820C48721056-01-01 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/475 +X-Sequence-Number: 18559 + +Milen, + +On 4/20/06 12:45 PM, "Milen Kulev" wrote: + +> I (still) haven't tried Bizgres, but what do you mean with "The current +> drawback to bitmap index is that it isn't very +> maintainable under insert/update, although it is safe for those operations"? + +Yes. + +> Do you mean that INSERT/UPDATE operations against bitmap indexes are +> imperformant ? +> If yes, to what extend ? + +Insert/Update (but not delete) operations will often invalidate a bitmap +index in our current implementation because we have not implemented a +maintenance method for them when insertions re-use TIDs. We are in the +planning stages for an update that will fix this. + +> Or you mean that bitmap index corruption is possible when issueing DML +> againts BMP indexes? + +We check for the case of an insertion that causes a re-used TID and issue an +error that indicates the index should be removed before the operation is +retried. This isn't particularly useful for cases where inserts occur +frequently, so the current use-case if for tables where DML should be done +in batches after removing the index, then the index re-applied. + +> I am asking this question because Oracle needed 3 years to solve its BMP index +> problems (BMP index corruption/ space +> usage explosion when several processes are performing DML operations ). + +We will be much faster than that! Concurrency will be less than ideal with +our maintenance approach initially, but there shouldn't be a corruption +problem. + +> Is Bizgres implementation suffering from this kind child deseases ? + +Sneeze, cough. + +- Luke +> +> +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Luke Lonergan +> Sent: Thursday, April 20, 2006 5:03 PM +> To: jim@contactbda.com; Simon Dale; pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Quick Performance Poll +> +> +> Jim, +> +> On 4/20/06 7:40 AM, "Jim Buttafuoco" wrote: +> +>> First of all this is NOT a single table and yes I am using +>> partitioning and the constaint exclusion stuff. the largest set of +>> tables is over 2T. I have not had to rebuild the biggest database +>> yet, but for a smaller one ~1T the restore takes about 12 hours +>> including many indexes on both large and small tables +> +> You would probably benefit greatly from the new on-disk bitmap index feature +> in Bizgres Open Source. It's 8.1 plus the +> sort speed improvement and on-disk bitmap index. +> +> Index creation and sizes for the binary version are in the table below (from a +> performance report on bizgres network. +> The version in CVS tip on pgfoundry is much faster on index creation as well. +> +> The current drawback to bitmap index is that it isn't very maintainable under +> insert/update, although it is safe for +> those operations. For now, you have to drop index, do inserts/updates, +> rebuild index. +> +> We'll have a version that is maintained for insert/update next. +> +> - Luke +> +> # Indexed Columns Create Time (seconds) Space Used (MBs) +> BITMAP BTREE BITMAP BTREE +> 1 L_SHIPMODE 454.8 2217.1 58 1804 +> 2 L_QUANTITY 547.2 937.8 117 1804 +> 3 L_LINENUMBER 374.5 412.4 59 1285 +> 4 L_SHIPMODE, L_QUANTITY 948.7 2933.4 176 2845 +> 5 O_ORDERSTATUS 83.5 241.3 5 321 +> 6 O_ORDERPRIORITY 108.5 679.1 11 580 +> 7 C_MKTSEGMENT 10.9 51.3 1 45 +> 8 C_NATIONKEY 8.3 9.3 2 32 +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> +> +> + + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 20:11:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 84C4911F7040 + for ; + Thu, 20 Apr 2006 20:11:09 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 4aN-jo1WsSLh + for ; + Thu, 20 Apr 2006 20:11:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id F1EC111F65F3 + for ; + Thu, 20 Apr 2006 20:11:05 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Thu, 20 Apr 2006 17:11:05 -0600 +In-Reply-To: +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Recovery will take 10 hours +Date: Thu, 20 Apr 2006 17:11:01 -0600 +To: Jeff Frost +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/477 +X-Sequence-Number: 18561 + +Hi Jeff, + +The WAL files are stored on a separate server and accessed through an +NFS mount located at /wal_archive. + +However, the restore failed about 5 hours in after we got this error: + +[2006-04-20 16:41:28 MDT] LOG: restored log file +"000000010000018F00000034" from archive +[2006-04-20 16:41:35 MDT] LOG: restored log file +"000000010000018F00000035" from archive +[2006-04-20 16:41:38 MDT] LOG: restored log file +"000000010000018F00000036" from archive +sh: line 1: /wal_archive/000000010000018F00000037.gz: No such file or +directory +[2006-04-20 16:41:46 MDT] LOG: could not open file "pg_xlog/ +000000010000018F00000037" (log file 399, segment 55): No such file or +directory +[2006-04-20 16:41:46 MDT] LOG: redo done at 18F/36FFF254 +sh: line 1: /wal_archive/000000010000018F00000036.gz: No such file or +directory +[2006-04-20 16:41:46 MDT] PANIC: could not open file "pg_xlog/ +000000010000018F00000036" (log file 399, segment 54): No such file or +directory +[2006-04-20 16:41:46 MDT] LOG: startup process (PID 9190) was +terminated by signal 6 +[2006-04-20 16:41:46 MDT] LOG: aborting startup due to startup +process failure +[2006-04-20 16:41:46 MDT] LOG: logger shutting down + + + +The /wal_archive/000000010000018F00000037.gz is there accessible on +the NFS mount. + +Is there a way to continue the restore process from where it left off? + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 20, 2006, at 3:19 PM, Jeff Frost wrote: + +> On Thu, 20 Apr 2006, Brendan Duddridge wrote: +> +>> Hi, +>> +>> We had a database issue today that caused us to have to restore to +>> our most recent backup. We are using PITR so we have 3120 WAL +>> files that need to be applied to the database. +>> +>> After 45 minutes, it has restored only 230 WAL files. At this +>> rate, it's going to take about 10 hours to restore our database. +>> +>> Most of the time, the server is not using very much CPU time or I/ +>> O time. So I'm wondering what can be done to speed up the process? +> +> Brendan, +> +> Where are the WAL files being stored and how are they being read back? +> +> -- +> Jeff Frost, Owner +> Frost Consulting, LLC http://www.frostconsultingllc.com/ +> Phone: 650-780-7908 FAX: 650-649-1954 +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that +> your +> message can get through to the mailing list cleanly +> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 20:15:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id D3BE711F6708 + for ; + Thu, 20 Apr 2006 20:15:09 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id rGNGr4zNqIHM + for ; + Thu, 20 Apr 2006 20:15:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 8D57D11F675F + for ; + Thu, 20 Apr 2006 20:15:06 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Thu, 20 Apr 2006 17:15:06 -0600 +In-Reply-To: <105.1145567988@sss.pgh.pa.us> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <29439.1145564220@sss.pgh.pa.us> + <47C1F053-EC91-4AEB-9F0B-B538716145D6@clickspace.com> + <105.1145567988@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <3D29F1D5-D0E8-4291-8426-CD0EBD6EC5F5@clickspace.com> +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Recovery will take 10 hours +Date: Thu, 20 Apr 2006 17:15:00 -0600 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/478 +X-Sequence-Number: 18562 + +Hi Tom, + +I found it... it's called ktrace on OS X Server. + +However, as I just finished posting to the list, the process died +with a PANIC error: + +[2006-04-20 16:41:28 MDT] LOG: restored log file +"000000010000018F00000034" from archive +[2006-04-20 16:41:35 MDT] LOG: restored log file +"000000010000018F00000035" from archive +[2006-04-20 16:41:38 MDT] LOG: restored log file +"000000010000018F00000036" from archive +sh: line 1: /wal_archive/000000010000018F00000037.gz: No such file or +directory +[2006-04-20 16:41:46 MDT] LOG: could not open file "pg_xlog/ +000000010000018F00000037" (log file 399, segment 55): No such file or +directory +[2006-04-20 16:41:46 MDT] LOG: redo done at 18F/36FFF254 +sh: line 1: /wal_archive/000000010000018F00000036.gz: No such file or +directory +[2006-04-20 16:41:46 MDT] PANIC: could not open file "pg_xlog/ +000000010000018F00000036" (log file 399, segment 54): No such file or +directory +[2006-04-20 16:41:46 MDT] LOG: startup process (PID 9190) was +terminated by signal 6 +[2006-04-20 16:41:46 MDT] LOG: aborting startup due to startup +process failure +[2006-04-20 16:41:46 MDT] LOG: logger shutting down + + +Would turning off fsync make it go faster? Maybe it won't take 10 +hours again if we start from scratch. + +Also, what if we did just start it up again? Will postgres realize +that the existing wal_archive files have already been processed and +just skip along until it finds one it hasn't processed yet? + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 20, 2006, at 3:19 PM, Tom Lane wrote: + +> Brendan Duddridge writes: +>> Do you mean do a kill -QUIT on the postgres process in order to +>> generate a stack trace? +> +> Not at all! I'm talking about tracing the kernel calls it's making. +> Depending on your platform, the tool for this is called strace, +> ktrace, truss, or maybe even just trace. With strace you'd do +> something like +> +> strace -p PID-of-process 2>outfile +> ... wait 30 sec or so ... +> control-C +> +> Not sure about the APIs for the others but they're probably roughly +> similar ... read the man page ... +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 20:20:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id B2B1E11F66DC + for ; + Thu, 20 Apr 2006 20:20:17 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[AWL=0.000, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id rg1gasiEGknU + for ; + Thu, 20 Apr 2006 20:20:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id DF6BC11F666A + for ; + Thu, 20 Apr 2006 20:20:12 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Thu, 20 Apr 2006 17:20:11 -0600 +In-Reply-To: +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + + +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Recovery will take 10 hours +Date: Thu, 20 Apr 2006 17:20:07 -0600 +To: Jeff Frost +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/479 +X-Sequence-Number: 18563 + +Oops... forgot to mention that both files that postgres said were +missing are in fact there: + +A partial listing from our wal_archive directory: + +-rw------- 1 postgres staff 4971129 Apr 19 20:08 +000000010000018F00000036.gz +-rw------- 1 postgres staff 4378284 Apr 19 20:09 +000000010000018F00000037.gz + +There didn't seem to be any issues with the NFS mount. Perhaps it +briefly disconnected and came back right away. + + +Thanks! + + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 20, 2006, at 5:11 PM, Brendan Duddridge wrote: + +> Hi Jeff, +> +> The WAL files are stored on a separate server and accessed through +> an NFS mount located at /wal_archive. +> +> However, the restore failed about 5 hours in after we got this error: +> +> [2006-04-20 16:41:28 MDT] LOG: restored log file +> "000000010000018F00000034" from archive +> [2006-04-20 16:41:35 MDT] LOG: restored log file +> "000000010000018F00000035" from archive +> [2006-04-20 16:41:38 MDT] LOG: restored log file +> "000000010000018F00000036" from archive +> sh: line 1: /wal_archive/000000010000018F00000037.gz: No such file +> or directory +> [2006-04-20 16:41:46 MDT] LOG: could not open file "pg_xlog/ +> 000000010000018F00000037" (log file 399, segment 55): No such file +> or directory +> [2006-04-20 16:41:46 MDT] LOG: redo done at 18F/36FFF254 +> sh: line 1: /wal_archive/000000010000018F00000036.gz: No such file +> or directory +> [2006-04-20 16:41:46 MDT] PANIC: could not open file "pg_xlog/ +> 000000010000018F00000036" (log file 399, segment 54): No such file +> or directory +> [2006-04-20 16:41:46 MDT] LOG: startup process (PID 9190) was +> terminated by signal 6 +> [2006-04-20 16:41:46 MDT] LOG: aborting startup due to startup +> process failure +> [2006-04-20 16:41:46 MDT] LOG: logger shutting down +> +> +> +> The /wal_archive/000000010000018F00000037.gz is there accessible on +> the NFS mount. +> +> Is there a way to continue the restore process from where it left off? +> +> Thanks, +> +> ____________________________________________________________________ +> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +> +> ClickSpace Interactive Inc. +> Suite L100, 239 - 10th Ave. SE +> Calgary, AB T2G 0V9 +> +> http://www.clickspace.com +> +> On Apr 20, 2006, at 3:19 PM, Jeff Frost wrote: +> +>> On Thu, 20 Apr 2006, Brendan Duddridge wrote: +>> +>>> Hi, +>>> +>>> We had a database issue today that caused us to have to restore +>>> to our most recent backup. We are using PITR so we have 3120 WAL +>>> files that need to be applied to the database. +>>> +>>> After 45 minutes, it has restored only 230 WAL files. At this +>>> rate, it's going to take about 10 hours to restore our database. +>>> +>>> Most of the time, the server is not using very much CPU time or I/ +>>> O time. So I'm wondering what can be done to speed up the process? +>> +>> Brendan, +>> +>> Where are the WAL files being stored and how are they being read +>> back? +>> +>> -- +>> Jeff Frost, Owner +>> Frost Consulting, LLC http://www.frostconsultingllc.com/ +>> Phone: 650-780-7908 FAX: 650-649-1954 +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 1: if posting/reading through Usenet, please send an appropriate +>> subscribe-nomail command to majordomo@postgresql.org so that +>> your +>> message can get through to the mailing list cleanly +>> +> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 20:20:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 14E7411F66DC + for ; + Thu, 20 Apr 2006 20:20:54 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.122 +X-Spam-Level: +X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Cblts2aYsRcN + for ; + Thu, 20 Apr 2006 20:20:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id B8E8F11F662D + for ; + Thu, 20 Apr 2006 20:20:49 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3KNKlgg001125; + Thu, 20 Apr 2006 19:20:47 -0400 (EDT) +To: Brendan Duddridge +cc: PostgreSQL Performance +Subject: Re: Recovery will take 10 hours +In-reply-to: <3D29F1D5-D0E8-4291-8426-CD0EBD6EC5F5@clickspace.com> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <29439.1145564220@sss.pgh.pa.us> + <47C1F053-EC91-4AEB-9F0B-B538716145D6@clickspace.com> + <105.1145567988@sss.pgh.pa.us> + <3D29F1D5-D0E8-4291-8426-CD0EBD6EC5F5@clickspace.com> +Comments: In-reply-to Brendan Duddridge + message dated "Thu, 20 Apr 2006 17:15:00 -0600" +Date: Thu, 20 Apr 2006 19:20:47 -0400 +Message-ID: <1124.1145575247@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/480 +X-Sequence-Number: 18564 + +Brendan Duddridge writes: +> However, as I just finished posting to the list, the process died +> with a PANIC error: + +> [2006-04-20 16:41:28 MDT] LOG: restored log file +> "000000010000018F00000034" from archive +> [2006-04-20 16:41:35 MDT] LOG: restored log file +> "000000010000018F00000035" from archive +> [2006-04-20 16:41:38 MDT] LOG: restored log file +> "000000010000018F00000036" from archive +> sh: line 1: /wal_archive/000000010000018F00000037.gz: No such file or +> directory +> [2006-04-20 16:41:46 MDT] LOG: could not open file "pg_xlog/ +> 000000010000018F00000037" (log file 399, segment 55): No such file or +> directory +> [2006-04-20 16:41:46 MDT] LOG: redo done at 18F/36FFF254 +> sh: line 1: /wal_archive/000000010000018F00000036.gz: No such file or +> directory +> [2006-04-20 16:41:46 MDT] PANIC: could not open file "pg_xlog/ +> 000000010000018F00000036" (log file 399, segment 54): No such file or +> directory + +This looks to me like a bug in your archive restore command. It had +just finished providing 000000010000018F00000036 at 16:41:38, why was +it not able to do so again at 16:41:46? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 20 20:27:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 48F2B11F8B9B + for ; + Thu, 20 Apr 2006 20:27:03 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76NWBm6xeCnC + for ; + Thu, 20 Apr 2006 20:26:56 -0300 (ADT) +X-Greylist: delayed 02:07:12.891259 by SQLgrey- +Received: from glacier.frostconsultingllc.com (glacier.frostconsultingllc.com + [64.127.99.90]) + by postgresql.org (Postfix) with ESMTP id 0A10511F8B54 + for ; + Thu, 20 Apr 2006 20:26:57 -0300 (ADT) +Received: from localhost ([127.0.0.1]:33068) + by glacier.frostconsultingllc.com with esmtp (Exim 4.61) + (envelope-from ) + id 1FWiY5-0001UU-KA; Thu, 20 Apr 2006 16:26:57 -0700 +Date: Thu, 20 Apr 2006 16:26:57 -0700 (PDT) +From: Jeff Frost +To: Brendan Duddridge +cc: PostgreSQL Performance +Subject: Re: Recovery will take 10 hours +In-Reply-To: +Message-ID: +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + + + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-SA-Exim-Connect-IP: 127.0.0.1 +X-SA-Exim-Mail-From: jeff@frostconsultingllc.com +X-SA-Exim-Scanned: No (on glacier.frostconsultingllc.com); + SAEximRunCond expanded to false +X-Archive-Number: 200604/481 +X-Sequence-Number: 18565 + + +Brendan, + +Is your NFS share mounted hard or soft? Do you have space to copy the files +locally? I suspect you're seeing NFS slowness in your restore since you +aren't using much in the way of disk IO or CPU. + +-Jeff + +On Thu, 20 Apr 2006, Brendan Duddridge wrote: + +> Oops... forgot to mention that both files that postgres said were missing are +> in fact there: +> +> A partial listing from our wal_archive directory: +> +> -rw------- 1 postgres staff 4971129 Apr 19 20:08 000000010000018F00000036.gz +> -rw------- 1 postgres staff 4378284 Apr 19 20:09 000000010000018F00000037.gz +> +> There didn't seem to be any issues with the NFS mount. Perhaps it briefly +> disconnected and came back right away. +> +> +> Thanks! +> +> +> ____________________________________________________________________ +> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +> +> ClickSpace Interactive Inc. +> Suite L100, 239 - 10th Ave. SE +> Calgary, AB T2G 0V9 +> +> http://www.clickspace.com +> +> On Apr 20, 2006, at 5:11 PM, Brendan Duddridge wrote: +> +>> Hi Jeff, +>> +>> The WAL files are stored on a separate server and accessed through an NFS +>> mount located at /wal_archive. +>> +>> However, the restore failed about 5 hours in after we got this error: +>> +>> [2006-04-20 16:41:28 MDT] LOG: restored log file "000000010000018F00000034" +>> from archive +>> [2006-04-20 16:41:35 MDT] LOG: restored log file "000000010000018F00000035" +>> from archive +>> [2006-04-20 16:41:38 MDT] LOG: restored log file "000000010000018F00000036" +>> from archive +>> sh: line 1: /wal_archive/000000010000018F00000037.gz: No such file or +>> directory +>> [2006-04-20 16:41:46 MDT] LOG: could not open file +>> "pg_xlog/000000010000018F00000037" (log file 399, segment 55): No such file +>> or directory +>> [2006-04-20 16:41:46 MDT] LOG: redo done at 18F/36FFF254 +>> sh: line 1: /wal_archive/000000010000018F00000036.gz: No such file or +>> directory +>> [2006-04-20 16:41:46 MDT] PANIC: could not open file +>> "pg_xlog/000000010000018F00000036" (log file 399, segment 54): No such file +>> or directory +>> [2006-04-20 16:41:46 MDT] LOG: startup process (PID 9190) was terminated by +>> signal 6 +>> [2006-04-20 16:41:46 MDT] LOG: aborting startup due to startup process +>> failure +>> [2006-04-20 16:41:46 MDT] LOG: logger shutting down +>> +>> +>> +>> The /wal_archive/000000010000018F00000037.gz is there accessible on the NFS +>> mount. +>> +>> Is there a way to continue the restore process from where it left off? +>> +>> Thanks, +>> +>> ____________________________________________________________________ +>> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +>> +>> ClickSpace Interactive Inc. +>> Suite L100, 239 - 10th Ave. SE +>> Calgary, AB T2G 0V9 +>> +>> http://www.clickspace.com +>> +>> On Apr 20, 2006, at 3:19 PM, Jeff Frost wrote: +>> +>>> On Thu, 20 Apr 2006, Brendan Duddridge wrote: +>>> +>>>> Hi, +>>>> +>>>> We had a database issue today that caused us to have to restore to our +>>>> most recent backup. We are using PITR so we have 3120 WAL files that need +>>>> to be applied to the database. +>>>> +>>>> After 45 minutes, it has restored only 230 WAL files. At this rate, it's +>>>> going to take about 10 hours to restore our database. +>>>> +>>>> Most of the time, the server is not using very much CPU time or I/O time. +>>>> So I'm wondering what can be done to speed up the process? +>>> +>>> Brendan, +>>> +>>> Where are the WAL files being stored and how are they being read back? +>>> +>>> -- +>>> Jeff Frost, Owner +>>> Frost Consulting, LLC http://www.frostconsultingllc.com/ +>>> Phone: 650-780-7908 FAX: 650-649-1954 +>>> +>>> ---------------------------(end of broadcast)--------------------------- +>>> TIP 1: if posting/reading through Usenet, please send an appropriate +>>> subscribe-nomail command to majordomo@postgresql.org so that your +>>> message can get through to the mailing list cleanly +>>> +>> +>> +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 3: Have you checked our extensive FAQ? +>> +>> http://www.postgresql.org/docs/faq +>> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +> + +-- +Jeff Frost, Owner +Frost Consulting, LLC http://www.frostconsultingllc.com/ +Phone: 650-780-7908 FAX: 650-649-1954 + +From pgsql-performance-owner@postgresql.org Thu Apr 20 20:28:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id B5C0A11F8C65 + for ; + Thu, 20 Apr 2006 20:28:01 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.579 +X-Spam-Level: +X-Spam-Status: No, score=-2.579 required=5 tests=[AWL=0.020, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 578Wnyxdi0qc + for ; + Thu, 20 Apr 2006 20:28:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id D7D0611F8C50 + for ; + Thu, 20 Apr 2006 20:27:57 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Thu, 20 Apr 2006 17:27:57 -0600 +In-Reply-To: <1124.1145575247@sss.pgh.pa.us> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <29439.1145564220@sss.pgh.pa.us> + <47C1F053-EC91-4AEB-9F0B-B538716145D6@clickspace.com> + <105.1145567988@sss.pgh.pa.us> + <3D29F1D5-D0E8-4291-8426-CD0EBD6EC5F5@clickspace.com> + <1124.1145575247@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <9B685F6D-A95E-48E1-A4D5-4A653B7A2C0D@clickspace.com> +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Recovery will take 10 hours +Date: Thu, 20 Apr 2006 17:27:53 -0600 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/482 +X-Sequence-Number: 18566 + +Well our restore command is pretty basic: + +restore_command = 'gunzip %p' + +I'm not sure why that would succeed then fail. + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 20, 2006, at 5:20 PM, Tom Lane wrote: + +> Brendan Duddridge writes: +>> However, as I just finished posting to the list, the process died +>> with a PANIC error: +> +>> [2006-04-20 16:41:28 MDT] LOG: restored log file +>> "000000010000018F00000034" from archive +>> [2006-04-20 16:41:35 MDT] LOG: restored log file +>> "000000010000018F00000035" from archive +>> [2006-04-20 16:41:38 MDT] LOG: restored log file +>> "000000010000018F00000036" from archive +>> sh: line 1: /wal_archive/000000010000018F00000037.gz: No such file or +>> directory +>> [2006-04-20 16:41:46 MDT] LOG: could not open file "pg_xlog/ +>> 000000010000018F00000037" (log file 399, segment 55): No such file or +>> directory +>> [2006-04-20 16:41:46 MDT] LOG: redo done at 18F/36FFF254 +>> sh: line 1: /wal_archive/000000010000018F00000036.gz: No such file or +>> directory +>> [2006-04-20 16:41:46 MDT] PANIC: could not open file "pg_xlog/ +>> 000000010000018F00000036" (log file 399, segment 54): No such file or +>> directory +> +> This looks to me like a bug in your archive restore command. It had +> just finished providing 000000010000018F00000036 at 16:41:38, why was +> it not able to do so again at 16:41:46? +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that +> your +> message can get through to the mailing list cleanly +> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 20:29:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B074511F8CE5 + for ; + Thu, 20 Apr 2006 20:29:57 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.122 +X-Spam-Level: +X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id qtXUH6c9V7ar + for ; + Thu, 20 Apr 2006 20:29:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 3BCD811F8CDE + for ; + Thu, 20 Apr 2006 20:29:53 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3KNTn8X001204; + Thu, 20 Apr 2006 19:29:49 -0400 (EDT) +To: Brendan Duddridge +cc: Jeff Frost , + PostgreSQL Performance +Subject: Re: Recovery will take 10 hours +In-reply-to: +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + + + +Comments: In-reply-to Brendan Duddridge + message dated "Thu, 20 Apr 2006 17:20:07 -0600" +Date: Thu, 20 Apr 2006 19:29:49 -0400 +Message-ID: <1203.1145575789@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/483 +X-Sequence-Number: 18567 + +Brendan Duddridge writes: +> Oops... forgot to mention that both files that postgres said were +> missing are in fact there: + +Please place the blame where it should fall: it's your archive restore +command that's telling postgres that. + +> There didn't seem to be any issues with the NFS mount. Perhaps it +> briefly disconnected and came back right away. + +Unstable NFS mounts are Really Bad News. You shouldn't be expecting +to run a stable database atop such a thing. + +If it's not the database but only the WAL archive that's NFS'd, it might +be possible to live with it, but you'll need to put some defenses into +your archive restore script to cope with such events. + +As far as restarting goes: I think you can restart from here without +first redoing your base-backup restore, but as previously noted it'll +still read through the same WAL files it looked at before. You won't +save much except the time to redo the base restore. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 20 20:43:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 31BAA11F6095 + for ; + Thu, 20 Apr 2006 20:43:55 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.57 +X-Spam-Level: +X-Spam-Status: No, score=-2.57 required=5 tests=[AWL=0.029, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id cxh2kR-ZdqLJ + for ; + Thu, 20 Apr 2006 20:43:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id E64F511F6081 + for ; + Thu, 20 Apr 2006 20:43:46 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Thu, 20 Apr 2006 17:43:46 -0600 +In-Reply-To: <1203.1145575789@sss.pgh.pa.us> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + + + + <1203.1145575789@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Recovery will take 10 hours +Date: Thu, 20 Apr 2006 17:43:41 -0600 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/484 +X-Sequence-Number: 18568 + +Thanks Tom, + +We are storing only the WAL archives on the NFS volume. It must have +been a hiccup in the NFS mount. Jeff Frost asked if we were using +hard or soft mounts. We were using soft mounts, so that may be where +the problem lies with the PANIC. + +Is it better to use the boot volume of the database machine for +archiving our WAL files instead of over the NFS mount? I'm sure it's +probably not a good idea to archive to the same volume as the pg_xlog +directory, so that's why I thought maybe using the boot drive would +be better. We'll just have to make sure we don't fill up the drive. +Although I know that PostgreSQL often writes to the /data directory +that is located on the boot drive. It might not be good to start +archiving there. Our table spaces are on a separate RAID. + +If we need to restore in the future we'll just have to copy the WAL +files from the boot drive of our database machine over the NFS to the +restore machine. + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 20, 2006, at 5:29 PM, Tom Lane wrote: + +> Brendan Duddridge writes: +>> Oops... forgot to mention that both files that postgres said were +>> missing are in fact there: +> +> Please place the blame where it should fall: it's your archive restore +> command that's telling postgres that. +> +>> There didn't seem to be any issues with the NFS mount. Perhaps it +>> briefly disconnected and came back right away. +> +> Unstable NFS mounts are Really Bad News. You shouldn't be expecting +> to run a stable database atop such a thing. +> +> If it's not the database but only the WAL archive that's NFS'd, it +> might +> be possible to live with it, but you'll need to put some defenses into +> your archive restore script to cope with such events. +> +> As far as restarting goes: I think you can restart from here without +> first redoing your base-backup restore, but as previously noted it'll +> still read through the same WAL files it looked at before. You won't +> save much except the time to redo the base restore. +> +> regards, tom lane +> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 21:24:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 1EED211F6969 + for ; + Thu, 20 Apr 2006 21:24:45 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.566 +X-Spam-Level: +X-Spam-Status: No, score=-2.566 required=5 tests=[AWL=0.033, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id Nd9tQ-8+AKIF + for ; + Thu, 20 Apr 2006 21:24:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 2A91311F690B + for ; + Thu, 20 Apr 2006 21:24:40 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Thu, 20 Apr 2006 18:24:41 -0600 +In-Reply-To: <105.1145567988@sss.pgh.pa.us> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <29439.1145564220@sss.pgh.pa.us> + <47C1F053-EC91-4AEB-9F0B-B538716145D6@clickspace.com> + <105.1145567988@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <53ACF10A-9240-420B-83AB-E4CBABD2AC56@clickspace.com> +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Recovery will take 10 hours +Date: Thu, 20 Apr 2006 18:24:36 -0600 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/485 +X-Sequence-Number: 18569 + +Hi Tom, + +Well, we started the restore back up with the WAL archives copied to +our local disk. + +It's going at about the same pace as with the restore over NFS. + +So I tried ktrace -p PID and it created a really big file. I had to +do 'ktrace -p PID -c' to get it to stop. + +The ktrace.out file is read using kdump, but there's a lot of binary +data in there intermixed with some system calls. + +For example: + +15267 postgres RET read 8192/0x2000 +15267 postgres CALL lseek(153,0,2) +15267 postgres RET lseek 0 +15267 postgres CALL lseek(127,0,2) +15267 postgres RET lseek 0 +15267 postgres CALL lseek(138,0,2) +15267 postgres RET lseek 0 +15267 postgres CALL lseek(153,0,2) +15267 postgres RET lseek 0 +15267 postgres CALL lseek(127,0,2) +15267 postgres RET lseek 0 +15267 postgres CALL read(5,25225728,8192) +15267 postgres GIO fd 5 read 8192 bytes + "\M-P]\0\^A\0\0\0\^A\0\0\^A\M^H,\M-5`\0\0\0\^C\M-6r fill, +polyester has a subtle sheen, machine wash\0\0\0Xreverses to\ + solid colour, polyester fill, polyester has a subtle sheen, +machine wash\^_\^Y7\M-3\0\0\0\0\0\0\0\0\0\0\0\0\0\0oG\0\ + \b\0\^[)\^C \M^Or\M-#\^B\0\0\0\0\0A\M-&\M-] + +... lots of data .... + + \M^K$\0\0\0\fcomplete\0\0\0HCustom-width Valanceless +Aluminum Mini Blinds 37 1/4-44" w. x 48" l.\0\0\0\M-P1" aluminum\ + slats, valanceless headrail and matching bottom rail, +hidden brackets, clear acrylic tilt wand, extra slats with rou\ + te holes in the back, can be cut down to minimum width of +14", hardware. . .\0\0\^Aq1" aluminum slats, valanceless he\ + adrail and matching bottom rail, hidden brackets, clear +acrylic tilt wand, extra slats with route holes in the back, \ + can be cut down to minimum width of 14", hardware and +instructions included, wipe with a dam" +15267 postgres RET read 8192/0x2000 +15267 postgres CALL lseek(138,0,2) +15267 postgres RET lseek 0 +15267 postgres CALL lseek(158,317251584,0) +15267 postgres RET lseek 0 +15267 postgres CALL write(158,35286464,8192) +15267 postgres GIO fd 158 wrote 8192 bytes + "\0\0\^A\M^H+\M^W@\M-,\0\0\0\^A\^A\M-D\^P\M-@\^_\M-p \^C?\M^X +\M^@$?P\M^@$?\b\M^@$>\M-@\M^@$>x\M^@$>0\M^@$=\M-h\M^@$=\ + \240\M^@$#0\M^@$"X\M^@$=X\M^@$=\^P\M^@$<\M-H\M^@$<\M^@\M^@$<8 +\M^@$;\M-p\M^@$;\M-(\M^@$;`\M^@$;\^X\M^@$:\M-P\M^@$:\M^H\ + +etc... + +I'm not sure that really tells me anything though other than the WAL +archives don't actually archive SQL, but store only the database +changes. + + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 20, 2006, at 3:19 PM, Tom Lane wrote: + +> Brendan Duddridge writes: +>> Do you mean do a kill -QUIT on the postgres process in order to +>> generate a stack trace? +> +> Not at all! I'm talking about tracing the kernel calls it's making. +> Depending on your platform, the tool for this is called strace, +> ktrace, truss, or maybe even just trace. With strace you'd do +> something like +> +> strace -p PID-of-process 2>outfile +> ... wait 30 sec or so ... +> control-C +> +> Not sure about the APIs for the others but they're probably roughly +> similar ... read the man page ... +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + + + +From pgsql-hackers-owner@postgresql.org Thu Apr 20 21:31:00 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id AD17F11F664B + for ; + Thu, 20 Apr 2006 21:30:59 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.122 +X-Spam-Level: +X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 5Wuhr5CXYRvA + for ; + Thu, 20 Apr 2006 21:30:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 8465411F6089 + for ; + Thu, 20 Apr 2006 21:30:56 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3L0UujP001723; + Thu, 20 Apr 2006 20:30:56 -0400 (EDT) +To: "Radovan Antloga" +cc: pgsql-hackers@postgreSQL.org +Subject: UPDATE on many-column tables (was Re: [PERFORM] Performance decrease) +In-reply-to: <015801c66494$ee3d25c0$1e4ba8c0@AR6> +References: <011b01c6648e$067ee170$1e4ba8c0@AR6> + <18973.1145547701@sss.pgh.pa.us> + <015801c66494$ee3d25c0$1e4ba8c0@AR6> +Comments: In-reply-to "Radovan Antloga" + message dated "Thu, 20 Apr 2006 18:10:21 +0200" +Date: Thu, 20 Apr 2006 20:30:55 -0400 +Message-ID: <1722.1145579455@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/759 +X-Sequence-Number: 82482 + +"Radovan Antloga" writes: +>> 190 fields in a table seems like rather a lot ... is that actually +>> representative of your intended applications? + +> Test table is like table I use in production +> with Firebird and Oracle db. Table has a lot of smallint +> and integer fields. + +I did some experiments with CVS tip on updating all rows of a table with +lots of columns --- to be specific, + + create table widetable( + int1 int, text1 text, num1 numeric, + int2 int, text2 text, num2 numeric, + int3 int, text3 text, num3 numeric, + ... + int59 int, text59 text, num59 numeric, + int60 int, text60 text, num60 numeric + ); + +for 180 columns altogether, with 16k rows of data and the test query + + update widetable set int30 = null; + +The gprof profile looks like this: + + % cumulative self self total + time seconds seconds calls ms/call ms/call name + 19.77 1.22 1.22 _mcount + 14.91 2.14 0.92 16385 0.06 0.06 XLogInsert + 9.08 2.70 0.56 2932736 0.00 0.00 slot_deform_tuple + 7.94 3.19 0.49 2965504 0.00 0.00 slot_getattr + 6.48 3.59 0.40 2949120 0.00 0.00 ExecEvalVar + 5.83 3.95 0.36 16384 0.02 0.02 ExecTargetList + 4.70 4.24 0.29 16384 0.02 0.02 heap_fill_tuple + 3.57 4.46 0.22 ExecEvalVar + 2.43 4.61 0.15 _write_sys + 2.27 4.75 0.14 16384 0.01 0.01 heap_compute_data_size + 1.62 4.85 0.10 noshlibs + 1.46 4.94 0.09 16384 0.01 0.03 heap_form_tuple + 1.30 5.02 0.08 16384 0.00 0.01 ExecGetJunkAttribute + 1.30 5.10 0.08 encore + 1.13 5.17 0.07 16384 0.00 0.00 ExecFilterJunk + 1.13 5.24 0.07 chunk2 + +The large number of calls to slot_deform_tuple() is annoying --- ideally +there'd be only one per row. But what actually happens is that the +ExecVariableList() optimization is disabled by the presence of one +non-user attribute in the scan's targetlist (ie, ctid, which is needed +by the top-level executor to do the UPDATE), not to mention that the +attribute(s) being updated will have non-Var expressions anyway. So we +execute the target list the naive way, and because the Vars referencing +the not-updated columns appear sequentially in the tlist, that means +each ExecEvalVar/slot_getattr ends up calling slot_deform_tuple again to +decipher just one more column of the tuple. + +This is just an O(N) penalty, not O(N^2), but still it's pretty annoying +considering that all the infrastructure is there to do better. If we +were to determine the max attribute number to be fetched and call +slot_getsomeattrs() up front (as happens in the ExecVariableList case) +then we could save a significant constant factor --- perhaps as much as +10% of the runtime in this case. + +The trick with such "optimizations" is to not turn them into +pessimizations --- if we decode attributes that end up not getting +fetched then we aren't saving cycles. So I'm thinking of tying this +specifically to the scan node's targetlist and only doing the +slot_getsomeattrs() call when we have decided to evaluate the +targetlist. Any columns referenced as part of the node's qual +conditions wouldn't participate in the improvement. We could +alternatively do the slot_getsomeattrs() call before evaluating the +quals, but I'm worried that this would be a loss in the case where +the qual condition fails and so the targetlist is never evaluated. + +Comments, better ideas? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 20 22:06:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id DB58511F6031 + for ; + Thu, 20 Apr 2006 22:06:07 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.12 +X-Spam-Level: +X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43h4OfzVuwAS + for ; + Thu, 20 Apr 2006 22:06:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 8B74311F8CC8 + for ; + Thu, 20 Apr 2006 22:06:04 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Thu, 20 Apr 2006 19:06:02 -0600 +In-Reply-To: <44482CAF.70309@fuzzy.cz> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <29439.1145564220@sss.pgh.pa.us> + <47C1F053-EC91-4AEB-9F0B-B538716145D6@clickspace.com> + <105.1145567988@sss.pgh.pa.us> + <53ACF10A-9240-420B-83AB-E4CBABD2AC56@clickspace.com> + <44482CAF.70309@fuzzy.cz> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <5C372D71-D189-4AA7-A857-1C8FE42311AE@clickspace.com> +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Recovery will take 10 hours +Date: Thu, 20 Apr 2006 19:05:57 -0600 +To: Tomas Vondra +X-Mailer: Apple Mail (2.749.3) +X-Archive-Number: 200604/486 +X-Sequence-Number: 18570 + +Hi Tomas, + +Hmm... ktrace -p PID -c returns immediately without doing anything +unless I've previously done a ktrace -p PID. + +According to the man page for ktrace's -c flag: + -c Clear the trace points associated with the specified file +or processes. + +When I run ktrace on OS X Server 10.4.6 it returns to the console +immediately, however the ktrace.out file gets larger and larger until +I issue another ktrace command with the -c flag. It never sits +waiting for keyboard input. + + +I haven't been able to find any way of generating the stats yet. The +man page for ktrace or kdump doesn't mention anything about stats. + + +Thanks, + + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 20, 2006, at 6:51 PM, Tomas Vondra wrote: + +>> So I tried ktrace -p PID and it created a really big file. I had +>> to do +>> 'ktrace -p PID -c' to get it to stop. +>> +>> The ktrace.out file is read using kdump, but there's a lot of binary +>> data in there intermixed with some system calls. +> +> Yes, that's what (s|k)trace does - it attaches to the process, and +> prints out all the system calls, parameters, return values etc. That +> gives you "exact" overview of what's going on in the program, but it's +> a little bit confusing if you are not familiar with that and/or you're +> in a hurry. +> +> But Luke Lonergan offered a '-c' switch, which gives you a statistics +> of the used system calls. This way you can see number of calls for +> individual syscalls and time spent in them. That could give you a hint +> why the process is so slow (for example there can be an I/O bottleneck +> or something like that). +> +> Just do 'ktrace -p PID -c' for about 30 seconds, then 'Ctrl-C' and +> post +> the output to this mailing list. +> +> t.v. +> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 20 22:16:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BAE3711F609E + for ; + Thu, 20 Apr 2006 22:15:59 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id n-j4RWymAW+5 + for ; + Thu, 20 Apr 2006 22:15:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linuxworld.com.au (unknown [203.34.46.50]) + by postgresql.org (Postfix) with ESMTP id 9A5A111F60B0 + for ; + Thu, 20 Apr 2006 22:15:54 -0300 (ADT) +Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) + by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id k3L1FU5G017126; + Fri, 21 Apr 2006 11:15:31 +1000 +Received: from localhost (swm@localhost) + by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id + k3L1FS2R017123; Fri, 21 Apr 2006 11:15:29 +1000 +X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs +Date: Fri, 21 Apr 2006 11:15:28 +1000 (EST) +From: Gavin Sherry +X-X-Sender: swm@linuxworld.com.au +To: Brendan Duddridge +cc: Tomas Vondra , + PostgreSQL Performance +Subject: Re: Recovery will take 10 hours +In-Reply-To: <5C372D71-D189-4AA7-A857-1C8FE42311AE@clickspace.com> +Message-ID: +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <29439.1145564220@sss.pgh.pa.us> + <47C1F053-EC91-4AEB-9F0B-B538716145D6@clickspace.com> + <105.1145567988@sss.pgh.pa.us> + <53ACF10A-9240-420B-83AB-E4CBABD2AC56@clickspace.com> + <44482CAF.70309@fuzzy.cz> + <5C372D71-D189-4AA7-A857-1C8FE42311AE@clickspace.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Archive-Number: 200604/487 +X-Sequence-Number: 18571 + +On Thu, 20 Apr 2006, Brendan Duddridge wrote: + +> Hi Tomas, +> +> Hmm... ktrace -p PID -c returns immediately without doing anything +> unless I've previously done a ktrace -p PID. +> +> According to the man page for ktrace's -c flag: +> -c Clear the trace points associated with the specified file +> or processes. + +On other systems, strace/truss with -c produces a list of sys calls with +the number of times they've been called in the elapsed period. + +To answer your other question, temporarily disabling fsync during the +recovery should speed it up. + +For future reference, processing thousands of WAL files for recovery is +not ideal. You should be doing a base backup much more often. + +Gavin + +From pgsql-performance-owner@postgresql.org Thu Apr 20 22:38:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id D36B011F6761 + for ; + Thu, 20 Apr 2006 22:38:32 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.367 +X-Spam-Level: +X-Spam-Status: No, score=-0.367 required=5 tests=[BAYES_00=-2.599, + RCVD_IN_WHOIS_INVALID=2.234, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id uCFKx7XA3dfQ + for ; + Thu, 20 Apr 2006 22:38:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.ustc.edu.cn (ns.ustc.edu.cn [202.38.64.1]) + by postgresql.org (Postfix) with ESMTP id 3059C11F66D5 + for ; + Thu, 20 Apr 2006 22:38:22 -0300 (ADT) +Received: from localhost.localdomain ([211.86.144.78]) + by mx1.ustc.edu.cn (8.11.6/8.11.6) with ESMTP id k3L1Ypw08477 + for ; Fri, 21 Apr 2006 09:34:52 +0800 +Received: from wfg by localhost.localdomain with local (Exim 4.50) + id 1FWkbK-0001Ma-RZ + for pgsql-performance@postgresql.org; Fri, 21 Apr 2006 09:38:26 +0800 +Date: Fri, 21 Apr 2006 09:38:26 +0800 +From: Wu Fengguang +To: pgsql-performance@postgresql.org +Subject: Introducing a new linux readahead framework +Message-ID: <20060421013826.GA5217@mail.ustc.edu.cn> +Mail-Followup-To: Wu Fengguang , + pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.11+cvs20060126 +X-Archive-Number: 200604/488 +X-Sequence-Number: 18572 + +Greetings, + +I'd like to introduce a new readahead framework for the linux kernel: +http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1021.html + +HOW IT WORKS + +In adaptive readahead, the context based method may be of particular +interest to postgresql users. It works by peeking into the file cache +and check if there are any history pages present or accessed. In this +way it can detect almost all forms of sequential / semi-sequential read +patterns, e.g. + - parallel / interleaved sequential scans on one file + - sequential reads across file open/close + - mixed sequential / random accesses + - sparse / skimming sequential read + +It also have methods to detect some less common cases: + - reading backward + - seeking all over reading N pages + +WAYS TO BENEFIT FROM IT + +As we know, postgresql relies on the kernel to do proper readahead. +The adaptive readahead might help performance in the following cases: + - concurrent sequential scans + - sequential scan on a fragmented table + (some DBs suffer from this problem, not sure for pgsql) + - index scan with clustered matches + - index scan on majority rows (in case the planner goes wrong) + +TUNABLE PARAMETERS + +There are two parameters which are described in this email: +http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1024.html + +Here are the more oriented guidelines for postgresql users: + +- /proc/sys/vm/readahead_ratio +Since most DB servers are bounty of memory, the danger of readahead +thrashing is near to zero. In this case, you can set readahead_ratio to +100(or even 200:), which helps the readahead window to scale up rapidly. + +- /proc/sys/vm/readahead_hit_rate +Sparse sequential reads are read patterns like {0, 2, 4, 5, 8, 11, ...}. +In this case we might prefer to do readahead to get good I/O performance +with the overhead of some useless pages. But if you prefer not to do so, +set readahead_hit_rate to 1 will disable this feature. + +- /sys/block/sd/queue/read_ahead_kb +Set it to a large value(e.g. 4096) as you used to do. +RAID users might want to use a bigger number. + +TRYING IT OUT + +The latest patch for stable kernels can be downloaded here: +http://www.vanheusden.com/ara/ + +Before compiling, make sure that the following options are enabled: +Processor type and features -> Adaptive file readahead +Processor type and features -> Readahead debug and accounting + +HELPING AND CONTRIBUTING + +The patch is open to fine-tuning advices :) +Comments and benchmarking results are highly appreciated. + +Thanks, +Wu + +From pgsql-performance-owner@postgresql.org Fri Apr 21 01:31:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id BB60011F605C + for ; + Fri, 21 Apr 2006 01:31:51 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.274 +X-Spam-Level: +X-Spam-Status: No, score=0.274 required=5 tests=[AWL=0.274] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id KR09v-6IZXOw + for ; + Fri, 21 Apr 2006 01:31:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B2BBF11F6C52 + for ; + Fri, 21 Apr 2006 01:31:48 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id E88D956431; Thu, 20 Apr 2006 23:31:47 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 20 Apr 2006 23:31:47 -0500 +Date: Thu, 20 Apr 2006 23:31:47 -0500 +From: "Jim C. Nasby" +To: Wu Fengguang , pgsql-performance@postgresql.org +Subject: Re: Introducing a new linux readahead framework +Message-ID: <20060421043147.GV49405@pervasive.com> +References: <20060421013826.GA5217@mail.ustc.edu.cn> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060421013826.GA5217@mail.ustc.edu.cn> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060421:wfg@mail.ustc.edu.cn::dhdGYnup1eZC4beE:00000000000000000 + 0000000000000000000000001xhN +X-Hashcash: + 1:20:060421:pgsql-performance@postgresql.org::s8mdlecibDykISyn:00000 + 0000000000000000000000002fWB +X-Archive-Number: 200604/489 +X-Sequence-Number: 18573 + +On Fri, Apr 21, 2006 at 09:38:26AM +0800, Wu Fengguang wrote: +> Greetings, +> +> I'd like to introduce a new readahead framework for the linux kernel: +> http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1021.html +> +> HOW IT WORKS +> +> In adaptive readahead, the context based method may be of particular +> interest to postgresql users. It works by peeking into the file cache +> and check if there are any history pages present or accessed. In this +> way it can detect almost all forms of sequential / semi-sequential read +> patterns, e.g. +> - parallel / interleaved sequential scans on one file +> - sequential reads across file open/close +> - mixed sequential / random accesses +> - sparse / skimming sequential read +> +> It also have methods to detect some less common cases: +> - reading backward +> - seeking all over reading N pages + +Are there any ways to inform the kernel that you either are or aren't +doing a sequential read? It seems that in some cases it would be better +to bypass a bunch of tricky logic trying to determine that it's doing a +sequential read. A sequential scan in PostgreSQL would be such a case. + +The opposite example would be an index scan of a highly uncorrelated +index, which would produce mostly random reads from the table. In that +case, reading ahead probably makes very little sense, though your logic +might have a better idea of the access pattern than PostgreSQL does. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri Apr 21 01:42:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id D4DCD11F60B0 + for ; + Fri, 21 Apr 2006 01:42:30 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599, + HTML_MESSAGE=0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id BH3dmPlFi3Wc + for ; + Fri, 21 Apr 2006 01:42:25 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.181]) + by postgresql.org (Postfix) with ESMTP id D924311F6077 + for ; + Fri, 21 Apr 2006 01:42:24 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so381661pye + for ; + Thu, 20 Apr 2006 21:42:24 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=o2KCLEQMJA+xUO+JEueetCdtymOTK6F5iw6yUlrG2i5Pv+vLNgwfmuiXQj79qWBlaxJ6+zzBf1JUPyaNUe+0DzZ1jyQtD3GbUWiv5KQWUFcsA8A9l8JGeaJEWiojbHXtjvOI/UNtjY10uKjSqI3mpLCOHjHM83EKxqQrR1r4gQw= +Received: by 10.35.97.17 with SMTP id z17mr1998052pyl; + Thu, 20 Apr 2006 21:42:24 -0700 (PDT) +Received: by 10.35.31.15 with HTTP; Thu, 20 Apr 2006 21:42:24 -0700 (PDT) +Message-ID: <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> +Date: Fri, 21 Apr 2006 10:12:24 +0530 +From: "soni de" +To: "Merlin Moncure" +Subject: Re: Takes too long to fetch the data from database +Cc: pgsql-performance@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_13063_2413221.1145594544005" +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> + + <9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com> + +X-Archive-Number: 200604/490 +X-Sequence-Number: 18574 + +------=_Part_13063_2413221.1145594544005 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I don't want to query exactly 81900 rows into set. I just want to fetch 50 +or 100 rows at a time in a decreasing order of stime.(i.e 50 or 100 rows +starting from last to end). + +if we fetched sequentially, there is also problem in fetching all the +records (select * from wan where kname=3D'pluto' order by stime) it is taki= +ng +more than 4~5 minutes. tried it on same table having more than 326054 +records. + + +On 4/20/06, Merlin Moncure wrote: +> +> > SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET 81900; +> +> you need to try and solve the problem without using 'offset'. you could +> do: +> BEGIN; +> DECLARE crs cursor FOR SELECT * FROM wan ORDER BY stime; +> FETCH ABSOLUTE 81900 in crs; +> FETCH 49 in crs; +> CLOSE crs; +> COMMIT; +> +> this may be a bit faster but will not solve the fundamental problem. +> +> the more interesting question is why you want to query exactly 81900 +> rows into a set. This type of thinking will always get you into +> trouble, absolute positioning will not really work in a true sql +> sense. if you are browsing a table sequentially, there are much +> better methods. +> +> merlin +> + +------=_Part_13063_2413221.1145594544005 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
I don't want to query exactly 81900 rows into set. I just want to fetc= +h 50 or 100 rows at a time in a decreasing order of stime.(i.e 50 or 100 ro= +ws starting from last to end).
+
 
+
if we fetched sequentially, there is also problem in fetching all the = +records (select * from wan where kname=3D'pluto' order by stime) it is= + taking more than 4~5 minutes. tried it on same table having more than 3260= +54 records. +
+

 
+
On 4/20/06, = +Merlin Moncure <mmoncure@gmail= +.com> wrote: +
> SELECT * FROM wan ORDER BY = +stime LIMIT 50 OFFSET 81900;

you need to try and solve the problem w= +ithout using 'offset'.  you could do: +
BEGIN;
DECLARE crs cursor FOR SELECT * FROM wan ORDER BY stime;
F= +ETCH ABSOLUTE 81900 in crs;
FETCH 49 in crs;
CLOSE crs;
COMMIT;
this may be a bit faster but will not solve the fundamental problem. +

the more interesting question is why you want to query exactly 8190= +0
rows into a set.  This type of thinking will always get you = +into
trouble, absolute positioning will not really work in a true sqlsense.  if you are browsing a table sequentially, there are much +
better methods.

merlin

+ +------=_Part_13063_2413221.1145594544005-- + +From pgsql-performance-owner@postgresql.org Fri Apr 21 02:22:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id CCE0611F6D2E + for ; + Fri, 21 Apr 2006 02:22:34 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.482 +X-Spam-Level: +X-Spam-Status: No, score=-2.482 required=5 tests=[AWL=0.118, BAYES_00=-2.599, + SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id pf4gTGthASFf + for ; + Fri, 21 Apr 2006 02:22:32 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) + by postgresql.org (Postfix) with SMTP id F2A1F11F6D2C + for ; + Fri, 21 Apr 2006 02:22:30 -0300 (ADT) +Received: (qmail invoked by alias); 21 Apr 2006 05:22:29 -0000 +Received: from dslb-084-057-005-138.pools.arcor-ip.net (EHLO ltmku) + [84.57.5.138] + by mail.gmx.net (mp036) with SMTP; 21 Apr 2006 07:22:29 +0200 +X-Authenticated: #23352258 +From: "Milen Kulev" +To: "'Luke Lonergan'" +Cc: +Subject: Re: Quick Performance Poll +Date: Fri, 21 Apr 2006 07:22:24 +0200 +Message-ID: <002101c66503$95741d80$0a00a8c0@trivadis.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +In-reply-to: +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Importance: Normal +X-Y-GMX-Trusted: 0 +X-Archive-Number: 200604/491 +X-Sequence-Number: 18575 + +Hi Luke, +Thank you very much for your prompt reply. +I have got ***much*** more information than expected ;) + +Obviously there are thing to be improved in the current implementation of BMP indexes, +But anyway they are worth usung (I wa pretty impressed from the BMP index performance, after +Reading a PDF document on Bizgres site). + +Thanks ahain for the information. + +Regards. Milen + +-----Original Message----- +From: Luke Lonergan [mailto:llonergan@greenplum.com] +Sent: Thursday, April 20, 2006 11:28 PM +To: Milen Kulev +Cc: pgsql-performance@postgresql.org; bizgres-general +Subject: Re: [PERFORM] Quick Performance Poll + + +Milen, + +On 4/20/06 12:45 PM, "Milen Kulev" wrote: + +> I (still) haven't tried Bizgres, but what do you mean with "The +> current drawback to bitmap index is that it isn't very maintainable +> under insert/update, although it is safe for those operations"? + +Yes. + +> Do you mean that INSERT/UPDATE operations against bitmap indexes are +> imperformant ? If yes, to what extend ? + +Insert/Update (but not delete) operations will often invalidate a bitmap index in our current implementation because we +have not implemented a maintenance method for them when insertions re-use TIDs. We are in the planning stages for an +update that will fix this. + +> Or you mean that bitmap index corruption is possible when issueing DML +> againts BMP indexes? + +We check for the case of an insertion that causes a re-used TID and issue an error that indicates the index should be +removed before the operation is retried. This isn't particularly useful for cases where inserts occur frequently, so +the current use-case if for tables where DML should be done in batches after removing the index, then the index +re-applied. + +> I am asking this question because Oracle needed 3 years to solve its +> BMP index problems (BMP index corruption/ space usage explosion when +> several processes are performing DML operations ). + +We will be much faster than that! Concurrency will be less than ideal with our maintenance approach initially, but +there shouldn't be a corruption problem. + +> Is Bizgres implementation suffering from this kind child deseases ? + +Sneeze, cough. + +- Luke +> +> +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Luke +> Lonergan +> Sent: Thursday, April 20, 2006 5:03 PM +> To: jim@contactbda.com; Simon Dale; pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Quick Performance Poll +> +> +> Jim, +> +> On 4/20/06 7:40 AM, "Jim Buttafuoco" wrote: +> +>> First of all this is NOT a single table and yes I am using +>> partitioning and the constaint exclusion stuff. the largest set of +>> tables is over 2T. I have not had to rebuild the biggest database +>> yet, but for a smaller one ~1T the restore takes about 12 hours +>> including many indexes on both large and small tables +> +> You would probably benefit greatly from the new on-disk bitmap index +> feature in Bizgres Open Source. It's 8.1 plus the sort speed +> improvement and on-disk bitmap index. +> +> Index creation and sizes for the binary version are in the table below +> (from a performance report on bizgres network. The version in CVS tip +> on pgfoundry is much faster on index creation as well. +> +> The current drawback to bitmap index is that it isn't very +> maintainable under insert/update, although it is safe for those +> operations. For now, you have to drop index, do inserts/updates, +> rebuild index. +> +> We'll have a version that is maintained for insert/update next. +> +> - Luke +> +> # Indexed Columns Create Time (seconds) Space Used (MBs) +> BITMAP BTREE BITMAP BTREE +> 1 L_SHIPMODE 454.8 2217.1 58 1804 +> 2 L_QUANTITY 547.2 937.8 117 1804 +> 3 L_LINENUMBER 374.5 412.4 59 1285 +> 4 L_SHIPMODE, L_QUANTITY 948.7 2933.4 176 2845 +> 5 O_ORDERSTATUS 83.5 241.3 5 321 +> 6 O_ORDERPRIORITY 108.5 679.1 11 580 +> 7 C_MKTSEGMENT 10.9 51.3 1 45 +> 8 C_NATIONKEY 8.3 9.3 2 32 +> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> +> +> + + + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 04:15:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 0CB5411F8CB4 + for ; + Fri, 21 Apr 2006 04:15:54 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.367 +X-Spam-Level: +X-Spam-Status: No, score=-0.367 required=5 tests=[BAYES_00=-2.599, + RCVD_IN_WHOIS_INVALID=2.234, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 5HeeSGiHyPhi + for ; + Fri, 21 Apr 2006 04:15:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.ustc.edu.cn (ns.ustc.edu.cn [202.38.64.1]) + by postgresql.org (Postfix) with ESMTP id 293A511F8C96 + for ; + Fri, 21 Apr 2006 04:15:41 -0300 (ADT) +Received: from localhost.localdomain ([211.86.144.78]) + by mx1.ustc.edu.cn (8.11.6/8.11.6) with ESMTP id k3L7BXw11816; + Fri, 21 Apr 2006 15:11:36 +0800 +Received: from wfg by localhost.localdomain with local (Exim 4.50) + id 1FWprD-0001II-7x; Fri, 21 Apr 2006 15:15:11 +0800 +Date: Fri, 21 Apr 2006 15:15:11 +0800 +From: Wu Fengguang +To: "Jim C. Nasby" +Cc: pgsql-performance@postgresql.org +Subject: Re: Introducing a new linux readahead framework +Message-ID: <20060421071511.GA4885@mail.ustc.edu.cn> +Mail-Followup-To: Wu Fengguang , + "Jim C. Nasby" , + pgsql-performance@postgresql.org +References: <20060421013826.GA5217@mail.ustc.edu.cn> + <20060421043147.GV49405@pervasive.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060421043147.GV49405@pervasive.com> +User-Agent: Mutt/1.5.11+cvs20060126 +X-Archive-Number: 200604/492 +X-Sequence-Number: 18576 + +On Thu, Apr 20, 2006 at 11:31:47PM -0500, Jim C. Nasby wrote: +> > In adaptive readahead, the context based method may be of particular +> > interest to postgresql users. It works by peeking into the file cache +> > and check if there are any history pages present or accessed. In this +> > way it can detect almost all forms of sequential / semi-sequential read +> > patterns, e.g. +> > - parallel / interleaved sequential scans on one file +> > - sequential reads across file open/close +> > - mixed sequential / random accesses +> > - sparse / skimming sequential read +> > +> > It also have methods to detect some less common cases: +> > - reading backward +> > - seeking all over reading N pages +> +> Are there any ways to inform the kernel that you either are or aren't +> doing a sequential read? It seems that in some cases it would be better + +This call will disable readahead totally for fd: + posix_fadvise(fd, any, any, POSIX_FADV_RANDOM); + +This one will reenable it: + posix_fadvise(fd, any, any, POSIX_FADV_NORMAL); + +This one will enable readahead _and_ set max readahead window to +2*max_readahead_kb: + posix_fadvise(fd, any, any, POSIX_FADV_SEQUENTIAL); + +> to bypass a bunch of tricky logic trying to determine that it's doing a +> sequential read. A sequential scan in PostgreSQL would be such a case. + +You do not need to worry about the detecting `overhead' on sequential +scans :) The adaptive readahead framework has a fast code path(the +stateful method) to handle normal sequential reads, the detection of +which is really trivial. + +> The opposite example would be an index scan of a highly uncorrelated +> index, which would produce mostly random reads from the table. In that +> case, reading ahead probably makes very little sense, though your logic +> might have a better idea of the access pattern than PostgreSQL does. + +As for the index scans, the failsafe code path(i.e. the context based +one) will normally be used, and it does have a little overhead in +looking up the page cache(about 0.4% more CPU time). However, the +penalty of random disk access is so large that if ever it helps +reducing a small fraction of disk accesses, you wins. + +Thanks, +Wu + +From pgsql-performance-owner@postgresql.org Fri Apr 21 04:53:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 4CC3711F8C58 + for ; + Fri, 21 Apr 2006 04:53:25 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.202 +X-Spam-Level: +X-Spam-Status: No, score=-2.202 required=5 tests=[AWL=0.262, BAYES_00=-2.599, + FORGED_RCVD_HELO=0.135] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id PGhUKOPLHu8W + for ; + Fri, 21 Apr 2006 04:53:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id E012211F6559 + for ; + Fri, 21 Apr 2006 04:53:20 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T8eeb.t.pppool.de + [89.55.142.235]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 6659D656CB; + Fri, 21 Apr 2006 09:54:20 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 9BBE8181C1F57; + Fri, 21 Apr 2006 09:53:34 +0200 (CEST) +Message-ID: <44488F7E.6060704@logix-tt.com> +Date: Fri, 21 Apr 2006 09:53:34 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Wu Fengguang +Cc: pgsql-performance@postgresql.org +Subject: Re: Introducing a new linux readahead framework +References: <20060421013826.GA5217@mail.ustc.edu.cn> + <20060421043147.GV49405@pervasive.com> + <20060421071511.GA4885@mail.ustc.edu.cn> +In-Reply-To: <20060421071511.GA4885@mail.ustc.edu.cn> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/493 +X-Sequence-Number: 18577 + +Hi, Wu, + +Wu Fengguang wrote: + +>>>In adaptive readahead, the context based method may be of particular +>>>interest to postgresql users. It works by peeking into the file cache +>>>and check if there are any history pages present or accessed. In this +>>>way it can detect almost all forms of sequential / semi-sequential read +>>>patterns, e.g. +>>> - parallel / interleaved sequential scans on one file +>>> - sequential reads across file open/close +>>> - mixed sequential / random accesses +>>> - sparse / skimming sequential read +>>> +>>>It also have methods to detect some less common cases: +>>> - reading backward +>>> - seeking all over reading N pages + +Gread news, thanks! + +> This call will disable readahead totally for fd: +> posix_fadvise(fd, any, any, POSIX_FADV_RANDOM); +> +> This one will reenable it: +> posix_fadvise(fd, any, any, POSIX_FADV_NORMAL); +> +> This one will enable readahead _and_ set max readahead window to +> 2*max_readahead_kb: +> posix_fadvise(fd, any, any, POSIX_FADV_SEQUENTIAL); + +I think that this is an easy, understandable and useful interpretation +of posix_fadvise() hints. + + +Are there any rough estimates when this will get into mainline kernel +(if you intend to submit)? + +Thanks, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Fri Apr 21 05:54:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id E073E11F8B99 + for ; + Fri, 21 Apr 2006 05:54:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id uSnoh3kWcXyB + for ; + Fri, 21 Apr 2006 05:54:31 -0300 (ADT) +X-Greylist: delayed 00:17:32.05536 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 2357B11F872A + for ; + Fri, 21 Apr 2006 05:54:28 -0300 (ADT) +Received: from rzcomm22.rz.tu-bs.de (rzcomm22.rz.tu-bs.de [134.169.9.68]) + by svr4.postgresql.org (Postfix) with ESMTP id 151C65AF9E3 + for ; + Fri, 21 Apr 2006 08:36:56 +0000 (GMT) +Received: from [134.169.64.209] (imt81.imt.ing.tu-bs.de [134.169.64.209]) + by rzcomm22.rz.tu-bs.de (8.13.4/8.13.4) with ESMTP id k3L8ap0W012001 + for ; Fri, 21 Apr 2006 10:36:52 +0200 + (envelope-from jdi@l4x.org) +Message-ID: <444899B6.6090001@l4x.org> +Date: Fri, 21 Apr 2006 10:37:10 +0200 +From: Jan Dittmer +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Better way to write aggregates? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/494 +X-Sequence-Number: 18578 + +Hi, + +I more or less often come about the problem of aggregating a +child table counting it's different states. The cleanest solution +I've come up with so far is: + +BEGIN; +CREATE TABLE parent ( + id int not null, + name text not null, + UNIQUE(id) +); + +CREATE TABLE child ( + name text not null, + state int not null, + parent int not null references parent(id) +); + +CREATE VIEW parent_childs AS +SELECT + c.parent, + count(c.state) as childtotal, + count(c.state) - count(nullif(c.state,1)) as childstate1, + count(c.state) - count(nullif(c.state,2)) as childstate2, + count(c.state) - count(nullif(c.state,3)) as childstate3 +FROM child c +GROUP BY parent; + +CREATE VIEW parent_view AS +SELECT p.*, +pc.* +FROM parent p +LEFT JOIN parent_childs pc ON (p.id = pc.parent); +COMMIT; + +Is this the fastest way to build these aggregates (not considering +tricks with triggers, etc)? The count(state) - count(nullif(...)) looks +a bit clumsy. +I also experimented with a pgsql function to sum these up, but considered +it as not-so-nice and it also always forces a sequential scan on the +data. + +Thanks for any advice, + +Jan + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 07:01:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id F12E511F8B7D + for ; + Fri, 21 Apr 2006 07:01:35 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.598 +X-Spam-Level: +X-Spam-Status: No, score=-2.598 required=5 tests=[BAYES_00=-2.599, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id Dsh8QG13E4ga + for ; + Fri, 21 Apr 2006 07:01:21 -0300 (ADT) +X-Greylist: delayed 00:27:53.936718 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 7ACD211F8BD1 + for ; + Fri, 21 Apr 2006 07:01:12 -0300 (ADT) +Received: from smtp1.voila.fr (smtp2.voila.fr [193.252.22.175]) + by svr4.postgresql.org (Postfix) with ESMTP id AA7095AFA24 + for ; + Fri, 21 Apr 2006 09:33:19 +0000 (GMT) +Received: from me-wanadoo.net (localhost [127.0.0.1]) + by mwinf4112.voila.fr (SMTP Server) with ESMTP id AC6CE1C0043F + for ; + Fri, 21 Apr 2006 11:33:15 +0200 (CEST) +Received: from wwinf4104 (wwinf4104 [172.22.152.31]) + by mwinf4112.voila.fr (SMTP Server) with ESMTP id 9560F1C0040C + for ; + Fri, 21 Apr 2006 11:33:15 +0200 (CEST) +X-ME-UUID: 20060421093315611.9560F1C0040C@mwinf4112.voila.fr +Message-ID: <4673479.1145611995600.JavaMail.www@wwinf4104> +From: luchot +Reply-To: luchot@voila.fr +To: pgsql-performance@postgresql.org +Subject: Little use of CPU ( < 5%) +Mime-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_14449_10775149.1145611995598" +X-Originating-IP: [129.185.75.10] +X-Wum-Nature: EMAIL-NATURE +X-WUM-FROM: |~| +X-WUM-TO: |~| +X-WUM-REPLYTO: |~| +Date: Fri, 21 Apr 2006 11:33:15 +0200 (CEST) +X-Archive-Number: 200604/495 +X-Sequence-Number: 18579 + +------=_Part_14449_10775149.1145611995598 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit + +Hello , + +I have a problem of performance with a query. I use PostgreSQL 8.1.3. + +The distribution of Linux is Red Hat Enterprise Linux ES release 4 (Nahant Update 2) and the server is a bi-processor Xeon 2.4GHz with 1 Go of Ram and the size of the database files is about 60 Go. + +The problem is that this query uses only a few percentage of the cpu as seen with the top command : + +PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND +3342 postgres 18 0 140m 134m 132m D 5.9 13.3 17:04.06 postmaster + +The vm stat command : +procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- + r b swpd free buff cache si so bi bo in cs us sy id wa + 0 1 184 16804 38104 933516 0 0 3092 55 667 145 12 4 71 14 + 0 1 184 16528 38140 933480 0 0 2236 0 1206 388 2 1 50 47 + 0 1 184 15008 38188 935252 0 0 2688 92 1209 396 2 0 49 48 + + +The config of PostgresQL is : + + +shared_buffers = 16384 (128Mo) +work_mem = 65536 (64 Mo) +maintenance_work_mem = 98304 (96 Mo) +effective_cache_size = 84000 + +I think that the problem is there are too much %wait that are waiting cause of the really bad rate of lecture (bi) which is only 3 Mo/s . +It is this value I do not understand because whit other queries this rate is about 120 Mo/s. I use SCSI DISK and a RAID 0 hardware system . + +This is the query plan of the query : + + QUERY PLAN +------------------------------------------------------------------------------------------------------------ + Aggregate (cost=24582205.20..24582205.22 rows=1 width=13) + -> Nested Loop (cost=2.11..24582054.88 rows=60129 width=13) + Join Filter: ("inner".l_quantity < (subplan)) + -> Seq Scan on part (cost=0.00..238744.00 rows=6013 width=4) + Filter: ((p_brand = 'Brand#51'::bpchar) AND (p_container = 'MED JAR'::bpchar)) + -> Bitmap Heap Scan on lineitem (cost=2.11..126.18 rows=31 width=27) + Recheck Cond: ("outer".p_partkey = lineitem.l_partkey) + -> Bitmap Index Scan on id_partkey_lineitem (cost=0.00..2.11 rows=31 width=0) + Index Cond: ("outer".p_partkey = lineitem.l_partkey) + SubPlan + -> Aggregate (cost=126.50..126.51 rows=1 width=10) + -> Index Scan using id_partkey_lineitem on lineitem (cost=0.00..126.42 rows=31 width=10) + Index Cond: (l_partkey = $0) +(13 rows) + + +The number of tuples in Lineitem is 180 000 000. + +So my question is what I have to do to increase the rate of the read which improve the execution of the query? +I add that the server is only dedicated for PostgreSQL. + +Regards, +------=_Part_14449_10775149.1145611995598 +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +

Hello ,

+

 

+

I have a problem of performance with a query. I use P= +ostgreSQL 8.1.3.

+

 

+

The distribution of Linux is Red Hat En= +terprise Linux ES release 4 (Nahant Update 2) and the server is a bi-proces= +sor Xeon 2.4GH= +z with 1 Go of Ram and the size of the database files is about 60 Go.<= +/o:p>

+

 

+

The problem is that this query uses only a few percen= +tage of the cpu as seen with the top command :

+

 

+

PID USER      PR  NI  VIRT  RES= +  SHR S %CPU %MEM    TIME+  COMMAND &= +nbsp;        +

3342 postgres  18   0  14= +0m 134m 132m D  5.9 13.3  17:04.06 postmaster

+

 

+

The vm stat command : 

+

procs ---------= +--memory---------- ---swap-- -----io---- --system-- ----cpu----<= +/FONT>

+

 r  <= +/SPAN>b   swpd   free   buff  cache     &n= +bsp;    si &nb= +sp; so    bi= +    bo   in      cs     us&nbs= +p; sy  id wa

+

 0  1<= +SPAN style=3D"mso-spacerun: yes">    184  16804  38104 933516  &n= +bsp; 0    0&= +nbsp; 3092    55  667   145&nbs= +p; 12  4   71 14

+

 0  1    184  16528  38140 933480    0    0= +  2236    = +; 0 1206   388   2   1  50 47

+

 0&= +nbsp; 1    1= +84  15008  38188 935252&= +nbsp;   0  &nb= +sp; 0  2688    92 1209    396  2  0  49 48

+

 

+

 

+

The config of PostgresQL is : 

+

 

+

 

+

shared_buffers =3D 16384            (128Mo)

+

work_mem =3D 65536          (64 Mo)= +

+

maintenance_work_mem =3D 98304  (96 Mo)

+

effective_= +cache_size =3D 84000

+

 

+

I think that the problem is there are too much= +  %wait  that are waiting cause of the really bad rate of = +lecture (bi) which is only 3 Mo/s .

+

It is this value I do not understand because whit other queries this rate = +is about 120 Mo/s. I use SCSI DISK and a RAID 0 hardware system .

+

 

+

This is the query plan of the query :

+

 

+

  = +            &nb= +sp;            = +            &nb= +sp;         QUERY PLAN        = +;      &n= +bsp;            = +;            &n= +bsp;         

+

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

+

 Aggregate  (cost=3D24582205.= +20..24582205.22 rows=3D1 width=3D13)

+

  = + ->  Nested Loop  (cost=3D2.11..24582054.88 rows= +=3D60129 width=3D13)

+

  = +       Join Filter: ("inner".l_quantity < (= +subplan))

+

         ->= +  Seq Scan on part  (cost=3D0.00..238744.00 rows=3D6013 width=3D4)

+

  = +             Filter: ((p_brand =3D 'Brand#51'::bpchar) AND (p_container =3D 'MED JA= +R'::bpchar))

+

  = +       ->  Bitmap Heap Scan on lineitem  (cost=3D2.11..126.18 rows=3D31 width=3D27)

+

  = +             Recheck Cond: ("outer".p_partkey =3D lineitem.l_partkey)

+

  = +             ->  Bitmap Index Scan= + on id_partkey_lineitem  (cos= +t=3D0.00..2.11 rows=3D31 width=3D0)

+

  = +            &nb= +sp;      Index Cond: ("outer".p_partkey =3D= + lineitem.l_partkey)

+

  = +       SubPlan

+

  = +         ->  Aggregate  (cost=3D126.50..126.51 rows=3D1 width=3D10)

+

  = +            &nb= +sp;  ->  Index= + Scan using id_partkey_lineitem on lineitem  (cost=3D0.00..126.42 rows=3D31 width=3D10)

+

  = +            &nb= +sp;        Index Cond: (l_partkey= + =3D $0)

+

(13 rows)

+

 

+

 

+

The number of tuples in Lineitem is 180 000 000.<= +/SPAN>

+

 

+

So my question is what I have to do to increase the rate of the read which= + improve the execution of the query?

+

I add that the server is only dedicated for PostgreSQL.<= +/FONT>

+

 

+

Regards,

+------=_Part_14449_10775149.1145611995598-- + + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 02:27:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 45A0911F748A + for ; + Fri, 21 Apr 2006 07:29:07 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id Zo4yUbW8NlVP + for ; + Fri, 21 Apr 2006 07:29:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id C568111F74AF + for ; + Fri, 21 Apr 2006 07:28:58 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id E98BE30DB2; Fri, 21 Apr 2006 12:28:55 +0200 (MET DST) +From: "Friends" +X-Newsgroups: pgsql.performance +Subject: security for row level but not based on Database user's login +Date: 21 Apr 2006 03:28:48 -0700 +Organization: http://groups.google.com +Lines: 53 +Message-ID: <1145615328.300612.56380@e56g2000cwe.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; + .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: e56g2000cwe.googlegroups.com; posting-host=203.196.152.82; + posting-account=FZagEA0AAABb9KJXdICpyvcEDyIZJqPB +To: pgsql-performance@postgresql.org +X-Archive-Number: 200604/538 +X-Sequence-Number: 18622 + +Hi + +I need to set security for row level but not based on Database user's +login. It should be based on the user table login. For the particular +user I need to allow only the particular records to access insert, +update delete and select. + +Let me explain clearly + +For example think we are using asp/asp.net website + +Eg: + +www.test.com + +So take this is our website and if you try this URL then you will get a +window for Login name and password. + For example the Login name is windows user name (Here windows user +means server windows user and not client) and windows password. So if +you have login user id you can able to login in our site and we have +another check. We have our own usertable this table consist all the +user login names and user rights. We will check the windows user who +login in our site has rights in the usertable I mean he is present in +the usertable if he is not present then we will display a message you +have no rights to access this site. + If he has login id in our usertable then he allowed viewing our +pages. Still if he has the login id we will check the user who login +has how much right to access to each page and the records of each table +its all depend on the user rights. + + So, here I need the row level security. For each and every table we +need to check the corresponding user and executing the record produce +lot of business logic problem for us. + So after the user login we need automatically to set row level +security for all the tables. Based on the user who login. + +So from there if we try select * from then we can only able +to get the allowed records to select, insert, update, delete. + +Please can some one help how to solve this? + +Note: + +For some help you can refer the below URL (See in that they only given +about the row level and column level security for each database users +not for our required concept) + +http://www.microsoft.com/technet/prodtechnol/sql/2005/multisec.mspx + + +Thanks in advance +Rams + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 09:20:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id B780111F7820 + for ; + Fri, 21 Apr 2006 09:20:42 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -0.999 +X-Spam-Level: +X-Spam-Status: No, score=-0.999 required=5 tests=[AWL=-0.045, BAYES_00=-2.599, + DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_WHOIS=1.447, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id hi3bS8nArnL8 + for ; + Fri, 21 Apr 2006 09:20:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.ustc.edu.cn (ns.ustc.edu.cn [202.38.64.1]) + by postgresql.org (Postfix) with ESMTP id 858C511F76C0 + for ; + Fri, 21 Apr 2006 09:20:32 -0300 (ADT) +Received: from localhost.localdomain ([211.86.144.78]) + by mx1.ustc.edu.cn (8.11.6/8.11.6) with ESMTP id k3LCGlw02948; + Fri, 21 Apr 2006 20:16:49 +0800 +Received: from wfg by localhost.localdomain with local (Exim 4.50) + id 1FWuce-0001ax-Ap; Fri, 21 Apr 2006 20:20:28 +0800 +Date: Fri, 21 Apr 2006 20:20:28 +0800 +From: Wu Fengguang +To: Markus Schaber +Cc: pgsql-performance@postgresql.org +Subject: Re: Introducing a new linux readahead framework +Message-ID: <20060421122028.GA5937@mail.ustc.edu.cn> +Mail-Followup-To: Wu Fengguang , + Markus Schaber , + pgsql-performance@postgresql.org +References: <20060421013826.GA5217@mail.ustc.edu.cn> + <20060421043147.GV49405@pervasive.com> + <20060421071511.GA4885@mail.ustc.edu.cn> + <44488F7E.6060704@logix-tt.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <44488F7E.6060704@logix-tt.com> +User-Agent: Mutt/1.5.11+cvs20060126 +X-Archive-Number: 200604/496 +X-Sequence-Number: 18580 + +Hi Markus, + +On Fri, Apr 21, 2006 at 09:53:34AM +0200, Markus Schaber wrote: +> Are there any rough estimates when this will get into mainline kernel +> (if you intend to submit)? + +I'm not quite sure :) + +The patch itself has been pretty stable. To get it accepted, we must +back it by good benchmarking results for some important applications. +I have confirmed that file service via FTP/HTTP/NFS can more or less +benefit from it. However, database services have not been touched yet. +Oracle/DB2 seem to bypass the readahead code route, while postgresql +relies totally on kernel readahead logic. So if postgresql is proved +to work well with this patch, it will have good opportunity to go into +mainline :) + +Thanks, +Wu + +From pgsql-performance-owner@postgresql.org Fri Apr 21 09:27:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 688C311F6B5A + for ; + Fri, 21 Apr 2006 09:27:39 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.106 +X-Spam-Level: +X-Spam-Status: No, score=0.106 required=5 tests=[AWL=0.106] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id boJXnThjlGKU + for ; + Fri, 21 Apr 2006 09:27:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from amanda.contactbda.com (ipn36372-e65122.cidr.lightship.net + [216.204.66.226]) + by postgresql.org (Postfix) with ESMTP id 725B111F76F4 + for ; + Fri, 21 Apr 2006 09:27:36 -0300 (ADT) +Received: from amanda.contactbda.com (amanda.contactbda.com [192.168.1.2]) + by amanda.contactbda.com (8.12.11/8.12.11/Debian-3) with ESMTP id + k3LCRWru007655; Fri, 21 Apr 2006 08:27:32 -0400 +From: "Jim Buttafuoco" +To: Jan Dittmer , pgsql-performance@postgresql.org +Reply-To: jim@contactbda.com +Subject: Re: Better way to write aggregates? +Date: Fri, 21 Apr 2006 08:27:32 -0400 +Message-Id: <20060421122617.M81850@contactbda.com> +In-Reply-To: <444899B6.6090001@l4x.org> +References: <444899B6.6090001@l4x.org> +X-Mailer: Open WebMail 2.41 20040926 +X-OriginatingIP: 192.168.1.1 (jim) +MIME-Version: 1.0 +Content-Type: text/plain; + charset=iso-8859-1 +X-Archive-Number: 200604/497 +X-Sequence-Number: 18581 + + +Jan, + +I write queries like this + +CREATE VIEW parent_childs AS +SELECT + c.parent, + count(c.state) as childtotal, + sum(case when c.state = 1 then 1 else 0 end) as childstate1, + sum(case when c.state = 2 then 1 else 0 end) as childstate2, + sum(case when c.state = 3 then 1 else 0 end) as childstate3 + FROM child c + GROUP BY parent; + +---------- Original Message ----------- +From: Jan Dittmer +To: pgsql-performance@postgresql.org +Sent: Fri, 21 Apr 2006 10:37:10 +0200 +Subject: [PERFORM] Better way to write aggregates? + +> Hi, +> +> I more or less often come about the problem of aggregating a +> child table counting it's different states. The cleanest solution +> I've come up with so far is: +> +> BEGIN; +> CREATE TABLE parent ( +> id int not null, +> name text not null, +> UNIQUE(id) +> ); +> +> CREATE TABLE child ( +> name text not null, +> state int not null, +> parent int not null references parent(id) +> ); +> +> CREATE VIEW parent_childs AS +> SELECT +> c.parent, +> count(c.state) as childtotal, +> count(c.state) - count(nullif(c.state,1)) as childstate1, +> count(c.state) - count(nullif(c.state,2)) as childstate2, +> count(c.state) - count(nullif(c.state,3)) as childstate3 +> FROM child c +> GROUP BY parent; +> +> CREATE VIEW parent_view AS +> SELECT p.*, +> pc.* +> FROM parent p +> LEFT JOIN parent_childs pc ON (p.id = pc.parent); +> COMMIT; +> +> Is this the fastest way to build these aggregates (not considering +> tricks with triggers, etc)? The count(state) - count(nullif(...)) looks +> a bit clumsy. +> I also experimented with a pgsql function to sum these up, but considered +> it as not-so-nice and it also always forces a sequential scan on the +> data. +> +> Thanks for any advice, +> +> Jan +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +------- End of Original Message ------- + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 09:35:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id BF0EA11F74C9 + for ; + Fri, 21 Apr 2006 09:35:45 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.549 +X-Spam-Level: +X-Spam-Status: No, score=-2.549 required=5 tests=[AWL=0.050, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id xgt8qCvkuj9Z + for ; + Fri, 21 Apr 2006 09:35:39 -0300 (ADT) +X-Greylist: delayed 03:58:40.75686 by SQLgrey- +Received: from rzcomm22.rz.tu-bs.de (rzcomm22.rz.tu-bs.de [134.169.9.68]) + by postgresql.org (Postfix) with ESMTP id 9B2AD11F74AF + for ; + Fri, 21 Apr 2006 09:35:36 -0300 (ADT) +Received: from [134.169.64.209] (imt81.imt.ing.tu-bs.de [134.169.64.209]) + by rzcomm22.rz.tu-bs.de (8.13.4/8.13.4) with ESMTP id k3LCZY9Z005768; + Fri, 21 Apr 2006 14:35:35 +0200 (envelope-from jdi@l4x.org) +Message-ID: <4448D195.4020801@l4x.org> +Date: Fri, 21 Apr 2006 14:35:33 +0200 +From: Jan Dittmer +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: jim@contactbda.com +CC: pgsql-performance@postgresql.org +Subject: Re: Better way to write aggregates? +References: <444899B6.6090001@l4x.org> <20060421122617.M81850@contactbda.com> +In-Reply-To: <20060421122617.M81850@contactbda.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200604/498 +X-Sequence-Number: 18582 + +Jim Buttafuoco wrote: +> Jan, +> +> I write queries like this +> +> CREATE VIEW parent_childs AS +> SELECT +> c.parent, +> count(c.state) as childtotal, +> sum(case when c.state = 1 then 1 else 0 end) as childstate1, +> sum(case when c.state = 2 then 1 else 0 end) as childstate2, +> sum(case when c.state = 3 then 1 else 0 end) as childstate3 +> FROM child c +> GROUP BY parent; + +It would help if booleans could be casted to integer 1/0 :-) But +performance wise it should be about the same? I think I'll +run some tests later today with real data. +Would an index on NULLIF(state,1) help count(NULLIF(state,1)) ? +Can one build an index on (case when c.state = 3 then 1 else 0 end)? + +Thanks, + +Jan + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 09:39:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9174811F76F4 + for ; + Fri, 21 Apr 2006 09:39:05 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.096 +X-Spam-Level: +X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id sB9frFqZwM1x + for ; + Fri, 21 Apr 2006 09:38:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from amanda.contactbda.com (ipn36372-e65122.cidr.lightship.net + [216.204.66.226]) + by postgresql.org (Postfix) with ESMTP id 98EBB11F76BE + for ; + Fri, 21 Apr 2006 09:39:02 -0300 (ADT) +Received: from amanda.contactbda.com (amanda.contactbda.com [192.168.1.2]) + by amanda.contactbda.com (8.12.11/8.12.11/Debian-3) with ESMTP id + k3LCcwtd008361; Fri, 21 Apr 2006 08:38:58 -0400 +From: "Jim Buttafuoco" +To: Jan Dittmer +Cc: pgsql-performance@postgresql.org +Reply-To: jim@contactbda.com +Subject: Re: Better way to write aggregates? +Date: Fri, 21 Apr 2006 08:38:58 -0400 +Message-Id: <20060421123759.M11447@contactbda.com> +In-Reply-To: <4448D195.4020801@l4x.org> +References: <444899B6.6090001@l4x.org> <20060421122617.M81850@contactbda.com> + <4448D195.4020801@l4x.org> +X-Mailer: Open WebMail 2.41 20040926 +X-OriginatingIP: 192.168.1.1 (jim) +MIME-Version: 1.0 +Content-Type: text/plain; + charset=iso-8859-1 +X-Archive-Number: 200604/499 +X-Sequence-Number: 18583 + + +I don't think an index will help you with this query. + +---------- Original Message ----------- +From: Jan Dittmer +To: jim@contactbda.com +Cc: pgsql-performance@postgresql.org +Sent: Fri, 21 Apr 2006 14:35:33 +0200 +Subject: Re: [PERFORM] Better way to write aggregates? + +> Jim Buttafuoco wrote: +> > Jan, +> > +> > I write queries like this +> > +> > CREATE VIEW parent_childs AS +> > SELECT +> > c.parent, +> > count(c.state) as childtotal, +> > sum(case when c.state = 1 then 1 else 0 end) as childstate1, +> > sum(case when c.state = 2 then 1 else 0 end) as childstate2, +> > sum(case when c.state = 3 then 1 else 0 end) as childstate3 +> > FROM child c +> > GROUP BY parent; +> +> It would help if booleans could be casted to integer 1/0 :-) But +> performance wise it should be about the same? I think I'll +> run some tests later today with real data. +> Would an index on NULLIF(state,1) help count(NULLIF(state,1)) ? +> Can one build an index on (case when c.state = 3 then 1 else 0 end)? +> +> Thanks, +> +> Jan +------- End of Original Message ------- + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 10:26:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id B31B211F66F5 + for ; + Fri, 21 Apr 2006 10:26:50 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.598 +X-Spam-Level: +X-Spam-Status: No, score=-2.598 required=5 tests=[BAYES_00=-2.599, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id 7tsv1ko6BFPD + for ; + Fri, 21 Apr 2006 10:26:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 9E48911F66F1 + for ; + Fri, 21 Apr 2006 10:26:35 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [63.226.156.118] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 88364541; Fri, 21 Apr 2006 06:26:34 -0700 +From: "Dave Dutcher" +To: "'soni de'" +Cc: +Subject: Re: Takes too long to fetch the data from database +Date: Fri, 21 Apr 2006 08:26:33 -0500 +Message-ID: <007801c66547$35e26270$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0079_01C6651D.4D0C5A70" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +In-reply-to: <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +Importance: Normal +X-Archive-Number: 200604/500 +X-Sequence-Number: 18584 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0079_01C6651D.4D0C5A70 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +I've never used a cursor in Postgres, but I don't think it will help you +a lot. In theory cursors make it easier to do paging, but your main +problem is that getting the first page is slow. A cursor isn't going to +be any faster at getting the first page than OFFSET/LIMIT is. + +Did you try Bruno's suggestion of: + +SELECT * FROM wan ORDER BY stime DESC OFFSET 0 LIMIT 50; + +You should run an EXPLAIN ANALYZE on that query to see if it is using an +index scan. Also what version of Postgres are you using? You can run +select version(); to check. + + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of soni de +Sent: Thursday, April 20, 2006 11:42 PM +To: Merlin Moncure +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Takes too long to fetch the data from database + +I don't want to query exactly 81900 rows into set. I just want to fetch +50 or 100 rows at a time in a decreasing order of stime.(i.e 50 or 100 +rows starting from last to end). + +if we fetched sequentially, there is also problem in fetching all the +records (select * from wan where kname='pluto' order by stime) it is +taking more than 4~5 minutes. tried it on same table having more than +326054 records. + + +On 4/20/06, Merlin Moncure wrote: +> SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET 81900; + +you need to try and solve the problem without using 'offset'. you could +do: +BEGIN; +DECLARE crs cursor FOR SELECT * FROM wan ORDER BY stime; +FETCH ABSOLUTE 81900 in crs; +FETCH 49 in crs; +CLOSE crs; +COMMIT; + +this may be a bit faster but will not solve the fundamental problem. + +the more interesting question is why you want to query exactly 81900 +rows into a set. This type of thinking will always get you into +trouble, absolute positioning will not really work in a true sql +sense. if you are browsing a table sequentially, there are much +better methods. + +merlin + + +------=_NextPart_000_0079_01C6651D.4D0C5A70 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + + + + + + +
+ +

I’ve never used a cursor in = +Postgres, but I don’t think it will help you = +a +lot.  In theory cursors = +make it +easier to do paging, but your main problem is that getting the first = +page is +slow.  A cursor isn’t = +going to +be any faster at getting the first page than OFFSET/LIMIT = +is.

+ +

 

+ +

Did you try Bruno’s = +suggestion of:

+ +

 

+ +

SELECT * FROM wan ORDER BY stime +DESC OFFSET 0 LIMIT 50;

+ +

 

+ +

You should run an EXPLAIN ANALYZE = +on that +query to see if it is using an index scan.  +Also what version of Postgres are you +using?  You can run select = +version(); to check.

+ +

 

+ +

 

+ +

 

+ +
+ +

-----Original Message-----
+From: +pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of soni de
+Sent: = +
Thursday, April 20, = +2006 11:42 PM
+To: Merlin Moncure
+Cc: +pgsql-performance@postgresql.org
+Subject: Re: [PERFORM] = +Takes too +long to fetch the data from database

+ +

 

+ +
+ +

I don't want to query exactly 81900 rows into set. I just want = +to fetch +50 or 100 rows at a time in a decreasing order of stime.(i.e 50 or 100 = +rows +starting from last to end).

+ +
+ +
+ +

 

+ +
+ +
+ +

if we fetched sequentially, there is also problem in fetching = +all the +records (select * from wan where kname=3D'pluto' order by stime) it = +is +taking more than 4~5 minutes. tried it on same table having more than = +326054 +records.

+ +
+ +
+ +


+ +
+ +
+ +

On 4/20/06, Merlin = +Moncure +<mmoncure@gmail.com> = +wrote: +

+ +

> SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET 81900;
+
+you need to try and solve the problem without using = +'offset'.  you +could do:
+BEGIN;
+DECLARE crs cursor FOR SELECT * FROM wan ORDER BY stime;
+FETCH ABSOLUTE 81900 in crs;
+FETCH 49 in crs;
+CLOSE crs;
+COMMIT;
+
+this may be a bit faster but will not solve the fundamental problem. = +
+
+the more interesting question is why you want to query exactly 81900
+rows into a set.  This type of thinking will always get you = +into
+trouble, absolute positioning will not really work in a true sql
+sense.  if you are browsing a table sequentially, there are = +much
+better methods.
+
+merlin

+ +
+ +

 

+ +
+ +
+ + + + + +------=_NextPart_000_0079_01C6651D.4D0C5A70-- + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 10:44:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id B263A11F68C6 + for ; + Fri, 21 Apr 2006 10:44:31 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.092 +X-Spam-Level: +X-Spam-Status: No, score=0.092 required=5 tests=[AWL=0.092] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id ApVzVGhLqn9S + for ; + Fri, 21 Apr 2006 10:44:23 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.202]) + by postgresql.org (Postfix) with ESMTP id B9BCF11F6756 + for ; + Fri, 21 Apr 2006 10:44:26 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id 9so371425nzo + for ; + Fri, 21 Apr 2006 06:44:27 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=aVlg/U/GVwP7RFWRlFalsyEaB3Ko7BCjEuwI1oCoTisxa76KSrwhm++g0QBY65G6BoYJcJBXk4SKRk0kWUjiiHjT70dtXWkMGobdT7+ulmFRi7zR21L9S7/kQAzVdDUBK/+X98bjXADxufyPvacnCr/UjuG5Ipfp7G0uszNLFMc= +Received: by 10.65.243.20 with SMTP id v20mr1028269qbr; + Fri, 21 Apr 2006 06:44:25 -0700 (PDT) +Received: by 10.65.137.8 with HTTP; Fri, 21 Apr 2006 06:44:25 -0700 (PDT) +Message-ID: +Date: Fri, 21 Apr 2006 09:44:25 -0400 +From: "Merlin Moncure" +To: "soni de" +Subject: Re: Takes too long to fetch the data from database +Cc: pgsql-performance@postgresql.org +In-Reply-To: <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> + + <9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com> + + <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> +X-Archive-Number: 200604/501 +X-Sequence-Number: 18585 + +On 4/21/06, soni de wrote: +> +> I don't want to query exactly 81900 rows into set. I just want to fetch 5= +0 +> or 100 rows at a time in a decreasing order of stime.(i.e 50 or 100 rows +> starting from last to end). + +aha! you need to implement a 'sliding window' query. simplest is +when you are ordering one field that is unique: + +1st 50: +select * from t order by k limit 50; +2nd 50: +select * from t where k > k1 order by k limit 50: + +if you are ordering on two fields or on a field that is not unique, you mus= +t do: + +1st 50: +select * from t order by j, k limit 50; +2nd 50: +select * from t where j >=3D j1 and (j > j1 or k > k1) order by j, k limit = +50; +3 fields: +select * from t where i >=3D i1 and (i > i1 or j >=3D j1) and (i > i1 or j +> k1 or k > k1) order by i,j,k limit 50; + +i1,j1,k1 are the values of the 50th record you pulled out of the last query= +. + +if this seems a little complicated, either wait for pg 8.2 or get cvs +tip and rewrite as: +select * from t where (i,j,k) > (i1,j1,k1) order by i,j,k limit 50; + +From pgsql-performance-owner@postgresql.org Fri Apr 21 10:54:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 5D46A11F6744 + for ; + Fri, 21 Apr 2006 10:54:23 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.499 +X-Spam-Level: +X-Spam-Status: No, score=-2.499 required=5 tests=[AWL=0.099, BAYES_00=-2.599, + HTML_MESSAGE=0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id JZx9vwpQ8FbR + for ; + Fri, 21 Apr 2006 10:54:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 505F111F678B + for ; + Fri, 21 Apr 2006 10:54:17 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 88367025; Fri, 21 Apr 2006 06:54:17 -0700 +From: "Dave Dutcher" +To: , + +Subject: Re: Little use of CPU ( < 5%) +Date: Fri, 21 Apr 2006 08:54:16 -0500 +Message-ID: <007f01c6654b$15077280$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0080_01C66521.2C316A80" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +In-reply-to: <4673479.1145611995600.JavaMail.www@wwinf4104> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +Importance: Normal +X-Archive-Number: 200604/502 +X-Sequence-Number: 18586 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0080_01C66521.2C316A80 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +Maybe you could post the query and an EXPLAIN ANALYZE of the query. That +would give more information for trying to decide what is wrong. + +So your question is basically why you get a slower read rate on this +query than on other queries? If I had to guess, maybe it could be that +you are scanning an index with a low correlation (The order of the +records in the index is very different then the order of the records on +the disk.) causing your drives to do a lot of seeking. A possible fix +for this might be to cluster the table on the index, but I would check +out the explain analyze first to see which step is really the slow one. + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of luchot +Sent: Friday, April 21, 2006 4:33 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] Little use of CPU ( < 5%) + +Hello , + +I have a problem of performance with a query. I use PostgreSQL 8.1.3. + +The distribution of Linux is Red Hat Enterprise Linux ES release 4 +(Nahant Update 2) and the server is a bi-processor Xeon 2.4GHz with 1 Go +of Ram and the size of the database files is about 60 Go. + +The problem is that this query uses only a few percentage of the cpu as +seen with the top command : + +PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + +3342 postgres 18 0 140m 134m 132m D 5.9 13.3 17:04.06 postmaster + +The vm stat command : +procs -----------memory---------- ---swap-- -----io---- --system-- +----cpu---- + r b swpd free buff cache si so bi bo in +cs us sy id wa + 0 1 184 16804 38104 933516 0 0 3092 55 667 145 12 +4 71 14 + 0 1 184 16528 38140 933480 0 0 2236 0 1206 388 2 +1 50 47 + 0 1 184 15008 38188 935252 0 0 2688 92 1209 396 2 +0 49 48 + + +The config of PostgresQL is : + + +shared_buffers = 16384 (128Mo) +work_mem = 65536 (64 Mo) +maintenance_work_mem = 98304 (96 Mo) +effective_cache_size = 84000 + +I think that the problem is there are too much %wait that are waiting +cause of the really bad rate of lecture (bi) which is only 3 Mo/s . +It is this value I do not understand because whit other queries this +rate is about 120 Mo/s. I use SCSI DISK and a RAID 0 hardware system . + +This is the query plan of the query : + + QUERY PLAN + +------------------------------------------------------------------------ +------------------------------------ + Aggregate (cost=24582205.20..24582205.22 rows=1 width=13) + -> Nested Loop (cost=2.11..24582054.88 rows=60129 width=13) + Join Filter: ("inner".l_quantity < (subplan)) + -> Seq Scan on part (cost=0.00..238744.00 rows=6013 width=4) + Filter: ((p_brand = 'Brand#51'::bpchar) AND (p_container += 'MED JAR'::bpchar)) + -> Bitmap Heap Scan on lineitem (cost=2.11..126.18 rows=31 +width=27) + Recheck Cond: ("outer".p_partkey = lineitem.l_partkey) + -> Bitmap Index Scan on id_partkey_lineitem +(cost=0.00..2.11 rows=31 width=0) + Index Cond: ("outer".p_partkey = +lineitem.l_partkey) + SubPlan + -> Aggregate (cost=126.50..126.51 rows=1 width=10) + -> Index Scan using id_partkey_lineitem on lineitem +(cost=0.00..126.42 rows=31 width=10) + Index Cond: (l_partkey = $0) +(13 rows) + + +The number of tuples in Lineitem is 180 000 000. + +So my question is what I have to do to increase the rate of the read +which improve the execution of the query? +I add that the server is only dedicated for PostgreSQL. + +Regards, + +------=_NextPart_000_0080_01C66521.2C316A80 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + + + + +
+ +

Maybe you could post the query and = +an +EXPLAIN ANALYZE of the query. That would give more information for = +trying to +decide what is wrong.

+ +

 

+ +

So your question is basically why = +you get +a slower read rate on this query than on other queries?  If I had to guess, maybe it = +could be that +you are scanning an index with a low correlation (The order of the = +records in +the index is very different then the order of the records on the disk.) = +causing +your drives to do a lot of seeking.  +A possible fix for this might be to cluster the table on the = +index, but +I would check out the explain analyze first = +to see which +step is really the slow one.

+ +

 

+ +

 

+ +
+ +

-----Original Message-----
+From: = +pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of luchot
+Sent: Friday, April 21, = +2006 4:33 +AM
+To: +pgsql-performance@postgresql.org
+Subject: [PERFORM] Little = +use of +CPU ( < 5%)

+ +

 

+ +

Hello ,

+ +

 

+ +

I have a problem of performance with a query. I use PostgreSQL = +8.1.3.

+ +

 

+ +

The distribution of Linux is Red Hat = +Enterprise +Linux ES release 4 (Nahant Update 2) and the server is a bi-processor = +Xeon 2.4GHz with 1 Go of = +Ram and the +size of the database files is about 60 Go.

+ +

 

+ +

The problem is that this query uses only a few percentage of the = +cpu as +seen with the top command :

+ +

 

+ +

PID +USER      +PR  NI  VIRT  RES  +SHR S %CPU %MEM    +TIME+  COMMAND       &nbs= +p;  +

+ +

3342 postgres  18   0  140m 134m 132m D  5.9 13.3  17:04.06 = +postmaster

+ +

 

+ +

The vm stat command = +: 

+ +

procs -----------memory---------- = +---swap-- +-----io---- --system-- ----cpu----

+ +

 r  +b   swpd   free   buff  cache       &nbs= +p;  +si   so    bi    bo   in      cs     us  sy  +id wa

+ +

 0  1    184  16804  38104 933516    0    0  3092    55  667   145  12  +4   71 = +14

+ +

 0  +1    = +184  16528  38140 933480    0    0  2236     0 1206   388   2   1  50 = +47

+ +

 0  +1    = +184  15008  38188 935252    0    0  2688    92 1209    396  2  +0  49 = +48

+ +

 

+ +

 

+ +

The config of = +PostgresQL is +:  = +

+ +

 

+ +

 

+ +

shared_buffers =3D = +16384        = +;    = +(128Mo)

+ +

work_mem =3D = +65536       &nbs= +p;  +(64 Mo)

+ +

maintenance_work_mem = +=3D +98304  (96 = +Mo)

+ +

effective_cache_size =3D 84000

+ +

 

+ +

I think that the = +problem is +there are too much  = +%wait  that are waiting cause of the = +really bad +rate of lecture (bi) which is only 3 Mo/s .

+ +

It is this value I do = +not +understand because whit other queries this rate is about 120 Mo/s. I use = +SCSI +DISK and a RAID 0 hardware system .

+ +

 

+ +

This is the query = +plan of the +query :

+ +

 

+ +

       &nbs= +p;            = +;            = +            &= +nbsp;    +QUERY PLAN       &nbs= +p;            = +;            = +            &= +nbsp;    +

+ +

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

+ +

 Aggregate  = +(cost=3D24582205.20..24582205.22 rows=3D1 +width=3D13)

+ +

   +->  Nested = +Loop  (cost=3D2.11..24582054.88 = +rows=3D60129 +width=3D13)

+ +

       &nbs= +p; +Join Filter: = +("inner".l_quantity +< (subplan))

+ +

       &nbs= +p; +->  Seq Scan on part  (cost=3D0.00..238744.00 = +rows=3D6013 width=3D4)

+ +

       &nbs= +p;       +Filter: ((p_brand =3D 'Brand#51'::bpchar) AND (p_container =3D = +'MED +JAR'::bpchar))

+ +

       &nbs= +p; +->  Bitmap Heap = +Scan on +lineitem  = +(cost=3D2.11..126.18 rows=3D31 +width=3D27)

+ +

       &nbs= +p;       +Recheck Cond: ("outer".p_partkey =3D = +lineitem.l_partkey)

+ +

       &nbs= +p;       +->  Bitmap Index = +Scan on +id_partkey_lineitem  +(cost=3D0.00..2.11 rows=3D31 = +width=3D0)

+ +

       &nbs= +p;            = +; +Index Cond: ("outer".p_partkey =3D = +lineitem.l_partkey)

+ +

       &nbs= +p; +SubPlan

+ +

       &nbs= +p;   +->  = +Aggregate  (cost=3D126.50..126.51 rows=3D1 = +width=3D10)

+ +

       &nbs= +p;         +->  Index Scan = +using +id_partkey_lineitem on lineitem  +(cost=3D0.00..126.42 rows=3D31 = +width=3D10)

+ +

       &nbs= +p;            = +;   +Index Cond: (l_partkey =3D $0)

+ +

(13 rows)

+ +

 

+ +

 

+ +

The number of tuples = +in +Lineitem is 180 000 000.

+ +

 

+ +

So my question is = +what I have +to do to increase the rate of the read which improve the execution of = +the +query?

+ +

I add that the server = +is only +dedicated for PostgreSQL.

+ +

 

+ +

Regards, = +

+ +
+ +
+ + + + + +------=_NextPart_000_0080_01C66521.2C316A80-- + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 11:26:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 526AC11F60BD + for ; + Fri, 21 Apr 2006 11:26:26 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.385 +X-Spam-Level: +X-Spam-Status: No, score=-2.385 required=5 tests=[AWL=0.216, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id stPvbxBYdR9i + for ; + Fri, 21 Apr 2006 11:26:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id A163311F60A4 + for ; + Fri, 21 Apr 2006 11:26:21 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3LEQG3c009497; + Fri, 21 Apr 2006 10:26:16 -0400 (EDT) +To: Jan Dittmer +cc: jim@contactbda.com, pgsql-performance@postgresql.org +Subject: Re: Better way to write aggregates? +In-reply-to: <4448D195.4020801@l4x.org> +References: <444899B6.6090001@l4x.org> <20060421122617.M81850@contactbda.com> + <4448D195.4020801@l4x.org> +Comments: In-reply-to Jan Dittmer + message dated "Fri, 21 Apr 2006 14:35:33 +0200" +Date: Fri, 21 Apr 2006 10:26:16 -0400 +Message-ID: <9496.1145629576@sss.pgh.pa.us> +From: Tom Lane +X-Archive-Number: 200604/503 +X-Sequence-Number: 18587 + +Jan Dittmer writes: +> It would help if booleans could be casted to integer 1/0 :-) + +As of 8.1 there is such a cast in the system: + +regression=# select 't'::bool::int; + int4 +------ + 1 +(1 row) + +In earlier releases you can make your own. + +As for the original question, though: have you looked at the crosstab +functions in contrib/tablefunc? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 21 12:25:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 0A7DB11F666A + for ; + Fri, 21 Apr 2006 12:25:00 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.599 +X-Spam-Level: +X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id ouTFzN3al8cz + for ; + Fri, 21 Apr 2006 12:24:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wumpus.mythic-beasts.com (wumpus.mythic-beasts.com + [212.69.37.9]) by postgresql.org (Postfix) with ESMTP id 3DC7B11F6279 + for ; + Fri, 21 Apr 2006 12:24:47 -0300 (ADT) +Received: from sphinx.mythic-beasts.com ([212.69.37.6]) + by wumpus.mythic-beasts.com with esmtp (Exim 4.44) + id 1FWxUy-0002pJ-IS; Fri, 21 Apr 2006 16:24:44 +0100 +Received: from xelah (helo=localhost) + by sphinx.mythic-beasts.com with local-esmtp (Exim 4.51) + id 1FWxUw-0007q8-70; Fri, 21 Apr 2006 16:24:42 +0100 +Date: Fri, 21 Apr 2006 16:24:42 +0100 (BST) +From: Alex Hayward +X-X-Sender: xelah@sphinx.mythic-beasts.com +To: Mikael Carneholm +cc: Pgsql performance +Subject: Re: Hardware: HP StorageWorks MSA 1500 +In-Reply-To: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3F4C@sesrv12.wirelesscar.com> +Message-ID: +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E3F4C@sesrv12.wirelesscar.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Archive-Number: 200604/504 +X-Sequence-Number: 18588 + +On Thu, 20 Apr 2006, Mikael Carneholm wrote: + +> We're going to get one for evaluation next week (equipped with dual +> 2Gbit HBA:s and 2x14 disks, iirc). Anyone with experience from them, +> performance wise? + +We (Seatbooker) use one. It works well enough. Here's a sample bonnie +output: + + -------Sequential Output-------- ---Sequential Input-- --Random-- + -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks--- + Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU + + 16384 41464 30.6 41393 10.0 16287 3.7 92433 83.2 119608 18.3 674.0 0.8 + +which is hardly bad (on a four 15kRPM disk RAID 10 with 2Gbps FC). +Sequential scans on a table produce about 40MB/s of IO with the +'disk' something like 60-70% busy according to FreeBSD's systat. + +Here's diskinfo -cvt output on a not quite idle system: + +/dev/da1 + 512 # sectorsize + 59054899200 # mediasize in bytes (55G) + 115341600 # mediasize in sectors + 7179 # Cylinders according to firmware. + 255 # Heads according to firmware. + 63 # Sectors according to firmware. + +I/O command overhead: + time to read 10MB block 0.279395 sec = 0.014 msec/sector + time to read 20480 sectors 11.864934 sec = 0.579 msec/sector + calculated command overhead = 0.566 msec/sector + +Seek times: + Full stroke: 250 iter in 0.836808 sec = 3.347 msec + Half stroke: 250 iter in 0.861196 sec = 3.445 msec + Quarter stroke: 500 iter in 1.415700 sec = 2.831 msec + Short forward: 400 iter in 0.586330 sec = 1.466 msec + Short backward: 400 iter in 1.365257 sec = 3.413 msec + Seq outer: 2048 iter in 1.184569 sec = 0.578 msec + Seq inner: 2048 iter in 1.184158 sec = 0.578 msec +Transfer rates: + outside: 102400 kbytes in 1.367903 sec = 74859 kbytes/sec + middle: 102400 kbytes in 1.472451 sec = 69544 kbytes/sec + inside: 102400 kbytes in 1.521503 sec = 67302 kbytes/sec + + +It (or any FC SAN, for that matter) isn't an especially cheap way to get +storage. You don't get much option if you have an HP blade enclosure, +though. + +HP's support was poor. Their Indian call-centre seems not to know much +about them and spectacularly failed to tell us if and how we could connect +this (with the 2/3-port FC hub option) to two of our blade servers, one of +which was one of the 'half-height' ones which require an arbitrated loop. +We ended up buying a FC switch. + +From pgsql-performance-owner@postgresql.org Fri Apr 21 12:55:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id DBE2511F7305 + for ; + Fri, 21 Apr 2006 12:55:38 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.693 +X-Spam-Level: +X-Spam-Status: No, score=0.693 required=5 tests=[BAYES_00=-2.599, + DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_POST=1.708, + MSGID_FROM_MTA_HEADER=0, SPF_SOFTFAIL=1.384] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id QtLR026ReGrq + for ; + Fri, 21 Apr 2006 12:55:35 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id AD2D111F6D8D + for ; + Fri, 21 Apr 2006 12:55:34 -0300 (ADT) +Received: from hotmail.com (bay19-f6.bay19.hotmail.com [64.4.53.56]) + by svr4.postgresql.org (Postfix) with ESMTP id 2F9095AF8BC + for ; + Fri, 21 Apr 2006 15:55:34 +0000 (GMT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 21 Apr 2006 08:55:31 -0700 +Message-ID: +Received: from 200.85.230.37 by by19fd.bay19.hotmail.msn.com with HTTP; + Fri, 21 Apr 2006 15:55:29 GMT +X-Originating-IP: [200.85.230.37] +X-Originating-Email: [arcila_alvaro@hotmail.com] +X-Sender: arcila_alvaro@hotmail.com +In-Reply-To: <007f01c6654b$15077280$8300a8c0@tridecap.com> +From: "ALVARO ARCILA" +To: pgsql-performance@postgresql.org +Subject: Inactive memory Grows unlimited +Date: Fri, 21 Apr 2006 15:55:29 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1; format=flowed +X-OriginalArrivalTime: 21 Apr 2006 15:55:31.0971 (UTC) + FILETIME=[04DE4530:01C6655C] +X-Archive-Number: 200604/505 +X-Sequence-Number: 18589 + +Hi, + +I hope you can help me...there's something wrong going on my db server (OS. +GNU/linux White box)... here's the problem... + +The amount of Inactive memory Grows unlimited .... this happens only when +Postgresql (8.1.1) is running... after a few days it "eats" all the RAM +memory ... so I've have to restart the server to free RAM.... + +Here's the parametres actually active in then postgresql.conf file + +max_connections = 100 +authentication_timeout = 60 +password_encryption = on +shared_buffers = 1000 +work_mem = 131076 +maintenance_work_mem = 262152 +redirect_stderr = on +log_directory = 'pg_log' +log_truncate_on_rotation = on +log_rotation_age = 1440 +log_rotation_size = 0 +lc_messages = 'es_ES.UTF-8' +lc_monetary = 'es_ES.UTF-8' +lc_numeric = 'es_ES.UTF-8' +lc_time = 'es_ES.UTF-8' + +Below you can find the content of meminfo file with 18 users connected +(average during working days) and the server has benn running during 2 days +2:19 + +#cat /proc/meminfo +MemTotal: 2074844 kB +MemFree: 1371660 kB +Buffers: 61748 kB +Cached: 555492 kB +SwapCached: 0 kB +Active: 348604 kB +Inactive: 305876 kB +HighTotal: 1179440 kB +HighFree: 579904 kB +LowTotal: 895404 kB +LowFree: 791756 kB +SwapTotal: 2048248 kB +SwapFree: 2048248 kB +Dirty: 260 kB +Writeback: 0 kB +Mapped: 54824 kB +Slab: 35756 kB +Committed_AS: 117624 kB +PageTables: 3404 kB +VmallocTotal: 106488 kB +VmallocUsed: 3356 kB +VmallocChunk: 102920 kB +HugePages_Total: 0 +HugePages_Free: 0 +Hugepagesize: 2048 kB + +thanks in advance for your help, + +Alvaro Arcila + +pd: sorry for my english It's not very good, I hope I'm clear.... + + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 13:38:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 3C2DA11F6A9F + for ; + Fri, 21 Apr 2006 13:38:37 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 1.516 +X-Spam-Level: * +X-Spam-Status: No, score=1.516 required=5 tests=[AWL=-0.403, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id Os0zthFLvwJ3 + for ; + Fri, 21 Apr 2006 13:38:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by postgresql.org (Postfix) with ESMTP id 6096611F663F + for ; + Fri, 21 Apr 2006 13:38:31 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx2.surnet.cl with ESMTP; 21 Apr 2006 12:38:30 -0400 +X-IronPort-Anti-Spam-Filtered: true +X-IronPort-Anti-Spam-Result: AQAAAE6QIkSICgIC +X-IronPort-AV: i="4.02,198,1139194800"; + d="scan'208"; a="44814434:sNHT242835652" +Received: from alvh.no-ip.org (200.126.99.223) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 443B7DDC00162F0C; Fri, 21 Apr 2006 12:38:30 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id E57F0C30F8E; Fri, 21 Apr 2006 12:38:29 -0400 (CLT) +Date: Fri, 21 Apr 2006 12:38:29 -0400 +From: Alvaro Herrera +To: ALVARO ARCILA +Cc: pgsql-performance@postgresql.org +Subject: Re: Inactive memory Grows unlimited +Message-ID: <20060421163829.GD7303@surnet.cl> +Mail-Followup-To: ALVARO ARCILA , + pgsql-performance@postgresql.org +References: <007f01c6654b$15077280$8300a8c0@tridecap.com> + +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.11+cvs20060403 +X-Archive-Number: 200604/506 +X-Sequence-Number: 18590 + +ALVARO ARCILA wrote: +> Hi, +> +> I hope you can help me...there's something wrong going on my db server (OS. +> GNU/linux White box)... here's the problem... +> +> The amount of Inactive memory Grows unlimited .... this happens only when +> Postgresql (8.1.1) is running... after a few days it "eats" all the RAM +> memory ... so I've have to restart the server to free RAM.... + +This is normal Unix behavior. Leave it running for a few more days and +you'll that nothing wrong happens. Why do you think you need "free" +memory? + +Only if the swap memory start getting used a lot you need to worry about +memory consumption. + +You should upgrade to 8.1.3 BTW. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Fri Apr 21 14:39:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id E78CB11F66EC + for ; + Fri, 21 Apr 2006 14:39:10 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.588 +X-Spam-Level: +X-Spam-Status: No, score=-2.588 required=5 tests=[AWL=0.011, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id h1Tz0MuUic6z + for ; + Fri, 21 Apr 2006 14:39:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id CD3BE11F6D59 + for ; + Fri, 21 Apr 2006 14:39:01 -0300 (ADT) +Received: (qmail 18236 invoked by uid 500); 21 Apr 2006 17:41:49 -0000 +Date: Fri, 21 Apr 2006 12:41:49 -0500 +From: Bruno Wolff III +To: soni de +Cc: Merlin Moncure , pgsql-performance@postgresql.org +Subject: Re: Takes too long to fetch the data from database +Message-ID: <20060421174149.GA13275@wolff.to> +Mail-Followup-To: Bruno Wolff III , + soni de , Merlin Moncure , + pgsql-performance@postgresql.org +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> + + <9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com> + + <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> +User-Agent: Mutt/1.4.2.1i +X-Archive-Number: 200604/507 +X-Sequence-Number: 18591 + +On Fri, Apr 21, 2006 at 10:12:24 +0530, + soni de wrote: +> I don't want to query exactly 81900 rows into set. I just want to fetch 50 +> or 100 rows at a time in a decreasing order of stime.(i.e 50 or 100 rows +> starting from last to end). + +You can do this efficiently, if stime has an index and you can deal with using +stime from the previous query instead of the record count. The idea is to +select up 50 or 100 records in descending order where the stime is <= +the previous stime. This can give you some overlapping records, so you need +some way to deal with this. + +From pgsql-performance-owner@postgresql.org Fri Apr 21 15:19:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 5F40311F8C79 + for ; + Fri, 21 Apr 2006 15:19:40 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.466 +X-Spam-Level: +X-Spam-Status: No, score=-2.466 required=5 tests=[AWL=0.133, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id HvFL3AEHYQ2c + for ; + Fri, 21 Apr 2006 15:19:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 7DE7711F6F0E + for ; + Fri, 21 Apr 2006 15:19:29 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id AE61556408; Fri, 21 Apr 2006 13:19:29 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 21 Apr 2006 13:19:27 -0500 +Date: Fri, 21 Apr 2006 13:19:27 -0500 +From: "Jim C. Nasby" +To: Merlin Moncure +Cc: soni de , pgsql-performance@postgresql.org +Subject: Re: Takes too long to fetch the data from database +Message-ID: <20060421181927.GK49405@pervasive.com> +References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> + + <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> + + <9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com> + + <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060421:mmoncure@gmail.com::p5IkpU4L7WYBYDiK:0000000000000000000 + 0000000000000000000000000wfx +X-Hashcash: + 1:20:060421:soni.de@gmail.com::KyzLpFtxuVkmqV/F:00000000000000000000 + 0000000000000000000000009WL3 +X-Hashcash: + 1:20:060421:pgsql-performance@postgresql.org::2BntZhNLL44MBYv1:00000 + 0000000000000000000000003Obf +X-Archive-Number: 200604/508 +X-Sequence-Number: 18592 + +On Fri, Apr 21, 2006 at 09:44:25AM -0400, Merlin Moncure wrote: +> 2nd 50: +> select * from t where j >= j1 and (j > j1 or k > k1) order by j, k limit 50; +> 3 fields: +> select * from t where i >= i1 and (i > i1 or j >= j1) and (i > i1 or j +> > k1 or k > k1) order by i,j,k limit 50; + +Note that in 8.2 you'll be able to do: + +WHERE (i, j, k) >= (i1, j1, k1) +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 25 02:27:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 9AC3011F6D0C + for ; + Fri, 21 Apr 2006 15:24:23 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 required=5 tests=[none] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id DOWUqcClDvLD + for ; + Fri, 21 Apr 2006 15:24:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 0CF4311F6D20 + for ; + Fri, 21 Apr 2006 15:24:19 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 29B8A30D11; Fri, 21 Apr 2006 20:24:19 +0200 (MET DST) +From: "Greg Stumph" +X-Newsgroups: pgsql.performance +Subject: Worsening performance with 7.4 on flash-based system +Date: Fri, 21 Apr 2006 11:24:15 -0700 +Organization: Hub.Org Networking Services +Lines: 50 +Message-ID: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +To: pgsql-performance@postgresql.org +X-Archive-Number: 200604/539 +X-Sequence-Number: 18623 + +We are experiencing gradually worsening performance in PostgreSQL 7.4.7, on +a system with the following specs: +Linux OS (Fedora Core 1, 2.4 kernal) +Flash file system (2 Gig, about 80% full) +256 Meg RAM +566 MHz Celeron CPU + +We use Orbit 2.9.8 to access PostGres. The database contains 62 tables. + +When the system is running with a fresh copy of the database, performance is +fine. At its worst, we are seeing fairly simple SELECT queries taking up to +1 second to execute. When these queries are run in a loop, the loop can take +up to 30 seconds to execute, instead of the 2 seconds or so that we would +expect. + +VACUUM FULL ANALYZE helps, but doesn't seem to eliminate the problem. + +The following table show average execution time in "bad" performance mode in +the first column, execution time after VACUUM ANALYZE in the second column, +and % improvement (or degradation?) in the third. The fourth column show the +query that was executed. + +741.831|582.038|-21.5| ^IDECLARE table_cursor +170.065|73.032|-57.1| FETCH ALL in table_cursor +41.953|45.513|8.5| CLOSE table_cursor +61.504|47.374|-23.0| SELECT last_value FROM pm_id_seq +39.651|46.454|17.2| select id from la_looprunner +1202.170|265.316|-77.9| select id from rt_tran +700.669|660.746|-5.7| ^IDECLARE my_tran_load_cursor +1192.182|47.258|-96.0| FETCH ALL in my_tran_load_cursor +181.934|89.752|-50.7| CLOSE my_tran_load_cursor +487.285|873.474|79.3| ^IDECLARE my_get_router_cursor +51.543|69.950|35.7| FETCH ALL in my_get_router_cursor +48.312|74.061|53.3| CLOSE my_get_router_cursor +814.051|1016.219|24.8| SELECT $1 = 'INSERT' +57.452|78.863|37.3| select id from op_sched +48.010|117.409|144.6| select short_name, long_name from la_loopapp +54.425|58.352|7.2| select id from cd_range +45.289|52.330|15.5| SELECT last_value FROM rt_tran_id_seq +39.658|82.949|109.2| SELECT last_value FROM op_sched_id_seq +42.158|68.189|61.7| select card_id,router_id from rt_valid + + +Has anyone else seen gradual performance degradation like this? Would +upgrading to Postgres 8 help? Any other thoughts on directions for +troubleshooting this? + +Thanks... + + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 15:34:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 6818D11F6B7F + for ; + Fri, 21 Apr 2006 15:34:29 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.254 +X-Spam-Level: +X-Spam-Status: No, score=0.254 required=5 tests=[AWL=0.254] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 1vmaYLLW+g4k + for ; + Fri, 21 Apr 2006 15:34:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 6694511F6B78 + for ; + Fri, 21 Apr 2006 15:34:25 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id DED6656423; Fri, 21 Apr 2006 13:34:24 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 21 Apr 2006 13:34:24 -0500 +Date: Fri, 21 Apr 2006 13:34:24 -0500 +From: "Jim C. Nasby" +To: Wu Fengguang , Markus Schaber , + pgsql-performance@postgresql.org +Subject: Re: Introducing a new linux readahead framework +Message-ID: <20060421183423.GL49405@pervasive.com> +References: <20060421013826.GA5217@mail.ustc.edu.cn> + <20060421043147.GV49405@pervasive.com> + <20060421071511.GA4885@mail.ustc.edu.cn> + <44488F7E.6060704@logix-tt.com> + <20060421122028.GA5937@mail.ustc.edu.cn> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060421122028.GA5937@mail.ustc.edu.cn> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060421:wfg@mail.ustc.edu.cn::g9ABxza9uxiTJ+Lp:00000000000000000 + 0000000000000000000000002MKN +X-Hashcash: + 1:20:060421:schabi@logix-tt.com::OAUKZ03YN2fLHkIU:000000000000000000 + 0000000000000000000000001E33 +X-Hashcash: + 1:20:060421:pgsql-performance@postgresql.org::7lDLaE7+eihPThnx:00000 + 0000000000000000000000004U5N +X-Archive-Number: 200604/509 +X-Sequence-Number: 18593 + +On Fri, Apr 21, 2006 at 08:20:28PM +0800, Wu Fengguang wrote: +> Hi Markus, +> +> On Fri, Apr 21, 2006 at 09:53:34AM +0200, Markus Schaber wrote: +> > Are there any rough estimates when this will get into mainline kernel +> > (if you intend to submit)? +> +> I'm not quite sure :) +> +> The patch itself has been pretty stable. To get it accepted, we must +> back it by good benchmarking results for some important applications. +> I have confirmed that file service via FTP/HTTP/NFS can more or less +> benefit from it. However, database services have not been touched yet. +> Oracle/DB2 seem to bypass the readahead code route, while postgresql +> relies totally on kernel readahead logic. So if postgresql is proved +> to work well with this patch, it will have good opportunity to go into +> mainline :) + +IIRC Mark from OSDL said he'd try testing this when he gets a chance, +but you could also try running dbt2 and dbt3 against it. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri Apr 21 18:20:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 4037311F61FD + for ; + Fri, 21 Apr 2006 18:20:34 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.499 +X-Spam-Level: +X-Spam-Status: No, score=-2.499 required=5 tests=[AWL=0.100, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id INK9OtTJzWiB + for ; + Fri, 21 Apr 2006 18:20:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.wirelesscar.com (mail.wirelesscar.com [212.209.35.30]) + by postgresql.org (Postfix) with ESMTP id 7669F11F6B54 + for ; + Fri, 21 Apr 2006 18:20:21 -0300 (ADT) +Received: from sesrv12.wirelesscar.com ([192.168.10.17]) by + mail.wirelesscar.com with InterScan Messaging Security Suite; + Fri, 21 Apr 2006 23:20:13 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Subject: Re: Hardware: HP StorageWorks MSA 1500 +Content-Transfer-Encoding: quoted-printable +Date: Fri, 21 Apr 2006 23:20:58 +0200 +Message-ID: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E4009@sesrv12.wirelesscar.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Hardware: HP StorageWorks MSA 1500 +Thread-Index: AcZlV9QbW3p1fQXGQnav71FGN1aRDQAA8lvQ +From: "Mikael Carneholm" +To: "Alex Hayward" +Cc: "Pgsql performance" +X-Archive-Number: 200604/510 +X-Sequence-Number: 18594 + +Your numbers seem quite ok considering the number of disks. We also get +a 256Mb battery backed cache module with it, so I'm looking forward to +testing the write performance (first using ext3, then xfs). If I get the +enough time to test it, I'll test both raid 0+1 and raid 5 +configurations although I trust raid 0+1 more. + +And no, it's not the cheapest way to get storage - but it's only half as +expensive as the other option: an EVA4000, which we're gonna have to go +for if we(they) decide to stay in bed with a proprietary database. With +postgres we don't need replication on SAN level (using slony) so the MSA +1500 would be sufficient, and that's a good thing (price wise) as we're +gonna need two. OTOH, the EVA4000 will not give us mirroring so either +way, we're gonna need two of whatever system we go for. Just hoping the +MSA 1500 is reliable as well... + +Support will hopefully not be a problem for us as we have a local +company providing support, they're also the ones setting it up for us so +at least we'll know right away if they're compentent or not :) + +Regards, +Mikael + + +-----Original Message----- +From: Alex Hayward [mailto:xelah@sphinx.mythic-beasts.com] On Behalf Of +Alex Hayward +Sent: den 21 april 2006 17:25 +To: Mikael Carneholm +Cc: Pgsql performance +Subject: Re: [PERFORM] Hardware: HP StorageWorks MSA 1500 + +On Thu, 20 Apr 2006, Mikael Carneholm wrote: + +> We're going to get one for evaluation next week (equipped with dual=20 +> 2Gbit HBA:s and 2x14 disks, iirc). Anyone with experience from them,=20 +> performance wise? + +We (Seatbooker) use one. It works well enough. Here's a sample bonnie +output: + + -------Sequential Output-------- ---Sequential Input-- +--Random-- + -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- +--Seeks--- + Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU +/sec %CPU + + 16384 41464 30.6 41393 10.0 16287 3.7 92433 83.2 119608 18.3 +674.0 0.8 + +which is hardly bad (on a four 15kRPM disk RAID 10 with 2Gbps FC). +Sequential scans on a table produce about 40MB/s of IO with the 'disk' +something like 60-70% busy according to FreeBSD's systat. + +Here's diskinfo -cvt output on a not quite idle system: + +/dev/da1 + 512 # sectorsize + 59054899200 # mediasize in bytes (55G) + 115341600 # mediasize in sectors + 7179 # Cylinders according to firmware. + 255 # Heads according to firmware. + 63 # Sectors according to firmware. + +I/O command overhead: + time to read 10MB block 0.279395 sec =3D 0.014 +msec/sector + time to read 20480 sectors 11.864934 sec =3D 0.579 +msec/sector + calculated command overhead =3D 0.566 +msec/sector + +Seek times: + Full stroke: 250 iter in 0.836808 sec =3D 3.347 msec + Half stroke: 250 iter in 0.861196 sec =3D 3.445 msec + Quarter stroke: 500 iter in 1.415700 sec =3D 2.831 msec + Short forward: 400 iter in 0.586330 sec =3D 1.466 msec + Short backward: 400 iter in 1.365257 sec =3D 3.413 msec + Seq outer: 2048 iter in 1.184569 sec =3D 0.578 msec + Seq inner: 2048 iter in 1.184158 sec =3D 0.578 msec +Transfer rates: + outside: 102400 kbytes in 1.367903 sec =3D 74859 +kbytes/sec + middle: 102400 kbytes in 1.472451 sec =3D 69544 +kbytes/sec + inside: 102400 kbytes in 1.521503 sec =3D 67302 +kbytes/sec + + +It (or any FC SAN, for that matter) isn't an especially cheap way to get +storage. You don't get much option if you have an HP blade enclosure, +though. + +HP's support was poor. Their Indian call-centre seems not to know much +about them and spectacularly failed to tell us if and how we could +connect this (with the 2/3-port FC hub option) to two of our blade +servers, one of which was one of the 'half-height' ones which require an +arbitrated loop. +We ended up buying a FC switch. + + +From pgsql-patches-owner@postgresql.org Fri Apr 21 21:10:25 2006 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id DEE0F11F6B36; + Fri, 21 Apr 2006 21:10:24 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.559 +X-Spam-Level: +X-Spam-Status: No, score=-2.559 required=5 tests=[AWL=0.040, BAYES_00=-2.599] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id dCGBtXni5dhR; Fri, 21 Apr 2006 21:10:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.188]) + by postgresql.org (Postfix) with ESMTP id 5B18911F6B20; + Fri, 21 Apr 2006 21:10:21 -0300 (ADT) +Received: from [84.12.84.125] (helo=[192.168.0.7]) + by mrelayeu.kundenserver.de (node=mrelayeu0) with ESMTP (Nemesis), + id 0MKwh2-1FX5hW32SF-0005fQ; Sat, 22 Apr 2006 02:10:16 +0200 +Subject: Re: [PERFORM] WAL logging of SELECT ... INTO command +From: Simon Riggs +To: Bruce Momjian +Cc: Kris Jurka , "Jim C. Nasby" , + pgsql-performance@postgresql.org, pgsql-patches@postgresql.org +In-Reply-To: <200604212356.k3LNuKT04925@candle.pha.pa.us> +References: <200604212356.k3LNuKT04925@candle.pha.pa.us> +Content-Type: text/plain +Date: Sat, 22 Apr 2006 00:11:09 +0100 +Message-Id: <1145661069.3112.145.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-4.fc4) +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:726643fe08f41a451f0fe7fa43bce239 +X-Archive-Number: 200604/150 +X-Sequence-Number: 19422 + +On Fri, 2006-04-21 at 19:56 -0400, Bruce Momjian wrote: +> Your patch has been added to the PostgreSQL unapplied patches list at: +> +> http://momjian.postgresql.org/cgi-bin/pgpatches +> +> It will be applied as soon as one of the PostgreSQL committers reviews +> and approves it. + +This patch should now be referred to as + allow CREATE TABLE AS/SELECT INTO to use default_tablespace +or something similar. + +The name of the original thread no longer bears any resemblance to the +intention of this patch as submitted in its final form. + +I've no objection to the patch, which seems to fill a functional +gap/bug. + +-- + Simon Riggs + EnterpriseDB http://www.enterprisedb.com/ + + +From pgsql-performance-owner@postgresql.org Fri Apr 21 20:56:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx2.hub.org [200.46.204.254]) + by postgresql.org (Postfix) with ESMTP id 682DE11F65ED; + Fri, 21 Apr 2006 20:56:36 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: -2.442 +X-Spam-Level: +X-Spam-Status: No, score=-2.442 required=5 tests=[AWL=0.159, BAYES_00=-2.599, + SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) + with ESMTP id Yftr5I-CAJR8; Fri, 21 Apr 2006 20:56:29 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id AB96B11F628A; + Fri, 21 Apr 2006 20:56:26 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k3LNuKT04925; + Fri, 21 Apr 2006 19:56:20 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200604212356.k3LNuKT04925@candle.pha.pa.us> +Subject: Re: WAL logging of SELECT ... INTO command +In-Reply-To: +To: Kris Jurka +Date: Fri, 21 Apr 2006 19:56:20 -0400 (EDT) +CC: "Jim C. Nasby" , + Simon Riggs , + pgsql-performance@postgresql.org, pgsql-patches@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Archive-Number: 200604/511 +X-Sequence-Number: 18595 + + +Your patch has been added to the PostgreSQL unapplied patches list at: + + http://momjian.postgresql.org/cgi-bin/pgpatches + +It will be applied as soon as one of the PostgreSQL committers reviews +and approves it. + +--------------------------------------------------------------------------- + + +Kris Jurka wrote: +> +> +> On Fri, 24 Mar 2006, Jim C. Nasby wrote: +> +> > On Wed, Mar 22, 2006 at 02:37:28PM -0500, Kris Jurka wrote: +> >> +> >> On Wed, 22 Mar 2006, Jim C. Nasby wrote: +> >> +> >>> Ok, I saw disk activity on the base directory and assumed it was pg_xlog +> >>> stuff. Turns out that both SELECT INTO and CREATE TABLE AS ignore +> >>> default_tablepsace and create the new tables in the base directory. I'm +> >>> guessing that's a bug... (this is on 8.1.2, btw). +> >> +> >> This has been fixed in CVS HEAD as part of a patch to allow additional +> >> options to CREATE TABLE AS. +> >> +> >> http://archives.postgresql.org/pgsql-patches/2006-02/msg00211.php +> > +> > I'll argue that the current behavior is still a bug and should be fixed. +> > Would it be difficult to patch 8.1 (and 8.0 if there were tablespaces +> > then...) to honor default_tablespace? +> +> Here are patches that fix this for 8.0 and 8.1. +> +> Kris Jurka + +Content-Description: + +[ Attachment, skipping... ] + +Content-Description: + +[ Attachment, skipping... ] + +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Sat Apr 22 09:16:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 46E5611F7DDB + for ; + Sat, 22 Apr 2006 09:16:00 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 2.83 +X-Spam-Level: ** +X-Spam-Status: No, score=2.83 required=5 tests=[AWL=-0.679, + DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_WHOIS=0.879, + RCVD_IN_WHOIS_INVALID=2.151] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id DUxXYZ0ObrsT + for ; + Sat, 22 Apr 2006 09:15:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.ustc.edu.cn (ns.ustc.edu.cn [202.38.64.1]) + by postgresql.org (Postfix) with ESMTP id 69E1B11F7DD3 + for ; + Sat, 22 Apr 2006 09:15:51 -0300 (ADT) +Received: from localhost.localdomain ([210.45.75.71]) + by mx1.ustc.edu.cn (8.11.6/8.11.6) with ESMTP id k3MCBrw02865; + Sat, 22 Apr 2006 20:11:54 +0800 +Received: from wfg by localhost.localdomain with local (Exim 4.50) + id 1FXH1K-0001JG-Gz; Sat, 22 Apr 2006 20:15:26 +0800 +Date: Sat, 22 Apr 2006 20:15:26 +0800 +From: Wu Fengguang +To: "Jim C. Nasby" +Cc: Markus Schaber , pgsql-performance@postgresql.org +Subject: Re: Introducing a new linux readahead framework +Message-ID: <20060422121526.GA5021@mail.ustc.edu.cn> +Mail-Followup-To: Wu Fengguang , + "Jim C. Nasby" , + Markus Schaber , + pgsql-performance@postgresql.org +References: <20060421013826.GA5217@mail.ustc.edu.cn> + <20060421043147.GV49405@pervasive.com> + <20060421071511.GA4885@mail.ustc.edu.cn> + <44488F7E.6060704@logix-tt.com> + <20060421122028.GA5937@mail.ustc.edu.cn> + <20060421183423.GL49405@pervasive.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060421183423.GL49405@pervasive.com> +User-Agent: Mutt/1.5.11+cvs20060126 +X-Archive-Number: 200604/513 +X-Sequence-Number: 18597 + +On Fri, Apr 21, 2006 at 01:34:24PM -0500, Jim C. Nasby wrote: +> IIRC Mark from OSDL said he'd try testing this when he gets a chance, +> but you could also try running dbt2 and dbt3 against it. + +Thanks for the info, I'll look into them. + +Regards, +wu + +From pgsql-performance-owner@postgresql.org Tue Apr 25 02:28:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (av.hub.org [200.46.204.144]) + by postgresql.org (Postfix) with ESMTP id 0AC8511F6603 + for ; + Sat, 22 Apr 2006 18:34:24 -0300 (ADT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Score: 0.55 +X-Spam-Level: +X-Spam-Status: No, score=0.55 required=5 tests=[NO_REAL_NAME=0.55] +Received: from postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id SwzWsQ8aamN3 + for ; + Sat, 22 Apr 2006 18:34:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 2FD1711F6609 + for ; + Sat, 22 Apr 2006 18:34:21 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id B1508314B3; Sat, 22 Apr 2006 23:34:19 +0200 (MET DST) +From: clemens.bertschler@gmail.com +X-Newsgroups: pgsql.performance +Subject: Easy question +Date: 22 Apr 2006 14:34:13 -0700 +Organization: http://groups.google.com +Lines: 16 +Message-ID: <1145741653.759727.38970@e56g2000cwe.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.8.0.2) Gecko/20060308 + Firefox/1.5.0.2,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: e56g2000cwe.googlegroups.com; posting-host=200.114.70.217; + posting-account=I3Q4Kw0AAAB5qSAosGYN-4vsrNRUrVAS +To: pgsql-performance@postgresql.org +X-Archive-Number: 200604/540 +X-Sequence-Number: 18624 + +Hi List +I have maybe an easy question but i do not find an answer, i have this +SQL query: + +SELECT geom,group,production_facs FROM south_america + WHERE municipio = '' + OR municipio = 'ACRE' + OR municipio = 'ADJUNTAS' + OR municipio = 'AGUADA' + +The performance of this query is quite worse as longer it gets, its +possible that this query gets over 20 to 30 OR comparisons, but then +the performance is really worse, is it possible to speed it up? +Thanks +Clemens + + +From pgsql-performance-owner@postgresql.org Sun Apr 23 14:05:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0665B11F610C + for ; + Sun, 23 Apr 2006 14:05:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 63025-01 + for ; + Sun, 23 Apr 2006 14:05:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.177]) + by postgresql.org (Postfix) with ESMTP id E7C0611F60BE + for ; + Sun, 23 Apr 2006 14:05:21 -0300 (ADT) +Received: from [195.112.43.22] (helo=[192.168.0.7]) + by mrelayeu.kundenserver.de (node=mrelayeu5) with ESMTP (Nemesis), + id 0ML25U-1FXi1J1658-0008Eo; Sun, 23 Apr 2006 19:05:13 +0200 +Subject: Re: Recovery will take 10 hours +From: Simon Riggs +To: Brendan Duddridge +Cc: PostgreSQL Performance +In-Reply-To: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> +Content-Type: text/plain +Date: Sun, 23 Apr 2006 17:06:07 +0100 +Message-Id: <1145808368.3112.222.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-4.fc4) +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:726643fe08f41a451f0fe7fa43bce239 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/514 +X-Sequence-Number: 18598 + +On Thu, 2006-04-20 at 13:29 -0600, Brendan Duddridge wrote: + +> We had a database issue today that caused us to have to restore to +> our most recent backup. We are using PITR so we have 3120 WAL files +> that need to be applied to the database. + +How often are you taking base backups? + +> After 45 minutes, it has restored only 230 WAL files. At this rate, +> it's going to take about 10 hours to restore our database. + +> Most of the time, the server is not using very much CPU time or I/O +> time. So I'm wondering what can be done to speed up the process? + +You can improve the performance of a recovery by making your restore +command overlap retrieval of files. The recovery process waits while the +restore command returns a file, so by doing an asynchronous lookahead of +one file you can be gunzipping the next file while the current one is +being processed. + +I'll either document this better, or build an overlap into the restore +command processing itself, so the script doesn't need to do this. + +-- + Simon Riggs + EnterpriseDB http://www.enterprisedb.com/ + + +From pgsql-performance-owner@postgresql.org Sun Apr 23 18:01:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4922F11F7C5C + for ; + Sun, 23 Apr 2006 18:01:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 96630-02 + for ; + Sun, 23 Apr 2006 17:57:47 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.225]) + by postgresql.org (Postfix) with ESMTP id 6ECDD11F6717 + for ; + Sun, 23 Apr 2006 17:57:45 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so757762wra + for ; + Sun, 23 Apr 2006 13:57:45 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:from:to:subject:date:organization:mime-version:content-type:content-transfer-encoding:x-mailer:x-mimeole:thread-index:message-id; + b=TgJEei1NOTRhPYmfgR2lPlV+95lMy78rG6qsGzCJBS0VbLGYa5ikqtojsNXw6H/NNdh2e8qfqleC5xp0NQ5hfITgRDKqGIdA/RMD0upsRYbFk32wqLy6ohMX6O+yqznXXIr61nslGNhi7ai6BOP24DNeD4JjHDeATddJO2XkL2k= +Received: by 10.54.115.20 with SMTP id n20mr179166wrc; + Sun, 23 Apr 2006 13:57:44 -0700 (PDT) +Received: from sbew318anc22 ( [200.157.135.150]) + by mx.gmail.com with ESMTP id 12sm2925090wrl.2006.04.23.13.57.43; + Sun, 23 Apr 2006 13:57:44 -0700 (PDT) +From: "Bruno Almeida do Lago" +To: +Subject: GROUP BY Vs. Sub SELECT +Date: Sun, 23 Apr 2006 17:57:40 -0300 +Organization: G&P +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcZnGI8osE8PVGWPQpGtuc6NjVorpQ== +Message-ID: <444bea48.5e66e367.75a4.0537@mx.gmail.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/515 +X-Sequence-Number: 18599 + +Hi, + +I'm just getting familiar with EXPLAIN ANALYZE output, so I'd like to get +some help to identify which one of the following queries would be better: + +teste=# EXPLAIN ANALYZE SELECT aa.avaliacao_id, MAX(aa.avaliacao_versao) AS +avaliacao_versao, a.avaliacao_nome, aa.editar +teste-# FROM teo01tb104_areas_avaliacoes aa, teo01tb201_avaliacoes a +teste-# WHERE aa.avaliacao_id=10 +teste-# AND aa.avaliacao_id=a.avaliacao_id +teste-# GROUP BY aa.avaliacao_id, a.avaliacao_nome, aa.editar; + QUERY +PLAN +---------------------------------------------------------------------------- +----------------------------------------------------------------------- + HashAggregate (cost=45.93..45.94 rows=1 width=52) (actual +time=0.466..0.469 rows=1 loops=1) + -> Nested Loop (cost=4.04..45.66 rows=27 width=52) (actual +time=0.339..0.356 rows=1 loops=1) + -> Bitmap Heap Scan on teo01tb201_avaliacoes a (cost=2.01..8.49 +rows=3 width=47) (actual time=0.219..0.223 rows=1 loops=1) + Recheck Cond: (avaliacao_id = 10) + -> Bitmap Index Scan on teo01tb201_avaliacoes_pk +(cost=0.00..2.01 rows=3 width=0) (actual time=0.166..0.166 rows=1 loops=1) + Index Cond: (avaliacao_id = 10) + -> Bitmap Heap Scan on teo01tb104_areas_avaliacoes aa +(cost=2.03..12.30 rows=9 width=9) (actual time=0.060..0.066 rows=1 loops=1) + Recheck Cond: (avaliacao_id = 10) + -> Bitmap Index Scan on teo01tb104_areas_avaliacoes_pk +(cost=0.00..2.03 rows=9 width=0) (actual time=0.040..0.040 rows=1 loops=1) + Index Cond: (avaliacao_id = 10) + Total runtime: 1.339 ms +(11 rows) + +teste=# SELECT a.avaliacao_id, a.avaliacao_versao, a.avaliacao_nome, +aa.editar +teste-# FROM teo01tb201_avaliacoes a, teo01tb104_areas_avaliacoes aa +teste-# WHERE a.avaliacao_id=10 +teste-# AND a.avaliacao_versao=(SELECT MAX(avaliacao_versao) +teste(# FROM teo01tb201_avaliacoes +teste(# WHERE avaliacao_id=10) +teste-# AND a.avaliacao_id=aa.avaliacao_id; + avaliacao_id | avaliacao_versao | avaliacao_nome | editar +--------------+------------------+----------------+-------- + 10 | 1 | Teste | t +(1 row) + +teste=# EXPLAIN ANALYZE SELECT a.avaliacao_id, a.avaliacao_versao, +a.avaliacao_nome, aa.editar +teste-# FROM teo01tb201_avaliacoes a, teo01tb104_areas_avaliacoes aa +teste-# WHERE a.avaliacao_id=10 +teste-# AND a.avaliacao_versao=(SELECT MAX(avaliacao_versao) +teste(# FROM teo01tb201_avaliacoes +teste(# WHERE avaliacao_id=10) +teste-# AND a.avaliacao_id=aa.avaliacao_id; + +QUERY PLAN +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +------------------------ + Nested Loop (cost=6.20..22.38 rows=9 width=52) (actual time=0.573..0.596 +rows=1 loops=1) + InitPlan + -> Result (cost=4.16..4.17 rows=1 width=0) (actual time=0.315..0.319 +rows=1 loops=1) + InitPlan + -> Limit (cost=0.00..4.16 rows=1 width=4) (actual +time=0.257..0.261 rows=1 loops=1) + -> Index Scan Backward using teo01tb201_avaliacoes_pk on +teo01tb201_avaliacoes (cost=0.00..12.48 rows=3 width=4) (actual +time=0.245..0.245 rows=1 loops=1) + Index Cond: (avaliacao_id = 10) + Filter: (avaliacao_versao IS NOT NULL) + -> Index Scan using teo01tb201_avaliacoes_pk on teo01tb201_avaliacoes a +(cost=0.00..5.83 rows=1 width=51) (actual time=0.410..0.420 rows=1 loops=1) + Index Cond: ((avaliacao_id = 10) AND (avaliacao_versao = $1)) + -> Bitmap Heap Scan on teo01tb104_areas_avaliacoes aa (cost=2.03..12.30 +rows=9 width=5) (actual time=0.110..0.114 rows=1 loops=1) + Recheck Cond: (avaliacao_id = 10) + -> Bitmap Index Scan on teo01tb104_areas_avaliacoes_pk +(cost=0.00..2.03 rows=9 width=0) (actual time=0.074..0.074 rows=1 loops=1) + Index Cond: (avaliacao_id = 10) + Total runtime: 1.418 ms +(15 rows) + + +I think 2nd would be better, since when database grow up the GROUP BY may +become too costly. Is that right? + +Regards, +Bruno + + +From pgsql-performance-owner@postgresql.org Sun Apr 23 20:34:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CE21111F6085 + for ; + Sun, 23 Apr 2006 20:34:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 22075-01 + for ; + Sun, 23 Apr 2006 20:34:29 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 3E37511F6081 + for ; + Sun, 23 Apr 2006 20:34:27 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3NNYP3s018882; + Sun, 23 Apr 2006 19:34:25 -0400 (EDT) +To: "Bruno Almeida do Lago" +cc: pgsql-performance@postgresql.org +Subject: Re: GROUP BY Vs. Sub SELECT +In-reply-to: <444bea48.5e66e367.75a4.0537@mx.gmail.com> +References: <444bea48.5e66e367.75a4.0537@mx.gmail.com> +Comments: In-reply-to "Bruno Almeida do Lago" + message dated "Sun, 23 Apr 2006 17:57:40 -0300" +Date: Sun, 23 Apr 2006 19:34:24 -0400 +Message-ID: <18881.1145835264@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/516 +X-Sequence-Number: 18600 + +"Bruno Almeida do Lago" writes: +> I'm just getting familiar with EXPLAIN ANALYZE output, so I'd like to get +> some help to identify which one of the following queries would be better: + +Well, you're breaking one of the first laws of PG performance analysis, +which is to not try to extrapolate the behavior on large tables from the +behavior on toy tables. You can't really see where the bottlenecks are +on a toy example, and what's more there's no reason to think that the +planner will use the same plan when presented with much larger tables. +So you need to load up a meaningful amount of data (don't forget to +ANALYZE afterward!) and then see what it does. + +> I think 2nd would be better, since when database grow up the GROUP BY may +> become too costly. Is that right? + +The two queries don't give the same answer, so asking which is faster +is a bit irrelevant. (When there's more than one group, wouldn't the +per-group MAXes be different?) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Apr 23 23:01:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9D28411F7DF1 + for ; + Sun, 23 Apr 2006 23:01:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 48259-01 + for ; + Sun, 23 Apr 2006 23:01:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz + [203.96.152.183]) + by postgresql.org (Postfix) with ESMTP id 731A611F660E + for ; + Sun, 23 Apr 2006 22:29:28 -0300 (ADT) +Received: from smtp-1.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-4.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IY700D4NDH4LC@linda-4.paradise.net.nz> for + pgsql-performance@postgresql.org; Mon, 24 Apr 2006 13:29:28 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-108.dsl.clear.net.nz [218.101.29.108]) by + smtp-1.paradise.net.nz (Postfix) with ESMTP id EF8BD582694; + Mon, 24 Apr 2006 13:29:27 +1200 (NZST) +Date: Mon, 24 Apr 2006 13:29:17 +1200 +From: Mark Kirkwood +Subject: Re: Hardware: HP StorageWorks MSA 1500 +In-reply-to: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E4009@sesrv12.wirelesscar.com> +To: Mikael Carneholm +Cc: Alex Hayward , + Pgsql performance +Message-id: <444C29ED.2070901@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Thunderbird 1.5 (X11/20060417) +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E4009@sesrv12.wirelesscar.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/517 +X-Sequence-Number: 18601 + +Mikael Carneholm wrote: +> Your numbers seem quite ok considering the number of disks. We also get +> a 256Mb battery backed cache module with it, so I'm looking forward to +> testing the write performance (first using ext3, then xfs). If I get the +> enough time to test it, I'll test both raid 0+1 and raid 5 +> configurations although I trust raid 0+1 more. +> +> And no, it's not the cheapest way to get storage - but it's only half as +> expensive as the other option: an EVA4000, which we're gonna have to go +> for if we(they) decide to stay in bed with a proprietary database. With +> postgres we don't need replication on SAN level (using slony) so the MSA +> 1500 would be sufficient, and that's a good thing (price wise) as we're +> gonna need two. OTOH, the EVA4000 will not give us mirroring so either +> way, we're gonna need two of whatever system we go for. Just hoping the +> MSA 1500 is reliable as well... +> +> Support will hopefully not be a problem for us as we have a local +> company providing support, they're also the ones setting it up for us so +> at least we'll know right away if they're compentent or not :) +> + +If I'm reading the original post correctly, the biggest issue is likely +to be that the 14 disks on each 2Gbit fibre channel will be throttled to +200Mb/s by the channel , when in fact you could expect (in RAID 10 +arrangement) to get about 7 * 70 Mb/s = 490 Mb/s. + +Cheers + +Mark + + +From pgsql-performance-owner@postgresql.org Sun Apr 23 23:49:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EF36411F6E80 + for ; + Sun, 23 Apr 2006 23:49:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 55007-01 + for ; + Sun, 23 Apr 2006 23:41:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 2C7AE11F61C9 + for ; + Sun, 23 Apr 2006 23:41:03 -0300 (ADT) +Received: from mx.sat.rackspace.com (mx.sat.rackspace.com [64.39.1.214]) + by svr4.postgresql.org (Postfix) with ESMTP id 75DF35AF8E9 + for ; + Mon, 24 Apr 2006 02:41:05 +0000 (GMT) +Received: from mail.rackspace.com (mail.rackspace.com [64.39.2.181]) + by mx.sat.rackspace.com (8.13.6/8.13.6) with ESMTP id k3O2f2D0031950 + for ; Sun, 23 Apr 2006 21:41:03 -0500 + (envelope-from wreese@rackspace.com) +Received: from [192.168.10.8] (vpn113-66.sat.rackspace.com [10.1.113.66]) + (authenticated bits=0) + by mail.rackspace.com (8.13.1/8.13.1) with ESMTP id k3O2f1m1002168 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) + for ; Sun, 23 Apr 2006 21:41:02 -0500 +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Transfer-Encoding: 7bit +Message-Id: <22780344-3C6A-474E-8101-60B8806DA152@rackspace.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Will Reese +Subject: Slow deletes in 8.1 when FKs are involved +Date: Sun, 23 Apr 2006 21:41:14 -0500 +X-Mailer: Apple Mail (2.749.3) +X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CP_URI_IN_BODY 0, + __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, + __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, + __SANE_MSGID 0, __STOCK_PHRASE_7 0' +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/518 +X-Sequence-Number: 18602 + +I'm preparing for an upgrade from PostgreSQL 7.4.5 to 8.1.3, and I +noticed a potential performance issue. + +I have two servers, a dual proc Dell with raid 5 running PostgreSQL +7.4, and a quad proc Dell with a storage array running PostgreSQL +8.1. Both servers have identical postgresql.conf settings and were +restored from the same 7.4 backup. Almost everything is faster on the +8.1 server (mostly due to hardware), except one thing...deletes from +tables with many foreign keys pointing to them. + +I have table A with around 100,000 rows, that has foreign keys from +about 50 other tables pointing to it. Some of these other tables +(table B, for example) have around 10 million rows. + +On the 7.4 server, I can delete a single row from a table A in well +under a second (as expected). On the 8.1 server, it takes over a +minute to delete. I tried all the usual stuff, recreating indexes, +vacuum analyzing, explain analyze. Everything is identical between +the systems. If I hit ctrl-c while the slow delete was running on +8.1, I repeatedly got the following message... + +db=# delete from "A" where "ID" in ('6'); +Cancel request sent +ERROR: canceling statement due to user request +CONTEXT: SQL statement "SELECT 1 FROM ONLY "public"."B" x WHERE +"A_ID" = $1 FOR SHARE OF x" + +It looks to me like the "SELECT ... FOR SHARE" functionality in 8.1 +is the culprit. Has anyone else run into this issue? + + +Will Reese -- http://blog.rezra.com + + +From pgsql-performance-owner@postgresql.org Mon Apr 24 02:41:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6BA9311F6B55 + for ; + Mon, 24 Apr 2006 02:41:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 80482-07-2 + for ; + Mon, 24 Apr 2006 02:39:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id C7E8811F8D07 + for ; + Mon, 24 Apr 2006 00:32:40 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3O3WdUE020019; + Sun, 23 Apr 2006 23:32:39 -0400 (EDT) +To: Will Reese +cc: pgsql-performance@postgresql.org +Subject: Re: Slow deletes in 8.1 when FKs are involved +In-reply-to: <22780344-3C6A-474E-8101-60B8806DA152@rackspace.com> +References: <22780344-3C6A-474E-8101-60B8806DA152@rackspace.com> +Comments: In-reply-to Will Reese + message dated "Sun, 23 Apr 2006 21:41:14 -0500" +Date: Sun, 23 Apr 2006 23:32:39 -0400 +Message-ID: <20018.1145849559@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/520 +X-Sequence-Number: 18604 + +Will Reese writes: +> ... Both servers have identical postgresql.conf settings and were +> restored from the same 7.4 backup. Almost everything is faster on the +> 8.1 server (mostly due to hardware), except one thing...deletes from +> tables with many foreign keys pointing to them. + +I think it's unquestionable that you have a bad FK plan in use on the +8.1 server. Double check that you have suitable indexes on the +referencing (not referenced) columns, that you've ANALYZEd all the +tables involved, and that you've started a fresh psql session (remember +the backend tends to cache FK plans for the life of the connection). + +It might help to EXPLAIN ANALYZE one of the slow deletes --- 8.1 will +break out the time spent in FK triggers, which would let you see which +one(s) are the culprit. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 24 01:46:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6926611F6C98 + for ; + Mon, 24 Apr 2006 01:46:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 72795-04 + for ; + Mon, 24 Apr 2006 01:46:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 09D9811F6C95 + for ; + Mon, 24 Apr 2006 01:46:44 -0300 (ADT) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Sun, 23 Apr 2006 22:46:43 -0600 +In-Reply-To: <1145808368.3112.222.camel@localhost.localdomain> +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <1145808368.3112.222.camel@localhost.localdomain> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Recovery will take 10 hours +Date: Sun, 23 Apr 2006 22:46:35 -0600 +To: Simon Riggs +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/519 +X-Sequence-Number: 18603 + +Hi Simon, + +The backup with 3120 WAL files was a 2 day old base backup. We've moved +to a 1 day base backup now, but that'll still be 1600 WALs or so a day. +That will probably take 5 hours to restore I suspect. Unless we move to +2 or more base backups per day. That seems crazy though. + +So how do you overlap the restore process with the retrieving of files? + +Our restore command is: + +restore_command = 'gunzip %p' + +If I change it to: + +restore_command = 'gunzip %p &' + +to execute the restore command in the background, will that do the +trick? + +But I don't think the real problem was the retrieval of the files. It +only +took maybe 1/2 a second to retrieve the file, but often took anywhere +from +5 to 30 seconds to process the file. More so on the longer end of the +scale. + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On Apr 23, 2006, at 10:06 AM, Simon Riggs wrote: + +> On Thu, 2006-04-20 at 13:29 -0600, Brendan Duddridge wrote: +> +>> We had a database issue today that caused us to have to restore to +>> our most recent backup. We are using PITR so we have 3120 WAL files +>> that need to be applied to the database. +> +> How often are you taking base backups? +> +>> After 45 minutes, it has restored only 230 WAL files. At this rate, +>> it's going to take about 10 hours to restore our database. +> +>> Most of the time, the server is not using very much CPU time or I/O +>> time. So I'm wondering what can be done to speed up the process? +> +> You can improve the performance of a recovery by making your restore +> command overlap retrieval of files. The recovery process waits +> while the +> restore command returns a file, so by doing an asynchronous +> lookahead of +> one file you can be gunzipping the next file while the current one is +> being processed. +> +> I'll either document this better, or build an overlap into the restore +> command processing itself, so the script doesn't need to do this. +> +> -- +> Simon Riggs +> EnterpriseDB http://www.enterprisedb.com/ +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that +> your +> message can get through to the mailing list cleanly +> + + + +From pgsql-performance-owner@postgresql.org Mon Apr 24 02:55:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D645711F6006 + for ; + Mon, 24 Apr 2006 02:55:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91085-05 + for ; + Mon, 24 Apr 2006 02:55:53 -0300 (ADT) +X-Greylist: delayed 00:18:38.006636 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 03FBF11F60E7 + for ; + Mon, 24 Apr 2006 02:55:52 -0300 (ADT) +Received: from maya.ngi.it (maya.ngi.it [88.149.128.3]) + by svr4.postgresql.org (Postfix) with ESMTP id 734DB5AF9D4 + for ; + Mon, 24 Apr 2006 05:37:14 +0000 (GMT) +Received: from [192.168.1.200] (88-149-138-20.f5.ngi.it [88.149.138.20]) + (authenticated bits=0) + by maya.ngi.it (8.13.6/8.13.5) with ESMTP id k3O5b6QX022805; + Mon, 24 Apr 2006 07:37:06 +0200 +Message-ID: <444C63F9.7000306@beccati.com> +Date: Mon, 24 Apr 2006 07:36:57 +0200 +From: Matteo Beccati +User-Agent: Mozilla Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: ALVARO ARCILA , + pgsql-performance@postgresql.org +Cc: alvherre@commandprompt.com +Subject: Re: Inactive memory Grows unlimited +References: <007f01c6654b$15077280$8300a8c0@tridecap.com> + + <20060421163829.GD7303@surnet.cl> +In-Reply-To: <20060421163829.GD7303@surnet.cl> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/521 +X-Sequence-Number: 18605 + +Hi, + +>> The amount of Inactive memory Grows unlimited .... this happens only when +>> Postgresql (8.1.1) is running... after a few days it "eats" all the RAM +>> memory ... so I've have to restart the server to free RAM.... +> +> This is normal Unix behavior. Leave it running for a few more days and +> you'll that nothing wrong happens. Why do you think you need "free" +> memory? +> +> Only if the swap memory start getting used a lot you need to worry about +> memory consumption. +> +> You should upgrade to 8.1.3 BTW. + +Also, shared_buffers seem too low and work_mem too much high for your setup: + +> shared_buffers = 1000 +> work_mem = 131076 + +You should really raise shared_buffers and decrease work_mem: 1000 +shared_buffers is probably too conservative. On the other hand 128MB per +sort could be eating your RAM quickly with 18 users connected. + + +Best regards +-- +Matteo Beccati +http://phpadsnew.com +http://phppgads.com + +From pgsql-performance-owner@postgresql.org Mon Apr 24 05:31:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7317711F6B24 + for ; + Mon, 24 Apr 2006 05:31:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 14267-03 + for ; + Mon, 24 Apr 2006 05:29:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 478F311F6AFF + for ; + Mon, 24 Apr 2006 05:29:31 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (Ta21a.t.pppool.de + [89.55.162.26]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 69D28656CD; + Mon, 24 Apr 2006 10:30:33 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 5D224181C1DEE; + Mon, 24 Apr 2006 10:29:44 +0200 (CEST) +Message-ID: <444C8C78.1000906@logix-tt.com> +Date: Mon, 24 Apr 2006 10:29:44 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Brendan Duddridge +Cc: PostgreSQL Performance +Subject: Re: Recovery will take 10 hours +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <1145808368.3112.222.camel@localhost.localdomain> + +In-Reply-To: +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/522 +X-Sequence-Number: 18606 + +Hi, Brandan, + +Brendan Duddridge wrote: + +> So how do you overlap the restore process with the retrieving of files? + +You need a shell script as restore command that does both uncompressing +the current file, and starting a background decompress of the next +file(s). It also has to check whether the current file is already in +progress from a last run, and wait until this is finished instead of +decompressing it. Seems to be a little complicated than it sounds first. + +> restore_command = 'gunzip %p &' + +Warning: Don't do it this way! + +It will break things because PostgreSQL will try to access a +not-completely-restored wal file. + + +HTH, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Mon Apr 24 15:17:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4E5DE11F8BF3 + for ; + Mon, 24 Apr 2006 15:17:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 54366-01-5 + for ; + Mon, 24 Apr 2006 15:17:11 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.205]) + by postgresql.org (Postfix) with ESMTP id CD8C411F8B7A + for ; + Mon, 24 Apr 2006 07:53:29 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id h31so623071wxd + for ; + Mon, 24 Apr 2006 03:53:30 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type; + b=CvPunHi8iH9qgwwUrOQyprOHACCYyNF34/rwR5XmyPZm05G1wZ24qSOPZ8q19WsoKWzRZyavROmGL8N1KINN0DTK3QE/YiWFiyZUObQZC/dNzoIRuyBJd1fyH1yY9AIabRYIM6aiFEk3BQianLOt7tHG7Qkq4B+BbBMRLysL3fI= +Received: by 10.70.43.8 with SMTP id q8mr3791011wxq; + Mon, 24 Apr 2006 03:53:30 -0700 (PDT) +Received: by 10.70.37.12 with HTTP; Mon, 24 Apr 2006 03:53:29 -0700 (PDT) +Message-ID: <786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.com> +Date: Mon, 24 Apr 2006 12:53:29 +0200 +From: "Paul Mackay" +To: pgsql-performance@postgresql.org +Subject: Index on function less well cached than "regular" index ? +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_23912_14956547.1145876009963" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/525 +X-Sequence-Number: 18609 + +------=_Part_23912_14956547.1145876009963 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I have a table of ~ 41 000 rows with an index on the result of a function +applied to a certain text column (the function basically removes "neutral" +or common words like "the","on","a", etc. from the string). + +I then execute a query with a where clause on this function result with an +order by on the function result also and a limit of 200. Logically the +EXPLAIN shows that an index scan is used by the planner. A query returning +the maximum 200 number of records takes around 20 ms. What is surprising is +that the same query executed several times takes practically the same time, +as if the result was not cached. + +To test this, I then added a new text column to the same table, populating +it with the function result mentioned above. Now, I create an index on this +new column and execute the same query as described above (order by on the +new column and limit 200). The execution plan is exactly the same, except +that the new index is used of course. The first execution time is similar, +i.e. 20 ms approx., but the next executions of the same query take about 2 +ms (i.e to say a 10 to 1 difference). So this time, it seems that the resul= +t +is properly cached. + +Could the problem be that an index on a function result is not cached or +less well cached ? + +Thanks, +Paul + +------=_Part_23912_14956547.1145876009963 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I have a table of ~ 41 000 rows with an index on the result of a function a= +pplied to a certain text column (the function basically removes "neutr= +al" or common words like "the","on","a",= + etc. from the string). +

I then execute a query with a where clause on this function result = +with an order by on the function result also and a limit of 200. Logically = +the EXPLAIN shows that an index scan is used by the planner. A query return= +ing the maximum 200 number of records takes around 20 ms. What is surprisin= +g is that the same query executed several times takes practically the same = +time, as if the result was not cached. +

To test this, I then added a new text column to the same table, pop= +ulating it with the function result mentioned above. Now, I create an index= + on this new column and execute the same query as described above (order by= + on the new column and limit 200). The execution plan is exactly the same, = +except that the new index is used of course. The first execution time is si= +milar,=20 +i.e. 20 ms approx., but the next executions of the same query take about 2 = +ms (i.e to say a 10 to 1 difference). So this time, it seems that the resul= +t is properly cached.

Could the problem be that an index on a functi= +on result is not cached or less well cached ?=20 +

Thanks,
Paul
+ +------=_Part_23912_14956547.1145876009963-- + +From pgsql-performance-owner@postgresql.org Mon Apr 24 15:47:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2A0CB11F8C9E + for ; + Mon, 24 Apr 2006 15:47:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 61799-01-7 + for ; + Mon, 24 Apr 2006 15:47:01 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.233]) + by postgresql.org (Postfix) with ESMTP id 46BD311F9506 + for ; + Mon, 24 Apr 2006 11:36:22 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so900547wra + for ; + Mon, 24 Apr 2006 07:36:23 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:from:to:cc:subject:date:organization:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:x-mimeole:thread-index:message-id; + b=Bnf7LHINcQNotyjSBjEgy8JDjAcJLQ0rA3wKDLp7//FT2CfxP7wn7Dx29dbYOe5U/FmDDkH7XKP6iyIPaRKs1J5bND40Pv5aPTmSCE+EqrV+5xBxZhOHLUXoXqGH5bQEHVi8qJrnsghocrsqry5DN3RZRD6Ch3/9QgUesBHupI4= +Received: by 10.54.67.6 with SMTP id p6mr4769861wra; + Mon, 24 Apr 2006 07:36:23 -0700 (PDT) +Received: from sbew318anc22 ( [200.157.135.150]) + by mx.gmail.com with ESMTP id 24sm2702056wrl.2006.04.24.07.36.22; + Mon, 24 Apr 2006 07:36:22 -0700 (PDT) +From: "Bruno Almeida do Lago" +To: "'Tom Lane'" +Cc: +Subject: Re: GROUP BY Vs. Sub SELECT +Date: Mon, 24 Apr 2006 11:36:18 -0300 +Organization: G&P +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +In-Reply-To: <18881.1145835264@sss.pgh.pa.us> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Thread-Index: AcZnLnVB6UHho65rRDeqBANJ7XWvYQAfUoVg +Message-ID: <444ce266.1ca74910.7370.ffffe386@mx.gmail.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/526 +X-Sequence-Number: 18610 + +OK! I totally understand what you said. I'll load this table with a +simulated data and see how PG deals with it. + +About the queries being different, yes, I'm sure they are :-) I did not +mention that application is able to handle both. + +I'd like to get more info on EXPLAIN ANALYZE output... where can I read more +about it? + +Thank you very much for your attention!! + +Regards, +Bruno + + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Sunday, April 23, 2006 8:34 PM +To: Bruno Almeida do Lago +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] GROUP BY Vs. Sub SELECT + +"Bruno Almeida do Lago" writes: +> I'm just getting familiar with EXPLAIN ANALYZE output, so I'd like to get +> some help to identify which one of the following queries would be better: + +Well, you're breaking one of the first laws of PG performance analysis, +which is to not try to extrapolate the behavior on large tables from the +behavior on toy tables. You can't really see where the bottlenecks are +on a toy example, and what's more there's no reason to think that the +planner will use the same plan when presented with much larger tables. +So you need to load up a meaningful amount of data (don't forget to +ANALYZE afterward!) and then see what it does. + +> I think 2nd would be better, since when database grow up the GROUP BY may +> become too costly. Is that right? + +The two queries don't give the same answer, so asking which is faster +is a bit irrelevant. (When there's more than one group, wouldn't the +per-group MAXes be different?) + + regards, tom lane + + +From pgsql-performance-owner@postgresql.org Mon Apr 24 16:01:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8B6DD11F690E + for ; + Mon, 24 Apr 2006 16:01:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 64829-01-8 + for ; + Mon, 24 Apr 2006 16:00:30 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wumpus.mythic-beasts.com (wumpus.mythic-beasts.com + [212.69.37.9]) by postgresql.org (Postfix) with ESMTP id A8B5411F9508 + for ; + Mon, 24 Apr 2006 11:36:26 -0300 (ADT) +Received: from sphinx.mythic-beasts.com ([212.69.37.6]) + by wumpus.mythic-beasts.com with esmtp (Exim 4.44) + id 1FY2Ar-00069J-Qe + for pgsql-performance@postgresql.org; Mon, 24 Apr 2006 15:36:25 +0100 +Received: from xelah (helo=localhost) + by sphinx.mythic-beasts.com with local-esmtp (Exim 4.51) + id 1FY2Ar-000365-08 + for pgsql-performance@postgresql.org; Mon, 24 Apr 2006 15:36:25 +0100 +Date: Mon, 24 Apr 2006 15:36:24 +0100 (BST) +From: Alex Hayward +X-X-Sender: xelah@sphinx.mythic-beasts.com +To: Pgsql performance +Subject: Re: Hardware: HP StorageWorks MSA 1500 +In-Reply-To: <444C29ED.2070901@paradise.net.nz> +Message-ID: +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E4009@sesrv12.wirelesscar.com> + <444C29ED.2070901@paradise.net.nz> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/527 +X-Sequence-Number: 18611 + +On Mon, 24 Apr 2006, Mark Kirkwood wrote: + +> If I'm reading the original post correctly, the biggest issue is likely +> to be that the 14 disks on each 2Gbit fibre channel will be throttled to +> 200Mb/s by the channel , when in fact you could expect (in RAID 10 +> arrangement) to get about 7 * 70 Mb/s = 490 Mb/s. + +The two controllers and two FC switches/hubs are intended for redundancy, +rather than performance, so there's only one 2Gbit channel. I don't know +if its possible to use both in parallel to get better performance. + +I believe it's possible to join two or more FC ports on the switch +together, but as there's only port going to the controller internally this +presumably wouldn't help. + +There are two SCSI U320 buses, with seven bays on each. I don't know what +the overhead of SCSI is, but you're obviously not going to get 490MB/s +for each set of seven even if the FC could do it. + +Of course your database may not spend all day doing sequential scans one +at a time over 14 disks, so it doesn't necessarily matter... + + +From pgsql-performance-owner@postgresql.org Mon Apr 24 15:14:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0AA5B11F6223 + for ; + Mon, 24 Apr 2006 15:14:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 53145-02-3 + for ; + Mon, 24 Apr 2006 15:14:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 6EAFD11F657F + for ; + Mon, 24 Apr 2006 14:09:38 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id AC27156427; Mon, 24 Apr 2006 12:09:15 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Mon, 24 Apr 2006 12:09:15 -0500 +Date: Mon, 24 Apr 2006 12:09:15 -0500 +From: "Jim C. Nasby" +To: Will Reese +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow deletes in 8.1 when FKs are involved +Message-ID: <20060424170914.GE38186@pervasive.com> +References: <22780344-3C6A-474E-8101-60B8806DA152@rackspace.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <22780344-3C6A-474E-8101-60B8806DA152@rackspace.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060424:wreese@rackspace.com::EhiWj6Hj9TOR7AxI:00000000000000000 + 0000000000000000000000002Avn +X-Hashcash: + 1:20:060424:pgsql-performance@postgresql.org::lLMiIGXFuJ++sjbt:00000 + 00000000000000000000000037fm +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/524 +X-Sequence-Number: 18608 + +On Sun, Apr 23, 2006 at 09:41:14PM -0500, Will Reese wrote: +> I'm preparing for an upgrade from PostgreSQL 7.4.5 to 8.1.3, and I +> noticed a potential performance issue. +> +> I have two servers, a dual proc Dell with raid 5 running PostgreSQL +> 7.4, and a quad proc Dell with a storage array running PostgreSQL +> 8.1. Both servers have identical postgresql.conf settings and were + +BTW, you'll want to tweak some things between the two .conf files, +especially if the 8.1.3 server has more memory. Faster drive array means +you probably want to tweak random_page_cost down. + +Also, 8.1.3 has a lot of new config settings compared to 7.4.x; it'd +probably be best to take the default 8.1 config and tweak it, rather +than bringing the 7.4 config over. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon Apr 24 15:04:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 71B6811F65EA + for ; + Mon, 24 Apr 2006 15:04:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50159-01-6 + for ; + Mon, 24 Apr 2006 15:04:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.177]) + by postgresql.org (Postfix) with ESMTP id 900EF11F6C8B + for ; + Mon, 24 Apr 2006 14:27:42 -0300 (ADT) +Received: from [195.112.43.22] (helo=[192.168.0.7]) + by mrelayeu.kundenserver.de (node=mrelayeu5) with ESMTP (Nemesis), + id 0ML25U-1FY4qa2xvk-0008F0; Mon, 24 Apr 2006 19:27:41 +0200 +Subject: Re: Recovery will take 10 hours +From: Simon Riggs +To: Brendan Duddridge +Cc: PostgreSQL Performance +In-Reply-To: +References: <85A15B2E-F59C-4FEF-82D4-61F48ABDCDE5@clickspace.com> + <1145808368.3112.222.camel@localhost.localdomain> + +Content-Type: text/plain +Date: Mon, 24 Apr 2006 18:27:31 +0100 +Message-Id: <1145899652.3112.326.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-4.fc4) +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:726643fe08f41a451f0fe7fa43bce239 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/523 +X-Sequence-Number: 18607 + +On Sun, 2006-04-23 at 22:46 -0600, Brendan Duddridge wrote: + +> So how do you overlap the restore process with the retrieving of files? + +The restore command can be *anything*. You just write a script... + +> Our restore command is: +> +> restore_command = 'gunzip %p' +> +> If I change it to: +> +> restore_command = 'gunzip %p &' +> +> to execute the restore command in the background, will that do the +> trick? + +No, but you can execute a shell script that does use & internally. + +> But I don't think the real problem was the retrieval of the files. It +> only +> took maybe 1/2 a second to retrieve the file, but often took anywhere +> from +> 5 to 30 seconds to process the file. More so on the longer end of the +> scale. + +Sorry, thought you meant the decompression time. + +-- + Simon Riggs + EnterpriseDB http://www.enterprisedb.com/ + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 02:28:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 45EFE11F6089 + for ; + Mon, 24 Apr 2006 17:05:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 86226-01-3 + for ; + Mon, 24 Apr 2006 17:04:45 -0300 (ADT) +X-Greylist: delayed 00:31:43.835445 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 1585611F6B05 + for ; + Mon, 24 Apr 2006 16:32:54 -0300 (ADT) +Received: from av2.karneval.cz (av2.karneval.cz [81.27.192.108]) + by svr4.postgresql.org (Postfix) with ESMTP id 88B4F5B030D + for ; + Mon, 24 Apr 2006 19:01:07 +0000 (GMT) +Received: from localhost (localhost [127.0.0.1]) + by av2.karneval.cz (Postfix) with ESMTP id 6C8476DB3C; + Mon, 24 Apr 2006 21:01:02 +0200 (CEST) +Received: from av2.karneval.cz ([127.0.0.1]) + by localhost (av2 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 32689-07; Mon, 24 Apr 2006 21:01:01 +0200 (CEST) +Received: from mail.karneval.cz (mx1.karneval.cz [81.27.192.53]) + by av2.karneval.cz (Postfix) with ESMTP id 8D4E772541; + Mon, 24 Apr 2006 21:01:01 +0200 (CEST) +Received: from [192.168.1.101] (ip-89-102-195-181.karneval.cz + [89.102.195.181]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.karneval.cz (Postfix) with ESMTP id 6AE7B17C9D0; + Mon, 24 Apr 2006 21:01:01 +0200 (CEST) +Message-ID: <444D2066.6090200@karneval.cz> +Date: Mon, 24 Apr 2006 21:00:54 +0200 +From: Tomas Vondra +User-Agent: Mail/News 1.5 (X11/20060131) +MIME-Version: 1.0 +To: Ahmad Fajar +Cc: pgsql-performance@postgresql.org +Subject: Re: serious problems with vacuuming databases +References: <003101c65c6b$ad079850$7f00a8c0@kicommunication.com> +In-Reply-To: <003101c65c6b$ad079850$7f00a8c0@kicommunication.com> +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by karneval.cz +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/541 +X-Sequence-Number: 18625 + +> Hi Tomas, +> +> Tomas wrote: +> We've decided to remove unneeded 'old' data, which means removing about +> 99.999% of rows from tables A, C and D (about 2 GB of data). At the +> beginning, the B table (containing aggregated from A, C and D) was emptied +> (dropped and created) and filled in with current data. Then, before the +> deletion the data from tables A, C, D were backed up using another tables +> (say A_old, C_old, D_old) filled in using +> ..... +> 1) drop, create and fill table B (aggregated data from A, C, D) +> 2) copy 'old' data from A, C and D to A_old, C_old a D_old +> 3) delete old data from A, C, D +> 4) dump data from A_old, C_old and D_old +> 5) truncate tables A, C, D +> 6) vacuum full analyze tables A, C, D, A_old, C_old and D_old +> ---- +> +> I think you do some difficult database maintainance. Why you do that, if you +> just want to have some small piece of datas from your tables. Why don't you +> try something like: +> 1. create table A with no index (don't fill data to this table), +> 2. create table A_week_year inherit table A, with index you want, and some +> condition for insertion. (eg: table A1 you used for 1 week data of a year +> and so on..) +> 3. do this step for table B, C and D +> 4. if you have relation, make the relation to inherit table (optional). +> +> I think you should read the postgresql help, for more information about +> table inheritance. +> +> The impact is, you might have much table. But each table will only have +> small piece of datas, example: just for one week. And you don't have to do a +> difficult database maintainance like you have done. You just need to create +> tables for every week of data, do vacuum/analyze and regular backup. +> +> +> Best regards, +> ahmad fajar, + +Thanks for your advice, but I've read the sections about inheritance and +I don't see a way how to use that in my case, as I think the inheritance +takes care about the structure, not about the data. + +But I've read a section about partitioning (using inheritance) too, and +it seems useful. I'll try to solve the performance issues using this. + +Thanks for your advices +Tomas + +From pgsql-performance-owner@postgresql.org Mon Apr 24 16:54:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D991011F6CC4 + for ; + Mon, 24 Apr 2006 16:54:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 81704-01-5 + for ; + Mon, 24 Apr 2006 16:53:51 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from web31812.mail.mud.yahoo.com (web31812.mail.mud.yahoo.com + [68.142.207.75]) + by postgresql.org (Postfix) with SMTP id EE71211F8E01 + for ; + Mon, 24 Apr 2006 16:07:40 -0300 (ADT) +Received: (qmail 82275 invoked by uid 60001); 24 Apr 2006 19:07:39 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=LlDwVV/g2PSitO0uEl3PfNVkQv/9ppMdt553gwK3NTgzl357v1p/bB/s8jAwYIkgiEb6gr2882X54y50EnnbTCuPhZRjOLvQ7BKJyn+iYTOYcEqsH044J1EBnfSNSXY5FwyimeMjqIC0Vpis+nYc2dY0rZNDOnYxZsrktJCHYVM= + ; +Message-ID: <20060424190739.82273.qmail@web31812.mail.mud.yahoo.com> +Received: from [65.211.203.38] by web31812.mail.mud.yahoo.com via HTTP; + Mon, 24 Apr 2006 12:07:39 PDT +Date: Mon, 24 Apr 2006 12:07:39 -0700 (PDT) +From: Richard Broersma Jr +Subject: Re: GROUP BY Vs. Sub SELECT +To: Bruno Almeida do Lago , 'Tom Lane' +Cc: pgsql-performance@postgresql.org +In-Reply-To: <444ce266.1ca74910.7370.ffffe386@mx.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/528 +X-Sequence-Number: 18612 + + +> I'd like to get more info on EXPLAIN ANALYZE output... where can I read more +> about it? + +I believe this link has what you are looking for: +http://www.postgresql.org/docs/8.1/interactive/performance-tips.html + + +Regards, + +Richard Broersma Jr. + +From pgsql-performance-owner@postgresql.org Mon Apr 24 17:55:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9A33911F6BAA + for ; + Mon, 24 Apr 2006 17:55:12 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97748-01-7 + for ; + Mon, 24 Apr 2006 17:54:30 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.wirelesscar.com (mail.wirelesscar.com [212.209.35.30]) + by postgresql.org (Postfix) with ESMTP id 8CBA811F6CCE + for ; + Mon, 24 Apr 2006 17:37:36 -0300 (ADT) +Received: from sesrv12.wirelesscar.com ([192.168.10.17]) by + mail.wirelesscar.com with InterScan Messaging Security Suite; + Mon, 24 Apr 2006 22:37:26 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Hardware: HP StorageWorks MSA 1500 +Date: Mon, 24 Apr 2006 22:38:12 +0200 +Message-ID: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E40AA@sesrv12.wirelesscar.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Hardware: HP StorageWorks MSA 1500 +Thread-Index: AcZn0a8ZNY5cY1IXSeqHrY4mLpBI6wACotZA +From: "Mikael Carneholm" +To: "Alex Hayward" , + "Pgsql performance" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/529 +X-Sequence-Number: 18613 + +> If I'm reading the original post correctly, the biggest issue is=20 +> likely to be that the 14 disks on each 2Gbit fibre channel will be=20 +> throttled to 200Mb/s by the channel , when in fact you could expect=20 +> (in RAID 10 +> arrangement) to get about 7 * 70 Mb/s =3D 490 Mb/s. + +> The two controllers and two FC switches/hubs are intended for +redundancy, rather than performance, so there's only one 2Gbit channel. +I > don't know if its possible to use both in parallel to get better +performance. + +> I believe it's possible to join two or more FC ports on the switch +together, but as there's only port going to the controller internally +this presumably wouldn't help. + +> There are two SCSI U320 buses, with seven bays on each. I don't know +what the overhead of SCSI is, but you're obviously not going to get > +490MB/s for each set of seven even if the FC could do it. + + +Darn. I was really looking forward to ~500Mb/s :( + + +> Of course your database may not spend all day doing sequential scans +one at a time over 14 disks, so it doesn't necessarily matter... + + +That's probably true, but *knowing* that the max seq scan speed is that +high gives you some confidence (true or fake) that the hardware will be +sufficient the next 2 years or so. So, if dual 2GBit FC:s still don't +deliver more than 200Mb/s, what does? + +-Mikael + +From pgsql-performance-owner@postgresql.org Mon Apr 24 18:05:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7064111F623F + for ; + Mon, 24 Apr 2006 18:05:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 00204-01-9 + for ; + Mon, 24 Apr 2006 18:05:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id F082E11F6D19 + for ; + Mon, 24 Apr 2006 18:00:19 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 5DF1056423; Mon, 24 Apr 2006 16:00:19 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Mon, 24 Apr 2006 16:00:18 -0500 +Date: Mon, 24 Apr 2006 16:00:18 -0500 +From: "Jim C. Nasby" +To: Richard Broersma Jr +Cc: Bruno Almeida do Lago , + 'Tom Lane' , pgsql-performance@postgresql.org +Subject: Re: GROUP BY Vs. Sub SELECT +Message-ID: <20060424210017.GM48010@pervasive.com> +References: <444ce266.1ca74910.7370.ffffe386@mx.gmail.com> + <20060424190739.82273.qmail@web31812.mail.mud.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060424190739.82273.qmail@web31812.mail.mud.yahoo.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060424:rabroersma@yahoo.com::GbZilHyem5eevMKW:00000000000000000 + 0000000000000000000000006FBy +X-Hashcash: + 1:20:060424:teolupus@gmail.com::VmZ2daQVkbWbnTmo:0000000000000000000 + 0000000000000000000000003mzf +X-Hashcash: + 1:20:060424:tgl@sss.pgh.pa.us::lRw0QxEgGU6WGAOk:00000000000000000000 + 0000000000000000000000002hLC +X-Hashcash: + 1:20:060424:pgsql-performance@postgresql.org::lPumJsc6E1O1WLa9:00000 + 0000000000000000000000003+kE +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/530 +X-Sequence-Number: 18614 + +On Mon, Apr 24, 2006 at 12:07:39PM -0700, Richard Broersma Jr wrote: +> +> > I'd like to get more info on EXPLAIN ANALYZE output... where can I read more +> > about it? +> +> I believe this link has what you are looking for: +> http://www.postgresql.org/docs/8.1/interactive/performance-tips.html + +http://www.pervasive-postgres.com/lp/newsletters/2006/Insights_postgres_Apr.asp#4 +might also be worth your time to read... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon Apr 24 19:12:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AE3AD11F7210 + for ; + Mon, 24 Apr 2006 19:12:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 07860-07 + for ; + Mon, 24 Apr 2006 19:11:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id CF60511F6C9A + for ; + Mon, 24 Apr 2006 19:11:47 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3OMBiNh007023; + Mon, 24 Apr 2006 18:11:44 -0400 (EDT) +To: "Paul Mackay" +cc: pgsql-performance@postgresql.org +Subject: Re: Index on function less well cached than "regular" index ? +In-reply-to: <786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.com> +References: <786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.com> +Comments: In-reply-to "Paul Mackay" + message dated "Mon, 24 Apr 2006 12:53:29 +0200" +Date: Mon, 24 Apr 2006 18:11:44 -0400 +Message-ID: <7022.1145916704@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/531 +X-Sequence-Number: 18615 + +"Paul Mackay" writes: +> ... +> EXPLAIN shows that an index scan is used by the planner. A query returning +> the maximum 200 number of records takes around 20 ms. What is surprising is +> that the same query executed several times takes practically the same time, +> as if the result was not cached. +> ... +> Could the problem be that an index on a function result is not cached or +> less well cached ? + +I can't see how that would be. The index machinery has no idea what +it's indexing, and the kernel disk cache even less. + +Perhaps the majority of the runtime is going somewhere else, like the +initial evaluation of the function value to compare against? Or maybe +you've found some inefficiency in the planner's handling of function +indexes. Try comparing EXPLAIN ANALYZE output for the two cases to see +if the discrepancy exists during query runtime, or if it's upstream at +plan time. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 24 19:45:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6708511F66F1 + for ; + Mon, 24 Apr 2006 19:45:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19762-01 + for ; + Mon, 24 Apr 2006 19:45:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id 1E70311F6315 + for ; + Mon, 24 Apr 2006 19:45:24 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Mon, 24 Apr 2006 22:45:23 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR2); + id 1145918723382; Mon, 24 Apr 2006 15:45:23 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Mon, 24 Apr 2006 15:45:23 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Mon, 24 Apr 2006 15:45:23 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR2); + id 1145918718457; Mon, 24 Apr 2006 15:45:18 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C667F0.C29E8EF9" +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: ip address data type +Date: Mon, 24 Apr 2006 15:45:14 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF0406B11B@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: ip address data type +Thread-Index: AcZn8MB9lb4KwNdoS1+OwmnGEybBWA== +From: "Sriram Dandapani" +To: "Pgsql-Performance \(E-mail\)" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/532 +X-Sequence-Number: 18616 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C667F0.C29E8EF9 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + +Hi + +=20 + +I have queries that use like operators and regex patterns to determine +if an ip address is internal or external (this is against a table with +say 100 million distinct ip addresses). + +=20 + +Does the inet data type offer comparison/search performance benefits +over plain text for ip addresses.. + + +------_=_NextPart_001_01C667F0.C29E8EF9 +Content-Type: text/html; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hi

+ +

 

+ +

I have queries that use like operators and regex = +patterns to +determine if an ip address is internal or external (this is against a = +table +with say 100 million distinct ip = +addresses).

+ +

 

+ +

Does the inet data type offer comparison/search = +performance +benefits over plain text for ip addresses..

+ +
+ + + + + +------_=_NextPart_001_01C667F0.C29E8EF9-- + +From pgsql-performance-owner@postgresql.org Mon Apr 24 19:48:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9370411F628C + for ; + Mon, 24 Apr 2006 19:48:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 11902-10 + for ; + Mon, 24 Apr 2006 19:48:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id F181B11F6232 + for ; + Mon, 24 Apr 2006 19:48:37 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id C211B56423; Mon, 24 Apr 2006 17:48:37 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Mon, 24 Apr 2006 17:48:37 -0500 +Date: Mon, 24 Apr 2006 17:48:37 -0500 +From: "Jim C. Nasby" +To: Sriram Dandapani +Cc: "Pgsql-Performance (E-mail)" +Subject: Re: ip address data type +Message-ID: <20060424224837.GF64695@pervasive.com> +References: <6992E470F12A444BB787B5C937B9D4DF0406B11B@ca-mail1.cis.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF0406B11B@ca-mail1.cis.local> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060424:sdandapani@counterpane.com::KF72tmQ3Gbv1I7Yn:00000000000 + 0000000000000000000000005hAs +X-Hashcash: + 1:20:060424:pgsql-performance@postgresql.org::DtULaOxiX6byFNH+:00000 + 0000000000000000000000000Qvp +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/533 +X-Sequence-Number: 18617 + +On Mon, Apr 24, 2006 at 03:45:14PM -0700, Sriram Dandapani wrote: +> Hi +> +> I have queries that use like operators and regex patterns to determine +> if an ip address is internal or external (this is against a table with +> say 100 million distinct ip addresses). +> +> Does the inet data type offer comparison/search performance benefits +> over plain text for ip addresses.. + +Well, benchmark it and find out. :) But it'd be hard to be slower than +like or regex... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon Apr 24 20:40:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CA01B11F66F5 + for ; + Mon, 24 Apr 2006 20:40:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26800-06 + for ; + Mon, 24 Apr 2006 20:40:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from m.wordtothewise.com (goliath.word-to-the-wise.com + [208.187.80.130]) + by postgresql.org (Postfix) with ESMTP id 5BC9911F66F1 + for ; + Mon, 24 Apr 2006 20:40:17 -0300 (ADT) +Received: from [10.3.2.7] (184.word-to-the-wise.com [208.187.80.184]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by m.wordtothewise.com (Postfix) with ESMTP id 739B6106B2 + for ; + Mon, 24 Apr 2006 16:40:17 -0700 (PDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF0406B11B@ca-mail1.cis.local> +References: <6992E470F12A444BB787B5C937B9D4DF0406B11B@ca-mail1.cis.local> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Steve Atkins +Subject: Re: ip address data type +Date: Mon, 24 Apr 2006 16:40:16 -0700 +To: "Pgsql-Performance ((E-mail))" +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/534 +X-Sequence-Number: 18618 + + +On Apr 24, 2006, at 3:45 PM, Sriram Dandapani wrote: + +> Hi +> +> +> +> I have queries that use like operators and regex patterns to +> determine if an ip address is internal or external (this is against +> a table with say 100 million distinct ip addresses). +> +> +> +> Does the inet data type offer comparison/search performance +> benefits over plain text for ip addresses.. +It's probably better than text-based, but it's hard to be worse than +regex and like. + +Depending on your exact needs http://pgfoundry.org/projects/ip4r/ may be +interesting, and I've also found pretty good behavior by mapping an IP +address onto a 2^31 offset integer. + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Mon Apr 24 20:57:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BCCBE11F6B08 + for ; + Mon, 24 Apr 2006 20:57:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29529-02 + for ; + Mon, 24 Apr 2006 20:57:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-4.paradise.net.nz (bm-4a.paradise.net.nz + [203.96.152.183]) + by postgresql.org (Postfix) with ESMTP id 29AD611F6AC1 + for ; + Mon, 24 Apr 2006 20:57:47 -0300 (ADT) +Received: from smtp-1.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-4.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IY900B253WAE0@linda-4.paradise.net.nz> for + pgsql-performance@postgresql.org; Tue, 25 Apr 2006 11:57:46 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-108.dsl.clear.net.nz [218.101.29.108]) by + smtp-1.paradise.net.nz (Postfix) with ESMTP id 33DF4AD1BB7; + Tue, 25 Apr 2006 11:57:46 +1200 (NZST) +Date: Tue, 25 Apr 2006 11:57:34 +1200 +From: Mark Kirkwood +Subject: Re: Hardware: HP StorageWorks MSA 1500 +In-reply-to: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E40AA@sesrv12.wirelesscar.com> +To: Mikael Carneholm +Cc: Alex Hayward , + Pgsql performance +Message-id: <444D65EE.6040605@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Thunderbird 1.5 (X11/20060417) +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E40AA@sesrv12.wirelesscar.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/535 +X-Sequence-Number: 18619 + +Mikael Carneholm wrote: + +> +>> There are two SCSI U320 buses, with seven bays on each. I don't know +> what the overhead of SCSI is, but you're obviously not going to get > +> 490MB/s for each set of seven even if the FC could do it. +> + +You should be able to get close to 300Mb/s on each SCSI bus - provided +the PCI bus on the motherboard is 64-bit and runs at 133Mhz or better +(64-bit and 66Mhz give you a 524Mb/s limit). + +> +>> Of course your database may not spend all day doing sequential scans +> one at a time over 14 disks, so it doesn't necessarily matter... +> + +Yeah, it depends on the intended workload, but at some point most +databases end up IO bound... so you really want to ensure the IO system +is as capable as possible IMHO. + +> +> That's probably true, but *knowing* that the max seq scan speed is that +> high gives you some confidence (true or fake) that the hardware will be +> sufficient the next 2 years or so. So, if dual 2GBit FC:s still don't +> deliver more than 200Mb/s, what does? +> + +Most modern PCI-X or PCIe RAID cards will do better than 200Mb/s (e.g. +3Ware 9550SX will do ~800Mb/s). + +By way of comparison my old PIII with a Promise TX4000 plus 4 IDE drives +will do 215Mb/s...so being throttled to 200Mb/s on modern hardware seems +unwise to me. + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Tue Apr 25 06:40:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A668011F60AF + for ; + Tue, 25 Apr 2006 06:40:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 68611-02 + for ; + Tue, 25 Apr 2006 06:40:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) + by postgresql.org (Postfix) with ESMTP id 361CC11F6095 + for ; + Tue, 25 Apr 2006 06:40:15 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by ptb-relay01.plus.net with esmtp (Exim) id 1FYK1n-0006eQ-5z; + Tue, 25 Apr 2006 10:40:15 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 9351073660; + Tue, 25 Apr 2006 10:43:42 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id 6CF5715EA7; + Tue, 25 Apr 2006 10:40:09 +0100 (BST) +Message-ID: <444DEE78.7020703@archonet.com> +Date: Tue, 25 Apr 2006 10:40:08 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Friends +Cc: pgsql-performance@postgresql.org +Subject: Re: security for row level but not based on Database user's +References: <1145615328.300612.56380@e56g2000cwe.googlegroups.com> +In-Reply-To: <1145615328.300612.56380@e56g2000cwe.googlegroups.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/542 +X-Sequence-Number: 18626 + +Friends wrote: +> Hi +> +> I need to set security for row level but not based on Database user's +> login. It should be based on the user table login. For the particular +> user I need to allow only the particular records to access insert, +> update delete and select. + +Well, the data access stuff is all manageable via views, which is the +standard way to do this. + +You don't say which version of PostgreSQL you are using, but I'd be +tempted just to switch to a different user after connecting and use the +session_user system function to control what is visible in the view. + +For example: +CREATE VIEW my_contacts AS SELECT * FROM contacts WHERE owner = +session_user; + +If that's not practical then you'll need to write some functions to +simulate your own session_user (say application_user()). This is easiest +to write in plperl/pltcl or some other interpreted language - check the +list archvies for plenty of discussion. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Apr 25 07:40:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 13ACF11F60B0 + for ; + Tue, 25 Apr 2006 07:40:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 77985-05 + for ; + Tue, 25 Apr 2006 07:40:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pih-relay05.plus.net (pih-relay05.plus.net [212.159.14.132]) + by postgresql.org (Postfix) with ESMTP id D21AB11F60AF + for ; + Tue, 25 Apr 2006 07:40:21 -0300 (ADT) +Received: from [213.162.97.75] (helo=mail.metronet.co.uk) + by pih-relay05.plus.net with esmtp (Exim) id 1FYKxv-0007BQ-Sk; + Tue, 25 Apr 2006 11:40:20 +0100 +Received: from mainbox.archonet.com + (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) + by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 4A6AB73677; + Tue, 25 Apr 2006 11:43:47 +0100 (BST) +Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP id AE4AC15EA6; + Tue, 25 Apr 2006 11:40:13 +0100 (BST) +Message-ID: <444DFC8D.9060801@archonet.com> +Date: Tue, 25 Apr 2006 11:40:13 +0100 +From: Richard Huxton +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Ramasamy +Cc: 'Postgresql Performance' +Subject: Re: security for row level but not based on Database user's +References: <1145615328.300612.56380@e56g2000cwe.googlegroups.com> + <444DEE78.7020703@archonet.com> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/543 +X-Sequence-Number: 18627 + +Ramasamy wrote: +> Hi Richard , +> Very good Day. Great information that you given to me. + +Great glad you think it's useful. Oh, don't forget to cc: the +mailing-list - that's the convention around here. + +> I will try in your idea. Here I am using SQL server 2000(Even I can use SQL +> Sever 2005 too if needed.) We are dealing with lot of databases with lot of +> business logic. I think your information will great for me. + +Ah - you're not using PostgreSQL? Well, the principle is the same but +you should be aware that this is a PostgreSQL list so the details will +be different. + +> Let I try and I will back with you. +> +> Thanks and hands of too you. +> +> But i don't have any idea of getting Session from databases (I think you are +> meaning that user can be handle with session). If you have some more idea +> then it will be great full to me. + +With MS-SQL you'll probably want to look at T-SQL variables, although I +don't know if they last longer than a single transaction. Failing that, +functions or temporary tables might be a help. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Apr 25 10:28:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1ED8711F66FA + for ; + Tue, 25 Apr 2006 10:28:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 16630-01 + for ; + Tue, 25 Apr 2006 10:28:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fafnir.androme.com (fafnir.androme.com [62.58.96.158]) + by postgresql.org (Postfix) with ESMTP id 5C57711F66EA + for ; + Tue, 25 Apr 2006 10:28:45 -0300 (ADT) +Received: by fafnir.androme.com (Postfix, from userid 1003) + id E2A1BB917E5; Tue, 25 Apr 2006 15:28:45 +0200 (CEST) +Message-ID: <444E240D.3050000@andromeiberica.com> +Date: Tue, 25 Apr 2006 15:28:45 +0200 +From: Arnau +Reply-To: arnaulist@andromeiberica.com +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Query on postgresql 7.4.2 not using index +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/544 +X-Sequence-Number: 18628 + +Hi all, + + I have the following running on postgresql version 7.4.2: + +CREATE SEQUENCE agenda_user_group_id_seq +MINVALUE 1 +MAXVALUE 9223372036854775807 +CYCLE +INCREMENT 1 +START 1; + +CREATE TABLE AGENDA_USERS_GROUPS +( + AGENDA_USER_GROUP_ID INT8 + CONSTRAINT pk_agndusrgrp_usergroup PRIMARY KEY + DEFAULT NEXTVAL('agenda_user_group_id_seq'), + USER_ID NUMERIC(10) + CONSTRAINT fk_agenda_uid REFERENCES +AGENDA_USERS (USER_ID) + ON DELETE CASCADE + NOT NULL, + GROUP_ID NUMERIC(10) + CONSTRAINT fk_agenda_gid REFERENCES +AGENDA_GROUPS (GROUP_ID) + ON DELETE CASCADE + NOT NULL, + CREATION_DATE DATE + DEFAULT CURRENT_DATE, + CONSTRAINT un_agndusrgrp_usergroup +UNIQUE(USER_ID, GROUP_ID) +); + +CREATE INDEX i_agnusrsgrs_userid ON AGENDA_USERS_GROUPS ( USER_ID ); +CREATE INDEX i_agnusrsgrs_groupid ON AGENDA_USERS_GROUPS ( GROUP_ID ); + + +When I execute: + +EXPLAIN ANALYZE SELECT agenda_user_group_id FROM agenda_users_groups +WHERE group_id = 9; + +it does a sequential scan and doesn't use the index and I don't +understand why, any idea? I have the same in postgresql 8.1 and it uses +the index :-| + +Thanks +-- +Arnau + +From pgsql-performance-owner@postgresql.org Tue Apr 25 10:34:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CAFBD11F6601 + for ; + Tue, 25 Apr 2006 10:34:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 11675-08-2 + for ; + Tue, 25 Apr 2006 10:34:26 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.192]) + by postgresql.org (Postfix) with ESMTP id 5077611F6602 + for ; + Tue, 25 Apr 2006 10:34:24 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id o1so1049297nzf + for ; + Tue, 25 Apr 2006 06:34:24 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=MVNKHJlzJ17qKSZrwkCYIh08ZfU/4aLRh17790ydvo+wrL++OSg7xjxzZd0abeBSCXHF9yHnSihkSJGJsFoAhRX9rCmB2lorl3Xp3aWJF37XTywVJQRJSST3n6bnU6/AfV1lIU1SYUlPqUI6EwdcFXJBgtXI9M4a9aB2YQ17PbY= +Received: by 10.36.221.45 with SMTP id t45mr3018349nzg; + Tue, 25 Apr 2006 06:34:24 -0700 (PDT) +Received: by 10.36.97.8 with HTTP; Tue, 25 Apr 2006 06:34:24 -0700 (PDT) +Message-ID: <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> +Date: Tue, 25 Apr 2006 23:34:24 +1000 +From: "chris smith" +To: arnaulist@andromeiberica.com +Subject: Re: Query on postgresql 7.4.2 not using index +Cc: pgsql-performance@postgresql.org +In-Reply-To: <444E240D.3050000@andromeiberica.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <444E240D.3050000@andromeiberica.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/545 +X-Sequence-Number: 18629 + +On 4/25/06, Arnau wrote: +> Hi all, +> +> I have the following running on postgresql version 7.4.2: +> +> CREATE SEQUENCE agenda_user_group_id_seq +> MINVALUE 1 +> MAXVALUE 9223372036854775807 +> CYCLE +> INCREMENT 1 +> START 1; +> +> CREATE TABLE AGENDA_USERS_GROUPS +> ( +> AGENDA_USER_GROUP_ID INT8 +> CONSTRAINT pk_agndusrgrp_usergroup PRIMARY KEY +> DEFAULT NEXTVAL('agenda_user_group_id_seq'), +> USER_ID NUMERIC(10) +> CONSTRAINT fk_agenda_uid REFERENCES +> AGENDA_USERS (USER_ID) +> ON DELETE CASCADE +> NOT NULL, +> GROUP_ID NUMERIC(10) +> CONSTRAINT fk_agenda_gid REFERENCES +> AGENDA_GROUPS (GROUP_ID) +> ON DELETE CASCADE +> NOT NULL, +> CREATION_DATE DATE +> DEFAULT CURRENT_DATE, +> CONSTRAINT un_agndusrgrp_usergroup +> UNIQUE(USER_ID, GROUP_ID) +> ); +> +> CREATE INDEX i_agnusrsgrs_userid ON AGENDA_USERS_GROUPS ( USER_ID ); +> CREATE INDEX i_agnusrsgrs_groupid ON AGENDA_USERS_GROUPS ( GROUP_ID ); +> +> +> When I execute: +> +> EXPLAIN ANALYZE SELECT agenda_user_group_id FROM agenda_users_groups +> WHERE group_id =3D 9; + +Try + +EXPLAIN ANALYZE SELECT agenda_user_group_id FROM agenda_users_groups +WHERE group_id::int8 =3D 9; + +or + +EXPLAIN ANALYZE SELECT agenda_user_group_id FROM agenda_users_groups +WHERE group_id =3D '9'; + +and let us know what happens. + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Tue Apr 25 10:49:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 410D911F624C + for ; + Tue, 25 Apr 2006 10:49:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18790-03 + for ; + Tue, 25 Apr 2006 10:49:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fafnir.androme.com (fafnir.androme.com [62.58.96.158]) + by postgresql.org (Postfix) with ESMTP id 0CF8211F622B + for ; + Tue, 25 Apr 2006 10:49:33 -0300 (ADT) +Received: by fafnir.androme.com (Postfix, from userid 1003) + id 610F8B915EC; Tue, 25 Apr 2006 15:49:34 +0200 (CEST) +Message-ID: <444E28ED.3090900@andromeiberica.com> +Date: Tue, 25 Apr 2006 15:49:33 +0200 +From: Arnau +Reply-To: arnaulist@andromeiberica.com +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: chris smith +CC: pgsql-performance@postgresql.org +Subject: Re: Query on postgresql 7.4.2 not using index +References: <444E240D.3050000@andromeiberica.com> + <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> +In-Reply-To: <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/546 +X-Sequence-Number: 18630 + +chris smith wrote: +> On 4/25/06, Arnau wrote: +> +>>Hi all, +>> +>> I have the following running on postgresql version 7.4.2: +>> +>>CREATE SEQUENCE agenda_user_group_id_seq +>>MINVALUE 1 +>>MAXVALUE 9223372036854775807 +>>CYCLE +>>INCREMENT 1 +>>START 1; +>> +>>CREATE TABLE AGENDA_USERS_GROUPS +>>( +>> AGENDA_USER_GROUP_ID INT8 +>> CONSTRAINT pk_agndusrgrp_usergroup PRIMARY KEY +>> DEFAULT NEXTVAL('agenda_user_group_id_seq'), +>> USER_ID NUMERIC(10) +>> CONSTRAINT fk_agenda_uid REFERENCES +>>AGENDA_USERS (USER_ID) +>> ON DELETE CASCADE +>> NOT NULL, +>> GROUP_ID NUMERIC(10) +>> CONSTRAINT fk_agenda_gid REFERENCES +>>AGENDA_GROUPS (GROUP_ID) +>> ON DELETE CASCADE +>> NOT NULL, +>> CREATION_DATE DATE +>> DEFAULT CURRENT_DATE, +>> CONSTRAINT un_agndusrgrp_usergroup +>>UNIQUE(USER_ID, GROUP_ID) +>>); +>> +>>CREATE INDEX i_agnusrsgrs_userid ON AGENDA_USERS_GROUPS ( USER_ID ); +>>CREATE INDEX i_agnusrsgrs_groupid ON AGENDA_USERS_GROUPS ( GROUP_ID ); +>> +>> +>>When I execute: +>> +>>EXPLAIN ANALYZE SELECT agenda_user_group_id FROM agenda_users_groups +>>WHERE group_id = 9; +> +> +> Try +> +> EXPLAIN ANALYZE SELECT agenda_user_group_id FROM agenda_users_groups +> WHERE group_id::int8 = 9; +> +> or +> +> EXPLAIN ANALYZE SELECT agenda_user_group_id FROM agenda_users_groups +> WHERE group_id = '9'; +> +> and let us know what happens. +> + + + The same, the table has 2547556 entries: + +espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +agenda_users_groups +espsm_moviltelevision-# WHERE group_id::int8 = 9; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on agenda_users_groups (cost=0.00..59477.34 rows=12738 +width=8) (actual time=3409.541..11818.794 rows=367026 loops=1) + Filter: ((group_id)::bigint = 9) + Total runtime: 13452.114 ms +(3 filas) + +espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +agenda_users_groups +espsm_moviltelevision-# WHERE group_id = '9'; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on agenda_users_groups (cost=0.00..53108.45 rows=339675 +width=8) (actual time=916.903..5763.830 rows=367026 loops=1) + Filter: (group_id = 9::numeric) + Total runtime: 7259.861 ms +(3 filas) + +espsm_moviltelevision=# select count(*) from agenda_users_groups ; + count +--------- + 2547556 + + +Thanks +-- +Arnau + +From pgsql-performance-owner@postgresql.org Tue Apr 25 11:32:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 85C9711F6236 + for ; + Tue, 25 Apr 2006 11:32:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 24738-05 + for ; + Tue, 25 Apr 2006 11:31:53 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.204]) + by postgresql.org (Postfix) with ESMTP id 77F4911F6207 + for ; + Tue, 25 Apr 2006 11:31:51 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id 9so1061175nzo + for ; + Tue, 25 Apr 2006 07:31:52 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=HCfl0Uy2+yq6qERt5t+KWR86eWp5zEIWl8EemZksGvPmqASaoxXp8OJLTtRLoFPKfvJipiU13LrNLI+sRsYjZ7SoCeykr7bRUNQ4EhvRAt+Gj6IInuFwWyomfi6TxFuVLZuYtL0CLqVMxNjoramWFGy286wMYQNJ2f7kbDq7xrE= +Received: by 10.65.114.5 with SMTP id r5mr175131qbm; + Tue, 25 Apr 2006 07:31:51 -0700 (PDT) +Received: by 10.65.122.19 with HTTP; Tue, 25 Apr 2006 07:31:51 -0700 (PDT) +Message-ID: <1d4e0c10604250731k5aac183eg92919020bfb3ff27@mail.gmail.com> +Date: Tue, 25 Apr 2006 16:31:51 +0200 +From: "Guillaume Smet" +To: arnaulist@andromeiberica.com +Subject: Re: Query on postgresql 7.4.2 not using index +Cc: "chris smith" , pgsql-performance@postgresql.org +In-Reply-To: <444E28ED.3090900@andromeiberica.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <444E240D.3050000@andromeiberica.com> + <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> + <444E28ED.3090900@andromeiberica.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/547 +X-Sequence-Number: 18631 + +On 4/25/06, Arnau wrote: +> espsm_moviltelevision=3D# EXPLAIN ANALYZE SELECT agenda_user_group_id FRO= +M +> agenda_users_groups +> espsm_moviltelevision-# WHERE group_id =3D '9'; +> QUERY PLAN +> -------------------------------------------------------------------------= +------------------------------------------------------- +> Seq Scan on agenda_users_groups (cost=3D0.00..53108.45 rows=3D339675 +> width=3D8) (actual time=3D916.903..5763.830 rows=3D367026 loops=3D1) +> Filter: (group_id =3D 9::numeric) +> Total runtime: 7259.861 ms +> (3 filas) + +Arnau, + +Why do you use a numeric instead of an integer/bigint?? + +IIRC, there were a few problems with index on numeric column on older +version of PostgreSQL. + +You can't change the type of a column with 7.4, so create a new +integer column then copy the values in this new column, drop the old +one, rename the new one. Run vacuum analyze and recreate your index. + +It should work far better with an int. + +Note that you will have to update all the tables referencing this key... + +-- +Guillaume + +From pgsql-performance-owner@postgresql.org Tue Apr 25 12:05:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E1EF511F6240 + for ; + Tue, 25 Apr 2006 12:05:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 30544-05 + for ; + Tue, 25 Apr 2006 12:05:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 3A1DC11F623C + for ; + Tue, 25 Apr 2006 12:05:04 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 25 Apr 2006 15:05:02 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 25 Apr 2006 10:05:02 -0500 +Subject: Re: Query on postgresql 7.4.2 not using index +From: Scott Marlowe +To: arnaulist@andromeiberica.com +Cc: chris smith , pgsql-performance@postgresql.org +In-Reply-To: <444E28ED.3090900@andromeiberica.com> +References: <444E240D.3050000@andromeiberica.com> + <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> + <444E28ED.3090900@andromeiberica.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1145977502.23538.201.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 25 Apr 2006 10:05:02 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/548 +X-Sequence-Number: 18632 + +On Tue, 2006-04-25 at 08:49, Arnau wrote: +> chris smith wrote: +> > On 4/25/06, Arnau wrote: +> > +> >>Hi all, +> >> +> >> I have the following running on postgresql version 7.4.2: +> >> +> >>CREATE SEQUENCE agenda_user_group_id_seq +> >>MINVALUE 1 +> >>MAXVALUE 9223372036854775807 +> >>CYCLE +> >>INCREMENT 1 +> >>START 1; +> >> +> >>CREATE TABLE AGENDA_USERS_GROUPS +> >>( +> >> AGENDA_USER_GROUP_ID INT8 +> >> CONSTRAINT pk_agndusrgrp_usergroup PRIMARY KEY +> >> DEFAULT NEXTVAL('agenda_user_group_id_seq'), +> >> USER_ID NUMERIC(10) +> >> CONSTRAINT fk_agenda_uid REFERENCES +> >>AGENDA_USERS (USER_ID) +> >> ON DELETE CASCADE +> >> NOT NULL, +> >> GROUP_ID NUMERIC(10) +> >> CONSTRAINT fk_agenda_gid REFERENCES +> >>AGENDA_GROUPS (GROUP_ID) +> >> ON DELETE CASCADE +> >> NOT NULL, +> >> CREATION_DATE DATE +> >> DEFAULT CURRENT_DATE, +> >> CONSTRAINT un_agndusrgrp_usergroup +> >>UNIQUE(USER_ID, GROUP_ID) +> >>); +> >> +> >>CREATE INDEX i_agnusrsgrs_userid ON AGENDA_USERS_GROUPS ( USER_ID ); +> >>CREATE INDEX i_agnusrsgrs_groupid ON AGENDA_USERS_GROUPS ( GROUP_ID ); + +SNIP + +> The same, the table has 2547556 entries: +> +> espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +> agenda_users_groups +> espsm_moviltelevision-# WHERE group_id::int8 = 9; +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------------------- +> Seq Scan on agenda_users_groups (cost=0.00..59477.34 rows=12738 +> width=8) (actual time=3409.541..11818.794 rows=367026 loops=1) +> Filter: ((group_id)::bigint = 9) +> Total runtime: 13452.114 ms +> (3 filas) +> +> espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +> agenda_users_groups +> espsm_moviltelevision-# WHERE group_id = '9'; +> QUERY PLAN +> -------------------------------------------------------------------------------------------------------------------------------- +> Seq Scan on agenda_users_groups (cost=0.00..53108.45 rows=339675 +> width=8) (actual time=916.903..5763.830 rows=367026 loops=1) +> Filter: (group_id = 9::numeric) +> Total runtime: 7259.861 ms +> (3 filas) +> +> espsm_moviltelevision=# select count(*) from agenda_users_groups ; +> count +> --------- +> 2547556 + +OK, a few points. + +1: 7.4.2 is WAY out of date for the 7.4 series. The 7.4 series, also +it a bit out of date, and many issues in terms of performance have been +enhanced in the 8.x series. You absolutely should update to the latest +7.4 series, as there are known data loss bugs and other issues in the +7.4.2 version. + +2: An index scan isn't always faster. In this instance, it looks like +the number of rows that match in the last version of your query is well +over 10% of the rows. Assuming your average row takes up <10% or so of +a block, which is pretty common, then you're going to have to hit almost +every block anyway to get your data. So, an index scan is no win. + +3: To test whether or not an index scan IS a win, you can use the +enable_xxx settings to prove it to yourself: + +set enable_seqscan = off; +explain analyze ; + +and compare. Note that the enable_seqscan = off thing is a sledge +hammer, not a nudge, and generally should NOT be used in production. If +an index scan is generally a win for you, but the database isn't using +it, you might need to tune the database for your machine. note that you +should NOT tune your database based on a single query. You'll need to +reach a compromise on your settings that makes all your queries run +reasonably fast without the planner making insane decisions. One of the +better postgresql tuning docs out there is the one at: +http://www.varlena.com/GeneralBits/Tidbits/perf.html . + +Good luck. + +From pgsql-performance-owner@postgresql.org Tue Apr 25 12:23:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0B20211F6240 + for ; + Tue, 25 Apr 2006 12:23:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 36477-01 + for ; + Tue, 25 Apr 2006 12:23:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 6A0C511F6260 + for ; + Tue, 25 Apr 2006 12:23:07 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3PFN00e019484; + Tue, 25 Apr 2006 11:23:00 -0400 (EDT) +To: arnaulist@andromeiberica.com +cc: chris smith , pgsql-performance@postgresql.org +Subject: Re: Query on postgresql 7.4.2 not using index +In-reply-to: <444E28ED.3090900@andromeiberica.com> +References: <444E240D.3050000@andromeiberica.com> + <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> + <444E28ED.3090900@andromeiberica.com> +Comments: In-reply-to Arnau + message dated "Tue, 25 Apr 2006 15:49:33 +0200" +Date: Tue, 25 Apr 2006 11:22:59 -0400 +Message-ID: <19483.1145978579@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/549 +X-Sequence-Number: 18633 + +Arnau writes: + +> Seq Scan on agenda_users_groups (cost=0.00..53108.45 rows=339675 +> width=8) (actual time=916.903..5763.830 rows=367026 loops=1) +> Filter: (group_id = 9::numeric) +> Total runtime: 7259.861 ms +> (3 filas) + +> espsm_moviltelevision=# select count(*) from agenda_users_groups ; +> count +> --------- +> 2547556 + +So the SELECT is fetching nearly 15% of the rows in the table. The +planner is doing *the right thing* to use a seqscan, at least for +this particular group_id value. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 25 12:48:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EE44E11F622B + for ; + Tue, 25 Apr 2006 12:48:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40442-02 + for ; + Tue, 25 Apr 2006 12:47:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fafnir.androme.com (fafnir.androme.com [62.58.96.158]) + by postgresql.org (Postfix) with ESMTP id 4E82211F6109 + for ; + Tue, 25 Apr 2006 12:47:49 -0300 (ADT) +Received: by fafnir.androme.com (Postfix, from userid 1003) + id 4B2BEB929A3; Tue, 25 Apr 2006 17:47:48 +0200 (CEST) +Message-ID: <444E44A2.6030703@andromeiberica.com> +Date: Tue, 25 Apr 2006 17:47:46 +0200 +From: Arnau +Reply-To: arnaulist@andromeiberica.com +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Query on postgresql 7.4.2 not using index +References: <444E240D.3050000@andromeiberica.com> + <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> + <444E28ED.3090900@andromeiberica.com> + <19483.1145978579@sss.pgh.pa.us> +In-Reply-To: <19483.1145978579@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/550 +X-Sequence-Number: 18634 + +Tom Lane wrote: +> Arnau writes: +> +> +>> Seq Scan on agenda_users_groups (cost=0.00..53108.45 rows=339675 +>>width=8) (actual time=916.903..5763.830 rows=367026 loops=1) +>> Filter: (group_id = 9::numeric) +>> Total runtime: 7259.861 ms +>>(3 filas) +> +> +>>espsm_moviltelevision=# select count(*) from agenda_users_groups ; +>> count +>>--------- +>> 2547556 +> +> +> So the SELECT is fetching nearly 15% of the rows in the table. The +> planner is doing *the right thing* to use a seqscan, at least for +> this particular group_id value. + + +I have done the same tests on 8.1.0. + + +espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +agenda_users_groups WHERE group_id = 9; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------- + Bitmap Heap Scan on agenda_users_groups (cost=2722.26..30341.78 +rows=400361 width=8) (actual time=145.533..680.839 rows=367026 loops=1) + Recheck Cond: (group_id = 9::numeric) + -> Bitmap Index Scan on i_agnusrsgrs_groupid (cost=0.00..2722.26 +rows=400361 width=0) (actual time=142.958..142.958 rows=367026 loops=1) + Index Cond: (group_id = 9::numeric) + Total runtime: 1004.966 ms +(5 rows) + +espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +agenda_users_groups WHERE group_id::int8 = 9; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on agenda_users_groups (cost=0.00..60947.43 rows=12777 +width=8) (actual time=457.963..2244.928 rows=367026 loops=1) + Filter: ((group_id)::bigint = 9) + Total runtime: 2571.496 ms +(3 rows) + +espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +agenda_users_groups WHERE group_id::int8 = '9'; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on agenda_users_groups (cost=0.00..60947.43 rows=12777 +width=8) (actual time=407.193..2182.880 rows=367026 loops=1) + Filter: ((group_id)::bigint = 9::bigint) + Total runtime: 2506.998 ms +(3 rows) + +espsm_moviltelevision=# select count(*) from agenda_users_groups ; + count +--------- + 2555437 +(1 row) + + + Postgresql then uses the index, I don't understand why? in this +server I tried to tune the configuration, it's because of the tuning? +Because it's a newer version of postgresql? + + +Thanks for all the replies +-- +Arnau + +From pgsql-performance-owner@postgresql.org Tue Apr 25 12:54:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 94DBF11F610C + for ; + Tue, 25 Apr 2006 12:54:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38570-09 + for ; + Tue, 25 Apr 2006 12:54:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 9770511F6109 + for ; + Tue, 25 Apr 2006 12:54:24 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 25 Apr 2006 15:54:23 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 25 Apr 2006 10:54:23 -0500 +Subject: Re: Query on postgresql 7.4.2 not using index +From: Scott Marlowe +To: arnaulist@andromeiberica.com +Cc: pgsql-performance@postgresql.org +In-Reply-To: <444E44A2.6030703@andromeiberica.com> +References: <444E240D.3050000@andromeiberica.com> + <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> + <444E28ED.3090900@andromeiberica.com> <19483.1145978579@sss.pgh.pa.us> + <444E44A2.6030703@andromeiberica.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1145980463.23538.218.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 25 Apr 2006 10:54:23 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/551 +X-Sequence-Number: 18635 + +On Tue, 2006-04-25 at 10:47, Arnau wrote: +> Tom Lane wrote: +> > Arnau writes: +> > +> > +> >>espsm_moviltelevision=# select count(*) from agenda_users_groups ; +> >> count +> >>--------- +> >> 2547556 +> > +> > +> > So the SELECT is fetching nearly 15% of the rows in the table. The +> > planner is doing *the right thing* to use a seqscan, at least for +> > this particular group_id value. +> +> +> I have done the same tests on 8.1.0. +> +> +> espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +> agenda_users_groups WHERE group_id = 9; +> QUERY PLAN +> ---------------------------------------------------------------------------------------------------------------------------------------------- +> Bitmap Heap Scan on agenda_users_groups (cost=2722.26..30341.78 +> rows=400361 width=8) (actual time=145.533..680.839 rows=367026 loops=1) +> Recheck Cond: (group_id = 9::numeric) +> -> Bitmap Index Scan on i_agnusrsgrs_groupid (cost=0.00..2722.26 +> rows=400361 width=0) (actual time=142.958..142.958 rows=367026 loops=1) +> Index Cond: (group_id = 9::numeric) +> Total runtime: 1004.966 ms +> (5 rows) + +How big are these individual records? I'm guessing a fairly good size, +since an index scan is winning. + +> espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +> agenda_users_groups WHERE group_id::int8 = 9; +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------- +> Seq Scan on agenda_users_groups (cost=0.00..60947.43 rows=12777 +> width=8) (actual time=457.963..2244.928 rows=367026 loops=1) +> Filter: ((group_id)::bigint = 9) +> Total runtime: 2571.496 ms +> (3 rows) + +OK. Stop and think about what you're telling postgresql to do here. + +You're telling it to cast the field group_id to int8, then compare it to +9. How can it cast the group_id to int8 without fetching it? That's +right, you're ensuring a seq scan. You need to put the int8 cast on the +other side of that equality comparison, like: + +where group_id = 9::int8 + + + +From pgsql-performance-owner@postgresql.org Sat Apr 29 17:13:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 152CF11F6089 + for ; + Tue, 25 Apr 2006 12:54:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40553-04 + for ; + Tue, 25 Apr 2006 12:54:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id A9E7711F6237 + for ; + Tue, 25 Apr 2006 12:54:07 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 5544D314AA; Tue, 25 Apr 2006 17:54:06 +0200 (MET DST) +From: "codeWarrior" +X-Newsgroups: pgsql.performance +Subject: Re: Easy question +Date: Tue, 25 Apr 2006 08:55:29 -0700 +Organization: iDynaTECH, Inc. +Lines: 25 +Message-ID: +References: <1145741653.759727.38970@e56g2000cwe.googlegroups.com> +Reply-To: "codeWarrior" +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/689 +X-Sequence-Number: 18773 + +SELECT geom, group, production_facs FROM south_america + +WHERE UPPER(municipio) IN ('ACRE', 'ADJUNTAS', 'AGUADA'); + + + wrote in message +news:1145741653.759727.38970@e56g2000cwe.googlegroups.com... +> Hi List +> I have maybe an easy question but i do not find an answer, i have this +> SQL query: +> +> SELECT geom,group,production_facs FROM south_america +> WHERE municipio = '' +> OR municipio = 'ACRE' +> OR municipio = 'ADJUNTAS' +> OR municipio = 'AGUADA' +> +> The performance of this query is quite worse as longer it gets, its +> possible that this query gets over 20 to 30 OR comparisons, but then +> the performance is really worse, is it possible to speed it up? +> Thanks +> Clemens +> + + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 12:55:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7EC1111F623C + for ; + Tue, 25 Apr 2006 12:55:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40731-05 + for ; + Tue, 25 Apr 2006 12:55:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 123AC11F622B + for ; + Tue, 25 Apr 2006 12:55:39 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3PFtaVE019862; + Tue, 25 Apr 2006 11:55:36 -0400 (EDT) +To: arnaulist@andromeiberica.com +cc: pgsql-performance@postgresql.org +Subject: Re: Query on postgresql 7.4.2 not using index +In-reply-to: <444E44A2.6030703@andromeiberica.com> +References: <444E240D.3050000@andromeiberica.com> + <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> + <444E28ED.3090900@andromeiberica.com> + <19483.1145978579@sss.pgh.pa.us> + <444E44A2.6030703@andromeiberica.com> +Comments: In-reply-to Arnau + message dated "Tue, 25 Apr 2006 17:47:46 +0200" +Date: Tue, 25 Apr 2006 11:55:36 -0400 +Message-ID: <19861.1145980536@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/552 +X-Sequence-Number: 18636 + +Arnau writes: +> I have done the same tests on 8.1.0. + +Bitmap scans are a totally different animal that doesn't exist in 7.4. +A plain indexscan, such as 7.4 knows about, is generally not effective +for fetching more than a percent or two of the table. The crossover +point for a bitmap scan is much higher (don't know exactly, but probably +something like 30-50%). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 25 13:33:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4272211F6095 + for ; + Tue, 25 Apr 2006 13:33:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43972-10 + for ; + Tue, 25 Apr 2006 13:33:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fafnir.androme.com (fafnir.androme.com [62.58.96.158]) + by postgresql.org (Postfix) with ESMTP id 7987011F6093 + for ; + Tue, 25 Apr 2006 13:33:38 -0300 (ADT) +Received: by fafnir.androme.com (Postfix, from userid 1003) + id BC5ADB92A65; Tue, 25 Apr 2006 18:33:37 +0200 (CEST) +Message-ID: <444E4F5D.2070808@andromeiberica.com> +Date: Tue, 25 Apr 2006 18:33:33 +0200 +From: Arnau +Reply-To: arnaulist@andromeiberica.com +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Query on postgresql 7.4.2 not using index +References: <444E240D.3050000@andromeiberica.com> + <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> + <444E28ED.3090900@andromeiberica.com> + <19483.1145978579@sss.pgh.pa.us> + <444E44A2.6030703@andromeiberica.com> + <1145980463.23538.218.camel@state.g2switchworks.com> +In-Reply-To: <1145980463.23538.218.camel@state.g2switchworks.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/553 +X-Sequence-Number: 18637 + + +>>I have done the same tests on 8.1.0. +>> +>> +>>espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +>>agenda_users_groups WHERE group_id = 9; +>> QUERY PLAN +>>---------------------------------------------------------------------------------------------------------------------------------------------- +>> Bitmap Heap Scan on agenda_users_groups (cost=2722.26..30341.78 +>>rows=400361 width=8) (actual time=145.533..680.839 rows=367026 loops=1) +>> Recheck Cond: (group_id = 9::numeric) +>> -> Bitmap Index Scan on i_agnusrsgrs_groupid (cost=0.00..2722.26 +>>rows=400361 width=0) (actual time=142.958..142.958 rows=367026 loops=1) +>> Index Cond: (group_id = 9::numeric) +>> Total runtime: 1004.966 ms +>>(5 rows) +> +> +> How big are these individual records? I'm guessing a fairly good size, +> since an index scan is winning. + + How I could know the size on an individual record? + +> +> +>>espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +>>agenda_users_groups WHERE group_id::int8 = 9; +>> QUERY PLAN +>>------------------------------------------------------------------------------------------------------------------------------- +>> Seq Scan on agenda_users_groups (cost=0.00..60947.43 rows=12777 +>>width=8) (actual time=457.963..2244.928 rows=367026 loops=1) +>> Filter: ((group_id)::bigint = 9) +>> Total runtime: 2571.496 ms +>>(3 rows) +> +> +> OK. Stop and think about what you're telling postgresql to do here. +> +> You're telling it to cast the field group_id to int8, then compare it to +> 9. How can it cast the group_id to int8 without fetching it? That's +> right, you're ensuring a seq scan. You need to put the int8 cast on the +> other side of that equality comparison, like: +> +> where group_id = 9::int8 + + I just did what Chris Smith asked me to do :), here I paste the +results I get when I change the cast. + +espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +agenda_users_groups WHERE group_id = 9::int8; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------- + Bitmap Heap Scan on agenda_users_groups (cost=2722.33..30343.06 +rows=400379 width=8) (actual time=147.723..714.473 rows=367026 loops=1) + Recheck Cond: (group_id = 9::numeric) + -> Bitmap Index Scan on i_agnusrsgrs_groupid (cost=0.00..2722.33 +rows=400379 width=0) (actual time=145.015..145.015 rows=367026 loops=1) + Index Cond: (group_id = 9::numeric) + Total runtime: 1038.537 ms +(5 rows) + +espsm_moviltelevision=# EXPLAIN ANALYZE SELECT agenda_user_group_id FROM +agenda_users_groups WHERE group_id = '9'::int8; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------- + Bitmap Heap Scan on agenda_users_groups (cost=2722.33..30343.06 +rows=400379 width=8) (actual time=153.858..1192.838 rows=367026 loops=1) + Recheck Cond: (group_id = 9::numeric) + -> Bitmap Index Scan on i_agnusrsgrs_groupid (cost=0.00..2722.33 +rows=400379 width=0) (actual time=151.298..151.298 rows=367026 loops=1) + Index Cond: (group_id = 9::numeric) + Total runtime: 1527.039 ms +(5 rows) + + +Thanks +-- +Arnau + +From pgsql-performance-owner@postgresql.org Tue Apr 25 13:56:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 21F2B11F6089 + for ; + Tue, 25 Apr 2006 13:56:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 47638-06 + for ; + Tue, 25 Apr 2006 13:56:15 -0300 (ADT) +X-Greylist: delayed 00:18:02.033648 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id BDFBD11F60E5 + for ; + Tue, 25 Apr 2006 13:56:08 -0300 (ADT) +Received: from techforce.com.br (techforce.com.br [216.218.247.150]) + by svr4.postgresql.org (Postfix) with ESMTP id C27385B2EB6 + for ; + Tue, 25 Apr 2006 16:38:05 +0000 (GMT) +Received: from techforce.com.br (techforce.com.br [127.0.0.1]) + by techforce.com.br (8.12.11/8.12.11) with ESMTP id k3PGcGUq023353 + for ; Tue, 25 Apr 2006 09:38:17 -0700 +From: "andremachado" +To: pgsql-performance@postgresql.org +Subject: Firebird 1.5.3 X Postgresql 8.1.3 (linux and windows) +Date: Tue, 25 Apr 2006 14:38:16 -0200 +Message-Id: <20060425160609.M20649@techforce.com.br> +X-Mailer: Open WebMail 2.51 20050228 +X-OriginatingIP: 161.148.39.27 (andremachado@techforce.com.br) +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=OPENWEBMAIL_ATT_0.810408543420152" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/555 +X-Sequence-Number: 18639 + +This is a multi-part message in MIME format. + +------=OPENWEBMAIL_ATT_0.810408543420152 +Content-Type: text/plain; + charset=iso-8859-1 + +Hello, +The performance comparison saga of the last month continues (see list archive). +After some time experimenting on windows, the conclusion is clear: + +windows is likely crap for databases other than MS-SQL. + +I guess that MS-SQL uses lot of undocumented api calls, may run in kernel +mode, ring 0 and a lot of dirty tricks to get some reasonable performance. + +Then, I asked my coleague to send a new FB dump and a Pg dump to try at my +desktop machine. +This time, the database is somewhat bigger. Around 20 million records. + +The timings are attached. Tried to follow the same query sequence on both files. +Both databases are much more faster on linux than on windows, and the desktop +machine is not dedicated and tuned. (no scsi, no raid, many services enabled, +ext3 fs, etc). +At many of the queries, postgresql is faster, sometimes way MUCH faster. +But Firebird have very good defaults out of the box and a few of the queries +are really a pain in Postgresql. +Please, see the abismal timing differences at the last 2 queries, for example. +They used 100% cpu, almost no disk activity, no twait cpu, for loooong time to +complete. +Maybe these queries bring into the light some instructions weaknesses, or bad +tuning. +Do you have some suggestions? +Regards. + +Andre Felipe Machado +http://www.techforce.com.br +linux blog + +------=OPENWEBMAIL_ATT_0.810408543420152 +Content-Type: application/x-gzip; + name="queries_timing_firebird.txt.tar.gz" +Content-Disposition: attachment; filename="queries_timing_firebird.txt.tar.gz" +Content-Transfer-Encoding: base64 + +H4sICLxMTkQAAzlTWWp0YS50YXIA7VrbbttGEPUzv6CP+1AEVmBTe+NNqYoystQysCVHkp2HoiBo +a+2okCiZpFL7rf/Qn+vndEjxfrGj1LkU1cIAyZ3d2dXsmTMzC99thDcXvh3Ml3P31r6Ze+Jq7s3k +4D44eK6GCcYq5wd/wvt3L/76G1OmaYwf4KgRTdPwAcGcMvgjGoHxKsf4AOFn28EjbeMHjofQgXMj +FvO1aBznb1y/WfqfbZO3pz8iXwQIzBD4aOW+kqS4byGuA3S92rjBoXViW9P+WQvdeKslOun3Ts2x +2TNH0StCc9cVHvp9NXdRzzwxJ9PxKHwBbegQnjJMz+Z0w9diVwuFLadlOJqa9sCa9MxTNBxEeoaD +cE6ivhurTb5b+dnhVu1QBbLiydZ29nDQTV5a6I/3whMo2Yw5fnthXY66BH4/2rbe6GI4lbq5FosI +UQCuTJJ6G88TboCWYrnyHlAXaZrCFFU6EYvAyXqxdObcZ5+6glWVS/2Fs/bFDIHniS4iTKYcjH4t +9dabcI6McfT5enNzIzwfuijmujQWziz8YLpicOmdNw+EHy0xEMH1++hdhU1oOtueo4S2xzm6mJ5f +TFH7/Wop2jHW24FYrturTbDeBDI84KffzBeig+6AFB5sJ9g4C9m/W3SkGAwv/wfnL0m/xub5CcUv +v32PZk4g0IsXqL1aB+2EJNtXc7c9BwOh47kLNqyz7mJ+v2LtkkHR8dbojx8HOr6Y9MfIf/BnVw46 +Pjcnk3ej8Qm6Dxsqb2U2c2/km9lVuMtwt9JE3CLzykMAK0I6lHe4gV6PJ5eAI6yWpAx3MMtJa0zw +Ze0yEx/a7maxeFYbMDDDIzbgHaY9ZYMmB9msI0vkcRux6qVpT6HvNKTP4eQE4NhFh7E3+ZvlYQpV +ORkZc2yG4S1Os4ERfEFNbq0E0vFYcT/3gcuTdUquUuPDR0W3TTwj5xfgXuiQ4BZy3BmquDTsZjs6 +15UfmWqv7DqVoK3qz2ebH5CRa6++LTiL0/6b1/zyl10RzVmHa42I5kqH8ycRLSXsHpLky7KFQwb9 +GGIGarUybn0kIKQRIaXyIrMXJhdQGq1Wxlm3AsZWHX677FU1WhuMcM6fiNaGwYmql6I1lomyQ7DG +9YGaYEPXSBynpTjv+qaYZDsi9P14peGAxtOqLLJzGlA+twachYvGSKOP5wCNxNVCrZrzJzrWGamk +a8SA/KyEAqJxVae0krYZRNbxDkhQoBZiGRqIoqqU5CDBKfQYWIlBUZOdV5PzGbD93I0OJz4b4FIf +hG7g3IrlUWgQ88we9wf9cX/Ys8xI6izXq7pD/FynuHsa1z87H/cnZviMpsIzHBt3xyvHX4WJ8dHb +5+NRrz+ZmCejsCvSAc88KxSg0kK33mqzRlcPVYutvBlor5HE5UJvNJyaP/fPUFI7mGfno0LtgGoK +iW2jyRNjhnleQvISJZMoCs8kHBuZRMV5CcGphFFDyUtIKiFUL0hoJtENNZMAdFMJJZjmJdkcCqK8 +hGXaNM7zkvSXEqqywjrJL9UYIbSwjppIwHWJkpdoObsxPS/Ra+o0naoa/NCS41PoKzt+PLLk9bJq +7FKrAW801GqMck3Ted7dawLAM/H/LgFgO7QxW8uFhKfTy39NKY8lpEB2n5I5xjo/LXes1v3gd7r+ +VCZBdELLAUTjMoD/47GkMr2p7qc6U6Hu19OEIqxVEOShNZV82cZHCMgyOojweTEd2aOBBfR2ehRG +ld7I7g3P39i98wHMmUytoTk1xxbMiqwNIzI7Q2z54NjBKnAWR8nt0Zb0tzdIIL8LZlYgXP+oKYAl +o4agxf+CmcbnumrITYjNGz2j8SW7J1l0/FmMSc9wZFkkeyaFDZVUiO5vr4ySJE84iyjoLAmWGVV8 +aeODPaDhJSGyqnJfAr1o24NllUJHQ+GUp+sUhiFXW8MULfaZaU1sc3oB8OpC1uWLkHky2BaQhlIW +Wzr3IZBpEXiRJ+QBTxuLpd5pXC6V79q6idoqwSaSJMPK7zFJxiKujbQWE6TS3mEELY6ovTum2S0c +rDy0ByMLpkwtwB2s3cXRakmakMb3YvBh1eiTNxFD2a9j1ZvIkimSWwv2lB3CwJOaom7nrSA8ZoLE +Ao4cI+HOauKGbuhcrVSghGBICYr1h8I0TaneGsuYfVodqnFYIld3qFxhSdWxB/aXAXb1nu4/g2VU +d52CNZ1WkiCDqVUs66pBq3cqOyXVDXcqVIH1jOxOJc6Cmi5s9+jeo7sW3Y1XL3vg7IGzIy0yjeIy +LTKuU1UvFYjbkWVa1OgOtKgD+aXESBkp3DVQFdOYGr/2/x3s277t277t29dt/wDzwxckACgAAA== + +------=OPENWEBMAIL_ATT_0.810408543420152 +Content-Type: application/x-gzip; name="queries_timing_postgresql.txt.tar.gz" +Content-Disposition: attachment; + filename="queries_timing_postgresql.txt.tar.gz" +Content-Transfer-Encoding: base64 + +H4sICMlMTkQAA2swTG9jYi50YXIA1F3dchu5cva1nyCXKOf4rFTHokmJ+tstp0qW5bM6kSWvJO9m +T6VqCpwByVkNB6PBjGRu6SLvkJfLG+Qql7lPdwOY/yFnaG0qYZ2zoijO9zUajUaj0YDvUxH7QjmJ +v/DDmRNJlcxioe6DQfI1efE8r+FoODwYj1/8G7z/hz//+38Md/cOD/fGL4b4Gu3vDQ8PXoyG4929 +8e7ueB8+Hx0Od4cv2PCZ+Fe+UpXwmLEXfCoCPxKt31NpqNr/+v/2NfG8cPruH5may0fGg+CHl6z0 +CvlClD9hT5XfmRJJAsZT/bj2vdaXJ5Qb+1Hiy/DlzrrXX9Z+o9/3Nny9ZNzznIWvFI6baSwX9fbL +6bRD65/YSZrIBU98FzpgibiKGWCW8EkgWCymIhahKxRLJPt4ffWJuQFPlVADkCN25/6DcFy5WPDQ +a8BH0006yPHLyYVBQ2qDhwwwSGIe+DxEPyF+lyEIslFLz8NExFEsEsVOTm9u3zD6zxn+B0W/Obll +HP6U8THkY0RIciRzEaKe0FRIFpkmRfyDYQcx4Hs3KAGAsQX/6i/ShebxQ7BlV4YeqRnaHwUiEaBq +H1gr7Foc+cDdNK11fV+13IAPMgIVQFU6iWIJna5KZA4PebD8XTgK7EU4U+4mMgaQ4WC3E9llupiI +GGRjSQoNhFYrAexvWBp5PIGeBTRPYMsVi2IffgNlGE7sHc6mMXCCDhAjFgHBtMiYzGE2mcvA09z7 +wy4d9MQ++SF1S/gNspYFCnlEfVwh6mowt/gsYKtAiIhNRPIoRFjsrBgG2ZuCBZXZzQ8XplcH5OVL +jboz6sb+s+bAx5l+HIgWfhD4hu0Nm0Lbc8J29gAm+mRzdr6QKY6FB+4H5JomApgFzBNRBE6jkxwl +uyXDHXeSo2q4q2zA9EpXczU/StYKjBC4dLCPdnNdLyGIMZk9xj64RQe8vwP+KOKzknuFUdOln+B7 +77l7N4uhgzymITP3lgsGJEwzgAzTIFVzFsFf6KmKLPC5i46vxDEc7O3tbSSLgQNuK8ckncK8tkaS +bLhUGXY7+pK6JHoQkzuwI5n+rqrDqiBGEKd/fOdcXH/p0jkoS2PndBrQHToH5VjZOYF07xzl/16N +DTOGo9Fxh9kIZj6IOxUjJDQK5vnqTsMDiwx/k2nsNMSg5umugU023b/XkGwSS+65HBwazCcPviso +0IXB6M4FtGyahuQxnIn0/Ep/gx/p8Hpip4jELBIzSF4aY2x1en12cnvGPn65PL09v7q0xJH0w8RR +YraAvlAVwPWjrtJYa1+g04RD8IjWHcgZy/CL0xjFnxQB5pKosly1eMvI1XEcro25eorzyOOwtuxA +cbqp6ULOYLxP2RTHO8CA+eXguY7mMLGJEAJynOWmsbhP4WOI0pM5RqdzX7GtvAnbKCFFiw5E69Dj +9VURKuKnC+fk5vT8vKvCNOR3CgTkOJehCwO7txQ5KazhnQXEixUnhWChTNDM16ol7yWNwwLxIAL8 +iMO0DzpQ6HXAKeSCIT+sFfykzVfTvLGOuspfiHPcWFZtBNYHoTLTuianBQR5KtQ6Wg4Iie4kF0/5 +E+xq1UDb1Yvn6jFTPojlpnGMSpFRWTBlgyPwnPBzYRdVVlEkWDj1YfnoB81d88TePvD4beBP3kYz +dR+8hXiCvy1kaRCgLBg6NBGDsSy4HxqCNKY1C9q60Ky4wMJBJL66oDK/7NS6L1zOQgwCNXEU8DAU +FNvAyrRAQnOIxPAb3fy9zjihGFHq+KEnvjoULVF8WoYfDobD9XNaofFGBmi9UMAHwReOa7OK0voH +DoxRBXfnjNhNrLYVy8dt65/1HyBQDY2c0LegQxnXhMzk3F1rQr3lhI9ITEuOo+GXH8+uz4xQzWor +CNUhHlgrFI1zI01BQBKsoDkUCZbtEmPp2EercNyAK1VwRBvM1xCJEfFdKB9DQ8AsATMEQI3DwvH8 +WOCaojFabBhHq6mzcURfzbCB7ANo5iZZtgxZSnPcXL1hnz782rmd4KcidHfoJrg2UFw5kE+jafKB +B6lu6cSB0aWDIhXxmkvvP3bBuHawjRMOoxaxKRYiLsE9ivQaZ/4+C6RbaKOd7osBNnqGRw7OW2Jo +AvGS8Zg0E6OZkSaMGCTRJJ05mEBKlvDDD2vRSPdMlEfze8RjpfWM5g/uW2S9oQqE6Cv1Vzcl/Bxr +V4gDjYCIykyk2tgwOqtyolDPwSm+CjelSUC3U7ZzxgIXBYkIS1jf1k4+xahFI1Nes8Y/5WkAU3QC +MxV4H1c5CY9nmbfobmqFAIIgWQ7JNGSBjtKrDcNoA1dl6QqQmESMBY5j/SGZGU0tApeaRTnyqMHx +lQz0dI348LxnooZE1JO7dTmKkVEORVFcNqGE4rH4vRZBkNqRYbBkvXKZVYUgzA7BYE+kCqWoCKAK +Ejz6ydyRvleN0rpLcKp1Thxa74jJrs4/QES2tERIuQRP57sOTAsxj8GhcPhaCepP8Cdw/d0bTRDk +tDQ2ZfQDWGzShLWQXqpzTwIW19B0TNtDh4jaWhrs/aCLwTdO3zArpgvaTmF8gn7brq/NVHPHiBTF +oDnAmfjJgkcY7tSV3nG52xAJgiQYCAKvxt8hAvyjyqnnXM35rL5Mei5qxIdxAxSxmPHMAVYk+A0W +fX+kBIwIKsTkCRqU/lzEhN+o9IUAP9jU5mdiJvzGNocQWgZSRg2Iz8KM+MLbIYomfiXumzT+bPxK +Jwh8HjQqXsm4eVJ5JnrxNQp8F+IpIgJVRAXyBJzqH9n22/MPrNxo+C2CRie4pmrI13R36b/As8aX +Tbh7pwIcUxqekrYy9vwQXDjTXLBugHCDByQEqARWoa1BY/fGf1Gm5T7FjuBVQJ4oTYpR+9m/fL44 +Ob9kP59dv7+6OSN+ECXkgRP5XtNCv8f2LKZqje5hQbbgCmOqz6B1G0VGwvWnPghmFvrAHXNnCvNP +AqujmV/JKW6SlsmT1QbQBMtICu0nLuiBHZ1Gy5YtuEEOK9UggGlG5JtQBYajvpLgNvgOLRBpepuI +pcR89tyHAEelE5NnoJxVKBNmyXFDe6qWobuSpatNfJQx7soj3jyWof87tztNdu8nz0JNU9xU4TPh +POqe3JjVWAIC5vsFmPJ6nAvM8sSgFIg1tC3o0JsXspsgy0zcy9UcfV3CTIQCc7ao96VN99itcqRz +IOZpd39dE3B/Pfvp6ntmoHzyPZ5eTSSlqBONUcIHMT2BSxFY1IIilJUG5dVpsYaO6DostDT5mCC3 +ozFNuMWDmYTemi8sbyRl0LJ18g28oec/+F4KLg/doXYRURqU9K9EIMy2hs+r+eEutQM5s4F6AJpY +QLQJYwxj7Fbq8sZqBXLUibu4xMnQoOlUDQN6X6iyC6BuNwYCYswnvD3NylozrTMHHrRZ1ooYWYbo +FXznVUOq9SXzcaJYwdvKSg/mvI2s9J0WXpieZrh5Ci4I8y6bL6Y+ZAjoSA0uw1wRahVDrP9Ft/63 +K5hadWI5dZPct0/B2hIYzyjSXTyBNZUSfqgoU7Z500kk8KjkRf5ZxDDWpCpkyLBoLgUjnFCOg2NA +AMMKuXewTiVUPo4QI5LuNmcOE3dtP3ODbEOGY9xMJp7mKZPeiWXdBGHuOr84+/6tSNy3aqm0FRkr +hGf3B/AULJ9L2VjpZtNbAymDJ2zkQezxQ9vWLaDaTYzOTW5tru8iY+BqQ0xah1qUOO+vuyiZ9qR1 +3jsw+RMIMClXhaUrhixZRiu8yQZk2eYe5bVh8jbaxqwRWhVaPqiZdmuKkjTu+G0gSdbNPJyluPUH +7lyPu4wBB1wW8Bl2CfM+b0q6b8hOLdPBJMXVlC/MWHQBktLcMAFCkNcSyT0bt55mDWW9iOyPoGxJ +/qNbFKHDPQ9n3aYIcjQc7A7h/4eD8fBN/sveYRs/OhIztGJ2/pkZ7C2htjGs0ozwDtnlDIYYrPnc +xqiph2elvXfKRKrUxR0liGRZDm24PNyGCm0qtIqhEhiR6zJz5XxkDofqzvPPZh1nadu3kbCDZw4+ +sRltDo0CIA66S5URq1b19tVt6Ol6GoXbdTLEykQ3SKkgwTOhgmW1kUMjWi9Waq6Fs7lmW0brYd0D +pYDFQhcNIDt0oYwd6IeJhOlyWUG1wfw69kzZORDQA/4MaK3zsoy0EQKkKMrGWjYrMAtmt/ipzKa4 +4dCwvYNCYLe3lzXl+/s7r3/deb3Yee05r398/en1zaBge4Vm0+xOeBEGQnHYaF+NsUfvlmc9nXsO +E/bnxot0ljXwQ4HJl6n/tQGta+BzKsMklrS60W6SErmEqtd/ZGvYYuTTzFgNY83RyQzPInatfq1V +fOQ7aY07mnwiYVlk0hCWFLcgsOBRGKMc5BLqEVARj5gjHrbNbWXd0EkAqqgsENr1Le7VIwXjCbp4 +LR4VLuk9IdBdk1htQcUzVhKVOGmvsHFQbjAsNVjfQWkSmo0y9BfBVMP0lCGWibZXVFgNezQed9oD +zQ6UZD6AWWBtiNJ109hkhi7RslOQuSJBQ46ie4KipwR3fiAny0yG+mgoYocQC3aRIc8XYKSOyfl8 +dJRsL/u8oet7d7ybLij58SD69j0sakMI+YWDe69WWbkYHfNxtwYF/BTyYTLczgOkA3TY5LVNqRP+ +1bKBIFg1BhEfyuw8yvgOHMGiTLA/2u2wM9lQ7wlIGPpoh0N5O5ylCoSm0MlsCMNja8LN0aanffLE +WaF8r8Bl2ElpWGntmMKnCnvPgoQ6u4Lfg4SHQqYqWOoCQt1TWYmasZL8IBAJphZOtRI9Jzwc9tw5 +rgtGm8SaASXRs9kUCzl0ZQPMHgksVu9oCFmJYhE05lOfRVUNFRQdJbO13DyuVX6SZOsFKy3T66Jl +Nd7AkJJ7MdSUoMMkfOxAuDcrFRc8sYNOBd1N1Dku07iGjmop78SywSye2F7XLOuKluqySGQwLcSy +LD1CimUnWQu7nOtZ3e1EQEcPyvUqSA7hH0z0wnNKNbcWtH9F77rhafmqlSsoC7h39w5WrFG5gsRw +7A7HHfKgDbIQLCNYOlyWzZNAG3GlwEN7WGoeL6PaGq7PFg4BZIiE3rZVkz21P+5iUoVG3Z5+1rDF +2Y/yCzAzYaeCgh08Zdl+5qdr+BHK4qHi/LgacWA5jqn58Rsy412XJBcgOuaAySRyOJjeDAdmy2We +kAWj8aT22401u0+s03ApanR9xS7HaCkvSgArnorExYqYzMWjaEJnJpyWpEp3U6KTrJh3yM6uUhUc +jxLcIzLwZtuc1FNcpMZiBg5sGvAH2ZjYeWLce8BAobUOrqYhgIRoLMYqgFinQtgrTfAKCJXA4861 +uq8C0J8w3f8mSifBqqVYcXsGlLvgBtmkjXGi0jsG2doHdy30V3fuUx7QTi0JRAn75zw8Ygbali3x +3W4/RWLYbY65AfVoMBp0Of2XTyKG3mAiCQ0Yxx4va3i4t7cseGw9Gk2kaTko1pwsC/KgHJiCSZyF +9Np2KLoG/tfgMYpt1cgBloqr+wCm5bmApQEFuA0kXY+T6UU+jCsTCekwWqf1dPNstgzmCSyRh0nL +nuHHwaVUsIaib+H4zc1FJWjGc2YehykJd5P0iRdT/aN6cnw3GAy+Y/ZZ2l7LK3+A2xT4aCVny7fm +OvUNqlzs/AsM8hGdpc1qblXSPdvkZMNlKbFJq0hHH5LUSZYqUedSVhngRrvSRyJ3NFhhKYk5ZVu6 +jwHJg58sMwFM55se+EYBCqS6DsukwfKLIlRGDJ5WJLiKNQ5F0aTQj/jvIpa4mtb80AXlVpuhBkyI +nTPLx0aNb9RkAOupcRLGMTKX5rCeM2jZn2TsOwYaLbF0O4RKIUSmcyGoe3jKKy+du9d3NDjVQl5X +BRIVYzj0NoqlJjmWitLb3PWDajpf419cnZ5c9MkeaEiYtQ3mq2ICgeqdzDd0laOXS0HLpGb03pvP +oOpZzBc6c2Jrjsw6bMk+azjc4Mjypr4VDARK3AjWZbB6CPwHgQMzrdYgHq/TiPnep9oiBaPqDBu6 +hhYnC58WoRVe3wuqhQeHnU7RoyLK5y99pVIc+yX2Jkq88OWBBwWow04rszrlyoaKRdQeUjxXCgJI +JB4UqAUWJlOjTIiDl4X8fUWS8om9v775uVMclaUw7T04+nCB3oLHDtAJEXOrDp2swW+Cy1hQ6S/m +QoSDKftpy8Hcrm7xr3o/Ac+w41mhGZ2Zzupf2cX5ze3ZJYlzeXV7/vHXjLy15rlPyIGFRcWtHz0H +wQiWaeziiDT1Ckimg9m2IzU5aO+jNTZTWICGpVflkE2FuniIpn+711BXj9ZYbtSTE2K5qbinmsBN +uG8x6FLsFS6d3l1+ubh4heVN9Cs7v2H0CRCmof8V+ti9E0nj1vkmR6kyGPDvsaDPvgDNDqyfOXUy +smVbavqMlVeRBe+3qB4z2EAW+UhF6xrNLK7rslS4YUakC7yKuVBMnHfZcixwc6qNYEW0VRI0XjJU +Qu4aB6+9b6jCVi/80+u4brnVHvcLVXgplwLWUow0kLd/K+naIkqHoPUlvvbr2R09NdK5X5nAu169 +0kI6pctYzEa6nl6yQ1o1crSGMvm3tZhKKFcI8MiDVZMr26DKs7zVsENiWAq06dI6HkX95eTCSIK1 +9s5CJHPZdNfdFKPzNeX9WhId5OsNagLLtqTg/669RCK7wilNCqX8TTtjZfxn3iXTVfVIS9scOAB/ +hxWS4/EFqM5r2g3qs+KBMDZM6Xaq7IB/hLfjGHhtJnOYbSjM3xod7GJmDRYlsVTbL1+aWySzn/YN ++1fPf7legvyFOVUOLgfv6eL/+d+4H3ymoO0Lztquk7yU7QV58MytH0l6wz7IUOrP9OuWT4Akv3By +kwsj/1J7047zktk04hPjsziNOKYLJBWAOBHWzq7upf8KPay7KCxe6jgljvg+9R+k3bvk3lqWFo4a +TpHF5R5HM1jfgtUsFqeI7Qk3wFQl74zejJ3jFNEhmoc/8+6Ct6AbnBJ0py7tAF3p0umd72QK9z2n +oKBpM1t3ZVexrXpagHtjF2QFdGtUbeh9OrKOvk72vujUnyh1Ybj11UtTX2a4a7SxKe56+9gMl35q +ZXgy7md7q3ATcNb6l1Wa6I6Lx4Jw8csRPJxupN8MYyU4OEcvXWUVPcEJd+rjVZkInw3MZvxm8AJG +Fd76cm3K1vzaLLEZvhGjgYj0UlCRnPquD81qaEorET5YhSZjsaB2xLcO/mboJoyuPPR5qmS57zfn +KUKtt6hmngLGGvhm6TeD972vjhtGv9mWtQ+x1fANiiFoiRcWuOhqfO6EPDOhHtBtUksndFuj+G+F +ztQd7u2vSfBuDj0er8mnbg69tkKpF7Q9CIFbk5vqusWlEfwc/rAgz7YefVOXZoj8EOxPduL6NqJY +uCLC6TsQsxZ7X03UHNNU0Slp+LzoCTgDH1rYoas36Wy8pUrfie+vdzd9hffDlR6mE3rLIAiz3t4c +evWCjFhSh6rEkOsPZQn8cN7B3beztHcCoCu8wcEJuyUxeloQwT8AgcdbCkDWw1dDTsR94E4CrJ0s +p1dUSOAiVugM+LLhNr6O4C0az4LZrsvWHqKTlWShZReCZvASTpGgGC13k7+XvUR3CV4r1EUrK+EJ +pQTcGIavasGG04md078119Hg1eAjGAYzWmQCPd6ytYamFbqKU6TJl4bfZqAZTg28GuKv5NkszK8F +3Rum/ao4RY5e8Cs4ivBb+wer8r0M7xBORPzDy9OLLze3Z9fZH+w/w6D/RY4fXv58cvrly6d6nthc +0pT9MyP6fhFGhRJb5x+c89uzT9t0iRD7cHZ6cXJ9cnpyRW8Z8+mcFV32dXry4eTm9voK32DBzRb8 +HMDj+TPv8G35o21SQgHl8ur2xPl4fnN6csEuPxLO5Ud8xsK/M7D29+3i0yiqgxDs3Dx8rp++/PjO +vtk2G5tWmJPrn76c/3z1blT955ee9/XTl7PrX9nni5PL9f/M0v/910t2Yi71A8+8hXta70YHe8Px +4eD4eDCgt0eD4RDLuNS7EXv0vWT+brzNtribpDBBY6HEu+PR8Giwe3Q0GJh3x/b7eIUc/NzGHtn5 +J8Z+xCvH/kZ35mmyg+HxeHcA/wOu4e7e7uDgwDw72j0Y7Y1bGPfG4/FgfLw/GByN4aG98Z59an80 +hF+KvPpFzKcy9L5nW69g4hfxqwHls9g79oosz/xeeAYlvhH37AbvY8ObQO28jFUUtgV4bfVgcDAe +43UB+1qM3b2D4Qh+0cIfVYSHJ0Cpg929vf3BeG9UfqQueaY3Q7h/PDoaDY6ge+w7jXA4HO+OdtsV +tjfY3zscDOw789Do+HB80MCac3+iewiLnTY6gL4+POglwNEB9DI8snsEejo6Pu5Er19agHrf2Xxe +uQftpy1g2KJzOoHzP+1dW2/duBHus3/FeUiBeGEQvF+C5sFw4uK0iR3E3r4a2VyKAImzbRKg++87 +Q5GSSIqSzi3OWYhYrJRjShwOyZlvLqT8qH73YbpJZyEMfu/vq3z0YQ5KSkwYSiaNslbUR98JWClU +Ea5tjw1mgg1+Nvo0oGwUmKGGcBleJVxtmcIQCM5g1GAcnI4TgOM6m2i6Kb7xf77/4wmGJ/qsHnto +cNUzo4iGucg4E8SKScqZJZLhKnNESR6qSz3FsX6prP8OyKezqPt9xrtzOdFOTLhJJ4oRDEY+TBMl +4bY6SXCkuAKJavvV53c4FxtMS09Cc23eKTXwsMpyIXFy+Wuv+nwKOjoGF9xILAvzg7uBwduUjTP7 +AJU1ajFOXJw1W3WhKU0nwhTqKIZ5g2+69fbqfwFqQctPVo4xEHiWrT5/PXnMzBDwW00Bt18WrLZb ++TNBtZNx7MQ4iNSoA1LsBHI1x2uoBqyFhQTy1wjAXLoOnzYDTnuCTEzxXHkBlaA2FaWSCGvroGkr +uKSsKXgEYkN4TBvuJhDL9lCpbNwoGBTLUVVbVBjz0NKecNIPR0jM5upPgZ7XDJUPmBPS6FkoaWN8 +JFy+MLSThHkFA+sJALrbACNtiI62wkUlxdwBqIOniOYgCpjeEBsdBhXtjoe4U4UBA6ICnhDcEaHM +pphoQzQEUjBnNMxHC/OIhJut4MQPxEJlD8DmBMYhqNQge3eBdBshIc4pcEwr2UChQR9YgYCahNEE +mPh9tv86v7uF316gL+vq5hngjaerxwEuff3++XGLRUisGRxeHUhpgEhX0eMTeE2vrYhZQl1/BszX +tp0MCw2AtLMUl0Xo0wM+mJ77mNFTv9WjwGxATVO791O/Zvv2gur2L6vm1Yfjzd9Wrlf2DOOODLid +JNKurwazlSqEElSAdgnwRSpnaasFc8jDQflpBWpQC84FMTK61QxPluzlx08guGEpPsbtjJ/e3J+u +zq+e9f+ZDtaTJ+HIz1P/+M33315BrZNWQhUeQUEAdBH4v0r9gCynGL+WBhIGL9FqjZQanoiXqiQc +zDZLgGTCUyAqqEk+QhR1DVF0nKhh6eaR7iN62jGo0NsSLXUCYNalDBowSAEFEX9parbaq0FECTn7 +Uc770Dk5zyPOqHr7sKJseN5Vrfd0mPE9tUKLLvWVecN+/H/K/gGvCqPDM6FK1CD70nztUYQziyqq +PFURVUxTNcywHtB/xE73taB5wzH+Uy3oCsM2XNAZVAE5axjYxGrEazPltEHfxy+5XkXHyBx/y9Xl +03XnMhnx87SOntZDkzpskocTbOJby9HF0wKCnA6hlqdir3r+iLT8yerKfxNp9cJ/dinR6tJSooK6 +085UPRiUoE8Qpq2Ilh3YpLnnYqQZ14pdKXRV7jLAF9AGa9vgFV9FtSVhOzud1uU7b5Zga6WO2uX7 +VkA08rtOX5BbnMWa41ZOXfmU8rfao7FtJaNaAv38qdSbryX0nB7V8EPwVQxih4M4ggDSRk3i5HRf +A6CKzhdT9LXWy54uvP9Q+Lt20FaFH3NAYw2s/bZHOh093tdYtc54jfWx6Yd3tGaKCwQQrAivtEb3 +FP7cdnZTAy3j0NLVJQ+PlTb2xlGQXL9V9DE2GjQyHw+BVM3609Xp4cIaR6Q0R0qIZqyvEjNKacYY +SG70vyqJWCwGyIVwrPWClpYy/JUSI1BNKmOUJEKyqst8t4BG1boXVgnWhjMQursunFFQHHJAmNRU +E6N6T6FffDSeobhGkQNKI9wNsKhI/7CWEWQMiXczohmFmcu5QY2/UcuMcnR8oONWOSIon2i4KZUx +2iKSURu7+w98/vgNKSiBk01ZoqSpD15OTX8gOVcwwTHK39xMZ0EgKwWokXAz29c/GmuY27qkRGI0 +3Uli9bHFGZhiru2k4EzXjXEJY0qAy4LFqXCoIEOxSB1xFjO0/PXBAgxbpVqAzQCTkmCURtKtSG/K +eGhhz85KMJISWyliskY4PZx7gynvRGXGxKpVuoa5VvVwwOMKlrt0vEGLbhAtzssofudPxvcwLaC0 +U//pti/33978+/3nM4RG5y/vXj+/fP76+dXF+rz5sNvn378MwblD4bnN81mev3z1+vnNOV79o3DF +uuHn0HL4V/JgAIF3r15fXzy/uTl/do0/+XfAte9HSUDjaTgX6bc/So41R98O/OVQAPP44eXJ6u/I +zkIucM0tVwSlOzcCI6E8GJe8pgysMpizgAk2TGhKbBuqtgVE62ce9JvSWghNWqtPUslcLTXUt6dR +jjrhNNh0egpZdEkH796TN597+/mmElMk5gAZhKBghwMU5WYOhcxqQB+YboCykwk6D/r8zJkpVoPF +0CYhcAfqvor7mAKWecQmMD1kBLXnZPenR8t6iZNKzUgHZTAvBAaxAPlJMHTasbKCUjahZPeRmGK0 +IpiQKrgUYD1MUwzzxMdawMDpwMx8JHVEeNExxIswPorvihcNpkhpQppr8zYHE64qLgDkAFJorr3q +WyQJ9wfbMcLmU+G/jwgiC6x1/JbBNlSMjnk8DiEZ8PDjRknIpQUEw4yLEGSuKbo5BMsk8+CcOrFD +N0c728HdXmfDjxu2kE/2EYwP2opYVrJADzgt0OyVREeptQMLCmuJeE1L2kjjSHDZNM5901XdjoZh +VpW7tld+D3giIWbRKRqnr2Jb05lzyVLvM/CXIJ6MrnsMwoj5a6/69iPW51NcmnDNdOos6jA6g84k +gDxqkLbMeGGgTECtiCapng97ujdxde/J072Jq7upWs3a6jm/p9PMdjaZxhLTwJjbJoMsvPPhc8iO +ypAZDC8bSXADDiAuAFMurBBl5IhPmWP2lSWmjd9mmWJRmBTGUWjLoGSP0bl6iFk1bhMT3Say4kCu +hpixOTbZTggx406Gejtdaw+R5MRYE2Qukpw2jjJnKU6jnTpwmFkOBirZUGpN0acinoxQZgjAj4dh +NzHoUrXMAA23+4+5HQvAcD+NReu/7zLUaiHZXrO5+Voatb2XDGRo1lIye7Z939XZzYjdkrlUmpQ3 +mjf1g1O67AY5msOrqZ+puees1pDMqMaJ+8EcM0mOxJ6S4MCOY7CARtzDE97hHGecrV69vvZgBK+/ +3l7fXV+uL9bnL87Qc3xxfXdx9eofdxevLuGZm9v11fnt+es1POURB9TosMabr6t4MtBZPNaicew2 +R1vA3//z7d0av4V3VnNSx1pX8JavPzCv4FD7KnsPBPb6q6+f8T3mFoZ/pn7nPQxZ563e0wsPe5AH +lqNCibNLzQUulBBUe7+0cII6TmS7Y1RoI1ooJoqtQ0w4gmdu4L487gCOBvmkhOS6POej7+7stwpP +S0viZuxZreKGCTzqg1ni2oBY9bCMxCGeAI4zf+4SKc9QPcMEsbdfmsM33/7+ITljcSIjgnGuAEYI +jsd5WIfhAjqrb5xqZQBzo0dJaCGJ0CN7Wvul4jkKnUo9R+HHeipC3hfc7Y994cyhl4fN7Ys0hOHO +Bu58ekm0DKb6Mtqj0aNZ8t7sYc8xz/G9BjvFOwiBFSZq2XldKnxbzKG6Fj6UFG67eIukUc3zAd4K +S6z30sXbeVGHnJwyBAR2Je4y3ZQkAxzUAh9zFIxGbeTmBDVlrwe75P09RKDI2tZVjIEia1yNSdKB +MS7RV4rBHiq25lEhTeOgCUc5UTNCMUA2kRizYxj65+2inhU8KstWp8DkPSqEj8At2ujtMGi/zQiJ +CRCdCrfna4UH6Wycq1OWQ54Qk/d/z1EoToEFmMsFzOMxZrMLL4pcNR8hqEYKytOmYKIZh/lA/mbn +WMEw5zYPaZR5kcShGSVAnrGk/twsPtCSfpeXjnNWV4O4lAgfEvXXrvaMU596fY56Hq/5TrNpGgBO +iYYE1kZxExIyY1Bp4/DAqlGX+4THvbWi0N2+vmqNnbuX5+ubu/PbX8E6wo0IX983X6KMf08MpVXr +iP785n9oh/HUbvKGXN9e49UdUBcvwh6o/Fycp/G1pY88/iUmAfVpjPlC3l3u35rm8GS0Qw2e1hg8 +k5F3J+ZAy1d3l9dreOR2DWYTtP2U+tZC6T6blcYPRBlA6LNIrLreifLUoIwVcQO6mOIDxg5aVgxR +fvoNh5mt3n+CIaer9/fvDmToHbt1dzKsJ5JV7yTIWK2davfV9BUFLw8Mgdp4pA0eMmLxP3hO1hTG +tBONOwHGCwZuw12bSlnJE+VE+2Mb/TVzXGH7iRhc33/8lvtAq4TgUSgGlWBzZycJUY56QlR0itcJ +6Tdd1UBvs4xyIMSCUA7clVbVdtMhDco1tERlSSdpaUrnWv54f/fhy8c7/IIpGLYwWUDy0HAUQHQ7 +j7xowN081PtdAxKiiEjw8YHqOTpNzhrKFWDYMfbEkrs/E1T3aM4bWkYnOSmPWOEArm+sBBNLzlge +LCwPNm8mzBqV5Hsu2ZBk05YhEg9zduR4wiYDQ4RlpmZN13wUqnwc6Vn+PbOp83EUoWyc6cw2OY3N +NWW6oYbWNlhm/cGmN4h9jc6xx0kuJ/JHhJU8vMoHkiW4FRwWjpHh4B07nC7hy4LgHgrBlWcLHQ1o +Wy2obbDMQW1gpBvDrMHzG4N0kkYxU4VtDOQt96aboCBiJbG2ei7sNGpTlkuNeaMk3OkJtST9sWfE +X/ODQHZBbdA8dUQ6TwjcqYmTxoEAhpvQmutBUJuyzIGiNpOoDUCvz+9DWmIOwTw1uKC2I0Ntanp5 +oLMXr3FnLX8A1GYmUVs4/ijiuyNHbRIFR3P9SVEb3xS1CaqdxQ16eJzD6s23FaP0r6u3v3+fQHAL +hFsg3ALh9lVmOd4ArzmmAAW0Hx/RRvEqgnMYkPDBVsWsNSDfxE4ADt4lrMdNeDdx8KDBIzGMT7zt +8h33A+CY0YR6JOnvJpCkQQQpPSFd0G7vAE6LFqCMATjcpcAaWmJKwALgegBOJ4nAxwzgJrAELgtG +w/KgDwfg5GwAR/8EAE5jtB9PmOhCxMcP4JgSTFs82HwugPvLUpaylKUsZSlLWcpSlrKUpSxlKUtZ +ylKWspSlLGUpS/kJy/8BOY/h6gDwAAA= + +------=OPENWEBMAIL_ATT_0.810408543420152-- + +From pgsql-performance-owner@postgresql.org Tue Apr 25 13:45:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 84A0511F6026 + for ; + Tue, 25 Apr 2006 13:45:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50050-02 + for ; + Tue, 25 Apr 2006 13:45:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail8.sea5.speakeasy.net (mail8.sea5.speakeasy.net + [69.17.117.10]) + by postgresql.org (Postfix) with ESMTP id C17CD11F6089 + for ; + Tue, 25 Apr 2006 13:45:01 -0300 (ADT) +Received: (qmail 25868 invoked from network); 25 Apr 2006 16:45:01 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail8.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP + for ; 25 Apr 2006 16:45:00 -0000 +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Transfer-Encoding: 7bit +Message-Id: +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance +From: David Wheeler +Subject: PL/pgSQL Loop Vs. Batch Update +Date: Tue, 25 Apr 2006 09:44:55 -0700 +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/554 +X-Sequence-Number: 18638 + +Fellow PostgreSQLers, + +This post is longish and has a bit of code, but here's my question up- +front: Why are batch queries in my PL/pgSQL functions no faster than +iterating over a loop and executing a series of queries for each +iteration of the loop? Are batch queries or array or series +generation slow in PL/pgSQL? + +Now, for the details of my problem. For managing an ordered many-to- +many relations between blog entries and tags, I created these tables: + + CREATE TABLE entry ( + id SERIAL PRIMARY KEY, + title text, + content text + ); + + CREATE TABLE tag ( + id SERIAL PRIMARY KEY, + name text + ); + + CREATE TABLE entry_coll_tag ( + entry_id integer REFERENCES entry(id) + ON UPDATE CASCADE + ON DELETE CASCADE, + tag_id integer REFERENCES tag(id) + ON UPDATE CASCADE + ON DELETE CASCADE, + ord smallint, + PRIMARY KEY (entry_id, tag_id) + ); + +To make it easy to associate an entry with a bunch of tags in a +single query, I wrote this PL/pgSQL function: + + CREATE OR REPLACE FUNCTION entry_coll_tag_set ( + obj_id integer, + coll_ids integer[] + ) RETURNS VOID AS $$ + DECLARE + -- For checking to see if a tuple was updated. + update_count smallint; + -- For looping through the array. + iloop integer := 1; + BEGIN + -- Lock the containing object tuple to prevernt inserts into the + -- collection table. + PERFORM true FROM entry WHERE id = obj_id FOR UPDATE; + + -- Update possible existing record with the current sequence so + -- as to avoid unique constraint violations. We just set it to a + -- negative number, since negative numbers are never used for + -- ord. + UPDATE entry_coll_tag + SET ord = -ord + WHERE entry_id = obj_id; + + -- Loop through the tag IDs to associate with the entry ID. + while coll_ids[iloop] is not null loop + -- Update possible existing collection record. + UPDATE entry_coll_tag + SET ord = iloop + WHERE entry_id = obj_id + AND tag_id = coll_ids[iloop]; + + -- Only insert the item if nothing was updated. + IF FOUND IS false THEN + -- Insert a new record. + INSERT INTO entry_coll_tag (entry_id, tag_id, ord) + VALUES (obj_id, coll_ids[iloop], iloop); + END IF; + iloop := iloop + 1; + END loop; + + -- Delete any remaining tuples. + DELETE FROM entry_coll_tag + WHERE entry_id = obj_id AND ord < 0; + END; + $$ LANGUAGE plpgsql SECURITY DEFINER; + +Josh Berkus kindly reviewed it, and suggested that I take advantage +of generate_series() and batch updates instead of looping through the +results. Here's the revised version: + + CREATE OR REPLACE FUNCTION entry_coll_tag_set ( + obj_id integer, + coll_ids integer[] + ) RETURNS VOID AS $$ + BEGIN + -- Lock the containing object tuple to prevernt inserts into the + -- collection table. + PERFORM true FROM entry WHERE id = obj_id FOR UPDATE; + + -- First set all ords to negative value to prevent unique index + -- violations. + UPDATE entry_coll_tag + SET ord = -ord + WHERE entry_id = obj_id; + + IF FOUND IS false THEN + -- There are no existing tuples, so just insert the new ones. + INSERT INTO entry_coll_tag (entry_id, tag_id, ord) + SELECT obj_id, coll_ids[gs.ser], gs.ser + FROM generate_series(1, array_upper(coll_ids, 1)) + AS gs(ser); + ELSE + -- First, update the existing tuples to new ord values. + UPDATE entry_coll_tag SET ord = ser + FROM ( + SELECT gs.ser, coll_ids[gs.ser] as move_tag + FROM generate_series(1, array_upper(coll_ids, 1)) + AS gs(ser) + ) AS expansion + WHERE move_tag = entry_coll_tag.tag_id + AND entry_id = obj_id; + + -- Now insert the new tuples. + INSERT INTO entry_coll_tag (entry_id, tag_id, ord ) + SELECT obj_id, coll_ids[gs.ser], gs.ser + FROM generate_series(1, array_upper(coll_ids, 1)) AS gs +(ser) + WHERE coll_ids[gs.ser] NOT IN ( + SELECT tag_id FROM entry_coll_tag ect2 + WHERE entry_id = obj_id + ); + + -- Delete any remaining tuples. + DELETE FROM entry_coll_tag + WHERE entry_id = obj_id AND ord < 0; + END IF; + END; + $$ LANGUAGE plpgsql SECURITY DEFINER; + +Josh thought that the replacement of the loop with a couple of batch +queries would be an order of magnitude faster. So I happily ran my +benchmark comparing the two approaches. The benchmark actually tests +two different functions that had a similar refactoring, as well as +two other functions that are quite simple. Before the tests, I +inserted 100,000 entry records, and a random number of tag records +(1-10 for each entry) and related entry_coll_tag records, which came +out to around 500,000 entries in entry_coll_tag. I ran VACUUM and +ANALYZE before each test, and got the following results: + + func: 13.67 wallclock seconds (0.11 usr + 1.82 sys = 1.93 CPU) @ +21.95/s +func2: 13.68 wallclock seconds (0.10 usr + 1.71 sys = 1.81 CPU) @ +21.93/s + perl: 41.14 wallclock seconds (0.26 usr + 6.94 sys = 7.20 CPU) @ +7.29/s + +"func" is my original version of the function with the loop, "func2" +is the refactored version with the batch queries, and "perl" is my +attempt to do roughly the same thing in Perl. The benefits of using +the functions over doing the work in app space is obvious, but there +seems to be little difference between the two function approaches. If +you want to see the complete benchmark SQL and test script, it's here: + + http://www.justatheory.com/code/ +bench_plpgsql_collection_functions2.tgz + +So my question is quite simple: Why was the batch query approach no +faster than the loop approach? I assume that if my tests managed 100 +or 1000 rows in the collection table, the batch approach would show +an improvement, but why would it not when I was using it to manage +8-10 rows? Have I missed something here? + +Thanks, + +David + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 14:08:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C6E6A11F609A + for ; + Tue, 25 Apr 2006 14:08:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50050-08 + for ; + Tue, 25 Apr 2006 14:08:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id 3AC0411F6089 + for ; + Tue, 25 Apr 2006 14:08:10 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Tue, 25 Apr 2006 17:08:09 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR2); + id 1145984888589; Tue, 25 Apr 2006 10:08:08 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Tue, 25 Apr 2006 10:08:08 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Tue, 25 Apr 2006 10:08:08 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR2); + id 1145984883470; Tue, 25 Apr 2006 10:08:03 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C6688A.CFAF8F3C" +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: planner not using index for like operator +Date: Tue, 25 Apr 2006 10:08:02 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF0406B241@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: planner not using index for like operator +Thread-Index: AcZois+SPxQqXcoBTgyErj46p/jgpg== +From: "Sriram Dandapani" +To: "Pgsql-Performance \(E-mail\)" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/556 +X-Sequence-Number: 18640 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C6688A.CFAF8F3C +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + +For the query + +=20 + +=20 + +Select col1 from table1 + +Where col1 like '172.%' + +=20 + +The table has 133 million unique ip addresses. Col1 is indexed. + +=20 + +The optimizer is using a sequential scan + +=20 + +This is the explain analyze output + +=20 + +"Seq Scan on table1 (cost=3D0.00..2529284.80 rows=3D1 width=3D15) = +(actual +time=3D307591.339..565251.775 rows=3D524288 loops=3D1)" + +" Filter: ((col1)::text ~~ '172.%'::text)" + +"Total runtime: 565501.873 ms" + +=20 + +=20 + +The number of affected rows (500K) is a small fraction of the total row +count. + + +------_=_NextPart_001_01C6688A.CFAF8F3C +Content-Type: text/html; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

For the query

+ +

 

+ +

 

+ +

Select col1 from table1

+ +

Where col1 like = +‘172.%’

+ +

 

+ +

The table has 133 million unique ip addresses. Col1 = +is +indexed.

+ +

 

+ +

The optimizer is using a sequential = +scan

+ +

 

+ +

This is the explain analyze = +output

+ +

 

+ +

"Seq Scan on table1 (cost=3D0.00..2529284.80 = +rows=3D1 +width=3D15) (actual time=3D307591.339..565251.775 rows=3D524288 = +loops=3D1)"

+ +

"  Filter: ((col1)::text ~~ = +'172.%'::text)"

+ +

"Total runtime: 565501.873 = +ms"

+ +

 

+ +

 

+ +

The number of affected rows (500K) is a small = +fraction of +the total row count.

+ +
+ + + + + +------_=_NextPart_001_01C6688A.CFAF8F3C-- + +From pgsql-performance-owner@postgresql.org Tue Apr 25 14:53:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AE04F11F6553 + for ; + Tue, 25 Apr 2006 14:53:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 68798-05 + for ; + Tue, 25 Apr 2006 14:52:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 40B9711F6601 + for ; + Tue, 25 Apr 2006 14:52:55 -0300 (ADT) +Received: (qmail 6769 invoked from network); 25 Apr 2006 19:53:16 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 25 Apr 2006 19:53:16 +0200 +Date: Tue, 25 Apr 2006 19:53:15 +0200 +To: pgsql-performance@postgresql.org +Subject: Slow queries salad ;) +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/557 +X-Sequence-Number: 18641 + + + Here is a simple test case for this strange behaviour : + +annonces=> CREATE TABLE test.current (id INTEGER PRIMARY KEY, description +TEXT); +INFO: CREATE TABLE / PRIMARY KEY creera un index implicite +<> pour la table <> +CREATE TABLE + +annonces=> CREATE TABLE test.archive (id INTEGER PRIMARY KEY, description +TEXT); +INFO: CREATE TABLE / PRIMARY KEY creera un index implicite +<> pour la table <> +CREATE TABLE + +annonces=> CREATE VIEW test.all AS SELECT * FROM test.archive UNION ALL +SELECT * FROM test.current ; +CREATE VIEW + + let's populate... + +annonces=> INSERT INTO test.current SELECT id, description FROM annonces; +INSERT 0 11524 +annonces=> INSERT INTO test.archive SELECT id, description FROM +archive_ext; +INSERT 0 437351 + +annonces=> ANALYZE test.archive; +ANALYZE +annonces=> ANALYZE test.current; +ANALYZE + + This is the bookmarks table... + +SELECT count(*), list_id FROM bookmarks GROUP BY list_id; + count | list_id +-------+--------- + 15 | 7 + 5 | 5 + 150 | 4 + 3 | 3 + 15 | 2 + 2 | 1 + 6 | 8 + + I want to list the stuff I bookmarked : + + +annonces=> EXPLAIN ANALYZE SELECT * FROM test.current WHERE id IN (SELECT +annonce_id FROM bookmarks WHERE list_id IN ('4')); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=6.58..532.84 rows=140 width=203) (actual +time=0.747..5.283 rows=150 loops=1) + Hash Cond: ("outer".id = "inner".annonce_id) + -> Seq Scan on current (cost=0.00..467.24 rows=11524 width=203) +(actual time=0.006..3.191 rows=11524 loops=1) + -> Hash (cost=6.23..6.23 rows=140 width=4) (actual time=0.244..0.244 +rows=150 loops=1) + -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +time=0.155..0.184 rows=150 loops=1) + -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +width=4) (actual time=0.008..0.097 rows=150 loops=1) + Filter: (list_id = 4) + Total runtime: 5.343 ms +(8 lignes) + +annonces=> set enable_hashjoin TO 0; +SET +annonces=> EXPLAIN ANALYZE SELECT * FROM test.current WHERE id IN (SELECT +annonce_id FROM bookmarks WHERE list_id IN ('4')); + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=4.83..824.22 rows=140 width=203) (actual +time=0.219..1.034 rows=150 loops=1) + -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +time=0.158..0.199 rows=150 loops=1) + -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 width=4) +(actual time=0.011..0.096 rows=150 loops=1) + Filter: (list_id = 4) + -> Index Scan using current_pkey on current (cost=0.00..5.83 rows=1 +width=203) (actual time=0.005..0.005 rows=1 loops=150) + Index Cond: (current.id = "outer".annonce_id) + Total runtime: 1.108 ms +(7 lignes) + + Hm, the row estimates on the "bookmarks" table are spot on ; why did it +choose the hash join ? + + Now, if I want to access the "all" view which contains the union of the +"current" and "archive" table : + +annonces=> set enable_hashjoin TO 1; +SET +annonces=> EXPLAIN ANALYZE SELECT * FROM test.all WHERE id IN (SELECT +annonce_id FROM bookmarks WHERE list_id IN ('4')); + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=6.58..33484.41 rows=314397 width=36) (actual +time=8300.484..8311.784 rows=150 loops=1) + Hash Cond: ("outer"."?column1?" = "inner".annonce_id) + -> Append (cost=0.00..23596.78 rows=449139 width=219) (actual +time=6.390..8230.821 rows=448875 loops=1) + -> Seq Scan on archive (cost=0.00..18638.15 rows=437615 +width=219) (actual time=6.389..8175.491 rows=437351 loops=1) + -> Seq Scan on current (cost=0.00..467.24 rows=11524 width=203) +(actual time=0.022..8.985 rows=11524 loops=1) + -> Hash (cost=6.23..6.23 rows=140 width=4) (actual time=0.255..0.255 +rows=150 loops=1) + -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +time=0.168..0.197 rows=150 loops=1) + -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +width=4) (actual time=0.015..0.102 rows=150 loops=1) + Filter: (list_id = 4) + Total runtime: 8311.870 ms +(10 lignes) + +annonces=> set enable_hashjoin TO 0; +SET +annonces=> EXPLAIN ANALYZE SELECT * FROM test.all WHERE id IN (SELECT +annonce_id FROM bookmarks WHERE list_id IN ('4')); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------- + Merge Join (cost=79604.61..84994.98 rows=314397 width=36) (actual +time=6944.229..7109.371 rows=150 loops=1) + Merge Cond: ("outer".annonce_id = "inner".id) + -> Sort (cost=11.22..11.57 rows=140 width=4) (actual +time=0.326..0.355 rows=150 loops=1) + Sort Key: bookmarks.annonce_id + -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +time=0.187..0.218 rows=150 loops=1) + -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +width=4) (actual time=0.028..0.126 rows=150 loops=1) + Filter: (list_id = 4) + -> Sort (cost=79593.40..80716.25 rows=449139 width=36) (actual +time=6789.786..7014.815 rows=448625 loops=1) + Sort Key: "all".id + -> Append (cost=0.00..23596.78 rows=449139 width=219) (actual +time=0.013..391.447 rows=448875 loops=1) + -> Seq Scan on archive (cost=0.00..18638.15 rows=437615 +width=219) (actual time=0.013..332.353 rows=437351 loops=1) + -> Seq Scan on current (cost=0.00..467.24 rows=11524 +width=203) (actual time=0.013..8.396 rows=11524 loops=1) + Total runtime: 37226.846 ms + + The IN() is quite small (150 values), but the two large tables are +seq-scanned... is there a way to avoid this ? + + +------------------------------------------------------------------------------------------------------------------------------------- + + Another nitpick : let's redo the first query differently. + +annonces=> EXPLAIN ANALYZE SELECT * FROM test.current WHERE id IN (SELECT +annonce_id FROM bookmarks WHERE list_id IN ('4')); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=6.58..532.84 rows=140 width=203) (actual +time=0.794..5.791 rows=150 loops=1) + Hash Cond: ("outer".id = "inner".annonce_id) + -> Seq Scan on current (cost=0.00..467.24 rows=11524 width=203) +(actual time=0.003..3.554 rows=11524 loops=1) + -> Hash (cost=6.23..6.23 rows=140 width=4) (actual time=0.265..0.265 +rows=150 loops=1) + -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +time=0.179..0.210 rows=150 loops=1) + -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +width=4) (actual time=0.021..0.102 rows=150 loops=1) + Filter: (list_id = 4) + Total runtime: 5.853 ms + +annonces=> EXPLAIN ANALYZE SELECT a.* FROM test.current a, (SELECT +DISTINCT annonce_id FROM bookmarks WHERE list_id IN ('4')) AS b WHERE +a.id=b.annonce_id; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=12.37..538.63 rows=140 width=203) (actual +time=0.812..5.362 rows=150 loops=1) + Hash Cond: ("outer".id = "inner".annonce_id) + -> Seq Scan on current a (cost=0.00..467.24 rows=11524 width=203) +(actual time=0.005..3.227 rows=11524 loops=1) + -> Hash (cost=12.02..12.02 rows=140 width=4) (actual +time=0.296..0.296 rows=150 loops=1) + -> Unique (cost=9.87..10.62 rows=140 width=4) (actual +time=0.215..0.265 rows=150 loops=1) + -> Sort (cost=9.87..10.25 rows=150 width=4) (actual +time=0.215..0.226 rows=150 loops=1) + Sort Key: bookmarks.annonce_id + -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +width=4) (actual time=0.007..0.104 rows=150 loops=1) + Filter: (list_id = 4) + Total runtime: 5.429 ms + + Hm, it does Sort + Unique + Hash ; the Hash alone would have been better. + Replacing DISTINCT with GROUP BY removes the sort. + +annonces=> EXPLAIN ANALYZE SELECT a.* FROM test.current a, (SELECT +annonce_id FROM bookmarks WHERE list_id IN ('4') GROUP BY annonce_id) AS b +WHERE a.id=b.annonce_id; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=7.98..534.24 rows=140 width=203) (actual +time=0.811..5.557 rows=150 loops=1) + Hash Cond: ("outer".id = "inner".annonce_id) + -> Seq Scan on current a (cost=0.00..467.24 rows=11524 width=203) +(actual time=0.006..3.434 rows=11524 loops=1) + -> Hash (cost=7.63..7.63 rows=140 width=4) (actual time=0.242..0.242 +rows=150 loops=1) + -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +time=0.156..0.186 rows=150 loops=1) + -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +width=4) (actual time=0.008..0.097 rows=150 loops=1) + Filter: (list_id = 4) + Total runtime: 5.647 ms + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:03:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 766A211F6097 + for ; + Tue, 25 Apr 2006 15:03:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 62649-08 + for ; + Tue, 25 Apr 2006 15:03:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 3653911F6093 + for ; + Tue, 25 Apr 2006 15:03:15 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 88648296; Tue, 25 Apr 2006 11:03:14 -0700 +From: "Dave Dutcher" +To: "'Sriram Dandapani'" , + "'Pgsql-Performance \(E-mail\)'" +Subject: Re: planner not using index for like operator +Date: Tue, 25 Apr 2006 13:03:13 -0500 +Message-ID: <000001c66892$8583d040$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0001_01C66868.9CB03940" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF0406B241@ca-mail1.cis.local> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/558 +X-Sequence-Number: 18642 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0001_01C66868.9CB03940 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +If you are using a locale other than the C locale, you need to create +the index with an operator class to get index scans with like. + +See here for details: + +http://www.postgresql.org/docs/8.1/interactive/indexes-opclass.html + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Sriram +Dandapani +Sent: Tuesday, April 25, 2006 12:08 PM +To: Pgsql-Performance (E-mail) +Subject: [PERFORM] planner not using index for like operator + + + +For the query + + + + + +Select col1 from table1 + +Where col1 like '172.%' + + + +The table has 133 million unique ip addresses. Col1 is indexed. + + + +The optimizer is using a sequential scan + + + +This is the explain analyze output + + + +"Seq Scan on table1 (cost=0.00..2529284.80 rows=1 width=15) (actual +time=307591.339..565251.775 rows=524288 loops=1)" + +" Filter: ((col1)::text ~~ '172.%'::text)" + +"Total runtime: 565501.873 ms" + + + + + +The number of affected rows (500K) is a small fraction of the total row +count. + + +------=_NextPart_000_0001_01C66868.9CB03940 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + +Message + + + + + +
If you=20 +are using a locale other than the C locale, you need to create the index = +with an=20 +operator class to get index scans with like.
+
 
+
See=20 +here for details:
+
 
+
http://www.postgresql.org/docs/8.1/interactive/indexes-opclass.html
+
 
+
+
+
-----Original Message-----
From:=20 + pgsql-performance-owner@postgresql.org=20 + [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of = +Sriram=20 + Dandapani
Sent: Tuesday, April 25, 2006 12:08 = +PM
To:=20 + Pgsql-Performance (E-mail)
Subject: [PERFORM] planner not = +using=20 + index for like operator

+
+

For the=20 + query

+

 

+

 

+

Select col1 from=20 + table1

+

Where col1 like=20 + ‘172.%’

+

 

+

The table has 133 = +million unique=20 + ip addresses. Col1 is indexed.

+

 

+

The optimizer is using a = + + sequential scan

+

 

+

This is the explain = +analyze=20 + output

+

 

+

"Seq Scan on table1=20 + (cost=3D0.00..2529284.80 rows=3D1 width=3D15) (actual = +time=3D307591.339..565251.775=20 + rows=3D524288 loops=3D1)"

+

"  Filter: = +((col1)::text ~~=20 + '172.%'::text)"

+

"Total runtime: = +565501.873=20 + ms"

+

 

+

 

+

The number of affected = +rows (500K)=20 + is a small fraction of the total row=20 +count.

+ +------=_NextPart_000_0001_01C66868.9CB03940-- + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:14:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C83AD11F6557 + for ; + Tue, 25 Apr 2006 15:14:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 81381-07-3 + for ; + Tue, 25 Apr 2006 15:14:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx00.pub.collaborativefusion.com + (mx00.pub.collaborativefusion.com [206.210.89.199]) + by postgresql.org (Postfix) with ESMTP id 3331C11F6602 + for ; + Tue, 25 Apr 2006 15:14:35 -0300 (ADT) +Received: from vanquish.pgh.priv.collaborativefusion.com + (vanquish.pgh.priv.collaborativefusion.com [192.168.2.61]) + by wingspan with esmtp; Tue, 25 Apr 2006 14:14:35 -0400 + id 0005641D.444E670B.00000F3B +Date: Tue, 25 Apr 2006 14:14:35 -0400 +From: Bill Moran +To: pgsql-performance@postgresql.org +Subject: Large (8M) cache vs. dual-core CPUs +Message-Id: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +Organization: Collaborative Fusion +X-Mailer: Sylpheed version 2.2.0 (GTK+ 2.8.12; i386-portbld-freebsd6.0) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/559 +X-Sequence-Number: 18643 + + +I've been given the task of making some hardware recommendations for +the next round of server purchases. The machines to be purchased +will be running FreeBSD & PostgreSQL. + +Where I'm stuck is in deciding whether we want to go with dual-core +pentiums with 2M cache, or with HT pentiums with 8M cache. + +Both of these are expensive bits of hardware, and I'm trying to +gather as much evidence as possible before making a recommendation. +The FreeBSD community seems pretty divided over which is likely to +be better, and I have been unable to discover a method for estimating +how much of the 2M cache on our existing systems is being used. + +Does anyone in the PostgreSQL community have any experience with +large caches or dual-core pentiums that could make any recommendations? +Our current Dell 2850 systems are CPU bound - i.e. they have enough +RAM, and fast enough disks that the CPUs seem to be the limiting +factor. As a result, this decision on what kind of CPUs to get in +the next round of servers is pretty important. + +Any advice is much appreciated. + +-- +Bill Moran +Collaborative Fusion Inc. + +**************************************************************** +IMPORTANT: This message contains confidential information and is +intended only for the individual named. If the reader of this +message is not an intended recipient (or the individual +responsible for the delivery of this message to an intended +recipient), please be advised that any re-use, dissemination, +distribution or copying of this message is prohibited. Please +notify the sender immediately by e-mail if you have received +this e-mail by mistake and delete this e-mail from your system. +E-mail transmission cannot be guaranteed to be secure or +error-free as information could be intercepted, corrupted, lost, +destroyed, arrive late or incomplete, or contain viruses. The +sender therefore does not accept liability for any errors or +omissions in the contents of this message, which arise as a +result of e-mail transmission. +**************************************************************** + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:20:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D1C7911F6629 + for ; + Tue, 25 Apr 2006 15:20:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 79090-06 + for ; + Tue, 25 Apr 2006 15:20:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id E05BA11F660E + for ; + Tue, 25 Apr 2006 15:20:32 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3PIKTGp022919; + Tue, 25 Apr 2006 14:20:29 -0400 (EDT) +To: PFC +cc: pgsql-performance@postgresql.org +Subject: Re: Slow queries salad ;) +In-reply-to: +References: +Comments: In-reply-to PFC + message dated "Tue, 25 Apr 2006 19:53:15 +0200" +Date: Tue, 25 Apr 2006 14:20:29 -0400 +Message-ID: <22918.1145989229@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/560 +X-Sequence-Number: 18644 + +PFC writes: +> The IN() is quite small (150 values), but the two large tables are +> seq-scanned... is there a way to avoid this ? + +Not in 8.1. HEAD is a bit smarter about joins to Append relations. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:24:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 527F511F6602 + for ; + Tue, 25 Apr 2006 15:24:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 77420-08 + for ; + Tue, 25 Apr 2006 15:24:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B915511F6553 + for ; + Tue, 25 Apr 2006 15:24:45 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id C25E656423; Tue, 25 Apr 2006 13:24:45 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 25 Apr 2006 13:24:45 -0500 +Date: Tue, 25 Apr 2006 13:24:45 -0500 +From: "Jim C. Nasby" +To: Sriram Dandapani +Cc: "Pgsql-Performance (E-mail)" +Subject: Re: planner not using index for like operator +Message-ID: <20060425182444.GK97354@pervasive.com> +References: <6992E470F12A444BB787B5C937B9D4DF0406B241@ca-mail1.cis.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF0406B241@ca-mail1.cis.local> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060425:sdandapani@counterpane.com::e21kxcYqrLpZRt2b:00000000000 + 0000000000000000000000003+28 +X-Hashcash: + 1:20:060425:pgsql-performance@postgresql.org::BZGbhDtVoVwpSHit:00000 + 0000000000000000000000002wQJ +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/561 +X-Sequence-Number: 18645 + +On Tue, Apr 25, 2006 at 10:08:02AM -0700, Sriram Dandapani wrote: +Here's the key: + +> " Filter: ((col1)::text ~~ '172.%'::text)" + +In order to do a like comparison, it has to convert col1 (which I'm +guessing is of type 'inet') to text, so there's no way it can use an +index on col1 (maybe a function index, but that's a different story). + +Is there some reason you're not doing + +WHERE col1 <<= '172/8'::inet + +? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:31:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id DFFBE11F6093 + for ; + Tue, 25 Apr 2006 15:31:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 95785-08 + for ; + Tue, 25 Apr 2006 15:31:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id A298311F6083 + for ; + Tue, 25 Apr 2006 15:31:23 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Tue, 25 Apr 2006 18:31:20 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR2); + id 114598988048; Tue, 25 Apr 2006 11:31:20 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Tue, 25 Apr 2006 11:31:20 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Tue, 25 Apr 2006 11:31:20 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR2); + id 1145989874708; Tue, 25 Apr 2006 11:31:14 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: planner not using index for like operator +Date: Tue, 25 Apr 2006 11:31:12 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF0406B26C@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] planner not using index for like operator +Thread-Index: AcZolZbKULheaNcyTjCKnpDZL42giQAAIwNA +From: "Sriram Dandapani" +To: "Jim C. Nasby" +Cc: "Pgsql-Performance \(E-mail\)" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/562 +X-Sequence-Number: 18646 + +The col is a varchar. I am currently testing with the inet data type(and +also the ipv4 pgfoundry data type). + +Due to time constraints, I am trying to minimize code changes. + +What kind of index do I need to create to enable efficient range scans +(e.g anything between 172.16.x.x thru 172.31.x.x) on the inet data type? + +Thanks + +Sriram + +-----Original Message----- +From: Jim C. Nasby [mailto:jnasby@pervasive.com]=20 +Sent: Tuesday, April 25, 2006 11:25 AM +To: Sriram Dandapani +Cc: Pgsql-Performance (E-mail) +Subject: Re: [PERFORM] planner not using index for like operator + +On Tue, Apr 25, 2006 at 10:08:02AM -0700, Sriram Dandapani wrote: +Here's the key: + +> " Filter: ((col1)::text ~~ '172.%'::text)" + +In order to do a like comparison, it has to convert col1 (which I'm +guessing is of type 'inet') to text, so there's no way it can use an +index on col1 (maybe a function index, but that's a different story). + +Is there some reason you're not doing + +WHERE col1 <<=3D '172/8'::inet + +? +--=20 +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:33:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D4E1911F653D + for ; + Tue, 25 Apr 2006 15:33:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 90448-05 + for ; + Tue, 25 Apr 2006 15:33:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 9C2BA11F6093 + for ; + Tue, 25 Apr 2006 15:33:40 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 25 Apr 2006 18:33:38 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 25 Apr 2006 13:33:38 -0500 +Subject: Re: Large (8M) cache vs. dual-core CPUs +From: Scott Marlowe +To: Bill Moran +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1145990018.23538.234.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 25 Apr 2006 13:33:38 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/563 +X-Sequence-Number: 18647 + +On Tue, 2006-04-25 at 13:14, Bill Moran wrote: +> I've been given the task of making some hardware recommendations for +> the next round of server purchases. The machines to be purchased +> will be running FreeBSD & PostgreSQL. +> +> Where I'm stuck is in deciding whether we want to go with dual-core +> pentiums with 2M cache, or with HT pentiums with 8M cache. + +Given a choice between those two processors, I'd choose the AMD 64 x 2 +CPU. It's a significantly better processor than either of the Intel +choices. And if you get the HT processor, you might as well turn of HT +on a PostgreSQL machine. I've yet to see it make postgresql run faster, +but I've certainly seen HT make it run slower. + +If you can't run AMD in your shop due to bigotry (let's call a spade a +spade) then I'd recommend the real dual core CPU with 2M cache. Most of +what makes a database slow is memory and disk bandwidth. Few datasets +are gonna fit in that 8M cache, and when they do, they'll get flushed +right out by the next request anyway. + +> Does anyone in the PostgreSQL community have any experience with +> large caches or dual-core pentiums that could make any recommendations? +> Our current Dell 2850 systems are CPU bound - i.e. they have enough +> RAM, and fast enough disks that the CPUs seem to be the limiting +> factor. As a result, this decision on what kind of CPUs to get in +> the next round of servers is pretty important. + +If the CPUs are running at 100% then you're likely not memory I/O bound, +but processing speed bound. The dual core will definitely be the better +option in that case. I take it you work at a "Dell Only" place, hence +no AMD for you... + +Sad, cause the AMD is, on a price / performance scale, twice the +processor for the same money as the Intel. + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:35:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E1BE011F6661 + for ; + Tue, 25 Apr 2006 15:35:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 09682-05-2 + for ; + Tue, 25 Apr 2006 15:35:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fon.nation-net.com (fon.nation-net.com [194.24.251.1]) + by postgresql.org (Postfix) with ESMTP id 814BA11F6618 + for ; + Tue, 25 Apr 2006 15:35:01 -0300 (ADT) +Received: from fon.nation-net.com (localhost [127.0.0.1]) + by fon.nation-net.com (Postfix) with ESMTP id B802D1370D9 + for ; + Tue, 25 Apr 2006 19:35:00 +0100 (BST) +Received: from eddie.acentral.co.uk + (80-192-144-33.cable.ubr04.pres.blueyonder.co.uk [80.192.144.33]) + by fon.nation-net.com (Postfix) with ESMTP id 9DB4E136FD2 + for ; + Tue, 25 Apr 2006 19:35:00 +0100 (BST) +Received: from eddie.acentral.co.uk (eddie.acentral.co.uk [127.0.0.1]) + by eddie.acentral.co.uk (Postfix) with ESMTP id 0262475C7D + for ; + Tue, 25 Apr 2006 19:35:03 +0100 (BST) +Received: from localhost.localdomain (unknown [10.0.0.29]) + by eddie.acentral.co.uk (Postfix) with SMTP id D806A75A98 + for ; + Tue, 25 Apr 2006 19:35:02 +0100 (BST) +Date: Tue, 25 Apr 2006 19:35:01 +0100 +From: Gavin Hamill +To: pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-Id: <20060425193501.52b14860.gdh@laterooms.com> +In-Reply-To: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.17; i486-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: ClamAV using ClamSMTP +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/564 +X-Sequence-Number: 18648 + +On Tue, 25 Apr 2006 14:14:35 -0400 +Bill Moran wrote: + +> Does anyone in the PostgreSQL community have any experience with +> large caches or dual-core pentiums that could make any +> recommendations?=20 + +Heh :) You're in the position I was in about a year ago - we "naturally" +replaced our old Dell 2650 with =A314k of Dell 6850 Quad Xeon with 8M +cache, and TBH the performance is woeful :/ + +Having gone through Postgres consultancy, been through IBM 8-way POWER4 +hardware, discovered a bit of a shortcoming in PG on N-way hardware +(where N is large) [1] , I have been able to try out a dual-dual-core +Opteron machine, and it flies. + +In fact, it flies so well that we ordered one that day. So, in short +=A33k's worth of dual-opteron beat the living daylights out of our Xeon +monster. I can't praise the Opteron enough, and I've always been a firm +Intel pedant - the HyperTransport stuff must really be doing wonders. I +typically see 500ms searches on it instead of 1000-2000ms on the Xeon) + +As it stands, I've had to borrow this Opteron so much (and send live +searches across the net to the remote box) because otherwise we simply +don't have enough CPU power to run the website (!) + +Cheers, +Gavin. + +[1] Simon Riggs + Tom Lane are currently involved in optimisation work +for this - it turns out our extremely read-heavy load pattern reveals +some buffer locking issues in PG. + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:35:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 94EC811F653D + for ; + Tue, 25 Apr 2006 15:35:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 99730-06-2 + for ; + Tue, 25 Apr 2006 15:35:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B4E4A11F6640 + for ; + Tue, 25 Apr 2006 15:35:23 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 4314C56437; Tue, 25 Apr 2006 13:35:23 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 25 Apr 2006 13:35:23 -0500 +Date: Tue, 25 Apr 2006 13:35:22 -0500 +From: "Jim C. Nasby" +To: PFC +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow queries salad ;) +Message-ID: <20060425183522.GL97354@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060425:lists@peufeu.com::QYIDxFegFG7+U2nf:00QXf +X-Hashcash: + 1:20:060425:pgsql-performance@postgresql.org::Qe+NqVlJfhDbqYfj:00000 + 0000000000000000000000002JFT +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/565 +X-Sequence-Number: 18649 + +On Tue, Apr 25, 2006 at 07:53:15PM +0200, PFC wrote: +What version is this?? + +> annonces=> EXPLAIN ANALYZE SELECT * FROM test.current WHERE id IN (SELECT +> annonce_id FROM bookmarks WHERE list_id IN ('4')); +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------- +> Hash Join (cost=6.58..532.84 rows=140 width=203) (actual +> time=0.747..5.283 rows=150 loops=1) +> Hash Cond: ("outer".id = "inner".annonce_id) +> -> Seq Scan on current (cost=0.00..467.24 rows=11524 width=203) +> (actual time=0.006..3.191 rows=11524 loops=1) +> -> Hash (cost=6.23..6.23 rows=140 width=4) (actual time=0.244..0.244 +> rows=150 loops=1) +> -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +> time=0.155..0.184 rows=150 loops=1) +> -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +> width=4) (actual time=0.008..0.097 rows=150 loops=1) +> Filter: (list_id = 4) +> Total runtime: 5.343 ms +> (8 lignes) +> +> annonces=> set enable_hashjoin TO 0; +> SET +> annonces=> EXPLAIN ANALYZE SELECT * FROM test.current WHERE id IN (SELECT +> annonce_id FROM bookmarks WHERE list_id IN ('4')); +> QUERY PLAN +> -------------------------------------------------------------------------------------------------------------------------------- +> Nested Loop (cost=4.83..824.22 rows=140 width=203) (actual +> time=0.219..1.034 rows=150 loops=1) +> -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +> time=0.158..0.199 rows=150 loops=1) +> -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 width=4) +> (actual time=0.011..0.096 rows=150 loops=1) +> Filter: (list_id = 4) +> -> Index Scan using current_pkey on current (cost=0.00..5.83 rows=1 +> width=203) (actual time=0.005..0.005 rows=1 loops=150) +> Index Cond: (current.id = "outer".annonce_id) +> Total runtime: 1.108 ms +> (7 lignes) +> +> Hm, the row estimates on the "bookmarks" table are spot on ; why did +> it choose the hash join ? + +Because it thought it would be cheaper; see the estimates. Increasing +effective_cache_size or decreasing random_page_cost would favor the +index scan. + +> Now, if I want to access the "all" view which contains the union of +> the "current" and "archive" table : +> +> annonces=> set enable_hashjoin TO 1; +> SET +> annonces=> EXPLAIN ANALYZE SELECT * FROM test.all WHERE id IN (SELECT +> annonce_id FROM bookmarks WHERE list_id IN ('4')); +> QUERY PLAN +> -------------------------------------------------------------------------------------------------------------------------------- +> Hash Join (cost=6.58..33484.41 rows=314397 width=36) (actual +> time=8300.484..8311.784 rows=150 loops=1) +> Hash Cond: ("outer"."?column1?" = "inner".annonce_id) +> -> Append (cost=0.00..23596.78 rows=449139 width=219) (actual +> time=6.390..8230.821 rows=448875 loops=1) +> -> Seq Scan on archive (cost=0.00..18638.15 rows=437615 +> width=219) (actual time=6.389..8175.491 rows=437351 loops=1) +> -> Seq Scan on current (cost=0.00..467.24 rows=11524 width=203) +> (actual time=0.022..8.985 rows=11524 loops=1) +> -> Hash (cost=6.23..6.23 rows=140 width=4) (actual time=0.255..0.255 +> rows=150 loops=1) +> -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +> time=0.168..0.197 rows=150 loops=1) +> -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +> width=4) (actual time=0.015..0.102 rows=150 loops=1) +> Filter: (list_id = 4) +> Total runtime: 8311.870 ms +> (10 lignes) +> +> annonces=> set enable_hashjoin TO 0; +> SET +> annonces=> EXPLAIN ANALYZE SELECT * FROM test.all WHERE id IN (SELECT +> annonce_id FROM bookmarks WHERE list_id IN ('4')); +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------- +> Merge Join (cost=79604.61..84994.98 rows=314397 width=36) (actual +> time=6944.229..7109.371 rows=150 loops=1) +> Merge Cond: ("outer".annonce_id = "inner".id) +> -> Sort (cost=11.22..11.57 rows=140 width=4) (actual +> time=0.326..0.355 rows=150 loops=1) +> Sort Key: bookmarks.annonce_id +> -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +> time=0.187..0.218 rows=150 loops=1) +> -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +> width=4) (actual time=0.028..0.126 rows=150 loops=1) +> Filter: (list_id = 4) +> -> Sort (cost=79593.40..80716.25 rows=449139 width=36) (actual +> time=6789.786..7014.815 rows=448625 loops=1) +> Sort Key: "all".id +> -> Append (cost=0.00..23596.78 rows=449139 width=219) (actual +> time=0.013..391.447 rows=448875 loops=1) +> -> Seq Scan on archive (cost=0.00..18638.15 rows=437615 +> width=219) (actual time=0.013..332.353 rows=437351 loops=1) +> -> Seq Scan on current (cost=0.00..467.24 rows=11524 +> width=203) (actual time=0.013..8.396 rows=11524 loops=1) +> Total runtime: 37226.846 ms +> +> The IN() is quite small (150 values), but the two large tables are +> seq-scanned... is there a way to avoid this ? + +Possibly if you break the view apart... + +SELECT ... FROM current WHERE id IN (...) +UNION ALL +SELECT ... FROM archive WHERE id IN (...) + +> ------------------------------------------------------------------------------------------------------------------------------------- +> +> Another nitpick : let's redo the first query differently. +> +> annonces=> EXPLAIN ANALYZE SELECT * FROM test.current WHERE id IN (SELECT +> annonce_id FROM bookmarks WHERE list_id IN ('4')); +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------- +> Hash Join (cost=6.58..532.84 rows=140 width=203) (actual +> time=0.794..5.791 rows=150 loops=1) +> Hash Cond: ("outer".id = "inner".annonce_id) +> -> Seq Scan on current (cost=0.00..467.24 rows=11524 width=203) +> (actual time=0.003..3.554 rows=11524 loops=1) +> -> Hash (cost=6.23..6.23 rows=140 width=4) (actual time=0.265..0.265 +> rows=150 loops=1) +> -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +> time=0.179..0.210 rows=150 loops=1) +> -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +> width=4) (actual time=0.021..0.102 rows=150 loops=1) +> Filter: (list_id = 4) +> Total runtime: 5.853 ms +> +> annonces=> EXPLAIN ANALYZE SELECT a.* FROM test.current a, (SELECT +> DISTINCT annonce_id FROM bookmarks WHERE list_id IN ('4')) AS b WHERE +> a.id=b.annonce_id; +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------- +> Hash Join (cost=12.37..538.63 rows=140 width=203) (actual +> time=0.812..5.362 rows=150 loops=1) +> Hash Cond: ("outer".id = "inner".annonce_id) +> -> Seq Scan on current a (cost=0.00..467.24 rows=11524 width=203) +> (actual time=0.005..3.227 rows=11524 loops=1) +> -> Hash (cost=12.02..12.02 rows=140 width=4) (actual +> time=0.296..0.296 rows=150 loops=1) +> -> Unique (cost=9.87..10.62 rows=140 width=4) (actual +> time=0.215..0.265 rows=150 loops=1) +> -> Sort (cost=9.87..10.25 rows=150 width=4) (actual +> time=0.215..0.226 rows=150 loops=1) +> Sort Key: bookmarks.annonce_id +> -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +> width=4) (actual time=0.007..0.104 rows=150 loops=1) +> Filter: (list_id = 4) +> Total runtime: 5.429 ms +> +> Hm, it does Sort + Unique + Hash ; the Hash alone would have been +> better. + +The hash alone wouldn't have gotten you the same output as a DISTINCT, +though. + +> Replacing DISTINCT with GROUP BY removes the sort. +> +> annonces=> EXPLAIN ANALYZE SELECT a.* FROM test.current a, (SELECT +> annonce_id FROM bookmarks WHERE list_id IN ('4') GROUP BY annonce_id) AS b +> WHERE a.id=b.annonce_id; +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------- +> Hash Join (cost=7.98..534.24 rows=140 width=203) (actual +> time=0.811..5.557 rows=150 loops=1) +> Hash Cond: ("outer".id = "inner".annonce_id) +> -> Seq Scan on current a (cost=0.00..467.24 rows=11524 width=203) +> (actual time=0.006..3.434 rows=11524 loops=1) +> -> Hash (cost=7.63..7.63 rows=140 width=4) (actual time=0.242..0.242 +> rows=150 loops=1) +> -> HashAggregate (cost=4.83..6.23 rows=140 width=4) (actual +> time=0.156..0.186 rows=150 loops=1) +> -> Seq Scan on bookmarks (cost=0.00..4.45 rows=150 +> width=4) (actual time=0.008..0.097 rows=150 loops=1) +> Filter: (list_id = 4) +> Total runtime: 5.647 ms + +Uhm.. that actually runs slower... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:37:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B2A3B11F6093 + for ; + Tue, 25 Apr 2006 15:37:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 60415-10 + for ; + Tue, 25 Apr 2006 15:36:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 4328D11F6602 + for ; + Tue, 25 Apr 2006 15:36:57 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 25 Apr 2006 18:36:56 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 25 Apr 2006 13:36:56 -0500 +Subject: Re: Large (8M) cache vs. dual-core CPUs +From: Scott Marlowe +To: Bill Moran +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1145990216.23538.238.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 25 Apr 2006 13:36:56 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/566 +X-Sequence-Number: 18650 + +On Tue, 2006-04-25 at 13:14, Bill Moran wrote: +> I've been given the task of making some hardware recommendations for +> the next round of server purchases. The machines to be purchased +> will be running FreeBSD & PostgreSQL. +> +> Where I'm stuck is in deciding whether we want to go with dual-core +> pentiums with 2M cache, or with HT pentiums with 8M cache. + +BTW: For an interesting article on why the dual core Opterons are so +much better than their Intel cousins, read this article: + +http://techreport.com/reviews/2005q2/opteron-x75/index.x?pg=1 + +Enlightening read. + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:37:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 08D3811F6083 + for ; + Tue, 25 Apr 2006 15:37:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 11476-02 + for ; + Tue, 25 Apr 2006 15:37:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.envysolutions.com (mark.mielke.cc [206.248.142.186]) + by postgresql.org (Postfix) with ESMTP id 183AB11F6648 + for ; + Tue, 25 Apr 2006 15:37:33 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envysolutions.com (Postfix) with ESMTP id 5C0831B69C; + Tue, 25 Apr 2006 14:38:17 -0400 (EDT) +Received: from mail.envysolutions.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 08904-08; Tue, 25 Apr 2006 14:38:17 -0400 (EDT) +Received: by mail.envysolutions.com (Postfix, from userid 500) + id 455FD1B6A2; Tue, 25 Apr 2006 14:38:17 -0400 (EDT) +Date: Tue, 25 Apr 2006 14:38:17 -0400 +From: mark@mark.mielke.cc +To: Scott Marlowe +Cc: Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060425183817.GA9241@mark.mielke.cc> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1145990018.23538.234.camel@state.g2switchworks.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envysolutions.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/567 +X-Sequence-Number: 18651 + +On Tue, Apr 25, 2006 at 01:33:38PM -0500, Scott Marlowe wrote: +> Sad, cause the AMD is, on a price / performance scale, twice the +> processor for the same money as the Intel. + +Maybe a year or two ago. Prices are all coming down. Intel more +than AMD. + +AMD still seems better - but not X2, and it depends on the workload. + +X2 sounds like biggotry against Intel... :-) + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:42:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3084311F610C + for ; + Tue, 25 Apr 2006 15:42:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10761-07 + for ; + Tue, 25 Apr 2006 15:42:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 74DA511F6109 + for ; + Tue, 25 Apr 2006 15:42:32 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 25 Apr 2006 18:42:31 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 25 Apr 2006 13:42:31 -0500 +Subject: Re: Large (8M) cache vs. dual-core CPUs +From: Scott Marlowe +To: mark@mark.mielke.cc +Cc: Bill Moran , + pgsql-performance@postgresql.org +In-Reply-To: <20060425183817.GA9241@mark.mielke.cc> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1145990551.23538.244.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 25 Apr 2006 13:42:31 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/568 +X-Sequence-Number: 18652 + +On Tue, 2006-04-25 at 13:38, mark@mark.mielke.cc wrote: +> On Tue, Apr 25, 2006 at 01:33:38PM -0500, Scott Marlowe wrote: +> > Sad, cause the AMD is, on a price / performance scale, twice the +> > processor for the same money as the Intel. +> +> Maybe a year or two ago. Prices are all coming down. Intel more +> than AMD. +> +> AMD still seems better - but not X2, and it depends on the workload. +> +> X2 sounds like biggotry against Intel... :-) + +Actually, that was from an article from this last month that compared +the dual core intel to the amd. for every dollar spent on the intel, +you got about half the performance of the amd. Not bigotry. fact. + +But don't believe me or the other people who've seen the difference. Go +buy the Intel box. No skin off my back. + + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:49:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 65E9511F6280 + for ; + Tue, 25 Apr 2006 15:49:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 11157-03 + for ; + Tue, 25 Apr 2006 15:49:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id 4402111F6109 + for ; + Tue, 25 Apr 2006 15:49:44 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k3PIneQS001087; Tue, 25 Apr 2006 11:49:40 -0700 +Message-ID: <444E6F41.8000102@commandprompt.com> +Date: Tue, 25 Apr 2006 11:49:37 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Bill Moran +CC: pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +In-Reply-To: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Tue, 25 Apr 2006 11:49:41 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/569 +X-Sequence-Number: 18653 + +Bill Moran wrote: +> I've been given the task of making some hardware recommendations for +> the next round of server purchases. The machines to be purchased +> will be running FreeBSD & PostgreSQL. +> +> Where I'm stuck is in deciding whether we want to go with dual-core +> pentiums with 2M cache, or with HT pentiums with 8M cache. + +Dual Core Opterons :) + +Joshua D. Drake + +> +> Both of these are expensive bits of hardware, and I'm trying to +> gather as much evidence as possible before making a recommendation. +> The FreeBSD community seems pretty divided over which is likely to +> be better, and I have been unable to discover a method for estimating +> how much of the 2M cache on our existing systems is being used. +> +> Does anyone in the PostgreSQL community have any experience with +> large caches or dual-core pentiums that could make any recommendations? +> Our current Dell 2850 systems are CPU bound - i.e. they have enough +> RAM, and fast enough disks that the CPUs seem to be the limiting +> factor. As a result, this decision on what kind of CPUs to get in +> the next round of servers is pretty important. +> +> Any advice is much appreciated. +> + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 15:52:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9340A11F610C + for ; + Tue, 25 Apr 2006 15:52:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 08455-09 + for ; + Tue, 25 Apr 2006 15:52:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from natasha.counterpane.com (natasha.hq.counterpane.com + [208.162.171.162]) + by postgresql.org (Postfix) with SMTP id A7B8111F6284 + for ; + Tue, 25 Apr 2006 15:52:26 -0300 (ADT) +Received: from kraken.hq.counterpane.com ([172.16.2.55]) by + natasha.counterpane.com; Tue, 25 Apr 2006 18:52:25 +0000 (UTC) +Received: From bluefish.counterpane.com ([172.16.2.51]) by kraken.cis.local + (WebShield SMTP v4.5 MR2); + id 1145991144918; Tue, 25 Apr 2006 11:52:24 -0700 +Received: from achilles.cis.local ([172.16.2.26]) + by bluefish.counterpane.com (PGP Universal service); + Tue, 25 Apr 2006 11:52:24 -0700 +X-PGP-Universal: processed; + by bluefish.counterpane.com on Tue, 25 Apr 2006 11:52:24 -0700 +Received: From ca-mail1.cis.local ([172.16.2.54]) by achilles.cis.local + (WebShield SMTP v4.5 MR2); + id 1145991139941; Tue, 25 Apr 2006 11:52:19 -0700 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: planner not using index for like operator +Date: Tue, 25 Apr 2006 11:52:19 -0700 +Message-ID: <6992E470F12A444BB787B5C937B9D4DF0406B27D@ca-mail1.cis.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] planner not using index for like operator +Thread-Index: AcZolZbKULheaNcyTjCKnpDZL42giQAA4Uvw +From: "Sriram Dandapani" +To: "Jim C. Nasby" +Cc: "Pgsql-Performance \(E-mail\)" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/570 +X-Sequence-Number: 18654 + +Using an index on col1 with the operator class varchar_pattern_ops , I +was able to get a 3 second response time. That will work for me. +I used a like '172.%' and an extra pattern matching condition to +restrict +Between 172.16.x.x and 172.31.x.x + +Thanks for the input..I will also test the inet data type to see if +there are differences. + +Sriram + +-----Original Message----- +From: Jim C. Nasby [mailto:jnasby@pervasive.com]=20 +Sent: Tuesday, April 25, 2006 11:25 AM +To: Sriram Dandapani +Cc: Pgsql-Performance (E-mail) +Subject: Re: [PERFORM] planner not using index for like operator + +On Tue, Apr 25, 2006 at 10:08:02AM -0700, Sriram Dandapani wrote: +Here's the key: + +> " Filter: ((col1)::text ~~ '172.%'::text)" + +In order to do a like comparison, it has to convert col1 (which I'm +guessing is of type 'inet') to text, so there's no way it can use an +index on col1 (maybe a function index, but that's a different story). + +Is there some reason you're not doing + +WHERE col1 <<=3D '172/8'::inet + +? +--=20 +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 25 16:12:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4C89211F6284 + for ; + Tue, 25 Apr 2006 16:12:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 13919-05 + for ; + Tue, 25 Apr 2006 16:12:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id 275B811F6285 + for ; + Tue, 25 Apr 2006 16:12:29 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k3PJCNNQ001604; Tue, 25 Apr 2006 12:12:23 -0700 +Message-ID: <444E7494.1040900@commandprompt.com> +Date: Tue, 25 Apr 2006 12:12:20 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Scott Marlowe +CC: mark@mark.mielke.cc, Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> +In-Reply-To: <1145990551.23538.244.camel@state.g2switchworks.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Tue, 25 Apr 2006 12:12:24 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/571 +X-Sequence-Number: 18655 + + +> But don't believe me or the other people who've seen the difference. Go +> buy the Intel box. No skin off my back. + +To be more detailed... AMD Opteron has some specific technical +advantages to their design over Intel when it comes to peforming for a +database. Specifically no front side bus :) + +Also it is widely known and documented (just review the archives) that +AMD performs better then the equivelant Intel CPU, dollar for dollar. + +Lastly it is also known that Dell frankly, sucks for PostgreSQL. Again, +check the archives. + +Joshua D. Drake + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 16:22:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5D82111F6109 + for ; + Tue, 25 Apr 2006 16:22:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 11892-10 + for ; + Tue, 25 Apr 2006 16:22:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 2078B11F6081 + for ; + Tue, 25 Apr 2006 16:22:24 -0300 (ADT) +Received: from mail.enyo.de (mail.enyo.de [212.9.189.167]) + by svr4.postgresql.org (Postfix) with ESMTP id C9EDE5B3163 + for ; + Tue, 25 Apr 2006 19:22:24 +0000 (GMT) +Received: from deneb.vpn.enyo.de ([212.9.189.177] helo=deneb.enyo.de) + by mail.enyo.de with esmtp id 1FYT74-0006i7-9D; + Tue, 25 Apr 2006 21:22:18 +0200 +Received: from fw by deneb.enyo.de with local (Exim 4.61) + (envelope-from ) + id 1FYT72-0002va-Tg; Tue, 25 Apr 2006 21:22:16 +0200 +From: Florian Weimer +To: "Sriram Dandapani" +Cc: "Pgsql-Performance (E-mail)" +Subject: Re: ip address data type +References: <6992E470F12A444BB787B5C937B9D4DF0406B11B@ca-mail1.cis.local> +Date: Tue, 25 Apr 2006 21:22:16 +0200 +In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF0406B11B@ca-mail1.cis.local> + (Sriram Dandapani's message of "Mon, 24 Apr 2006 15:45:14 -0700") +Message-ID: <87d5f54g0n.fsf@mid.deneb.enyo.de> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/572 +X-Sequence-Number: 18656 + +* Sriram Dandapani: + +> Does the inet data type offer comparison/search performance benefits +> over plain text for ip addresses.. + +Queries like "host << '192.168.17.192/28'" use an available index on +the host column. In theory, you could do this with LIKE and strings, +but this gets pretty messy and needs a lot of client-side logic. + +From pgsql-performance-owner@postgresql.org Tue Apr 25 17:16:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0CEDF11F620A + for ; + Tue, 25 Apr 2006 17:16:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 23971-09 + for ; + Tue, 25 Apr 2006 17:16:14 -0300 (ADT) +X-Greylist: delayed 00:17:32.710647 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 4BAA311F61C9 + for ; + Tue, 25 Apr 2006 17:16:04 -0300 (ADT) +Received: from skunk.mtbrook.bozemanpass.com (unknown [69.145.82.195]) + by svr4.postgresql.org (Postfix) with ESMTP id 34BA65B31ED + for ; + Tue, 25 Apr 2006 19:58:31 +0000 (GMT) +Received: from [69.145.82.218] (unknown [69.145.82.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by skunk.mtbrook.bozemanpass.com (Postfix) with ESMTP id 301935584C6 + for ; + Tue, 25 Apr 2006 12:58:29 -0700 (PDT) +Message-ID: <444E7F47.3010003@boreham.org> +Date: Tue, 25 Apr 2006 13:57:59 -0600 +From: David Boreham +Reply-To: david_list@boreham.org +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> +In-Reply-To: <1145990551.23538.244.camel@state.g2switchworks.com> +Content-Type: multipart/alternative; + boundary="------------020801060700020202050706" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/573 +X-Sequence-Number: 18657 + +This is a multi-part message in MIME format. +--------------020801060700020202050706 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + + +>Actually, that was from an article from this last month that compared +>the dual core intel to the amd. for every dollar spent on the intel, +>you got about half the performance of the amd. Not bigotry. fact. +> +>But don't believe me or the other people who've seen the difference. Go +>buy the Intel box. No skin off my back. +> +> +I've been doing plenty of performance evaluation on a parallel application +we're developing here : on Dual Core Opterons, P4, P4D. I can say that +the Opterons open up a can of wupass on the Intel processors. Almost 2x +the performance on our application vs. what the SpecCPU numbers would +suggest. + + + +--------------020801060700020202050706 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + + +
+
+
Actually, that was from an article from this last month that compared
+the dual core intel to the amd.  for every dollar spent on the intel,
+you got about half the performance of the amd.  Not bigotry.  fact.
+
+But don't believe me or the other people who've seen the difference.  Go
+buy the Intel box.  No skin off my back.
+  
+
+I've been doing plenty of performance evaluation on a parallel +application
+we're developing here : on Dual Core Opterons, P4, P4D. I can say that
+the Opterons open up a can of wupass on the Intel processors. Almost 2x
+the performance on our application vs. what the SpecCPU numbers would
+suggest.
+
+
+ + + +--------------020801060700020202050706-- + +From pgsql-performance-owner@postgresql.org Tue Apr 25 18:00:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C484611F610C + for ; + Tue, 25 Apr 2006 18:00:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 34150-02 + for ; + Tue, 25 Apr 2006 18:00:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id 471D011F61E8 + for ; + Tue, 25 Apr 2006 18:00:16 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k3PL0BEo003843; Tue, 25 Apr 2006 14:00:12 -0700 +Message-ID: <444E8DD8.3040504@commandprompt.com> +Date: Tue, 25 Apr 2006 14:00:08 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: david_list@boreham.org +CC: pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> + <444E7F47.3010003@boreham.org> +In-Reply-To: <444E7F47.3010003@boreham.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Tue, 25 Apr 2006 14:00:12 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/574 +X-Sequence-Number: 18658 + +David Boreham wrote: +> +>> Actually, that was from an article from this last month that compared +>> the dual core intel to the amd. for every dollar spent on the intel, +>> you got about half the performance of the amd. Not bigotry. fact. +>> +>> But don't believe me or the other people who've seen the difference. Go +>> buy the Intel box. No skin off my back. +>> +> I've been doing plenty of performance evaluation on a parallel application +> we're developing here : on Dual Core Opterons, P4, P4D. I can say that +> the Opterons open up a can of wupass on the Intel processors. Almost 2x +> the performance on our application vs. what the SpecCPU numbers would +> suggest. + +Because Stone Cold Said So! + +> +> + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 18:04:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9AF9311F610C + for ; + Tue, 25 Apr 2006 18:04:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 30703-10 + for ; + Tue, 25 Apr 2006 18:03:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 9659011F61C2 + for ; + Tue, 25 Apr 2006 18:03:55 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k3PL3nM03949; + Tue, 25 Apr 2006 17:03:49 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200604252103.k3PL3nM03949@candle.pha.pa.us> +Subject: Re: Large (8M) cache vs. dual-core CPUs +In-Reply-To: <444E8DD8.3040504@commandprompt.com> +To: "Joshua D. Drake" +Date: Tue, 25 Apr 2006 17:03:49 -0400 (EDT) +CC: david_list@boreham.org, pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/575 +X-Sequence-Number: 18659 + +Joshua D. Drake wrote: +> David Boreham wrote: +> > +> >> Actually, that was from an article from this last month that compared +> >> the dual core intel to the amd. for every dollar spent on the intel, +> >> you got about half the performance of the amd. Not bigotry. fact. +> >> +> >> But don't believe me or the other people who've seen the difference. Go +> >> buy the Intel box. No skin off my back. +> >> +> > I've been doing plenty of performance evaluation on a parallel application +> > we're developing here : on Dual Core Opterons, P4, P4D. I can say that +> > the Opterons open up a can of wupass on the Intel processors. Almost 2x +> > the performance on our application vs. what the SpecCPU numbers would +> > suggest. +> +> Because Stone Cold Said So! + +I'll believe someone who uses 'wupass' in a sentence any day! + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 18:10:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0524111F6B1D + for ; + Tue, 25 Apr 2006 18:10:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 36504-01 + for ; + Tue, 25 Apr 2006 18:09:56 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 12FF411F61C2 + for ; + Tue, 25 Apr 2006 18:09:55 -0300 (ADT) +Received: from smtpauth04.mail.atl.earthlink.net + (smtpauth04.mail.atl.earthlink.net [209.86.89.64]) + by svr4.postgresql.org (Postfix) with ESMTP id 7B73C5B16EF + for ; + Tue, 25 Apr 2006 21:09:55 +0000 (GMT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=nykrEzkC4+dgfY1erryZuFGXXB4gePQhyKd9wkd7TtgROyI7Ty1MV+OXyezdRiFm; + h=Message-ID:Date:From:Reply-To:To:Subject:Mime-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:X-ELNK-Trace:X-Originating-IP; +Received: from [209.86.224.41] (helo=elwamui-mouette.atl.sa.earthlink.net) + by smtpauth04.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FYUnB-00021s-9S; Tue, 25 Apr 2006 17:09:53 -0400 +Received: from 70.22.235.105 by webmail.pas.earthlink.net with HTTP; + Tue, 25 Apr 2006 17:09:53 -0400 +Message-ID: + <26953267.1145999393194.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +Date: Tue, 25 Apr 2006 17:09:53 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: EarthLink Zoo Mail 1.0 +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc477c7904e7ec0ec88d2bab7b7fac9cf4350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 209.86.224.41 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/576 +X-Sequence-Number: 18660 + +As others have noted, the current price/performance "sweet spot" for DB servers is 2S 2C AMD CPUs. These CPUs are also the highest performing x86 compatible solution for pg. + +If you must go Intel for some reason, then wait until the new NGMA CPU's (Conroe, Merom, Woodcrest) come out and see how they bench on DB workloads. Preliminary benches on these chips look good, but I would not recommend making a purchase decision based on just preliminary benches of unreleased products. + +If you must buy soon, then the decision is clear cut from anything except possinly a political/religious standpoint. +The NetBurst based Pentium and Xeon solutions are simply not worth the money spent or the PITA they will put you through compared to the AMD dual cores. The new Intel NGMA CPUs may be different, but all the pertinent evidence is not yet available. + +My personal favorite pg platform at this time is one based on a 2 socket, dual core ready mainboard with 16 DIMM slots combined with dual core AMD Kx's. + +Less money than the "comparable" Intel solution and _far_ more performance. + +...and even if you do buy Intel, =DON"T= buy Dell unless you like causing trouble for yourself. +Bad experiences with Dell in general and their poor PERC RAID controllers in specific are all over this and other DB forums. + +Ron + + +-----Original Message----- +>From: Bill Moran +>Sent: Apr 25, 2006 2:14 PM +>To: pgsql-performance@postgresql.org +>Subject: [PERFORM] Large (8M) cache vs. dual-core CPUs +> +> +>I've been given the task of making some hardware recommendations for +>the next round of server purchases. The machines to be purchased +>will be running FreeBSD & PostgreSQL. +> +>Where I'm stuck is in deciding whether we want to go with dual-core +>pentiums with 2M cache, or with HT pentiums with 8M cache. +> +>Both of these are expensive bits of hardware, and I'm trying to +>gather as much evidence as possible before making a recommendation. +>The FreeBSD community seems pretty divided over which is likely to +>be better, and I have been unable to discover a method for estimating +>how much of the 2M cache on our existing systems is being used. +> +>Does anyone in the PostgreSQL community have any experience with +>large caches or dual-core pentiums that could make any recommendations? +>Our current Dell 2850 systems are CPU bound - i.e. they have enough +>RAM, and fast enough disks that the CPUs seem to be the limiting +>factor. As a result, this decision on what kind of CPUs to get in +>the next round of servers is pretty important. +> +>Any advice is much appreciated. +> + +From pgsql-performance-owner@postgresql.org Tue Apr 25 18:16:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3535A11F6089 + for ; + Tue, 25 Apr 2006 18:16:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26389-07 + for ; + Tue, 25 Apr 2006 18:15:50 -0300 (ADT) +X-Greylist: delayed 01:17:16.306004 by SQLgrey- +Received: from skunk.mtbrook.bozemanpass.com (unknown [69.145.82.195]) + by postgresql.org (Postfix) with ESMTP id 4A70D11F6083 + for ; + Tue, 25 Apr 2006 18:15:47 -0300 (ADT) +Received: from [69.145.82.218] (unknown [69.145.82.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by skunk.mtbrook.bozemanpass.com (Postfix) with ESMTP id 5AC155584C6 + for ; + Tue, 25 Apr 2006 14:15:47 -0700 (PDT) +Message-ID: <444E915A.4060609@boreham.org> +Date: Tue, 25 Apr 2006 15:15:06 -0600 +From: David Boreham +Reply-To: david_list@boreham.org +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: + <26953267.1145999393194.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +In-Reply-To: + <26953267.1145999393194.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/577 +X-Sequence-Number: 18661 + + +>My personal favorite pg platform at this time is one based on a 2 socket, dual core ready mainboard with 16 DIMM slots combined with dual core AMD Kx's. +> +> +Right. We've been buying Tyan bare-bones boxes like this. +It's better to go with bare-bones than building boxes from bare metal +because the cooling issues are addressed correctly. + +Note that if you need a large number of machines, then Intel +Core Duo may give the best overall price/performance because +they're cheaper to run and cool. + + + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 18:41:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A494111F6095 + for ; + Tue, 25 Apr 2006 18:41:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38453-10 + for ; + Tue, 25 Apr 2006 18:41:05 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.177]) + by postgresql.org (Postfix) with ESMTP id DD9E711F6089 + for ; + Tue, 25 Apr 2006 18:41:03 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so1484266pye + for ; + Tue, 25 Apr 2006 14:41:04 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type; + b=neQcjUZaU0HWUgs4n+tMjUKhIeDGv6O02e1Sr8dBWZermlXg7O5ES+R2Ugurpdx1cZJSwhZrYPDci3n1pRR+WibiomXRLarSKzGtsW7+QH8C4Y/rAt5Ivpe1nsmGnp/kahg7lyGsEhBHaSNfMY9ViaW8BOlmPE7QjuS321e6zeM= +Received: by 10.35.40.10 with SMTP id s10mr187587pyj; + Tue, 25 Apr 2006 14:41:03 -0700 (PDT) +Received: by 10.35.82.19 with HTTP; Tue, 25 Apr 2006 14:41:03 -0700 (PDT) +Message-ID: <8d04ce990604251441ya85c42evb47946272536cabe@mail.gmail.com> +Date: Tue, 25 Apr 2006 14:41:03 -0700 +From: "Junaili Lie" +To: pgsql-performance@postgresql.org +Subject: slow deletes on pgsql 7.4 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_6825_1133211.1146001263938" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/578 +X-Sequence-Number: 18662 + +------=_Part_6825_1133211.1146001263938 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi all, +we encounter issues when deleting from a table based on id (primary key). O= +n +certain 'id', it took forever to delete and the i/o is 100% busy. +Table scenario has around 1400 entries. It is the parent of 3 other table. + Table "public.scenario" + Column | Type | Modifiers +-----------------+-----------------------+---------------------------------= +--------------- + id | bigint | not null default +nextval('scenario_seq'::text) + name | character varying(50) | + description | text | + subscriber_id | bigint | + organization_id | bigint | + schedule_id | bigint | +Indexes: + "scenario_pkey" primary key, btree (id) + "org_ind_scenario_index" btree (organization_id) + "sch_ind_scenario_index" btree (schedule_id) + "sub_ind_scenario_index" btree (subscriber_id) +Check constraints: + "$3" CHECK (schedule_id >=3D 0) + "$2" CHECK (organization_id >=3D 0) + "$1" CHECK (subscriber_id >=3D 0) +Foreign-key constraints: + "0_4774" FOREIGN KEY (schedule_id) REFERENCES schedule(id) ON DELETE +CASCADE + "0_4773" FOREIGN KEY (organization_id) REFERENCES organization(id) ON +DELETE CASCADE + "0_4772" FOREIGN KEY (subscriber_id) REFERENCES subscriber(id) ON DELET= +E +CASCADE + +In all the child tables, the foreign key has the same data type and are +indexed. +When I do "delete from scenario where id=3D'1023', it takes less than 200 m= +s. +But when i do "delete from scenario where id=3D'1099', it took forever (mor= +e +than 10 minutes that i decided to cancel it. +I can't do explain analyze, but here is the explain: +MONSOON=3D# begin; +BEGIN +MONSOON=3D# explain delete from scenario where id=3D'1099'; + QUERY PLAN +---------------------------------------------------------------------------= +--- + Index Scan using scenario_pkey on scenario (cost=3D0.00..3.14 rows=3D1 +width=3D6) + Index Cond: (id =3D 1099::bigint) +(2 rows) + +MONSOON=3D# explain delete from scenario where id=3D'1023'; + QUERY PLAN +---------------------------------------------------------------------------= +--- + Index Scan using scenario_pkey on scenario (cost=3D0.00..3.14 rows=3D1 +width=3D6) + Index Cond: (id =3D 1023::bigint) +(2 rows) + +MONSOON=3D# explain analyze delete from scenario where id=3D'1023'; + QUERY PLAN +---------------------------------------------------------------------------= +--------------------------------------------- + Index Scan using scenario_pkey on scenario (cost=3D0.00..3.14 rows=3D1 +width=3D6) (actual time=3D0.028..0.030 rows=3D1 loops=3D1) + Index Cond: (id =3D 1023::bigint) + Total runtime: 0.174 ms +(3 rows) + +I have also tried increasing statistics on both parent and child tables to +100, vacuum analyze parent and all child tables. But still the same +slowness. +The o/s is Solaris 10, with fsync =3D true. +Any ideas what's going on? +Thanks in advance, + +J + +------=_Part_6825_1133211.1146001263938 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi all,
+we encounter issues when deleting from a table based on id (primary +key). On certain 'id', it took forever to delete and the i/o is 100% +busy.
+Table scenario has around 1400 entries. It is the parent of 3 other table.<= +br> +            &nb= +sp;            = +        +Table "public.scenario"
+     Column      +|         +Type          +|            &n= +bsp;      +Modifiers
+-----------------+-----------------------+---------------------------------= +---------------
+ id           &= +nbsp;  +| +bigint           &nb= +sp;    +| not null default nextval('scenario_seq'::text)
+ name           = +; | character varying(50) |
+ description     | +text            = +;      +|
+ subscriber_id   | +bigint           &nb= +sp;    +|
+ organization_id | bigint       &nb= +sp;        |
+ schedule_id     | +bigint           &nb= +sp;    +|
+Indexes:
+    "scenario_pkey" primary key, btree (id)
+    "org_ind_scenario_index" btree (organization_i= +d)
+    "sch_ind_scenario_index" btree (schedule_id) +    "sub_ind_scenario_index" btree (subscriber_id)= +
+Check constraints:
+    "$3" CHECK (schedule_id >=3D 0)
+    "$2" CHECK (organization_id >=3D 0)
+    "$1" CHECK (subscriber_id >=3D 0)
+Foreign-key constraints:
+    "0_4774" FOREIGN KEY (schedule_id) REFERENCES = +schedule(id) ON DELETE CASCADE
+    "0_4773" FOREIGN KEY (organization_id) REFEREN= +CES organization(id) ON DELETE CASCADE
+    "0_4772" FOREIGN KEY (subscriber_id) REFERENCE= +S subscriber(id) ON DELETE CASCADE
+
+In all the child tables, the foreign key has the same data type and are ind= +exed.
+When I do "delete from scenario where id=3D'1023', it takes less than = +200 ms.
+But when i do "delete from scenario where id=3D'1099', it took forever= + (more than 10 minutes that i decided to cancel it.
+I can't do explain analyze, but here is the explain:
+MONSOON=3D# begin;
+BEGIN
+MONSOON=3D# explain delete from scenario where id=3D'1099';
+            &nb= +sp;            = +         +QUERY PLAN
+---------------------------------------------------------------------------= +---
+ Index Scan using scenario_pkey on scenario  (cost=3D0.00..3.14 r= +ows=3D1 width=3D6)
+   Index Cond: (id =3D 1099::bigint)
+(2 rows)
+
+MONSOON=3D# explain delete from scenario where id=3D'1023';
+            &nb= +sp;            = +         +QUERY PLAN
+---------------------------------------------------------------------------= +---
+ Index Scan using scenario_pkey on scenario  (cost=3D0.00..3.14 r= +ows=3D1 width=3D6)
+   Index Cond: (id =3D 1023::bigint)
+(2 rows)
+
+MONSOON=3D# explain analyze delete from scenario where id=3D'1023';
+            &nb= +sp;            = +            &nb= +sp;            = +     +QUERY PLAN
+---------------------------------------------------------------------------= +---------------------------------------------
+ Index Scan using scenario_pkey on scenario  (cost=3D0.00..3.14 +rows=3D1 width=3D6) (actual time=3D0.028..0.030 rows=3D1 loops=3D1)
+   Index Cond: (id =3D 1023::bigint)
+ Total runtime: 0.174 ms
+(3 rows)
+
+I have also tried increasing statistics on both parent and child tables +to 100, vacuum analyze parent and all child tables. But still the same +slowness.
+The o/s is Solaris 10, with fsync =3D true.
+Any ideas what's going on?
+Thanks in advance,
+
+J
+ +------=_Part_6825_1133211.1146001263938-- + +From pgsql-performance-owner@postgresql.org Tue Apr 25 18:43:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8009D11F60AE + for ; + Tue, 25 Apr 2006 18:43:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40991-05 + for ; + Tue, 25 Apr 2006 18:43:17 -0300 (ADT) +X-Greylist: delayed 00:33:21.061468 by SQLgrey- +Received: from smtpauth04.mail.atl.earthlink.net + (smtpauth04.mail.atl.earthlink.net [209.86.89.64]) + by postgresql.org (Postfix) with ESMTP id CF2C011F6095 + for ; + Tue, 25 Apr 2006 18:43:14 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=rXGIRL6VGQAAK8eiwkoN7zSRgF6Blxnk1/DONpykqY7qH8mkGf95IIxR4Pw7iCal; + h=Message-ID:Date:From:Reply-To:To:Subject:Mime-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:X-ELNK-Trace:X-Originating-IP; +Received: from [209.86.224.41] (helo=elwamui-mouette.atl.sa.earthlink.net) + by smtpauth04.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FYVJS-00048u-Ty; Tue, 25 Apr 2006 17:43:14 -0400 +Received: from 70.22.235.105 by webmail.pas.earthlink.net with HTTP; + Tue, 25 Apr 2006 17:43:14 -0400 +Message-ID: + <26758313.1146001394944.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +Date: Tue, 25 Apr 2006 17:43:14 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: david_list@boreham.org, pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: EarthLink Zoo Mail 1.0 +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bcfdb6555dbcacabc698a35d9a5b709ae5350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 209.86.224.41 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/579 +X-Sequence-Number: 18663 + +I've had intermittent "freeze and reboot" and, worse, just plain freeze problems with the Core Duo's I've been testing. I have not been able to narrow it down so I do not know if it is a platform issue or a CPU issue. It appears to be HW, not SW, related since I have experienced the problem both under M$ and Linux 2.6 based OS's. I have not tested the Core Duo's under *BSD. + +Also, being that they are only 32b Core Duo's have limited utility for a present day DB server. + +Power and space critical applications where 64b is not required may be a reasonable place for them... ...if the +present reliability problems I'm seeing go away. + +Ron + + +-----Original Message----- +>From: David Boreham +>Sent: Apr 25, 2006 5:15 PM +>To: pgsql-performance@postgresql.org +>Subject: Re: [PERFORM] Large (8M) cache vs. dual-core CPUs +> +> +>>My personal favorite pg platform at this time is one based on a 2 socket, dual core ready mainboard with 16 DIMM slots combined with dual core AMD Kx's. +>> +>> +>Right. We've been buying Tyan bare-bones boxes like this. +>It's better to go with bare-bones than building boxes from bare metal +>because the cooling issues are addressed correctly. +> +>Note that if you need a large number of machines, then Intel +>Core Duo may give the best overall price/performance because +>they're cheaper to run and cool. +> + +From pgsql-performance-owner@postgresql.org Tue Apr 25 18:46:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0140C11F6097 + for ; + Tue, 25 Apr 2006 18:46:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43212-03 + for ; + Tue, 25 Apr 2006 18:46:32 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.176]) + by postgresql.org (Postfix) with ESMTP id 39FC411F6083 + for ; + Tue, 25 Apr 2006 18:46:30 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so1485515pye + for ; + Tue, 25 Apr 2006 14:46:31 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; + b=IDLqzv6zdukADO9QpqDSopz236W9+grLbRhFvj00bEmFw1JKaP1cKU9FTcXwNX7fohqgUYUFb5Oh2aQX2S2jMHtPDytOWOarDiZ+m0rvyokpOgytNtu8h+AJ5uNdO4BgqrqEfot2bOF4+Az2UbgxkyM9tAJygYnftg6wW+xji8A= +Received: by 10.35.50.9 with SMTP id c9mr49812pyk; + Tue, 25 Apr 2006 14:46:31 -0700 (PDT) +Received: by 10.35.82.19 with HTTP; Tue, 25 Apr 2006 14:46:30 -0700 (PDT) +Message-ID: <8d04ce990604251446l967aaa5j5909e7f19ddecd6d@mail.gmail.com> +Date: Tue, 25 Apr 2006 14:46:30 -0700 +From: "Junaili Lie" +To: pgsql-performance@postgresql.org +Subject: Re: slow deletes on pgsql 7.4 +In-Reply-To: <8d04ce990604251441ya85c42evb47946272536cabe@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_6949_31381341.1146001590961" +References: <8d04ce990604251441ya85c42evb47946272536cabe@mail.gmail.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/580 +X-Sequence-Number: 18664 + +------=_Part_6949_31381341.1146001590961 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I should also mention that select ... for update is fast: +MONSOON=3D# begin;explain analyze select * from SCENARIO WHERE id =3D '1099= +' FOR +UPDATE; +BEGIN + QUERY PLAN +---------------------------------------------------------------------------= +---------------------------------------------- + Index Scan using scenario_pkey on scenario (cost=3D0.00..3.17 rows=3D1 +width=3D64) (actual time=3D0.016..0.017 rows=3D1 loops=3D1) + Index Cond: (id =3D 1099::bigint) + Total runtime: 0.072 ms +(3 rows) + + + + +On 4/25/06, Junaili Lie wrote: +> +> Hi all, +> we encounter issues when deleting from a table based on id (primary key). +> On certain 'id', it took forever to delete and the i/o is 100% busy. +> Table scenario has around 1400 entries. It is the parent of 3 other table= +. +> Table "public.scenario" +> Column | Type | Modifiers +> +> -----------------+-----------------------+-------------------------------= +----------------- +> id | bigint | not null default +> nextval('scenario_seq'::text) +> name | character varying(50) | +> description | text | +> subscriber_id | bigint | +> organization_id | bigint | +> schedule_id | bigint | +> Indexes: +> "scenario_pkey" primary key, btree (id) +> "org_ind_scenario_index" btree (organization_id) +> "sch_ind_scenario_index" btree (schedule_id) +> "sub_ind_scenario_index" btree (subscriber_id) +> Check constraints: +> "$3" CHECK (schedule_id >=3D 0) +> "$2" CHECK (organization_id >=3D 0) +> "$1" CHECK (subscriber_id >=3D 0) +> Foreign-key constraints: +> "0_4774" FOREIGN KEY (schedule_id) REFERENCES schedule(id) ON DELETE +> CASCADE +> "0_4773" FOREIGN KEY (organization_id) REFERENCES organization(id) ON +> DELETE CASCADE +> "0_4772" FOREIGN KEY (subscriber_id) REFERENCES subscriber(id) ON +> DELETE CASCADE +> +> In all the child tables, the foreign key has the same data type and are +> indexed. +> When I do "delete from scenario where id=3D'1023', it takes less than 200 +> ms. +> But when i do "delete from scenario where id=3D'1099', it took forever (m= +ore +> than 10 minutes that i decided to cancel it. +> I can't do explain analyze, but here is the explain: +> MONSOON=3D# begin; +> BEGIN +> MONSOON=3D# explain delete from scenario where id=3D'1099'; +> QUERY PLAN +> +> -------------------------------------------------------------------------= +----- +> Index Scan using scenario_pkey on scenario (cost=3D0.00..3.14 rows=3D1 +> width=3D6) +> Index Cond: (id =3D 1099::bigint) +> (2 rows) +> +> MONSOON=3D# explain delete from scenario where id=3D'1023'; +> QUERY PLAN +> +> -------------------------------------------------------------------------= +----- +> Index Scan using scenario_pkey on scenario (cost=3D0.00..3.14 rows=3D1 +> width=3D6) +> Index Cond: (id =3D 1023::bigint) +> (2 rows) +> +> MONSOON=3D# explain analyze delete from scenario where id=3D'1023'; +> QUERY PLAN +> +> -------------------------------------------------------------------------= +----------------------------------------------- +> Index Scan using scenario_pkey on scenario (cost=3D0.00..3.14 rows=3D1 +> width=3D6) (actual time=3D0.028..0.030 rows=3D1 loops=3D1) +> Index Cond: (id =3D 1023::bigint) +> Total runtime: 0.174 ms +> (3 rows) +> +> I have also tried increasing statistics on both parent and child tables t= +o +> 100, vacuum analyze parent and all child tables. But still the same +> slowness. +> The o/s is Solaris 10, with fsync =3D true. +> Any ideas what's going on? +> Thanks in advance, +> +> J +> + +------=_Part_6949_31381341.1146001590961 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +I should also mention that select ... for update is fast:
+MONSOON=3D# begin;explain analyze select * from SCENARIO WHERE id =3D '1099= +' FOR UPDATE;
+BEGIN
+            &nb= +sp;            = +            &nb= +sp;            = +     +QUERY PLAN
+---------------------------------------------------------------------------= +----------------------------------------------
+ Index Scan using scenario_pkey on scenario  (cost=3D0.00..3.17 +rows=3D1 width=3D64) (actual time=3D0.016..0.017 rows=3D1 loops=3D1)
+   Index Cond: (id =3D 1099::bigint)
+ Total runtime: 0.072 ms
+(3 rows)
+
+
+

On 4/25/06, Junaili Lie <junaili@gm= +ail.com> wrote:
+
Hi all,
+we encounter issues when deleting from a table based on id (primary +key). On certain 'id', it took forever to delete and the i/o is 100% +busy.
+Table scenario has around 1400 entries. It is the parent of 3 other table.<= +br>            = +            &nb= +sp;        +Table "public.scenario"
+     Column      +|         +Type          +|            &n= +bsp;      +Modifiers
+-----------------+-----------------------+---------------------------------= +---------------
+ id           &= +nbsp;  +| +bigint           &nb= +sp;    +| not null default nextval('scenario_seq'::text)
+ name           = +; | character varying(50) |
+ description     | +text            = +;      +|
+ subscriber_id   | +bigint           &nb= +sp;    +|
+ organization_id | bigint       &nb= +sp;        |
+ schedule_id     | +bigint           &nb= +sp;    +|
+Indexes:
+    "scenario_pkey" primary key, btree (id)
+    "org_ind_scenario_index" btree (organization_i= +d)
+    "sch_ind_scenario_index" btree (schedule_id) +    "sub_ind_scenario_index" btree (subscriber_id)= +
+Check constraints:
+    "$3" CHECK (schedule_id >=3D 0)
+    "$2" CHECK (organization_id >=3D 0)
+    "$1" CHECK (subscriber_id >=3D 0)
+Foreign-key constraints:
+    "0_4774" FOREIGN KEY (schedule_id) REFERENCES = +schedule(id) ON DELETE CASCADE
+    "0_4773" FOREIGN KEY (organization_id) REFEREN= +CES organization(id) ON DELETE CASCADE
+    "0_4772" FOREIGN KEY (subscriber_id) REFERENCE= +S subscriber(id) ON DELETE CASCADE
+
+In all the child tables, the foreign key has the same data type and are ind= +exed.
+When I do "delete from scenario where id=3D'1023', it takes less than = +200 ms.
+But when i do "delete from scenario where id=3D'1099', it took forever= + (more than 10 minutes that i decided to cancel it.
+I can't do explain analyze, but here is the explain:
+MONSOON=3D# begin;
+BEGIN
+MONSOON=3D# explain delete from scenario where id=3D'1099';
+            &nb= +sp;            = +         +QUERY PLAN
+---------------------------------------------------------------------------= +---
+ Index Scan using scenario_pkey on scenario  (cost=3D0.00..3.14 r= +ows=3D1 width=3D6)
+   Index Cond: (id =3D 1099::bigint)
+(2 rows)
+
+MONSOON=3D# explain delete from scenario where id=3D'1023';
+            &nb= +sp;            = +         +QUERY PLAN
+---------------------------------------------------------------------------= +---
+ Index Scan using scenario_pkey on scenario  (cost=3D0.00..3.14 r= +ows=3D1 width=3D6)
+   Index Cond: (id =3D 1023::bigint)
+(2 rows)
+
+MONSOON=3D# explain analyze delete from scenario where id=3D'1023';
+            &nb= +sp;            = +            &nb= +sp;            = +     +QUERY PLAN
+---------------------------------------------------------------------------= +---------------------------------------------
+ Index Scan using scenario_pkey on scenario  (cost=3D0.00..3.14 +rows=3D1 width=3D6) (actual time=3D0.028..0.030 rows=3D1 loops=3D1)
+   Index Cond: (id =3D 1023::bigint)
+ Total runtime: 0.174 ms
+(3 rows)
+
+I have also tried increasing statistics on both parent and child tables +to 100, vacuum analyze parent and all child tables. But still the same +slowness.
+The o/s is Solaris 10, with fsync =3D true.
+Any ideas what's going on?
+Thanks in advance,
+
+J
+ +

+ +------=_Part_6949_31381341.1146001590961-- + +From pgsql-performance-owner@postgresql.org Tue Apr 25 19:03:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 685DF11F6081 + for ; + Tue, 25 Apr 2006 19:03:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 44203-05 + for ; + Tue, 25 Apr 2006 19:03:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id 7556611F6093 + for ; + Tue, 25 Apr 2006 19:03:42 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k3PM3d4m005000; Tue, 25 Apr 2006 15:03:39 -0700 +Message-ID: <444E9CB7.6050604@commandprompt.com> +Date: Tue, 25 Apr 2006 15:03:35 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Ron Peacetree +CC: Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: + <26953267.1145999393194.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +In-Reply-To: + <26953267.1145999393194.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Tue, 25 Apr 2006 15:03:40 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/581 +X-Sequence-Number: 18665 + +Ron Peacetree wrote: +> As others have noted, the current price/performance "sweet spot" for DB servers is 2S 2C AMD CPUs. These CPUs are also the highest performing x86 compatible solution for pg. +> +> If you must go Intel for some reason, then wait until the new NGMA CPU's (Conroe, Merom, Woodcrest) come out and see how they bench on DB workloads. Preliminary benches on these chips look good, but I would not recommend making a purchase decision based on just preliminary benches of unreleased products. +> +> If you must buy soon, then the decision is clear cut from anything except possinly a political/religious standpoint. +> The NetBurst based Pentium and Xeon solutions are simply not worth the money spent or the PITA they will put you through compared to the AMD dual cores. The new Intel NGMA CPUs may be different, but all the pertinent evidence is not yet available. +> +> My personal favorite pg platform at this time is one based on a 2 socket, dual core ready mainboard with 16 DIMM slots combined with dual core AMD Kx's. +> +> Less money than the "comparable" Intel solution and _far_ more performance. +> +> ...and even if you do buy Intel, =DON"T= buy Dell unless you like causing trouble for yourself. +> Bad experiences with Dell in general and their poor PERC RAID controllers in specific are all over this and other DB forums. +> +> Ron +> + +To add to this... the HP DL 385 is a pretty nice dual core capable +opteron box. Just don't buy the extra ram from HP (they like to charge +entirely too much). + +Joshua D. Drake + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 20:09:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 05D6811F6280 + for ; + Tue, 25 Apr 2006 20:09:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50169-10 + for ; + Tue, 25 Apr 2006 20:09:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 91B1311F6282 + for ; + Tue, 25 Apr 2006 20:09:20 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3PN9I7q009148; + Tue, 25 Apr 2006 19:09:18 -0400 (EDT) +To: "Junaili Lie" +cc: pgsql-performance@postgresql.org +Subject: Re: slow deletes on pgsql 7.4 +In-reply-to: <8d04ce990604251441ya85c42evb47946272536cabe@mail.gmail.com> +References: <8d04ce990604251441ya85c42evb47946272536cabe@mail.gmail.com> +Comments: In-reply-to "Junaili Lie" + message dated "Tue, 25 Apr 2006 14:41:03 -0700" +Date: Tue, 25 Apr 2006 19:09:18 -0400 +Message-ID: <9147.1146006558@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/582 +X-Sequence-Number: 18666 + +"Junaili Lie" writes: +> we encounter issues when deleting from a table based on id (primary key). O= +> n +> certain 'id', it took forever to delete and the i/o is 100% busy. + +Almost always, if delete is slow when selecting the same rows is fast, +it's because you've got a trigger performance problem --- most commonly, +there are foreign keys referencing this table from other tables and you +don't have the referencing columns indexed. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 25 20:55:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1B70111F6083 + for ; + Tue, 25 Apr 2006 20:55:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 56088-05 + for ; + Tue, 25 Apr 2006 20:55:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id E467711F6081 + for ; + Tue, 25 Apr 2006 20:55:05 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id AE86256427; Tue, 25 Apr 2006 18:55:05 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 25 Apr 2006 18:55:04 -0500 +Date: Tue, 25 Apr 2006 18:55:04 -0500 +From: "Jim C. Nasby" +To: Scott Marlowe +Cc: Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060425235504.GO97354@pervasive.com> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1145990018.23538.234.camel@state.g2switchworks.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060425:smarlowe@g2switchworks.com::lHKgrcDqKAtWgcHF:00000000000 + 0000000000000000000000007eGO +X-Hashcash: + 1:20:060425:wmoran@collaborativefusion.com::cVDout8rwVfl7mjK:0000000 + 00000000000000000000000006ok +X-Hashcash: + 1:20:060425:pgsql-performance@postgresql.org::kjAQMwZLckbJa44j:00000 + 0000000000000000000000002Mr6 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/583 +X-Sequence-Number: 18667 + +On Tue, Apr 25, 2006 at 01:33:38PM -0500, Scott Marlowe wrote: +> On Tue, 2006-04-25 at 13:14, Bill Moran wrote: +> > I've been given the task of making some hardware recommendations for +> > the next round of server purchases. The machines to be purchased +> > will be running FreeBSD & PostgreSQL. +> > +> > Where I'm stuck is in deciding whether we want to go with dual-core +> > pentiums with 2M cache, or with HT pentiums with 8M cache. +> +> Given a choice between those two processors, I'd choose the AMD 64 x 2 +> CPU. It's a significantly better processor than either of the Intel +> choices. And if you get the HT processor, you might as well turn of HT +> on a PostgreSQL machine. I've yet to see it make postgresql run faster, +> but I've certainly seen HT make it run slower. + +Actually, believe it or not, a coworker just saw HT double the +performance of pgbench on his desktop machine. Granted, not really a +representative test case, but it still blew my mind. This was with a +database that fit in his 1G of memory, and running windows XP. Both +cases were newly minted pgbench databases with a scale of 40. Testing +was 40 connections and 100 transactions. With HT he saw 47.6 TPS, +without it was 21.1. + +I actually had IT build put w2k3 server on a HT box specifically so I +could do more testing. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue Apr 25 21:03:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8722D11F6026 + for ; + Tue, 25 Apr 2006 21:03:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 63760-04 + for ; + Tue, 25 Apr 2006 21:02:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 39E9D11F6081 + for ; + Tue, 25 Apr 2006 21:02:48 -0300 (ADT) +Received: from mx.sat.rackspace.com (mx.sat.rackspace.com [64.39.1.214]) + by svr4.postgresql.org (Postfix) with ESMTP id 22B765B33F6 + for ; + Wed, 26 Apr 2006 00:02:48 +0000 (GMT) +Received: from mail.rackspace.com (mail.rackspace.com [64.39.2.181]) + by mx.sat.rackspace.com (8.13.6/8.13.6) with ESMTP id k3Q02jpK007079 + for ; Tue, 25 Apr 2006 19:02:45 -0500 + (envelope-from wreese@rackspace.com) +Received: from [10.6.104.60] (office104-60.sat4.rackspace.com [10.6.104.60]) + (authenticated bits=0) + by mail.rackspace.com (8.13.1/8.13.1) with ESMTP id k3Q02ibn022998 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) + for ; Tue, 25 Apr 2006 19:02:44 -0500 +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <20018.1145849559@sss.pgh.pa.us> +References: <22780344-3C6A-474E-8101-60B8806DA152@rackspace.com> + <20018.1145849559@sss.pgh.pa.us> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <65B945E0-2F69-42F2-B594-74A680B25A3A@rackspace.com> +Content-Transfer-Encoding: 7bit +From: Will Reese +Subject: Re: Slow deletes in 8.1 when FKs are involved +Date: Tue, 25 Apr 2006 19:02:37 -0500 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.749.3) +X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CP_URI_IN_BODY 0, + __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, + __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, + __SANE_MSGID 0' +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/584 +X-Sequence-Number: 18668 + +I did double check for indexes on the referenced and referencing +columns, and even though this database is restored and vacuum +analyzed nightly the issue remains. Using explain analyze in +postgresql 8.1, I was able to see where the problem lies. For +performance reasons on our 7.4 server, we removed one of the 3 RI +triggers for some constraints (the RI trigger that performs the +SELECT....FOR UPDATE to prevent modifications) and replaced it with a +trigger to just prevent deletes on this data indefinitely (the data +never gets deleted or updated in our app). This works great in +postgresql 7.4 and nearly eliminated our performance issue, but when +that database is restored to postgresql 8.1 one of the remaining two +RI triggers does not perform well at all when you try to delete from +that table (even though it's fine in postgresql 7.4). On the 8.1 +server I dropped the remaining two RI triggers, and added the +constraint to recreate the 3 RI triggers. After that the delete +performed fine. So it looks like the 7.4 RI triggers that carried +over to the 8.1 server don't perform very well. I'm hoping that the +SELECT...FOR SHARE functionality in 8.1 will allow us to re-add our +constraints and not suffer from the locking issues we had in +postgresql 7.4. + +Will Reese -- http://blog.rezra.com + +On Apr 23, 2006, at 10:32 PM, Tom Lane wrote: + +> Will Reese writes: +>> ... Both servers have identical postgresql.conf settings and were +>> restored from the same 7.4 backup. Almost everything is faster on the +>> 8.1 server (mostly due to hardware), except one thing...deletes from +>> tables with many foreign keys pointing to them. +> +> I think it's unquestionable that you have a bad FK plan in use on the +> 8.1 server. Double check that you have suitable indexes on the +> referencing (not referenced) columns, that you've ANALYZEd all the +> tables involved, and that you've started a fresh psql session +> (remember +> the backend tends to cache FK plans for the life of the connection). +> +> It might help to EXPLAIN ANALYZE one of the slow deletes --- 8.1 will +> break out the time spent in FK triggers, which would let you see which +> one(s) are the culprit. +> +> regards, tom lane + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 21:15:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4925B11F6081 + for ; + Tue, 25 Apr 2006 21:15:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 62091-04 + for ; + Tue, 25 Apr 2006 21:14:57 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.181]) + by postgresql.org (Postfix) with ESMTP id B904011F6026 + for ; + Tue, 25 Apr 2006 21:14:55 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so1513275pye + for ; + Tue, 25 Apr 2006 17:14:56 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=eseQMjxnGvdT4lG1lrRIFxXIU7PE3OXA30nbXWD5lQw0DgNqr7Ill9G7LGdUhGx7y4YP0qP/S0vdUa8DokV8AL54FBkN3ooRkLIC0aU/PnxoScCrPgcbBKFcsDbWw9WCAU2TQjOyitPO3BuHOFse+9rQc7WeIezlq5maALZrrOU= +Received: by 10.35.22.17 with SMTP id z17mr311983pyi; + Tue, 25 Apr 2006 17:14:56 -0700 (PDT) +Received: by 10.35.82.19 with HTTP; Tue, 25 Apr 2006 17:14:56 -0700 (PDT) +Message-ID: <8d04ce990604251714g1f5d99bbn172ec554a49c8374@mail.gmail.com> +Date: Tue, 25 Apr 2006 17:14:56 -0700 +From: "Junaili Lie" +To: "Tom Lane" +Subject: Re: slow deletes on pgsql 7.4 +Cc: pgsql-performance@postgresql.org +In-Reply-To: <9147.1146006558@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_9449_16353100.1146010496029" +References: <8d04ce990604251441ya85c42evb47946272536cabe@mail.gmail.com> + <9147.1146006558@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/585 +X-Sequence-Number: 18669 + +------=_Part_9449_16353100.1146010496029 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +hi, +Thanks for the answer. +I have double checked that all the foreign key that are referencing "id" on +scenario are indexed. +I have even vacuum analyze scenario table and all the tables that reference= +d +this table. +Something that is interesting is that: it only happens for a certain values= +. + +ie. delete from scenario where id=3D'1023' is very fast, but delete from +scenario where id=3D'1099' is running forever. + +Any ideas? + +J + + + + +On 4/25/06, Tom Lane wrote: +> +> "Junaili Lie" writes: +> > we encounter issues when deleting from a table based on id (primary +> key). O=3D +> > n +> > certain 'id', it took forever to delete and the i/o is 100% busy. +> +> Almost always, if delete is slow when selecting the same rows is fast, +> it's because you've got a trigger performance problem --- most commonly, +> there are foreign keys referencing this table from other tables and you +> don't have the referencing columns indexed. +> +> regards, tom lane +> + +------=_Part_9449_16353100.1146010496029 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +hi,
+Thanks for the answer.
+I have double checked that all the foreign key that are referencing "i= +d" on scenario are indexed.
+I have even vacuum analyze scenario table and all the tables that reference= +d this table.
+Something that is interesting is that: it only happens for a certain values= +.
+ie. delete from scenario where id=3D'1023' is very fast, but delete from sc= +enario where id=3D'1099' is running forever.
+
+Any ideas?
+
+J
+
+
+

On 4/25/06, Tom Lane <tgl@sss.pgh.p= +a.us> wrote:
+"Junaili Lie" <junaili@gm= +ail.com> writes:
> we encounter issues when deleting from a ta= +ble based on id (primary key). O=3D
> n
> certain 'id', it took= + forever to delete and the i/o is 100% busy. +

Almost always, if delete is slow when selecting the same rows is fa= +st,
it's because you've got a trigger performance problem --- most commo= +nly,
there are foreign keys referencing this table from other tables and= + you +
don't have the referencing columns indexed.

   &n= +bsp;            = +;        regards, +tom lane

+ +------=_Part_9449_16353100.1146010496029-- + +From pgsql-performance-owner@postgresql.org Tue Apr 25 21:54:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BE74A11F6213 + for ; + Tue, 25 Apr 2006 21:54:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 68207-08 + for ; + Tue, 25 Apr 2006 21:53:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.envysolutions.com (mark.mielke.cc [206.248.142.186]) + by postgresql.org (Postfix) with ESMTP id D472D11F6081 + for ; + Tue, 25 Apr 2006 21:53:55 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envysolutions.com (Postfix) with ESMTP id A72131B69C; + Tue, 25 Apr 2006 20:54:40 -0400 (EDT) +Received: from mail.envysolutions.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 12423-08; Tue, 25 Apr 2006 20:54:40 -0400 (EDT) +Received: by mail.envysolutions.com (Postfix, from userid 500) + id 8768B1B6A2; Tue, 25 Apr 2006 20:54:40 -0400 (EDT) +Date: Tue, 25 Apr 2006 20:54:40 -0400 +From: mark@mark.mielke.cc +To: Scott Marlowe +Cc: Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060426005440.GA12711@mark.mielke.cc> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1145990551.23538.244.camel@state.g2switchworks.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envysolutions.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/586 +X-Sequence-Number: 18670 + +On Tue, Apr 25, 2006 at 01:42:31PM -0500, Scott Marlowe wrote: +> On Tue, 2006-04-25 at 13:38, mark@mark.mielke.cc wrote: +> > On Tue, Apr 25, 2006 at 01:33:38PM -0500, Scott Marlowe wrote: +> > > Sad, cause the AMD is, on a price / performance scale, twice the +> > > processor for the same money as the Intel. +> > Maybe a year or two ago. Prices are all coming down. Intel more +> > than AMD. +> > AMD still seems better - but not X2, and it depends on the workload. +> > X2 sounds like biggotry against Intel... :-) +> Actually, that was from an article from this last month that compared +> the dual core intel to the amd. for every dollar spent on the intel, +> you got about half the performance of the amd. Not bigotry. fact. +> But don't believe me or the other people who've seen the difference. Go +> buy the Intel box. No skin off my back. + +AMD Opteron vs Intel Xeon is different than AMD X2 vs Pentium D. + +For AMD X2 vs Pentium D - I have both - in similar price range, and +similar speed. I choose to use the AMD X2 as my server, and Pentium D +as my Windows desktop. They're both quite fast. + +I made the choice I describe based on a lot of research. I was going +to go both Intel, until I noticed that the Intel prices were dropping +fast. 30% price cut in 2 months. AMD didn't drop at all during the +same time. + +There are plenty of reasons to choose one over the other. Generally +the AMD comes out on top. It is *not* 2X though. Anybody who claims +this is being highly selective about which benchmarks they consider. + +One article is nothing. + +There is a lot of hype these days. AMD is winning the elite market, +which means that they are able to continue to sell high. Intel, losing +this market, is cutting its prices to compete. And they do compete. +Quite well. + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 22:04:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 217B411F653D + for ; + Tue, 25 Apr 2006 22:04:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 68986-09 + for ; + Tue, 25 Apr 2006 22:04:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 749B611F6213 + for ; + Tue, 25 Apr 2006 22:04:37 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3Q14Yuq010986; + Tue, 25 Apr 2006 21:04:34 -0400 (EDT) +To: "Junaili Lie" +cc: pgsql-performance@postgresql.org +Subject: Re: slow deletes on pgsql 7.4 +In-reply-to: <8d04ce990604251714g1f5d99bbn172ec554a49c8374@mail.gmail.com> +References: <8d04ce990604251441ya85c42evb47946272536cabe@mail.gmail.com> + <9147.1146006558@sss.pgh.pa.us> + <8d04ce990604251714g1f5d99bbn172ec554a49c8374@mail.gmail.com> +Comments: In-reply-to "Junaili Lie" + message dated "Tue, 25 Apr 2006 17:14:56 -0700" +Date: Tue, 25 Apr 2006 21:04:34 -0400 +Message-ID: <10985.1146013474@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/587 +X-Sequence-Number: 18671 + +"Junaili Lie" writes: +> ie. delete from scenario where id=3D'1023' is very fast, but delete from +> scenario where id=3D'1099' is running forever. + +What does EXPLAIN show for each of those cases? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 25 22:16:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 74F6F11F6640 + for ; + Tue, 25 Apr 2006 22:16:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 76586-02 + for ; + Tue, 25 Apr 2006 22:16:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.envysolutions.com (mark.mielke.cc [206.248.142.186]) + by postgresql.org (Postfix) with ESMTP id 4569E11F6618 + for ; + Tue, 25 Apr 2006 22:16:14 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envysolutions.com (Postfix) with ESMTP id ED0EE1B69C; + Tue, 25 Apr 2006 21:17:01 -0400 (EDT) +Received: from mail.envysolutions.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 12930-03; Tue, 25 Apr 2006 21:17:01 -0400 (EDT) +Received: by mail.envysolutions.com (Postfix, from userid 500) + id D0BF51B6A2; Tue, 25 Apr 2006 21:17:01 -0400 (EDT) +Date: Tue, 25 Apr 2006 21:17:01 -0400 +From: mark@mark.mielke.cc +To: Scott Marlowe +Cc: Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060426011701.GB12711@mark.mielke.cc> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> + <20060426005440.GA12711@mark.mielke.cc> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060426005440.GA12711@mark.mielke.cc> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envysolutions.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/588 +X-Sequence-Number: 18672 + +On Tue, Apr 25, 2006 at 08:54:40PM -0400, mark@mark.mielke.cc wrote: +> I made the choice I describe based on a lot of research. I was going +> to go both Intel, until I noticed that the Intel prices were dropping +> fast. 30% price cut in 2 months. AMD didn't drop at all during the +> same time. + +Errr.. big mistake. That was going to be - I was going to go both AMD. + +> There are plenty of reasons to choose one over the other. Generally +> the AMD comes out on top. It is *not* 2X though. Anybody who claims +> this is being highly selective about which benchmarks they consider. + +I have an Intel Pentium D 920, and an AMD X2 3800+. These are very +close in performance. The retail price difference is: + + Intel Pentium D 920 is selling for $310 CDN + AMD X2 3800+ is selling for $347 CDN + +Another benefit of Pentium D over AMD X2, at least until AMD chooses +to switch, is that Pentium D supports DDR2, whereas AMD only supports +DDR. There are a lot of technical pros and cons to each - with claims +from AMD that DDR2 can be slower than DDR - but one claim that isn't +often made, but that helped me make my choice: + + 1) DDR2 supports higher transfer speeds. I'm using DDR2 5400 on + the Intel. I think I'm at 3200 or so on the AMD X2. + + 2) DDR2 is cheaper. I purchased 1 Gbyte DDR2 5400 for $147 CDN. + 1 Gbyte of DDR 3200 starts at around the same price, and + stretches into $200 - $300 CDN. + +Now, granted, the Intel 920 requires more electricity to run. Running +24/7 for a year might make the difference in cost. + +It doesn't address point 1) though. I like my DDR2 5400. + +So, unfortunately, I won't be able to do a good test for you to prove +that my Windows Pentium D box is not only cheaper to buy, but faster, +because the specs aren't exactly equivalent. In the mean time, I'm +quite enjoying my 3d games while doing other things at the same time. +I imagine my desktop load approaches that of a CPU-bound database +load. 3d games require significant I/O and CPU. + +Anybody who claims that Intel is 2X more expensive for the same +performance, isn't considering all factors. No question at all - the +Opteron is good, and the Xeon isn't - but the original poster didn't +ask about Opeteron or Xeon, did he? For the desktop lines - X2 is not +double Pentium D. Maybe 10%. Maybe not at all. Especially now that +Intel is dropping it's prices due to overstock. + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 22:20:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E076511F657F + for ; + Tue, 25 Apr 2006 22:20:01 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 75449-03 + for ; + Tue, 25 Apr 2006 22:19:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2109811F6557 + for ; + Tue, 25 Apr 2006 22:19:48 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3Q1JlVM011056; + Tue, 25 Apr 2006 21:19:47 -0400 (EDT) +To: David Wheeler +cc: pgsql-performance +Subject: Re: PL/pgSQL Loop Vs. Batch Update +In-reply-to: +References: +Comments: In-reply-to David Wheeler + message dated "Tue, 25 Apr 2006 09:44:55 -0700" +Date: Tue, 25 Apr 2006 21:19:47 -0400 +Message-ID: <11055.1146014387@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/589 +X-Sequence-Number: 18673 + +David Wheeler writes: +> This post is longish and has a bit of code, but here's my question up- +> front: Why are batch queries in my PL/pgSQL functions no faster than +> iterating over a loop and executing a series of queries for each +> iteration of the loop? + +You'd really have to look at the plans generated for each of the +commands in the functions to be sure. A knee-jerk reaction is to +suggest that that NOT IN might be the core of the problem, but it's +only a guess. + +It's a bit tricky to examine the behavior of a parameterized query, +which is what these will all be since they depend on local variables +of the plpgsql function (which are passed as parameters to the main +SQL executor). The basic idea is + + PREPARE foo(datatype, datatype, ...) AS SELECT ... $1 ... $2 ... + + EXPLAIN ANALYZE EXECUTE foo(value, value) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 25 22:39:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C9C4611F653D + for ; + Tue, 25 Apr 2006 22:39:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 75436-09 + for ; + Tue, 25 Apr 2006 22:39:43 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.207]) + by postgresql.org (Postfix) with ESMTP id 1E2AE11F6081 + for ; + Tue, 25 Apr 2006 22:39:40 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id o1so1190479nzf + for ; + Tue, 25 Apr 2006 18:39:41 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=WWRnYj/WIQAwmCmV4cX4m/lJB1/WDG9bYrzDDkjkpLqx9njZDDr+teA4q3k1zoa+Ue0kVoJaG5u5mLemLt+PSbXTwCyEVqG8Fblp4A2cqC9PmxXM+b29tBwJsUIgtL2ERpH9rVFVq+j9YQm5JIFJXmrnfN67e8IJvgsL08U2VwI= +Received: by 10.36.43.1 with SMTP id q1mr539245nzq; + Tue, 25 Apr 2006 18:39:41 -0700 (PDT) +Received: by 10.36.97.8 with HTTP; Tue, 25 Apr 2006 18:39:41 -0700 (PDT) +Message-ID: <3c1395330604251839g1063da6k62f0c85d59fe89c0@mail.gmail.com> +Date: Wed, 26 Apr 2006 11:39:41 +1000 +From: "chris smith" +To: "Scott Marlowe" +Subject: Re: Query on postgresql 7.4.2 not using index +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1145980463.23538.218.camel@state.g2switchworks.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <444E240D.3050000@andromeiberica.com> + <3c1395330604250634r6f215ceame157f3dd5f5f4fa3@mail.gmail.com> + <444E28ED.3090900@andromeiberica.com> <19483.1145978579@sss.pgh.pa.us> + <444E44A2.6030703@andromeiberica.com> + <1145980463.23538.218.camel@state.g2switchworks.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/590 +X-Sequence-Number: 18674 + +> OK. Stop and think about what you're telling postgresql to do here. +> +> You're telling it to cast the field group_id to int8, then compare it to +> 9. How can it cast the group_id to int8 without fetching it? That's +> right, you're ensuring a seq scan. You need to put the int8 cast on the +> other side of that equality comparison, like: + +Yeh that one was my fault :) I couldn't remember which way it went and +if 7.4.x had issues with int8 indexes.. + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Sat Apr 29 17:13:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 19D4E11F6618 + for ; + Tue, 25 Apr 2006 22:42:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 73289-09 + for ; + Tue, 25 Apr 2006 22:42:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id A1A9311F60A2 + for ; + Tue, 25 Apr 2006 22:42:14 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 81F3C3147B; Wed, 26 Apr 2006 03:42:14 +0200 (MET DST) +From: "mlartz@gmail.com" +X-Newsgroups: pgsql.performance +Subject: Re: Hardware: HP StorageWorks MSA 1500 +Date: 25 Apr 2006 18:42:04 -0700 +Organization: http://groups.google.com +Lines: 36 +Message-ID: <1146015724.925765.91670@t31g2000cwb.googlegroups.com> +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E4009@sesrv12.wirelesscar.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; + rv:1.7.12) Gecko/20051006 Firefox/1.0.7,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: t31g2000cwb.googlegroups.com; posting-host=68.55.221.98; + posting-account=hpADjAwAAABN5Lkl4wJ_Us9DXosY2bot +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/690 +X-Sequence-Number: 18774 + +I'd be interested in those numbers once you get them, especially for +ext3. We just picked up an HP MSA1500cs with the MSA50 sled, and I am +curious as to how best to configure it for Postgres. My server is the +HP DL585 (quad, dual-core Opteron, 16GB RAM) with 4 HD bays run by a HP +SmartArray 5i controller. I have 15 10K 300GB drives and 1 15K 150GB +drive (don't ask how that happened). + +The database is going to be very datawarehouse-ish (bulk loads, lots of +queries) and has the potential to grow very large (1+ TB). Plus, with +that much data, actual backups won't be easy, so I'll be relying on +RAID+watchfullness to keep me safe, at least through the prototype +stages. + +How would/do you guys set up your MSA1x00 with 1 drive sled? RAID10 vs +RAID5 across 10+ disks? Here's what I was thinking (ext3 across +everything): + +Direct attached: + 2x300GB RAID10 - OS + ETL staging area + 2x300GB RAID10 - log + indexes +MSA1500: + 10x300GB RAID10 + 1x300GB hot spare - tablespace + +I'm not quite sure what to do with the 15K/150GB drive, since it is a +singleton. I'm also planning on giving all the 256MB MSA1500 cache to +reads, although I might change it for the batch loads to see if it +speeds things up. + +Also, unfortunately, the MSA1500 only has a single SCSI bus, which +could significantly impact throughput, but we got a discount, so +hopefully we can get another bus module in the near future and pop it +in. + +Any comments are appreciated, +-Mike + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 23:26:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0FD2811F6093 + for ; + Tue, 25 Apr 2006 23:26:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03644-02 + for ; + Tue, 25 Apr 2006 23:25:40 -0300 (ADT) +X-Greylist: delayed 00:34:05.864791 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 39FCF11F6089 + for ; + Tue, 25 Apr 2006 23:25:37 -0300 (ADT) +Received: from preston.office (mail.eclinic.com.au [203.202.134.251]) + by svr4.postgresql.org (Postfix) with ESMTP id 7B7A35B239D + for ; + Wed, 26 Apr 2006 01:51:32 +0000 (GMT) +Received: from preston.office (preston [127.0.0.1]) + by preston.office (Postfix) with ESMTP id 623EE10008A9; + Wed, 26 Apr 2006 11:51:23 +1000 (EST) +Received: from preston.office (preston [127.0.0.1]) + by preston.office (Postfix) with ESMTP id 0A7AD1001741; + Wed, 26 Apr 2006 11:51:23 +1000 (EST) +Received: from [192.168.1.28] (shawn.office [192.168.1.28]) + by preston.office (Postfix) with ESMTP id 01C0610008A9; + Wed, 26 Apr 2006 11:51:21 +1000 (EST) +Message-ID: <444ED282.6010102@eclinic.com.au> +Date: Wed, 26 Apr 2006 11:53:06 +1000 +From: Leigh Dyer +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: mark@mark.mielke.cc +Cc: Scott Marlowe , + Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> + <20060426005440.GA12711@mark.mielke.cc> + <20060426011701.GB12711@mark.mielke.cc> +In-Reply-To: <20060426011701.GB12711@mark.mielke.cc> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AV-Checked: ClamAV using ClamSMTP +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/592 +X-Sequence-Number: 18676 + +mark@mark.mielke.cc wrote: +> Another benefit of Pentium D over AMD X2, at least until AMD chooses +> to switch, is that Pentium D supports DDR2, whereas AMD only supports +> DDR. There are a lot of technical pros and cons to each - with claims +> from AMD that DDR2 can be slower than DDR - but one claim that isn't +> often made, but that helped me make my choice: +> +They're switching quite soon though -- within the next month now it +seems, after moving up their earlier plans to launch in June: + +http://www.dailytech.com/article.aspx?newsid=1854 + +This Anandtech article shows the kind of performance increase we can +expect with DDR2 on AMD's new socket: + +http://www.anandtech.com/cpuchipsets/showdoc.aspx?i=2741 + +The short version is that it's an improvement, but not an enormous one, +and you need to spend quite a bit of cash on 800Mhz (PC6400) DDR2 sticks +to see the most benefit. Some brief local (Australian) price comparisons +show 1GB PC-3200 DDR sticks starting at just over AU$100, with 1GB +PC2-4200 DDR2 sticks around the same price, though Anandtech's tests +showed PC2-4200 DDR2 benching generally slower than PC-3200 DDR, +probably due to the increased latency in DDR2. + +Comparing reasonable quality matched pairs of 1GB sticks, PC-3200 DDR +still seems generally cheaper than PC2-5300 DDR2, though not by a lot, +and I'm sure the DDR2 will start dropping even further as AMD systems +start using it in the next month or so. + +One thing's for sure though -- Intel's Pentium D prices are remarkably +low, and at the lower end of the price range AMD has nothing that's even +remotely competitive in terms of price/performance. The Pentium D 805, +for instance, with its dual 2.67Ghz cores, costs just AU$180. The X2 +3800+ is a far better chip, but it's also two-and-a-half times the price. + +None of this really matters much in the server space though, where +Opteron's real advantage over Xeon is not its greater raw CPU power, or +its better dual-core implementation (though both would be hard to +dispute), but the improved system bandwidth provided by Hypertransport. +Even with Intel's next-gen CPUs, which look set to address the first two +points quite well, they still won't have an interconnect technology that +can really compete with AMD's. + +Thanks +Leigh + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 23:06:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5FB8911F60B0 + for ; + Tue, 25 Apr 2006 23:06:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 83526-06-2 + for ; + Tue, 25 Apr 2006 23:06:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 7E22611F6093 + for ; + Tue, 25 Apr 2006 23:06:29 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3Q26TvD011304; + Tue, 25 Apr 2006 22:06:29 -0400 (EDT) +To: "andremachado" +cc: pgsql-performance@postgresql.org +Subject: Re: Firebird 1.5.3 X Postgresql 8.1.3 (linux and windows) +In-reply-to: <20060425160609.M20649@techforce.com.br> +References: <20060425160609.M20649@techforce.com.br> +Comments: In-reply-to "andremachado" + message dated "Tue, 25 Apr 2006 14:38:16 -0200" +Date: Tue, 25 Apr 2006 22:06:29 -0400 +Message-ID: <11303.1146017189@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/591 +X-Sequence-Number: 18675 + +"andremachado" writes: +> After some time experimenting on windows, the conclusion is clear: +> windows is likely crap for databases other than MS-SQL. + +Maybe. One thing that comes to mind is that you really should do some +performance tuning experiments. In particular it'd be a good idea to +increase checkpoint_segments and try other settings for wal_sync_method. +Your fifth query, + +bddnf=# explain analyze update NOTA_FISCAL set VA_TOTAL_ITENSDNF = (select sum(ITEM_NOTA.VA_TOTAL) from ITEM_NOTA where ITEM_NOTA.ID_NF = NOTA_FISCAL.ID_NF) where ID_NF in (select NF2.ID_NF from DECLARACAO DE inner join CADASTRO CAD on (CAD.ID_DECLARACAO=DE.ID_DECLARACAO) inner join NOTA_FISCAL NF2 on (NF2.ID_CADASTRO=CAD.ID_CADASTRO) where DE.ID_ARQUIVO in (1) ); + +shows runtime of the plan proper as 158 seconds but total runtime as 746 +seconds --- the discrepancy has to be associated with writing out the +updated rows, which there are a lot of (719746) in this query, but still +we should be able to do it faster than that. So I surmise a bottleneck +in pushing WAL updates to disk. + +The last two queries are interesting. Does Firebird have any equivalent +of EXPLAIN, ie a way to see what sort of query plan they are using? +I suspect they are being more aggressive about optimizing the max() +functions in the sub-selects than we are. In particular, the 8.1 code +for optimizing min/max just punts if it sees any sub-selects in the +WHERE clause, which prevents us from doing anything with these examples. + + /* + * Also reject cases with subplans or volatile functions in WHERE. This + * may be overly paranoid, but it's not entirely clear if the + * transformation is safe then. + */ + if (contain_subplans(parse->jointree->quals) || + contain_volatile_functions(parse->jointree->quals)) + return NULL; + +This is something I'd wanted to go back and look at more carefully, but +never got around to. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Apr 25 23:28:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D6D3C11F6089 + for ; + Tue, 25 Apr 2006 23:28:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 02782-04 + for ; + Tue, 25 Apr 2006 23:27:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail5.sea5.speakeasy.net (mail5.sea5.speakeasy.net + [69.17.117.7]) by postgresql.org (Postfix) with ESMTP id 665DD11F6093 + for ; + Tue, 25 Apr 2006 23:27:52 -0300 (ADT) +Received: (qmail 23951 invoked from network); 26 Apr 2006 02:27:52 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail5.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP + for ; 26 Apr 2006 02:27:52 -0000 +In-Reply-To: <11055.1146014387@sss.pgh.pa.us> +References: + <11055.1146014387@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <8FE57896-2F9B-4838-857B-FA6CC2EE162A@kineticode.com> +Cc: pgsql-performance +Content-Transfer-Encoding: 7bit +From: David Wheeler +Subject: Re: PL/pgSQL Loop Vs. Batch Update +Date: Tue, 25 Apr 2006 19:27:48 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/593 +X-Sequence-Number: 18677 + +On Apr 25, 2006, at 18:19, Tom Lane wrote: + +> You'd really have to look at the plans generated for each of the +> commands in the functions to be sure. A knee-jerk reaction is to +> suggest that that NOT IN might be the core of the problem, but it's +> only a guess. + +Well, the rows are indexed (I forgot to include the indexes in my +first post), and given that each entry_id has no more than ten +associated tag_ids, I would expect it to be quite fast, relying on +the primary key index to look up the entry_id first, and then the +associated tag_ids. But that's just a guess on my part, too. Perhaps +I should try a left outer join with tag_id IS NULL? + +> It's a bit tricky to examine the behavior of a parameterized query, +> which is what these will all be since they depend on local variables +> of the plpgsql function (which are passed as parameters to the main +> SQL executor). + +Right, that makes sense. + +> The basic idea is +> +> PREPARE foo(datatype, datatype, ...) AS SELECT ... $1 ... $2 ... +> +> EXPLAIN ANALYZE EXECUTE foo(value, value) + +Just on a lark, I tried to get this to work: + +try=# explain analyze EXECUTE foo(1, ARRAY +[600001,600002,600003,600004,600005,600006,600007]); + QUERY PLAN +------------------------------------------------------------------------ +-------------- +Result (cost=0.00..0.01 rows=1 width=0) (actual time=26.241..26.251 +rows=1 loops=1) +Total runtime: 27.512 ms +(2 rows) + +That's not much use. Is there no way to EXPLAIN ANALYZE this stuff? + +Thanks Tom. + +Best, + +David + + +From pgsql-performance-owner@postgresql.org Tue Apr 25 23:36:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D944611F6089 + for ; + Tue, 25 Apr 2006 23:36:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 82170-09 + for ; + Tue, 25 Apr 2006 23:36:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id DE25311F6093 + for ; + Tue, 25 Apr 2006 23:36:22 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3Q2aLoT011515; + Tue, 25 Apr 2006 22:36:21 -0400 (EDT) +To: David Wheeler +cc: pgsql-performance +Subject: Re: PL/pgSQL Loop Vs. Batch Update +In-reply-to: <8FE57896-2F9B-4838-857B-FA6CC2EE162A@kineticode.com> +References: + <11055.1146014387@sss.pgh.pa.us> + <8FE57896-2F9B-4838-857B-FA6CC2EE162A@kineticode.com> +Comments: In-reply-to David Wheeler + message dated "Tue, 25 Apr 2006 19:27:48 -0700" +Date: Tue, 25 Apr 2006 22:36:21 -0400 +Message-ID: <11514.1146018981@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/594 +X-Sequence-Number: 18678 + +David Wheeler writes: +> Just on a lark, I tried to get this to work: + +> try=# explain analyze EXECUTE foo(1, ARRAY +> [600001,600002,600003,600004,600005,600006,600007]); +> QUERY PLAN +> ------------------------------------------------------------------------ +> -------------- +> Result (cost=0.00..0.01 rows=1 width=0) (actual time=26.241..26.251 +> rows=1 loops=1) +> Total runtime: 27.512 ms +> (2 rows) + +> That's not much use. + +It looks like you had something trivial as the definition of foo(). +Try one of the actual queries from the plpgsql function. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Apr 26 00:08:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D066211F622B + for ; + Wed, 26 Apr 2006 00:08:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 15411-01 + for ; + Wed, 26 Apr 2006 00:07:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth04.mail.atl.earthlink.net + (smtpauth04.mail.atl.earthlink.net [209.86.89.64]) + by postgresql.org (Postfix) with ESMTP id 5FE7B11F6237 + for ; + Wed, 26 Apr 2006 00:07:19 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=ZxKD581OSaKS1b37Ow4SouJOGFiHTuWrMtCcKRNkbuepU4QRT6N5VxK1jWZr+XFw; + h=Message-ID:Date:From:Reply-To:To:Subject:Cc:Mime-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:X-ELNK-Trace:X-Originating-IP; +Received: from [209.86.224.41] (helo=elwamui-mouette.atl.sa.earthlink.net) + by smtpauth04.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FYaN3-0004oW-Ee; Tue, 25 Apr 2006 23:07:17 -0400 +Received: from 70.22.235.105 by webmail.pas.earthlink.net with HTTP; + Tue, 25 Apr 2006 23:07:17 -0400 +Message-ID: + <8991088.1146020837420.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +Date: Tue, 25 Apr 2006 23:07:17 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: mark@mark.mielke.cc, Scott Marlowe +Subject: Re: Large (8M) cache vs. dual-core CPUs +Cc: Bill Moran , + pgsql-performance@postgresql.org +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: EarthLink Zoo Mail 1.0 +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc2e9d25295200e177cd33bf51438af657350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 209.86.224.41 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/595 +X-Sequence-Number: 18679 + +>Another benefit of Pentium D over AMD X2, at least until AMD chooses +>to switch, is that Pentium D supports DDR2, whereas AMD only supports +>DDR. There are a lot of technical pros and cons to each - with claims +>from AMD that DDR2 can be slower than DDR - but one claim that isn't +>often made, but that helped me make my choice: +> +> 1) DDR2 supports higher transfer speeds. I'm using DDR2 5400 on +> the Intel. I think I'm at 3200 or so on the AMD X2. +> +> 2) DDR2 is cheaper. I purchased 1 Gbyte DDR2 5400 for $147 CDN. +> 1 Gbyte of DDR 3200 starts at around the same price, and +> stretches into $200 - $300 CDN. +> +There's a logical fallacy here that needs to be noted. + +THROUGHPUT is better with DDR2 if and only if there is enough data to be fetched in a serial fashion from memory. + +LATENCY however is dependent on the base clock rate of the RAM involved. +So PC3200, 200MHz x2, is going to actually perform better than PC2-5400, 166MHz x4, for almost any memory access pattern except those that are highly sequential. + +In fact, even PC2-6400, 200MHz x4, has a disadvantage compared to 200MHz x2 memory. +The minimum latency of the two types of memory in clock cycles is always going to be higher for the memory type that multiplies its base clock rate by the most. + +For the mostly random memory access patterns that comprise many DB applications, the base latency of the RAM involved is going to matter more than the peak throughput AKA the bandwidth of that RAM. + +The big message here is that despite engineering tricks and marketing claims, the base clock rate of the RAM you use matters. + +A minor point to be noted in addition here is that most DB servers under load are limited by their physical IO subsystem, their HDs, and not the speed of their RAM. + +All of the above comments about the relative performance of different RAM types become insignificant when performance is gated by the HD subsystem. + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 00:18:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id ECDA811F60A9 + for ; + Wed, 26 Apr 2006 00:18:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 15062-03 + for ; + Wed, 26 Apr 2006 00:18:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail7.sea5.speakeasy.net (mail7.sea5.speakeasy.net + [69.17.117.9]) by postgresql.org (Postfix) with ESMTP id 8419011F6089 + for ; + Wed, 26 Apr 2006 00:18:13 -0300 (ADT) +Received: (qmail 21791 invoked from network); 26 Apr 2006 03:18:11 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail7.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP + for ; 26 Apr 2006 03:18:11 -0000 +In-Reply-To: <11514.1146018981@sss.pgh.pa.us> +References: + <11055.1146014387@sss.pgh.pa.us> + <8FE57896-2F9B-4838-857B-FA6CC2EE162A@kineticode.com> + <11514.1146018981@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <4180CE7A-4FD4-466B-B4C0-CF6754DF7945@kineticode.com> +Cc: pgsql-performance +Content-Transfer-Encoding: 7bit +From: David Wheeler +Subject: Re: PL/pgSQL Loop Vs. Batch Update +Date: Tue, 25 Apr 2006 20:18:05 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/596 +X-Sequence-Number: 18680 + +On Apr 25, 2006, at 19:36, Tom Lane wrote: + +> It looks like you had something trivial as the definition of foo(). + +Yeah, the function call. :-) + +> Try one of the actual queries from the plpgsql function. + +Oh. Duh. Will do. Tomorrow. + +Best, + +David + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 03:48:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 29F6A11F620C + for ; + Wed, 26 Apr 2006 03:48:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50423-02 + for ; + Wed, 26 Apr 2006 03:48:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.envysolutions.com (mark.mielke.cc [206.248.142.186]) + by postgresql.org (Postfix) with ESMTP id C64B311F620E + for ; + Wed, 26 Apr 2006 03:48:09 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envysolutions.com (Postfix) with ESMTP id 22AEC1B69A; + Wed, 26 Apr 2006 02:48:53 -0400 (EDT) +Received: from mail.envysolutions.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 17009-04; Wed, 26 Apr 2006 02:48:53 -0400 (EDT) +Received: by mail.envysolutions.com (Postfix, from userid 500) + id 098AF1B69C; Wed, 26 Apr 2006 02:48:53 -0400 (EDT) +Date: Wed, 26 Apr 2006 02:48:53 -0400 +From: mark@mark.mielke.cc +To: Ron Peacetree +Cc: Scott Marlowe , + Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060426064852.GA16879@mark.mielke.cc> +References: + <8991088.1146020837420.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: + <8991088.1146020837420.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envysolutions.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=0.404 tagged_above=0 required=5 tests=AWL, BAYES_00, + FORGED_RCVD_HELO, NO_REAL_NAME, SPF_HELO_SOFTFAIL, SPF_SOFTFAIL +X-Spam-Level: +X-Archive-Number: 200604/597 +X-Sequence-Number: 18681 + +On Tue, Apr 25, 2006 at 11:07:17PM -0400, Ron Peacetree wrote: +> THROUGHPUT is better with DDR2 if and only if there is enough data +> to be fetched in a serial fashion from memory. +> LATENCY however is dependent on the base clock rate of the RAM +> involved. So PC3200, 200MHz x2, is going to actually perform better +> than PC2-5400, 166MHz x4, for almost any memory access pattern +> except those that are highly sequential. + +I had forgotten about this. Still, it's not quite as simple as you say. + +DDR2 has increased latency, however, it has a greater upper limit, +and when run at the same clock speed (200 Mhz for 200 Mhz), it is +not going to perform worse. Add in double the pre-fetching capability, +and what you get is that most benchmarks show DDR2 5400 as being +slightly faster than DDR 3200. + +AMD is switching to DDR2, and I believe that, even after making such a +big deal about latency, and why they wouldn't switch to DDR2, they are +now saying that their on-chip memory controller will be able to access +DDR2 memory (when they support it soon) faster than Intel can, not +having an on-chip memory controller. + +You said that DB accesses are random. I'm not so sure. In PostgreSQL, +are not the individual pages often scanned sequentially, especially +because all records are variable length? You don't think PostgreSQL +will regularly read 32 bytes (8 bytes x 4) at a time, in sequence? +Whether for table pages, or index pages - I'm not seeing why the +accesses wouldn't be sequential. You believe PostgreSQL will access +the table pages and index pages randomly on a per-byte basis? What +is the minimum PostgreSQL record size again? Isn't it 32 bytes or +over? :-) + +I wish my systems were running the same OS, and I'd run a test for +you. Alas, I don't think comparing Windows to Linux would be valuable. + +> A minor point to be noted in addition here is that most DB servers +> under load are limited by their physical IO subsystem, their HDs, +> and not the speed of their RAM. + +It seems like a pretty major point to me. :-) + +It's why Opteron with RAID kicks ass over HyperTransport. + +> All of the above comments about the relative performance of +> different RAM types become insignificant when performance is gated +> by the HD subsystem. + +Yes. + +Luckily - we don't all have Terrabyte databases... :-) + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Sat Apr 29 17:13:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7384011F6979 + for ; + Wed, 26 Apr 2006 05:12:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 63723-02 + for ; + Wed, 26 Apr 2006 05:12:41 -0300 (ADT) +X-Greylist: delayed 00:25:46.88529 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 5C87411F623C + for ; + Wed, 26 Apr 2006 05:12:40 -0300 (ADT) +Received: from mail1.ardec.com.au (unknown [203.11.83.254]) + by svr4.postgresql.org (Postfix) with ESMTP id 8C0065B2F29 + for ; + Wed, 26 Apr 2006 07:44:57 +0000 (GMT) +Received: from [192.168.1.188] (lorax.bedrock.ardec.com.au [192.168.1.188]) + by mail1.ardec.com.au (8.13.3/8.13.3) with ESMTP id k3Q7iNOD021763 + for ; + Wed, 26 Apr 2006 17:14:24 +0930 (CST) +Message-ID: <444F24E9.2010907@lisasoft.com> +Date: Wed, 26 Apr 2006 17:14:41 +0930 +From: Eric Lam +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Slow restoration question +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV 0.88/1425/Tue Apr 25 21:39:41 2006 on + mizaru.adl.ardec.com.au +X-Virus-Status: Clean +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/691 +X-Sequence-Number: 18775 + +Hello list, + +what is the quickest way of dumping a DB and restoring it? I have done a + + "pg_dump -D database | split --line-bytes 1546m part" + +Restoration as + + "cat part* | psql database 2> errors 1>/dev/null" + +all dumpfiles total about 17Gb. It has been running for 50ish hrs and up +to about the fourth file (5-6 ish Gb) and this is on a raid 5 server. + +A while back I did something similar for a table with where I put all +the insert statements in one begin/end/commit block, this slowed down +the restoration process. Will the same problem [slow restoration] occur +if there is no BEGIN and END block? I assume the reason for slow inserts +in this instance is that it allows for rollback, if this is the case +can I turn this off? + +Thanks in advance +Eric Lam + +From pgsql-performance-owner@postgresql.org Wed Apr 26 09:41:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5270211F6223 + for ; + Wed, 26 Apr 2006 09:41:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 05148-07-2 + for ; + Wed, 26 Apr 2006 09:40:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by postgresql.org (Postfix) with ESMTP id 5D94B11F60BF + for ; + Wed, 26 Apr 2006 09:40:39 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=bHovQvivnMGWXB/0D+zWLOF4ijSF1ixcmZ/o1AD5zrW3ZwPGlUFfQ9j3siYmdYML; + h=Message-ID:Date:From:Reply-To:To:Subject:Mime-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:X-ELNK-Trace:X-Originating-IP; +Received: from [209.86.224.33] (helo=elwamui-darkeyed.atl.sa.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FYjJt-0008GA-Df; Wed, 26 Apr 2006 08:40:37 -0400 +Received: from 70.22.235.105 by webmail.pas.earthlink.net with HTTP; + Wed, 26 Apr 2006 08:40:37 -0400 +Message-ID: + <7096611.1146055237377.JavaMail.root@elwamui-darkeyed.atl.sa.earthlink.net> +Date: Wed, 26 Apr 2006 08:40:37 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: mark@mark.mielke.cc, pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: EarthLink Zoo Mail 1.0 +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc0b231f137d9dff606f44d2f131f2c141350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 209.86.224.33 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/598 +X-Sequence-Number: 18682 + +I'm posting this to the entire performance list in the hopes that it will be generally useful. +=r + +-----Original Message----- +>From: mark@mark.mielke.cc +>Sent: Apr 26, 2006 3:25 AM +>To: Ron Peacetree +>Subject: Re: [PERFORM] Large (8M) cache vs. dual-core CPUs +> +>Hi Ron: +> +>As a result of your post on the matter, I've been redoing some of my +>online research on this subject, to see whether I do have one or more +>things wrong. +> +I'm always in favor of independent investigation to find the truth. :-) + + +>You say: +> +>> THROUGHPUT is better with DDR2 if and only if there is enough data +>> to be fetched in a serial fashion from memory. +>... +>> So PC3200, 200MHz x2, is going to actually perform better than +>> PC2-5400, 166MHz x4, for almost any memory access pattern except +>> those that are highly sequential. +>... +>> For the mostly random memory access patterns that comprise many DB +>> applications, the base latency of the RAM involved is going to +>> matter more than the peak throughput AKA the bandwidth of that RAM. +> +>I'm trying to understand right now - why does DDR2 require data to be +>fetched in a serial fashion, in order for it to maximize bandwidth? +> +SDR transfers data on either the rising or falling edge of its clock cycle. + +DDR transfers data on both the rising and falling edge of the base clock signal. If there is a contiguous chunk of 2+ datums to be transferred. + +DDR2 basically has a second clock that cycles at 2x the rate of the base clock and thus we get 4 data transfers per base clock cycle. If there is a contiguous chunk of 4+ datums to be transferred. + +Note also what happens when transferring the first datum after a lull period. +For purposes of example, let's pretend that we are talking about a base clock rate of 200MHz= 5ns. + +The SDR still transfers data every 5ns no matter what. +The DDR transfers the 1st datum in 10ns and then assuming there are at least 2 sequential datums to be transferred will transfer the 2nd and subsequent sequential pieces of data every 2.5ns. +The DDR2 transfers the 1st datum in 20ns and then assuming there are at least 4 sequential datums to be transferred will transfer the 2nd and subsequent sequential pieces of data every 1.25ns. + +Thus we can see that randomly accessing RAM degrades performance significantly for DDR and DDR2. We can also see that the conditions for optimal RAM performance become more restrictive as we go from SDR to DDR to DDR2. +The reason DDR2 with a low base clock rate excelled at tasks like streaming multimedia and stank at things like small transaction OLTP DB applications is now apparent. + +Factors like CPU prefetching and victim buffers can muddy this picture a bit. +Also, if the CPU's off die IO is slower than the RAM it is talking to, how fast that RAM is becomes unimportant. + +The reason AMD is has held off from supporting DDR2 until now are: +1. DDR is EOL. JEDEC is not ratifying any DDR faster than 200x2 while DDR2 standards as fast as 333x4 are likely to be ratified (note that Intel pretty much avoided DDR, leaving it to AMD, while DDR2 is Intel's main RAM technology. Guess who has more pull with JEDEC?) + +2. DDR and DDR2 RAM with equal base clock rates are finally available, removing the biggest performance difference between DDR and DDR2. + +3. Due to the larger demand for DDR2, more of it is produced. That in turn has resulted in larger supplies of DDR2 than DDR. Which in turn, especially when combined with the factors above, has resulted in lower prices for DDR2 than for DDR of the same or faster base clock rate by now. + +Hope this is helpful, +Ron + +From pgsql-performance-owner@postgresql.org Wed Apr 26 11:02:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B6F7211F620C + for ; + Wed, 26 Apr 2006 11:02:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18492-06 + for ; + Wed, 26 Apr 2006 11:02:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from skunk.mtbrook.bozemanpass.com (unknown [69.145.82.195]) + by postgresql.org (Postfix) with ESMTP id 3753D11F60AF + for ; + Wed, 26 Apr 2006 11:02:24 -0300 (ADT) +Received: from [69.145.82.249] (unknown [69.145.82.249]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by skunk.mtbrook.bozemanpass.com (Postfix) with ESMTP id 2ED2655829A + for ; + Wed, 26 Apr 2006 07:02:22 -0700 (PDT) +Message-ID: <444F7D6F.5080909@boreham.org> +Date: Wed, 26 Apr 2006 08:02:23 -0600 +From: David Boreham +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: + <7096611.1146055237377.JavaMail.root@elwamui-darkeyed.atl.sa.earthlink.net> +In-Reply-To: + <7096611.1146055237377.JavaMail.root@elwamui-darkeyed.atl.sa.earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/599 +X-Sequence-Number: 18683 + + +> +>The reason AMD is has held off from supporting DDR2 until now are: +>1. DDR is EOL. JEDEC is not ratifying any DDR faster than 200x2 while DDR2 standards as fast as 333x4 are likely to be ratified (note that Intel pretty much avoided DDR, leaving it to AMD, while DDR2 is Intel's main RAM technology. Guess who has more pull with JEDEC?) +> +> +> +DDR2 is to RDRAM as C# is to Java + +;) + + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 11:20:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D14A411F64E0 + for ; + Wed, 26 Apr 2006 11:20:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 22461-06 + for ; + Wed, 26 Apr 2006 11:19:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 430FC11F627C + for ; + Wed, 26 Apr 2006 11:19:40 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 3BE5D3147B; Wed, 26 Apr 2006 16:19:40 +0200 (MET DST) +From: William Yu +X-Newsgroups: pgsql.performance +Subject: Re: Large (8M) cache vs. dual-core CPUs +Date: Wed, 26 Apr 2006 07:19:38 -0700 +Organization: Hub.Org Networking Services +Lines: 35 +Message-ID: +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> + <20060426005440.GA12711@mark.mielke.cc> + <20060426011701.GB12711@mark.mielke.cc> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Thunderbird 1.5 (X11/20051201) +In-Reply-To: <20060426011701.GB12711@mark.mielke.cc> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=1.217 tagged_above=0 required=5 tests=BAYES_00, + SPF_HELO_SOFTFAIL, SPF_SOFTFAIL +X-Spam-Level: * +X-Archive-Number: 200604/600 +X-Sequence-Number: 18684 + +mark@mark.mielke.cc wrote: +> +> I have an Intel Pentium D 920, and an AMD X2 3800+. These are very +> close in performance. The retail price difference is: +> +> Intel Pentium D 920 is selling for $310 CDN +> AMD X2 3800+ is selling for $347 CDN +> +> Anybody who claims that Intel is 2X more expensive for the same +> performance, isn't considering all factors. No question at all - the +> Opteron is good, and the Xeon isn't - but the original poster didn't +> ask about Opeteron or Xeon, did he? For the desktop lines - X2 is not +> double Pentium D. Maybe 10%. Maybe not at all. Especially now that +> Intel is dropping it's prices due to overstock. + +There's part of the equation you are missing here. This is a PostgreSQL +mailing list which means we're usually talking about performance of just +this specific server app. While in general there may not be that much of +a % difference between the 2 chips, there's a huge gap in Postgres. For +whatever reason, Postgres likes Opterons. Way more than Intel +P4-architecture chips. (And it appears way more than IBM Power4 chips +and a host of other chips also.) + +Here's one of the many discussions we had about this issue last year: + +http://qaix.com/postgresql-database-development/337-670-re-opteron-vs-xeon-was-what-to-do-with-6-disks-read.shtml + +The exact reasons why Opteron runs PostgreSQL so much better than P4s, +we're not 100% sure of. We have guesses -- lower memory latency, lack of +shared FSB, better 64-bit, 64-bit IOMMU, context-switch storms on P4, +better dualcore implementation and so on. Perhaps it's a combination of +all the above factors but somehow, the general experience people have +had is that equivalently priced Opterons servers run PostgreSQL 2X +faster than P4 servers as the baseline and the gap increases as you add +more sockets and more cores. + +From pgsql-performance-owner@postgresql.org Wed Apr 26 11:27:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3AC7B11F60A2 + for ; + Wed, 26 Apr 2006 11:27:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 22246-07 + for ; + Wed, 26 Apr 2006 11:27:17 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.177]) + by postgresql.org (Postfix) with ESMTP id 6F6AD11F620C + for ; + Wed, 26 Apr 2006 11:27:14 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so1681137pye + for ; + Wed, 26 Apr 2006 07:27:13 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=US3JRl+ScfizTvbkI/kVQfM84P9OzVoAxo8YvdVeI3w8x1AgoudF5DieU24Rtrp9MNuPHXEdAeP905qJNjC5LZZK2VgP8+d7k5p+rxLKew+bu9/0xVPUGw7wFtr3OmQQmphWErXDvxQZOAB6eo5kI+tyTFTNdKa5btcgCzPPQqA= +Received: by 10.35.54.20 with SMTP id g20mr537785pyk; + Wed, 26 Apr 2006 07:27:13 -0700 (PDT) +Received: by 10.35.82.19 with HTTP; Wed, 26 Apr 2006 07:27:13 -0700 (PDT) +Message-ID: <8d04ce990604260727r65d009d6pef436465701c4203@mail.gmail.com> +Date: Wed, 26 Apr 2006 07:27:13 -0700 +From: "Junaili Lie" +To: "Tom Lane" +Subject: Re: slow deletes on pgsql 7.4 +Cc: pgsql-performance@postgresql.org +In-Reply-To: <10985.1146013474@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_3653_14548820.1146061633558" +References: <8d04ce990604251441ya85c42evb47946272536cabe@mail.gmail.com> + <9147.1146006558@sss.pgh.pa.us> + <8d04ce990604251714g1f5d99bbn172ec554a49c8374@mail.gmail.com> + <10985.1146013474@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/601 +X-Sequence-Number: 18685 + +------=_Part_3653_14548820.1146061633558 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +It was on my first email. +Here it is again: +MONSOON=3D# explain delete from scenario where id=3D'1099'; + QUERY PLAN +---------------------------------------------------------------------------= +--- + Index Scan using scenario_pkey on scenario (cost=3D0.00..3.14 rows=3D1 +width=3D6) + Index Cond: (id =3D 1099::bigint) +(2 rows) + +MONSOON=3D# explain delete from scenario where id=3D'1023'; + QUERY PLAN +---------------------------------------------------------------------------= +--- + Index Scan using scenario_pkey on scenario (cost=3D0.00..3.14 rows=3D1 +width=3D6) + Index Cond: (id =3D 1023::bigint) +(2 rows) + +Thanks, +J + + +On 4/25/06, Tom Lane wrote: +> +> "Junaili Lie" writes: +> > ie. delete from scenario where id=3D3D'1023' is very fast, but delete f= +rom +> > scenario where id=3D3D'1099' is running forever. +> +> What does EXPLAIN show for each of those cases? +> +> regards, tom lane +> + +------=_Part_3653_14548820.1146061633558 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +
It was on my first email.
+
Here it is again:
+
MONSOON=3D# explain delete from scenario where id=3D'1099';
 &= +nbsp;           &nbs= +p;            &= +nbsp;       QUERY PLAN
-------------------= +-----------------------------------------------------------
 Index = +Scan using scenario_pkey on scenario  (cost=3D +0.00..3.14 rows=3D1 width=3D6)
   Index Cond: (id =3D 1099::bi= +gint)
(2 rows)

MONSOON=3D# explain delete from scenario where id= +=3D'1023';
          &= +nbsp;           &nbs= +p;           QUERY PLAN-------------------------------------------------------------------------= +----- +
 Index Scan using scenario_pkey on scenario  (cost=3D0.00..3.= +14 rows=3D1 width=3D6)
   Index Cond: (id =3D 1023::bigint)(2 rows)
 
+
Thanks,
+
J

 
+
On 4/25/06, = +Tom Lane <tgl@sss.pgh.pa.us= +> wrote: +
"Junaili Lie" <junaili@gmail.com> writes:
> = +ie. delete from scenario where id=3D3D'1023' is very fast, but delete from +
> scenario where id=3D3D'1099' is running forever.

What does = +EXPLAIN show for each of those cases?

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

+ +------=_Part_3653_14548820.1146061633558-- + +From pgsql-performance-owner@postgresql.org Wed Apr 26 11:43:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CEAE911F620E + for ; + Wed, 26 Apr 2006 11:43:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27398-04 + for ; + Wed, 26 Apr 2006 11:43:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from skunk.mtbrook.bozemanpass.com (unknown [69.145.82.195]) + by postgresql.org (Postfix) with ESMTP id C333A11F60B1 + for ; + Wed, 26 Apr 2006 11:43:18 -0300 (ADT) +Received: from [69.145.82.249] (unknown [69.145.82.249]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by skunk.mtbrook.bozemanpass.com (Postfix) with ESMTP id 6E59C55829A + for ; + Wed, 26 Apr 2006 07:43:19 -0700 (PDT) +Message-ID: <444F870D.2000307@boreham.org> +Date: Wed, 26 Apr 2006 08:43:25 -0600 +From: David Boreham +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> + <20060426005440.GA12711@mark.mielke.cc> + <20060426011701.GB12711@mark.mielke.cc> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=0.245 tagged_above=0 required=5 tests=AWL, BAYES_00, + SPF_HELO_SOFTFAIL, SPF_SOFTFAIL +X-Spam-Level: +X-Archive-Number: 200604/602 +X-Sequence-Number: 18686 + + + >While in general there may not be that much of a % difference between +the 2 chips, + >there's a huge gap in Postgres. For whatever reason, Postgres likes +Opterons. + >Way more than Intel P4-architecture chips. + +It isn't only Postgres. I work on a number of other server applications +that also run much faster on Opterons than the published benchmark +figures would suggest they should. They're all compiled with gcc4, +so possibly there's a compiler issue. I don't run Windows on any +of our Opteron boxes so I can't easily compare using the MS compiler. + + + + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 11:44:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A78EF11F6602 + for ; + Wed, 26 Apr 2006 11:44:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29111-02 + for ; + Wed, 26 Apr 2006 11:43:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) + by postgresql.org (Postfix) with ESMTP id AB52611F6236 + for ; + Wed, 26 Apr 2006 11:43:55 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYC00GEM3L4O200@vms046.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 26 Apr 2006 09:43:53 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 70A376E7F0; Wed, + 26 Apr 2006 10:43:51 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 05393-03-8; Wed, 26 Apr 2006 10:43:50 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 5DA3A6E81C; Wed, 26 Apr 2006 10:43:50 -0400 (EDT) +Date: Wed, 26 Apr 2006 10:43:49 -0400 +From: Michael Stone +Subject: Re: Introducing a new linux readahead framework +In-reply-to: <20060421013826.GA5217@mail.ustc.edu.cn> +To: pgsql-performance@postgresql.org +Cc: Wu Fengguang +Mail-followup-to: pgsql-performance@postgresql.org, + Wu Fengguang +Message-id: <20060426144347.GA31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060421013826.GA5217@mail.ustc.edu.cn> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=1.217 tagged_above=0 required=5 tests=BAYES_00, + SPF_HELO_SOFTFAIL, SPF_SOFTFAIL +X-Spam-Level: * +X-Archive-Number: 200604/603 +X-Sequence-Number: 18687 + + From my initial testing this is very promising for a postgres server. +Benchmark-wise, a simple dd with an 8k blocksize gets ~200MB/s as +compared to ~140MB/s on the same hardware without the patch. Also, that +200MB/s seems to be unaffected by the dd blocksize, whereas without the +patch a 512k blocksize would get ~100MB/s. I'm now watching to see how +it does over a couple of days on real-world workloads. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Wed Apr 26 12:11:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BC35611F6207 + for ; + Wed, 26 Apr 2006 12:11:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33483-03 + for ; + Wed, 26 Apr 2006 12:10:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by postgresql.org (Postfix) with ESMTP id 5809811F61E9 + for ; + Wed, 26 Apr 2006 12:10:41 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=rhzp97PXGOynqTJMzRv/uw8XbeLkJfR5I+jG7bfgt7jQkU0LS/w9rbctJCWiSmvS; + h=Message-ID:Date:From:Reply-To:To:Subject:Mime-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:X-ELNK-Trace:X-Originating-IP; +Received: from [209.86.224.33] (helo=elwamui-darkeyed.atl.sa.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FYlf6-0005my-Ca; Wed, 26 Apr 2006 11:10:40 -0400 +Received: from 70.22.235.105 by webmail.pas.earthlink.net with HTTP; + Wed, 26 Apr 2006 11:10:40 -0400 +Message-ID: + <9515919.1146064240401.JavaMail.root@elwamui-darkeyed.atl.sa.earthlink.net> +Date: Wed, 26 Apr 2006 11:10:40 -0400 (EDT) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: mark@mark.mielke.cc, pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: EarthLink Zoo Mail 1.0 +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc101e4a9e0c8888eea7b60fa35821d059350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 209.86.224.33 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=0.263 tagged_above=0 required=5 tests=AWL, BAYES_00, + SPF_HELO_SOFTFAIL, SPF_SOFTFAIL +X-Spam-Level: +X-Archive-Number: 200604/604 +X-Sequence-Number: 18688 + +Mea Culpa. There is a mistake in my example for SDR vs DDR vs DDR2. +This is what I get for posting before my morning coffee. + +The base latency for all of the memory types is that of the base clock rate; 200MHz= 5ns in my given examples. + +I double factored, making DDR and DDR2 worse than they actually are. + +Again, my apologies. +Ron + +-----Original Message----- +>From: Ron Peacetree +>Sent: Apr 26, 2006 8:40 AM +>To: mark@mark.mielke.cc, pgsql-performance@postgresql.org +>Subject: Re: [PERFORM] Large (8M) cache vs. dual-core CPUs +> +>I'm posting this to the entire performance list in the hopes that it will be generally useful. +>=r + +> +>Note also what happens when transferring the first datum after a lull period. +>For purposes of example, let's pretend that we are talking about a base clock rate of 200MHz= 5ns. +> +>The SDR still transfers data every 5ns no matter what. +>The DDR transfers the 1st datum in 10ns and then assuming there are at least 2 sequential datums to be >transferred will transfer the 2nd and subsequent sequential pieces of data every 2.5ns. +>The DDR2 transfers the 1st datum in 20ns and then assuming there are at least 4 sequential datums to be >transferred will transfer the 2nd and subsequent sequential pieces of data every 1.25ns. +> +=5= ns to first transfer in all 3 casess. Bad Ron. No Biscuit! + +> +>Thus we can see that randomly accessing RAM degrades performance significantly for DDR and DDR2. We can >also see that the conditions for optimal RAM performance become more restrictive as we go from SDR to DDR to >DDR2. +>The reason DDR2 with a low base clock rate excelled at tasks like streaming multimedia and stank at things like >small transaction OLTP DB applications is now apparent. +> +>Factors like CPU prefetching and victim buffers can muddy this picture a bit. +>Also, if the CPU's off die IO is slower than the RAM it is talking to, how fast that RAM is becomes unimportant. +> +These statements, and everything else I posted, are accurate. + +From pgsql-performance-owner@postgresql.org Wed Apr 26 12:13:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C87EC11F61E8 + for ; + Wed, 26 Apr 2006 12:13:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 32821-04 + for ; + Wed, 26 Apr 2006 12:13:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 2662711F60B5 + for ; + Wed, 26 Apr 2006 12:12:59 -0300 (ADT) +Received: (qmail 17169 invoked from network); 26 Apr 2006 17:13:26 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 26 Apr 2006 17:13:26 +0200 +Date: Wed, 26 Apr 2006 17:13:24 +0200 +To: "David Boreham" , pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> + <20060426005440.GA12711@mark.mielke.cc> + <20060426011701.GB12711@mark.mielke.cc> + <444F870D.2000307@boreham.org> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <444F870D.2000307@boreham.org> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/605 +X-Sequence-Number: 18689 + + + Have a look at this Wikipedia page which outlines some differences +between the AMD and Intel versions of 64-bit : + + http://en.wikipedia.org/wiki/EM64T + +> It isn't only Postgres. I work on a number of other server applications +> that also run much faster on Opterons than the published benchmark +> figures would suggest they should. They're all compiled with gcc4, +> so possibly there's a compiler issue. I don't run Windows on any +> of our Opteron boxes so I can't easily compare using the MS compiler. + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 12:18:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6902F11F60A2 + for ; + Wed, 26 Apr 2006 12:18:19 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33483-07 + for ; + Wed, 26 Apr 2006 12:18:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 3F8D111F60B1 + for ; + Wed, 26 Apr 2006 12:17:59 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 26 Apr 2006 15:17:58 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 26 Apr 2006 10:17:58 -0500 +Subject: Re: Large (8M) cache vs. dual-core CPUs +From: Scott Marlowe +To: "Jim C. Nasby" +Cc: Bill Moran , + pgsql-performance@postgresql.org +In-Reply-To: <20060425235504.GO97354@pervasive.com> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425235504.GO97354@pervasive.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1146064678.23538.252.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 26 Apr 2006 10:17:58 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/606 +X-Sequence-Number: 18690 + +On Tue, 2006-04-25 at 18:55, Jim C. Nasby wrote: +> On Tue, Apr 25, 2006 at 01:33:38PM -0500, Scott Marlowe wrote: +> > On Tue, 2006-04-25 at 13:14, Bill Moran wrote: +> > > I've been given the task of making some hardware recommendations for +> > > the next round of server purchases. The machines to be purchased +> > > will be running FreeBSD & PostgreSQL. +> > > +> > > Where I'm stuck is in deciding whether we want to go with dual-core +> > > pentiums with 2M cache, or with HT pentiums with 8M cache. +> > +> > Given a choice between those two processors, I'd choose the AMD 64 x 2 +> > CPU. It's a significantly better processor than either of the Intel +> > choices. And if you get the HT processor, you might as well turn of HT +> > on a PostgreSQL machine. I've yet to see it make postgresql run faster, +> > but I've certainly seen HT make it run slower. +> +> Actually, believe it or not, a coworker just saw HT double the +> performance of pgbench on his desktop machine. Granted, not really a +> representative test case, but it still blew my mind. This was with a +> database that fit in his 1G of memory, and running windows XP. Both +> cases were newly minted pgbench databases with a scale of 40. Testing +> was 40 connections and 100 transactions. With HT he saw 47.6 TPS, +> without it was 21.1. +> +> I actually had IT build put w2k3 server on a HT box specifically so I +> could do more testing. + +Just to clarify, this is PostgreSQL on Windows, right? + +I wonder if the latest Linux kernel can do that well... I'm guessing +that the kernel scheduler in Windows has had a lot of work to make it +good at scheduling on a HT architecture than the linux kernel has. + +From pgsql-performance-owner@postgresql.org Wed Apr 26 12:24:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1737411F6747 + for ; + Wed, 26 Apr 2006 12:24:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 36283-04-2 + for ; + Wed, 26 Apr 2006 12:24:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 0653311F671F + for ; + Wed, 26 Apr 2006 12:24:38 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id EBAFF3147B; Wed, 26 Apr 2006 17:24:37 +0200 (MET DST) +From: William Yu +X-Newsgroups: pgsql.performance +Subject: Re: Large (8M) cache vs. dual-core CPUs +Date: Wed, 26 Apr 2006 08:24:35 -0700 +Organization: Hub.Org Networking Services +Lines: 19 +Message-ID: +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> + <20060426005440.GA12711@mark.mielke.cc> + <20060426011701.GB12711@mark.mielke.cc> + <444F870D.2000307@boreham.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Thunderbird 1.5 (X11/20051201) +In-Reply-To: <444F870D.2000307@boreham.org> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=1.217 tagged_above=0 required=5 tests=BAYES_00, + SPF_HELO_SOFTFAIL, SPF_SOFTFAIL +X-Spam-Level: * +X-Archive-Number: 200604/607 +X-Sequence-Number: 18691 + +David Boreham wrote: +> It isn't only Postgres. I work on a number of other server applications +> that also run much faster on Opterons than the published benchmark +> figures would suggest they should. They're all compiled with gcc4, +> so possibly there's a compiler issue. I don't run Windows on any +> of our Opteron boxes so I can't easily compare using the MS compiler. + + +Maybe it's just a fact that the majority of x86 64-bit development for +open source software happens on Opteron/A64 machines. 64-bit AMD +machines were selling a good year before 64-bit Intel machines were +available. And even after Intel EMT64 were available, anybody in their +right mind would have picked AMD machines over Intel due to +cost/heat/performance. So you end up with 64-bit OSS being +developed/optimized for Opterons and the 10% running Intel EMT64 handle +compatibility issues. + +Would be interesting to see a survey of what machines OSS developers use +to write/test/optimize their code. + +From pgsql-performance-owner@postgresql.org Wed Apr 26 12:27:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E1F7411F60B5 + for ; + Wed, 26 Apr 2006 12:27:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38125-01 + for ; + Wed, 26 Apr 2006 12:27:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 94CF411F60B1 + for ; + Wed, 26 Apr 2006 12:27:19 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 26 Apr 2006 15:27:18 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 26 Apr 2006 10:27:18 -0500 +Subject: Re: Large (8M) cache vs. dual-core CPUs +From: Scott Marlowe +To: mark@mark.mielke.cc +Cc: Bill Moran , + pgsql-performance@postgresql.org +In-Reply-To: <20060426011701.GB12711@mark.mielke.cc> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> + <20060426005440.GA12711@mark.mielke.cc> + <20060426011701.GB12711@mark.mielke.cc> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1146065238.23538.261.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 26 Apr 2006 10:27:18 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/608 +X-Sequence-Number: 18692 + +On Tue, 2006-04-25 at 20:17, mark@mark.mielke.cc wrote: +> On Tue, Apr 25, 2006 at 08:54:40PM -0400, mark@mark.mielke.cc wrote: +> > I made the choice I describe based on a lot of research. I was going +> > to go both Intel, until I noticed that the Intel prices were dropping +> > fast. 30% price cut in 2 months. AMD didn't drop at all during the +> > same time. +> +> Errr.. big mistake. That was going to be - I was going to go both AMD. +> +> > There are plenty of reasons to choose one over the other. Generally +> > the AMD comes out on top. It is *not* 2X though. Anybody who claims +> > this is being highly selective about which benchmarks they consider. +> +> I have an Intel Pentium D 920, and an AMD X2 3800+. These are very +> close in performance. The retail price difference is: +> +> Intel Pentium D 920 is selling for $310 CDN +> AMD X2 3800+ is selling for $347 CDN + +Let me be clear. The performance difference between those boxes running +the latest first person shooter is not what I was alluding to in my +first post. While the price of the Intel's may have dropped, there's a +huge difference (often 2x or more) in performance when running +PostgreSQL on otherwise similar chips from Intel and AMD. + +Note that my workstation at work, my workstation at home, and my laptop +are all intel based machines. They work fine for that. But if I needed +to build a big fast oracle or postgresql server, I'd almost certainly go +with the AMD, especially so if I needed >2 cores, where the performance +difference becomes greater and greater. + +You'd likely find that for PostgreSQL, the slowest dual core AMDs out +would still beat the fasted Intel Dual cores, because of the issue we've +seen on the list with context switching storms. + +If you haven't actually run a heavy benchmark of postgresql on the two +architectures, please don't make your decision based on other +benchmarks. Since you've got both a D920 and an X2 3800, that'd be a +great place to start. Mock up some benchmark with a couple dozen +threads hitting the server at once and see if the Intel can keep up. It +should do OK, but not great. If you can get your hands on a dual +dual-core setup for either, you should really start to see the advantage +going to AMD, and by the time you get to a quad dual core setup, it +won't even be a contest. + +From pgsql-performance-owner@postgresql.org Wed Apr 26 17:08:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 34AC411F6228 + for ; + Wed, 26 Apr 2006 17:08:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 00391-05 + for ; + Wed, 26 Apr 2006 17:08:26 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.226]) + by postgresql.org (Postfix) with ESMTP id 77FC111F60AE + for ; + Wed, 26 Apr 2006 17:08:25 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so1452091wra + for ; + Wed, 26 Apr 2006 13:08:24 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; + b=HD5AGzDLjFkP7wGKwvMDBmHFD01UYwq0LCBkDWnAZHyczPQfjW+fnxrN3oiLc7fCmvpelyVpoH3uR/PW6VaPw8WpS1Cm2r56KOJVNNbASQoRX9PY/9UcSVZXqepESCRII9b6c8Utz0VrO03SJOF8jJURR4c1bucjzUoO/oRnjNc= +Received: by 10.54.110.13 with SMTP id i13mr5144772wrc; + Wed, 26 Apr 2006 13:08:24 -0700 (PDT) +Received: from ?172.27.173.172? ( [66.194.95.2]) + by mx.gmail.com with ESMTP id 39sm447866wrl.2006.04.26.13.08.23; + Wed, 26 Apr 2006 13:08:24 -0700 (PDT) +Subject: Re: Introducing a new linux readahead framework +From: Steve Poe +To: Wu Fengguang +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060421013826.GA5217@mail.ustc.edu.cn> +References: <20060421013826.GA5217@mail.ustc.edu.cn> +Content-Type: text/plain +Date: Wed, 26 Apr 2006 15:08:59 -0500 +Message-Id: <1146082140.11414.14.camel@amd64-gentoo-laptop> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.2.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/609 +X-Sequence-Number: 18693 + +I found an average 14% improvement Using Pg 7.4.11 with odbc-bench as my +test bed with Wu's kernel patch. I have not tried version 8.x yet. + +Thanks Wu. + +Steve Poe + +Using Postgresql 7.4.11, on an dual Opteron with 4GB + +On Fri, 2006-04-21 at 09:38 +0800, Wu Fengguang wrote: +> Greetings, +> +> I'd like to introduce a new readahead framework for the linux kernel: +> http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1021.html +> +> HOW IT WORKS +> +> In adaptive readahead, the context based method may be of particular +> interest to postgresql users. It works by peeking into the file cache +> and check if there are any history pages present or accessed. In this +> way it can detect almost all forms of sequential / semi-sequential read +> patterns, e.g. +> - parallel / interleaved sequential scans on one file +> - sequential reads across file open/close +> - mixed sequential / random accesses +> - sparse / skimming sequential read +> +> It also have methods to detect some less common cases: +> - reading backward +> - seeking all over reading N pages +> +> WAYS TO BENEFIT FROM IT +> +> As we know, postgresql relies on the kernel to do proper readahead. +> The adaptive readahead might help performance in the following cases: +> - concurrent sequential scans +> - sequential scan on a fragmented table +> (some DBs suffer from this problem, not sure for pgsql) +> - index scan with clustered matches +> - index scan on majority rows (in case the planner goes wrong) +> +> TUNABLE PARAMETERS +> +> There are two parameters which are described in this email: +> http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1024.html +> +> Here are the more oriented guidelines for postgresql users: +> +> - /proc/sys/vm/readahead_ratio +> Since most DB servers are bounty of memory, the danger of readahead +> thrashing is near to zero. In this case, you can set readahead_ratio to +> 100(or even 200:), which helps the readahead window to scale up rapidly. +> +> - /proc/sys/vm/readahead_hit_rate +> Sparse sequential reads are read patterns like {0, 2, 4, 5, 8, 11, ...}. +> In this case we might prefer to do readahead to get good I/O performance +> with the overhead of some useless pages. But if you prefer not to do so, +> set readahead_hit_rate to 1 will disable this feature. +> +> - /sys/block/sd/queue/read_ahead_kb +> Set it to a large value(e.g. 4096) as you used to do. +> RAID users might want to use a bigger number. +> +> TRYING IT OUT +> +> The latest patch for stable kernels can be downloaded here: +> http://www.vanheusden.com/ara/ +> +> Before compiling, make sure that the following options are enabled: +> Processor type and features -> Adaptive file readahead +> Processor type and features -> Readahead debug and accounting +> +> HELPING AND CONTRIBUTING +> +> The patch is open to fine-tuning advices :) +> Comments and benchmarking results are highly appreciated. +> +> Thanks, +> Wu +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 19:09:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0A68E11F6228 + for ; + Wed, 26 Apr 2006 19:09:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 37289-01 + for ; + Wed, 26 Apr 2006 19:09:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B381711F6236 + for ; + Wed, 26 Apr 2006 19:09:30 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 292FE56435; Wed, 26 Apr 2006 17:09:30 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 26 Apr 2006 17:09:29 -0500 +Date: Wed, 26 Apr 2006 17:09:29 -0500 +From: "Jim C. Nasby" +To: Scott Marlowe +Cc: mark@mark.mielke.cc, Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060426220929.GY97354@pervasive.com> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425183817.GA9241@mark.mielke.cc> + <1145990551.23538.244.camel@state.g2switchworks.com> + <20060426005440.GA12711@mark.mielke.cc> + <20060426011701.GB12711@mark.mielke.cc> + <1146065238.23538.261.camel@state.g2switchworks.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1146065238.23538.261.camel@state.g2switchworks.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060426:smarlowe@g2switchworks.com::pvYov70doGXUKNSt:00000000000 + 0000000000000000000000002MeT +X-Hashcash: + 1:20:060426:mark@mark.mielke.cc::NRshrpW+exZWS8Gj:000000000000000000 + 0000000000000000000000000hCm +X-Hashcash: + 1:20:060426:wmoran@collaborativefusion.com::AGYfdiuGXALmNtfs:0000000 + 0000000000000000000000000krR +X-Hashcash: + 1:20:060426:pgsql-performance@postgresql.org::a0fOKHjlIy0eXAV3:00000 + 0000000000000000000000002ia8 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/610 +X-Sequence-Number: 18694 + +On Wed, Apr 26, 2006 at 10:27:18AM -0500, Scott Marlowe wrote: +> If you haven't actually run a heavy benchmark of postgresql on the two +> architectures, please don't make your decision based on other +> benchmarks. Since you've got both a D920 and an X2 3800, that'd be a +> great place to start. Mock up some benchmark with a couple dozen +> threads hitting the server at once and see if the Intel can keep up. It + +Or better yet, use dbt* or even pgbench so others can reproduce... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 26 19:15:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 79C4811F6228 + for ; + Wed, 26 Apr 2006 19:15:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 36856-02 + for ; + Wed, 26 Apr 2006 19:14:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 0C13911F620C + for ; + Wed, 26 Apr 2006 19:14:48 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 651DC56427; Wed, 26 Apr 2006 17:14:48 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 26 Apr 2006 17:14:47 -0500 +Date: Wed, 26 Apr 2006 17:14:47 -0500 +From: "Jim C. Nasby" +To: Scott Marlowe +Cc: Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060426221447.GZ97354@pervasive.com> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <1145990018.23538.234.camel@state.g2switchworks.com> + <20060425235504.GO97354@pervasive.com> + <1146064678.23538.252.camel@state.g2switchworks.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1146064678.23538.252.camel@state.g2switchworks.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060426:smarlowe@g2switchworks.com::EAiPxJTsbk6Pn3vS:00000000000 + 0000000000000000000000002EAI +X-Hashcash: + 1:20:060426:wmoran@collaborativefusion.com::tp0sVnq13n0gz1ba:0000000 + 0000000000000000000000003t2U +X-Hashcash: + 1:20:060426:pgsql-performance@postgresql.org::WCE0FM07Iu9ihLQG:00000 + 0000000000000000000000005sHR +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/611 +X-Sequence-Number: 18695 + +On Wed, Apr 26, 2006 at 10:17:58AM -0500, Scott Marlowe wrote: +> On Tue, 2006-04-25 at 18:55, Jim C. Nasby wrote: +> > On Tue, Apr 25, 2006 at 01:33:38PM -0500, Scott Marlowe wrote: +> > > On Tue, 2006-04-25 at 13:14, Bill Moran wrote: +> > > > I've been given the task of making some hardware recommendations for +> > > > the next round of server purchases. The machines to be purchased +> > > > will be running FreeBSD & PostgreSQL. +> > > > +> > > > Where I'm stuck is in deciding whether we want to go with dual-core +> > > > pentiums with 2M cache, or with HT pentiums with 8M cache. +> > > +> > > Given a choice between those two processors, I'd choose the AMD 64 x 2 +> > > CPU. It's a significantly better processor than either of the Intel +> > > choices. And if you get the HT processor, you might as well turn of HT +> > > on a PostgreSQL machine. I've yet to see it make postgresql run faster, +> > > but I've certainly seen HT make it run slower. +> > +> > Actually, believe it or not, a coworker just saw HT double the +> > performance of pgbench on his desktop machine. Granted, not really a +> > representative test case, but it still blew my mind. This was with a +> > database that fit in his 1G of memory, and running windows XP. Both +> > cases were newly minted pgbench databases with a scale of 40. Testing +> > was 40 connections and 100 transactions. With HT he saw 47.6 TPS, +> > without it was 21.1. +> > +> > I actually had IT build put w2k3 server on a HT box specifically so I +> > could do more testing. +> +> Just to clarify, this is PostgreSQL on Windows, right? +> +> I wonder if the latest Linux kernel can do that well... I'm guessing +> that the kernel scheduler in Windows has had a lot of work to make it +> good at scheduling on a HT architecture than the linux kernel has. + +Yes, this is on Windows XP. Larry might also have a HT box with some +other OS on it we can check with (though I suspect that maybe that's +been beaten to death...) +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 26 19:16:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5782211F6223 + for ; + Wed, 26 Apr 2006 19:16:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40655-02 + for ; + Wed, 26 Apr 2006 19:16:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 7C07D11F628C + for ; + Wed, 26 Apr 2006 19:16:33 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id B186D56423; Wed, 26 Apr 2006 17:16:33 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 26 Apr 2006 17:16:31 -0500 +Date: Wed, 26 Apr 2006 17:16:31 -0500 +From: "Jim C. Nasby" +To: Ron Peacetree +Cc: mark@mark.mielke.cc, Scott Marlowe , + Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060426221631.GA97354@pervasive.com> +References: + <8991088.1146020837420.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: + <8991088.1146020837420.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060426:rjpeace@earthlink.net::/J+ct5xuUu7MwOsu:0000000000000000 + 0000000000000000000000003T1q +X-Hashcash: + 1:20:060426:mark@mark.mielke.cc::3FUZHiVDPHysPRNh:000000000000000000 + 0000000000000000000000000qeA +X-Hashcash: + 1:20:060426:smarlowe@g2switchworks.com::QCZsAhL3JkJ8NMah:00000000000 + 0000000000000000000000002CbS +X-Hashcash: + 1:20:060426:wmoran@collaborativefusion.com::KJyB8Rs6KSxyT7Jr:0000000 + 000000000000000000000000G3DU +X-Hashcash: + 1:20:060426:pgsql-performance@postgresql.org::712UEAit4ob6LeMK:00000 + 0000000000000000000000004D95 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/612 +X-Sequence-Number: 18696 + +On Tue, Apr 25, 2006 at 11:07:17PM -0400, Ron Peacetree wrote: +> A minor point to be noted in addition here is that most DB servers under load are limited by their physical IO subsystem, their HDs, and not the speed of their RAM. + +I think if that were the only consideration we wouldn't be seeing such a +dramatic difference between AMD and Intel though. Even in a disk-bound +server, caching is going to have a tremendous impact, and that's +essentially entirely bound by memory bandwith and latency. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 26 19:17:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3A92111F6240 + for ; + Wed, 26 Apr 2006 19:17:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40655-03 + for ; + Wed, 26 Apr 2006 19:16:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 4E5CA11F6228 + for ; + Wed, 26 Apr 2006 19:16:47 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k3QMGkk15952; + Wed, 26 Apr 2006 18:16:46 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200604262216.k3QMGkk15952@candle.pha.pa.us> +Subject: Re: Large (8M) cache vs. dual-core CPUs +In-Reply-To: <20060426220929.GY97354@pervasive.com> +To: "Jim C. Nasby" +Date: Wed, 26 Apr 2006 18:16:46 -0400 (EDT) +CC: Scott Marlowe , mark@mark.mielke.cc, + Bill Moran , + pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/613 +X-Sequence-Number: 18697 + +Jim C. Nasby wrote: +> On Wed, Apr 26, 2006 at 10:27:18AM -0500, Scott Marlowe wrote: +> > If you haven't actually run a heavy benchmark of postgresql on the two +> > architectures, please don't make your decision based on other +> > benchmarks. Since you've got both a D920 and an X2 3800, that'd be a +> > great place to start. Mock up some benchmark with a couple dozen +> > threads hitting the server at once and see if the Intel can keep up. It +> +> Or better yet, use dbt* or even pgbench so others can reproduce... + +For why Opterons are superior to Intel for PostgreSQL, see: + + http://techreport.com/reviews/2005q2/opteron-x75/index.x?pg=2 + +Section "MESI-MESI-MOESI Banana-fana...". Specifically, this part about +the Intel implementation: + + The processor with the Invalid data in its cache (CPU 0, let's say) + might then wish to modify that chunk of data, but it could not do so + while the only valid copy of the data is in the cache of the other + processor (CPU 1). Instead, CPU 0 would have to wait until CPU 1 wrote + the modified data back to main memory before proceeding.and that takes + time, bus bandwidth, and memory bandwidth. This is the great drawback of + MESI. + +AMD transfers the dirty cache line directly from cpu to cpu. I can +imaging that helping our test-and-set shared memory usage quite a bit. + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 19:25:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8A76C11F60E3 + for ; + Wed, 26 Apr 2006 19:25:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 34338-04 + for ; + Wed, 26 Apr 2006 19:25:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id CA48411F60AE + for ; + Wed, 26 Apr 2006 19:24:58 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 664CA56423; Wed, 26 Apr 2006 17:24:58 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 26 Apr 2006 17:24:57 -0500 +Date: Wed, 26 Apr 2006 17:24:57 -0500 +From: "Jim C. Nasby" +To: mark@mark.mielke.cc +Cc: Ron Peacetree , + Scott Marlowe , + Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060426222456.GB97354@pervasive.com> +References: + <8991088.1146020837420.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> + <20060426064852.GA16879@mark.mielke.cc> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060426064852.GA16879@mark.mielke.cc> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060426:mark@mark.mielke.cc::PocIXakYwn2/oIkL:000000000000000000 + 0000000000000000000000000lev +X-Hashcash: + 1:20:060426:rjpeace@earthlink.net::e/OTybcsZ590A7H5:0000000000000000 + 0000000000000000000000005vpM +X-Hashcash: + 1:20:060426:smarlowe@g2switchworks.com::9a+Fcwr1NxLKRpI8:00000000000 + 0000000000000000000000002w2l +X-Hashcash: + 1:20:060426:wmoran@collaborativefusion.com::7L4tPA+plp0MqDXv:0000000 + 0000000000000000000000001WNH +X-Hashcash: + 1:20:060426:pgsql-performance@postgresql.org::jVr/D2s3JHH9aQOC:00000 + 0000000000000000000000002bSM +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/614 +X-Sequence-Number: 18698 + +On Wed, Apr 26, 2006 at 02:48:53AM -0400, mark@mark.mielke.cc wrote: +> You said that DB accesses are random. I'm not so sure. In PostgreSQL, +> are not the individual pages often scanned sequentially, especially +> because all records are variable length? You don't think PostgreSQL +> will regularly read 32 bytes (8 bytes x 4) at a time, in sequence? +> Whether for table pages, or index pages - I'm not seeing why the +> accesses wouldn't be sequential. You believe PostgreSQL will access +> the table pages and index pages randomly on a per-byte basis? What +> is the minimum PostgreSQL record size again? Isn't it 32 bytes or +> over? :-) + +Data within a page can absolutely be accessed randomly; it would be +horribly inefficient to slog through 8K of data every time you needed to +find a single row. + +The header size of tuples is ~23 bytes, depending on your version of +PostgreSQL, and data fields have to start on the proper alignment +(generally 4 bytes). So essentially the smallest row you can get is 28 +bytes. + +I know that tuple headers are dealt with as a C structure, but I don't +know if that means accessing any of the header costs the same as +accessing the whole thing. I don't know if PostgreSQL can access fields +within tuples without having to scan through at least the first part of +preceeding fields, though I suspect that it can access fixed-width +fields that sit before any varlena fields directly (without scanning +through the other fields). + +If we ever got to the point of divorcing the in-memory tuple layout from +the table layout it'd be interesting to experiment with having all +varlena length info stored immediately after all fixed-width fields; +that could potentially make accessing varlena's randomly faster. Note +that null fields are indicated as such in the null bitmap, so I'm pretty +sure that their in-tuple position doesn't matter much. Of course if you +want the definitive answer, Use The Source. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 26 19:29:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6473211F60B1 + for ; + Wed, 26 Apr 2006 19:29:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31351-10 + for ; + Wed, 26 Apr 2006 19:29:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 92E8211F60AE + for ; + Wed, 26 Apr 2006 19:28:58 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 8A8DF56423; Wed, 26 Apr 2006 17:28:58 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 26 Apr 2006 17:28:56 -0500 +Date: Wed, 26 Apr 2006 17:28:56 -0500 +From: "Jim C. Nasby" +To: Steve Poe , bizgres-general@pgfoundry.org +Cc: Wu Fengguang , pgsql-performance@postgresql.org +Subject: Re: Introducing a new linux readahead framework +Message-ID: <20060426222855.GC97354@pervasive.com> +References: <20060421013826.GA5217@mail.ustc.edu.cn> + <1146082140.11414.14.camel@amd64-gentoo-laptop> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1146082140.11414.14.camel@amd64-gentoo-laptop> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060426:steve.poe@gmail.com::zRGkH/YdNjbFk3Ub:000000000000000000 + 0000000000000000000000000xQ6 +X-Hashcash: + 1:20:060426:bizgres-general@pgfoundry.org::mwDEyrDFumTEMadD:00000000 + 000000000000000000000000MRPB +X-Hashcash: + 1:20:060426:wfg@mail.ustc.edu.cn::CpeQNugui5XgJEP1:00000000000000000 + 00000000000000000000000044Eo +X-Hashcash: + 1:20:060426:pgsql-performance@postgresql.org::5deflESmwVjbkrx9:00000 + 0000000000000000000000003sUr +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/615 +X-Sequence-Number: 18699 + +(including bizgres-general) + +Has anyone done any testing on bizgres? It's got some patches that +eliminate a lot of IO bottlenecks, so it might present even larger +gains. + +On Wed, Apr 26, 2006 at 03:08:59PM -0500, Steve Poe wrote: +> I found an average 14% improvement Using Pg 7.4.11 with odbc-bench as my +> test bed with Wu's kernel patch. I have not tried version 8.x yet. +> +> Thanks Wu. +> +> Steve Poe +> +> Using Postgresql 7.4.11, on an dual Opteron with 4GB +> +> On Fri, 2006-04-21 at 09:38 +0800, Wu Fengguang wrote: +> > Greetings, +> > +> > I'd like to introduce a new readahead framework for the linux kernel: +> > http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1021.html +> > +> > HOW IT WORKS +> > +> > In adaptive readahead, the context based method may be of particular +> > interest to postgresql users. It works by peeking into the file cache +> > and check if there are any history pages present or accessed. In this +> > way it can detect almost all forms of sequential / semi-sequential read +> > patterns, e.g. +> > - parallel / interleaved sequential scans on one file +> > - sequential reads across file open/close +> > - mixed sequential / random accesses +> > - sparse / skimming sequential read +> > +> > It also have methods to detect some less common cases: +> > - reading backward +> > - seeking all over reading N pages +> > +> > WAYS TO BENEFIT FROM IT +> > +> > As we know, postgresql relies on the kernel to do proper readahead. +> > The adaptive readahead might help performance in the following cases: +> > - concurrent sequential scans +> > - sequential scan on a fragmented table +> > (some DBs suffer from this problem, not sure for pgsql) +> > - index scan with clustered matches +> > - index scan on majority rows (in case the planner goes wrong) +> > +> > TUNABLE PARAMETERS +> > +> > There are two parameters which are described in this email: +> > http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1024.html +> > +> > Here are the more oriented guidelines for postgresql users: +> > +> > - /proc/sys/vm/readahead_ratio +> > Since most DB servers are bounty of memory, the danger of readahead +> > thrashing is near to zero. In this case, you can set readahead_ratio to +> > 100(or even 200:), which helps the readahead window to scale up rapidly. +> > +> > - /proc/sys/vm/readahead_hit_rate +> > Sparse sequential reads are read patterns like {0, 2, 4, 5, 8, 11, ...}. +> > In this case we might prefer to do readahead to get good I/O performance +> > with the overhead of some useless pages. But if you prefer not to do so, +> > set readahead_hit_rate to 1 will disable this feature. +> > +> > - /sys/block/sd/queue/read_ahead_kb +> > Set it to a large value(e.g. 4096) as you used to do. +> > RAID users might want to use a bigger number. +> > +> > TRYING IT OUT +> > +> > The latest patch for stable kernels can be downloaded here: +> > http://www.vanheusden.com/ara/ +> > +> > Before compiling, make sure that the following options are enabled: +> > Processor type and features -> Adaptive file readahead +> > Processor type and features -> Readahead debug and accounting +> > +> > HELPING AND CONTRIBUTING +> > +> > The patch is open to fine-tuning advices :) +> > Comments and benchmarking results are highly appreciated. +> > +> > Thanks, +> > Wu +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 4: Have you searched our list archives? +> > +> > http://archives.postgresql.org +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed Apr 26 19:37:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9B42411F6315 + for ; + Wed, 26 Apr 2006 19:37:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 54223-01 + for ; + Wed, 26 Apr 2006 19:37:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B6EE411F6275 + for ; + Wed, 26 Apr 2006 19:37:33 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 4EDB156423; Wed, 26 Apr 2006 17:37:33 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 26 Apr 2006 17:37:31 -0500 +Date: Wed, 26 Apr 2006 17:37:31 -0500 +From: "Jim C. Nasby" +To: Bruce Momjian +Cc: Scott Marlowe , mark@mark.mielke.cc, + Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060426223731.GE97354@pervasive.com> +References: <20060426220929.GY97354@pervasive.com> + <200604262216.k3QMGkk15952@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200604262216.k3QMGkk15952@candle.pha.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060426:pgman@candle.pha.pa.us::xiaDS0Yk1PQ9W8nr:000000000000000 + 0000000000000000000000003mwC +X-Hashcash: + 1:20:060426:smarlowe@g2switchworks.com::eGuo5LvF5/QxXhHz:00000000000 + 0000000000000000000000007t3A +X-Hashcash: + 1:20:060426:mark@mark.mielke.cc::SgA0/l1OZ3yF/NmC:000000000000000000 + 00000000000000000000000005ee +X-Hashcash: + 1:20:060426:wmoran@collaborativefusion.com::tfDTca7Wpo2sF+Ng:0000000 + 0000000000000000000000007FhP +X-Hashcash: + 1:20:060426:pgsql-performance@postgresql.org::8hogssmu3+Nw7Ag3:00000 + 0000000000000000000000005rTd +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/616 +X-Sequence-Number: 18700 + +On Wed, Apr 26, 2006 at 06:16:46PM -0400, Bruce Momjian wrote: +> Jim C. Nasby wrote: +> > On Wed, Apr 26, 2006 at 10:27:18AM -0500, Scott Marlowe wrote: +> > > If you haven't actually run a heavy benchmark of postgresql on the two +> > > architectures, please don't make your decision based on other +> > > benchmarks. Since you've got both a D920 and an X2 3800, that'd be a +> > > great place to start. Mock up some benchmark with a couple dozen +> > > threads hitting the server at once and see if the Intel can keep up. It +> > +> > Or better yet, use dbt* or even pgbench so others can reproduce... +> +> For why Opterons are superior to Intel for PostgreSQL, see: +> +> http://techreport.com/reviews/2005q2/opteron-x75/index.x?pg=2 +> +> Section "MESI-MESI-MOESI Banana-fana...". Specifically, this part about +> the Intel implementation: +> +> The processor with the Invalid data in its cache (CPU 0, let's say) +> might then wish to modify that chunk of data, but it could not do so +> while the only valid copy of the data is in the cache of the other +> processor (CPU 1). Instead, CPU 0 would have to wait until CPU 1 wrote +> the modified data back to main memory before proceeding.and that takes +> time, bus bandwidth, and memory bandwidth. This is the great drawback of +> MESI. +> +> AMD transfers the dirty cache line directly from cpu to cpu. I can +> imaging that helping our test-and-set shared memory usage quite a bit. + +Wasn't the whole point of test-and-set that it's the recommended way to +do lightweight spinlocks according to AMD/Intel? You'd think they'd have +a way to make that performant on multiple CPUs (though if it's relying +on possibly modifying an underlying data page I can't really think of +how to do that without snaking through the cache...) +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-patches-owner@postgresql.org Wed Apr 26 20:04:13 2006 +X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B058C11F60A2; + Wed, 26 Apr 2006 20:02:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50838-07; Wed, 26 Apr 2006 20:02:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 99CB611F60AE; + Wed, 26 Apr 2006 20:02:35 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k3QN2YW23329; + Wed, 26 Apr 2006 19:02:34 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200604262302.k3QN2YW23329@candle.pha.pa.us> +Subject: Re: [PERFORM] WAL logging of SELECT ... INTO command +In-Reply-To: +To: Kris Jurka +Date: Wed, 26 Apr 2006 19:02:34 -0400 (EDT) +CC: "Jim C. Nasby" , + Simon Riggs , + pgsql-performance@postgresql.org, pgsql-patches@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/216 +X-Sequence-Number: 19488 + + +Backpatched to 8.0.X and 8.1.X. + +--------------------------------------------------------------------------- + +Kris Jurka wrote: +> +> +> On Fri, 24 Mar 2006, Jim C. Nasby wrote: +> +> > On Wed, Mar 22, 2006 at 02:37:28PM -0500, Kris Jurka wrote: +> >> +> >> On Wed, 22 Mar 2006, Jim C. Nasby wrote: +> >> +> >>> Ok, I saw disk activity on the base directory and assumed it was pg_xlog +> >>> stuff. Turns out that both SELECT INTO and CREATE TABLE AS ignore +> >>> default_tablepsace and create the new tables in the base directory. I'm +> >>> guessing that's a bug... (this is on 8.1.2, btw). +> >> +> >> This has been fixed in CVS HEAD as part of a patch to allow additional +> >> options to CREATE TABLE AS. +> >> +> >> http://archives.postgresql.org/pgsql-patches/2006-02/msg00211.php +> > +> > I'll argue that the current behavior is still a bug and should be fixed. +> > Would it be difficult to patch 8.1 (and 8.0 if there were tablespaces +> > then...) to honor default_tablespace? +> +> Here are patches that fix this for 8.0 and 8.1. +> +> Kris Jurka + +Content-Description: + +[ Attachment, skipping... ] + +Content-Description: + +[ Attachment, skipping... ] + +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 20:34:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B03E711F6832 + for ; + Wed, 26 Apr 2006 20:34:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 04167-02 + for ; + Wed, 26 Apr 2006 20:33:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id BEB6F11F685A + for ; + Wed, 26 Apr 2006 20:33:54 -0300 (ADT) +Received: from 172.16.1.112 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Wed, 26 Apr 2006 19:33:44 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 26 Apr + 2006 19:33:44 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.118]) with Microsoft Exchange Server HTTP-DAV ; Wed, 26 Apr + 2006 23:33:44 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 26 Apr 2006 16:33:40 -0700 +Subject: Re: [Bizgres-general] Introducing a new linux +From: "Luke Lonergan" +To: "Jim C. Nasby" , "Steve Poe" , + "bizgres-general" +cc: pgsql-performance@postgresql.org, + "Wu Fengguang" +Message-ID: +Thread-Topic: [Bizgres-general] [PERFORM] Introducing a new linux + readahead framework +Thread-Index: AcZpgOwmZtCPuHK5QveaI8Ih0syZkAACOztn +In-Reply-To: <20060426222855.GC97354@pervasive.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 26 Apr 2006 23:33:44.0668 (UTC) + FILETIME=[DBDBA9C0:01C66989] +X-WSS-ID: 684EDCD22XS52494611-01-01 +Content-Type: multipart/alternative; + boundary=B_3228914020_4686675 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/618 +X-Sequence-Number: 18702 + +> This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--B_3228914020_4686675 +Content-Type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + +Jim, + +I=B9m thinking about it, we=B9re already using a fixed read-ahead of 16MB using +blockdev on the stock Redhat 2.6.9 kernel, it would be nice to not have to +set this so we may try it. + +- Luke=20 + + +On 4/26/06 3:28 PM, "Jim C. Nasby" wrote: + +> (including bizgres-general) +>=20 +> Has anyone done any testing on bizgres? It's got some patches that +> eliminate a lot of IO bottlenecks, so it might present even larger +> gains. +>=20 +> On Wed, Apr 26, 2006 at 03:08:59PM -0500, Steve Poe wrote: +>> > I found an average 14% improvement Using Pg 7.4.11 with odbc-bench as = +my +>> > test bed with Wu's kernel patch. I have not tried version 8.x yet. +>> > +>> > Thanks Wu.=20 +>> > +>> > Steve Poe +>> > +>> > Using Postgresql 7.4.11, on an dual Opteron with 4GB +>> > +>> > On Fri, 2006-04-21 at 09:38 +0800, Wu Fengguang wrote: +>>> > > Greetings, +>>> > > +>>> > > I'd like to introduce a new readahead framework for the linux kerne= +l: +>>> > > http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1021.html +>>> > > +>>> > > HOW IT WORKS +>>> > > +>>> > > In adaptive readahead, the context based method may be of particula= +r +>>> > > interest to postgresql users. It works by peeking into the file cac= +he +>>> > > and check if there are any history pages present or accessed. In th= +is +>>> > > way it can detect almost all forms of sequential / semi-sequential = +read +>>> > > patterns, e.g. +>>> > > - parallel / interleaved sequential scans on one file +>>> > > - sequential reads across file open/close +>>> > > - mixed sequential / random accesses +>>> > > - sparse / skimming sequential read +>>> > > +>>> > > It also have methods to detect some less common cases: +>>> > > - reading backward +>>> > > - seeking all over reading N pages +>>> > > +>>> > > WAYS TO BENEFIT FROM IT +>>> > > +>>> > > As we know, postgresql relies on the kernel to do proper readahead. +>>> > > The adaptive readahead might help performance in the following case= +s: +>>> > > - concurrent sequential scans +>>> > > - sequential scan on a fragmented table +>>> > > (some DBs suffer from this problem, not sure for pgsql) +>>> > > - index scan with clustered matches +>>> > > - index scan on majority rows (in case the planner goes wrong) +>>> > > +>>> > > TUNABLE PARAMETERS +>>> > > +>>> > > There are two parameters which are described in this email: +>>> > > http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1024.html +>>> > > +>>> > > Here are the more oriented guidelines for postgresql users: +>>> > > +>>> > > - /proc/sys/vm/readahead_ratio +>>> > > Since most DB servers are bounty of memory, the danger of readahead +>>> > > thrashing is near to zero. In this case, you can set readahead_rati= +o to +>>> > > 100(or even 200:), which helps the readahead window to scale up rap= +idly. +>>> > > +>>> > > - /proc/sys/vm/readahead_hit_rate +>>> > > Sparse sequential reads are read patterns like {0, 2, 4, 5, 8, 11, = +...}. +>>> > > In this case we might prefer to do readahead to get good I/O perfor= +mance +>>> > > with the overhead of some useless pages. But if you prefer not to d= +o so, +>>> > > set readahead_hit_rate to 1 will disable this feature. +>>> > > +>>> > > - /sys/block/sd/queue/read_ahead_kb +>>> > > Set it to a large value(e.g. 4096) as you used to do. +>>> > > RAID users might want to use a bigger number. +>>> > > +>>> > > TRYING IT OUT +>>> > > +>>> > > The latest patch for stable kernels can be downloaded here: +>>> > > http://www.vanheusden.com/ara/ +>>> > > +>>> > > Before compiling, make sure that the following options are enabled: +>>> > > Processor type and features -> Adaptive file readahead +>>> > > Processor type and features -> Readahead debug and accounting +>>> > > +>>> > > HELPING AND CONTRIBUTING +>>> > > +>>> > > The patch is open to fine-tuning advices :) +>>> > > Comments and benchmarking results are highly appreciated. +>>> > > +>>> > > Thanks, +>>> > > Wu +>>> > > +>>> > > ---------------------------(end of broadcast)----------------------= +----- +>>> > > TIP 4: Have you searched our list archives? +>>> > > +>>> > > http://archives.postgresql.org +>> > +>> > +>> > ---------------------------(end of broadcast)-------------------------= +-- +>> > TIP 4: Have you searched our list archives? +>> > +>> > http://archives.postgresql.org +>> > +>=20 +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> _______________________________________________ +> Bizgres-general mailing list +> Bizgres-general@pgfoundry.org +> http://pgfoundry.org/mailman/listinfo/bizgres-general +>=20 +>=20 + + + +--B_3228914020_4686675 +Content-Type: text/html; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + +Re: [Bizgres-general] [PERFORM] Introducing a new linux readahead fr= +amework + + +Jim,<= +BR> +
+I’m thinking about it, we’re already using a fixed read-ahead o= +f 16MB using blockdev on the stock Redhat 2.6.9 kernel, it would be nice to = +not have to set this so we may try it.
+
+- Luke
+
+
+On 4/26/06 3:28 PM, "Jim C. Nasby" <jnasby@pervasive.com> w= +rote:
+
+
(including bizgres-general)
+
+Has anyone done any testing on bizgres? It's got some patches that
+eliminate a lot of IO bottlenecks, so it might present even larger
+gains.
+
+On Wed, Apr 26, 2006 at 03:08:59PM -0500, Steve Poe wrote:
+> I found an average 14% improvement Using Pg 7.4.11 with odbc-bench as = +my
+> test bed with Wu's kernel patch. I have not tried version 8.x yet.
+>
+> Thanks Wu.
+>
+> Steve Poe
+>
+> Using Postgresql 7.4.11, on an dual Opteron with 4GB
+>
+> On Fri, 2006-04-21 at 09:38 +0800, Wu Fengguang wrote:
+> > Greetings,
+> >
+> > I'd like to introduce a new readahead framework for the linux ker= +nel:
+> > http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1021.html +> >
+> > HOW IT WORKS
+> >
+> > In adaptive readahead, the context based method may be of particu= +lar
+> > interest to postgresql users. It works by peeking into the file c= +ache
+> > and check if there are any history pages present or accessed. In = +this
+> > way it can detect almost all forms of sequential / semi-sequentia= +l read
+> > patterns, e.g.
+> >     - parallel / interleaved sequential scans= + on one file
+> >     - sequential reads across file open/close= +
+> >     - mixed sequential / random accesses
+> >     - sparse / skimming sequential read
+> >
+> > It also have methods to detect some less common cases:
+> >     - reading backward
+> >     - seeking all over reading N pages
+> >
+> > WAYS TO BENEFIT FROM IT
+> >
+> > As we know, postgresql relies on the kernel to do proper readahea= +d.
+> > The adaptive readahead might help performance in the following ca= +ses:
+> >     - concurrent sequential scans
+> >     - sequential scan on a fragmented table +> >       (some DBs suffer from this pr= +oblem, not sure for pgsql)
+> >     - index scan with clustered matches
+> >     - index scan on majority rows (in case th= +e planner goes wrong)
+> >
+> > TUNABLE PARAMETERS
+> >
+> > There are two parameters which are described in this email:
+> > http://www.ussg.iu.edu/hypermail/linux/kernel/0603.2/1024.html +> >
+> > Here are the more oriented guidelines for postgresql users:
+> >
+> > - /proc/sys/vm/readahead_ratio
+> > Since most DB servers are bounty of memory, the danger of readahe= +ad
+> > thrashing is near to zero. In this case, you can set readahead_ra= +tio to
+> > 100(or even 200:), which helps the readahead window to scale up r= +apidly.
+> >
+> > - /proc/sys/vm/readahead_hit_rate
+> > Sparse sequential reads are read patterns like {0, 2, 4, 5, 8, 11= +, ...}.
+> > In this case we might prefer to do readahead to get good I/O perf= +ormance
+> > with the overhead of some useless pages. But if you prefer not to= + do so,
+> > set readahead_hit_rate to 1 will disable this feature.
+> >
+> > - /sys/block/sd<X>/queue/read_ahead_kb
+> > Set it to a large value(e.g. 4096) as you used to do.
+> > RAID users might want to use a bigger number.
+> >
+> > TRYING IT OUT
+> >
+> > The latest patch for stable kernels can be downloaded here:
+> > http://www.vanheusden.co= +m/ara/
+> >
+> > Before compiling, make sure that the following options are enable= +d:
+> > Processor type and features -> Adaptive file readahead
+> > Processor type and features ->   Readahead debug and= + accounting
+> >
+> > HELPING AND CONTRIBUTING
+> >
+> > The patch is open to fine-tuning advices :)
+> > Comments and benchmarking results are highly appreciated.
+> >
+> > Thanks,
+> > Wu
+> >
+> > ---------------------------(end of broadcast)--------------------= +-------
+> > TIP 4: Have you searched our list archives?
+> >
+> >            = +;    http://arc= +hives.postgresql.org
+>
+>
+> ---------------------------(end of broadcast)-------------------------= +--
+> TIP 4: Have you searched our list archives?
+>
+>            &nbs= +p;   http://archives= +.postgresql.org
+>
+
+--
+Jim C. Nasby, Sr. Engineering Consultant      jnas= +by@pervasive.com
+Pervasive Software      http://pervasive.com    work: 512-231-6117
+vcard: http://jim.nasby.net/pe= +rvasive.vcf       cell: 512-569-9461
+_______________________________________________
+Bizgres-general mailing list
+Bizgres-general@pgfoundry.org
+http://pgfo= +undry.org/mailman/listinfo/bizgres-general
+
+
+

+
+ + + + +--B_3228914020_4686675-- + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 20:44:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F2CB811F61EE + for ; + Wed, 26 Apr 2006 20:44:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06578-01 + for ; + Wed, 26 Apr 2006 20:43:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpout08-04.prod.mesa1.secureserver.net + (smtpout08-04.prod.mesa1.secureserver.net [64.202.165.12]) + by postgresql.org (Postfix) with SMTP id D730011F61E8 + for ; + Wed, 26 Apr 2006 20:43:53 -0300 (ADT) +Received: (qmail 25566 invoked from network); 26 Apr 2006 23:43:53 -0000 +Received: from unknown (69.199.39.70) + by smtpout08-04.prod.mesa1.secureserver.net (64.202.165.12) with ESMTP; + 26 Apr 2006 23:43:52 -0000 +Message-ID: <445005AD.2000503@ummon.com> +Date: Wed, 26 Apr 2006 19:43:41 -0400 +From: Stef T +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Will Reese +CC: pgsql-performance@postgresql.org +Subject: Re: Slow deletes in 8.1 when FKs are involved +References: <9EAB2F2F-0BC2-4685-96A1-A29D7872D068@rackspace.com> +In-Reply-To: <9EAB2F2F-0BC2-4685-96A1-A29D7872D068@rackspace.com> +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/619 +X-Sequence-Number: 18703 + + +Hey there Will, + I would assume that, perhaps, jst perhaps, the FK doesn't have an +index on the field on both sides, so, your seeing a potential sequential +scan happening. Can you fling up an explain anaylze for everyone please +? Anything more will be merely shooting in the dark, and, tracer bullets +aside, I have heard that -that- can be dangerous ;p + + Regards + Stef + +Will Reese wrote: +> I'm preparing for an upgrade from PostgreSQL 7.4.5 to 8.1.3, and I +> noticed a potential performance issue. +> +> I have two servers, a dual proc Dell with raid 5 running PostgreSQL +> 7.4, and a quad proc Dell with a storage array running PostgreSQL 8.1. +> Both servers have identical postgresql.conf settings and were restored +> from the same 7.4 backup. Almost everything is faster on the 8.1 +> server (mostly due to hardware), except one thing...deletes from +> tables with foreign keys. +> +> I have table A with around 100,000 rows, that has foreign keys to +> around 50 other tables. Some of these other tables (table B, for +> example) have around 10 million rows. +> +> On the 7.4 server, I can delete a single row from a table A in well +> under a second (as expected). On the 8.1 server, it takes over a +> minute to delete. I tried all the usual stuff, recreating indexes, +> vacuum analyzing, explain analyze. Everything is identical between +> the systems. If I hit ctrl-c while the delete was running on 8.1, I +> repeatedly got the following message... +> +> db=# delete from "A" where "ID" in ('6'); +> Cancel request sent +> ERROR: canceling statement due to user request +> CONTEXT: SQL statement "SELECT 1 FROM ONLY "public"."B" x WHERE +> "A_ID" = $1 FOR SHARE OF x" +> +> It looks to me like the "SELECT ... FOR SHARE" functionality in 8.1 is +> the culprit. Has anyone else run into this issue? +> +> +> Will Reese -- http://blog.rezra.com +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 20:54:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EE40111F61DE + for ; + Wed, 26 Apr 2006 20:54:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 04167-08 + for ; + Wed, 26 Apr 2006 20:54:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by postgresql.org (Postfix) with ESMTP id 0222D11F60E5 + for ; + Wed, 26 Apr 2006 20:53:58 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYC00H5CT1Y2SP2@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 26 Apr 2006 18:53:58 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 7948A6E6C1 for + ; + Wed, 26 Apr 2006 19:53:56 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 10310-03 for ; Wed, + 26 Apr 2006 19:53:55 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 56F966E6C2; Wed, 26 Apr 2006 19:53:55 -0400 (EDT) +Date: Wed, 26 Apr 2006 19:53:54 -0400 +From: Michael Stone +Subject: Re: [Bizgres-general] Introducing a new linux +In-reply-to: +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060426235352.GD31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=iso-8859-1; format=flowed +Content-transfer-encoding: 8BIT +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060426222855.GC97354@pervasive.com> + +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/620 +X-Sequence-Number: 18704 + +On Wed, Apr 26, 2006 at 04:33:40PM -0700, Luke Lonergan wrote: +>I�m thinking about it, we�re already using a fixed read-ahead of 16MB using +>blockdev on the stock Redhat 2.6.9 kernel, it would be nice to not have to +>set this so we may try it. + +FWIW, I never saw much performance difference from doing that. Wu's +patch, OTOH, gave a big boost. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Sat Apr 29 17:13:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3630311F60E8 + for ; + Wed, 26 Apr 2006 22:26:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29372-06 + for ; + Wed, 26 Apr 2006 22:26:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id D9FFA11F60E3 + for ; + Wed, 26 Apr 2006 22:26:13 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id D68A2314A8; Thu, 27 Apr 2006 03:26:13 +0200 (MET DST) +From: "Bert" +X-Newsgroups: pgsql.performance +Subject: Re: Easy question +Date: 26 Apr 2006 18:26:07 -0700 +Organization: http://groups.google.com +Lines: 5 +Message-ID: <1146101167.724196.253740@v46g2000cwv.googlegroups.com> +References: <1145741653.759727.38970@e56g2000cwe.googlegroups.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +In-Reply-To: +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.8.0.2) Gecko/20060308 + Firefox/1.5.0.2,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: v46g2000cwv.googlegroups.com; posting-host=200.114.70.217; + posting-account=I3Q4Kw0AAAB5qSAosGYN-4vsrNRUrVAS +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/692 +X-Sequence-Number: 18776 + +Thanks, +But the performance is the same just the formating is more simple. +Greets, +Bert + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 23:07:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3F5A311F60B0 + for ; + Wed, 26 Apr 2006 23:07:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38296-08-2 + for ; + Wed, 26 Apr 2006 23:07:01 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.233]) + by postgresql.org (Postfix) with ESMTP id 7666511F6920 + for ; + Wed, 26 Apr 2006 23:06:59 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so1507619wra + for ; + Wed, 26 Apr 2006 19:07:00 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:user-agent:date:subject:from:to:message-id:thread-topic:thread-index:mime-version:content-type; + b=oF6MVNfhLbxoE/w6x3TIzvr1SOaGYsBc4uZ7bGGS9JCOOGfRIUtbjTUFsq1+7yHM2HL2L6w6niBGbOqiRrcsAigQSrUunjG75bhC53J26LhDr/07VJnm3tf1jrNQ5DAnTy3ce/pFZzVzXkMAdhowXF8UaHCr/PzH3WPhnm7RfoE= +Received: by 10.54.125.3 with SMTP id x3mr219924wrc; + Wed, 26 Apr 2006 19:07:00 -0700 (PDT) +Received: from ?192.168.0.12? ( [72.156.236.193]) + by mx.gmail.com with ESMTP id 26sm121898wra.2006.04.26.19.07.00; + Wed, 26 Apr 2006 19:07:00 -0700 (PDT) +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Wed, 26 Apr 2006 22:06:58 -0400 +Subject: Running on an NFS Mounted Directory +From: Ketema Harris +To: +Message-ID: +Thread-Topic: Running on an NFS Mounted Directory +Thread-Index: AcZpn0OCglyb5tWSEdqtugARJHlfcA== +Mime-version: 1.0 +Content-type: multipart/alternative; + boundary="B_3228934019_1019469" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/621 +X-Sequence-Number: 18705 + +> This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--B_3228934019_1019469 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit + +I was wondering if there were any performance issues with having a data +directory that was an nfs mounted drive? Say like a SAN or NAS device? Has +anyone done this before? + + +--B_3228934019_1019469 +Content-type: text/html; + charset="US-ASCII" +Content-transfer-encoding: quoted-printable + + + +Running on an NFS Mounted Directory + + +I was wondering if the= +re were any performance issues with having a data directory that was an nfs = +mounted drive?  Say like a SAN or NAS device? Has anyone done this befo= +re?
+
+ + + + +--B_3228934019_1019469-- + + + +From pgsql-performance-owner@postgresql.org Wed Apr 26 23:13:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 81C1311F6B38 + for ; + Wed, 26 Apr 2006 23:13:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40064-07 + for ; + Wed, 26 Apr 2006 23:13:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 29B5511F6B1C + for ; + Wed, 26 Apr 2006 23:13:16 -0300 (ADT) +Received: from mx.sat.rackspace.com (mx.sat.rackspace.com [64.39.1.214]) + by svr4.postgresql.org (Postfix) with ESMTP id 644165B567E + for ; + Thu, 27 Apr 2006 02:13:17 +0000 (GMT) +Received: from mail.rackspace.com (mail.rackspace.com [64.39.2.181]) + by mx.sat.rackspace.com (8.13.6/8.13.6) with ESMTP id k3R2DECZ011510 + for ; Wed, 26 Apr 2006 21:13:14 -0500 + (envelope-from wreese@rackspace.com) +Received: from [192.168.10.8] (vpn113-65.sat.rackspace.com [10.1.113.65]) + (authenticated bits=0) + by mail.rackspace.com (8.13.1/8.13.1) with ESMTP id k3R2DDVj000849 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) + for ; Wed, 26 Apr 2006 21:13:13 -0500 +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <445005AD.2000503@ummon.com> +References: <9EAB2F2F-0BC2-4685-96A1-A29D7872D068@rackspace.com> + <445005AD.2000503@ummon.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <1D2B84DA-3FE5-4583-9414-5A7CD9D48E70@rackspace.com> +Content-Transfer-Encoding: 7bit +From: Will Reese +Subject: Re: Slow deletes in 8.1 when FKs are involved +Date: Wed, 26 Apr 2006 21:13:18 -0500 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.749.3) +X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CP_URI_IN_BODY 0, + __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, + __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, + __SANE_MSGID 0, __STOCK_PHRASE_7 0' +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/622 +X-Sequence-Number: 18706 + +Stef: + +There is already a post explaining the solution. All the proper +indexes were there, and it works great on 7.4. The problem lies with +leftover 7.4 RI triggers being carried over to an 8.1 database. The +solution is to drop the triggers and add the constraint. Hopefully +this will not cause as many locking issues with FKs on 8.1 as it did +in 7.4 (which is why one of the RI triggers was removed in the first +place). + +Will Reese -- http://blog.rezra.com + +On Apr 26, 2006, at 6:43 PM, Stef T wrote: + +> +> Hey there Will, +> I would assume that, perhaps, jst perhaps, the FK doesn't have an +> index on the field on both sides, so, your seeing a potential +> sequential +> scan happening. Can you fling up an explain anaylze for everyone +> please +> ? Anything more will be merely shooting in the dark, and, tracer +> bullets +> aside, I have heard that -that- can be dangerous ;p +> +> Regards +> Stef +> +> Will Reese wrote: +>> I'm preparing for an upgrade from PostgreSQL 7.4.5 to 8.1.3, and I +>> noticed a potential performance issue. +>> +>> I have two servers, a dual proc Dell with raid 5 running PostgreSQL +>> 7.4, and a quad proc Dell with a storage array running PostgreSQL +>> 8.1. +>> Both servers have identical postgresql.conf settings and were +>> restored +>> from the same 7.4 backup. Almost everything is faster on the 8.1 +>> server (mostly due to hardware), except one thing...deletes from +>> tables with foreign keys. +>> +>> I have table A with around 100,000 rows, that has foreign keys to +>> around 50 other tables. Some of these other tables (table B, for +>> example) have around 10 million rows. +>> +>> On the 7.4 server, I can delete a single row from a table A in well +>> under a second (as expected). On the 8.1 server, it takes over a +>> minute to delete. I tried all the usual stuff, recreating indexes, +>> vacuum analyzing, explain analyze. Everything is identical between +>> the systems. If I hit ctrl-c while the delete was running on 8.1, I +>> repeatedly got the following message... +>> +>> db=# delete from "A" where "ID" in ('6'); +>> Cancel request sent +>> ERROR: canceling statement due to user request +>> CONTEXT: SQL statement "SELECT 1 FROM ONLY "public"."B" x WHERE +>> "A_ID" = $1 FOR SHARE OF x" +>> +>> It looks to me like the "SELECT ... FOR SHARE" functionality in +>> 8.1 is +>> the culprit. Has anyone else run into this issue? +>> +>> +>> Will Reese -- http://blog.rezra.com +>> +>> +>> +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 1: if posting/reading through Usenet, please send an appropriate +>> subscribe-nomail command to majordomo@postgresql.org so that +>> your +>> message can get through to the mailing list cleanly +>> +> + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 00:36:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1630711F60E8 + for ; + Thu, 27 Apr 2006 00:36:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 67794-05 + for ; + Thu, 27 Apr 2006 00:35:51 -0300 (ADT) +X-Greylist: delayed 01:00:08.878658 by SQLgrey- +Received: from noao.edu (noao.edu [140.252.1.54]) + by postgresql.org (Postfix) with ESMTP id 2619211F60E5 + for ; + Thu, 27 Apr 2006 00:35:50 -0300 (ADT) +X-TFF-CGPSA-Version: 1.4f1 +X-TFF-CGPSA-Filter: Scanned +Received: from weaver.tuc.noao.edu ([140.252.14.8] verified) + by noao.edu (CommuniGate Pro SMTP 5.0.9) + with ESMTPS id 25881248; Wed, 26 Apr 2006 19:35:42 -0700 +Received: from weaver.tuc.noao.edu (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.13.1/8.13.1) with ESMTP id k3R2Zg0p014715; + Wed, 26 Apr 2006 19:35:42 -0700 +Received: (from swampler@localhost) + by weaver.tuc.noao.edu (8.13.1/8.13.1/Submit) id k3R2ZgDg014714; + Wed, 26 Apr 2006 19:35:42 -0700 +Date: Wed, 26 Apr 2006 19:35:42 -0700 +From: Steve Wampler +To: Ketema Harris +Cc: pgsql-performance@postgresql.org +Subject: Re: Running on an NFS Mounted Directory +Message-ID: <20060427023542.GA14672@weaver.tuc.noao.edu> +Reply-To: swampler@noao.edu +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/624 +X-Sequence-Number: 18708 + +On Wed, Apr 26, 2006 at 10:06:58PM -0400, Ketema Harris wrote: +> I was wondering if there were any performance issues with having a data +> directory that was an nfs mounted drive? Say like a SAN or NAS device? Has +> anyone done this before? + +My understanding is that NFS is pretty poor in performance in general, +so I would expect it to be particularly bad for a DB. You might run +some (non-DB) performance tests to get a feel for how bad it might me. +(Someone once told me that NFS topped out at around 12MB/s, but I don't +know if that's really true [they were trying to sell a competitive +networked filesystem]). + +In any event, you're at least limited by ethernet speeds, if not more. + +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Wed Apr 26 23:55:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 319F511F60A2 + for ; + Wed, 26 Apr 2006 23:55:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 60826-01 + for ; + Wed, 26 Apr 2006 23:55:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.envysolutions.com (mark.mielke.cc [206.248.142.186]) + by postgresql.org (Postfix) with ESMTP id 9E3EC11F620C + for ; + Wed, 26 Apr 2006 23:55:13 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.envysolutions.com (Postfix) with ESMTP id A0DC91B69C; + Wed, 26 Apr 2006 22:56:02 -0400 (EDT) +Received: from mail.envysolutions.com ([127.0.0.1]) + by localhost (mark.mielke.cc [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 19057-04; Wed, 26 Apr 2006 22:56:02 -0400 (EDT) +Received: by mail.envysolutions.com (Postfix, from userid 500) + id 868821B6A4; Wed, 26 Apr 2006 22:56:02 -0400 (EDT) +Date: Wed, 26 Apr 2006 22:56:02 -0400 +From: mark@mark.mielke.cc +To: "Jim C. Nasby" +Cc: Bruce Momjian , + Scott Marlowe , + Bill Moran , + pgsql-performance@postgresql.org +Subject: Re: Large (8M) cache vs. dual-core CPUs +Message-ID: <20060427025602.GA19089@mark.mielke.cc> +References: <20060426220929.GY97354@pervasive.com> + <200604262216.k3QMGkk15952@candle.pha.pa.us> + <20060426223731.GE97354@pervasive.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060426223731.GE97354@pervasive.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: amavisd-new at mail.envysolutions.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/623 +X-Sequence-Number: 18707 + +On Wed, Apr 26, 2006 at 05:37:31PM -0500, Jim C. Nasby wrote: +> On Wed, Apr 26, 2006 at 06:16:46PM -0400, Bruce Momjian wrote: +> > AMD transfers the dirty cache line directly from cpu to cpu. I can +> > imaging that helping our test-and-set shared memory usage quite a bit. +> Wasn't the whole point of test-and-set that it's the recommended way to +> do lightweight spinlocks according to AMD/Intel? You'd think they'd have +> a way to make that performant on multiple CPUs (though if it's relying +> on possibly modifying an underlying data page I can't really think of +> how to do that without snaking through the cache...) + +It's expensive no matter what. One method might be less expensive than +another. :-) + +AMD definately seems to have things right for lowest absolute latency. +2X still sounds like an extreme case - but until I've actually tried a +very large, or thread intensive PostgreSQL db on both, I probably +shouldn't doubt the work of others too much. :-) + +Cheers, +mark + +-- +mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________ +. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder +|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | +| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada + + One ring to rule them all, one ring to find them, one ring to bring them all + and in the darkness bind them... + + http://mark.mielke.cc/ + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 02:02:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C791D11F68FC + for ; + Thu, 27 Apr 2006 02:02:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 89207-09 + for ; + Thu, 27 Apr 2006 02:02:42 -0300 (ADT) +X-Greylist: delayed 00:18:44.681278 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id D0A8711F68DA + for ; + Thu, 27 Apr 2006 02:02:41 -0300 (ADT) +Received: from corpmail.hi5.com (corpmail.hi5.com [204.13.49.5]) + by svr4.postgresql.org (Postfix) with ESMTP id 718B25B2E5D + for ; + Thu, 27 Apr 2006 04:43:56 +0000 (GMT) +Received: from [192.168.15.101] by hi5.com (MDaemon PRO v9.0.0 trial) + with ESMTP id md50002838323.msg + for ; Wed, 26 Apr 2006 21:43:26 -0700 +In-Reply-To: <20060427023542.GA14672@weaver.tuc.noao.edu> +References: + <20060427023542.GA14672@weaver.tuc.noao.edu> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: Ketema Harris , + pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Dan Gorman +Subject: Re: Running on an NFS Mounted Directory +Date: Wed, 26 Apr 2006 21:43:26 -0700 +To: swampler@noao.edu +X-Mailer: Apple Mail (2.749.3) +X-Authenticated-Sender: dgorman@hi5.com +X-Spam-Processed: corpmail, Wed, 26 Apr 2006 21:43:26 -0700 + (not processed: message from valid local sender) +X-Lookup-Warning: EHLO lookup on [192.168.15.101] does not match 65.254.152.26 +X-MDRemoteIP: 65.254.152.26 +X-Return-Path: dgorman@hi5.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-MDAV-Processed: corpmail, Wed, 26 Apr 2006 21:43:26 -0700 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/626 +X-Sequence-Number: 18710 + +We have gotten very good performance from netapp and postgres 7.4.11 . + +I was able to push about 100MB/s over gigE, but that was limited by +our netapp. + +DAS will generally always be faster, but if for example you have 2 +disks vs. 100 NFS mounted ,NFS will be faster. + +NFS is very reliable and I would stay away from iscsi. + + + +Regards, +Dan Gorman + +On Apr 26, 2006, at 7:35 PM, Steve Wampler wrote: + +> On Wed, Apr 26, 2006 at 10:06:58PM -0400, Ketema Harris wrote: +>> I was wondering if there were any performance issues with having a +>> data +>> directory that was an nfs mounted drive? Say like a SAN or NAS +>> device? Has +>> anyone done this before? +> +> My understanding is that NFS is pretty poor in performance in general, +> so I would expect it to be particularly bad for a DB. You might run +> some (non-DB) performance tests to get a feel for how bad it might me. +> (Someone once told me that NFS topped out at around 12MB/s, but I +> don't +> know if that's really true [they were trying to sell a competitive +> networked filesystem]). +> +> In any event, you're at least limited by ethernet speeds, if not more. +> +> -- +> Steve Wampler -- swampler@noao.edu +> The gods that smiled on your birth are now laughing out loud. +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster + + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 01:55:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id DE8D311F65A1 + for ; + Thu, 27 Apr 2006 01:55:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 82983-06 + for ; + Thu, 27 Apr 2006 01:55:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 7429511F65AD + for ; + Thu, 27 Apr 2006 01:55:27 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 07E0D56423; Wed, 26 Apr 2006 23:55:27 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 26 Apr 2006 23:55:24 -0500 +Date: Wed, 26 Apr 2006 23:55:24 -0500 +From: "Jim C. Nasby" +To: Steve Wampler +Cc: Ketema Harris , pgsql-performance@postgresql.org +Subject: Re: Running on an NFS Mounted Directory +Message-ID: <20060427045524.GV97354@pervasive.com> +References: + <20060427023542.GA14672@weaver.tuc.noao.edu> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060427023542.GA14672@weaver.tuc.noao.edu> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060427:swampler@noao.edu::il9/UeObdk7aPmFz:00000000000000000000 + 0000000000000000000000006Rie +X-Hashcash: 1:20:060427:ketema@gmail.com::AijIYmKXQl9dxi1M:0DWdr +X-Hashcash: + 1:20:060427:pgsql-performance@postgresql.org::xAyxho/ARBavvnB6:00000 + 000000000000000000000000CviL +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/625 +X-Sequence-Number: 18709 + +On Wed, Apr 26, 2006 at 07:35:42PM -0700, Steve Wampler wrote: +> On Wed, Apr 26, 2006 at 10:06:58PM -0400, Ketema Harris wrote: +> > I was wondering if there were any performance issues with having a data +> > directory that was an nfs mounted drive? Say like a SAN or NAS device? Has +> > anyone done this before? +> +> My understanding is that NFS is pretty poor in performance in general, +> so I would expect it to be particularly bad for a DB. You might run +> some (non-DB) performance tests to get a feel for how bad it might me. +> (Someone once told me that NFS topped out at around 12MB/s, but I don't +> know if that's really true [they were trying to sell a competitive +> networked filesystem]). +> +> In any event, you're at least limited by ethernet speeds, if not more. + +More importantly, the latency involved will kill commit performance. If +it doesn't then it's likely that fsync isn't being obeyed, which means 0 +data integrity. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Apr 27 03:59:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 906C511F60B1 + for ; + Thu, 27 Apr 2006 03:59:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 62534-04 + for ; + Thu, 27 Apr 2006 03:59:24 -0300 (ADT) +X-Greylist: delayed 00:27:49.710065 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 1603B11F624A + for ; + Thu, 27 Apr 2006 03:59:22 -0300 (ADT) +Received: from ns2.nec.com.au (ns2.nec.com.au [147.76.180.2]) + by svr4.postgresql.org (Postfix) with ESMTP id 8F1B95B58A9 + for ; + Thu, 27 Apr 2006 06:31:33 +0000 (GMT) +Received: from ns2.nec.com.au ([127.0.0.1]) + by localhost (ns2.nec.com.au [127.0.0.1]) (amavisd-new, + port 10024) with LMTP + id 26239-01-41 for ; + Thu, 27 Apr 2006 16:31:26 +1000 (EST) +Received: from smtp1.nec.com.au (unknown [172.31.8.18]) + by ns2.nec.com.au (Postfix) with ESMTP id 21AC13B6A7 + for ; + Thu, 27 Apr 2006 16:31:26 +1000 (EST) +Received: from eddy (eddy.ssd.neca.nec.com.au [147.76.48.116]) + by warp.ssd.neca.nec.com.au (8.12.10+Sun/8.12.10) with SMTP id + k3R6VOuP008411; Thu, 27 Apr 2006 16:31:24 +1000 (EST) +Reply-To: +From: "Guoping Zhang" +To: +Cc: "Guoping Zhang (E-mail)" +Subject: how unsafe (or worst scenarios) when setting fsync OFF for postgresql +Date: Thu, 27 Apr 2006 16:31:23 +1000 +Message-ID: <003b01c669c4$34bbd7b0$74304c93@eddy> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="hz-gb-2312" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=0.644 tagged_above=0 required=5 tests=BAYES_20, + SPF_SOFTFAIL +X-Spam-Level: +X-Archive-Number: 200604/627 +X-Sequence-Number: 18711 + +Hi,. + +We are new to Postgresql. I am appreciated if the following question can be +answered. + +Our application has a strict speed requirement for DB operation. Our tests +show that it takes about 10secs for the operation when setting fsync off, +but takes about 70 seconds when setting fsync ON (with other WAL related +parametered tuned). + +We have to looking at setting fsync OFF option for performance reason, +our questions are + + a) if we set fsync OFF and anything (very low chance though) like OS +crash, loss of power, or hardware fault happened, can postgresql rolls back +to the state that the last checkpoint was done ( but all the operations +after that is lost) + + b) Does this roll back to last checkpoint can ensure the database back to +consistent state? + + c) What is worst scenarios if setting fsync OFF in term of database +safety. We try to avoid to restore the database from nightly backup. + +We view our application is not that data loss critical, say loss of five +minutes of data and operation occasionally, but the database integrity and +consistency must be kept. + +Can we set fsync OFF for the performance benefit, have the risk of only 5 +minutes data loss or much worse? + +Thanks in advance. + +Regards, + +Guoping + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 04:13:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 702E311F61E8 + for ; + Thu, 27 Apr 2006 04:13:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 65798-02 + for ; + Thu, 27 Apr 2006 04:13:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.187]) + by postgresql.org (Postfix) with ESMTP id 93D5211F66FA + for ; + Thu, 27 Apr 2006 04:13:20 -0300 (ADT) +Received: from [195.112.43.22] (helo=[192.168.0.7]) + by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis), + id 0ML2ov-1FZ0gb0MvG-0001Qp; Thu, 27 Apr 2006 09:13:14 +0200 +Subject: Re: how unsafe (or worst scenarios) when setting fsync +From: Simon Riggs +To: guoping.zhang@nec.com.au +Cc: pgsql-performance@postgresql.org, + "Guoping Zhang (E-mail)" +In-Reply-To: <003b01c669c4$34bbd7b0$74304c93@eddy> +References: <003b01c669c4$34bbd7b0$74304c93@eddy> +Content-Type: text/plain +Date: Thu, 27 Apr 2006 08:13:04 +0100 +Message-Id: <1146121984.3120.56.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-4.fc4) +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:726643fe08f41a451f0fe7fa43bce239 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/628 +X-Sequence-Number: 18712 + +On Thu, 2006-04-27 at 16:31 +1000, Guoping Zhang wrote: + +> We have to looking at setting fsync OFF option for performance reason, +> our questions are +> +> a) if we set fsync OFF and anything (very low chance though) like OS +> crash, loss of power, or hardware fault happened, can postgresql rolls back +> to the state that the last checkpoint was done ( but all the operations +> after that is lost) + +There is no rollback, only a rollforward from the checkpoint. + +> b) Does this roll back to last checkpoint can ensure the database back to +> consistent state? + +Therefore no consistent state guaranteed if some WAL is missing + +> c) What is worst scenarios if setting fsync OFF in term of database +> safety. We try to avoid to restore the database from nightly backup. + +Losing some DDL changes, probably. You'd need to be wary of things like +ANALYZE, VACUUM etc, since these make catalog changes also. + +> We view our application is not that data loss critical, say loss of five +> minutes of data and operation occasionally, but the database integrity and +> consistency must be kept. +> +> Can we set fsync OFF for the performance benefit, have the risk of only 5 +> minutes data loss or much worse? + +Thats up to you. + +fsync can be turned on and off, so you can make critical changes with +fsync on, then continue with fsync off. + +The risk and the decision, are yours. You are warned. + +-- + Simon Riggs + EnterpriseDB http://www.enterprisedb.com/ + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 04:43:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 19BD111F624C + for ; + Thu, 27 Apr 2006 04:43:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 65859-06 + for ; + Thu, 27 Apr 2006 04:43:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.wirelesscar.com (mail.wirelesscar.com [212.209.35.30]) + by postgresql.org (Postfix) with ESMTP id 27B2F11F60E3 + for ; + Thu, 27 Apr 2006 04:42:59 -0300 (ADT) +Received: from sesrv12.wirelesscar.com ([192.168.10.17]) by + mail.wirelesscar.com with InterScan Messaging Security Suite; + Thu, 27 Apr 2006 09:42:07 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: how unsafe (or worst scenarios) when setting fsync OFF for + postgresql +Date: Thu, 27 Apr 2006 09:42:54 +0200 +Message-ID: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E422A@sesrv12.wirelesscar.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] how unsafe (or worst scenarios) when setting fsync OFF + for postgresql +Thread-Index: AcZpyGgmk/JOJRn2SNmzmslkwr9BzAABKMxQ +From: "Mikael Carneholm" +To: , + +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/629 +X-Sequence-Number: 18713 + +Get a SCSI controller with a battery backed cache, and mount the disks +with data=3Dwriteback (if you use ext3). If you loose power in the = +middle +of a transaction, the battery will ensure that the write operation still +completes. With asynch writing setup like this, fsync operations will +return almost immidiately giving you performance close to that of +running with fsync off. + +Regards, +Mikael + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Guoping +Zhang +Sent: den 27 april 2006 08:31 +To: pgsql-performance@postgresql.org +Cc: Guoping Zhang (E-mail) +Subject: [PERFORM] how unsafe (or worst scenarios) when setting fsync +OFF for postgresql + +Hi,. + +We are new to Postgresql. I am appreciated if the following question can +be answered. + +Our application has a strict speed requirement for DB operation. Our +tests show that it takes about 10secs for the operation when setting +fsync off, but takes about 70 seconds when setting fsync ON (with other +WAL related parametered tuned). + +We have to looking at setting fsync OFF option for performance reason, +our questions are + + a) if we set fsync OFF and anything (very low chance though) like OS +crash, loss of power, or hardware fault happened, can postgresql rolls +back to the state that the last checkpoint was done ( but all the +operations after that is lost) + + b) Does this roll back to last checkpoint can ensure the database back +to consistent state? + + c) What is worst scenarios if setting fsync OFF in term of database +safety. We try to avoid to restore the database from nightly backup. + +We view our application is not that data loss critical, say loss of five +minutes of data and operation occasionally, but the database integrity +and consistency must be kept. + +Can we set fsync OFF for the performance benefit, have the risk of only +5 minutes data loss or much worse? + +Thanks in advance. + +Regards, + +Guoping + + +---------------------------(end of broadcast)--------------------------- +TIP 2: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 06:26:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B01EC11F64E0 + for ; + Thu, 27 Apr 2006 06:26:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 12986-08 + for ; + Thu, 27 Apr 2006 06:26:19 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.201]) + by postgresql.org (Postfix) with ESMTP id 4720A11F60E5 + for ; + Thu, 27 Apr 2006 06:26:18 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id 9so1523586nzo + for ; + Thu, 27 Apr 2006 02:26:18 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=bQPHjeyQ/9eS+l3CO+BigvIQBm1DF7pp3a/6CvowNCiQcAu079+r2AxqB8n6bXEWPZoh/wq+Zj9cbp3rbW2v7RN4diPB2OLVxrxnNjEJcyLyfL8YSmsZzQ+AmIdVuapM1oXplc+jpukQ9KDPt+icV8kNFHCe0T9pFvxap9rkpTI= +Received: by 10.65.116.2 with SMTP id t2mr528049qbm; + Thu, 27 Apr 2006 02:26:18 -0700 (PDT) +Received: by 10.65.122.19 with HTTP; Thu, 27 Apr 2006 02:26:18 -0700 (PDT) +Message-ID: <1d4e0c10604270226s53e261e9m943bf44766c880bf@mail.gmail.com> +Date: Thu, 27 Apr 2006 11:26:18 +0200 +From: "Guillaume Smet" +To: guoping.zhang@nec.com.au +Subject: Re: how unsafe (or worst scenarios) when setting fsync OFF for + postgresql +Cc: pgsql-performance@postgresql.org, + "Guoping Zhang (E-mail)" +In-Reply-To: <003b01c669c4$34bbd7b0$74304c93@eddy> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <003b01c669c4$34bbd7b0$74304c93@eddy> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/630 +X-Sequence-Number: 18714 + +Guoping, + +On 4/27/06, Guoping Zhang wrote: +> We have to looking at setting fsync OFF option for performance reason, + +Did you try the other wal sync methods (fdatasync in particular)? I +saw a few posts lately explaining how changing sync method can affect +performances in specific cases. + +-- +Guillaume + +From pgsql-performance-owner@postgresql.org Thu Apr 27 08:44:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2238C11F65DA + for ; + Thu, 27 Apr 2006 08:43:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03934-05 + for ; + Thu, 27 Apr 2006 08:43:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) + by postgresql.org (Postfix) with ESMTP id 4D59C11F65A1 + for ; + Thu, 27 Apr 2006 08:43:47 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYD00EMNPWZ7B60@vms046.mailsrvcs.net> for + pgsql-performance@postgresql.org; Thu, 27 Apr 2006 06:43:48 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id B9F476E6A8; Thu, + 27 Apr 2006 07:43:43 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 15816-01-5; Thu, 27 Apr 2006 07:43:43 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id F2C196E7A7; Thu, 27 Apr 2006 07:43:42 -0400 (EDT) +Date: Thu, 27 Apr 2006 07:43:42 -0400 +From: Michael Stone +Subject: Re: Introducing a new linux readahead framework +In-reply-to: <20060426144347.GA31328@mathom.us> +To: pgsql-performance@postgresql.org, Wu Fengguang +Mail-followup-to: pgsql-performance@postgresql.org, + Wu Fengguang +Message-id: <20060427114340.GE31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060421013826.GA5217@mail.ustc.edu.cn> + <20060426144347.GA31328@mathom.us> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/631 +X-Sequence-Number: 18715 + +On Wed, Apr 26, 2006 at 10:43:48AM -0400, Michael Stone wrote: +>patch a 512k blocksize would get ~100MB/s. I'm now watching to see how +>it does over a couple of days on real-world workloads. + +I've got one DB where the VACUUM ANALYZE generally takes 11M-12M ms; +with the patch the job took 1.7M ms. Another VACUUM that normally takes +between 300k-500k ms took 150k. Definately a promising addition. + +Mike Stone + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 09:32:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AC8E211F60AE + for ; + Thu, 27 Apr 2006 09:32:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10899-05 + for ; + Thu, 27 Apr 2006 09:32:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 3EB6D11F61F8 + for ; + Thu, 27 Apr 2006 09:32:22 -0300 (ADT) +Received: from techforce.com.br (techforce.com.br [216.218.247.150]) + by svr4.postgresql.org (Postfix) with ESMTP id 0DDC45B5BEB + for ; + Thu, 27 Apr 2006 12:32:22 +0000 (GMT) +Received: from techforce.com.br (techforce.com.br [127.0.0.1]) + by techforce.com.br (8.12.11/8.12.11) with ESMTP id k3RCWVKg024428 + for ; Thu, 27 Apr 2006 05:32:31 -0700 +From: "andremachado" +To: pgsql-performance@postgresql.org +Subject: Firebird 1.5.3 X Postgresql 8.1.3 (linux Firebird 1.5.3 X Postgresql + 8.1.3 (linux and and windows)] +Date: Thu, 27 Apr 2006 10:32:31 -0200 +Message-Id: <20060427122235.M42721@techforce.com.br> +X-Mailer: Open WebMail 2.51 20050228 +X-OriginatingIP: 161.148.39.27 (andremachado@techforce.com.br) +MIME-Version: 1.0 +Content-Type: text/plain; + charset=iso-8859-1 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/632 +X-Sequence-Number: 18716 + +Hello, +Many thanks for your suggestions. +I will try them. +The last two queries almost did not use disk, but used 100% cpu. +The differences of performance are big. +Firebird has something similiar to EXPLAIN. Please look below. +Is there something really wrong with the postgresql configuration (at my +previous msg) that is causing this poor performance at these 2 queries? +I tweaked until almost no disk was used, but now it is using 100% cpu and took +too much time to complete. +Thanks. +Andre Felipe Machado + +http://www.techforce.com.br + + + + +SQL> set plan on; +SQL> set stats on; +SQL> update CADASTRO set IN_CADASTRO_MAIS_ATUAL = case when +CADASTRO.ID_CADASTRO= (select max(CAD2.ID_CADASTRO) from CADASTRO CAD2 inner +join DECLARACAO DECL on (DECL.ID_DECLARACAO=CAD2.ID_DECLARACAO) where +CAD2.ID_EMPRESA=CADASTRO.ID_EMPRESA and DECL.AM_REFERENCIA = (select +max(DEC2.AM_REFERENCIA) from DECLARACAO DEC2 where DEC2.IN_FOI_RETIFICADA=0 +and 1 in (select CAD3.ID_CADASTRO from CADASTRO CAD3 where +CAD3.ID_DECLARACAO=DEC2.ID_DECLARACAO and CAD3.ID_EMPRESA=CADASTRO.ID_EMPRESA +) )and DECL.IN_FOI_RETIFICADA=0 )then 1 else 0 end; + +PLAN (CAD3 INDEX (PK_CADASTRO_DESC)) +PLAN (DEC2 NATURAL) +PLAN JOIN (DECL INDEX (IDX_DT_REFERENCIA),CAD2 INDEX (RDB$FOREIGN18)) +PLAN (CADASTRO NATURAL) +Current memory = 911072 +Delta memory = 355620 +Max memory = 911072 +Elapsed time= 1.89 sec +Cpu = 0.00 sec +Buffers = 2048 +Reads = 1210 +Writes = 14 +Fetches = 310384 + +SQL> +SQL> update CADASTRO set IN_CADASTRO_MAIS_ATUAL = case when +CADASTRO.ID_CADASTRO= (select max(CAD2.ID_CADASTRO) from CADASTRO CAD2 inner +join DECLARACAO DECL on (DECL.ID_DECLARACAO=CAD2.ID_DECLARACAO) where +CAD2.ID_EMPRESA=CADASTRO.ID_EMPRESA and DECL.AM_REFERENCIA = (select +max(DEC2.AM_REFERENCIA) from DECLARACAO DEC2 where DEC2.IN_FOI_RETIFICADA=0 +and exists (select CAD3.ID_CADASTRO from CADASTRO CAD3 where +CAD3.ID_DECLARACAO=DEC2.ID_DECLARACAO and CAD3.ID_EMPRESA=CADASTRO.ID_EMPRESA +) )and DECL.IN_FOI_RETIFICADA=0 )then 1 else 0 end; + +PLAN (CAD3 INDEX (RDB$FOREIGN18)) +PLAN (DEC2 NATURAL) +PLAN JOIN (DECL INDEX (IDX_DT_REFERENCIA),CAD2 INDEX (RDB$FOREIGN18)) +PLAN (CADASTRO NATURAL) +Current memory = 938968 +Delta memory = 8756 +Max memory = 15418996 +Elapsed time= 1.09 sec +Cpu = 0.00 sec +Buffers = 2048 +Reads = 0 +Writes = 0 +Fetches = 301007 + +SQL> + + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 09:39:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BE16611F60E5 + for ; + Thu, 27 Apr 2006 09:39:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 13993-01 + for ; + Thu, 27 Apr 2006 09:38:58 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.233]) + by postgresql.org (Postfix) with ESMTP id 0A00711F60A2 + for ; + Thu, 27 Apr 2006 09:38:56 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so1583805wra + for ; + Thu, 27 Apr 2006 05:38:57 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:user-agent:date:subject:from:to:cc:message-id:thread-topic:thread-index:in-reply-to:mime-version:content-type:content-transfer-encoding; + b=lrWGE1aTRkzzukhc7v8gPlN8BmT/6Hox1hDWWLsnwG316kmQ+jDuPH06mEBgl85sp8wG3QDNuAE8QMYuzF8Bn0b5+Pbd+SH9t+5cz9sB2awSfjGZhxVK0s43yoz+cPmLsEP34Yg4FnxJnK853+VcViFqQQsokfKeJ/4i8VqXqxg= +Received: by 10.54.140.11 with SMTP id n11mr2168287wrd; + Thu, 27 Apr 2006 05:38:57 -0700 (PDT) +Received: from ?192.168.0.12? ( [72.156.236.193]) + by mx.gmail.com with ESMTP id 28sm802435wrl.2006.04.27.05.38.56; + Thu, 27 Apr 2006 05:38:57 -0700 (PDT) +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 27 Apr 2006 08:38:55 -0400 +Subject: Re: Running on an NFS Mounted Directory +From: Ketema Harris +To: "Jim C. Nasby" , + Steve Wampler +CC: +Message-ID: +Thread-Topic: [PERFORM] Running on an NFS Mounted Directory +Thread-Index: AcZp94vNypahiNXqEdqi1AARJHlfcA== +In-Reply-To: <20060427045524.GV97354@pervasive.com> +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/633 +X-Sequence-Number: 18717 + +I am looking for the best solution to have a large amount of disk storage +attached to my PostgreSQL 8.1 server. I was thinking of having a san or nas +attached device be mounted by the pg server over nfs, hence the question +about nfs performance. What other options/protocols are there to get high +performance and data integrity while having the benefit of not having the +physical storage attached to the db server? + + +On 4/27/06 12:55 AM, "Jim C. Nasby" wrote: + +> On Wed, Apr 26, 2006 at 07:35:42PM -0700, Steve Wampler wrote: +>> On Wed, Apr 26, 2006 at 10:06:58PM -0400, Ketema Harris wrote: +>>> I was wondering if there were any performance issues with having a data +>>> directory that was an nfs mounted drive? Say like a SAN or NAS device? Has +>>> anyone done this before? +>> +>> My understanding is that NFS is pretty poor in performance in general, +>> so I would expect it to be particularly bad for a DB. You might run +>> some (non-DB) performance tests to get a feel for how bad it might me. +>> (Someone once told me that NFS topped out at around 12MB/s, but I don't +>> know if that's really true [they were trying to sell a competitive +>> networked filesystem]). +>> +>> In any event, you're at least limited by ethernet speeds, if not more. +> +> More importantly, the latency involved will kill commit performance. If +> it doesn't then it's likely that fsync isn't being obeyed, which means 0 +> data integrity. + + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 09:45:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1011B11F60A2 + for ; + Thu, 27 Apr 2006 09:45:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 13295-03 + for ; + Thu, 27 Apr 2006 09:45:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by postgresql.org (Postfix) with ESMTP id 0BD3711F60E5 + for ; + Thu, 27 Apr 2006 09:45:00 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYD00H9DSQZ2TS4@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Thu, 27 Apr 2006 07:45:00 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id BB31C6E6C0; Thu, + 27 Apr 2006 08:44:58 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 16366-02-2; Thu, 27 Apr 2006 08:44:57 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id AFD346E7A7; Thu, 27 Apr 2006 08:44:57 -0400 (EDT) +Date: Thu, 27 Apr 2006 08:44:57 -0400 +From: Michael Stone +Subject: Re: Running on an NFS Mounted Directory +In-reply-to: +To: Ketema Harris +Cc: pgsql-performance@postgresql.org +Mail-followup-to: Ketema Harris , + pgsql-performance@postgresql.org +Message-id: <20060427124455.GF31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060427045524.GV97354@pervasive.com> + +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/634 +X-Sequence-Number: 18718 + +On Thu, Apr 27, 2006 at 08:38:55AM -0400, Ketema Harris wrote: +>I am looking for the best solution to have a large amount of disk storage +>attached to my PostgreSQL 8.1 server. + +>What other options/protocols are there to get high performance and data +>integrity while having the benefit of not having the physical storage +>attached to the db server? + +These are two distinct requirements. Are both really requirements or is +one "nice to have"? The "best" solution for "a large amount of disk +storage" isn't "not having the physical storage attached to the db +server". If you use non-local storage it will be slower and more +expensive, quite likely by a large margin. There may be other advantages +to doing so, but you haven't mentioned any of those as requirements. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Thu Apr 27 09:58:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3117511F61F8 + for ; + Thu, 27 Apr 2006 09:58:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10537-09 + for ; + Thu, 27 Apr 2006 09:57:54 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.231]) + by postgresql.org (Postfix) with ESMTP id B9DD311F60E5 + for ; + Thu, 27 Apr 2006 09:57:52 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so1586928wra + for ; + Thu, 27 Apr 2006 05:57:52 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:user-agent:date:subject:from:to:cc:message-id:thread-topic:thread-index:in-reply-to:mime-version:content-type:content-transfer-encoding; + b=PnOr0dVc4lqa+PVR+tZHZAYk+i7hk+BMyCUAd1Q7KfKnzqRcIwTzkne/xkTgFb0yvPzUSTs3uq3th6/sM73nobitQ7dUE616XCEoHgyQNaeWCJes0dYrjrjFDEssP2hg3mUqMoPHSiJ0SYHl72qQryxVluhxl08j1auSEY6XctU= +Received: by 10.54.147.19 with SMTP id u19mr286203wrd; + Thu, 27 Apr 2006 05:57:52 -0700 (PDT) +Received: from ?192.168.0.12? ( [72.156.236.193]) + by mx.gmail.com with ESMTP id 29sm496872wrl.2006.04.27.05.57.52; + Thu, 27 Apr 2006 05:57:52 -0700 (PDT) +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 27 Apr 2006 08:57:51 -0400 +Subject: Re: Running on an NFS Mounted Directory +From: Ketema Harris +To: Michael Stone +CC: +Message-ID: +Thread-Topic: [PERFORM] Running on an NFS Mounted Directory +Thread-Index: AcZp+jDpb2ae0dXtEdqi1AARJHlfcA== +In-Reply-To: <20060427124455.GF31328@mathom.us> +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/635 +X-Sequence-Number: 18719 + +OK. My thought process was that having non local storage as say a big raid +5 san ( I am talking 5 TB with expansion capability up to 10 ) would allow +me to have redundancy, expandability, and hopefully still retain decent +performance from the db. I also would hopefully then not have to do +periodic backups from the db server to some other type of storage. Is this +not a good idea? How bad of a performance hit are we talking about? Also, +in regards to the commit data integrity, as far as the db is concerned once +the data is sent to the san or nas isn't it "written"? The storage may have +that write in cache, but from my reading and understanding of how these +various storage devices work that is how they keep up performance. I would +expect my bottleneck if any to be the actual Ethernet transfer to the +storage, and I am going to try and compensate for that with a full gigabit +backbone. + + +On 4/27/06 8:44 AM, "Michael Stone" wrote: + +> On Thu, Apr 27, 2006 at 08:38:55AM -0400, Ketema Harris wrote: +>> I am looking for the best solution to have a large amount of disk storage +>> attached to my PostgreSQL 8.1 server. +> +>> What other options/protocols are there to get high performance and data +>> integrity while having the benefit of not having the physical storage +>> attached to the db server? +> +> These are two distinct requirements. Are both really requirements or is +> one "nice to have"? The "best" solution for "a large amount of disk +> storage" isn't "not having the physical storage attached to the db +> server". If you use non-local storage it will be slower and more +> expensive, quite likely by a large margin. There may be other advantages +> to doing so, but you haven't mentioned any of those as requirements. +> +> Mike Stone + + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 10:02:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 11CC911F60B1 + for ; + Thu, 27 Apr 2006 10:02:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 15132-08 + for ; + Thu, 27 Apr 2006 10:02:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id 8FFC911F60E7 + for ; + Thu, 27 Apr 2006 10:02:44 -0300 (ADT) +Received: (qmail 15627 invoked by uid 500); 27 Apr 2006 13:05:55 -0000 +Date: Thu, 27 Apr 2006 08:05:55 -0500 +From: Bruno Wolff III +To: Ketema Harris +Cc: Michael Stone , + pgsql-performance@postgresql.org +Subject: Re: Running on an NFS Mounted Directory +Message-ID: <20060427130555.GE6159@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Ketema Harris , + Michael Stone , + pgsql-performance@postgresql.org +References: <20060427124455.GF31328@mathom.us> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/636 +X-Sequence-Number: 18720 + +On Thu, Apr 27, 2006 at 08:57:51 -0400, + Ketema Harris wrote: +> performance from the db. I also would hopefully then not have to do +> periodic backups from the db server to some other type of storage. Is this +> not a good idea? How bad of a performance hit are we talking about? Also, + +You always need to do backups if you care about your data. What if someone +accidental deletes a lot of data? What if someone blows up your data +center (or there is a flood)? + +From pgsql-performance-owner@postgresql.org Thu Apr 27 10:07:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D85C911F60B1 + for ; + Thu, 27 Apr 2006 10:07:01 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18560-02 + for ; + Thu, 27 Apr 2006 10:06:52 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.229]) + by postgresql.org (Postfix) with ESMTP id DC77711F65AD + for ; + Thu, 27 Apr 2006 10:06:50 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so1588617wra + for ; + Thu, 27 Apr 2006 06:06:51 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:user-agent:date:subject:from:to:cc:message-id:thread-topic:thread-index:in-reply-to:mime-version:content-type:content-transfer-encoding; + b=ZhhaknAllm3eoL5vCd1FenmQTMJWnSLXwqXTJ6xrycCdub1Llai0EHNQJMQN+0iu7hP0ILLoiQbYEMENO4YEyi4EHF2TLsB+H0127tHYsEXCkW5o/amOxUAOGLpANRJyGVDjkFRqBSzVpj8y80mLCYc5pfXGw97OB1YMUxajK+E= +Received: by 10.54.107.17 with SMTP id f17mr6096236wrc; + Thu, 27 Apr 2006 06:06:51 -0700 (PDT) +Received: from ?192.168.0.12? ( [72.156.236.193]) + by mx.gmail.com with ESMTP id 7sm488320wrl.2006.04.27.06.06.50; + Thu, 27 Apr 2006 06:06:50 -0700 (PDT) +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 27 Apr 2006 09:06:48 -0400 +Subject: Re: Running on an NFS Mounted Directory +From: Ketema Harris +To: Bruno Wolff III +CC: Michael Stone , + +Message-ID: +Thread-Topic: Running on an NFS Mounted Directory +Thread-Index: AcZp+3D9r6PWJtXuEdqi1AARJHlfcA== +In-Reply-To: <20060427130555.GE6159@wolff.to> +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/637 +X-Sequence-Number: 18721 + +Yes, your right, I meant not have to do the backups from the db server +itself. I can do that within the storage device now, by allocating space +for it, and letting the device copy the data files on some periodic basis. + + +On 4/27/06 9:05 AM, "Bruno Wolff III" wrote: + +> On Thu, Apr 27, 2006 at 08:57:51 -0400, +> Ketema Harris wrote: +>> performance from the db. I also would hopefully then not have to do +>> periodic backups from the db server to some other type of storage. Is this +>> not a good idea? How bad of a performance hit are we talking about? Also, +> +> You always need to do backups if you care about your data. What if someone +> accidental deletes a lot of data? What if someone blows up your data +> center (or there is a flood)? + + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 10:10:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D5D1D11F6780 + for ; + Thu, 27 Apr 2006 10:10:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 13991-06 + for ; + Thu, 27 Apr 2006 10:09:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noao.edu (noao.edu [140.252.1.54]) + by postgresql.org (Postfix) with ESMTP id B27F911F65C6 + for ; + Thu, 27 Apr 2006 10:09:56 -0300 (ADT) +X-TFF-CGPSA-Version: 1.4f1 +X-TFF-CGPSA-Filter: Scanned +Received: from weaver.tuc.noao.edu ([140.252.14.8] verified) + by noao.edu (CommuniGate Pro SMTP 5.0.9) + with ESMTPS id 25895456; Thu, 27 Apr 2006 06:09:51 -0700 +Received: from weaver.tuc.noao.edu (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.13.1/8.13.1) with ESMTP id k3RD9pAn021314; + Thu, 27 Apr 2006 06:09:51 -0700 +Received: (from swampler@localhost) + by weaver.tuc.noao.edu (8.13.1/8.13.1/Submit) id k3RD9ot0021313; + Thu, 27 Apr 2006 06:09:50 -0700 +Date: Thu, 27 Apr 2006 06:09:50 -0700 +From: Steve Wampler +To: Ketema Harris +Cc: Michael Stone , + pgsql-performance@postgresql.org +Subject: Re: Running on an NFS Mounted Directory +Message-ID: <20060427130950.GA21200@weaver.tuc.noao.edu> +Reply-To: swampler@noao.edu +References: <20060427124455.GF31328@mathom.us> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/638 +X-Sequence-Number: 18722 + +On Thu, Apr 27, 2006 at 08:57:51AM -0400, Ketema Harris wrote: +> OK. My thought process was that having non local storage as say a big raid +> 5 san ( I am talking 5 TB with expansion capability up to 10 ) would allow +> me to have redundancy, expandability, and hopefully still retain decent +> performance from the db. I also would hopefully then not have to do +> periodic backups from the db server to some other type of storage. Is this +> not a good idea? How bad of a performance hit are we talking about? Also, +> in regards to the commit data integrity, as far as the db is concerned once +> the data is sent to the san or nas isn't it "written"? The storage may have +> that write in cache, but from my reading and understanding of how these +> various storage devices work that is how they keep up performance. I would +> expect my bottleneck if any to be the actual Ethernet transfer to the +> storage, and I am going to try and compensate for that with a full gigabit +> backbone. + +Well, if you have to have both the best performance and remote attach +storage, I think you'll find that a fibre-channel SAN is still the king +of the hill. 4Gb FC switches are common now, though finding a 4Gb +HBA for your computer might be a trick. 2Gb HBAs are everywhere in +FC land. That's a premium price solution, however, and I don't know +anything about how well PG would perform with a FC SAN. We use our +SAN for bulk science data and leave the PGDB on a separate machine +with local disk. + +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Thu Apr 27 10:25:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8CEE111F65C9 + for ; + Thu, 27 Apr 2006 10:25:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 17431-10 + for ; + Thu, 27 Apr 2006 10:25:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) + by postgresql.org (Postfix) with ESMTP id 47E0111F65AD + for ; + Thu, 27 Apr 2006 10:24:58 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYD004EGULLJC25@vms048.mailsrvcs.net> for + pgsql-performance@postgresql.org; Thu, 27 Apr 2006 08:24:59 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id D72676E6C0; Thu, + 27 Apr 2006 09:24:55 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 16702-02; Thu, 27 Apr 2006 09:24:55 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id A7C996E945; Thu, 27 Apr 2006 09:24:54 -0400 (EDT) +Date: Thu, 27 Apr 2006 09:24:54 -0400 +From: Michael Stone +Subject: Re: Running on an NFS Mounted Directory +In-reply-to: +To: Ketema Harris +Cc: pgsql-performance@postgresql.org +Mail-followup-to: Ketema Harris , + pgsql-performance@postgresql.org +Message-id: <20060427132452.GG31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060427124455.GF31328@mathom.us> + +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/639 +X-Sequence-Number: 18723 + +On Thu, Apr 27, 2006 at 08:57:51AM -0400, Ketema Harris wrote: +>OK. My thought process was that having non local storage as say a big raid +>5 san ( I am talking 5 TB with expansion capability up to 10 ) + +That's two disk trays for a cheap slow array. (Versus a more expensive +solution with more spindles and better seek performance.) + +>would allow +>me to have redundancy, expandability, and hopefully still retain decent +>performance from the db. I also would hopefully then not have to do +>periodic backups from the db server to some other type of storage. + +No, backups are completely unrelated to your storage type; you need them +either way. On a SAN you can use a SAN backup solution to back multiple +systems up with a single backup unit without involving the host CPUs. +This is fairly useless if you aren't amortizing the cost over a large +environment. + +>Is this not a good idea? + +It really depends on what you're hoping to get. As described, it's not +clear. (I don't know what you mean by "redundancy, expandability" or +"decent performance".) + +>How bad of a performance hit are we talking about? + +Way too many factors for an easy answer. Consider the case of NAS vs +SCSI direct attach storage. You're probably in that case comparing a +single 125MB/s (peak) gigabit ethernet channel to (potentially several) +320MB/s (peak) SCSI channels. With a high-end NAS you might get 120MB/s +off that GBE. With a (more realistic) mid-range unit you're more likely +to get 40-60MB/s. Getting 200MB/s off the SCSI channel isn't a stretch, +and you can fairly easily stripe across multiple SCSI channels. (You can +also bond multiple GBEs, but then your cost & complexity start going way +up, and you're never going to scale as well.) If you have an environment +where you're doing a lot of sequential scans it isn't even a contest. +You can also substitute SATA for SCSI, etc. + +For a FC SAN the peformance numbers are a lot better, but the costs & +complexity are a lot higher. An iSCSI SAN is somewhere in the middle. + +>Also, in regards to the commit data integrity, as far as the db is +>concerned once the data is sent to the san or nas isn't it "written"? +>The storage may have that write in cache, but from my reading and +>understanding of how these various storage devices work that is how +>they keep up performance. + +Depends on the configuration, but yes, most should be able to report +back a "write" once the data is in a non-volatile cache. You can do the +same with a direct-attached array and eliminate the latency inherent in +accessing the remote storage. + +>I would expect my bottleneck if any to be the actual Ethernet transfer +>to the storage, and I am going to try and compensate for that with a +>full gigabit backbone. + +see above. + +The advantages of a NAS or SAN are in things you haven't really touched +on. Is the filesystem going to be accessed by several systems? Do you +need the ability to do snapshots? (You may be able to do this with +direct-attach also, but doing it on a remote storage device tends to be +simpler.) Do you want to share one big, expensive, reliable unit between +multiple systems? Will you be doing failover? (Note that failover +requires software to go with the hardware, and can be done in a +different way with local storage also.) In some environments the answers +to those questions are yes, and the price premium & performance +implications are well worth it. For a single DB server the answer is +almost certainly "no". + +Mike Stone + +From pgsql-performance-owner@postgresql.org Thu Apr 27 10:30:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2955A11F65C6 + for ; + Thu, 27 Apr 2006 10:28:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19963-08 + for ; + Thu, 27 Apr 2006 10:28:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id C276211F60E5 + for ; + Thu, 27 Apr 2006 10:28:18 -0300 (ADT) +Received: (qmail 19756 invoked by uid 500); 27 Apr 2006 13:31:30 -0000 +Date: Thu, 27 Apr 2006 08:31:30 -0500 +From: Bruno Wolff III +To: Ketema Harris +Cc: Michael Stone , + pgsql-performance@postgresql.org +Subject: Re: Running on an NFS Mounted Directory +Message-ID: <20060427133130.GA19320@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Ketema Harris , + Michael Stone , + pgsql-performance@postgresql.org +References: <20060427130555.GE6159@wolff.to> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/640 +X-Sequence-Number: 18724 + +On Thu, Apr 27, 2006 at 09:06:48 -0400, + Ketema Harris wrote: +> Yes, your right, I meant not have to do the backups from the db server +> itself. I can do that within the storage device now, by allocating space +> for it, and letting the device copy the data files on some periodic basis. + +Only if the database server isn't running or your SAN provides a way to +provide a snapshot of the data at a particular instant in time. + +From pgsql-performance-owner@postgresql.org Thu Apr 27 10:41:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 71DDD11F65A1 + for ; + Thu, 27 Apr 2006 10:41:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 24260-04 + for ; + Thu, 27 Apr 2006 10:41:25 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.231]) + by postgresql.org (Postfix) with ESMTP id 3DC6D11F65AD + for ; + Thu, 27 Apr 2006 10:41:22 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so1595590wra + for ; + Thu, 27 Apr 2006 06:41:23 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:user-agent:date:subject:from:to:cc:message-id:thread-topic:thread-index:in-reply-to:mime-version:content-type:content-transfer-encoding; + b=ewLTScQD79gylz9P7vv4WF2DBT64eLCw8W6gUrmPYm9LtJOBX/R9lmEU9C4wpA+qftA3JOLw/M/wFZ11jSTyM7BbowOKdeE1lvBmjE4ZCDsNe244H8+dccOLvxsK8k/CGhtXFlxJCAuiIKUzaM4xSTcKnqf7jUOtqLbGblmR744= +Received: by 10.54.128.20 with SMTP id a20mr4287472wrd; + Thu, 27 Apr 2006 06:41:23 -0700 (PDT) +Received: from ?192.168.0.12? ( [72.156.236.193]) + by mx.gmail.com with ESMTP id 13sm854035wrl.2006.04.27.06.41.22; + Thu, 27 Apr 2006 06:41:23 -0700 (PDT) +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 27 Apr 2006 09:41:21 -0400 +Subject: Re: Running on an NFS Mounted Directory +From: Ketema Harris +To: Michael Stone +CC: +Message-ID: +Thread-Topic: [PERFORM] Running on an NFS Mounted Directory +Thread-Index: AcZqAESYgxTUytXzEdqi1AARJHlfcA== +In-Reply-To: <20060427132452.GG31328@mathom.us> +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/641 +X-Sequence-Number: 18725 + +First, I appreciate all of your input. + +>No, backups are completely unrelated to your storage type; you need them +> either way. +Please another post. I meant the storage would do the back ups. +>redundancy, expandability +What I mean by these stupid flavor words is: +Redundancy : raid 5. +Expandability : the ability to stick another drive in my array and get more +storage and not have to turn of the db. +>Do you +> need the ability to do snapshots? +Yes. +>Do you want to share one big, expensive, reliable unit between +> multiple systems? Will you be doing failover? +Yes, and Yes. Really on one other system, a phone system, but it is the +crux of my business and will be writing a lot of recorded phone calls. I am +working with a storage company now to set up the failover, I want the db and +phone systems to never no if the storage switched over. + +You have given me a lot to think about. The performance concerns me and I +will have to find some way to test. Perhaps spending a little less on the +storage system and more on the actual servers is the way to go? Then +utilize some combination off pg_backup, and the archive_command directive +with a periodic script. + +Thank You all. I will keep researching this and the more input the better. +Thank You. + +On 4/27/06 9:24 AM, "Michael Stone" wrote: + +> On Thu, Apr 27, 2006 at 08:57:51AM -0400, Ketema Harris wrote: +>> OK. My thought process was that having non local storage as say a big raid +>> 5 san ( I am talking 5 TB with expansion capability up to 10 ) +> +> That's two disk trays for a cheap slow array. (Versus a more expensive +> solution with more spindles and better seek performance.) +> +>> would allow +>> me to have redundancy, expandability, and hopefully still retain decent +>> performance from the db. I also would hopefully then not have to do +>> periodic backups from the db server to some other type of storage. +> +> No, backups are completely unrelated to your storage type; you need them +> either way. On a SAN you can use a SAN backup solution to back multiple +> systems up with a single backup unit without involving the host CPUs. +> This is fairly useless if you aren't amortizing the cost over a large +> environment. +> +>> Is this not a good idea? +> +> It really depends on what you're hoping to get. As described, it's not +> clear. (I don't know what you mean by "redundancy, expandability" or +> "decent performance".) +> +>> How bad of a performance hit are we talking about? +> +> Way too many factors for an easy answer. Consider the case of NAS vs +> SCSI direct attach storage. You're probably in that case comparing a +> single 125MB/s (peak) gigabit ethernet channel to (potentially several) +> 320MB/s (peak) SCSI channels. With a high-end NAS you might get 120MB/s +> off that GBE. With a (more realistic) mid-range unit you're more likely +> to get 40-60MB/s. Getting 200MB/s off the SCSI channel isn't a stretch, +> and you can fairly easily stripe across multiple SCSI channels. (You can +> also bond multiple GBEs, but then your cost & complexity start going way +> up, and you're never going to scale as well.) If you have an environment +> where you're doing a lot of sequential scans it isn't even a contest. +> You can also substitute SATA for SCSI, etc. +> +> For a FC SAN the peformance numbers are a lot better, but the costs & +> complexity are a lot higher. An iSCSI SAN is somewhere in the middle. +> +>> Also, in regards to the commit data integrity, as far as the db is +>> concerned once the data is sent to the san or nas isn't it "written"? +>> The storage may have that write in cache, but from my reading and +>> understanding of how these various storage devices work that is how +>> they keep up performance. +> +> Depends on the configuration, but yes, most should be able to report +> back a "write" once the data is in a non-volatile cache. You can do the +> same with a direct-attached array and eliminate the latency inherent in +> accessing the remote storage. +> +>> I would expect my bottleneck if any to be the actual Ethernet transfer +>> to the storage, and I am going to try and compensate for that with a +>> full gigabit backbone. +> +> see above. +> +> The advantages of a NAS or SAN are in things you haven't really touched +> on. Is the filesystem going to be accessed by several systems? Do you +> need the ability to do snapshots? (You may be able to do this with +> direct-attach also, but doing it on a remote storage device tends to be +> simpler.) Do you want to share one big, expensive, reliable unit between +> multiple systems? Will you be doing failover? (Note that failover +> requires software to go with the hardware, and can be done in a +> different way with local storage also.) In some environments the answers +> to those questions are yes, and the price premium & performance +> implications are well worth it. For a single DB server the answer is +> almost certainly "no". +> +> Mike Stone + + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 10:42:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5B91F11F65C6 + for ; + Thu, 27 Apr 2006 10:42:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27073-02 + for ; + Thu, 27 Apr 2006 10:42:13 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.225]) + by postgresql.org (Postfix) with ESMTP id 81A0711F65A1 + for ; + Thu, 27 Apr 2006 10:42:11 -0300 (ADT) +Received: by wproxy.gmail.com with SMTP id i32so1595737wra + for ; + Thu, 27 Apr 2006 06:42:12 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:user-agent:date:subject:from:to:cc:message-id:thread-topic:thread-index:in-reply-to:mime-version:content-type:content-transfer-encoding; + b=GSHswkVL1/WCBdNS4E7895xtEyr94U83iWbDMMHomBre2HquZYygNUCiKx4y18xsXVTDf0E7TV2BdFlRMK6qCO6rqrtl9Y5XtaGoX8bkMgcjhBdpbevIdvtqwvmxbw0h/LP7W7kpNMb6MHBqUtZwCabFJp+ZLuOS7s8bK3wwR0U= +Received: by 10.54.123.12 with SMTP id v12mr2526556wrc; + Thu, 27 Apr 2006 06:42:12 -0700 (PDT) +Received: from ?192.168.0.12? ( [72.156.236.193]) + by mx.gmail.com with ESMTP id 11sm826720wrl.2006.04.27.06.42.11; + Thu, 27 Apr 2006 06:42:11 -0700 (PDT) +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 27 Apr 2006 09:42:10 -0400 +Subject: Re: Running on an NFS Mounted Directory +From: Ketema Harris +To: Bruno Wolff III +CC: Michael Stone , + +Message-ID: +Thread-Topic: Running on an NFS Mounted Directory +Thread-Index: AcZqAGHMoC+A0tXzEdqi1AARJHlfcA== +In-Reply-To: <20060427133130.GA19320@wolff.to> +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/642 +X-Sequence-Number: 18726 + +The SAN has the snapshot capability. + + +On 4/27/06 9:31 AM, "Bruno Wolff III" wrote: + +> On Thu, Apr 27, 2006 at 09:06:48 -0400, +> Ketema Harris wrote: +>> Yes, your right, I meant not have to do the backups from the db server +>> itself. I can do that within the storage device now, by allocating space +>> for it, and letting the device copy the data files on some periodic basis. +> +> Only if the database server isn't running or your SAN provides a way to +> provide a snapshot of the data at a particular instant in time. + + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 11:04:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D8AC711F60AE + for ; + Thu, 27 Apr 2006 11:04:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 28476-07 + for ; + Thu, 27 Apr 2006 11:04:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by postgresql.org (Postfix) with ESMTP id A233E11F60A2 + for ; + Thu, 27 Apr 2006 11:04:25 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYD008GGWFBV2K0@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Thu, 27 Apr 2006 09:04:24 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 1170F6E6A8; Thu, + 27 Apr 2006 10:04:21 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 16908-03; Thu, 27 Apr 2006 10:04:20 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id CCBE56E945; Thu, 27 Apr 2006 10:04:19 -0400 (EDT) +Date: Thu, 27 Apr 2006 10:04:19 -0400 +From: Michael Stone +Subject: Re: Running on an NFS Mounted Directory +In-reply-to: +To: Ketema Harris +Cc: pgsql-performance@postgresql.org +Mail-followup-to: Ketema Harris , + pgsql-performance@postgresql.org +Message-id: <20060427140417.GH31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060427132452.GG31328@mathom.us> + +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/643 +X-Sequence-Number: 18727 + +On Thu, Apr 27, 2006 at 09:41:21AM -0400, Ketema Harris wrote: +>>No, backups are completely unrelated to your storage type; you need them +>> either way. +>Please another post. I meant the storage would do the back ups. + +Which isn't a backup. Even expensive storage arrays can break or burn +down. + +>>redundancy, expandability +>What I mean by these stupid flavor words is: +>Redundancy : raid 5. + +You can get that without external storage. + +>Expandability : the ability to stick another drive in my array and get more +>storage and not have to turn of the db. + +You can also get that without external storage assuming you choose a +platform with a volume manager. + +>>Do you +>> need the ability to do snapshots? +>Yes. + +If that's a hard requirement you'll have to eat the cost & performance +problems of an external solution or choose a platform that will let you +do that with direct-attach storage. (Something with a volume manager.) + +>>Do you want to share one big, expensive, reliable unit between +>> multiple systems? Will you be doing failover? +>Yes, and Yes. Really on one other system, a phone system, but it is the +>crux of my business and will be writing a lot of recorded phone calls. I am +>working with a storage company now to set up the failover, I want the db and +>phone systems to never no if the storage switched over. + +If you actually have a couple of systems you're trying to fail over, a +FC SAN may be a reasonable solution. Depending on your reliability +requirement you can have multiple interfaces & FC switches to get +redundant paths and a much higher level of storage reliability than you +could get with direct attach storage. OTOH, if the DB server itself +breaks you're still out of luck. :) You might compare that sort of +solution with a solution that has redundant servers and implements the +failover in software instead of hardware. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Thu Apr 27 11:05:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9EABC11F65C9 + for ; + Thu, 27 Apr 2006 11:05:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27612-07 + for ; + Thu, 27 Apr 2006 11:05:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wumpus.mythic-beasts.com (wumpus.mythic-beasts.com + [212.69.37.9]) by postgresql.org (Postfix) with ESMTP id 0E90111F61DE + for ; + Thu, 27 Apr 2006 11:05:10 -0300 (ADT) +Received: from sphinx.mythic-beasts.com ([212.69.37.6]) + by wumpus.mythic-beasts.com with esmtp (Exim 4.44) + id 1FZ77G-0007L8-Ow + for pgsql-performance@postgresql.org; Thu, 27 Apr 2006 15:05:10 +0100 +Received: from xelah (helo=localhost) + by sphinx.mythic-beasts.com with local-esmtp (Exim 4.51) + id 1FZ77G-0005Cd-Gm + for pgsql-performance@postgresql.org; Thu, 27 Apr 2006 15:05:10 +0100 +Date: Thu, 27 Apr 2006 15:05:10 +0100 (BST) +From: Alex Hayward +X-X-Sender: xelah@sphinx.mythic-beasts.com +To: Pgsql performance +Subject: Re: Hardware: HP StorageWorks MSA 1500 +In-Reply-To: <444D65EE.6040605@paradise.net.nz> +Message-ID: +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E40AA@sesrv12.wirelesscar.com> + <444D65EE.6040605@paradise.net.nz> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/644 +X-Sequence-Number: 18728 + +On Tue, 25 Apr 2006, Mark Kirkwood wrote: + +> Mikael Carneholm wrote: +> +> > +> >> There are two SCSI U320 buses, with seven bays on each. I don't know +> > what the overhead of SCSI is, but you're obviously not going to get > +> > 490MB/s for each set of seven even if the FC could do it. +> > +> +> You should be able to get close to 300Mb/s on each SCSI bus - provided +> the PCI bus on the motherboard is 64-bit and runs at 133Mhz or better +> (64-bit and 66Mhz give you a 524Mb/s limit). + +I've no idea if the MSA1500's controllers use PCI internally. Obviously +this argument applies to the PCI bus you plug your FC adapters in to, +though. + +AIUI it's difficult to get PCI to actually give you it's theoretical +maximum bandwidth. Those speeds are still a lot more than 200MB/s, though. + +> >> Of course your database may not spend all day doing sequential scans +> > one at a time over 14 disks, so it doesn't necessarily matter... +> > +> +> Yeah, it depends on the intended workload, but at some point most +> databases end up IO bound... so you really want to ensure the IO system +> is as capable as possible IMHO. + +IO bound doesn't imply IO bandwidth bound. 14 disks doing a 1ms seek +followed by an 8k read over and over again is a bit over 100MB/s. Adding +in write activity would make a difference, too, since it'd have to go to +at least two disks. There are presumably hot spares, too. + +I still wouldn't really want to be limited to 200MB/s if I expected to use +a full set of 14 disks for active database data where utmost performance +really matters and where there may be some sequential scans going on, +though. + +> > That's probably true, but *knowing* that the max seq scan speed is that +> > high gives you some confidence (true or fake) that the hardware will be +> > sufficient the next 2 years or so. So, if dual 2GBit FC:s still don't +> > deliver more than 200Mb/s, what does? +> > +> +> Most modern PCI-X or PCIe RAID cards will do better than 200Mb/s (e.g. +> 3Ware 9550SX will do ~800Mb/s). +> +> By way of comparison my old PIII with a Promise TX4000 plus 4 IDE drives +> will do 215Mb/s...so being throttled to 200Mb/s on modern hardware seems +> unwise to me. + +Though, of course, these won't do many of the things you can do with a SAN +- like connect several computers, or split a single array in to two pieces +and have two computers access them as if they were separate drives, or +remotely shut down one database machine and then start up another using +the same disks and data. The number of IO operations per second they can +do is likely to be important, too...possibly more important. + +There's 4GB FC, and so presumably 4GB SANs, but that's still not vast +bandwidth. Using multiple FC ports is the other obvious way to do it with +a SAN. I haven't looked, but I suspect you'll need quite a budget to get +that... + +From pgsql-performance-owner@postgresql.org Thu Apr 27 11:53:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 12D4911F61DE + for ; + Thu, 27 Apr 2006 11:53:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 41270-01 + for ; + Thu, 27 Apr 2006 11:53:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 461A111F60BF + for ; + Thu, 27 Apr 2006 11:53:33 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3RErS4r011094; + Thu, 27 Apr 2006 10:53:28 -0400 (EDT) +To: guoping.zhang@nec.com.au +cc: pgsql-performance@postgresql.org, + "Guoping Zhang (E-mail)" +Subject: Re: how unsafe (or worst scenarios) when setting fsync OFF for + postgresql +In-reply-to: <003b01c669c4$34bbd7b0$74304c93@eddy> +References: <003b01c669c4$34bbd7b0$74304c93@eddy> +Comments: In-reply-to "Guoping Zhang" + message dated "Thu, 27 Apr 2006 16:31:23 +1000" +Date: Thu, 27 Apr 2006 10:53:28 -0400 +Message-ID: <11093.1146149608@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/645 +X-Sequence-Number: 18729 + +"Guoping Zhang" writes: +> Our application has a strict speed requirement for DB operation. Our tests +> show that it takes about 10secs for the operation when setting fsync off, +> but takes about 70 seconds when setting fsync ON (with other WAL related +> parametered tuned). + +I can't believe that a properly tuned application would have an fsync +penalty that large. Are you performing that "operation" as several +thousand small transactions, or some such? Try grouping the operations +into one (or at most a few) transactions. Also, what wal_buffers and +wal_sync_method settings are you using, and have you experimented with +alternatives? What sort of platform is this on? What PG version? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 27 11:58:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 951C311F6262 + for ; + Thu, 27 Apr 2006 11:58:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 39188-03 + for ; + Thu, 27 Apr 2006 11:57:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2F8EF11F60AE + for ; + Thu, 27 Apr 2006 11:57:55 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3REvkW5011143; + Thu, 27 Apr 2006 10:57:46 -0400 (EDT) +To: Simon Riggs +cc: guoping.zhang@nec.com.au, pgsql-performance@postgresql.org, + "Guoping Zhang (E-mail)" +Subject: Re: how unsafe (or worst scenarios) when setting fsync +In-reply-to: <1146121984.3120.56.camel@localhost.localdomain> +References: <003b01c669c4$34bbd7b0$74304c93@eddy> + <1146121984.3120.56.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Thu, 27 Apr 2006 08:13:04 +0100" +Date: Thu, 27 Apr 2006 10:57:46 -0400 +Message-ID: <11142.1146149866@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/646 +X-Sequence-Number: 18730 + +Simon Riggs writes: +> On Thu, 2006-04-27 at 16:31 +1000, Guoping Zhang wrote: +>> Can we set fsync OFF for the performance benefit, have the risk of only 5 +>> minutes data loss or much worse? + +> Thats up to you. + +> fsync can be turned on and off, so you can make critical changes with +> fsync on, then continue with fsync off. + +I think it would be a mistake to assume that the behavior would be +nice clean "we only lost recent changes". Things could get arbitrarily +badly corrupted if some writes make it to disk and some don't. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 27 12:11:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C1B1B11F6282 + for ; + Thu, 27 Apr 2006 12:11:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 39210-08 + for ; + Thu, 27 Apr 2006 12:11:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 1465A11F60AE + for ; + Thu, 27 Apr 2006 12:11:45 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id AD13EB827 + for ; + Thu, 27 Apr 2006 11:11:43 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <3EF41DD8-1073-4EAC-B6D7-4A78BE7549F8@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Large (8M) cache vs. dual-core CPUs +Date: Thu, 27 Apr 2006 11:11:42 -0400 +To: Pgsql performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/647 +X-Sequence-Number: 18731 + + +On Apr 25, 2006, at 2:14 PM, Bill Moran wrote: + +> Where I'm stuck is in deciding whether we want to go with dual-core +> pentiums with 2M cache, or with HT pentiums with 8M cache. + +In order of preference: + +Opterons (dual core or single core) +Xeon with HT *disabled* at the BIOS level (dual or single core) + + +Notice Xeon with HT is not on my list :-) + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 12:19:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 030C111F60AE + for ; + Thu, 27 Apr 2006 12:19:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40671-04 + for ; + Thu, 27 Apr 2006 12:19:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id E351111F6285 + for ; + Thu, 27 Apr 2006 12:19:37 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 5C848B827 + for ; + Thu, 27 Apr 2006 11:19:37 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: + <26953267.1145999393194.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +References: + <26953267.1145999393194.JavaMail.root@elwamui-mouette.atl.sa.earthlink.net> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <28EEAFE6-22FA-4CC3-81BC-45E14CD530CA@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Large (8M) cache vs. dual-core CPUs +Date: Thu, 27 Apr 2006 11:19:36 -0400 +To: Pgsql performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/648 +X-Sequence-Number: 18732 + + +On Apr 25, 2006, at 5:09 PM, Ron Peacetree wrote: + +> ...and even if you do buy Intel, =DON"T= buy Dell unless you like +> causing trouble for yourself. +> Bad experiences with Dell in general and their poor PERC RAID +> controllers in specific are all over this and other DB forums. + +I don't think that their current controllers suck like their older +ones did. That's what you'll read about in the archives -- the old +stuff. Eg, the 1850's embedded RAID controller really flies, but it +only works with the internal disks. I can't comment on the external +array controller for the 1850, but I cannot imagine it being any slower. + +And personally, I've not experienced any major problems aside from +two bad PE1550's 4 years ago. And I have currently about 15 Dell +servers running 24x7x365 doing various tasks, including postgres. + +However, my *big* databases always go on dual opteron boxes. my +current favorite is the SunFire X4100 with an external RAID. + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 13:13:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9589011F6228 + for ; + Thu, 27 Apr 2006 13:13:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 66201-04 + for ; + Thu, 27 Apr 2006 13:13:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id ADD9E11F60E3 + for ; + Thu, 27 Apr 2006 13:13:27 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3RGDQ1m011870; + Thu, 27 Apr 2006 12:13:26 -0400 (EDT) +To: "andremachado" +cc: pgsql-performance@postgresql.org +Subject: Re: Firebird 1.5.3 X Postgresql 8.1.3 (linux Firebird 1.5.3 X + Postgresql 8.1.3 (linux and and windows)] +In-reply-to: <20060427122235.M42721@techforce.com.br> +References: <20060427122235.M42721@techforce.com.br> +Comments: In-reply-to "andremachado" + message dated "Thu, 27 Apr 2006 10:32:31 -0200" +Date: Thu, 27 Apr 2006 12:13:26 -0400 +Message-ID: <11869.1146154406@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/649 +X-Sequence-Number: 18733 + +"andremachado" writes: +> Firebird has something similiar to EXPLAIN. Please look below. + +Hm, maybe I just don't know how to read their output, but it's not +obvious to me where they are doing the min/max aggregates. + +> Is there something really wrong with the postgresql configuration (at my +> previous msg) that is causing this poor performance at these 2 queries? + +I don't think it's a configuration issue, it's a quality-of-plan issue. + +Could you put together a self-contained test case for this problem? I +don't have the time or interest to try to reverse-engineer tables and +test data for these queries --- but I would be interested in finding out +where the time is going, if I could run the queries. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 27 14:50:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C1BE111F620C + for ; + Thu, 27 Apr 2006 14:50:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97833-03 + for ; + Thu, 27 Apr 2006 14:50:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 44F1911F60E5 + for ; + Thu, 27 Apr 2006 14:50:32 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 54E8456423; Thu, 27 Apr 2006 12:50:17 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 27 Apr 2006 12:50:16 -0500 +Date: Thu, 27 Apr 2006 12:50:16 -0500 +From: "Jim C. Nasby" +To: Ketema Harris , pgsql-performance@postgresql.org +Subject: Re: Running on an NFS Mounted Directory +Message-ID: <20060427175016.GH97354@pervasive.com> +References: <20060427132452.GG31328@mathom.us> + + <20060427140417.GH31328@mathom.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060427140417.GH31328@mathom.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060427:ketema@gmail.com::OUtvWD/w4nKEJmi0:04ZzH +X-Hashcash: + 1:20:060427:pgsql-performance@postgresql.org::gjmrtUjNLQgQCcmU:00000 + 0000000000000000000000001Fqw +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/650 +X-Sequence-Number: 18734 + +On Thu, Apr 27, 2006 at 10:04:19AM -0400, Michael Stone wrote: +> >>redundancy, expandability +> >What I mean by these stupid flavor words is: +> >Redundancy : raid 5. +> +> You can get that without external storage. + +Yes, but some dedicated storage devices actually provide good +performance with RAID5. Most simpler solutions give pretty abysmal write +performance. + +> >>Do you +> >>need the ability to do snapshots? +> >Yes. +> +> If that's a hard requirement you'll have to eat the cost & performance +> problems of an external solution or choose a platform that will let you +> do that with direct-attach storage. (Something with a volume manager.) + +I'm wondering if PITR would suffice. Or maybe even Slony. + +> >>Do you want to share one big, expensive, reliable unit between +> >>multiple systems? Will you be doing failover? +> >Yes, and Yes. Really on one other system, a phone system, but it is the +> >crux of my business and will be writing a lot of recorded phone calls. I am +> >working with a storage company now to set up the failover, I want the db +> >and +> >phone systems to never no if the storage switched over. +> +> If you actually have a couple of systems you're trying to fail over, a +> FC SAN may be a reasonable solution. Depending on your reliability +> requirement you can have multiple interfaces & FC switches to get +> redundant paths and a much higher level of storage reliability than you +> could get with direct attach storage. OTOH, if the DB server itself +> breaks you're still out of luck. :) You might compare that sort of +> solution with a solution that has redundant servers and implements the +> failover in software instead of hardware. + +BTW, I know a company here in Austin that does capacity planning for +complex systems like this; contact me off-list if you're interested in +talking to them. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu Apr 27 14:57:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3210011F620E + for ; + Thu, 27 Apr 2006 14:57:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 00111-03 + for ; + Thu, 27 Apr 2006 14:57:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) + by postgresql.org (Postfix) with ESMTP id 6653A11F61EE + for ; + Thu, 27 Apr 2006 14:57:10 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYE00GBF77AO6Z5@vms046.mailsrvcs.net> for + pgsql-performance@postgresql.org; Thu, 27 Apr 2006 12:57:10 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 4FB8E6E6C0 for + ; + Thu, 27 Apr 2006 13:57:08 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 18998-01 for ; Thu, + 27 Apr 2006 13:57:07 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id BE6E76E945; Thu, 27 Apr 2006 13:57:06 -0400 (EDT) +Date: Thu, 27 Apr 2006 13:57:06 -0400 +From: Michael Stone +Subject: Re: Running on an NFS Mounted Directory +In-reply-to: <20060427175016.GH97354@pervasive.com> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060427175704.GI31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060427132452.GG31328@mathom.us> + + <20060427140417.GH31328@mathom.us> + <20060427175016.GH97354@pervasive.com> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/651 +X-Sequence-Number: 18735 + +On Thu, Apr 27, 2006 at 12:50:16PM -0500, Jim C. Nasby wrote: +>Yes, but some dedicated storage devices actually provide good +>performance with RAID5. Most simpler solutions give pretty abysmal write +>performance. + +dedicated storage device != SAN != NAS. You can get good performance in +a dedicated direct-attach device without paying for the SAN/NAS +infrastructure if you don't need it; you don't have to go right from EMC +to PERC with nothing in the middle. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Thu Apr 27 15:12:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A4DEB11F61F0 + for ; + Thu, 27 Apr 2006 15:12:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03936-05 + for ; + Thu, 27 Apr 2006 15:12:06 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 8D8B211F61E8 + for ; + Thu, 27 Apr 2006 15:12:04 -0300 (ADT) +Received: from hotmail.com (bay101-f19.bay101.hotmail.com [64.4.56.29]) + by svr4.postgresql.org (Postfix) with ESMTP id 5BFFD5B5DF1 + for ; + Thu, 27 Apr 2006 18:12:04 +0000 (GMT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 27 Apr 2006 11:12:02 -0700 +Message-ID: +Received: from 64.4.56.200 by by101fd.bay101.hotmail.msn.com with HTTP; + Thu, 27 Apr 2006 18:12:01 GMT +X-Originating-IP: [84.210.10.106] +X-Originating-Email: [bealach_na_bo@hotmail.com] +X-Sender: bealach_na_bo@hotmail.com +From: "Bealach-na Bo" +To: pgsql-performance@postgresql.org +Subject: Why so slow? +Date: Thu, 27 Apr 2006 18:12:01 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +X-OriginalArrivalTime: 27 Apr 2006 18:12:02.0437 (UTC) + FILETIME=[153EB350:01C66A26] +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=0.693 tagged_above=0 required=5 tests=BAYES_00, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, MSGID_FROM_MTA_HEADER, + SPF_SOFTFAIL +X-Spam-Level: +X-Archive-Number: 200604/652 +X-Sequence-Number: 18736 + +Hi folks, + +Sorry to be bringing this up again, but I'm stumped by this problem +and hope you can shed some light on it. + +I'm running postgresql 8.0 on a RLE4 server with 1.5 GB of RAM and a +Xenon 2 GHz CPU. The OS is bog standard and I've not done any kernel +tuning on it. The file system is also bog standard ext3 with no raid +of any kind. I know I could improve this aspect of the set up with +more disks and raid 0+1 etc, but the lack of performance that I'm +experiencing is not likely to be attributable to this sort of +thing. More likely it's my bad understanding of Postgresql - I hope +it's my bad understanding of Postgresql!! + +My database is very simple and not by the book (normal forms etc. are +not all as they should be). My biggest table, by a factor of 3000 or +so is one of 4 tables in my tiny database. It looks like this + + + +\d job_log + Table "job_log" + Column | Type | Modifiers +----------------+-----------------------------+-------------------------------------------------- +job_log_id | integer | not null default +nextval('job_log_id_seq'::text) +first_registry | timestamp without time zone | +customer_name | character(50) | +node_id | integer | +job_type | character(50) | +job_name | character(256) | +job_start | timestamp without time zone | +job_timeout | interval | +job_stop | timestamp without time zone | +nfiles_in_job | integer | +status | integer | +error_code | smallint | +file_details | text | +Indexes: + "job_log_id_pkey" PRIMARY KEY, btree (job_log_id) + "idx_customer_name_filter" btree (customer_name) + "idx_job_name_filter" btree (job_name) + "idx_job_start_filter" btree (job_start) + "idx_job_stop_filter" btree (job_stop) +Check constraints: + "job_log_status_check" CHECK (status = 0 OR status = 1 OR status = 8 OR +status = 9) +Foreign-key constraints: + "legal_node" FOREIGN KEY (node_id) REFERENCES node(node_id) + + +The node table is tiny (2500 records). What I'm pulling my hair out +over is that ANY Query, even something as simple as select count(*) +form job_log takes of the order of tens of minutes to complete. Just +now I'm trying to run an explain analyze on the above query, but so +far, it's taken 35min! with no result and there is a postgres process at +the top of top + +What am I doing wrong?? + +Many thanks, + +Bealach + + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 15:27:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3DA9311F660E + for ; + Thu, 27 Apr 2006 15:27:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06620-05 + for ; + Thu, 27 Apr 2006 15:27:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from 137086.vserver.de (vs137086.vserver.de [62.75.137.86]) + by postgresql.org (Postfix) with ESMTP id 57F2811F6641 + for ; + Thu, 27 Apr 2006 15:27:37 -0300 (ADT) +Received: from a-kretschmer.de (p54B3A7CA.dip0.t-ipconnect.de + [84.179.167.202]) + (authenticated bits=0) + by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id k3RIRTvU015378 + for ; Thu, 27 Apr 2006 20:27:31 +0200 +Received: from kretschmer by a-kretschmer.de with local (Exim 4.61) + (envelope-from ) id 1FZBDz-0008EQ-IF + for pgsql-performance@postgresql.org; Thu, 27 Apr 2006 20:28:23 +0200 +Date: Thu, 27 Apr 2006 20:28:23 +0200 +From: Andreas Kretschmer +To: pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Message-ID: <20060427182823.GA29375@KanotixBox> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: +X-OS: Debian/GNU Linux - weil ich es mir Wert bin! +X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA +X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the + answer is "no"! +X-Lugdd: Gerd Kube +X-Info: My name is root. Just root. And I am licensed to kill -9 +User-Agent: mutt-ng 1.5.9i (Linux) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/653 +X-Sequence-Number: 18737 + +Bealach-na Bo schrieb: +> The node table is tiny (2500 records). What I'm pulling my hair out +> over is that ANY Query, even something as simple as select count(*) +> form job_log takes of the order of tens of minutes to complete. Just +> now I'm trying to run an explain analyze on the above query, but so +> far, it's taken 35min! with no result and there is a postgres process at +> the top of top +> +> What am I doing wrong?? + +The 'explain analyse' don't return a result, but it returns the query +plan and importance details, how PG works. + +That's why you should paste the query and the 'explain analyse' - +output. This is very important. + +Anyway, do you periodical vacuum your DB? My guess: no, and that's why +you have many dead rows. + +20:26 < akretschmer|home> ??vacuum +20:26 < rtfm_please> For information about vacuum +20:26 < rtfm_please> see http://developer.postgresql.org/~wieck/vacuum_cost/ +20:26 < rtfm_please> or http://www.postgresql.org/docs/current/static/sql-vacuum.html +20:26 < rtfm_please> or http://www.varlena.com/varlena/GeneralBits/116.php + +20:27 < akretschmer|home> ??explain +20:27 < rtfm_please> For information about explain +20:27 < rtfm_please> see http://techdocs.postgresql.org/oscon2005/robert.treat/OSCON_Explaining_Explain_Public.sxi +20:27 < rtfm_please> or http://www.gtsm.com/oscon2003/toc.html +20:27 < rtfm_please> or http://www.postgresql.org/docs/current/static/sql-explain.html + + +Read this links for more informations about vacuum and explain. + + +HTH, Andreas +-- +Really, I'm not out to destroy Microsoft. That will just be a completely +unintentional side effect. (Linus Torvalds) +"If I was god, I would recompile penguin with --enable-fly." (unknow) +Kaufbach, Saxony, Germany, Europe. N 51.05082�, E 13.56889� + +From pgsql-performance-owner@postgresql.org Thu Apr 27 15:46:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BCE2C11F60E3 + for ; + Thu, 27 Apr 2006 15:46:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 08477-05 + for ; + Thu, 27 Apr 2006 15:45:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 889AE11F66C3 + for ; + Thu, 27 Apr 2006 15:45:57 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 81DBA30E5A; Thu, 27 Apr 2006 20:45:56 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: CPU usage goes to 100%, query seems to ran forever +Date: Thu, 27 Apr 2006 21:44:49 +0300 +Organization: Hub.Org Networking Services +Lines: 76 +Message-ID: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/654 +X-Sequence-Number: 18738 + +I have small database running in 8.1.3 in W2K server. +The following query causes Postgres process to use 100% CPU and seems to run +forever. +If I change '1EEKPANT' to less frequently used item code, it runs fast. + +How to speed it up ? + +set search_path to public,firma2; + select rid.toode + FROM dok JOIN rid USING (dokumnr) + JOIN toode USING (toode) + LEFT JOIN artliik ON toode.grupp=artliik.grupp and + toode.liik=artliik.liik + WHERE (NOT '0' or dok.kinnitatud) + AND dok.kuupaev BETWEEN '2006-04-08' AND '2006-04-27' + AND rid.toode='1EEKPANT' + AND (NOT dok.eimuuda or '0' ) and + dok.laonr='1'::float8 and + POSITION( dok.doktyyp IN 'OSIDVGYKIF')!=0 AND + ( ( ('1' OR (POSITION(dok.doktyyp IN 'TUNH')=0 and + (rid.kogus<0 or + ('1' and rid.kogus=0)))) + and + POSITION(dok.doktyyp IN 'VGYKITDNHMEBARCFJ' )!=0 + AND CASE WHEN NOT dok.objrealt OR dok.doktyyp='I' THEN dok.yksus +ELSE rid.kuluobjekt END LIKE 'LADU%' ESCAPE '!' + ) + OR + (POSITION(dok.doktyyp IN 'OSIUDP' )!=0 + AND CASE WHEN dok.objrealt THEN rid.kuluobjekt ELSE dok.sihtyksus +END LIKE 'LADU%' ESCAPE '!' + ) + ) + AND dok.kuupaev||dok.kellaaeg BETWEEN '2006-04-08' AND '2006-04-2723 59' + AND ('0' or ( length(trim(rid.toode))>2 AND + rid.toode is NOT NULL)) + + AND ( LENGTH('' )=0 OR rid.partii='' OR (dok.doktyyp='I' AND + rid.kulupartii='' ) ) + AND (NOT dok.inventuur or rid.kogus!=0) + AND dok.dokumnr!= 0 + AND ( artliik.arttyyp NOT IN ('Teenus', 'Komplekt' ) OR artliik.arttyyp IS +NULL) + + +explain returns: + +"Nested Loop Left Join (cost=0.00..1828.18 rows=1 width=24)" +" Filter: ((("inner".arttyyp <> 'Teenus'::bpchar) AND ("inner".arttyyp <> +'Komplekt'::bpchar)) OR ("inner".arttyyp IS NULL))" +" -> Nested Loop (cost=0.00..1822.51 rows=1 width=43)" +" -> Nested Loop (cost=0.00..1816.56 rows=1 width=24)" +" Join Filter: (("outer".dokumnr = "inner".dokumnr) AND +((("position"('VGYKITDNHMEBARCFJ'::text, ("outer".doktyyp)::text) <> 0) AND +(CASE WHEN ((NOT ("outer".objrealt)::boolean) OR ("outer".doktyyp = +'I'::bpchar)) THEN "outer".yksus ELSE "inner (..)" +" -> Seq Scan on dok (cost=0.00..787.80 rows=1 width=39)" +" Filter: ((kuupaev >= '2006-04-08'::date) AND (kuupaev +<= '2006-04-27'::date) AND (NOT (eimuuda)::boolean) AND ((laonr)::double +precision = 1::double precision) AND ("position"('OSIDVGYKIF'::text, +(doktyyp)::text) <> 0) AND (((kuupaev):: (..)" +" -> Seq Scan on rid (cost=0.00..1019.42 rows=249 width=51)" +" Filter: ((toode = '1EEKPANT'::bpchar) AND +(length(btrim((toode)::text)) > 2) AND (toode IS NOT NULL))" +" -> Index Scan using toode_pkey on toode (cost=0.00..5.94 rows=1 +width=43)" +" Index Cond: ('1EEKPANT'::bpchar = toode)" +" -> Index Scan using artliik_pkey on artliik (cost=0.00..5.65 rows=1 +width=88)" +" Index Cond: (("outer".grupp = artliik.grupp) AND ("outer".liik = +artliik.liik))" + + +Andrus. + + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 16:00:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9D50D11F6750 + for ; + Thu, 27 Apr 2006 16:00:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 14449-03 + for ; + Thu, 27 Apr 2006 15:59:56 -0300 (ADT) +X-Greylist: delayed 14:15:58.359001 by SQLgrey- +Received: from corpmail.hi5.com (corpmail.hi5.com [204.13.49.5]) + by postgresql.org (Postfix) with ESMTP id 88B7811F66E7 + for ; + Thu, 27 Apr 2006 15:59:55 -0300 (ADT) +Received: from [192.168.1.133] by hi5.com (MDaemon PRO v9.0.0 trial) + with ESMTP id md50002978775.msg + for ; Thu, 27 Apr 2006 11:59:06 -0700 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: Bruno Wolff III , + Michael Stone , + +Content-Transfer-Encoding: 7bit +From: Dan Gorman +Subject: Re: Running on an NFS Mounted Directory +Date: Thu, 27 Apr 2006 11:58:59 -0700 +To: Ketema Harris +X-Mailer: Apple Mail (2.749.3) +X-Authenticated-Sender: dgorman@hi5.com +X-Spam-Processed: corpmail, Thu, 27 Apr 2006 11:59:06 -0700 + (not processed: message from valid local sender) +X-MDRemoteIP: 66.237.43.131 +X-Return-Path: dgorman@hi5.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-MDAV-Processed: corpmail, Thu, 27 Apr 2006 11:59:06 -0700 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/655 +X-Sequence-Number: 18739 + +So do NAS's + +Dan + +On Apr 27, 2006, at 6:42 AM, Ketema Harris wrote: + +> The SAN has the snapshot capability. +> +> +> On 4/27/06 9:31 AM, "Bruno Wolff III" wrote: +> +>> On Thu, Apr 27, 2006 at 09:06:48 -0400, +>> Ketema Harris wrote: +>>> Yes, your right, I meant not have to do the backups from the db +>>> server +>>> itself. I can do that within the storage device now, by +>>> allocating space +>>> for it, and letting the device copy the data files on some +>>> periodic basis. +>> +>> Only if the database server isn't running or your SAN provides a +>> way to +>> provide a snapshot of the data at a particular instant in time. +> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + + + +From pgsql-performance-owner@postgresql.org Thu Apr 27 16:09:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3B50811F6ADE + for ; + Thu, 27 Apr 2006 16:09:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 13258-06 + for ; + Thu, 27 Apr 2006 16:09:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 456C311F674D + for ; + Thu, 27 Apr 2006 16:09:18 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3RJ9DdA014691; + Thu, 27 Apr 2006 15:09:13 -0400 (EDT) +To: "Andrus" +cc: pgsql-performance@postgresql.org +Subject: Re: CPU usage goes to 100%, query seems to ran forever +In-reply-to: +References: +Comments: In-reply-to "Andrus" + message dated "Thu, 27 Apr 2006 21:44:49 +0300" +Date: Thu, 27 Apr 2006 15:09:13 -0400 +Message-ID: <14690.1146164953@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/656 +X-Sequence-Number: 18740 + +"Andrus" writes: +> I have small database running in 8.1.3 in W2K server. +> The following query causes Postgres process to use 100% CPU and seems to run +> forever. +> If I change '1EEKPANT' to less frequently used item code, it runs fast. + +You have ANALYZEd all these tables recently, I hope? The planner +certainly doesn't think this query will take very long. + +To find out what's wrong, you're going to have to be patient enough to +let an EXPLAIN ANALYZE run to completion. Plain EXPLAIN won't tell. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Apr 27 23:31:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1F34411F66E7 + for ; + Thu, 27 Apr 2006 23:31:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 51727-07 + for ; + Thu, 27 Apr 2006 23:30:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz + [203.96.152.180]) + by postgresql.org (Postfix) with ESMTP id 9916611F61F0 + for ; + Thu, 27 Apr 2006 23:30:53 -0300 (ADT) +Received: from smtp-3.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-1.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IYE003QQUZ8IK@linda-1.paradise.net.nz> for + pgsql-performance@postgresql.org; Fri, 28 Apr 2006 14:30:44 +1200 (NZST) +Received: from [192.168.1.11] (218-101-29-28.dsl.clear.net.nz [218.101.29.28]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id AC4F1E342E9; Fri, + 28 Apr 2006 14:30:43 +1200 (NZST) +Date: Fri, 28 Apr 2006 14:30:36 +1200 +From: Mark Kirkwood +Subject: Re: Hardware: HP StorageWorks MSA 1500 +In-reply-to: +To: Alex Hayward +Cc: Pgsql performance +Message-id: <44517E4C.3090809@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Thunderbird 1.5 (X11/20060417) +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E40AA@sesrv12.wirelesscar.com> + <444D65EE.6040605@paradise.net.nz> + +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/657 +X-Sequence-Number: 18741 + +Alex Hayward wrote: + +> +> IO bound doesn't imply IO bandwidth bound. 14 disks doing a 1ms seek +> followed by an 8k read over and over again is a bit over 100MB/s. Adding +> in write activity would make a difference, too, since it'd have to go to +> at least two disks. There are presumably hot spares, too. +> + +Very true - if your workload is primarily random, ~100Mb/s may be enough +bandwidth. + +> I still wouldn't really want to be limited to 200MB/s if I expected to use +> a full set of 14 disks for active database data where utmost performance +> really matters and where there may be some sequential scans going on, +> though. +> + +Yeah - thats the rub, Data mining, bulk loads, batch updates, backups +(restores....) often use significant bandwidth. + +> Though, of course, these won't do many of the things you can do with a SAN +> - like connect several computers, or split a single array in to two pieces +> and have two computers access them as if they were separate drives, or +> remotely shut down one database machine and then start up another using +> the same disks and data. The number of IO operations per second they can +> do is likely to be important, too...possibly more important. +> + +SAN flexibility is nice (when it works as advertised), the cost and +performance however, are the main detractors. On that note I don't +recall IO/s being anything special on most SAN gear I've seen (this +could have changed for later products I guess). + +> There's 4GB FC, and so presumably 4GB SANs, but that's still not vast +> bandwidth. Using multiple FC ports is the other obvious way to do it with +> a SAN. I haven't looked, but I suspect you'll need quite a budget to get +> that... +> + +Yes - the last place I worked were looking at doing this ('multiple +attachment' was the buzz word I think) - I recall it needed special +(read extra expensive) switches and particular cards... + +Cheers + +Mark + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 01:43:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 87C4011F6474 + for ; + Fri, 28 Apr 2006 01:43:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 25881-05 + for ; + Fri, 28 Apr 2006 01:43:32 -0300 (ADT) +X-Greylist: delayed 22:12:02.081086 by SQLgrey- +Received: from ns2.nec.com.au (ns2.nec.com.au [147.76.180.2]) + by postgresql.org (Postfix) with ESMTP id A9DE111F6483 + for ; + Fri, 28 Apr 2006 01:43:31 -0300 (ADT) +Received: from ns2.nec.com.au ([127.0.0.1]) + by localhost (ns2.nec.com.au [127.0.0.1]) (amavisd-new, + port 10024) with LMTP + id 30409-01-21 for ; + Fri, 28 Apr 2006 14:43:28 +1000 (EST) +Received: from smtp1.nec.com.au (unknown [172.31.8.18]) + by ns2.nec.com.au (Postfix) with ESMTP id C74193B6B4 + for ; + Fri, 28 Apr 2006 14:43:28 +1000 (EST) +Received: from eddy (eddy.ssd.neca.nec.com.au [147.76.48.116]) + by warp.ssd.neca.nec.com.au (8.12.10+Sun/8.12.10) with SMTP id + k3S4hRuP026162; Fri, 28 Apr 2006 14:43:27 +1000 (EST) +Reply-To: +From: "Guoping Zhang" +To: "'Tom Lane'" +Cc: , + "'Guoping Zhang (E-mail)'" +Subject: Re: how unsafe (or worst scenarios) when setting fsync OFF for + postgresql +Date: Fri, 28 Apr 2006 14:43:26 +1000 +Message-ID: <004101c66a7e$4ab95000$74304c93@eddy> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 8bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +In-Reply-To: <11093.1146149608@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/658 +X-Sequence-Number: 18742 + +Hi, Tom, + +Thanks for the reply. + +a) The tests consists of ten thousands very small transactions, which are +not grouped, that is why so slow with compare to set fsync off. +b) we are using Solaris 10 on a SUN Fire 240 SPARC machine with a latest +postgresql release (8.1.3) +c) wal_sync_method is set to 'open_datasync', which is fastest among the +four, right? +d) wal_buffers set to 32 + +Looks like, if we have to set fsync be true, we need to modify our +application. + +Thanks and regards, +Guoping + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Tom Lane +Sent: 2006��4��28�� 0:53 +To: guoping.zhang@nec.com.au +Cc: pgsql-performance@postgresql.org; Guoping Zhang (E-mail) +Subject: Re: [PERFORM] how unsafe (or worst scenarios) when setting +fsync OFF for postgresql + + +"Guoping Zhang" writes: +> Our application has a strict speed requirement for DB operation. Our tests +> show that it takes about 10secs for the operation when setting fsync off, +> but takes about 70 seconds when setting fsync ON (with other WAL related +> parametered tuned). + +I can't believe that a properly tuned application would have an fsync +penalty that large. Are you performing that "operation" as several +thousand small transactions, or some such? Try grouping the operations +into one (or at most a few) transactions. Also, what wal_buffers and +wal_sync_method settings are you using, and have you experimented with +alternatives? What sort of platform is this on? What PG version? + + regards, tom lane + +---------------------------(end of broadcast)--------------------------- +TIP 6: explain analyze is your friend + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 01:57:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F23D911F6474 + for ; + Fri, 28 Apr 2006 01:57:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 28866-09 + for ; + Fri, 28 Apr 2006 01:56:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 44C7911F647F + for ; + Fri, 28 Apr 2006 01:56:53 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3S4um0G025292; + Fri, 28 Apr 2006 00:56:49 -0400 (EDT) +To: guoping.zhang@nec.com.au +cc: pgsql-performance@postgresql.org, + "'Guoping Zhang (E-mail)'" +Subject: Re: how unsafe (or worst scenarios) when setting fsync OFF for + postgresql +In-reply-to: <004101c66a7e$4ab95000$74304c93@eddy> +References: <004101c66a7e$4ab95000$74304c93@eddy> +Comments: In-reply-to "Guoping Zhang" + message dated "Fri, 28 Apr 2006 14:43:26 +1000" +Date: Fri, 28 Apr 2006 00:56:48 -0400 +Message-ID: <25291.1146200208@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/659 +X-Sequence-Number: 18743 + +"Guoping Zhang" writes: +> a) The tests consists of ten thousands very small transactions, which are +> not grouped, that is why so slow with compare to set fsync off. + +Yup. + +> c) wal_sync_method is set to 'open_datasync', which is fastest among the +> four, right? + +Well, is it? You shouldn't assume that without testing. + +> Looks like, if we have to set fsync be true, we need to modify our +> application. + +Yes, you should definitely look into batching your operations into +larger transactions. On normal hardware you can't expect to commit +transactions faster than one per disk revolution (unless they're coming +from multiple clients, where there's a hope of ganging several parallel +commits per revolution). + +Or buy a disk controller with battery-backed write cache and put your +faith in that cache surviving a machine crash. But don't turn off fsync +if you care about your data. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 28 02:01:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A68E711F6475 + for ; + Fri, 28 Apr 2006 02:01:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 46031-08 + for ; + Fri, 28 Apr 2006 02:01:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ns2.nec.com.au (ns2.nec.com.au [147.76.180.2]) + by postgresql.org (Postfix) with ESMTP id C45DC11F6251 + for ; + Fri, 28 Apr 2006 02:01:20 -0300 (ADT) +Received: from ns2.nec.com.au ([127.0.0.1]) + by localhost (ns2.nec.com.au [127.0.0.1]) (amavisd-new, + port 10024) with LMTP + id 30410-01-89 for ; + Fri, 28 Apr 2006 15:01:19 +1000 (EST) +Received: from smtp1.nec.com.au (unknown [172.31.8.18]) + by ns2.nec.com.au (Postfix) with ESMTP id CBBCA3B6E7 + for ; + Fri, 28 Apr 2006 15:01:19 +1000 (EST) +Received: from eddy (eddy.ssd.neca.nec.com.au [147.76.48.116]) + by warp.ssd.neca.nec.com.au (8.12.10+Sun/8.12.10) with SMTP id + k3S51IuP026592; Fri, 28 Apr 2006 15:01:18 +1000 (EST) +Reply-To: +From: "Guoping Zhang" +To: "'Tom Lane'" , "'Simon Riggs'" +Cc: , + "'Guoping Zhang (E-mail)'" +Subject: Re: how unsafe (or worst scenarios) when setting fsync +Date: Fri, 28 Apr 2006 15:01:17 +1000 +Message-ID: <004201c66a80$c8f86d00$74304c93@eddy> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 8bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +In-Reply-To: <11142.1146149866@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/660 +X-Sequence-Number: 18744 + +Hi, Simon/tom, + +Thanks for the reply. + +It appears to me that we have to set fsync ON, as a badly corrupted database +by any chance in production line +will lead a serious problem. + +However, when try the differnt 'wal_sync_method' setting, lead a quite +different operation time (open_datasync is best for speed). + +But altering the commit_delay from 1 to 100000, I observed that there is no +time difference for the operation. Why is that? As our tests consists of +10000 small transactions which completed in 66 seconds, that is, about 160 +transactions per second. When commit_delay set to 100000 (i.e., 0.1 second), +that in theory, shall group around 16 transactions into one commit, but +result is same from the repeated test. Am I mistaken something here? + +Cheers and Regards, +Guoping + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: 2006��4��28�� 0:58 +To: Simon Riggs +Cc: guoping.zhang@nec.com.au; pgsql-performance@postgresql.org; Guoping +Zhang (E-mail) +Subject: Re: [PERFORM] how unsafe (or worst scenarios) when setting +fsync + + +Simon Riggs writes: +> On Thu, 2006-04-27 at 16:31 +1000, Guoping Zhang wrote: +>> Can we set fsync OFF for the performance benefit, have the risk of only 5 +>> minutes data loss or much worse? + +> Thats up to you. + +> fsync can be turned on and off, so you can make critical changes with +> fsync on, then continue with fsync off. + +I think it would be a mistake to assume that the behavior would be +nice clean "we only lost recent changes". Things could get arbitrarily +badly corrupted if some writes make it to disk and some don't. + + regards, tom lane + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 02:06:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 81AA211F6478 + for ; + Fri, 28 Apr 2006 02:06:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 32849-09 + for ; + Fri, 28 Apr 2006 02:05:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 410B211F6251 + for ; + Fri, 28 Apr 2006 02:05:56 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3S55mgi025361; + Fri, 28 Apr 2006 01:05:48 -0400 (EDT) +To: guoping.zhang@nec.com.au +cc: "'Simon Riggs'" , pgsql-performance@postgresql.org, + "'Guoping Zhang (E-mail)'" +Subject: Re: how unsafe (or worst scenarios) when setting fsync +In-reply-to: <004201c66a80$c8f86d00$74304c93@eddy> +References: <004201c66a80$c8f86d00$74304c93@eddy> +Comments: In-reply-to "Guoping Zhang" + message dated "Fri, 28 Apr 2006 15:01:17 +1000" +Date: Fri, 28 Apr 2006 01:05:48 -0400 +Message-ID: <25360.1146200748@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/661 +X-Sequence-Number: 18745 + +"Guoping Zhang" writes: +> But altering the commit_delay from 1 to 100000, I observed that there is no +> time difference for the operation. Why is that? As our tests consists of +> 10000 small transactions which completed in 66 seconds, that is, about 160 +> transactions per second. When commit_delay set to 100000 (i.e., 0.1 second), +> that in theory, shall group around 16 transactions into one commit, but +> result is same from the repeated test. Am I mistaken something here? + +commit_delay can only help if there are multiple clients issuing +transactions concurrently, so that there are multiple commits pending at +the same instant. If you are issuing one serial stream of transactions, +it's useless. + +If you do have multiple active clients, then we need to look more closely; +but your statement does not indicate that. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 28 02:18:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9D7E311F647B + for ; + Fri, 28 Apr 2006 02:18:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 59048-04 + for ; + Fri, 28 Apr 2006 02:18:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ns2.nec.com.au (ns2.nec.com.au [147.76.180.2]) + by postgresql.org (Postfix) with ESMTP id EFCFC11F6477 + for ; + Fri, 28 Apr 2006 02:18:11 -0300 (ADT) +Received: from ns2.nec.com.au ([127.0.0.1]) + by localhost (ns2.nec.com.au [127.0.0.1]) (amavisd-new, + port 10024) with LMTP + id 30500-01-77 for ; + Fri, 28 Apr 2006 15:18:10 +1000 (EST) +Received: from smtp1.nec.com.au (unknown [172.31.8.18]) + by ns2.nec.com.au (Postfix) with ESMTP id 4E0C73B7A4 + for ; + Fri, 28 Apr 2006 15:18:10 +1000 (EST) +Received: from eddy (eddy.ssd.neca.nec.com.au [147.76.48.116]) + by warp.ssd.neca.nec.com.au (8.12.10+Sun/8.12.10) with SMTP id + k3S5I9uP026964; Fri, 28 Apr 2006 15:18:09 +1000 (EST) +Reply-To: +From: "Guoping Zhang" +To: "'Guillaume Smet'" +Cc: , + "'Guoping Zhang (E-mail)'" +Subject: Re: how unsafe (or worst scenarios) when setting fsync OFF for + postgresql +Date: Fri, 28 Apr 2006 15:18:08 +1000 +Message-ID: <004301c66a83$234bd470$74304c93@eddy> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 8bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +In-Reply-To: <1d4e0c10604270226s53e261e9m943bf44766c880bf@mail.gmail.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/662 +X-Sequence-Number: 18746 + +Hi, Guillaume, + +Thanks for the reply. + +I am using wal_sync_methods be open_datasync, which appear much faster than +'fdatasync'. + +Regards, +Guoping + +-----Original Message----- +From: Guillaume Smet [mailto:guillaume.smet@gmail.com] +Sent: 2006��4��27�� 19:26 +To: guoping.zhang@nec.com.au +Cc: pgsql-performance@postgresql.org; Guoping Zhang (E-mail) +Subject: Re: [PERFORM] how unsafe (or worst scenarios) when setting +fsync OFF for postgresql + + +Guoping, + +On 4/27/06, Guoping Zhang wrote: +> We have to looking at setting fsync OFF option for performance reason, + +Did you try the other wal sync methods (fdatasync in particular)? I +saw a few posts lately explaining how changing sync method can affect +performances in specific cases. + +-- +Guillaume + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 02:58:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3ACF211F6228 + for ; + Fri, 28 Apr 2006 02:58:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 41021-08-3 + for ; + Fri, 28 Apr 2006 02:58:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ns2.nec.com.au (ns2.nec.com.au [147.76.180.2]) + by postgresql.org (Postfix) with ESMTP id 1EB7E11F6232 + for ; + Fri, 28 Apr 2006 02:58:10 -0300 (ADT) +Received: from ns2.nec.com.au ([127.0.0.1]) + by localhost (ns2.nec.com.au [127.0.0.1]) (amavisd-new, + port 10024) with LMTP + id 30619-01-35 for ; + Fri, 28 Apr 2006 15:58:09 +1000 (EST) +Received: from smtp1.nec.com.au (unknown [172.31.8.18]) + by ns2.nec.com.au (Postfix) with ESMTP id 8FACA3B7A4 + for ; + Fri, 28 Apr 2006 15:58:09 +1000 (EST) +Received: from eddy (eddy.ssd.neca.nec.com.au [147.76.48.116]) + by warp.ssd.neca.nec.com.au (8.12.10+Sun/8.12.10) with SMTP id + k3S5w7uP027789; Fri, 28 Apr 2006 15:58:08 +1000 (EST) +Reply-To: +From: "Guoping Zhang" +To: "'Tom Lane'" +Cc: , + "'Guoping Zhang (E-mail)'" +Subject: Re: how unsafe (or worst scenarios) when setting fsync OFF for + postgresql +Date: Fri, 28 Apr 2006 15:58:06 +1000 +Message-ID: <004901c66a88$b909edd0$74304c93@eddy> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 8bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +In-Reply-To: <25291.1146200208@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/663 +X-Sequence-Number: 18747 + +Hi, Tom + +Many thanks for quick replies and that helps a lot. + +Just in case, anyone out there can recommend a good but cost effective +battery-backed write cache SCSI for Solaris SPARC platform? How well does it +work with UFS or newer ZFS for solaris? + +Cheers and regards, +Guoping + + + + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: 2006��4��28�� 14:57 +To: guoping.zhang@nec.com.au +Cc: pgsql-performance@postgresql.org; 'Guoping Zhang (E-mail)' +Subject: Re: [PERFORM] how unsafe (or worst scenarios) when setting +fsync OFF for postgresql + + +"Guoping Zhang" writes: +> a) The tests consists of ten thousands very small transactions, which are +> not grouped, that is why so slow with compare to set fsync off. + +Yup. + +> c) wal_sync_method is set to 'open_datasync', which is fastest among the +> four, right? + +Well, is it? You shouldn't assume that without testing. + +> Looks like, if we have to set fsync be true, we need to modify our +> application. + +Yes, you should definitely look into batching your operations into +larger transactions. On normal hardware you can't expect to commit +transactions faster than one per disk revolution (unless they're coming +from multiple clients, where there's a hope of ganging several parallel +commits per revolution). + +Or buy a disk controller with battery-backed write cache and put your +faith in that cache surviving a machine crash. But don't turn off fsync +if you care about your data. + + regards, tom lane + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 05:49:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4F52E11F60E3 + for ; + Fri, 28 Apr 2006 05:49:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 17824-07 + for ; + Fri, 28 Apr 2006 05:49:18 -0300 (ADT) +X-Greylist: delayed 00:16:49.751071 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 36DFD11F609E + for ; + Fri, 28 Apr 2006 05:49:17 -0300 (ADT) +Received: from mail.aeccom.com (port-83-236-156-26.static.qsc.de + [83.236.156.26]) + by svr4.postgresql.org (Postfix) with ESMTP id 227805B6482 + for ; + Fri, 28 Apr 2006 08:32:25 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.aeccom.com (Postfix) with ESMTP id 9D36D1C4E7; + Fri, 28 Apr 2006 10:32:21 +0200 (CEST) +Received: from mail.aeccom.com ([127.0.0.1]) + by localhost (gate6.aeccom.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 16945-01-3; Fri, 28 Apr 2006 10:32:20 +0200 (CEST) +Received: from [192.168.2.14] (andes.core.aeccom.com [192.168.2.14]) + by mail.aeccom.com (Postfix) with ESMTP id 7F8DB1C49A; + Fri, 28 Apr 2006 10:32:20 +0200 (CEST) +Message-ID: <4451D310.7010701@aeccom.com> +Date: Fri, 28 Apr 2006 10:32:16 +0200 +From: Sven Geisler +Organization: AEC/communications GmbH +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: Vivek Khera +Cc: Pgsql performance +Subject: Re: Large (8M) cache vs. dual-core CPUs +References: <20060425141435.6c8c163c.wmoran@collaborativefusion.com> + <3EF41DD8-1073-4EAC-B6D7-4A78BE7549F8@khera.org> +In-Reply-To: <3EF41DD8-1073-4EAC-B6D7-4A78BE7549F8@khera.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: amavisd-new at aeccom.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/664 +X-Sequence-Number: 18748 + +Hi all, + +Vivek Khera schrieb: + > On Apr 25, 2006, at 2:14 PM, Bill Moran wrote: + >> Where I'm stuck is in deciding whether we want to go with dual-core + >> pentiums with 2M cache, or with HT pentiums with 8M cache. + > + > In order of preference: + > + > Opterons (dual core or single core) + > Xeon with HT *disabled* at the BIOS level (dual or single core) + > + > + > Notice Xeon with HT is not on my list :-) + > + +I support Vivek's order of preference. I have been going through a +nightmare of performance issues with different x86 hardware. +At the end of the day I can say the Opterons are faster because of their +memory bandwidth. I also had to disable HT on all our customers servers + which were still using XEON's with HT. + +There is a paper from HP which describes the advantage of the memory +architecture of the Opterons. This is the best explanation to me why +Opteron 875 is faster than a XEON MP 3 GHz, which I did compare last year. + +I remember a thread in the postgresql devel list around HT in 2004, +where you can find the reason why you should disable HT. +This thread refers to Intel Developer Manual Volume 4 (Architecture +Optimisation) where there is some advice regarding spin-wait loop. +This is related to the code of src/include/storage/s_lock.h. + +Cheers Sven. + +====== + From Intel Developer Manual Volume 4 + +Synchronization for Short Periods + +The frequency and duration that a thread needs to synchronize with +other threads depends application characteristics. When a +synchronization loop needs very fast response, applications may use a +spin-wait loop. + +A spin-wait loop is typically used when one thread needs to wait a short +amount of time for another thread to reach a point of synchronization. A +spin-wait loop consists of a loop that compares a synchronization +variable with some pre-defined value [see Example 7-1(a)]. + +On a modern microprocessor with a superscalar speculative execution +engine, a loop like this results in the issue of multiple simultaneous read +requests from the spinning thread. These requests usually execute +out-of-order with each read request being allocated a buffer resource. +On detection of a write by a worker thread to a load that is in progress, +the processor must guarantee no violations of memory order occur. The +necessity of maintaining the order of outstanding memory operations +inevitably costs the processor a severe penalty that impacts all threads. + +This penalty occurs on the Pentium Pro processor, the Pentium II +processor and the Pentium III processor. However, the penalty on these +processors is small compared with penalties suffered on the Pentium 4 +and Intel Xeon processors. There the performance penalty for exiting +the loop is about 25 times more severe. + +On a processor supporting Hyper-Threading Technology, spin-wait +loops can consume a significant portion of the execution bandwidth of +the processor. One logical processor executing a spin-wait loop can +severely impact the performance of the other logical processor. + +==== + +From pgsql-performance-owner@postgresql.org Fri Apr 28 05:51:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 981CE11F608B + for ; + Fri, 28 Apr 2006 05:51:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 20841-02 + for ; + Fri, 28 Apr 2006 05:50:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.wirelesscar.com (mail.wirelesscar.com [212.209.35.30]) + by postgresql.org (Postfix) with ESMTP id AEFCE11F60B6 + for ; + Fri, 28 Apr 2006 05:50:46 -0300 (ADT) +Received: from sesrv12.wirelesscar.com ([192.168.10.17]) by + mail.wirelesscar.com with InterScan Messaging Security Suite; + Fri, 28 Apr 2006 10:50:35 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: how unsafe (or worst scenarios) when setting fsync OFF for + postgresql +Date: Fri, 28 Apr 2006 10:51:22 +0200 +Message-ID: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E4315@sesrv12.wirelesscar.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] how unsafe (or worst scenarios) when setting fsync OFF + for postgresql +Thread-Index: AcZqhXFBk7lJHXpNRHKMyMAsBrybjAAGbxEQ +From: "Mikael Carneholm" +To: , + +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/665 +X-Sequence-Number: 18749 + +a) I have absolutely no idea regarding price tags when it comes to SUN = +hardware, last time I worked with SUN gear was in =B401 so you'll have = +to check with your local (SUN-)supplier for uptodate prices. + +b) Same here (no idea). But I'd be surprised if UFS (and ZFS) was unable = +to take advantage of battery backed write cache... + +Regards, +Mikael + + +-----Original Message----- +From: Guoping Zhang [mailto:guoping.zhang@nec.com.au]=20 +Sent: den 28 april 2006 07:35 +To: Mikael Carneholm; pgsql-performance@postgresql.org +Cc: Guoping Zhang (E-mail) +Subject: RE: [PERFORM] how unsafe (or worst scenarios) when setting = +fsync OFF for postgresql + +Hi, Mikael, + +We have not looked at this option yet, but very good direction though. + +Two issues are unsure: +a) we are on SUN SPARC platform, unsure what the price tag for such a = +hardware device with SUN brand? + +b) how well does UFS (or a new ZFS) work with the device (as ext3 can = +mount with data=3Dwriteback)? + =20 +Cheers and regards, +Guoping + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Mikael = +Carneholm +Sent: 2006=C4=EA4=D4=C227=C8=D5 17:43 +To: guoping.zhang@nec.com.au; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] how unsafe (or worst scenarios) when setting = +fsync OFF for postgresql + + +Get a SCSI controller with a battery backed cache, and mount the disks = +with data=3Dwriteback (if you use ext3). If you loose power in the = +middle of a transaction, the battery will ensure that the write = +operation still completes. With asynch writing setup like this, fsync = +operations will return almost immidiately giving you performance close = +to that of running with fsync off. + +Regards, +Mikael + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Guoping = +Zhang +Sent: den 27 april 2006 08:31 +To: pgsql-performance@postgresql.org +Cc: Guoping Zhang (E-mail) +Subject: [PERFORM] how unsafe (or worst scenarios) when setting fsync = +OFF for postgresql + +Hi,. + +We are new to Postgresql. I am appreciated if the following question can = +be answered. + +Our application has a strict speed requirement for DB operation. Our = +tests show that it takes about 10secs for the operation when setting = +fsync off, but takes about 70 seconds when setting fsync ON (with other = +WAL related parametered tuned). + +We have to looking at setting fsync OFF option for performance reason, = +our questions are + + a) if we set fsync OFF and anything (very low chance though) like OS = +crash, loss of power, or hardware fault happened, can postgresql rolls = +back to the state that the last checkpoint was done ( but all the = +operations after that is lost) + + b) Does this roll back to last checkpoint can ensure the database back = +to consistent state? + + c) What is worst scenarios if setting fsync OFF in term of database = +safety. We try to avoid to restore the database from nightly backup. + +We view our application is not that data loss critical, say loss of five = +minutes of data and operation occasionally, but the database integrity = +and consistency must be kept. + +Can we set fsync OFF for the performance benefit, have the risk of only +5 minutes data loss or much worse? + +Thanks in advance. + +Regards, + +Guoping + + +---------------------------(end of broadcast)--------------------------- +TIP 2: Don't 'kill -9' the postmaster + + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 05:59:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 48BD811F60AC + for ; + Fri, 28 Apr 2006 05:59:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18490-07 + for ; + Fri, 28 Apr 2006 05:58:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 0EAC811F609E + for ; + Fri, 28 Apr 2006 05:58:54 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T9c46.t.pppool.de + [89.55.156.70]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 11CB6656CD; + Fri, 28 Apr 2006 10:59:59 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 54B2A18151EB4; + Fri, 28 Apr 2006 10:59:10 +0200 (CEST) +Message-ID: <4451D95E.9080308@logix-tt.com> +Date: Fri, 28 Apr 2006 10:59:10 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: guoping.zhang@nec.com.au +Subject: Re: how unsafe (or worst scenarios) when setting fsync +References: <004101c66a7e$4ab95000$74304c93@eddy> +In-Reply-To: <004101c66a7e$4ab95000$74304c93@eddy> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/666 +X-Sequence-Number: 18750 + +Hk, Guoping, + +Guoping Zhang wrote: + +> a) The tests consists of ten thousands very small transactions, which are +> not grouped, that is why so slow with compare to set fsync off. + +If those transactions are submitted by concurrent applications over +several simulataneous connections, playing with commit_delay and +commit_siblins may improve your situation. + +HTH, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Fri Apr 28 06:00:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4636E11F60B6 + for ; + Fri, 28 Apr 2006 06:00:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 21053-07 + for ; + Fri, 28 Apr 2006 06:00:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 4CE2D11F609E + for ; + Fri, 28 Apr 2006 06:00:43 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 0351031478; Fri, 28 Apr 2006 11:00:43 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: Re: CPU usage goes to 100%, query seems to ran forever +Date: Fri, 28 Apr 2006 12:00:35 +0300 +Organization: Hub.Org Networking Services +Lines: 48 +Message-ID: +References: <14690.1146164953@sss.pgh.pa.us> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/667 +X-Sequence-Number: 18751 + +> You have ANALYZEd all these tables recently, I hope? The planner +> certainly doesn't think this query will take very long. + +I have autovacuum running so I expect it takes care of ANALYZE, isn't it ? + +I ran also analyze command before running explain analyze. + +> To find out what's wrong, you're going to have to be patient enough to +> let an EXPLAIN ANALYZE run to completion. Plain EXPLAIN won't tell. + +Here it is running in my local computer. I'm expecting run time no more 1 +second + +"Nested Loop Left Join (cost=0.00..1829.95 rows=1 width=24) (actual +time=492064.990..492064.990 rows=0 loops=1)" +" Filter: ((("inner".arttyyp <> 'Teenus'::bpchar) AND ("inner".arttyyp <> +'Komplekt'::bpchar)) OR ("inner".arttyyp IS NULL))" +" -> Nested Loop (cost=0.00..1825.01 rows=1 width=43) (actual +time=492064.983..492064.983 rows=0 loops=1)" +" -> Nested Loop (cost=0.00..1819.04 rows=1 width=24) (actual +time=492064.978..492064.978 rows=0 loops=1)" +" Join Filter: (("outer".dokumnr = "inner".dokumnr) AND +((("position"('VGYKITDNHMEBARCFJ'::text, ("outer".doktyyp)::text) <> 0) AND +(CASE WHEN ((NOT ("outer".objrealt)::boolean) OR ("outer".doktyyp = +'I'::bpchar)) THEN "outer".yksus ELSE "inner (..)" +" -> Seq Scan on dok (cost=0.00..787.80 rows=1 width=39) +(actual time=0.152..878.198 rows=7670 loops=1)" +" Filter: ((kuupaev >= '2006-04-08'::date) AND (kuupaev +<= '2006-04-27'::date) AND (NOT (eimuuda)::boolean) AND ((laonr)::double +precision = 1::double precision) AND ("position"('OSIDVGYKIF'::text, +(doktyyp)::text) <> 0) AND (((kuupaev):: (..)" +" -> Seq Scan on rid (cost=0.00..1019.42 rows=315 width=51) +(actual time=22.003..62.216 rows=839 loops=7670)" +" Filter: ((toode = '1EEKPANT'::bpchar) AND +(length(btrim((toode)::text)) > 2) AND (toode IS NOT NULL))" +" -> Index Scan using toode_pkey on toode (cost=0.00..5.96 rows=1 +width=43) (never executed)" +" Index Cond: ('1EEKPANT'::bpchar = toode)" +" -> Index Scan using artliik_pkey on artliik (cost=0.00..4.92 rows=1 +width=31) (never executed)" +" Index Cond: (("outer".grupp = artliik.grupp) AND ("outer".liik = +artliik.liik))" +"Total runtime: 492065.840 ms" + + +Andrus. + + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 08:31:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 44F8111F6067 + for ; + Fri, 28 Apr 2006 08:31:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 45008-06 + for ; + Fri, 28 Apr 2006 08:31:01 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from web51009.mail.yahoo.com (web51009.mail.yahoo.com + [206.190.39.128]) + by postgresql.org (Postfix) with SMTP id A7BD811F6004 + for ; + Fri, 28 Apr 2006 08:30:59 -0300 (ADT) +Received: (qmail 57109 invoked by uid 60001); 28 Apr 2006 11:30:59 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=wYl1Pf9Y1rC/oO+G9z3njiQtb1+8jkaDsuZ9YRIb2ovEQhG8VwX3XgT52I1EjPNvonB4NiKM/3r8O+nLZvtKD7XaKbiTzdfDuWf5uyiZ9YSr8eC/MT1bT2zErlQ+oC8uXK4V/6i148PMuw7Dx8oP6QxEWndt1nq7VzbRiXiEETg= + ; +Message-ID: <20060428113059.57107.qmail@web51009.mail.yahoo.com> +Received: from [193.140.92.26] by web51009.mail.yahoo.com via HTTP; + Fri, 28 Apr 2006 04:30:59 PDT +Date: Fri, 28 Apr 2006 04:30:59 -0700 (PDT) +From: gulsah +Subject: query performance question +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-157778718-1146223859=:52971" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/668 +X-Sequence-Number: 18752 + +--0-157778718-1146223859=:52971 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi, + + I have a performance problem with Postgresql version 8.1 installed on a Fedora Core release 4 (Stentz) with kernel version 2.6.11. + + The machine I am working on has 512MB of RAM and Pentium III 800 MHz CPU. + + I have only one table in the database which consists of 256 columns and 10000 rows. Each column is of float type and each row corresponds to a vector in my application. What I want to do is to compute the distance between a predefined vector in hand and the ones in the database. + + The computation proceeds according to the following pseudocode: + + for(i=1; i<=256 ; i++){ + distance += abs(x1_i - x2_i); + } + + where x1_i denotes the vector in hand's i coordinate and x2_i denotes the i + coordinate of the vector in the database. + + The distance computation have to be done for all the vectors in the database + by means of a query and the result set should be sorted in terms of the + computed distances. + + When I implement the query and measure the time spent for it in an application + I see that the query is handled in more than 8 seconds which is undesirable in + my application. + + Here what I want to ask you all is that, is it a normal performance for a + computer with the properties that I have mentioned above? Is there any solution + in your mind to increase the performance of my query? + + To make it more undestandable, I should give the query for vectors with size + 3, but in my case their size is 256. + + select + id as vectorid, + abs(40.9546-x2_1)+abs(-72.9964-x2_2)+abs(53.5348-x2_3) as distance + from vectordb + order by distance + + Thank you all for your help. + + + - + gulsah + + +--------------------------------- +Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min. +--0-157778718-1146223859=:52971 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi,

I have a performance problem with Postgresql version 8.1 installed on a Fedora Core release 4 (Stentz) with kernel version 2.6.11.

The machine I am working on has 512MB of RAM and Pentium III 800 MHz CPU.

I have only one table in the database which consists of 256 columns and 10000 rows. Each column is of float type and each row corresponds to a vector in my application. What I want to do is to compute the distance between a predefined vector in hand and the ones in the database.

The computation proceeds according to the following pseudocode:

        for(i=1; i<=256 ; i++){
                distance += abs(x1_i - x2_i);
        }

where x1_i denotes the vector in hand's i coordinate and x2_i denotes the i
coordinate of the vector in the database.

The + distance computation have to be done for all the vectors in the database
by means of a query and the result set should be sorted in terms of the
computed distances.

When I implement the query and measure the time spent for it in an application
I see that the query is handled in more than 8 seconds which is undesirable in
my application.

Here what I want to ask you all is that, is it a normal performance for a
computer with the properties that I have mentioned above? Is there any solution
in your mind to increase the performance of my query?

To make it more undestandable, I should give the query for vectors with size
3, but in my case their size is 256.

select
id as vectorid,
abs(40.9546-x2_1)+abs(-72.9964-x2_2)+abs(53.5348-x2_3) as distance
from vectordb
order by distance

Thank you all for your help.


-
gulsah

+


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min. +--0-157778718-1146223859=:52971-- + +From pgsql-performance-owner@postgresql.org Fri Apr 28 08:41:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 35F8C11F602F + for ; + Fri, 28 Apr 2006 08:41:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 41050-09 + for ; + Fri, 28 Apr 2006 08:41:12 -0300 (ADT) +X-Greylist: delayed 17:29:04.017004 by SQLgrey- +Received: from hotmail.com (bay101-f16.bay101.hotmail.com [64.4.56.26]) + by postgresql.org (Postfix) with ESMTP id 705BB11F6031 + for ; + Fri, 28 Apr 2006 08:41:10 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 28 Apr 2006 04:41:09 -0700 +Message-ID: +Received: from 64.4.56.200 by by101fd.bay101.hotmail.msn.com with HTTP; + Fri, 28 Apr 2006 11:41:06 GMT +X-Originating-IP: [84.210.10.106] +X-Originating-Email: [bealach_na_bo@hotmail.com] +X-Sender: bealach_na_bo@hotmail.com +In-Reply-To: <20060427182823.GA29375@KanotixBox> +From: "Bealach-na Bo" +To: akretschmer@spamfence.net, pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Date: Fri, 28 Apr 2006 11:41:06 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +X-OriginalArrivalTime: 28 Apr 2006 11:41:09.0978 (UTC) + FILETIME=[A4E733A0:01C66AB8] +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/669 +X-Sequence-Number: 18753 + +OK, here is a much more detailed output. I still don't quite +understand why simple queries like counting the number of rows in a +table should take minutes to complete. Surely, any performance +enhancement to be had by vacuuming is closely related to indexes +which, in turn, are closely related to sorting and searching. A simple +count of 365590 does not involve indexes (or does it??) and should not take +minutes. Should I be forcing the +way postgresql plans my queries? + +Here is my first attempt at vacuum that got nowhere and I had to +cancel it. + +----------psql session start---------- +vacuum verbose analyze job_log; +INFO: vacuuming "job_log" +INFO: index "job_log_id_pkey" now contains 10496152 row versions in 59665 +pages +DETAIL: 0 index row versions were removed. +28520 index pages have been deleted, 20000 are currently reusable. +CPU 1.44s/3.49u sec elapsed 33.71 sec. +INFO: index "idx_job_stop_filter" now contains 10496152 row versions in +71149 pages +DETAIL: 0 index row versions were removed. +24990 index pages have been deleted, 20000 are currently reusable. +CPU 2.11s/3.61u sec elapsed 115.69 sec. +INFO: index "idx_job_start_filter" now contains 10496152 row versions in +57891 pages +DETAIL: 0 index row versions were removed. +19769 index pages have been deleted, 19769 are currently reusable. +CPU 1.58s/3.44u sec elapsed 23.11 sec. +Cancel request sent +----------psql session finish---------- + + +I thought that combining indexes would improve things and dropped the +3 separate ones above and created this one + +----------psql session start---------- +create index idx_job_log_filter on job_log(job_name,job_start,job_stop); + +select count(*) from job_log; +count +-------- +365590 +(1 row) + +explain analyse select count(*) from job_log; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------- +Aggregate (cost=1382171.88..1382171.88 rows=1 width=0) (actual +time=207011.882..207011.883 rows=1 loops=1) + -> Seq Scan on job_log (cost=0.00..1381257.90 rows=365590 width=0) +(actual time=199879.510..206708.523 rows=365590 loops=1) +Total runtime: 207014.363 ms +(3 rows) +----------psql session finish---------- + +Then I tried another vacuum and decided to be very patient + +----------psql session start---------- +vacuum verbose analyze job_log; +INFO: vacuuming "job_log" +INFO: index "job_log_id_pkey" now contains 10496152 row versions in 59665 +pages +DETAIL: 0 index row versions were removed. +28520 index pages have been deleted, 20000 are currently reusable. +CPU 1.39s/3.39u sec elapsed 24.19 sec. +INFO: index "idx_job_log_filter" now contains 365590 row versions in 15396 +pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.59s/0.20u sec elapsed 10.28 sec. +INFO: "job_log": removed 2795915 row versions in 368091 pages +DETAIL: CPU 33.30s/30.11u sec elapsed 2736.54 sec. +INFO: index "job_log_id_pkey" now contains 7700230 row versions in 59665 +pages +DETAIL: 2795922 index row versions were removed. +37786 index pages have been deleted, 20000 are currently reusable. +CPU 2.76s/6.45u sec elapsed 152.14 sec. +INFO: index "idx_job_log_filter" now contains 365590 row versions in 15396 +pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.52s/0.20u sec elapsed 7.75 sec. +INFO: "job_log": removed 2795922 row versions in 220706 pages +DETAIL: CPU 19.81s/17.92u sec elapsed 1615.95 sec. +INFO: index "job_log_id_pkey" now contains 4904317 row versions in 59665 +pages +DETAIL: 2795913 index row versions were removed. +45807 index pages have been deleted, 20000 are currently reusable. +CPU 2.22s/5.30u sec elapsed 129.02 sec. +INFO: index "idx_job_log_filter" now contains 365590 row versions in 15396 +pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.50s/0.22u sec elapsed 7.61 sec. +INFO: "job_log": removed 2795913 row versions in 188139 pages +DETAIL: CPU 17.03s/15.37u sec elapsed 1369.45 sec. +INFO: index "job_log_id_pkey" now contains 2108405 row versions in 59665 +pages +DETAIL: 2795912 index row versions were removed. +53672 index pages have been deleted, 20000 are currently reusable. +CPU 2.13s/4.57u sec elapsed 122.74 sec. +INFO: index "idx_job_log_filter" now contains 365590 row versions in 15396 +pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.53s/0.23u sec elapsed 8.24 sec. +INFO: "job_log": removed 2795912 row versions in 187724 pages +DETAIL: CPU 16.84s/15.22u sec elapsed 1367.50 sec. +INFO: index "job_log_id_pkey" now contains 365590 row versions in 59665 +pages +DETAIL: 1742815 index row versions were removed. +57540 index pages have been deleted, 20000 are currently reusable. +CPU 1.38s/2.85u sec elapsed 76.52 sec. +INFO: index "idx_job_log_filter" now contains 365590 row versions in 15396 +pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.54s/0.31u sec elapsed 7.99 sec. +INFO: "job_log": removed 1742815 row versions in 143096 pages +DETAIL: CPU 12.77s/11.75u sec elapsed 1046.10 sec. +INFO: "job_log": found 12926477 removable, 365590 nonremovable row versions +in 1377602 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 7894754 unused item pointers. +0 pages are entirely empty. +CPU 124.49s/117.57u sec elapsed 8888.80 sec. +INFO: vacuuming "pg_toast.pg_toast_17308" +INFO: index "pg_toast_17308_index" now contains 130 row versions in 12 +pages +DETAIL: 2543 index row versions were removed. +9 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.11 sec. +INFO: "pg_toast_17308": removed 2543 row versions in 617 pages +DETAIL: CPU 0.04s/0.05u sec elapsed 4.85 sec. +INFO: "pg_toast_17308": found 2543 removable, 130 nonremovable row versions +in 650 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 0 unused item pointers. +0 pages are entirely empty. +CPU 0.06s/0.06u sec elapsed 5.28 sec. +INFO: analyzing "rshuser.job_log" +INFO: "job_log": scanned 3000 of 1377602 pages, containing 695 live rows +and 0 dead rows; 695 rows in sample, 319144 estimated total rows +VACUUM + + +explain analyse select count(*) from job_log; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------- +Aggregate (cost=1382171.88..1382171.88 rows=1 width=0) (actual +time=207267.094..207267.095 rows=1 loops=1) + -> Seq Scan on job_log (cost=0.00..1381257.90 rows=365590 width=0) +(actual time=200156.539..206962.895 rows=365590 loops=1) +Total runtime: 207267.153 ms +(3 rows) + +----------psql session finish---------- + + +I also took snapshots of top output while I ran the above + + +----------top output start---------- +Cpu(s): 0.7% us, 0.7% sy, 0.0% ni, 49.7% id, 48.5% wa, 0.5% hi, 0.0% si +Mem: 1554788k total, 1538268k used, 16520k free, 6220k buffers +Swap: 1020024k total, 176k used, 1019848k free, 1404280k cached + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND +3368 postgres 18 0 37492 29m 11m D 2.7 1.9 3:00.54 postmaster + + + +Cpu(s): 0.7% us, 0.8% sy, 0.0% ni, 49.7% id, 48.5% wa, 0.3% hi, 0.0% si +Mem: 1554788k total, 1538580k used, 16208k free, 2872k buffers +Swap: 1020024k total, 176k used, 1019848k free, 1414908k cached + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND +3368 postgres 15 0 37492 29m 11m D 2.3 1.9 5:26.03 postmaster + + +Cpu(s): 0.5% us, 5.8% sy, 0.0% ni, 48.7% id, 44.4% wa, 0.5% hi, 0.0% si +Mem: 1554788k total, 1538196k used, 16592k free, 1804k buffers +Swap: 1020024k total, 176k used, 1019848k free, 1444576k cached + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND +3368 postgres 15 0 20956 13m 11m D 11.0 0.9 6:25.10 postmaster +----------top output end---------- + + +I know my database needs a major redesign. But I'm having a hard time +explaining the poor performance nevertheless. + + +Regards, + +Bealach + + +>From: Andreas Kretschmer +>To: pgsql-performance@postgresql.org +>Subject: Re: [PERFORM] Why so slow? +>Date: Thu, 27 Apr 2006 20:28:23 +0200 +> +>Bealach-na Bo schrieb: +> > The node table is tiny (2500 records). What I'm pulling my hair out +> > over is that ANY Query, even something as simple as select count(*) +> > form job_log takes of the order of tens of minutes to complete. Just +> > now I'm trying to run an explain analyze on the above query, but so +> > far, it's taken 35min! with no result and there is a postgres process at +> > the top of top +> > +> > What am I doing wrong?? +> +>The 'explain analyse' don't return a result, but it returns the query +>plan and importance details, how PG works. +> +>That's why you should paste the query and the 'explain analyse' - +>output. This is very important. +> +>Anyway, do you periodical vacuum your DB? My guess: no, and that's why +>you have many dead rows. +> +>20:26 < akretschmer|home> ??vacuum +>20:26 < rtfm_please> For information about vacuum +>20:26 < rtfm_please> see +>http://developer.postgresql.org/~wieck/vacuum_cost/ +>20:26 < rtfm_please> or +>http://www.postgresql.org/docs/current/static/sql-vacuum.html +>20:26 < rtfm_please> or http://www.varlena.com/varlena/GeneralBits/116.php +> +>20:27 < akretschmer|home> ??explain +>20:27 < rtfm_please> For information about explain +>20:27 < rtfm_please> see +>http://techdocs.postgresql.org/oscon2005/robert.treat/OSCON_Explaining_Explain_Public.sxi +>20:27 < rtfm_please> or http://www.gtsm.com/oscon2003/toc.html +>20:27 < rtfm_please> or +>http://www.postgresql.org/docs/current/static/sql-explain.html +> +> +>Read this links for more informations about vacuum and explain. +> +> +>HTH, Andreas +>-- +>Really, I'm not out to destroy Microsoft. That will just be a completely +>unintentional side effect. (Linus Torvalds) +>"If I was god, I would recompile penguin with --enable-fly." (unknow) +>Kaufbach, Saxony, Germany, Europe. N 51.05082�, E 13.56889� +> +>---------------------------(end of broadcast)--------------------------- +>TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match + + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 11:46:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4E53211F6067 + for ; + Fri, 28 Apr 2006 11:46:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 01133-03 + for ; + Fri, 28 Apr 2006 11:46:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id D8EE611F6069 + for ; + Fri, 28 Apr 2006 11:46:10 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T9c46.t.pppool.de + [89.55.156.70]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id C1C97656C8; + Fri, 28 Apr 2006 16:47:15 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id A05C418151EB4; + Fri, 28 Apr 2006 16:46:27 +0200 (CEST) +Message-ID: <44522AC3.6030707@logix-tt.com> +Date: Fri, 28 Apr 2006 16:46:27 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL Performance List +Subject: Arrays and index scan +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/670 +X-Sequence-Number: 18754 + +Hello, + +I'm searching for a comfortable way to get a variable-size bunch of user +specified Objects via a single prepared statement, so I wanted to submit +an ARRAY. + +However, the query planner seems to refuse to make index scans even with +8.1: + +testdb=# EXPLAIN SELECT * from streets WHERE link_id = ANY(ARRAY[1,2,3]); + QUERY PLAN +-------------------------------------------------------------------- + Seq Scan on streets (cost=0.00..288681.74 rows=1713754 width=393) + Filter: (link_id = ANY ('{1,2,3}'::integer[])) +(2 rows) + + + +Via IN, it works fine, but hast the disadvantage that we cannot use +prepared statements effectively: + +testdb=# explain select * from streets where link_id in (1,2,3); + QUERY PLAN + +----------------------------------------------------------------------------------------------- + Bitmap Heap Scan on streets (cost=6.02..16.08 rows=5 width=393) + Recheck Cond: ((link_id = 1) OR (link_id = 2) OR (link_id = 3)) + -> BitmapOr (cost=6.02..6.02 rows=5 width=0) + -> Bitmap Index Scan on streets_link_id_idx (cost=0.00..2.01 +rows=2 width=0) + Index Cond: (link_id = 1) + -> Bitmap Index Scan on streets_link_id_idx (cost=0.00..2.01 +rows=2 width=0) + Index Cond: (link_id = 2) + -> Bitmap Index Scan on streets_link_id_idx (cost=0.00..2.01 +rows=2 width=0) + Index Cond: (link_id = 3) +(9 rows) + + +And on the net, I found a nice trick via an "array flattening" function, +which at least uses a nested loop of index scans instead of an index +bitmap scan: + +testdb=# CREATE FUNCTION flatten_array(anyarray) RETURNS SETOF +anyelement AS +testdb-# 'SELECT ($1)[i] FROM (SELECT +generate_series(array_lower($1,1),array_upper($1,1)) as i) as foo;' +testdb-# language SQL STRICT IMMUTABLE; + + +testdb=# EXPLAIN SELECT * from streets JOIN flatten_array(ARRAY[1,2,3]) +on flatten_array=link_id; + QUERY PLAN + +-------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..5882.15 rows=1566 width=397) + -> Function Scan on flatten_array (cost=0.00..12.50 rows=1000 width=4) + -> Index Scan using treets_link_id_idx on streets (cost=0.00..5.84 +rows=2 width=393) + Index Cond: ("outer".flatten_array = streets.link_id) +(4 rows) + + +Currently, we're planning to use the array flattening approach, but are +there any plans to enhance the query planner for the direct ARRAY approach? + +Thanks, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Fri Apr 28 11:57:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C56C811F60B9 + for ; + Fri, 28 Apr 2006 11:57:19 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10402-04 + for ; + Fri, 28 Apr 2006 11:57:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 504A611F60E2 + for ; + Fri, 28 Apr 2006 11:57:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3SEv0if000901; + Fri, 28 Apr 2006 10:57:00 -0400 (EDT) +To: "Andrus" +cc: pgsql-performance@postgresql.org +Subject: Re: CPU usage goes to 100%, query seems to ran forever +In-reply-to: +References: <14690.1146164953@sss.pgh.pa.us> + +Comments: In-reply-to "Andrus" + message dated "Fri, 28 Apr 2006 12:00:35 +0300" +Date: Fri, 28 Apr 2006 10:57:00 -0400 +Message-ID: <900.1146236220@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/671 +X-Sequence-Number: 18755 + +"Andrus" writes: +> Here it is running in my local computer. I'm expecting run time no more 1 +> second + +Something seems to have truncated your EXPLAIN output, but anyway we +can see where the problem is: + +> " -> Seq Scan on dok (cost=0.00..787.80 rows=1 width=39) +> (actual time=0.152..878.198 rows=7670 loops=1)" +> " Filter: ((kuupaev >= '2006-04-08'::date) AND (kuupaev +> <= '2006-04-27'::date) AND (NOT (eimuuda)::boolean) AND ((laonr)::double +> precision = 1::double precision) AND ("position"('OSIDVGYKIF'::text, +> (doktyyp)::text) <> 0) AND (((kuupaev):: (..)" + +The planner is expecting to get one row from "dok" passing the filter +condition, and hence chooses a plan that is suitable for a small number +of rows ... but in reality there are 7670 rows matching the filter +condition, and that's what blows the runtime out of the water. (Most of +the runtime is actually going into 7670 repeated scans of "rid", which +wouldn't have happened with another plan type.) + +So you need to see about getting that estimate to be more accurate. +First thing is to make sure that "dok" has been ANALYZEd --- just do it +by hand. If that doesn't change the EXPLAIN plan then you need to work +harder. I can see at least three things you are doing that are +unnecessarily destroying the planner's ability to estimate the number of +matching rows: + + dok.laonr='1'::float8 and + +Since laonr apparently isn't float8, this forces a runtime type +conversion as well as interfering with statistics use. (The planner +will have ANALYZE stats about dok.laonr, but the connection to +dok.laonr::float8 escapes it.) Just write the constant with quotes +and no type coercion. + + POSITION( dok.doktyyp IN 'OSIDVGYKIF')!=0 AND + +This is completely unestimatable given the available statistics, and it +doesn't look to me like it is all that great a semantic representation +either. Perhaps the query that's really meant here is "dok.doktypp IN +('O','S','I', ...)"? If so, you should say what you mean, not play +games with converting the query into some strange string operation. + + AND dok.kuupaev||dok.kellaaeg BETWEEN '2006-04-08' AND '2006-04-2723 59' + +This is another case where the planner is not going to have any ability +to make a useful estimate, and it's because you are using a crummy +representation of your data. You should merge those two columns into +one timestamp column and just do a simple BETWEEN test. + + +By and large, unnatural representations of data that you use in WHERE +clauses are going to cost you big-time in SQL queries. It's worth +taking time up front to design a clean table schema, and taking time +to revise it when requirements change. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 28 11:59:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F378511F60B8 + for ; + Fri, 28 Apr 2006 11:59:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 14457-03 + for ; + Fri, 28 Apr 2006 11:58:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B0F4611F60B9 + for ; + Fri, 28 Apr 2006 11:58:44 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 37A4256431; Fri, 28 Apr 2006 09:58:45 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 28 Apr 2006 09:58:43 -0500 +Date: Fri, 28 Apr 2006 09:58:43 -0500 +From: "Jim C. Nasby" +To: Bealach-na Bo +Cc: akretschmer@spamfence.net, pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Message-ID: <20060428145842.GI97354@pervasive.com> +References: <20060427182823.GA29375@KanotixBox> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060428:bealach_na_bo@hotmail.com::K72/E1vNK3uc+AK7:000000000000 + 0000000000000000000000007jmK +X-Hashcash: + 1:20:060428:akretschmer@spamfence.net::jYjpIDGY/IgxRbNw:000000000000 + 0000000000000000000000006iKc +X-Hashcash: + 1:20:060428:pgsql-performance@postgresql.org::JRO+BqeZnJr2owVK:00000 + 0000000000000000000000009wLQ +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/672 +X-Sequence-Number: 18756 + +On Fri, Apr 28, 2006 at 11:41:06AM +0000, Bealach-na Bo wrote: +> OK, here is a much more detailed output. I still don't quite +> understand why simple queries like counting the number of rows in a +> table should take minutes to complete. Surely, any performance +> enhancement to be had by vacuuming is closely related to indexes +> which, in turn, are closely related to sorting and searching. A simple +> count of 365590 does not involve indexes (or does it??) and should not take +> minutes. Should I be forcing the +> way postgresql plans my queries? +> +> Here is my first attempt at vacuum that got nowhere and I had to +> cancel it. +> +> ----------psql session start---------- +> vacuum verbose analyze job_log; +> INFO: vacuuming "job_log" +> INFO: index "job_log_id_pkey" now contains 10496152 row versions in 59665 +> pages +> DETAIL: 0 index row versions were removed. +> 28520 index pages have been deleted, 20000 are currently reusable. +> CPU 1.44s/3.49u sec elapsed 33.71 sec. +> INFO: index "idx_job_stop_filter" now contains 10496152 row versions in +> 71149 pages +> DETAIL: 0 index row versions were removed. +> 24990 index pages have been deleted, 20000 are currently reusable. +> CPU 2.11s/3.61u sec elapsed 115.69 sec. +> INFO: index "idx_job_start_filter" now contains 10496152 row versions in +> 57891 pages +> DETAIL: 0 index row versions were removed. +> 19769 index pages have been deleted, 19769 are currently reusable. +> CPU 1.58s/3.44u sec elapsed 23.11 sec. +> Cancel request sent +> ----------psql session finish---------- +> +> +> I thought that combining indexes would improve things and dropped the +> 3 separate ones above and created this one +> +> ----------psql session start---------- +> create index idx_job_log_filter on job_log(job_name,job_start,job_stop); +> +> select count(*) from job_log; +> count +> -------- +> 365590 +> (1 row) + +The above shows that the indexes contained 10M rows and 160M of dead +space each. That means you weren't vacuuming nearly enough. + +> explain analyse select count(*) from job_log; +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------------------- +> Aggregate (cost=1382171.88..1382171.88 rows=1 width=0) (actual +> time=207011.882..207011.883 rows=1 loops=1) +> -> Seq Scan on job_log (cost=0.00..1381257.90 rows=365590 width=0) +> (actual time=199879.510..206708.523 rows=365590 loops=1) +> Total runtime: 207014.363 ms +> (3 rows) +> ----------psql session finish---------- +> +> Then I tried another vacuum and decided to be very patient +> +> ----------psql session start---------- +> vacuum verbose analyze job_log; +> INFO: vacuuming "job_log" +> INFO: index "job_log_id_pkey" now contains 10496152 row versions in 59665 +> pages +> DETAIL: 0 index row versions were removed. +> 28520 index pages have been deleted, 20000 are currently reusable. +> CPU 1.39s/3.39u sec elapsed 24.19 sec. +> INFO: index "idx_job_log_filter" now contains 365590 row versions in 15396 +> pages +> DETAIL: 0 index row versions were removed. +> 0 index pages have been deleted, 0 are currently reusable. +> CPU 0.59s/0.20u sec elapsed 10.28 sec. +> INFO: "job_log": removed 2795915 row versions in 368091 pages +> DETAIL: CPU 33.30s/30.11u sec elapsed 2736.54 sec. +> INFO: index "job_log_id_pkey" now contains 7700230 row versions in 59665 +> pages +> DETAIL: 2795922 index row versions were removed. +> 37786 index pages have been deleted, 20000 are currently reusable. +> CPU 2.76s/6.45u sec elapsed 152.14 sec. +> INFO: index "idx_job_log_filter" now contains 365590 row versions in 15396 +> pages +> DETAIL: 0 index row versions were removed. +> 0 index pages have been deleted, 0 are currently reusable. +> CPU 0.52s/0.20u sec elapsed 7.75 sec. +> INFO: "job_log": removed 2795922 row versions in 220706 pages +> DETAIL: CPU 19.81s/17.92u sec elapsed 1615.95 sec. +> INFO: index "job_log_id_pkey" now contains 4904317 row versions in 59665 +> pages +> DETAIL: 2795913 index row versions were removed. +> 45807 index pages have been deleted, 20000 are currently reusable. +> CPU 2.22s/5.30u sec elapsed 129.02 sec. +> INFO: index "idx_job_log_filter" now contains 365590 row versions in 15396 +> pages +> DETAIL: 0 index row versions were removed. +> 0 index pages have been deleted, 0 are currently reusable. +> CPU 0.50s/0.22u sec elapsed 7.61 sec. +> INFO: "job_log": removed 2795913 row versions in 188139 pages +> DETAIL: CPU 17.03s/15.37u sec elapsed 1369.45 sec. +> INFO: index "job_log_id_pkey" now contains 2108405 row versions in 59665 +> pages +> DETAIL: 2795912 index row versions were removed. +> 53672 index pages have been deleted, 20000 are currently reusable. +> CPU 2.13s/4.57u sec elapsed 122.74 sec. +> INFO: index "idx_job_log_filter" now contains 365590 row versions in 15396 +> pages +> DETAIL: 0 index row versions were removed. +> 0 index pages have been deleted, 0 are currently reusable. +> CPU 0.53s/0.23u sec elapsed 8.24 sec. +> INFO: "job_log": removed 2795912 row versions in 187724 pages +> DETAIL: CPU 16.84s/15.22u sec elapsed 1367.50 sec. +> INFO: index "job_log_id_pkey" now contains 365590 row versions in 59665 +> pages +> DETAIL: 1742815 index row versions were removed. +> 57540 index pages have been deleted, 20000 are currently reusable. +> CPU 1.38s/2.85u sec elapsed 76.52 sec. +> INFO: index "idx_job_log_filter" now contains 365590 row versions in 15396 +> pages +> DETAIL: 0 index row versions were removed. +> 0 index pages have been deleted, 0 are currently reusable. +> CPU 0.54s/0.31u sec elapsed 7.99 sec. +> INFO: "job_log": removed 1742815 row versions in 143096 pages +> DETAIL: CPU 12.77s/11.75u sec elapsed 1046.10 sec. +> INFO: "job_log": found 12926477 removable, 365590 nonremovable row +> versions in 1377602 pages + +13M dead rows, and the table is 1.4M pages, or 11GB. No wonder it's +slow. + +You need to run a vacuum full, and then you need to vacuum far more +often. If you're running 8.1, turn on autovacuum and cut each default +scale factor in half, to 0.2 and 0.1. + +> DETAIL: 0 dead row versions cannot be removed yet. +> There were 7894754 unused item pointers. +> 0 pages are entirely empty. +> CPU 124.49s/117.57u sec elapsed 8888.80 sec. +> INFO: vacuuming "pg_toast.pg_toast_17308" +> INFO: index "pg_toast_17308_index" now contains 130 row versions in 12 +> pages +> DETAIL: 2543 index row versions were removed. +> 9 index pages have been deleted, 0 are currently reusable. +> CPU 0.00s/0.00u sec elapsed 0.11 sec. +> INFO: "pg_toast_17308": removed 2543 row versions in 617 pages +> DETAIL: CPU 0.04s/0.05u sec elapsed 4.85 sec. +> INFO: "pg_toast_17308": found 2543 removable, 130 nonremovable row +> versions in 650 pages +> DETAIL: 0 dead row versions cannot be removed yet. +> There were 0 unused item pointers. +> 0 pages are entirely empty. +> CPU 0.06s/0.06u sec elapsed 5.28 sec. +> INFO: analyzing "rshuser.job_log" +> INFO: "job_log": scanned 3000 of 1377602 pages, containing 695 live rows +> and 0 dead rows; 695 rows in sample, 319144 estimated total rows +> VACUUM +> +> +> explain analyse select count(*) from job_log; +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------------------- +> Aggregate (cost=1382171.88..1382171.88 rows=1 width=0) (actual +> time=207267.094..207267.095 rows=1 loops=1) +> -> Seq Scan on job_log (cost=0.00..1381257.90 rows=365590 width=0) +> (actual time=200156.539..206962.895 rows=365590 loops=1) +> Total runtime: 207267.153 ms +> (3 rows) +> +> ----------psql session finish---------- +> +> +> I also took snapshots of top output while I ran the above +> +> +> ----------top output start---------- +> Cpu(s): 0.7% us, 0.7% sy, 0.0% ni, 49.7% id, 48.5% wa, 0.5% hi, 0.0% si +> Mem: 1554788k total, 1538268k used, 16520k free, 6220k buffers +> Swap: 1020024k total, 176k used, 1019848k free, 1404280k cached +> +> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND +> 3368 postgres 18 0 37492 29m 11m D 2.7 1.9 3:00.54 postmaster +> +> +> +> Cpu(s): 0.7% us, 0.8% sy, 0.0% ni, 49.7% id, 48.5% wa, 0.3% hi, 0.0% si +> Mem: 1554788k total, 1538580k used, 16208k free, 2872k buffers +> Swap: 1020024k total, 176k used, 1019848k free, 1414908k cached +> +> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND +> 3368 postgres 15 0 37492 29m 11m D 2.3 1.9 5:26.03 postmaster +> +> +> Cpu(s): 0.5% us, 5.8% sy, 0.0% ni, 48.7% id, 44.4% wa, 0.5% hi, 0.0% si +> Mem: 1554788k total, 1538196k used, 16592k free, 1804k buffers +> Swap: 1020024k total, 176k used, 1019848k free, 1444576k cached +> +> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND +> 3368 postgres 15 0 20956 13m 11m D 11.0 0.9 6:25.10 postmaster +> ----------top output end---------- +> +> +> I know my database needs a major redesign. But I'm having a hard time +> explaining the poor performance nevertheless. +> +> +> Regards, +> +> Bealach +> +> +> >From: Andreas Kretschmer +> >To: pgsql-performance@postgresql.org +> >Subject: Re: [PERFORM] Why so slow? +> >Date: Thu, 27 Apr 2006 20:28:23 +0200 +> > +> >Bealach-na Bo schrieb: +> >> The node table is tiny (2500 records). What I'm pulling my hair out +> >> over is that ANY Query, even something as simple as select count(*) +> >> form job_log takes of the order of tens of minutes to complete. Just +> >> now I'm trying to run an explain analyze on the above query, but so +> >> far, it's taken 35min! with no result and there is a postgres process at +> >> the top of top +> >> +> >> What am I doing wrong?? +> > +> >The 'explain analyse' don't return a result, but it returns the query +> >plan and importance details, how PG works. +> > +> >That's why you should paste the query and the 'explain analyse' - +> >output. This is very important. +> > +> >Anyway, do you periodical vacuum your DB? My guess: no, and that's why +> >you have many dead rows. +> > +> >20:26 < akretschmer|home> ??vacuum +> >20:26 < rtfm_please> For information about vacuum +> >20:26 < rtfm_please> see +> >http://developer.postgresql.org/~wieck/vacuum_cost/ +> >20:26 < rtfm_please> or +> >http://www.postgresql.org/docs/current/static/sql-vacuum.html +> >20:26 < rtfm_please> or http://www.varlena.com/varlena/GeneralBits/116.php +> > +> >20:27 < akretschmer|home> ??explain +> >20:27 < rtfm_please> For information about explain +> >20:27 < rtfm_please> see +> >http://techdocs.postgresql.org/oscon2005/robert.treat/OSCON_Explaining_Explain_Public.sxi +> >20:27 < rtfm_please> or http://www.gtsm.com/oscon2003/toc.html +> >20:27 < rtfm_please> or +> >http://www.postgresql.org/docs/current/static/sql-explain.html +> > +> > +> >Read this links for more informations about vacuum and explain. +> > +> > +> >HTH, Andreas +> >-- +> >Really, I'm not out to destroy Microsoft. That will just be a completely +> >unintentional side effect. (Linus Torvalds) +> >"If I was god, I would recompile penguin with --enable-fly." (unknow) +> >Kaufbach, Saxony, Germany, Europe. N 51.05082?, E 13.56889? +> > +> >---------------------------(end of broadcast)--------------------------- +> >TIP 9: In versions below 8.0, the planner will ignore your desire to +> > choose an index scan if your joining column's datatypes do not +> > match +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri Apr 28 12:03:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9B69311F60B8 + for ; + Fri, 28 Apr 2006 12:03:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31143-03 + for ; + Fri, 28 Apr 2006 12:03:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from skynet.simkin.ca (skynet.simkin.ca [199.175.137.210]) + by postgresql.org (Postfix) with ESMTP id CE34711F60A0 + for ; + Fri, 28 Apr 2006 12:03:16 -0300 (ADT) +Received: from charon.medialogik.com (S0106000c6eb33e73.vf.shawcable.net + [70.68.174.20]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by skynet.simkin.ca (Postfix) with ESMTP id 13B63FAB9 + for ; + Fri, 28 Apr 2006 08:03:15 -0700 (PDT) +From: Alan Hodgson +Organization: Simkin Network Consulting +To: pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Date: Fri, 28 Apr 2006 08:02:59 -0700 +User-Agent: KMail/1.8.3 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604280802.59696@hal.medialogik.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/673 +X-Sequence-Number: 18757 + +On April 28, 2006 04:41 am, "Bealach-na Bo" +wrote: +> INFO: index "job_log_id_pkey" now contains 10496152 row versions in +> 59665 pages + +See the 10496152 above? That means you have 10496152 rows of data in your +table. If those, only 365000 are alive. That means you have basically +never vacuumed this table before, correct? + +Every update or delete creates a new dead row. count(*) scans the whole +table, dead rows included. That's why it takes so long, the table acts as +though it has 10496152 rows when doing sequential scans. + +Do a VACCUM FULL on it or CLUSTER it on on a index, both of which will empty +out all the free space and make it behave as it should. Note; VACUUM FULL +will take quite a while and requires an exclusive lock on the table. +CLUSTER also requires an exclusive lock but should be a lot faster for this +table. + +Oh, and get autovacuum setup and working, posthaste. + +-- +No long, complicated contracts. No actuarial tables to pore over. Social +Security operates on a very simple principle: the politicians take your +money from you and squander it " + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 12:35:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F1D8A11F61B8 + for ; + Fri, 28 Apr 2006 12:35:19 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 47954-01 + for ; + Fri, 28 Apr 2006 12:35:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id ABF5D11F60E8 + for ; + Fri, 28 Apr 2006 12:35:07 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3SFZ41V001310; + Fri, 28 Apr 2006 11:35:04 -0400 (EDT) +To: Markus Schaber +cc: PostgreSQL Performance List +Subject: Re: Arrays and index scan +In-reply-to: <44522AC3.6030707@logix-tt.com> +References: <44522AC3.6030707@logix-tt.com> +Comments: In-reply-to Markus Schaber + message dated "Fri, 28 Apr 2006 16:46:27 +0200" +Date: Fri, 28 Apr 2006 11:35:04 -0400 +Message-ID: <1309.1146238504@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/674 +X-Sequence-Number: 18758 + +Markus Schaber writes: +> However, the query planner seems to refuse to make index scans even with +> 8.1: +> testdb=# EXPLAIN SELECT * from streets WHERE link_id = ANY(ARRAY[1,2,3]); + +Yup, that was just done in HEAD a couple months ago. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Apr 28 13:19:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7B56811F60A5 + for ; + Fri, 28 Apr 2006 13:19:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 54426-03 + for ; + Fri, 28 Apr 2006 13:19:29 -0300 (ADT) +X-Greylist: delayed 00:33:17.601119 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id B7A7511F6069 + for ; + Fri, 28 Apr 2006 13:19:28 -0300 (ADT) +Received: from mail.aviawest.com (mail.aviawest.com [70.66.0.234]) + by svr4.postgresql.org (Postfix) with ESMTP id 75CB65B6900 + for ; + Fri, 28 Apr 2006 15:38:24 +0000 (GMT) +Received: from s0106000d5639fbfb.gv.shawcable.net ([24.69.163.91] + helo=[192.168.33.226]) + by mail.aviawest.com with asmtp (TLSv1:AES256-SHA:256) (Exim 4.24) + id 1FZV2e-0000WE-U0 + for pgsql-performance@postgresql.org; Fri, 28 Apr 2006 08:38:01 -0700 +Message-ID: <445236D5.5060509@aviawest.com> +Date: Fri, 28 Apr 2006 08:37:57 -0700 +From: Erik Myllymaki +Reply-To: erik.myllymaki@aviawest.com +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: hardare config question +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-"AviawestResorts"-MailScanner-Information: Please contact the ISP for more + information +X-"AviawestResorts"-MailScanner: Found to be clean +X-"AviawestResorts"-MailScanner-SpamScore: s +X-MailScanner-From: erik.myllymaki@aviawest.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/675 +X-Sequence-Number: 18759 + +This is a question that I also posted on Dell hardware forums, and I realize it +probably belongs there more than here. But I am thinking someone might have +some anecdotal information that could help me and this post may help someone +else down the road. + +My PowerEdge 1800 (dual 3ghz Xeon, 3GB ram) came with a single SATA drive. I +installed and developed a modest database application (Postgresql, Windows 2003 +Server, Python) on it and was pretty impressed with the performance. + +I wanted to add some more space, speed and reliability so I bought a used 3ware +9500s SATA raid card. I bought three more of the same drives (Seagate +ST3808110as) and configured them in RAID 5 (3 in RAID one as hot spare). I +reinstalled the OS and software (my efforts to ghost were not +fruitful...another story), and the first thing I did was run a sql script to +make tables, indexes, sequences etc for my app and import about 20MB of data. + +When I had this installed on a single SATA drive running from the PE1800's +on-board SATA interface, this operation took anywhere from 65-80 seconds. + +With my new RAID card and drives, this operation took 272 seconds!? + +I did a quick search and found a few posts about how RAID 5 with Databases is a +poor choice and one in particular about Postgres and how you could expect +performance to be halved with RAID 5 over a single drive or RAID 1 (until you +get above 6 disks in your RAID 5 array). So, a poorly planned configuration on +my part. + +I scrubbed the RAID config, made two RAID 1 containers (also read about how +moving database logs to a different partition than the database data is optimal +for speed and reliability). I installed the OS on the first RAID 1 volume, the +Postgresql apps and data on the other, and used Junction from sysinternals to +put the pg_xlogs back on the OS partition (does Postgresql have an easier way +to do this on Windows?). + +Well, things didn't improve noticeably - 265 seconds. + +Next step, turn on the 3ware RAID card's write cache (even though I have no +Battery Backup Unit on the RAID card and am warned about possible data loss in +the event of power loss). + +This helped - down to 172 seconds. + +Is this loss in performance just the normal overhead involved when adding a +raid card - writes now having to go to two drives instead of one? Or maybe is +the SATA interface on the Dell 1800s motherboard faster than the interface on +the 3ware raid card (SATA II ?). + +Thanks for any help you guidance you can provide. + +From pgsql-performance-owner@postgresql.org Fri Apr 28 13:20:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BDE3E11F605C + for ; + Fri, 28 Apr 2006 13:20:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52363-06 + for ; + Fri, 28 Apr 2006 13:20:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 27F6511F609E + for ; + Fri, 28 Apr 2006 13:20:24 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 818CD3147E; Fri, 28 Apr 2006 18:20:22 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: Re: CPU usage goes to 100%, query seems to ran forever +Date: Fri, 28 Apr 2006 19:19:33 +0300 +Organization: Hub.Org Networking Services +Lines: 83 +Message-ID: +References: <14690.1146164953@sss.pgh.pa.us> + <900.1146236220@sss.pgh.pa.us> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/676 +X-Sequence-Number: 18760 + +> Something seems to have truncated your EXPLAIN output, but anyway we +> can see where the problem is: + +I copied it from pgAdmin in 640x480 screen resolution in XP +Maybe pgAdmin bug ? + +> The planner is expecting to get one row from "dok" passing the filter +> condition, and hence chooses a plan that is suitable for a small number +> of rows ... but in reality there are 7670 rows matching the filter +> condition, and that's what blows the runtime out of the water. (Most of +> the runtime is actually going into 7670 repeated scans of "rid", which +> wouldn't have happened with another plan type.) + +I added index + +CREATE INDEX rid_toode_idx ON firma2.rid USING btree (toode); + +and query start working fast ! + +> So you need to see about getting that estimate to be more accurate. +> First thing is to make sure that "dok" has been ANALYZEd --- just do it +> by hand. + +As I wrote I have autovacuum running. Is'nt this sufficient ? + +> I can see at least three things you are doing that are +> unnecessarily destroying the planner's ability to estimate the number of +> matching rows: +> +> dok.laonr='1'::float8 and +> Since laonr apparently isn't float8, this forces a runtime type +> conversion as well as interfering with statistics use. (The planner +> will have ANALYZE stats about dok.laonr, but the connection to +> dok.laonr::float8 escapes it.) Just write the constant with quotes +> and no type coercion. + +I re-wrote it as + +dok.laonr=1 + +this query is automatically generated by VFP and ODBC parameter substitution +which adds those type conversions. +VFP has only float8 type and it probably forces ODBC driver convert numbers +to float8 + +> POSITION( dok.doktyyp IN 'OSIDVGYKIF')!=0 AND +> +> This is completely unestimatable given the available statistics, and it +> doesn't look to me like it is all that great a semantic representation +> either. Perhaps the query that's really meant here is "dok.doktypp IN +> ('O','S','I', ...)"? If so, you should say what you mean, not play +> games with converting the query into some strange string operation. + +'OSID ...' is a string parameter substituted to SELECT template. +changing this to IN ( 'O', 'S', .. requires re-writing parts of code and I'm +not sure it makes code faster. + +> AND dok.kuupaev||dok.kellaaeg BETWEEN '2006-04-08' AND '2006-04-2723 59' + +> This is another case where the planner is not going to have any ability +> to make a useful estimate, and it's because you are using a crummy +> representation of your data. You should merge those two columns into +> one timestamp column and just do a simple BETWEEN test. +> By and large, unnatural representations of data that you use in WHERE +> clauses are going to cost you big-time in SQL queries. It's worth +> taking time up front to design a clean table schema, and taking time +> to revise it when requirements change. + +date range test in other part of where clause + +dok.kuupaev BETWEEN .... + + is optimizable. + +AND dok.kuupaev||dok.kellaaeg adds time range test to date range. +There are less that some thousands documents per day. + +Wasting time to re-engineer database and deployed application seems not +reasonable in this case. + +Andrus. + + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 14:31:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6402111F6067 + for ; + Fri, 28 Apr 2006 14:31:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 60919-10 + for ; + Fri, 28 Apr 2006 14:31:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay101-f18.bay101.hotmail.com [64.4.56.28]) + by postgresql.org (Postfix) with ESMTP id 8E5C111F60A6 + for ; + Fri, 28 Apr 2006 14:31:34 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 28 Apr 2006 10:31:35 -0700 +Message-ID: +Received: from 64.4.56.200 by by101fd.bay101.hotmail.msn.com with HTTP; + Fri, 28 Apr 2006 17:31:30 GMT +X-Originating-IP: [84.210.10.106] +X-Originating-Email: [bealach_na_bo@hotmail.com] +X-Sender: bealach_na_bo@hotmail.com +In-Reply-To: <200604280802.59696@hal.medialogik.com> +From: "Bealach-na Bo" +To: pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Date: Fri, 28 Apr 2006 17:31:30 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +X-OriginalArrivalTime: 28 Apr 2006 17:31:35.0703 (UTC) + FILETIME=[99363A70:01C66AE9] +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/677 +X-Sequence-Number: 18761 + +> > INFO: index "job_log_id_pkey" now contains 10496152 row versions in +> > 59665 pages +> +>See the 10496152 above? That means you have 10496152 rows of data in your +>table. If those, only 365000 are alive. That means you have basically +>never vacuumed this table before, correct? + +Almost correct :| I have vacuumed this table monthly (obviously not nearly +enough), but it +is basically a log of events of which there are a very large number of each +day. + +> +>Every update or delete creates a new dead row. count(*) scans the whole +>table, dead rows included. That's why it takes so long, the table acts as +>though it has 10496152 rows when doing sequential scans. + +Oh! This explains my problems. + +> +>Do a VACCUM FULL on it or CLUSTER it on on a index, both of which will +>empty +>out all the free space and make it behave as it should. Note; VACUUM FULL +>will take quite a while and requires an exclusive lock on the table. +>CLUSTER also requires an exclusive lock but should be a lot faster for this +>table. +> +>Oh, and get autovacuum setup and working, posthaste. + +The exclusive lock is going to cause problems for me since the table is very +active. Is there a way of getting around that or do I need to schedule the +application that accesses this table? + +I'm running version 8.0. Is there autovacuum for this version too? + +Regards, +Bealach + + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 14:36:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id ACE7811F6031 + for ; + Fri, 28 Apr 2006 14:36:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 64863-06 + for ; + Fri, 28 Apr 2006 14:36:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id C402411F602F + for ; + Fri, 28 Apr 2006 14:36:46 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 8B45AB827 + for ; + Fri, 28 Apr 2006 13:36:46 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <445236D5.5060509@aviawest.com> +References: <445236D5.5060509@aviawest.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <3DFCE70E-E4BB-40AB-B27F-99E90E8159CA@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: hardare config question +Date: Fri, 28 Apr 2006 13:36:45 -0400 +To: Pgsql performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/678 +X-Sequence-Number: 18762 + + +On Apr 28, 2006, at 11:37 AM, Erik Myllymaki wrote: + +> When I had this installed on a single SATA drive running from the +> PE1800's on-board SATA interface, this operation took anywhere from +> 65-80 seconds. +> +> With my new RAID card and drives, this operation took 272 seconds!? + +switch it to RAID10 and re-try your experiment. if that is fast, +then you know your raid controller does bad RAID5. + +anyhow, I have in one server (our office mail server and part-time +development testing box) an adaptec SATA RAID from dell. it is +configured for RAID5 and does well for normal office stuff, but when +we do postgres tests on it, it just is plain old awful. + +but I have some LSI based cards on which RAID5 is plenty fast and +suitable for the DB, but those are SCSI. + +For what it is worth, the Dell PE1850 internal PERC4/Si card is +wicked fast when hooked up with a pair of U320 SCSI drives. + + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 14:37:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 931C411F6067 + for ; + Fri, 28 Apr 2006 14:37:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 67720-02 + for ; + Fri, 28 Apr 2006 14:37:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay101-f30.bay101.hotmail.com [64.4.56.40]) + by postgresql.org (Postfix) with ESMTP id 9045D11F602F + for ; + Fri, 28 Apr 2006 14:37:36 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 28 Apr 2006 10:37:35 -0700 +Message-ID: +Received: from 64.4.56.200 by by101fd.bay101.hotmail.msn.com with HTTP; + Fri, 28 Apr 2006 17:37:30 GMT +X-Originating-IP: [84.210.10.106] +X-Originating-Email: [bealach_na_bo@hotmail.com] +X-Sender: bealach_na_bo@hotmail.com +In-Reply-To: <20060428145842.GI97354@pervasive.com> +From: "Bealach-na Bo" +To: jnasby@pervasive.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Date: Fri, 28 Apr 2006 17:37:30 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +X-OriginalArrivalTime: 28 Apr 2006 17:37:35.0417 (UTC) + FILETIME=[6F9E3A90:01C66AEA] +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/679 +X-Sequence-Number: 18763 + +>The above shows that the indexes contained 10M rows and 160M of dead +>space each. That means you weren't vacuuming nearly enough. + +How is it that a row in the table can grow to a size far exceeding the sum +of the maximum sized of the fields it consists of? + +>13M dead rows, and the table is 1.4M pages, or 11GB. No wonder it's +>slow. + +I had a look at the disk files and they are HUGE indeed. + +> +>You need to run a vacuum full, and then you need to vacuum far more +>often. If you're running 8.1, turn on autovacuum and cut each default +>scale factor in half, to 0.2 and 0.1. + +I'm not runing 8.1. Is there a way of doing this in 8.0 or do I need to +write a shell script + cron job? + +Regards, + +Bealach + + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 14:43:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5441711F6004 + for ; + Fri, 28 Apr 2006 14:43:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 58739-09 + for ; + Fri, 28 Apr 2006 14:43:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from skynet.simkin.ca (skynet.simkin.ca [199.175.137.210]) + by postgresql.org (Postfix) with ESMTP id 4C1B111F6067 + for ; + Fri, 28 Apr 2006 14:43:32 -0300 (ADT) +Received: from charon.medialogik.com (S0106000c6eb33e73.vf.shawcable.net + [70.68.174.20]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by skynet.simkin.ca (Postfix) with ESMTP id C054A106F5 + for ; + Fri, 28 Apr 2006 10:43:31 -0700 (PDT) +From: Alan Hodgson +Organization: Simkin Network Consulting +To: pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Date: Fri, 28 Apr 2006 10:43:15 -0700 +User-Agent: KMail/1.8.3 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200604281043.16083@hal.medialogik.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/680 +X-Sequence-Number: 18764 + +On April 28, 2006 10:31 am, "Bealach-na Bo" +wrote: +> The exclusive lock is going to cause problems for me since the table is +> very active. Is there a way of getting around that or do I need to +> schedule the application that accesses this table? + +If you don't need access to the old data constantly: + + - copy the live data to a new table + - TRUNCATE the old table (which needs an exclusive lock but is very fast) + - insert the data back in + - for an event log I would imagine this could work + +If you do need the old data while the app is running then I'm not sure what +you can do. + +> +> I'm running version 8.0. Is there autovacuum for this version too? + +There is an autovacuum daemon in contrib; it's more annoying to setup and +keep running than the one built into 8.1, but it works OK. + +-- +Eat right. Exercise regularly. Die anyway. + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 14:49:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5BDAB11F602F + for ; + Fri, 28 Apr 2006 14:49:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 68293-03 + for ; + Fri, 28 Apr 2006 14:49:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id C0D4C11F6031 + for ; + Fri, 28 Apr 2006 14:49:07 -0300 (ADT) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 28 Apr 2006 10:47:21 -0700 +Subject: Re: hardare config question +From: Mark Lewis +To: Vivek Khera +Cc: Pgsql performance +In-Reply-To: <3DFCE70E-E4BB-40AB-B27F-99E90E8159CA@khera.org> +References: <445236D5.5060509@aviawest.com> + <3DFCE70E-E4BB-40AB-B27F-99E90E8159CA@khera.org> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Fri, 28 Apr 2006 10:47:21 -0700 +Message-Id: <1146246441.15712.41.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-27) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/681 +X-Sequence-Number: 18765 + +It's also possible that the single SATA drive you were testing (or the +controller it was attached to) is lying about fsync and performing write +caching behind your back, whereas your new controller and drives are +not. + +You'll find a lot more info on the archives of this list about it, but +basically if your application is committing a whole lot of small +transactions, then it will run fast (but not safely) on a drive which +lies about fsync, but slower on a better disk subsystem which doesn't +lie about fsync. + +Try running a test with fsync=off with your new equipment and if it +suddenly starts running faster, then you know that's the problem. +You'll either have a choice of losing all of your data the next time the +system shuts down uncleanly but being fast, or of running slow, or of +fixing the applications to use chunkier transactions. + +-- Mark + +On Fri, 2006-04-28 at 13:36 -0400, Vivek Khera wrote: +> On Apr 28, 2006, at 11:37 AM, Erik Myllymaki wrote: +> +> > When I had this installed on a single SATA drive running from the +> > PE1800's on-board SATA interface, this operation took anywhere from +> > 65-80 seconds. +> > +> > With my new RAID card and drives, this operation took 272 seconds!? +> +> switch it to RAID10 and re-try your experiment. if that is fast, +> then you know your raid controller does bad RAID5. +> +> anyhow, I have in one server (our office mail server and part-time +> development testing box) an adaptec SATA RAID from dell. it is +> configured for RAID5 and does well for normal office stuff, but when +> we do postgres tests on it, it just is plain old awful. +> +> but I have some LSI based cards on which RAID5 is plenty fast and +> suitable for the DB, but those are SCSI. +> +> For what it is worth, the Dell PE1850 internal PERC4/Si card is +> wicked fast when hooked up with a pair of U320 SCSI drives. +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + +From pgsql-performance-owner@postgresql.org Fri Apr 28 15:19:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D493511F6029 + for ; + Fri, 28 Apr 2006 15:19:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 73596-08 + for ; + Fri, 28 Apr 2006 15:19:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtpauth08.mail.atl.earthlink.net + (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) + by postgresql.org (Postfix) with ESMTP id 4823911F605C + for ; + Fri, 28 Apr 2006 15:19:24 -0300 (ADT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; + d=earthlink.net; + b=mrzOwu+cQUL6b2cju1qTrEi7PpFZfK3r9TKQLIGbzqImuKe9xtg7yBUA2vCgAUzk; + h=Message-ID:Date:From:Reply-To:To:Subject:Cc:Mime-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:X-ELNK-Trace:X-Originating-IP; +Received: from [209.86.224.46] (helo=elwamui-royal.atl.sa.earthlink.net) + by smtpauth08.mail.atl.earthlink.net with asmtp (Exim 4.34) + id 1FZXYp-0006FU-97; Fri, 28 Apr 2006 14:19:23 -0400 +Received: from 70.22.235.105 by webmail.pas.earthlink.net with HTTP; + Fri, 28 Apr 2006 14:19:23 -0400 +Message-ID: + <29786081.1146248363265.JavaMail.root@elwamui-royal.atl.sa.earthlink.net> +Date: Fri, 28 Apr 2006 14:19:23 -0400 (GMT-04:00) +From: Ron Peacetree +Reply-To: Ron Peacetree +To: Mark Lewis , Vivek Khera +Subject: Re: hardare config question +Cc: Pgsql performance +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Mailer: EarthLink Zoo Mail 1.0 +X-ELNK-Trace: + acd68a6551193be5d780f4a490ca69563f9fea00a6dd62bc659bc993575e8e05ca736489509da710350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c +X-Originating-IP: 209.86.224.46 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/682 +X-Sequence-Number: 18766 + +The best of all worlds is to use a HW RAID card with battery backed cache. + +Then you can have both high performance and high reliability. + +Benches suggest that the best such cards currently are the Areca cards which support up to 2GB of battery backed cache. + +Ron + +-----Original Message----- +>From: Mark Lewis +>Sent: Apr 28, 2006 1:47 PM +>To: Vivek Khera +>Cc: Pgsql performance +>Subject: Re: [PERFORM] hardare config question +> +>It's also possible that the single SATA drive you were testing (or the +>controller it was attached to) is lying about fsync and performing write +>caching behind your back, whereas your new controller and drives are +>not. +> +>You'll find a lot more info on the archives of this list about it, but +>basically if your application is committing a whole lot of small +>transactions, then it will run fast (but not safely) on a drive which +>lies about fsync, but slower on a better disk subsystem which doesn't +>lie about fsync. +> +>Try running a test with fsync=off with your new equipment and if it +>suddenly starts running faster, then you know that's the problem. +>You'll either have a choice of losing all of your data the next time the +>system shuts down uncleanly but being fast, or of running slow, or of +>fixing the applications to use chunkier transactions. + +From pgsql-performance-owner@postgresql.org Sat Apr 29 17:13:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id DF0EE11F6087 + for ; + Fri, 28 Apr 2006 15:36:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 77458-06 + for ; + Fri, 28 Apr 2006 15:36:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id D6F8E11F607D + for ; + Fri, 28 Apr 2006 15:36:31 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id DE6AB31478; Fri, 28 Apr 2006 20:36:30 +0200 (MET DST) +From: "Greg Stumph" +X-Newsgroups: pgsql.performance +Subject: Re: Worsening performance with 7.4 on flash-based system +Date: Fri, 28 Apr 2006 11:36:21 -0700 +Organization: Hub.Org Networking Services +Lines: 64 +Message-ID: +References: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Response +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/693 +X-Sequence-Number: 18777 + +Well, since I got no response at all to this message, I can only assume that +I've asked the question in an insufficient way, or else that no one has +anything to offer on our problem. + +This was my first post to the list, so if there's a better way I should be +asking this, or different data I should provide, hopefully someone will let +me know... + +Thanks, +Greg + +"Greg Stumph" wrote in message +news:e2b80f$245o$1@news.hub.org... +> We are experiencing gradually worsening performance in PostgreSQL 7.4.7, +> on a system with the following specs: +> Linux OS (Fedora Core 1, 2.4 kernal) +> Flash file system (2 Gig, about 80% full) +> 256 Meg RAM +> 566 MHz Celeron CPU +> +> We use Orbit 2.9.8 to access PostGres. The database contains 62 tables. +> +> When the system is running with a fresh copy of the database, performance +> is fine. At its worst, we are seeing fairly simple SELECT queries taking +> up to 1 second to execute. When these queries are run in a loop, the loop +> can take up to 30 seconds to execute, instead of the 2 seconds or so that +> we would expect. +> +> VACUUM FULL ANALYZE helps, but doesn't seem to eliminate the problem. +> +> The following table show average execution time in "bad" performance mode +> in the first column, execution time after VACUUM ANALYZE in the second +> column, and % improvement (or degradation?) in the third. The fourth +> column show the query that was executed. +> +> 741.831|582.038|-21.5| ^IDECLARE table_cursor +> 170.065|73.032|-57.1| FETCH ALL in table_cursor +> 41.953|45.513|8.5| CLOSE table_cursor +> 61.504|47.374|-23.0| SELECT last_value FROM pm_id_seq +> 39.651|46.454|17.2| select id from la_looprunner +> 1202.170|265.316|-77.9| select id from rt_tran +> 700.669|660.746|-5.7| ^IDECLARE my_tran_load_cursor +> 1192.182|47.258|-96.0| FETCH ALL in my_tran_load_cursor +> 181.934|89.752|-50.7| CLOSE my_tran_load_cursor +> 487.285|873.474|79.3| ^IDECLARE my_get_router_cursor +> 51.543|69.950|35.7| FETCH ALL in my_get_router_cursor +> 48.312|74.061|53.3| CLOSE my_get_router_cursor +> 814.051|1016.219|24.8| SELECT $1 = 'INSERT' +> 57.452|78.863|37.3| select id from op_sched +> 48.010|117.409|144.6| select short_name, long_name from la_loopapp +> 54.425|58.352|7.2| select id from cd_range +> 45.289|52.330|15.5| SELECT last_value FROM rt_tran_id_seq +> 39.658|82.949|109.2| SELECT last_value FROM op_sched_id_seq +> 42.158|68.189|61.7| select card_id,router_id from rt_valid +> +> +> Has anyone else seen gradual performance degradation like this? Would +> upgrading to Postgres 8 help? Any other thoughts on directions for +> troubleshooting this? +> +> Thanks... +> + + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 16:00:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D0EF411F60A4 + for ; + Fri, 28 Apr 2006 16:00:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 80481-08 + for ; + Fri, 28 Apr 2006 15:59:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id 2DD2E11F60A2 + for ; + Fri, 28 Apr 2006 15:59:54 -0300 (ADT) +Received: (qmail 17394 invoked by uid 500); 28 Apr 2006 19:00:05 -0000 +Date: Fri, 28 Apr 2006 14:00:05 -0500 +From: Bruno Wolff III +To: Bealach-na Bo +Cc: jnasby@pervasive.com, pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Message-ID: <20060428190005.GA15689@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Bealach-na Bo , jnasby@pervasive.com, + pgsql-performance@postgresql.org +References: <20060428145842.GI97354@pervasive.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/683 +X-Sequence-Number: 18767 + +On Fri, Apr 28, 2006 at 17:37:30 +0000, + Bealach-na Bo wrote: +> >The above shows that the indexes contained 10M rows and 160M of dead +> >space each. That means you weren't vacuuming nearly enough. +> +> How is it that a row in the table can grow to a size far exceeding the sum +> of the maximum sized of the fields it consists of? + +Because unless you run vacuum, the old deleted rows are not reused. Those +rows cannot be deleted immediately, because the rows may be visible to +other transactions. Periodic vacuums are used to find deleted rows which +are no longer visible to any transactions. + +You probably want to read the following: +http://developer.postgresql.org/docs/postgres/routine-vacuuming.html + +From pgsql-performance-owner@postgresql.org Sat Apr 29 17:13:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 72BCA11F605B + for ; + Fri, 28 Apr 2006 17:28:12 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 93155-06 + for ; + Fri, 28 Apr 2006 17:28:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 2C05E11F605A + for ; + Fri, 28 Apr 2006 17:27:59 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 59AB030CC7; Fri, 28 Apr 2006 22:27:57 +0200 (MET DST) +From: "Gregory Stewart" +X-Newsgroups: pgsql.performance +Subject: Performance Issues on Opteron Dual Core +Date: Fri, 28 Apr 2006 15:29:58 -0500 +Organization: Hub.Org Networking Services +Lines: 59 +Message-ID: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/694 +X-Sequence-Number: 18778 + +Hello, + +We are currently developing a web application and have the webserver and +PostgreSQL with our dev db running on a machine with these specs: + +Win 2003 standard +AMD Athlon XP 3000 / 2.1 GHZ +2 Gig ram +120 gig SATA HD +PostgreSQL 8.1.0 +Default pgsql configuration + shared buffers = 30,000 + +The performance of postgresql and our web application is good on that +machine, but we decided to build a dedicated database server for our +production database that scales better and that we can also use for internal +applications (CRM and so on). + +To make a long story short, we built a machine with these specs: + +Windows 2003 Standard +AMD Opteron 165 Dual Core / running at 2 GHZ +2 gig ram +2 x 150 Gig SATA II HDs in RAID 1 mode (mirror) +PostgreSQL 8.1.3 +Default pgsql configuration + shared buffers = 30,000 + +Perfomance tests in windows show that the new box outperforms our dev +machine quite a bit in CPU, HD and memory performance. + +I did some EXPLAIN ANALYZE tests on queries and the results were very good, +3 to 4 times faster than our dev db. + +However one thing is really throwing me off. +When I open a table with 320,000 rows / 16 fields in the pgadmin tool (v +1.4.0) it takes about 6 seconds on the dev server to display the result (all +rows). During these 6 seconds the CPU usage jumps to 90%-100%. + +When I open the same table on the new, faster, better production box, it +takes 28 seconds!?! During these 28 seconds the CPU usage jumps to 30% for 1 +second, and goes back to 0% for the remaining time while it is running the +query. + +What is going wrong here? It is my understanding that postgresql supports +multi-core / cpu environments out of the box, but to me it appears that it +isn't utilizing any of the 2 cpu's available. I doubt that my server is that +fast that it can perform this operation in idle mode. + +I played around with the shared buffers and tried out versions 8.1.3, 8.1.2, +8.1.0 with the same result. + +Has anyone experienced this kind of behaviour before? +How representative is the query performance in pgadmin? + +I appreciate your ideas, comments and help. + +Thanks, +Greg + + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 23:22:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3E9BC11F605A + for ; + Fri, 28 Apr 2006 23:22:12 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43190-08 + for ; + Fri, 28 Apr 2006 23:22:04 -0300 (ADT) +X-Greylist: delayed 00:34:43.331369 by SQLgrey- +Received: from imsm058dat.netvigator.com (imsm058.netvigator.com + [218.102.48.211]) + by postgresql.org (Postfix) with ESMTP id 36A1211F6002 + for ; + Fri, 28 Apr 2006 23:22:00 -0300 (ADT) +Received: from n2.netvigator.com ([218.103.190.155]) + by imsm058dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20060429014714.MMTR18293.imsm058dat.netvigator.com@n2.netvigator.com> + for ; + Sat, 29 Apr 2006 09:47:14 +0800 +Received: from n2.netvigator.com ([127.0.0.1]) + by [127.0.0.1] with ESMTP (SpamPal v1.594) + sender ; 29 Apr 2006 09:47:10 +???? +Message-Id: <6.2.1.2.0.20060429084119.05290438@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Sat, 29 Apr 2006 09:46:06 +0800 +To: pgsql-performance@postgresql.org +From: K C Lau +Subject: Re: Why so slow? +In-Reply-To: <20060428190005.GA15689@wolff.to> +References: <20060428145842.GI97354@pervasive.com> + + <20060428190005.GA15689@wolff.to> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/684 +X-Sequence-Number: 18768 + + +At 03:00 06/04/29, Bruno Wolff III wrote: +>On Fri, Apr 28, 2006 at 17:37:30 +0000, +> Bealach-na Bo wrote: +> > >The above shows that the indexes contained 10M rows and 160M of dead +> > >space each. That means you weren't vacuuming nearly enough. +> > +> > How is it that a row in the table can grow to a size far exceeding the sum +> > of the maximum sized of the fields it consists of? +> +>Because unless you run vacuum, the old deleted rows are not reused. Those +>rows cannot be deleted immediately, because the rows may be visible to +>other transactions. Periodic vacuums are used to find deleted rows which +>are no longer visible to any transactions. +> +>You probably want to read the following: +>http://developer.postgresql.org/docs/postgres/routine-vacuuming.html + +Would recycling dead tuples on the fly (mentioned in p.14 in the article +http://www.postgresql.org/files/developer/transactions.pdf ) significantly +reduce the need for periodic vacuums? + +Without knowing the internals, I have this simplistic idea: if Postgres +maintains the current lowest transaction ID for all active transactions, it +probably could recycle dead tuples on the fly. The current lowest +transaction ID could be maintained in a doubly linked list with maximum + entries. A backward link in the tuple header might be +needed too. + +Any comments? + +Cheers, +KC. + + + + + +From pgsql-performance-owner@postgresql.org Fri Apr 28 23:39:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EF86411F605C + for ; + Fri, 28 Apr 2006 23:39:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 45624-09 + for ; + Fri, 28 Apr 2006 23:39:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2157211F6029 + for ; + Fri, 28 Apr 2006 23:39:30 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3T2dSg8019398; + Fri, 28 Apr 2006 22:39:28 -0400 (EDT) +To: K C Lau +cc: pgsql-performance@postgresql.org +Subject: Re: Why so slow? +In-reply-to: <6.2.1.2.0.20060429084119.05290438@localhost> +References: <20060428145842.GI97354@pervasive.com> + + <20060428190005.GA15689@wolff.to> + <6.2.1.2.0.20060429084119.05290438@localhost> +Comments: In-reply-to K C Lau + message dated "Sat, 29 Apr 2006 09:46:06 +0800" +Date: Fri, 28 Apr 2006 22:39:28 -0400 +Message-ID: <19397.1146278368@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/685 +X-Sequence-Number: 18769 + +K C Lau writes: +> Without knowing the internals, I have this simplistic idea: if Postgres +> maintains the current lowest transaction ID for all active transactions, it +> probably could recycle dead tuples on the fly. + +[ yawn... ] Yes, we've heard that before. The hard part is getting rid +of index entries. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Apr 29 00:19:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B687711F60A5 + for ; + Sat, 29 Apr 2006 00:19:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 60872-06 + for ; + Sat, 29 Apr 2006 00:19:12 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from imsm058dat.netvigator.com (imsm058.netvigator.com + [218.102.48.211]) + by postgresql.org (Postfix) with ESMTP id DDE6211F609E + for ; + Sat, 29 Apr 2006 00:19:10 -0300 (ADT) +Received: from n2.netvigator.com ([218.103.190.155]) + by imsm058dat.netvigator.com + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id + <20060429031909.MTQS18293.imsm058dat.netvigator.com@n2.netvigator.com>; + Sat, 29 Apr 2006 11:19:09 +0800 +Received: from n2.netvigator.com ([127.0.0.1]) + by [127.0.0.1] with ESMTP (SpamPal v1.594) + sender ; 29 Apr 2006 11:19:05 +???? +Message-Id: <6.2.1.2.0.20060429110036.02c01b98@localhost> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 +Date: Sat, 29 Apr 2006 11:18:10 +0800 +To: Tom Lane +From: K C Lau +Subject: Re: Why so slow? +Cc: pgsql-performance@postgresql.org +In-Reply-To: <19397.1146278368@sss.pgh.pa.us> +References: <20060428145842.GI97354@pervasive.com> + + <20060428190005.GA15689@wolff.to> + <6.2.1.2.0.20060429084119.05290438@localhost> + <19397.1146278368@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/686 +X-Sequence-Number: 18770 + + +At 10:39 06/04/29, Tom Lane wrote: +>K C Lau writes: +> > Without knowing the internals, I have this simplistic idea: if Postgres +> > maintains the current lowest transaction ID for all active +> transactions, it +> > probably could recycle dead tuples on the fly. +> +>[ yawn... ] Yes, we've heard that before. The hard part is getting rid +>of index entries. +> +> regards, tom lane + +I apologize for simplistic ideas again. I presume that the equivalent tuple +header information is not maintained for index entries. What if they are, +probably only for the most commonly used index types to allow recycling +where possible? The extra space required would be recycled too. It would +probably also help save a trip to the tuple data pages to determine the +validity of index entries during index scans. + +Cheers, +KC. + + +From pgsql-performance-owner@postgresql.org Sat Apr 29 02:07:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8805511F6067 + for ; + Sat, 29 Apr 2006 02:07:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 80050-01 + for ; + Sat, 29 Apr 2006 02:07:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw02.mi8.com [63.240.6.46]) + by postgresql.org (Postfix) with ESMTP id 51AE711F6031 + for ; + Sat, 29 Apr 2006 02:07:39 -0300 (ADT) +Received: from 172.16.1.110 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D2)); Sat, 29 Apr 2006 01:07:34 -0400 +X-Server-Uuid: 7829E76E-BB9E-4995-8473-3C0929DF7DD1 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Sat, 29 Apr + 2006 01:07:34 -0400 +Received: from 69.181.100.71 ([69.181.100.71]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.107]) with Microsoft Exchange Server HTTP-DAV ; Sat, 29 Apr + 2006 05:07:33 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Fri, 28 Apr 2006 22:07:29 -0700 +Subject: Re: hardare config question +From: "Luke Lonergan" +To: erik.myllymaki@aviawest.com, + pgsql-performance@postgresql.org +Message-ID: +Thread-Topic: [PERFORM] hardare config question +Thread-Index: AcZq4BnYGK5LqRepSyGYyH0NRnhU2wAarZEs +In-Reply-To: <445236D5.5060509@aviawest.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 29 Apr 2006 05:07:34.0246 (UTC) + FILETIME=[D33E3860:01C66B4A] +X-WSS-ID: 684C2B1C20K283343-01-01 +Content-Type: multipart/alternative; + boundary=B_3229106850_7112162 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/687 +X-Sequence-Number: 18771 + +> This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--B_3229106850_7112162 +Content-Type: text/plain; + charset=us-ascii +Content-Transfer-Encoding: 7bit + +Erik, + +I think you have a mismatch in your Linux driver and firmware for your 3Ware +card. Download a matched Linux driver and firmware from www.3ware.com and +your problems should disappear. + +- Luke + + +On 4/28/06 8:37 AM, "Erik Myllymaki" wrote: + +> This is a question that I also posted on Dell hardware forums, and I realize +> it +> probably belongs there more than here. But I am thinking someone might have +> some anecdotal information that could help me and this post may help someone +> else down the road. +> +> My PowerEdge 1800 (dual 3ghz Xeon, 3GB ram) came with a single SATA drive. I +> installed and developed a modest database application (Postgresql, Windows +> 2003 +> Server, Python) on it and was pretty impressed with the performance. +> +> I wanted to add some more space, speed and reliability so I bought a used +> 3ware +> 9500s SATA raid card. I bought three more of the same drives (Seagate +> ST3808110as) and configured them in RAID 5 (3 in RAID one as hot spare). I +> reinstalled the OS and software (my efforts to ghost were not +> fruitful...another story), and the first thing I did was run a sql script to +> make tables, indexes, sequences etc for my app and import about 20MB of data. +> +> When I had this installed on a single SATA drive running from the PE1800's +> on-board SATA interface, this operation took anywhere from 65-80 seconds. +> +> With my new RAID card and drives, this operation took 272 seconds!? +> +> I did a quick search and found a few posts about how RAID 5 with Databases is +> a +> poor choice and one in particular about Postgres and how you could expect +> performance to be halved with RAID 5 over a single drive or RAID 1 (until you +> get above 6 disks in your RAID 5 array). So, a poorly planned configuration on +> my part. +> +> I scrubbed the RAID config, made two RAID 1 containers (also read about how +> moving database logs to a different partition than the database data is +> optimal +> for speed and reliability). I installed the OS on the first RAID 1 volume, the +> Postgresql apps and data on the other, and used Junction from sysinternals to +> put the pg_xlogs back on the OS partition (does Postgresql have an easier way +> to do this on Windows?). +> +> Well, things didn't improve noticeably - 265 seconds. +> +> Next step, turn on the 3ware RAID card's write cache (even though I have no +> Battery Backup Unit on the RAID card and am warned about possible data loss in +> the event of power loss). +> +> This helped - down to 172 seconds. +> +> Is this loss in performance just the normal overhead involved when adding a +> raid card - writes now having to go to two drives instead of one? Or maybe is +> the SATA interface on the Dell 1800s motherboard faster than the interface on +> the 3ware raid card (SATA II ?). +> +> Thanks for any help you guidance you can provide. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> +> + + + +--B_3229106850_7112162 +Content-Type: text/html; + charset=us-ascii +Content-Transfer-Encoding: quoted-printable + + + +Re: [PERFORM] hardare config question + + +Erik,= +
+
+I think you have a mismatch in your Linux driver and firmware for your 3War= +e card.  Download a matched Linux driver and firmware from www.3ware.co= +m and your problems should disappear.
+
+- Luke
+
+
+On 4/28/06 8:37 AM, "Erik Myllymaki" <erik.myllymaki@aviawest.= +com> wrote:
+
+
This is a question that I also posted on Dell hardware = +forums, and I realize it
+probably belongs there more than here. But I am thinking someone might have= +
+some anecdotal information that could help me and this post may help someon= +e
+else down the road.
+
+My PowerEdge 1800 (dual 3ghz Xeon, 3GB ram) came with a single SATA drive. = +I
+installed and developed a modest database application (Postgresql, Windows = +2003
+Server, Python) on it and was pretty impressed with the performance.
+
+I wanted to add some more space, speed and reliability so I bought a used 3= +ware
+9500s SATA raid card. I bought three more of the same drives (Seagate
+ST3808110as) and configured them in RAID 5 (3 in RAID one as hot spare). I<= +BR> +reinstalled the OS and software (my efforts to ghost were not
+fruitful...another story), and the first thing I did was run a sql script t= +o
+make tables, indexes, sequences etc for my app and import about 20MB of dat= +a.
+
+When I had this installed on a single SATA drive running from the PE1800's<= +BR> +on-board SATA interface, this operation took anywhere from 65-80 seconds. +
+With my new RAID card and drives, this operation took 272 seconds!?
+
+I did a quick search and found a few posts about how RAID 5 with Databases = +is a
+poor choice and one in particular about Postgres and how you could expect +performance to be halved with RAID 5 over a single drive or RAID 1 (until y= +ou
+get above 6 disks in your RAID 5 array). So, a poorly planned configuration= + on
+my part.
+
+I scrubbed the RAID config, made two RAID 1 containers (also read about how= +
+moving database logs to a different partition than the database data is opt= +imal
+for speed and reliability). I installed the OS on the first RAID 1 volume, = +the
+Postgresql apps and data on the other, and used Junction from sysinternals = +to
+put the pg_xlogs back on the OS partition (does Postgresql have an easier w= +ay
+to do this on Windows?).
+
+Well, things didn't improve noticeably - 265 seconds.
+
+Next step, turn on the 3ware RAID card's write cache (even though I have no= +
+Battery Backup Unit on the RAID card and am warned about possible data loss= + in
+the event of power loss).
+
+This helped - down to  172 seconds.
+
+Is this loss in performance just the normal overhead involved when adding a= +
+raid card - writes now having to go to two drives instead of one? Or maybe = +is
+the SATA interface on the Dell 1800s motherboard faster than the interface = +on
+the 3ware raid card (SATA II ?).
+
+Thanks for any help you guidance you can provide.
+
+---------------------------(end of broadcast)--------------------------- +TIP 3: Have you checked our extensive FAQ?
+
+            &nb= +sp;  
http://www.postg= +resql.org/docs/faq
+
+
+

+
+ + + + +--B_3229106850_7112162-- + + +From pgsql-performance-owner@postgresql.org Sat Apr 29 08:29:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7C03C11F60E3 + for ; + Sat, 29 Apr 2006 08:29:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31078-01 + for ; + Sat, 29 Apr 2006 08:29:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by postgresql.org (Postfix) with ESMTP id A8F9011F61C6 + for ; + Sat, 29 Apr 2006 08:29:33 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYH00332EL6BRX2@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Sat, 29 Apr 2006 06:29:31 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id A11E56E6BF for + ; + Sat, 29 Apr 2006 07:29:29 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 04636-04-2 for ; Sat, + 29 Apr 2006 07:29:29 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id DB4C06EC80; Sat, 29 Apr 2006 07:29:28 -0400 (EDT) +Date: Sat, 29 Apr 2006 07:29:28 -0400 +From: Michael Stone +Subject: Re: Why so slow? +In-reply-to: <6.2.1.2.0.20060429110036.02c01b98@localhost> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060429112926.GJ31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060428145842.GI97354@pervasive.com> + + <20060428190005.GA15689@wolff.to> + <6.2.1.2.0.20060429084119.05290438@localhost> + <19397.1146278368@sss.pgh.pa.us> + <6.2.1.2.0.20060429110036.02c01b98@localhost> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/688 +X-Sequence-Number: 18772 + +On Sat, Apr 29, 2006 at 11:18:10AM +0800, K C Lau wrote: +>I apologize for simplistic ideas again. I presume that the equivalent tuple +>header information is not maintained for index entries. What if they are, +>probably only for the most commonly used index types to allow recycling +>where possible? + +Alternatively, you could just run vacuum... + +Mike Stone + +From pgsql-performance-owner@postgresql.org Sat Apr 29 17:23:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3C15811F6210 + for ; + Sat, 29 Apr 2006 17:23:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 51634-06 + for ; + Sat, 29 Apr 2006 17:23:29 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id DF1FE11F60BC + for ; + Sat, 29 Apr 2006 17:23:27 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3TKNNEX006111; + Sat, 29 Apr 2006 16:23:23 -0400 (EDT) +To: Eric Lam +cc: pgsql-performance@postgresql.org +Subject: Re: Slow restoration question +In-reply-to: <444F24E9.2010907@lisasoft.com> +References: <444F24E9.2010907@lisasoft.com> +Comments: In-reply-to Eric Lam + message dated "Wed, 26 Apr 2006 17:14:41 +0930" +Date: Sat, 29 Apr 2006 16:23:23 -0400 +Message-ID: <6110.1146342203@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/695 +X-Sequence-Number: 18779 + +Eric Lam writes: +> what is the quickest way of dumping a DB and restoring it? I have done a + +> "pg_dump -D database | split --line-bytes 1546m part" + +Don't use "-D" if you want fast restore ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Apr 29 17:40:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 36C9C11F628A + for ; + Sat, 29 Apr 2006 17:40:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 96812-04 + for ; + Sat, 29 Apr 2006 17:40:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from 137086.vserver.de (vs137086.vserver.de [62.75.137.86]) + by postgresql.org (Postfix) with ESMTP id 1551C11F6056 + for ; + Sat, 29 Apr 2006 17:40:04 -0300 (ADT) +Received: from a-kretschmer.de (p54B3B054.dip0.t-ipconnect.de [84.179.176.84]) + (authenticated bits=0) + by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id k3TKdtQg031967 + for ; Sat, 29 Apr 2006 22:39:56 +0200 +Received: from kretschmer by a-kretschmer.de with local (Exim 4.61) + (envelope-from ) id 1FZwFJ-0008Fw-PK + for pgsql-performance@postgresql.org; Sat, 29 Apr 2006 22:40:53 +0200 +Date: Sat, 29 Apr 2006 22:40:53 +0200 +From: Andreas Kretschmer +To: pgsql-performance@postgresql.org +Subject: Re: Slow restoration question +Message-ID: <20060429204053.GA31334@KanotixBox> +References: <444F24E9.2010907@lisasoft.com> <6110.1146342203@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <6110.1146342203@sss.pgh.pa.us> +X-OS: Debian/GNU Linux - weil ich es mir Wert bin! +X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA +X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the + answer is "no"! +X-Lugdd: Gerd Kube +X-Info: My name is root. Just root. And I am licensed to kill -9 +User-Agent: mutt-ng 1.5.9i (Linux) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/696 +X-Sequence-Number: 18780 + +Tom Lane schrieb: + +> Eric Lam writes: +> > what is the quickest way of dumping a DB and restoring it? I have done a +> +> > "pg_dump -D database | split --line-bytes 1546m part" +> +> Don't use "-D" if you want fast restore ... + +hehe, yes ;-) + +http://people.planetpostgresql.org/devrim/index.php?/archives/44-d-of-pg_dump.html + + +Andreas +-- +Really, I'm not out to destroy Microsoft. That will just be a completely +unintentional side effect. (Linus Torvalds) +"If I was god, I would recompile penguin with --enable-fly." (unknow) +Kaufbach, Saxony, Germany, Europe. N 51.05082�, E 13.56889� + +From pgsql-performance-owner@postgresql.org Sat Apr 29 17:59:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D2FA811F6289 + for ; + Sat, 29 Apr 2006 17:59:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10994-08 + for ; + Sat, 29 Apr 2006 17:59:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 4253911F60AB + for ; + Sat, 29 Apr 2006 17:59:31 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A8FE830F58; Sat, 29 Apr 2006 22:59:29 +0200 (MET DST) +From: William Yu +X-Newsgroups: pgsql.performance +Subject: Re: Worsening performance with 7.4 on flash-based system +Date: Sat, 29 Apr 2006 13:59:27 -0700 +Organization: Hub.Org Networking Services +Lines: 70 +Message-ID: +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Thunderbird 1.5 (X11/20051201) +In-Reply-To: +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/697 +X-Sequence-Number: 18781 + +Usually when simple queries take a long time to run, it's the system +tables (pg_*) that have become bloated and need vacuuming. But that's +just random guess on my part w/o my detailed info. + + +Greg Stumph wrote: +> Well, since I got no response at all to this message, I can only assume that +> I've asked the question in an insufficient way, or else that no one has +> anything to offer on our problem. +> +> This was my first post to the list, so if there's a better way I should be +> asking this, or different data I should provide, hopefully someone will let +> me know... +> +> Thanks, +> Greg +> +> "Greg Stumph" wrote in message +> news:e2b80f$245o$1@news.hub.org... +>> We are experiencing gradually worsening performance in PostgreSQL 7.4.7, +>> on a system with the following specs: +>> Linux OS (Fedora Core 1, 2.4 kernal) +>> Flash file system (2 Gig, about 80% full) +>> 256 Meg RAM +>> 566 MHz Celeron CPU +>> +>> We use Orbit 2.9.8 to access PostGres. The database contains 62 tables. +>> +>> When the system is running with a fresh copy of the database, performance +>> is fine. At its worst, we are seeing fairly simple SELECT queries taking +>> up to 1 second to execute. When these queries are run in a loop, the loop +>> can take up to 30 seconds to execute, instead of the 2 seconds or so that +>> we would expect. +>> +>> VACUUM FULL ANALYZE helps, but doesn't seem to eliminate the problem. +>> +>> The following table show average execution time in "bad" performance mode +>> in the first column, execution time after VACUUM ANALYZE in the second +>> column, and % improvement (or degradation?) in the third. The fourth +>> column show the query that was executed. +>> +>> 741.831|582.038|-21.5| ^IDECLARE table_cursor +>> 170.065|73.032|-57.1| FETCH ALL in table_cursor +>> 41.953|45.513|8.5| CLOSE table_cursor +>> 61.504|47.374|-23.0| SELECT last_value FROM pm_id_seq +>> 39.651|46.454|17.2| select id from la_looprunner +>> 1202.170|265.316|-77.9| select id from rt_tran +>> 700.669|660.746|-5.7| ^IDECLARE my_tran_load_cursor +>> 1192.182|47.258|-96.0| FETCH ALL in my_tran_load_cursor +>> 181.934|89.752|-50.7| CLOSE my_tran_load_cursor +>> 487.285|873.474|79.3| ^IDECLARE my_get_router_cursor +>> 51.543|69.950|35.7| FETCH ALL in my_get_router_cursor +>> 48.312|74.061|53.3| CLOSE my_get_router_cursor +>> 814.051|1016.219|24.8| SELECT $1 = 'INSERT' +>> 57.452|78.863|37.3| select id from op_sched +>> 48.010|117.409|144.6| select short_name, long_name from la_loopapp +>> 54.425|58.352|7.2| select id from cd_range +>> 45.289|52.330|15.5| SELECT last_value FROM rt_tran_id_seq +>> 39.658|82.949|109.2| SELECT last_value FROM op_sched_id_seq +>> 42.158|68.189|61.7| select card_id,router_id from rt_valid +>> +>> +>> Has anyone else seen gradual performance degradation like this? Would +>> upgrading to Postgres 8 help? Any other thoughts on directions for +>> troubleshooting this? +>> +>> Thanks... +>> +> +> + +From pgsql-performance-owner@postgresql.org Sat Apr 29 18:53:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4AEBB11F6202 + for ; + Sat, 29 Apr 2006 18:53:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 95850-10 + for ; + Sat, 29 Apr 2006 18:53:12 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.194]) + by postgresql.org (Postfix) with ESMTP id E2CF711F61F6 + for ; + Sat, 29 Apr 2006 18:53:10 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id h31so1612193wxd + for ; + Sat, 29 Apr 2006 14:53:11 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; + b=e9Z7UBRZEJxoIxAXATST8NL/gtefg3XEKP2CQ/tX/MTlhw6uy/nm8eRq6VfgPXAqvJTk8d0FZ4MQa6MkLnEmJ4mXWT7VR+Sx1qAWV+bo66yuD3Qhf37uqWYv0zpaTteUFYc08kx20UX3btRYdOvrvyWK2xvTJVsfWTJ8/My9BNM= +Received: by 10.70.94.7 with SMTP id r7mr1007454wxb; + Sat, 29 Apr 2006 14:53:10 -0700 (PDT) +Received: by 10.70.111.19 with HTTP; Sat, 29 Apr 2006 14:53:10 -0700 (PDT) +Message-ID: +Date: Sat, 29 Apr 2006 17:53:10 -0400 +From: "Michael Artz" +To: pgsql-performance@postgresql.org +Subject: Re: Easy question +In-Reply-To: <1146101167.724196.253740@v46g2000cwv.googlegroups.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_16251_18954078.1146347590360" +References: <1145741653.759727.38970@e56g2000cwe.googlegroups.com> + + <1146101167.724196.253740@v46g2000cwv.googlegroups.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/698 +X-Sequence-Number: 18782 + +------=_Part_16251_18954078.1146347590360 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +You have a functional index on UPPER(municipo), right? How large is the +table? + +On 26 Apr 2006 18:26:07 -0700, Bert wrote: +> +> Thanks, +> But the performance is the same just the formating is more simple. +> Greets, +> Bert +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + +------=_Part_16251_18954078.1146347590360 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +You have a functional index on UPPER(municipo), right?  How large is t= +he table?

On 26 Apr 2006 18:26:07 -= +0700, Bert < +clemens.bertschler@gmail.com> wrote:
Thanks,
But the performance is the same= + just the formating is more simple. +
Greets,
Bert


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

+ +------=_Part_16251_18954078.1146347590360-- + +From pgsql-performance-owner@postgresql.org Sat Apr 29 20:51:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9A5EF11F61BF + for ; + Sat, 29 Apr 2006 20:51:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 78352-02 + for ; + Sat, 29 Apr 2006 20:51:46 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.197]) + by postgresql.org (Postfix) with ESMTP id 7ADAE11F6003 + for ; + Sat, 29 Apr 2006 20:51:44 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id 9so2064701nzo + for ; + Sat, 29 Apr 2006 16:51:44 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=UeN6DAVw+HicvYZCKxa4sYMNck8RurQwWHV6cG+EJJZad45u3JNEklCfTAifTXOpXZKsmr9O6ZjuBQ8T223+vI6cWInIVWUJsJu4FBsgerAkiCTqiAVv7kiT/puPwx8bwCP+Rv0oGU/Xs5F75ZJ/J68+JeOhHpaGWyEWGzLMh6g= +Received: by 10.36.89.1 with SMTP id m1mr1821118nzb; + Sat, 29 Apr 2006 16:51:44 -0700 (PDT) +Received: by 10.36.97.2 with HTTP; Sat, 29 Apr 2006 16:51:44 -0700 (PDT) +Message-ID: <3c1395330604291651q129b4e14v5f3849f842e8b9d8@mail.gmail.com> +Date: Sun, 30 Apr 2006 09:51:44 +1000 +From: "chris smith" +To: "Greg Stumph" +Subject: Re: Worsening performance with 7.4 on flash-based system +Cc: pgsql-performance@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/699 +X-Sequence-Number: 18783 + +On 4/29/06, Greg Stumph wrote: +> Well, since I got no response at all to this message, I can only assume t= +hat +> I've asked the question in an insufficient way, or else that no one has +> anything to offer on our problem. +> +> This was my first post to the list, so if there's a better way I should b= +e +> asking this, or different data I should provide, hopefully someone will l= +et +> me know... +> +> Thanks, +> Greg +> +> "Greg Stumph" wrote in message +> news:e2b80f$245o$1@news.hub.org... +> > We are experiencing gradually worsening performance in PostgreSQL 7.4.7= +, +> > on a system with the following specs: +> > Linux OS (Fedora Core 1, 2.4 kernal) +> > Flash file system (2 Gig, about 80% full) +> > 256 Meg RAM +> > 566 MHz Celeron CPU +> > +> > We use Orbit 2.9.8 to access PostGres. The database contains 62 tables. +> > +> > When the system is running with a fresh copy of the database, performan= +ce +> > is fine. At its worst, we are seeing fairly simple SELECT queries takin= +g +> > up to 1 second to execute. When these queries are run in a loop, the lo= +op +> > can take up to 30 seconds to execute, instead of the 2 seconds or so th= +at +> > we would expect. + +If you're inserting/updating/deleting a table or tables heavily, then +you'll need to vacuum it a lot more often than a reasonably static +table. Are you running contrib/autovacuum at all? PG 8.0 and above +have autovacuum built in but 7.4.x needs to run the contrib version. + +PS - the latest 7.4 version is .12 - see +http://www.postgresql.org/docs/7.4/interactive/release.html for what +has changed (won't be much in performance terms but may fix data-loss +bugs). + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Wed May 3 03:10:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9C5AA11F60A6 + for ; + Sat, 29 Apr 2006 21:08:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 83088-07 + for ; + Sat, 29 Apr 2006 21:08:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 1634F11F6091 + for ; + Sat, 29 Apr 2006 21:08:05 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 5F7A130F4E; Sun, 30 Apr 2006 02:08:05 +0200 (MET DST) +From: "Bert" +X-Newsgroups: pgsql.performance +Subject: Re: Easy question +Date: 29 Apr 2006 17:07:59 -0700 +Organization: http://groups.google.com +Lines: 9 +Message-ID: <1146355679.311472.57800@u72g2000cwu.googlegroups.com> +References: <1145741653.759727.38970@e56g2000cwe.googlegroups.com> + + <1146101167.724196.253740@v46g2000cwv.googlegroups.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +In-Reply-To: +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.8.0.2) Gecko/20060308 + Firefox/1.5.0.2,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: u72g2000cwu.googlegroups.com; posting-host=200.114.70.217; + posting-account=I3Q4Kw0AAAB5qSAosGYN-4vsrNRUrVAS +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/71 +X-Sequence-Number: 18858 + +No i didn't defined any indexes for the table, I know the performance +will increase with an index, but this was not my question. My question +furthermore belongs to the access mode of the SQL statement. +Furthermore i do not understand why the Upper function should increase +the performance. +The table has approximately 20.000 entries. +Is it the best way to use a B-Tree index on the municipio column in +this case or are there better solution to do this. + + +From pgsql-performance-owner@postgresql.org Sun Apr 30 07:30:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 157839FAE4E + for ; + Sun, 30 Apr 2006 07:30:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 07868-04 + for ; + Sun, 30 Apr 2006 07:30:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from hotmail.com (bay101-f38.bay101.hotmail.com [64.4.56.48]) + by postgresql.org (Postfix) with ESMTP id C52B59F9AFD + for ; + Sun, 30 Apr 2006 07:29:59 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Sun, 30 Apr 2006 03:29:57 -0700 +Message-ID: +Received: from 64.4.56.200 by by101fd.bay101.hotmail.msn.com with HTTP; + Sun, 30 Apr 2006 10:29:55 GMT +X-Originating-IP: [84.210.10.106] +X-Originating-Email: [bealach_na_bo@hotmail.com] +X-Sender: bealach_na_bo@hotmail.com +In-Reply-To: <200604281043.16083@hal.medialogik.com> +From: "Bealach-na Bo" +To: ahodgson@simkin.ca, pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Date: Sun, 30 Apr 2006 10:29:55 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +X-OriginalArrivalTime: 30 Apr 2006 10:29:57.0740 (UTC) + FILETIME=[0746EAC0:01C66C41] +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/700 +X-Sequence-Number: 18784 + +>If you don't need access to the old data constantly: +> +> - copy the live data to a new table +> - TRUNCATE the old table (which needs an exclusive lock but is very fast) +> - insert the data back in +> - for an event log I would imagine this could work + +Obtaining exclusive locks on this table is very difficult, or rather, +will make life very difficult for others, so I'm averse to running +vacuum full or truncate (though I don't know how fast truncate is) +on a regular basis. I might just get away with running it +once a month, but no more. + +(Lazy) vacuum, however is a much more palatable option. But (lazy) +vacuum does not always reclaim space. Will this affect performance and +does this mean that a full vacuum is unavoidable? Or can I get away +with daily (lazy) vacuums? Disk space is not an issue for me, but +performance is a BIG issue. Of course, I realize that I could improve +the latter with better schema design - I'm working on a new schema, +but can't kill this one yet :|. + +Regards, + +Bealach + + + +From pgsql-performance-owner@postgresql.org Sun Apr 30 08:00:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1254E9F9AFD + for ; + Sun, 30 Apr 2006 08:00:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 36924-08 + for ; + Sun, 30 Apr 2006 08:00:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz + [203.96.152.182]) + by postgresql.org (Postfix) with ESMTP id 336FA9FA999 + for ; + Sun, 30 Apr 2006 08:00:09 -0300 (ADT) +Received: from smtp-3.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-3.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IYJ00HV47W65J@linda-3.paradise.net.nz> for + pgsql-performance@postgresql.org; Sun, 30 Apr 2006 23:00:06 +1200 (NZST) +Received: from [192.168.1.11] (218-101-29-19.dsl.clear.net.nz [218.101.29.19]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id 5A1BB160C569; Sun, + 30 Apr 2006 23:00:06 +1200 (NZST) +Date: Sun, 30 Apr 2006 22:59:56 +1200 +From: Mark Kirkwood +Subject: Re: Performance Issues on Opteron Dual Core +In-reply-to: +To: Gregory Stewart +Cc: pgsql-performance@postgresql.org +Message-id: <445498AC.10700@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Thunderbird 1.5 (X11/20060417) +References: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/701 +X-Sequence-Number: 18785 + +Gregory Stewart wrote: +> Hello, +> +> We are currently developing a web application and have the webserver and +> PostgreSQL with our dev db running on a machine with these specs: +> +> Win 2003 standard +> AMD Athlon XP 3000 / 2.1 GHZ +> 2 Gig ram +> 120 gig SATA HD +> PostgreSQL 8.1.0 +> Default pgsql configuration + shared buffers = 30,000 +> +> The performance of postgresql and our web application is good on that +> machine, but we decided to build a dedicated database server for our +> production database that scales better and that we can also use for internal +> applications (CRM and so on). +> +> To make a long story short, we built a machine with these specs: +> +> Windows 2003 Standard +> AMD Opteron 165 Dual Core / running at 2 GHZ +> 2 gig ram +> 2 x 150 Gig SATA II HDs in RAID 1 mode (mirror) +> PostgreSQL 8.1.3 +> Default pgsql configuration + shared buffers = 30,000 +> +> Perfomance tests in windows show that the new box outperforms our dev +> machine quite a bit in CPU, HD and memory performance. +> +> I did some EXPLAIN ANALYZE tests on queries and the results were very good, +> 3 to 4 times faster than our dev db. +> +> However one thing is really throwing me off. +> When I open a table with 320,000 rows / 16 fields in the pgadmin tool (v +> 1.4.0) it takes about 6 seconds on the dev server to display the result (all +> rows). During these 6 seconds the CPU usage jumps to 90%-100%. +> +> When I open the same table on the new, faster, better production box, it +> takes 28 seconds!?! During these 28 seconds the CPU usage jumps to 30% for 1 +> second, and goes back to 0% for the remaining time while it is running the +> query. +> +> What is going wrong here? It is my understanding that postgresql supports +> multi-core / cpu environments out of the box, but to me it appears that it +> isn't utilizing any of the 2 cpu's available. I doubt that my server is that +> fast that it can perform this operation in idle mode. +> +> I played around with the shared buffers and tried out versions 8.1.3, 8.1.2, +> 8.1.0 with the same result. +> +> Has anyone experienced this kind of behaviour before? +> How representative is the query performance in pgadmin? +> + +Pgadmin can give misleading times for queries that return large result +sets over a network, due to: + +1/ It takes time to format the (large) result set for display. +2/ It has to count the time spent waiting for the (large) result set to +travel across the network. + +You aren't running Pgadmin off the dev server are you? If not check your +network link to dev and prod - is one faster than the other? (etc). + +To eliminate Pgadmin and the network as factors try wrapping your query +in a 'SELECT count(*) FROM (your query here) AS a', and see if it +changes anything! + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Sun Apr 30 11:03:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 27A8F9FA9BD + for ; + Sun, 30 Apr 2006 11:03:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19651-01 + for ; + Sun, 30 Apr 2006 11:03:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx00.pub.collaborativefusion.com + (mx00.pub.collaborativefusion.com [206.210.89.199]) + by postgresql.org (Postfix) with ESMTP id 3CC049FA999 + for ; + Sun, 30 Apr 2006 11:03:49 -0300 (ADT) +Received: from localhost (monrovll-cuda1-24-53-251-44.pittpa.adelphia.net + [24.53.251.44]) + (AUTH: LOGIN wmoran, TLS: TLSv1/SSLv3,256bits,AES256-SHA) + by wingspan with esmtp; Sun, 30 Apr 2006 10:03:47 -0400 + id 00056410.4454C3C3.0001387C +Date: Sun, 30 Apr 2006 10:03:46 -0400 +From: Bill Moran +To: "Bealach-na Bo" +Cc: ahodgson@simkin.ca, pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Message-Id: <20060430100346.20f010a9.wmoran@collaborativefusion.com> +In-Reply-To: +References: <200604281043.16083@hal.medialogik.com> + +Organization: Collaborative Fusion +X-Mailer: Sylpheed version 1.0.6 (GTK+ 1.2.10; i386-portbld-freebsd5.4) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/702 +X-Sequence-Number: 18786 + +"Bealach-na Bo" wrote: + +> >If you don't need access to the old data constantly: +> > +> > - copy the live data to a new table +> > - TRUNCATE the old table (which needs an exclusive lock but is very fast) +> > - insert the data back in +> > - for an event log I would imagine this could work +> +> Obtaining exclusive locks on this table is very difficult, or rather, +> will make life very difficult for others, so I'm averse to running +> vacuum full or truncate (though I don't know how fast truncate is) +> on a regular basis. I might just get away with running it +> once a month, but no more. +> +> (Lazy) vacuum, however is a much more palatable option. But (lazy) +> vacuum does not always reclaim space. Will this affect performance and +> does this mean that a full vacuum is unavoidable? Or can I get away +> with daily (lazy) vacuums? Disk space is not an issue for me, but +> performance is a BIG issue. Of course, I realize that I could improve +> the latter with better schema design - I'm working on a new schema, +> but can't kill this one yet :|. + +My understanding is basically that if you vacuum with the correct +frequency, you'll never need to vacuum full. This is why the +autovacuum system is so nice, it adjusts the frequency of vacuum according +to how much use the DB is getting. + +The problem is that if you get behind, plain vacuum is unable to get things +caught up again, and a vacuum full is required to recover disk space. + +At this point, it seems like you need to do 2 things: +1) Schedule lazy vacuum to run, or configure autovacuum. +2) Schedule some downtime to run "vacuum full" to recover some disk space. + +#2 only needs done once to get you back on track, assuming that #1 is +done properly. + +A little bit of wasted space in the database is OK, and lazy vacuum done +on a reasonable schedule will keep the level of wasted space to an +acceptable level. + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + +From pgsql-performance-owner@postgresql.org Wed May 3 03:15:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 342549FB21A + for ; + Sun, 30 Apr 2006 20:37:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 53091-03 + for ; + Sun, 30 Apr 2006 20:37:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id D51909FA682 + for ; + Sun, 30 Apr 2006 20:37:25 -0300 (ADT) +Received: from mail1.ardec.com.au (unknown [203.11.83.254]) + by svr4.postgresql.org (Postfix) with ESMTP id 9A49B5B2D1F + for ; + Sun, 30 Apr 2006 23:37:24 +0000 (GMT) +Received: from [192.168.1.188] (lorax.bedrock.ardec.com.au [192.168.1.188]) + by mail1.ardec.com.au (8.13.3/8.13.3) with ESMTP id k3UNb9Jn029261 + for ; + Mon, 1 May 2006 09:07:09 +0930 (CST) +Message-ID: <44554A35.7060308@lisasoft.com> +Date: Mon, 01 May 2006 09:07:25 +0930 +From: Eric Lam +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow restoration question +References: <444F24E9.2010907@lisasoft.com> <6110.1146342203@sss.pgh.pa.us> +In-Reply-To: <6110.1146342203@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV 0.88/1429/Sun Apr 30 20:00:14 2006 on + mizaru.adl.ardec.com.au +X-Virus-Status: Clean +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/72 +X-Sequence-Number: 18859 + +Tom Lane wrote: + +>Eric Lam writes: +> +> +>>what is the quickest way of dumping a DB and restoring it? I have done a +>> +>> +> +> +> +>> "pg_dump -D database | split --line-bytes 1546m part" +>> +>> +> +>Don't use "-D" if you want fast restore ... +> +> regards, tom lane +> +> +> +thanks, I read that from the doco, the reason why I am using the -D +option is because I was informed by previous people in the company that +they never got a 100% strike rate in database restoration without using +the -D or -d options. If I have enough space on the QA/staging machine +I'll give the no options dump restoration a try. + +Anyone have any estimates the time differences between the -D, -d and +[using no option]. + +regards +Eric Lam +