Re: [SQL] problem with OR'ed AND queriess - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: [SQL] problem with OR'ed AND queriess
Date
Msg-id 199912220351.WAA26485@candle.pha.pa.us
Whole thread Raw
In response to problem with OR'ed AND queriess  (Michael McCarthy <michael@tcsi.com>)
List pgsql-sql
> Using PQexec from libpq in postgresql 6.5.3, I submit a query of the
> following form, which has 13 OR'ed AND expressions:
> 
>     DECLARE my_cursor CURSOR FOR SELECT col1 FROM testCNF where
>     ( ( col1=0  and col2=1  ) OR ( col1=1  and col2=2  ) OR
>       ( col1=2  and col2=3  ) OR ( col1=3  and col2=4  ) OR
>       ( col1=4  and col2=5  ) OR ( col1=5  and col2=6  ) OR
>       ( col1=6  and col2=7  ) OR ( col1=7  and col2=8  ) OR
>       ( col1=8  and col2=9  ) OR ( col1=9  and col2=10 ) OR
>       ( col1=10 and col2=11 ) OR ( col1=11 and col2=12 ) OR
>       ( col1=12 and col2=13 ) )

I have this in the cvs log file, and it will appear in 7.0.  You can
check the current cvs snapshot to see how much better it is:

---------------------------------------------------------------------------

revision 1.18
date: 1999/09/07 03:47:06;  author: tgl;  state: Exp;  lines: +236 -249
Performance improvements in cnfify(): get rid of exponential
space consumption in pull_args, and avoid doing the full CNF transform on
operands of operator clauses, where it's really not particularly helpful.
This answers the TODO item about large numbers of OR clauses, at least
partially.  I was able to do a ten-thousand-OR-clause query with about
20Mb memory consumption ... it took an obscenely long time, but it worked...


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-sql by date:

Previous
From: David C Hartwig Jr
Date:
Subject: Re: [SQL] problem with OR'ed AND queriess
Next
From: Tom Lane
Date:
Subject: Re: [SQL] problem with OR'ed AND queriess