Jump to content

help me with slow load times for a large database


scarhand

Recommended Posts

i have a database with around 250,000 entries in a table

 

the problem is, pulling data from this table seems to take a REALLY long time

 

i want to know how i can make the queries execute faster

 

the web site is at www.fretlords.com

 

as you can see if you go to a letter, the page loads slow

 

here is the table structure:

 

  id int(10)         

  ugid int(10)          

  band text          

  slug_band text             

  song text            

  slug_song text              

  tab longtext                

  version int(11)               

  date_posted int(10)                

  rating int(11)           

  views int(10)            

 

here is an example of a query:

 

$letter = 'a';

"SELECT DISTINCT(band), slug_band, COUNT(band) AS count FROM tabs WHERE band REGEXP '^$letter' GROUP BY band ORDER BY band ASC LIMIT 100";

Link to comment
Share on other sites

Use indexes.  I'm guessing by the looks at it that it will check EVERY record to see if it matches "starts with $letter" which is very costly in itself.  Not sure about the GROUP BY either...esp with the distinct there..

 

Also, if I'm correct in assuming that COUNT(band) returns the same value for every row, meaning it counts all the distinct bands in the database, then it is also unnecessary; you could use a mysql_num_rows() to get that value, but I doubt that the count is high costly.

 

Also, it doesn't look like your database is normalized.  Have you read up on proper normalization?

Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.