vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Forum and Server Management (https://vborg.vbsupport.ru/forumdisplay.php?f=232)
-   -   Should a 50k row query take 59-304 seconds? (https://vborg.vbsupport.ru/showthread.php?t=201520)

ZomgStuff 01-12-2009 03:58 PM

Should a 50k row query take 59-304 seconds?
 
So I come home from classes and I see that bluehost has shut me down because I've been quote on quote using too many of their system resources.

I have a forum that at most has maybe 30 people on (including both members and guests).

I'm looking at the sql_slow_queries log and I see a certain query taking anywhere from 59-304 seconds to execute? This is part of a rating mod that I have installed, and I've never had any problems with it before. Out of nowhere do I see this being a problem in the log. Is this a possible issue with my code, or is this bluehost having server hardware from 1999?

Here's an example
Quote:

# Mon Jan 12 07:35:53 2009
# Query_time: 305 Lock_time: 0 Rows_sent: 1 Rows_examined: 51233
SELECT r.*, count(r.rating) as count
FROM erate AS r
LEFT JOIN post as p ON(r.pid = p.postid)
WHERE p.userid = 9272
GROUP BY r.rating
ORDER BY count DESC
LIMIT 1
Should it even take more than a second because it says "limit 1"?

ssslippy 01-13-2009 01:55 AM

I would uninstall the mod anything that has to examine that many rows has issues.

Marco van Herwaarden 01-13-2009 08:38 AM

Using a LIMIT will not make any difference in how long it would take to execute the query. It will only shorten the amount of data that needs to be transfered. The LIMIT is only applied after the rest of the query has been executed. SELECT, JOIN, GROUP BY & WHERE are all done first, maybe even using temporary tables to sort.

ZomgStuff 01-13-2009 11:17 AM

Oh okay, because my host claims that the SQL was quering "billions" of rows...Must have been a bug in the code somewhere.

Marco van Herwaarden 01-13-2009 11:20 AM

He might be right. I never said he wasn't, and that actualy just fits in what i have posted.

PS Not literally billions, the number of rows involved are in the example you posted.


All times are GMT. The time now is 10:52 PM.

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.00985 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
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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