Bug #104581 | AUTOINCREMENT value from information_schema not returning correct value | ||
---|---|---|---|
Submitted: | 10 Aug 2021 13:43 | Modified: | 12 Aug 2021 15:00 |
Reporter: | Tariq K | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 5.7, 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | autoincrement, BEFORE INSERT, trigger |
[10 Aug 2021 13:43]
Tariq K
[12 Aug 2021 14:11]
MySQL Verification Team
Hi Mr. K, Thank you for your bug report. However, it is not a bug. if you read our Reference Manual on the topic, you will find out that this value, in the I_S table, for InnoDB tables provide only informational and not exact value. This is due to the fact that InnoDB is a MVCC storage engine and it adheres to the standard of multi-versioning. The only exact manner of obtaining exact number of rows in InnoDB, is to get count(*). However, since it has to scan all rows, it is very, very slow on large tables. Hence, we recommend that, after insertion, you simply get the next auto_increment column, for what ever purposes that you need. Not a bug.
[12 Aug 2021 15:00]
Tariq K
I understand that information_schema is not reliable in the sense to get the exact value everytime. But one of the main concern here is the difference in behavior when the query to get auto_increment separately vs when it is executed from inside the trigger. Behavior should be consistent