Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 09-04-2007, 11:11 PM
telc's Avatar
telc telc is offline
 
Join Date: Dec 2001
Posts: 128
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Anyone know where they query is called from in vb3.6.x

I was looking at my slow query log and found several queries similiar to this one:



I had to cut out the postids because the query was over 350,000 characters and too large to post here.



Code:
# Query_time: 16 Lock_time: 0 Rows_sent: 43736 Rows_examined: 87970



SELECT thread.threadid, thread.forumid, post.userid 
FROM thread AS thread INNER JOIN post AS post ON(thread.threadid = post.threadid ) 
WHERE post.postid IN (MANY POST IDS) AND post.visible = 1;
Reply With Quote
  #2  
Old 09-04-2007, 11:37 PM
Eikinskjaldi's Avatar
Eikinskjaldi Eikinskjaldi is offline
 
Join Date: Feb 2006
Location: Hell, never looked better
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by telc View Post
I was looking at my slow query log and found several queries similiar to this one:



I had to cut out the postids because the query was over 350,000 characters and too large to post here.
Put your code in code tags so it can be quoted back at you.

The query in question lives in a plugin, not any of the vb code (I did a search on the vb code base, which is to say I might be wrong).

The query is slow because it contains over 350 000 characters. The issue is why so many postids, not is there a problem with the query.
Reply With Quote
  #3  
Old 09-05-2007, 12:02 AM
telc's Avatar
telc telc is offline
 
Join Date: Dec 2001
Posts: 128
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't have any plug-ins, I am just trying to locate where in the VB code this query is. It is a very large forum, any only occasionally this query is slow.

They query may be formatted different in the php file so I can't search for the entire thing such as "SELECT thread.threadid, thread.forumid, post.userid"
Reply With Quote
  #4  
Old 09-05-2007, 12:31 AM
Wayne Luke's Avatar
Wayne Luke Wayne Luke is offline
Senior Member
 
Join Date: Jan 2002
Location: Southern California
Posts: 1,694
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looks like one of the search queries.

Actual query is as line 1503 in search.php within vBulletin 3.6.8, the building of the query is before that.

PHP Code:
     $threads $db->query_read_slave("
      SELECT
      " 
implode(', '$thread_select_logic) . "
      FROM " 
TABLE_PREFIX "thread AS thread $userid_index
      " 
. ((!empty($post_query_logic) OR !empty($post_join_query_logic)) ? "INNER JOIN " TABLE_PREFIX "post AS post ON(thread.threadid = post.threadid $post_join_query_logic)" "") . "
      " 
. (!empty($querylogic) ? "WHERE " implode(" AND "$querylogic) : "") . "
      
$nl_query_limit
     "
); 
Searching is fairly intensive. Might want to reduce the number of results returned if you don't already.
Reply With Quote
  #5  
Old 09-05-2007, 12:37 AM
telc's Avatar
telc telc is offline
 
Join Date: Dec 2001
Posts: 128
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Wayne,

I have the limit # of results set to 500 in the Admincp.

I just counted the # of postid's in that IN clause and there was 44,486 postids.

I am not sure dropping that 500 down would have much affect.
Reply With Quote
  #6  
Old 09-05-2007, 02:04 AM
Wayne Luke's Avatar
Wayne Luke Wayne Luke is offline
Senior Member
 
Join Date: Jan 2002
Location: Southern California
Posts: 1,694
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Track your slow query log and look at your recent searches that happen about the same time. Check the words that are being searched for and if they are overly common, remove them from the search index. For instance on a vBulletin related website, you shouldn't allow searches for vBulletin as it will occur in too many places to be useful. If your site is about flowers than flower can be eliminated. It may mean that your users have to get more creative but that shouldn't cause too much harm. They should get more relevant results.

You can see what people searched for in the query column of your search table. This is cleared every hour so you might want to adjust the query for this in includes/cron/cleanup.php. It is this code:
PHP Code:
//searches expire after one hour
$vbulletin->db->query_write("
 DELETE FROM " 
TABLE_PREFIX "search
 WHERE dateline < " 
. (TIMENOW 3600) . "
 ### Remove stale searches ###
"
); 
Having these records stored for a longer period of time during your investigation shouldn't cause too many problems and would allow you to track things down easier.
Reply With Quote
  #7  
Old 09-05-2007, 02:07 AM
telc's Avatar
telc telc is offline
 
Join Date: Dec 2001
Posts: 128
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Wayne Luke View Post
Track your slow query log and look at your recent searches that happen about the same time. Check the words that are being searched for and if they are overly common, remove them from the search index. For instance on a vBulletin related website, you shouldn't allow searches for vBulletin as it will occur in too many places to be useful. If your site is about flowers than flower can be eliminated. It may mean that your users have to get more creative but that shouldn't cause too much harm. They should get more relevant results.

You can see what people searched for in the query column of your search table. This is cleared every hour so you might want to adjust the query for this in includes/cron/cleanup.php. It is this code:
PHP Code:
//searches expire after one hour
$vbulletin->db->query_write("
 DELETE FROM " 
TABLE_PREFIX "search
 WHERE dateline < " 
. (TIMENOW 3600) . "
 ### Remove stale searches ###
"
); 
Having these records stored for a longer period of time during your investigation shouldn't cause too many problems and would allow you to track things down easier.
Thanks again Wayne.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:33 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04117 seconds
  • Memory Usage 2,234KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete