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:
- Is this per-row token snapshot expected/by design?
- Is the duplication of the trackable tokens (already in
page_redirects) actually necessary, or am I misreading what’s stored? - Is there any setting to limit how long
tokensis 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?