BigSQLv4102 BestPractices and Performance Session7 ProblemDetermination 15012016
BigSQLv4102 BestPractices and Performance Session7 ProblemDetermination 15012016
SQL
Big Best Practices
For questions about this presentation contact Simon Harris [email protected] © 2015 IBM Corporation
IBMIBM
Analytics
Security
Session 7:
Big SQL Performance
Problem Determination
1. General Problem Determination
2. Performance Problem Determination:
a. Statistics
b. How to identify a Suspicious Plan
c. Ways to influence the Optimizer
d. Big SQL Health Check
e. Docs to collect
Big SQL logs information to a number of log files located in (v4 and
beyond): /var/ibm/bigsql
File Description
diag/DIAGXXXX The "db2dump" directory. Contains Big SQL (DB2) runtime log files,
event files, trace information, dumps, and traps. ‘XXXX’ represents the
node number.
logs/bigsql.log Log messages for the java I/O and DDL handler
logs/bigsql-sched.log Log for the scheduler service. Only found on the host on which the
scheduler is installed (typically the Big SQL master node)
logs/bigsql-ndfsio.log Log for the native I/O engine
SQL5197N
SQL5197N The
The statement
statement failed
failed because
because of
of aa communication
communication error
error
with a Big SQL component. Big SQL component name:
with a Big SQL component. Big SQL component name: "HDFS"."HDFS".
Reason
Reason code:
code: "1".
"1". Log
Log entry
entry identifier:
identifier: "BSL-9-3ef8abc4".
"BSL-9-3ef8abc4".
The "Log entry identifier" indicates that the details of the failure may be found
in a specific Big SQL log file. The format is:
NRL-9-3ef8abc4
Which Log File Which Node What to Look For
BSL – bigsql.log The node # (from A unique string to
SCL – bigsql-sched.log db2nodes.cfg) that search for in the log
NRL – bigsql-ndfsio.log owns the log file to locate the error
DDL – DB2 diag logs
Edit the appropriate file and search for the “Log entry identifier”.
Info related to the error messages can also be retrieved using SQL:
SELECT * FROM table(SYSHADOOP.LOG_ENTRY('log_entry_id'));
For example:
Can also control the number of lines output before and after:
– Output 30 lines before, 30 lines after:
Most likely causes of Big SQL performance issues - in approximate order (most
frequent first):
1. Incomplete or inaccurate statistics
2. Only small amount of cluster resources dedicated to Big SQL – default of 25% used
3. Single disk used for temporary working data – default of one path/disk used
4. Not using the most optimal storage format
5. Big SQL Configuration
6. Mapping Hive String data types as VARCHAR(32k) – default of 32k used
First port of call for a Big SQL performance problem – Make sure ANALYZE has
been run and statistics are up to date
1 STATS_TIME CARD
------------ -------------------------- --------------------
NATION - -1
ORDERS - -1
CUSTOMER - -1
LINEITEM - -1
STATS-TIME=-. CARD=-1.
ANALYZE not ANALYZE not
run. run.
7 © 2015 IBM Corporation
IBMIBM
Analytics
Security
Diagnostic Identifier: 1
Diagnostic Details: EXP0021W Table column has no statistics. The
column "DATEKEY" of table “EDW ".
"DIMENSION" has not had runstats run on it.
This can lead to poor cardinality and predicate
filtering estimates.
Diagnostic Identifier: 2
Diagnostic Details: EXP0021W Table column has no statistics. The
column "APP_TYPE" of table “EDW ".“FACT"
has not had runstats run on it. This can lead to
poor cardinality and predicate filtering estimates.
But it cannot tell you if the statistics are out of date or inaccurate
Therefore, in BigSQL, a NLJOIN will scan all the qualifying rows of the inner for
every row of the outer
– This can be very costly if there are more than just a handful of rows on the outer
Nested Loop Joins (NLJOIN) can be efficient in Big SQL when it can guarantee
there is only a single row qualifying on the outer
– And also for Hbase lookups
If correct statistics are not enough to achieve an efficient access plan, then
there are alternative ways to influence the access plan chosen by the optimizer
Use the SELECTIVITY clause to tell the optimizer the correct filter factor of
predicates
– Useful for influencing plans
When this registry variable is set to YES, the SELECTIVITY clause can be
specified for the following predicate types:
– A user-defined predicate
– A basic predicate in which at least one expression contains host variables or parameter
markers
Add the SELECTIVITY clause to the SQL statement indicating the selectivity of
the predicate
– over-writes the filter factor being calculated by the optimizer.
– For example, to tell the optimizer that this predicate will select 10% of the data from the table:
D_DATE >= :orderdate SELECTIVITY 0.1
If Big SQL is the priority resource on this cluster, increase using autoconfigure
command:
call syshadoop.big_sql_service_mode('on');
autoconfigure using mem_percent 75
workload_type complex
is_populated no
apply db and dbm;
To find out if the default was changed to use the recommended multiple paths, use the
following query:
SELECT member,count(container_name) as count_containers FROM TABLE(MON_GET_CONTAINER('',-
2)) AS t where tbsp_name='TEMPSPACE1' group by member ;
+--------+------------------+
| MEMBER | COUNT_CONTAINERS |
+--------+------------------+
| 0 | 9 |
| 1 | 9 |
| 2 | 9 |
| 3 | 9 |
| 4 | 9 |
+--------+------------------+
Temporary tablespace should be spread across the same set of disks as your Hadoop
data. See following article to redistribute tablespace paths:
https://developer.ibm.com/hadoop/blog/2016/02/02/redistribute-big-sql-4-x-storage-paths/
See “Session 2: Best Practices: 1. Physical Database Design” for more information.
<APP_HANDLE><AUTHID>
+-----------------+--------------------+------------+------------+----------+
| SCHEMA | TABNAME | APP_HANDLE | DATA_SIZE | LOB_SIZE |
+-----------------+--------------------+------------+------------+----------+
| <413><BIGSQL > | TEMP (00001,00336) | 413 | 1591148544 | [NULL] |
| <436><BIGSQL > | TEMP (00001,00002) | 436 | 365330432 | [NULL] |
| <429><BIGSQL > | TEMP (00001,00003) | 429 | 3548217344 | [NULL] |
| <429><BIGSQL > | TEMP (00001,00004) | 429 | 3547267072 | [NULL] |
| <413><BIGSQL > | TEMP (00001,00005) | 413 | 131072 | [NULL] |
| <436><BIGSQL > | TEMP (00001,00006) | 436 | 371982336 | [NULL] |
| <429><BIGSQL > | TEMP (00001,00007) | 429 | 173801472 | [NULL] |
| <429><BIGSQL > | TEMP (00001,00008) | 429 | 173867008 | [NULL] |
| <429><BIGSQL > | TEMP (00001,00009) | 429 | 173899776 | [NULL] |
17 © 2015 IBM Corporation
IBMIBM
Analytics
Security
db2set
See “Session 2: Best Practices: 4. Big SQL Logical Design” for more information.