-2

I have a java + react + mysql db application that displays objects for different cities. Objects can be displayed for each city.

  • filtering is java side
  • React side pagination

I have a little problem, it takes up to 9 seconds to display all objects on the front for large cities. How could I increase the filtering speed? One of the ideas I've read is to divide the database into cities, create filtering on the base, and create pagination by JPA. This solution is a lot of work, is there any other way to increase the filter speed? (changing the base is not an option)

Paweł Pamuła
  • 75
  • 1
  • 11

3 Answers3

3

You could go for the CACHE design where you could store the data in KEY | VALUE pair. City will be the key and List of Objects will become the value, by this way the fetch will have O(1) complexity.

Koushlendra
  • 280
  • 1
  • 9
1

It fully depends on your frameworks and their caching mechanisms, but in general, it's like:

  1. Reduce the result set at the database level as much as you can (check the SQL query/joins/use better selectivity criteria/review query explain plan/check indexes/statistics/etc.)
  2. Fetch the results using batches (How to fetch data from oracle in batches from java in equal batches)
  3. The query results should be cached at the java level based on your framework and app. architecture (microservice, monolith, bloody JEE, etc.)
  4. Return this cached data to the frontend
lazylead
  • 1,453
  • 1
  • 14
  • 26
1

you can try vectorization, the process reduce time and there are many libraries in java you can read morehere

Johan
  • 29
  • 5