Duplicate holidays, and a question

One can, in fact, have too many holidays.

Koha uses the DateTime::Set Perl module when (among other things) calculating the next day the library is open. Unfortunately, the more special holidays you have in a Koha database, the more time DateTime::Set takes to initialize itself — and the time appears to grow faster than linearly with the number of holidays.

Jonathan Druart partially addressed this with his patch for bug 11112 by implementing some lazy initialization and caching for Koha::Calendar, but that doesn’t make DateTime::Set‘s constructor itself any faster.

Today I happened to be working on a Koha database that turned out to have duplicate rows in the special_holidays table. In other words, for a given library, there might be four rows all expressing that the library is closed on 15 August 2014. That database contains hundreds of duplicates, which results in an extra 1-3 seconds per circulation operation.

The duplication is not apparent in the calendar editor, alas.

So here’s my first question: has anybody else seen this in their Koha database? The following query will turn up duplicates:

SELECT branchcode, year, month, day, isexception, COUNT(*)
FROM special_holidays
GROUP BY 1, 2, 3, 4, 5
HAVING COUNT(*) > 1;                    

And my second question: assuming that this somehow came about during normal operation of Koha (as opposed to duplicate rows getting directly loaded into the database), does anybody have any ideas how this happened?

CC BY-SA 4.0 Duplicate holidays, and a question by Galen Charlton is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

3 thoughts on “Duplicate holidays, and a question

  1. Lots of duplicates in mine after trying out a few things… just a bit hard to replicate reliably. I am quite sure by now that it’s related to copying holidays from one branch to another.

  2. Hm, I think I have a repeatable test case:
    1) add a yearly holiday
    2) add an exception for it
    3) copy to another branch
    It also looks like the exceptions won’t get copied, but only the holidays.

Comments are closed.