Click here to Skip to main content
15,891,006 members
Please Sign up or sign in to vote.
1.00/5 (6 votes)
See more:
hi all,

I have 100000 record in a table,

i want select 10000 records with in 0 seconds,

If i use select query like
SQL
select top 10000 * from table1
it takes me 25 to 50 seconds

can you help me

thanks advance.
Posted
Updated 14-May-14 5:16am
v4
Comments
Richard MacCutchan 7-Apr-14 12:23pm    
Have you ever heard of the Laws of Physics? You cannot do anything in 0 seconds.
phil.o 14-May-14 11:25am    
Yes, you can, if you admit the possibility of an infinite speed :)

You cannot select anything in 0 seconds, usually it will take some amount of time >0.

To select 10,000 records from 100,000 records you can do the following (if you don't have a filter to work with):
SQL
select top 10000 * from table1 

To make things faster you can add indexes to your table.
 
Share this answer
 
Comments
Andrius Leonavicius 7-Apr-14 11:24am    
Agree with you, +5.
One more thing to mention: select only needed columns instead of *.
Mehdi Gholam 7-Apr-14 11:48am    
True, thanks Andrius!
Andrius Leonavicius 7-Apr-14 11:58am    
You're welcome.
Sergey Alexandrovich Kryukov 7-Apr-14 15:14pm    
Captain Obvious at work got 5.

It's a bit late but... have you seen my 1st of April publication?
Power Over IP: Testing of the First Experimental Facility.

Hope it can feel you more energetic :-) and fun; and perhaps you can ask me some difficult questions. ;-)

—SA
Maciej Los 7-Apr-14 17:41pm    
Excellent answer, +5!
Please, see my answer ;)
I'd like to say it's a very poor idea to load large portion of data!

Have you ever heard about paging[^]?

Have a look here:
Tutorial 25: Efficiently Paging Through Large Amounts of Data[^]
Paging SQL Server result sets[^]

More on CP KB[^].
 
Share this answer
 
Comments
Mehdi Gholam 8-Apr-14 3:56am    
Touche :)
CPallini 14-May-14 12:28pm    
5.
Maciej Los 14-May-14 12:47pm    
Thank you, Carlo.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900