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 |
|
TranscendMedia
Starting Member
1 Post |
Posted - 2003-09-12 : 15:21:59
|
| An article on SQLTeam suggests the use of Order By NewID() to return random records from a database. I have used this in many applications and it works great, with the exception of one. I have an application that has a SQL table with a few hundred thousand records. The application goes through and runs a "Select top 30 * From table Where Id <> @InputID Order by NewId()" query a couple hundred times. Half way through the application the system times out.I also have seen "Order by Rand(id)" used where ID is the primary key.Is there a better solution then the ones listed above? What are the best performance wise? The application is developed in ASP/VB and the db is running on SQL 2000.Thank you all in advance for your help!Gregory A. Van HornTranscend Media GroupInteractive Marketing & Development |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-09-12 : 16:06:08
|
| Do you have the appropriate indexes on the table to support the WHERE clause?Tara |
 |
|
|
|
|
|