Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id A69C0633B38 for ; Thu, 9 Jul 2009 15:33:25 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 06258-06 for ; Thu, 9 Jul 2009 15:33:12 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail1.mailhostingservice.com (mail1.mailhostingservice.com [216.154.198.171]) by mail.postgresql.org (Postfix) with SMTP id D0FFD6339F3 for ; Thu, 9 Jul 2009 15:33:14 -0300 (ADT) Received: From aers.ca (24.68.32.77) by mail1.mailhostingservice.com Id <4ffc4dd1d2655cf746b77c651dbf4bfaeeb3f564@mail1.mailhostingservice.com> ; Thr, 9 Jul 2009 18:32:08 +0000 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: FW: Query length limitation in postgres server > 8.2.9 Date: Thu, 9 Jul 2009 11:33:09 -0700 Message-ID: <6B5AF6293A289F45826220B17ABE7937FDB1D3@BORON.aers.local> In-Reply-To: <4289.1247164139@sss.pgh.pa.us> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] FW: Query length limitation in postgres server > 8.2.9 Thread-Index: AcoAwyZSrAX9qWB0SMmpkc1Ma9qvQgAAGA7g References: <6B5AF6293A289F45826220B17ABE7937FDB16C@BORON.aers.local> <6B5AF6293A289F45826220B17ABE7937FDB1C0@BORON.aers.local> <3795.1247162732@sss.pgh.pa.us> <6B5AF6293A289F45826220B17ABE7937FDB1C6@BORON.aers.local> <3981.1247163226@sss.pgh.pa.us> <6B5AF6293A289F45826220B17ABE7937FDB1CB@BORON.aers.local> <4289.1247164139@sss.pgh.pa.us> From: To: Cc: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL=0.000, UNPARSEABLE_RELAY=0.001 X-Spam-Level: X-Archive-Number: 200907/48 X-Sequence-Number: 32789 the data is insert once, read many so we should be fine on that side. I've past this on to the dev's and I'll let you know when I get feed back. Thanks for your input Tom (and the others). -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 Sent: Thursday, July 09, 2009 11:29 AM To: Jacob Bresciani Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] FW: Query length limitation in postgres server > 8.2.9=20 writes: > leaf_category_1 =20 Ah. So you are wishing it would use this index: "search_site1_2009_03_13_leaf_category_1" btree (leaf_category_1, site_id) WHERE leaf_category_1 IS NOT NULL If I were you I'd drop the WHERE clause, which is eliminating no index entries whatsoever (since the column is actually declared not null). What it is doing is forcing the planner to expend many cycles proving that the query's WHERE clause requires leaf_category_1 to be non-null hence the index is potentially usable. The reason recent releases are giving you trouble is that we put a limit on how many cycles we'd expend on such silliness. If you really don't want to change the schema, you could work around the issue by adding a separate "leaf_category_1 IS NOT NULL" test to the query, so that the planner can prove the index is relevant without having to grovel through hundreds of IN-list items to do it. In general, this table schema looks like somebody has drastically overengineered the index definitions with rather little understanding of what they were doing or what the performance consequences would be. I hope the table is read-mostly, because you're paying a *lot* anytime you update those indexes. regards, tom lane