Follow vBSEO on Twitter
vBulletin Modifications
  • Forums
  • Add-Ons
  • Template Modifications
  • Styles
  • Graphics
  • Tutorials
  • Support Center
  • Register
  • vBulletin SEO

Member Log In

Site Navigation

  • Register
  • Members List
  • Social Groups
  • Search
  • Today's Posts
  • Mark Forums Read

Latest Modifications

  • [vB 3.6.x] StopSpam
    By: flappi282
  • [vB 3.8.x] vBulletin Chat Addon for...
    By: 123flashchat
  • [vB 3.5.x] 404 Page Redirect To...
    By: Ak Worm
  • [vB 3.8.x] 404 Page Redirect To...
    By: Ak Worm
  • [vB 4.0.x] 404 Page Redirect To...
    By: Ak Worm

Latest Template Mods

  • [vB 3.8.4] Images PassWordBox...
    By: cRs!MP
  • [vB 3.8.4] Footer Follow Ups
    By: Ak Worm
  • [vB 3.7.2] Worldofwarcraft blue...
    By: Mikeyodesigns
  • [vB 3.7.0] My Links
    By: blind-eddie
  • [vB 3.7.0] Pop-Up Warning Before...
    By: Thelonius Beck

Latest Styles

  • [vB 3.8.4] CompletevB - Skylight
    By: DreadKnight
  • [vB 3.8.3] [vB 3.8.4] Barcelona...
    By: hoiquantinhoc.com
  • [vB 3.8.3] Natures Walk by vBSkin...
    By: Chri5
  • [vB 3.8.3] Green Theme
    By: Robdog
  • [vB 3.8.2] Unreal T 3 - vB3.8.x
    By: Butcher

