Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Big Board Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
I think this could really help us bigboards if VB or a VB.org implemented this Details »»
I think this could really help us bigboards if VB or a VB.org implemented this
Version: , by telc telc is offline
Developer Last Online: Mar 2012 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 09-06-2007 Last Update: Never Installs: 0
 
No support by the author.

http://www.vbulletin.com/forum/showthread.php?t=242202

My forum is very large, and when I enabled the slow_query log in mysql. I noticed that searches that match a large # of posts could take a long time to execute. (this is extremly CPU intensive and causes a downward spiral at times)

This is the query that gives me the most trouble, it is in search.php

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

There was over 40,000 matching postids being passed into that "IN" clause.


I do have the search results limit set to 500 in admincp but that does not have any affect on this query.

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;
Propasal:

If a users search matches over X number of posts, the user could be prompted to refine the query.

It would be nice if X this could be an admincp setting, it would stop large #'s of postid's from being passed into that "IN" clause.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 09-06-2007, 07:18 PM
Eikinskjaldi's Avatar
Eikinskjaldi Eikinskjaldi is offline
 
Join Date: Feb 2006
Location: Hell, never looked better
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think I'm looking at the right section in search.php, but might you be able to get a line number for the query that's causing the problem?
Reply With Quote
  #3  
Old 09-06-2007, 07:36 PM
telc's Avatar
telc telc is offline
 
Join Date: Dec 2001
Posts: 128
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wayne said this is the query: https://vborg.vbsupport.ru/showpost....75&postcount=4

I think it would be an easy Add-on:

Search.php: Line1296

PHP Code:
$post_query_logic[] = "post.postid IN(" implode(','$requiredposts) . ")"

If count() of $requiredposts > X prompt user to refine query.

This would stop thousands of postid's from being passed to that "IN" clause.
Reply With Quote
  #4  
Old 09-06-2007, 08:00 PM
Eikinskjaldi's Avatar
Eikinskjaldi Eikinskjaldi is offline
 
Join Date: Feb 2006
Location: Hell, never looked better
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd already played with that, throwing
Code:
if(count($requiredposts > 0)) {
eval(standard_error(fetch_error('please_refine_search_query')));
}
just above that line. Unfortunately it doesn't seem to do much of anything. Let me know if it works for you.
Reply With Quote
  #5  
Old 09-06-2007, 08:42 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Line 1296 is not the only place that postids is built into the query logic, see also lines 1050 & 1123.
Reply With Quote
  #6  
Old 09-06-2007, 08:42 PM
telc's Avatar
telc telc is offline
 
Join Date: Dec 2001
Posts: 128
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Eikinskjaldi View Post
I'd already played with that, throwing
Code:
if(count($requiredposts > 0)) {
eval(standard_error(fetch_error('please_refine_search_query')));
}
just above that line. Unfortunately it doesn't seem to do much of anything. Let me know if it works for you.
I will try when I get home, but it should be:

PHP Code:
if(count($requiredposts) > 0) { 
not

PHP Code:
if(count($requiredposts 0)) { 
Reply With Quote
  #7  
Old 09-07-2007, 08:51 PM
Analogpoint's Avatar
Analogpoint Analogpoint is offline
 
Join Date: Feb 2007
Posts: 656
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Without looking at it at depth, I think the following would work. Edit your search.php file with the following changes. Be sure to back up your search.php file before doing this, so if it doesn't work right, you can revert to the regular version. Warning: this code is untested.

First define a phrase called searchrefinequery with your error message, maybe: "Your search returned gazillions of posts, try being more specific, thanks".

Also, change the number 1000 to whatever suits your fancy.

(1)

Add this:
PHP Code:
if (count ($ANDs) > 1000)
{
    eval(
standard_error(fetch_error('searchrefinequery')));

Right before this on line 1050:
PHP Code:
$post_query_logic[100] = 'post.postid IN(' implode(','$ANDs) . ')'
(2)

Add this:
PHP Code:
if (count ($postids) > 1000)
{
    eval(
standard_error(fetch_error('searchrefinequery')));

Right before this on line 1123:
PHP Code:
$post_query_logic[] = 'post.postid IN(' implode(','$postids) . ')'
(3)

Add this:
PHP Code:
if (count ($requiredposts) > 1000)
{
    eval(
standard_error(fetch_error('searchrefinequery')));

Right before this on line 1296:
PHP Code:
$post_query_logic[] = "post.postid IN(" implode(','$requiredposts) . ")"
Reply With Quote
Reply


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 11:24 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.05259 seconds
  • Memory Usage 2,282KB
  • Queries Executed 22 (?)
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
  • (3)bbcode_code
  • (9)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)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
  • (6)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