The weird thing about learning programming:
You can feel completely lost for 6 days straight...
Then suddenly one bug fix makes the last 6 days make sense.
Learning to code isn't linear.
It's confusion stacking until your brain finally connects two wires.
Which is also why tutorials feel productive right before reality punches you in the face.
THIS QUERY RETURNS DUPLICATES.
SELECT DISTINCT user_id
FROM orders
ORDER BY created_at;
Why?
Because DISTINCT only applies to the columns you select.
You're selecting:
user_id
But ordering by:
created_at
Now the database has a problem:
Which created_at should it use for each unique user_id?
A user can have multiple orders.
Which timestamp wins?
Some databases reject this query completely.
Others return results that look random enough to ruin your afternoon.
What you probably wanted was:
SELECT DISTINCT ON (user_id)
user_id,
created_at
FROM orders
ORDER BY user_id, created_at DESC;
That gives you:
"latest order per user"
SQL gets weird fast once you combine:
- DISTINCT
- ORDER BY
- GROUP BY
And ORMs make it worse because now the broken query is hiding behind:
.distinct().order_by()
...which somehow passed code review.
What will this return?
SELECT COUNT(NULL), COUNT(1), COUNT(*);
Most developers get at least one of these wrong.
Output:
0 | total_rows | total_rows
Why?
COUNT(NULL)
β counts non-null values
β NULL is always NULL
β result: 0
COUNT(1)
β counts every row because 1 is never NULL
β result: total row count
COUNT(*)
β also counts every row
β result: total row count
So this:
COUNT(1)
and this:
COUNT(*)
are effectively the same in modern databases.
The real trap is this:
COUNT(column_name)
That only counts rows where the column is NOT NULL.
I've seen analytics dashboards quietly undercount users for months because someone wrote:
COUNT(email)
instead of:
COUNT(*)
NULLs don't throw errors.
They just lie quietly.
People think motivation comes first.
It doesn't.
You start learning because you're excited.
You continue learning because you're frustrated.
And eventually you keep learning because you've seen what happens when you stop.
The best developers I know aren't motivated every day.
They're just deeply allergic to staying stuck.
That's the real fuel behind most late-night debugging sessions.
Not passion.
Pain.
Your microservices architecture has 40 services.
One user request touches 28 of them.
Are you happy with this design?
Or did you accidentally reinvent a distributed monolith with extra network latency?
Every service call adds:
- retries
- timeouts
- tracing noise
- deployment coordination
- another place for auth to break at 2am
I've seen "microservices" where a single feature needed:
Kafka β API Gateway β Auth β User β Billing β Notification β Analytics β 11 more services nobody wanted to own.
The diagrams looked incredible.
The p99 latency did not.
Most teams don't need microservices.
They need better module boundaries inside a monolith and one database query that isn't committing war crimes.
The hard part isn't splitting services.
It's reducing coupling after you split them.