This gist contains setup SQL and example data for reproducing an object ordering problem that I'm trying to optimize.