Infrastructure as (real) Code – Manage your K8s resources with Pulumi
Hekaton & CSI Version 2 unter der Lupe
1. SQL 2014 CTP1
Hekaton & CSI Version 2 unter der Lupe
Sascha Götz
Karlsruhe, 03. Dezember 2013
2. 2
“Most of today’s database managers are built on the
assumption that data lives on a disk, with little bits of
data at a time loaded into memory for manipulation.
There’s a whole lot of infrastructure involved in paging
those subsets of data in and out[…]”
- Kevin Farlee, SQL Server program manager, Microsoft -
SQL 2014 CTP1
Hekaton – Memory optimized tables
4. 4
SQL 2014 CTP1
Hekaton – Memory optimized tables
SQL Server
Memory
Disk
Query
Cache
File
group
Index
Paging
Memory-OptimizedDisk-Based
Synchronisation
Index
Locking
Disk
(Memory Dump)
5. 5
‣ Filegroup hinzufügen
ALTER DATABASE [AdventureWorksDW2012]
ADD FILEGROUP [Hekaton_FG]
CONTAINS MEMORY_OPTIMIZED_DATA
GO
‣ Datafile hinzufügen
ALTER DATABASE [AdventureWorksDW2012]
ADD FILE ( NAME = N'Hekaton', FILENAME = N'C:Hekaton.ndf')
TO FILEGROUP [Hekaton_FG]
GO
SQL 2014 CTP1
Hekaton – Memory optimized tables
6. 6
CREATE TABLE [dbo].[FactInternetSales_Hekaton]
(
[ProductKey] [int] NOT NULL,
[OrderDateKey] [int] NOT NULL,
[...],
)
WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA)
‣ DURABILITY:
‣ SCHEMA_AND_DATA
‣ Schema und Daten werden mit Disk synchronisiert
‣ Speicherplatz wird im RAM und auf Disk benötigt
‣ SCHEMA_ONLY
‣ Nur Schema wird mit Disk synchronisiert
SQL 2014 CTP1
Hekaton – Memory optimized tables
7. 7
‣ Natively Compiled Stored Procedure
CREATE PROCEDURE <Schema_Name, sysname, dbo>.<Procedure_Name, sysname,
Procedure_Name>
-- Add the parameters for the stored procedure here
[…]
WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER
AS BEGIN ATOMIC WITH
--Insert statements for the stored procedure here
[…]
END
‣ Nur Abfrage auf In-Memory Tabellen
SQL 2014 CTP1
Hekaton – Memory optimized tables
8. 8
‣ Index
‣ Memory Optimized tables müssen mindestens einen Index haben (auf PK)
‣ Keine Clustered Indizes
‣ Indexe werden nur im Speicher gehalten
‣ Kein Index Drop, Rebuild
‣ Max. 8 Index pro Tabelle
SQL 2014 CTP1
Hekaton – Memory optimized tables
CI Date
1 11.11.13
2 12.11.13
3 13.11.13
4 14.11.13
5 15.11.13
6 16.11.13
7 17.11.13
Date
13.11.13
16.11.13
14.11.13
17.11.13
15.11.13
11.11.13
12.11.13
Non-CI
1
2
3
4
5
6
7
I1 I2 … I8 Date Order# …
3 6 13.11.13 98165
6 2 16.11.13 98121
4 1 14.11.13 98474
7 3 17.11.13 98521
5 4 15.11.13 98451
1 5 11.11.13 98514
2 7 12.11.13 98563
9. 9
‣ Limitations
‣ Keine Trigger
‣ Keine Foreign Key & Constraints
‣ Keine Identity columns
‣ Keine Schema changes (ALTER TABLE…)
SQL 2014 CTP1
Hekaton – Memory optimized tables
17. 17
Non-Clustered
Columnstore Index
(SQL Server 2012)
• (+) Performance
• (+) Easy-To-Use
• (-) Read-Only
Clustered
Columnstore Index
(SQL Server 2014 CTP 1)
• (+) Performance
• (+) Easy-To-Use
• (+) Updateable
• (-) Keine PK & FK
• (-) Keine Constraints
SQL 2014 CTP1
Columnstore Index
18. 18
106
71
9
1
0
20
40
60
80
100
120
1
Aggregierung (SUM & Group BY) über 25 Mio Datensätze
Ohne Index Non-Clustered Index Non-Clustered Columnstore Index Clustered Columnstore Index
SQL 2014 CTP1
Columnstore Index
DauerinSekunden
19. 19
SQL 2014 CTP1
Columnstore Index
20
23
27
0
5
10
15
20
25
30
1 Mio. Datensätze Load
Ohne Index Non-Clustered Index Non-Clustered Columnstore Index Clustered Columnstore Index
Nichtmöglich
DauerinSekunden
20. Szenario: 25 Mio Datensätze, Non-Clustered CSI, 1 Mio Datensätze Load 20
‣ Daten doch Laden bei Non-Clustered Columnstore Index?
‣ Drop, Load and Rebuild
‣ Partition Swap
SQL 2014 CTP1
4
20
103
1
20
5
1
Columnstore Index
Split Load Build Swap
Drop Load Build