pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: jacob@aers.ca
Cc: pgsql-sql@postgresql.org
Subject: Re: FW: Query length limitation in postgres server > 8.2.9
Date: Thu, 09 Jul 2009 14:28:59 -0400
Message-ID: <4289.1247164139@sss.pgh.pa.us> (raw)
In-Reply-To: <6B5AF6293A289F45826220B17ABE7937FDB1CB@BORON.aers.local>
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>

<jacob@aers.ca> writes:
> leaf_category_1     

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



view thread (13+ messages)  latest in thread

Message-ID: <4289.1247164139@sss.pgh.pa.us>
Permalink:  ../4289.1247164139@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4289.1247164139@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jacob@aers.ca
  Subject: Re: FW: Query length limitation in postgres server > 8.2.9
  In-Reply-To: <4289.1247164139@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox