Markus Winand
use-the-index-luke.com · Personal blog · on HN since 2010
Markus Winand writes about SQL indexing, query performance and modern SQL features for application developers.
What HN saysCommenters recommend it highly as a readable guide to database indexing, and some say they have new hires and interns read it.
171HN people shared it
122linked it in comments
137stories submitted
1.7Kstory points
3 months agolast shared
2010people per year2026
Most-shared posts
- 1SQL Indexing and Tuning E-Book for Developers86 people · 206 points · first shared 2010 · 6 comments on HN
- 2Do Not Use Offset for pagination (2014)27 people · 30 points · first shared 2014 · 2 comments on HN
- 3SQL OFFSET is worse than keyset pagination14 people · 14 points · first shared 2012 · 1 comments on HN
- 4On Uber’s Choice of Databases9 people · 169 points · first shared 2016 · 13 comments on HN
- 5Unreasonable Defaults: Primary Key as Clustering Key7 people · 7 points · first shared 2014 · discussion on HN
- 6Better Covering Indexes with Include Clause5 people · 6 points · first shared 2019 · discussion on HN
- 7What's left of NoSQL?4 people · 148 points · first shared 2014 · 104 comments on HN
- 8All you need to know about SQL performance4 people · 13 points · first shared 2011 · discussion on HN
- 9The smartest way to make SQL slow4 people · 6 points · first shared 2011 · discussion on HN
- 10The Dark Side of Clustered Indexes4 people · 2 points · first shared 2011 · 1 comments on HN
- 11MongoDB is to NoSQL like MySQL to SQL - in the most harmful way3 people · 224 points · first shared 2013 · 124 comments on HN
- 12The 3-minute SQL indexing quiz: Can you spot the five most common mistakes?3 people · 111 points · first shared 2011 · 32 comments on HN
- 13Modern SQL in PostgreSQL [and other databases]3 people · 18 points · first shared 2015 · discussion on HN
- 14SQL Paging queries using SQL "window functions"3 people · 2 points · first shared 2012 · discussion on HN
- 15Pagination done the postgresql way3 people · first shared 2016
What HN people wrote when they linked it
KellyCriterion · 2026-06-06
An for everyone starting fresh, I can HIGHLY recommend the SQL website:
"Use the Index, Luke"
https://use-the-index-luke.com/
qohen · 2026-06-04
A couple of sites worth checking out to level up, both by Markus Winand:
https://modern-sql.com/
https://use-the-index-luke.com/
tdfirth · 2025-12-22
If you do backend web development in 99% of software companies then being very good at whatever your RDBMS is is a superpower.
It's definitely worth learning SQL very well, but you also need to learn the data structures your RDBMS uses, how queries translate into operations on that data, and what those operations look like in a query plan.
You can go surprisingly far with just that knowledge.
A great resource is https://use-the-index-luke.com/
ethanseal · 2025-09-29
Highly recommend https://use-the-index-luke.com/
It's very readable - I always ask new hires and interns to read it.
bunderbunder · 2024-07-25
It's a great heuristic.
A big part of why it works out that way is that the query planner can only optimize for the query you give it. If you give it a bunch of small queries, it can only make relatively inconsequential micro-optimizations. The one big query gives it a lot more degrees of freedom and opportunities to make big gains.
Here's another great resource for getting more out of relational databases: https://use-the-index-luke.com/
sbuttgereit · 2024-04-17
Always worth a mention:
https://use-the-index-luke.com/
Markus Winand (the website's author) has also written a book on the subject targeted at software developers which is decent for non-DBA level knowledge.
eatonphil · 2024-04-01
Good call linking to Use The Index Luke. A great resource.
https://use-the-index-luke.com/
cocoflunchy · 2023-08-12
I recommend https://use-the-index-luke.com/ or even better do the training with Markus Winand, it'll change how you view databases.
bironran · 2022-06-27
Nice post, though for the indexing "introduction-deep-dive" I would still recommend newbies to look at https://use-the-index-luke.com/ .
jihadjihad · 2022-03-08
My team has really enjoyed the concise and informative book [0] from Markus Winand. It comes up sometimes here on HN, and IMHO it's a great resource on the topic for anyone who touches a relational database in their line of work.
His website "Use the Index, Luke!" [1] is also great.
0: https://sql-performance-explained.com
1: https://use-the-index-luke.com
twoquestions · 2021-07-30
To learn yourself, also go over the execution plan when running a query and Google absolutely everything it tells you, and look through the MSSQL documentation at what it all means. It won't lead you to what you don't know, but it will fill in everything you're a bit cloudy on.
One of my favorites to get the very basics is Select Star, especially because you work with real and meaningful data: https://selectstarsql.com/
Use the Index, Luke has also really helped me make queries that don't waste a ton of time:
https://use-the-index-luke.com/
Microsoft also has a bunch of paid training classes for MSSQL, if you or your boss don't mind ponying up some $$$. MSSQL is an amazing tool, and it's worth it to really learn how to use it well.
Good luck!
NeutralForest · 2021-05-28
Probably one of the best resources to understand indexes and the output of `EXPLAIN ANALYZE` would be https://use-the-index-luke.com/
alecco · 2020-09-12
For practical knowledge start with databases. Declarative is a great way to program, and a good starting point is https://use-the-index-luke.com/
About CompSci, it might get a bit dry at times. Seduce yourself into it, watch some Computerphile YouTube videos instead of a textbook. Then when you get the interest bug, search for what you are interested in. Try to keep it fun.
Once you built stamina, TAOC and SICP.
https://web.mit.edu/alexmv/6.037/sicp.pdf
imheretolearn · 2020-08-08
https://use-the-index-luke.com/
This is the site I was looking for but could not remember. Would recommend 100/100
moreaccountspls · 2020-07-02
There's a difference between operating the database [SRE type job] vs consuming a database [developer]. They're both very valuable skills, but learning the basics of SQL [i.e. being a consumer] is a no brainer. The skills will serve you well for the rest of your career. It's not something that changes every few years like frontend frameworks do.
This is my favorite learning material for ANY programming related skill ever: https://use-the-index-luke.com/, and it's all about SQL queries.
rsecora · 2020-05-11
This is the best part of HN.
Not only you did a comment on previous post, but it's a comment from the author of an awesome guide [https://use-the-index-luke.com].
Markus, I can assure you, that your guide has saved a lot of machine-computed-hours over the world with less energy consumption/wasted. Great work. :)
branko_d · 2020-05-11
If you are an application programmer needing to query the database, I wholeheartedly recommend "SQL Performance Explained" by Markus Winand, or his website: https://use-the-index-luke.com/
alexhutcheson · 2019-11-04
I recommend "Use the Index, Luke"[1] for people who are relatively new to SQL performance issues and want to learn how to make their queries fast.
[1] https://use-the-index-luke.com/
NDizzle · 2019-02-13
https://use-the-index-luke.com/ - great resource for various database products.
MarkusWinand · 2019-02-13
Since you ased about indexing in particular, here is my site about indexing:
https://use-the-index-luke.com/
You might also want to follow my other project:
https://modern-sql.com/
traviscj · 2018-09-16
For the love of god, learn how database indices work -- basically everything at https://use-the-index-luke.com/
fnord123 · 2018-04-11
SQL Antipatterns is good as another commenter recommended. But my favourite book on the topic is Markus Winand's SQL Performance Explained. Most of it is online here: https://use-the-index-luke.com/ but I recommend buying it since it's tiny and worth its weight in gold.
It's short so you actually read it and possibly reread it. It's to the point. It has pretty pictures. And it had directly applicable advice.
mwexler · 2018-02-05
Markus is modest; he is the author of the top post, and imho is up with Joe Celko in offering great techniques to use SQL effectively (both at http://modern-sql.com/ as above and http://use-the-index-luke.com/). I'm a fan.
j_s · 2017-10-02
Here's a recent discussion recommending a specific site that might help you as a resource, but I don't see much there regarding locality.
How far can you go with MySQL or MariaDB?
| https://news.ycombinator.com/item?id=14892184 (Aug 2017)
> dmux This is a great resource RE indexing: http://use-the-index-luke.com/
There is a detailed PostgreSQL optimization comment there that may be more what you had in mind:
https://news.ycombinator.com/item?id=14896154
> olavgg: Use multi-column/functional/partial indexes, as this will help you design a database where most of your 'hot' indexes can fit in RAM. If you have too many indexes, you will do index scan on disk, which is painfully slow. I[n] many cases a full table scan (sequential read) would be faster instead.
dmux · 2017-07-31
This is a great resource RE indexing: http://use-the-index-luke.com/
Artemis2 · 2017-05-21
Use the Index Luke is an excellent resource about relational database performance tuning as well: http://use-the-index-luke.com. I bought Markus Winand's book, it's extremely clear and concise (not the thick technical reference you would expect). Being able to understand the internals of modern database systems is great.
adamnemecek · 2017-01-19
If this tickles you fancy, you should check out this site http://use-the-index-luke.com or a book by the same author https://www.amazon.com/Performance-Explained-Everything-Developers-abo…
He goes into great detail to explain how exactly SQL indices work and how to leverage this to write queries.
Dangeranger · 2016-11-17
The list is missing http://use-the-index-luke.com and http://modern-sql.com which are some of the very best resources out there for SQL in general.
It also misses https://www.pgexercises.com which is an amazing resource for learning the specifics of PostgreSQL in particular.
dguaraglia · 2016-08-09
If what you are looking is a general book (not necessarily just for Postgres) I can't recommend the "Use The Index, Luke"[1] tutorial, and the accompanying book "SQL Performance Explained" by Markus Winand, enough.
It doesn't go into a lot of relational theory, but it does provide a somewhat low-level description on how indices and database data are stored, and why you want to use different kind of indices in different scenarios.
[1] http://use-the-index-luke.com
olalonde · 2015-08-03
http://use-the-index-luke.com/ is another great resource though not specifically targeted at Postgres.