You are on page 1of 15

Configuration of the SAP-Oracle Database Interface

Default Values and Manual Adjustments

Manfred Riemer, Developer SAP AG, Oracle Platform 18.11.2009

This presentation summarizes the ways in which you can tune certain default values in the SAP-Oracle database interface (database shared library, DBSL). We also look at how this affects the ongoing operation of the SAP system. The presentation is tailored to the SAP kernel as of Version 7.10, although most details are valid for all currently supported SAP releases. Main topics:

1 Environment Parameters
This section discusses how to specify general, global criteria at system start.

2 Database-Relevant SAP Profile Parameters 3 ABAP Hints

Sections 2 and 3 discuss how to optimize the internal construction of very long SQL statements. We look at how to influence the way that ABAP statements (Open SQL) are converted to Oracle SQL statements for example, the effect of literals and ABAP internal tables. This directly impacts system performance.

4 R/3 System Tables

This section discusses how to regulate database connect, for example, for connections to external databases with differing character sets. In addition, we also give hints on how to control the type and amount of detailed information passed by the DBSL to the SAP work process logs (for example, for error analysis).

SAP 2009 / Page 2

1 Environment Variables
Which variables must be set for <sid>adm on the application server?
= <DB_SID> Oracle system identification SAP system identification Database system type (here Oracle) Directory of dboraslib.<ext> (SAP-Oracle interface library) Standard: SAP exe directory (/usr/sap/<SID>/SYS/exe/run) Can be changed to test a new dboraslib.<ext>. Directory of Oracle-SQL*Net files Default: $ORACLE_HOME/network/admin on the application server, for example: .../instantclient/software/network/admin AMERICAN_AMERICA.WE8DEC (Non-Unicode) or AMERICAN_AMERICA.UTF8 (Unicode)





Contains the path to the Oracle instant client For example: <path1>:<path2>: ... :/oracle/client/102_64/instantclient)

The following environment parameters might be overwritten by the R/3 profile. They are necessary for SAP tools (R3trans, ..., which do not read the R/3 profile), in case they differ from the default: dbs_ora_tnsname = <SID> dbs_ora_schema = SAP<SID2>
TNS alias name (in tnsnames.ora), Owner of the SAP tables, Default: SAPSYSTEMNAME, also dbs/ora/tnsname Default: SAPSR3 (previously SAPR3), also dbs/ora/schema

Variables not required on the application server:

Oracle home directory (only necessary on the database server, ora<sid> and <sid>adm) (/oracle/<DB_SID>/<rel>, for example: /oracle/C11/102_64)

SAP 2009 / Page 3

2 Database-Relevant SAP Profile Parameters


The SAP profile is only read when R/3 starts. The R/3 tools (R3trans, R3load, ...) use either environment variables or they run only with the internal defaults. The parameters dbs/ora/... are only valid for the Oracle database interface.

Parameter overview dbs/ora/tnsname dbs/ora/schema

possible values, default underlined Meaning

= <sid> Logical DB name (alias) in tnsnames.ora Owner of R/3 tables Input / output buffer (bytes) for DB operations Size of statement cache (number of statements)

= sap<sid2>, SAPSR3 (was SAPR3) =m =n 32500 ... 130000 ... 1040000 10 ... 250 ... 2000

dbs/ora/array_buf_size dbs/ora/stmt_cache_size

dbs/ora/substitute_literals = s

= FALSE | TRUE = 0 | 1

TRUE: literal variables instead of host variables

SAP 2009 / Page 4

2 Database-Relevant SAP Profile Parameters


Literals and host variables in SQL statements

ABAP statement: SQL statement, default:

(see also section 3, the SUBSTITUTE hints):

SELECT * FROM tab WHERE s1 = v1 AND s2 = 10. SELECT * FROM tab WHERE s1 = :A0 AND s2 = :A1.

By default, all variable values (for example, v1) and literals (constants, for example, 10) are replaced by host variables (:A0, :A1, ...).

(a) Profile parameters dbs/ora/substitute_literals or hint &substitute literals&: For TRUE or when using the hint, all literals in the SQL statement remain as they are in the ABAP statement. Instead of the literals, no host variables appear. SQL statement: SELECT * FROM tab WHERE s1 = :A0 AND s2 = 10.

(b) Hint &substitute values& (not available as profile parameter): In addition, the ABAP hint &substitute values& is described in section 3. With this hint, not only ABAP literals, but all host variables are replaced with specific values: SQL statement: SELECT * FROM tab WHERE s1 = 22 AND s2 = 10. SELECT * FROM tab WHERE s1 = 33 AND s2 = 10.

