Vinit Gavankar
Aug 20, 2026
visibility 681
star star star star star
(0 votes)

Get count of pages, blocks , Assets from the CMS.

The following queries retrieve details from the CMS database. Make sure to try these queries locally first. 

 

Step 1 — Discover your content type bases first:

```
SELECT Base, COUNT(*) AS TypeCount
FROM tblContentType
GROUP BY Base
ORDER BY TypeCount DESC;
```

Step 2 — Count all content grouped by base type (single query):

```
SELECT
ct.Base AS ContentBase,
ct.Name AS ContentTypeName,
COUNT(c.pkID) AS ContentCount
FROM tblContent c
INNER JOIN tblContentType ct ON c.fkContentTypeID = ct.pkID
GROUP BY ct.Base, ct.Name
ORDER BY ct.Base, ContentCount DESC;
```

Step 3 — Individual counts per category:

```
-- Pages
SELECT COUNT(*) AS PageCount
FROM tblContent c
INNER JOIN tblContentType ct ON c.fkContentTypeID = ct.pkID
WHERE ct.Base = 'Page';

-- Blocks
SELECT COUNT(*) AS BlockCount
FROM tblContent c
INNER JOIN tblContentType ct ON c.fkContentTypeID = ct.pkID
WHERE ct.Base = 'Block';

-- Images (adjust base value based on Step 1 results)
SELECT COUNT(*) AS ImageCount
FROM tblContent c
INNER JOIN tblContentType ct ON c.fkContentTypeID = ct.pkID
WHERE ct.Base = 'Image';

-- Documents / Files
SELECT COUNT(*) AS DocumentCount
FROM tblContent c
INNER JOIN tblContentType ct ON c.fkContentTypeID = ct.pkID
WHERE ct.Base IN ('File', 'Video', 'Media');
```
Aug 20, 2026

Comments

Tomas Hensrud Gulla
Tomas Hensrud Gulla Aug 20, 2026 12:49 PM

Nice queries!

And if you can't access the database directly, this addon can help:
https://www.gulla.net/no/blog/sql-addon-for-optimizely-cms-12-updated-with-new-features/

error Please login to comment.
Latest blogs
Advanced Reviews 2.2.0

Editable review links without a CMS login and support for headless websites

Bartosz Sekula | Nov 22, 2026 |

No name

Jagmeet Kaur | Nov 19, 2026 |

What the CMS 13 MCP Server Actually Does When You Write Properties

This post covers the setup gotchas, what each

Adnan Zameer | Nov 19, 2026 |

Pick images from Optimizely DAM straight into rich text

Rich text editors in Optimizely CMS (SaaS), and in CMS 13.7.0 on sites that use the Content Manager, have a new image button. It puts images from t...

Stuart Greig | Nov 18, 2026