Re: query planner not using the correct index - Mailing list pgsql-performance

From Tom Lane
Subject Re: query planner not using the correct index
Date
Msg-id 27696.1218143560@sss.pgh.pa.us
Whole thread Raw
In response to Re: query planner not using the correct index  ("Joshua Shanks" <jjshanks@gmail.com>)
Responses Re: query planner not using the correct index
List pgsql-performance
"Joshua Shanks" <jjshanks@gmail.com> writes:
> It seems obvious that the stats on attr1 at the current level are
> inaccurate as there are over 100,000 unique enteries in the table.

Well, you haven't told us how big any of these tables are, so it's
hard to tell if the n_distinct value is wrong or not ... but in
any case I don't think that the stats on attr1 have anything to do
with your problem.  The reason that the "fast" query is fast is that
it benefits from the fact that there's only one bars row with
bars_id = 12345.  So the question is how many such rows does the
planner now think there are (try "explain analyze select * from bars
where bars_id = 12345"), and if it's badly wrong, then you need to be
looking at the stats on bars.bars_id to find out why.

            regards, tom lane

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Query Plan choice with timestamps
Next
From: "Scott Marlowe"
Date:
Subject: Re: file system and raid performance