Querying a lot of pages in multiselect slows down panel

Hi!

I’m using a multiselect field to connect different pages with each other (to model database-like relations). There are multiple fields like this and the queried folders contain big numbers of subfolders (2k+). This slows down the panel very noticeably, although these fields are aggregated in a separate tab in the blueprint.

I guess the issue is that the panel has to fetch multiple large folders and their subfolders in order to get all the options in the multiselect dropdown, because even pages with no connections are very slow. Is there a way to speed this up with caching or maybe just loading the options when they’re needed, like when you click on the tab containing these fields?

This is what the fields look like (manytomany is a field-plugin, its basically inheriting everything from structure):

persons:
            type: manytomany
            label: Personen
            translate: false
            fields:
              foreignkey:
                label: Person
                type: multiselect
                min: 1
                max: 1
                options: query
                query:
                  fetch: site.find('personen').childrenAndDrafts
                  text: "{{ page.title }}"
                  value: "{{ page.uuid }}"
             validate:
              unique: persons

Thanks for any hints / directions to look in!

1 Like