SlideShare a Scribd company logo
1 of 25
Dimensional Performance Benchmarking of SQL
Brendan Furey, March 2017
http://aprogrammerwrites.eu/
Ireland Oracle User Group, March 23-24, 2017
whoami
Freelance Oracle developer and blogger
Dublin-based Europhile
25 years Oracle experience, currently working in Finance
Started as a Fortran programmer at British Gas
Numerical analysis and optimization
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 2
Agenda
Summary (7 slides)
 Overview – origin - motivation
6 Examples (10 slides)
 Problem definition – query description – results graph – points to note
Framework Structure (4 slides)
 Data model – code structure diagram – Framework installation and use
References (1 slide)
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 3
Summary
Performance comparison of different SQL for same problem
Relative performance may vary with size and shape of test data
Define data set in terms of (x,y) parameters, run queries across 2-d grid
Developer writes procedure to generate a data set with input (x,y)
Query added as metadata to a query group
Framework loops over every point in input ranges of x and y, for each query
 Write results to CSV file
 Captures CPU and elapsed times in detail, and other information including…
 Execution plan
 Aggregate plan statistics, including cardinality estimate errors
 v$ statistics, such as physical reads
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 4
Big-O Notation
Big-O notation : Extract…
Framework shows actual performance over x and y ranges
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 5
Comparison with Runstats
Runstats
1. Set up test data if necessary
2. Rs_start
3. Do SQL 1
4. Rs_middle
5. Do SQL 2
6. Rs_stop – displays statistics for run 1 and run 2 side by side with difference
One data point
Two SQLs
No execution plans
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 6
SQL> exec runstats_pkg.rs_start;
SQL> insert into all_objects_copy select owner, object_name, edition_name from
all_objects;
SQL> exec runstats_pkg.rs_middle;
SQL> begin
for row in (select owner, object_name, edition_name from all_objects) loop
insert into all_objects_copy (owner, object_name, edition_name)
values (row.owner, row.object_name, row.edition_name);
end loop;
end;
/
SQL> runstats_pkg.rs_stop;
Name Run1 Run2 Diff
LATCH.SQL memory manager worka 139,651 139,781 130
Etc.
Dim_Bench_Sql_Oracle – Body Output Extract
 Extract from output for string splitting example, Model clause:
 6 sections timed
 1 Init + 1 Write_Times +
 7 Increment_Time (Write to file in 2 places)
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 7
Plan hash value: 1656081500
----------------------------------------------------------------------------------------------------------------------------- --------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | Writes | OMem | 1Mem | Used-Mem |
----------------------------------------------------------------------------------------------------------------------------- --------------------
| 0 | SELECT STATEMENT | | 1 | | 5400K|03:10:43.97 | 1509 | 2883 | 2883 | | | |
| 1 | SQL MODEL ORDERED FAST| | 1 | 3000 | 5400K|03:10:43.97 | 1509 | 2883 | 2883 | 2047M | 112M| 2844M (1)|
| 2 | TABLE ACCESS FULL | DELIMITED_LISTS | 1 | 3000 | 3000 |00:00:00.01 | 1509 | 0 | 0 | | | |
----------------------------------------------------------------------------------------------------------------------------- --------------------
Timer Set: Cursor, Constructed at 04 Feb 2017 02:14:57, written at 02:25:51
===========================================================================
[Timer timed: Elapsed (per call): 0.00 (0.000000), CPU (per call): 0.00 (0.000000), calls: 1000, '***' denotes corrected line below]
Timer Elapsed CPU Calls Ela/Call CPU/Call
----------------- ---------- ---------- ------------ ------------- -------------
Pre SQL 0.00 0.00 1 0.00000 0.00000
Open cursor 0.00 0.00 1 0.00000 0.00000
First fetch 40.64 40.55 1 40.64400 40.55000
Write to file 9.81 9.82 5,401 0.00182 0.00182
Remaining fetches 603.80 603.21 5,400 0.11181 0.11171
Write plan 0.45 0.45 1 0.45400 0.45000
(Other) 0.02 0.01 1 0.01600 0.01000
----------------- ---------- ---------- ------------ ------------- -------------
Total 654.72 654.04 10,806 0.06059 0.06053
----------------- ---------- ---------- ------------ ------------- -------------
Timer_Set.Init_Time (l_timer_cur);
Timer_Set.Increment_Time (l_timer_cur, l_timer_cur_names(1));
-- above times 1 section, repeat for each section timed
Timer_Set.Write_Times (l_timer_cur);
Code Timer Object
Code Timing and Object Orientation and Zombies
Low footprint in code and in time
Object type-based as shown, but…
…all code in package for reasons in link
Object is set of timers: Reduces footprint
Hash required for efficiency when many timers
Oracle associative array (hash) traversed by key
Hence use of hash to point to tabular array…
…so can list results in order of timer creation
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 8
Testing, Timing and Automation
Unit testing
 Oracle Unit Testing with utPLSQL
 TRAPIT - TRansactional API Testing in Oracle
 Automation means more work initially, but…
 Automated regression testing gives confidence to refactor safely
 Code is continuously refined and improved
 Less technical debt
Performance testing
 A Framework for Dimensional Benchmarking of SQL Query Performance
 Automation means more work initially, but…
 More rigorous testing becomes possible
 Additional queries or SQL statements can easily be added
 Once parameterized, as many data points as desired can be tested
 New tests use previous ones as a starting point
