> I have to do this calculation, because the raw data is just times when the
> emp. enter work and leave work.
Just to make it shorter: make an additional field in the data,
containing just hours (decimal hours, with 5 hours 45 minutes expressed
as 5.75) or hours:minutes in two fields, so you calculate that only
once.
Another trick is to have each worker's daily totals somewhere,
calculated once the day is over. Now that may make a smaller table and
be indexed by worker's code and date (just two tags), and should work
fast enough to stand minute-by minute recalculation. The limit is that
you are updating it when the day is over; it's fresh with yesterday. If
you want to include today, you can update it at the same time as the raw
data, but then it's hit more often and you might have a
too-much-network-traffic problem.
You might also consider an old xBase programmer's trick: the heavily
loaded transactional tables are split into archive and daily part.
"Daily" means any current period - day, month, week. At the end of the
period, the daily data are moved to the archive. Thus you do all the
quick-and-dirty queries over a small table, and for some heavy reports
you extend your selections to have an union with the archive part. You
can even do this automatically, sending your SQL request to a simple
date-range routine first:
Proc Pre_Select
Para date1, date2
if between(archiving_date, date1, date2)
select * from archive where date between date1 and date2;
union select * from daily where date between date1 and date2;
into curs first
else
select * from daily where date between date1 and date2;
into curs first
endif
So in most cases you open only the second one.