DBTrail
Fast queries from MySQL

From your MySQL client

Run reports and heavy queries from your MySQL client, on port 3309, without slowing down your MySQL.

Point mysql, a driver or a BI tool at port 3309, and heavy queries come back from DBTrail's copy of your tables instead of your MySQL. The heaviest of 14 real reports took 7.9 seconds where a MySQL replica took 225 (the numbers). The copy is seconds behind, like a replica with some lag, so a question about the last second belongs on your MySQL.

With PostgreSQL servers, the port is 5433 and the client is psql: From your PostgreSQL client.

1. Turn the port on

In the web interface: Settings → MySQL clients → Turn on. Or, in a script (In production):

curl -s -X PUT -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  http://127.0.0.1:8090/api/flashback -d '{"enabled": true}' | jq -r .password

Either way you get a password, shown only then. New password in the panel, or POST /api/flashback/password, replaces it.

2. Connect

The user is your server's name:

mysql -h 127.0.0.1 -P 3309 -u shop -p
SELECT status, count(*) FROM orders GROUP BY 1;
You should see

The answers, without slowing down your MySQL.

The SQL you can send

The client is MySQL's, the copy runs the statement. Most reports run as written:

Names
SELECT * FROM `orders`;
runs

Backtick names are read as MySQL reads them (0.127.0 or newer).

Lists
GROUP_CONCAT(name)
runs

The order of its list can differ from MySQL’s.

Dates
DATE_FORMAT(d, '%Y-%m')
runs

Written for the copy, and DATEDIFF too (0.132.0 or newer). Day and month names come out in English.

Parsing
STR_TO_DATE(s, '%d/%m/%Y')
with routing

Other MySQL-only functions need routing: DBTrail then sends them to your MySQL. Without it, error 1235 says how to write them for the copy.

To keep an application's SQL exactly as it is, turn on routing. Everything that still answers differently: SQL on the copy.

Limits

Small on purpose: a report should not be able to take the machine.

ReadsonlyOne read per statement. Anything else is refused with error 1064. Nothing here can change your data.
10,000rowsA bigger result is error 1104, not a cut answer. Add a LIMIT. The same error past 64 MB.
60 sper statementThen it is stopped, with error 1317. Past 2 GB of memory it goes on more slowly, on disk, and fails past 8 GB.
No limitin lineWhen every worker is busy, the next statement waits its turn, for as long as its client stays connected. Many clients at once are slower, not refused.

Next: one connection for your application

Turn on routing and your application can use port 3309 in place of its MySQL: light queries run on your MySQL, heavy ones on the copy, and it keeps writing MySQL's SQL. Fast queries on your app's connection.

On this page