By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
CREATE INDEX
INSERT 0 259201
| QUERY PLAN |
|---|
| Result (cost=1.19..1.20 rows=1 width=16) (actual time=103.116..103.118 rows=1 loops=1) |
| InitPlan 1 (returns $0) |
| -> Limit (cost=0.42..0.59 rows=1 width=8) (actual time=103.049..103.050 rows=1 loops=1) |
| -> Index Scan using pk_rttx on relation_tuple_transaction (cost=0.42..14904.25 rows=86024 width=8) (actual time=102.906..102.906 rows=1 loops=1) |
| Index Cond: (id IS NOT NULL) |
| Filter: ("timestamp" >= (now() - '00:00:05'::interval)) |
| Rows Removed by Filter: 259199 |
| InitPlan 2 (returns $1) |
| -> Limit (cost=0.42..0.59 rows=1 width=8) (actual time=0.057..0.057 rows=1 loops=1) |
| -> Index Scan Backward using pk_rttx on relation_tuple_transaction relation_tuple_transaction_1 (cost=0.42..14904.25 rows=86024 width=8) (actual time=0.055..0.056 rows=1 loops=1) |
| Index Cond: (id IS NOT NULL) |
| Filter: ("timestamp" >= (now() - '00:00:05'::interval)) |
| Planning Time: 1.987 ms |
| Execution Time: 103.342 ms |
EXPLAIN
VACUUM
PREPARE
| QUERY PLAN |
|---|
| Aggregate (cost=8.46..8.47 rows=1 width=16) (actual time=0.287..0.289 rows=1 loops=1) |
| -> Index Scan using ix_relation_tuple_transaction_by_timestamp on relation_tuple_transaction (cost=0.42..8.46 rows=2 width=8) (actual time=0.011..0.013 rows=2 loops=1) |
| Index Cond: ("timestamp" >= '2025-10-01 16:26:31.124427'::timestamp without time zone) |
| Planning Time: 1.075 ms |
| Execution Time: 1.246 ms |
EXPLAIN
| QUERY PLAN |
|---|
| Aggregate (cost=8.46..8.47 rows=1 width=16) (actual time=0.011..0.012 rows=1 loops=1) |
| -> Index Scan using ix_relation_tuple_transaction_by_timestamp on relation_tuple_transaction (cost=0.42..8.46 rows=2 width=8) (actual time=0.007..0.008 rows=2 loops=1) |
| Index Cond: ("timestamp" >= '2025-10-01 16:26:31.127392'::timestamp without time zone) |
| Planning Time: 0.346 ms |
| Execution Time: 0.031 ms |
EXPLAIN
| QUERY PLAN |
|---|
| Aggregate (cost=8.46..8.47 rows=1 width=16) (actual time=0.011..0.012 rows=1 loops=1) |
| -> Index Scan using ix_relation_tuple_transaction_by_timestamp on relation_tuple_transaction (cost=0.42..8.46 rows=2 width=8) (actual time=0.007..0.008 rows=2 loops=1) |
| Index Cond: ("timestamp" >= '2025-10-01 16:26:31.127958'::timestamp without time zone) |
| Planning Time: 0.302 ms |
| Execution Time: 0.045 ms |
EXPLAIN
| QUERY PLAN |
|---|
| Aggregate (cost=8.46..8.47 rows=1 width=16) (actual time=0.012..0.012 rows=1 loops=1) |
| -> Index Scan using ix_relation_tuple_transaction_by_timestamp on relation_tuple_transaction (cost=0.42..8.46 rows=2 width=8) (actual time=0.007..0.008 rows=2 loops=1) |
| Index Cond: ("timestamp" >= '2025-10-01 16:26:31.128604'::timestamp without time zone) |
| Planning Time: 0.482 ms |
| Execution Time: 0.030 ms |
EXPLAIN
| QUERY PLAN |
|---|
| Aggregate (cost=8.46..8.47 rows=1 width=16) (actual time=0.010..0.010 rows=1 loops=1) |
| -> Index Scan using ix_relation_tuple_transaction_by_timestamp on relation_tuple_transaction (cost=0.42..8.46 rows=2 width=8) (actual time=0.006..0.007 rows=2 loops=1) |
| Index Cond: ("timestamp" >= '2025-10-01 16:26:31.129401'::timestamp without time zone) |
| Planning Time: 0.265 ms |
| Execution Time: 0.027 ms |
EXPLAIN
| QUERY PLAN |
|---|
| Result (cost=1.06..1.07 rows=1 width=16) (actual time=61.736..61.738 rows=1 loops=1) |
| InitPlan 1 (returns $0) |
| -> Limit (cost=0.42..0.53 rows=1 width=8) (actual time=61.701..61.702 rows=1 loops=1) |
| -> Index Scan using pk_rttx on relation_tuple_transaction (cost=0.42..9445.44 rows=86400 width=8) (actual time=61.699..61.699 rows=1 loops=1) |
| Index Cond: (id IS NOT NULL) |
| Filter: ("timestamp" >= $1) |
| Rows Removed by Filter: 259199 |
| InitPlan 2 (returns $1) |
| -> Limit (cost=0.42..0.53 rows=1 width=8) (actual time=0.028..0.029 rows=1 loops=1) |
| -> Index Scan Backward using pk_rttx on relation_tuple_transaction relation_tuple_transaction_1 (cost=0.42..9445.44 rows=86400 width=8) (actual time=0.027..0.027 rows=1 loops=1) |
| Index Cond: (id IS NOT NULL) |
| Filter: ("timestamp" >= $1) |
| Planning Time: 0.459 ms |
| Execution Time: 61.764 ms |
EXPLAIN