Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Performance improvement on low hit rate query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 11/08/2012 :  12:31:01  Show Profile  Reply with Quote
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
set @i=1
while @i < 10000 -- N
begin tran

set @s = 'select count(*) from dbo.Asg1_tbl where prsi_no = ' + str(@prsi_no)
commit tran
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??

The Chadinator

1974 Posts

Posted - 11/09/2012 :  03:17:41  Show Profile  Visit chadmat's Homepage  Reply with Quote
@prsi_no is NULL for every execution. Is that your intention?

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000