Description
In EventTicketService.getEventTickets and TicketOrderService, pagination is implemented using MongoDB's .skip(offset) method. While acceptable for small datasets, .skip() requires the database to scan and discard all documents up to the offset, resulting in O(N) performance degradation as the page number increases.
Proposed Solution
Implement cursor-based (keyset) pagination for endpoints that are expected to handle large datasets (e.g., ticket orders, event listings). Instead of passing page, clients should pass a cursor (usually the _id and sort field of the last item).
Acceptance Criteria
Files
src/services/event-ticket.service.ts
src/services/ticket-order.service.ts
Notes
For backward compatibility, the page query parameter can be maintained with .skip() as a fallback, but cursor should be preferred.
Description
In
EventTicketService.getEventTicketsandTicketOrderService, pagination is implemented using MongoDB's.skip(offset)method. While acceptable for small datasets,.skip()requires the database to scan and discard all documents up to the offset, resulting in O(N) performance degradation as the page number increases.Proposed Solution
Implement cursor-based (keyset) pagination for endpoints that are expected to handle large datasets (e.g., ticket orders, event listings). Instead of passing
page, clients should pass acursor(usually the_idand sort field of the last item).Acceptance Criteria
EventTicketService.getEventTicketsupdated to support cursor-based pagination.TicketOrderServiceupdated to support cursor-based pagination.Files
src/services/event-ticket.service.tssrc/services/ticket-order.service.tsNotes
For backward compatibility, the
pagequery parameter can be maintained with.skip()as a fallback, butcursorshould be preferred.