Fast fetch - getting only contentobject_id and name

Author Message

Marcin Bogowski

Wednesday 15 November 2006 4:25:03 am

Hi,
I've got edit form with few generated <select> lists. Now editing works really slow, because I'm using e.g.
{def $forets = fetch('content','list', hash(parent_node_id,174, 'sort_by', array('name', true()) ))}
Creating objects takes long time and I only need 'contentobject_id' and 'name' of object.

<b>My question is:</b>
Does anybody know any way to get list of 'contentobject_id' and 'name' ?
Maybe some simple extension fetching objects as array, but only name and id (no data_map)?

Ps. {cache-block} is useless in edit forms.

Thanks,
Marcin

Xavier Dutoit

Wednesday 15 November 2006 8:21:41 am

Hi,

Why couldn't you use cache-block into an edit form ?

An otherwise, yes, you could write an extension to fetch only the id and the name (done it for an ajax subselect thing).
as long as it fi
Are you sure that it's slow because of your select ? the edit form might be painfully slow without that ;). Have a look at the powercontent extension, it might speed the process.

X+

http://www.sydesy.com

Kristian Hole

Wednesday 15 November 2006 8:26:53 am

Hi Marcin,

Welcome to the forum.

The datamap and other information is not fetched until you access it. Which means, even if you fetch the object, the datamap is not fetched until you access $object.data_map from the templates, or $object->attribute('data_map') in PHP.

As far as i know, the default fetchfunction only returns the objects. It should however be easy to create an extension which allows you to do what you want.

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Kristian Hole

Wednesday 15 November 2006 8:28:44 am

If you want to make an extension with fetch functions, you can use this extension as basis:
http://ez.no/community/contribs/hacks/informationcollection_fetch_functions

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Marcin Bogowski

Thursday 16 November 2006 3:42:29 am

Hi,
Thanks for answres!

I forgot add that select (multiple) contains 1000 rows - that's why it works so slowly. Don't ask me why it is done this way ;)

I resolved my problem writing really small extension:

$FunctionList['fastObjectFetch'] = array( 'name' => 'fastFetchObjects',
	'operation_types' => array( 'read' ),
	'call_method' => array( 'include_file' =>'extension/myOwn/modules/forest/FunctionCollection.php',
	'class' => 'ForetFunctionCollection',
	'method' => 'fastFetchObjects' ),
	'parameter_type' => 'standard',
	'parameters' => array(
			array( 
				'name' => 'node_id',
				'type' => 'integer',
				'required' => true ),
		)
);

and

function fastFetchObjects($node_id) 
{
$temp =  eZContentObjectTreeNode::subTree( array('AsObject' => false), $node_id);
return array( 'result' => $temp);
}

In template I use

{def $forets = fetch('forets', 'fastFetchObjects', hash('node_id', 174))}

instead of

{def $forets = fetch('content','list', hash(parent_node_id,174, 'sort_by', array('name', true()) ))}

And now it works much, much faster. Could you explain me why?

Proof:
Slow case:

Time accumulators:
Mysql Total				
Mysql_queries	8.2988 sec	31.8806%	125	0.0664 sec
Looping result	0.6058 sec	2.3272%	93	0.0065 sec
--
Template Total	25.3405 sec	 97.3%	 3	 8.4468 sec
Template load	1.7985 sec	6.9092%	3	0.5995 sec
Template parser: create text elements	0.0455 sec	0.1750%	1	0.0455 sec
Template parser: remove whitespace	0.0123 sec	0.0474%	1	0.0123 sec
Template parser: construct tree	0.2718 sec	1.0442%	1	0.2718 sec
Template load and register function	0.0166 sec	0.0637%	7	0.0024 sec
Template processing	23.5410 sec	90.4345%	3	7.8470 sec
--
Total script time:	26.0310 sec

Fast case:

Time accumulators:
Mysql Total				
Mysql_queries	0.3948 sec	8.9410%	124	0.0032 sec
Looping result	0.0719 sec	1.6276%	92	0.0008 sec
--
Template Total	3.7193 sec	 84.2%	 3	 1.2398 sec
Template load	1.7923 sec	40.5901%	3	0.5974 sec
Template parser: create text elements	0.0446 sec	1.0110%	1	0.0446 sec
Template parser: remove whitespace	0.0124 sec	0.2807%	1	0.0124 sec
Template parser: construct tree	0.2732 sec	6.1875%	1	0.2732 sec
Template load and register function	0.0164 sec	0.3709%	7	0.0023 sec
Template processing	1.9260 sec	43.6170%	3	0.6420 sec
--
Total script time:	4.4156 sec	

Marcin Bogowski

Thursday 16 November 2006 3:54:25 am

About {cache-block},
"Why couldn't you use cache-block into an edit form ?"

Maybe I missed something.
For example I've got two required fileds: name (text) and language (select). I sent form with empty name and selected language as 'polish'. Is it possible to set language on 'polish' again as it was selected? Form is in {cache-block} so when validation is wrong form will be displayed from cache. Does it work this way?

Thanks
Marcin

André R.

Thursday 16 November 2006 5:45:13 am

You can use the selected_id as cache-block key, if this content depends on user rights you should also use $current_user.role_id_list|implode( ',' ) and $current_user.limited_assignment_value_list|implode( ',' ) as keys.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Kristian Hole

Thursday 16 November 2006 9:53:07 am

Marcin:
To have a fair comparison, you should use the same sorting in both cases. Now you are sorting one, and not the other. The one who is not sorted is of course going to be faster :-)

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Marcin Bogowski

Thursday 16 November 2006 10:08:58 am

Sorry, it was sample code;) I added sorting and it works also much faster. SQL is executed fast (ORDER BY isn't important here). Maybe creating objects makes script slower.

My updated function:

	function fastFetchObjects($node_id, $sort_field) 
	{
		$list =  eZContentObjectTreeNode::subTree( array('AsObject' => false, 'SortBy' => array( $sort_field, true )), $node_id);
		return array( 'result' => $list);
	}

Regarding "cache-block key". Can I really use selected_id as key? What will happen for edit form with 5 different selects (with 100 rows)? Block cache will be generated for each case?

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 21:17:36
Script start
Timing: Jan 18 2025 21:17:36
Module start 'layout'
Timing: Jan 18 2025 21:17:36
Module start 'content'
Timing: Jan 18 2025 21:17:37
Module end 'content'
Timing: Jan 18 2025 21:17:37
Script end

Main resources:

Total runtime1.0743 sec
Peak memory usage4,096.0000 KB
Database Queries79

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 588.0469152.6406
Module start 'layout' 0.00610.0029 740.687539.4922
Module start 'content' 0.00891.0636 780.1797714.6953
Module end 'content' 1.07250.0017 1,494.875024.1250
Script end 1.0742  1,519.0000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.3289160.0002
Check MTime0.00130.1225160.0001
Mysql Total
Database connection0.00080.072410.0008
Mysqli_queries1.004093.4608790.0127
Looping result0.00070.0649770.0000
Template Total1.031896.020.5159
Template load0.00240.219120.0012
Template processing1.029595.828320.5147
Template load and register function0.00020.015310.0002
states
state_id_array0.00140.127810.0014
state_identifier_array0.00180.171920.0009
Override
Cache load0.00210.1937680.0000
Sytem overhead
Fetch class attribute can translate value0.00040.041240.0001
Fetch class attribute name0.00070.0618120.0001
XML
Image XML parsing0.00160.144740.0004
class_abstraction
Instantiating content class attribute0.00000.0020140.0000
General
dbfile0.00100.0936290.0000
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
21content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 55
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs