Å·±¦ÓéÀÖ

Jump to ratings and reviews
Rate this book

SQL Performance Explained

Rate this book
SQL Performance Explained helps developers to improve database performance. The focus is on SQL-it covers all major SQL databases without getting lost in the details of any one specific product. Starting with the basics of indexing and the WHERE clause, SQL Performance Explained guides developers through all parts of an SQL statement and explains the pitfalls of object-relational mapping (ORM) tools like Hibernate. Topics covered include: Using multi-column indexes; Correctly applying SQL functions; Efficient use of LIKE queries; Optimizing join operations; Clustering data to improve performance; Pipelined execution of ORDER BY and GROUP BY; Getting the best performance for pagination queries; Understanding the scalability of databases. Its systematic structure makes SQL Performance Explained both a textbook and a reference manual that should be on every developer's bookshelf.

84 pages, ebook

First published March 8, 2011

55 people are currently reading
868 people want to read

About the author

Markus Winand

4Ìýbooks4Ìýfollowers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
180 (54%)
4 stars
118 (35%)
3 stars
31 (9%)
2 stars
4 (1%)
1 star
0 (0%)
Displaying 1 - 30 of 46 reviews
Profile Image for Pavel.
64 reviews3 followers
July 19, 2014
A tiny book containing a lot of useful material. Very relevant for developers who are also responsible for the database.
6 reviews2 followers
July 31, 2016
Good introduction into how databases uses indices to make effective and efficient queries. Relatively small chapters that focus on one topic at a time and use examples and visualization a to explain the topics discussed. I had never read anything about SQL performance before and this served as a very good introduction. I imagine this being a good reference to come back to when tackling performance problems.
11 reviews4 followers
February 23, 2021
Every application developer should read this book. Nothing more to say. Thank you Markus
Profile Image for ÀµØ¯Ù‰.
198 reviews59 followers
November 27, 2021
I Loved this book, I really had a clear image now of how Index works.
reading it will surely make a difference when writing queries.
Profile Image for Leo.
304 reviews24 followers
December 18, 2023
Very condensed guide to everything related to indexes in relational databases. It's just 200 pages long, so you can read this in 3 days, and you can't get more information in such a short timespan from anywhere else.
It's also very practical, so you'll rarely see mentions of deep under-the-hood stuff or how specifically it works - more about "how you can benefit from it working that way".
The only con is it can be somewhat dated by now, though I suppose at least 80% are still widely applicable.
Profile Image for Jon Gauthier.
129 reviews239 followers
April 3, 2012
This little book contains so many useful nuggets of information. It focuses largely on indexes, but also touches on things like query parameters and their gotchas. With each major feature Winand includes a table listing usage details specific to each SQL implementation. Definitely worth a read.
39 reviews1 follower
October 8, 2018
It's really strange that there are so few SQL and relational data management books written for a general developer audience. RDBMS systems are integrated in all kinds of applications that deal with user data, and a big majority of web aplications interface to them. The job of creating, running and optimizing SQL, however, has been delegated to specialized subsystems such ORM's, and DB administrators. The results are the various horrendously performing web applications that I have had the pleasure to work with, and the weird ORM generated schemas that worked perfectly well in local development or testing, but turned out to be ticking timebombs on production systems.

This book fits perfectly in this space of SQL books for all developers. Its aim is to concisely explain principles of database performance and optimization, focusing on the most important tools that all databases provide, especially the B-tree index. Winand starts with a description of how databases organize data, and how B-tree indexes are used to find the relevant data. The discussion of indexes is coupled with many concrete examples and tips on finding out how a database is processing a query. The examples are for Oracle databases,and in some places, there are lengthy discussions of Oracle-specific topics (such as non-standard handling of NULL values), but they are mostly applicable to other databases, especially PostgreSQL. There is also an appendix on using the query explainers of various RDBMS systems. Winand goes into detail on various ways of creating indexes (e.g. covering and partial indexes), and for which scenarios these different methods are suitable, without getting lost in text. The discussion of index-related topics takes approximately half of the book. The rest is dedicated to other RDBMS functionalities such as joins, insert and update statements, but always with a focus on how the index can be used to make these processes faster and more efficient, and how various indexes themselves are affected.

The most obvious shortcoming of SQL Performance Explained is that there is no sample data set for experimenting. I had the chance of appying many techniques described here to our production database, but directly experimenting with a sample database with various complexities would lead to a better learning experience in general. Clarity also sometimes suffers from the conciseness. For example, some terms are not defined, such as access rate on p. 86 or what to materialize means, on p. 140. Generally useful would have been a glossary that defines the most important terms. That said, if such minor ommissions that can be completed by a quick web search are the price of the conciseness of this book, this is a price I'm happy to pay.

