0% found this document useful (0 votes)
45 views42 pages

Performance Tune Iseries Access Odbc: I Want Stress-Free It. I Want Control. I Want An

ODBC IBM AS400 DB2

Uploaded by

senzai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views42 pages

Performance Tune Iseries Access Odbc: I Want Stress-Free It. I Want Control. I Want An

ODBC IBM AS400 DB2

Uploaded by

senzai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

IBM System i™

Session: 401918
Agenda Key: 42MK

Performance Tune iSeries Access ODBC

Brent Nelson - bmnelson@[Link]


iSeries Access Development

8 Copyright IBM Corporation, 2006. All Rights Reserved.


i want stress-free IT. This publication may refer to products that are not currently
available in your country. IBM makes no commitment to make

i want control. available any products referred to herein.

i want an i.

IBM System i

Typical Performance Problems

Client

Network

Server

i want an i. © 2006 IBM Corporation

1
IBM System i

Typical Performance Problems

• Fetching data
• Long-running SQL queries
• Network issues
• Inserting data
• Lots of connections

i want an i. © 2006 IBM Corporation

Applications
Database (Host)
DB2 Control PCOMM File
iSeries Navigator Data Transfer On
Center Transfer
Demand
Middleware

ODBC CLI/ODBC
JDBC .NET .NET
(Windows, DB APIs OLE DB (Windows, JDBC OLE DB
Linux) Toolbox Linux, AIX)

ODBC iSeries
JDBC HTTP
Database (Linux Access
Toolbox DDM / DRDA File Transfer
Host Server partition) for Web
Server Server
Websphere [Link]
Middleware
Native

Stored Stored
Procedures Native Native Procedures
CLI JDBC

DB2 UDB for iSeries

System i5

OWNER: iSeries Access DB2 V8.2 iSeries function Other

2
IBM System i

Explanation of Scale

Programming Potential
Required? Benefit

Y 3

Y = Yes 1 = Low
N = No 2 = Medium
3 = High

i want an i. © 2006 IBM Corporation

IBM System i

Agenda

• Process for Analyzing Performance Problems


• Performance Considerations
– Application Design
– Network
– Database Design
• Examples
– 3-Tier Application
– Off-the-shelf Applications
• Appendices

i want an i. © 2006 IBM Corporation

3
IBM System i

Process for Analyzing Performance Problems

1. Understand what the application is doing


2. Narrow down the problem
3. Understand options to fix the problem
4. Fix the problem

i want an i. © 2006 IBM Corporation

IBM System i

Understand What the Application is Doing

• Lots of data retrieved?


• Lots of data inserted?
• Lots of connections?
• Complex queries?
• LOB fields?
• Problem related to scaling application?
• Did something change recently?
• …

i want an i. © 2006 IBM Corporation

4
IBM System i

Narrow Down the Problem

• Review database design


• Time parts of code

i want an i. © 2006 IBM Corporation

IBM System i

Understand Options to Fix Problem

• Research options
• Understand the benefits to different alternatives

i want an i. © 2006 IBM Corporation

5
IBM System i

Fix the Problem

• Make changes
• Compare performance before / after

i want an i. © 2006 IBM Corporation

IBM System i

Performance Considerations

• Application design
– Choice of programming interface
– Connection pooling
– Inserting data
– Fetching data
– Isolation level and concurrency
• Network
• Database design

i want an i. © 2006 IBM Corporation

6
IBM System i

Y 2
Choosing a Programming Interface

Application

[Link] ADO
Delphi Powerbuilder PHP
ODBC .NET MSDASQL
Provider Provider

ODBC Driver Manager

iSeries Access ODBC Driver

DB2 UDB for iSeries

i want an i. © 2006 IBM Corporation

IBM System i

Y 3
Connection Pooling

Application Application using Connection Pooling

1 2 3 1 3 2

C1 C2 C3 C1 C2

DB2 UDB for iSeries

i want an i. © 2006 IBM Corporation

7
IBM System i

Insert Data (Example Scenario)

Customer has submitted an order for 3 items on our website

We need to record this in the ORDERS table on the System i5

i want an i. © 2006 IBM Corporation

IBM System i

Insert Data - Insert with Constants

INSERT INTO ORDERS


C1 S1 VALUES ( ‘book’, 12345 )

