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

Reply
 
Thread Tools Display Modes
  #1  
Old 10-24-2007, 12:17 PM
Keloran Keloran is offline
 
Join Date: Nov 2006
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Query Optimization

Im wondering when vBulletin will be optimizing its querys, i see a worrying amount of <table>.* querys, or SELECT COUNT(*)

why are there so many of these, its madness and wastes processing, if i add a plugin that adds another field to the posts table for example, then doing SELECT * is pulling that info too

what should be done is, e.g.

SELECT COUNT(postid) as postcount FROM post WHERE threadid = <threadid>

NOT

SELECT COUNT(*) as postcount FROM post WHERE threadid = <threadid>

that is just stupid, in the next version of vB (vB4) will all these problems be sorted, it would also mean, after correct index's the processing/memory requirements of vB would fall dramaticlly
Reply With Quote
  #2  
Old 10-24-2007, 12:34 PM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try turning on debug mode and looking at the queries or compare the following:
Code:
EXPLAIN SELECT COUNT(postid) AS postcount FROM post WHERE threadid = <threadid>;

EXPLAIN SELECT COUNT(*) AS postcount FROM post WHERE threadid = <threadid>;
Reply With Quote
  #3  
Old 10-24-2007, 12:46 PM
Keloran Keloran is offline
 
Join Date: Nov 2006
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

whilst with those 2 simple ones it might seem like it makes no difference, do the same query and watch your ram usage, there is a large difference, (WITHOUT THE EXPLAIN), you will see a difference, becasue the SELECT * is loading it ALL in memory, where as the SELECT postid, ONLY loads the postid, and thus is alot more optimal,

if you look at the code and read the optimization guides for MySQL you will see why doing * is a very bad idea

easy way of explaining it

i want to find how many wheels are on my car, so what ill do is take my car apart, take all the parts, and put them in piles, and then count them all up, and then take the part i want out, and do another count on that, or i could take the wheels of my car and just count them

which will take less time, less room, and be better for me ????

--------------- Added [DATE]1193301090[/DATE] at [TIME]1193301090[/TIME] ---------------

either this is being lookd into, or vB dont seem to want to admit its mistakes ??
Reply With Quote
  #4  
Old 10-25-2007, 07:37 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

"SELECT *" versus "SELECT postid" makes a difference.

"SELECT COUNT(*)" versus "SELECT COUNT(postid)" however hardly makes a difference. This is already optimised by MySQL, and in both cases the only data returned is the count.

There can be many reasons why more data is pulled from the database then absolutly needed: 1 generic query versus a specific query for each process, the availability of all data to be used if needed,.....

Anyway, vB.org is not the right place to ask this. Better ask at vbulletin.com as the vB developers will see it there.
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 12:05 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03693 seconds
  • Memory Usage 2,185KB
  • 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
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete