Re: Slow update

From: Herouth Maoz <herouth(at)unicell(dot)co(dot)il>
To: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Slow update
Date: 2009-01-21 11:50:01
Message-ID: 49770BE9.50804@unicell.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Marc Mamin wrote:

> Hello,
>
> - did you vacuum your tables recently ?
>
> - What I miss in your query is a check for the rows that do not need
> to be udated:
>
> AND NOT (service = b.service
> AND status = b.status
> AND has_notification = gateway_id NOT IN (4,101,102)
> AND operator = COALESCE( b.actual_target_network_id,
> b.requested_target_network_id )
>
>
> depending on the fraction of rows that are already up to date, the
> might fasten your process quite a lot...
I don't see why it would. As far as I know, the high saving in update
time is done by using the indices. All the other conditions that are not
on indices are all checked using a sequential scan on the rows that were
brought from the index, so adding more conditions wouldn't make this a
lot faster - maybe even slower because more comparisons are made.

In any case, the logic of the database is that the records that have
delivered = 0 are always a subset of the records that are changed in
this query, so querying on delivered=0 - which is an indexed query -
actually make the above redundant.

Thanks for your response,
Herouth

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jasen Betts 2009-01-21 11:50:27 Re: Get object creation sql script in psql client
Previous Message Marc Mamin 2009-01-21 11:36:08 Re: Slow update