Magento 2 SQL queries › Products and catalogue
How many products are in each attribute set?
Short answer: Filter the product grid by attribute set and read the count, set by set, or count them all at once.
In the Magento admin
- Go to Catalog › Products › Filters, choose one Attribute Set and read the record count.
With one query
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.
Magento Open Source
SELECT s.attribute_set_name, COUNT(*) AS products
FROM catalog_product_entity e
JOIN eav_attribute_set s ON s.attribute_set_id = e.attribute_set_id
GROUP BY s.attribute_set_id, s.attribute_set_name
ORDER BY products DESC;
Adobe Commerce
Product, category, rule and CMS values are stored per version and joined on row_id (why):
SELECT s.attribute_set_name, COUNT(*) AS products
FROM catalog_product_entity e
JOIN eav_attribute_set s ON s.attribute_set_id = e.attribute_set_id
WHERE e.created_in <= UNIX_TIMESTAMP() AND e.updated_in > UNIX_TIMESTAMP()
GROUP BY s.attribute_set_id, s.attribute_set_name
ORDER BY products DESC;
Good to know
- On Adobe Commerce,
catalog_product_entityholds a row per scheduled version; the filter oncreated_in/updated_incounts each product once.