[Info-vax] Indexed RMS file question
P. Sture
paul.nospam at sture.ch
Sun Oct 4 10:24:11 EDT 2009
In article <004088ae$0$26779$c3e8da3 at news.astraweb.com>,
JF Mezei <jfmezei.spamnot at vaxination.ca> wrote:
> Not sure this is most efficient, but I have been able to define
> overlapping keys.
>
>
> for instance, primary key is year and record number (reset to 1 each
> start of year), and I also have a date key which consists of year, month
> day.
>
> This way, I can do a search for records between specific dates.
>
> So yes, the indices may not be the most efficient since the year value
> is used in different keys, but it worked.
I'll add that you can also read on partial keys, so in your example
(which you might not want for other considerations), you could simply
define one key as the primary CCYYMMDD plus record number.
To read all records for a year, do as Hein suggests - do a $FIND with a
key length of 4, followed by a set _LIM and $GET operations also with a
key length of 4. Repeat and rinse for a given month by using a key
length of 6. If you only need to read in record number order for month
end or year end reporting, doing it via a sorted extract will save the
overhead of that extra index during daily processing.
Careful design of keys so that partial key reads and read to limit can
be used effectively can reduce the number of keys you need to define.
Don't underestimate the power of sorts for infrequently run jobs;
judicious use of them can diminish the overhead of indexes for the rest
of the time.
--
Paul Sture
More information about the Info-vax
mailing list