我的查询语句是这样的。
from t in db.GameArticles where t.Type!=9 && t.Title.Contains(key) orderby t.PublishDate descending select t
不过这表总共才10000条记录,为什么这样查,速度很慢。
大家可以看看效果http://leyoufang.com/search/news?key=%E5%A4%A7
哪位大侠帮忙看下,这语句怎么写好
...全文
67318打赏收藏
EF查询语句效率优化
我的查询语句是这样的。 from t in db.GameArticles where t.Type!=9 && t.Title.Contains(key) orderby t.PublishDate descending select t 不过这表总共才10000条记录,为什么这样查,速度很慢。 大家可以看看效果http://leyoufang.com/search/news?key=%E5%A4%A7 哪位大侠帮忙看下,这语句怎么写好
Ttitle建立索引后可以这样写效率应该会提升不少,因为like 'abc%'是会使用到索引的
from t in db.GameArticles where t.Type!=9 && t.Title.StartWith(key) orderby t.PublishDate descending select t