Indexing Beyond the Basics

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Hi! I'm Tobias Petry, a full stack developer who used to suck at writing fast database queries. Whenever I had a slow query, I needed to ask more advanced developers for help and hope they had time for me. Like everyone, I always wished I could solve those problems on my own. But even after reading some tutorials I didn't get any closer to my goal. The number of queries I couldn't optimize by far exceeded the ones I could make faster. So I learned everything about databases over the next 10+ years from countless books, conferences, trainings, articles and much practice. Finally, I could fix any slow query entirely without help. But during my consulting work I found that most developers still face the same problem. The reason database indexes are still not understood by developers is the depth of the existing content. Whether it is books, articles or videos - they all have their own problems that limit the ability to understand database indexing. Blog articles and Youtube videos explain indexes by short examples on the most trivial problems (e.g. a missing single-column index) and won't go in-depth any further. But the minimal knowledge learned from these examples cannot be applied to your more complex queries. However, published books are written for database administrators (DBA) and teach everything from backup approaches over complex database internals to obscure tuning settings that make it hard for developers to get actionable advice. Most likely, you have already stopped reading at least one of these books with 500+ pages because they include too many topics you are not interested in. In the end, database indexes were only covered on a few pages and are not sufficiently explained because the target audience of these books is interested in other topics. Who is this book for? You are a developer who can write SQL queries but struggle with creating the correct indexes to make them fast. Neither do you have the time or interest to learn this topic in weeks - a couple evenings on the couch should be enough. You also just want to learn the practical knowledge necessary to complete your task and move on to other things. The content should avoid any technical complex database implementation details - you want the core information quickly, concisely and understandably.

Author(s): Tobias Petry
Publisher: Independently Published
Year: 2023

Language: English
Pages: 85

Contents
Preface
Why You Didn't Understand Indexes Until Now
1. Fundamentals
1.1 A Different View on B+ Trees
1.2 The Interaction of Indexes and Tables
2. Index Access Principles
2.1 Principle 1: Fast Lookup
2.2 Principle 2: Scan in One Direction
2.3 Principle 3: From Left To Right
2.4 Principle 4: Scan On Range Conditions
3. Index Supported Operations
3.1 Inequality (!=)
3.2 Nullable Values (IS NULL and IS NOT NULL)
3.3 Pattern Matching (LIKE)
3.4 Sorting Values (ORDER BY)
3.5 Aggregating Values (DISTINCT and GROUP BY)
3.6 Joins
3.7 Subqueries
3.8 Data Manipulation (UPDATE and DELETE)
4. Why Isn’t the Database Using My Index?
4.1 The Index Can’t Be Used
4.2 No Index Will Be the Fastest
4.3 Another index is faster
5. Pitfalls and Tips
5.1 Indexes on Functions
5.2 Boolean Flags
5.3 Transforming Range Conditions
5.4 Leading Wildcard Search
5.5 Type Juggling
5.6 Index-Only Queries
5.7 Filtering and Sorting With Joins
5.8 Exceeding the Maximum Index Size
5.9 JSON Objects and Arrays
5.10 Unique Indexes and Null
5.11 Location-Based Searching With Bounding-Boxes