EPiServer Page Type usage report

Do you have a lot of page types in an EPiServer project and a gut feeling some of the are not used?

Quite common if you migrate a project from EPiServer CMS 4 that are based on the EPiServerSample project or if you inherit a project based on one of the new Public or Demo templates.

SQL Query for Page Type usage

SELECT 
  pt.Name, 
  pt.Filename, 
  COUNT(p.pkID) AS Antal
FROM 
  tblPage AS p RIGHT OUTER JOIN
  tblPageType AS pt ON p.fkPageTypeID = pt.pkID
GROUP BY 
  pt.Name, pt.Filename, pt.SortOrder
ORDER BY 
  pt.SortOrder

Before you run this query, remember to empty your recycle bin and also check that your pageRootId in web.config. If it is not equal to one there can be a lot of hidden pages in your database.