0

I am using mysql database with codeigniter framework.
In that join more then 5 tables at a time. MySql query is fine and it produce result correctly, but it's taking too much time to produce result approx 9-12 sec. How can I increase the execution time of query.

SELECT `questions`.* FROM `questions` LEFT JOIN `universities_questions` ON `questions`.`id` = `universities_questions`.`question_id` LEFT JOIN `courses_questions` ON `questions`.`id` = `courses_questions`.`question_id` LEFT JOIN `branches_questions` ON `questions`.`id` = `branches_questions`.`question_id` LEFT JOIN `subjects_questions` ON `questions`.`id` = `subjects_questions`.`question_id` LEFT JOIN `question_types_questions` ON `questions`.`id` = `question_types_questions`.`question_id` LEFT JOIN `questions_year` ON `questions`.`id` = `questions_year`.`question_id` WHERE `questions`.`status` = '1' GROUP BY `questions`.`id` ORDER BY `questions`.`id` DESC LIMIT 1
Insane Skull
  • 9,220
  • 9
  • 44
  • 63
Jitendra
  • 558
  • 8
  • 23
  • Please refer this similar question :- http://stackoverflow.com/questions/18253934/set-maximum-execution-time-in-mysql-php – Hemdip Dec 10 '15 at 05:54
  • I guess you mean "decrease", i.e. get the results faster? Or do you really mean "increase" the timeout before something bad happens to your application? ;-) – VolkerK Dec 10 '15 at 05:54
  • ya.exactly decerase. nut i mean, increase mean, produce result faster. – Jitendra Dec 10 '15 at 05:55
  • @Hemdip thanx for your efforts, but its not execution error. – Jitendra Dec 10 '15 at 05:56
  • Then the starting point is (http://dev.mysql.com/doc/refman/5.7/en/explain.html). Please add the table definitions (preferrably the exact output of `SHOW CREATE TABLE questions`, `SHOW CREATE TABLE universities_questions` and so on) and the exact result of `EXPLAIN SELECT questions.* FROM ...`. Some sample data (again preferrably in the form of valid `INSERT INTO ...` statements) would be nice, too. – VolkerK Dec 10 '15 at 05:58

1 Answers1

0

You can use php sleep function if you don't want to mess with your sql...

sleep(10);

Above line will delay execution of any code bellow of this line for 10 seconds. Here is the php documentation

user2417624
  • 653
  • 10
  • 32