add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
CREATE TABLE
INSERT 0 262993
CREATE INDEX
ANALYZE
QUERY PLAN
Bitmap Heap Scan on test (cost=1272.65..3631.26 rows=59730 width=8) (actual time=5.102..12.266 rows=60346 loops=1)
  Recheck Cond: (((created_at)::time without time zone >= '10:00:00'::time without time zone) AND ((created_at)::time without time zone <= '15:30:00'::time without time zone))
  Heap Blocks: exact=1164
  -> Bitmap Index Scan on test_created_at_idx (cost=0.00..1257.72 rows=59730 width=0) (actual time=4.944..4.945 rows=60346 loops=1)
        Index Cond: (((created_at)::time without time zone >= '10:00:00'::time without time zone) AND ((created_at)::time without time zone <= '15:30:00'::time without time zone))
Planning Time: 0.189 ms
Execution Time: 14.313 ms
EXPLAIN
QUERY PLAN
Bitmap Heap Scan on test (cost=1272.65..3631.26 rows=59730 width=8) (actual time=4.093..11.213 rows=60346 loops=1)
  Recheck Cond: (((created_at)::time without time zone >= '10:00:00'::time without time zone) AND ((created_at)::time without time zone <= '15:30:00'::time without time zone))
  Heap Blocks: exact=1164
  -> Bitmap Index Scan on test_created_at_idx (cost=0.00..1257.72 rows=59730 width=0) (actual time=3.942..3.942 rows=60346 loops=1)
        Index Cond: (((created_at)::time without time zone >= '10:00:00'::time without time zone) AND ((created_at)::time without time zone <= '15:30:00'::time without time zone))
Planning Time: 0.080 ms
Execution Time: 13.266 ms
EXPLAIN
QUERY PLAN
Seq Scan on test (cost=0.00..9053.79 rows=55196 width=8) (actual time=0.022..102.872 rows=210427 loops=1)
  Filter: (((date_part('hour'::text, created_at) >= '10'::double precision) AND (date_part('minute'::text, created_at) >= '0'::double precision)) OR ((date_part('hour'::text, created_at) <= '15'::double precision) AND (date_part('minute'::text, created_at) <= '30'::double precision)))
  Rows Removed by Filter: 52566
Planning Time: 0.072 ms
Execution Time: 109.913 ms
EXPLAIN
DISCARD ALL
PREPARE
PREPARE
DROP TABLE
CREATE TABLE
DO
variant avg execution time - lower is better
cast_to_time_s 00:00:00.012207
four_date_parts 00:00:00.110047
SELECT 2