home clear 64x64
en blue 200x116 de orange 200x116 info letter User
suche 36x36
Latest versionsfixlist
11.1.0.7 FixList
10.5.0.9 FixList
10.1.0.6 FixList
9.8.0.5 FixList
9.7.0.11 FixList
9.5.0.10 FixList
9.1.0.12 FixList
Have problems? - contact us.
Register for free anmeldung-x26
Contact form kontakt-x26

DB2 - Problem description

Problem IC88349 Status: Closed

XQuery with "let" expressions aggregating large sequences with
predicate may perform slower in v95/v97 vs. v91.

product:
DB2 FOR LUW / DB2FORLUW / A10 - DB2
Problem description:
XQueries using "let" expressions which aggregate large xml 
sequences and apply some predicate on that sequence give slower 
performance in v95, v97 when compared with v91. 
 
The query: 
 
declare default element namespace "http://xxxx/ 
namespace/portal/ap0021/zc_xdb_ap0021.xsd"; let 
$Source:=db2-fn:xmlcolumn("ZC_AP0021.DATA")[1] return 
<root>{$Source}</root> 
 
The performance impact comes from the following "let" 
expression: 
 
let $Source:=db2-fn:xmlcolumn("ZC_AP0021.DATA") 
 
The problem here is that we collect  ALL xml documents found in 
DATA column into one huge sequence. Afterwards we apply 
positional predicate of [1] to every item in the large sequence 
to only fetch the first item. The performance hit is NOT coming 
from the positional predicate itself but from the fact that we 
are applying it to every item in that sequence. Applying any 
other kind of predicate to these kinds of sequences will give 
similar performance results. 
 
The performance for such queries is bad in all releases and we 
advice against writing similar queries but the performance for 
these kinds of queries appears to be worst starting v95 GA 
onwards. This is because performance improvements such as 
Multiple Extractions (MEP) and Predicate Pushdown where 
delivered which changed a large portion of the XML engine, from 
query compiler, optimizer to XML Navigation runtime. As side 
effect of these features was how XML Navigation changed the way 
it generates empty tuples to represent empty sequences which 
will have an impact for queries like the one above.
Problem Summary:
**************************************************************** 
* USERS AFFECTED:                                              * 
* DB2 UDB Version 10.1                                         * 
**************************************************************** 
* PROBLEM DESCRIPTION:                                         * 
* See Error Description                                        * 
**************************************************************** 
* RECOMMENDATION:                                              * 
* Upgrade to Version 10.1 FixPack 2.                           * 
****************************************************************
Local Fix:
Rewrite query more efficiently so that it only fetches first row 
using sqlxml (xmltable). 
 
select 
xmlquery('declare default element namespace 
"http://xxxx/namespace/portal/ap0021/zc_xdb_ap0021.xsd"; let 
$ReceivedOrder := $newdoc return <root>{$ReceivedOrder}</root>' 
passing DOC as "newdoc") 
from 
(select T.DOC from 
 ZC_AP0021, 
 XMLTABLE (XMLNAMESPACES(DEFAULT 
'http://xxxx/namespace/portal/ap0021/zc_xdb_ap0021.xsd'), 
'$d' passing DATA as "d" 
    COLUMNS 
      DOC XML PATH '.') AS T 
FETCH FIRST ROW ONLY 
)@
available fix packs:
DB2 Version 10.1 Fix Pack 2 for Linux, UNIX, and Windows
DB2 Version 10.1 Fix Pack 3 for Linux, UNIX, and Windows
DB2 Version 10.1 Fix Pack 4 for Linux, UNIX, and Windows
DB2 Version 10.1 Fix Pack 3a for Linux, UNIX, and Windows
DB2 Version 10.1 Fix Pack 6 for Linux, UNIX, and Windows

Solution
Problem was first fixed in DB2 UDB Version 10.1 FixPack 2.
Workaround
not known / see Local fix
Timestamps
Date  - problem reported    :
Date  - problem closed      :
Date  - last modified       :
17.11.2012
06.05.2014
06.05.2014
Problem solved at the following versions (IBM BugInfos)
Problem solved according to the fixlist(s) of the following version(s)
10.1.0.2 FixList
10.5.0.2 FixList