Apparently i'm doing something wrong in the query but I can't get it right.
Below is the output of the query done in Raw mode. The output is the expected one. There are 8 items in the db. Takes 120+ seconds (waits for the built-in timeout and then outputs the result).
Same query in GUI mode. Takes less than a second.