I have the below data that I am caching in Python now:
id timestamp data-string
The data-string size is ~87 bytes. Storing this optimally in python (using dict and having the timestamp pre-pended to the data-str with delimiter), the RAM costing per entry comes to ~198 bytes. This is quite big for the size of the cache I need.
I would like to try out storing the same in MySQL table, to see if I can save on RAM space. While doing so, I store this as:
id timestamp data-string
4B 4B
<---- PK ---->
I understand that MySQL will load the index of the InnoDB table (that's what I have now) into RAM. Therefore, the id (unique), timestamp and a pointer to the data-string will reside on RAM.
How do I calculate the complete RAM usage (ie including the meta-data) for the B+Tree of MySQL only for this new table?
There are so many variables, padding, etc, that it is impractical to estimate how much disk space an InnoDB BTree will consume. The 2x you quote is pretty good. The buffer_pool is a cache in RAM, so you can't say that the BTree will consume as much RAM space as disk did. Caching is on 16KB blocks.
(@ec5 has good info on the current size, on disk, of the index(es).)