I have the latest Drupal 7 running on a Centos OS.
I have a content type named publications which is composed of lets say around 20 fields (i.e. publication title, name, doi, authors, keywords, date, chapter, etc etc.).
I have Staff content type that references Publications using Entity References. One of our staff has around 700 publications (700 references from Staff node to publication nodes).
I have a view of type page with following features/conditions:
- Contextual filter that accepts username of the staff as arg (filters only those publications referenced by that staff whose username is supplied as argument)
- Filter on Staff and Publication content types
- Relationship (A bridge to the Content entity that is referencing Content via field_staff_selected_publication)
Show output as Fields (I construct a publication entry that should look as follow using the fields of publication content type)
Role of aberrant HLA-DR expression and antigen presentation in induction of endocrine autoimmunity. Bottazzo GF, Pujol-Borrell R, Hanafusa T, Feldmann M . Lancet 1983; 2: 1115-1119
The execution time is directly dependent upon the number of publication nodes, one of our staff has around 600 publications and I have get the following execution times for him:
Query build time 4.35 ms Query execute time 60.24 ms View render time 6226.73 ms
Executing the view for a staff that has 170 publications, I get the following time
Query build time 1.8 ms Query execute time 18.99 ms View render time 2107.41 ms
I have the following code to attach the view in the node template file (node--staff.tpl.php)
<div id="selected-publications" class="tab-pane fade in active key-publications"> <?php print views_embed_view('selected_publications', 'page',$node->field_staff_username['und']['value']); ?> </div> <div id="all-publications" class="tab-pane fade all-publications"> <?php print views_embed_view('all_publications', 'page',$node->field_staff_username['und']['value']); ?> </div>
Opening the staff profile with huge number of publication causes a delay in page showing up because, obviously Drupal executes the view and gets back the result and render it. I do know that Views cache or Boost module might help me here to cache the result of the view rather then execute it every time the page is visited but, I am looking for a more efficient approach.
I would like the node--staff.tpl.php page to execute the views_embed_view only when the document loading is done (this would render everything else in the page but, the publication parts will get rendered afterwards).
I would like the views_embed_view to be executed asyncronously (in the background) via ajax or similar solution. The would avoid the page from waiting and while the user is looking at the rest of the page, the publications are rendered in the background.
At the moment, opening the profile page of one of our scientists with 600 publication take around 10 seconds, I believe 8 second of that is because of rendering the view, If I be able to do this 8 second in the background, that would be AMAZING.
Thank you in advance for you help/advise.