From: Tom Lane <tgl@sss.pgh.pa.us>
To: n.kobzarev@aeronavigator.ru
Cc: 'Laurenz Albe' <laurenz.albe@cybertec.at>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Unnecessary locks for partitioned tables
Date: Wed, 09 Nov 2022 09:29:35 -0500
Message-ID: <3968476.1668004175@sss.pgh.pa.us> (raw)
In-Reply-To: <01a401d8f440$c48bf320$4da3d960$@aeronavigator.ru>
References: <012801d8f42c$06ea5af0$14bf10d0$@aeronavigator.ru>
<b6a944c1a7f58d2189b008ac4a523b00c1e124ab.camel@cybertec.at>
<01a401d8f440$c48bf320$4da3d960$@aeronavigator.ru>
<n.kobzarev@aeronavigator.ru> writes:
> Oh, I did not explicitly write that, in case of custom plan (first attempts or with force_custom_plan) database holds only a couple of locks! Why in this case it is sufficient to lock only one partition and parent table ?
Because partition routing is done at planning time in that case, based
on the actual values of the plan's parameters. A generic plan
doesn't have the parameter values available, so it has to build
plan nodes for every partition that could conceivably be accessed.
So for queries of this kind (ie point queries against heavily partitioned
tables) the generic plan is pretty much always going to lose. That
doesn't bother me enormously --- there are other query patterns
with similar behavior.
If you know that your queries always need custom plans, I question
the value of using PREPARE at all.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, n.kobzarev@aeronavigator.ru, laurenz.albe@cybertec.at
Subject: Re: Unnecessary locks for partitioned tables
In-Reply-To: <3968476.1668004175@sss.pgh.pa.us>
References: <012801d8f42c$06ea5af0$14bf10d0$@aeronavigator.ru> <b6a944c1a7f58d2189b008ac4a523b00c1e124ab.camel@cybertec.at> <01a401d8f440$c48bf320$4da3d960$@aeronavigator.ru> <3968476.1668004175@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox