pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael P. McDonnell <bzaks1424@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Hung Query with No Locking Issues
Date: Sun, 07 May 2023 21:00:17 -0400
Message-ID: <209710.1683507617@sss.pgh.pa.us> (raw)
In-Reply-To: <CAHmCLHrsd81NLtOD9zpGjQc+Csn94bjxsXSmK1UBsLcFPkSA7Q@mail.gmail.com>
References: <CAHmCLHqDsYXQmNYROBQnFvtFnEkQxhD57Qz2h+wp4oOWRBYXVQ@mail.gmail.com>
	<183988.1683494734@sss.pgh.pa.us>
	<CAHmCLHrsd81NLtOD9zpGjQc+Csn94bjxsXSmK1UBsLcFPkSA7Q@mail.gmail.com>

"Michael P. McDonnell" <bzaks1424@gmail.com> writes:
> On Sun, May 7, 2023 at 4:25 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Perhaps an "ANALYZE table_b" in between would help.

> Okay - that worked.
> How did you know that would work? That's incredible.

Well, I guessed ;-) ... but it was a well-educated guess.

The symptoms sounded like you were getting a bad plan choice for
the second query, which is unsurprising if you populate a table
from empty and don't give auto-analyze enough time to collect
some statistics behind your back.

As a solution going forward, I'd recommend adding the ANALYZE
as the last step in the table-populating procedure.

			regards, tom lane





view thread (4+ messages)

Message-ID: <209710.1683507617@sss.pgh.pa.us>
Permalink:  ../209710.1683507617@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/209710.1683507617@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 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, bzaks1424@gmail.com
  Subject: Re: Hung Query with No Locking Issues
  In-Reply-To: <209710.1683507617@sss.pgh.pa.us>
  References: <CAHmCLHqDsYXQmNYROBQnFvtFnEkQxhD57Qz2h+wp4oOWRBYXVQ@mail.gmail.com> <183988.1683494734@sss.pgh.pa.us> <CAHmCLHrsd81NLtOD9zpGjQc+Csn94bjxsXSmK1UBsLcFPkSA7Q@mail.gmail.com> <209710.1683507617@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