mohammad atif
08/13/2026, 11:00 AMRocky
08/13/2026, 11:01 AMenable_query_history feature is used to persist query execution information into a system table for analysis. If you have enabled it but are not seeing data, please check the following points:
1. Verify the Table Name
The query history is stored in a specific internal database and table. Note the underscores:
* Correct table: _statistics_.query_history (Note the underscore after statistics).
_ Query to check: SELECT _ FROM _statistics_.query_history;
2. Check the Sync Interval
StarRocks does not write queries to the table in real-time. It buffers them in memory and syncs them periodically.
* Check the variable query_history_load_interval_seconds.
* By default, it may take a few minutes (e.g., 60 to 300 seconds) for data to appear. You can try lowering this for testing:
sql
SET GLOBAL query_history_load_interval_seconds = 5;
3. Reconnect Your Session
Setting a variable GLOBAL only affects new sessions created after the command was run. Your current session will not capture its queries into the history table unless you:
* Set it at the session level: SET enable_query_history = true;
* Or disconnect and reconnect your client to start a new session.
4. Version Requirement
This feature was introduced and refined in later versions of StarRocks. While the variable might exist in earlier versions, it became fully functional and documented in:
* v3.1.5+ (for related profile collection)
* Official support for _statistics_.query_history is standard in v3.2 and v3.3+.
5. Check Other Variables
Ensure there aren't conflicting configurations. Run the following to see all related settings:
sql
SHOW VARIABLES LIKE '%query_history%';
* `query_history_keep_seconds`: Determines how long data is kept (default is usually 3 days or 259200 seconds). If this is set to 0, data is deleted immediately.
6. Required Permissions
To query the _statistics_ database, you typically need the SYSTEM-level OPERATE privilege or be logged in as a user with sufficient admin rights (like root).
Summary Troubleshooting Checklist:
1. Run SET enable_query_history = true; in your current session.
2. Run a few test queries (e.g., SELECT 1;).
3. Wait at least 1 minute (or check query_history_load_interval_seconds).
4. Query SELECT * FROM _statistics_.query_history ORDER BY dt DESC LIMIT 10;.
If the table still shows no data after these steps, check the FE leader's fe.log for any errors related to "QueryHistory" or "Statistics"Syncer".
References
• administration/management/FE_configuration.md
• sql-reference/sql-statements/loading_unloading/routine_load/CREATE_ROUTINE_LOAD.md
• administration/management/BE_configuration.md