Mysql – Querying MySQL InnoDB to find if the Record is in its Buffer Pool

buffer-poolinnodbMySQL

For us, it is very important to get high response time for our website php script which queries a large database. It is essentially getting user information for the user who visited the page. There may be millions of users in the db.

We would like to not bother using the user data at all if the record is not already in the InnoDB Buffer Pool of the MySQL database, and use information only if present in the above cache.

Is there a way to directly ask Mysql/InnoDB whether the record is in cache?

We thought this might have been addressed by many others when developing high performance web apps. Is it not common to get data only if can be retrieved in super quick time (for some scenarios at least where response time is very critical) and not otherwise?

Best Answer

There is no built-in mechanism to query the MySQL cache without causing MySQL to bring the row into memory from disk if it is not already in memory.

You might want to consider using a caching layer between your website and the database. Stack Exchange uses Redis; you may want to evaluate that.