Jump to content

Create Index - Speed Issues


Borderline

Recommended Posts

Afternoon

 

I'm working on producing a series of pages that pull data from several databases. I've generated an index on the data (raceid), as when I first joined the tables, the resulting page was horribly slow to load. Testing in this instance was on a limited number of rows (approx 750) on a different server, and the result was excellent.

 

I've since finished the data collation, which has resulted in 11,969 rows in the main database. I've tried a similar code on this dataset but despite the index, the page fails to load and provides an error message: Internal Server Error - The server encountered an internal error or misconfiguration and was unable to complete your request. The result loaded fine with the horse and jockey joins, it was only when the third join was added that the issue occurred.

 

I was wondering whether anyone could advise me on how to proceed - am I asking for an unrealistic result, or is there an issue with my code? Is there a chance the change of webhost could be a problem - my current hosting is shared, whereas my previous was a VPS. I attached below the current SQL, and would be grateful for any advice/pointers.

$result = mysqli_query($con,"SELECT 	runners.raceid, runners.pos, runners.horse, runners.eqp, runners.age, runners.weight,					runners.rat, runners.dist, runners.beat, runners.jockey, runners.trainer,					horse.horse, horse.h_ctry, horse.h_link,					jockey_career.jockey, jockey_career.careerlink,					trainer_career.trainer, trainer_career.careerlink														FROM 		runners			INNER JOIN      horse			ON 		runners.horse = horse.horse									 			INNER JOIN      jockey_career			ON 		runners.jockey = jockey_career.jockey  			INNER JOIN      trainer_career			ON 		runners.trainer = trainer_career.trainer									 			WHERE		runners.raceid = 2000001			ORDER BY	runners.runid");

Thanks

Charlie

Link to comment
Share on other sites

  • 3 weeks later...

You can go into phpMyAdmin and use an EXPLAIN EXTENDED query to have the database server show you how it is doing the joins and what keys it is using, if any. Every join should be with keys, if you have joins that are not using keys then that's a problem. Just write EXPLAIN EXTENDED before your select query and you'll see the output from MySQL.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...