My idea is this:

  1. get mysql dump file from production (GBs)
  2. prepare set of requests based on access logs and run them
  3. record all accessed records in mysql
  4. remove everything else in my db
  5. finally: have lightweight db and recorded requests as tests.

I have a problem with points 3+4. I wonder if such a feature even exists for MySQL, with the possibility to delete, and drop everything that was not accessed (including indexes rebuild).

Of course, having a lightweight DB is needed to easily auto-generate test fixtures, and this is the main purpose.

  • you cant do it so easy. If you have query like : SELECT .... WHERE datefield > NOW() - interval 1 DAY . So it works only today.
    – Bernd Buffen
    Commented Aug 25, 2016 at 13:52
  • There is acceptable, db has hundreds of tables and writing fixtures from scratch for every possible request type will be really time consuming. The problem is how to examine access coverage in mysql ? and then how to use that coverage to remove everything else ? btw - it could have usage in different purpose as well.
    – ups
    Commented Aug 25, 2016 at 13:59
  • .... and you can freeze time in tests, so don't worry about state.
    – ups
    Commented Aug 25, 2016 at 14:01
  • What is the advantage of slimming? With good indexes, performance is unlikely to improve noticeably.
    – Rick James
    Commented Aug 26, 2016 at 3:12
  • @Rick James: Slimming here is an inter-state for preparing test environment - we want loading a specific, known set of data, then generate fixtures (programming objects/code/json/...) based on that data. After all these fixtures (serialized db data in code) will be loaded (as new database) and modified by tests again and again. It's crucial to have fast running tests. In my db I have exactly 949 tables with thousands or millions records each, but for tests I need only dozens/hundreds records in each table. Commented Aug 26, 2016 at 6:39

1 Answer 1


MySQL doesn't contain any built-in way of marking rows when they're accessed. You could conceivably use triggers to record updates, inserts, and deletes, but not selects.

It's conceivable that somebody could adapt the alpha-quality MySQL proxy server, or the MySQL relay, to build a recording proxy. But that would be a lot of work, and it would yield the queries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.