Search⌘ K
AI Features

Paging Data

Explore how to implement data paging in a web API using ASP.NET Core to improve performance and scalability. This lesson guides you through adding query parameters for page number and size, modifying the database query to fetch only the requested data subset, and comparing load test results to demonstrate the benefits of paging large datasets.

In this section, we are going to force the consumers of our questions endpoint to specify the page of data when executing the request with the search query parameter. So, we'll only be returning a portion of the data rather than all of it.

Paging helps with performance and scalability in the following ways:

  • The number of page read I/Os is reduced when SQL Server grabs the data.

  • The amount of data that's transferred from the database server to the web server is reduced.

  • The amount of memory that's used to store the data on the web server in our model is reduced.

  • The amount of data that's transferred from the web server to the client is reduced.

This all adds up to a potentially significant positive impact—particularly for large collections of data.

We will start this section by load testing the current implementation of the questions endpoint. We will then implement paging and see the impact this has on a load test.

Adding test questions for the load test

...