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

  • Home
  • SEARCH
  • 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 71081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:49:54+00:00 2026-05-10T19:49:54+00:00

EDIT: I’m still waiting for more answers. Thanks! In SQL 2000 days, I used

  • 0

EDIT: I’m still waiting for more answers. Thanks!

In SQL 2000 days, I used to use temp table method where you create a temp table with new identity column and primary key then select where identity column between A and B.

When SQL 2005 came along I found out about Row_Number() and I’ve been using it ever since…

But now, I found a serious performance issue with Row_Number(). It performs very well when you are working with not-so-gigantic result sets and sorting over an identity column. However, it performs very poorly when you are working with large result sets like over 10,000 records and sorting it over non-identity column. Row_Number() performs poorly even if you sort by an identity column if the result set is over 250,000 records. For me, it came to a point where it throws an error, ‘command timeout!‘

What do you use to do paginate a large result set on SQL 2005? Is temp table method still better in this case? I’m not sure if this method using temp table with SET ROWCOUNT will perform better… But some say there is an issue of giving wrong row number if you have multi-column primary key.

In my case, I need to be able to sort the result set by a date type column… for my production web app.

Let me know what you use for high-performing pagination in SQL 2005. And I’d also like to know a smart way of creating indexes. I’m suspecting choosing right primary keys and/or indexes (clustered/non-clustered) will play a big role here.

Thanks in advance.

P.S. Does anyone know what stackoverflow uses?

EDIT: Mine looks something like…

SELECT postID, postTitle, postDate FROM    (SELECT postID, postTitle, postDate,           ROW_NUMBER() OVER(ORDER BY postDate DESC, postID DESC) as RowNum     FROM MyTable    ) as DerivedMyTable WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @maximumRows) - 1 

postID: Int, Identity (auto-increment), Primary key

postDate: DateTime

EDIT: Is everyone using Row_Number()?

  • 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. 2026-05-10T19:49:55+00:00Added an answer on May 10, 2026 at 7:49 pm

    Well, for your sample query ROW_COUNT should be pretty fast with thousands of rows, provided you have an index on your PostDate field. If you don’t, the server needs to perform a complete clustered index scan on your PK, practically load every page, fetch your PostDate field, sort by it, determine the rows to extract for the result set and again fetch those rows. It’s kind of creating a temp index over and over again (you might see an table/index spool in the plain).

    No wonder you get timeouts.

    My suggestion: set an index on PostDate DESC, this is what ROW_NUMBER will go over – (ORDER BY PostDate DESC, …)

    As for the article you are referring to – I’ve done pretty much paging and stuff with SQL Server 2000 in the past without ROW_COUNT and the approach used in the article is the most efficient one. It does not work in all circumstances (you need unique or almost unique values). An overview of some other methods is here.

    .

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

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Just a quick follow up, there's a quite straight forward… May 11, 2026 at 12:35 pm
  • added an answer Instead of using the height propertiy (since its causing problems)… May 11, 2026 at 12:35 pm
  • added an answer That is because you are comparing an Object to a… May 11, 2026 at 12:35 pm

Related Questions

Edit: I have solved this by myself. See my answer below I have set
EDIT: I missed a crucial point: .NET 2.0 Consider the case where I have
EDIT: I'm still waiting for more answers. Thanks! In SQL 2000 days, I used
Edit: I am using SqlDataAdapters to fill the data sets. Sorry--I should have been
EDIT: I also have access to ESXLT functions. I have two node sets of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.