f*****e 发帖数: 5177 | |
B*****g 发帖数: 34098 | 2 bu hui.
learning java now, nnd.
你不是都当小头头了吗?还学这干啥?
【在 f*****e 的大作中提到】 : 看得头都大了。
|
c**t 发帖数: 2744 | 3 check execution plan first to find where the bottleneck is...
【在 f*****e 的大作中提到】 : 看得头都大了。
|
f*****e 发帖数: 5177 | 4
谁又在散播谣言?
【在 B*****g 的大作中提到】 : bu hui. : learning java now, nnd. : 你不是都当小头头了吗?还学这干啥?
|
B*****g 发帖数: 34098 | 5 你自己说的都去参加architect meeting了
【在 f*****e 的大作中提到】 : : 谁又在散播谣言?
|
f*****e 发帖数: 5177 | 6 Did I?
我怎么都不记得了。
再说architect meeting也没什么呀。
该干活还是得干。
【在 B*****g 的大作中提到】 : 你自己说的都去参加architect meeting了
|
B*****g 发帖数: 34098 | 7 你到特奈特干的好好的,学啥西口色乌尔。
【在 f*****e 的大作中提到】 : Did I? : 我怎么都不记得了。 : 再说architect meeting也没什么呀。 : 该干活还是得干。
|
j*****n 发帖数: 1781 | 8 帖个例子上来,俺给你瞧瞧?
beijing 是做orancle 的,你寻错人了,呵呵
往下看看我的帖子,一位给了我一本电子版的书,很好很强大。 |
j*****n 发帖数: 1781 | 9 some rules for you to start
rule 1. avoid table scan... check your execution plan by hit ctrl+l
rule 2. avoid CASE...THEN... in select statement
rule 3. avoid NOT IN, NOT EXIST
rule 4. use INNER JOIN when possible instead of LEFT/RIGHT OUTER JOIN
rule 5. use UNION ALL when possible against UNION
rule 6. avoid function against columns in WHERE clause
rule 7. use ISNULL() instead of OR in WHERE clause
e.g. WHERE col1 = @var1 OR @var1 IS NULL
can be written to
WHERE col1 |
p******a 发帖数: 41 | 10 I am a newbie too, curious to know?
what to use?
wha to use?
whay not coalesce?
【在 j*****n 的大作中提到】 : some rules for you to start : rule 1. avoid table scan... check your execution plan by hit ctrl+l : rule 2. avoid CASE...THEN... in select statement : rule 3. avoid NOT IN, NOT EXIST : rule 4. use INNER JOIN when possible instead of LEFT/RIGHT OUTER JOIN : rule 5. use UNION ALL when possible against UNION : rule 6. avoid function against columns in WHERE clause : rule 7. use ISNULL() instead of OR in WHERE clause : e.g. WHERE col1 = @var1 OR @var1 IS NULL : can be written to
|
|
|
j*****n 发帖数: 1781 | 11 so what is your question?
【在 p******a 的大作中提到】 : I am a newbie too, curious to know? : : what to use? : wha to use? : whay not coalesce?
|
B*****g 发帖数: 34098 | 12 人家要optimize sql server,不是tuning sql。
【在 j*****n 的大作中提到】 : 帖个例子上来,俺给你瞧瞧? : beijing 是做orancle 的,你寻错人了,呵呵 : 往下看看我的帖子,一位给了我一本电子版的书,很好很强大。
|
B*****g 发帖数: 34098 | 13 what to use?
wha to use?
whay not coalesce? |
B*****g 发帖数: 34098 | 14 这个对新手足够了,你把整本书贴出来吧。
【在 j*****n 的大作中提到】 : some rules for you to start : rule 1. avoid table scan... check your execution plan by hit ctrl+l : rule 2. avoid CASE...THEN... in select statement : rule 3. avoid NOT IN, NOT EXIST : rule 4. use INNER JOIN when possible instead of LEFT/RIGHT OUTER JOIN : rule 5. use UNION ALL when possible against UNION : rule 6. avoid function against columns in WHERE clause : rule 7. use ISNULL() instead of OR in WHERE clause : e.g. WHERE col1 = @var1 OR @var1 IS NULL : can be written to
|
c**t 发帖数: 2744 | 15 good, should be marked
【在 j*****n 的大作中提到】 : some rules for you to start : rule 1. avoid table scan... check your execution plan by hit ctrl+l : rule 2. avoid CASE...THEN... in select statement : rule 3. avoid NOT IN, NOT EXIST : rule 4. use INNER JOIN when possible instead of LEFT/RIGHT OUTER JOIN : rule 5. use UNION ALL when possible against UNION : rule 6. avoid function against columns in WHERE clause : rule 7. use ISNULL() instead of OR in WHERE clause : e.g. WHERE col1 = @var1 OR @var1 IS NULL : can be written to
|
c**t 发帖数: 2744 | 16 where is the e-Book? can you share?
【在 j*****n 的大作中提到】 : 帖个例子上来,俺给你瞧瞧? : beijing 是做orancle 的,你寻错人了,呵呵 : 往下看看我的帖子,一位给了我一本电子版的书,很好很强大。
|
j*****n 发帖数: 1781 | 17 http://www.mitbbs.com/article_t/Database/31138084.html
【在 c**t 的大作中提到】 : where is the e-Book? can you share?
|
j*****n 发帖数: 1781 | 18 这样哈,理解错误了....等我整理一下我的经验再发上来。
【在 B*****g 的大作中提到】 : 人家要optimize sql server,不是tuning sql。
|
j*****n 发帖数: 1781 | 19 rule 2. avoid CASE...THEN... in select statement |
B*****g 发帖数: 34098 | |
|
|
j*****n 发帖数: 1781 | 21 这个俺没有书... 干活的时候琢磨,然后在网上找的资料...
Online Book 其实能解决很多问题了。
【在 B*****g 的大作中提到】 : 这个对新手足够了,你把整本书贴出来吧。
|
B*****g 发帖数: 34098 | 22 rule2:
这个和front end有什么关系?
rule3:
这个永远是depends
rule7:
nod,I think you are right.
【在 j*****n 的大作中提到】 : rule 2. avoid CASE...THEN... in select statement
|
B*****g 发帖数: 34098 | 23 我还是先看oracle吧,学无止境呀
【在 j*****n 的大作中提到】 : 这个俺没有书... 干活的时候琢磨,然后在网上找的资料... : Online Book 其实能解决很多问题了。
|
j*****n 发帖数: 1781 | 24 嗯,这个比较麻烦,得看情况:
多少个 cpu,
多少 ram,
磁盘阵列/SAN 的连接情况,有几个 physical I/O path,
SQL Server 2k5 EE 的话还要考虑是否作 table partitioning,
32 bit 得考虑 AWE (Allocation Windowing Extensions)
数据库是用作 OLTP/OLAP,
OLTP 的话还得小心 clustered index,
建议先开一个 perfmon 看看, 找到bottle neck 再说其他。
【在 B*****g 的大作中提到】 : 人家要optimize sql server,不是tuning sql。
|
j*****n 发帖数: 1781 | 25
【在 B*****g 的大作中提到】 : rule2: : 这个和front end有什么关系? : rule3: : 这个永远是depends : rule7: : nod,I think you are right.
|
j*****n 发帖数: 1781 | 26 倒数第二个回帖不是么?
【在 B*****g 的大作中提到】 : wk,我竟然还会了这个帖子。没找到下载link
|
p******a 发帖数: 41 | 27 STILL CONFUSED---
rule 2. avoid CASE...THEN... in select statement |
B*****g 发帖数: 34098 | 28 如果我有10000个record要在backend做这个select怎么办?
【在 j*****n 的大作中提到】
|
B*****g 发帖数: 34098 | 29 算了,不着了。等下半年直接看sql2008
【在 j*****n 的大作中提到】 : 倒数第二个回帖不是么?
|
j*****n 发帖数: 1781 | 30 ***************************************************************
What is wrong with this:
select result=case when type like 'Dec%' then 1 else 0 end.....
what other better way can do the same?
***************************************************************
that's why I suggested that you need ask front-end to do this job...
or, if this query is frequently used, add one more column to handle it:
UPDATE table
SET newCol = 1
FROM table
WHERE type LIKE 'Dec%'
UPDATE table
SET newCol = 0
FROM table
W |
|
|
j*****n 发帖数: 1781 | 31 实在要用也行。
看楼上我另一个跟帖。
【在 B*****g 的大作中提到】 : 如果我有10000个record要在backend做这个select怎么办?
|
j*****n 发帖数: 1781 | 32 6兆多一个文件,你懒得找给个信箱我发给你好了。
【在 B*****g 的大作中提到】 : 算了,不着了。等下半年直接看sql2008
|
B*****g 发帖数: 34098 | 33 其实我就是跟你闹,这些书应该很好电驴的。
你那个sql optimize再展开说说,还有怎样有效利用execution plan
【在 j*****n 的大作中提到】 : 6兆多一个文件,你懒得找给个信箱我发给你好了。
|
j*****n 发帖数: 1781 | 34 你可能不记得了,咱俩去年开始就有无数互相跟贴了,好像是从jobhunting 开始的,
呵呵
再要展开确实不知从何说起了,得有好的案例了。
execution plan 一般找找 table/index scan 就差不多了,其他的象 hash join 什么
的还不如直接看code来得快。
你把这个主题里面我的跟贴都看了的话主要idea 应该也差不多了吧。
【在 B*****g 的大作中提到】 : 其实我就是跟你闹,这些书应该很好电驴的。 : 你那个sql optimize再展开说说,还有怎样有效利用execution plan
|
w*******e 发帖数: 1622 | 35 看execution plan, 偶主要看:
1. table scan ---这是worst的, 最好避免 (当然, 要select*也没办法)
2. index scan --- this is 2nd worst, 也要避免
3. bookmark lookup ---说明你的index没放对地方
4. hash/nest/merge join --- 要根据情况用JOIN hint
【在 B*****g 的大作中提到】 : 其实我就是跟你闹,这些书应该很好电驴的。 : 你那个sql optimize再展开说说,还有怎样有效利用execution plan
|
B*****g 发帖数: 34098 | 36 2要不好哪个好用?
【在 w*******e 的大作中提到】 : 看execution plan, 偶主要看: : 1. table scan ---这是worst的, 最好避免 (当然, 要select*也没办法) : 2. index scan --- this is 2nd worst, 也要避免 : 3. bookmark lookup ---说明你的index没放对地方 : 4. hash/nest/merge join --- 要根据情况用JOIN hint
|
j*****n 发帖数: 1781 | 37 index seek is the best.
index scan is slightly better than table scan when scan in nonclustered
index, because it looks into smaller file.
Q: why index scan?
A: no enough info (column(s) within index)
【在 B*****g 的大作中提到】 : 2要不好哪个好用?
|
B*****g 发帖数: 34098 | 38 ding。
我现在sql server也是小牛牛了
【在 j*****n 的大作中提到】 : index seek is the best. : index scan is slightly better than table scan when scan in nonclustered : index, because it looks into smaller file. : Q: why index scan? : A: no enough info (column(s) within index)
|
j*****n 发帖数: 1781 | 39 恭喜 mm, 你已经成为了大牛牛了,oracle 俺是不懂地,呵呵
【在 B*****g 的大作中提到】 : ding。 : 我现在sql server也是小牛牛了
|
d****y 发帖数: 701 | 40 哈,什么牛人总结的?挺对啊。
把OPTIMIZER的难点都列出来了。 |