Forums / General / Question about searching and quotes

Question about searching and quotes

Author Message

Carlos Revillo

Thursday 27 December 2007 3:40:32 am

Hello. We're having problems with some search strings in one of our sites. Sometimes, when the user search and string with quotes in it, we have no response. if we wait sometimes we have a php maximum time execution error. but if we decide to do something more with the administrator, the query never ends, and all other queries seem to be locked waiting for the first to end.

we think the query that "locks" the other is this one

 $searchQuery = "SELECT DISTINCT ezcontentobject.*, ezcontentclass.serialized_name_list as class_serialized_name_list, ezcontentobject_tree.*
                            $versionNameTargets
                    FROM
                       $tmpTablesFrom $tmpTablesSeparator
                       ezcontentobject,
                       ezcontentclass,
                       ezcontentobject_tree
                       $versionNameTables
                       $sortFromSQL
                    WHERE
                    $tmpTablesWhere $and
                    $tmpTablesWhereExtra
                    ezcontentobject.contentclass_id = ezcontentclass.id and
                    ezcontentclass.version = '0' and
                    ezcontentobject.id = ezcontentobject_tree.contentobject_id and
                    ezcontentobject_tree.node_id = ezcontentobject_tree.main_node_id
                    $versionNameJoins
                    $showInvisibleNodesCond
                    $sortWhereSQL
                    ORDER BY $orderByFieldsSQL";

wich is in /kernel/search/plugins/ezsearchengine/ezsearchengine.php

if we do a "show procceslist" in our mysql server we can see the state of this query is "statistics" for a while.

anyone have experienced the same issue.

Carlos Revillo

Monday 07 January 2008 5:54:20 am

Still having troubles with this. i will try to explain it better.

Sometimes, when users in admin section search for a long phrase, we have troubles with the next queries. (for example update a content). If we do a show full processlist on our database we can see that a question related to ezsearchengine takes a long time to end. While these query (status = statistics) is executing, next queries shows a "locked" state. the first one seems to block the others. the server is still responding, but if some editors tries to edit content, we have many queries in our processlist with "locked" state. when we reach our max_user_connections, users can't do anything more and see our site.

That's the query who "locks" the other ones

SELECT DISTINCT ezcontentobject.*, ezcontentclass.serialized_name_list as c
lass_serialized_name_list, ezcontentobject_tree.*
                            , ezcontentobject_name.name as name,  ezcontentobjec
t_name.real_translation
                    FROM
                       ezsearch_tmp__0, ezsearch_tmp__1, ezsearch_tmp__2, ezsear
ch_tmp__3, ezsearch_tmp__4, ezsearch_tmp__5, ezsearch_tmp__6, ezsearch_tmp__7, e
zsearch_tmp__8, ezsearch_tmp__9, ezsearch_tmp__10, ezsearch_tmp__11, ezsearch_tm
p__12 ,
                       ezcontentobject,
                       ezcontentclass,
                       ezcontentobject_tree
                       , ezcontentobject_name

                    WHERE
                     ezsearch_tmp__0.contentobject_id=ezsearch_tmp__1.contentobj
ect_id   AND  ezsearch_tmp__0.contentobject_id=ezsearch_tmp__2.contentobject_id
  AND  ezsearch_tmp__0.contentobject_id=ezsearch_tmp__3.contentobject_id   AND
ezsearch_tmp__0.contentobject_id=ezsearch_tmp__4.contentobject_id   AND  ezsearc
h_tmp__0.contentobject_id=ezsearch_tmp__5.contentobject_id   AND  ezsearch_tmp__
0.contentobject_id=ezsearch_tmp__6.contentobject_id   AND  ezsearch_tmp__0.conte
ntobject_id=ezsearch_tmp__7.contentobject_id   AND  ezsearch_tmp__0.contentobjec
t_id=ezsearch_tmp__8.contentobject_id   AND  ezsearch_tmp__0.contentobject_id=ez
search_tmp__9.contentobject_id   AND  ezsearch_tmp__0.contentobject_id=ezsearch_
tmp__10.contentobject_id   AND  ezsearch_tmp__0.contentobject_id=ezsearch_tmp__1
1.contentobject_id   AND  ezsearch_tmp__0.contentobject_id=ezsearch_tmp__12.cont
entobject_id    AND
                    ezcontentobject.id=ezsearch_tmp__0.contentobject_id AND
                    ezcontentobject.contentclass_id = ezcontentclass.id and
                    ezcontentclass.version = '0' and
                    ezcontentobject.id = ezcontentobject_tree.contentobject_id a
