Vinit Gavankar
Aug 20, 2026
visibility 509
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
Building UI Extensions for Optimizely SaaS CMS

Introduction Developers have been extending the functionality of Optimizely PaaS CMS for years using addons built in C# and deployed as NuGet...

Mark Stott | Oct 15, 2026

Cheapskate AI Translator: Because Translation Should Not Require a Second Mortgage

There is a particular kind of software project that begins with a detailed architecture document, a product roadmap, and a carefully assembled...

Linh Doan Cuu | Oct 15, 2026

Computed Fields in CMS 13 Content Contracts with Optimizely Graph

Content Contracts in Optimizely CMS 13 allow different content types to share a common structure when querying Optimizely Graph. But what if the...

Mardy | Oct 14, 2026

Opal Workflow Agents And The Graph Webhook Trap

What we did? We built a compliance review workflow agent in Opal. The job was simple: when an editor submits a page for review in Optimizely CMS 13...

Ritu Madan | Oct 14, 2026