Re: Skip partition tuple routing with constant partition key

From: Zhihong Yu <zyu(at)yugabyte(dot)com>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>
Subject: Re: Skip partition tuple routing with constant partition key
Date: 2021-06-17 04:51:00
Message-ID: CALNJ-vR+u9kNS4jC8i0HPu0ejFUa3uhtdaGZmJ6CB0Q_-rn_0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 16, 2021 at 9:29 PM Amit Langote <amitlangote09(at)gmail(dot)com>
wrote:

> On Wed, Jun 16, 2021 at 4:27 PM Amit Langote <amitlangote09(at)gmail(dot)com>
> wrote:
> > On Mon, Jun 7, 2021 at 8:38 PM houzj(dot)fnst(at)fujitsu(dot)com
> > <houzj(dot)fnst(at)fujitsu(dot)com> wrote:
> > > The rough idea is to check the average batch number every 1000 rows.
> > > If the average batch num is greater than 1, then we enable the cache
> check,
> > > if not, disable cache check. This is similar to what 0d5f05cde0 did.
> >
> > Thanks for sharing the idea and writing a patch for it.
> >
> > I considered a simpler heuristic where we enable/disable caching of a
> > given offset if it is found by the binary search algorithm at least N
> > consecutive times. But your idea to check the ratio of the number of
> > tuples inserted over partition/bound offset changes every N tuples
> > inserted may be more adaptive.
> >
> > Please find attached a revised version of your patch, where I tried to
> > make it a bit easier to follow, hopefully. While doing so, I realized
> > that caching the bound offset across queries makes little sense now,
> > so I decided to keep the changes confined to execPartition.c. Do you
> > have a counter-argument to that?
>
> Attached a slightly revised version of that patch, with a commit
> message this time.
>
> --
> Amit Langote
> EDB: http://www.enterprisedb.com

Hi,

+ int n_tups_inserted;
+ int n_offset_changed;

Since tuples appear in plural, maybe offset should be as well: offsets.

+ part_index = get_cached_list_partition(pd, boundinfo, key,
+ values);

nit:either put values on the same line, or align the 4 parameters on
different lines.

+ if (part_index < 0)
+ {
+ bound_offset =
partition_range_datum_bsearch(key->partsupfunc,

Do we need to check the value of equal before computing part_index ?

Cheers

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2021-06-17 05:09:27 Re: Decoding speculative insert with toast leaks memory
Previous Message Mark Dilger 2021-06-17 04:31:22 Fix for segfault in logical replication on master