Re: index/join madness - Mailing list pgsql-sql

From jdassen@cistron.nl (J.H.M. Dassen (Ray))
Subject Re: index/join madness
Date
Msg-id slrn9gngn1.oth.jdassen@odin.cistron-office.nl
Whole thread Raw
In response to index/join madness  ("Michael Richards" <michael@fastmail.ca>)
List pgsql-sql
Michael Richards <michael@fastmail.ca> wrote:
> Ok, I've built the most insane query ever.

Indeed. Kindly stay away from sharp objects and wait for the friendly people
to bring you to the bouncy room :-)

> If anyone has a screen wide enough to see this, you will see that the
> majority of the time is spent doing sequential scans on the formdata
> table. This table needs formid, fieldid and userid to find the value I'm
> looking for.

> In my case I'm ignoring occid since it's always 1 for these values. 

What happens if you put in an "and occid = 1"? Perhaps it's the case that
you know it's always one, but the query planner doesn't realise this.

> I'm a little curious as to why it's not using the primary key...

Another possible cause which I've seen in a couple of recent threads is that
the query analyzer isn't very smart about the relationships between types,
so it may help to explicitly cast values to the exact type used in the
index.

HTH,
Ray
-- 
"Never trust a poll you haven't rigged yourself."



pgsql-sql by date:

Previous
From: "Chris Ruprecht"
Date:
Subject: Select question
Next
From: David Olbersen
Date:
Subject: Re: index/join madness