API version 8 and fast vs. slow

I’ve been talking about Apex a lot lately, but I want to go back and sing the praises of the 8.0 API which was released in January. I know that’s old news, but it has made our daily work much more palatable.

I built an S-Control that is a weekly timesheet. It allows us to track our time against projects. The interface shows a lot of data–each time entry has basic info (hours, date, comments) and also is related to an Opprotunity, and Account, and one other custom object. In a typical week, each person would have 20-40 time entries.

timecard.png

With the 7.0 API, I would load all the time entries for the current week–one Query. Then, for each time entry, I had to Retrieve data from the Opportunity, Account, and custom object, so the names of each would be displayed. That’s 3 more calls. So a by the end of a typical week, loading the timesheet for a person would take 100+ calls to the API. It was slow.

With the 8.0 API, I do things a little differently. I make an initial Query call to get the time entries. Using a feature called Relationship Queries, that initial call also pulls in the related information from the Opportunity, Account, and custom object. So at the end of a typical week it takes 1 call to load the timesheet.

Because of the 8.0 API I got rid of 99% of my API hits. I think this is a fairly common use case, so I can imagine lots of application developers are feeling this kind of improvement. Not surprisingly, my users have noticed the performance improvements, and in their eyes the timesheet app has gone from a bit painful to painless.

2 Responses to “API version 8 and fast vs. slow”

  1. benji jasik Says:

    Great to hear! People can also reduce API calls by using Outbound Messaging instead of polling for changes.

  2. Steve Says:

    Yeah, outbound messages are really cool. I was just talking with Evan about how he’s using one to fire emails to Contacts when they are created. Cool thing is it fires even if the Contacts are created via a bulk import.

    I could also have reduced my calls by taking my initial query result and do the Retrieve call with an array of all the Id’s I need to look up. If you guys hadn’t released relationships in SOQL, that’s what I would have done next.

Leave a Reply