我只是想知道做多重選擇與使用單一選擇之間的區別是什麼有什麼性能增益?我看到有人這樣做了,我覺得它有點像在下面那樣失控;多重選擇與單一選擇聲明
select @a = cBranchName from mstores where nBranchCode = 1
select @b = cBranchAddress from mstores where nBranchCode = 1
select @c = dCreateDate from mstores where nBranchCode = 1
select @d = AssignedCompanyId from mstores where nBranchCode = 1
select @e = StoreFormat from mstores where nBranchCode = 1
與
select @a = cBranchName
,@b = cBranchAddress
,@c = dCreateDate
,@d = AssignedCompanyId
,@e = StoreFormat from mstores where nBranchCode = 1
我還假定在5選擇的使5趟數據庫,我怎麼能證明一個SELECT語句比5個select語句更快,
即使只是看着它,我已經認爲單個select語句比多個選擇語句快得多。
讀書五次更快或讀一本書的時間更快? – SenthilPrabhu
@SenthilPrabhu:並不那麼簡單。數據庫經常優化您的查詢,但我不認爲在這種情況下。 –
@TimSchmelter:數據庫需要優化可能需要至少一秒鐘的查詢。 – SenthilPrabhu