SELECT is immediate but the UPDATE takes forever

From: Raimon Fernandez <coder(at)montx(dot)com>
To: pgsql-general List <pgsql-general(at)postgresql(dot)org>
Subject: SELECT is immediate but the UPDATE takes forever
Date: 2010-12-07 11:11:27
Message-ID: DC307393-7759-4E60-B9E8-5675B31584F2@montx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces

Hi,

I want to understand why one of my postgresql functions takes an eternity to finish.

Here's an example:

UPDATE comptes SET belongs_to_compte_id=42009 WHERE (codi_compte LIKE '10000%' AND empresa_id=2 AND nivell=11); // takes forever to finish

QUERY PLAN
--------------------------------------------------------------------------------------------
Seq Scan on comptes (cost=0.00..6559.28 rows=18 width=81)
Filter: (((codi_compte)::text ~~ '10000%'::text) AND (empresa_id = 2) AND (nivell = 11))
(2 rows)

but the same SELECT count, it's immediate:

SELECT count(id) FROM comptes WHERE codi_compte LIKE '10000%' AND empresa_id=2 AND nivell=11;

what I'm doing wrong ?

thanks,

regards,

r.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2010-12-07 11:14:13 Re: Copying entire tsv record (from file) into a single field
Previous Message Allan Kamau 2010-12-07 11:07:19 Copying entire tsv record (from file) into a single field

Browse pgsql-interfaces by date

  From Date Subject
Next Message Michał Roszka 2010-12-07 14:45:37 Re: SELECT is immediate but the UPDATE takes forever
Previous Message Francisco Figueiredo Jr. 2010-11-06 01:16:01 Npgsql 2.0.11 released!