Bug #465

avatar

ActiveFedora::Base#fields method performance issues

Added by Willy Mene 344 days ago. Updated 311 days ago.

Status:Closed Start:08/19/2009
Priority:Normal Due date:
Assigned to:- % Done:

0%

Category:- Spent time: -
Target version:1.0.7
Sponsor:


Description

We ran into some performance issues with MetadataDatastreams and using
the ActiveFedora::Base#fields method to access the fields within those
datastreams. In our application, we have an ActiveFedora object with
a couple of MetadataDatastreams. We found that it took a long time to
render the page that displayed all of those metadata fields. So I dug
a little deeper, and found that to render this one page for this one
object, we were making 75 getObjectXML calls to Fedora. We thought we
were only doing one getObjectXML call for the page.

So, the controller would load our ActiveFedora object once and pass it
to the view. To display the value of one field, we would do something
like:
@af_obj.fields[:name][:values].first.

Working with the object on the console, I observed that each #fields
call made 2 getObjectXML calls to Fedora.

To speed things up, we've eliminated all #fields method calls, and
read values directly from the datastream.

History

Updated by Matt Zumwalt 336 days ago

avatar
  • Target version set to 1.0.9

Updated by Matt Zumwalt 314 days ago

avatar
  • Target version changed from 1.0.9 to 1.0.7

Updated by Willy Mene 314 days ago

avatar

ActiveFedora::Base#fields calls Fedora::FedoraObject#create_date and Fedora::FedoraObject#modified_date. However, when an object is loaded, those attributes are not set. This causes #properties_from_fedora to be called, which does the unnecessary objectXML call, once for each method.

Updated by Matt Zumwalt 311 days ago

avatar
  • Status changed from New to Closed

I'm 99% certain that this was caused by the fact that Base.fields relies on Base.datastreams. I've fixed the datastreams method, so now fields should work efficiently as well. Closing the bug. Re-post if inefficiencies persist in 1.0.7+

Updated by Willy Mene 311 days ago

avatar

Hmm, the first line of Base.fields (line 346 in active-fedora-1.0.6.5/base.rb) makes the call to FedoraObject.create_date and FedoraObject.modified_date BEFORE the call to Base.datastreams in the third line of the field (line 347), so I think the problem is still there. Look at these methods in FedoraObject, and you will see the potential to make an objectXML call.

Updated by Matt Zumwalt 311 days ago

avatar

Thanks for reminding me. I've updated the Base.refresh method, which gets called when you save an object, to pull all of the object attributes from Fedora. This has the drawback of adding a call to objectXML whenever you save an object. #493 will fix this, calling .profile instead of .object_xml

Also available in: Atom PDF