我现在用的asp+mssql2005 数据有30万条,有10个字段,有5个字段是ntext。
问题1、我在内容列表网页中用select schoolname,shijian,dizhi,schoolid from school where schooltype=5 order by schoolid desc 来查询数据。
经常用到的字段就是schoolname,shijian,dizhi,schoolid。
而其他字段都是需要查看内容页的时候才用到,请问是否可以把不常用的字段移动到另外一张表中,这样列表网页中用select schoolname,shijian,dizhi,schoolid from school where schooltype=5 order by schoolid desc 来查询数据是不是会提高速度?
问题2、我有一个搜索网页,用的是select schoolname,shijian,dizhi,schoolid from school where schoolname like '%湖北中学%' 来查询,感觉非常慢,大概需要20秒才返回数据。有什么办法优化?
------解决方案--------------------
对的,虽然你不需要查询ntext字段的值,但是实际上sql server在查询的时候,会把整个表的数据都查出来的,然后把这些数据加载到内存,然后取出那几个字段,而其他不需要查询的字段的值,就不需要了,虽然这些数据也加载到了内存中,所以这样效率必然会有所下降