This week I got a deeper look into why indexes, which are meant to speed up queries, sometimes don’t work as fast as you’d expect. The article, Slow Indexes, explained that while the initial tree traversal part of the index is efficient there are two other steps that can slow things down. First, when there are multiple matches the database has to follow a chain of leaf nodes to find all the entries, which can take extra time. Second, for each match it has to access the actual table data which means reading a lot of additional blocks. These extra steps can make the query slower even though the index itself isn’t "broken" or “unbalanced.” It was interesting to learn that rebuilding the index doesn’t actually solve the issue. The performance hit comes from the natural way the lookup process works, especially when there are many matches to process.

Comments

Popular posts from this blog