payload icon indicating copy to clipboard operation
payload copied to clipboard

Extremely slow pagination when collection contains Join field

Open mfilteau opened this issue 1 year ago • 10 comments

Describe the Bug

Adding a Join field to a collection impacts the performance of pagination in the View List even if I disable ListColumn and ListFilter.

export const Customers: CollectionConfig = {
...
    {
      name: 'orders',
      type: 'join',
      collection: 'orders',
      on: 'product',
      admin: {
        disableListColumn: true,
        disableListFilter: true,
      },
    },
};

Link to the code that reproduces this issue

https://github.com/mfilteau/payload-bugs

Reproduction Steps

  1. Seed the database (Customers, Products, Orders)

http://localhost:3000/api/seed

  1. In the admin panel, go to the Customers collection and navigate between pages

  2. Compare that to the Orders collection where there is no Join field.

https://github.com/user-attachments/assets/20e3aafe-2793-46b2-985a-fc2b0e800c6b

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Binaries:
  Node: 20.10.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.17.1
  next: 15.1.0
  @payloadcms/db-mongodb: 3.17.1
  @payloadcms/email-nodemailer: 3.17.1
  @payloadcms/graphql: 3.17.1
  @payloadcms/next/utilities: 3.17.1
  @payloadcms/payload-cloud: 3.17.1
  @payloadcms/richtext-lexical: 3.17.1
  @payloadcms/translations: 3.17.1
  @payloadcms/ui/shared: 3.17.1
  react: 19.0.0
  react-dom: 19.0.0
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 65457
  Available CPU cores: 16

mfilteau avatar Jan 17 '25 19:01 mfilteau

I'm having the same issue and after some testing I found an issue where when setting pagination: false on a query for a collection with a join field, the limit field will be ignored and and return everything that matches

Is there a chance that this is related?

stofolus avatar Feb 14 '25 06:02 stofolus

New update :) For me the slowness of the payload UI could be solved by adding an index to the relationship field that was joined.

stofolus avatar Feb 14 '25 08:02 stofolus

I tried indexing, but it’s not working.

Is there any other workaround for this?

prathap-puthran avatar Feb 19 '25 03:02 prathap-puthran

If incase anyone needs, this temporarly solved my issue.

    {
      name: 'notificationsSent',
      type: 'join',
      collection: 'notifications',
      on: 'contact',
      _sanitized: true,
      admin: {
        allowCreate: false,
      },
    },

prathap-puthran avatar Feb 20 '25 19:02 prathap-puthran

@prathap-puthran - thank you , really helped

tsemachh avatar Feb 22 '25 21:02 tsemachh

I am not 100% comfortable with JoinField. For me it does not load related items from relationship field. Its just shows loading. I have two collection. One product and another prices. Prices has the relationship field to product. but when I want to use the product detail to see the connected prices, it just shows loading.

Image

naimRahman08 avatar Feb 24 '25 15:02 naimRahman08

Hi! Apologies for the long delay in getting a response here, are you still experiencing this behavior on the latest version v3.72.0?

JessRynkar avatar Jan 19 '26 15:01 JessRynkar

Hi, Its working as expected in two of my recent projects. One is running in 3.50.0 and another 3.66.0, so I assume its also working on 3.72.0

naimRahman08 avatar Jan 19 '26 16:01 naimRahman08

Thank you for confirming! I will close this issue for now as it appears resolved on latest.

JessRynkar avatar Feb 20 '26 16:02 JessRynkar

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Feb 28 '26 05:02 github-actions[bot]