nd
                    ezcontentobject_tree.node_id = ezcontentobject_tree.main_nod
e_id
                     and  ezcontentobject_tree.contentobject_id = ezcontentobjec
t_name.contentobject_id and
                                  ezcontentobject_tree.contentobject_version = e
zcontentobject_name.content_version and
 ( ezcontentobject_name.language_id & ezcontentobject.language_mask > 0 AND
     ( (   ezcontentobject.language_mask - ( ezcontentobject.language_mask & ezc
ontentobject_name.language_id ) ) & 1 )
   + ( ( ( ezcontentobject.language_mask - ( ezcontentobject.language_mask & ezc
ontentobject_name.language_id ) ) & 2 ) )
   <
     ( ezcontentobject_name.language_id & 1 )
   + ( ( ezcontentobject_name.language_id & 2 ) )
 )



                    ORDER BY ezcontentobject.modified DESC
LIMIT 0, 10 

If we search for the same phrase without any of the words all works as expected. We also notice that more words on the search phrase makes this statistics time bigger.

Btw, we also noticed that the query i have shown uses 12 tmp tables. if we quote some of the words, we have 24 tables in this query...

i mean, it's not the same if we search for 'in other country' or 'in "other country"'

I have searched for what could be the reason for this long "statistics" state for this process and i found this http://forums.devshed.com/mysql-help-4/a-long-statistics-state-46232.html

So, finally my questions.

a) Is there any way to optimize this query?
b) I know this is not related to ez, but do you know any way to tell mysql to "kill" this process after an amount of seconds?. If we kill this process manually then the locked queries executes and all works as expected.

thank you so much.

Carlos Revillo

Tuesday 08 January 2008 6:55:07 am

If it may help, we'are using mysql 4.1.22.
we have done another installation but using mysql 5.0.45, importing the same database, and the problem dissapear...
so maybe the quick fix is to upgrade our mysql server, but we still looking for another solution.
Thanks.

eZ debug

Timing: Jan 19 2025 00:31:06
Script start
Timing: Jan 19 2025 00:31:06
Module start 'content'
Timing: Jan 19 2025 00:31:06
Module end 'content'
Timing: Jan 19 2025 00:31:07
Script end

Main resources:

Total runtime0.8053 sec
Peak memory usage4,096.0000 KB
Database Queries192

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0084 587.7344180.8359
Module start 'content' 0.00840.6294 768.5703464.6484
Module end 'content' 0.63780.1674 1,233.2188337.4766
Script end 0.8052  1,570.6953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.5321210.0002
Check MTime0.00160.2031210.0001
Mysql Total
Database connection0.00170.213510.0017
Mysqli_queries0.723889.87831920.0038
Looping result0.00240.29381900.0000
Template Total0.773096.020.3865
Template load0.00250.304820.0012
Template processing0.770595.684320.3853
Template load and register function0.00030.033310.0003
states
state_id_array0.00080.105310.0008
state_identifier_array0.00080.095520.0004
Override
Cache load0.00190.2341270.0001
Sytem overhead
Fetch class attribute can translate value0.00210.263320.0011
Fetch class attribute name0.00170.206930.0006
XML
Image XML parsing0.00070.082820.0003
class_abstraction
Instantiating content class attribute0.00000.001630.0000
General
dbfile0.00410.5108210.0002
String conversion0.00000.000930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs