Re: SELECT is immediate but the UPDATE takes forever - Mailing list pgsql-general

From Raimon Fernandez
Subject Re: SELECT is immediate but the UPDATE takes forever
Date
Msg-id 3A78FFE0-ADE3-4BDD-9260-89EB45414BB7@montx.com
Whole thread Raw
In response to Re: SELECT is immediate but the UPDATE takes forever  (Michał Roszka <mike@if-then-else.pl>)
Responses Re: SELECT is immediate but the UPDATE takes forever  (Vick Khera <vivek@khera.org>)
use a variable name for an insert in a trigger for an audit  (Raimon Fernandez <coder@montx.com>)
List pgsql-general
On 7dic, 2010, at 15:45 , Michał Roszka wrote:

> Quoting Raimon Fernandez <coder@montx.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
wrongin my current development database. 

I'm checking this now ...

thanks,

r.


>
> Cheers,
>
>   -Mike
>
> --
> Michał Roszka
> mike@if-then-else.pl
>
>



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: SELECT is immediate but the UPDATE takes forever
Next
From: Andy Colson
Date:
Subject: Re: Do we want SYNONYMS?