Hello there, this is a MySQL question but also a beginners question as I am not really a PHP developer at all.
I run a website that is mostly DB driven and at peak times the site grinds to a halt. After plenty of testing and debugging between the web host and myself it appears the MySQL queries to my DB need “optimising”. The web host stated that my MySQL queries were unoptimised and hanging which resulted in slower performance, and which has started to also affect my SERP results. Not good.
After Googling for help it appears that most of the websites are far too advanced for me as most of it went over my head.
Below is the code for how I connect to my database then storing the resulting array into a variable,
[php]mysql_connect($host, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$query = “SELECT id, txtitem2, txtitem3 FROM mytable WHERE type = ‘A String’ OR type = ‘A String 2’ OR type = ‘A String 3’ ORDER BY id DESC LIMIT 5”;
$result = mysql_query($query);[/php]
What way would be best to optimise this code to prevent the site from crashing? Ideally I am looking for some code to copy and paste along with an explanation as to what it does (i like to know what each line does as opposed to blindly copying and pasting) - any advice would be greatly appreciated!
Thanks
Craigy