Sylvain Lefran
Sylvain Lefran

Reputation: 3

Left join mysql which is loading indefinitely

This code is loading indefinitely:

$answer_articles = $bdd->prepare(
 "SELECT * 
  FROM todo
  LEFT JOIN links_task_text
  ON links_task_text.links_task_text_id_task = todo.ID
  WHERE todo.site = ?");
$answer_articles->execute(array('xxx'));
exit();

This code is of course working:

$answer_articles = $bdd->prepare(
 "SELECT * 
  FROM todo
  WHERE site = ?");
$answer_articles->execute(array('xxx'));
exit();

//working and no loading delays

And this code is working as well:

$answer_articles = $bdd->prepare(
 "SELECT * FROM todo
  INNER JOIN links_task_text
  ON links_task_text.links_task_text_id_task = todo.ID
  WHERE todo.site = ?");
$answer_articles->execute(array('xxx'));
exit();

//works but it's not what I need

links_task_text.links_task_text_id_task and todo.ID are INT.

I don't understand why the left join isn't working. Some ideas?

Upvotes: 0

Views: 57

Answers (1)

Phil Rennie
Phil Rennie

Reputation: 376

Does column links_task_text_id_task have an index on it?

If not it could be that the query is running a full table scan on links_task_text that is taking a long time.

Upvotes: 1

Related Questions