Why the Fastest Queries and the Best Minds Both Learn to Filter Early

Kai Nguyen

Hatched by Kai Nguyen

Jul 14, 2026

9 min read

78%

0

The hidden cost of doing everything

What if the biggest reason systems slow down is not that they are too weak, but that they are too polite? Too willing to consider every possibility. Too eager to entertain every row, every branch, every idea.

That sounds like a database problem, until it starts sounding like a thinking problem.

In SQL, a query can look elegant and still be painfully slow if it asks the engine to do work in the wrong order. If you wrap an indexed column in a function, negate it, or hide it behind a leading wildcard, you may force the engine to scan far more data than necessary. The result is not just inefficiency. It is wasted motion. The system knows the answer is somewhere in the table, but you have made it search by lantern light instead of using the road map already built into the index.

Human cognition often makes the same mistake. We call it thoroughness, but sometimes it is just indiscriminate attention. We inspect every option before we know which ones matter. We explore forever when a known good path would suffice. Or we exploit too early, ossifying around safe choices and never discovering better ones. The real question is not whether to be careful or curious. It is when to filter early and when to keep searching.


The deeper pattern: both systems suffer when they pay for uncertainty too late

A database optimizer is an engineer of restraint. It tries to reduce the amount of work required to answer a question. It does this by using indexes, limiting result sizes, avoiding unnecessary sorting and grouping, and pushing filters as close to the beginning of execution as possible.

That is a powerful idea because it changes the shape of work. If the database can eliminate 99 percent of rows before sorting, grouping, or calculating, the query becomes dramatically faster. If it cannot, every later step becomes more expensive than it needed to be.

This is not just an implementation detail. It reveals a general law: the cost of ambiguity compounds. When a system postpones decisive filtering, every downstream step inherits the burden.

The same pattern appears in learning and decision making. In any environment with multiple choices, there is a tension between exploit and explore. Exploitation uses known, safe choices with predictable payoff. Exploration tests uncertain options that may yield something better. The trap is that both strategies can become pathological. Too much exploitation creates local maxima, a life optimized for yesterday. Too much exploration creates permanent drift, a life that never cashes in what it already knows.

The common thread is not speed alone. It is information ordering. The best systems learn where to spend uncertainty and where to collapse it quickly.

Efficiency is not doing less. Efficiency is deciding earlier what no longer needs to be considered.


SQL execution order is a model of disciplined thought

Most people see query optimization as a technical trick. But it is better understood as a philosophy of sequence.

Suppose you want all active customers in a city who purchased in the last 30 days. A naive query might compute derived values first, sort everything, and then filter. A better query filters by city and recency early, then computes aggregates only on the smaller set. The difference feels small in code, but enormous at scale. The engine is no longer doing expensive work on data that was never going to matter.

Now translate that to reasoning.

Imagine preparing a business decision. You could generate ten metrics, interview fifteen people, build three models, and only then ask whether the opportunity even fits your strategy. Or you could first establish a few high leverage constraints: Does this solve a real pain point? Is the buyer reachable? Can we deliver it profitably? Those constraints function like indexes. They let you eliminate irrelevant territory before you spend time exploring details.

This is the neglected power of searchable questions. A good question is one that can be answered early and cheaply. A bad question is one that forces a full scan of reality.

That is what SARGable thinking looks like outside SQL. It means framing problems so the most informative criteria appear first, while the expensive work comes later, only if needed.

For example:

  • Instead of asking, “What can we build with this technology?” ask, “Which customer problem is urgent enough to justify adoption?”
  • Instead of asking, “How can we improve this process everywhere?” ask, “Where is the bottleneck that determines throughput?”
  • Instead of asking, “Which of these 30 opportunities is best?” ask, “Which 3 survive the strongest constraints?”

The more precisely you filter, the less you confuse motion with progress.


Exploration is expensive, but ignorance is more expensive

If filtering early is so powerful, why not always do it?

Because good systems do not merely minimize work. They also avoid premature certainty.

This is where the second idea enters: the deliberate balance between exploration and exploitation. A person who only uses known strategies may become very efficient at a shrinking game. They accumulate expertise in a narrow range of safe choices, but they may never notice when the world changes. A person who only explores may remain forever interesting and forever underinformed. They are busy sampling possibilities, but they never build stable skill.

The line between these failure modes is subtle. The best performers often spend much of their time, maybe two thirds, deepening a reliable base of safe choices, while reserving the remaining third for new experiments. That ratio is not a law. It is a reminder that mature judgment has both a backbone and a curiosity.

This maps beautifully onto query design.

