pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Posgresql Log: lots of parse statements
5+ messages / 3 participants
[nested] [flat]

* Posgresql Log: lots of parse statements
@ 2018-03-01 15:23 Vikas Sharma <shavikas@gmail.com>
  2018-03-01 15:30 ` Re: Posgresql Log: lots of parse statements David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Vikas Sharma @ 2018-03-01 15:23 UTC (permalink / raw)
  To: pgsql-general

Hi All,

I need help to understand this please. I was looking to do performance
tuning on slow queries so have stated logging queries taking more than 15
secs. In the postgresql log  I can see a query which appears only as
"parse" while others appear as execute.

2018-01-21 14:01:16 GMT LOG:  duration: 62952.558 ms  parse <unnamed>:
select this_.busi_type as business_type from tablea where this_.busi_id =
$1 and this_.busi_date = $2
2018-01-21 14:05:00 GMT LOG:  duration: 62952.558 ms  parse <unnamed>:
select this_.busi_type as business_type from tablea where this_.busi_id =
$1 and this_.busi_date = $2
2018-01-21 14:17:12 GMT LOG:  duration: 62952.558 ms  parse <unnamed>:
select this_.busi_type as business_type from tablea where this_.busi_id =
$1 and this_.busi_date = $2
2018-01-21 14:34:08 GMT LOG:  duration: 62952.558 ms  parse <unnamed>:
select this_.busi_type as business_type from tablea where this_.busi_id =
$1 and this_.busi_date = $2

I don't see this query to appear as execute, so how can find out how much
time it's taking to execute? does this parse timing includes execute also?

Best Regards
Vikas

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Posgresql Log: lots of parse statements
  2018-03-01 15:23 Posgresql Log: lots of parse statements Vikas Sharma <shavikas@gmail.com>
@ 2018-03-01 15:30 ` David G. Johnston <david.g.johnston@gmail.com>
  2018-03-01 17:21   ` Re: Posgresql Log: lots of parse statements Vikas Sharma <shavikas@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: David G. Johnston @ 2018-03-01 15:30 UTC (permalink / raw)
  To: Vikas Sharma <shavikas@gmail.com>; +Cc: pgsql-general

On Thu, Mar 1, 2018 at 8:23 AM, Vikas Sharma <shavikas@gmail.com> wrote:

> Hi All,
>
> I need help to understand this please. I was looking to do performance
> tuning on slow queries so have stated logging queries taking more than 15
> secs. In the postgresql log  I can see a query which appears only as
> "parse" while others appear as execute.
> ​[...]​
> I don't see this query to appear as execute, so how can find out how much
> time it's taking to execute? does this parse timing includes execute also?
>

​The most likely explanation is that executing the already parsed query
takes less than 15 seconds and so doesn't appear due to your filter.

David J.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Posgresql Log: lots of parse statements
  2018-03-01 15:23 Posgresql Log: lots of parse statements Vikas Sharma <shavikas@gmail.com>
  2018-03-01 15:30 ` Re: Posgresql Log: lots of parse statements David G. Johnston <david.g.johnston@gmail.com>
@ 2018-03-01 17:21   ` Vikas Sharma <shavikas@gmail.com>
  2018-03-01 17:26     ` Re: Posgresql Log: lots of parse statements Tom Lane <tgl@sss.pgh.pa.us>
  2018-03-01 17:28     ` Re: Posgresql Log: lots of parse statements David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Vikas Sharma @ 2018-03-01 17:21 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-general

Thanks David,

But why are there so many parse statement occurances for one query? Does
postgres parse the statement everytime before  execution or parse the query
only first time it is loaded in memory and reuse the same parsed plan until
it ages out of memory?.

In the log I can see these parse statement occurances about 400 times in a
day and everytime taking longer than 15 secs.

Regards
Vikas

On Mar 1, 2018 15:30, "David G. Johnston" <david.g.johnston@gmail.com>
wrote:

> On Thu, Mar 1, 2018 at 8:23 AM, Vikas Sharma <shavikas@gmail.com> wrote:
>
>> Hi All,
>>
>> I need help to understand this please. I was looking to do performance
>> tuning on slow queries so have stated logging queries taking more than 15
>> secs. In the postgresql log  I can see a query which appears only as
>> "parse" while others appear as execute.
>> ​[...]​
>> I don't see this query to appear as execute, so how can find out how much
>> time it's taking to execute? does this parse timing includes execute also?
>>
>
> ​The most likely explanation is that executing the already parsed query
> takes less than 15 seconds and so doesn't appear due to your filter.
>
> David J.
>
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Posgresql Log: lots of parse statements
  2018-03-01 15:23 Posgresql Log: lots of parse statements Vikas Sharma <shavikas@gmail.com>
  2018-03-01 15:30 ` Re: Posgresql Log: lots of parse statements David G. Johnston <david.g.johnston@gmail.com>
  2018-03-01 17:21   ` Re: Posgresql Log: lots of parse statements Vikas Sharma <shavikas@gmail.com>
@ 2018-03-01 17:26     ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-03-01 17:26 UTC (permalink / raw)
  To: Vikas Sharma <shavikas@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-general

Vikas Sharma <shavikas@gmail.com> writes:
> But why are there so many parse statement occurances for one query?

A "parse" log entry is recorded when the client sends a Parse protocol
message.  So the answer to that question needs to be sought in your
client application's logic.

> In the log I can see these parse statement occurances about 400 times in a
> day and everytime taking longer than 15 secs.

That seems like a mighty long time for parse analysis.  Maybe you're
having difficulties with something taking exclusive locks, thereby
blocking other queries?

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Posgresql Log: lots of parse statements
  2018-03-01 15:23 Posgresql Log: lots of parse statements Vikas Sharma <shavikas@gmail.com>
  2018-03-01 15:30 ` Re: Posgresql Log: lots of parse statements David G. Johnston <david.g.johnston@gmail.com>
  2018-03-01 17:21   ` Re: Posgresql Log: lots of parse statements Vikas Sharma <shavikas@gmail.com>
@ 2018-03-01 17:28     ` David G. Johnston <david.g.johnston@gmail.com>
  1 sibling, 0 replies; 5+ messages in thread

From: David G. Johnston @ 2018-03-01 17:28 UTC (permalink / raw)
  To: Vikas Sharma <shavikas@gmail.com>; +Cc: pgsql-general

On Thursday, March 1, 2018, Vikas Sharma <shavikas@gmail.com> wrote:

> Thanks David,
>
> But why are there so many parse statement occurances for one query? Does
> postgres parse the statement everytime before  execution or parse the query
> only first time it is loaded in memory and reuse the same parsed plan until
> it ages out of memory?.
>
> In the log I can see these parse statement occurances about 400 times in a
> day and everytime taking longer than 15 secs.
>

Please don't top-post replies.

Normally "parse unnamed" happens when client interfaces execute prepared
statements using parse-bind-execute protocol.  If you want to reduce the
number you will need to change your application.  As for the time it takes
its impossible to say without knowing more about the environment and query.

David J.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2018-03-01 17:28 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01 15:23 Posgresql Log: lots of parse statements Vikas Sharma <shavikas@gmail.com>
2018-03-01 15:30 ` David G. Johnston <david.g.johnston@gmail.com>
2018-03-01 17:21   ` Vikas Sharma <shavikas@gmail.com>
2018-03-01 17:26     ` Tom Lane <tgl@sss.pgh.pa.us>
2018-03-01 17:28     ` David G. Johnston <david.g.johnston@gmail.com>

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