vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How do you classify a query as being server intensive? (https://vborg.vbsupport.ru/showthread.php?t=101603)

Lea Verou 11-26-2005 03:36 PM

How do you classify a query as being server intensive?
 
I have this question for a long time...
How can I understand whether a query that I am planning to write is server intensive or not?
Does it depend on the table size?
On the where statement of the query?
On if it only counts and not selects?
On what?

Thanks in advance :)

Marco van Herwaarden 11-26-2005 08:46 PM

I would say in order of importance:
- WHERE/JOIN
- ORDER BY
- Amount of data

Most important is to avoid full table scans on larger tables/joins.

Easiest is to turn on debug mode, and examine the query times and the explain queries.

Lea Verou 11-26-2005 08:49 PM

So, of I don't put a where statement and exclude the data I don't need by php code it would be lighter? :eek:
Same for ORDER BY, if I don't put that in the query and then sort the results when they are in an array the script would be lighter?
Does it count whether the query selects the whole fields or counts them (with the COUNT(*) in the query) instead?

Andreas 11-26-2005 08:56 PM

- Queries that don't use indexes
- Queries than scan a large amount of rows
- Queries that cause filesorts
- Queries that involve multiple tables

Lea Verou 11-26-2005 08:59 PM

What is an index exactly? vbulletin tables have indexes? The table that stores the post texts? I am thinking of making a smilie usage statistics mod, but I'm afraid the queries will be very intensive :nervous:
If the table has an index how should I use it in my query to make it less intensive?

Oh and btw thanks Andreas and Marco for your replies :)

Marco van Herwaarden 11-26-2005 09:38 PM

Indexes are added to the tables. You don't 'use' them in your queries (although you can give hints). MySQL will automatically try to use the most efficient access method.

If you are handling large amounts of rows, it will hardly ever be more effecitive to do sorting in PHP.

An index is just what the word suggest: an index.

Compair it with a book.
If the book have a nice wordlist/index, that points you to the page where you can find some information, you can find it rather fast. If there is no index, you will have to go read all pages of the book until you have what you are looking for.


All times are GMT. The time now is 03:53 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.01457 seconds
  • Memory Usage 1,712KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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