This means that, in principle, a PREPARE must be performed for every execution, since a new statement is created for every execution. Unfortunately, this means that the statement cache is useless see SAP Note 902042.

SAP 2009 / Page 5

2 Datenbank-relevante SAP-Profile-Parameter

The parameters rsdb/... are evaluated by the database-independent part of the kernel. The following parameters all refer to the ABAP construction FOR ALL ENTRIES.

Parameter overview

possible values, default underlined

(see also SAP Note 48230)

rsdb/prefer_union_all rsdb/prefer_in_itab_opt rsdb/prefer_join rsdb/max_blocking_factor rsdb/max_in_blocking_factor rsdb/prefer_fix_blocking rsdb/min_blocking_factor rsdb/min_in_blocking_factor

= FALSE | TRUE = 0 | 1 = FALSE | TRUE = 0 | 1 = FALSE | TRUE = 0 | 1 =5|n =5|n = FALSE | TRUE = 0 | 1 =5|n =5|n

a OR b or UNION IN (a, b, ...) FROM join_table max. num. OR or UNION max. num. IN list elements last stmt. has fixed length min. num. OR or UNION min. num. IN list elements

(Each parameter can be set in the SAP profile to -1, which always corresponds to the default.)

SAP 2009 / Page 6

2 Database-Relevant SAP Profile Parameters rsdb/prefer_union_all

ABAP (Open SQL) Oracle (native SQL):
itab is an internal table with N rows (x = 1, ..., N) and 1 column a: itab[x] = a[x] = i1 i2 ... iN a[1]=i1, a[2]=i2, ..., a[N]= iN

SELECT sp, ... FROM tab FOR ALL ENTRIES IN itab WHERE sp = itab-a .

rsdb/prefer_union_all = 0/FALSE SELECT sp, ... FROM tab WHERE sp = i1 OR sp = i2 ... OR sp = iN


ix is the value of the field in the x-th row of the internal table.

rsdb/prefer_union_all = 1/TRUE SELECT sp, ... FROM tab UNION ALL SELECT sp, ... FROM tab ... UNION ALL SELECT sp, ... FROM tab
SAP 2009 / Page 7

WHERE sp = i1 WHERE sp = i2 ... WHERE sp = iN

2 Database-Relevant SAP Profile Parameters rsdb/prefer_in_itab_opt

SELECT sp, ... FROM tab FOR ALL ENTRIES IN itab WHERE sp = itab-a
[ AND AND sp2 = itab-b ... ]

itab is an internal table with N rows (x = 1, ..., N) and 1 column a: itab[x] = a[x] = i1 i2 ... iN
a[1]=i1, a[2]=i2, ..., a[N]= iN

rsdb/prefer_in_itab_opt = 0|FALSE (prefer_union_all=0 or 1)

or more than 1 column:

SELECT sp, [sp2, ...] ... FROM tab WHERE sp = i1 [AND sp2 = j1 ...] OR sp = i2 [AND sp2 = j2 ...] ... OR sp = iN [AND sp2 = jN ...]

itab[x] = [a[x] b[x] ...] =

(shown here for prefer_union_all=0)

a[1]=i1, a[2]=i2, ..., a[N]= iN b[1]=j1, b[2]=j2, ..., b[N]= jN ... ...

i1 j1 ... i2 j2 ... ... iN jN ...

rsdb/prefer_in_itab_opt = 1|TRUE (takes precedence over prefer_union_all)

SELECT sp, ... FROM tab WHERE sp IN (i1, i2, ..., iN)
[AND ... sp2 IN (j1, j2, ..., jN)

] (would be false!)

(The IN list is only possible if itab only has a single column! prefer_in_itab_opt=TRUE is ignored if there is more than one column)

SAP 2009 / Page 8

2 Database-Relevant SAP Profile Parameters rsdb/prefer_join

SELECT S0, S1, S2, S3, S4 FROM tab FOR ALL ENTRIES IN itab WHERE S1 = itab-a AND S2 = itab-b AND S3 > 1000. rsdb/prefer_join = 0/FALSE (prefer_in_itab_opt or prefer_union_all) SELECT S0, S1, S2, S3, S4 FROM tab WHERE (S1 = 1 AND S2 = 11 OR S1 = 2 AND S2 = 22 OR S1 = 3 AND S2 = 33 OR S1 = 4 AND S2 = 44 ) AND S3 > 1000 rsdb/prefer_join = 1/TRUE (take precedence over prefer_union_all, prefer_in_itab_opt) SELECT S0, S1, S2, S3, S4 FROM tab, (SELECT 1 a, 11 b FROM DUAL UNION SELECT 2 a, 22 b FROM DUAL UNION SELECT 3 a, 33 b FROM DUAL UNION SELECT 4 a, 44 b FROM DUAL) itab WHERE AND AND S1 = itab.a S2 = itab.b S3 > 1000 itab is an internal table with 4 rows (N=4) and 2 columns a,b: itab[x] = [a[x],b[x]] = 1, 11 (x = 1, 2, 3, 4) 2, 22 3, 33 4, 44 itab[1] = (a[1],b[1]) = (1, 11) itab[2] = (a[2],b[2]) = (2, 22) itab[3] = (a[3],b[3]) = (3, 33) itab[4] = (a[4],b[4]) = (4, 44)

