Re: [HACKERS] Runtime Partition Pruning

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: Beena Emerson <memissemerson(at)gmail(dot)com>, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, amul sul <sulamul(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Subject: Re: [HACKERS] Runtime Partition Pruning
Date: 2017-12-22 01:29:46
Message-ID: CA+TgmoZv8sd9cKyYtHwmd_13+BAjkVKo=ECe7G98tBK5Ejwatw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 21, 2017 at 6:53 PM, David Rowley
<david(dot)rowley(at)2ndquadrant(dot)com> wrote:
> On 22 December 2017 at 12:45, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> PREPARE q3 (int, int) AS SELECT * FROM unpartitioned_table WHERE
>> partkey BETWEEN $1 AND $2;
>>
>> ...that has to decide whether to use an index. And to do that it has
>> to estimate what fraction of the table will match the BETWEEN clause.
>> That may be an uninformed guess, but it guesses something. We
>> probably want to do something here that makes the guess for a
>> partitioned_table similar to the guess for an unpartitioned_table.
>
> Are you considering some sort of clauselist_selectivity() estimate on
> the given parameters and comparing that to the same selectivities that
> were determined for the previous custom plans?

No, I don't think comparing to previous custom plans is a workable
approach. I was thinking, rather, that if we know for example that
we've doing pruning on partition_column = $1, then we know that only
one partition will match. That's probably a common case. If we've
got partition_column > $1, we could assume that, say, 75% of the
partitions would match. partition_column BETWEEN $1 and $2 is
probably a bit more selective, so maybe we assume 50% of the
partitions would match.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-12-22 01:31:37 Re: Basebackups reported as idle
Previous Message Amit Langote 2017-12-22 00:57:45 Re: [HACKERS] path toward faster partition pruning