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

is the default gcTime of 5 minutes too long? #9

Open
thomasballinger opened this issue Oct 29, 2024 · 4 comments
Open

is the default gcTime of 5 minutes too long? #9

thomasballinger opened this issue Oct 29, 2024 · 4 comments

Comments

@thomasballinger
Copy link
Collaborator

thomasballinger commented Oct 29, 2024

With @convex-dev/react-query the default gcTime of 5 minutes [edit: maybe] isn't appropriate because it means continuing to receive updates for a query for 5 minutes. This could be a problem especially if e.g. subscribing to a new query on keystroke, but even in normal cases it's potentially a lot of extra function executions for queries that update frequently.

@thomasballinger
Copy link
Collaborator Author

Maybe two solutions are needed:

  1. change the default: convexQuery() should use a gcTime of 30 seconds?
  2. limit how many subscriptions to retain? We've talked about doing this per hook, when the arguments of a useQuery() hook change that should immediately invalidate the old one.

@thomasballinger thomasballinger changed the title gcTime of 5 minutes is too long is the default gcTime of 5 minutes too long? Nov 5, 2024
@thomasballinger
Copy link
Collaborator Author

The argument in the other direction is generally TanStack Query has more aggressive defaults (like refreshing every query when the tab becomes active again) and once you start to tweak for performance and costs you dial these down, so something aggressive is nice. And that this way global changes to the default gcTime will be reflected in queries https://tanstack.com/query/latest/docs/framework/react/guides/important-defaults#:~:text=By%20default%2C%20"inactive"%20queries,1000%20*%2060%20*%205%20milliseconds.

@mez
Copy link

mez commented Nov 8, 2024

I think a decent stop gap is to update the document with a Defaults section that describes the use case and let the user think about changing the gcTime! What "cache" actually means etc.

@thomasballinger
Copy link
Collaborator Author

Here's where that might go, plus the README here https://docs.convex.dev/client/tanstack-query#differences-from-using-fetch-with-tanstack-query

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

2 participants