https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30017 Bug ID: 30017 Summary: Should we prefer iterator.first over calling variable.count to reduce our DB hits Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Templates Assignee: oleonard@myacpl.org Reporter: martin.renvoize@ptfs-europe.com QA Contact: testopia@bugs.koha-community.org I noticed a pattern recently whereby we often call a count prior to iterating over the resultset: [% IF things.count %] <table> . . . [% FOREACH thing IN things %] <td>[% thing.whatever %]</td> [% END %] </table> [% END %] This introduces a count(*) DB call. We could instead use the first iteration of the iterator to setup the boilerplate and reduce our DB hits. [% FOREACH thing IN things %] [% IF thing.first %] <table> [% END %] <td>[% thing.whatever %]</td> [% IF thing.last %] </table> [% END %] [% END %] -- You are receiving this mail because: You are watching all bug changes.