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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:15:43+00:00 2026-05-12T13:15:43+00:00

I’m using ASP.NET MVC and Azure Table Storage in the local development fabric. My

  • 0

I’m using ASP.NET MVC and Azure Table Storage in the local development fabric. My pagination code is very slow when working with a large resultset:

var PageSize = 25;
var qResult2 = from c in svc.CreateQuery<SampleEntity>(sampleTableName)
                           where c.PartitionKey == "samplestring"
                           select c;
TableStorageDataServiceQuery<SampleEntity> tableStorageQuery = 
                 new TableStorageDataServiceQuery<SampleEntity>
                 (qResult2 as DataServiceQuery<SampleEntity>);
var result = tableStorageQuery.ExecuteAllWithRetries()
                                .Skip((page - 1) * PageSize)
                                .Take(PageSize);
var numberOfEntities = tableStorageQuery.ExecuteAllWithRetries().Count
ViewData["TotalPages"] = (int)Math.Ceiling((double) numberOfEntities / PageSize);
ViewData["CurrentPage"] = page;
return View(result);

The ViewData is used by the View to calculate paging links using code from Sanderson’s MVC book. For an Azure Table with 1000+ entities, this is very slow. For starters, “Count” takes quite a long time to calculate the total number of entities. If I’m reading my LINQ book correctly, this is because the query doesn’t implement ICollection. The book is “Pro LINQ” by Joseph Rattz.

Even if I set “numberOfEntities” to the known total (e.g. 1500), the paging is still slow for pages above 10. I’m guessing that .Skip and/or .Take are slow. Also, I call ExecuteAllWithRetries() twice, and that can’t be helping if in fact Azure is queried twice.

What strategy should I follow for paging through large datasets with ASP.NET MVC and Azure?

EDIT: I don’t need to know the exact total number of pages.

  • 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-12T13:15:43+00:00Added an answer on May 12, 2026 at 1:15 pm

    Skip and Take aren’t the problem here – they will be executed against the IEnumerable, which will already be in memory and thus very quick.

    ExecuteAllWithRetries is likely to be the culprit here – you’re basically retrieving all of the entities in the partition from the remote storage in this call, which will result in a very large payload.

    Pagination in the manner you’re showing is quite difficult in Table Storage. Here are a few issues:

    • The only order that’s guaranteed is the PartitionKey/RowKey order, so you need to design your RowKeys with this in mind.

    • You can perform the Take in the query (ie, your qResult2), so this will reduce the number of entities going over the wire.

    • To perform the Skip-like functionality, you’ll need to use a comparison operator. So you’ll need to know where you are in the result set and query all RowKeys above that value (ie, add something like where c.RowKey > [lastRowKey] to your query)

    • There’s no way to retrieve a count without keeping track of it yourself (or retrieving the entire table like you’re already doing). Depending on your design, you could store the count along with each entity (ie, use an incrementing value) – but just make sure you keep track of concurrent edit conflicts, etc. If you do keep track of the count with each entity, then you can also perform your Skip using this as well. Another option would be to store the count in a single value in another entity (you could use the same table to ensure transactional behaviour). You could actually combine these approaches too (store the count in a single entity, to get the optimistic concurrency, and also store it in each entity so you know where it lies).

    • An alternative would be, if possible, to get rid of the count altogether. You’ll notice a couple of large scalable sites do this – they don’t provide an exact list of how many pages there are, but they might let you go a couple of pages ahead/back. This basically eliminates the need for count – you just need to keep track of the RowKeys for the next/prev pages.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported

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.