From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Alessandro Aste <alessandro.aste@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Postgresql 10.3 , query never completes if LIMIT clause is specified and paralle processing is on
Date: Thu, 22 Mar 2018 17:00:37 +0100
Message-ID: <b3b102a2-b177-4caf-49a4-0bc8c3ade958@2ndquadrant.com> (raw)
In-Reply-To: <CAM9F+O1RHzMg07_QS0hTakSOOHjdHfnGU7V1UNeb-US4o8tHYg@mail.gmail.com>
References: <CAM9F+O1szk4_sPbzRhwFhTwUyz-H1tixrXGA0gRzR6bZwREA0g@mail.gmail.com>
<e6ba9154-1dfb-012e-4422-41226455c153@2ndquadrant.com>
<CAM9F+O3AaSUeF43KFvUHxpL+1vf4JB8V8hD2eaC5rKQpNtuCCg@mail.gmail.com>
<c6e20f1c-1eca-47e4-5e77-8c6987073ae6@2ndquadrant.com>
<CAM9F+O1RHzMg07_QS0hTakSOOHjdHfnGU7V1UNeb-US4o8tHYg@mail.gmail.com>
On 03/22/2018 11:33 AM, Alessandro Aste wrote:
> Tomas, thank you. This machine is abare metal server running only a
> staging postgresql 10.3 instance. Nobody is using it beside me.
>
> I'm attaching 4 files.
>
> every_30_seconds_top_stats_during_query.txt - this is a caputure of
> the top command every 30 seconds(more or less) for 10+ minutes while I'm
> running the query. Let me know if this helps to answere your question.
> EXPLAIN_WITH_LIMIT_AND_max_parallel_workers_per_gather_SET_TO_0.txt -
> query plan with full query and max_parallel_workers_per_gather force
> to 0. Full output.
> EXPLAIN_WITH_LIMIT_AND_DEFAULT_PARALLEL_PROCESSING_SETTINGS.txt -
> query plan with full query and default parellel processing settings.
> Full output.
> EXPLAIN_WITHOUT_LIMIT_AND_DEFAULT_PARALLEL_PROCESSING_SETTINGS.tx -
> query plan of the query omitting the LIMIT clause and default parellel
> processing settings. Full output.
>
OK. Looking at the top output, I see this:
PID USER VIRT RES SHR S %CPU %MEM TIME+ COMMAND
104880 postgres 30.8g 1.9g 1.9g R 92.0 1.5 15:15.60 postmaster
111732 postgres 30.8g 476m 473m R 88.2 0.4 0:00.47 postmaster
111730 postgres 30.8g 473m 470m R 86.4 0.4 0:00.46 postmaster
111731 postgres 30.8g 476m 473m R 86.4 0.4 0:00.46 postmaster
111733 postgres 30.8g 476m 473m R 86.4 0.4 0:00.46 postmaster
111734 postgres 30.8g 476m 473m R 86.4 0.4 0:00.46 postmaster
111728 root 15824 1912 828 R 3.8 0.0 0:00.04 top
That means it certainly is not stuck, it's simply doing a lot of work on
CPU. The question is why and what it's doing ...
Can you collect some CPU profiles using perf? There's a howto here:
https://wiki.postgresql.org/wiki/Profiling_with_perf
But in short - install perf, install debuginfo packages for postgres,
and then do
perf record -a -g -s sleep 60
while running the query. Once the profile data is collected, do
perf report > report.txt
and share the report.txt with us (well, if it's very large you may need
to only cut the first 1000 lines or so).
That should tell us in which functions most of the time is spent. That
will give us some hints, hopefully.
>
> For what concerns the self-contained test case - I'll do my best to
> prepare it.
>
Yeah, that would be helpful.
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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: tomas.vondra@2ndquadrant.com, alessandro.aste@gmail.com
Subject: Re: Postgresql 10.3 , query never completes if LIMIT clause is specified and paralle processing is on
In-Reply-To: <b3b102a2-b177-4caf-49a4-0bc8c3ade958@2ndquadrant.com>
References: <CAM9F+O1szk4_sPbzRhwFhTwUyz-H1tixrXGA0gRzR6bZwREA0g@mail.gmail.com> <e6ba9154-1dfb-012e-4422-41226455c153@2ndquadrant.com> <CAM9F+O3AaSUeF43KFvUHxpL+1vf4JB8V8hD2eaC5rKQpNtuCCg@mail.gmail.com> <c6e20f1c-1eca-47e4-5e77-8c6987073ae6@2ndquadrant.com> <CAM9F+O1RHzMg07_QS0hTakSOOHjdHfnGU7V1UNeb-US4o8tHYg@mail.gmail.com> <b3b102a2-b177-4caf-49a4-0bc8c3ade958@2ndquadrant.com>
* 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