Is there an ideal order to enter criteria into a s...
# suiteanalytics
g
Is there an ideal order to enter criteria into a saved search to improve the time it takes for the search to run? Specifically when searching system notes? I have a feeling I'm just damned due to what my search is looking for (audit of changes to items for a specific field, in a specific time frame). And while the 1 minute it takes to load doesn't bother me, I can definitely see the users it's being created for having an issue with it.
e
Criteria order shouldn’t matter but if you use OR that would be slower
👍🏻 1
t
@Gregory Jones I know that you asked specifically about this with regards to saved searches, but it is possible to query System Notes using SuiteQL - and the performance is usually pretty good. I wrote about this here: https://timdietrich.me/blog/netsuite-suiteql-system-notes-auditing/ (Scroll down to "Auditing With System Notes.") An example of a query with filters on the record type and a field name would look something like this:
Copy code
SELECT
	Date,
	RecordTypeID,
	BUILTIN.DF( RecordTypeID ) AS RecordType,
	RecordID,
	Field,
	OldValue,
	NewValue,
	Name As EmployeeID,
	BUILTIN.DF( Name ) AS EmployeeName,
	Role,
	BUILTIN.DF( Role ) AS RoleName,
	Context,
	BUILTIN.DF( Context ) AS ContextName
FROM
	SystemNote
WHERE
	( Date BETWEEN To_Date ( '2022-03-16', 'YYYY-MM-DD' ) AND To_Date ( '2022-03-17', 'YYYY-MM-DD' ) )
	AND ( BUILTIN.DF( RecordTypeID ) = 'Transaction' )
	AND ( Field = 'TRANDOC.KSTATUS' )
ORDER BY
	Date DESC
I hope this helps. Good luck!
👍🏻 1
g
I believe in a saved search on a record that is time series based (like system notes, or even transactions), using the time criteria first may help. But you can also be hindered by the fact that system notes are a joined record, so it has to trawl through not just all the relevant primary records, but then all the joined records as well. Then if you use some kind of aggregation it can slow down even further, especially if your grouping with a formula. If you can post your saved search criteria and results configuration, we might be able to provide more input.
g
I honestly think that there is only so much that I can do regarding the setup of the criteria....at the end of the day, I'm also at the mercy of the server. Search was reasonable last night - as said it was about a minute to load. Same search, same amount of results - almost 3 minutes this morning. Client / Network times were similar to what I was seeing last night. Server time was where the slowdown was.
j
In general, the most restrictive criteria first is always a good policy in any system. That's how I order my criteria. Can't say for sure whether it makes a difference, but it feels like it makes a slight difference to me. Avoiding "use expression" (if possible, even if it means adding custom fields to do it) also has a significant impact on search speed as Eric B alluded to. Strip out any unnecessary columns and especially linked fields/joins. Finally if you raze hell with NetSuite support for an extended period of time, they might index a particular table for you to make things run faster (but it breaks every few major updates/hotfixes and then you have to fight them all over again, so just make sure it's worth the time/effort).
👍🏻 1
g
That was my thinking when messing about with it - try to cut down the results as much as possible in the first few lines of the criteria. It seemed to help, but not in a massively significant way. In the end, the users all had specific bits of criteria that conflicted with each other, so I had to split it out into multiple searches instead of having one search for all of them to use (which is my preference, but we can't always get what we want, can we?)