# Does \`email\_stats.tokens\` store redundant data? Looking for a sanity check

**URL:** <https://forum.mautic.org/t/does-email-stats-tokens-store-redundant-data-looking-for-a-sanity-check/38798>\
**Category:** Product Support\
**Created:** [November 24, 2026, 5:02pm UTC](https://forum.mautic.org/t/does-email-stats-tokens-store-redundant-data-looking-for-a-sanity-check/38798 "2026-11-24T17:02:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dirk\_s](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dirk_s/32/748_2.png) [@dirk\_s](https://forum.mautic.org/u/dirk_s)\
**Post date:** [November 24, 2026, 5:02pm UTC](https://forum.mautic.org/t/does-email-stats-tokens-store-redundant-data-looking-for-a-sanity-check/38798/1 "2026-11-24T17:02:51Z")

</div>

**Context**

I run a high-volume Mautic 7.x instance where `email_stats` is by far the largest table and keeps growing with send volume (~19M rows). The `tokens` column is what dominates its size, so before trimming old rows I took a closer look at what’s actually in there — and I’m not sure whether what I’m seeing is expected or a real inefficiency. Hoping someone who knows the internals better than I do can confirm or correct my reading.

**What I see**

Decoding the serialized `tokens` value of a typical row (~5–7 KB each):

- ~9 × `{trackable=<hash>}` entries at ≈339 bytes each → roughly **60% of the cell**
- Standard placeholders: `{unsubscribe_text/url}`, `{webview_text/url}`, `{tracking_pixel}`, `{dnc_url}`, etc.
- Actually per-contact data (`{contactfield=email}`, `{ownerfield=…}`): only a few dozen bytes, some empty.

Rows are very uniform in size — no outlier, it looks structural.

**My question**

The `{trackable=...}` part — which is the bulk — looks **identical for every recipient of the same email** ; it doesn’t seem personalized. But it appears to be stored again in every `email_stats` row. And the link→target mapping already lives once in `page_redirects`, so my naive reading is that `tokens` holds a second, per-row copy of data that exists elsewhere.

I’m guessing this is intentional — a snapshot so the “view in browser” webview can reproduce the email exactly as sent? If so, that makes sense, but it does mean the biggest table carries a lot of duplicated, non-personalized data.

So, for people who know this better:

1. Is this per-row token snapshot expected/by design?
2. Is the duplication of the trackable tokens (already in `page_redirects`) actually necessary, or am I misreading what’s stored?
3. Is there any setting to limit how long `tokens` is kept, or to reduce what’s stored?

For reference, my current workaround is a script that nulls `tokens` on rows older than a retention window (keeping the rows and open/click stats) — but I’d rather understand whether the storage itself is as redundant as it looks before going further.

**Environment:** Mautic 7.x, MariaDB 10.11, PHP 8.4

@joeyk What do you think?

---

<div class="post-metadata">

**Author:** ![dirk\_s](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dirk_s/32/748_2.png) [@dirk\_s](https://forum.mautic.org/u/dirk_s)\
**Post date:** [November 24, 2026, 7:00pm UTC](https://forum.mautic.org/t/does-email-stats-tokens-store-redundant-data-looking-for-a-sanity-check/38798/2 "2026-11-24T19:00:36Z")

</div>

@driskell I saw you already work on a solution after I posted this. Preventing growth may be a thing before trimming. Did you also come across this?

---

<div class="post-metadata">

**Author:** ![ekke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ekke/32/296_2.png) [@ekke](https://forum.mautic.org/u/ekke)\
**Post date:** [November 25, 2026, 11:06am UTC](https://forum.mautic.org/t/does-email-stats-tokens-store-redundant-data-looking-for-a-sanity-check/38798/3 "2026-11-25T11:06:59Z")

</div>

I think you have a great point @dirk_s! There appears to be a ton of redundancy in email\_stats.tokens , which means some really huge potential for optimization (in Mautic 8, obviously, but nonetheless 🙂 )  
…which I’d LOVE as we have clients with tons of emails that carry 20k of tokens each!!!

First of all: The actual “trackable=” (which actually REFERS to page\_redirects.redirect\_id, and should be only 25 chars) looks like clean design to me.

BUT it seems to me that  
a) the **“ct=” value** (big portion in tokens!) is identical (by definition) for every link within a recipients “tokens” string, so it could be **reduced to just one per email\_stats row**. Should be easy to improve!!!

b) The only difference from the “ct=” value across multiple recipients within the same email ID result from their “stats” and “lead” values which we have present in the email\_stats row anyway. And the only other information in my test was the channel and the email id. So the **“ct=” value could be calculated entirely on the fly** (takes a bit more research, obviously.)

c) If you work with **UTM** (those configured to be attached to every link within the email) there’s also a **ton of redundancy, too** (within each email\_stats row, and even across multiple recipients) that could be tackled.

And just to capture that thought: Assuming that the main purpose is proper webview/timeline for already-sent emails, any after-send changes (e.g in UTM) will need to be covered by some fallback mechanism for existing rows.

---

<div class="post-metadata">

**Author:** ![ekke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ekke/32/296_2.png) [@ekke](https://forum.mautic.org/u/ekke)\
**Post date:** [November 25, 2026, 11:09am UTC](https://forum.mautic.org/t/does-email-stats-tokens-store-redundant-data-looking-for-a-sanity-check/38798/4 "2026-11-25T11:09:35Z")

</div>

P.S. meanwhile, the **cleanup** is nicely handled by `--email-stats-tokens` in the Leuchtfeuer Housekeeping plugin 🙂  
[GitHub - Leuchtfeuer/mautic-housekeeping-bundle: Additional options for data cleanup and advanced database maintenance (beyond mautic:maintenance:cleanup) · GitHub](https://github.com/Leuchtfeuer/mautic-housekeeping-bundle)

---

<div class="post-metadata">

**Author:** ![alexzlobin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/alexzlobin/32/13606_2.png) [@alexzlobin](https://forum.mautic.org/u/alexzlobin)\
**Post date:** [November 27, 2026, 9:28am UTC](https://forum.mautic.org/t/does-email-stats-tokens-store-redundant-data-looking-for-a-sanity-check/38798/5 "2026-11-27T09:28:41Z")

</div>

I believe that for large-scale Mautic installations, we should consider introducing ClickHouse as an optional, dedicated storage backend for statistical data.

The idea is not to replace MySQL or MariaDB, nor to migrate Mautic’s business logic to another database. All existing application logic, contacts, campaigns, segments, configuration, and transactional operations would remain in MySQL/MariaDB.

ClickHouse would be used exclusively for storing statistical and tracking data, such as email sending statistics, opens, clicks, page hits, and historical events.

In this particular use case, ClickHouse offers significant advantages over MySQL/MariaDB:

- Highly efficient column-oriented storage and data compression.
- High-throughput ingestion of large volumes of statistical events.
- Significantly faster analytical queries and data aggregation.
- Reduced disk space and I/O requirements.
- Better scalability as historical data volumes grow.
- Native data retention mechanisms without resource-intensive mass DELETE operations.

ClickHouse was specifically designed for this type of workload, where datasets can grow to hundreds of millions or even billions of records while maintaining efficient analytical performance.

From my experience managing large-scale production Mautic installations, the continuous growth of statistical tables is one of the most significant infrastructure challenges. We often have to sacrifice valuable historical data simply to maintain acceptable database performance.

I am currently experimenting with this architecture on my own fork of Mautic 7.2.2, and the initial results are already quite promising.

For these experiments, I deliberately chose not to use synthetic test data. Instead, I am using real statistical data taken from an existing production Mautic installation. Even at this early stage, the same statistical dataset stored in ClickHouse occupies several times less disk space than in MySQL.

The experiments are still ongoing, so it would be premature to draw definitive conclusions about overall system performance. Nevertheless, the initial results already demonstrate the considerable potential of this approach.

Separating statistical data from transactional data would also significantly reduce the load on the primary MySQL/MariaDB database, freeing up resources for campaign execution, segment rebuilding, contact management, and other core Mautic operations.

Ideally, this could be implemented as an optional statistical storage backend, keeping MySQL/MariaDB as the default and ensuring backward compatibility with existing installations.

The core business logic of Mautic would remain conceptually unchanged. Only the statistical data access layer, reporting mechanisms, and segmentation queries that rely on statistical data would need to be adapted.

Optimizing the `tokens` field is certainly a valuable improvement. However, it addresses only one manifestation of a much broader problem.

I believe that moving statistical data to a dedicated analytical storage backend could address the fundamental scalability challenge at an architectural level, rather than repeatedly addressing its individual symptoms.

In my opinion, this would be a valuable architectural direction to explore as part of the Mautic 8 development roadmap.
