Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

Postgres not using partial timestamp index on interval queries (e.g., ...

Language: Layout:
absolute service time: 0,46 sec 
edit mode |  history
   now ?column?
1 06.03.2017 15:43:21 27.02.2017 15:43:21
   QUERY PLAN
1 Index Scan using idx_precip_gauge_id_last_five_days on precip (cost=0.13..8.15 rows=1 width=24) (actual time=0.106..0.108 rows=2 loops=1)
2 Index Cond: ((gauge_id = 208) AND (reading_time > '2017-02-27 00:00:00+00'::timestamp with time zone))
3 Planning time: 0.626 ms
4 Execution time: 0.153 ms
   QUERY PLAN
1 Index Scan using idx_precip_gauge_id_last_five_days on precip (cost=0.13..8.15 rows=1 width=24) (actual time=0.011..0.012 rows=2 loops=1)
2 Index Cond: ((gauge_id = 208) AND (reading_time > '2017-02-26 00:00:00+00'::timestamp with time zone))
3 Planning time: 0.088 ms
4 Execution time: 0.038 ms
   QUERY PLAN
1 Seq Scan on precip (cost=0.00..10.00 rows=1 width=24) (actual time=0.148..0.148 rows=0 loops=1)
2 Filter: ((gauge_id = 208) AND (reading_time > now()))
3 Rows Removed by Filter: 400
4 Planning time: 0.080 ms
5 Execution time: 0.178 ms
   QUERY PLAN
1 Seq Scan on precip (cost=0.00..11.00 rows=1 width=24) (actual time=0.162..0.164 rows=2 loops=1)
2 Filter: ((gauge_id = 208) AND (reading_time > (now() - '7 days'::interval)))
3 Rows Removed by Filter: 398
4 Planning time: 0.101 ms
5 Execution time: 0.203 ms
   QUERY PLAN
1 Index Scan using idx_precip_gauge_id_last_five_days on precip (cost=0.14..8.16 rows=1 width=24) (actual time=0.013..0.013 rows=0 loops=1)
2 Index Cond: ((gauge_id = 208) AND (reading_time > '2017-02-26 00:00:00+00'::timestamp with time zone) AND (reading_time > now()))
3 Planning time: 0.105 ms
4 Execution time: 0.050 ms
   QUERY PLAN
1 Index Scan using idx_precip_gauge_id_last_five_days on precip (cost=0.14..8.16 rows=1 width=24) (actual time=0.017..0.019 rows=2 loops=1)
2 Index Cond: ((gauge_id = 208) AND (reading_time > '2017-02-26 00:00:00+00'::timestamp with time zone) AND (reading_time > (now() - '7 days'::interval)))
3 Planning time: 0.109 ms
4 Execution time: 0.055 ms

    
                
λ
.NET NoSQL database for rapid development