Re: Query hangs (and then timeout) after using COPY to import data

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: steott(at)gmail(dot)com, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Query hangs (and then timeout) after using COPY to import data
Date: 2024-02-12 17:01:54
Message-ID: 6991cae7-c791-4718-a20a-82b5f8c45c90@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/12/24 08:42, Adrian Klaver wrote:
> On 2/11/24 15:13, steott(at)gmail(dot)com wrote:
>> Thanks, Adrian, for the suggestion, but same problem.
>>
>> I've just tried to execute "ANALYZE" (on the whole database) after the
>> import of all the tables (with COPY) and before the other queries, but
>> the query always hangs (I hope this was the way you suggested).
>
> Yes, this is what I was suggesting. Anytime I see data migration and
> slow queries, my first suggestion is to run ANALYZE to get the planner
> statistics up to date. That at least eliminates one possible source of
> slowness. In this case though there seems to be something else at work,
> see Tom Lanes suggestion. This may end up requiring installing
> auto-explain:
>
> https://www.postgresql.org/docs/current/auto-explain.html
>
> to get an EXPLAIN of the query.

I should have added, auto-explain incurs overhead so you just want to
run it until you solve the issue.

>
>>
>> Stefano
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message veem v 2024-02-12 19:04:48 Re: How should we design our tables and indexes
Previous Message Greg Sabino Mullane 2024-02-12 16:54:53 Re: Safest pgupgrade jump distance