Weitere ähnliche Inhalte
Ähnlich wie Whats New on SAP HANA SPS 11 Core Database Capabilities (20)
Mehr von SAP Technology (20)
Kürzlich hochgeladen (20)
Whats New on SAP HANA SPS 11 Core Database Capabilities
- 1. 1© 2014 SAP AG or an SAP affiliate company. All rights reserved.
SAP HANA SPS 11 - What’s New?
HANA Core
SAP HANA Product Management December, 2015
(Delta from SPS 10 to SPS 11)
- 2. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 2Public
Agenda
Dynamic Range Partitioning
Result Cache Extension (View Cache) for SQL Views, CalcViews and CDS Views
Misc
Flexible Table enhancement, Select with Partition Restriction
- 4. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 4Public
Partitioning - Overview
Partitioning supports the creation of very large tables by decomposing them into smaller and more manageable pieces. Partitioning is
transparent for most SQL queries and Data Manipulation Language (DML) statements.
Typical use cases for partitioning
Load-balancing
Performance: parallelization, partition pruning, merge
Overcome 2 billion rows limit
Types of partitioning
Single-Level partitioning: hash, range, round-robin
Multi-Level partitioning: hash-range, hash-round-robin, hash-hash, round-robin-range, range-range
FebJan Mar
HANA Server 1
OTHERS FebJan Mar
HANA Server 2
OTHERS
- 5. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 5Public
Dynamic Range Partitioning - Overview
Before SPS11:
Active partition management for fast growing tables required (monitoring, add partition)
In case of range partitioned tables it may lead to huge OTHERS partition
As of SPS11:
allows an automatic and dynamic (via a background job) range partitioning for a table based only on the size of the OTHERS partition
can be applied to single-level range partitioned tables as well as multi-level hash-range, range-range, roundrobin-range tables
FebJan Mar
HANA Database
OTHERS FebJan Mar
HANA Database
Before SPS11
Dynamic
Part Others
As of SPS11
huge OTHERS partition dynamically added partition, keeps OTHERS partition small (user defined)
- 6. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 6Public
Dynamic Range Partitioning - Details
Functionality
The user can specify a threshold value that will trigger the cut of the current OTHERS partition and the creation of a new dynamic partition
Define the threshold at table level (metadata) or system parameter
HANA background job evaluates periodically the number of rows in the current OTHERS partition and generates a new dynamic range partition from OTHERS, if the
threshold is exceeded
Pre-requisite:
The range partitioning column is a non-null monotonically increasing value
The following datatypes for the range partitioning column are supported: INT, VARCHAR, DATE, TIMESTAMP, SECONDDATE
SQL Syntax:
CREATE COLUMN TABLE T1 (A VARCHAR(5) NOT NULL, NUM INTEGER NOT NULL) PARTITION BY RANGE (A AS INT) (PARTITION OTHERS DYNAMIC THRESHOLD 3000000);
ALTER TABLE T PARTITION OTHERS DYNAMIC THRESHOLD 1000000;
ALTER TABLE T PARTITION OTHERS NO DYNAMIC
Configuration Parameter:
indexserver.ini [partitioning] dynamic_range_check_time_interval_sec (default value: 900; deactivate: -1): Interval in sec for the Dynamic Range Background Job
dynamic_range_default_threshold (default value: 100 000 000): number of rows; used when no threshold is defined in table metadata
- 8. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 8Public
Overview
Customer Issue:
Complex CDS-views have been suffered from lack of multi-user scalability due to large CPU consumption
Solution:
Avoid redundant computation of identical and frequent queries in read-mostly workloads for complex CDS Views, SQL Views and CalcViews
Basic Concept:
Query result on complex view is cached and refreshed periodically. The maximum staleness restriction can be specified by users.
Features:
Ease of use: No application modification necessary
Selectively enabled for sets of queries using a view definition (DDL) statement
Two types of view caches:
– aggregated cache that allows explicit aggregation types for caching (MIN, MAX, COUNT, SUM)
– parameterized cache (caching of table function)
Limitations
No data freshness guarantees for view caches (depends on user definition)
Availability
Pilotversion with rev102 (SAP note 2232909)
GA with SPS11
- 9. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 9Public
How it works
Initial Plan
Top-level view matching
Project
GroupBy
Filter
CDS_VIEW
Project
View Cache
(CDS_VIEW)
• Check if GroupBy is used
• Check if projection columns &
aggregation type is matched with
cache spec
View Cache on CDS_VIEW
Filter
GroupBy
Project
NESTED_CDS_VIEW
Join
…
…
Execution Plan after View-Cache matching (name-based matching)
First query generates the cache entry;
Cache will be refreshed periodically => defined by retention time
- 10. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 10Public
How to use
View related DDL:
CREATE VIEW SIMPLE_VIEW AS (SELECT A, SUM(KF1), MAX(KF2), MIN(KF3), COUNT(KF4) FROM SIMPLE_TABLE GROUP BY A) WITH CACHE RETENTION 100;
ALTER VIEW <view_name> DROP | ADD | ALTER CACHE ...;
Table function related DDL:
CREATE FUNCTION SIMPLE_FUNCTION (INPUT_VAL INT)
RETURNS TABLE (A INT, KF1 INT, KF2, INT, KF3 INT, KF4 INT)
LANGUAGE SQLSCRIPT AS
BEGIN
RETURN A, SUM(KF1 + INTPUT_VAL), MIN(KF2), MIN(KF3), KF4 FROM SIMPLE_TABLE GROUP BY A;
WITH CACHE RETENTION 100;
System Views:
SELECT * FROM RESULT_CACHE; shows all cached views and table functions
SELECT * FROM RESULT_CACHE_COLUMNS; shows all cached columns of cached view and table functions
- 11. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 11Public
How to use - cont.
Monitoring Views:
SELECT * FROM M_RESULT_CACHE; shows cache-related information, e.g. cache id, cache key, memory size, record count
SELECT * FROM M_RESULT_CACHE_EXCLUSIONS; list of excluded views from caching
– Views in this list will not be cached by HANA, even if the user has created the view cache
– HANA adds views to the list automatically, if the cache result exceeds total cache size and cache refresh time > cache retention time
Configuration:
indexserver.ini [result_cache] enabled = yes (default: no);
indexserver.ini [result_cache] total_size = <MB> (default: 10000);
Note: The section [result_cache] must be created in the indexserver.ini
System Commands:
ALTER SYSTEM CLEAR RESULT CACHE;
ALTER SYSTEM REFRESH RESULT CACHE <object_name>; object_name can be found in system view RESULT_CACHE
- 12. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 12Public
Remarks on other Result Cache in HANA
Column Store Result Cache (<SPS06), works only for Column Store Views/Tables
Features:
Transaction-consistent or time-controlled result cache for column store queries
Ease of use: No application modification necessary
Selectively enabled for sets of tables/views using a configuration parameter
Allows individual behavior on cached queries or column view creation
Monitoring of cache entries M_CACHE_ENTRIES
There is no max cache size
Indexserver.ini -> [cache] -> resultcache_enabled = yes
Limitations:
Only usable for queries entirely operating on column store tables/views
Cache is invalidated if one of the base tables the query operates on is updated
Each query and parameter set has a separate cache entry
SQL-Syntax:
SELECT ... WITH PARAMETERS ('CACHE'=('REALTIME'));the result will be cached, which is the default.
SELECT ... WITH PARAMETERS ('CACHE'=('TIME_CONTROLLED','N')); the result will be cached for N seconds
ALTER SYSTEM CLEAR COLUMN RESULT CACHE; clears the result cache
- 14. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 14Public
Flexible Table enhancement
Flexibel Table: schema-flexible database tables that support data items with greatly varying sets of attributes
Use Cases: store classification data (e.g. search), graph data, input data sets (e.g. KXEN)
Feature:
Dynamic columns (but has at least one static column – predefined in the schema)
Dynamic columns can be created automatically during a data insertion operation, an update operation, or a replace/upsert operation
Dynamic column is automatically dropped if and only if no values are left (NULL values)
By default, NVARCHAR(5000) will be used as the default data type for dynamic columns
Enhancement:
Automatic Datatype Detection
– by scanning the input data and deriving the best matching data type from it
– The data type is not changed after the initial creation of the column
– SQL Syntax: CREATE COLUMN TABLE <table name> ( <column definitions> ) WITH SCHEMA FLEXIBILITY (DEFAULT DATA TYPE *)
Automatic Data Type Promotion
– the existing column type of a dynamic column will be altered to a more generic data type that is able to store the old and the new data without any loss of information
– SQL Syntax: CREATE COLUMN TABLE <table name> ( <column definitions> ) WITH SCHEMA FLEXIBILITY (AUTO DATA TYPE PROMOTION)
Combination of both:
– SQL Syntax: CREATE COLUMN TABLE <table name> ( <column definitions> ) WITH SCHEMA FLEXIBILITY (DEFAULT DATA TYPE * AUTO DATA TYPE PROMOTION)
- 15. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 15Public
Flexible Table with Automatic Datatype Detection / Promotion
SESSIONLAYER
SQLCompiler
front-end
Normal Table
COL1 INTEGER
COL2 VARCHAR
Rule 1: Add column
Action: Compare input
values list and actual table
columns. Decide type and
execute ALTER TABLE if
applicable.
Rule 2: Promote datatype
Action: Decide promote type
and execute ALTER
COLUMN if applicable.
Flexible Table
COL1 INTEGER
COL2 VARCHAR
INSERT INTO Tab
(COL1, COL2, COL3)
VALUES
(1, ‘xyz’, 5);
Exception
SQLCompiler
front-end
Retry
Add column
Flexible Table
COL1 INTEGER
COL2 VARCHAR
COL3 INTEGER
SQLCompiler
front-end
Retry
Alter column
Flexible Table
COL1 INTEGER
COL2 VARCHAR
COL3 INTEGER
Flexible Table
COL1 INTEGER
COL2 VARCHAR
COL3 DECIMAL
INSERT INTO FlexTab
(COL1, COL2, COL3)
VALUES
(1, ‘abc’, 5);
INSERT INTO FlexTab
(COL1, COL2, COL3)
VALUES
(2, ‘xyz’, 1.5);
- 16. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 16Public
SELECT with partition restriction
Definition
An optional explicit specification of a partition or a list of partitions followed by the table reference in FROM clause of SELECT and target table reference of DMLs
Use Case:
Application-controlled access to dedicated partitions of a table
Example:
a table is defined a partitioned table with 4 hash partitions
– CREATE COLUMN TABLE mytab (a INT, b INT, c INT, PRIMARY KEY (a, b)) PARTITION BY HASH (a, b) PARTITIONS 4
access or modifies the 1st partition
– SELECT * FROM mytab PARTITION (1) WHERE a = 1 AND b = 1;
the partition ID can be obtained from the monitoring view M_CS_PARTITIONS
Current Scope:
Only single table access without join & aggregation will be handled in SPS11
- 17. © 2015 SAP SE or an SAP affiliate company. All rights reserved. 17Public
Disclaimer
This presentation outlines our general product direction and should not be relied on in making
a purchase decision. This presentation is not subject to your license agreement or any other
agreement with SAP.
SAP has no obligation to pursue any course of business outlined in this presentation or to
develop or release any functionality mentioned in this presentation. This presentation and
SAP’s strategy and possible future developments are subject to change and may be changed
by SAP at any time for any reason without notice.
This document is provided without a warranty of any kind, either express or implied, including
but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or
non-infringement. SAP assumes no responsibility for errors or omissions in this document,
except if such damages were caused by SAP intentionally or grossly negligent.
- 18. © 2015 SAP SE or an SAP affiliate company. All rights reserved.
Thank you
Contact information
Ruediger Karl
SAP HANA Product Management
AskSAPHANA@sap.com