Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with...

Preview:

Citation preview

Work with SQL from Version 2000

OLTP/ BI Database Design and Code Review

Performance Tuning

HA/DR Plan Design

Upgrade/ Migration/ Consolidation

Capacity Planning

Health Check

- Columnstore indexes store data column-wise

- Highly compressed

- Each column can be accessed independently

C1 C2 C3 C4

- Heaps, B-trees store data row-wise

Rowstore

Columnstore

Up to 1000 rows per operation

Row mode 1 row per operation

Batch Mode Less CPU usage

Pros Less CPU time

Row mode requires to read metadata

every single one operation

Cons Batch mode requires larger memory size

MAXDOP > 1

Outer Join

IN

DOs

DON’Ts NOT IN UNION ALL

HASH JOIN Hint

EXISTS

Segments

Minimum

Logical

Data Chunk 1 million rows

Meta data Max ValueMin Value

Storage Engine

Check Filter Condition

Check Meta Data

Eliminate unnecessary segments

column_id segment_id min_data_id max_data_id

1 1 20120601 20120630

1 2 20120615 20120715

1 3 20120701 20120731

1 4 20120715 20120815sys.column_store_segments

select C1, sum(C2)

from T

where C1 between 20120618 and 20120713

group by C1

Segment_id 4 can be eliminated

xEvent

column_store_segment_eliminate

Debug Channel

Attention:

Number of events

Size of xel file

Trace Flag 646

Undocumented

But

found in Technet site…

column_id segment_id min_data_id max_data_id

1 1 20120601 20120730

1 2 20120620 20120812

1 3 20120713 20120831

1 4 20120710 20120915Not Sorted Data

Data is mixed between

segments

Difficult

To

Maximize the benefit of segment elimination

select C1, sum(C2)

from T

where C1 between 20120618 and 20120713

group by C1

column_id segment_id min_data_id max_data_id

1 1 20120601 20120630

1 2 20120701 20120731

1 3 20120801 20120831

1 4 20120901 20120930Sorted Data

Clear border of Segments

Easy

To

Maximze the benefit of Segment

Elimination

Ensure data is sorted effectively Clustered Index

select C1, sum(C2)

from T

where C1 between 20120618 and 20120713

group by C1

Nightly Load Scenario

Drop-Rebuild Strategy

Common in BI space

Data

Warehouse Data Mart

Required Fast Parallel Columnstore Index Builds

DOP

Memory Size

Check sys.dm_exec_query_memory_grants

Required size in MB =

[(4.2 *Num of cols in the CS idx) + 68]*DOP + (Num of string cols * 34)

8657/8658 Error

8657/8658 Error

Msg 8657

Could not get the memory grant of %I64d KB because it exceeds the maximum

configuration limit in workload group '%ls' (%ld) and resource pool '%ls' (%ld).

Contact the server administrator to increase the memory usage limit.

Msg 8658

Cannot start the columnstore index build because it requires at least %I64d KB,

while the maximum memory grant is limited to %I64d KB per query in workload

group '%ls' (%ld) and resource pool '%ls' (%ld).

Retry after modifying columnstore index to contain fewer columns, or after

increasing the maximum memory grant limit with Resource Governor.

8657/8658 Error

Increase RESOURCE GOVERNOR Default Pool Setting

REQUEST_MAX_MEMORY_GRANT_PERCENT= 25% (Should be <=50%)

Partitioned Table Scenario Switch Partition Strategy

Improvement for avoiding DDL Starvation

Recommended