Latest Graphics

  • [vB ] [anim.]Team Ranks
    By: cRs!MP
  • [vB ] Abstract Circles (3...
    By: cRs!MP
  • [vB ] PlayStation Rank Images
    By: cRs!MP
  • [vB 3.6.12] Heavy Stroked Button...
    By: Shelley
  • [vB ] Minature Ranks.
    By: Shelley
vBulletin Modifications » Support Center » PHP / SQL » Slow Queries
Reply

 

  • Thread Tools
Old 06-20-2009, 09:33 PM   #1
final4ever
vB Newbie

Activity Longevity
0/20 5/20
Today Posts
0/3 ssssssss3
final4ever is on a distinguished road
Status: Offline Default Slow Queries
Can someone please help me optimize this query as it happens all the time.

These queries appears at forum ID 96 I have there like 164,833 threads and 418,405 posts. And I can't figure out what is wrong.

# User@Host: forums[forums] @ localhost []
# Query_time: 11 Lock_time: 0 Rows_sent: 100 Rows_examined: 116077
SELECT threadid , title, lastpost, replycount
FROM thread AS thread
WHERE forumid = 96
AND visible = 1
AND open <> 10

ORDER BY dateline ASC
LIMIT 5000,100;
# User@Host: forums[forums] @ localhost []
# Query_time: 11 Lock_time: 0 Rows_sent: 100 Rows_examined: 115777
SELECT threadid , title, lastpost, replycount
FROM thread AS thread
WHERE forumid = 96
AND visible = 1
AND open <> 10

ORDER BY dateline ASC
LIMIT 4700,100;
# Time: 090208 19:52:25
# User@Host: forums[forums] @ localhost []
# Query_time: 12 Lock_time: 0 Rows_sent: 100 Rows_examined: 116177
SELECT threadid , title, lastpost, replycount
FROM thread AS thread
WHERE forumid = 96
AND visible = 1
AND open <> 10

ORDER BY dateline ASC
LIMIT 5100,100;
# Time: 090208 19:52:26
# User@Host: forums[forums] @ localhost []
# Query_time: 13 Lock_time: 0 Rows_sent: 100 Rows_examined: 116377
SELECT threadid , title, lastpost, replycount
FROM thread AS thread
WHERE forumid = 96
AND visible = 1
AND open <> 10

ORDER BY dateline ASC
LIMIT 5300,100;
Reply With Quote
Old 06-26-2009, 12:11 PM   #2
Idan
Coder
Idan's Avatar

Activity Longevity
6/20 17/20
Today Posts
0/3 sssss1482
Location: Israel
Age: 29
Idan is on a distinguished road
Status: Offline Default
i've refrained answering this till now, as i'm not sure what problem here.

In my experience i can say the problem for most mysql optimization problems in large DBs are bad structure databses, specific the lack of INDEX/KEY fields, for fields that are used in WHERE statements.
Solution: adding those fields INDEX.
This will make any large databses search matter of mili-seconds, while without them queries can take on large DB's even closer to 20-30 secons (on DB with ovr 3 milllions records in it).

Did this start after installing something specific you can remember ?
Also high cpu usage can affect greatly on mysql performance, so if this is dedicated/vps box, try to check if anything is overloading your box cpu.
Regards,
Idan.

* Support will only be given via forums !
* If this post solved/aided your problem, please click "mark as aid" / "mark as solution" as explained in here

Last edited by Idan; 06-26-2009 at 12:26 PM.
Reply With Quote
Old 06-26-2009, 05:16 PM   #3
final4ever
vB Newbie

Activity Longevity
0/20 5/20
Today Posts
0/3 ssssssss3
final4ever is on a distinguished road
Status: Offline Default
Thanks for your reply Idan!

And no I did not install anything. I have those slow queries at forum ID 96.

Only vBulletin running on the server.

It's a dedicated dual xeon 3.0 with 8 GB RAM RAID 1.

I wonder if there's a lack of index keys I would of have slow queries on other foru ID'S

Forum is running quite fast and suddenly load goes even to 20

Any suggestions would be appreciated.

Allen
Reply With Quote
Old 06-26-2009, 05:56 PM   #4
Idan
Coder
Idan's Avatar

Activity Longevity
6/20 17/20
Today Posts
0/3 sssss1482
Location: Israel
Age: 29
Idan is on a distinguished road
Status: Offline Default
In general, if certain forum id has more posts, then it means the sql query will have to examine more rows. should the WHERE include non indexed field(s), the search time can be rather long & spike cpu during process.

looking at my current indexes list on 'thread' table (on my server) i see that "open" field is NOT indexed (by default). That could explain why any query with "open" in WHERE condition could have slower queries on large databases. Try to run query without the "AND open <> 10" in it, see if this is fast for you, or still slower for you.
If the above is fast for you, then possible solution SUGGESTION is making the field "open" (on 'thread' table) indexed.

DISCLAIMER:
The above suggestion is given as my advise to you, from my own knowledge, AS-IS & should it be attempted to be made, it's totaly upon your decision. I, nor this site, cannot take any responsibility for any result of such action. You should FULLY backup your entire database before any attempt to do any database operation, should it fail & result in "crash" that will force recovery from last backup.
Please be aware that during this process can sometimes (depands on cpu) take up to several hours, during which the cpu is very high, and box likely not to be useable during this time.
Furthermore i would highly advise take site offline during this time, so there wont be any new DB additions during the process, in way that might conflict/fail the index process.
Regards,
Idan.

* Support will only be given via forums !
* If this post solved/aided your problem, please click "mark as aid" / "mark as solution" as explained in here
Reply With Quote
Old 06-26-2009, 11:39 PM   #5
final4ever
vB Newbie

Activity Longevity
0/20 5/20
Today Posts
0/3 ssssssss3
final4ever is on a distinguished road
Status: Offline Default
About the disclaimer it's ok I cloned the the website on another server so I'm testing in there.

So if you have any queries to run shoot it.

I tried with and without AND open <> 10 and it's taking 1.+ seconds for the query to finish.
With AND open <> 10

Showing rows 0 - 99 (100 total, Query took 1.0899 sec)

Whithout AND open <> 10

Showing rows 0 - 99 (100 total, Query took 1.0838 sec)

This is quite fast. I have 3+ sec everytime when I click on the link on forumdisplay 96 as admin "results from microstats."

If you have other ideas I can run queries as I'm testing this on backup server.

Allen
Reply With Quote
Old 06-27-2009, 02:17 PM   #6
Idan
Coder
Idan's Avatar

Activity Longevity
6/20 17/20
Today Posts
0/3 sssss1482
Location: Israel
Age: 29
Idan is on a distinguished road
Status: Offline Default
i'm sorry, but i have no further ideas at this time. I'f i'll think on something i'll post it here.
Regards,
Idan.

* Support will only be given via forums !
* If this post solved/aided your problem, please click "mark as aid" / "mark as solution" as explained in here
Reply With Quote

Reply

« - | VB Member Area Addon & HTACCESS FILE »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
[How-To] Use plugins to join default queries Ken Iovino vBulletin Modification Tutorials 2 04-04-2006 09:01 PM
[FIXED] Slow Scrolling Oblivion Knight Site Feedback 11 09-16-2004 11:22 PM



All times are GMT. The time now is 12:46 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Transverse Styles
  • Top
  • Archive
  • vBSEO
  • Contact Us
LinkBack
LinkBack URL LinkBack URL
About LinkBacks About LinkBacks
Bookmark & Share
Digg this Thread! Digg this Thread!
Add Thread to del.icio.us Add Thread to del.icio.us
Bookmark in Technorati Bookmark in Technorati
Furl this Thread! Furl this Thread!