SQL Server - Inside Optimizer Engine

Preview:

Citation preview

Inside SQL Server Optimizer

By Hamid Jabarpour Fard

Hamid Jabarpour Fard Consultant / Author / Trainer / Speaker Data Platform Specialist, Fard Solutions Sdn. Bhd.

Email: Hamid@Fard-Solutions.com Website: http://www.Fard-Solutions.com

AgendaOptimizer Limitations with Filtered IndexesForcing a Parallel Query Execution PlanStatistics on Ascending ColumnsQuestions and Answers15 Minutes Break

Optimizer Limitations with Filtered Indexes

Demo

Optimizer Limitations with Filtered IndexesConclusion

Redundant join predicates can be necessary to match filtered indexes.

Filtered unique indexes do not provide uniqueness information to the optimizer.

In some cases it may be practical to simply add the redundant predicates to every query.

Forcing a Parallel Query Execution Plan

Demo

Forcing a Parallel Query Execution PlanConclusion

Below actions make serial plan in SQL ServerTable variable’s content modification.Any T-SQL scalar function.CLR scalar functions marked as performing data

access.Random intrinsic functions including

OBJECT_NAME, ENCRYPTBYCERT and IDENT_CURRENT.System table access. (e.g. sys.tables)TOPSequence Project (e.g. ROW_NUMBER, RANK)Recursive CTEs

Forcing a Parallel Query Execution Plan (Cont.)

ConclusionEven experts with decades of SQL Server

experience and detailed internal knowledge will want to be careful with trace 8649 flag.

Statistics on Ascending Columns

Demo

Statistics on Ascending Columns

ConclusionThis is just an alternative way to fix a problem that

is seen with large tables with ascending columns.The best solution is to update statistics

periodically.Trace flag 2389 will work only for columns branded

as ascending.Trace flag 2390 does not make sense to do so

because it will stop working when the column turns out to be ascending.

Questions and Answers

?

Thanks For Attending This

Event.

Recommended