Comment 16 for bug 590708

Revision history for this message
Leonard Richardson (leonardr) wrote :

Let me explain the optimization I was investigating, since it hasn't been recorded here.

The idea is to avoid running the count(*) query when the total size of the collection is less than the batch size. If we know this bit of information, we know what value to put for total_size, and we know not to include next_collection_link or prev_collection_link.

The trick is to find the total size of the collection without triggering _Batch.listlength, which will run the count(*) query. This turns out to be fairly difficult in our existing system. The _Batch constructor calls .listlength if no value for it is passed in, and the BatchNavigator constructor (which is what lazr.restful uses) invokes _Batch() without passing in that argument. So right now, the count(*) query is run as soon as we create the BatchNavigator object.

This optimization should not be incredibly difficult, but it's not nearly as easy as I thought, and it may require changing lazr.batchnavigator as well as lazr.restful. Since neither of our users will benefit from this optimization, I suggest we shelve it.