4

Newest Edit - 27 Feb 2014 - In case some poor soul with the same issue stumbles on this thread, I did not find a solution and ended up removing Matrix and replacing it with Grid.


My company would like to upgrade EE from 2.5.2 to the latest 2.7.2

I have created a sandboxed copy of our website, and executed the upgrade.

As a result, our template for our products page went from an execution time of approximately two seconds to an execution time of over sixty seconds.

After a lot of trial and error, I have broken it down to one particular chunk of code. The code works just fine in the old version of EE, but not in the new version.

See the following code (edited to correct conditionals as per commenters statements):

                                  {if cf_product_options}          

                 {if entry_id==20}
                                              <hr class="soften">
                                              <h2>Configuration Options</h2>
                        <table class="table table-striped table-bordered table-condensed table-disable-hover">
                      <thead>{cf_product_options_labels limit="1"}<tr><th width="50%">{col_1}</th><th width="50%">{col_2}</th></tr>{/cf_product_options_labels}</thead>
                      <tbody>{cf_product_options limit="1"}<tr> <td>{col_1}</td><td>{col_2}</td></tr>{/cf_product_options}</tbody>
                        </table>
                                          {/if}
                                    {if entry_id==22}
                    <hr class="soften">
                                            <h2>Configuration Options</h2>
                    <table class="table table-striped table-bordered table-condensed table-disable-hover">
                      <thead>{cf_product_options_labels limit="1"}<tr><th width="50%">{col_1}</th><th width="50%">{col_2}</th></tr>{/cf_product_options_labels}</thead>
                      <tbody>{cf_product_options limit="1"}<tr> <td>{col_1}</td><td>{col_2}</td></tr>{/cf_product_options}</tbody>
                    </table>
                                            {/if}
                                    {if entry_id==76}
                    <hr class="soften">
                                            <h2>Typical Options <small>( <span style="font-size:12px;">*</span> ) represents standards features</small></h2>
                    <table class="table table-striped table-bordered table-condensed table-disable-hover">
                      <thead>{cf_product_options_labels limit="1"}<tr><th width="33%">{col_1}</th><th width="33%">{col_2}</th><th width="33%">{col_3}</th></tr>{/cf_product_options_labels}</thead>
                      <tbody>{cf_product_options limit="1"}<tr><td>{col_1}</td><td>{col_2}</td><td>{col_3}</td></tr>{/cf_product_options}</tbody>
                      <thead>{cf_product_options_labels limit="1"}<tr><th width="33%">{col_4}</th><th width="33%">{col_5}</th><th width="33%">{col_6}</th></tr>{/cf_product_options_labels}</thead>
                      <tbody>{cf_product_options limit="1"}<tr><td>{col_4}</td><td>{col_5}</td><td>{col_6}</td></tr>{/cf_product_options}</tbody>
                    </table>
                                            {/if}
                                    {if entry_id==77}
                    <hr class="soften">
                                            <h2>Compatible Options</h2>
                    <table class="table table-striped table-bordered table-condensed table-disable-hover">
                      <tbody>{cf_product_options limit="1"}<tr><td>{col_1}</td><td>{col_2}</td><td>{col_3}</td></tr>{/cf_product_options}</tbody>
                    </table>
                  {/if}
                                    {if entry_id==79}
                    <hr class="soften">
                                            <h2>Typical Options <small>( <span style="font-size:12px;">*</span> ) represents standards features</small></h2>
                    <table class="table table-striped table-bordered table-condensed table-disable-hover">
                      <thead>{cf_product_options_labels limit="1"}<tr><th width="20%">{col_1}</th><th width="20%">{col_2}</th><th width="20%">{col_3}</th><th width="20%">{col_4}</th><th width="20%">{col_5}</th></tr>{/cf_product_options_labels}</thead>
                      <tbody>{cf_product_options limit="1"}<tr><td>{col_1}</td><td>{col_2}</td><td>{col_3}</td><td>{col_4}</td><td>{col_5}</td></tr>{/cf_product_options}</tbody>
                    </table>
                                            {/if}
                                    {if entry_id==89}
                    <hr class="soften">
                                            <h2>Typical Options</h2>
                    <table class="table table-striped table-bordered table-condensed table-disable-hover">
                      <tbody>{cf_product_options limit="1"}<tr><td width="50%">{col_1}</td><td width="50%">{col_2}</td></tr>{/cf_product_options}</tbody>
                    </table>
                  {/if}
                                    {if entry_id==101}
                    <hr class="soften">
                                            <h2>Typical Options <small>( <span style="font-size:12px;">*</span> ) represents standards features</small></h2>
                    <table class="table table-striped table-bordered table-condensed table-disable-hover">
                      <thead>{cf_product_options_labels limit="1"}<tr><th width="16%">{col_1}</th><th width="16%">{col_2}</th><th width="16%">{col_3}</th><th width="16%">{col_4}</th><th width="16%">{col_5}</th><th width="16%">{col_6}</th></tr>{/cf_product_options_labels}</thead>
                      <tbody>{cf_product_options limit="1"}<tr><td>{col_1}</td><td>{col_2}</td><td>{col_3}</td><td>{col_4}</td><td>{col_5}</td><td>{col_6}</td></tr>{/cf_product_options}</tbody>
                    </table>
                                            {/if}

                  {/if}

