Improve efficiency of ST_Graph