We consider the class of database programs and address the problem of minimizing the cost of their exchanges with the database server. This cost partly consists of query execution at the server side, and partly of query submission and network exchanges between the program and the server. The natural organization of database programs leads to submit an intensive flow of elementary SQL queries to the server, and exploits only locally its optimization power. In this paper, we develop a global optimization approach. We base this approach on an execution model where queries can be executed asynchronously with respect to the flow of the application program. Our method aims at choosing an efficient query scheduling which limits the penalty of client/server interactions. Our results show that the technique can improve the execution time of database programs by several orders of magnitude.