0

I have to run a query which produces very large result set (20K result and 5 columns each row).

I am doing some processing on the data and storing the result in another database table.

All this processing is done on a cron process.

My problem is that when I run the query CPU utilization of my database server reaches up to 100% until the process finishes.

Please help me in understanding best practice for this kind of scenarios.

1 Answer 1

1

In such cases you need to start thinking about optimization and/or vertical scaling of the MySQL instance.

  • Try to find a way to optimize the SQL query you're using
  • If possible, split the cron job in several steps that execute lighter queries.
  • If some of the data in the returned query set is identical on each cron run - cache it.
  • If frequency of script execution is not of critical importance, split the runs and limit the query sets to a smaller number. You can execute the script 4 times in 20 minutes with 5k items in the query set.
  • Think about migrating to a non-relational database, if possible.
  • Do some performance tuning of the MySQL instance.
  • etc.
Sign up to request clarification or add additional context in comments.

Comments

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.