How to speed up Reference module's Views plugin? I have a 'Node reference' field via the References 7.x-2.1 module which is pointing at a View which returns up to ~5000 results. I'm also exposing this field as a filter in a separate View. The issue that I'm having is that these ~5k results are taking up to 20s to render, despite only 10 rows being shown to the browser.

Judging by XHProf's results, I thought the best way to do this was to cache the rendered results of the referenced View. That brought the time for references_plugin_display::render down from 20s down to 10s, but that still seems like a long time. The References module doesn't seem to have documentation.

Is there a way to skip rendering 'Node reference' options, or to generally speed this process up? If the solution is to change modules, is there a migration path from D6 References fields to the new module in D7?
I wound up replacing references_plugin_style with a custom, bare-bones plugin style in my_references_plugin_style.inc:

/**
 * @file
 * Handler for my_references_plugin_style.
 */
class my_references_plugin_style extends references_plugin_style {
  function render() {
    if (!empty($this-&gt;options['grouping'])) {
      throw new Exception(t('References list (fast) does not support grouping.'));
    }

    $options = $this-&gt;display-&gt;handler-&gt;get_option('references_options');

    // Play nice with View UI 'preview' : if the view is not executed through
    // _*_reference_potential_references_views(), just display the HTML.
    if (empty($options)) {
      // "Render" rows quickly
      foreach ($this-&gt;view-&gt;result as &amp;$row) {
        $row = $row-&gt;node_title;
      }

      $function = new ReflectionMethod('views_plugin_style', 'render');
      return $function-&gt;invoke($this);
    }

    // Foreach supposedly has better performance than array_map
    // @see http://stackoverflow.com/questions/18144782/performance-of-foreach-array-map-with-lambda-and-array-map-with-static-function
    $results = array();
    foreach ($this-&gt;view-&gt;result as $input) {
      $results[$input-&gt;nid] = array(
        'rendered' =&gt; $input-&gt;node_title,
        'group' =&gt; '',
        'title' =&gt; $input-&gt;node_title,
      );
    }

    return $results;
  }
}


Then registering it with:

/**
 * Implements hook_views_plugins().
 *
 * references.module's references_style plugin was way too slow (110s to render ~5k rows),
 * so fork that style plugin and strip most of the functionality away.
 */
function my_views_plugins() {
  $plugins = array(
    'style' =&gt; array(
      'my_references_style' =&gt; array(
        'title' =&gt; t('References list (fast)'),
        'help' =&gt; 'Returns results as a PHP array of names + rendered rows. (Less bloat than "References list").',
        'handler' =&gt; 'my_references_plugin_style',
        'theme' =&gt; 'views_view_unformatted',
        'uses row plugin' =&gt; FALSE,
        'uses fields' =&gt; TRUE,
        'uses options' =&gt; FALSE,
        'uses grouping' =&gt; FALSE,
        'type' =&gt; 'references',
        'even empty' =&gt; TRUE,
      ),
    ),
  );
  return $plugins;
}


And including the .inc file in my module's .info file:

files[] = views/my_references_plugin_style.inc


Finally, I went to my Views' UI and updated the Formatter to the new "References list (fast)" format.