Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 09-14-2005, 11:40 AM
Swedie's Avatar
Swedie Swedie is offline
 
Join Date: Feb 2002
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
PHP Code:
$sql mysql_query("SELECT * FROM thread WHERE forumid NOT IN(3,6,11,12,19,20,24,28,29,31,32,34,35,36,37,38,40,41,43,44,45,48,49,50,52,53,5  8,61) AND visible IN (0,1,2) AND sticky IN (0,1) ORDER BY lastpost DESC LIMIT 20"); 
Except that and caching, I don't see any chances for optimization.
Thanks. I guess I'll cry alone now.

Btw, totally off-topic, is this automerge thingy that has happened for me a couple of times. Is this a new feature in vb3.0.8? I have vb3.0.3 right now.

Quote:
Originally Posted by The Geek
Just thinking aloud... but what about putting in a dateline restriction that restricts the data to within the last week (that is assuming that you would have more than 20 within a week)?
I honestly dont know if that would help - just thinking aloud.
Worth a shot I guess. thanks
Reply With Quote
  #12  
Old 09-14-2005, 11:41 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nope. It's a Hack by Xenon
Reply With Quote
  #13  
Old 09-14-2005, 11:46 AM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What about the order of the WHERE clause? For example, the first post has NOT IN($excludethreadid) AND forumid NOT IN($excludeforumid) but $excludethreadid is likely bigger than $excludeforumid, so does order matter here?
Reply With Quote
  #14  
Old 09-14-2005, 11:48 AM
Swedie's Avatar
Swedie Swedie is offline
 
Join Date: Feb 2002
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
Nope. It's a Hack by Xenon
Hack of the millenium!

Quote:
Originally Posted by calorie
What about the order of the WHERE clause? For example, the first post has NOT IN($excludethreadid) AND forumid NOT IN($excludeforumid) but $excludethreadid is likely bigger than $excludeforumid, so does order matter here?
Actually what I said in my first post differs to what I got live on the server at the moment. Right now i am excluding threadids inside the while() using "in_array" (or not).
I have a limit of 20 in the first query to ensure that the total after the exceptions has been made that i still have atleast 10 left.
Reply With Quote
  #15  
Old 09-14-2005, 11:51 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am not sure if order does matter. But if mySQL is smart (I expect it is) it should optimize the query itself to perform bolean shortcut tests as fast as possible.
Reply With Quote
  #16  
Old 09-14-2005, 11:54 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
I am not sure if order does matter. But if mySQL is smart (I expect it is) it should optimize the query itself to perform bolean shortcut tests as fast as possible.
Quote:
Right now i am excluding threadids inside the while() using "in_array" (or not).
Array Operations are costly ...

Maybe (not sure!) better
PHP Code:
if (strpos(',1,2,3,4,5,6,7,8,9,10,'",$threadid,") !== false)
{
// got some valid data

Reply With Quote
  #17  
Old 09-14-2005, 02:23 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$sql mysql_query("SELECT * 
FROM thread 
WHERE forumid NOT IN(3,6,11,12,19,20,24,28,29,31,32,34,35,36,37,38,40,41,43,44,45,48,49,50,52,53,58,61)AND visible IN (0,1,2) 
AND sticky IN (0,1) 
ORDER BY lastpost DESC LIMIT 20"
); 
I don't understand why you select on visible and sticky, seems to me you are allowing all possible values. Take those out would speed up.
I suggest you just put back the threadid in the WHERE clause.

Then add indexes on all (on forumid, on threadid & on lastpost) columns used in a WHERE or ORDER BY clause.

This could speed up things a lot. For threadid and forumid, you can use unique indexes.
Reply With Quote
  #18  
Old 09-14-2005, 04:10 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, those are all possible Values for sticky and visible.
Depending on the mySQL Version, this is necessary to convince the optimizer to use the Indexes.
Take a look at search.php, it does the same.

https://vborg.vbsupport.ru/showthread.php?t=66578
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 06:56 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.07180 seconds
  • Memory Usage 2,243KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_php
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete