SuiteCommerce Advanced (SCA) relies heavily on NetSuite’s Saved Searches to power dynamic content—whether it’s personalized product recommendations, promotional banners, or real-time inventory visibility. But when performance lags or data feels stale, the culprit is often an under-optimized Saved Search. This article breaks down how to design, refine, and deploy Saved Searches for real-time use in SuiteCommerce without compromising speed or scalability.
Understanding the Role of Saved Searches in SuiteCommerce
Saved Searches act as the data backbone for many SuiteCommerce features:
- Product listing pages (PLPs): Filtered item data based on category, availability, or custom tags.
- Homepage modules: Featured products, banners, or promotional blocks.
- Cart and checkout logic: Real-time pricing, stock levels, and eligibility checks.
- Custom SuiteScript services: Backend APIs that expose Saved Search results to the frontend.
Common Pitfalls in Real-Time Use
Before optimizing, it’s critical to recognize what slows down Saved Searches:
- Too many joins: Linking across multiple record types (e.g., Item → Vendor → Location) increases query complexity.
- Unindexed filters: Using formula fields or non-indexed criteria can degrade performance.
- Large result sets: Returning thousands of rows when only a few are needed.
- Heavy sorting/grouping: Especially when done on calculated fields.
Optimization Strategies
1. Scope the Search Precisely
- Use specific filters like isActive = true, location = current, or inventoryLocation.quantityAvailable > 0.
- Avoid broad filters like Name contains or Description starts with.
2. Limit Columns to Essentials
- Only include fields that are consumed by the frontend or SuiteScript.
- Avoid adding display-only fields like Last Modified or Created Date unless needed.
3. Use Summary Searches for Aggregation
- If you need totals (e.g., total quantity across locations), use summary type searches with GROUP BY logic.
- This reduces row count and speeds up rendering.
4. Index-Aware Filtering
- Prefer native fields over formula fields for filtering.
- Example: Use quantityAvailable directly instead of a formula like {onHand}-{committed}.
5. Pagination & Sorting
- Use row limit and sort by options to control result size.
- For SuiteScript, use search.runPaged() to handle large datasets efficiently.
Real-Time Strategies for SuiteCommerce
Exposing Saved Searches via SuiteScript
Use search.load() and search.run() or runPaged() to expose Saved Search results as JSON to the frontend.
javascript
const searchObj = search.load({ id: ‘customsearch_featured_items’ });
const results = searchObj.run().getRange({ start: 0, end: 20 });
Caching with TTL
Implement caching with a short TTL (e.g., 5–15 minutes) for semi-real-time data like