<?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 Join not Returning all Results on Right Side in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143646#M39915</link>
    <description>&lt;P&gt;By default a subsearch will not yield 500000 events, IIRC it'll only give you 50000. Take a look at &lt;A href="http://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;http://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt; for alternatives.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Dec 2014 23:30:27 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-12-04T23:30:27Z</dc:date>
    <item>
      <title>Left Join not Returning all Results on Right Side</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143645#M39914</link>
      <description>&lt;P&gt;Ok, y'all, I'm completely flummoxed.&lt;/P&gt;

&lt;P&gt;Simplified: I have two sourcetypes ("a" and "b"). Each sourcetype has 500,000 items. I want to join "b" onto "a", matching on "id", because there's a column in "b" that I want. I know for a fact that all 500,000 entries in "a" have a corresponding match in "b". BTW, the timestamps in "a" and "b" don't line up, and I don't care about that - this isn't a "transaction". They may be off by a day or more, and that's fine.&lt;/P&gt;

&lt;P&gt;I try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="a" | join id type="left" [ search sourcetype="b" type="baz" | fields id unit ] | table id, foo, bar, unit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I expect to have 500,000 results, with columns "id", "foo", "bar", (from "a") and "unit" (from "b") all filled in.&lt;/P&gt;

&lt;P&gt;Instead, I get (for simplification) roughly 3,500 records with "unit" from sourcetype "b", and the rest with "unit" blank.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;+--------+------+------+--------+
| id     | foo  | bar  | unit   |
+--------+------+------+--------+
| 12345  | 1    | 1    | 99999  |
| 67890  | 1    | 1    |        | &amp;lt;-- ?
| 54321  | 1    | 1    |        | &amp;lt;-- ?
+--------+------+------+--------+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I cannot for the life of me figure out why this is!&lt;/P&gt;

&lt;P&gt;I compared values in "a" that had matches display vs. those that did not, and could not spot a difference.&lt;/P&gt;

&lt;P&gt;Note, if I &lt;EM&gt;specify&lt;/EM&gt; id in both sides of the join, like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="a" id=12345 | join id type="left" [ search sourcetype="b" type="baz" id=12345 | fields id unit ] | table id, foo, bar, unit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I get the results I expect. I need 500,000 rows, though, not one.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;

&lt;P&gt;One final clue: when I compare those with a "hit" versus those without a "hit", I can restrict the search on "a" and pipe the results into | table *, like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="a" id=12345 | join id type="left" [ search sourcetype="b" type="baz" | fields id unit ] | table *

sourcetype="a" id=67890 | join id type="left" [ search sourcetype="b" type="baz" | fields id unit ] | table *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Assuming 12345 shows "unit" from "b", and 67890 does not, when I pipe to | table * it's interesting, because the "resultset" column shows "b" for 12345, but "a" for 67890. WTF?!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;+--------+-------------+--------+
| id     | sourcetype  | unit   |
+--------+-------------+--------+
| 12345  | b           | 99999  |
| 67890  | a           |        | &amp;lt;-- ?
+--------+------+------+--------+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am not a smart man. And Splunk isn't SQL.&lt;/P&gt;

&lt;P&gt;Help?...&lt;/P&gt;</description>
      <pubDate>Thu, 04 Dec 2014 23:13:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143645#M39914</guid>
      <dc:creator>photuris</dc:creator>
      <dc:date>2014-12-04T23:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join not Returning all Results on Right Side</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143646#M39915</link>
      <description>&lt;P&gt;By default a subsearch will not yield 500000 events, IIRC it'll only give you 50000. Take a look at &lt;A href="http://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;http://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt; for alternatives.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Dec 2014 23:30:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143646#M39915</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-12-04T23:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join not Returning all Results on Right Side</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143647#M39916</link>
      <description>&lt;P&gt;The &lt;CODE&gt;join&lt;/CODE&gt; command has a limit of 50000 records. Once you run your search, have a look on the "Job" link, below the search box on the right side. It might show a exclamation saying that you reached the limit.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Dec 2014 23:31:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143647#M39916</guid>
      <dc:creator>musskopf</dc:creator>
      <dc:date>2014-12-04T23:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join not Returning all Results on Right Side</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143648#M39917</link>
      <description>&lt;P&gt;Awesome, thanks so much! That pointed me in the right direction. I'm still a newb, apparently.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Dec 2014 23:47:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143648#M39917</guid>
      <dc:creator>photuris</dc:creator>
      <dc:date>2014-12-05T23:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join not Returning all Results on Right Side</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143649#M39918</link>
      <description>&lt;P&gt;Thanks so much! The link you sent was useful, and I learned a lot.&lt;/P&gt;

&lt;P&gt;I'm good with SQL, not so much with SPL (as if you couldn't tell by my post).&lt;/P&gt;

&lt;P&gt;Ultimately, I had to sit down and think about my data sources, and discern which data really are "events," and which data are "static" (or semi-static) sets.&lt;/P&gt;

&lt;P&gt;Instead of fooling with all this left join business, I refactored my data on the right side of my query into lookups. Works great. I'm refining now, making the lookups smarter, but as it is, a simple CSV is doing the job. And it's FAST.&lt;/P&gt;

&lt;P&gt;Thanks for the help. I'm learning to think like Splunk. It's taking a little time.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Dec 2014 23:52:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-Join-not-Returning-all-Results-on-Right-Side/m-p/143649#M39918</guid>
      <dc:creator>photuris</dc:creator>
      <dc:date>2014-12-05T23:52:22Z</dc:date>
    </item>
  </channel>
</rss>

