FEDERATED DATABASE PERFORMACE SUCCESS IS NEVER EASY DB2’s GOT TALENT GRAND FINALE PRESENTER: PRASAD PANDE
Jan 14, 2015
FEDERATED DATABASE PERFORMACE SUCCESS IS NEVER EASY
DB2’s GOT TALENT GRAND FINALE
PRESENTER: PRASAD PANDE
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/
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;
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.
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
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
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.
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.
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’);
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;
This is what SUCESS is all about for me..
Email: pande.prasad1@gmail.com
Twitter: Follow me at @pandeprasad1
LinkedIn: in.linkedin.com/pub/prasad-pande/24/292/a23/
Blog: http://prasadspande.wordpress.com/
My Experience about DB2’s Got Talent and db2nightshow at
prasadspande.wordpress.com/2014/03/08/db2-4-db2nightshow-delic
ious-dinner-for-fridays
/
Vote for Prasad..!!