由买买提看人间百态

topics

全部话题 - 话题: isdeleted
(共0页)
x**********7
发帖数: 973
1
来自主题: ChinaNews版 - grasshopper怎么被杀挡了?
Horrible
At least mitbbs should tell why a BM isdeleted
w*r
发帖数: 2421
2
Your query sucks, give this a try, you better have index on isdeleted/
deleteds on both questions and
answers table. EV table also needs index. Otherwise, it will suck anyway.
SELECT
Questions.QuestionID,
Questions.QuestionText,
Answers.AnswerText,
Answers.CorrectAnswer,
Answers.PointValue AS AnswerPointValue,
CASE WHEN S1.AnswerID ID NOT NULL
THEN 1
ELSE 0
END AS AnswerUsed
FROM Questions
INNER JOIN
Answers
ON
(Questions.QuestionID = Answers.QuestionID
AND ANSWE
c****o
发帖数: 265
3
多谢指教!
讨论一下几个问题
1。你把where里的条件尽量放在了join里,其实我也式过,得到的exe plan 好像一样
,可能sql server自己会做这样的优化(?)
2。我们每个表基本都有isdeleted这样的东西,查询常用到。但index似乎只在key上有
, 我一个developer要求改变数据库结构恐怕不行。我不懂的问一下,这个index重要在
哪里?如果确实必要,我就去找manager问一下...
3。exsists为什么不好?你改过的sql我想要加distinct的,而distinct好像比较
expensive.更麻烦的是distinct有些东西不能比较,比如text类型


(共0页)