The post has been translated automatically. Original language: Russian
Changing the table structure on a running project with live traffic is a frequent source of nighttime incidents. A direct ALTER TABLE on a large table is able to block a record for minutes and stop accepting orders. I wrote about how to safely change the schema through step-by-step expansion and compression of the structure in the guide "Database Migrations without downtime: the expand and contract template".
In parallel with the schema change, it is important to monitor how the database performs samples as the volume of records increases, otherwise even simple filtering by date starts loading the CPU by 100%. There is a practical analysis of the search for bottlenecks in the article "MySQL indexes and EXPLAIN: how to find and speed up slow queries".
Competent work with indexes and managed migrations allow you to develop the backend continuously — without technical windows and degradation of response speed.
Изменить структуру таблицы на работающем проекте с живым трафиком — частый источник ночных инцидентов. Прямой ALTER TABLE на крупной таблице способен заблокировать запись на минуты и положить прием заказов. О том, как безопасно менять схему через поэтапное расширение и сжатие структуры, я писал в руководстве «Миграции базы данных без простоя: шаблон expand и contract».
Параллельно с изменением схемы важно следить за тем, как база выполняет выборки при росте объема записей, иначе даже простая фильтрация по дате начинает грузить CPU на 100%. Практический разбор поиска узких мест есть в статье «Индексы MySQL и EXPLAIN: как найти и ускорить медленные запросы».
Грамотная работа с индексами и управляемые миграции позволяют развивать бэкенд непрерывно — без технических окон и деградации скорости отклика.
Comments 2
Newest Popular