SQL execution order

QuestDB attempts to implement standard ANSI SQL. We also try to be compatible with PostgreSQL, although parts of this are a work in progress. QuestDB implements these clauses which have the following execution order:

  1. FROM
  2. ON
  3. JOIN
  4. WHERE
  5. LATEST ON
  6. GROUP BY (optional)
  7. WITH
  8. HAVING (implicit)
  9. SELECT
  10. DISTINCT
  11. ORDER BY
  12. LIMIT

We have also implemented sub-queries that users may execute at any part of a query that mentions a table name. The sub-query implementation adds almost zero execution cost to SQL. We encourage the use of sub-queries as they add flavors of functional language features to traditional SQL.

For more information on the SQL extensions in QuestDB which deviate from ANSI SQL and PostgreSQL, see the SQL extensions documentation.