# Performance problem with large database records

**URL:** <https://forum.mautic.org/t/performance-problem-with-large-database-records/2490>\
**Category:** Product Support\
**Created:** [October 8, 2015, 3:52pm UTC](https://forum.mautic.org/t/performance-problem-with-large-database-records/2490 "2015-10-08T15:52:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![seti](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/seti/32/6477_2.png) [@seti](https://forum.mautic.org/u/seti)\
**Post date:** [October 8, 2015, 3:52pm UTC](https://forum.mautic.org/t/performance-problem-with-large-database-records/2490/1 "2015-10-08T15:52:19Z")

</div>

Hi all !  
  
  
  
I’ve a Mautic 1.2 instance that is registering a lot of traffic, most of them Anonymous Leads.  
  
  
  
The table “page\_hits” have more than 2 million of records and the problem comes when I try to open in Mautic the statistics page of a Landing Page, the application gets locked during several minutes and it blocks the application.  
  
  
  
Monitoring database activity I’ve seen that when I try to open the info page of a Landing Page (not when I try to edit it) there is a query that takes these several minutes to finish because is querying that table:

Code:

SELECT h.page\_id, count(distinct(h.tracking\_id)) as bounces FROM page\_hits h WHERE (h.tracking\_id IN (SELECT b.tracking\_id FROM page\_hits b LEFT JOIN pages p ON b.page\_id = p.id WHERE b.code = 200 GROUP BY b.tracking\_id HAVING count(distinct(b.page\_id)) = 1)) AND (h.page\_id IN (4)) GROUP BY h.page\_id

  
I guess that this query is doing a heavy work looking through that 2 millions of rows.  
  
Do you think that is there any way to optimize that query?  
  
Or perhaps, am I suffering any data inconsistency problem?  
  
Thanks a lot!

---

<div class="post-metadata">

**Author:** ![seti](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/seti/32/6477_2.png) [@seti](https://forum.mautic.org/u/seti)\
**Post date:** [October 8, 2015, 3:52pm UTC](https://forum.mautic.org/t/performance-problem-with-large-database-records/2490/2 "2015-10-08T15:52:19Z")

</div>

Hi all !

I’ve a Mautic 1.2 instance that is registering a lot of traffic, most of them Anonymous Leads.

The table “page\_hits” have more than 2 million of records and the problem comes when I try to open in Mautic the statistics page of a Landing Page, the application gets locked during several minutes and it blocks the application.

Monitoring database activity I’ve seen that when I try to open the info page of a Landing Page (not when I try to edit it) there is a query that takes these several minutes to finish because is querying that table:

```auto
SELECT h.page_id, count(distinct(h.tracking_id)) as bounces FROM page_hits h WHERE (h.tracking_id IN (SELECT b.tracking_id FROM page_hits b LEFT JOIN pages p ON b.page_id = p.id WHERE b.code = 200 GROUP BY b.tracking_id HAVING count(distinct(b.page_id)) = 1)) AND (h.page_id IN (4)) GROUP BY h.page_id
```

I guess that this query is doing a heavy work looking through that 2 millions of rows.

Do you think that is there any way to optimize that query?

Or perhaps, am I suffering any data inconsistency problem?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![gmillard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gmillard/32/5_2.png) [@gmillard](https://forum.mautic.org/u/gmillard)\
**Post date:** [October 8, 2015, 5:34pm UTC](https://forum.mautic.org/t/performance-problem-with-large-database-records/2490/3 "2015-10-08T17:34:48Z")

</div>

Hi Seti,

Were the indexes on the page\_hits table created when you upgraded to 1.2?

---

<div class="post-metadata">

**Author:** ![seti](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/seti/32/6477_2.png) [@seti](https://forum.mautic.org/u/seti)\
**Post date:** [October 8, 2015, 5:50pm UTC](https://forum.mautic.org/t/performance-problem-with-large-database-records/2490/4 "2015-10-08T17:50:06Z")

</div>

Hi Alan,

No, I updated it via `php app/console doctrine:schema:update --force` and probably it hasn’t worked properly

Would you tell me what tables must be indexed in version 1.2?

Is it documented somewhere?

Thanks

---

<div class="post-metadata">

**Author:** ![smartive](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@smartive](https://forum.mautic.org/u/smartive)\
**Post date:** [October 26, 2016, 11:52am UTC](https://forum.mautic.org/t/performance-problem-with-large-database-records/2490/5 "2016-10-26T11:52:42Z")

</div>

Hi Alan( @alanhartless ),

I have installed Mautic on my portal and it is collecting approx 90K - 100K anonymous leads daily. I am seeing performance issues with it. Currently it is installed on a 24GB Linode in London(Linode 24GB-RAM 24 GB- CPU 8 Cores-384 GB SSD).

Can i get some help from you or your colleagues. I am really interested in making Mautic a success for my company, however it will only happen if the performance is acceptable.

Thanks  
Hemang

---

<div class="post-metadata">

**Author:** ![caleb.hurd](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@caleb.hurd](https://forum.mautic.org/u/caleb.hurd)\
**Post date:** [November 1, 2016, 11:25pm UTC](https://forum.mautic.org/t/performance-problem-with-large-database-records/2490/6 "2016-11-01T23:25:23Z")

</div>

@smartive - add me to the list. Large number of emails sent, large user DB… experiencing performance issues.

---

<div class="post-metadata">

**Author:** ![smartive](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@smartive](https://forum.mautic.org/u/smartive)\
**Post date:** [November 2, 2016, 9:26am UTC](https://forum.mautic.org/t/performance-problem-with-large-database-records/2490/7 "2016-11-02T09:26:06Z")

</div>

@alanhartless @caleb.hurd , i am sure there must be a way to cluster and scale mautic horizontally. Strange that no one has asked this before and there is no documentation to do so.

---

<div class="post-metadata">

**Author:** ![caleb.hurd](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@caleb.hurd](https://forum.mautic.org/u/caleb.hurd)\
**Post date:** [January 10, 2017, 9:09pm UTC](https://forum.mautic.org/t/performance-problem-with-large-database-records/2490/8 "2017-01-10T21:09:24Z")

</div>

@smartive There is no method, due to the nature of how cron/spooling works within the architecture.

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [February 2, 2020, 10:58pm UTC](https://forum.mautic.org/t/performance-problem-with-large-database-records/2490/9 "2020-02-02T22:58:01Z")

</div>


