vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   # of queries versus performance issue with MySQL 4.x (https://vborg.vbsupport.ru/showthread.php?t=57802)

AKosygin 10-11-2003 09:55 PM

# 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?

Xenon 10-12-2003 05:56 PM

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 :)

AKosygin 10-29-2003 08:45 AM

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.


All times are GMT. The time now is 08:33 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.00946 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete