Optimisation
Practical guidance for stable table state, large datasets, and expensive cell rendering.
Overview
Most DataTable performance problems come from the data flow around the table rather than from the renderer itself. The best results usually come from stable inputs, a clear decision about where filtering and searching happen, and virtualization once row counts grow.
Stable Inputs
- Keep
columnsstable withuseMemowhen they contain custom renderers or metadata. - Avoid rebuilding large
dataarrays on every render unless the contents really changed. - Provide
getRowIdwhenever rows already have stable ids. This improves selection, editing, and virtualization behavior.
Choose Where Work Happens
- Use local search and client-side filters for small to medium datasets.
- Move search, filtering, and pagination server-side once network latency is cheaper than repeated browser work.
- Enable only the feature flags you need. Each extra row model adds work.
Keep Cell Renderers Cheap
- Prefer small, pure cell renderers over large components with their own expensive state.
- Use lightweight formatting and memoized lookup data instead of recomputing heavy values per cell.
- Keep inline edit opt-in and column-scoped rather than making every cell editable by default.
Use Virtualisation Deliberately
- Reach for virtualization when row counts are large enough that DOM size becomes the bottleneck.
- Set
virtualRowHeightclose to reality so the virtualizer does less correction work. - Increase
virtualOverscanonly when scroll smoothness needs it. Higher overscan means more rendered rows.
Performance Knobs
| Prop / Pattern | Why It Matters |
|---|---|
getRowId | Preserves stable row identity across sorting, filtering, and virtualization |
enableRowVirtualization | Reduces DOM size for large datasets |
virtualRowHeight | Improves virtualization estimates and reduces layout correction |
virtualOverscan | Trades extra rendering for smoother scroll windows |
useFiltersTanstack({ strategy: "server" }) | Moves expensive filtering out of the browser |
useSearch outside DataTable | Keeps search state and ranking reusable and easier to optimize |