Magento 2 troubleshooting › Store configuration
Should you use the flat catalog in Magento 2.4?
Short answer: No. Adobe has not recommended the flat catalog since Magento 2.3: with modern MySQL and full-page cache it brings little speed and causes indexing problems and stale data. If it's on, turn it off.
The flat catalog copies product and category attributes into wide catalog_product_flat_* and catalog_category_flat_* tables per store view. Every attribute change must then be reindexed into them, which is a frequent cause of products showing old names, prices or status.
Check it step by step
These queries only read data. Run them on a copy of your database if you can, or ask your developer to. If your tables have a prefix (set in app/etc/env.php), add it to each table name.
1. Is it switched on?
Works on Magento Open Source and Adobe Commerce:
SELECT path, scope, scope_id, value
FROM core_config_data
WHERE path IN ('catalog/frontend/flat_catalog_product', 'catalog/frontend/flat_catalog_category');
1 means on. No row means off (the default).
2. Are there flat tables left over?
Works on Magento Open Source and Adobe Commerce:
SELECT table_name, ROUND((data_length + index_length) / 1024 / 1024) AS size_mb
FROM information_schema.tables
WHERE table_schema = DATABASE()
AND (table_name LIKE 'catalog\_product\_flat\_%' OR table_name LIKE 'catalog\_category\_flat\_%')
ORDER BY table_name;
How to fix it
- Switch both off in Stores › Configuration › Catalog › Catalog › Storefront (Use Flat Catalog Category and Use Flat Catalog Product = No), or from the command line:
bin/magento config:set catalog/frontend/flat_catalog_product 0 bin/magento config:set catalog/frontend/flat_catalog_category 0 bin/magento cache:flush - Test category pages and search on staging first; some old extensions read the flat tables directly.
- Leftover flat tables can be dropped by your developer after a backup, once nothing reads them.