Skip to content

Instantly share code, notes, and snippets.

@precary
Forked from leekelleher/cmsContentType_Usage.sql
Created August 16, 2016 12:15
Show Gist options
  • Select an option

  • Save precary/42818580e16dbe7b5c78fbfdded87e5c to your computer and use it in GitHub Desktop.

Select an option

Save precary/42818580e16dbe7b5c78fbfdded87e5c to your computer and use it in GitHub Desktop.
Umbraco - database analysis
-- Copied from Hendy https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/72814-creating-a-list-of-unused-doc-types#comment-233729
-- Find all unused docTypes
-- These results may contain docTypes that are masters of used ones, so need to exclude these too...
SELECT
A.nodeId as 'DocTypeId',
B.text AS 'Name',
A.alias AS 'Alias'
FROM
cmsContentType A LEFT JOIN
umbracoNode B ON A.nodeId = B.id
WHERE
A.nodeId NOT IN (SELECT contentType FROM cmsContent)
;
SELECT
ContentId,
COUNT(ContentId) AS VersionCount
FROM
cmsContentVersion
GROUP BY
ContentId
ORDER BY
COUNT(ContentId) DESC
;
SELECT
logHeader,
COUNT(logHeader) AS LogCount
FROM
umbracoLog
GROUP BY
logHeader
ORDER BY
COUNT(logHeader) DESC
;
SELECT
CASE
WHEN nodeObjectType = '7A333C54-6F43-40A4-86A2-18688DC7E532' THEN 'ContentItemType'
WHEN nodeObjectType = 'EA7D8624-4CFE-4578-A871-24AA946BF34D' THEN 'ROOT'
WHEN nodeObjectType = 'C66BA18E-EAF3-4CFF-8A22-41B16D66A972' THEN 'Document'
WHEN nodeObjectType = 'B796F64C-1F99-4FFB-B886-4BF4BC011A9C' THEN 'Media'
WHEN nodeObjectType = '9B5416FB-E72F-45A9-A07B-5A9A2709CE43' THEN 'MemberType'
WHEN nodeObjectType = '6FBDE604-4178-42CE-A10B-8A2600A2F07D' THEN 'Template'
WHEN nodeObjectType = '366E63B9-880F-4E13-A61C-98069B029728' THEN 'MemberGroup'
WHEN nodeObjectType = '10E2B09F-C28B-476D-B77A-AA686435E44A' THEN 'ContentItem'
WHEN nodeObjectType = '4EA4382B-2F5A-4C2B-9587-AE9B3CF3602E' THEN 'MediaType'
WHEN nodeObjectType = 'A2CB7800-F571-4787-9638-BC48539A0EFB' THEN 'DocumentType'
WHEN nodeObjectType = '01BB7FF2-24DC-4C0C-95A2-C24EF72BBAC8' THEN 'RecycleBinContent'
WHEN nodeObjectType = '9F68DA4F-A3A8-44C2-8226-DCBD125E4840' THEN 'Stylesheet'
WHEN nodeObjectType = '5555DA4F-A123-42B2-4488-DCDFB25E4111' THEN 'StylesheetProperty'
WHEN nodeObjectType = 'CF3D8E34-1C1C-41E9-AE56-878B57B32113' THEN 'RecycleBinMedia'
WHEN nodeObjectType = '39EB0F98-B348-42A1-8662-E7EB18487560' THEN 'Member'
WHEN nodeObjectType = '30A2A501-1978-4DDB-A57B-F7EFED43BA3C' THEN 'DataType'
ELSE convert(nvarchar(50), nodeObjectType)
END AS objectType,
COUNT(nodeObjectType) AS nodeCount
FROM
umbracoNode
GROUP BY
nodeObjectType
ORDER BY
COUNT(nodeObjectType) DESC
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment