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

N+1 Query Problem in api manage/connector-status #3520

Open
t0nem1n opened this issue Dec 20, 2024 · 0 comments
Open

N+1 Query Problem in api manage/connector-status #3520

t0nem1n opened this issue Dec 20, 2024 · 0 comments

Comments

@t0nem1n
Copy link

t0nem1n commented Dec 20, 2024

It appears that there might be an N+1 query problem in the api manage/connector-status. It impacts performance, makes the API slow.

    return [
        BasicCCPairInfo(
            has_successful_run=cc_pair.last_successful_index_time is not None,
            source=cc_pair.connector.source,
        )
        for cc_pair in cc_pairs
        if cc_pair.connector.source != DocumentSource.INGESTION_API
    ]

the line source=cc_pair.connector.source will run the query to get connector.source in the for loop.

I think we can fix it by add a left join to prevent this n+1 query problem.

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