A query is executed on a multi-database system. The multi-database system includes a first system database and a second system database. The query is partially executed on a first system database by generating a spool. It is determined that it is more efficient to store the spool on the second system database than to store the spool on the first system database, and in response the spool is stored on the second system database. The query execution is continued by accessing the spool on the second system database, completing execution of the query to produce a result, and storing the result.