<?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: How to reduce number of joins? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634519#M220442</link>
    <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;points out, these subsearches are extremely confusing, especially when used in combination with join on _time. &amp;nbsp;Even without consideration of the cost of join, most operations inside the subsearches are pointless in regard to the final timechart command. &amp;nbsp;Then, the final fields command removed all the additional fields these subsearches expensively build up that come in from the join commands.&lt;/P&gt;&lt;P&gt;Semantically, all these (outer) join commands combine to achieve only this:&amp;nbsp;remove any event from the main search that&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;do not have _time value that is at time of day 00:00:00, and&lt;/LI&gt;&lt;LI&gt;fall on days in which there is no event in index=abc sourcetype=abc&amp;nbsp;satisfying conditions &amp;nbsp;ShuttleId=* &lt;EM&gt;AND&lt;/EM&gt; TechnicalWeighingFactor&amp;nbsp;&amp;gt;0.01, and&lt;/LI&gt;&lt;LI&gt;fall on days in which there is no event in index=abc sourcetype=abc&amp;nbsp;satisfying conditions ShuttleId=* &lt;EM&gt;AND&lt;/EM&gt; OperationalWeighingFactor &amp;gt;0.01.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;So, I doubt if there is a need for any join. &amp;nbsp;Of source, this really depends on whether the main search is also on&amp;nbsp;index=abc sourcetype=abc. &amp;nbsp;If not, I can suggest the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| join _time 
    [index=abc sourcetype=abc ShuttleId=* OperationalWeighingFactor&amp;gt;0.01 TechnicalWeighingFactor&amp;gt;0.01
    | timechart span="1d@d1" count
    | fields - count]&lt;/LI-CODE&gt;&lt;P&gt;If the main search is also on&amp;nbsp;index=abc sourcetype=abc, absolutely get rid of join and restructure the entire search.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Mar 2023 06:39:32 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-03-15T06:39:32Z</dc:date>
    <item>
      <title>How to reduce number of joins?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634356#M220368</link>
      <description>&lt;P&gt;Hello Splunkers!!&lt;/P&gt;
&lt;P&gt;As per the below search you can see we have used join commands to get the results from same index &amp;amp; sourcetype. Due to multiple join commands the query become slow. Please help me how can I use single join command to get the result from all the fields "| fields - Total_Orders, Errors, Technical_Error, Operational_Error"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;search&amp;gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| join max=0 _time
[| search ((index=* OR index=_*) index=abc sourcetype=abc)
| fields + _time, host, source, sourcetype, Active, ErrorCode, ErrorDescription, ErrorDuration, ErrorId, From, Id, Location, ModuleId, OperationalWeighingFactor, ShuttleId, TechnicalWeighingFactor, TraceFlags, TraceId, TraceVersion, Version, date_hour, date_mday, date_minute, date_month, date_second, date_wday, date_year, index, Recoverable
| eval weeknum=strftime('_time',"%V")
| eval date_year=strftime('_time',"%Y"), date_month=strftime('_time',"%B"), day_week=strftime('_time',"%A"), date_mday=strftime('_time',"%d"), date_hour=strftime('_time',"%H"), date_minute=strftime('_time',"%M")
| search (date_year="*" date_month="*" weeknum="*" day_week="*" date_hour="*" date_minute="*" ShuttleId=*)
| fields + Id, _time, ErrorId, ErrorDescription
| table ErrorId, _time
| timechart span="1d@d1" count(ErrorId) as "Errors"]
| sort 0 _time
| fillnull Total_Orders Errors value="0"
| eval Total_Error_Per_10000_Order=round(((Errors / Total_Orders) * 10000),0)
| join max=0 _time
[| search ((index=* OR index=_*) index=abc sourcetype=abc)
| fields + _time, host, source, sourcetype, Active, ErrorCode, ErrorDescription, ErrorDuration, ErrorId, From, Id, Location, ModuleId, OperationalWeighingFactor, ShuttleId, TechnicalWeighingFactor, TraceFlags, TraceId, TraceVersion, Version, date_hour, date_mday, date_minute, date_month, date_second, date_wday, date_year, index, Recoverable
| eval weeknum=strftime('_time',"%V")
| eval date_year=strftime('_time',"%Y"), date_month=strftime('_time',"%B"), day_week=strftime('_time',"%A"), date_mday=strftime('_time',"%d"), date_hour=strftime('_time',"%H"), date_minute=strftime('_time',"%M")
| search (date_year="*" date_month="*" weeknum="*" day_week="*" date_hour="*" date_minute="*" ShuttleId=*)
| fields + Id, _time, ErrorId, ErrorDescription, TechnicalWeighingFactor
| rename TechnicalWeighingFactor as Technical_Error
| table _time, ErrorId, Technical_Error
| search Technical_Error&amp;gt;0.01
| timechart span="1d@d1" count(Technical_Error) as "Technical_Error"
| fillnull Technical_Error value="0"]
| fillnull Total_Orders Technical_Error value="0"
| eval Technical_Error_Per_10000_Order=round(((Technical_Error / Total_Orders) * 10000),0)
| join max=0 _time
[| search ((index=* OR index=_*) index=abc sourcetype=abc)
| fields + _time, host, source, sourcetype, Active, ErrorCode, ErrorDescription, ErrorDuration, ErrorId, From, Id, Location, ModuleId, OperationalWeighingFactor, ShuttleId, TechnicalWeighingFactor, TraceFlags, TraceId, TraceVersion, Version, date_hour, date_mday, date_minute, date_month, date_second, date_wday, date_year, index, Recoverable
| eval weeknum=strftime('_time',"%V")
| eval date_year=strftime('_time',"%Y"), date_month=strftime('_time',"%B"), day_week=strftime('_time',"%A"), date_mday=strftime('_time',"%d"), date_hour=strftime('_time',"%H"), date_minute=strftime('_time',"%M")
| search (date_year="*" date_month="*" weeknum="*" day_week="*" date_hour="*" date_minute="*" ShuttleId=*)
| fields + Id, _time, ErrorId, ErrorDescription, OperationalWeighingFactor
| rename OperationalWeighingFactor as Operational_Error
| table _time, ErrorId, Operational_Error
| search Operational_Error&amp;gt;0.01
| timechart span="1d@d1" count(Operational_Error) as "Operational_Error"
| fillnull Operational_Error value="0"]
| fillnull Total_Orders Operational_Error Technical_Error value="0"
| eval Operational_Error_Per_10000_Order=round(((Operational_Error / Total_Orders) * 10000),0)
| fields - Total_Orders, Errors, Technical_Error, Operational_Error

