Skip to product information
1 of 1

More SQL Antipatterns

Regular price $49.95
Sale price $49.95 Regular price $49.95
Sale Sold out
Don't make the mistakes most people make when optimizing your database.It’s easy to get something working with SQL but getting it working well requires skill and experience. Rather than learning by...
Read More
  • Format:
  • 14 July 2026
View Product Details

Don't make the mistakes most people make when optimizing your database.


It’s easy to get something working with SQL but getting it working well requires skill and experience. Rather than learning by trial and error, let renowned database expert Bill Karwin give you the benefit of his years of experience as he shows you the mistakes people make and how to fix them.


Dig into SQL language issues rarely covered in other books. Learn advanced queries such as relational division, efficient pagination, and pivoting. Explore tradeoffs in optimization, including denormalization, JSON, and choosing SQL versus NoSQL. Turn mistakes into successes by employing SQL in application design: transactions, polling, and object-relational mapping. Finally, take a deep dive into scaling out with sharded databases.


This book contains fourteen all-new topics, making it a valuable complement to SQL Antipatterns Volume 1. In each chapter, you’ll learn how to recognize one type of common pitfall, and how to solve it. Examples use the current popular combination of PostgreSQL and Python, but the principles apply to any modern database and language. Like the first volume, this book also includes a selection of mini-antipatterns, or brief tips you can use for quick wins.


Optimize SQL the right way and graduate from journeyman to senior database developer.

files/i.png Icon
Price: $49.95
Pages: 224
Publisher: The Pragmatic Programmers
Imprint: Pragmatic Bookshelf
Publication Date: 14 July 2026
Trim Size: 9.25 X 7.50 in
ISBN: 9798888652060
Format: Paperback
BISACs:

COMPUTERS / Database Administration & Management, Database programming, COMPUTERS / Languages / SQL, Database software, Relational databases

Bill Karwin has been a software engineer for more than 30 years, developing and supporting applications, libraries, and servers, and consulting for leading technology companies. Throughout his career, Bill has shared his knowledge to help other programmers achieve success and productivity. Bill has answered thousands of questions, giving him a unique perspective on SQL mistakes that most commonly cause problems.
  • SQL Language Antipatterns
    • Fear of JOINs
      • Objective: Combining Matching Data in Two Tables
      • Antipattern: Fearing JOINs
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Preferring JOINs
      • Mini-Antipattern: Comma-Style Join Syntax
      • Mini-Antipattern: NATURAL JOIN
    • Relational Division
      • Objective: Matching a List of Values
      • Antipattern: Searching Multiple Rows in a WHERE Clause
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Using Relational Division
      • Mini-Antipattern: Aggregation Functions in the WHERE Clause
    • Dynamic Pivot
      • Objective: Turning the Table
      • Antipattern: Using a Single Query
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Using Code to Assist
      • Mini-Antipattern: Operand Must Contain One Column
    • Pagination: Take It from the Top
      • Objective: Presenting Query Results in Pages
      • Antipattern: Mistaking Offset for Optimization
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Changing the Rules
      • Mini-Antipattern: LIMIT without ORDER BY
  • Optimization Antipatterns
    • Non-Sargable Queries
      • Objective: Optimizing Complex Queries
      • Antipattern: Using Queries That Can’t Be Optimized
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Refactoring the Query
      • Mini-Antipattern: Redundant Indexes
    • Premature Denormalization
      • Objective: Breaking the Rules to Improve Performance
      • Antipattern: Breaking the Rules Recklessly
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Breaking the Rules Carefully
      • Mini-Antipattern: Query Snipers
    • NoSQL: The Grass Is Always Greener on the Other Side
      • Objective: Relief from the Challenges of SQL
      • Antipattern: Switching to NoSQL Is Easy
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Match Your Queries to Your NoSQL Models
      • Mini-Antipattern: N+1 Queries
    • JSON: Matryoshka Dolls
      • Objective: Unlimited Flexibility
      • Antipattern: Semi-Structured Data in a Relational Database
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Be Mindful and Moderate About Flexibility
      • Mini-Antipattern: Quotes for All Occasions
    • Cacheless Transactions
      • Objective: A Magic Trick to Improve Performance
      • Antipattern: The Performance Vanishing Act
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Use Sleight of Hand
      • Mini-Antipattern: Query Caching
  • Application Design Antipatterns
    • Polling: Are We There Yet?
      • Objective: Notify of Changes to Data
      • Antipattern: Polling for Changes
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Just Wake Me Up When We Get There
      • Mini-Antipattern: Enqueuing Before Committing
    • Transaction Encapsulation
      • Objective: Transactions for Multiple Models
      • Antipattern: Every Model Class Manages Its Transactions
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Simplify, Simplify
      • Mini-Antipattern: ORMs that Pluralize Table Names
    • Fear of Deadlocks
      • Objective: Don’t See Deadlock Errors
      • Antipattern: Trying to Prevent All Deadlocks
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: Mitigate Deadlocks
      • Mini-Antipattern: Sharing Connections Between Threads
    • Data Hoarding
      • Objective: Cope with Data Bloat
      • Antipattern: The Belief That You Need All Data
      • How to Recognize the Antipattern
      • Legitimate Uses of the Antipattern
      • Solution: An Intervention to Manage Data Retention