假如想查出某一段时间的有效的单据中(或者某些产品)的明细资料,一般的做法: select 所需字段 from detail_tab a,main_tab b where a.prod_id = b.prod_id and a.yyyymmdd = b.yyyymmdd and a.paper_no = b.paper_no and a.io = b.io and b.yyyymmdd = '指定日期' and a.io = '进仓' and b.code = '有效的';
这个查询的速度会因为这两个表过于巨大而非常的缓慢,
现在有一个解决办法,就是给两个表都加上条件,即使是两个表关联的字段也加: select 所需字段 from detail_tab a,main_tab b where a.prod_id = b.prod_id and a.yyyymmdd = b.yyyymmdd and a.paper_no = b.paper_no and a.io = b.io and b.yyyymmdd = '指定日期' and a.yyyymmdd = '指定日期' and a.io = '进仓' and b.io = '进仓' and b.code = '有效的';