Code timing object used in both my testing frameworks
 Can trap issues such as index changes in unit test regression at negligible cost
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 9
Dim_Bench_Sql_Oracle – Summary Output
3 kinds of statistics printed in matrix format (WxD and DxW) to csv files
 Basic timing and output rows, including CPU and elapsed time
 Execution plan aggregates, read from v$sql_plan_statistics_all
 V$ statistics (after-before) differences, read from v$mystat, v$latch, v$sess_time_model
Print full grid and ‘slice’, being the high point values for one of the dimensions
Also print ratios of statistics to the smallest values across queries at the data point
Example slice output for the 3 types (ORG_STRUCT problem):
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 10
Example 1 – Simple Bursting Problem - Definition
Determine break groups using distance from group start point
All records that start within a fixed distance from the group start are in the group
First record after the end of a group defines the next group start
Example output using 3 days, omitting partition key
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 11
Detail Level
START_DAT END_DATE GROUP_STA GROUP_END
--------- --------- --------- ---------
01-JUN-11 03-JUN-11 01-JUN-11 07-JUN-11
02-JUN-11 05-JUN-11 01-JUN-11 07-JUN-11
04-JUN-11 07-JUN-11 01-JUN-11 07-JUN-11
08-JUN-11 16-JUN-11 08-JUN-11 16-JUN-11
09-JUN-11 14-JUN-11 08-JUN-11 16-JUN-11
20-JUN-11 30-JUN-11 20-JUN-11 30-JUN-11
Summary Level
GROUP_STA GROUP_END NUM_ROWS
--------- --------- ----------
01-JUN-11 07-JUN-11 3
08-JUN-11 16-JUN-11 2
20-JUN-11 30-JUN-11 1
 MOD_QRY: Model clause, no iteration. Linear in time by width
 RSF_QRY: Recursive Subquery Factors Query 1 – Direct. Quadratic
 RSF_TMP: Recursive Subquery Factors Query 2 – Pre-inserting to temporary table.
 Linear due to indexed scan on temporary table
 Framework allows for any SQL statement to be executed before the query
 Included in timing and permits benchmarking of non-query SQL
 MTH_QRY: Match Recognize. Linear
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 12
Example 1 – Simple Bursting Problem - Results
Example 2 – General Bursting Problem 1 - Results
Like 'simple' problem but using a running aggregate based on function of attributes
Depth is number of records per partition key
 MOD_QRY: Model clause using Automatic Order. Quadratic in time by depth
 MOD_QRY_D: Model clause using (default) Sequential Order, via reverse ordering of a
rule. Linear
 RSF_QRY, RSF_TMP, MTH_QRY: Similar queries to Example 1, and similar behaviour
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 13
Example 2 – General Bursting Problem 2 – Model Anomaly
 MOD_QRY Plan: SQL MODEL CYCLIC. Quadratic timing variation: Very slow
 Sequential Order -> ORA-32637: Self cyclic rule in sequential order Model
 MOD_QRY_D Plan: SQL MODEL ORDERED. Linear timing variation: Much faster
 Add non-default rule-ordering: final_grp[ANY] ORDER BY rn DESC = …
 Now Rules Sequential Order does not throw an error
 Exactly same functionally but ‘under the covers’ Model has used a much faster algorithm
 Dimensional benchmarking shows difference without knowing underlying algorithms
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 14
WITH all_rows AS (
SELECT id, cat, seq, weight, sub_weight, final_grp
FROM items
MODEL
PARTITION BY (cat)
DIMENSION BY (Row_Number() OVER (PARTITION BY cat ORDER BY seq DESC) rn)
MEASURES (id, weight, weight sub_weight, id final_grp, seq)
RULES AUTOMATIC ORDER (
sub_weight[rn > 1] = CASE WHEN sub_weight[cv()-1] >= 5000 THEN weight[cv()] ELSE sub_weight[cv()-1] + weight[cv()] END,
final_grp[ANY] = PRESENTV (final_grp[cv()+1], CASE WHEN sub_weight[cv()] >= 5000 THEN id[cv()] ELSE final_grp[cv()+1] END,
id[cv()])
)
)
SELECT cat, final_grp, COUNT(*) num_rows
FROM all_rows
GROUP BY cat, final_grp
ORDER BY cat, final_grp
Example 3 – Bracket Parsing
Obtain the matching brackets from string expressions (from OTN thread)
 CBL_QRY, mathguy: Connect By, Analytics, Regex
 MRB_QRY, Peter vd Zwan: Connect By, Match_Recognize
 WFB_QRY, me: With PL/SQL Function, Arrays
 PFB_QRY, me: Pipelined PL/SQL Function, Arrays
 Pipelined function is fastest, slightly, but consistently ~5% faster than With Function
 Match_Recognize only one to increase time with nesting level
 Rises quadratically with number of bracket pairs, others rise more slowly though above linearly
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 15
Example 4 – 5-Level Hierarchy
 Fixed-level hierarchy traversal
 Multi-child, multi-parent with multiplicative incidence factors
 JNS_QRY: Sequence of joins
 PLF_QRY: Recursive pipelined PL/SQL Function
 RSF_QRY: Recursive subquery factor
 JNS_QRY fastest, then RSF_QRY, with PLF_QRY slowest
 PLF_QRY inefficiency caused by query execution at every node, observe correlation with #Recs
 Above 140 disk writes rise, correlating with increase in elapsed-CPU time differences
 RSF_QRY uses ~50% more disk writes than the others
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 16
Example 5 – 5-Level Hierarchy by Joins – Hash Join “Inputs Order”
 Same fixed-level hierarchy problem, JNS_QRY only, largest data point
 Hash joining c to rowset (a.b), two ‘directions’
 (a.b).c : rowset (a.b) is the hash table (‘build’ input), c is the ‘probe’ input - no_swap_join_inputs(c)
 c.(a.b) : c is the ‘build’ and (a.b) the ‘probe’ input - swap_join_inputs(c)
 leading, use_hash hints to force main join order, and hash joins
 swap_join_inputs, no_swap_join_inputs to generate all 32 possible combinations
 First half double elapsed time, and about an extra second of CPU time
 Times correlates with disk writes, two sources:
 Hash table spilling to disk: Eliminated by swap_join_order on final table
 Other processing, also present in the other queries on previous slide
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 17
Example 6 – String Splitting 1 – Problem / datasets / queries
 Queries using Connect By for row generation
 MUL_QRY - Cast/Multiset to correlate Connect By
 LAT_QRY - v12 Lateral correlated Connect By
 UNH_QRY - Uncorrelated Connect By unhinted
 RGN_QRY - Uncorrelated Connect By with leading hint
 GUI_QRY - Connect By in main query using sys_guid trick
 RGX_QRY - Regular expression function, Regexp_Substr
 Queries not using Connect By for row generation
 XML_QRY - XMLTABLE
 MOD_QRY - Model clause
 PLF_QRY - database pipelined function
 WFN_QRY - 'WITH' PL/SQL function directly in query
 RSF_QRY - Recursive Subquery Factor
 RMR_QRY - Match_Recognize
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 18
 Split delimited strings into their tokens - very common question on forums
 6 queries based on row-generation via Connect By, 6 using other methods
 Width = number of tokens, depth = length of token
 4 datasets: 1 dimension fixed at low/high value, other range of high/low values
