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

Let's carry out the following steps to add lots of questions to our database. This will allow us to see the impact of data paging:

  1. Let's open SQL Server Management Studio, right-click the “QandA” database in “Object Explorer,” and choose “New Query.”

  2. In the query window that opens, add the following command:

Get hands-on with 1200+ tech skills courses.