Hi,
I have a distributed table with XML column. I exposed this table via a view with all XML operations in select clause of the view.
I use this view in my join with other distributed table(distribution key is the same).
I am little confused with the resulting query plan. For the XML columns (xscans) the query tries to do broadcast joins. Why does this XML evaluation need a broadcast? Isnt it local to each partition?
Any help is appreciated.
Database details: DB2 Ver 9.7 and its a DPF environment
Query/Table details:
Base Table: RPT_PRODUCT
CREATE TABLE TEST_TABLE1
(
DIST_KEY BIGINT
,DIST_KEY_VALUE VARCHAR(64)
,ID BIGINT
,COL1 VARCHAR(64)
,COL2 VARCHAR(64)
,COL3 VARCHAR(64)
,COL4 VARCHAR(64)
,COL5 VARCHAR(64)
,COL6 VARCHAR(64)
,APP_LEVEL_OVERRIDE XML
)
DISTRIBUTE BY HASH(DIST_KEY)
IN PDPG_PERMDATA
;
View : VW_RPT_PRODUCT
CREATE VIEW VW_TEST_TABLE1
(
DIST_KEY
,DIST_KEY_VALUE
,ID
,COL1
,COL2
,COL3
,COL4
,COL5
,COL6
) AS
(
SELECT
RP.DIST_KEY
,RP.DIST_KEY_VALUE
,RP.ID
,RP.COL1
,COALESCE(XMLCAST(XMLQUERY('$C/APP_LEVEL_OVERRIDE/COL2' PASSING RP.APP_LEVEL_OVERRIDE AS "C") AS VARCHAR(64)),RP.COL2)
,COALESCE(XMLCAST(XMLQUERY('$C/APP_LEVEL_OVERRIDE/COL3' PASSING RP.APP_LEVEL_OVERRIDE AS "C") AS VARCHAR(64)),RP.COL3)
,COALESCE(XMLCAST(XMLQUERY('$C/APP_LEVEL_OVERRIDE/COL4' PASSING RP.APP_LEVEL_OVERRIDE AS "C") AS VARCHAR(64)),RP.COL4)
,COALESCE(XMLCAST(XMLQUERY('$C/APP_LEVEL_OVERRIDE/COL5' PASSING RP.APP_LEVEL_OVERRIDE AS "C") AS VARCHAR(64)),RP.COL5)
,COALESCE(XMLCAST(XMLQUERY('$C/APP_LEVEL_OVERRIDE/COL6' PASSING RP.APP_LEVEL_OVERRIDE AS "C") AS VARCHAR(64)),RP.COL6)
FROM TEST_TABLE1 rp
);
Query
UPDATE TEST_TABLE_2 AP -- (distributed by DIST_KEY )
SET (
COL2
,COL3
,COL4
,COL5
,COL6
) =
( SELECT
COL2
,COL3
,COL4
,COL5
,COL6
FROM VW_TEST_TABLE1 P
WHERE AP.ID = P.ID
AND AP.DIST_KEY = P.DIST_KEY
)
WHERE EXISTS ( SELECT 1
FROM VW_TEST_TABLE1 P1
WHERE AP.ID = P1.ID
AND AP.DIST_KEY = P1.DIST_KEY
)
Query Plan Snippet:
Query Plan Snippet :
Section Code Page = 1208
Estimated Cost = 3213296.750000
Estimated Cardinality = 26435.000000
Coordinator Subsection - Main Processing:
Distribute Subsection #1
| Broadcast to Node List
| | Nodes = 1, 3, 4, 5, 6
Distribute Subsection #2
| Broadcast to Node List
| | Nodes = 1, 3, 4, 5, 6
Distribute Subsection #3
| Broadcast to Node List
| | Nodes = 1, 3, 4, 5, 6
Distribute Subsection #4
| Broadcast to Node List
| | Nodes = 1, 3, 4, 5, 6
Subsection #1:
Access Table Name = TEST_TABLE_2 ID = 22,209
| Index Scan: Name = UN1_TEST_TABLE_2 ID = 8
| | Regular Index (Not Clustered)
| | Index Columns:
| | | 1: ID (Ascending)
| | | 2: DIST_KEY (Ascending)
| #Columns = 8
| Compressed Table
| #Key Columns = 1
| | Start Key: Beginning of Index
| | Stop Key: Exclusive Value
| | | | 1: NULL
| Data Prefetch: Eligible 0
| Index Prefetch: None
| Lock Intents
| | Table: Intent Exclusive
| | Row : Exclusive
Merge Join
| Early Out: Single Match Per Outer Row
| Access Table Name = TEST_TABLE1 ID = 14,19
| | #Columns = 9
| | Avoid Locking Committed Data
| | May participate in Scan Sharing structures
| | Scan may start anywhere and wrap, for completion
| | Fast scan, for purposes of scan sharing management
| | Scan can be throttled in scan sharing management
| | Relation Scan
| | | Prefetch: Eligible
| | Lock Intents
| | | Table: Intent Share
| | | Row : Next Key Share
| | Sargable Predicate(s)
| | | #Predicates = 1
| Insert Into Sorted Temp Table ID = t1
| | #Columns = 9
| | #Sort Key Columns = 1
| | | Key 1: ID (Ascending)
| | Sortheap Allocation Parameters:
| | | #Rows = 26435.000000
| | | Row Width = 328
| | Piped
| Access Temp Table ID = t1
| | #Columns = 9
| | Relation Scan
| | | Prefetch: Eligible
| Residual Predicate(s)
| | #Predicates = 1
Nested Loop Join
| Piped Inner
| Insert Into Synchronous Table Queue ID (XTQB) = q1
| | Send to Specific Node
| Access Table Queue ID (XTQA_AGG) = q2 #Columns = 1
Nested Loop Join
| Piped Inner
| Insert Into Synchronous Table Queue ID (XTQB) = q3
| | Send to Specific Node
| Access Table Queue ID (XTQA_AGG) = q4 #Columns = 1
Nested Loop Join
| Piped Inner
| Insert Into Synchronous Table Queue ID (XTQB) = q5
| | Send to Specific Node
| Access Table Queue ID (XTQA_AGG) = q6 #Columns = 1
Update: Table Name = TEST_TABLE_2 ID = 22,209
Subsection #2:
Access Table Queue ID () = q1 #Columns = 1
XML Doc Navigation
| Navigator is
| | /$CONTEXT_NODE$()/child::element(APP_LEVEL_OVERRIDE)
| | /child::element(COL2)(: Output Data :)
Insert Into Asynchronous Table Queue ID () = q2
| Send to Specific Node
Jump Back to Start of Subsection
Subsection #3:
Access Table Queue ID () = q3 #Columns = 1
XML Doc Navigation
| Navigator is
| | /$CONTEXT_NODE$()/child::element(APP_LEVEL_OVERRIDE)
| | /child::element(COL3)(: Output Data :)
Insert Into Asynchronous Table Queue ID () = q4
| Send to Specific Node
Jump Back to Start of Subsection
Subsection #4:
Access Table Queue ID () = q5 #Columns = 1
XML Doc Navigation
| Navigator is
| | /$CONTEXT_NODE$()/child::element(APP_LEVEL_OVERRIDE)
| | /child::element(COL4)(: Output Data :)
Insert Into Asynchronous Table Queue ID () = q6
| Send to Specific Node
Jump Back to Start of Subsection
End of section