кн
Size: a a a
кн
Z
Z
кн
Z
KK
VY
select * from item
order by id limit 1
ON item (id) WHERE id IS NOT NULL
Z
Z
VY
M
YS
explain (analyze, buffers) select min(id) from item
Result (cost=0.69..0.70 rows=1 width=8) (actual time=45535.327..45535.327 rows=1 loops=1)
Buffers: shared hit=2757593 read=182247 dirtied=253 written=11026
InitPlan 1 (returns $0)
-> Limit (cost=0.43..0.69 rows=1 width=8) (actual time=45535.317..45535.318 rows=1 loops=1)
Buffers: shared hit=2757593 read=182247 dirtied=253 written=11026
-> Index Only Scan using item_id_idx on item (cost=0.43..1087166.50 rows=4299775 width=8) (actual time=45535.314..45535.315 rows=1 loops=1)
Index Cond: (id IS NOT NULL)
Heap Fetches: 3087185
Buffers: shared hit=2757593 read=182247 dirtied=253 written=11026
Planning time: 0.151 ms
Execution time: 45535.361 ms
\d item
кн
ON item (id) WHERE id IS NOT NULL
кн
\d item
\d item
Table "public.item"
Column | Type | Collation | Nullable | Default
---------+-----------------------------+-----------+----------+---------------------------------------------
id | bigint | | not null | nextval('item_id_seq'::regclass)
item_id | bigint | | |
ts | timestamp without time zone | | | now()
event | character(1) | | |
data | jsonb | | |
Indexes:
"item_id_idx" btree (id)
"item_id_idx1" btree (id) WHERE id IS NOT NULL
KK
YS
explain (analyze, buffers) select min(id) from item
Result (cost=0.69..0.70 rows=1 width=8) (actual time=45535.327..45535.327 rows=1 loops=1)
Buffers: shared hit=2757593 read=182247 dirtied=253 written=11026
InitPlan 1 (returns $0)
-> Limit (cost=0.43..0.69 rows=1 width=8) (actual time=45535.317..45535.318 rows=1 loops=1)
Buffers: shared hit=2757593 read=182247 dirtied=253 written=11026
-> Index Only Scan using item_id_idx on item (cost=0.43..1087166.50 rows=4299775 width=8) (actual time=45535.314..45535.315 rows=1 loops=1)
Index Cond: (id IS NOT NULL)
Heap Fetches: 3087185
Buffers: shared hit=2757593 read=182247 dirtied=253 written=11026
Planning time: 0.151 ms
Execution time: 45535.361 ms
SELECT MIN(id) AS min_id, MAX(id) AS max_id, COUNT(*) AS total_rows?
FROM item;
KK
кн
SELECT MIN(id) AS min_id, MAX(id) AS max_id, COUNT(*) AS total_rows?
FROM item;
кн
YS
VACUUM FULL item;> ничего не помагает из вакуума, только truncate
VACUUM ANALYZE item;