Re: Skip partition tuple routing with constant partition key - Mailing list pgsql-hackers

From David Rowley
Subject Re: Skip partition tuple routing with constant partition key
Date
Msg-id CAApHDvo67JrvhwdiG3F6WtruvZU7Ly-NQvpDCzy0zSv-ny9dZg@mail.gmail.com
Whole thread Raw
In response to Re: Skip partition tuple routing with constant partition key  (Amit Langote <amitlangote09@gmail.com>)
List pgsql-hackers
On Thu, 20 May 2021 at 20:49, Amit Langote <amitlangote09@gmail.com> wrote:
>
> On Thu, May 20, 2021 at 9:31 AM David Rowley <dgrowleyml@gmail.com> wrote:
> > Wondering what your thoughts are on, instead of caching the last used
> > ResultRelInfo from the last call to ExecFindPartition(), to instead
> > cached the last looked up partition index in PartitionDescData? That
> > way we could cache lookups between statements.  Right now your caching
> > is not going to help for single-row INSERTs, for example.
>
> Hmm, addressing single-row INSERTs with something like you suggest
> might help time-range partitioning setups, because each of those
> INSERTs are likely to be targeting the same partition most of the
> time.  Is that case what you had in mind?

Yeah, I thought it would possibly be useful for RANGE partitioning. I
was a bit undecided with LIST. There seemed to be bigger risk there
that the usage pattern would route to a different partition each time.
In my imagination, RANGE partitioning seems more likely to see
subsequent tuples heading to the same partition as the last tuple.

>  Although, in the cases
> where that doesn't help, we'd end up making a ResultRelInfo for the
> cached partition to check the partition constraint, only then to be
> thrown away because the new row belongs to a different partition.
> That overhead would not be free for sure.

Yeah, there's certainly above zero overhead to getting it wrong. It
would be good to see benchmarks to find out what that overhead is.

David



pgsql-hackers by date:

Previous
From: Paul Guo
Date:
Subject: Re: pg_rewind fails if there is a read only file.
Next
From: "houzj.fnst@fujitsu.com"
Date:
Subject: RE: Skip partition tuple routing with constant partition key