INSERT INTO ORDERS


S2 VALUES ( ‘watch’, 12345 )

INSERT INTO ORDERS


S2 VALUES ( ‘phone’, 12345 )

System i5

i want an i. © 2006 IBM Corporation

8
IBM System i

Y 2
Insert Data - Prepare Once, Execute Many

INSERT INTO ORDERS


C1 S1 VALUES ( ?, ? )

‘book’, 12345
‘watch’, 12345
‘phone’, 12345

System i5

i want an i. © 2006 IBM Corporation

IBM System i

Y 3
Insert Data - Block Insert

INSERT INTO ORDERS


C1 S1 VALUES ( ?, ? )

‘book’, 12345
‘watch’, 12345
‘phone’, 12345

System i5

i want an i. © 2006 IBM Corporation

9
IBM System i

Insert Data - Block Insert Notes

• Best alternative because:


– Parsed only once
– Avoids full open/close of target table
– 1 send/receive for N rows
– Path optimized from client->database

• Drawbacks
– May not be practical for all applications
– AS/400 only feature if use "? rows" SQL clause

i want an i. © 2006 IBM Corporation

IBM System i

Block Insert Performance

For 500 36-byte rows with three columns

Insert with Literals 97.6x


constants
Prepare once,
Execute many PM 13.6x

Block insert
Block Insert
x
0 20 40 60 80 100

Response Time

i want an i. © 2006 IBM Corporation

10
IBM System i

Deleting Data Y 1

• Consider:
CALL [Link]( ‘CLRPFM FILE(MYLIB/MYFILE)’,0000000025.00000)

• Instead of:
DELETE FROM [Link]

• NOTE: This is not necessary on V5R3 (and later) systems.

i want an i. © 2006 IBM Corporation

IBM System i

Fetching Data - Blocking N 3

Application ODBC Driver Server

i want an i. © 2006 IBM Corporation

11
IBM System i

Fetching Data – Settings that Affect Blocking N 3

• Cursor Type
– SQLSetStmtAttr API with SQL_ATTR_CURSOR_TYPE option
– Forward-only versus Scrollable
• Rowset size
– SQLSetStmtAttr API with SQL_ATTR_ROW_ARRAY_SIZE option
• Block fetch of 1 row option (BLOCKFETCH keyword)
– Block size option – (BLOCKSIZE keyword)
• Cursor Concurrency
– SQLSetStmtAttr API with SQL_ATTR_CONCURRENCY option

i want an i. © 2006 IBM Corporation

IBM System i

Fetching Data - Forward-only Cursor Examples

• Table retrieving from has a 32K row size

• Example 1: App Driver Server


– Application is fetching one row at a time
– Block fetch of 1 row option with a Block Size of 32K
– Results: 1 row at a time is fetched

• Example 2: App Driver Server


– Application is fetching one row at a time
– Block fetch of 1 row option with a Block Size of 128K
– Results: ~4 rows are fetched at a time

• Example 3: App Driver Server


– Application is fetching with rowset size of 4 rows
– Results: 4 rows are fetched at a time

i want an i. © 2006 IBM Corporation

12
IBM System i

Fetching Data - Scrollable Cursor Examples

• Table retrieving from has a 32K row size

• Example 1:
– Application is fetching one row at a time App Driver Server
– Results: 1 Row is fetched at a time

• Example 2:
– Application is fetching with rowset size of 4 rows
App Driver Server
– Results: 4 Rows are fetched at a time

i want an i. © 2006 IBM Corporation

IBM System i

Fetching Data – SQLBindCol vs SQLGetData Y 2

• Example:
– SQLBindCol usage: COL1 COL2 COL3
• 3 SQLBindCol calls
• up to 5 SQLFetch calls

– SQLGetData usage:
• 5 SQLFetch calls
• 15 SQLGetData calls

i want an i. © 2006 IBM Corporation

13
IBM System i

N 2
Large Objects (LOBs)

• MAXFIELDLEN keyword
– Default is 32 (KB)
– Lower setting usually better

• Inserting data
– Use SQLParamData / SQLPutData

• Fetching data
– Use SQLGetData

i want an i. © 2006 IBM Corporation

IBM System i

Y 1
Isolation Level

• By default, ODBC runs with autocommit ON


– Equivalent to *NONE on pre-V5R3 servers
• Use lowest level of transaction isolation for least overhead