SAP 2009 / Page 9

2 Database-Relevant SAP Profile Parameters rsdb/..._blocking_faktor

rsdb/prefer_in_itab_opt FALSE (OR | UNION ALL)
(rsdb/prefer_union_all = FALSE | TRUE)

TRUE (with IN list) rsdb/max_in_blocking_factor = 8

rsdb/max_blocking_factor = 8

rsdb/prefer_fix_blocking = TRUE rsdb/min_blocking_factor = 4 rsdb/min_in_blocking_factor = 4

Example for prefer_in_itab_opt = TRUE, the internal table itab has N=10 (=8+2) rows:

SELECT sp, ... SELECT sp, ...

FROM tab WHERE sp IN (i1, i2, ..., i8) FROM tab WHERE sp IN (i1, i2, i2, i2)

(8 values, max_in_blocking_factor) (4 values, min_in_blocking_factor)

-> Only SQL statements with either 8 or 4 host variables are generated!

rsdb/prefer_fix_blocking = FALSE
-> Only max_blocking_factor or max_in_blocking_factor are used, i.e. for multiple statements, the last one can have any number of host variables (here 1 to 8).
SAP 2009 / Page 10

3 ABAP Hints
The profile parameters listed in section 2 can all also be specified as ABAP hints. The meaning is the same, except that the hint is only locally valid for the single statement for which it is specified. The hint then takes precedence over the globally valid profile parameters, which are valid for all statements. ABAP hints only influence the conversion of Open SQL to Native SQL in contrast to Oracle hints, they are not passed on to Oracle (OCI). Hint &substitute literals& &substitute values& &prefer_join &prefer_in_itab_opt &prefer_union_all &prefer_fix_blocking n& n& n& n& Corresponding profile parameter dbs/ora/substitute_literals = n
(only available as hint, no global parameter)

rsdb/prefer_join rsdb/prefer_in_itab_opt rsdb/prefer_union_all rsdb/prefer_fix_blocking rsdb/..._blocking_factor

=n =n =n =n =m

(n=0=FALSE or n=1=TRUE or n = -1 [default])

&..._blocking_factor m& Example:

(m = -1 [default] or m > 0)

SELECT * INTO TABLE itab1 FROM extab FOR ALL ENTRIES IN itab2 WHERE ex_a = itab2-a AND ex_b = itab2-b %_hints oracle '&PREFER_JOIN 1&'. or several hints for each statement, for example: ... %_hints oracle '&prefer_in_itab_opt 1&&prefer_fix_blocking -1&.

SAP 2009 / Page 11

4 R/3 System Tables


Output of detailed trace info for a particular table (table_name) to the work process log dev_wN (N=0,1,2,...): SQL Statement, bind or define infos, read/inserted data INSERT INTO SAPSR3.SDBAD (BEG, LINE) VALUES (TRACE, table_name); or UPDATE SAPSR3.SDBAD SET LINE = table_name WHERE BEG = TRACE; This requires transaction SM50 of the R/3 system to be specified in the corresponding work process of trace level 2 or 3 for the component DBSL (see next slide).

SAP 2009 / Page 12

4 R/3 System Tables

On table SAPSR3.SDBAD (Tracing):
Transaction SM50 -> Administration -> Trace -> Active Components ->

SAP 2009 / Page 13

4 R/3 System Tables

Table SAPSR3.DBCON - Setting up of a secondary connection from the primary SAP system database
to a remote database

- Enter the connect info using transaction DBCO in table SAPSR3.DBCON,

column CON_ENV: tnsname[:characterset[:national_characterset]]
The specification of the character set of the remote database in the event of differing character sets prevents the automatic character conversion by Oracle between the two databases (SELECT from or INSERT/UPDATE to the remote database). Example: Character set of the SAP DB: WE8DEC Character set of the secondary DB: WE8ROMAN8 tnsname for the secondary DB: XYZ Connect info: XYZ:WE8ROMAN8

SAP 2009 / Page 14

Thats all!

Thanks for your time!

SAP 2009 / Page 15