Abstract With the development of computer network technology, distributed database has become a current research hotspot. Based on the structural characteristics of distributed database systems, the article leads to the optimization of distributed database queries at the global optimization level. Then, according to the basic principle of genetic algorithms, combined with the characteristics of the biological immune system, an improved immune genetic algorithm is proposed. The improved immunogenetic algorithm is applied to the database multi-connection query optimization technology, and the distributed database multi-connection query optimization algorithm based on the improved immunogenetic algorithm is designed. In the simulation experiments, a set of optimal parameter values applicable to the system is obtained through continuous experiments, and the distributed multi-connection query is optimized with this set of parameter values, which achieves the expected optimization effect. The final experimental results show that the improved optimization algorithm has a significant improvement in terms of query cost compared to the base algorithm in dealing with distributed database query problems. Meanwhile, under the same conditions, the basic algorithm is used to test and compare the communication cost, mean and standard deviation of the optimal solutions obtained by the two algorithms, and it is concluded that the optimization algorithm in this paper can obtain better solutions and better stability.