memsql / dbbench

Database Benchmark Tool
Apache License 2.0
155 stars 30 forks source link

Update TUTORIAL.md to include query-log-file #2

Closed mpchlets closed 8 years ago

mpchlets commented 8 years ago

https://github.com/mpchlets/dbbench/blob/master/TUTORIAL.md

awreece commented 8 years ago

Please link to the answer in the tutorial selection. :)

rafaelalmeida commented 5 years ago

If you're OK with the answer being a Python script, I can submit a PR:

import sys

for line in sys.stdin:
    if line.startswith("SET timestamp"):
        timestamp = 1000 * 1000 * int(line.split("=")[1][:-2])
        query = next(sys.stdin).strip()
        print("{},{}".format(timestamp, query))

Usage is cat mysql-slowquery.log* | python3 convert.py (assuming queries in the log are in order)