Re: SELECT is immediate but the UPDATE takes forever

From: Raimon Fernandez <coder(at)montx(dot)com>
To: Michał Roszka <mike(at)if-then-else(dot)pl>
Cc: pgsql-general List <pgsql-general(at)postgresql(dot)org>
Subject: Re: SELECT is immediate but the UPDATE takes forever
Date: 2010-12-07 15:14:28
Message-ID: 3A78FFE0-ADE3-4BDD-9260-89EB45414BB7@montx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces


On 7dic, 2010, at 15:45 , Michał Roszka wrote:

> Quoting Raimon Fernandez <coder(at)montx(dot)com>:
>
>> 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
>
> [...]
>
>> 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;
>
> Maybe there is any check or constraint on belongs_to_compte_id.comptes that
> might take longer?

no, there's no check or constraint (no foreign key, ...) on this field.

I'm using now another database with same structure and data and the delay doesn't exist there, there must be something wrong in my current development database.

I'm checking this now ...

thanks,

r.

>
> Cheers,
>
> -Mike
>
> --
> Michał Roszka
> mike(at)if-then-else(dot)pl
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Clark 2010-12-07 15:17:16 dotted quad netmask conversion
Previous Message paulo matadr 2010-12-07 15:12:12 restore In parallel postgres 9

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 2010-12-07 15:37:40 Re: SELECT is immediate but the UPDATE takes forever
Previous Message Michał Roszka 2010-12-07 14:45:37 Re: SELECT is immediate but the UPDATE takes forever