# Slow Query

Slow query log is used to monitor abnormal time-consuming of command execution. Bitalosproxy and Bitalostored can log slow queries. The time-consuming threshold of slow query is configurable. If the command execution time exceeds the threshold, it will be recorded in the log. The slow query log has two purposes. One is to check unreasonable command call according to one record, and the other is to observe the stability of the service based on the number of slow query.

  • Bitalostored calculates the command execution time, including the time of raft proposal, and does not include the upstream network I/O time.
  • Bitalosproxy calculates the command execution time, including the response time of Bitalostored (multiple Bitalostured nodes may be called concurrently, taking the longest response time), and does not include the network I/O time to the upstream.

# Bitalostored

The slow query log is enabled by default. The slow query time-consuming threshold is configured by option server.slow_time. The slow query log directory is (option server.db_path + log), file name is bitalos.log.slow.xxx.

Slow query log format:

2024-02-29 13:07:18.667973 server/client.go:303 [SLOW] [ip_port:127.0.0.1:62895] [duration(us):50802] [raftsync(us):0] [query:"xxx"] [status:OK]

- slow query log time, unit is microsecond (μs)
- ip_port, upstream ip and port
- duration, the total time of slow query(including raft proposal time), unit is microseconds (μs)
- raftsync,raft proposal time, unit is microseconds (μs)
- query, command details, output up to the first 128 bytes
- status, whether the command execution is failed. If failed, output "FAIL", otherwise output "OK"

# Bitalosproxy

The slow query log configuration is as follows.

Option Description Remark
log.slow_log Whether to enable slow query log ture|false
log.slow_log_cost Time threshold of slow query
log.slow_log_file Slow query log path Contains filename prefix

Slow query log format:

2024/02/28 23:05:38.502621 log.go:394: [INFO] [ip_port:127.0.0.1:51372] [duration(us):50530] [status:OK] [query:"xxx"]

- slow query log time, unit is microsecond (μs)
- ip_port, upstream ip and port
- duration, the total time of slow query, unit is microseconds (μs)
- status,whether the command execution is failed. If failed, output error, otherwise output "OK"
- query, command details, output up to the first 256 bytes
ZUOYEBANG