[Koha-bugs] [Bug 30017] New: Should we prefer iterator.first over calling variable.count to reduce our DB hits
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Thu Feb 3 16:05:13 CET 2022
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 at myacpl.org
Reporter: martin.renvoize at ptfs-europe.com
QA Contact: testopia at 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.
More information about the Koha-bugs
mailing list