SQL Indexing and Tuning
This is an online ebook / site explaining SQL indexing to developers’no crap about administration. SQL indexing is the most effective tuning method-yet it is often neglected during development. Use The Index, Luke explains SQL indexing from grounds up and doesn’t stop at ORM tools like Hibernate.
SQL performance problems are as old as SQL itself’some might even say that SQL is inherently slow. Although this might have been true in the early days of SQL, it is definitely not true anymore. Nevertheless SQL performance problems are still commonplace. How does this happen?
The SQL language is perhaps the most successful fourth-generation programming language (4GL). Its main benefit is the capability to separate ‘what’ and ‘how’. An SQL statement is a straight description what is needed without instructions as to how to get it done.
The SQL query reads like an English sentence that explains the requested data. Writing SQL statements generally does not require any knowledge about inner workings of the database or the storage system (such as disks, files, etc.). There is no need to tell the database which files to open or how to find the requested rows. Many developers have years of SQL experience yet they know very little about the processing that happens in the database.
The separation of concerns’what is needed versus how to get it-works remarkably well in SQL, but it is still not perfect. The abstraction reaches its limits when it comes to performance: the author of an SQL statement by definition does not care how the database executes the statement. Consequently, the author is not responsible for slow execution. However, experience proves the opposite; i.e., the author must know a little bit about the database to prevent performance problems.
It turns out that the only thing developers need to learn is how to index. Database indexing is, in fact, a development task. That is because the most important information for proper indexing is not the storage system configuration or the hardware setup. The most important information for indexing is how the application queries the data. This knowledge-about the access path-is not very accessible to database administrators (DBAs) or external consultants. Quite some time is needed to gather this information through reverse engineering of the application: development, on the other hand, has that information anyway.
This book covers everything developers need to know about indexes’and nothing more. To be more precise, the book covers the most important index type only: the B-tree index.