Re: [GENERAL] Query optimization and indexes

2006-08-19 Thread Tom Lane
Gregory Stark <[EMAIL PROTECTED]> writes: > Tom Lane <[EMAIL PROTECTED]> writes: >> only the a = 5 clause would be used with the index. As of 8.1 it will >> consider using nonconsecutive index columns > Really? Is this the "skip scan" plan people were pining for? No, there's no skip scan, it jus

Re: [GENERAL] Query optimization and indexes

2006-08-19 Thread Gregory Stark
Tom Lane <[EMAIL PROTECTED]> writes: > Before (if memory serves) 8.1, the planner would only consider leading > index columns as potential indexscan qualifiers. So given > > where a = 5 and c = 4; > > only the a = 5 clause would be used with the index. As of 8.1 it will > consider using

Re: [GENERAL] Query optimization and indexes

2006-08-18 Thread Tom Lane
[EMAIL PROTECTED] writes: > 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? Yes, the optimizer understands about commutativity/associativity of AND and OR ;-) > If I don't specify co

[GENERAL] Query optimization and indexes

2006-08-18 Thread felix
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