Re: Slow update SQL

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Ken Hill <ken(at)scottshill(dot)com>
Cc: Postgres Help <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Slow update SQL
Date: 2006-02-14 02:14:34
Message-ID: 20060214021434.GA75196@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Feb 13, 2006 at 05:48:45PM -0800, Ken Hill wrote:
> When I try to analyze the query plan with:
>
> EXPLAIN ANALYZE
> UPDATE ncccr10
> SET key = facilityno||'-'||
> lastname||'-'||
> sex||'-'||
> ssno||'-'||
> birthdate||'-'||
> primarysit||'-'||
> dxdate||'-'||
> morphology3
> WHERE date_part('year',dxdate) > '2000';
>
> The query just never finishes (even 1 hour later). The colum key100 is
> indexed, and I'm setting the value of this
> column from other columns. Why is this so slow?

If EXPLAIN ANALYZE is taking too long then could we at least see
the EXPLAIN output? How many rows does the condition match?

SELECT count(*) FROM ncccr10 WHERE date_part('year',dxdate) > '2000';

Do you have an expression index on date_part('year',dxdate)? Does
the table have any triggers or rules? Have you queried pg_locks
to see if the update is blocked on an ungranted lock?

Do other tables have foreign key references to ncccr10? If so then
you might need indexes on the referring columns.

What version of PostgreSQL are you running?

--
Michael Fuhr

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message chester c young 2006-02-14 02:29:37 Re: group by complications
Previous Message Ken Hill 2006-02-14 01:48:45 Slow update SQL