Question

I've got a heavily used process that needs to access a 3rd party API and store an abridged version of the data to my own database. This data spans 3 tables so I have 3 separate insert statements that are called independently. If this API needs to be called 100 times then that is 300 insert statements being run.

I'm using AWS EC2 (PHP) and RDS (MySql) and now the RDS I/O cost is beginning to match the instance costs, I'm sure primarily due to this process.

Will using multi_query to package up the 3 insert statements result in a third of the database I/O's (and hence a third of the associated costs) or does it not make a difference due to having to call $mysqli->more_results() for each statement?

Was it helpful?

Solution

I very much doubt it would help in that regard.

While mutli_query is useful, the RDS server is still running the same number of queries,IOPS are counted for any reads or writes to your RDS instance that is related to the database software. That includes logs as well (binlog, but also error log, general log, etc), temporary files, etc.

You will also find that long or complex queries will count as multiple IOPS. Read replicas will also cause additional IOPS since they are reading a binlog and then running queries based on that.

So it is unlikely that putting multiple queries into one call would lower the iops used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top