Built-in functions and indexing 

When using a built-in function in your query, the query may not use the indexes on the table. For example, the following query needs to do a full scan of the table: 

USE lahmansbaseballdb;
SELECT UPPER(playerid) as playeridupper, playerid
FROM allstarfull
WHERE upper(playerid) = 'AARONHA01';

The following screenshot shows the execution plan of the previous query: 

The following query can seek the rows that are needed: 

USE lahmansbaseballdb;
SELECT playerid FROM allstarfull
WHERE playerid = 'aaronha01';

The following screenshot shows the execution plan of the previous query: 

You can see that the query that doesn't use a built-in function in the WHERE clause performs much better than the one that does. 

Reading and running execution plans are covered in more detail in Chapter 6, Querying a Single Table, and in Chapter 7, Querying Multiple Tables

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.33.157