In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
CREATE INDEX listens_idx_uid ON "listens" ("uid");
WITH max_table AS (SELECT
max(listens.timestamp) - 10000 AS max
FROM
listens
GROUP BY
listens.uid) SELECT
1
FROM
listens
WHERE
listens.timestamp < (
SELECT
max_table.max
FROM
max_table
)