Go Back   vb.org Archive > Community Central > Community Lounge
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-08-2005, 06:35 AM
Brinnie's Avatar
Brinnie Brinnie is offline
 
Join Date: Jul 2005
Location: Louisiana
Posts: 360
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How Big Is 1 Query?

I noticed a lot of people make a big deal over queries and I'm wondering if I should be making a big deal too.

How much space/time/whatever does your average query load?
Reply With Quote
  #2  
Old 08-08-2005, 06:58 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A query basically means that your database has to be accessed in order to get data.

Too many queries or one badly written query could mean a slow down of your site due to an increased server load due to increased CPU usage and/or hard disk read/writes. It all depends on the query, the number of them and the size of the database/ table being accessed.
Reply With Quote
  #3  
Old 08-08-2005, 07:03 AM
m0nde's Avatar
m0nde m0nde is offline
 
Join Date: Mar 2005
Location: Toronto, ON Canada
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brinnie
I noticed a lot of people make a big deal over queries and I'm wondering if I should be making a big deal too.

How much space/time/whatever does your average query load?
It depends on what the query is. You can have ONE SQL query insert or lookup a number of different things. Also, as Erwin said, a badly written one will do, slowly and inefficiently, what a well written one would do fairly painlessly.

You'll notice, for instance that at the bottom of vBulletin.org's pages they've got something showing the load. This page tells me: Page generated in 0.16971 seconds with 15 queries. This tells me that the queries were fairly light and that the CPU this thing is running on is fairly good!

- Sid
Reply With Quote
  #4  
Old 08-08-2005, 12:44 PM
Brinnie's Avatar
Brinnie Brinnie is offline
 
Join Date: Jul 2005
Location: Louisiana
Posts: 360
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by m0nde
It depends on what the query is. You can have ONE SQL query insert or lookup a number of different things. Also, as Erwin said, a badly written one will do, slowly and inefficiently, what a well written one would do fairly painlessly.
Would you consider the Quick Reply box a poorly written query?
Reply With Quote
  #5  
Old 08-08-2005, 01:05 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brinnie
Would you consider the Quick Reply box a poorly written query?
The quick reply box is not a query. A query is a call to the database to retrive information from the database (be it stored on the hdd or in memory), that is written in SQL.

What is SQL?

Quote:
SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems. SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database. Some common relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc. Although most database systems use SQL, most of them also have their own additional proprietary extensions that are usually only used on their system. However, the standard SQL commands such as "Select", "Insert", "Update", "Delete", "Create", and "Drop" can be used to accomplish almost everything that one needs to do with a database.
There is no one thing that seperates poor SQL from proper SQL, like anything with coding it's something you learn over time.

Here is a good place to get started if you want to learn more about SQL: http://sqlcourse.com/intro.html
Reply With Quote
  #6  
Old 08-08-2005, 07:00 PM
FleaBag's Avatar
FleaBag FleaBag is offline
 
Join Date: Dec 2001
Posts: 1,674
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd often wondered the same thing actually, thanks for sharing guys.
Reply With Quote
  #7  
Old 08-08-2005, 07:05 PM
vBintense's Avatar
vBintense vBintense is offline
 
Join Date: May 2005
Location: Omnipresent
Posts: 233
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The big issue over quarys is due to multiple hacking.

Say you have 10 hacks on showthread, and all the hacks add 1 quary, then you risk slowing down your server. So when a quary can be removed, and data retrieved with out the quary then it is the best option.

It is not that 1 quary is bad, it is that they add up, and due to that everyone trys not to have any.
Reply With Quote
  #8  
Old 08-08-2005, 07:22 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by insane-topics
The big issue over quarys is due to multiple hacking.

Say you have 10 hacks on showthread, and all the hacks add 1 quary, then you risk slowing down your server. So when a quary can be removed, and data retrieved with out the quary then it is the best option.

It is not that 1 quary is bad, it is that they add up, and due to that everyone trys not to have any.
Nor does many queries mean higher load. 2 small queries could cause less load than one large one.

Again, it depends on how the SQL is written, and more importantly how the database itself is layed out plus many of factors.

It's all trail and error
Reply With Quote
  #9  
Old 08-08-2005, 07:32 PM
vBintense's Avatar
vBintense vBintense is offline
 
Join Date: May 2005
Location: Omnipresent
Posts: 233
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, but I was explaining why alot try not to add any quarys

If you look thru posts people always say can't you do this with out a quary? personally I do not mind one extra quary here and there if it is not massive. But if I was to release something I would use as few as possible

It is like file edits, one line of file edit hurts nothing, but it is so much more liked if can do it with out an edit.
Reply With Quote
  #10  
Old 08-08-2005, 07:44 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by insane-topics
Yes, but I was explaining why alot try not to add any quarys

If you look thru posts people always say can't you do this with out a quary? personally I do not mind one extra quary here and there if it is not massive. But if I was to release something I would use as few as possible

It is like file edits, one line of file edit hurts nothing, but it is so much more liked if can do it with out an edit.
less is not always best.

10 querys could be lighter than 5 querys

Its all about trial and error, some times querys are nessary, some times they arn't. Indies also help alot.

and its query not quary
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 08:19 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.04263 seconds
  • Memory Usage 2,263KB
  • 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
  • (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
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete