frappe / frappe/press

Tune Performance Schema in better way

Open
#6,380 0 comments 0 reactions 0 assignees View on GitHub
database performance
Dominant language
Python
Stars
562
Forks
410
Avg merge
22h 15m
Merged PRs (30d)
197

Description

In servers with lot of tables, performance schema is taking lot of usage.
It's not the amount of history, instead no of tracked objects.

```
| performance_schema | (pfs_table).count                                           | 925696      |
| performance_schema | (pfs_table).memory                                          | 8649703424  |
```

For ~1.9 lac tables, its tracking 9 lac objects.

The major issue is
- It's not like open table cache, that mariadb will drop in case of emergency
- Once, mariadb allocated memory to perf schema, we can't take it back
- We can call `sys.ps_truncate_all_tables()`, that will truncate perf_schema, but will not release RSS

The probable solution seems -
- Limit max table instances with [performance_schema_max_table_instances](https://mariadb.com/docs/server/reference/system-tables/performance-schema/performance-schema-system-variables#performance_schema_max_table_instances)
- Based on the above param, adjust innodb allocation and all. Usually each tracked table object take ~9KB space.
- Stop perf schema for shared server by default.
- Add some schedule like `perf schema enabled till` to auto disable perf schema on the server, we added to investigate some case.
- We can also have some process, which can take the summary of required data and purge the perf schema table with `sys.ps_truncate_all_tables()`. In need to be paired with `max_instances` limit to prevent growing memory.

If there is some way to release perf schema memory without restarting db, that will be nice. But haven't found anyway to do that.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no repository files, tests, or code entry points. Start by reviewing MariaDB's performance_schema_max_table_instances setting and sys.ps_truncate_all_tables(), then determine which proposed behavior is in scope. Done would require an agreed implementation and validation that performance-schema memory use is bounded or recoverable without restarting the server.

Written by the indexing model from the issue text.

Assessment

Tech stack
mariadb
Domain
databases, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.