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 6603697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:02:59+00:00 2026-05-25T19:02:59+00:00

My method of paging is inefficient as it calls the same query twice therefore

  • 0

My method of paging is inefficient as it calls the same query twice therefore doubling the query time. I currently call the 1 query that joins about 5 tables together with XML search querys to allow for passing List from ASP.net.. then I need to call exactly the same query except with a Count(row) to get the amount of records

For Example (I have removed bits to make it easier to read)

Main Query:

WITH Entries AS (
  select row_number() over (order by DateReady desc)
  as rownumber, Columns...,

 from  quote

 join geolookup as Pickup on pickup.geoid = quote.pickupAddress

 where 
     quote.Active=1
     and //More 
 )
 select * from entries 
 where Rownumber between (@pageindex - 1) * @pagesize + 1 and @pageIndex * @pageSize
 end

Count Query:

 select count(rowID)        
 from  quote

 join geolookup as Pickup on pickup.geoid = quote.pickupAddress

 where 
     quote.Active=1
     and //More 
 )
  • 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-25T19:03:00+00:00Added an answer on May 25, 2026 at 7:03 pm

    You could select the results of your big query into a temp table, then you could query this table for the row number and pull out the rows you need.

    To do this, add (after your select statement and before the from)

    INTO #tmpTable
    

    Then reference your table as #tmpTable


    select row_number() over (order by DateReady desc)  
      as rownumber, Columns...,  
    into #tmpTable
    
     from  quote  
    
     join geolookup as Pickup on pickup.geoid = quote.pickupAddress  
    
     where   
         quote.Active=1  
         and //More   
     )  
    
     SELECT @Count = COUNT(*) FROM #tmpTable
    
     select * from #tmpTable  
     where Rownumber between (@pageindex - 1) * @pagesize + 1 and @pageIndex * @pageSize  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a linq to sql method that handles sorting, paging, and
Currently, the ItemCollection#query method in the Ruby AWS SDK returns the whole dataset. I
I have found an extension method that handles sorting and paging for LINQ .
Currently, I am using this recordset paging method: (this example has been cut down
I've found out the following article about A More Efficient Method for Paging Through
Task: implement paging of database records suitable for different RDBMS. Method should work for
When using SetFirstResult(start) and SetMaxResults(count) methods to implement paging I've noticed that the generated
What method do you use when you want to get performance data about specific
What method do I call to get the name of a class?
Should I use LINQ's Skip() and Take() method for paging, or implement my own

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.