Answers.Body: <p>Have you looked into eager loading the Matrix field if you are on 2.6? This should vastly cut down on the number of queries needed.</p>
  
  <p>The other thought could be to use the Preparse field plugin to push the matrix fields into simple text, and then direct the search query to only look at the title field and preparse fields.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-29T14:03:50.763Z
Answers.Text: thanks will have a look at it. Will need to upgrade to 2.6 first but looks like it will be worth the effort. Cheers
Answers.UserDisplayName: Lettie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-29T12:12:37.853Z
Answers.LastActivityDate: 2016-03-29T12:12:37.853Z
Answers.UserDisplayName: Patrick Harrington
Body: <p>I am trying to improve the performance of our site search. I'm wondering if there is anything I can implement that may speed things up. Currently we have a search being sent to a results page. In the results page we have this call to the database.</p>
  
  <pre><code>{% set entries = craft.entries.search(query).order('score') %}
  </code></pre>
  
  <p>query is returned from the q parameter in the url.</p>
  
  <p>We are using a matrix field for all the main content blocks on the site. This field has 10 block types with a max of 7 fields in each. This is used on all entries across the site.</p>
  
  <p>Looking at the profiler after running a query on a phrase that is very popular across the site it takes around 11s and queries the db 500+ times.</p>
  
  <p>Any suggestions how we may reduce this time down? Or is this just a disadvantage of using matrix fields?</p>
  
Tags: <matrix><search>
Title: How to improve search performance on front-end?
ThreadText: # How to improve search performance on front-end?
  
  (Asked by: username_0 on 2016-03-29)
  
  I am trying to improve the performance of our site search. I'm wondering if there is anything I can implement that may speed things up. Currently we have a search being sent to a results page. In the results page we have this call to the database.
  
  ```
  {% set entries = craft.entries.search(query).order('score') %}
  
  ```
  
  query is returned from the q parameter in the url.
  
  We are using a matrix field for all the main content blocks on the site. This field has 10 block types with a max of 7 fields in each. This is used on all entries across the site.
  
  Looking at the profiler after running a query on a phrase that is very popular across the site it takes around 11s and queries the db 500+ times.
  
  Any suggestions how we may reduce this time down? Or is this just a disadvantage of using matrix fields?
  
  **Tags:** matrix, search
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-03-29. Score: 2
  
  Have you looked into eager loading the Matrix field if you are on 2.6? This should vastly cut down on the number of queries needed.
  
  The other thought could be to use the Preparse field plugin to push the matrix fields into simple text, and then direct the search query to only look at the title field and preparse fields.
  
  > **Comments:**
  > **username_0**: thanks will have a look at it. Will need to upgrade to 2.6 first but looks like it will be worth the effort. Cheers  
  
  ---
  
  