描述1:
Hi, hope this help:
The ‘driving’ table is the table we will join FROM — that is JOIN TO other
tables. For example, lets say you have the query:
select * from emp, dept where emp.deptno = dept.deptno;
In this case the driving table might be DEPT, we would fetch rows from DEPT in a
full scan and then find the rows in EMP that match. DEPT is the driving table.
The choice of a driving table made using many factors. For example, in the
above query if there was an index on DEPT(DEPTNO) but not EMP(DEPTNO), we would
probably use EMP as the driving table — we would fetch rows from EMP and then
using the DEPT(DEPTNO) index — find their matches in the DEPT table. Table
sizes, cardinality of column values, and other things can affect the choice of a
driving table (eg: HINTS).
When using the Rule Based Optimizer — the placement of tables in the FROM
clause is relevant. We process the from clause from the RIGHT to the LEFT — we
would tend to pick a driving table from the end of the FROM list. There is a
hint in the Cost Based Optimizer to have this happen as well.
When using CBO — the order of tables is not relevant (unless you hint it to
be). We use the statistics and data dictionary to determine which table is best
to be used as the driving table.
描述2:
以一个比较两本字典来做例子:
一本字典有索引目录(dict a), 一本没有(dict b)
现在要找出所有a开头的单词的异同
那么比较的时候,你会怎么比较?
合理的做法应该是以没有索引的字典dict b开始, 找到a开头的那一页, 然后对于每个单词, 通过使用索引在dict a中找到相应的条目
如果反过来, 效率会相同吗?
驱动表,通俗的讲就是先从哪个表开始检索,良好的驱动表是成功优化的一半