A distributed algorithm for global query optimization in multidatabase systems