Perfomance issue with N1QL self join

Hi @keshav_m, can you please post the same answer on Stack Overflow so others can find it? Here is the question on Stack Overflow:

Thanks,
Gerald