Re: Postgresql selecting strange index for simple query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Maxim Boguk <mboguk(at)masterhost(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgresql selecting strange index for simple query
Date: 2009-02-26 20:04:04
Message-ID: 2424.1235678644@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Maxim Boguk <mboguk(at)masterhost(dot)ru> writes:
> So i have two theory (just waving hands ofcourse):
> 1)integer owerflow somewhere in cost calculation

Costs are floats, and in any case you're not showing costs anywhere near
the integer overflow limit...

> 2)floating rounding errors (because cost very close in wrong situations: 254918.19 vs 259709.09)

The planner is intentionally set up to consider costs within a percent
or so of each other as being effectively equal. If the estimated costs
are that close then it doesn't surprise me if it sometimes picks the
"wrong" plan. The real question is why are the estimates so close?
They should not be, since AFAICS you are talking about a situation
where we'd have to scan all of the multicol index versus only about
a fifth of the single-col one.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martin Gainty 2009-02-26 20:29:48 Re: Off Topic: ICD-10 codes in a database table?
Previous Message Lennin Caro 2009-02-26 19:38:26 Re: Problem setting up PostgreSQL