Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6348397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:24:42+00:00 2026-05-24T21:24:42+00:00

Hi everyone I’m using custom paging and I’m getting data with this query. DECLARE

  • 0

Hi everyone I’m using custom paging and I’m getting data with this query.

DECLARE @pageIndex INT = 0;
DECLARE @pageSize INT = 10;
WITH foo AS (
    SELECT ROW_NUMBER() OVER (ORDER BY test ASC) as rownumber, test, col
    FROM TestDB.dbo.test
)
SELECT test, col FROM foo
WHERE rownumber BETWEEN (@pageIndex * @pageSize) + 1 AND (@pageIndex * @pageSize) + @pageSize

Its working as it should but I must consider performance so, here is the question.
Which way is better for SQL Server Performance?
Selecting whole data in table then paging in asp.net, php etc. OR selecting data with method which I described above.
I’m confused a bit because the method I described above is selecting whole data and giving Row Number to every row then Selecting rows which Row Number is between X and Y.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:24:43+00:00Added an answer on May 24, 2026 at 9:24 pm

    I think there is no obvious answer for this question. It really depends on following conditions:

    1. How large amount of data you are paging.
    2. How frequent you need to access these data (i.e. how much clients access data at a time).

    If you have large amount of data I would go for SQL paging, which should be faster, since the database engine is optimized for this (providing that you have the right indexes created).
    However if you have small amount of data (in terms, that it’ll fit in ram memory) you may load all the data, and you will boost performance, since the IO won’t be a bottle neck.

    In general, I would go for SQL paging, which is easier to maintain and to optimize if your dataset grows. Anyhow if io starts to be a bottleneck, depending on your resources you may replicate the databases, change the hardware etc. without the need of rewriting your running application.

    To sum up: it really depends :).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

everyone, I have this piece of the code: void foo(int var, int var1) {
everyone. I'm trying to get data from some page, it's updated using javascript. First,
Everyone I work with is obsessed with the data-centric approach to enterprise development and
Everyone has accidentally forgotten the WHERE clause on a DELETE query and blasted some
Everyone has this huge massively parallelized supercomputer on their desktop in the form of
Everyone is familiar with this functionality. If you open up the the outlook address
Everyone uses source-code control to manage versions (right?) and this provides some level of
everyone. I know this is a far treated subject, but I've looked everywhere and
everyone I got problem here I need to update a plist data in a
everyone! I've been at this for a while, and I'm not sure how this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.