-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
enhancementNew feature or requestNew feature or requestgood-first-issueGood for newcomersGood for newcomers
Description
Description
In app/api/auth.py, the create_profile endpoint checks if this is the first user by fetching all existing users from the database:
result = await db.execute(select(User))
existing = result.scalars().all()
is_first_user = len(existing) == 0Impact
As the userbase grows, this will fetch and instantiate ORM objects for every single user in the database just to check if the count is zero, consuming unnecessary memory and database I/O.
Suggested Fix
Replace this with a fast count query, or simply fetch a single user with a limit:
result = await db.execute(select(User.id).limit(1))
is_first_user = result.scalar_one_or_none() is NoneReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood-first-issueGood for newcomersGood for newcomers