Professional Documents
Culture Documents
Session
SQL
SQLProcessor
Processor
MDX
Request SQLScript …
Processing
Metadata Manager
Transaction Manager
Optimizer & Plan Generator, Execution Control
Logs Data
© 2012 SAP AG. All rights reserved. 4
SAP HANA Technology Innovation
+
+
T
+ +
+
Column and Insert only Minimal Text Retrieval &
No aggregates
row store on change projections Exploration
t A P
Analytics on Multi-core/ Multi-threading In-memory Active/passive
historical data parallelization within nodes Compression & data aging
SQL
+ + + x
1000x
100x
1 TB ~ $10K
10x
1 core 2 cores 8 cores -16 threads / CPU More cores, bigger caches
32 bits 2 CPUs per server 4 CPUs per server 16 ... 64 CPUs per server
4MB External Controllers On-chip memory control Greater on-chip integration
Quick interconnect (PCIe, network, ...)
VM and vector support Data-direct I/O
64 bits; 256 GB - 1 TB Tens - hundreds of TBs
L2 Westmere-EX
L3 L2
10 cores =
20 threads
ALU
L1
State of the art: pipelined cores w 256KB L2 cache; 30MB shared L3 cache
Hyper-threading: Sharing of one ALU between two threads; the chip handles the cycle-level
task-switching (when a thread is stalled, typically when it waits for memory)
Client
Application
Database
Server
t
1980 1990 2000 2010
© 2012 SAP AG. All rights reserved. 12
Database Evolution
Over time, a separate “application server” tier, processing the data
from the DB, was introduced; the web popularized this architecture
Client
(web)
App Server
Database
Server
t
1980 1990 2000 2010
© 2012 SAP AG. All rights reserved. 13
Database Evolution
Bigger and bigger datasets forced the introduction of separate,
specialized “Data Warehouses”, used for analytic processing (OLAP)
Client Analytic
(web) Client
Transaction Data
Server Warehouse
Data
transformation
and aggregation
t
1980 1990 2000 2010
© 2012 SAP AG. All rights reserved. 14
Opportunity: Eliminate Compute Tier Overhead
Using in-memory computing, SAP HANA offers a vision of simplicity
and integration, pushing data-intensive operations into the data layer
Data
Client
App Server
SAP HANA
t
1980 1990 2000 2010
© 2012 SAP AG. All rights reserved. 15
Elements of HANA
Performance
DBs typically use a row-based storage; SAP HANA supports rows, but
is optimized for column-order data organization
Single-record access:
456 France corn 1000 SELECT * FROM SalesOrders
wheat WHERE Order = „457‟
457 Italy 900
458 Italy corn 600 Single-scan aggregation:
459 Spain rice 800 SELECT Country, SUM(sales) FROM
SalesOrders WHERE Product=„corn‟
Column order organization GROUP BY Country
4
…
A B $A$B$
0 2 4 2;4
1 3 5 3;5
2 2 6 2;6
3 3 7 3;7
From Indexes in “HANA Column Store, Muddles & Dissolutions”, Sascha Schwedes, 2011-11-18
© 2012 SAP AG. All rights reserved. 20
Elimination of Aggregates
Column Row
Analytic (OLAP) performance
Strengths: In-memory data compression Single transaction (OLTP) performance
Parallel aggregations In-place updates, no delta merges
Administrative simplicity
Short-running query overhead
Weak Little data compression
High cost for SELECT *…
nesses: Needs indexes for fast data access
Delta merge for updates
Concurrent users
Concurrent POPs (Plan Operations) within a query
Data partitioning, on one host quant. type sales
or distributed to multiple hosts 150 43 $1000
60 12 $900
Horizontal and vertical core
100 12 $600
parallelization of a single query 3
45 33 $800
operation, using multiple 75 33 $500
84 12 $750
cores / threads
96 32 $600
162 43 $600 core
Transparent to app developer 45 12 $1100 4
366 33 $450
$2000
core core
1 2
Dimension A Dimension B
Dimension Key Dimension Key
Attribute 1 Attribute 1
Attribute 2 Attribute 2
Attribute ... Attribute ...
Fact Table
Primary Key
Foreign Key A
Foreign Key B
Foreign Key C
Foreign Key D
Fact 1
Dimension D Dimension C
Fact 2
Dimension Key Dimension Key
Fact …
Attribute 1 Attribute 1
Attribute 2 Attribute 2
Attribute ... Attribute ...
HANA Studio
– Admin perspective, Performance Tab
o Expensive SQL statements
o Active Threads
o SQL Plan Cache
o Load graph
– Monitoring Views
o M_EXPENSIVE_STATEMENTS, M_MUTEXES, M_DELTA_MERGE_STATISTICS ,
M_CONNECTIONS, M_SQL_PLAN_CACHE, …
– Execution Plan
– Execution Plan Visualization ( in SPS4, from V25)
– SQL Trace
Qpic Query Performance ( May 2012, internal only)
http://www.creattor.com/vectors/toolbox-79
© 2012 SAP AG. All rights reserved. 28
HANA Studio
Active Threads
System Load
Expensive Statements
CTRL-SHIFT-Z
Column
or row?
Operator HDB
Main estimates Beware
operation details of row!
the relative
cost
*Example uses the “gary1.sql” query
© 2012 SAP AG. All rights reserved. 33
Studio: Plan Visualization
Linux
Physical Memory & other
programs
Allocation Limit
pre
GBytes allocated
Used
Memory
HANA
code &
used by your data stack
Limit SQL Query
Allocation Limit Allocation Limit
SELECT HOST, round(ALLOCATION_LIMIT/1024 /1024) AS "Allocation Limit MB"
FROM PUBLIC.M_HOST_RESOURCE_UTILIZATION
Used Memory Total used memory SELECT round(sum(TOTAL_MEMORY_USED_SIZE/1024/1024)) AS "Total Used MB"
FROM SYS.M_SERVICE_MEMORY;
– of which, code and Code and stack size SELECT round(sum(CODE_SIZE+STACK_SIZE)/1024/1024) AS "Code+stack MB"
FROM SYS.M_SERVICE_MEMORY;
stack size Total memory consumption SELECT round(sum(MEMORY_SIZE_IN_TOTAL)/1024/1024) AS "Column Tables MB"
– of which, space used of all columnar tables FROM M_CS_TABLES;
Total memory consumption SELECT round(sum(USED_FIXED_PART_SIZE + USED_VARIABLE_PART_SIZE)/1024/1024)
by Column Tables of all row tables AS "Row Tables MB" FROM M_RS_TABLES;
– of which, space used Total memory consumption
of all columnar tables by
SELECT SCHEMA_NAME AS "Schema", round(sum(MEMORY_SIZE_IN_TOTAL) /1024/1024)
by Row Tables AS "MB" FROM M_CS_TABLES GROUP BY SCHEMA_NAME ORDER BY "MB" DESC;
schema
List all columnar tables of SELECT TABLE_NAME AS "Table", round(MEMORY_SIZE_IN_TOTAL/1024/1024, 2)
Column tables schema 'SYSTEM' AS "MB" FROM M_CS_TABLES WHERE SCHEMA_NAME = 'SYSTEM' ORDER BY "MB" DESC;
Show column details of table SELECT COLUMN_NAME AS "Column", LOADED AS "Is Loaded",
– Show utilization & "LineItem" in schema round(UNCOMPRESSED_SIZE/1024/1024) AS "Uncompressed MB",
compression ratio of "SYSTEM" round(MEMORY_SIZE_IN_MAIN/1024/1024) AS "Main MB",
round(MEMORY_SIZE_IN_DELTA/1024/1024) AS "Delta MB",
a column table round(MEMORY_SIZE_IN_TOTAL/1024/1024) AS "Total Used MB",
round(COMPRESSION_RATIO_IN_PERCENTAGE/100, 2) AS "Compr. Ratio"
FROM M_CS_Columns WHERE TABLE_NAME = 'LINEITEM';
List all row tables of schema SELECT SCHEMA_NAME, TABLE_NAME, round((USED_FIXED_PART_SIZE +
Row tables ‘SYS’ by descending size USED_VARIABLE_PART_SIZE)/1024/1024, 2) AS "MB Used" FROM M_RS_TABLES
WHERE schema_name = 'SYS' ORDER BY "MB Used" DESC, TABLE_NAME
5. project
2. join
1. predicates
3. aggregate
4. sort
Execution Plan
5
4
3
2
1
Source: demo/saph_q5
© 2012 SAP AG. All rights reserved. 41
SAP-H Q5: The Performance and Trace Graphs
join aggregate
Source: demo/saph_q5
© 2012 SAP AG. All rights reserved. 42
How to use
Step 1
Enter server
info
Step 2
Step 3
Enter HDB
view results
info & SQL
is slower than:
SELECT * FROM T
WHERE date_string < TO_CHAR(CURRENT_DATE, 'YYYYMMDD’)
INNER JOIN keys ON cust.hkey = keys.hkey INNER JOIN keys ON cust.hkey = keys.hkey
WHERE cust.id IN ( INNER JOIN keys AS tempkeys
SELECT DISTINCT cust.id ON cust.hkey = tempkeys.hkey
FROM cust
LEFT OUTER JOIN keys
ON cust.hkey = keys.hkey
WHERE cust.is_best = 1 WHERE cust.is_best = 1
AND keys.sourcesys = 'ORACLE‟ AND tempkeys.sourcesys = 'ORACLE„
)
GROUP BY keys.sourcesys GROUP BY keys.sourcesys
ORDER BY cnt_alias DESC; ORDER BY cnt_alias DESC;
Data
© 2012 SAP AG. All rights reserved. Slide inspiration: San Tran, Sven-Eric Eigemann,&Holger Graeber,
50
HANA Performance Information Sources
Communities Internal
HANA PM Notifications https://community.wdf.sap.corp/sbs/groups/pm-hana-communications
Database Technology / HANA https://community.wdf.sap.corp/sbs/community/dt/hana
Building HANA Apps & Round Table https://community.wdf.sap.corp/sbs/community/in-memory-apps
Oliver Frick, Hermann Gahm: How To Analyze the Root Cause of Poor Query http://bit.ly/J9KatJ
Performance (Nov 11)
Shel Finkelstein‟s lecture: Guidelines for Applications on HANA (Mar 12) https://community.wdf.sap.corp/sbs/docs/DOC-115494
San Tran: Best Practices on HANA Modeling for OLAP Scenarios (2011) https://community.wdf.sap.corp/sbs/docs/DOC-117335
San Tran: HANA Content Modeling with Performance Aspects (Oct 11) https://community.wdf.sap.corp/sbs/message/221454#221454
Sang Yong Wang: SQL query transformations in HANA (Feb 11) https://wiki.wdf.sap.corp/wiki/display/ngdb/SQL+query+transformation
HANA help: Dev Guide (Best Practices), SQL ref guide and SQLScript (May 12) http://help.sap.com/hana_appliance/
Sven-Eric Eigemann, Holger Graeber, HANA Performance Project (Dec 11) http://bit.ly/IPdSpn
Sang Yong Wang: SQL tuning tips for the column engine (Aug 11) https://wiki.wdf.sap.corp/wiki/display/ngdb/SQL+query+tuning+tips+for+column+engine
Qpic Installation and Reference Guide / how to start with QPic Email: Chaim.Bendelac@sap.com
Take advantage!
HANA
© 2012 SAP AG. All rights reserved. 53
Thank You!
SAP HANA