Re: BUG #7495: chosen wrong index - Mailing list pgsql-bugs

From Kevin Grittner
Subject Re: BUG #7495: chosen wrong index
Date
Msg-id 502BB47E020000250004975C@gw.wicourts.gov
Whole thread Raw
In response to Re: BUG #7495: chosen wrong index  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-bugs
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> wrote:
<> psql@elbrief.de> wrote:
>
>> insert into bla ( a , b )
>>   select a , a
>>     from generate_series( 1 , 1000000 ) as a ( a ) ;
>
>> explain analyze select * from bla
>>   where b > 990000 order by a limit 10 ;
>> [uses index on b and has a long run time]
>
> The problem is that PostgreSQL doesn't have any sense of the
> correlation between columns a and b (i.e., they are always equal)

A belated thought on this -- you went right from your load to
running queries without leaving any time for autovacuum to kick in
and generate statistics.  I recommend that somewhere after you
insert the data and before you run your selects, you run:

VACUUM ANALYZE bla;

This will get you to something which more closely resembles a
"steady state" environment.

-Kevin

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Possible Bug in 9.2beta3
Next
From: daniel@heroku.com
Date:
Subject: BUG #7497: Excessive toast bloat after standby promotion