Avoiding the Full-Table Scan

A full-table scan occurs when the database server reads every record in a table in order to execute a SQL statement. Full-table scans are normally an issue when dealing with queries or the SELECT statement. However, a full-table scan can also come into play when dealing with updates and deletes. A full-table scan occurs when the columns in the WHERE clause do not have an index associated with them. A full-table scan is like reading a book from cover to cover and trying to find a keyword. Most often, you will opt to use the index.

You can avoid a full-table scan by creating an index on columns that are used as conditions in the WHERE clause of a SQL statement. Indexes provide a direct path to the data the same way ...

Get Sams Teach Yourself SQL in 21 Days, Fourth 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.