BTW, after more analysis on this, this does not resove the issue.
The same command executed on repetition, will most of the times finish in 22 seconds. Then, out of nowhere, it will run and never finishes.
Yes, the move of the two conditions inside an INNER JOIN results in the same. But, this INNER JOIN results in the same command I had at first.
This is probably why I end up in the same situation again.