<?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: ... | append [ | makeresults ] makes the search time explode in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692313#M235647</link>
    <description>&lt;P&gt;I found the solution. In the end, it boiled down to a stupid mistake in a defined macro.&lt;BR /&gt;&lt;BR /&gt;My search really looked like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`my_search(param1, param2)`
| `fixedrange`&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;...which expanded to the following snippet from my original question:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;```from macro "my_search":```
...
| table _time, y1, y2, y3, ..., yN


```from macro "fixedrange":```
| append [
  | makeresults
  | addinfo
  | eval x=mvappend(info_min_time, info_max_time)
  | mvexpand x
  | rename x as _time
  | eval _t=0
  | table _time, _t
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;But `my_search` was defined like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| search index=... sourcetype=... param1=... param2=...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;EM&gt;Note the leading pipe, which shouldn't have been there!&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;Now, the search optimization produced different results, depending on whether the 2nd macro was applied or not.&lt;BR /&gt;&lt;BR /&gt;Case A (fast):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`my_search(param1, param2)`

... produced:

| search (sourcetype=... param1=... param2=...)
| search index=...
| ...&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Case B (slow):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`my_search(param1, param2)`
| `fixedrange`

... produced:

| search
| search (index=... sourcetype=... param1=... param2=...)
| ...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... and obviously the first search term in case B was causing the headache, although the final result set was identical in both cases.&lt;BR /&gt;&lt;BR /&gt;Ouch!&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jul 2024 15:19:34 GMT</pubDate>
    <dc:creator>rikinet</dc:creator>
    <dc:date>2024-07-03T15:19:34Z</dc:date>
    <item>
      <title>... | append [ | makeresults ] makes the search time explode</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692155#M235621</link>
      <description>&lt;P&gt;I have a dashboard with multiple line charts showing values over time. I want all charts to have the same fixed time (X) axis range, so I can compare the graphs visually. Something like the &lt;EM&gt;fixedrange&lt;/EM&gt; option in the &lt;EM&gt;timechart&lt;/EM&gt; command. However, I use a simple "| table _time, y1, y2, yN" instead of timechart, because I want the real timestamps in the graph, not some approximation due to timechart's notorious binning.&lt;BR /&gt;&lt;BR /&gt;To mimic the fixedrange behavior, I append a hidden graph with just two coordinate points (t_min|0) and (t_max|0):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
| table _time, y1, y2, y3, ..., yN

| append [
  | makeresults
  | addinfo
  | eval x=mvappend(info_min_time, info_max_time)
  | mvexpand x
  | rename x as _time
  | eval _t=0
  | table _time, _t
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This appended search appears very cheap to me - it alone runs in less than 0.5 seconds. But now I realized that it makes the overall search&amp;nbsp;&lt;EM&gt;dramatically&amp;nbsp;&lt;/EM&gt;slower, about x10 in time. The number of scanned events explodes.&lt;BR /&gt;&lt;BR /&gt;This even happens when I reduce to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| append maxout=1 [ | makeresults count=1 ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;What's going on here? I would have expected the main search to run exactly as fast as before, and the only toll should be the time required to add one more line with a timestamp to the end of the finalized table, no?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 23:25:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692155#M235621</guid>
      <dc:creator>rikinet</dc:creator>
      <dc:date>2024-07-01T23:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: ... | append [ | makeresults ] makes the search time explode</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692159#M235623</link>
      <description>&lt;P&gt;Not sure why that is happening - does search log show anything&lt;/P&gt;&lt;P&gt;Have you tried using appendpipe rather than append - that will run after the initial search, not before&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| appendpipe [
  | stats count 
  | addinfo
  | eval x=mvappend(info_min_time, info_max_time)
  | mvexpand x
  | rename x as _time
  | eval _t=0
  | table _time, _t
  ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 00:55:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692159#M235623</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-07-02T00:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: ... | append [ | makeresults ] makes the search time explode</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692167#M235626</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/255974"&gt;@rikinet&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;in addition to the perfect solution from&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;, you could test the Horizon Chart add-on (&lt;A href="https://splunkbase.splunk.com/app/3117" target="_blank"&gt;https://splunkbase.splunk.com/app/3117&lt;/A&gt;) that gives you the requested parallel visualization.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 05:57:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692167#M235626</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-07-02T05:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: ... | append [ | makeresults ] makes the search time explode</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692174#M235629</link>
      <description>&lt;P&gt;That does indeed seem strange. Is this the last part of the search? Do the search dashboard and search log show anything significantly changing after you add this append command?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 07:29:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692174#M235629</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-07-02T07:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: ... | append [ | makeresults ] makes the search time explode</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692313#M235647</link>
      <description>&lt;P&gt;I found the solution. In the end, it boiled down to a stupid mistake in a defined macro.&lt;BR /&gt;&lt;BR /&gt;My search really looked like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`my_search(param1, param2)`
| `fixedrange`&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;...which expanded to the following snippet from my original question:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;```from macro "my_search":```
...
| table _time, y1, y2, y3, ..., yN


```from macro "fixedrange":```
| append [
  | makeresults
  | addinfo
  | eval x=mvappend(info_min_time, info_max_time)
  | mvexpand x
  | rename x as _time
  | eval _t=0
  | table _time, _t
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;But `my_search` was defined like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| search index=... sourcetype=... param1=... param2=...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;EM&gt;Note the leading pipe, which shouldn't have been there!&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;Now, the search optimization produced different results, depending on whether the 2nd macro was applied or not.&lt;BR /&gt;&lt;BR /&gt;Case A (fast):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`my_search(param1, param2)`

... produced:

| search (sourcetype=... param1=... param2=...)
| search index=...
| ...&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Case B (slow):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`my_search(param1, param2)`
| `fixedrange`

... produced:

| search
| search (index=... sourcetype=... param1=... param2=...)
| ...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... and obviously the first search term in case B was causing the headache, although the final result set was identical in both cases.&lt;BR /&gt;&lt;BR /&gt;Ouch!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2024 15:19:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692313#M235647</guid>
      <dc:creator>rikinet</dc:creator>
      <dc:date>2024-07-03T15:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: ... | append [ | makeresults ] makes the search time explode</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692366#M235658</link>
      <description>&lt;P&gt;Thanks for closing the loop&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2024 22:21:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-makeresults-makes-the-search-time-explode/m-p/692366#M235658</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-07-03T22:21:33Z</dc:date>
    </item>
  </channel>
</rss>

