Presentation is loading. Please wait.

Presentation is loading. Please wait.

# - it’s not about social media it’s about temporary tables and data

Similar presentations


Presentation on theme: "# - it’s not about social media it’s about temporary tables and data"— Presentation transcript:

1 # vs @ - it’s not about social media it’s about temporary tables and data
=tg= Thomas Grohser, NTT Data SQL Server MVP SQL Server Performance Engineering Pittsburgh, PA 9/30/2017

2 select * from =tg= where topic =
Remark SQL 4.21 First SQL Server ever used (1994) SQL 6.0 First Log Shipping with failover SQL 6.5 First SQL Server Cluster (NT4.0 + Wolfpack) SQL 7.0 2+ billion rows / month in a single Table SQL 2000 938 days with 100% availability SQL 2000 IA64 First SQL Server on Itanium IA64 SQL 2005 IA64 First OLTP long distance database mirroring SQL 2008 IA64 First Replication into mirrored databases SQL 2008R2 IA64 SQL 2008R2 x64 First 256 CPUs & > STMT/sec First Scale out > STMT/sec First time 1.2+ trillion rows in a table SQL 2012 > Transactions per second > 1.3 Trillion Rows in a table SQL 2014 > Transactions per second Fully automated deploy and management SQL 2016 AlwaysOn Automatic HA and DR, crossed the PB in storage SQL vNext Can’t wait to push the limits even further =tg= Thomas Grohser, NTT DATA Senior Director Technical Solutions Architecture / Focus on SQL Server Security, Performance Engineering, Infrastructure and Architecture Wrote some of Close Relationship with SQLCAT (SQL Server Customer Advisory Team) SCAN (SQL Server Customer Advisory Network) TAP (Technology Adoption Program) Product Teams in Redmond Active PASS member and PASS Summit Speaker 23 Years with SQL Server

3 What is the difference between @ and #?
29 SELECT - ASCII('#')

4 Source Temporary Target
Repeatable

5 How to measure performance
Time to read source(s) n x sources Time to create temp table 1 x Time to insert into temp table n x sources Time to modify temp table 1 x Time to read temp table n x targets Time to insert into target(s) n x targets

6 Options for Temporary Tables
AS TABLE (…); @Table CREATE #TableName (…); #Table CREATE ##TableName (…); ##Table Use TempDB; CREATE TableName (…); TinTDB CREATE TABLE TableName ( … ) WITH ( MO MEMORY_OPTIMIZED=ON, DURABILITY=SCHEMA_ONLY); CREATE TABLE TableName ( … ) WITH ( MOD DURABILITY=SCHEMA_AND_DATA); Use MyDatabase; CREATE TABLE … UT

7 Indexes @Table Yes during declaration only
DEMO @Table Yes during declaration only #Table Yes (Clustered, Non Clustered, Filtered) ##Table Yes (Clustered, Non Clustered, Filtered) TinTDB Yes (Clustered, Non Clustered, Filtered) MO Yes (Hash and BTree) MOD Yes (Hash and BTree) UT Yes (Clustered, Non Clustered, Filtered, Special)

8 Scope / Isolation / Durability
@Table Current Batch Yes None #Table Current Session Yes None ##Table Global No None TinTDB Global No None MO Global No None MOD Global No Yes UT Global No Yes DEMO

9 Create Table Triggers Recompilation
@Table No #Table Yes ##Table Yes TinTDB Yes MO Yes MOD Yes UT Yes

10 Statistics @Table No #Table Yes ##Table Yes TinTDB Yes MO Yes MOD Yes
UT Yes Cardinality is assumed to be 30% of row count Same problems as with normal tables that update statistics might not be triggered depending on number of rows added/changed Manual Update Statistics can happen

11 Commit / Rollback supported
@Table Yes No #Table Yes Yes ##Table Yes Yes TinTDB Yes Yes MO Yes Yes MOD Yes Yes UT Yes Yes DEMO

12 Truncate table @Table No #Table Yes ##Table Yes TinTDB Yes
MO No (but DELETE is super fast) MOD No (but DELETE is super fast) UT Yes

13 Transaction Log IO @Table None #Table Reduced (no recovery needed)
TinTDB Reduced (no recovery needed) MO None MOD Optimized UT Yes TempDB Your DB

14 Locking and Blocking @Table No #Table No ##Table Yes TinTDB Yes
MO No (retry logic for updates/deletes) MOD No (retry logic for updates/deletes) UT Yes

15 Performance Read Write @Table Fast Fast #Table Fast OK ##Table Fast OK
TinTDB Fast OK MO Fastest Fastest MOD Fastest Very Fast UT Fast Slowest

16 Create Table Time @Table µs #Table ms ##Table ms TinTDB ms MO seconds
MOD seconds UT ms

17 Alternative Option

18 CTE – Common Table Expression
DEMO WITH tempName AS ( SELECT … ) Do Something with tempName

19 Summary @Table small datasets in procedures,
logging of transaction steps #Table all other cases ##Table sharing temp data between processes TinTDB just don’t do/use it MO staging if source grab is repeatable high frequency MOD staging if source grab is not repeatable UT only is in memory is not available

20 THANK YOU! and may the force be with you…
Questions? (9 to 5 5 days a week :-) (24x7)


Download ppt "# - it’s not about social media it’s about temporary tables and data"

Similar presentations


Ads by Google