Above, in the code, "cf_product_options" is a matrix field. The code checks with the first conditional to see that data exists, and if so, it checks the entry_id and serves up the appropriate code.

Removing this chunk of code entirely returns the execution time to normal.

(I was originally using a switchee statement here, and while that works in our old version of EE, it is JUST as slow here in the updated version... so I have removed switchee code for the time being to simplify and make it easier to see what is going on)

Thank you for any suggestions.

* DEBUGGING *

Here is the output from the debugging in EE (when I use switchee in addition to the code above):

(0.375135 / 19.24MB) Calling Class/Method: Channel/entries (0.383207 / 19.28MB) -> Class Called: Channel (0.385074 / 19.29MB) -> Method Called: entries (0.393458 / 19.40MB) Calling Extension Class/Method: Assets_ext/channel_entries_query_result (0.411238 / 19.58MB) Calling Extension Class/Method: Playa_ext/channel_entries_tagdata (0.413006 / 19.61MB) Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata (36.993778 / 21.28MB) Calling Extension Class/Method: Pt_field_pack_ext/channel_entries_tagdata (37.032971 / 21.14MB) Calling Extension Class/Method: Playa_ext/channel_entries_tagdata (37.034998 / 21.17MB) Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata (69.008183 / 21.34MB) Calling Extension Class/Method: Pt_field_pack_ext/channel_entries_tagdata (69.041813 / 20.97MB) -> Data Returned

Here is the debugging, after removing switchee and using a fix as suggested below: (0.886224 / 19.24MB) Calling Class/Method: Channel/entries (0.892344 / 19.27MB) -> Class Called: Channel (0.896914 / 19.29MB) -> Method Called: entries (0.954155 / 19.39MB) Calling Extension Class/Method: Assets_ext/channel_entries_query_result (1.011197 / 19.57MB) Calling Extension Class/Method: Playa_ext/channel_entries_tagdata (1.017665 / 19.59MB) Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata (19.454163 / 21.26MB) Calling Extension Class/Method: Pt_field_pack_ext/channel_entries_tagdata (19.519405 / 21.13MB) Calling Extension Class/Method: Playa_ext/channel_entries_tagdata (19.521837 / 21.16MB) Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata (33.768249 / 21.32MB) Calling Extension Class/Method: Pt_field_pack_ext/channel_entries_tagdata (33.818316 / 20.96MB) -> Data Returned

With suggested UPDATE2 the debug output: (0.826544 / 19.24MB) Calling Class/Method: Channel/entries (0.832316 / 19.28MB) -> Class Called: Channel (0.835756 / 19.29MB) -> Method Called: entries (0.853860 / 19.40MB) Calling Extension Class/Method: Assets_ext/channel_entries_query_result (0.878189 / 19.57MB) Calling Extension Class/Method: Playa_ext/channel_entries_tagdata (0.880296 / 19.60MB) Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata (18.803853 / 21.26MB) Calling Extension Class/Method: Pt_field_pack_ext/channel_entries_tagdata (18.863077 / 21.13MB) Calling Extension Class/Method: Playa_ext/channel_entries_tagdata (18.865144 / 21.16MB) Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata (35.012716 / 21.32MB) Calling Extension Class/Method: Pt_field_pack_ext/channel_entries_tagdata (35.067242 / 20.96MB) -> Data Returned

