मुझे पता चला कि कुछ मामलों मेंएसक्यूएल सर्वर बनाम सबक्वेरी प्रदर्शन प्रश्न में शामिल होने
select
usertable.userid,
(select top 1 name from nametable where userid = usertable.userid) as name
from usertable
where active = 1
की तरह एक प्रश्न
select
usertable.userid,
nametable.name
from usertable
left join nametable on nametable.userid = usertable.userid
where usertable.active = 1
जहां दोनों बराबर की तुलना में SS2008R2 में पूरा करने के लिए क्वेरी में शामिल होने के लंबे समय तक परिमाण के एक आदेश ले जाता है टेबल अनुक्रमित हैं और 100k पंक्तियों से अधिक है। दिलचस्प बात यह है मूल प्रश्न में एक शीर्ष खंड डालने इसमें शामिल होने क्वेरी के साथ बराबरी पर प्रदर्शन बनाता है:
select
top (select count(*) from usertable where active = 1) usertable.userid,
(select top 1 name from nametable where userid = usertable.userid) as name
from usertable
where active = 1
किसी को भी किसी भी विचार क्यों मूल प्रश्न तो खराब प्रदर्शन है?
FYI करें जब प्रदर्शन की समस्याओं के निदान के लिए आप हमेशा एक प्रश्न कार्य योजना लागू करके मिलना चाहिए। – Justin
यदि आपके पास सफारी पुस्तकें ऑनलाइन तक पहुंच है तो "माइक्रोसॉफ्ट® एसक्यूएल सर्वर 2005 के अंदर: क्वेरी ट्यूनिंग और ऑप्टिमाइज़ेशन - अध्याय 3" या एक और अच्छा लिंक http://blogs.msdn.com/b/craigfr/archive/2006 पर एक नज़र डालें /09/27/774107.aspx –