Vinit Gavankar
Aug 20, 2026
visibility 422
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
Composition Over Inheritance: Why Your Content Contract Is Not a Base Class

Inside the structural conformance pattern in SaaS CMS — from server-side inheritance to pipeline governance. A contract in Optimizely SaaS CMS is...

Vipin Banka | Sep 19, 2026

Optimizely Opti ID Integration: Why the API Key Was Missing from the DXP Management Portal

While working on an Optimizely CMS 12 Opti ID integration recently, we ran into an issue that initially appeared to be related to SSO authenticatio...

Madhu | Sep 18, 2026 |

Extending a Contract: What You Can Override

Contracts share fields across content types — but not every field setting can be overridden. Push the same contract onto several components, and CM...

Chirag Khanna | Sep 18, 2026 |

Building a Blazor Server UI Inside the Optimizely CMS 13 Admin Shell

What I learned shipping a Blazor Server UI inside Optimizely CMS 13 — Razor components in a NuGet package, the Blazor hub next to MapContent(),...

Stanisław Szołkowski | Sep 17, 2026 |

Giving Optimizely 13 Content Types Meaningful Icons and Thumbnails

When working with an Optimizely CMS solution that has evolved over time, it is common to end up with many content types. As the number grows, the...

Pär Wissmark | Sep 16, 2026 |

force-dynamic vs connection() for Optimizely Graph

If you have built an Optimizely CMS SDK site, you already know getContentByPath on a catch-all. This post is about the part that file never says ou...

Chirag Khanna | Sep 16, 2026 |