Re: [PERFORM] Querying with multicolumn index

2016-12-10 Thread Daniel Blanch Bataller
Hi all, Thomas is absolutely right, the distribution I synthetically made, had 6M records but very old, 9M old, as you can see it had to skip 9M records before finding a suitable record using time index. EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM updates WHERE driver_id = 100 ORDER BY "time" DE

Re: [PERFORM] Querying with multicolumn index

2016-12-10 Thread Eric Jiang
On Sat, Dec 10, 2016 at 4:49 PM, Tom Lane wrote: >> We aren't using any special planner settings - all enable_* options are "on". > > No, I'm asking about the cost settings (random_page_cost etc). The cost > estimates you're showing seem impossible with the default settings. Tom, really apprecia

Re: [PERFORM] Querying with multicolumn index

2016-12-10 Thread Tom Lane
Tomas Vondra writes: > On 12/10/2016 12:51 AM, Tom Lane wrote: >> I tried to duplicate this behavior, without success. Are you running >> with nondefault planner parameters? > My guess is this is a case of LIMIT the matching rows are uniformly > distributed in the input data. The planner likely

Re: [PERFORM] Querying with multicolumn index

2016-12-10 Thread Tom Lane
Eric Jiang writes: > We aren't using any special planner settings - all enable_* options are "on". No, I'm asking about the cost settings (random_page_cost etc). The cost estimates you're showing seem impossible with the default settings. regards, tom lane -- Sent via

Re: [PERFORM] Querying with multicolumn index

2016-12-10 Thread Tomas Vondra
Hi, On 12/10/2016 12:51 AM, Tom Lane wrote: Eric Jiang writes: I have a query that I *think* should use a multicolumn index, but sometimes isn't, resulting in slow queries. I tried to duplicate this behavior, without success. Are you running with nondefault planner parameters? My guess i

Re: [PERFORM] Querying with multicolumn index

2016-12-10 Thread Eric Jiang
We aren't using any special planner settings - all enable_* options are "on". On Sat, Dec 10, 2016 at 12:06 AM, Daniel Blanch Bataller wrote: > As a quick fix: Have you considered dropping ix_updates_time index? We do occasionally want to use ix_updates_time, although not very often. > I’ve bee

Re: [PERFORM] Querying with multicolumn index

2016-12-10 Thread Daniel Blanch Bataller
Hi As a quick fix: Have you considered dropping ix_updates_time index? I’ve been able to reproduce the issue, but with bigger numbers than you. When I dropped ix_updates_time it went much much faster. It uses updates_driver_id_time_idx index instead. For some reason the planner does not make