SPLK-3003 · Question #57
Which of the following is the most efficient search?
The correct answer is B. (index=www status=200 uri=/cart/checkout) OR (index=sales) | stats count, sum(revenue) as. Option B is the most efficient because it pushes all filtering to the index search level using an inline OR, allowing Splunk to retrieve only the relevant events from each index in a single pass without any subsearches or post-retrieval filtering. A is inefficient because…
Question
Which of the following is the most efficient search?
Options
- Aindex=www status=200 uri=/cart/checkout | append [search index = sales] | stats count,
- B(index=www status=200 uri=/cart/checkout) OR (index=sales) | stats count, sum(revenue) as
- Cindex=www | append [search index = sales] | stats count, sum(revenue) as total_revenue by
- D(index=www) OR (index=sales) | search (index=www status=200 uri=/cart/checkout) OR
How the community answered
(43 responses)- A16% (7)
- B70% (30)
- C5% (2)
- D9% (4)
Explanation
Option B is the most efficient because it pushes all filtering to the index search level using an inline OR, allowing Splunk to retrieve only the relevant events from each index in a single pass without any subsearches or post-retrieval filtering.
- A is inefficient because
append [search ...]spawns a subsearch, which runs separately, loads results into memory, and then merges them - a costly two-phase operation. - C is doubly inefficient: it retrieves all events from
index=wwwwith no early filtering, then compounds the problem with an expensiveappendsubsearch. - D retrieves all events from both indexes first, then applies
| searchas a post-pipeline filter - a "filter late" anti-pattern that makes Splunk do unnecessary work before narrowing results.
Memory tip: Think "filter early, filter inline." Conditions placed directly in the initial search string are evaluated at the index tier (cheapest), while | search filters late at the search tier (expensive), and append [search ...] adds a full subsearch on top of that (most expensive). In Splunk, the earlier and more inline your filters, the better.
Topics
Community Discussion
No community discussion yet for this question.