The issue at hand concerns a significantly slow "SELECT COUNT(*)" query in MySQL, even when a "WHERE" clause is applied. To address this challenge, it's crucial to understand MySQL's storage mechanism.
InnoDB, the storage engine used in this instance, utilizes clustered primary keys. This means that the primary key is stored alongside the data row in the same data pages, rather than in separate index pages. Consequently, performing a range scan on a clustered primary key requires scanning through all rows, including their potentially wide column values. The table in question contains a TEXT column, further exacerbating the performance issue.
To optimize this query, consider the following strategies:
To further enhance performance, consider modifying the "change_event_id" column to be "BIGINT UNSIGNED" if it increments from zero. This change can result in reduced storage requirements and improved performance.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3