要看具体的执行计划,有些时候with as 会使用临时表,有时不用,用临时表也不一定能提高效率。有时候为了强迫它用临时表可以加一些特殊的查询
例如:with ta as select id,name from tsc_ta, tb as select id,name from tsc_tbselecct a.name,b.name from ta a,tb b where a.id=b.id;其中,TA中的数据量是100W,TB中的数据量200W.SQL语句的形式是这样的.另外,如果WITH语句是将结果存放在临时表中的话,那么这个临时表是存放在内存中,还是在临时表空间中呢?
ta as select id,name from tsc_ta,
tb as select id,name from tsc_tbselecct a.name,b.name from ta a,tb b where a.id=b.id;其中,TA中的数据量是100W,TB中的数据量200W.SQL语句的形式是这样的.另外,如果WITH语句是将结果存放在临时表中的话,那么这个临时表是存放在内存中,还是在临时表空间中呢?