Re: Query using cursors using 100% CPU - Mailing list pgsql-general

From Mark Cave-Ayland
Subject Re: Query using cursors using 100% CPU
Date
Msg-id 200802121709.55134.mark.cave-ayland@siriusit.co.uk
Whole thread Raw
In response to Re: Query using cursors using 100% CPU  (Glyn Astill <glynastill@yahoo.co.uk>)
List pgsql-general
On Tuesday 12 February 2008 16:03:31 Glyn Astill wrote:

> Thanks Mark,
>
> I've turned this on and I never see a DECLARE CURSOR so I presume I
> was wrong and it is not using cursors.
>
> I do see a DEALLOCATE though, although no PREPARE.  Before this it
> does lots of statements that are limited to 100 records, and all the
> statements are named and preceded by execute, so I presume it is
> using prepared statements getting little chunks of data and relying
> on the first execute to prepare them?

Yup, it's using prepared queries. Unfortunately prepared queries are not
always a good thing, because if your data is non-uniformly distributed then
the planner has guess what will be the best plan without knowing what
parameters you are passing in at run-time. Hence you may get a plan that is
optimal for one set of values, but not for others.

> Both tests were run over the network.

Okay. From what you mention above, it's likely that what you're seeing is a
bad query plan choice anyway.


ATB,

Mark.

--
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063

pgsql-general by date:

Previous
From: Ivan Sergio Borgonovo
Date:
Subject: Re: end of life for pg versions...
Next
From: Dave Cramer
Date:
Subject: Re: deadlock while re-indexing table