I have the following structure : http://sqlfiddle.com/#!9/92747b/2
Currently it\'s taking 12-16 seconds to execute on my server , because tables contains millions of rows