User:IIgwilo (WMF)/Real Time Preview for Wikitext/Finding content models

From Meta, a Wikimedia project coordination wiki

This database query finds all the different content models being used on a wiki and returns one page (if it exists) using that model.

SELECT page_title, page_namespace, rev_page, content_model, role_name, model_name
FROM slots
LEFT JOIN content ON slot_content_id=content_id
LEFT JOIN revision ON slot_revision_id=rev_id
LEFT JOIN page ON rev_page=page_id
LEFT JOIN slot_roles ON slot_role_id=role_id
LEFT JOIN content_models ON content_model=model_id
GROUP BY role_name, model_name;