<@U0A71G31CDV> For a given query, how to get the v...
# questions-and-troubleshooting
p
@Rocky For a given query, how to get the volume of data scanned by individual BE and across all BEs?
r
To retrieve the volume of data scanned for a query, both in aggregate and broken down by Backend (BE), you can use the following methods: 1. Across All BEs (Total Scan Volume) For the total volume scanned by a query across the entire cluster, the easiest way is to query the system audit logs or the query detail table. * Via SQL (v3.1+): You can query the
information_schema.audit_log
table:
Copy code
sql
    SELECT query_id, scan_bytes, scan_rows, cpu_cost_ns
    FROM information_schema.audit_log
    WHERE query_id = '<your_query_id>';
* Via Audit Logs: Check the
fe/log/fe.audit.log
(or
fe.big_query.log
if enabled). Each entry contains a
ScanBytes
field representing the total data processed for that specific query. * Via Query Profile Summary: In a query profile, the Summary section contains a
ScanBytes
metric. 2. By Individual BE (Per-node Scan Volume) To see how much data each individual BE scanned, you must look at the Query Profile. This provides a breakdown of metrics per execution fragment and instance. * Method A:
EXPLAIN ANALYZE
(Recommended for v3.0+):
Prepend your query with
EXPLAIN ANALYZE
to execute it and immediately see the performance breakdown:
Copy code
sql
    EXPLAIN ANALYZE SELECT ... FROM table WHERE ...;
In the output, look for the
OLAP_SCAN
(or
Connector Scan
) operator. It will list metrics like
BytesRead
or
UncompressedBytesRead
for each node/instance participating in the scan. * Method B: Manual Profile Analysis: 1. Enable profile collection for your session:
Copy code
sql
        SET enable_profile = true;
2. Run your query. 3. Find the query ID using
SHOW PROFILELIST;
. 4. Analyze the profile:
Copy code
sql
        ANALYZE PROFILE FROM '<query_id>';
5. Navigate to the Scan Operator in the tree. The profile breaks down statistics by Fragment Instance. Each instance is associated with a specific BE (identified by its IP/ID). Look for the
BytesRead
metric under each instance to see the volume scanned by that specific BE. Key Metrics to Look For *
BytesRead
: The total amount of data read by the scan operator on that node. *
CompressedBytesRead
: The amount of data read from disk before decompression. *
RowsRead
: The number of rows processed by the BE after predicate filtering. Referencesadministration/http_interface/query_detail.mdsql-reference/information_schema/loads.mdsql-reference/sql-statements/cluster-management/plan_profile/EXPLAIN.mdbest_practices/query_tuning/query_profile_operator_metrics.md