👋 Hey friends,

Here’s what I’ve got for you this week:

  • Another snippet from The Backend Lowdown

  • Recent post highlights: AI tips & Ralph Wiggum Loop Intro

  • Personal news: site redesign

Let’s get into it 👇

Every newsletter will include a snippet from my book in progress, The Backend Lowdown, available for $5 right now on Gumroad!

Get The Backend Lowdown →

Chapter 2: Indexing, Query Planning, and Performance

Composite and Partial Indexes: Tools with Sharp Edges

When a single-column index doesn't cut it, you've got two advanced options: composite and partial indexes. These aren't exotic - they're powerful, common tools that can dramatically improve performance if used well. But they come with tradeoffs.

Keep them in your toolbox - just don't reach for them blindly.

Composite Indexes

A composite index covers multiple columns, in a specific order:

CREATE INDEX ON orders (user_id, created_at);

This index is useful when your query filters or sorts by both columns - or when it starts with user_id. But here's the catch:

The order matters.
Postgres can use this index for:

  • WHERE user_id = ?

  • WHERE user_id = ? AND created_at > ?

But not for:

  • WHERE created_at > ? (by itself)

Warning

Composite indexes often get created based on a single query, but then go unused because other queries filter on the columns in a different order.

Partial Indexes

A partial index applies to only a subset of the table, based on a condition:

CREATE INDEX ON users (last_login_at) WHERE suspended = false;

Used well, they're lightweight and fast - perfect when you only care about a slice of your data.

Use case: You often query only active users, and don't need an index that covers suspended ones.

Pitfall #1:
Your query must exactly match the predicate (WHERE suspended = false) - otherwise the index won't be used.

Pitfall #2:
Stats and usage tracking (pg_stat_user_indexes) may be misleading - if the predicate isn't common, it may show up as "unused" even when it's working exactly as intended.

AI Content

You may have seen a few of my recent posts which cover AI. It’s a new type of content I’m exploring alongside my usual backend content. Two of those recent posts covered some AI tips, so I wanted to include them here:

Tips

Here are a few tips from one of the videos:

  1. First: when an agent does exploration, have it write down its findings in a markdown file.

    Seriously. If it goes spelunking through a codebase, docs, or tickets and learns something useful, save that somewhere. Otherwise, next time, you’re paying for the same discovery work all over again.

  2. Second: watch your context overhead.

    A lot of people think they’re sending a tiny prompt, but they’ve got tools, integrations, MCPs, and system instructions quietly bloating the context. So what feels like a lightweight call might already be starting thousands of tokens deep.

You can watch the full video here:

@stevencodes.swe

Here are 3 AI workflow tips everyone should know by now. Seriously, check your context! Limits and compaction matter! #techtok #coding #so... See more

Wiggum Loop

My favorite recent video covers a topic that still doesn’t seem widely known: the Ralph Wiggum Loop.

At its core, Ralph is basically just: give the agent a goal, let it try, see what happened, and if the task isn’t truly done, run it again.. over and over until the work is actually complete.

There are a lot of benefits to using the Ralph Loop. It can make implementation more economical, let the agent operate more autonomously, and help it work through long-running tasks without being as vulnerable to compaction issues.

That said, there are a few drawbacks to watch out for:

  1. If the prompt is bad, the implementation will be too. I recommend building in phases and checking in after each phase is complete so you don’t let things go too far off course before you have a chance to correct them.

  2. Cost is another big one. Put safeguards in your script: things like a max turn count and overall cost limits. That way, if the agent gets stuck in a loop, it won’t keep looping forever and quietly rack up unnecessary compute and token usage.

If there’s interest, I’ll share out my current script. It’s not in perfect shape but it works pretty well for me. You can watch the full video here:

Instagram post

Site Redesign

I recently took a stab at re-designing my site: https://www.stevencodes.dev/

I wanted to retain the same structure / format, but thought it could use a little TLC. 🙂

That’s a wrap for this week. If something here made your day smoother, feel free to reply and tell me about it. And if you think a friend or teammate would enjoy this too, I’d be grateful if you shared it with them.

Until next time,
Steven

Keep Reading