I need to create a new index on large table in RDS MySQL. This index is needed to reduce the scan time on this table. Below is the configuration:
- Table size: 400 GB
- Records: 400 Million
- column – Timestamp-col
- RDS MySQL – db.m5.4xlarge, Engine – MySQL Community
Looking for below details:
- How long such index creation takes place.
- Will there be any outage to production DB. If so how to mange with lower impact.
- Any good/bad experiences and lessons learned on such deployment.
Appreciate your inputs.
There’s no way we can predict how long it will take. This depends on the RDS instance size, the data types of columns you are indexing, as well as concurrent load on the RDS instance, etc.
MySQL 5.6 and later have Online DDL which is supposed to allow some concurrent query traffic against your table. Read https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html for details. There are some limitations to how “online” this is.
However, I can suggest a better solution: a free tool called pt-online-schema-change. This is what we use at my company, where we do hundreds of schema changes per week. It may take longer than creating the index directly, but it’s not a problem because it allows you to read and write the table while it’s running.