&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Mar 2023 16:48:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634356#M220368</guid>
      <dc:creator>uagraw01</dc:creator>
      <dc:date>2023-03-14T16:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to reduce number of joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634363#M220372</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/70277"&gt;@uagraw01&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;it's really hard to help you because I haven't your data to test the search, I can only give you some general hint:&lt;/P&gt;&lt;P&gt;at first don't use "&lt;SPAN&gt;((index=* OR index=_*) index=abc sourcetype=abc)" because if you have sourcetype and index you don't need to addthe first part of the search.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;then don't use _time as join key because also a millisecond could block the join.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;then I don't understand what you want to have as result because you have always the same subsearch and the same time period, so what's the scope of your search?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if you want to correlate data from different searches you have to put in the main search all the searches you have and then to find a correlation field to use in a stats command to group results; then in the stats command you add all the fields you need using the options of the stats command (values, earliest, last, etc...)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ciao.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Giuseppe&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 07:37:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634363#M220372</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-14T07:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to reduce number of joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634367#M220374</link>
      <description>&lt;P&gt;OK, a side question - is this a manually crafted search or has it been generated by some tool?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 08:18:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634367#M220374</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-03-14T08:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to reduce number of joins?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634519#M220442</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;points out, these subsearches are extremely confusing, especially when used in combination with join on _time. &amp;nbsp;Even without consideration of the cost of join, most operations inside the subsearches are pointless in regard to the final timechart command. &amp;nbsp;Then, the final fields command removed all the additional fields these subsearches expensively build up that come in from the join commands.&lt;/P&gt;&lt;P&gt;Semantically, all these (outer) join commands combine to achieve only this:&amp;nbsp;remove any event from the main search that&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;do not have _time value that is at time of day 00:00:00, and&lt;/LI&gt;&lt;LI&gt;fall on days in which there is no event in index=abc sourcetype=abc&amp;nbsp;satisfying conditions &amp;nbsp;ShuttleId=* &lt;EM&gt;AND&lt;/EM&gt; TechnicalWeighingFactor&amp;nbsp;&amp;gt;0.01, and&lt;/LI&gt;&lt;LI&gt;fall on days in which there is no event in index=abc sourcetype=abc&amp;nbsp;satisfying conditions ShuttleId=* &lt;EM&gt;AND&lt;/EM&gt; OperationalWeighingFactor &amp;gt;0.01.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;So, I doubt if there is a need for any join. &amp;nbsp;Of source, this really depends on whether the main search is also on&amp;nbsp;index=abc sourcetype=abc. &amp;nbsp;If not, I can suggest the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| join _time 
    [index=abc sourcetype=abc ShuttleId=* OperationalWeighingFactor&amp;gt;0.01 TechnicalWeighingFactor&amp;gt;0.01
    | timechart span="1d@d1" count
    | fields - count]&lt;/LI-CODE&gt;&lt;P&gt;If the main search is also on&amp;nbsp;index=abc sourcetype=abc, absolutely get rid of join and restructure the entire search.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 06:39:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634519#M220442</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-03-15T06:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to reduce number of joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634879#M220562</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;Its manually crafted&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 08:37:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-reduce-number-of-joins/m-p/634879#M220562</guid>
      <dc:creator>uagraw01</dc:creator>
      <dc:date>2023-03-17T08:37:06Z</dc:date>
    </item>
  </channel>
</rss>