If you are going to read only one book about database performance,there are much worse choices than SQL Performance Explained. But do read more books about databases in general, so that I don't have to take over another agonizingly slow legacy system.
Profile Image for Aaron Schumacher.
201 reviews11 followers
December 7, 2021
This is the printed version of "Use the index, Luke." It avoids the Jedi goofiness—and the author's unsettling gaze. It's pretty good, especially for a self-published book, and it delivers on the promise of explaining, very accessibly, how SQL engines run.

The mental model offered goes beyond just "index means O(log(n))," though there are the obligatory graphs showing linear vs. log growth. Winand describes tree traversal of indexes, but then also (depending on data and query) linked-list traversal, and how this relates to accessing data that isn't in the index, and connected trade-offs.

The material starts rudimentary, but reaches details such as this, on page 140:

"The Oracle database cannot read an index backwards in order to execute a pipelined group by that is followed by an order by."

One of the most interesting things for me turned out to be the frequent comparisons and notes specific to SQL implementations. Very often the notes were explaining that MySQL didn't offer a particular feature, or that a feature was only available in Postgres. MS SQL Server and Oracle seem to be somewhere in the middle.

The level of detail was also sufficient to make clear that declarative languages like SQL are not the panacea that they are sometimes made out to be. I hadn't realized, for example, that SQL engines make execution choices based on statistics they keep about the data they store, and that those statistics can be incorrect, leading to bad choices.

Winand is also critical of ORMs that can lead to bad SQL. Though I didn't find these examples particularly compelling, I do think it's a related case of trading control for convenience.

Also, the book comes with a bookmark, which is a laminated miniature of the cover.
Profile Image for Sergey Machulskis.
99 reviews8 followers
April 15, 2020
It's short and very well-written. It's the most valuable read on SQL I've ever seen. Usually I avoid reading books online because it's distracting but I couldn't switch to anything else until I finished it.

It's here

Hard to say what was the most useful in this book. It's dense with advice. Maybe the most important thing for backend developers is .

I wish there was a book about other index types (this one explains B-tree indexes in detail).
Profile Image for Jesus.
90 reviews1 follower
May 18, 2023
Teniendo en cuenta que es un libro que tiene ya más de 10 años y sabiendo como cambia todo lo relacionado al software, hay que revisar qué de lo que dice ya no aplica (total o parcialmente) en la base de datos que estás usando actualmente.
Aún así, me ha aportado muchísima información de base que me faltaba. Sobre cómo funcionan los índices más allá del "si buscas mucho por un campo, métele un índice".
La explicación de cómo funciona el plan de ejecución también es muy interesante de cara a encontrar problemas de performance en las queries.
Profile Image for ´¡²Ô»å°ùé.
106 reviews6 followers
December 24, 2020
This is just brilliant. I had the pleasure and joy working with Markus on a small task where I could see and experience his profound knowledge on SQL performance. This made me buy this book. Reading this book now got me back to that time and as I already saw that the knowledge and efficiency taught in this book is really paying off, it was an even greater joy reading more about the underlying magic behind this performance improvements.
44 reviews2 followers
February 6, 2021
It takes real skill to explain relatively complex things so simply. I was also impress by Winand's ability to split the content into bite-sized chapters which makes reading effortless as opposed to some work you have to do (even if you do it for work)
Profile Image for Ferhat Elmas.
822 reviews13 followers
June 15, 2021
Basis of B-tree indexes. Useful to review but not like wow.

It is mostly the theoretical extended explanation of his 3-min test in his website. If you had the test good enough consciously, no need for the text.
Profile Image for Lucija.
23 reviews1 follower
April 29, 2018
Very useful and easy to read, Contains lots of examples.
Profile Image for Danny.
19 reviews1 follower
July 11, 2018
Great little book, just going through the first chapter on how the specific index algorithms work (behind the scenes) is worth the small price tag.
2 reviews
August 11, 2018
Every backend developer should read this book
Profile Image for Bugzmanov.
230 reviews89 followers
December 22, 2019
Short and solid. Delivers what is promised in a concise, no-bs way. I wish there were more books like this.
Profile Image for Patryk Woziński.
16 reviews1 follower
July 18, 2022
The best book related to the SQL Performance I’ve ever read. It’s totally must-read position for every backend developer in my opinion. Highly recommended, short and concrete - awesome!
Profile Image for Roman Protsiuk.
13 reviews
August 8, 2022
All useful information, but the way it's written... I can't remember last time it was so hard for me to read a book.
Profile Image for Miroslav Lesov.
44 reviews
October 12, 2022
A piece of work that is a must-read for every backend developer regardless of the experience and seniority
Displaying 1 - 30 of 46 reviews

Can't find what you're looking for?

Get help and learn more about the design.