Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
marko_1
Starting Member
1 Post |
Posted - 2012-11-08 : 12:31:01
|
I was asked to think of an example database in which an index would improve the performance of a low hit rate query.declare @prsi_no intdeclare @L int, @i int, @x datetime, @y datetime, @z real, @u datetimedeclare @s varchar(1000)set @x = getdate() -- start timeselect x = @xset @i=1while @i < 10000 -- Nbegin begin tran set @s = 'select count(*) from dbo.Asg1_tbl where prsi_no = ' + str(@prsi_no) exec(@s) commit tran set @i = @i + 1endset @y= getdate()select y = @yset @z = datediff(ms, @x, @y)select 'Run time = ' + cast(@z as varchar(20)) + ' miliseconds.'goselect * from dbo.Asg1_tbl where prsi_no = ceiling (rand()*10000)I used this code to test the speed with a primary key on and with no primary key to test the speed improvement..Anyone have an what code to use to generate a random number and also how to tabulate results?? |
|
chadmat
The Chadinator
1974 Posts |
Posted - 2012-11-09 : 03:17:41
|
@prsi_no is NULL for every execution. Is that your intention?-Chad |
|
|
|
|
|