Stop rebuilding the tool_calls primary key on every boot - #159
Closed
salluexez wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Postgres startup schema migration for tool_calls to avoid rebuilding the tool_calls primary key index on every boot by only applying the PK change when it appears to be needed.
Changes:
- Replaces unconditional
DROP CONSTRAINT/ADD PRIMARY KEYfortool_calls_pkeywith a conditionalDO $$ ... $$block that inspectsinformation_schemafirst.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+76
to
+80
| `DO $$ | ||
| BEGIN | ||
| IF EXISTS ( | ||
| SELECT 1 FROM information_schema.constraint_column_usage | ||
| WHERE table_name = 'tool_calls' AND constraint_name = 'tool_calls_pkey' AND column_name = 'run_id' |
Collaborator
|
Fixed on our side, going out shortly with you as co-author on the commit 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace unconditional
ALTER TABLE tool_calls DROP CONSTRAINT/ADD PRIMARY KEYon startup with a conditionalDO $$block insrc/runs/postgres-run-store.tsthat checksinformation_schema.constraint_column_usagefirst. This prevents taking anACCESS EXCLUSIVElock and rebuilding the primary key index on every application boot.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.