Hi,
we have a table partitioned by time. Each month goes into a separate
child table. Primary key in each table is (underlying, ts). The
resulting index is perfect for ordering like in the query below. Each
child table has a constraint like:
CHECK(ts>= '2011-1-1' and ts<'2011-1-1'::DATE + interval '1 month')
Now, we have queries of this type:
SELECT * FROM tick
WHERE underlying = 'R_50' AND ts <= '2013-05-02'
ORDER BY ts DESC LIMIT 100
The query plan for this is at http://explain.depesz.com/s/fB6
According to this plan it fetches all the result tuples from tick_2013_4
which is fine because tick_2013_5 obviously does not contain matches.
My question is, why does it then try to fetch one row from every other
index? Can that be avoided without a lower bound on ts?
Thanks,
Torsten