Local join in a distributed database