Uploaded image for project: 'Pig'
  1. Pig
  2. PIG-4449

Optimize the case of Order by + Limit in nested foreach

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • 0.18.0
    • None

    Description

      This is one of the very frequently used patterns

      grouped_data_set = group data_set by id;
      
      capped_data_set = foreach grouped_data_set
      {
        ordered = order joined_data_set by timestamp desc;
        capped = limit ordered $num;
       generate flatten(capped);
      };
      

      But this performs very poorly when there are millions of rows for a key in the groupby with lot of spills. This can be easily optimized by pushing the limit into the InternalSortedBag and maintain only $num records any time and avoid memory pressure.

      Attachments

        Issue Links

          Activity

            People

              rohini Rohini Palaniswamy
              rohini Rohini Palaniswamy
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: