12
Inside SQL Server Optimizer By Hamid Jabarpour Fard

SQL Server - Inside Optimizer Engine

Embed Size (px)

Citation preview

Page 1: SQL Server - Inside Optimizer Engine

Inside SQL Server Optimizer

By Hamid Jabarpour Fard

Page 2: SQL Server - Inside Optimizer Engine

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

Email: [email protected] Website: http://www.Fard-Solutions.com

Page 3: SQL Server - Inside Optimizer Engine

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

Page 4: SQL Server - Inside Optimizer Engine

Optimizer Limitations with Filtered Indexes

Demo

Page 5: SQL Server - Inside Optimizer Engine

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.

Page 6: SQL Server - Inside Optimizer Engine

Forcing a Parallel Query Execution Plan

Demo

Page 7: SQL Server - Inside Optimizer Engine

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

Page 8: SQL Server - Inside Optimizer Engine

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.

Page 9: SQL Server - Inside Optimizer Engine

Statistics on Ascending Columns

Demo

Page 10: SQL Server - Inside Optimizer Engine

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.

Page 11: SQL Server - Inside Optimizer Engine

Questions and Answers

?

Page 12: SQL Server - Inside Optimizer Engine

Thanks For Attending This

Event.