OR with multi-key indexes - Mailing list pgsql-hackers

From Bruce Momjian
Subject OR with multi-key indexes
Date
Msg-id 199808011133.HAA22411@candle.pha.pa.us
Whole thread Raw
List pgsql-hackers
Here is a comment in path/indxpath.c that says they don't want to use
multi-key indexes with OR clauses.  Of course, we now support multi-key
indexes, and this code was disabled anyway because it was broken.  (In
fact, it was disabled by having SingleAttributeIndex() always return
false.

Is there any reason we can't use multi-key indexes if the first key
matches our OR column?  I don't see why not.  Also, I don't know how to
handle the case where we specify the first key of a multi-key index in
an AND clause, and specify the second key in an OR clause because the
AND's are handled in a separate are of the code.  Any ideas how to
implement this?  (Of course, the code would still use the index for the
AND, but I don't know how to bring the AND case into my OR index clause
processing area.)

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


    /*
     * 1. If this index has only one key, try matching it against
     * subclauses of an 'or' clause.  The fields of the clauseinfo nodes
     * are marked with lists of the matching indices no path are actually
     * created.
     *
     * XXX NOTE:  Currently btrees dos not support indices with > 1 key, so
     * the following test will always be true for now but we have decided
     * not to support index-scans on disjunction . -- lp
     */
    if (SingleAttributeIndex(index))
    {

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

pgsql-hackers by date:

Previous
From: Vadim Mikheev
Date:
Subject: Re: [HACKERS] OR clause - check code
Next
From: Vadim Mikheev
Date:
Subject: Re: [HACKERS] OR with multi-key indexes