Optimization - first name vs last name

Inspired by H0nza's annual optimization email, I'm diving back into optimization for one of my projects. I created a loop that goes to 10 records, and found one change that brings the time to visit 10 records from around 36 seconds to around 9 seconds.

UPDATE: I had a conditional formatting on those fields. It wasn't the "hide object when" that was causing the problem. Removing the conditional formatting speeds it up drastically. SIDE NOTE: If EITHER of these fields had conditional formatting the time was super long.


Staff can search for students. About half the staff members sort students by first name and about half sort them by last name. You can see my layout below (names blocked out for privacy).

I have two indexed text fields (not calculations) which are

CombinedNameFirstLast and CombinedNameLastFirst

When users log in I set a global variable based on their preference of sort order and then in the portal on the lefthand side I put both cached fields and to show the correct one I use:

Hide Object When: $$SortOrder = "Last"
Hide Object When: $$SortOrder = "First"

to show the correct one. When I remove these two hide statements the entire screen speeds by 75%! Things I've tried that didn't have noticeable effect:

  • Making two portals and putting the hide on the entire portal (not faster)
  • Setting a GlobalField instead of $$GlobalVariable for sort order (slower)
  • Using that GlobalField to join to a new table which stores every students name and show the correct related field (slower)

One option would be for me to have two different layouts, but this actually affects half a dozen layouts, so I'd need to make another half a dozen layouts and going forward every change I make would have to be made to two layouts.

I'd have to go and find every script that goes to this layout and put a hook in the script, which won't be that hard with 2empowerFM search tool, and it might be worth it, but I'm wondering if anyone has any other ideas that they might be able to suggest.

So it sounds like the change resulted in an average of 2.7 seconds per record load?

And the change was to remove the two hide conditions, but not remove the actual fields? Was there also a change to the sort condition on the portal during the performance test? I could imagine that removing a portal sort specification could possibly yield this kind of change. Adding or removing the hide conditions, on their own, resulting in this kind of delta is something that I would not have expected.

I had too much clutter on my screen and didn't realize that there was conditional formatting (color change) on those fields. The problem wasn't the "hide" it was the fields having a conditional formatting on them.