Example 6 – String Splitting 2 – Results for high numbers of tokens
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 19
 RGN_QRY is my attempt at Connect By solution both simple and efficient
 Generate max number of rows in subquery, join to main record on actual number
 Need to prevent CBO from reversing the join order (UNH_QRY) with leading hint
 31 seconds
Example 6 – String Splitting 3 – Discussion of results
 Best 3 methods all linear by number of tokens, worst 3 quadratic
 Pipelined function best (across all data points, including not shown)
 Same logic in SQL ‘WITH’ function about a third slower
 Model, regex and recursive subquery factor quadratic and very slow
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 20
 MUL_QRY is classic forum solution using complex ‘TABLE (CAST (MULTISET’ code
 Syntax to correlate Connect By with the main record, effectively a pre-12.1 Lateral
 Correlating a tree-walk is actually bad for performance
 141 seconds
 GUI_QRY is more recent forum favourite and simpler
 Embeds Connect By in main query, using ‘PRIOR sys_guid() IS NOT NULL’ to circumvent ORA-01436
 Turning main query into 1 big tree-walk is very inefficient
 335 seconds
Dim_Bench_Sql_Oracle – Data Model
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 21
Dim_Bench_Sql_Oracle – Code Structure Diagram
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 22
Data Setup Procedures – Pseudocode for string splitting example
Construct timer (then increment throughout as desired)
Truncate tables (execute immediate)
Loop for 1 to deep point
 Add character to base token string
Loop for 1 to wide point
 Add base token string with delimiter to string accumulating delimited string
Loop for number of records to insert
 Insert delimited string with uid to table
Gather table statistics
Write the timer set to log
Set the output parameters
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 23
Framework Installation
Clone project from GitHub
 BrenPatF/dim_bench_sql_oracle
From the README
 This is best run initially in a private database where you have sys user access
 Clone the project and go to the relevant bat (pre-v12 versions) or bat_12c folder
 Update bench.bat and SYS.bat with any credentials differences on your system
 Check the Install_SYS.sql (Install_SYS_v11.sql) script, and ensure you have a write-able output folder
with the same name as in the script
 Run Install_SYS.bat (Install_SYS_v11.bat) to create the bench user and output directory, and grant
privileges
 Run Install_lib.bat to install general library utilities in the bench schema
 Run Install_bench.bat to install the benchmarking framework in the bench schema
 Run Install_bench_examples.bat (Install_bench_examples_v11.bat) to install the the demo problems
 Check log files for any errors
 Run Test_Bur.bat, or Batch_Bra.bat (etc.) for the demo problems
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 24
References
1. BrenPatF/dim_bench_sql_oracle
2. Runstats
3. Code Timing and Object Orientation and Zombies
4. Big-O notation
5. Oracle Unit Testing with utPLSQL
6. TRAPIT - TRansactional API Testing in Oracle
7. A Framework for Dimensional Benchmarking of SQL Query Performance
8. Dimensional Benchmarking of Oracle v10-v12 Queries for SQL Bursting Problems
9. Dimensional Benchmarking of General SQL Bursting Problems
10. Dimensional Benchmarking of Bracket Parsing SQL
11. Dimensional Benchmarking of SQL for Fixed-Depth Hierarchies
12. Benchmarking of Hash Join Options in SQL for Fixed-Depth Hierarchies
13. Dimensional Benchmarking of String Splitting SQL
Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 25

More Related Content

What's hot

Demo of MYNG 1.01
Demo of MYNG 1.01Demo of MYNG 1.01
Demo of MYNG 1.01Tara Athan
 
Window functions with SQL Server 2016
Window functions with SQL Server 2016Window functions with SQL Server 2016
Window functions with SQL Server 2016Mark Tabladillo
 
Query Decomposition and data localization
Query Decomposition and data localization Query Decomposition and data localization
Query Decomposition and data localization Hafiz faiz
 
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific StatisticsThe Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific StatisticsMichael Rosenblum
 
Certified Reasoning for Automated Verification
Certified Reasoning for Automated VerificationCertified Reasoning for Automated Verification
Certified Reasoning for Automated VerificationAsankhaya Sharma
 
Unit II - LINEAR DATA STRUCTURES
Unit II -  LINEAR DATA STRUCTURESUnit II -  LINEAR DATA STRUCTURES
Unit II - LINEAR DATA STRUCTURESUsha Mahalingam
 
Towards Structural Version Control
Towards Structural Version ControlTowards Structural Version Control
Towards Structural Version ControlIan Wang
 
Query decomposition in data base
Query decomposition in data baseQuery decomposition in data base
Query decomposition in data baseSalman Memon
 
Analytic & Windowing functions in oracle
Analytic & Windowing functions in oracleAnalytic & Windowing functions in oracle
Analytic & Windowing functions in oracleLogan Palanisamy
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructuresNguync91368
 
Sql server ___________session_18(stored procedures)
Sql server  ___________session_18(stored procedures)Sql server  ___________session_18(stored procedures)
Sql server ___________session_18(stored procedures)Ehtisham Ali
 
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZEMySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZENorvald Ryeng
 
An introduction to knitr and R Markdown
An introduction to knitr and R MarkdownAn introduction to knitr and R Markdown
An introduction to knitr and R Markdownsahirbhatnagar
 
Sedna XML Database: Executor Internals
Sedna XML Database: Executor InternalsSedna XML Database: Executor Internals
Sedna XML Database: Executor InternalsIvan Shcheklein
 

What's hot (20)

Demo of MYNG 1.01
Demo of MYNG 1.01Demo of MYNG 1.01
Demo of MYNG 1.01
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Oracle 12c SPM
Oracle 12c SPMOracle 12c SPM
Oracle 12c SPM
 
Stored procedure in sql server
Stored procedure in sql serverStored procedure in sql server
Stored procedure in sql server
 
Window functions with SQL Server 2016
Window functions with SQL Server 2016Window functions with SQL Server 2016
Window functions with SQL Server 2016
 
Query Decomposition and data localization
Query Decomposition and data localization Query Decomposition and data localization
Query Decomposition and data localization
 
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific StatisticsThe Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
 
Certified Reasoning for Automated Verification
Certified Reasoning for Automated VerificationCertified Reasoning for Automated Verification
Certified Reasoning for Automated Verification
 
Unit II - LINEAR DATA STRUCTURES
Unit II -  LINEAR DATA STRUCTURESUnit II -  LINEAR DATA STRUCTURES
Unit II - LINEAR DATA STRUCTURES
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Towards Structural Version Control
Towards Structural Version ControlTowards Structural Version Control
Towards Structural Version Control
 
Query decomposition in data base
Query decomposition in data baseQuery decomposition in data base
Query decomposition in data base
 
Analytic & Windowing functions in oracle
Analytic & Windowing functions in oracleAnalytic & Windowing functions in oracle
Analytic & Windowing functions in oracle
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
 
Sql server ___________session_18(stored procedures)
Sql server  ___________session_18(stored procedures)Sql server  ___________session_18(stored procedures)
Sql server ___________session_18(stored procedures)
 
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZEMySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
 
An introduction to knitr and R Markdown
An introduction to knitr and R MarkdownAn introduction to knitr and R Markdown
An introduction to knitr and R Markdown
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
SQL Windowing
SQL WindowingSQL Windowing
SQL Windowing
 
Sedna XML Database: Executor Internals
Sedna XML Database: Executor InternalsSedna XML Database: Executor Internals
Sedna XML Database: Executor Internals
 

Viewers also liked

Ranges, ranges everywhere (Oracle SQL)
Ranges, ranges everywhere (Oracle SQL)Ranges, ranges everywhere (Oracle SQL)
Ranges, ranges everywhere (Oracle SQL)Stew Ashton
 
Row Pattern Matching in Oracle Database 12c
Row Pattern Matching in Oracle Database 12cRow Pattern Matching in Oracle Database 12c
Row Pattern Matching in Oracle Database 12cStew Ashton
 
Oracle Unit Testing with utPLSQL
Oracle Unit Testing with utPLSQLOracle Unit Testing with utPLSQL
Oracle Unit Testing with utPLSQLBrendan Furey
 
Bench Marking
Bench MarkingBench Marking
Bench Markingwebmace
 
All About PL/SQL Collections
All About PL/SQL CollectionsAll About PL/SQL Collections
All About PL/SQL CollectionsSteven Feuerstein
 
Flying windmills Presentation
Flying windmills PresentationFlying windmills Presentation
Flying windmills PresentationHimanshu Rajput
 
Smart Revolutions in XXI Century: the Creative Destruction of the World
Smart Revolutions in XXI Century: the Creative Destruction of the WorldSmart Revolutions in XXI Century: the Creative Destruction of the World
Smart Revolutions in XXI Century: the Creative Destruction of the WorldAzamat Abdoullaev
 
Les évolutions adaptatives
Les évolutions adaptativesLes évolutions adaptatives
Les évolutions adaptativesRESPONSIV
 
The Coming Intelligent Digital Assistant Era and Its Impact on Online Platforms
The Coming Intelligent Digital Assistant Era and Its Impact on Online PlatformsThe Coming Intelligent Digital Assistant Era and Its Impact on Online Platforms
The Coming Intelligent Digital Assistant Era and Its Impact on Online PlatformsCognizant
 
Missing Action Plan (May 2015)
Missing Action Plan (May 2015)Missing Action Plan (May 2015)
Missing Action Plan (May 2015)Victoria Gaitskell
 
How To Make Effective Presentation
How To Make Effective PresentationHow To Make Effective Presentation
How To Make Effective Presentationdabinslc
 

Viewers also liked (15)

Ranges, ranges everywhere (Oracle SQL)
Ranges, ranges everywhere (Oracle SQL)Ranges, ranges everywhere (Oracle SQL)
Ranges, ranges everywhere (Oracle SQL)
 
Row Pattern Matching in Oracle Database 12c
Row Pattern Matching in Oracle Database 12cRow Pattern Matching in Oracle Database 12c
Row Pattern Matching in Oracle Database 12c
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 
Oracle Unit Testing with utPLSQL
Oracle Unit Testing with utPLSQLOracle Unit Testing with utPLSQL
Oracle Unit Testing with utPLSQL
 
Bench Marking
Bench MarkingBench Marking
Bench Marking
 
Flying windmills Report
Flying windmills ReportFlying windmills Report
Flying windmills Report
 
All About PL/SQL Collections
All About PL/SQL CollectionsAll About PL/SQL Collections
All About PL/SQL Collections
 
Flying windmills Presentation
Flying windmills PresentationFlying windmills Presentation
Flying windmills Presentation
 
Smart Revolutions in XXI Century: the Creative Destruction of the World
Smart Revolutions in XXI Century: the Creative Destruction of the WorldSmart Revolutions in XXI Century: the Creative Destruction of the World
Smart Revolutions in XXI Century: the Creative Destruction of the World
 
Les évolutions adaptatives
Les évolutions adaptativesLes évolutions adaptatives
Les évolutions adaptatives
 
The Coming Intelligent Digital Assistant Era and Its Impact on Online Platforms
The Coming Intelligent Digital Assistant Era and Its Impact on Online PlatformsThe Coming Intelligent Digital Assistant Era and Its Impact on Online Platforms
The Coming Intelligent Digital Assistant Era and Its Impact on Online Platforms
 
Storyboard
StoryboardStoryboard
Storyboard
 
Poseidon Adventures
Poseidon AdventuresPoseidon Adventures
Poseidon Adventures
 
Missing Action Plan (May 2015)
Missing Action Plan (May 2015)Missing Action Plan (May 2015)
Missing Action Plan (May 2015)
 
How To Make Effective Presentation
How To Make Effective PresentationHow To Make Effective Presentation
How To Make Effective Presentation
 

Similar to Dimensional performance benchmarking of SQL

Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basicsnitin anjankar
 
Analysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptxAnalysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptxBrendan Furey
 
Writing efficient sql
Writing efficient sqlWriting efficient sql
Writing efficient sqlj9soto
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq lsInSync Conference
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And Whatudaymoogala
 
Oracle Query Optimizer - An Introduction
Oracle Query Optimizer - An IntroductionOracle Query Optimizer - An Introduction
Oracle Query Optimizer - An Introductionadryanbub
 
D73549GC10_06.pptx
D73549GC10_06.pptxD73549GC10_06.pptx
D73549GC10_06.pptxVLQuyNhn
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 
Checking clustering factor to detect row migration
Checking clustering factor to detect row migrationChecking clustering factor to detect row migration
Checking clustering factor to detect row migrationHeribertus Bramundito
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?Andrej Pashchenko
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq lsInSync Conference
 
EvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfEvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfPraveenPolu1
 
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ISql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ICarlos Oliveira
 
SQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19cSQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19cRachelBarker26
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsJohn Kanagaraj
 

Similar to Dimensional performance benchmarking of SQL (20)

Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
 
Analysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptxAnalysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptx
 
Writing efficient sql
Writing efficient sqlWriting efficient sql
Writing efficient sql
 
Aspects of 10 Tuning
Aspects of 10 TuningAspects of 10 Tuning
Aspects of 10 Tuning
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
 
Oracle Query Optimizer - An Introduction
Oracle Query Optimizer - An IntroductionOracle Query Optimizer - An Introduction
Oracle Query Optimizer - An Introduction
 
D73549GC10_06.pptx
D73549GC10_06.pptxD73549GC10_06.pptx
D73549GC10_06.pptx
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 
Using AWR for SQL Analysis
Using AWR for SQL AnalysisUsing AWR for SQL Analysis
Using AWR for SQL Analysis
 
Checking clustering factor to detect row migration
Checking clustering factor to detect row migrationChecking clustering factor to detect row migration
Checking clustering factor to detect row migration
 
PoC Oracle Exadata - Retour d'expérience
PoC Oracle Exadata - Retour d'expériencePoC Oracle Exadata - Retour d'expérience
PoC Oracle Exadata - Retour d'expérience
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
 
Chapter15
Chapter15Chapter15
Chapter15
 
EvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfEvolveExecutionPlans.pdf
EvolveExecutionPlans.pdf
 
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ISql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices I
 
SQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19cSQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19c
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 

Dimensional performance benchmarking of SQL

  • 1. Dimensional Performance Benchmarking of SQL Brendan Furey, March 2017 http://aprogrammerwrites.eu/ Ireland Oracle User Group, March 23-24, 2017
  • 2. whoami Freelance Oracle developer and blogger Dublin-based Europhile 25 years Oracle experience, currently working in Finance Started as a Fortran programmer at British Gas Numerical analysis and optimization Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 2
  • 3. Agenda Summary (7 slides)  Overview – origin - motivation 6 Examples (10 slides)  Problem definition – query description – results graph – points to note Framework Structure (4 slides)  Data model – code structure diagram – Framework installation and use References (1 slide) Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 3
  • 4. Summary Performance comparison of different SQL for same problem Relative performance may vary with size and shape of test data Define data set in terms of (x,y) parameters, run queries across 2-d grid Developer writes procedure to generate a data set with input (x,y) Query added as metadata to a query group Framework loops over every point in input ranges of x and y, for each query  Write results to CSV file  Captures CPU and elapsed times in detail, and other information including…  Execution plan  Aggregate plan statistics, including cardinality estimate errors  v$ statistics, such as physical reads Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 4
  • 5. Big-O Notation Big-O notation : Extract… Framework shows actual performance over x and y ranges Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 5
  • 6. Comparison with Runstats Runstats 1. Set up test data if necessary 2. Rs_start 3. Do SQL 1 4. Rs_middle 5. Do SQL 2 6. Rs_stop – displays statistics for run 1 and run 2 side by side with difference One data point Two SQLs No execution plans Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 6 SQL> exec runstats_pkg.rs_start; SQL> insert into all_objects_copy select owner, object_name, edition_name from all_objects; SQL> exec runstats_pkg.rs_middle; SQL> begin for row in (select owner, object_name, edition_name from all_objects) loop insert into all_objects_copy (owner, object_name, edition_name) values (row.owner, row.object_name, row.edition_name); end loop; end; / SQL> runstats_pkg.rs_stop; Name Run1 Run2 Diff LATCH.SQL memory manager worka 139,651 139,781 130 Etc.
  • 7. Dim_Bench_Sql_Oracle – Body Output Extract  Extract from output for string splitting example, Model clause:  6 sections timed  1 Init + 1 Write_Times +  7 Increment_Time (Write to file in 2 places) Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 7 Plan hash value: 1656081500 ----------------------------------------------------------------------------------------------------------------------------- -------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | Writes | OMem | 1Mem | Used-Mem | ----------------------------------------------------------------------------------------------------------------------------- -------------------- | 0 | SELECT STATEMENT | | 1 | | 5400K|03:10:43.97 | 1509 | 2883 | 2883 | | | | | 1 | SQL MODEL ORDERED FAST| | 1 | 3000 | 5400K|03:10:43.97 | 1509 | 2883 | 2883 | 2047M | 112M| 2844M (1)| | 2 | TABLE ACCESS FULL | DELIMITED_LISTS | 1 | 3000 | 3000 |00:00:00.01 | 1509 | 0 | 0 | | | | ----------------------------------------------------------------------------------------------------------------------------- -------------------- Timer Set: Cursor, Constructed at 04 Feb 2017 02:14:57, written at 02:25:51 =========================================================================== [Timer timed: Elapsed (per call): 0.00 (0.000000), CPU (per call): 0.00 (0.000000), calls: 1000, '***' denotes corrected line below] Timer Elapsed CPU Calls Ela/Call CPU/Call ----------------- ---------- ---------- ------------ ------------- ------------- Pre SQL 0.00 0.00 1 0.00000 0.00000 Open cursor 0.00 0.00 1 0.00000 0.00000 First fetch 40.64 40.55 1 40.64400 40.55000 Write to file 9.81 9.82 5,401 0.00182 0.00182 Remaining fetches 603.80 603.21 5,400 0.11181 0.11171 Write plan 0.45 0.45 1 0.45400 0.45000 (Other) 0.02 0.01 1 0.01600 0.01000 ----------------- ---------- ---------- ------------ ------------- ------------- Total 654.72 654.04 10,806 0.06059 0.06053 ----------------- ---------- ---------- ------------ ------------- ------------- Timer_Set.Init_Time (l_timer_cur); Timer_Set.Increment_Time (l_timer_cur, l_timer_cur_names(1)); -- above times 1 section, repeat for each section timed Timer_Set.Write_Times (l_timer_cur);
  • 8. Code Timer Object Code Timing and Object Orientation and Zombies Low footprint in code and in time Object type-based as shown, but… …all code in package for reasons in link Object is set of timers: Reduces footprint Hash required for efficiency when many timers Oracle associative array (hash) traversed by key Hence use of hash to point to tabular array… …so can list results in order of timer creation Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 8
  • 9. Testing, Timing and Automation Unit testing  Oracle Unit Testing with utPLSQL  TRAPIT - TRansactional API Testing in Oracle  Automation means more work initially, but…  Automated regression testing gives confidence to refactor safely  Code is continuously refined and improved  Less technical debt Performance testing  A Framework for Dimensional Benchmarking of SQL Query Performance  Automation means more work initially, but…  More rigorous testing becomes possible  Additional queries or SQL statements can easily be added  Once parameterized, as many data points as desired can be tested  New tests use previous ones as a starting point Code timing object used in both my testing frameworks  Can trap issues such as index changes in unit test regression at negligible cost Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 9
  • 10. Dim_Bench_Sql_Oracle – Summary Output 3 kinds of statistics printed in matrix format (WxD and DxW) to csv files  Basic timing and output rows, including CPU and elapsed time  Execution plan aggregates, read from v$sql_plan_statistics_all  V$ statistics (after-before) differences, read from v$mystat, v$latch, v$sess_time_model Print full grid and ‘slice’, being the high point values for one of the dimensions Also print ratios of statistics to the smallest values across queries at the data point Example slice output for the 3 types (ORG_STRUCT problem): Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 10
  • 11. Example 1 – Simple Bursting Problem - Definition Determine break groups using distance from group start point All records that start within a fixed distance from the group start are in the group First record after the end of a group defines the next group start Example output using 3 days, omitting partition key Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 11 Detail Level START_DAT END_DATE GROUP_STA GROUP_END --------- --------- --------- --------- 01-JUN-11 03-JUN-11 01-JUN-11 07-JUN-11 02-JUN-11 05-JUN-11 01-JUN-11 07-JUN-11 04-JUN-11 07-JUN-11 01-JUN-11 07-JUN-11 08-JUN-11 16-JUN-11 08-JUN-11 16-JUN-11 09-JUN-11 14-JUN-11 08-JUN-11 16-JUN-11 20-JUN-11 30-JUN-11 20-JUN-11 30-JUN-11 Summary Level GROUP_STA GROUP_END NUM_ROWS --------- --------- ---------- 01-JUN-11 07-JUN-11 3 08-JUN-11 16-JUN-11 2 20-JUN-11 30-JUN-11 1
  • 12.  MOD_QRY: Model clause, no iteration. Linear in time by width  RSF_QRY: Recursive Subquery Factors Query 1 – Direct. Quadratic  RSF_TMP: Recursive Subquery Factors Query 2 – Pre-inserting to temporary table.  Linear due to indexed scan on temporary table  Framework allows for any SQL statement to be executed before the query  Included in timing and permits benchmarking of non-query SQL  MTH_QRY: Match Recognize. Linear Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 12 Example 1 – Simple Bursting Problem - Results
  • 13. Example 2 – General Bursting Problem 1 - Results Like 'simple' problem but using a running aggregate based on function of attributes Depth is number of records per partition key  MOD_QRY: Model clause using Automatic Order. Quadratic in time by depth  MOD_QRY_D: Model clause using (default) Sequential Order, via reverse ordering of a rule. Linear  RSF_QRY, RSF_TMP, MTH_QRY: Similar queries to Example 1, and similar behaviour Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 13
  • 14. Example 2 – General Bursting Problem 2 – Model Anomaly  MOD_QRY Plan: SQL MODEL CYCLIC. Quadratic timing variation: Very slow  Sequential Order -> ORA-32637: Self cyclic rule in sequential order Model  MOD_QRY_D Plan: SQL MODEL ORDERED. Linear timing variation: Much faster  Add non-default rule-ordering: final_grp[ANY] ORDER BY rn DESC = …  Now Rules Sequential Order does not throw an error  Exactly same functionally but ‘under the covers’ Model has used a much faster algorithm  Dimensional benchmarking shows difference without knowing underlying algorithms Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 14 WITH all_rows AS ( SELECT id, cat, seq, weight, sub_weight, final_grp FROM items MODEL PARTITION BY (cat) DIMENSION BY (Row_Number() OVER (PARTITION BY cat ORDER BY seq DESC) rn) MEASURES (id, weight, weight sub_weight, id final_grp, seq) RULES AUTOMATIC ORDER ( sub_weight[rn > 1] = CASE WHEN sub_weight[cv()-1] >= 5000 THEN weight[cv()] ELSE sub_weight[cv()-1] + weight[cv()] END, final_grp[ANY] = PRESENTV (final_grp[cv()+1], CASE WHEN sub_weight[cv()] >= 5000 THEN id[cv()] ELSE final_grp[cv()+1] END, id[cv()]) ) ) SELECT cat, final_grp, COUNT(*) num_rows FROM all_rows GROUP BY cat, final_grp ORDER BY cat, final_grp
  • 15. Example 3 – Bracket Parsing Obtain the matching brackets from string expressions (from OTN thread)  CBL_QRY, mathguy: Connect By, Analytics, Regex  MRB_QRY, Peter vd Zwan: Connect By, Match_Recognize  WFB_QRY, me: With PL/SQL Function, Arrays  PFB_QRY, me: Pipelined PL/SQL Function, Arrays  Pipelined function is fastest, slightly, but consistently ~5% faster than With Function  Match_Recognize only one to increase time with nesting level  Rises quadratically with number of bracket pairs, others rise more slowly though above linearly Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 15
  • 16. Example 4 – 5-Level Hierarchy  Fixed-level hierarchy traversal  Multi-child, multi-parent with multiplicative incidence factors  JNS_QRY: Sequence of joins  PLF_QRY: Recursive pipelined PL/SQL Function  RSF_QRY: Recursive subquery factor  JNS_QRY fastest, then RSF_QRY, with PLF_QRY slowest  PLF_QRY inefficiency caused by query execution at every node, observe correlation with #Recs  Above 140 disk writes rise, correlating with increase in elapsed-CPU time differences  RSF_QRY uses ~50% more disk writes than the others Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 16
  • 17. Example 5 – 5-Level Hierarchy by Joins – Hash Join “Inputs Order”  Same fixed-level hierarchy problem, JNS_QRY only, largest data point  Hash joining c to rowset (a.b), two ‘directions’  (a.b).c : rowset (a.b) is the hash table (‘build’ input), c is the ‘probe’ input - no_swap_join_inputs(c)  c.(a.b) : c is the ‘build’ and (a.b) the ‘probe’ input - swap_join_inputs(c)  leading, use_hash hints to force main join order, and hash joins  swap_join_inputs, no_swap_join_inputs to generate all 32 possible combinations  First half double elapsed time, and about an extra second of CPU time  Times correlates with disk writes, two sources:  Hash table spilling to disk: Eliminated by swap_join_order on final table  Other processing, also present in the other queries on previous slide Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 17
  • 18. Example 6 – String Splitting 1 – Problem / datasets / queries  Queries using Connect By for row generation  MUL_QRY - Cast/Multiset to correlate Connect By  LAT_QRY - v12 Lateral correlated Connect By  UNH_QRY - Uncorrelated Connect By unhinted  RGN_QRY - Uncorrelated Connect By with leading hint  GUI_QRY - Connect By in main query using sys_guid trick  RGX_QRY - Regular expression function, Regexp_Substr  Queries not using Connect By for row generation  XML_QRY - XMLTABLE  MOD_QRY - Model clause  PLF_QRY - database pipelined function  WFN_QRY - 'WITH' PL/SQL function directly in query  RSF_QRY - Recursive Subquery Factor  RMR_QRY - Match_Recognize Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 18  Split delimited strings into their tokens - very common question on forums  6 queries based on row-generation via Connect By, 6 using other methods  Width = number of tokens, depth = length of token  4 datasets: 1 dimension fixed at low/high value, other range of high/low values
  • 19. Example 6 – String Splitting 2 – Results for high numbers of tokens Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 19
  • 20.  RGN_QRY is my attempt at Connect By solution both simple and efficient  Generate max number of rows in subquery, join to main record on actual number  Need to prevent CBO from reversing the join order (UNH_QRY) with leading hint  31 seconds Example 6 – String Splitting 3 – Discussion of results  Best 3 methods all linear by number of tokens, worst 3 quadratic  Pipelined function best (across all data points, including not shown)  Same logic in SQL ‘WITH’ function about a third slower  Model, regex and recursive subquery factor quadratic and very slow Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 20  MUL_QRY is classic forum solution using complex ‘TABLE (CAST (MULTISET’ code  Syntax to correlate Connect By with the main record, effectively a pre-12.1 Lateral  Correlating a tree-walk is actually bad for performance  141 seconds  GUI_QRY is more recent forum favourite and simpler  Embeds Connect By in main query, using ‘PRIOR sys_guid() IS NOT NULL’ to circumvent ORA-01436  Turning main query into 1 big tree-walk is very inefficient  335 seconds
  • 21. Dim_Bench_Sql_Oracle – Data Model Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 21
  • 22. Dim_Bench_Sql_Oracle – Code Structure Diagram Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 22
  • 23. Data Setup Procedures – Pseudocode for string splitting example Construct timer (then increment throughout as desired) Truncate tables (execute immediate) Loop for 1 to deep point  Add character to base token string Loop for 1 to wide point  Add base token string with delimiter to string accumulating delimited string Loop for number of records to insert  Insert delimited string with uid to table Gather table statistics Write the timer set to log Set the output parameters Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 23
  • 24. Framework Installation Clone project from GitHub  BrenPatF/dim_bench_sql_oracle From the README  This is best run initially in a private database where you have sys user access  Clone the project and go to the relevant bat (pre-v12 versions) or bat_12c folder  Update bench.bat and SYS.bat with any credentials differences on your system  Check the Install_SYS.sql (Install_SYS_v11.sql) script, and ensure you have a write-able output folder with the same name as in the script  Run Install_SYS.bat (Install_SYS_v11.bat) to create the bench user and output directory, and grant privileges  Run Install_lib.bat to install general library utilities in the bench schema  Run Install_bench.bat to install the benchmarking framework in the bench schema  Run Install_bench_examples.bat (Install_bench_examples_v11.bat) to install the the demo problems  Check log files for any errors  Run Test_Bur.bat, or Batch_Bra.bat (etc.) for the demo problems Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 24
  • 25. References 1. BrenPatF/dim_bench_sql_oracle 2. Runstats 3. Code Timing and Object Orientation and Zombies 4. Big-O notation 5. Oracle Unit Testing with utPLSQL 6. TRAPIT - TRansactional API Testing in Oracle 7. A Framework for Dimensional Benchmarking of SQL Query Performance 8. Dimensional Benchmarking of Oracle v10-v12 Queries for SQL Bursting Problems 9. Dimensional Benchmarking of General SQL Bursting Problems 10. Dimensional Benchmarking of Bracket Parsing SQL 11. Dimensional Benchmarking of SQL for Fixed-Depth Hierarchies 12. Benchmarking of Hash Join Options in SQL for Fixed-Depth Hierarchies 13. Dimensional Benchmarking of String Splitting SQL Brendan Furey, 2017 Dimensional Performance Benchmarking of SQL 25

Editor's Notes

  1. https://www.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/big-o-notation
  2. http://betteratoracle.com/posts/12-runstats
  3. http://aprogrammerwrites.eu/?p=1632
  4. http://aprogrammerwrites.eu/?p=1545 http://aprogrammerwrites.eu/?p=1723 http://aprogrammerwrites.eu/?p=1833
  5. Dimensional Benchmarking of Oracle v10-v12 Queries for SQL Bursting Problems http://aprogrammerwrites.eu/?p=1836
  6. Dimensional Benchmarking of General SQL Bursting Problems http://aprogrammerwrites.eu/?p=1872
  7. Dimensional Benchmarking of Bracket Parsing SQL http://aprogrammerwrites.eu/?p=1913
  8. Dimensional Benchmarking of SQL for Fixed-Depth Hierarchies http://aprogrammerwrites.eu/?p=1937
  9. Benchmarking of Hash Join Options in SQL for Fixed-Depth Hierarchies http://aprogrammerwrites.eu/?p=1950
  10. Dimensional Benchmarking of String Splitting SQL http://aprogrammerwrites.eu/?p=1957
  11. https://github.com/BrenPatF/dim_bench_sql_oracle