3 ms·
Uhh ... Postgres supports Index-only scans; as long as the data you're asking for is in the index, that is. So if you have an index on (conversation_id, messag
by pritambaral 10y ago
Uhh ... Postgres supports Index-only scans; as long as the data you're asking for is in the index, that is.
So if you have an index on (conversation_id, message_id), and you try to retrieve message ids of a specific conversation, only the index will be touched.
- vanviegen 10y agoDoh, you're right of course! We were having this problem in the Postgres 9.1 era, before index-only scans were a thing. Still, it's quite inefficient maintaining an extra copy of the data that is never actually used. Though no longer multiple orders of magnitude less efficient. However, I'd guess that programmers don't often think to add these seemingly useless fields to an index, as it feels inefficient and just wrong. But at least this offers an out in pathetic cases.