Isolation Level Overhead

(*NONE) Commit immediate less


(*CHG) Read uncommitted
(*CS) Read committed
(*ALL) Repeatable read
(*RR) Serializable more

i want an i. © 2006 IBM Corporation

14
IBM System i

Application Design Summary

• Use connection pooling


• Use parameter markers
• SQLPrepare once, SQLExecute many times
• Use blocking effectively

i want an i. © 2006 IBM Corporation

IBM System i

Performance Considerations

• Application design
• Network
– Reduce Trips to Server
– Reduce Data Between Server
• Database design

i want an i. © 2006 IBM Corporation

15
IBM System i

Network

• About 1/3 of all ODBC performance problems


• ODBC sends much larger blocks of data then most applications

i want an i. © 2006 IBM Corporation

IBM System i

N 2
Reduce Trips to Server

• Stored procedures
• Triggers
• Connection pooling
• Block inserts
• Block fetches
• Lazy close
• Pre-fetch

i want an i. © 2006 IBM Corporation

16
IBM System i

Reduce Trips to Server

• iSeries Navigator connection


properties
– IP Address lookup
– Port lookup

i want an i. © 2006 IBM Corporation

IBM System i

Reduce Data Between Server

• Data compression
• LOB threshold
• Avoid “SELECT *” SQL statements

i want an i. © 2006 IBM Corporation

17
IBM System i

N 3
Data Compression

• “Enable Data Compression” DSN setting ON by default


• Recommended for variable length fields
– e.g. VARCHAR, VARGRAPHIC
• Improved compression algorithm on V5R1+ servers

i want an i. © 2006 IBM Corporation

IBM System i

N 2
CWBCOPWR

• Options to concentrate on:


– Communication buffer size (Option /SC)
– TCP/IP buffer size (Options /WSS and /WSR)
– TCP/IP nagling (Option /NGL)

• Found in \Program Files\IBM\Client Access directory


• See [Link] for help

i want an i. © 2006 IBM Corporation

18
IBM System i

Network Summary

• Reduce Trips to Server


• Reduce Data Between Server

i want an i. © 2006 IBM Corporation

IBM System i

Windows ODBC DSN Setup GUI N 3

• Performance tab
• Advanced performance options
• Package tab

ODBC DSN keywords:


[Link]

i want an i. © 2006 IBM Corporation

19
IBM System i

N 3
Linux ODBC DSN GUI

• Other options added to the .[Link]


file or programmatically specified via
SQLDriverConnect API

i want an i. © 2006 IBM Corporation

IBM System i

Performance Considerations

• Application design
• Network
• Database design
– Indexes
– Extended dynamic support
– Stored procedures
– Trigger programs

i want an i. © 2006 IBM Corporation

20
IBM System i

SQL Interfaces
ODBC / JDBC / ADO

Network

Host Server

Static Dynamic Extended


Dynamic
Compiled Prepare Prepare
embedded every once and
statements time then
reference
SQL

Optimizer

DB2 UDB
(Data Storage & Management)

i want an i. © 2006 IBM Corporation

IBM System i

Y 2
SQL Statement Tuning

• Avoid SELECT *
• SQL clauses:
– OPTIMIZE FOR N ROWS
– FOR FETCH ONLY / FOR UPDATE
– FETCH FIRST N ROWS ONLY

i want an i. © 2006 IBM Corporation

21
IBM System i

Indexes N 3

• Two methods for accessing data--keyed and sequential


– Lack of understanding can seriously impact performance
• Aimed specifically at optimizing queries (SELECTs)
• Most important aspect--proper indices for queries

i want an i. © 2006 IBM Corporation

IBM System i

Indexes

• Index is required for following cases:


– ORDER BY
– GROUP BY
– JOIN of two tables
• Optimizer will create index if an appropriate one doesn't exist

i want an i. © 2006 IBM Corporation

22
IBM System i

Indexes

• Create index over tables when queries return less than 20% of table
– Create index over columns used in WHERE clause
– Create index over columns used to join tables
– Create index on grouping columns

• White paper: "Indexing Strategies for DB2 UDB for iSeries"


[Link]

i want an i. © 2006 IBM Corporation

IBM System i

Access Plans and ODPs Y 3

• Minimize access plan builds


