speed up queries for distribution graphs