Skip to content
Advertisement

Is there efficient SQL to query a portion of a large table

The typical way of selecting data is:

select * from my_table

But what if the table contains 10 million records and you only want records 300,010 to 300,020

Is there a way to create a SQL statement on Microsoft SQL that only gets 10 records at once?

E.g.

select * from my_table from records 300,010 to 300,020

This would be way more efficient than retrieving 10 million records across the network, storing them in the IIS server and then counting to the records you want.

Advertisement

Answer

Try looking at info about pagination. Here’s a short summary of it for SQL Server.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement