pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Faludi Gábor <gfaludi@fits.hu>
Cc: pgsql-performance@postgresql.org
Subject: Re: how does pg handle concurrent queries and same queries
Date: Mon, 28 Jul 2008 16:46:12 +0800
Message-ID: <488D8754.2010208@postnewspapers.com.au> (raw)
In-Reply-To: <000301c8f07d$4bee0f10$e3ca2d30$@hu>
References: <000301c8f07d$4bee0f10$e3ca2d30$@hu>

Faludi Gábor wrote:

> .         Why does the second and the later queries take the whole on second
> if the dataset is the same . Shouldn't PG realise that the query is the same
> so i give the user the same resultset ?

That would require a result cache. I don't know if Pg even has a query
result cache - I don't think so, but I'm not sure. Even if it does, it'd
still only be useful if the queries were issued under *exactly* the same
conditions - in other words, no writes had been made to the database
since the cached query was issued, and the first query had committed
before the second began (or was read-only). Additionally, no volatile
functions could be called in the query, because their values/effects
might be different when the query is executed a second time. That
includes triggers, etc.

Since 7.4 doesn't do lazy xid allocation it can't really tell that
nothing has been changed since the previous query was cached. So, if I'm
not missing something here, a query result cache would be useless anyway.

> .         How do I know if one query blocks the other ?

Examination of pg_catalog.pg_locks is certainly a start. It's trickier
with lots of short-running queries, though.

> .         Is there a way to log the long running queries in 7.4 ? If not is
> it available in any newer version ?

It's certainly available in 8.3, as log_min_duration_statement in
postgresql.conf . You can find out if it's in 7.4, and if not what
version it was introduced in, by looking through the documentation for
versions 7.4 and up.

--
Craig Ringer



view thread (7+ messages)  latest in thread

Message-ID: <488D8754.2010208@postnewspapers.com.au>
Permalink:  ../488D8754.2010208@postnewspapers.com.au/
Also on:    postgresql.org/message-id/488D8754.2010208@postnewspapers.com.au

 · 

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: craig@postnewspapers.com.au, gfaludi@fits.hu
  Subject: Re: how does pg handle concurrent queries and same queries
  In-Reply-To: <488D8754.2010208@postnewspapers.com.au>

* 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