Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL Indexing not improving speed

Given an SQL database with index for (startpage, endpage), with a relation Articles(*ID*, title, startpage, endpage), why isn’t a query

SELECT title 
FROM Articles 
WHERE endpage = 100;

sped up by the previous index?

Apologies for this peculiar question as it came from a practice paper without explanation.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Why the index shown does not help that query: because endpage is not the leftmost column of the index.

See my answer to Does Order of Fields of Multi-Column Index in MySQL Matter for more explanation (that question is about MySQL, but the answer should apply to any implementation of B-tree indexes).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading