问题:
问题是这样的,表a 140万条数据,表b 临时表 350条数据,
我现在用这样的查询语句, select * from a where exists (select 1 from b where b.batchno=a.batchno)
a,b表靠batchno字段关联,字段类型为varchar(50),其中a表的batchno建了索引
数据库为sql server 2000, 查询时间大概在23-30之间,有没有办法做些优化处理?
解决:
不要用两个表的连接
先把b表中的batchno
用select batchno from b
查出来
组成字符串(batchno1,batchno2,batchno3,batch4,......)
再select * from a where batchno int(batchno1,batchno2,batchno3,batch4,......)
最近做的一个项目里要处理日志记录,日志表好几百万条,我用连接查询半天出不来
后来分开一个一个表查,把限制条件先保存就快多了
原地址:http://topic.csdn.net/u/20090523/16/9e891fda-72dc-4417-b554-22edfde7e437.html?52778
