Re: Query using cursors using 100% CPU

From: Glyn Astill <glynastill(at)yahoo(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Query using cursors using 100% CPU
Date: 2008-02-12 16:03:31
Message-ID: 265615.89674.qm@web25812.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


--- Mark Cave-Ayland <mark(dot)cave-ayland(at)siriusit(dot)co(dot)uk> wrote:

> Hi Glyn,
>
> In order to determine whether or not your driver is using cursors,
> the easiest
> way is to alter postgresql.conf so that individual SQL statements
> are
> recorded in the server log. You should then be able to see
> statements of the
> form DECLARE CURSOR foo FOR SELECT... if cursors are being used.
>

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?

> Looking at the differences in CPU usage, could it be that when you
> run your
> query in psql, you are running psql on the database server itself
> while your
> application is running on a separate server and sends its queries
> over the
> network? If so, the extra CPU usage may be involved with
> sending/receiving
> large datasets across the network.
>

Both tests were run over the network.

__________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Maarten Boekhold 2008-02-12 16:04:01 Re: WINDOWS INSTALLATION TIPS
Previous Message Gregory Stark 2008-02-12 15:59:21 Re: deadlock while re-indexing table