# SuiteScript Scheduled Script Run Count Calculator

> Source: https://netray.co/tools/suitescript-scheduled-script-run-count-calculator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Estimate total governance units, records per run, number of reschedules and total runtime for a scheduled script before you write it.

## Category

netsuite

## Erp

NetSuite

## Audience

- SuiteScript developer
- NetSuite consultant

## Tool

**Kind:** calculator

**Inputs:**

#### Records to process

**Key:** records

**Type:** number

**Default:** 25000

**Min:** 1

**Step:** 500

**Unit:** records

#### Governance units per record

**Key:** units_per

**Type:** number

**Default:** 12

**Min:** 1

**Step:** 1

**Unit:** units

**Help:** Sum of API unit costs for everything you do per record: load, field set, save, lookup.

#### Governance limit per run

**Key:** limit

**Type:** number

**Default:** 10000

**Min:** 100

**Step:** 100

**Unit:** units

**Help:** Scheduled scripts have a per-run governance allowance. Confirm it in the current NetSuite help.

#### Reserve kept for wrap-up

**Key:** reserve

**Type:** number

**Default:** 200

**Min:** 0

**Step:** 50

**Unit:** units

**Help:** Units you hold back to save state and reschedule safely.

#### Seconds per record

**Key:** sec_per

**Type:** number

**Default:** 0.6

**Min:** 0.01

**Step:** 0.05

**Unit:** seconds

#### Queue gap between runs

**Key:** gap_min

**Type:** number

**Default:** 2

**Min:** 0

**Step:** 1

**Unit:** minutes

**Help:** Time a rescheduled deployment waits before starting.

**Outputs:**

#### Total governance units

**Key:** total_units

**Expr:** records * units_per

**Format:** integer

#### Usable units per run

**Key:** usable

**Expr:** max(limit - reserve, 0)

**Format:** integer

#### Records per run

**Key:** recs_per_run

**Expr:** floor(usable / units_per)

**Format:** integer

**Primary:** true

#### Runs required

**Key:** runs

**Expr:** ceil(records / max(recs_per_run, 1))

**Format:** integer

**Primary:** true

#### Processing time

**Key:** proc_min

**Expr:** records * sec_per / 60

**Format:** minutes

#### Elapsed time including queue gaps

**Key:** elapsed

**Expr:** proc_min + max(runs - 1, 0) * gap_min

**Format:** minutes

**Chart:**

#### Runs required vs records processed

**Type:** line

**X:** records

**From:** 1000

**To:** 100000

**Steps:** 30

**Series:**

- runs

**Disclaimer:** Unit costs vary by API call and record type. Measure with runtime.getCurrentScript().getRemainingUsage() in a sandbox before committing to these numbers.

## Content

**Intro:** A scheduled script that works on 500 records in testing can quietly stop at record 800 in production because it ran out of governance units. This calculator tells you how many runs a given volume needs so you can design the yield or reschedule logic up front.

**Sections:**

#### How to use it

**Body:** Count the API calls your script makes for one record: a record.load, several setValue calls, a save, perhaps a search.lookupFields. Add their unit costs from the NetSuite help to get units per record. Enter your expected record count and the per-run limit. Keep a reserve so the script can write its state and reschedule before it hits zero. The calculator returns how many records fit in a run, how many runs you need and the elapsed time including the queue gap between reschedules.

#### The math

**Body:** Usable units equal the limit minus the reserve. Records per run equal usable units divided by units per record, rounded down. Runs equal total records divided by records per run, rounded up. With 12 units per record, 10,000 units and a 200 unit reserve, each run handles 816 records, so 25,000 records need 31 runs. That is a strong signal to consider a map/reduce script, which spreads work across many small governed jobs instead of one long chain.

**Bullets:**

- Usable = limit - reserve
- Records per run = floor(usable / units per record)
- Runs = ceil(records / records per run)
- Elapsed = processing time + queue gaps between runs

#### Reading the output

**Body:** If runs is 1 you have no rescheduling logic to build, but keep a check on remaining usage anyway because data volumes grow. If runs is between 2 and about 10, a scheduled script with a saved cursor works well. Beyond that, elapsed time is dominated by queue gaps and a single failed run can strand a long chain, so map/reduce or splitting the work by subsidiary or date range is usually the better design.

#### Common mistakes

**Body:** The most frequent error is counting only the obvious calls. Transaction loads and saves cost far more units than a simple search, and sublist operations add up. The second is rescheduling without persisting the last processed internal ID, which reprocesses records. The third is ignoring script timeouts: a script can fail on time before it fails on units.

**Bullets:**

- Log getRemainingUsage at start, mid-run and end in a sandbox
- Persist a cursor such as the last internal ID
- Make the processing idempotent so a restart is safe
- Use submitFields instead of load and save where possible

**Cta:** If you have long running scheduled scripts that are fragile, Netray can help review them and plan a migration to map/reduce.

**Faq:**

#### What is the governance limit for a scheduled script?

**Answer:** Scheduled scripts have a fixed governance allowance per execution, and the value has changed between releases and script versions. Use the current NetSuite help for your SuiteScript version and enter it in the calculator.

#### How do I find units per record?

**Answer:** Add up the documented unit costs for each API call in your per-record code, or run a small sample in a sandbox and log the difference in remaining usage before and after one record.

#### When should I use map/reduce instead?

**Answer:** When the volume needs more than a handful of runs, when records are independent, or when you want parallel processing and built-in restart handling. Map/reduce governs each stage invocation separately.

#### Does the reserve matter?

**Answer:** Yes. If you spend every unit on records, the script has nothing left to save its cursor or reschedule, and the next run cannot continue where this one stopped.

## Search terms

suitescript scheduled script governance, suitescript 10000 units scheduled script, netsuite scheduled script yield reschedule, suitescript governance usage calculator, netsuite scheduled script runtime estimate, scheduled script vs map reduce

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
