What are the factors that would affect the RAM usage by a query?
How do I assess the rough RAM usage of a query given the complete SQL?
This is regarding the MySQL RDBMS.
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
MySQL uses RAM in many ways...
For caching data and indexes. In some sense, it does not matter how much RAM, since it is cache. This may be the biggest use, but it is a "shared" use.
SELECT may need a temporary table (eg, for
GROUP BY and/or
ORDER BY and/or subquery). This may be done in RAM, or it may not even attempt to do it in RAM, but instead do it on disk. There is one setting that puts a limit on the size of each in-memory temp table.
The parsing of the statement takes a little bit of RAM.
binlog is buffered through RAM.
"Group commit" is buffered in RAM.
Galera does its "will this commit with a deadlock" logic in RAM.
InnoDB uses bits to keep track of what is locked.
Shall I go on? Your question is not easy to answer. Furthermore, I would argue that it is mostly irrelevant. Would you care to explain why you asked?