Re: Postgresql selecting strange index for simple query - Mailing list pgsql-general

From Tom Lane
Subject Re: Postgresql selecting strange index for simple query
Date
Msg-id 2424.1235678644@sss.pgh.pa.us
Whole thread Raw
In response to Re: Postgresql selecting strange index for simple query  (Maxim Boguk <mboguk@masterhost.ru>)
Responses Re: Postgresql selecting strange index for simple query
List pgsql-general
Maxim Boguk <mboguk@masterhost.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

pgsql-general by date:

Previous
From: Andreas Kretschmer
Date:
Subject: Re: Returning null for joined tables when one column non existant
Next
From: Martin Gainty
Date:
Subject: Re: Off Topic: ICD-10 codes in a database table?