Total Execution time: 37.3617

UPDATE:

I know that this is related to the matrix field in particular. If I remove the matrix field and simply use the if/else conditionals to display regular html code, the load time drops to just 3 seconds.

Add a matrix field and try to display it's contents, and suddenly the execution seems to multiply exponentially for each if/else that exists.

UPDATE 2

To simplify debugging, I have stripped the problem area of my template to contain the following plain html code: (note that there is plenty more to the template, just not shown here)

I can't seem to force my post to remove html code between my code tags, so I have substituted regular brackets for now

(hr class="soften")
(h2)Configuration Options(/h2)

Which has a total execution time of: 2.5+ seconds

If I add my matrix field to that simple code like so:

(hr class="soften")
(h2)Configuration Options(/h2)
{cf_product_options_labels limit="1"}{col_1}{col_2}{/cf_product_options_labels}
{cf_product_options limit="1"}{col_1}{col_2}{/cf_product_options}

Total Execution time jumps to: 4.6+ seconds

The debug looks the same as all the other problem debugs with the execution time jumping drastically when calling " Matrix_ext/channel_entries_tagdata " and " Pt_field_pack_ext/channel_entries_tagdata "

Unfortunately, I have contacted P&T and they responded that there would be a fee to help as debugging a template falls outside the normal scope of their support. Fair enough. I believe I have narrowed it enough right now and have sent them another email, so hopefully they will have ideas on where to go next. I'm at a complete loss.

NEW EDIT: I thought I had this issue licked, but it turns out I didn't. In my excitement over an improved load time, I didn't notice that by embedding my template, I of course was not actually rendering the matrix data, and instead was just displaying variable names. I hadn't edited the template to take into account that I would have to pass the entry_id to the embedded template in order for it to show relevant data.

So this is still unsolved, and I believe I'm going to have to do a MASSIVE amount of work to use an alternate solution.

  • 2
    Turn on template debugging, and try to identify exactly where the delay is occurring that way - it may clarify things further. – Derek Hogue Dec 1 '13 at 19:27
  • I have added the output from the debugging. – enga Dec 2 '13 at 15:47
  • 1
    I haven't seen anyone else mention it, but the entire channel:entries tag parsing was refactored in EE 2.6. It technically does the same thing as before, but the code is organized differently, so its possible its looking at the conditionals differently. – Brian Litzinger Dec 4 '13 at 17:50
  • Thank you Brian, I believe you are right on the money here. – enga Dec 10 '13 at 18:24
  • Curious: can you still look at your memory usage and timing in 2.5.2 for this step: Playa_ext/channel_entries_tagdata (0.413006 / 19.61MB) Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata (36.993778 / 21.28MB)? What does this same template look like, at those two steps, in 2.5.2? Also, what's your php memory_limit on the 2.5.2 machine vs the 2.7.2 machine? Note though I'm not optimistic that this is a simple memory issue, but it's always worth double-checking. – Jay F Dec 16 '13 at 19:08
2

Yeah, you've got a mess on your hands. Try this no add-on method. If it doesn't help you out, notacouch's suggestion to use IfElse should be helpful.

{if entry_id == "20" && cf_product_options:total_rows > "0"}
    <hr class="soften">
    <h2>Configuration Options</h2>
    <table class="table table-striped table-bordered table-condensed table-disable-hover">
      <thead>{cf_product_options_labels limit="1"}<tr><th width="50%">{col_1}</th><th width="50%">{col_2}</th></tr>{/cf_product_options_labels}</thead>
      <tbody>{cf_product_options limit="1"}<tr> <td>{col_1}</td><td>{col_2}</td></tr>{/cf_product_options}</tbody>
    </table>
{/if}

{if entry_id == "22" && cf_product_options:total_rows > "0"}
    <hr class="soften">
    <h2>Configuration Options</h2>
    <table class="table table-striped table-bordered table-condensed table-disable-hover">
      <thead>{cf_product_options_labels limit="1"}<tr><th width="50%">{col_1}</th><th width="50%">{col_2}</th></tr>{/cf_product_options_labels}</thead>
      <tbody>{cf_product_options limit="1"}<tr> <td>{col_1}</td><td>{col_2}</td></tr>{/cf_product_options}</tbody>
    </table>
{/if}

{if entry_id == "76" && cf_product_options:total_rows > "0"}
  <hr class="soften">
  <h2>Typical Options <small>( <span style="font-size:12px;">*</span> ) represents standards features</small></h2>
  <table class="table table-striped table-bordered table-condensed table-disable-hover">
    <thead>{cf_product_options_labels limit="1"}<tr><th width="33%">{col_1}</th><th width="33%">{col_2}</th><th width="33%">{col_3}</th></tr>{/cf_product_options_labels}</thead>
    <tbody>{cf_product_options limit="1"}<tr><td>{col_1}</td><td>{col_2}</td><td>{col_3}</td></tr>{/cf_product_options}</tbody>
    <thead>{cf_product_options_labels limit="1"}<tr><th width="33%">{col_4}</th><th width="33%">{col_5}</th><th width="33%">{col_6}</th></tr>{/cf_product_options_labels}</thead>
  <tbody>{cf_product_options limit="1"}<tr><td>{col_4}</td><td>{col_5}</td><td>{col_6}</td></tr>{/cf_product_options}</tbody>
  </table>
{/if}

{if entry_id == "77" && cf_product_options:total_rows > "0"}
  <hr class="soften">
  <h2>Compatible Options</h2>
  <table class="table table-striped table-bordered table-condensed table-disable-hover">
    <tbody>{cf_product_options limit="1"}<tr><td>{col_1}</td><td>{col_2}</td><td>{col_3}</td></tr>{/cf_product_options}</tbody>
  </table>
{/if}

{if entry_id == "79" && cf_product_options:total_rows > "0"}
  <hr class="soften">
  <h2>Typical Options <small>( <span style="font-size:12px;">*</span> ) represents standards features</small></h2>
  <table class="table table-striped table-bordered table-condensed table-disable-hover">
    <thead>{cf_product_options_labels limit="1"}<tr><th width="20%">{col_1}</th><th width="20%">{col_2}</th><th width="20%">{col_3}</th><th width="20%">{col_4}</th><th width="20%">{col_5}</th></tr>{/cf_product_options_labels}</thead>
    <tbody>{cf_product_options limit="1"}<tr><td>{col_1}</td><td>{col_2}</td><td>{col_3}</td><td>{col_4}</td><td>{col_5}</td></tr>{/cf_product_options}</tbody>
  </table>
{/if}

{if entry_id == "89" && cf_product_options:total_rows > "0"}
  <hr class="soften">
  <h2>Typical Options</h2>
  <table class="table table-striped table-bordered table-condensed table-disable-hover">
    <tbody>{cf_product_options limit="1"}<tr><td width="50%">{col_1}</td><td width="50%">{col_2}</td></tr>{/cf_product_options}</tbody>
  </table>
{/if}

{if entry_id == "101" && cf_product_options:total_rows > "0"}
  <hr class="soften">
  <h2>Typical Options <small>( <span style="font-size:12px;">*</span> ) represents standards features</small></h2>
  <table class="table table-striped table-bordered table-condensed table-disable-hover">
    <thead>{cf_product_options_labels limit="1"}<tr><th width="16%">{col_1}</th><th width="16%">{col_2}</th><th width="16%">{col_3}</th><th width="16%">{col_4}</th><th width="16%">{col_5}</th><th width="16%">{col_6}</th></tr>{/cf_product_options_labels}</thead>
    <tbody>{cf_product_options limit="1"}<tr><td>{col_1}</td><td>{col_2}</td><td>{col_3}</td><td>{col_4}</td><td>{col_5}</td><td>{col_6}</td></tr>{/cf_product_options}</tbody>
  </table>
{/if}

UPDATE

What happens if you put all your Matrix calls inside of the entry_id conditional check? What does the debugger say?

{if entry_id == "20"}
  {if cf_product_options:total_rows > "0"}
    <hr class="soften">
    <h2>Configuration Options</h2>
    <table class="table table-striped table-bordered table-condensed table-disable-hover">
      <thead>{cf_product_options_labels limit="1"}<tr><th width="50%">{col_1}</th><th width="50%">{col_2}</th></tr>{/cf_product_options_labels}</thead>
      <tbody>{cf_product_options limit="1"}<tr> <td>{col_1}</td><td>{col_2}</td></tr>{/cf_product_options}</tbody>
    </table>
  {/if}
{/if}

UPDATE 2

Looks like my update above helped some. Still haven't heard if IfElse helps you. If this doesn't help, can you tell what PHP version you have, what's in your Matrix fields, and verify that all of them have limit="1" where you need that?

{exp:ifelse parse="inward"}
  {if entry_id == "20"}
    {if cf_product_options:total_rows > "0"}
      <hr class="soften">
      <h2>Configuration Options</h2>
      <table class="table table-striped table-bordered table-condensed table-disable-hover">
        <thead>{cf_product_options_labels limit="1"}<tr><th width="50%">{col_1}</th><th width="50%">{col_2}</th></tr>{/cf_product_options_labels}</thead>
        <tbody>{cf_product_options limit="1"}<tr> <td>{col_1}</td><td>{col_2}</td></tr>{/cf_product_options}</tbody>
      </table>
    {/if}
  {if:elseif entry_id == "22"}
    {if cf_product_options:total_rows > "0"}
      <hr class="soften">
      <h2>Configuration Options</h2>
      <table class="table table-striped table-bordered table-condensed table-disable-hover">
        <thead>{cf_product_options_labels limit="1"}<tr><th width="50%">{col_1}</th><th width="50%">{col_2}</th></tr>{/cf_product_options_labels}</thead>
        <tbody>{cf_product_options limit="1"}<tr> <td>{col_1}</td><td>{col_2}</td></tr>{/cf_product_options}</tbody>
      </table>
    {/if}
  {/if}
{/exp:ifelse}
| improve this answer | |
  • Aren't those advanced conditionals? – notacouch Dec 1 '13 at 21:41
  • 1
    True that. Updated. – Stephen Callender Dec 2 '13 at 3:04
  • Thank you so much for helping. I tried your code, but I'm afraid the execution time does not improve. Unfortunately, I have already used Switchee. It was working successfully before the EE upgrade, but doesn't help at all after. – enga Dec 2 '13 at 15:42
  • That makes sense. Try the update. – Stephen Callender Dec 2 '13 at 17:30
  • Unfortunately, it is the same (without switchee, the time is 30 seconds, and using the fix, still 30ish seconds). I will add the output though above for you to see. – enga Dec 2 '13 at 17:42
1

If that is really the case I'm surprised any of those conditions are even working. Programmatically speaking those are assignments, not conditions, which in EE templating terms... is neither, unless they let that slide as conditions then that'd be interesting.

Once that is fixed, if those conditions are really the issue (even if they aren't!) I would try using Mark Croxton's IfElse, or Switchee plugins to handle your conditions so that only the code you need to run is parsed.

the below wouldn't be advanced conditionals due to the IfElse plugin and only the passing condition's content would work/be parsed (if I understand this correctly)

{exp:ifelse parse="inward"} 
  {if entry_id == 78}
  ...
  {if:elseif entry_id == 79}
  ...
  {/if}
{/exp:ifelse}

or switchee, only the valid case's content would be parsed (if I understand this correctly)

{exp:switchee variable="{entry_id}" parse="inward"}
  {case value="78"}...{/case}
  {case value="79"}...{/case}
  ...
{/exp:switchee}
| improve this answer | |
  • Oh my, you are right. What happened there is I removed Switchee, which actually uses one equals sign to compare in the case statements, and forgot to clean that up after. I will come back after I have cleaned the code, and tested. embarassed – enga Dec 2 '13 at 15:34
  • Note: I have updated the code to correct the issue with the conditionals. – enga Dec 2 '13 at 15:39
  • Also, as I said in my post, I had been using switchee, and it did not help. In fact, removing it improved the execution time. – enga Dec 2 '13 at 15:41
  • No worries, we've all been there! My brain is fried all the time. That's surprising that switchee would perform worse, let's see if IfElse helps as Stephen said. path of least resistance. – notacouch Dec 2 '13 at 22:30
  • This is what I find strange as well. Early this year I had the same issue with this page (EE v2.5.1) and part of the fix was using Switchee. My fear is that I vaguely remember finding a patch for a weird issue with my Pixel & Tonic plugins (Matrix, Playa, etc), but I have no idea what that was, and now that they have updated their websites and moved their support to a new system, there is absolutely no trail of what I may have done. I know that this is related to the Matrix field in particular, and may or may not be the actual P&T Lists inside of it, but otherwise, I'm stuck. :( – enga Dec 2 '13 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.