Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review ORM classes and generated SQL queries for improvements #448

Open
leafty opened this issue Oct 9, 2024 · 0 comments
Open

Review ORM classes and generated SQL queries for improvements #448

leafty opened this issue Oct 9, 2024 · 0 comments

Comments

@leafty
Copy link
Member

leafty commented Oct 9, 2024

For a example to retrieve a single project, this is what sqlalchemy generates:

INFO     sqlalchemy.engine.Engine:base.py:2701 BEGIN (implicit)
INFO     sqlalchemy.engine.Engine:base.py:1846 SELECT projects.projects.id, projects.projects.name, projects.projects.visibility, projects.projects.created_by_id, projects.projects.description, projects.projects.keywords, projects.projects.creation_date, projects.projects.updated_at, groups_1.id AS id_1, groups_1.name AS name_1, groups_1.created_by, groups_1.creation_date AS creation_date_1, groups_1.description AS description_1, users_1.keycloak_id, users_1.first_name, users_1.last_name, users_1.email, users_1.secret_key, users_1.id AS id_2, namespaces_1.id AS id_3, namespaces_1.slug, namespaces_1.group_id, namespaces_1.user_id, project_slugs_1.id AS id_4, project_slugs_1.slug AS slug_1, project_slugs_1.project_id, project_slugs_1.namespace_id 
FROM projects.projects LEFT OUTER JOIN projects.project_slugs AS project_slugs_1 ON projects.projects.id = project_slugs_1.project_id LEFT OUTER JOIN common.namespaces AS namespaces_1 ON namespaces_1.id = project_slugs_1.namespace_id LEFT OUTER JOIN common.groups AS groups_1 ON groups_1.id = namespaces_1.group_id LEFT OUTER JOIN users.users AS users_1 ON users_1.keycloak_id = namespaces_1.user_id 
WHERE projects.projects.id = $1::VARCHAR
INFO     sqlalchemy.engine.Engine:base.py:1846 [generated in 0.00021s] ('01J9RH5JSX13FPPND9B2EX719C',)
INFO     sqlalchemy.engine.Engine:base.py:1846 SELECT projects.projects_repositories.project_id AS projects_projects_repositories_project_id, projects.projects_repositories.id AS projects_projects_repositories_id, projects.projects_repositories.url AS projects_projects_repositories_url 
FROM projects.projects_repositories 
WHERE projects.projects_repositories.project_id IN ($1::VARCHAR)
INFO     sqlalchemy.engine.Engine:base.py:1846 [generated in 0.00028s] ('01J9RH5JSX13FPPND9B2EX719C',)
INFO     sqlalchemy.engine.Engine:base.py:2704 ROLLBACK

We can see that we should eagerly fetch from projects.projects_repositories since the repository list is immediately needed in dump().

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

No branches or pull requests

1 participant