Re: PostgreSQL 10.0 SELECT LIMIT performance problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mareks Kalnačs <Mareks(dot)Kalnacs(at)datakom(dot)lv>
Cc: Victor Yegorov <vyegorov(at)gmail(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, Māris Rucis <Maris(dot)Rucis(at)datakom(dot)lv>, Pāvels Koržs <Pavels(dot)Korzs(at)datakom(dot)lv>
Subject: Re: PostgreSQL 10.0 SELECT LIMIT performance problem
Date: 2018-09-13 17:42:10
Message-ID: 12108.1536860530@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?utf-8?B?TWFyZWtzIEthbG5hxI1z?= <Mareks(dot)Kalnacs(at)datakom(dot)lv> writes:
> But we are using value indexes not a json index:

> CREATE INDEX idx_oss_alarms_dn
> ON oss_alarms
> USING btree
> ((jdata ->> 'dn'::text) COLLATE pg_catalog."default");

I think you're outsmarting yourself by including those COLLATE clauses.
They don't do anything, since they're just selecting the default behavior
--- but they're enough to make the planner not realize that stats
collected on the index expression would be applicable to a plain
reference to oss_alarms.jdata ->> 'dn'. In general you want the index
expression to be spelled exactly the same way that you refer to the
value in queries, else the system may not realize it's relevant.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-09-13 17:57:45 Re: BUG #15383: Join Filter cost estimation problem in 10.5
Previous Message Tom Lane 2018-09-13 17:30:04 Re: BUG #15382: Error create dictionary in pg_dump