somewhat serious

It's Queries All The Way Down

I was recording a screencast to show my brother olical with sql client, since we are both bullish on neovim and I'm bullish on the lisp way of integrated REPLs everywhere.

During recording, I was musing about evaluating sub-queries in the context of a larger queries and noted, "It's queries all the way down."

Oddly, the phrase hung in my mind, and still does, because I find the statement to be generally and objectively true.

Any interaction with data, which is the foundation of most systems, starts with a query.

That query may be to a 40-year veteran neck beard sys-admin about how to access the database.

Which will lead to one or more queries to inspect data in the database.

Which will lead to more queries to gather information. And so on, and so forth...


When it comes to systems, they're composed of two things:

  • People
  • Machines

The people are the most critical component of any system, since they make them, break them, and evolve them over time. The context I've been in for the last few years has been "cloud native" web programming. Any interaction with an interface is performing 1 or more queries to people, before know how to query 1 or more data sources.

For the rest of this musing, we'll focus on data.

I wonder why there is so much complication. Using an OOP example, the pattern of queries via HTTP endpoints is usually:

  1. Receive query request (i.e. GET)
  2. Deserialize request into class(es).
  3. Make SQL query.
  4. Deserialize SQL query result into class(es).
  5. Process and/or transform into other class(es) (optional, though common).
  6. Serialize class(es) to JSON.
  7. Send over the wire.
  8. Deserialize into class(es).

The process is repeated for each dependent data source with some JSON API as a facade.

Day to day, I'm caught up in layers of indirection, leaky abstraction, and invented concepts. Formulating an evident reality like "its queries all the way down", while may seem trivial, is a beneficial exercise in order to be brought back down to earth about a key property of most systems.

It just queries... man...