PostgreSQL - 13.15. Tenho uma tabela com 7 TB de tamanho. Há um índice -
CREATE INDEX mytable_cmp_ts ON mytable USING btree (campaign_id, created_at);
Não posso tentar explain analyse para a consulta a seguir porque pode levar muito tempo. Um EXPLAIN diz que o índice será usado. Isso é possível, considerando que created_at é a segunda coluna no índice?
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)