Skip to content

Add indexes for active builds and build history - #842

Merged
pablogsal merged 1 commit into
python:mainfrom
pablogsal:fix-build-history-indexes
Nov 20, 2026
Merged

pablogsal merged 1 commit into
python:mainfrom
pablogsal:fix-build-history-indexes

Conversation

@pablogsal

Copy link
Copy Markdown
Member

A request for active builds read about 1.36 million rows to find 52 builds and took 383 ms. Add indexes for active builds and for builder and worker history so the database can find those rows with less work.

Parallel Seq Scan on builds
  Filter: (complete_at IS NULL)
  Rows Removed by Filter: 452019
Execution Time: 383.269 ms

@pablogsal

Copy link
Copy Markdown
Member Author

CC @zware

@pablogsal
pablogsal merged commit 41c33c5 into python:main Nov 20, 2026
1 check passed
@vstinner

Copy link
Copy Markdown
Member

Oh nice! How did you notice that a SQL query was so slow?

@zware

zware commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Indexes deployed manually (cat /srv/buildbot/utils/database-indexes.sql | psql -h <host> -p <port> <database> <user>):

Timing is on.
CREATE INDEX
Time: 734.747 ms
CREATE INDEX
Time: 3503.043 ms (00:03.503)
CREATE INDEX
Time: 3144.713 ms (00:03.145)

@pablogsal

Copy link
Copy Markdown
Member Author

@vstinner I took stack samples during a slow dashboard refresh and saw repeated waits on the Buildbot data API. Then I ran EXPLAIN ANALYZE on the queries behind those calls. The active-build lookup scanned about 1.36 million rows to return only 52 builds, so I checked the indexes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants