<?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 Limit Fetch Table Size in Lookup Commands Using DQL in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Limit-Fetch-Table-Size-in-Lookup-Commands-Using-DQL/m-p/248099#M977</link>
    <description>&lt;P&gt;I'm trying to make a lookup as efficient as possible, thus I'd require to provide a dynamic filter to the "fetch" command within a lookup.&lt;/P&gt;
&lt;P&gt;Take this code:&lt;/P&gt;
&lt;PRE&gt;fetch spans&lt;BR /&gt;| filter k8s.namespace.name == "webshop-frontend"&lt;BR /&gt;| filter trace.id == toUid("2ece9047533a31d3808c57165e511ad3")&lt;BR /&gt;&lt;BR /&gt;// get service name&lt;BR /&gt;| fieldsAdd service.name = entityName(dt.entity.service)&lt;BR /&gt;&lt;BR /&gt;// get the service name of the parent span service&lt;BR /&gt;| lookup [fetch spans&lt;BR /&gt;           | filter trace.id == toUid("2ece9047533a31d3808c57165e511ad3")&lt;BR /&gt;         ],&lt;BR /&gt;         sourceField:span.parent_id,&lt;BR /&gt;         lookupField:span.id,&lt;BR /&gt;         prefix: "parent."&lt;/PRE&gt;
&lt;P&gt;The lookup's purpose is to get the service name of the parent span of a given span.id. (I'm basically trying to build a "service flow" with timing information between services).&lt;/P&gt;
&lt;P&gt;Now, as you can see in the code I can do this with individual traces by providing the same trace id in the query and in the lookup fetch. However this will not work without the single trace context.&lt;BR /&gt;What I'd need is to limit the "fetch" within the lookup so that it only returns a small set of spans, namely the ones it is currently operating on.&lt;/P&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;PRE&gt;| lookup [fetch spans&lt;BR /&gt;           | filter span.id == valueOf(sourceField)&lt;BR /&gt;         ],&lt;BR /&gt;         sourceField:span.parent_id,&lt;BR /&gt;         lookupField:span.id,&lt;BR /&gt;         prefix: "parent."&lt;/PRE&gt;
&lt;P&gt;Isn't that quite a common usecase? Having access to "outer" variable within the fetch?&lt;/P&gt;
&lt;P&gt;kr&lt;/P&gt;</description>
    <pubDate>Thu, 18 Dec 2025 14:24:12 GMT</pubDate>
    <dc:creator>r_weber</dc:creator>
    <dc:date>2025-12-18T14:24:12Z</dc:date>
    <item>
      <title>Limit Fetch Table Size in Lookup Commands Using DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Limit-Fetch-Table-Size-in-Lookup-Commands-Using-DQL/m-p/248099#M977</link>
      <description>&lt;P&gt;I'm trying to make a lookup as efficient as possible, thus I'd require to provide a dynamic filter to the "fetch" command within a lookup.&lt;/P&gt;
&lt;P&gt;Take this code:&lt;/P&gt;
&lt;PRE&gt;fetch spans&lt;BR /&gt;| filter k8s.namespace.name == "webshop-frontend"&lt;BR /&gt;| filter trace.id == toUid("2ece9047533a31d3808c57165e511ad3")&lt;BR /&gt;&lt;BR /&gt;// get service name&lt;BR /&gt;| fieldsAdd service.name = entityName(dt.entity.service)&lt;BR /&gt;&lt;BR /&gt;// get the service name of the parent span service&lt;BR /&gt;| lookup [fetch spans&lt;BR /&gt;           | filter trace.id == toUid("2ece9047533a31d3808c57165e511ad3")&lt;BR /&gt;         ],&lt;BR /&gt;         sourceField:span.parent_id,&lt;BR /&gt;         lookupField:span.id,&lt;BR /&gt;         prefix: "parent."&lt;/PRE&gt;
&lt;P&gt;The lookup's purpose is to get the service name of the parent span of a given span.id. (I'm basically trying to build a "service flow" with timing information between services).&lt;/P&gt;
&lt;P&gt;Now, as you can see in the code I can do this with individual traces by providing the same trace id in the query and in the lookup fetch. However this will not work without the single trace context.&lt;BR /&gt;What I'd need is to limit the "fetch" within the lookup so that it only returns a small set of spans, namely the ones it is currently operating on.&lt;/P&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;PRE&gt;| lookup [fetch spans&lt;BR /&gt;           | filter span.id == valueOf(sourceField)&lt;BR /&gt;         ],&lt;BR /&gt;         sourceField:span.parent_id,&lt;BR /&gt;         lookupField:span.id,&lt;BR /&gt;         prefix: "parent."&lt;/PRE&gt;
&lt;P&gt;Isn't that quite a common usecase? Having access to "outer" variable within the fetch?&lt;/P&gt;
&lt;P&gt;kr&lt;/P&gt;</description>
      <pubDate>Thu, 18 Dec 2025 14:24:12 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Limit-Fetch-Table-Size-in-Lookup-Commands-Using-DQL/m-p/248099#M977</guid>
      <dc:creator>r_weber</dc:creator>
      <dc:date>2025-12-18T14:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Limiting the "fetch" table in lookup commands</title>
      <link>https://community.dynatrace.com/t5/DQL/Limit-Fetch-Table-Size-in-Lookup-Commands-Using-DQL/m-p/248196#M979</link>
      <description>&lt;P&gt;Generally &lt;EM&gt;&lt;STRONG&gt;lookup&lt;/STRONG&gt;&lt;/EM&gt; command's parameter &lt;EM&gt;&lt;STRONG&gt;executionOrder:leftFirst&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;() does what you need. From user perspective it can be describe this way: it executes left part of the query until subquery results are needed and injects set of values of &lt;EM&gt;&lt;STRONG&gt;sourceLookup:&lt;/STRONG&gt;&lt;/EM&gt; field as condition [ &lt;EM&gt;&lt;STRONG&gt;in()&lt;/STRONG&gt;&lt;/EM&gt; ] in subquery on &lt;EM&gt;&lt;STRONG&gt;lookupField:&lt;/STRONG&gt;&lt;/EM&gt;.&lt;BR /&gt;&lt;BR /&gt;However still limits will apply and in case joining spans with spans this may be too weak.&lt;BR /&gt;&lt;BR /&gt;I tested on my environment (1 min timeframe) and went from query which was failing to query scanning 50GB and returning 1000 (default limit) first spans.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;my query for reference:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch spans
| filter k8s.namespace.name == "seg-index"

| lookup [ fetch spans ],
         sourceField:span.parent_id,
         lookupField:span.id,
         executionOrder:leftFirst,
         prefix: "parent."&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 18:46:33 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Limit-Fetch-Table-Size-in-Lookup-Commands-Using-DQL/m-p/248196#M979</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2024-06-12T18:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: Limiting the "fetch" table in lookup commands</title>
      <link>https://community.dynatrace.com/t5/DQL/Limit-Fetch-Table-Size-in-Lookup-Commands-Using-DQL/m-p/248236#M980</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/25373"&gt;@krzysztof_hoja&lt;/a&gt;&amp;nbsp;, after a bit of more reading I figured out the leftFirst parameter and it improved just like you described.&lt;BR /&gt;However it still is limited to a very short timeframe (1-5min in my case using the equivalent to lookup with a join:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;fetch spans&lt;BR /&gt;| filter dt.entity.service == "SERVICE-8ACA58863A49B15E"&lt;BR /&gt;| fields trace.id, span.id, span.parent_id, dt.entity.service,duration&lt;BR /&gt;| fieldsAdd service.name = entityName(dt.entity.service, type:"dt.entity.service")&lt;BR /&gt;&lt;BR /&gt;// get all caller spans&lt;BR /&gt;| join [fetch spans ],&lt;BR /&gt;       kind: leftOuter,&lt;BR /&gt;       executionOrder: leftFirst,&lt;BR /&gt;       on: { left[span.parent_id] == right[span.id] },&lt;BR /&gt;       prefix: "caller."&lt;/PRE&gt;&lt;P&gt;I'm wondering how - in an alternative way - that usecase could be achieved with DQL:&lt;/P&gt;&lt;P&gt;I want to know response times between services similar to what service-flow does. Not the response time of a service itself but the response time for caller services.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 07:15:20 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Limit-Fetch-Table-Size-in-Lookup-Commands-Using-DQL/m-p/248236#M980</guid>
      <dc:creator>r_weber</dc:creator>
      <dc:date>2024-06-13T07:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Limiting the "fetch" table in lookup commands</title>
      <link>https://community.dynatrace.com/t5/DQL/Limit-Fetch-Table-Size-in-Lookup-Commands-Using-DQL/m-p/291844#M2951</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/35901"&gt;@r_weber&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;SPAN&gt;I just wanted to check in and see if you still need help with this. If so, I’d be happy to look into it for you!&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please let me know what works best for you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Dec 2025 14:23:33 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Limit-Fetch-Table-Size-in-Lookup-Commands-Using-DQL/m-p/291844#M2951</guid>
      <dc:creator>IzabelaRokita</dc:creator>
      <dc:date>2025-12-18T14:23:33Z</dc:date>
    </item>
  </channel>
</rss>

