Implement segment-level query parallelism

This gives quite a speedup, particularly for complex queries.