3 つの異なるテーブルから 3 つの単一の値を返したいと考えています。
リソースの使用量とパフォーマンス (ストアド プロシージャ内) を考慮して、これらのコードのどれが優れているかを知りたいです。
コード 1:
declare @acc_cnt int, @selected_item int, @worker_cnt int
select @acc_cnt=count(0) from accounts
select @selected_item=id from items where name='something'
select @worker_cnt=count(0) from workers
select @acc_cnt ,@selected_item,@worker_cnt
コード 2:
select count(0) from accounts
select id from items where name='something'
select count(0) from workers
3つの選択を返すことと単一の選択を返すことに違いはありますか? SQL Server 2008 を使用しています