Re: Date index not used when selecting a date range - Mailing list pgsql-general

From Poul Møller Hansen
Subject Re: Date index not used when selecting a date range
Date
Msg-id 488EC201.5020803@pbnet.dk
Whole thread Raw
In response to Date index not used when selecting a date range  (Poul Møller Hansen <freebsd@pbnet.dk>)
List pgsql-general
> You can prevent postgres from using the index on node by changing the reference in the WHERE clause to an expression,
likeso: 
>
> SELECT * FROM public.stat WHERE node||'' = '1010101010' AND
>  ("date" <= '2008-06-30'::date AND "date" >= '2008-01-01'::date);
>
> Perhaps this will lead the optimizer to choose the index on date. However, I have noticed reluctance in the postgres
optimizerto use multi-column indexes, presumably because the increased size of the indexed values lowers expectations
forperformance of the index. 
>
>
>
I think you are right about the multi-column usage.
When I use node||'' instead of node, it will do a seq scan.

Poul


pgsql-general by date:

Previous
From: Klint Gore
Date:
Subject: Re: why can't I load pgxml.sql
Next
From: Craig Ringer
Date:
Subject: Re: How to give input a file for a stored procedure