On Mon, Jun 20, 2022 at 1:17 AM Дмитрий Иванов <firstdismay@xxxxxxxxx> wrote:
Your statement seems obvious to me. But what I see doesn't seem like a conscious choice. It turns out that it is better to have a lighter general-purpose index than to strive to create a target covering index for a certain kind of operation.
If both indexes are expected to be hit only once in the query and return only one row, their expected costs will be the same. In this case, the tie is broken arbitrarily, and that often means the most-recently created index will get chosen.
As the expected number of leaf page accesses in a given query goes up, the smaller index will start to look less expensive.
Cheers,
Jeff