Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-11897

fetch content list - mysql query - optimization

    XMLWordPrintable

Details

    Description

      The mysql query generate by a fetch content list are not optimize.
      The query use the path_string to find the childrens nodes.
      The query could be 10 time faster if it use the parent_node_id to find the childrens nodes

      this fetch

      {def $nodes=fetch( 'content', 'list', hash( 'parent_node_id', 14766 ,	
      'sort_by', array( 'priority', true() ),
      'attribute_filter', array( array( 'priority', '>', '0' ))) )}
      

      Will generate this query

      SELECT ezcontentobject.*,
                             ezcontentobject_tree.*,
                             ezcontentclass.serialized_name_list as class_serialized_name_list,
                             ezcontentclass.identifier as class_identifier
                             
                             , ezcontentobject_name.name as name,  ezcontentobject_name.real_translation 
                         FROM
                            ezcontentobject_tree,
                            ezcontentobject,ezcontentclass
                            , ezcontentobject_name 
      WHERE
       ezcontentobject_tree.path_string like '/1/2/14766/%' 
      and  ezcontentobject_tree.depth <= 3  
      and  ( ezcontentobject_tree.priority > '0'  ) 
      AND  ezcontentclass.version=0 
      AND  ezcontentobject_tree.node_id != 14766 
      AND ezcontentobject_tree.contentobject_id = ezcontentobject.id  
      AND ezcontentclass.id = ezcontentobject.contentclass_id AND
                            
                            
                             ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id and
                                         ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version and 
       ( ezcontentobject_name.language_id & ezcontentobject.language_mask > 0 AND
           ( (   ezcontentobject.language_mask - ( ezcontentobject.language_mask & ezcontentobject_name.language_id ) ) & 1 )
         + ( ( ( ezcontentobject.language_mask - ( ezcontentobject.language_mask & ezcontentobject_name.language_id ) ) & 2 ) )
         <
           ( ezcontentobject_name.language_id & 1 )
         + ( ( ezcontentobject_name.language_id & 2 ) )
       ) 
      
      AND ezcontentobject_tree.is_invisible = 0
      AND ((ezcontentobject.section_id in ( 23, 24, 6, 7, 8, 9))) 
      AND  ezcontentobject.language_mask & 3 > 0 
      ORDER BY ezcontentobject_tree.priority ASC
      

      The mysql query should use the columns parent_node_id instead of the .path_string.
      The query should be

      SELECT ezcontentobject.*,
                             ezcontentobject_tree.*,
                             ezcontentclass.serialized_name_list as class_serialized_name_list,
                             ezcontentclass.identifier as class_identifier
                             
                             , ezcontentobject_name.name as name,  ezcontentobject_name.real_translation 
                         FROM
                            ezcontentobject_tree,
                            ezcontentobject,ezcontentclass
                            , ezcontentobject_name 
      WHERE
       ezcontentobject_tree.parent_node_id =14766  
      and  ( ezcontentobject_tree.priority > '0'  ) 
      AND  ezcontentclass.version=0 
      AND ezcontentobject_tree.contentobject_id = ezcontentobject.id  
      AND ezcontentclass.id = ezcontentobject.contentclass_id 
      AND  ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id and
                                         ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version and 
       ( ezcontentobject_name.language_id & ezcontentobject.language_mask > 0 AND
           ( (   ezcontentobject.language_mask - ( ezcontentobject.language_mask & ezcontentobject_name.language_id ) ) & 1 )
         + ( ( ( ezcontentobject.language_mask - ( ezcontentobject.language_mask & ezcontentobject_name.language_id ) ) & 2 ) )
         <
           ( ezcontentobject_name.language_id & 1 )
         + ( ( ezcontentobject_name.language_id & 2 ) )
       ) 
      
      AND ezcontentobject_tree.is_invisible = 0
      AND ((ezcontentobject.section_id in ( 23, 24, 6, 7, 8, 9))) 
      AND  ezcontentobject.language_mask & 3 > 0 
      ORDER BY ezcontentobject_tree.priority ASC
      

      Attachments

        1. content_list_fetch_39.diff
          7 kB
        2. content_list_fetch_40.diff
          6 kB
        3. content_list_fetch_pluss_40.diff
          44 kB
        4. ezcontentobjecttreenode.php
          262 kB
        5. patch.txt
          2 kB
        6. patch.txt
          3 kB
        7. patch.txt
          2 kB

        Activity

          People

            cyberwolf cyberwolf
            kouz28 kouz28
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: