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
are you using a local database or online?
Potato pc maybe
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?
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
Is it normal for the data flow to take this long?
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
that is exactly what I want to do
if possible can you share the docs please
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 ...
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()
I see, amazing thank you for help!
I am really grateful
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 directlyyes, I am using pscale and vercel for prod but I undersand what you mean
Then verify that your db is close to the lambda
I'll check it now
it seems like they are pretty close
and they feel slow in prod? or is it just in dev, if so, where are you located in dev?
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
in dev, its in Turkey
GitHub
feat: add unstable_overrides to next by juliusmarminge · Pull Reque...
let these options be defined in createTRPCNext too
ref: https://discord.com/channels/867764511159091230/1032031459852156938
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
prod's pretty snappy if u ask me
can you add todo and change the check state
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
cleanshot