-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add guide on debugging memory issues
- Loading branch information
1 parent
ef5f627
commit 4c4d6a3
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
slug: /en/guides/developer/debugging-memory-issues | ||
sidebar_label: Debugging Memory Issues | ||
sidebar_position: 1 | ||
description: Queries to help you debug memory issues. | ||
--- | ||
|
||
# Debugging memory issues | ||
|
||
When encountering memory issues, it is helpful to know what queries and resources are consuming a significant amount of memory. Below are queries that can help find which queries, databases, and tables can be optimized: | ||
|
||
**List queries by peak memory usage** | ||
|
||
```sql | ||
SELECT | ||
initial_query_id, | ||
query, | ||
elapsed, | ||
formatReadableSize(memory_usage), | ||
formatReadableSize(peak_memory_usage), | ||
FROM system.processes | ||
ORDER BY peak_memory_usage DESC | ||
LIMIT 100; | ||
``` | ||
|
||
**List metrics based on total memory usage** | ||
|
||
```sql | ||
SELECT | ||
metric, description, formatReadableSize(value) size | ||
FROM | ||
system.asynchronous_metrics | ||
WHERE | ||
metric like '%Cach%' | ||
or metric like '%Mem%' | ||
order by | ||
value desc; | ||
``` | ||
|
||
**List databases by current memory usage** | ||
|
||
```sql | ||
SELECT | ||
database, | ||
name, | ||
formatReadableSize(total_bytes) | ||
FROM system.tables | ||
WHERE engine IN ('Memory','Set','Join'); | ||
``` | ||
|
||
**List merges by current memory usage** | ||
|
||
```sql | ||
SELECT formatReadableSize(sum(memory_usage)) FROM system.merges; | ||
``` | ||
|
||
**List processes by current memory usage** | ||
|
||
```sql | ||
SELECT formatReadableSize(sum(memory_usage)) FROM system.processes; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters