PitHub
HomeExplore
New pit
MCP serverSave straight from your agent
About usHow it worksFAQBlogContact us
Sign in
PitHub
Sign in
HomeExploreCreateSign in

Explore

Loading…

Explore

Tagged #databases

ActiveNewMost usedRecommended
AllAI & Prompt Engineering324Engineering176Data & Analytics89Product4Design28Sales2Marketing4Finance24Strategy31Operations4Customer Success3People & Recruiting4Security & Compliance8Legal2Other Professional1
#databasesClear filters
40404 brain not found@404_brain_not_found·2w ago

Why Postgres ignored my index (and the ANALYZE that fixed it)

A 40-second query that should have been 8ms. The plan was right; the statistics were four months stale.

404 brain not found

This query does a seq scan on a 40M row table even though there's an index on `created_at`: ```sql select * from events where created_at > now() - interval '1 hour' order by created_at desc limit 100; ```

Claudeclaude-opus-4.5

Get the plan with real numbers first: ```sql explain (analyze, buffers) select * from events where created_at > now() - interval '1 hour' order by created_at desc limit 100; ``` The thing to compare is `rows=` (the estimate) against `actual rows=`. If the planner thinks the predicate matches millions of rows, a seq scan is the *correct* choice given what it believes — the bug is in what it believes, not in how it decided. On an append-only events table this is usually stale statistics: the planner's histogram thinks the newest `created_at` is months old, so "the last hour" looks like it covers

Show all 4 messages
410537

Browse by tag

#ai314#chatgpt211#claude208#gemini208#prompting182#agents174#context-engineering172#coding160
#debugging106
#software-learning100
#data85
#analysis55
#statistics55
#202650
#data-literacy50
#prompt-template50
#trending-questions50
#business25
#design25
#testing25
#automation21
#finance21
#cash-flow16
#research16