Author
|
Message
|
Sébastien Antoniotti
|
Friday 06 April 2007 1:21:36 am
Hi, I'm working on a personnal ezpublish site, and one view is very slow. She just make a fetch who return 200 results approximately. Here is a link to this view : http://sunemu.dnsalias.net/index.php/fr/accords/liste (login : dev, pass : dev) And here is the template code :
{set-block scope=root variable=cache_ttl}0{/set-block}
{def $debut1=concat($view_parameters.lettre,'*')}
{cache-block}
{def $chansons = fetch( 'content', 'tree',
hash( 'parent_node_id', 59,
'sort_by', array( 'name',true() ),
'class_filter_type', 'include',
'class_filter_array', array( 'chanson','tablature','guitar_pro' ),
'attribute_filter', array(array( 'name', 'like', $debut1 ))
)
)
}
{/cache-block}
<table style="width:830px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="barrePubGauche" style="vertical-align:top;padding:8px 5px 0px 5px;width:160px;background-color:#B6C796;">
<!--adsense -->
</td>
<td style="border:0px solid red;padding-top:5px;padding-left:20px;vertical-align:top;">
<div style="text-align:center">
<a href={'accords/liste/(lettre)/a'|ezurl()}' >A</a>
<a href={'accords/liste/(lettre)/b'|ezurl()}' >B</a>
<a href={'accords/liste/(lettre)/c'|ezurl()}' >C</a>
<a href={'accords/liste/(lettre)/d'|ezurl()}' >D</a>
<a href={'accords/liste/(lettre)/e'|ezurl()}' >E</a>
<a href={'accords/liste/(lettre)/f'|ezurl()}' >F</a>
<a href={'accords/liste/(lettre)/g'|ezurl()}' >G</a>
<a href={'accords/liste/(lettre)/h'|ezurl()}' >H</a>
<a href={'accords/liste/(lettre)/i'|ezurl()}' >I</a>
<a href={'accords/liste/(lettre)/j'|ezurl()}' >J</a>
<a href={'accords/liste/(lettre)/l'|ezurl()}' >L</a>
<a href={'accords/liste/(lettre)/m'|ezurl()}' >M</a>
<a href={'accords/liste/(lettre)/n'|ezurl()}' >N</a>
<a href={'accords/liste/(lettre)/o'|ezurl()}' >O</a>
<a href={'accords/liste/(lettre)/p'|ezurl()}' >P</a>
<a href={'accords/liste/(lettre)/q'|ezurl()}' >Q</a>
<a href={'accords/liste/(lettre)/r'|ezurl()}' >R</a>
<a href={'accords/liste/(lettre)/s'|ezurl()}' >S</a>
<a href={'accords/liste/(lettre)/t'|ezurl()}' >T</a>
<a href={'accords/liste/(lettre)/u'|ezurl()}' >U</a>
<a href={'accords/liste/(lettre)/v'|ezurl()}' >V</a>
<a href={'accords/liste/(lettre)/z'|ezurl()}' >Z</a> <a href={'accords/liste'|ezurl()}' >[Tous]</a>
</div>
<br />
<br />
<table id="tableListeChansons" width="100%">
<tr>
<th>Titre</th>
<th>Album</th>
<th>Artiste</th>
<th>Note</th>
<th style="text-align:center;width:32px;">Clics</th>
<th style="text-align:center">Posté par</th>
</tr>
{if $chansons}
{foreach $chansons as $chanson}
{def $idCreateur=$chanson.object.owner.id}
{def $createur=fetch('content','object',hash( 'object_id', $idCreateur ))}
<tr>
<td><a title="Vers accords guitare de {$chanson.data_map.titre.data_text}" href="{$chanson.url_alias|ezurl('no')}">{$chanson.data_map.titre.data_text|extract_left( 48 )}</a></td>
<td>{$chanson.path.3.name}</td>
<td>{$chanson.path.2.name}</td>
<td>{def $note=ratingoperatorresult(hash( 'key', $chanson.node_id,
'function', 'average_value' ) )}
{if eq($note,"")}
{set $note=0}
{/if}
{def $nomImage=concat("accords/note",$note,".jpg")}
<img alt="Note des accords de{attribute_view_gui attribute=$chanson.data_map.titre}" src="{$nomImage|ezimage('no')}" /></td>
<td style="text-align:center">{ezviewcounter($chanson.node_id)}</td>
<td style="text-align:center">{$createur.contentobject_attributes.2.content.login}</td>
</tr>
{/foreach}
{/if}
</table>
<br />
</td>
</tr>
</table>
So I have tried to use the cache blocks but the result is still very slow !
My server is a dedibox :
# CPU 2GHz
# 1024 Mo RAM DDR-2 # Disque dur 160Go SATA-2 and another pages are faster ! Thanks in advance for your help ;-)
eZ Publish Freelance
web : http://www.webaxis.fr
|
Xavier Dutoit
|
Friday 06 April 2007 4:54:42 am
Hi,
- use the owner.name instead of fetching the owner for every song
- on the cache block, don't put any expiry on time and put it on the subtree that contains the songs
- don't use table to format, that's sooo last millennium ;) - not sure what the rate operator does, comment it out to see if it's the guily one This being said, fetching a few hundred nodes and loop them is painfully slow without caching.
http://www.sydesy.com
|
Sébastien Antoniotti
|
Friday 06 April 2007 6:29:48 am
Hi Xavier, Thanks a lot for this tips, I have keeped the table structure because she don't increase the execution time (verified with the debug), but I have been obliged to delete a lot of column to get an execution time of 7s (30s before applying changes). here is my final code :
{set-block scope=root variable=cache_ttl}0{/set-block}
{def $debut1=concat($view_parameters.lettre,'*')}
{cache-block subtree_expiry='artistes/'}
{def $chansons = fetch( 'content', 'tree',
hash( 'parent_node_id', 59,
'sort_by', array( 'name',true() ),
'class_filter_type', 'include',
'class_filter_array', array( 'chanson','tablature','guitar_pro' ),
'attribute_filter', array(array( 'name', 'like', $debut1 ))
)
)
}
{/cache-block}
<table style="width:830px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="barrePubGauche" style="vertical-align:top;padding:8px 5px 0px 5px;width:160px;background-color:#B6C796;">
<!--ads//--><
</td>
<td style="border:0px solid red;padding-top:5px;padding-left:20px;vertical-align:top;">
<div style="text-align:center">
<a href={'accords/liste/(lettre)/a'|ezurl()}' >A</a>
<a href={'accords/liste/(lettre)/b'|ezurl()}' >B</a>
<a href={'accords/liste/(lettre)/c'|ezurl()}' >C</a>
<a href={'accords/liste/(lettre)/d'|ezurl()}' >D</a>
<a href={'accords/liste/(lettre)/e'|ezurl()}' >E</a>
<a href={'accords/liste/(lettre)/f'|ezurl()}' >F</a>
<a href={'accords/liste/(lettre)/g'|ezurl()}' >G</a>
<a href={'accords/liste/(lettre)/h'|ezurl()}' >H</a>
<a href={'accords/liste/(lettre)/i'|ezurl()}' >I</a>
<a href={'accords/liste/(lettre)/j'|ezurl()}' >J</a>
<a href={'accords/liste/(lettre)/l'|ezurl()}' >L</a>
<a href={'accords/liste/(lettre)/m'|ezurl()}' >M</a>
<a href={'accords/liste/(lettre)/n'|ezurl()}' >N</a>
<a href={'accords/liste/(lettre)/o'|ezurl()}' >O</a>
<a href={'accords/liste/(lettre)/p'|ezurl()}' >P</a>
<a href={'accords/liste/(lettre)/q'|ezurl()}' >Q</a>
<a href={'accords/liste/(lettre)/r'|ezurl()}' >R</a>
<a href={'accords/liste/(lettre)/s'|ezurl()}' >S</a>
<a href={'accords/liste/(lettre)/t'|ezurl()}' >T</a>
<a href={'accords/liste/(lettre)/u'|ezurl()}' >U</a>
<a href={'accords/liste/(lettre)/v'|ezurl()}' >V</a>
<a href={'accords/liste/(lettre)/z'|ezurl()}' >Z</a> <a href={'accords/liste'|ezurl()}' >[Tous]</a>
</div>
<br />
<br />
<table align="center" id="tableListeChansons" width="100%">
<tr>
<th>Titre</th>
<th>Artiste</th>
</tr>
{if $chansons}
{foreach $chansons as $chanson}
<tr>
<td><a title="Vers accords guitare de {$chanson.data_map.titre.data_text}" href="{$chanson.url_alias|ezurl('no')}">{$chanson.data_map.titre.data_text|extract_left( 48 )}</a></td>
<td>{$chanson.path.2.name}</td>
</tr>
{/foreach}
{/if}
</table>
<br />
</td>
</tr>
</table>
eZ Publish Freelance
web : http://www.webaxis.fr
|
Nabil Alimi
|
Friday 06 April 2007 9:41:22 am
Hi Séb, Why do you disable view caching for this template ?
My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr
|
Sébastien Antoniotti
|
Saturday 07 April 2007 3:29:17 am
Hi Nabil, You think I should remove this : "{set-block scope=root variable=cache_ttl}0{/set-block} " ? This is the first time for me that I use cache optimization, so I'm not sure about what I do and I don't understand the documentation a lot...
eZ Publish Freelance
web : http://www.webaxis.fr
|
Xavier Dutoit
|
Sunday 08 April 2007 1:40:00 am
HI, It disable the view cache node, so your cache-block are the one controlling the behaviour. You have to do it if you display content from elsewhere (they are other options, but this one does).
have a look at the options for cache-block in the doc. No recalculation based on timeout (by default every two hours) and don't recalculate if the content pulbished isn't below your "chanson" folder. X+
http://www.sydesy.com
|
Pascal von Büren
|
Sunday 08 April 2007 12:54:23 pm
Hi Sébastien, i suppose, you're closing your cache-block too early. Imagine a cache-block as a part of plain HTML-Code, not able to perform any logic on template level: You're only caching the tree-fetch, but all the processing (including the heavy foreach-loop) stays uncached...
|
Nabil Alimi
|
Monday 09 April 2007 4:34:08 pm
Yup Seb, that's what I meant. Actually, by looking at your code, I'm wondering if you have tried it with cache and template compile enabled. Because it won't work anymore. :) Just as Pascal said, a cache-block is in the end a piece of HTML code. After the 1st generation, there won't be any template processing nor php processing between the start and end of your cache-block tag. That means that those 'chanson','tablature','guitar_pro' won't be retrieved anymore as the content / tree fetch won't be executed. Enable TemplateCompile and TemplateCache in your site.ini and tell me how it goes.
My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr
|
Sébastien Antoniotti
|
Monday 09 April 2007 11:52:13 pm
Hi Nabil, I have placed the end of the cache block at the end of my template, modified the site.ini of my siteaccess like this and cleared all caches but it's still very long, about 10seconds to display a view...
[ContentSettings]
TranslationList=
ViewCaching=enabled
StaticCache=enabled
EditDirtyObjectAction=usecurrent
[TemplateSettings]
NodeTreeCaching=enabled
TemplateCompile=enabled
ProcessCaching=enabled
TemplateCache=enabled
Debug=disabled
ShowXHTMLCode=disabled
ShowUsedTemplates=disabled
eZ Publish Freelance
web : http://www.webaxis.fr
|
Michael Lee
|
Wednesday 11 April 2007 8:59:02 am
Hi Sébastien,
I think you should try 'limit' and 'offset' parameter when fetching records. It's not a good idea to fetch all records in one time. The 'limit' and 'offset' will optimize the fetch operation at data base level. Besides, I'm not sure why you are using 'content/tree' instead of 'content/list'. I think if possible, you should change 'content/tree' to 'content/list' which requires less system resources. I hope this helps.
Michael Lee | Managing Director | ZerusTech Ltd | www.zerustech.com
Skype: zerustech
|
Sébastien Antoniotti
|
Wednesday 11 April 2007 12:34:23 pm
Hi Michael, Thanks a lot for trying to help me, but my songs are located in subfolders of the folder fetched, so the content/tree is necessary. Maybe the solution is to use a pagination, but I think it's very sad that ezpublish can't display a simple list more faster. And moreover I use eaccelerator !
eZ Publish Freelance
web : http://www.webaxis.fr
|
Nabil Alimi
|
Wednesday 11 April 2007 1:33:54 pm
Sébastien, Actually, the fetch subtree isn't required. You can instead stick to the fetch content list and play on the <b>depth</b> parameter. Anyway, no matter what, the first access to your page will be slow. With almost 200 objects, this is something you can't avoid. However, ViewCaching will dramatically increase access speed after the first access if used correctly. In your case, you don't need to disable cache. {set-block scope=root variable=cache_ttl}0{/set-block}
would be useful if you had for example part of your template that were user-related, session-related, time-related and so on, since ViewCaching stores the result as plain HTML and is not meant to change on such parameters. (it is actually stored as a serialied object, but nevermind). I suggest that you remove this line and your cache-block.
My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr
|
Sébastien Antoniotti
|
Wednesday 11 April 2007 11:36:56 pm
Hi Nabil, You're right ! I have removed the first line, the cache block, switched to a content/list and now the display seems to be faster ! Thanks a lot !
eZ Publish Freelance
web : http://www.webaxis.fr
|
Kristof Coomans
|
Thursday 12 April 2007 12:54:25 am
Hi Sébastien I would be surprised if switching from content/list to content/tree makes any difference in system resources used because actually the same PHP code is used for both fetch functions (eZContentFunctionCollection::fetchObjectTree). Only the default parameters are different. If there is difference then it is caused by the difference in parameters used.
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
|
Sébastien Antoniotti
|
Thursday 12 April 2007 1:25:30 am
Hi Kristof, Maybe the improvementis is just because I remove the cache block...
eZ Publish Freelance
web : http://www.webaxis.fr
|
Michael Lee
|
Thursday 12 April 2007 2:11:03 am
Hi Kristof, Thanks for your information. I think you are right, the differences between 'list' and 'tree' were caused by different parameters used. The 'list' function use '1' as the default depth while 'tree' does not specify the depth by default.
kernel/content/function_definition.php
===============================
parameter for 'list' function
array( 'name' => 'depth',
'type' => 'integer',
'required' => false,
'default' => 1 )
parameter for 'tree' function
array( 'name' => 'depth',
'type' => 'integer',
'required' => false,
'default' => false ),
So if you didn't specify 'depth' when using 'tree' function, it will try to fetch all sub-nodes recursively, thus requires more resources while the 'list' function will try to fetch the first level sub-nodes only. So Sébastien, maybe you can try to set the 'depth' to reduce the resource usage?
Michael Lee | Managing Director | ZerusTech Ltd | www.zerustech.com
Skype: zerustech
|
Sébastien Antoniotti
|
Thursday 12 April 2007 2:27:18 am
Hi Michael, I have already set the depth to 3
eZ Publish Freelance
web : http://www.webaxis.fr
|