In the `/services/rest/query/v1/suiteql` endpoint ...
# suitescript
m
In the
/services/rest/query/v1/suiteql
endpoint in the REST API... if you have a big SQL statement and you want to optimize it, what are the existing options? Our client wants to fetch the data of some transactions for the last 5 months. And fetching one day takes around 2 hours.
t
If RESTlets are an option for you, then you can use the N/query module to pull up to 5,000 rows per request. That should help a little. Also, I've found that RESTlets generally tend to be faster, and the resulting payloads are more streamlined (and much easier to consume, too). If you need an example of a RESTlet that can handle SuiteQL queries, there's the SuiteQL Query API ( https://timdietrich.me/blog/netsuite-suiteql-query-api/ ) as well as SuiteAPI ( https://suiteapi.com ). Also, if this is something that your client is going to want to do long term, then you might want to look into SuiteAnalytics Connect (which is NetSuite's ODBC, JDBC, and ADO.NET offering). It costs extra (I believe it's currently priced at $500 / month). But if you need it, it's well worth the cost. As a side note, I've built SuiteAnalytics Connect support into the upcoming Suite.js runtime (https://suitejs.io), and I'm finding it to be insanely fast. For example, in one test, I was able to fetch the headers and lineitems for more than 10,000 sales orders in 2 minutes and 38 seconds. I recently wrote about all of this here: https://timdietrich.me/blog/suitejs-update-20240521/
e
How many rows is one day of transaction? How many columns do you retrieve? How many joins are in the query?
m
Sorry for the late reply. Thanks @tdietrich, I tried the RESTlet option, but it produces many errors similar to this
Field 'amount' for record 'transactionLine' was not found. Reason: NOT_EXPOSED
@Edgar Valdes It is about 60k rows, 23 columns and one join. We also use a lot of functions like REGEXP_REPLACE, ABS, BUILTIN.DF and CONCAT.
So it turned out that creating a saved search with the same columns then exporting the data is way faster than using the REST API or a RESTlet.