What is a dependency chain?

Could anyone explain to me what dependency chains are and how I am supposed to minimize them? How do I measure their length, if there is such a thing?

I have lots of components in a monolithic app and the new performance tab of the debug console says there is a problem. [see below]

It's apparently important, as described in the Retool documentation here

"... Avoid querying large datasets
Minimize long dependency chains
Put complex logic in workflows or backends ... "

ChatGPT 4 agrees:

"Understanding and managing these dependency chains is crucial for creating efficient, maintainable, and scalable Retool applications."

But I can't work out how to find these chains or fix them. It makes the new performance stats less useful than they would otherwise be.

Hi @stewart.anstey, here is a great definition from deepsource:

"A dependency graph is a data structure formed by a directed graph that describes the dependency of an entity in the system on the other entities of the same system. The underlying structure of a dependency graph is a directed graph where each node points to the node on which it depends."

In the context of Retool, think of how your app is connected to components, and how those are connected to queries. This connection between nodes can grow extensively. For example, a query can be connected to another query that runs on success, and the response of the latter query can update the text of a button. When we click the button, we may run another query, and so on.

The more dependencies, the more risk for slowdowns, specially when there is an extensive chain of queries that are being ran one after another.

Here is our doc on performance best practices. Having lots of components is a sign we could break our application into two or more, each app can send necessary data to another app by using query params.

I also recommend this amazing article from @stefancvrkotic and @sophie that goes into great detail on how to improve performance in Retool.

Happy building! :hammer_and_pick: