If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Slow queries.. Cant think of a solution

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-29-09, 22:48
biba028 biba028 is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
Slow queries.. Cant think of a solution

The ONLY slow query is
Code:
SELECT * FROM video WHERE username = 'XXXXX';
I need that query because i need to count the rows, therefore be able to count how many videos a user uploaded.

the member XXXXX has 117738 videos in total...

Any help?

PS:
The server is a private server..
512 MB RAM and 1GHZ CPU


Here is the slow queries log

Code:
# Time: 091129 19:37:34
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
use lucky_XXXXX;
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:37:45
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:38:06
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:38:42
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 5  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:39:00
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:39:04
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:39:25
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:39:34
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:39:55
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:40:20
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:40:51
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:41:29
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:43:14
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:43:25
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:43:50
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
# Time: 091129 19:44:00
# User@Host: lucky_fb[lucky_fb] @ localhost []
# Query_time: 4  Lock_time: 0  Rows_sent: 117733  Rows_examined: 117738
SELECT * FROM video WHERE username = 'XXXXX';
Reply With Quote
  #2 (permalink)  
Old 11-30-09, 04:37
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Try:

Code:
SELECT count(*) FROM video WHERE username = 'XXXXX';
Should be a little bit faster
Reply With Quote
  #3 (permalink)  
Old 11-30-09, 05:08
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
is the username column indexed?
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #4 (permalink)  
Old 11-30-09, 23:00
biba028 biba028 is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
Yes, username is indexed.
select count(*) was actually slower according to response time
Reply With Quote
  #5 (permalink)  
Old 12-01-09, 07:01
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Can you post the full DDL of the table including the indexes. Just because a column is indexed, doesn't mean that your query uses it! Perhaps your column order in the index is not available? Or that you don't have a clustered index?

etc etc
__________________
George
Twitter | Blog
Reply With Quote
  #6 (permalink)  
Old 12-01-09, 20:24
biba028 biba028 is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
Quote:
Originally Posted by gvee View Post
Can you post the full DDL of the table including the indexes. Just because a column is indexed, doesn't mean that your query uses it! Perhaps your column order in the index is not available? Or that you don't have a clustered index?

etc etc
im new to this.. i dont exactly know what you want me to do
Reply With Quote
  #7 (permalink)  
Old 12-02-09, 09:45
sakis sakis is offline
Registered User
 
Join Date: Nov 2009
Posts: 19
Hi George

Your last post is interesting to me.

How this could be examined (if the query does not use indexes or its not availiable or not clustered index) ??
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On