Professional Documents
Culture Documents
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.
Three new features in SAP Sybase Adaptive Server Enterprise (ASE) 15.7 ESD #2:
Hash-based update statistics
Reduce maintenance window and reduce tempdb usage
Shared query plans
Reduce memory footprint and improve performance
User-defined optimization policy
Improve performance
Generating statistics
create table A (a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int)
go
declare @count int
select @count = 0
while (@count < 1000)
begin
Insert into A values (@count % 100, @count, @count, @count, @count, @count, @count, @count, @count)
select @count = @count + 1
end
go
create index a_idx1 on A(a1, a2, a6, a7)
go
create index a_idx2 on A(a9)
go
insert into A values (@count % 100, @count, @count, @count, @count, @count, @count, @count, @count)
For table A, column a1: 100 unique values, each occurring 10 times
Density = ((10 * 10) + (10 * 10) + )/(1000 * 1000) = 10000/1000000 = 0.01
A representation of the distribution of the values of a column consisting of range intervals and
weights
The number of range intervals can be given in the UPDATE STATISTICS command default is 20
update statistics A (a1) using 11 values
To create a histogram:
Sort the column values in ascending order
Calculate the number of rows to put in each range cell
Divide the total number of rows in the table by the number of ranges (values - 1) (i.e. 1000/10 = 100)
Determine the range cell boundary values by reading the rows and setting a boundary every 100 values
(value, count) pairs
o First boundary value is -1
o (0, 10), (1, 10), (2, 10), (3, 10) (9,10) = 100 rows, so boundary value is 9
o (10, 10), (11, 10), (12, 10) (19, 10) = 100 rows, so boundary value is 19
As data in a table changes over time, the statistics can become inaccurate.
The SAP Sybase ASE optimizer can miscalculate the costs of various access paths and choose the
wrong plan.
UPDATE STATISTICS must be executed regularly to help the optimizer choose the best plan.
select datachange(A, A, a1)
Update statistics
Updates histogram and density for the first column in each index
Uses the available ordering of the index rows to do sort based statistics generation on first column
Updates multi-column densities for prefixes containing the remaining columns in each index
Updates table and index level statistics (row size, cluster ratios)
no_hashing
Use sort-based stats
partial_hashing
Use hash-based stats for low unique count domains (threshold defined internally as <= 65535 )
Fall back to sort-based stats if unique values exceed threshold
Will use a subsequent index/table scan to do sorting.
hashing
Hash-based stats with low domain AND high domain hashing.
When unique count exceeds low domain threshold, switch to high domain hashing algorithm internally.
Generates and merges intermediate statistics
Unique counts and densities could become less accurate histograms OK.
Use with max_resource_granularity clause to increase available buffer cache for big tables
Table Row count Column count Index count Sorting Hashing Ratio (S/H)
LTAP 85,973,877 160 3 84.19 16.18 5.2
IDOCREL 692,211,695 6 5 351.26 105.82 3.3
May get less accurate statistics if the number of unique column values exceeds 65535
Intermediate density and unique-value counts are combined to generate the final statistics
Can avoid this by using partial hashing instead of hashing
update statistics A (a1) with partial_hashing
Tells the SAP Sybase ASE query execution engine how to generate the result set of a SQL
statement (query).
Example:
1. Get read locks on tab1
Instruction: Get lock on table
Meta data: Read lock, table tab1
4. For each row, extract column col1
Temporary storage: Memory to write the value of col1 into
Metadata is stored in memory that is only read, not written to during execution.
Because of the writable part of the query plan, each query plan can only be executed by a
single SAP Sybase ASE process (connection) at a time.
If two connections execute the same query at the same time, each must create its own query plan.
SAP Sybase ASE query processing (QP) layer compiles query plans:
1. Parse SQL text into internal structures (query tree)
2. Resolve data base object references in the query tree
3. Preprocess/transform the query tree
4. Optimize
Permute through possible access paths, costing each one to find the query plan with the lowest estimated
cost.
5. Create the query plan chosen by the optimizer
6. Execute the query plan
7. Release the query plan to procedure cache for re-use
Starting with SAP Sybase ASE 15.7 ESD #2, query plans can be created by cloning.
Thread #1 is executing a query plan for the same SQL statement that thread #2 will execute:
Thread #2 will clone the plan that is in use by thread #1 by:
1. Allocating memory to hold a new query plan
2. Allocating memory corresponding to the writable parts of the original plan in the new query plan memory
3. Copying some of the meta data from the original plan into the new plan memory
4. Setting memory pointers into the original plans instructions and remaining meta data
5. Marking the new plan as a shared plan.
PRIMARY plan
1. A compiled query plan and is a complete, standalone query plan.
2. Can be used as a source plan to clone a SHARED plan.
3. Is pinned in the procedure cache as long as any SHARED plan points to it.
4. Has a larger memory footprint than a SHARED plan.
SHARED plan
1. A cloned plan that is a partial plan that includes pointers to some elements of a PRIMARY plan.
2. Cannot be used as a source to clone another SHARED plan.
3. Is not pinned in the procedure cache when it is not in use.
4. Has a smaller memory footprint than a PRIMARY plan.
An optimization goal is a collection of access paths and optimizer costing algorithms that are
used to control the SAP Sybase ASE optimizer
It lists the access paths/algorithms that the optimizer may consider when searching for a query plan.
It lists which of the code changes that may influence optimizer costing are enabled or disabled.
Both access paths and code changes are called optcriteria.
Optimizer costing code evolves from one SAP Sybase ASE release to the next
Costing bug fixes
Costing enhancements
Each bug fix or enhancement to the optimizers costing algorithms is called an optcriteria.
Each optcriteria is given a name, i.e. cr421607
When optcriteria are introduced in an SAP Sybase ASE ESD release, they are off by default
Each optcriteria can be turned on or off using a set command
set cr421607 on
The collection of all of the optcriteria for an ESD release is called an optlevel
set plan optlevel ase157esd1
set plan optlevel ase_current enables all optcriteria up to and including the current ESD release
The more choices the optimizer has to cost, the longer it takes to find a plan.
Allrows_oltp has the fewest number of enabled access paths
The optimizer will cost the possible query plans more quickly than the other optimizer goals.
The optimizer has fewer plans to choose from and so has a smaller chance of picking the wrong plan.
If the SAP Sybase ASE installation is used for an OLTP workload, there may be little benefit to considering the
extra plans.
Optimization goals are used to customize the SAP Sybase ASE optimizer to fit the application.
sp_optgoal
New system stored procedure to administer user optimization goals.
sp_optgoal [goal_name], [action]
[goal-name]
User-defined name
Limited to 12 characters
[action]
show - displays the definition of [goal-name]
save creates a new goal or modifies an existing goal called [goal_name]
delete deletes [goal_name]
If [goal-name] is not given, sp_optgoal displays names of all user-defined optimization goals
Use global variable, @@optgoal to find out which optimization goal is currently enabled
------------------------------------------------------------
my_dss
(1 row affected)
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express Google App Engine, Google Apps, Google Checkout, Google Data API, Google Maps, Google Mobile Ads,
permission of SAP AG. The information contained herein may be changed without prior notice. Google Mobile Updater, Google Mobile, Google Store, Google Sync, Google Updater, Google Voice,
Google Mail, Gmail, YouTube, Dalvik and Android are trademarks or registered trademarks of Google Inc.
Some software products marketed by SAP AG and its distributors contain proprietary software components of
other software vendors. INTERMEC is a registered trademark of Intermec Technologies Corporation.
Microsoft, Windows, Excel, Outlook, PowerPoint, Silverlight, and Visual Studio are registered trademarks of Wi-Fi is a registered trademark of Wi-Fi Alliance.
Microsoft Corporation.
Bluetooth is a registered trademark of Bluetooth SIG Inc.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System
Motorola is a registered trademark of Motorola Trademark Holdings LLC.
z10, z10, z/VM, z/OS, OS/390, zEnterprise, PowerVM, Power Architecture, Power Systems, POWER7,
POWER6+, POWER6, POWER, PowerHA, pureScale, PowerPC, BladeCenter, System Storage, Storwize, Computop is a registered trademark of Computop Wirtschaftsinformatik GmbH.
XIV, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, AIX, Intelligent Miner, WebSphere,
Tivoli, Informix, and Smarter Planet are trademarks or registered trademarks of IBM Corporation. SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects Explorer, StreamWork,
SAP HANA, and other SAP products and services mentioned herein as well as their respective logos are
Linux is the registered trademark of Linus Torvalds in the United States and other countries. trademarks or registered trademarks of SAP AG in Germany and other countries.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are trademarks or registered trademarks of Adobe Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web
Systems Incorporated in the United States and other countries. Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their
respective logos are trademarks or registered trademarks of Business Objects Software Ltd. Business Objects
Oracle and Java are registered trademarks of Oracle and its affiliates.
is an SAP company.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere, and other Sybase products and services
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or mentioned herein as well as their respective logos are trademarks or registered trademarks of Sybase Inc.
registered trademarks of Citrix Systems Inc. Sybase is an SAP company.
HTML, XML, XHTML, and W3C are trademarks or registered trademarks of W3C, World Wide Web Crossgate, m@gic EDDY, B2B 360, and B2B 360 Services are registered trademarks of Crossgate AG
Consortium, Massachusetts Institute of Technology. in Germany and other countries. Crossgate is an SAP company.
Apple, App Store, iBooks, iPad, iPhone, iPhoto, iPod, iTunes, Multi-Touch, Objective-C, Retina, Safari, Siri, All other product and service names mentioned are the trademarks of their respective companies. Data
and Xcode are trademarks or registered trademarks of Apple Inc. contained in this document serves informational purposes only. National product specifications may vary.
IOS is a registered trademark of Cisco Systems Inc. The information in this document is proprietary to SAP. No part of this document may be reproduced, copied,
or transmitted in any form or for any purpose without the express prior written permission of SAP AG.
RIM, BlackBerry, BBM, BlackBerry Curve, BlackBerry Bold, BlackBerry Pearl, BlackBerry Torch, BlackBerry
Storm, BlackBerry Storm2, BlackBerry PlayBook, and BlackBerry App World are trademarks or registered
trademarks of Research in Motion Limited.