pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David G Johnston <david.g.johnston@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Re: parse/bind/execute
Date: Wed, 4 Jun 2014 18:57:56 -0700 (PDT)
Message-ID: <1401933476623-5806133.post@n5.nabble.com> (raw)
In-Reply-To: <D83E55F5F4D99B4A9B4C4E259E6227CD0149D128@AUX1EXC01.apac.experian.local>
References: <D83E55F5F4D99B4A9B4C4E259E6227CD0149D128@AUX1EXC01.apac.experian.local>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

Huang, Suya wrote
> Hello,
> 
> I am using Pgbadger to analyze the postgresql database log recently and
> noticed a section "Prepared queries ratio". For my report, it has:
> 
> 1.03 as Ratio of bind vs prepare
> 0.12% Ratio between prepared and "usual" statements
> 
> I'm trying to understand what the above metrics mean and if it's a
> problem. I found people can clearly clarify the parse/bind/execute time of
> a query. To my limited knowledge of Postgres, using explain analyze, I can
> only get the total execution time.
> 
> Can someone shed me some light on this subject? How to interpret the
> ratios?
> 
> Thanks,
> Suya

Both are related to using prepared statements (usually with parameters). 
Each bind is a use of an already prepared query with parameters filled in. 
The prepare is the initial preparation of the query.  A ratio of 1 means
that each time you prepare a query you use it once then throw it away. 
Likewise a value of 2 would mean you are executing each prepared statement
twice.

"Usual" statements are those that are not prepared.  The ratio is simply the
counts of each as seen by the database - I do not know specifics as to what
exactly is counted (ddl?).

That low a ratio means that almost all statements you send to the database
are non-prepared.  In those relatively few cases where you do prepare first
you almost always immediately execute a single set of inputs then discard
the prepared statement.

I do not know enough about the underlying data to draw a conclusion but
typically the higher the bind/prepare ratio the more efficient your use of
database resources.  Same goes for the prepare ratio.  The clients you use
and the general usage of the database heavily influence what would be
considered reasonable ratios.

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/parse-bind-execute-tp5806132p5806133.html
Sent from the PostgreSQL - performance mailing list archive at Nabble.com.


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (4+ messages)  latest in thread

Message-ID: <1401933476623-5806133.post@n5.nabble.com>
Permalink:  ../1401933476623-5806133.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1401933476623-5806133.post@n5.nabble.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: david.g.johnston@gmail.com
  Subject: Re: parse/bind/execute
  In-Reply-To: <1401933476623-5806133.post@n5.nabble.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