# Performance Guide

Avonni Dynamic Components are fast by default. This guide helps you keep them that way as your components grow in complexity.

## Three Rules That Matter Most

### **1. Fetch data once, pass it down**

* Parent components should query Salesforce
* Child components receive data through resources
* Avoid multiple components querying the same data independently

### **2. Only load what you need**

* Use specific filters in your queries (e.g., RecordType, Status, Date Range, etc.).
* Show/hide sections with conditional visibility instead of loading everything upfront
* Consider if data needs to load immediately or can wait for a user action

### **3. Keep structures simple**

* Flat component structures perform better than deeply nested ones
* Use specialized components ([Data Table](https://docs.avonnicomponents.com/dynamic-components/components/data-table), [Tree](https://docs.avonnicomponents.com/dynamic-components/components/tree)) for complex data instead of nesting multiple Dynamic Components
* If you're nesting more than 2-3 levels deep, there's usually a more straightforward way

***

## Common Performance Mistakes

❌ **Each nested component runs its own "On Load" query** This creates a cascade of queries that slows everything down.

✅ **Parent fetches data, passes subsets to children via resources** One query, multiple components use the results.

***

❌ **Loading all 50 columns in a Data Table by default** Most users only need 5-7 key fields initially.

✅ **Show essential columns, reveal details on-demand** Use [Open Flow Panel](https://docs.avonnicomponents.com/dynamic-components/component-builder/interactions/flow-builder-integration/open-flow-panel) or [Open Dynamic Component Panel](https://docs.avonnicomponents.com/dynamic-components/component-builder/interactions/dynamic-component-control/open-dynamic-component-panel) for full record details.

***

❌ **Component A updates Component B, which updates Component A** Creates infinite loops or excessive re-rendering.

✅ **Design one-way data flows** Parent → Child communication through resources, Child → Parent through events.

***

## When to Optimize

You probably have a performance issue if:

* Components take more than 2-3 seconds to load
* Users see multiple loading spinners in sequence
* Browser Network tab shows 10+ Salesforce queries for one page load

**Use Browser Developer Tools (Network tab)** to see what's actually happening. If you're seeing dozens of requests or slow queries, that's your starting point.

***

## Need Help?

Many Trailblazers in our [**Community Group**](https://trailhead.salesforce.com/trailblazer-community/groups/0F9KX000000iFxO0AU?tab=discussion\&sort=LAST_MODIFIED_DATE_DESC) have tackled these exact challenges. They share:

* Network tab screenshots with diagnostic help
* Before/after architecture improvements
* Query patterns for large datasets
* What actually worked in production environments

[**Join the Community**](https://trailhead.salesforce.com/trailblazer-community/groups/0F9KX000000iFxO0AU?tab=discussion\&sort=LAST_MODIFIED_DATE_DESC) | Direct questions: <support_dc@avonni.app>
