Federated database performace

13
FEDERATED DATABASE PERFORMACE SUCCESS IS NEVER EASY DB2’s GOT TALENT GRAND FINALE PRESENTER: PRASAD PANDE

description

Performance Tuning parameters in the Federated System. Couple of parameters that I mentioned are not documented by IBM because they can be brutal to our system. But in my environment setup they proved to be very useful. So I will suggest that one should have a look at them and try those in your systems.

Transcript of Federated database performace

Page 1: Federated database performace

FEDERATED DATABASE PERFORMACE SUCCESS IS NEVER EASY

DB2’s GOT TALENT GRAND FINALE

PRESENTER: PRASAD PANDE

Page 2: Federated database performace

Quick Recap

For further details visit: http://prasadspande.wordpress.com/2014/03/23/db2-6-the-db2night-show-128-db2s-got-talent-top-10-finalists-compete/

Page 3: Federated database performace

Important Commands• CREATE WRAPPER NET8

LIBRARY 'libdb2net8.a' ;

• CREATE SERVER ora_server TYPE oracle

VERSION 11.2.0 WRAPPER net8

OPTIONS (NODE ‘ORCL');

• CREATE USER MAPPING FOR userName

SERVER ora_server

OPTIONS (REMOTE_AUTHID ‘username', REMOTE_PASSWORD ‘pwd) ;

• CREATE NICKNAME ora_emp FOR ora_server.scott.emp;

Page 4: Federated database performace

Creating MQT

• MQTs good for static tables.

E.g: Customer data, address etc.

• MQTs not good for constantly changing tables, requires call to remote data.

E.g: Customer transactions etc.

Page 5: Federated database performace

SYSCAT.SERVEROPTIONS

• View that catalogs the federated server settings for each remote data source.

• Each row specifies the server-specific options and corresponding values.

• Server option includes critical performance options like:

• PUSHDOWN

• DB2_MAXIMAL_PUSHDOWN

• DB2_SCALARFUNC_SCALAR_SQ

• DB2_SELECT_SCALAR_SQ

Page 6: Federated database performace

PUSHDOWN

• SELECT * FROM ORA_EMPLOYEE

WHERE CUSTOMERID = ‘053141245124’;

• Cardinality of the table : 42 Millions

• Original Execution Time: 29 secs

• Set PUSHDOWN parameter to ‘Y’ to allow the filtering of data at the remote data source.

ALTER SERVER ora_server

OPTIONS (ADD PUSHDOWN ‘Y’);

• Final Execution Time: < 1 sec

Page 7: Federated database performace

DB2_MAXIMAL_PUSHDOWN

• Determines whether to use the execution plan based on cost , or to favour pushing down the maximum number of operations.

• Setting this parameter to ‘Y’ will choose the execution plan with the lowest number of SHIP operators.

SET SERVER OPTION DB2_MAXIMAL_PUSHDOWN

TO ‘Y' FOR SERVER ora_server;

• Decision will not consider the statistical information of nicknames, nor consider the  CPU_RATIO and IO_RATIO settings.

Page 8: Federated database performace

DB2_SELECT_SCALAR_SQ

• Issues with federated queries involving sub-queries in their select list.

SELECT emp_name, (SELECT job_desc from job

where emp_no =123) from ora_emp;

• Allows the push down of such queries if set to ‘Y’.

SET SERVER OPTION db2_select_scalar_SQ TO 'Y'

for server  ora_server;

• Need to be careful. It might send the unsupported SQL for the pushdown which might result into the failure.

Page 9: Federated database performace

DB2_SCALARFUNC_SCALAR_SQ

• Creating the template for remote functions with no compatible counterpart.

CREATE FUNCTION localFunc_tmpl(INTEGER) RETURNS INTEGER AS TEMPLATE DETERMINISTIC NO EXTERNAL ACTION;

• Mapping the template with remote function.

CREATE FUNCTION MAPPING func_mapping

FOR localFunc_tmpl SERVER ORACLE_SERVER OPTIONS(REMOTE_NAME ‘RemoteFuncName');

• This parameter tell compiler if sub-query is allowed as a parameter to the scalar function.

SELECT localFunc_tmpl(select empno from ora_employee WHERE employee_name=‘PRASAD’);

Page 10: Federated database performace

Tips and Tricks

• Use fenced wrapper over unfenced to prevent optimizer from generating parallelized plans.

• Make sure that remote server has SAME code page as federated server.

• Can make use of PLAN_HINTS to send additional information to remote data source.

• Can make a use of SET PASSTHRU to query the remote database which are not pushed down.

set passthru server-name;

Call Remote sql statement;

set passthru reset;

Page 11: Federated database performace

This is what SUCESS is all about for me..

Page 12: Federated database performace