Fix for postgresql, do not assume nodes to be returned in the order they have been inserted