Why is my t3 app running so slow?

GitHub
GitHub - violetbee/t3-todo-app
Contribute to violetbee/t3-todo-app development by creating an account on GitHub.
25 Replies
cje
cje2y ago
are you using a local database or online?
barry
barry2y ago
Potato pc maybe
Çağlar
Çağlar2y ago
I am using planetscale I know some code blocks are repeating itself but in this case I just wanted to focus how tRPC is working. Dont judgme pls 3070, 5900x is it potato?
cje
cje2y ago
never mind barry lol the reason why it feels slow is you need to wait for the data to travel to the database and back before you're updating the ui
Çağlar
Çağlar2y ago
Is it normal for the data flow to take this long?
cje
cje2y ago
yes if this is a problem, read up on optimistic updates basically you update the ui before you know that the data has been changed in the database and if for some reason the change doesn't happen in the database, you undo the change in the ui
Çağlar
Çağlar2y ago
that is exactly what I want to do if possible can you share the docs please
cje
cje2y ago
Optimistic Updates | TanStack Query Docs
When you optimistically update your state before performing a mutation, there is a chance that the mutation will fail. In most of these failure cases, you can just trigger a refetch for your optimistic queries to revert them to their true server state. In some circumstances though, refetching may not work correctly and the mutation error could ...
cje
cje2y ago
syntax is a bit different in trpc's version of react query but hopefully you can figure it out from this in trpc you get the queryClient with const queryClient = trpc.useContext()
Çağlar
Çağlar2y ago
I see, amazing thank you for help! I am really grateful
julius
julius2y ago
in prod, put your db as close to your server as possible, i.e. if your db is in us-east deploy your app on us-east. if you're using pscale in dev (not entirely sure how it works with their cli) and it's in us-east and you're sitting at home in eu and dev-ing the travelling times will be slow you dont get the queryclient, you get a few helper methods on the proxy, if you need the raw client you should still use the useQueryClient from tanstack directly
Çağlar
Çağlar2y ago
yes, I am using pscale and vercel for prod but I undersand what you mean
julius
julius2y ago
Then verify that your db is close to the lambda
Çağlar
Çağlar2y ago
I'll check it now
Çağlar
Çağlar2y ago
it seems like they are pretty close
Want results from more Discord servers?
Add your server