मेरे पास कुछ sprocs हैं जिन्हें एक temp तालिका की आवश्यकता है। कॉलम प्रकारों को हार्डकोड न करने के लिए (जो कुछ लंबाई के साथ वर्चर हैं) इसलिए संदर्भ तालिका स्कीमा में परिवर्तन होने पर मुझे घोषणाओं को बदलने की ज़रूरत नहीं है (यानी फ़ील्ड लंबा हो जाता है) मैं ऐसा करता हूं (एक तालिका तालिका बनाने के बजाए): (लाइन 1 पर) वक्तव्य 1 के लिएक्या प्रत्येक पंक्ति के लिए 1 = 2 कहलाता है?
क्वेरी के योजना:
select orderId into #sometmptbl from orders where 1=2
हालांकि, जब आप इस पर एक showplan कर यह वास्तव में तालिका/सूचकांक करने के लिए जा रहा है।
STEP 1 The type of query is CREATE TABLE. STEP 2 The type of query is INSERT. The update mode is direct. FROM TABLE orders Nested iteration. Index : orders_idx1 Forward scan. Positioning at index start. Index contains all needed columns. Base table will not be read. Using I/O Size 2 Kbytes for index leaf pages. With LRU Buffer Replacement Strategy for index leaf pages. TO TABLE #sometmptbl Using I/O Size 2 Kbytes for data pages.
कुल अनुमानित मैं बयान 1 (लाइन 1 पर) के लिए/ओ लागत: 632082.
यह मतलब 1 = 2 सूचकांक में प्रत्येक प्रविष्टि के लिए मूल्यांकन किया जाता है? क्या निरंतर समय में ऐसा करने का कोई तरीका है?
अद्यतन:
यहाँ वास्तविक आई/ओ शुल्क नहीं लिया जाता के बाद निष्पादित तो ऐसा लगता है कि वास्तविक पढ़ता है वास्तव में 0 रहे हैं इसलिए कोई प्रदर्शन प्रभाव है:
Table: orders scan count 0, logical reads: (regular=0 apf=0 total=0), physical reads: (regular=0 apf=0 total=0), apf IOs used=0
Table: #sometmptbl_____00002860018595346 scan count 0, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0
Total actual I/O cost for this command: 2.
Total writes for this command: 3
0 row(s) affected.
ऐसा लगता है कि आप सही हैं - वास्तविक रीड 0 हैं – naumcho