Re: [NOVICE] WHERE clause not used when index is used

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Petr Jelinek <petr(at)2ndquadrant(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Tobias Florek <postgres(at)ibotty(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com>
Subject: Re: [NOVICE] WHERE clause not used when index is used
Date: 2016-03-01 18:47:05
Message-ID: 19581.1456858025@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-novice

I wrote:
> I'm not sure if the costing change is a bug or not --- the non-bitmap scan
> does seem to be cheaper in reality, but not by a couple orders of
> magnitude as the planner now thinks.

Ah, scratch that, I wasn't looking closely enough. The 9.4 plan is an
IndexScan whereas 9.5+ uses IndexOnlyScan, which accounts for the cost
differential. The reason it changed is the remove_unused_subquery_outputs
patch (55d5b3c08279b487), which allows the subquery to know that it
doesn't actually have to return all columns of tenk1, so that an
index-only scan is legal.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-03-01 18:54:46 Re: psql completion for ids in multibyte string
Previous Message Robert Haas 2016-03-01 18:33:02 Re: Fixing wrong comment on PQmblen and PQdsplen.

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2016-03-01 20:03:39 Re: [NOVICE] WHERE clause not used when index is used
Previous Message Tom Lane 2016-03-01 18:32:10 Re: [NOVICE] WHERE clause not used when index is used