# Reports need long time to load

**URL:** <https://forum.mautic.org/t/reports-need-long-time-to-load/27313>\
**Category:** Product Support\
**Created:** [March 10, 2023, 2:16pm UTC](https://forum.mautic.org/t/reports-need-long-time-to-load/27313 "2023-03-10T14:16:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Madlen](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/madlen/32/15300_2.png) [@Madlen](https://forum.mautic.org/u/Madlen)\
**Post date:** [March 10, 2023, 2:16pm UTC](https://forum.mautic.org/t/reports-need-long-time-to-load/27313/1 "2023-03-10T14:16:25Z")

</div>

**Your software**  
My Mautic version is: 4.4.1  
My PHP version is: 7.4.3  
My Database type and version is: mysql 8.0.32

**Your problem**  
We have a large Mautic instance with a high volume of emails sent every month. We’ve created a report for emails (including columns like sent count, click ration, bounce ratio, published up, …).  
Opening the report takes around 10 minutes which of course is very inconvenient.

Is anyone encountering similar problems and what are your ideas to improve this?

These errors are showing in the log: -

Steps I have tried to fix the problem: -

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [March 23, 2023, 10:13am UTC](https://forum.mautic.org/t/reports-need-long-time-to-load/27313/2 "2023-03-23T10:13:04Z")

</div>

Yes ☹ the reporting is super slow inside Mautic, especially when you start to get to medium/big data.

Check out a previous post of mine where we implement a different reporting software inside Mautic: [Surge Mautic Dashboard into something Amazing!](https://forum.mautic.org/t/surge-mautic-dashboard-into-something-amazing/23864)

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [April 26, 2023, 9:02am UTC](https://forum.mautic.org/t/reports-need-long-time-to-load/27313/3 "2023-04-26T09:02:55Z")

</div>

This should be the fix:

> <https://github.com/mautic/mautic/issues/12146>
>
> \### Mautic Version
> 
> 4.4.x series
> 
> \### PHP version
> 
> 7.4
> 
> \### What browser…s are you seeing the problem on?
> 
> Not relevant
> 
> \### What happened?
> 
> \## Issue
> If the \`lead\_donotcontact\` table has a lot of entries (e.g. 60.000), the report-generation for \`emails\` becomes extremly (unusable) slow, if the bounced or unsubscribed columns are selected.
> 
> We tracked down the issue to the following sub-query, which is added e.g. when the \`bounced\` column is selected for an email report (same applies for \`unsubcribed\`):
> \`\`\`
> IFNULL((SELECT ROUND(SUM(IF(dnc.id IS NOT NULL AND dnc.channel\_id=e.id AND dnc.reason=2 , 1, 0)), 1) FROM lead\_donotcontact dnc), 0)
> \`\`\`
> While checking if all the fields inside the condition having an index, we found out that an index for \`channel\_id\` is missing.
> 
> \## Solution
> To test it, we manually added the index, which increased the query speed for the email report by ~90%:
> \`\`\`
> ALTER TABLE lead\_donotcontact ADD INDEX dnc\_channel\_id\_serch (channel\_id);
> \`\`\`
> 
> As permanent solution, please add \`-\>addIndex(\['channel\_id'\], 'dnc\_channel\_id\_search')\` in the following line:
> https://github.com/mautic/mautic/blob/d7a7c3e90afe8ee82e3f66585f8641d8b231fa60/app/bundles/LeadBundle/Entity/DoNotContact.php#L73
> 
> 
> \### How can we reproduce this issue?
> 
> \## Step 1
> Take a huge Mautic database, e.g.:
> leads: 1.500.000
> lead\_donotcontact: 60.000
> emails: 200
> email\_stats: 3.500.000
> 
> \## Step 2
> \- Create an email-report
> \- Add the following columns: \`Read count, Read ratio, Clicks, Clicks ratio, Unique clicks, Unique clicks ratio\`
> \- Add the following columns to slow down the query drastically: \`bounced, unsubscribed\`
> \- Add filter: \`Sent count\` greather than \`100\` (dynamic yes)
> 
> \### Relevant log output
> 
> \_No response\_
> 
> \### Code of Conduct
> 
> \- \[X\] I confirm that I have read and agree to follow this project's Code of Conduct

Joey

---

<div class="post-metadata">

**Author:** ![carlosatfongo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/carlosatfongo/32/10223_2.png) [@carlosatfongo](https://forum.mautic.org/u/carlosatfongo)\
**Post date:** [June 5, 2024, 6:45pm UTC](https://forum.mautic.org/t/reports-need-long-time-to-load/27313/4 "2024-06-05T18:45:49Z")

</div>

Huge fix, thank you for pointing this out! (Mautic v4.4.12)

---

<div class="post-metadata">

**Author:** ![arnoldmatt](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@arnoldmatt](https://forum.mautic.org/u/arnoldmatt)\
**Post date:** [June 6, 2024, 7:49am UTC](https://forum.mautic.org/t/reports-need-long-time-to-load/27313/5 "2024-06-06T07:49:22Z")

</div>

I understand how frustrating slow report loading times can be. We’ve faced similar issues, and one thing that helped us was optimizing our database and archiving old data. You might also consider upgrading your PHP version if possible. Hope this helps a bit!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)\
**Post date:** [June 7, 2024, 7:50pm UTC](https://forum.mautic.org/t/reports-need-long-time-to-load/27313/6 "2024-06-07T19:50:02Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
