Re: index vs seqscan question - Mailing list pgsql-general

From Tom Lane
Subject Re: index vs seqscan question
Date
Msg-id 28753.1038004241@sss.pgh.pa.us
Whole thread Raw
In response to Re: index vs seqscan question  (Frank Bax <fbax@sympatico.ca>)
Responses Re: index vs seqscan question  (Frank Bax <fbax@sympatico.ca>)
List pgsql-general
Frank Bax <fbax@sympatico.ca> writes:
> OK, I should have finished testing my changes before posting - the
> new/faster query should have brackets around (typ=' ' OR typ='A'), but its
> still fast as lightning!  I don't think it made a big difference to explain
> results, but it appears seqscan is cheaper than it was before?

The version with the typo couldn't use an indexscan, I think (planner's
not real smart about asymmetrical AND/OR structures).  The fixed
version is probably going for seqscan because with the additional AND
condition, it's estimating fewer rows need to be sorted.  The seqscan
isn't getting cheaper, but the sort is.

Looking only at the planner's estimates is not very reliable though.
What does EXPLAIN ANALYZE have to say?

            regards, tom lane

pgsql-general by date:

Previous
From: Frank Bax
Date:
Subject: Re: index vs seqscan question
Next
From: Eric B.Ridge
Date:
Subject: Re: UNION and array types