Re: [GENERAL] Long update query ?

From: David Hartwig <daveh(at)insightdist(dot)com>
To: Sergei Chernev <ser(at)nsu(dot)ru>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Long update query ?
Date: 1998-09-28 13:21:08
Message-ID: 360F8D43.8CF53472@insightdist.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

This is caused by a semi-well known weakness in the optimizer. The optimizer
rewrites the WHERE clause in conjunctive normal form (CNF):

(A and B) or (C and D) ==> (A or C) and (A or D) and (B or C) and (B or D)

Try this with your statement and you will see the expression explodes. Foe
now, I would suggest that you break this up into multiple statements.

Sergei Chernev wrote:

> Hello,
> I have query:
> UPDATE userd_session_stat SET status =1 WHERE status=0 AND ((uid <>627 AND
> tty <>'ttyA03') OR (uid <> 425 AND tty <> 'ttyA05') OR (uid <> 8011 AND tty
> <> 'ttyA09') OR (uid <> 2092 AND tty <> 'ttyA0f') OR (uid <> 249 AND tty <>
> 'ttyp3') OR (uid <> 249 AND tty <> 'ttyp4') OR (uid <> 249 AND tty <>
> 'ttyp5') OR (uid <> 249 AND tty <> 'ttyp6'))
>
> But, postgres complains that:
> FATAL 1: palloc failure: memory exhausted
>
> I see, the query must be less than 4kB, and this query is less.
> Long SELECT queries works fine.
> Have any idea? Maybe, I have to change postmaster's settings ? Query
> executes from libpg programm.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jackson, DeJuan 1998-09-28 14:48:50 RE: [GENERAL] slow queries
Previous Message Alexzander Blashko 1998-09-28 08:19:34 Wisconsin Benchmark

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1998-09-28 14:28:26 Proper cleanup at backend exit
Previous Message Magnus Hagander 1998-09-28 08:30:01 RE: [HACKERS] LIBPQ for WIN32