Queries and collectors for performing joins