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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Select

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-26 : 09:55:48
Meeta writes "Is there any other way to obtain records without using the select
statement.My table is really huge and i want to display the latest 4 records on my asp page.But it always return a timeout.
My select statement is as such:

select top 4 uid,coname,industry,email from vendor where typemember='Free' order by datestart desc

Is there any other way? Or is my select statement not valid?

Thank u
Meeta"

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2002-06-26 : 10:05:33
No, SELECT is the only way to return recordsets.
The is nothing wrong with your select statement.

You should look at your indexes, especially on typemember and datestart.
Go to Top of Page

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-06-26 : 10:07:19
I'm thinking this is a problem with your connection statement from your page.

Try running a statement of

select 'hi,'bye'

or something simular and see what that does.

I've got a table with 2.17 million records that will return a recordset in under 10 seconds when asked for something simular, so I don't think it's the size of your table and your query looks fine

Check indexes maybe....

[edit] spelling and [/edit]

-----------------------
Take my advice, I dare ya

Edited by - M.e. on 06/26/2002 10:08:14
Go to Top of Page

MuffinMan
Posting Yak Master

107 Posts

Posted - 2002-06-26 : 10:09:12
Two ideas:

1) If you are constantly pulling data based on a date (or date range) or are sorting by date(s), then put your clustered index on the date field. This should take care of your timeout issue.

2) If the clustered index is on the primary key (and you want to keep it that way), create an INSERT trigger on your table that writes the primary key value of the newest row to a holding table. This holding table would always keep the primary key value of the last four records (you'll have to write some code to keep only four records in the table). Simply join this holding table with your Vendor table on the primary key to return to data.

Go to Top of Page
   

- Advertisement -