Design patterns in internal database query representation

Is there a good resource on design patterns for representation of database queries & execution internally, other than looking at database open source code?

For example, say you have this statement:

SELECT country FROM world
WHERE population>
(SELECT population FROM world
WHERE country=‘Russia’)

How such a nesting statement with various qualifiers is represented internally, as a design pattern, and then evaluated, fascinates me. I’d imagine it’s very similar to the old arithmetic expression tree, but I’d still like to see thoughts on how others approached this. Is there an implementation-centric resource on this?

Are you talking about how the SQL parser itself represents the code? If so you’re talking about a fairly straightforward AST.

This is pretty standard material in most database textbooks. There’s about a hundred pages on it in Ramakrishnan & Gehrke, which shouldn’t be too hard to find at a library.

MS SQL includes a profiler that will show you the execution plan for a query. I mostly just played around with that until I got a feel for it.

Thanks for the book rec. Leafing through it, it does seem to have what I want. Thanks again :slight_smile: