Re: BUG #1487: Index problem - Mailing list pgsql-bugs

From Richard Huxton
Subject Re: BUG #1487: Index problem
Date
Msg-id 421A0019.8020801@archonet.com
Whole thread Raw
In response to BUG #1487: Index problem  ("Tom Yeh" <tom_m_yeh@yahoo.com>)
List pgsql-bugs
Tom Yeh wrote:
>
> I created an index for a table, say Entity, on a field, say id.
>
> Then, the follwoing two SQL has different result:
>
> select * from "Entity" e where e.id = '1000'
> select * from  "Entity" e where e.id like '1000'

What is the definition of "Entity"?
How many rows are there in the table?
How many match '1000'?
Are your statistics up to date?
Are you happy that you are gathering enough statistics values for the
"id" column?
Do you understand the issues with using LIKE and non-C locales?

> (The later uses sequential scan. BTW, while 7.4.x uses index why 8.0 behave
> worse?)

You don't say how the EXPLAIN ANALYSE for each is different.

> Once I re-index it, the problem is gone. However, the problem comes back
> randomly if I change some id.

By "randomly" do you mean it switches plans depending on the value you
match against, or that you can repeat the same query twice and it uses
different plans?

> The above can be replicated by using pgAdmin III only.

Are you saying it doesn't do this from psql?

If you're not convinced this is an actual bug in PostgreSQL's planner,
it might be better to post details to the performance or sql lists where
there are more people to help answer.

--
   Richard Huxton
   Archonet Ltd

pgsql-bugs by date:

Previous
From: "Markus Bertheau"
Date:
Subject: BUG #1495: RPM: wrong quoting of error message about old database format after upgrading
Next
From: "Dave Page"
Date:
Subject: Re: BUG #1487: Index problem