pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <robertmhaas@gmail.com>
To: Brian Cox <brian.cox@ca.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: query looping?
Date: Mon, 4 Jan 2010 16:53:18 -0500
Message-ID: <603c8f071001041353u52e03014yad4f809befe5b66f@mail.gmail.com> (raw)
In-Reply-To: <4B42446A.1090005@ca.com>
References: <4B42446A.1090005@ca.com>

On Mon, Jan 4, 2010 at 2:41 PM, Brian Cox <brian.cox@ca.com> wrote:
> The query shown below [select count(distinct...] seems to be looping
> (99-101% CPU as shown by top for 11+ hours). This using postgres 8.3.5 on a
> dual quad core machine (Intel(R) Xeon(R) CPU X5460 @ 3.16GHz) with 32G RAM.
> Can I provide any other info to help investigate this issue? Or any thoughts
> on how to prevent/avoid it?

You posted an EXPLAIN ANALYZE showing almost the same query taking 17
seconds, but a crucial difference is that the EXPLAIN ANALYZE shows
the query with the parameters actually in the query, whereas the query
that's actually running for a long time uses bound parameters.
PostgreSQL won't take the particular values into account in planning
that version, which can sometimes lead to a markedly inferior plan.

What do you get if you do this?

PREPARE foo AS <the query, with the $x entries still in there>
EXPLAIN EXECUTE foo(<the values>);

...Robert



view thread (9+ messages)  latest in thread

Message-ID: <603c8f071001041353u52e03014yad4f809befe5b66f@mail.gmail.com>
Permalink:  ../603c8f071001041353u52e03014yad4f809befe5b66f@mail.gmail.com/
Also on:    postgresql.org/message-id/603c8f071001041353u52e03014yad4f809befe5b66f@mail.gmail.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: robertmhaas@gmail.com, brian.cox@ca.com
  Subject: Re: query looping?
  In-Reply-To: <603c8f071001041353u52e03014yad4f809befe5b66f@mail.gmail.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