Skip to content

SuiteScript Performance: The Fixes We Make Most Often

The SuiteScript changes that most often make NetSuite scripts faster and cheaper on governance: fewer record loads, better searches, the right script type, and how to measure.

Stenbase Team · February 2, 2026 · 10 min read

SuiteScript Performance: The Fixes We Make Most Often

Slow SuiteScript usually comes down to a few patterns. A user event script loads the same customer record for every line on an order. A scheduled script runs out of governance halfway through a batch. A client script runs a search on every field change, so the form lags while the user types.

None of these need clever tricks. They need less work per record, done in the right place.

Know what each call costs

NetSuite charges governance units for API calls and caps the units each script can use. A few numbers to keep in mind:

CallTransactionCustom recordOther records
record.load1025
record.submitFields1025
record.save20410
search.lookupFields111

A user event script gets 1,000 units. A scheduled script gets 10,000. In a Map/Reduce script, each map call gets 1,000 and each reduce call gets 5,000. Check Oracle's governance documentation for the method you're using before you rely on a number.

You can log what's left at any point:

const remaining = runtime.getCurrentScript().getRemainingUsage();
log.debug({ title: 'Units left', details: remaining });

Log it at the start and end of each batch, not on every row.

Read fields without loading records

The single most common fix. If you need three fields from a sales order, don't load the whole record:

// 10 units, plus the time to load every field and sublist
const so = record.load({ type: record.Type.SALES_ORDER, id: orderId });
const status = so.getValue('status');

// 1 unit
const fields = search.lookupFields({
  type: search.Type.SALES_ORDER,
  id: orderId,
  columns: ['status', 'entity'],
});

The same goes for writes. To update body fields, record.submitFields costs half of a load plus a save on a transaction, and it skips loading sublists you don't touch.

Search once, not once per line

Loading or looking up a record inside a loop is the pattern that eats governance fastest. Collect the IDs first, then run one search:

const itemIds = lines.map((line) => line.item);

const results = search.create({
  type: search.Type.ITEM,
  filters: [['internalid', 'anyof', itemIds]],
  columns: ['itemid', 'custitem_lead_time'],
}).run().getRange({ start: 0, end: 1000 });

Ask for only the columns you need and put the filtering in the search, not in JavaScript after the results come back. For complex joins, SuiteQL through N/query is often simpler to write and faster to run than a saved search.

For more than 1,000 results, use search.runPaged(). Sort by a unique field like internal ID. Without a stable sort, rows can repeat or go missing between pages.

Put work in the right script type

User events run while someone waits for a record to save. Keep them short. Exit early when the event type doesn't need the logic:

function afterSubmit(context) {
  if (context.type !== context.UserEventType.CREATE) return;
  if (runtime.executionContext === runtime.ContextType.CSV_IMPORT) return;
  // ...
}

If the work doesn't need to finish before the save completes, queue it. A Map/Reduce or scheduled script started with N/task keeps the user from waiting.

Client scripts run in the browser. A search in fieldChanged runs on every change. Load reference data once in pageInit, or call one Suitelet or RESTlet that returns everything the form needs.

Map/Reduce fits batch work that splits into independent pieces, like one key per customer or per order. NetSuite handles yielding and parallel processing for you. Make each piece safe to retry, and log failures with enough detail to rerun them. For small jobs, a plain scheduled script is easier to read and debug.

SuiteCommerce services run SuiteScript on shopper requests. Every unit and every millisecond there adds to page load time. Keep those services small, and move anything that can run ahead of time into a scheduled script that saves its results.

Cache what doesn't change often

N/cache saves the result of an expensive lookup, like a configuration record or a tax table, so the next run can skip it. Include every input that affects the answer in the cache key, set a sensible TTL, and write the code to handle a cache miss. Never cache customer-specific or permission-sensitive data under a shared key.

Measure before and after

For each slow script:

  1. Record the deployment, input size, time taken and units used.
  2. Find the repeated or expensive call in the execution log.
  3. Change one thing.
  4. Run the same input in a sandbox.
  5. Compare time and units, and check that the records it produced are still correct.

Oracle's Application Performance Management SuiteApp shows script timing across the account, which helps when you don't know which script is the slow one.

If a script is holding up your team, our SuiteScript development service covers performance reviews.

Tags: SuiteScript, Performance Optimization, Governance, Map/Reduce, NetSuite Development, SuiteQL

Need help with your SuiteCommerce store?

Talk to the developers who wrote this article. The first call is free.

Related articles