question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scalability when many `useQuery` are used

See original GitHub issue

Intended outcome: Using the same useQuery throughout many components should have relatively low performance impact.

Actual outcome: Long task is created when rendering components with many useQuerys.

image

How to reproduce the issue: Reproduction Repo

Versions

  System:
    OS: macOS 12.6
  Binaries:
    Node: 14.18.3 - ~/.nvm/versions/node/v14.18.3/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v14.18.3/bin/yarn
    npm: 8.10.0 - ~/.nvm/versions/node/v14.18.3/bin/npm
  Browsers:
    Chrome: 107.0.5304.121
    Firefox: 99.0.1
    Safari: 16.0
  npmPackages:
    @apollo/client: ^3.7.1 => 3.7.1

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jerelmillercommented, Dec 2, 2022

(sorry to interject)

My guess is it’s probably interacting with the cache often. #10270 mentions the cache as a bottleneck with useQuery and I suspect this is in the same ballpark.

1reaction
dkempnercommented, Dec 1, 2022

@jpvajda it’s not network latency it’s 300ms of CPU time (mosly from Apollo’s cache), since in the template repo all data is local to the Apollo cache.

I use chrome devtools “Performance” tab

image

Hit “record” button and then click the “Click Me” button in my reproduction app, then hit stop recording.

image
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle multiple queries with React-Query
However, I'm struggling to find a good way to query multiple collections for use in a single component. One Query (no problem): const...
Read more >
Multiple queries in a single component with useQuery hook
This seems to be an obvious question, but I'm having a hella time finding an answer. Is it possible to run more than...
Read more >
How and Why You Should Use React Query - Bits and Pieces
The useQuery hook is a function used to register your data fetching code into React Query library. It takes an arbitrary key and...
Read more >
Effective React Query Keys | TkDodo's blog
The most important part is that keys need to be unique for your queries. If React Query finds an entry for a key...
Read more >
Is it possible to call multiple queries with useQuery? #120
Hi, In advance thank you great library. In our product, there is the a page which needs data from 2 or 3 GraphQL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found