Skip to content

Commit

Permalink
Add index for common prediction query
Browse files Browse the repository at this point in the history
Previously, requests to the `/v1/allocate` endpoint took around 57ms. After adding a composite index that covers the complete spec and the most common query during the prediction algo, we get a large speedup to around 1.3ms per request. While more indices could be added, the returns were diminished and more risky as we don't want to negatively impact the INSERT speed for the jobs table.
  • Loading branch information
cmelone committed Aug 21, 2024
1 parent c0e2977 commit 2c7948a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions gantry/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ async def apply_migrations(db: aiosqlite.Connection):
# they are applied in the correct order
# and not inadvertently added to the migrations folder
("001_initial.sql", 1),
("003_spec_index.sql", 3),
]

# apply migrations that have not been applied
Expand Down
1 change: 1 addition & 0 deletions migrations/003_spec_index.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE INDEX complete_spec on jobs(pkg_name, pkg_variants, pkg_version, compiler_name, compiler_version, end);

0 comments on commit 2c7948a

Please sign in to comment.