Generates much more efficient SQL