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

Connection.prefetch() could handle multi-databases more intelligently #273

Open
jamadden opened this issue Jun 28, 2019 · 0 comments
Open

Comments

@jamadden
Copy link
Member

Right now, in a multi-database, if a user has an iterable of ghost objects, it's up to them to split it up by database so that it gets to the right connection to prefetch:

# sketch
iterable_of_ghosts = get_some_ghosts()
ghost_by_connection = defaultdict(list)
for ghost in iterable_of_ghosts:
    ghost_by_connection[ghost._p_jar].append(ghost)
for conn, ghosts in ghost_by_connection.items():
   conn.prefetch(ghosts)

If they don't do that, the results are anything between "only some data got prefetched" to "it was a bunch of pointless work, because this connection had none of them" to "this connection prefetched them, but they're not from this database, so it pushed a bunch of useful data out of the cache."

It seems like this could be better handled by the prefetch method itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant