Categories > TinyButStrong general >

Slow rendering of sub blocks

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Sebastian
Date: 2009-03-27
Time: 15:24

Slow rendering of sub blocks

Hello, tbs it great!!!

One thing always makes me sad is the bad performance of sub blocks.

I have multiple data entries and for each entry I have eg. some countries, some memos, some specials, meaning data from different tables in the database.

Why is there this performance issue and how can I sove it? I think for me headergrp, footergrp and so on are not working.

One line of data to show:
----------------------------------------------------------------------------
| CODE | NAME | SEED_COMPANY | BREEDER | COUNTRIES | COUNTRY_OTHERS | STATUS |
|      |      | SEED_COMPANY | BREEDER | COUNTRIES | COUNTRY_OTHERS |        |
|      |      | SEED_COMPANY | ...     | COUNTRIES | COUNTRY_OTHERS |        |
|      |      | ...          |         | COUNTRIES | COUNTRY_OTHERS |        |
|      |      |              |         | COUNTRIES | ...            |        |
|      |      |              |         | ...       |                |        |
----------------------------------------------------------------------------
| MEMO1, MEMO2, MEMO3 ...                                                    |
----------------------------------------------------------------------------

Data is in an array like this:
array(10) {
  [1043111]=>
  array(20) {
    ["CODE"]=>
    string(6) "104311"
    ["COUNTRY"]=>
    string(2) "UA"
    ["NAME"]=>
    string(10) " ES Astrid"
    ["STATUS"]=>
    string(6) "active"
    ["CROP"]=>
    string(103) "Raps, Körner-/Winter&nbsp;(110)<br>Raps, Winter/Non-Food&nbsp;(1933)<br>Raps, Winter/Food&nbsp;(20619)"
    ["SEED_COMPANY"]=>
    array(2) {
      [0]=>
      array(14) {
        ["CODE"]=>
        string(2) "25"
        ["NAME"]=>
        string(10) "Company 1"
      }
      [2]=>
      array(14) {
        ["CODE"]=>
        string(2) "26"
        ["NAME"]=>
        string(10) "Company 2"
      }
    }
    ["BREEDER"]=>
    array(2) {
      [0]=>
      array(14) {
        ["CODE"]=>
        string(2) "19"
        ["NAME"]=>
        string(10) "B 1"
      }
      [2]=>
      array(14) {
        ["CODE"]=>
        string(2) "17"
        ["NAME"]=>
        string(10) "B 2"
      }
    }
    ["COUNTRIES"]=>
    array(1) {
      [0]=>
      array(14) {
        ["COUNTRY"]=>
        string(2) "UA"
        ["NAME"]=>
        string(10) " ES Astrid"
        ["STATUS"]=>
        string(6) "active"
      }
    }
    ["COUNTRY_OTHERS"]=>
    array(11) {
      [0]=>
      array(14) {
        ["COUNTRY"]=>
        string(3) "INT"
        ["NAMES"]=>
        string(9) "ES Astrid"
      }
      [1]=>
      array(14) {
        ["COUNTRY"]=>
        string(3) "INT"
        ["NAMES"]=>
        string(10) "Astrid, ES"
      }
      [2]=>
      array(14) {
        ["COUNTRY"]=>
        string(2) "BG"
        ["NAMES"]=>
        string(9) "ES Astrid"
      }
      [3]=>
      array(14) {
        ["COUNTRY"]=>
        string(2) "CZ"
        ["NAMES"]=>
        string(6) "Astrid"
      }
      [4]=>
      array(14) {
        ["COUNTRY"]=>
        string(1) "D"
        ["NAMES"]=>
        string(6) "Astrid"
      }
        }
    }
    ...next entry...
}
By: Skrol29
Date: 2009-03-27
Time: 15:48

Re: Slow rendering of sub blocks

But what is the template code ?
By: Sebastian
Date: 2009-03-27
Time: 17:16

Re: Slow rendering of sub blocks

Something like

<table>
<thead>...</thead>
<tr><td>[code.CODE;block=tr+tr;bmagnet=table]</td>
<td><span>[countries.COUNTRY;block=span;p1=[code.$]]</span></td>
<td><span>[country_others.COUNTRY;block=span;p1=[code.$]]</span></td>
<td>[code.NAME]</td>
</tr>
<tr>
<td>Memos:</td>
<td>[memos.COUNTRY]: [memos.TEXT;block=tr;magnet=tr;p1=[code.$]]</td>
</tr>
</table>

and so on!

If you need complete code I hove to prepare it first.
One row of data with some columns where I have more than one data to show.
By: Skrol29
Date: 2009-03-28
Time: 23:03

Re: Slow rendering of sub blocks

Hi Sebastian,

> Why is there this performance issue and how can I sove it?

Using sub blocks cost one MergeBlock() for each record of the main block.
This can be a lot. And in your case, you are using 6 sub blocks for your main block.
And a MergeBlock() is doing a complete data retreiving and a complete block search/analyzis. Since your data is in the same array, you may don't need a MergeBlock() to retreive it.

For example, you can use a custom onformat function to get the SEED_COMPANY items of the current record and put them into a table or separate them with a line break.

You can also try to use parameter "ope=list" (see http://www.tinybutstrong.com/manual.php#html_field_prm_ope )
This can replace several of your sub blocks. Memo for example.