view和表值函数(inline function)的效率有不同吗? 這個還沒有測試。不清楚 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /* 自己做的测试,但是每次执行结果很参差。看不出两者性能差异。 可能是测试不合理。*/create view test_viewas select * from syscolumnsgocreate function test_func(@id int) returns tableasreturn select * from syscolumns where [id] = @idgodeclare @t datetime, @count int, @view_result nvarchar(30), @func_result nvarchar(30)select @t = getdate(), @count = 1while @count < 50begin select * from test_view where [id] = 1 set @count = @count + 1endselect @view_result = ltrim(str(datediff(ms, @t, getdate())))select @t = getdate(), @count = 1while @count < 50begin select * from test_func(1) set @count = @count + 1endselect @func_result = ltrim(str(datediff(ms, @t, getdate())))print 'test_view: ' + @view_resultprint 'test_func: ' + @func_resultdrop view test_viewdrop function test_func 差别因该很小,毕竟只是调用上的问题,相对于检索数据来说是分辨不出来效率的个人见解,呵呵 小弟有关于转换问题请教 sqlserver2005 安装后,外围配置器没有数据库引擎 这样的关联怎么写? 怎样用sql语句清除字段中的空格及换行符? 全文检索无法用 一个表,已作分区,现在的情况是: 不断地有数据插入该表. 可以用循环来插入来测试. 日志不断地增长,收缩日志没有起作用.... 怎么办?? 二合一的问题? VFP!请你退出历史的舞台吧!!! sql 问题 在VB中如何程序实现两个数据库的出版/订阅过程的控制? 取Min值,不好意思再问一次 SQLserver小数点问题!!!!!!!!!!!!!!!!!!
自己做的测试,但是每次执行结果很参差。看不出两者性能差异。
可能是测试不合理。
*/create view test_view
as
select * from syscolumns
gocreate function test_func(@id int)
returns table
as
return
select * from syscolumns where [id] = @id
godeclare @t datetime, @count int, @view_result nvarchar(30), @func_result nvarchar(30)select @t = getdate(), @count = 1
while @count < 50
begin
select * from test_view where [id] = 1
set @count = @count + 1
end
select @view_result = ltrim(str(datediff(ms, @t, getdate())))
select @t = getdate(), @count = 1
while @count < 50
begin
select * from test_func(1)
set @count = @count + 1
end
select @func_result = ltrim(str(datediff(ms, @t, getdate())))print 'test_view: ' + @view_result
print 'test_func: ' + @func_resultdrop view test_view
drop function test_func