``` function getInputData() { var script = runti...
# suitescript
d
Copy code
function getInputData() {
		var script = runtime.getCurrentScript();
		log.debug({
			'title': 'Governance Monitoring',
			'details': 'Remaining Usage = ' + script.getRemainingUsage()
		});
		var inputData = search.create({
		   type: "item",
		   filters:
		   [

		      ["ispreferredvendor","is","T"], 
		      "AND", 
		      ["isinactive","is","F"]
		   ],
		   columns:
		   [
   		     	search.createColumn({name: "custitem_price_matrix_group", sort: search.Sort.ASC}),
		     	//search.createColumn({name: "vendorcost"})
		   ]
		});
		log.debug({
			'title': 'Governance Monitoring',
			'details': 'Remaining Usage = ' + script.getRemainingUsage()
		});		
		return inputData

	}
m
Hey David,
Just a thought, when I run into issues like this, I sometimes remove the 'ispreferredvendor' logic out of the search
Then i make sure to get it as a column and then use an if statement
in the actual script where you do something with the data
Not sure if that'll help you, but sometimes it runs faster for me that way
d
@Michael Pope I am thinking about this approach, thanks for the input. I am guessing the proper approach is to remove the filter from the query and use the MAP stage to filter on "ispreferredvendor" and execute my business logic during the reduce stage. Is this how you are accomplishing it? Also doesn't this seem to be opposite approach of how to use a database system? I have always pressed performance related filters into a SQL query to enhance application performance.
BTW Thank you for your insight, it has helped me a lot in re-thinking my approach to MR scripts.
m
Actually, to be honest, I haven't used Map Reduce Script much. But I do use it in Mass Update Scripts which are kinda similar
Basically, the idea is this - rater than create a search filter, filter out the records when you call a function on that record.
For example, if you were summing fields, you could just not sum the fields if you wanted to filter the record out
you know, with an if statement
With map reduce... let me take a look for a sec
Looking at it, you'd be right, remove the filter from the query, and use map to filter 'ispreferredvendor'
so you go t it
got it*
Now, most of the time, search filters are better. It's just in this sort of situation they aren't
Best of luck on it!
And yeah, your right, it's the opposite approach
Generally, filters will perform a bit better
however, I'm not sure how Netsuite limits things internally
If concurrency is big, and only 1 thread can access the database at a time, it may be best to do things outside of the database most of the time
I'm not sure what their limits are
sorry, wish I could be of more help