muellerrj

AF 2.4.0.4431 finding specific element when path is known in large AF dataset

Discussion created by muellerrj on Sep 9, 2014
Latest reply on Sep 9, 2014 by David Hearn

I am trying to determine the fastest method in AFSDK to lookup an attribute value when I know the specific path to the AF element in a large AF heirachy

 

The AF structure is a flat structure of over a million elements that have identical templates and attribute names. I cannot change the structure or AF version at this time, that is planned, I am trying to find the best way to mitigate for the next few months. This AF server has 25M elements

 

 

 

this is an example of the heirachy (bold are elements)

 

root

 

-meter1

 

--Input

 

---Voltage

 

----.Value

 

---Event

 

----.Value

 

 

 

-meter2

 

--Input

 

---Voltage

 

----.Value

 

---Event

 

----.Value

 

...

 

-meter1600000

 

--Input

 

---Voltage

 

----.Value

 

---Event

 

----.Value

 

I know the explicit path to the element,

 

\\AFDB\METER12345\INPUT\VOLTAGE.Value

 

however experimentation and reading on the dicussion board has found that path searches are much slower in this version and when I tried to do an attribute search it was even slower per record

 

The below code is average about 45-60 seconds for 100 element lookups (p is a record of a prexisting data structure from another database that is being loaded with tag values), it seems inefficient to perform the second search 

 

Is there any way to speed this up?

 

 

 
AFNamedCollectionList<OSIsoft.AF.Asset.AFElement> elements = OSIsoft.AF.Asset.AFElement.FindElements(AFSystemDB, null,p.meter, AFSearchField.Name, false, AFSortField.Name, AFSortOrder.Descending, 1);

foreach (OSIsoft.AF.Asset.AFElement A in elements.ToList())
{
  p.lastEvent = A.Attributes["Event"].GetValue().Value.ToString();
  AFNamedCollectionList<OSIsoft.AF.Asset.AFElement> voltage = OSIsoft.AF.Asset.AFElement.FindElements(AFSystemDB, elements.ToList()[0], "Voltage", AFSearchField.Name, true, AFSortField.Name, AFSortOrder.Descending, 1);
  p.lastVoltage = voltage[0].Attributes["Value"].GetValue().Value.ToString();
  p.lastVoltageTime = voltage[0].Attributes["Value"].GetValue().Timestamp.LocalTime;
}

 

Outcomes