Re: BUG #7495: chosen wrong index

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <psql(at)elbrief(dot)de>,<pgsql-bugs(at)postgresql(dot)org>, "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Subject: Re: BUG #7495: chosen wrong index
Date: 2012-08-15 19:38:54
Message-ID: 502BB47E020000250004975C@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> wrote:
<> psql(at)elbrief(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message daniel 2012-08-15 20:00:25 BUG #7497: Excessive toast bloat after standby promotion
Previous Message Adam Mackler 2012-08-15 19:14:11 Re: Possible Bug in 9.2beta3