![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a merge statement run pretty slow, when checking explain. It simply scan both tables. Source table and Target table are partitioned by different columns, both indexed. This is on db2 v9.1 merge tgt using src on tgt.primarykey = src.key when matched when not matched. I am expecting it scan only the src table. Any idea? |
#3
| |||
| |||
|
|
On Mar 6, 11:44*pm, Anwei Shen <shenan... (AT) gmail (DOT) com> wrote: I have a merge statement run pretty slow, when checking explain. It simply scan both tables. Source table and Target table are partitioned by different columns, both indexed. This is on db2 v9.1 merge tgt using src on tgt.primarykey = src.key when matched when not matched. I am expecting it scan only the src table. Any idea? Even I create another table like Target table using the same partition key, merge will do 2 table scan. |
#4
| |||
| |||
|
|
On Mar 6, 11:44 pm, Anwei Shen<shenan... (AT) gmail (DOT) com> wrote: I have a merge statement run pretty slow, when checking explain. It simply scan both tables. Source table and Target table are partitioned by different columns, both indexed. This is on db2 v9.1 merge tgt using src on tgt.primarykey = src.key when matched when not matched. I am expecting it scan only the src table. Any idea? Even I create another table like Target table using the same partition key, merge will do 2 table scan. Drop the optimization level to 3. That disables hashjoin. |
#5
| |||
| |||
|
|
On 3/7/2011 8:26 PM, Anwei Shen wrote: On Mar 6, 11:44 pm, Anwei Shen<shenan... (AT) gmail (DOT) com> *wrote: I have a merge statement run pretty slow, when checking explain. It simply scan both tables. Source table and Target table are partitioned by different columns, both indexed. This is on db2 v9.1 merge tgt using src on tgt.primarykey = src.key when matched when not matched. I am expecting it scan only the src table. Any idea? Even I create another table like Target table using the same partition key, merge will do 2 table scan. Drop the optimization level to 3. That disables hashjoin. Do you have stats on the source table? How big is the source table compared to the target table? -- Serge Rielau SQL Architect DB2 for LUW, IBM Toronto Lab Blog: * *tinyurl.com/SQLTips4DB2 Wiki: * *tinyurl.com/Oracle2DB2Wiki Twitter: srielau- Hide quoted text - - Show quoted text - |
#6
| |||
| |||
|
|
Drop the optimization level to 3. That disables hashjoin. Do you have stats on the source table? How big is the source table compared to the target table? -- Serge Rielau SQL Architect DB2 for LUW, IBM Toronto Lab Blog: tinyurl.com/SQLTips4DB2 Wiki: tinyurl.com/Oracle2DB2Wiki Twitter: srielau |
#7
| |||
| |||
|
|
Any chance of setting optimization level at the statement level (sort of like can be done with isolation level)? |
#8
| |||
| |||
|
|
Any chance of setting optimization level at the statement level (sort of like can be done with isolation level)? |
#9
| |||
| |||
|
|
Any chance of setting optimization level at the statement level (sort of like can be done with isolation level)? You can't set the optimization level at statement level (within the SQL statement), but you can use the following special register: set current query optimization = 3 run your statement here set current query optimization = <old value -- Helmut K. C. Tessarek DB2 Performance and Development IBM Toronto Lab |
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |