Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# InnoDB Adaptive Hash Index (AHI) efficiency check

## Description

MySQL's InnoDB engine can automatically build a hash index in memory on frequently accessed data, this is called the Adaptive Hash Index (AHI). When it works well, the AHI lets MySQL answer queries with a fast hash lookup instead of traversing the full B-tree index, which means lower CPU usage and faster queries.

This check looks at two things:

- **how often the AHI is actually helping** (hit ratio): if most lookups still fall back to the B-tree, the AHI isn't doing much.
- **whether the AHI is causing contention** (latch wait load): under heavy concurrent workloads, multiple threads competing for the AHI's internal lock can slow things down more than the AHI speeds them up.

You'll see different alert levels depending on what's found:

- **Notice**: AHI is working normally, or it's disabled.
- **Warning**: contention is building up and starting to affect performance.
- **Major**: contention is high enough that the AHI is likely hurting more than helping. Increase AHI partitions or disable AHI altogether.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Can you check if the "Major" alert level is used in our code base?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Major" is not a supported severity level. The supported levels (defined in managed/pi/common/severity.go) are: emergency, alert, critical, error, warning, notice, info, debug. Passing "major" to ParseSeverity() would silently return Unknown (0).

Fixed in the latest commit by replacing "major" with "error" in both the check YAML (mysql_ahi_efficiency_performance_basic_check.yml) and the documentation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tusamarco Could you please review this fix? Do we want the severity to be set to "error" or "critical" in this case?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my opinin:

  • Info: AHI is working normally, or it's disabled.
  • Notice: contention is building up and starting to affect performance.
  • Warning: contention is high enough that the AHI is likely hurting more than helping. Increase AHI partitions or disable AHI altogether.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, we can change the severity to "warning" on line 123, but then there will be no difference between two branches: this one and the one above.

I think we need to refactor the code here, since not all branches are present.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ademidoff @Tusamarco - Mariana Bonsignore needs this topic live by the end of the month. do you think we could refactor the code and merge by then?


## Resolution

### If you're seeing Warning or Major alerts

Increase the number of AHI partitions. This splits the internal lock across more structures, reducing contention:

```sql
SET GLOBAL innodb_adaptive_hash_index_parts = 16;
```

To make it permanent, add it to your MySQL configuration file and restart:

```ini
[mysqld]
innodb_adaptive_hash_index_parts = 16
```

If contention is still high after increasing partitions, disabling the AHI entirely is worth testing:

```sql
SET GLOBAL innodb_adaptive_hash_index = OFF;
```

Benchmark your workload with it off to see if performance improves.

### If the AHI is disabled

Consider turning it on and watching the **InnoDB Adaptive Hash Index** panel on the [MySQL InnoDB Details](../../reference/dashboards/dashboard-mysql-innodb-details.md) dashboard. The AHI is most useful for read-heavy workloads that repeatedly access the same index data.

## Need more support from Percona?

Percona experts bring years of experience in tackling tough database performance issues and design challenges.

<div data-tf-live="01JKGYABNVYHQ8A91QNW69A9TP"></div><script src="//embed.typeform.com/next/embed.js"></script>
Comment thread
catalinaadam marked this conversation as resolved.
Outdated
1 change: 1 addition & 0 deletions documentation/mkdocs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ nav:
- Performance advisors:
- Generic performance checks:
- advisors/checks/multiple-mongod-running-in-a-node.md
- advisors/checks/mysql-ahi-efficiency-performance-basic-check.md
- advisors/checks/performance-pg-low-cache-hit-ratio.md
- advisors/checks/configuration-pg-settings-changed.md
- advisors/checks/postgresql-tmpfiles-check.md
Expand Down