![]() | |
#1
| |||||||
| |||||||
|
| GRPBY |
| TBSCAN |
| SORT |
| MSJOIN |
|
| SORT SORT |
|
| TBSCAN TBSCAN |
|
| Table: Table: |
#2
| |||
| |||
|
|
I have a query that joins two tables. The optimizer plan looks like this: RETURN ( 1) | GRPBY ( 2) | TBSCAN ( 3) | SORT ( 4) | MSJOIN ( 5) / \ TBSCAN TBSCAN ( 6) ( 10) | | SORT SORT ( 7) ( 11) | | TBSCAN TBSCAN ( 8) ( 12) | | Table: Table: DB2ADMIN DB2ADMIN SCL_ITEM SCL The primary keys for the two tables are: SCL_ITEM SCL ------------ ------------ SCL_ID SCL_ID PAGE_NBR PAGE_NBR ITEM_ID The query is: select scl.scl_id, scl.page_nbr, count(*), sum(item.qty) from scl scl join scl_item item on scl.scl_id = item.scl_id and scl.page_nbr = item.page_nbr group by scl.scl_id, scl.page_nbr The statistics are up to date, but this query runs slowly. I always thought that the optimizer would choose to use an index path for a join such as this, but it seems to prefer the table scan. Is there another trick that I could try out to convince the optimizer to use the index path? (Platform is AIX 4.3.3 UDB 7.2 fp5) Thanks, Mike |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
I have a query that joins two tables. The optimizer plan looks like this: RETURN ( 1) | GRPBY ( 2) | TBSCAN ( 3) | SORT ( 4) | MSJOIN ( 5) / \ TBSCAN TBSCAN ( 6) ( 10) | | SORT SORT ( 7) ( 11) | | TBSCAN TBSCAN ( 8) ( 12) | | Table: Table: DB2ADMIN DB2ADMIN SCL_ITEM SCL The primary keys for the two tables are: SCL_ITEM SCL ------------ ------------ SCL_ID SCL_ID PAGE_NBR PAGE_NBR ITEM_ID The query is: select scl.scl_id, scl.page_nbr, count(*), sum(item.qty) from scl scl join scl_item item on scl.scl_id = item.scl_id and scl.page_nbr = item.page_nbr group by scl.scl_id, scl.page_nbr The statistics are up to date, but this query runs slowly. I always thought that the optimizer would choose to use an index path for a join such as this, but it seems to prefer the table scan. Is there another trick that I could try out to convince the optimizer to use the index path? (Platform is AIX 4.3.3 UDB 7.2 fp5) |
#5
| |||
| |||
|
|
The primary keys for the two tables are: SCL_ITEM SCL ------------ ------------ SCL_ID SCL_ID PAGE_NBR PAGE_NBR ITEM_ID The query is: select scl.scl_id, scl.page_nbr, count(*), sum(item.qty) from scl scl join scl_item item on scl.scl_id = item.scl_id and scl.page_nbr = item.page_nbr group by scl.scl_id, scl.page_nbr Do you need to join scl? |
#6
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |