Chapter 3 - Lesson 1 Flashcards
What is a searched argument?
A column used in the where clause without manipulation is caled a searched argument
Why is it important to use searched arguments?
Because sql server otherwise will not use indexes to search for that argument and perform instead a table scan, which is slow.
Is this a searched argument? WHERE COALESCE(e.region,' ' ) <> 'wa'
no, Because Coalesce is performed on each row, sql server will not use a possible index on that column.
How can i make region in COALESCE(e.region,’ ‘ ) <> ‘wa’ a searched argument and still get the same rows back?
WHERE e.region <> ‘wa’ OR e.region IS NULL
Is shipped date a sa? WHERE COALESCE(shippeddate, '19000101') = COALESCE(@DT, '19000101');
Becasuse we are manipulating it with COALESCE, preventing sql server from using indexes.
How can i solve the problem that COALESCE(shippeddate, ‘19000101’) = COALESCE(@DT, ‘19000101’) is not a searched argument?
WHERE shippeddate = @DT OR (shippeddate IS NULL AND @DT IS NULL)
What is the precedence when it comes to logical operators AND , OR and NOT and the parentheses(pr. parentesees)?
- ()
- 2.NOT
- 3.AND
- 4.OR
Why will the follwoing predicate influence the performance of a query, suppose u know that lastname is nvarchar?
– WHERE lastname = ‘Davis’;
Now the column lastname is not a searched argument anymore because of the (manupulation) implicit convertion to varchar, so no index will be used.
What rule do you have to follow when it comes to wild cards to not influence the performance?
never use the wildcard at the beginning of the charachters, because your column will not be a searched argument anymore
Which one is a sa?
cl1 like ‘%ABC%’ is not good, like ‘ABC%’
the second
What is the form of a filter predicate that can rely on index ordering called?
A search argument, or SARG, for short.
What is the standard way(style) to compare dates?
‘yyyymmdd’
Why is the use of between when comparing dates not recommended?
‘20071231’ and ‘20071231 23:59:59.999’ will also.
get records of 1 jan 2008
Hoe bepaalt sql server wat de stijl is van een gegeven literal bijvoorbeeld ‘25-08-1983’?
Dit is afhankelijk van je taal instelling!
Welke form van date is niet afhankelijk van je taal instelling?
‘yyyymmdd’ oftewel ‘19832508’.