pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: slow queries over information schema.tables
Date: Thu, 06 Dec 2018 12:50:32 -0500
Message-ID: <17422.1544118632@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoYrs92UR6dEuzVp-ghuj0HAhZ0iyqb3memusje9Rr3uaw@mail.gmail.com>
References: <CAFj8pRBUCX4LZ2rA2BbEkdD6NN59mgx+BLo1gO08Wod4RLtcTg@mail.gmail.com>
	<5978.1544030694@sss.pgh.pa.us>
	<20181205175657.s7mt6as356kwvrji@alap3.anarazel.de>
	<8210.1544034143@sss.pgh.pa.us>
	<20181205182555.x4wtnzffmhwsc3c7@alap3.anarazel.de>
	<8843.1544035292@sss.pgh.pa.us>
	<CA+TgmobB=Ky_GOa4-M3afJHup3LC9FoV-tLmU--XBdV+8Do-Tg@mail.gmail.com>
	<20577.1544113962@sss.pgh.pa.us>
	<CA+TgmoaNhWkCt2MBpvhHX2ckJd=JHTqDAS1oXRdQPuVtp2MD=g@mail.gmail.com>
	<21728.1544115813@sss.pgh.pa.us>
	<CA+TgmoYrs92UR6dEuzVp-ghuj0HAhZ0iyqb3memusje9Rr3uaw@mail.gmail.com>

Robert Haas <robertmhaas@gmail.com> writes:
> On Thu, Dec 6, 2018 at 12:03 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> [ further experimentation... ]  It looks like if you prepare
>> a query and then just execute it repeatedly in one transaction,
>> you'd not reach AIM (as long as you were getting generic plans).
>> Possibly that's a gap worth closing.

> If we called it at the start of every query, couldn't we dispense with
> the call in relation_openrv_extended()?

No.  You need to do AIM *after* obtaining the lock, else you still
have the race condition that you can execute a query on a table
without being aware of recent DDL on it.

What we could possibly do to close the gap cited above is to have
plancache.c's CheckCachedPlan force an AIM call if it notices that
the plan it wants to re-use has a non-empty PlanInvalItems list.
If it does not, then there is nothing that AIM would cause invalidation
for anyway.  This still leaves us with a query-duration-sized race
condition window for DDL on functions and domains, but not any larger
than that.

			regards, tom lane




view thread (21+ messages)  latest in thread

Message-ID: <17422.1544118632@sss.pgh.pa.us>
Permalink:  ../17422.1544118632@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17422.1544118632@sss.pgh.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, andres@anarazel.de, pavel.stehule@gmail.com
  Subject: Re: slow queries over information schema.tables
  In-Reply-To: <17422.1544118632@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