SQL调优

网上看到如下sql:
留一个线索在此
select /*+ cardinality(@a 20000) cardinality(@b 20000)  */ ((v.yvalue * 300) / (u.xvalue * 50)), u.xtime 
  2    from (select x.index_value xvalue, substr(x.update_time, 1, 14) xtime 
  3            from tb_indexs x 
  4           where x.id in (select /*+ QB_NAME(a)*/ min(a.id) 
  5                            from tb_indexs a 
  6                           where a.code = 'HSI' 
  7                             and a.update_time > 20110701000000 
  8                             and a.update_time < 20110722000000 
  9                           group by a.update_time)) u, 
10         (select  y.index_value yvalue, substr(y.update_time, 1, 14) ytime 
11            from tb_indexs y 
12           where y.id in (select /*+ QB_NAME(b) */ min(b.id) 
13                            from tb_indexs b 
14                           where b.code = '000300' 
15                             and b.update_time > 20110701000000 
16                             and b.update_time < 20110722000000 
17                           group by b.update_time)) v 
18   where u.xtime = v.ytime 
19   order by u.xtime; 
cardinality:指定查询基数
This hint specifies the estimated cardinality returned by a query or portions of the query. Note if no table is specified, the cardinality is the total number of rows returned by the entire query.

QB_NAME hint query block name length limitation

http://feed.askmaclean.com/archives/qb_name-hint-query-block-name-length-limitation.html

你可能感兴趣的:(sql)