33.2. Expressions and Unnested Queries
Despite the fact that this book is devoted to fancy queries and programming tricks, the truth is that most real work is done with very simple logic. The better the design of the database schema, the easier the queries will be to write.
Here are some tips for keeping your query as simple as possible. Like all general statements, these tips will not be valid for all products in all situations, but they are how the smart money bets. In fairness, most optimizers are smart enough to do many of these things internally today.
33.2.1. Use Simple Expressions
Where possible, avoid JOIN conditions in favor of simple search arguments, called SARGs in the jargon. For example, let’s match up students with rides back ...
Get Joe Celko's SQL for Smarties, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.