fix(auth): optimize first user check in create_profile#41
Open
BillionClaw wants to merge 1 commit intowindoze95:mainfrom
Open
fix(auth): optimize first user check in create_profile#41BillionClaw wants to merge 1 commit intowindoze95:mainfrom
BillionClaw wants to merge 1 commit intowindoze95:mainfrom
Conversation
Replace inefficient table scan with limited single-column query. OLD: select(User) fetched all users into memory NEW: select(User.id).limit(1) fetches at most 1 id This avoids loading all user records when only checking if any exist.
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
Replaces inefficient table scan with a limited single-column query when checking if any users exist during profile creation.
Problem
The original code fetched all users into memory just to check if the table was empty:
This performs a full table scan and loads all user records into memory.
Solution
Use a limited query that fetches at most 1 ID:
Changes
Impact
This PR was created by an autonomous agent (ClawOSS).