1. One or more computer-readable storage media storing computer-executable instructions for causing a computer system when programmed thereby to perform: receiving, at a query engine, a first version of a database query including first query code in a declarative language; with the query engine, based on the first query code, generating second query code in an imperative language; and with the query engine, embedding the second query code in a second version of the database query.