| From: | Steve Adams |
| Date: | 14-Sep-2000 15:07 |
| Subject: | Placement of RULE hint in INSERT SELECT |
|
|
Your hint is in the wrong position. It should come after the INSERT, not after the SELECT. Although the insert and the select are optimized separately, they are treated as a single statement block so far as determining an optimization approach is concerned. Therefore a RULE hint needs to be placed after the first keyword in that statement to be effective. I have just checked the documentation on this, and unfortunately it is not very helpful. The Oracle8i Tuning guide even says, "A statement block can have only one comment containing hints. This comment can only follow the SELECT, UPDATE, or DELETE keyword", which suggests that you cannot put a hint after an INSERT keyword at all. Of course, you can and you sometimes must.
|
![]() |
The really odd thing is that the init.ora file has optimizer_mode = RULE. Here's the SQL. It's pretty simple... INSERT INTO PS_QVC_FAST_SEC SELECT --+ RULE A.* FROM PS_QVC_PERS_SRCH_VW A, PS_QVC_QUERY_USERS B WHERE A.OPRID=B.OPRCLASS;The view it references (PA_QVC_PERS_SRCH_VW) has no hints at all in it's definition. I'm still perplexed by this one.
|
![]() |
It sounds like there is some syntax error in the hint so that it just has the effect of forcing CBO to be used despite the absence of statistics.
|
![]() |
I have a query with a RULE hint, but the execution plan is show hash joins. Is this something new in the 8.1.5 optimizer? It used to be that you could only get HASH joins with CBO. Also, each of the operations is showing a cost and cardinality even though none of the tables have stats. The net result is I'm getting a horrible execution plan that includes Cartesian merges and runs for hours when previously this query ran in minutes. Any ideas?
|