Re: Incorrect index used in few cases..

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: AminPG Jaffer <aminjaffer(dot)pg(at)gmail(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Incorrect index used in few cases..
Date: 2019-06-18 21:07:55
Message-ID: 23028.1560892075@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

AminPG Jaffer <aminjaffer(dot)pg(at)gmail(dot)com> writes:
> Here is the table structure.

Hpmh. I thought it was just barely possible that you had a datatype
mismatch between the columns and the parameters, but nope, the columns
are "numeric" just like the parameters.

I'm pretty baffled. I tried to duplicate the problem with some dummy
data (as attached) and could not. In my hands, it wants to use the
i_tc_adid_tid index, or if I drop that then the pkey index, and any
other possible plan is orders of magnitude more expensive than those.

Another far-fetched theory is that the theoretically-better indexes
are so badly bloated as to discourage the planner from using them.
You could eliminate that one by checking the index sizes with "\di+".

Are you perhaps running with non-default values for any planner cost
parameters? Or it's not a stock build of Postgres?

If you could find a way to adjust the attached example so that it
produces the same misbehavior you see with live data, that would be
very interesting ...

regards, tom lane

Attachment Content-Type Size
test-case-that-proves-nothing.sql text/plain 2.9 KB

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Peter Geoghegan 2019-06-18 21:49:40 Re: Incorrect index used in few cases..
Previous Message AminPG Jaffer 2019-06-18 18:55:47 Re: Incorrect index used in few cases..