Re: odd intermittent query hanging issue

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Aaron Burnett <aburnett(at)bzzagent(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: odd intermittent query hanging issue
Date: 2012-05-18 18:17:30
Message-ID: 4FB6923A.9070205@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/18/2012 11:01 AM, Aaron Burnett wrote:
>>> ... One particular query will run perfectly fine (around 5 seconds)
>>> for several weeks, then suddenly decide to hang indefinitely and never
>>> finish....
>> Is the machine busy processing the query or is it idle?
>
> It is processing and in fact drives the load up a bit.
What CPU, disk and memory is it using? It would be very interesting to
see the query plan when things go South.

> Yeah, the query is poo... autogenerated... the LEFT JOIN is not needed as I have pointed out to the person responsible for the code many times, and
> the 'in(1)' may indeed have many categories in there. But the OLY one that
> hangs is the 'in(1)'

Is "1" the largest category? Also, how have you tuned work_mem (show
work_mem;)?

When the query gets bad do you see PostgreSQL swapping to temp files
(watch files in PGDATA/base/DB_OID/pgsql_tmp). Note that work_mem can be
set per-connection so you if it is too small for your nighttime
maintenance you can adjust it for those operations only.

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2012-05-18 18:30:22 Re: Fetching multiple rows in single round trip
Previous Message Aaron Burnett 2012-05-18 18:01:11 Re: odd intermittent query hanging issue