<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Efficient searches using boolean operators in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Efficient-searches-using-boolean-operators/m-p/132819#M184618</link>
    <description>&lt;P&gt;I'm currently trying to optimize my searches to keep my Splunk searches as quick as possible. Is there any appreciable difference in search time or efficiency in the two following searches? My main point is, does condensed logic help make searches faster, or does it not matter in these cases?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* NOT a NOT b NOT c&lt;/CODE&gt;&lt;/PRE&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* NOT (a OR b OR c)&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Both of these are logically equivalent because of the implied ANDs in the first query ((NOT a) AND (NOT b) AND (NOT c)), so I was curious if there was any major timing difference in the two queries.&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jan 2014 22:46:59 GMT</pubDate>
    <dc:creator>petermuller</dc:creator>
    <dc:date>2014-01-30T22:46:59Z</dc:date>
    <item>
      <title>Efficient searches using boolean operators</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Efficient-searches-using-boolean-operators/m-p/132819#M184618</link>
      <description>&lt;P&gt;I'm currently trying to optimize my searches to keep my Splunk searches as quick as possible. Is there any appreciable difference in search time or efficiency in the two following searches? My main point is, does condensed logic help make searches faster, or does it not matter in these cases?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* NOT a NOT b NOT c&lt;/CODE&gt;&lt;/PRE&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* NOT (a OR b OR c)&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Both of these are logically equivalent because of the implied ANDs in the first query ((NOT a) AND (NOT b) AND (NOT c)), so I was curious if there was any major timing difference in the two queries.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2014 22:46:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Efficient-searches-using-boolean-operators/m-p/132819#M184618</guid>
      <dc:creator>petermuller</dc:creator>
      <dc:date>2014-01-30T22:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient searches using boolean operators</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Efficient-searches-using-boolean-operators/m-p/132820#M184619</link>
      <description>&lt;P&gt;When you look at the search job inspector, you'll see debug messages at the very top. For both your examples they read the same:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DEBUG: base lispy: [ AND [ NOT a ] [ NOT b ] [ NOT c ] index::* ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There cannot be a timing difference because Splunk's doing the same thing underneath.&lt;/P&gt;

&lt;P&gt;As a general optimization, the NOT operator can be slow in many situations. For example, when you run this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal NOT log_level=INFO
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can see Splunk is scanning many events for only few matches. Looking at the debug info you see this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DEBUG: base lispy: [ AND index::_internal ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This means Splunk was not able to use any filter beyond selecting the index. That's because there's no word to look for that could be sped up by the index structure. Loading events without the word "info" wouldn't be correct, because it could appear elsewhere other than in the field log_level.&lt;/P&gt;

&lt;P&gt;On the other hand, running this search is faster:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal NOT INFO
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The debug shows it's using some index structures to only look for events that don't have the word info in them, and avoids loading them off disk:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DEBUG: base lispy: [ AND index::_internal [ NOT info ] ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;These two searches obviously aren't equivalent.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2014 23:12:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Efficient-searches-using-boolean-operators/m-p/132820#M184619</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-01-30T23:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient searches using boolean operators</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Efficient-searches-using-boolean-operators/m-p/132821#M184620</link>
      <description>&lt;P&gt;Thanks! I'll keep those in mind!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2014 23:17:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Efficient-searches-using-boolean-operators/m-p/132821#M184620</guid>
      <dc:creator>petermuller</dc:creator>
      <dc:date>2014-01-30T23:17:45Z</dc:date>
    </item>
  </channel>
</rss>

