Help needed troubleshooting slow panel query/multiselect field

something like this… untested but should get you started.

type: multiselect
options: query
accept: options
search:
  display: 50
query:
  fetch: kirby.collection("connectable_kv") # <-- new _kv
  text: "{{ arrayItem.title }}"
  value: "{{ arrayItem.blueprint_title }} - {{ arrayItem.autoid }}"

site/collections/connectable_kv.php

return function ($site) {
    // I assume all these templates have an autoid to keep lapse fast
    $collection = $site->index(true)->filterBy('intendedTemplate', 'in', [
        'person',
        'event',
        'document',
        'place'
    ]);
    // ->sortBy('title') // this would be slow

    // use lapse to either generate or load data array from cache
    $data = Lapse::io(
        // use laspe to create a key from collection based on modified values stored in autoid db
        ['connectable_kv_for_multiselect', $collection],
        function () use ($site, $collection) {
            // inside callback things are only executed on cache refresh
            
            // its ok to sort here
            $collection = $collection->sortBy('title');

            // create primitive types of data to serialize
            return array_values($collection->toArray(function($page) {
                return [
                    'title' => $page->title(),
                    'blueprint_title' => $page->blueprint()->title(),
                    'autoid' => $page->autoid(),
                ];
            });
        }
    );

    // build objects that kirby can use for multiselect field
    $kv = array_map(function ($item) {
        return new \Kirby\Toolkit\Obj($item);
    }, $data);
    return $kv;
};