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

Reply
 
Thread Tools Display Modes
  #1  
Old 10-11-2003, 09:55 PM
AKosygin's Avatar
AKosygin AKosygin is offline
 
Join Date: Oct 2003
Location: Los Angeles County
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default # of queries versus performance issue with MySQL 4.x

With the query caching of MySQL 4.x, I always wondered how information is retrieved will have on the performance of the database. Presuming you will retrieve the same information either way, would many small queries be faster? Or would one large query with a bunch of JOINs be faster?

According to the MySQL documentation of the query cache, a change in the query statement will render that query a new query. Hence "SELECT * FROM table" is different than "select * from table" OR "SELECT column FROM table".

Keeping that in mind, a large query may involve small changes to it. Like when you are retriving a row, you may have to retrieve the poster's name, the contents of the post, the subject, and the avatar. One large query, where let's say only the name of the poster was changed and you run a query on that. Would that not cause the server to do a FULL table search again? Not just the poster name, but also the contents of the post, the subject, and the avatar, despite there are no change to those other parts?

On the other hand, if you seperate the queries with the above case, when PHP request for each item, the poster's name, the post contents, the subject, and the avatar, wouldn't only the poster's name be searched again while all the others are retrieved from cache?

So will one large query not take as much advantage of the cache as many small queries?

Wouldn't it because of the query cache size limit, a large query would not be cache due to its size? But many small ones will have a good portion of it cached, thus reducing query search load?

Sounds like, unless you are retriving less information when eliminating the number of queries, consolidating the queries in to one giant query may actually slow it down. (At least with MySQL 4.x). Anyone have any performance test they could cite?
Reply With Quote
  #2  
Old 10-12-2003, 05:56 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
According to the MySQL documentation of the query cache, a change in the query statement will render that query a new query. Hence "SELECT * FROM table" is different than "select * from table" OR "SELECT column FROM table".
hmm according to a documentation i read, that's not correct.
IIRC it's not the values which are cached but the pointers to the resultrows, so it's actually the "WHERE" tag which decides if the cache can be used or not.
I'm not 100% sure, but according to that article i read about MySQL4 it's this way
Reply With Quote
  #3  
Old 10-29-2003, 08:45 AM
AKosygin's Avatar
AKosygin AKosygin is offline
 
Join Date: Oct 2003
Location: Los Angeles County
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

According to here: http://www.mysql.com/newsletter/2003...000000108.html

Quote:
As the query arrives to MySQL server it performs a textual comparison with the queries in the Query Cache. This means "SELECT * FROM a" and "Select * From a" will be recognized as different queries.
Because of this, that is why I am asking if there are any performance benchmarks or the like to see if one large query or many small one will be faster.
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 03:18 AM.


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.03744 seconds
  • Memory Usage 2,184KB
  • 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
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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