Re: [PATCH] Avoid open and lock the table Extendend Statistics (src/backend/commands/statscmds.c)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Tomas Vondra <tv(at)fuzzy(dot)cz>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Avoid open and lock the table Extendend Statistics (src/backend/commands/statscmds.c)
Date: 2022-02-13 23:30:06
Message-ID: 2744246.1644795006@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> writes:
> On 2/13/22 22:43, Andres Freund wrote:
>> Having looked briefly at it, I don't understand what the locking scheme is?

> I don't recall the details of the discussion (if at all), but if you try
> to do concurrent ALTER STATISTICS, that'll end up with:
> ERROR: tuple concurrently updated
> reported by CatalogTupleUpdate. AFAIK that's what we do for other object
> types that don't have a relation that we might lock (e.g. try to co
> CREATE OR REPLACE FUNCTION).

Yeah, we generally haven't bothered with a separate locking scheme
for objects other than relations. I don't see any big problem with
that for objects that are defined by a single catalog entry, since
"tuple concurrently updated" failures serve fine (although maybe
that error message could be nicer). Extended stats don't quite
fit that definition, but at least for updates that only need to
touch the pg_statistic_ext row, it's the same story.

When we get around to supporting multi-relation statistics,
there might need to be some protocol around when ANALYZE can
update pg_statistic_ext_data rows. But I don't think that
issue exists yet, since only one ANALYZE can run on a particular
relation at a time.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2022-02-13 23:31:57 Re: buildfarm warnings
Previous Message Andres Freund 2022-02-13 23:22:49 bailing out in tap tests nearly always a bad idea