From: | Scott Marlowe <smarlowe(at)g2switchworks(dot)com> |
---|---|
To: | Neil Hepworth <nhepworth(at)gmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: High CPU Usage - PostgreSQL 7.3 |
Date: | 2006-07-10 16:04:18 |
Message-ID: | 1152547458.6540.6.camel@state.g2switchworks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Sun, 2006-07-09 at 19:52, Neil Hepworth wrote:
> Hi,
>
> I am running PostgreSQL 7.3 on a Linux box (RHEL 2.1 - Xeon 2.8GHz
> with 1GB of RAM) and seeing very high CPU usage (normally over 90%)
> when I am running the following queries, and the queries take a long
> time to return; over an hour!
>
> CREATE TEMPORARY TABLE fttemp1600384653 AS SELECT * FROM ftoneway LIMIT 0;
>
> INSERT INTO fttemp1600384653 SELECT epId, TO_TIMESTAMP(start,
> 'YYYY-MM-DD HH24:00:00.0')::timestamp AS start, 60 AS consolidation,
> SUM(cnt) AS cnt FROM ftone WHERE consolidation = 0 AND start <
> TO_TIMESTAMP('2006-06-27 18:43:27.391103+1000', 'YYYY-MM-DD
> HH24:00:00.0')::timestamp;
I don't need to see an explain analyze to make a guess here...
start < TO_TIMESTAMP('2006-06-27 18:43:27.391103+1000', 'YYYY-MM-DD
HH24:00:00.0')::timestamp
is gonna be a problem because while you and I know that to_timestamp...
is gonna be a constant, pg 7.3 doesn't. I've run into this before.
Just run a query ahead of time with a simple:
select TO_TIMESTAMP('2006-06-27 18:43:27.391103+1000', 'YYYY-MM-DD
HH24:00:00.0')::timestamp as starttime
and then pull that out and stick it into your query. do the same for
any other parts of the query like that.
That's assuming the issue here is that you're getting seq scans cause of
that part of the query.
From | Date | Subject | |
---|---|---|---|
Next Message | Craig A. James | 2006-07-11 05:50:40 | Kill a session |
Previous Message | Jeff Frost | 2006-07-10 15:26:51 | Re: High CPU Usage - PostgreSQL 7.3 |