– Reduces CPU use on server
• Reuse (Open Data Path) ODPs
– Prepare once/run many
– Statement pooling
– Connection pooling
– Use parameter markers
– Cache package locally

i want an i. © 2006 IBM Corporation

23
IBM System i

Extended Dynamic Access (Packages) Y 3

1. Application runs:
SELECT * FROM MYTABLE
SELECT * FROM MYTABLE WHERE COL1=? WHERE COL1=?
2. Application re-runs: Access plan
SELECT * FROM MYTABLE WHERE COL1=?

Package

i want an i. © 2006 IBM Corporation

IBM System i

Extended Dynamic Access (Packages)

• Caches SQL statements on server or local


• Allows reuse of statements (across sessions)
• Can be shared among many users

i want an i. © 2006 IBM Corporation

24
IBM System i

SQL Statements in Packages

• The following SQL statements are put into extended dynamic packages:
– Statements that contain parameter markers
– INSERT with subselect
– Positioned UPDATE or DELETE
– SELECT FOR UPDATE
– DECLARE PROCEDURE

i want an i. © 2006 IBM Corporation

IBM System i

N 2
QAQQINI file

• OPTIMIZATION_GOAL
– *DEFAULT
• Packages: *ALLIO
• No Packages: *FIRSTIO
– *FIRSTIO
– *ALLIO

• QAQQINI query options:


[Link]

i want an i. © 2006 IBM Corporation

25
IBM System i

Stored Procedures Y 3

• Powerful tool--accepts input parameters, returns output parameters


• SQL procedure
• Stored procedure as external procedure
– Does not need to contain SQL
– Can be any C, RPG, CL, COBOL, Java program
• Can return multiple result sets
• Can hide details of application from user

i want an i. © 2006 IBM Corporation

IBM System i

Stored Procedures

• Stored Procedures can be utilized to provide...


– Static SQL performance behavior to dynamic ODBC & JDBC client requests
– Access to tuning knobs/precompiler options such as ALWCPYDTA, etc

i want an i. © 2006 IBM Corporation

26
IBM System i

Insert Data (Example Scenario)

Customer has submitted an order for 3 items on our website

We need to record this in the ORDERS table on the System i5

i want an i. © 2006 IBM Corporation

IBM System i

Insert Data - Stored Procedure Example

create procedure PLACEORDER( ITEM in varchar(20), CUSTID in int)


language sql
begin

declare sqlstmt char(2048);

