Re: help understanding create statistic

2018-06-28 Thread David Rowley
On 28 June 2018 at 21:38, Luca Ferrari wrote: > CREATE INDEX idx_year > ON expenses ( EXTRACT( year FROM day ) ); > > why is the planner not choosing to use such index on a 'year' raw query? > > EXPLAIN SELECT * FROM expenses > WHERE year = 2016; The expression in the where clause must match the

help understanding create statistic

2018-06-28 Thread Luca Ferrari
Hi all, in order to better understand this feature of 10, I've created a table like this: CREATE TABLE expenses( ... day date, year int, CHECK( year = EXTRACT( year FROM day ) ) ); so that I can ensure 'year' and 'day' are tied together: SELECT count(*) FILTER( WHERE year = 2016 ) AS