Forum OpenACS Development: Ordering photos in the photo album

Hi, I'm workin on letting the user change the order of the photos in the photo album, just like one can change the order of the slides in wp, so I did some database changes to store the sort key of the photo and then I saw this comment just above the query that gets the photos of one page:

"    # I query the data without an orderby in the sql to cut the querry time
    # and then sort the returned data manually while constructing the multirow datasource.
    # This goes against the theory of let oracle do the hard work, but load testing and
    # query tuning showed that the order by doubled the query time while sorting a few rows in tcl was fast "

I tried to write him/her but the email no longer exists, so... does anyone knows how to order an array in tcl? or may be another way to do this sort in order to avoid slowing down the query?

I will do the sort in the sql by the moment and wait if someone can give me a help :)

Thanks!

Collapse
Posted by Jeff Davis on
you should not need to add any metadata for sorting photos since you should be manipulating the cr_child_rels order_n field for sort order of photos withing a folder.
select * from cr_child_rels where relation_tag = 'pa_album-pa_photo';
to see the rows that are there.

I doubt sorting in the db is really that bad if there are statistics on the db and the query optimizer works.

Collapse
Posted by Bart Teeuwisse on
I've modified my copy of photo album to use the order_n field to sort photos. The order_n values can be modfied on the album edit page.

I recommend coordinating your changes with Rocael whom I've sent my changes and is committing many of them along with his own work to the OpenACS repository.

/Bart