512MB memory limit in an automation script

I am trying to run the following script:

const tableDeals = base.getTable("Deals")
const queryDeals = await tableDeals.selectRecordsAsync()

And I am getting an error “Your script exceeded the 512MB memory limit.”.

Though the Deals table has only about 3500 records and weighs about 4 MB. What am I doing wrong and how can I fix this? Thanks!

1 Like

Do you have any updates from Airtable about this @Sergey_Filimonov ?

The selectRecordsAsync method automatically collects all fields from all records. This a) takes more processing time for large tables, and b) could potentially eat a lot of memory with high record counts and lots of fields and data. It’s best to only collect the fields needed later in the script. This is done by passing an object to selectRecordsAsync with a “fields” property that contains an array of field names.

const queryOrders = await base.getTable("Orders").selectRecordsAsync({
    fields: [
        "Field Name 1",
        "Field Name 2"
    ]
})

Only those field names listed can be used later in the script for things like getCellValues, etc.

2 Likes

This worked like a charm. Thank you!

1 Like