work with sql from version 2000download.microsoft.com/documents/hk/technet/techdays2013...work with...
TRANSCRIPT
![Page 1: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/1.jpg)
![Page 2: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/2.jpg)
![Page 3: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/3.jpg)
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
![Page 4: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/4.jpg)
![Page 5: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/5.jpg)
![Page 6: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/6.jpg)
![Page 7: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/7.jpg)
- 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
![Page 8: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/8.jpg)
Up to 1000 rows per operation
Row mode 1 row per operation
Batch Mode Less CPU usage
![Page 9: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/9.jpg)
![Page 10: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/10.jpg)
![Page 11: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/11.jpg)
Pros Less CPU time
Row mode requires to read metadata
every single one operation
Cons Batch mode requires larger memory size
![Page 12: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/12.jpg)
MAXDOP > 1
Outer Join
IN
DOs
DON’Ts NOT IN UNION ALL
HASH JOIN Hint
EXISTS
![Page 13: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/13.jpg)
![Page 14: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/14.jpg)
![Page 15: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/15.jpg)
![Page 16: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/16.jpg)
Segments
Minimum
Logical
Data Chunk 1 million rows
Meta data Max ValueMin Value
![Page 17: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/17.jpg)
Storage Engine
Check Filter Condition
Check Meta Data
Eliminate unnecessary segments
![Page 18: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/18.jpg)
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
![Page 19: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/19.jpg)
xEvent
column_store_segment_eliminate
Debug Channel
Attention:
Number of events
Size of xel file
Trace Flag 646
Undocumented
But
found in Technet site…
![Page 20: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/20.jpg)
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
![Page 21: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/21.jpg)
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
![Page 22: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/22.jpg)
![Page 23: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/23.jpg)
![Page 24: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/24.jpg)
Nightly Load Scenario
Drop-Rebuild Strategy
Common in BI space
Data
Warehouse Data Mart
Required Fast Parallel Columnstore Index Builds
![Page 25: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/25.jpg)
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)
![Page 26: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/26.jpg)
8657/8658 Error
![Page 27: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/27.jpg)
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.
![Page 28: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/28.jpg)
8657/8658 Error
Increase RESOURCE GOVERNOR Default Pool Setting
REQUEST_MAX_MEMORY_GRANT_PERCENT= 25% (Should be <=50%)
![Page 29: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/29.jpg)
![Page 30: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/30.jpg)
Partitioned Table Scenario Switch Partition Strategy
Improvement for avoiding DDL Starvation
![Page 31: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/31.jpg)
![Page 32: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/32.jpg)
![Page 33: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/33.jpg)
![Page 34: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/34.jpg)
![Page 35: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/35.jpg)
![Page 36: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/36.jpg)
![Page 37: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/37.jpg)
![Page 38: Work with SQL from Version 2000download.microsoft.com/documents/hk/technet/techdays2013...Work with SQL from Version 2000 OLTP/ BI Database Design and Code Review Performance Tuning](https://reader033.vdocuments.net/reader033/viewer/2022042109/5e89006dc5b84e33a32a56f4/html5/thumbnails/38.jpg)