Skip to content

Instantly share code, notes, and snippets.

@aabumuslimov
Last active March 9, 2017 10:17
Show Gist options
  • Save aabumuslimov/405de28d3aefe1e42c0fe2a267798cbf to your computer and use it in GitHub Desktop.
Save aabumuslimov/405de28d3aefe1e42c0fe2a267798cbf to your computer and use it in GitHub Desktop.
Magento1 indexers healthcheck
SELECT m.metadata_id, m.table_name, m.changelog_name, IF(ccd.value = 1, "On Save", "Scheduled") AS "Mode", m.version_id AS "Processed version", v.version_id AS "Changelog version"
, CAST(v.version_id AS SIGNED) - CAST(m.version_id AS SIGNED) AS "Behind"
FROM (
(SELECT "enterprise_url_rewrite_redirect_cl" AS changelog_name, "index_management/index_options/redirect_url_rewrite" AS path, version_id FROM enterprise_url_rewrite_redirect_cl ORDER BY version_id DESC LIMIT 1)
UNION (SELECT "cataloginventory_stock_status_cl", "index_management/index_options/product_price_and_stock", version_id FROM cataloginventory_stock_status_cl ORDER BY version_id DESC LIMIT 1)
UNION (SELECT "catalogsearch_fulltext_cl", "index_management/index_options/fulltext", version_id FROM catalogsearch_fulltext_cl ORDER BY version_id DESC LIMIT 1)
UNION (SELECT "enterprise_url_rewrite_category_cl", "index_management/index_options/category_url_rewrite", version_id FROM enterprise_url_rewrite_category_cl ORDER BY version_id DESC LIMIT 1)
UNION (SELECT "enterprise_url_rewrite_product_cl", "index_management/index_options/product_url_rewrite", version_id FROM enterprise_url_rewrite_product_cl ORDER BY version_id DESC LIMIT 1)
UNION (SELECT "catalog_category_product_index_cl", "index_management/index_options/category_product", version_id FROM catalog_category_product_index_cl ORDER BY version_id DESC LIMIT 1)
UNION (SELECT "catalog_category_product_cat_cl", "index_management/index_options/category_product", version_id FROM catalog_category_product_cat_cl ORDER BY version_id DESC LIMIT 1)
UNION (SELECT "catalog_product_index_price_cl", "index_management/index_options/product_price_and_stock", version_id FROM catalog_product_index_price_cl ORDER BY version_id DESC LIMIT 1)
UNION (SELECT "catalog_category_flat_cl", "index_management/index_options/category_flat", version_id FROM catalog_category_flat_cl ORDER BY version_id DESC LIMIT 1)
UNION (SELECT "catalog_product_flat_cl", "index_management/index_options/product_flat", version_id FROM catalog_product_flat_cl ORDER BY version_id DESC LIMIT 1)
) AS v
LEFT JOIN enterprise_mview_metadata AS m ON v.changelog_name = m.changelog_name
LEFT JOIN core_config_data AS ccd ON v.path = ccd.path
#ORDER BY behind DESC
ORDER BY metadata_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment