Posted - 11/08/2012 : 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 int
declare @L int, @i int, @x datetime, @y datetime, @z real, @u datetime
declare @s varchar(1000)
set @x = getdate() -- start time
select x = @x
while @i < 10000 -- N
set @s = 'select count(*) from dbo.Asg1_tbl where prsi_no = ' + str(@prsi_no)
set @i = @i + 1
set @y= getdate()
select y = @y
set @z = datediff(ms, @x, @y)
select 'Run time = ' + cast(@z as varchar(20)) + ' miliseconds.'
select * 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??