<?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 Re: Search Query Optimizing in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Search-Query-Optimizing/m-p/745143#M11906</link>
    <description>&lt;P&gt;Optimising this will depend on your data. Using subsearches with lookups can be expensive and using NOT with subsearches, even more so.&lt;/P&gt;&lt;P&gt;Depending on the volume of entries in those lookups you will be better off using a lookup, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index:: rasp_ NOT (
    forwarded_for="140.108.26.152" OR 
    forwarded_for="" OR 
    forwarded_for="10.*" OR 
    forwarded_for=null)
    app!="" app!="\"*\"" app!="VASTID*" 
    host!="10.215*" host!="ip-10-*" host!="carogngsa*" host!="carogngta*" host!="carofuzedd** host!="*ebiz*" host!="echo*" host!="not logged" host!="onm*" host!="tfnm*" host!="voip*" host!="wfm*"
    category!="Config*" category!="Depend*" category!="Stat*" category!="Large*" category!="Uncaught*" category!="Unvalidated Redirect" category!="License" category!="*Parse*" action=*

| lookup Scanners_Ext.csv forwarded_for OUTPUT forwarded_for as found
| where isnull(found)
| lookup Scanners_Int.csv ip_addr as forwarded_for OUTPUT ip_addr as found 
| where isnull(found)
| lookup vz_nets.csv netblock as forwarded_for OUTPUT netblock as found
| where isnull(found)

| stats count&lt;/LI-CODE&gt;&lt;P&gt;so the static NOT statement and other != comparisons is part of the search and then you do each lookup in turn and if it's found then it will be discarded.&lt;/P&gt;&lt;P&gt;The order of the 3 lookups would be in likely match count order, so the first lookup should be done that would be expected to reduce the event count by the max, and so on.&lt;/P&gt;&lt;P&gt;Using NOT or all your != wildcard searches at the beginning will be somewhat expensive, you can use TERM() to reduce data scan count, but that requires knowing your data well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Apr 2025 04:21:23 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2025-04-29T04:21:23Z</dc:date>
    <item>
      <title>Search Query Optimizing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Search-Query-Optimizing/m-p/745125#M11905</link>
      <description>&lt;P&gt;Please help me to Optimize this Splunk Query&lt;/P&gt;&lt;PRE&gt;index:: rasp_&lt;BR /&gt;&lt;BR /&gt;NOT [inputlookup Scanners_Ext.csv | fields forwarded_for]&lt;BR /&gt;&lt;BR /&gt;NOT [inputlookup Scanners_Int.csv | rename ip_addr AS forwarded_for | fields forwarded_for]&lt;BR /&gt;&lt;BR /&gt;NOT [inputlookup vz_nets.csv | rename netblock AS forwarded_for | fields forwarded_for]&lt;BR /&gt;&lt;BR /&gt;NOT (forwarded_for="140.108.26.152" OR forwarded_for="" OR forwarded_for="10.*" OR forwarded_for=null) app!="" app!="\"*\"" app!="VASTID*" host!="10.215*" host!="ip-10-*" host!="carogngsa*" host!="carogngta*" host!="carofuzedd** host!="*ebiz*" host!="echo*" host!="not logged" host!="onm*" host!="tfnm*" host!="voip*" host!="wfm*" category!="Config*" category!="Depend*" category!="Stat*" category!="Large*" category!="Uncaught*" category!="Unvalidated Redirect" category!="License" category!="*Parse*" action=*&lt;BR /&gt;&lt;BR /&gt;| stats count&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Apr 2025 21:08:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Search-Query-Optimizing/m-p/745125#M11905</guid>
      <dc:creator>kunalsingh</dc:creator>
      <dc:date>2025-04-28T21:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Search Query Optimizing</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Search-Query-Optimizing/m-p/745143#M11906</link>
      <description>&lt;P&gt;Optimising this will depend on your data. Using subsearches with lookups can be expensive and using NOT with subsearches, even more so.&lt;/P&gt;&lt;P&gt;Depending on the volume of entries in those lookups you will be better off using a lookup, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index:: rasp_ NOT (
    forwarded_for="140.108.26.152" OR 
    forwarded_for="" OR 
    forwarded_for="10.*" OR 
    forwarded_for=null)
    app!="" app!="\"*\"" app!="VASTID*" 
    host!="10.215*" host!="ip-10-*" host!="carogngsa*" host!="carogngta*" host!="carofuzedd** host!="*ebiz*" host!="echo*" host!="not logged" host!="onm*" host!="tfnm*" host!="voip*" host!="wfm*"
    category!="Config*" category!="Depend*" category!="Stat*" category!="Large*" category!="Uncaught*" category!="Unvalidated Redirect" category!="License" category!="*Parse*" action=*

| lookup Scanners_Ext.csv forwarded_for OUTPUT forwarded_for as found
| where isnull(found)
| lookup Scanners_Int.csv ip_addr as forwarded_for OUTPUT ip_addr as found 
| where isnull(found)
| lookup vz_nets.csv netblock as forwarded_for OUTPUT netblock as found
| where isnull(found)

| stats count&lt;/LI-CODE&gt;&lt;P&gt;so the static NOT statement and other != comparisons is part of the search and then you do each lookup in turn and if it's found then it will be discarded.&lt;/P&gt;&lt;P&gt;The order of the 3 lookups would be in likely match count order, so the first lookup should be done that would be expected to reduce the event count by the max, and so on.&lt;/P&gt;&lt;P&gt;Using NOT or all your != wildcard searches at the beginning will be somewhat expensive, you can use TERM() to reduce data scan count, but that requires knowing your data well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2025 04:21:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Search-Query-Optimizing/m-p/745143#M11906</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-04-29T04:21:23Z</dc:date>
    </item>
  </channel>
</rss>

