engine-deprecated icon indicating copy to clipboard operation
engine-deprecated copied to clipboard

Log something on slow queries

Open dpordomingo opened this issue 7 years ago • 1 comments

discovered at https://github.com/src-d/empathy-sessions/issues/37 related to https://github.com/src-d/engine/issues/271 related to https://github.com/src-d/engine/issues/279

If a query takes a lot with no output at all until it finishes, the user can think that something was broken.

I wonder if we could let the user know that something is being processed. For example adding the spinner we already added when starting gitbase on https://github.com/src-d/engine/pull/216

$ srcd sql "SELECT cf.file_path,
    LANGUAGE(f.file_path,  f.blob_content) as lang
FROM ref_commits r
NATURAL JOIN commit_files cf
NATURAL JOIN files f
WHERE r.ref_name = 'HEAD'
AND r.history_index = 0;"

I wonder if SHOW PROCESSLIST could give some info about the process. I saw that while running a slow query in background, files field keeps growing until the query finish. I think that files field represents the number of repositories, or sivas being processed... or at least it matched that number in a couple of tests.

$ srcd sql 'SHOW PROCESSLIST;'
+----+------+--------------------+---------+---------+------+--------------+--------------------------------+
| ID | USER |        HOST        |   DB    | COMMAND | TIME |    STATE     |              INFO              |
+----+------+--------------------+---------+---------+------+--------------+--------------------------------+
| 44 | root | 192.168.96.2:34616 | gitbase | query   |    0 | running      | SHOW PROCESSLIST;              |
|  4 | root | 192.168.96.2:34616 | gitbase | query   |  151 | files(17/34) | SELECT count(*) as count       |
|    |      |                    |         |         |      |              | FROM files                     |
|    |      |                    |         |         |      |              | WHERE language(file_path,      |
|    |      |                    |         |         |      |              | blob_content) = 'Go'           |
|    |      |                    |         |         |      |              | LIMIT 50;                      |
+----+------+--------------------+---------+---------+------+--------------+--------------------------------+

dpordomingo avatar Mar 06 '19 09:03 dpordomingo

related: #121.

carlosms avatar Mar 28 '19 13:03 carlosms