Docs

Smart alerts

waw-sql watches every query and points out scripts that use the database badly, with the script's name, the query and how to fix it.

What it finds

The findings are listed under Problems → Smart alerts.

findingwhat it meanswhen it fires
Query running in a loopthe same query repeated constantly: a query inside a loop, a tick or an event that fires all the timethe same query 200 times within 10 seconds
One query per row (N+1)a script fetches a list and then asks the database about every item separately; one IN (...) query would dothe same SELECT 20 times in a row, each with a different value
Values written into the query texta script joins values into the SQL instead of using ? parameters. With text from a player this is an SQL injection holethe same query seen with 5 different texts and no parameters
Script flooding the databaseone script sends so many queries that it can slow every other script down300 queries per second for 5 seconds in a row

At the top of the page, What is watched shows the limit of each of these four checks and whether automatic slowing is on, and Scripts closest to the limits shows how close each script has come to them since the server started.

Queries made while the server starts are not counted. A finding is recorded once and its counter goes up when it happens again.

  • Dismiss removes a finding for good.
  • Reset forgets everything, dismissed findings included.

Findings are stored in waw-sql-data/insights.json and survive a restart. With the Discord log switched on, each finding is also sent to the channel.

What to do with a finding

A finding is about another script, not about waw-sql, and it does not mean your server is broken. It points at a script that makes the database work harder than it needs to.

  1. Open the finding: it names the script, shows its query and says how it could be fixed.
  2. Send that to whoever made the script: its seller's support for a paid script, or its GitHub page for a free one. If you edit the script yourself, the finding tells you what to change.
  3. While you wait for a fix, you can let waw-sql slow a flooding script down (see below).
  4. Press Dismiss once it is fixed, or if you have decided to live with it.

Slowing a flooding script down

By default waw-sql only reports. Switch on Slow down runaway scripts under Maintenance → Settings and it also slows a flooding script down, so the rest of the server keeps its speed. Next to the switch you set how many queries a second such a script may still send (150 unless you change it).

  • A script that waits for its results (await, or the next query sent from the callback) drops to that many queries per second.
  • A script that fires queries without waiting gets each query delayed, by 5 seconds at most.
  • No query is ever refused or lost, other scripts are not touched, and the limit is lifted 30 seconds after the script calms down.

Settings

convardefaultmeaning
waw_sql_hotloop_count200the same query this many times within 10 seconds is reported as a loop
waw_sql_runaway_qps300queries per second from one script, 5 seconds in a row, reported as flooding
waw_sql_throttlefalseslow a flooding script down instead of only reporting it
waw_sql_throttle_qps150queries per second allowed to a script that is being slowed down

The last two are only used until Slow down runaway scripts is saved in the panel; from then on the panel's values are used.