Thread: steps of a sql

steps of a sql

From
PegoraroF10
Date:
Some days ago one of my customers claimed that one of his queries were
spending too much time. Then on postgres log it appears really strange. That
query doesn´t usually appears as parse, sometimes only as execute, because
it tooks almost all times less than 500ms. But on that day something
happened, what was that, PARSE time of 10 minutes ?

Command_Tag  Message
PARSE              duration: 552607.263 ms  parse PRSTMTST13817971293: WITH
...
SELECT            duration: 1211.195 ms  execute
PRSTMTST13955596862/PORTALST13955596862: WITH  ...
PARSE              duration: 673398.585 ms  parse PRSTMTST13857292877: WITH
...
SELECT            duration: 2742.588 ms  execute
PRSTMTST13817971293/PORTALST13817971293: WITH  ...
SELECT            duration: 1318.766 ms  execute
PRSTMTST13844185613/PORTALST13844185613: WITH  ...

Then, I didn´t find in the docs what are the steps of execution of a query
and obviously why that SQL took so long. These 5 examples are the same
query, so it doesn´t make sense that I´ll wait 10 minutes do parse and just
1 or 2 seconds to execute. So, the quetion is, how can I know if I´m running
a simple query or a extended query, like the docs explain on
https://www.postgresql.org/docs/11/protocol-flow.html and what can I do to
find what happened and solve to never occur again.



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html



Re: steps of a sql

From
Tom Lane
Date:
PegoraroF10 <marcos@f10.com.br> writes:
> Some days ago one of my customers claimed that one of his queries were
> spending too much time. Then on postgres log it appears really strange. That
> query doesn´t usually appears as parse, sometimes only as execute, because
> it tooks almost all times less than 500ms. But on that day something
> happened, what was that, PARSE time of 10 minutes ?

Something else sitting on an exclusive table lock, perhaps?

            regards, tom lane