Performance issue

It was not performing correctly with 500k relationships. problem was
caused due the usage of just one transaction.