0

I have a database that syncs completely every 2 hours. All data is dropped and populated from the main data source.

I have some queries coming from client app, that have the same response for the current 2-hours dataset. So, if 100 clients run their apps, I will have to run this query 100 times for each of them, even though they don't differ.

How do I avoid running this real query against my database every time, but just keep its response somewhere and return it instead?

I think I can run this query after each sync and save to its own table then return from it.

What are other options, probably provided by Postgres itself?

1 Answer 1

1

You should use something like redis to store the result or your query in memory. It comes with many clients. You can invalidate the result of this query when it's time to.

There are other memory caching like memcache, easy to install & to use.

Note these are specific to postgres.

Sign up to request clarification or add additional context in comments.

1 Comment

Databases like Postgres already do this, so there's no need to use Redis for it."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.