Query optimization and indexes - Mailing list pgsql-general

From felix@crowfix.com
Subject Query optimization and indexes
Date
Msg-id 20060818231928.GA19900@crowfix.com
Whole thread Raw
Responses Re: Query optimization and indexes
List pgsql-general
Suppose I have an index on 5 columns (A, B, C, D, E).

If my WHERE clause is not in that order, will the optimizer reorder
them as necessary and possible?

    WHERE A=1 AND C=3 AND B=2 AND E=5 AND D=4

Obviously it can't reorder them in all cases:

    WHERE A=1 AND (C=3 OR B=2) AND (E=5 OR D=4)

If I don't specify columns in the WHERE clause, how much can it use
the index?  I think it is smart enough to use beginning columns:

    WHERE A=1 AND B=2

How about skipping leading columns?

    WHERE B=2

How about skipping intermediate columns?

    WHERE A=1 AND C=3

Or both, which is probably the same?

    WHERE B=2 AND D=4?

--
            ... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
     Felix Finch: scarecrow repairman & rocket surgeon / felix@crowfix.com
  GPG = E987 4493 C860 246C 3B1E  6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Connection string
Next
From: Tom Lane
Date:
Subject: Re: Query optimization and indexes