set sqlstmt = 'insert into ORDERS values ( ''' || ITEM || ''', ' || CUSTID || ')';
execute immediate sqlstmt;

end

i want an i. © 2006 IBM Corporation

27
IBM System i

Y 2
Insert Data - Stored Procedure

CALL PLACEORDER ( ? , ? )
C1 S1
‘book’, 12345
PLACEORDER
‘watch’, 12345 Stored Procedure
‘phone’, 12345

i want an i. © 2006 IBM Corporation

IBM System i

Insert Data - Stored Procedure Example

create procedure PLACEORDER( ITEM in varchar(20), CUSTID in int)


language sql
begin

declare sqlstmt char(2048);

set sqlstmt = 'insert into ORDERS values ( ''' || ITEM || ''', ' || CUSTID || ')';
execute immediate sqlstmt;

set sqlstmt =
'update ORDERLOG set TIME=CURRENT_TIMESTAMP
where CUSTID = ' || CUSTID;
execute immediate sqlstmt;

end

i want an i. © 2006 IBM Corporation

28
IBM System i

Y 2
Trigger Programs

• Based on target file/table


• Can be invoked for each INSERT/UPDATE/DELETE against the table
• Slight performance advantage over stored procedures
• Be careful: All operations, regardless of origin, fire the trigger program

i want an i. © 2006 IBM Corporation

IBM System i

iSeries Navigator Tools

• SQL Performance Monitor


– DSN setting for “Enable Database Monitor” located on Diagnostic tab
– File stored in QUSRSYS/QODBxxx where xxx is the job number
• Visual Explain
– Query Access Plan Diagram
– Index Advisor

• Links:
– [Link]
– [Link]

i want an i. © 2006 IBM Corporation

29
IBM System i

Other Database Tools

• Graphical
– Centerfield Technology DB Essentials
• [Link]
• Text-based
– Debug joblogs
– SST (iSeries Communication Trace)
– ODBC trace ([Link])

i want an i. © 2006 IBM Corporation

IBM System i

Database Design Summary

• Create indices where needed


• Use stored procedures where possible

i want an i. © 2006 IBM Corporation

30
IBM System i

Examples

• 3-Tier application
• Stand-alone application
• Solutions for typical performance problems

i want an i. © 2006 IBM Corporation

IBM System i

Example Scenarios (3-Tier Application)

Presentation Layer Business Logic Database/Services

Any
Web/
App
Server

i want an i. © 2006 IBM Corporation

31
IBM System i

Helpful Settings with 3-Tier Applications

• Goals

• Settings
– Connection pooling
– Stored procedures
– Block fetches

i want an i. © 2006 IBM Corporation

IBM System i

Example scenarios (Stand-alone application)

MS Excel MS Access Open Office

[Link] ADO
Delphi Powerbuilder PHP
ODBC .NET MSDASQL
Provider Provider

ODBC Driver Manager

iSeries Access ODBC Driver

DB2 UDB for iSeries

i want an i. © 2006 IBM Corporation

32
IBM System i

Helpful settings with stand-alone applications

• Goals

• Settings
– Block fetch of 1 row
– Compression
– LOB threshold
– Packages

i want an i. © 2006 IBM Corporation

IBM System i

Summary

• Process
– Understand application
– Narrow problem
– Understand options
– Fix problem
• Application Design:
– Use parameter markers
– Prepare once, execute many
• Network:
– Adjust data compression as needed
– Use blocking
• Database Design:
– Indexes
– Use stored procedures

i want an i. © 2006 IBM Corporation

33
IBM System i

iSeries Access for Windows sessions:

32MC - iSeries Access for Windows: What’s New in V5R4


33MI - iSeries Access Data Transfer: Tips & Techniques
42MK - Performance Tune iSeries Access ODBC
43MC - PC5250 Emulation: Everything You Need To Know
46ME - iSeries Access in the .NET World

iSeries Access for Linux session:

53ML – Creating the iSeries Linux Desktop

Stop in EXPO for a demo…

Functional enhancements can be submitted via the FITS system. The


url is:
[Link]
And click on link “Request for Design Change”

i want an i. © 2006 IBM Corporation

IBM System i

Session Title: Performance Tune iSeries Access ODBC

Session ID: 401918

Agenda Key: 42MK

Speaker: Brent Nelson

i want an i. © 2006 IBM Corporation

34
IBM System i

Appendices

• A – Reference Information
• B – Insert data example code
• C – Compression
• D – Extended Dynamic Packages

i want an i. © 2006 IBM Corporation

IBM System i

A.1 - Additional Client-side Information

• ODBC
– [Link]

• OLE DB
– See OLE DB Tech Ref installed with iSeries Access

• .NET
– See .NET Tech Ref installed with V5R4 iSeries Access

• JDBC
– [Link]

i want an i. © 2006 IBM Corporation

35
IBM System i

A.2 - Additional Information

• DB2 UDB for iSeries home page


– [Link]
• Newsgroups
– [Link]
– [Link]-db2
• Education Resources - Classroom & Online
– [Link]
• DB2 UDB for iSeries Publications
– Online Manuals: [Link]
– Indexing Strategies for DB2 UDB for iSeries: [Link]
– DB2 UDB for AS/400 Redbooks ([Link]
• DB2 UDB for AS/400 Object Relational Support (SG24-5409)
• DB2/400 Advanced Database Functions (SG24-4249-02)
• SQL/400 Developer's Guide by Paul Conte & Mike Cravitz
– 29th Street Press, ISBN 1-882419-70-7
– [Link]

i want an i. © 2006 IBM Corporation

IBM System i

A.3 - Performance Service Tips

• Before calling SupportLine with a query performance problem...


– Run query in DEBUG mode and check JOBLOG
• Index recommendations
• Understand query implementation
– Check resources and Work Management
• QQRYDEGREE or CHGQRYA
• Memory and MAX ACTIVE settings
• What else is running?
• Does QQQOPTIONS data area exist?
– Check file stats
• Size of objects, number of rows
• Number of indexes
– Understand your data
– Save JOBLOGs and system settings

i want an i. © 2006 IBM Corporation

36
IBM System i

A.4 - Tech Tip: Improve Query Performance

• DB2 UDB for iSeries has a phenomenal query optimizer built into it.
– without the DB2 Symmetric Multiprocessing (SMP) feature your SQL database tasks
and index builds are running single-threaded?
– the DEFAULT system tuning setup could be significantly hindering ODBC performance?
– the database utility called DB2 OLAP can provide sub-second response times to
complex queries?
• For more information about query optimization, check out these resources:
– S6140 – iSeries/i5 Performance Analysis Workshop:
• [Link]
– DB2 Symmetric Multiprocessing and DB2 OLAP Utilities:
• [Link]

i want an i. © 2006 IBM Corporation

IBM System i

B.1 - Insert Data - Insert with Constants

strcpy(stmt, "insert into ORDERS values(‘book‘, 12345)");


rc = SQLExecDirect(hStmt, stmt, SQL_NTS);

strcpy(stmt, "insert into ORDERS values(‘watch‘, 12345)");


rc = SQLExecDirect(hStmt, stmt, SQL_NTS);

strcpy(stmt, "insert into ORDERS values(‘phone‘, 12345)");


rc = SQLExecDirect(hStmt, stmt, SQL_NTS);

i want an i. © 2006 IBM Corporation

37
IBM System i

B.2 - Insert Data - Prepare Once, Execute Many

strcpy(stmt,"insert into ORDERS values (?,?)");


rc = SQLPrepare(hStmt, stmt, SQL_NTS);

rc = SQLBindParameter(hStmt, 1, .... , szItem, … );


rc = SQLBindParameter(hStmt, 2, .... , &custID, … );

strcpy(szItem, ”book”);
custID = 123
rc = SQLExecute(hStmt);

strcpy(szItem, ”watch”);
rc = SQLExecute(hStmt);

strcpy(szItem, ”phone”);
rc = SQLExecute(hStmt);

i want an i. © 2006 IBM Corporation

IBM System i

B.3 - Insert Data – Block Insert

strcpy(stmt, "insert into ORDERS values (?,?)");


rc = SQLPrepare(hStmt, stmt, SQL_NTS);

rc = SQLSetStmtAttr(hStmt, SQL_ATTR_PARAMSET_SIZE, (PTR)3, … );

rc = SQLBindParameter(hStmt, 1, .... , szItemArray[0], … );


rc = SQLBindParameter(hStmt, 2, .... , &custID, … );

strcpy(szItemArray[0], ”book”);
strcpy(szItemArray[1], ”watch”);
strcpy(szItemArray[2], ”phone”);
custID = 12345;

rc = SQLExecute(hStmt);

i want an i. © 2006 IBM Corporation

38
IBM System i

B.4 - Insert Data - Stored Procedure

strcpy(stmt, "CALL PLACEORDER (?,?)");


rc = SQLPrepare(hstmt1, stmt, SQL_NTS);

rc = SQLBindParameter(hStmt, 1, .... , szItem, … );


rc = SQLBindParameter(hStmt, 2, .... , &custID, … );

strcpy(szItem, ”book”);
custID = 123
rc = SQLExecute(hStmt);

strcpy(szItem, ”watch”);
rc = SQLExecute(hStmt);

strcpy(szItem, ”phone”);
rc = SQLExecute(hStmt);

i want an i. © 2006 IBM Corporation

IBM System i

C.1 - Compression

• Can be activated at the connection level or statement level


• Connection level settings
– COMPRESSION=1 in SQLDriverConnect connection string OR...
– SQLSetConnectAttr(hdbc, 2106, 1) OR...
– “Enable Data Compression” option on ODBC DSN setup GUI
• Statement level settings
– SQLSetStmtAttr(hstmt, 2106, 1)

i want an i. © 2006 IBM Corporation

39
IBM System i

D.1 Package contents

• Extended dynamic
– Use iSeries Navigator to view the contents of the package
– Alternatively, you can use the PRTSQLINF command on the System i5 to
dump the package containing your statements
– PRTSQLINF produces spoolfile showing syntax and optimization information

i want an i. © 2006 IBM Corporation

IBM System i

D.2 - Package contents sample

Extended Dynamic
Sample PRTSQLINF output:

5722SS1 V5R2M0 030905 Print SQL information SQL package QGPL/ODBCXXXFBA


Object name...............QGPL/ODBCXXXFBA
Object type...............*SQLPKG
CRTSQL***
PGM(QGPL/ODBCXXXFBA)
SRCFILE( / )
SRCMBR( )
COMMIT(*NONE)
OPTION(*SQL *PERIOD)
TGTRLS(*PRV)
ALWCPYDTA(*OPTIMIZE)
CLOSQLCSR(*ENDPGM)
STATEMENT TEXT CCSID(37)
STATEMENT NAME: QZ84DC1FE6AC488000
select * from [Link] where lstnam=?
SQL4021 Access plan last saved on 09/16/02 at [Link].
SQL4020 Estimated query run time is 1 seconds.
SQL4027 Access plan was saved with DB2 UDB Symmetric Multiprocessing installed on the system.
SQL4010 Table scan access for table 1.

i want an i. © 2006 IBM Corporation

40
IBM System i

D.3 - Unusable packages

• Package can become unusable if package attributes do not match


application
– Different CCSID, Date & time format attributes, decimal delimiter, default
collection, etc
– With ODBC packages, a default collection for unqualified names can be
specified - if package already exists and the client application has a different
default collection, then package cannot be used
– If package unusable, new requests are executed as "pure" Dynamic SQL

i want an i. © 2006 IBM Corporation

IBM System i

D.4 - Package names

• First time an SQL statement is prepared, the package is created (if it


doesn't exist yet)
• Can specify a name and location for package on the data source or let
the system do that work
– Default ODBC SQL package name is created by taken the first 7 characters of
the application name and appending 3 letters that are encoding of the package
configuration attributes
• Default package name for Lotus Approach would be: APPROACFBA
• New setup GUI allows setting of package name for a specific application
– Default library determined by data source configuration

i want an i. © 2006 IBM Corporation

41
IBM System i

Sample Code Disclaimer

This material contains IBM copyrighted sample programming source code for your
consideration. This sample code has not been thoroughly tested under all conditions. IBM,
therefore, cannot guarantee or imply reliability, serviceability, or function. IBM provides no
program services for this material. This material is provided "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSIONS MAY NOT
APPLY TO YOU. IN NO EVENT WILL IBM BE LIABLE TO ANY PARTY FOR ANY
DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY USE
OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOST PROFITS,
BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON YOUR
INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN IF EXPRESSLY ADVISED
OF THE POSSIBILITY OF SUCH DAMAGES.

i want an i. © 2006 IBM Corporation

IBM System i

Trademarks and Disclaimers


8 IBM Corporation 1994-2006. All rights reserved.
References in this document to IBM products or services do not imply that IBM intends to make them available in every country.

Trademarks of International Business Machines Corporation in the United States, other countries, or both can be found on the World Wide Web at
[Link]

Intel, Intel logo, Intel Inside, Intel Inside logo, Intel Centrino, Intel Centrino logo, Celeron, Intel Xeon, Intel SpeedStep, Itanium, and Pentium are trademarks or registered
trademarks of Intel Corporation or its subsidiaries in the United States and other countries.
Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.
Other company, product, or service names may be trademarks or service marks of others.

Information is provided "AS IS" without warranty of any kind.

The customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual
environmental costs and performance characteristics may vary by customer.

Information concerning non-IBM products was obtained from a supplier of these products, published announcement material, or other publicly available sources and does
not constitute an endorsement of such products by IBM. Sources for non-IBM list prices and performance numbers are taken from publicly available information,
including vendor announcements and vendor worldwide homepages. IBM has not tested these products and cannot confirm the accuracy of performance, capability, or
any other claims related to non-IBM products. Questions on the capability of non-IBM products should be addressed to the supplier of those products.

All statements regarding IBM future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only.

Some information addresses anticipated future capabilities. Such information is not intended as a definitive statement of a commitment to specific levels of performance,
function or delivery schedules with respect to any future products. Such commitments are only made in IBM product announcements. The information is presented here
to communicate IBM's current investment and development activities as a good faith effort to help with our customers' future planning.

Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput or performance that any
user will experience will vary depending upon considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage
configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve throughput or performance improvements
equivalent to the ratios stated here.

Photographs shown may be engineering prototypes. Changes may be incorporated in production models.

i want an i. © 2006 IBM Corporation

42

You might also like