Re: index usage - Mailing list pgsql-performance

From Tom Lane
Subject Re: index usage
Date
Msg-id 11751.1042815424@sss.pgh.pa.us
Whole thread Raw
In response to index usage  (Timur Irmatov <thor@sarkor.com>)
Responses Re: index usage  (Timur Irmatov <thor@sarkor.com>)
List pgsql-performance
Timur Irmatov <thor@sarkor.com> writes:
> Limit  (cost=0.00..0.19 rows=1 width=6) (actual time=0.43..0.43 rows=0 loops=1)
>   ->  Index Scan using timeindex on mediumstats  (cost=0.00..2898.96 rows=15185 width=6) (actual time=0.42..0.42
rows=0loops=1) 

The planner has absolutely no clue about the behavior of your function,
and so its estimate of the number of rows matched is way off, leading to
a poor estimate of the cost of an indexscan.  There is not much to be
done about this in the current system (though I've speculated about the
possibility of computing statistics for functional indexes).

Just out of curiosity, why don't you lose all this year/month/day stuff
and use a timestamp column?  Less space, more functionality.

            regards, tom lane

pgsql-performance by date:

Previous
From: "Roman Fail"
Date:
Subject: Implicit casting and JOIN syntax constraints
Next
From: Timur Irmatov
Date:
Subject: Re: index usage