Santosh Reddy
Santosh Reddy

Reputation: 1

optimising sql select statement

Is there a way to fetch 4 million records from SQL Server 2005 in under 60 seconds?

My table consists of 15 columns. Each has datatype of varchar(100) and there is no primary key.

Upvotes: 0

Views: 131

Answers (2)

Ashish Gupta
Ashish Gupta

Reputation: 15139

Actually last time I did something like this, i put a filter dropdown and then the records would be filtered using the filter user selects. I also give the option "All" in the dropdown selecting which I show the user a message like "Retrieving all records will be bit slow. Want to continue?". And in any case, as Mark suggested, I used paging .

Upvotes: 0

Mark Byers
Mark Byers

Reputation: 838116

Assuming you want the entire contents of the table then try this first:

SELECT col1, col2, ... col15 FROM your_table

If that is too slow then there's not really anything more you can do apart from change your program design so that it is not necessary to fetch so many rows at once.

If this records will be displayed in a graphical user interface you could consider using paging instead of fetching all the rows at once.

Upvotes: 2

Related Questions