Re: slow queries over information schema.tables

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: slow queries over information schema.tables
Date: 2018-12-07 20:24:32
Message-ID: CA+TgmoZTAPeh8jrMaaZNNAdj9X+q=cdT-dEvg-DmuJHkXVv9KA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 6, 2018 at 12:50 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > 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.

Huh? The call in relation_openrv_extended() happens before acquiring the lock.

> 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.

That would be a nice place to get. Not perfect, but better than now.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2018-12-07 20:28:09 Re: proposal: plpgsql pragma statement
Previous Message Robert Haas 2018-12-07 20:21:43 Re: Statement-level rollback