PostgreSQL - 13.15. I have a table that is 7 TB in size. There is an index -
CREATE INDEX mytable_cmp_ts ON mytable USING btree (campaign_id, created_at);
I can't try explain analyze for the following query because it may take a long time. An EXPLAIN says the index will be used. Is that possible, considering that created_at is the second column in the index?
explain select min(created_at) from mytable;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------
Finalize Aggregate (cost=244894227.70..244894227.71 rows=1 width=8)
-> Gather (cost=244894227.48..244894227.69 rows=2 width=8)
Workers Planned: 2
-> Partial Aggregate (cost=244893227.48..244893227.49 rows=1 width=8)
-> Parallel Index Only Scan using mytable_cmp_ts on mytable (cost=0.71..238551221.08 rows=2536802560 width=8)