How to reduce queries



  • Hi,

    How can I reduce the number of queries on a page? For example.

    I have extended the fields on the page module with a module pageExtension explained in the screencast.
    On a page I need those extra fields and calling them this way:

    $page->extension()->field_name
    $page->extension()->second_field_name
    $page->extension()->third_field_name
    

    Every time I call $page->extension()->..... an extra query is been counted.
    I have a basic page where the number of queries is around 150, I think this is to much and I really want to have them reduced.

    Best regards,
    StanB



  • No replies yet :(

    I did a dirty fix, on the template file I added

    $extension = $page->extension()
    then I replaced all $page->extension with $extension.

    This reduced the queries to between 80 and 100.


  • admin

    You can also use laravel's eager loading feature.


Log in to reply
 

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.