toSql
Renders the SQL this query would send.
A query here is a value rather than an action waiting to happen, and this is what makes it composable: the rendered SQL drops into a WITH clause, a subquery, an arm of a UNION - anywhere the statement it produces belongs inside a larger one. Parameters are never carried by a query and are always supplied at the terminal, so the @name placeholders survive the embedding untouched and are bound by whoever runs the outer statement. The plainer uses follow from the same method: a log line, a test that asserts on what a builder generated.
Rendering is not cached and costs whatever assembling costs, which for a builder means walking its clauses again. Composing a statement once per request is nothing; doing it per row is not.