<?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: Splunk query optimization in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701938#M238061</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;Yes, I replace join with lookup command. Do you want me to try something more to optimize further?&lt;/P&gt;</description>
    <pubDate>Tue, 15 Oct 2024 13:07:50 GMT</pubDate>
    <dc:creator>uagraw01</dc:creator>
    <dc:date>2024-10-15T13:07:50Z</dc:date>
    <item>
      <title>Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701777#M238022</link>
      <description>&lt;P&gt;Hello Splunker!!&lt;/P&gt;
&lt;P&gt;Could you please help me to optimize below query ? Customer saying &lt;STRONG&gt;dedup&lt;/STRONG&gt; is taking so much resource consumption.&amp;nbsp;So what should I change in the query so that the complete query gets optimized?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=abc  sourcetype=abc _tel type=TEL (trigger=MFC_SND OR trigger=FMC_SND) telegram_type=CO order_type=TO area=D10 aisle=A01 *1000383334*
| rex field=_raw "(?P&amp;lt;Ordernumber&amp;gt;[0-9]+)\[ETX\]"
| fields _time area aisle section source_tel position destination Ordernumber
| join area aisle
[ inputlookup isc where section=""
| fields area aisle mark_code
| rename area AS area aisle AS aisle]
| lookup movement_type mark_code source AS source_tel position AS position destination AS destination OUTPUT movement_type
| fillnull value="Unspecified" movement_type
| eval movement_category = case( movement_type like "%IH - LH%", "Storage", movement_type like "%LH - R%", "Storage", movement_type like "%IH - IH%", "Storage", movement_type like "%R - LH%", "Retrieval", movement_type like "%LH - O%", "Retrieval", 1 == 1, "Unknown" )
| fields - source_tel position destination
| dedup Ordernumber movement_category
| stats count AS orders by area aisle section movement_category movement_type Ordernumber _raw&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 14 Oct 2024 14:11:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701777#M238022</guid>
      <dc:creator>uagraw01</dc:creator>
      <dc:date>2024-10-14T14:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701782#M238023</link>
      <description>&lt;P&gt;Optimisation will usually depend on the data set(s) you are dealing with, which you haven't provided. Having said that, the dedup by Ordernumber and movement_category will mean that there is only one event with each unique combination of the values in these fields, which means the count from the stats will always be 1, so what is the point of doing the stats?&lt;/P&gt;&lt;P&gt;Your join is to an inputlookup, can this be replaced by a simple lookup?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 09:02:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701782#M238023</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-10-14T09:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701801#M238027</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; Thanks for your response.&lt;BR /&gt;&lt;BR /&gt;As per your suggestion &amp;nbsp;I will take care of the join and replace that will lookup command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am adding screenshots of the results so that you can get a little more clarity.&lt;/P&gt;&lt;P&gt;Below are the results while executing the above query. Order number is same but one entry is for "Storage" &amp;amp; other one for "Retrieval" .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uagraw01_0-1728904090796.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/33078i04EF1201A45019E2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uagraw01_0-1728904090796.png" alt="uagraw01_0-1728904090796.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Job inspection&amp;nbsp; &amp;nbsp;while executing above query&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uagraw01_1-1728904194666.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/33079iE09E2CE90206F1A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uagraw01_1-1728904194666.png" alt="uagraw01_1-1728904194666.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do you have any suggestion so that I can replace dedup with some more optimized command?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 11:18:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701801#M238027</guid>
      <dc:creator>uagraw01</dc:creator>
      <dc:date>2024-10-14T11:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701804#M238028</link>
      <description>&lt;P&gt;Given that the number of orders is always 1 (as previously explained and shown in your screenshot), the dedup is not actually doing anything useful and can be removed. This could affect the orders field in that it could be more than 1. This could be resolved by either evaluating it to 1 after the stats command, or by using distinct count&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats dc(Ordernumber) AS orders by area aisle section movement_category movement_type Ordernumber _raw&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 14 Oct 2024 11:50:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701804#M238028</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-10-14T11:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701819#M238029</link>
      <description>&lt;P&gt;Well, if your Splunk needs 13 seconds to scan just 14 thousand events... that looks weird.&lt;/P&gt;&lt;P&gt;But if you have big events (like 100K-big jsons), considering your wildcard at the beginning of the search term, the initial search might indeed be slow.&lt;/P&gt;&lt;P&gt;So that's the first and probably the most important optimization you can do - if you can drop the wildcard at the beginning of *1000383334*, it will save you &lt;STRONG&gt;a lot&lt;/STRONG&gt; of time.&lt;/P&gt;&lt;P&gt;Notice that Splunk had to scan over 14k events just to match two of them. That's because it can't use indexed terms, it has to scan every single raw event.&lt;/P&gt;&lt;P&gt;Since you're extracting&amp;nbsp; Odernumber (and rely on it being non-empty by including it in the BY clause for stats) using [EXT] as an anchor for your regex the [EXT] part must obviously be in your event. So if it's only in part of the events, you can use it as additional search term (square brackets are major breakers so you can just add EXT to your search terms).&lt;/P&gt;&lt;P&gt;The inputlookup and join &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt; already covered.&lt;/P&gt;&lt;P&gt;Dedup should _not_ be using much resources. As you can see from your job inspect table, it gets just 10 results on input and returns 2. It's not a huge amount. The main problem here is the initial search.&lt;/P&gt;&lt;P&gt;Also if your events are big, you can drop _raw early on so you don't drag it along with you along the pipeline (you only use a few fields in your stats anyway).&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 14:16:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701819#M238029</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-10-14T14:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701879#M238045</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;After executing&amp;nbsp; suggested command I am getting below results. The count should 2 only.&lt;BR /&gt;&lt;BR /&gt;1 for the storage and 1 for the retrieval.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uagraw01_0-1728969804057.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/33092i73ACCE00B055635B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uagraw01_0-1728969804057.png" alt="uagraw01_0-1728969804057.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 05:25:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701879#M238045</guid>
      <dc:creator>uagraw01</dc:creator>
      <dc:date>2024-10-15T05:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701915#M238048</link>
      <description>&lt;P&gt;Remove _raw from the by clause&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 11:57:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701915#M238048</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-10-15T11:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701922#M238051</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; Thanks for your response.&lt;BR /&gt;&lt;BR /&gt;With dedup command it is giving expected 2 results. 1 for storage and 2 for retrieval.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uagraw01_0-1728994373979.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/33098i9D9658F7E7EFFE1C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uagraw01_0-1728994373979.png" alt="uagraw01_0-1728994373979.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Without dedup command it is giving me 5 results.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uagraw01_1-1728994469784.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/33099iF242553B66ECF0AE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uagraw01_1-1728994469784.png" alt="uagraw01_1-1728994469784.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Note : There are no such impact seen after removing the join inputlookup with "lookup command".&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 12:17:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701922#M238051</guid>
      <dc:creator>uagraw01</dc:creator>
      <dc:date>2024-10-15T12:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701925#M238054</link>
      <description>&lt;LI-CODE lang="markup"&gt;| stats dc(Ordernumber) as count first(movement_type) as movement_type by area aisle section movement_category Ordernumber&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 15 Oct 2024 12:22:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701925#M238054</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-10-15T12:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701927#M238055</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; Although this method is correct, it takes one second longer than the dedup command.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uagraw01_0-1728995180622.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/33100i2D10BFBA07BABFD7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uagraw01_0-1728995180622.png" alt="uagraw01_0-1728995180622.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 12:45:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701927#M238055</guid>
      <dc:creator>uagraw01</dc:creator>
      <dc:date>2024-10-15T12:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701932#M238056</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; After apply your suggested command I also replaced lookup command and now search is taking 10.5 seconds to complete the results.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uagraw01_0-1728996808788.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/33101i0EC821C8C9015C1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uagraw01_0-1728996808788.png" alt="uagraw01_0-1728996808788.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 12:55:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701932#M238056</guid>
      <dc:creator>uagraw01</dc:creator>
      <dc:date>2024-10-15T12:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701935#M238058</link>
      <description>&lt;P&gt;Have you tried this with the join being replaced by a lookup?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 13:02:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701935#M238058</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-10-15T13:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701938#M238061</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;Yes, I replace join with lookup command. Do you want me to try something more to optimize further?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 13:07:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701938#M238061</guid>
      <dc:creator>uagraw01</dc:creator>
      <dc:date>2024-10-15T13:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query optimization</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701940#M238062</link>
      <description>&lt;P&gt;Without knowledge of your data, I can't see any further optimisations you might try&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 13:09:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-optimization/m-p/701940#M238062</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-10-15T13:09:55Z</dc:date>
    </item>
  </channel>
</rss>

