feat: support real-time retrieval of profiles from admin API (part 1) #15958
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
Support get PlanProfile from admin API if the query is still running:
/v1/queries/:query_id/profiling
This PR is part one. It only support the running query. If the query finish very quickly, it cannot get the result.
For the next part, It will maintain a cache queue for the latest 50 (could be config) queries's profile.
Example:
GET http://localhost:8080/v1/queries/46f89e47-9e27-4ca9-b87c-868d80678ec0/profiling
RESPONSE:
],
"statistics_desc": {
"CpuTime": {
"desc": "The time spent to process in nanoseconds",
"display_name": "cpu time",
"index": 0,
"unit": "NanoSeconds",
"plain_statistics": false
},
"WaitTime": {
"desc": "The time spent to wait in nanoseconds, usually used to measure the time spent on waiting for I/O",
"display_name": "wait time",
"index": 1,
"unit": "NanoSeconds",
"plain_statistics": false
},
"ExchangeRows": {
"desc": "The number of data rows exchange between nodes in cluster mode",
"display_name": "exchange rows",
"index": 2,
"unit": "Rows",
"plain_statistics": true
},
"ExchangeBytes": {
"desc": "The number of data bytes exchange between nodes in cluster mode",
"display_name": "exchange bytes",
"index": 3,
"unit": "Bytes",
"plain_statistics": true
},
"OutputRows": {
"desc": "The number of rows from the physical plan output to the next physical plan",
"display_name": "output rows",
"index": 4,
"unit": "Rows",
"plain_statistics": true
},
"OutputBytes": {
"desc": "The number of bytes from the physical plan output to the next physical plan",
"display_name": "output bytes",
"index": 5,
"unit": "Bytes",
"plain_statistics": true
},
"ScanBytes": {
"desc": "The bytes scanned of query",
"display_name": "bytes scanned",
"index": 6,
"unit": "Bytes",
"plain_statistics": true
},
"ScanCacheBytes": {
"desc": "The bytes scanned from cache of query",
"display_name": "bytes scanned from cache",
"index": 7,
"unit": "Bytes",
"plain_statistics": true
},
"ScanPartitions": {
"desc": "The partitions scanned of query",
"display_name": "partitions scanned",
"index": 8,
"unit": "Count",
"plain_statistics": true
},
"SpillWriteCount": {
"desc": "The number of spilled by write",
"display_name": "numbers spilled by write",
"index": 9,
"unit": "Count",
"plain_statistics": true
},
"SpillWriteBytes": {
"desc": "The bytes spilled by write",
"display_name": "bytes spilled by write",
"index": 10,
"unit": "Bytes",
"plain_statistics": true
},
"SpillWriteTime": {
"desc": "The time spent to write spill in millisecond",
"display_name": "spilled time by write",
"index": 11,
"unit": "MillisSeconds",
"plain_statistics": false
},
"SpillReadCount": {
"desc": "The number of spilled by read",
"display_name": "numbers spilled by read",
"index": 12,
"unit": "Count",
"plain_statistics": true
},
"SpillReadBytes": {
"desc": "The bytes spilled by read",
"display_name": "bytes spilled by read",
"index": 13,
"unit": "Bytes",
"plain_statistics": true
},
"SpillReadTime": {
"desc": "The time spent to read spill in millisecond",
"display_name": "spilled time by read",
"index": 14,
"unit": "MillisSeconds",
"plain_statistics": false
},
"RuntimeFilterPruneParts": {
"desc": "The partitions pruned by runtime filter",
"display_name": "parts pruned by runtime filter",
"index": 15,
"unit": "Count",
"plain_statistics": true
},
"MemoryUsage": {
"desc": "The real time memory usage",
"display_name": "memory usage",
"index": 16,
"unit": "Bytes",
"plain_statistics": false
}
}
}
Tests
Type of change
This change is