Amazon Aurora pricing page mentions that:
For I/O charges, let’s assume the same database reads 100 data pages from storage per second to satisfy the queries running on it. This would result in 262.8 million read I/Os per month (100 pages per second x 730 hours x 60 minutes x 60 seconds).
What is meant by "data pages" here?
Similarly, let’s assume your application makes changes to the database affecting an average of 10 data pages per second. Aurora will charge one I/O operation for up to 4 KB of changes on each data page. If the volume of data changed per page is less than 4 KB, this would result in 10 write I/Os per second.
Do multiple smaller SQL queries result in more IOPs than a single large SQL query?
CodePudding user response:
What is meant by "data pages" here?
Each database page is 16 KB for MySQL-compatible Aurora & 8 KB for PostgreSQL-compatible Aurora (source: Amazon Aurora FAQs).
Do multiple smaller SQL queries result in more IOPs than a single large SQL query?
Not necessarily but it is possible.
The key here is that you optimise your queries to read/write only as much as you need and to not split un-necessarily.
Too many small writes less than 4KB will mean that you will pay more in the long run for no reason & you'll be better off making changes of at least 4KB or more to get the most 'bang for your buck'.
Example
Let's say we want to write 22KB of data to the database.
If done in one query, you would be charged for 6 I/O operations.
-> 22KB / 4KB = 5, remainder 2
-> 5 I/O operations with an extra 1 I/O op. (to account for the remaining 2KB left over)
If done in 5 different queries, split by you, you would also be charged for only 6 I/O operations (hence why I said not necessarily).
However, if done in queries split so that each query is less than 4KB, you would then be paying more than needed as you would be consuming more I/O operations.
e.g. if your queries each write only 2KB to the database, you would theoretically1be charged for 11 I/O operations, which would be an extra 5 I/O operations.
-> 22KB / 2KB = 11 I/O operations
1 As the documentation mentions, the number of write operations can potentially be less but that is subject to internal Aurora write I/O optimizations that can combine write operations less than 4 KB in size together under certain circumstances. In other words, they may combine operations together for you but it is not guaranteed.