2 Replies Latest reply on Nov 16, 2017 6:49 PM by Rick Davin

    Need to Improve performance on finding & retrieving eventframes


      We need to find Eventframes generated for last 21 days and retrieve the attributes (nearly 10) for those. For that we are using FindEventFrames PI-SDK method with the startTime parameter as "t-21d" and getting around 40K event frames in the elapsed time of 9min. This is currently taking a lot of time and we need to improve performance a lot. Please suggest us improving performance, by which methods we need to choose for that.

      Code used for finding and retrieving eventframes.


      var eventFrames = AFEventFrame.FindEventFrames(
                            database: afDatabase,
                            searchRoot: null,
                            startTime: "t-21d",
                            startIndex: 0,
                            maxCount: int.MaxValue,
                            searchMode: AFEventFrameSearchMode.ForwardFromStartTime,
                            nameFilter: "",
                            referencedElementNameFilter: "",
                            elemCategory: null,
                            elemTemplate: efTemplate,
                            searchFullHierarchy: true);


                foreach (AFEventFrame ef in eventFrames)
                          var val1 = ef.Attributes["AssetGlobalUniqueId"].GetValue();
                          var val2 = ef.Attributes["EventDefinitionId"].GetValue();
                          var val3 = ef.Attributes["DetectorId"].GetValue();


        • Re: Need to Improve performance on finding & retrieving eventframes
          Rick Davin

          If you are on PI AF SDK 2.8 or better, you should use AFEventFrameSearch.FindEventFrames.  The older AFEventFrame.FindEventFrames is more sluggish because it must load and sort everything into memory before your foreach would be reached.  With AFEventFrameSearch, event frames are streamed to you in smaller paged groups.


          If you are on PI AF SDK 2.9.1, or need a great reason to upgrade, there is the lightweight AFEventFrameSearch.FindObjectFields.  Much, much faster than the old methods.  See this blog in the section Explaining the Performance Boost for an explanation of why its faster.

          1 of 1 people found this helpful
          • Re: Need to Improve performance on finding & retrieving eventframes
            Rick Davin

            Hi Soundararajan,


            I know this is 5 months old, but were you able to improve performance?  If you were using AF SDK 2.9.x, the the AFEventFrameSearch.FindObjectFields would have been a tremendous performance boost particularly for retrieving values.


            The bulk of the slowness would not have on finding and retrieving the event frames.  Rather, you are making 3 individual GetValue() calls for each event frame.  If you have 10K event frames returned, you are making 30K additional calls to the server to get data values.  There would be a way to make bulk calls, but how they would work for you requires knowing more than the simplified loop that you have provided.


            For some reason this post bubbled up to my queue today.  I wanted to follow up with you to see what you did with it.