Re: [SQL] problem with OR'ed AND queriess

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Michael McCarthy <michael(at)tcsi(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] problem with OR'ed AND queriess
Date: 1999-12-22 03:51:51
Message-ID: 199912220351.WAA26485@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 1999-12-22 04:13:52 Re: [SQL] problem with OR'ed AND queriess
Previous Message David C Hartwig Jr 1999-12-22 02:47:23 Re: [SQL] problem with OR'ed AND queriess