Improve support for big queries (joins, group bys, distincts)