Best practices and common pitfalls
Learn how Ninox executes read and write transactions, and how to avoid common performance issues in scripts.
Good Ninox logic does more than return the right result. It should also run predictably, avoid blocking other users, and stay easy to maintain.
Understand transactions in Ninox
Ninox runs database actions as transactions. A transaction groups one or more operations into a single execution step.
In practice, this means Ninox handles reading data and changing data in different ways.
Read transactions
A read transaction looks up data without changing it.
Typical examples are:
filtering records in a table
running a query to find matching records
reading values to display them in the app
When Ninox starts a read transaction, it works with the data state that was current at that moment. Changes saved by other users during that same query are not part of that result.
Ninox can process many read transactions at the same time. One user reading data does not usually block another user from reading data.
Write transactions
A write transaction changes data.
Typical examples are:
creating a record
editing a field value
deleting a record
clicking a button that updates data
running logic that writes values back to the database
Only one write transaction runs at a time. Other write transactions wait until the current one finishes.
That usually is not a problem. Most write transactions finish very quickly.
Automations such as On create and On update run inside the same write transaction that caused them.
Client and server execution
Ninox can execute logic on the client or on the server.
The client is the app running on a user's device. The server handles shared database operations in the background.
Where logic runs depends on what the action needs to do. For most users, the important point is this:
read operations are usually lightweight
write operations must wait their turn
long write operations can slow down other write actions
Why Ninox can feel slow
If Ninox seems slow or briefly unresponsive, a longer write transaction may be blocking the queue.
This happens when one action takes much longer than usual, and later write actions must wait.
Common causes are:
calls to external services, for example with
http(...)large data evaluations combined with
selectcomplex logic inside buttons or automations that updates many records
How to avoid slow write transactions
Keep write logic focused and short.
Use these habits:
read and prepare data first when possible
keep API calls out of critical write flows when possible
avoid repeated
selectqueries inside loopstest buttons and automations with realistic data volumes
split large updates into smaller steps when possible
A practical way to think about it
Use read transactions to inspect data.
Use write transactions only when you need to save a change.
The less work a write transaction has to do, the smoother the app feels for everyone.
Last updated
Was this helpful?