Re: [HACKERS] RE: [GENERAL] Long update query ? (also Re: [GENERAL] CNF vs. DNF)

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: taral(at)mail(dot)utexas(dot)edu (Taral)
Cc: jwieck(at)debis(dot)com, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] RE: [GENERAL] Long update query ? (also Re: [GENERAL] CNF vs. DNF)
Date: 1998-10-04 01:57:30
Message-ID: 199810040157.VAA04640@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


I have another idea.

When we cnfify, this:

(A AND B) OR (C AND D)

becomes

(A OR C) AND (A OR D) AND (B OR C) AND (B OR D)

however if A and C are identical, this could become:

(A OR A) AND (A OR D) AND (B OR A) AND (B OR D)

and A OR A is A:

A AND (A OR D) AND (B OR A) AND (B OR D)

and since we are now saying A has to be true, we can remove OR's with A:

A AND (B OR D)

Much smaller, and a big win for queries like:

SELECT *
FROM tab
WHERE (a=1 AND b=2) OR
(a=1 AND b=3)

This becomes:

(a=1) AND (b=2 OR b=3)

which is accurate, and uses our OR indexing.

Seems I could code cnfify() to look for identical qualifications in two
joined OR clauses and remove the duplicates.

Sound like big win, and fairly easy and inexpensive in processing time.

Comments?

--
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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Taral 1998-10-04 02:26:20 RE: [HACKERS] RE: [GENERAL] Long update query ? (also Re: [GENERAL] CNF vs. DNF)
Previous Message Patrick Verdon 1998-10-04 00:39:31 DBD::Pg & cursors & total results

Browse pgsql-hackers by date

  From Date Subject
Next Message Taral 1998-10-04 02:26:20 RE: [HACKERS] RE: [GENERAL] Long update query ? (also Re: [GENERAL] CNF vs. DNF)
Previous Message Bruce Momjian 1998-10-04 01:06:44 Re: [HACKERS] Dumping of views -- done!