<?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: Left outer join in splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Left-outer-join-in-splunk/m-p/19309#M2924</link>
    <description>&lt;P&gt;Splunk isn't a relational database, so while it's possible to do a left outer join, it's not a good way to implement it using the &lt;CODE&gt;join&lt;/CODE&gt; command. The most efficient way in Splunk to get the results you want is probably:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=A MOD_SN=* NOT [ search index=B MOD_SN=* | return 10000 MOD_SN ] | dedup MOD_SN | table MOD_SN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which will work as long as there are no more than 10000 distinct MOD_SN values in B. Unfortunately, this is simply not a terribly easy result to compute. Another way that would work (and again, be more efficient than the &lt;CODE&gt;join&lt;/CODE&gt; command) is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=A OR index=B MOD_SN=* 
| eval s=case(index=="B","b",sourcetype=="A","a",null())
| chart count by MOD_SN,s
| where a &amp;gt; 0 AND b==0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are other possible queries, but selecting which one is best depends on the approximate expected sizes of A and B and the number of distinct values of MOD_SN in each, much in the way that a SQL database may generate table statistics to help the optimizer choose a query plan.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Apr 2012 02:27:07 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2012-04-05T02:27:07Z</dc:date>
    <item>
      <title>Left outer join in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-outer-join-in-splunk/m-p/19308#M2923</link>
      <description>&lt;P&gt;I have a sourcetype  A - which has a field by the name of MOD_SN&lt;BR /&gt;
I have another index  B ( I can only use the name of the index and not the name of the sourcetype for the second table) which has a field by the name of MOD_SN as well.&lt;/P&gt;

&lt;P&gt;I am trying to do a left outer join on MOD_SN - the Great Goal is to be able to get every MOD_SN in sourcetype A which does NOT match a MOD_SN in B&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype = "A" MOD_SN=* | dedup MOD_SN | fields MOD_SN | 
join type=outer MOD_SN [search index="B" | where isnull(MOD_SN) | fields MOD_SN ] | table MOD_SN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does this look ok  ????&lt;/P&gt;

&lt;P&gt;I am trying to recreate what can be done in sql in splunk and I actually tried doing a subsearch but that was not beneficial&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:37:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-outer-join-in-splunk/m-p/19308#M2923</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2020-09-28T11:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Left outer join in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-outer-join-in-splunk/m-p/19309#M2924</link>
      <description>&lt;P&gt;Splunk isn't a relational database, so while it's possible to do a left outer join, it's not a good way to implement it using the &lt;CODE&gt;join&lt;/CODE&gt; command. The most efficient way in Splunk to get the results you want is probably:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=A MOD_SN=* NOT [ search index=B MOD_SN=* | return 10000 MOD_SN ] | dedup MOD_SN | table MOD_SN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which will work as long as there are no more than 10000 distinct MOD_SN values in B. Unfortunately, this is simply not a terribly easy result to compute. Another way that would work (and again, be more efficient than the &lt;CODE&gt;join&lt;/CODE&gt; command) is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=A OR index=B MOD_SN=* 
| eval s=case(index=="B","b",sourcetype=="A","a",null())
| chart count by MOD_SN,s
| where a &amp;gt; 0 AND b==0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are other possible queries, but selecting which one is best depends on the approximate expected sizes of A and B and the number of distinct values of MOD_SN in each, much in the way that a SQL database may generate table statistics to help the optimizer choose a query plan.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2012 02:27:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-outer-join-in-splunk/m-p/19309#M2924</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-04-05T02:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Left outer join in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-outer-join-in-splunk/m-p/19310#M2925</link>
      <description>&lt;P&gt;What are lowercase a and lowercase b ?&lt;/P&gt;

&lt;P&gt;I dont get this segment&lt;/P&gt;

&lt;P&gt;| eval s=case(index=="B","b",sourcetype=="A","a",null())&lt;BR /&gt;
| chart count by MOD_SN,s&lt;BR /&gt;
| where a &amp;gt; 0 AND b==0&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2012 04:48:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-outer-join-in-splunk/m-p/19310#M2925</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2012-04-05T04:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Left outer join in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-outer-join-in-splunk/m-p/19311#M2926</link>
      <description>&lt;P&gt;This search did not work at all :&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;sourcetype=A MOD_SN=* NOT [ search index=B MOD_SN=* | return 10000 MOD_SN ] | dedup MOD_SN | table MOD_SN&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:37:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-outer-join-in-splunk/m-p/19311#M2926</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2020-09-28T11:37:38Z</dc:date>
    </item>
  </channel>
</rss>

