Re: Hung Query with No Locking Issues

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Michael P(dot) McDonnell" <bzaks1424(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Hung Query with No Locking Issues
Date: 2023-05-08 01:00:17
Message-ID: 209710.1683507617@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Michael P. McDonnell" <bzaks1424(at)gmail(dot)com> writes:
> On Sun, May 7, 2023 at 4:25 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Munro 2023-05-08 02:17:16 Re: "PANIC: could not open critical system index 2662" - twice
Previous Message Michael P. McDonnell 2023-05-07 23:42:21 Re: Hung Query with No Locking Issues