How does SQL work in Manalens?
The Explorer runs read-only SQL on the table raw_events, where each row is one event. The tables sessions and session_events hold sessions. Read fields in context and properties with JSONExtractString() or JSONExtractFloat().
Write one SELECT or WITH statement. A result has at most 200 rows, and a query stops after 8 seconds. You can run 10 queries a minute, and a project can run 30. raw_events includes bot rows, so exclude them with JSONExtractString(context, 'device') != 'bot'. Use uniqExact(message_id) for exact event counts, because a client retry can repeat a row.
Sources: Manalens SQL explorer guide.
What does an example look like?
Example: the fail rate of each level is fails / starts. The query below counts both for each level. With example numbers of 480 starts and 168 fails on level 3, the fail rate is 168 / 480 = 35%.
SQL
SELECT JSONExtractInt(properties, 'level') AS level,
uniqExactIf(message_id, event = 'level_start') AS starts,
uniqExactIf(message_id, event = 'level_fail') AS fails,
round(fails / starts * 100, 1) AS fail_rate
FROM raw_events
WHERE type = 'track'
AND event IN ('level_start', 'level_fail')
AND JSONExtractString(context, 'device') != 'bot'
GROUP BY level
ORDER BY levelSources: worked example; Manalens SQL explorer guide and game events documentation.
Why does SQL matter for indie PC and web games?
Games have their own questions, such as which weapon players pick or which level each build makes harder. A fixed report cannot know them in advance. SQL answers them on your own events, and you can save the query as a dashboard chart.
ClickHouse says uniqExact gives the exact number of different values and uses more memory than uniq. Exact counts matter when you compare small groups.
Sources: ClickHouse documentation: uniqExact; Manalens SQL explorer guide.
Frequently asked questions
Can I change data with SQL in Manalens?
No. The Explorer runs read-only SQL. Write one SELECT or WITH statement on raw_events, sessions or session_events. A result has at most 200 rows, and a query stops after 8 seconds. You can run 10 queries a minute, and a project can run 30, so group and count in the query instead of listing rows.
How do I keep a SQL query?
The Explorer does not save queries. Open a dashboard, click Add chart, then Blank chart, paste the query into the SQL query box, name the columns to draw and save the chart. An AI tool can run the same SQL with the MCP tool execute_query and the query:read scope.
Why use uniqExact(message_id) instead of count()?
A client retry can repeat a row in raw_events, so count() can count one event twice. uniqExact(message_id) counts each event once. ClickHouse says uniqExact gives the exact number of different values and uses more memory than uniq. Exact counts matter when you compare small groups, such as one level or one build.