Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsql-server,admin: add top-k queries to stats #486

Merged
merged 2 commits into from
Oct 24, 2023

Commits on Oct 23, 2023

  1. libsql-server,admin: add top-k queries to stats

    Top 10 most expensive queries are now stored and available
    in the admin api. The ranking is kept in-memory only.
    
    ```
    $ curl -s http://localhost:8081/v1/namespaces/default/stats | jq '.top_queries[]'
    {
      "rows_written": 0,
      "rows_read": 1,
      "query": "EXPLAIN SELECT * FROM t;"
    }
    {
      "rows_written": 0,
      "rows_read": 1,
      "query": "SELECT 1;"
    }
    {
      "rows_written": 2,
      "rows_read": 0,
      "query": "INSERT INTO t VALUES (1, 'a'), (2, 'bb');"
    }
    {
      "rows_written": 2,
      "rows_read": 1,
      "query": "create table t(id, v)"
    }
    {
      "rows_written": 0,
      "rows_read": 4,
      "query": "SELECT * FROM t;"
    }
    {
      "rows_written": 2,
      "rows_read": 4,
      "query": "INSERT INTO t SELECT * FROM t;"
    }
    ```
    psarna committed Oct 23, 2023
    Configuration menu
    Copy the full SHA
    4fcddf8 View commit details
    Browse the repository at this point in the history
  2. sqld: use unexpanded SQL for top queries

    ... so that we don't distinguish between different bound values
    when tracking queries, and instead only gather information
    about the raw query string that may contain wildcards, like:
     INSERT INTO t VALUES (?, ?, ?);
    psarna committed Oct 23, 2023
    Configuration menu
    Copy the full SHA
    b375291 View commit details
    Browse the repository at this point in the history