The Where Clause


The previous chapter explored the index structure and discussed the cause of poor index performance. In the next step, we learn how to spot these causes in SQL statements. First, looking at the where clause.

The where clause defines the search condition of an SQL statement, and thus falls into the core domain of an index: finding data quickly. Although the where clause has a huge impact on performance, it is often phrased carelessly so that the database has to scan a large part of the index. That means, a badly written where clause adds the first ingredient to a slow query.

This chapter explains how different operators affect index usage and how to make sure that an index is usable for many queries. The last section presents common anti-patterns and alternatives that deliver better performance.

Recent Questions at Ask.Use-The-Index-Luke.com

0
votes
1
answer
277
views

Updating multiple rows using a subquery in SQL

Jan 08 at 09:52 Jan 26
subquery update sql
1
vote
1
answer
210
views

Should 'id' (the primary key) be included in an index

Jan 03 at 15:24 Jan 26
index include
0
votes
1
answer
227
views

Best index for a multiple join-tables and filter

Jan 03 at 14:31 Markus Winand ♦♦ 216
index join where