Search code examples
asp.netajaxdatabaseperformance-testing

One big call to db vs multiple small calls to implement auto suggest


I am working on a project and implementing the search functionality.

I have a text box and there will be an auto suggestion implemented.

I have two ways to go.

  1. Make a single call to the DB and filter the list of the auto-suggest or.

  2. Make multiple calls in the DB and update the auto-suggest list using ajax

what is the best solution performance-wise and why?


Solution

  • It depends on how "heavy" both approaches are from the database perspective and how fast should auto-suggest response be. Well-behaved application built on connection pool pattern should not take too many resources for 2nd approach, however, this way network traffic and latency come into play. On the other hand, 1st approach might take more resources.

    So I would recommend testing it out in real conditions using a load testing tool like Apache JMeter, producing the same load against 2 implementations, and measuring which one works faster and consumes fewer resources. See The Real Secret to Building a Database Test Plan With JMeter to get familiarized with the databases load testing concept.