Faster NNS canister query?

I noticed that every NNS canister query (e.g. get_neuron_ids, get_neuron_info) using dfx takes like 4 - 6 seconds, much longer than suggested. Yet apps like Dsvcr seems quite smooth for large content.

Any way to optimize those read queries (on client side) ?

You should add --no-wallet arg in the dfx call command

yeah already using --no-wallet flag.

The NNS app is using “update” calls to retrieve data that needs to be trusted, because update calls go through full consensus.
For less critical results, an application’s canisters may allow “query” calls to its public methods, which will currently serve from a single replica on the edge of the network and are very fast, this is what dscvr will be doing in most places. You can write some logic to hide necessary update calls behind clever UI feedback too.

There are solutions for verifying query results too, so the NNS app could possibly change the way it does things at some point.

3 Likes

Thanks Ori! How do I do “query” only calls with dfx?

The query or update call type for each method is set in the canister’s interface, so it’s decided by the developer. I’ve edited the reply above to (hopefully) clarify what’s happening here.

If you try to make a query call to an update method in dfx you’ll get an error. (You can try this using dfx canister call --query …).

1 Like

I’m curious. What are these solutions? Is there any code example for us to learn?

Thanks Ori. --query flag brings down to like ~1sec. Could it goto ~hundred ms level - given no consensus is needed?