Skip to main content
16-Pearl
August 13, 2026
Question

Best Practice for Handling Large SQL Queries (40+ Seconds) That Run Only a Few Times Per Month?

  • August 13, 2026
  • 2 replies
  • 29 views

Hi everyone,

I have a scenario where a very large SQL query processes data from multiple large tables and applies different joins, filters, and calculations before producing the final output. The execution time can sometimes reach 40+ seconds.

One important detail is that this process is not a frequent operation. It only occurs about 3 times per month, so optimizing for high-volume traffic is not a requirement.

Because of this, I'm questioning whether implementing a full asynchronous processing architecture is worth the added complexity. At the same time, simply increasing server timeouts doesn't feel like the best practice.

For a low-frequency but resource-intensive operation like this, what would you recommend?

 

 

  • What approach have you used for similar low-frequency, long-running database operations?

I'd appreciate any recommendations or real-world experiences.

Thanks in advance! 

2 replies

Rocko
19-Tanzanite
August 13, 2026

Run it directly in the DB. You can have scheduled jobs in the DB that create (or update) materialized views (or a similar concept). TWX then just gets the precomputed data. This is DB reporting, nothing you would put onto an IOT platform.

16-Pearl
August 14, 2026

Not sure how you trigger the SQL currently, but if with SQLThing: You can set query timeout per service:

Which is great :) PTC support showed me that option and I was amazed as I did not spot it myself.