This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-16. For the latest, interactive version please visit https://mariadb.com/kb/.

index usage on updates

I have seen a few times that even if there is a covering index for an UPDATE (including the column in SET), it will ignore the index and fall back on the PRIMARY key.

what could be the reasoning behind it.

Answer Answered by Ian Gilfillan in this comment.

The query optimizer makes a best guess for a query plan - without your specific data, it's hard to give a reason. Take a look at the articles in Statistics for Optimizing Queries for more on how the query optimizer works.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.