Skip to content

Data Explorer

The Data Explorer provides a unified interface for querying, analyzing, and exporting data stored in EMQX Tables. It is designed to streamline common workflows such as writing and running queries, inspecting query execution behavior, managing query history, and exporting results for further analysis.

This page describes the main components of the Data Explorer and explains how to use its features effectively.

Overview

The Data Explorer consists of the following main areas:

  1. Tables panel: Browse available schemas, tables, and columns, and quickly reference table structures while writing queries.
  2. Query editor: Write and execute SQL or PromQL queries.
  3. Action toolbar: Run queries, analyze execution plans with Explain Query, upload or download query files, and access query history.
  4. Results area: View query results, execution details, and export data in supported formats.

data_explorer_overview

Tables Panel Controls

The Tables panel can be expanded or collapsed to help you focus on query authoring and result analysis.

  • Click the collapse/expand icon next to Tables to toggle the panel.

    tables_panel_control

  • When the panel is hidden, the query editor and results area automatically expand, providing more horizontal space.

This is particularly useful when working with long or complex queries, where additional editor space improves readability and efficiency.

Query Editor

The Query Editor is where you write and execute SQL or PromQL queries against your EMQX Tables data.

Supported Query Types

The Query Editor supports the following query languages:

  • SQL (default)
  • PromQL

You can switch the query type using the selector in the top-right corner of the editor.

Run Query

The Run Query button executes a query based on the selected query language.

SQL Queries

The Run Query button executes one SQL statement at a time.

  • If the editor contains only one SQL statement, click Run Query to execute it directly.
  • If the editor contains multiple SQL statements, Data Explorer determines which statement to execute using the rules below.

This behavior allows you to work efficiently with both simple queries and multi-statement scripts in the same editor.

Statement Selection Rules (SQL only)

When multiple SQL statements are present:

  • Statements are separated by semicolons (;).
  • If no text is selected, the statement where the cursor is currently located is executed.
  • If text is selected, only the selected statement(s) are executed.

Use Run All to execute every SQL statement in the editor sequentially.

Examples of SQL Statement Selection

Example 1: Multiple statements on a single line
sql
SELECT * FROM t1;SELECT count(*) FROM t1;SELECT * FROM t2;
  • If the cursor is placed inside SELECT count(*) FROM t1;, the following statement is executed:

    sql
    SELECT count(*) FROM t1;

    query_example_1

  • If the cursor is placed inside SELECT * FROM t2;, the following statement is executed:

    sql
    SELECT * FROM t2;

    query_example_1_result2

Example 2: Statements split across multiple lines
sql
SELECT * FROM t1
WHERE host = 'server1';

SELECT * FROM t2
ORDER BY "timestamp" DESC
LIMIT 10;

If the cursor is placed anywhere inside the first query (SELECT * FROM t1 ...), the following statement is executed:

sql
SELECT * FROM t1
WHERE host = 'server1';

query_example_2

Example 3: Executing multiple statements together
sql
SELECT * FROM t1
WHERE host = 'server1';

SELECT avg(usage_user) FROM t1
WHERE region = 'us-east-1';

Select both statements using the mouse and click Run Query.

Both statements are executed sequentially, and each successful execution produces a separate result tab.

query_example3_result1

query_example3_result2

PromQL Queries

For PromQL, the Run Query button always executes a single PromQL statement.

  • Only one PromQL statement is supported in the editor at a time.
  • Cursor position and text selection are not applicable.
  • Executing multiple PromQL statements or selecting part of a statement is not supported.

When a PromQL query is present, click Run Query to execute the statement directly.

Run All

The Run All button executes every SQL statement in the editor sequentially.

  • Available for SQL only.
  • Each successfully executed statement generates a separate result tab.

Use this when you want to run batch queries or compare results from multiple queries at once.

Explain Query

The Explain Query feature helps you understand how a SQL or PromQL query is executed internally.

It returns the detailed execution process of the query, including:

  • The execution stages involved
  • How the query is planned and executed
  • The time spent in each stage

Explain Query is commonly used to identify performance bottlenecks, analyze slow SQL/PromQL queries, and optimize query design.

Click Explain Query to analyze the current SQL or PromQL statement. The Explain result is displayed as a dedicated Explain tab, positioned to the left of normal query result tabs. Only the latest Explain result is retained and displayed.

The Explain Query result supports two types of views.

  • Table view: Table-based view of execution stages.

    explain_query_table

  • Raw view: Raw API response (JSON) format, which can be copied for further analysis.

    explain_query_api

Query Results

Each time a query is executed successfully, Data Explorer generates a new query result.

  • Each successful query execution generates a new Result tab.
  • Tabs are labeled incrementally (e.g., Result 1, Result 2) and can be switched freely.
  • You can close individual tabs using the icon.

Results are not persisted after leaving the current deployment page.

Result Views

Depending on the query and data shape, results can be displayed in the following formats:

  • Table view (default): Displays query results in a tabular format with pagination. This view is suitable for inspecting raw records and exact values.

  • Chart view: Visualizes query results as charts for easier trend analysis and comparison.

    query_result_chart

Export Query Results

You can export query results in CSV format directly from the Data Explorer.

  1. Enter a query statement.
  2. Click the dropdown arrow next to Run Query.
  3. Select Export Result as CSV.
  4. The system runs the query and downloads the result.

export_result

Query History

Query History helps you review, reuse, and manage previously executed SQL and PromQL queries within the current deployment.

Automatic History Retention

Query history is recorded automatically according to the following rules:

  • Query history is stored locally in your browser.
  • Records are retained for up to 30 days.
  • For each deployment:
    • Up to 100 SQL queries.
    • Up to 100 PromQL queries.
  • When the limit is reached, the oldest records are removed automatically.
  • All query history is deleted when the deployment is removed.

Open Query History Panel

Click the History icon in the toolbar to open the Query History panel.

From this panel, you can:

  • Filter records by SQL or PromQL.
  • Search within query history.
  • View the execution time of each query.
  • Click a history entry to insert the query back into the editor.

Download Query History

You can download query history records, including filtered search results.

  • SQL history

    • Exported as a .sql file
    • Statements separated by blank lines
    • Each statement ends with a semicolon (;)
    sql
    select * from t2
    where host = 'server1';
    
    SELECT * FROM public."t2" ORDER BY "timestamp" DESC LIMIT 100;
  • PromQL history

    • Exported as a .txt file
    • One query per line
    text
    sum(t1)
    t1

query_history_panel

Upload Query History File

You can upload a query history file to quickly reuse or edit existing queries.

  • Supported file formats are .sql and .txt.
  • After uploading, the file content replaces the current content in the query editor.

upload_query_file