Making my Container Ordered breaks client side performance

Hi

I have a custom made Container which I’ve used for quite some time. It implemented only the Container interface and was used in Tables. Everything worked fine. Then I got a task to preselect the first item in a Table with ~50000 items in it. The custom made Container loads stuff lazily from the database so that item count was just fine performance wise.

In order to select the first item, I had to know what the first item was. So I decided to do this all nice and official and implemented the methods of Container.Ordered. After making the changes and unit tests to make sure it worked, I tried it out. The result: My Table became laggy as hell.

It turns out that when I scroll the table around, there are constant calls to the Container.Ordered methods. nextItemId() is called a bazillion times and lastItemId() get called slightly less, but a zillion times nonetheless.

These method calls weren’t needed before and they certainly aren’t serving any purpose right now either. I’ll probably have to make my own duplicate methods into my Tables and Containers and forget about the official interfaces so that everything works.

Does anyone know what’s causing this and how to avoid it without having to “go unofficial”.

Hi!

You need to implement Container.Indexed to get things working smoothly. If indexed sub interface is not implemented, Table needs to do expensive workarounds to do lazy loading properly.

cheers,
matti

Thanks Matti!

I thought I’d do things one step at a time, since Ordered is a subset or Indexed. I’ll implement Indexed now.