How do create an index for this query? I've tried every possible combination of indexes I can think of but explain plan always shows a SEQ_SCAN is being used.
select exchange_id, currency, max(timestamp) timestamp2
from exchange_balance
where account_id = 'foo'
group by exchange_id, currency
The table isn't large right now and so it's actually quite fast, but it will grow quickly.
PostgreSQL 9.6
[edit] added a group by col - sorry
I've tried this for example:
CREATE INDEX idx_exchange_balance_1 ON exchange_balance (exchange_id, currency, timestamp desc, account_id);
But always a table scan on a table with 45k rows