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
cje3y ago
are you using a local database or online?
barry
barry3y ago
Potato pc maybe
Çağlar
ÇağlarOP3y 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
cje3y 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ğlarOP3y ago
Is it normal for the data flow to take this long?
cje
cje3y 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ğlarOP3y ago
that is exactly what I want to do if possible can you share the docs please
cje
cje3y 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
cje3y 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ğlarOP3y ago
I see, amazing thank you for help! I am really grateful
julius
julius3y 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ğlarOP3y ago
yes, I am using pscale and vercel for prod but I undersand what you mean
julius
julius3y ago
Then verify that your db is close to the lambda
Çağlar
ÇağlarOP3y ago
I'll check it now
Çağlar
ÇağlarOP3y ago
it seems like they are pretty close
julius
julius3y ago
and they feel slow in prod? or is it just in dev, if so, where are you located in dev?
Çağlar
ÇağlarOP3y ago
if possible can you try it yourself? I wonder how slow it comes to you https://t3todoapp.caglark.dev/
Todo App
Generated by create-t3-app
Çağlar
ÇağlarOP3y ago
in dev, its in Turkey
julius
julius3y ago
yea so then you gotta consider that your server is on your local computer, but your db is in us-east so there will be latency you can use mysql in a docker container in dev so that your data don't have to travel between turkey and us-east
julius
julius3y ago
prod's pretty snappy if u ask me
Çağlar
ÇağlarOP3y ago
can you add todo and change the check state
julius
julius3y ago
Çağlar
ÇağlarOP3y ago
Thank you, I think I am considering too much I would like to ask one more question How did you create the gif? it looks pretty cool
julius
julius3y ago
cleanshot
Want results from more Discord servers?
Add your server