Skip to content

High memory usage by Purchased Tickets Summary in admin edit screen #199

@trevor-cuffe

Description

@trevor-cuffe

Describe the bug

The admin edit view for an event (/admin/events/events/{ticketType}/45081) which has a large number of purchased tickets is using an excessive amount of memory, leading to slow load times and loading errors. In order to avoid breaking, I am temporarily increasing my php memory limit, but it is still a very slow query that bogs down the server.

My particular event has 5,000+ purchased tickets, including 4 different ticket types.

The culprit appears to be coming from the file src/templates/events/_edit.html on line 210:
{% set purchasedTickets = craft.events.purchasedTickets.eventId(event.id).all() %}

These are then looped through to get the total count of purchased tickets by ticket type.

There should be a more efficient way to query the database and get the ticket count for each ticket type, without having to load all 5000+ ticket elements and loop through them.

Steps to reproduce

  1. Create an Event
  2. Purchase a large number of tickets for the event (5,000+)
  3. Access the event edit page in the admin panel

Craft CMS version

4.16.16

Plugin version

2.0.11

Multi-site?

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions