Re: High CPU load on Postgres Server during Peak times!!!!

From: Karl Denninger <karl(at)denninger(dot)net>
To: Dave Dutcher <dave(at)tridecap(dot)com>
Cc: "'Shiva Raman'" <raman(dot)shivag(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: High CPU load on Postgres Server during Peak times!!!!
Date: 2009-09-24 17:55:50
Message-ID: 4ABBB2A6.6070709@denninger.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Dave Dutcher wrote:
>> From: Shiva Raman
>> Subject: Re: [PERFORM] High CPU load on Postgres Server during Peak
>>
> not explicitly committed.
>
>> We have started updating the code on this.
>>
>
> You need a COMMIT for every BEGIN. If you just run a SELECT statement
> without first beginning a transaction, then you should not end up with a
> connection that is Idle in Transaction. If you are beginning a transaction,
> doing a select, and then not committing, then yes that is a bug.
>
> Dave
>
>
Dave is correct. A SELECT without a BEGIN in front of it will not begin
a transaction. Atomic SELECTs (that is, those not intended to return
rows that will then be updated or deleted, etc.) does not need and
should NOT have a BEGIN in front of it.

Any block of statements that must act in an atomic fashion must have a
BEGIN/COMMIT or BEGIN/ROLLBACK block around them to guarantee atomic
results across statements; any time you issue a BEGIN you MUST issue
either a ROLLBACK or COMMIT. Exiting SOUNDS safe (and if the connection
is truly dropped it is as that will implicitly roll back any uncommitted
transaction) BUT in a pooled connection environment it leads to exactly
what you're seeing here.

It is a serious mistake to leave open transactions active in a session
as that leaves multiple copies of rows and the support data necessary to
handle them either in memory, on disk or both. When the working set of
all postgresql instances reaches the physical memory limit and the
system starts to page performance will go straight in the toilet.

-- Karl

Attachment Content-Type Size
karl.vcf text/x-vcard 124 bytes

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Craig James 2009-09-24 18:45:28 Re: High CPU load on Postgres Server during Peak times!!!!
Previous Message keshav upadhyaya 2009-09-24 17:41:15 Regarding Sequential Scans count increase each time we press refresh .