Sometimes the fastest query is not the one that minimizes all work. Sometimes you need a broader scan because the question itself is underdefined. If you do not know which columns matter, forcing an early index path can be a false precision. In human terms, that is like optimizing a decision before you understand the space of possibilities. You get speed, but only by narrowing too soon.

So the real lesson is not “filter early at all costs.” It is this: filter early when the filters are trustworthy, and explore when the world is not yet legible.

That distinction matters. Mature systems do not confuse uncertainty with openness. They treat exploration as a budgeted investment, not a default state.


A practical framework: the three gates of efficient thinking

The most useful synthesis of these ideas is a simple mental model for deciding when to narrow and when to widen.

1. The relevance gate

Ask: What criteria can remove the most noise with the least cost?

In SQL, this is where indexes matter. A range predicate on an indexed column is powerful because it quickly shrinks the search space. An expression that hides the column from the index is expensive because it delays elimination.

In life or work, relevance gates are the few questions that most strongly determine whether something deserves further attention. These are the questions that should be asked first, not last.

Examples:

  • Does this customer fit our target segment?
  • Is this problem frequent and painful enough to matter?
  • Does this option violate a nonnegotiable constraint?

If a criterion can eliminate 80 percent of the possibilities, it belongs near the front.

2. The uncertainty gate

Ask: What do we not know well enough to filter on yet?

This is where exploration lives. If the environment is changing, if the data is sparse, or if your model is stale, early filtering may harden assumptions into dogma. In those cases, a small, deliberate scan can reveal which variables actually predict success.

This is why skilled people keep a portion of their time for experimentation. They are not being indulgent. They are maintaining the quality of their future filters.

3. The cost gate

Ask: What work becomes expensive if we do it too early?

Sorting huge datasets, computing derived metrics for every row, or joining unneeded tables are the analogues of overthinking. They feel productive because they produce output. But if the output is built on unfiltered noise, it is just sophisticated waste.

In human terms, this is the temptation to elaborate before deciding. We make slide decks, models, and plans long before the core question is settled. The result is more polish on a weaker premise.

When all three gates are used together, you get a disciplined cycle: first shrink uncertainty, then spend effort, then validate with enough exploration to avoid blindness.

The goal is not to choose between efficiency and discovery. The goal is to decide the sequence in which they should appear.


The best minds do not think faster. They waste less attention

There is a romantic idea that brilliance means seeing more, considering more, and holding more complexity in mind. But in practice, the strongest thinkers often do the opposite. They are ruthless about what does not deserve processing.

That is why they seem fast.

A query planner is impressive not because it can do everything, but because it knows what to avoid. It uses structure to skip unnecessary work. It understands that a million-row scan is not inherently bad, but it is wasteful if a few selective conditions can reduce the problem to a thousand rows before the expensive steps begin.

Human expertise works similarly. Experts do not consider every possibility equally. They have internal indexes. They notice which symptoms matter, which signals are weak, which patterns are decoys. Their judgment is not just richer than a novice’s. It is more selective.

This selectivity is often mistaken for intuition, but it is better described as compressed experience. Through repeated exposure, experts learn which questions can be answered early and which require broader exploration. They know when to trust the safe choice and when to probe for a better one.

That is why the old opposition between caution and curiosity is misleading. The real divide is between structured selectivity and undifferentiated attention.

The first one scales. The second one exhausts.


Key Takeaways

  • Filter early whenever possible. Start with the fewest, strongest criteria that can eliminate the most irrelevant options.
  • Do not optimize before the question is legible. If the environment is uncertain, spend some time exploring to discover which variables actually matter.
  • Treat attention like query processing. Expensive work should come after high-signal filters, not before.
  • Balance exploit and explore deliberately. A stable base of known-good choices should fund a smaller but real budget for experimentation.
  • Ask better front-loaded questions. The quality of your early constraints often matters more than the sophistication of your later analysis.

Conclusion: intelligence is mostly about where you stop

We usually picture intelligence as the ability to do more. More analysis, more options, more information, more possibilities. But the deeper pattern across databases and decision making is almost the opposite.

Intelligence is the ability to know where not to spend work.

A fast SQL query is not fast because it runs harder. It is fast because it narrows the problem before expensive operations begin. A wise mind is not wise because it explores everything. It is wise because it knows when to exploit what is already proven, when to explore what is still unknown, and how to frame questions so that irrelevant paths fall away early.

That reframes productivity in a powerful way. The point is not to process more. The point is to reduce unnecessary processing of the wrong things.

In that sense, the best query plan and the best life plan are cousins. Both depend on disciplined restraint, selective curiosity, and the courage to decide, early, what deserves the rest of your attention.

Sources

← Back to Library

Hatch New Ideas with Glasp AI 🐣

Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)

Start Hatching 🐣