I could obviously test this empirically but I've found that without loading fake data EXPLAIN
shows that Postgres just loads the full page of memory containing the table and scans. I also haven't found the answer in the docs.
My question is, if I have an index on a table such as (colA, colB)
and a query containing where colA = 'something'
will Postgres use this index even though colB
is not in the query? Assume that no index containing just colA
exists. It stands to reason that this index could be useful in the query execution, but I've had a hard time tracking the answer down definitively.
(Postgres v12.x)
create table j as select floor(random()*10000)::int as a, floor(random()*10000)::int as b, md5(random()::text) as t from generate_series(1,1e6);