Database developers speak fluent index language—B-tree, primary key, clustering. Easytrieve TABLE indexing is simpler and more rigid: one search key layout called ARG, sorted ascending, loaded into memory, queried by binary search through SEARCH. You do not issue CREATE INDEX or maintain separate index datasets. The product builds the in-memory structure when INSTREAM rows compile into the program or when an external maintenance file loads at JOB initiation. Understanding indexing explains why ARG sort order is non-negotiable, why duplicate keys break lookups, how composite business keys map to a single ARG definition, and how max-entries reserves slots for external tables. This page teaches table indexing concepts for beginners migrating from Db2 or VSAM KSDS mental models: what is indexed, when indexing happens, field layout rules, composite key patterns, memory reservation, and operational validation after reference data changes.
Every TABLE file has exactly one ARG definition describing where the search key sits in each table row. DESC holds payload data returned on match but is not part of the index. Think of ARG as the primary key in a miniature keyed table Easytrieve manages for you. SEARCH WITH compares your search-field to ARG values using the indexed order. Misaligned ARG—wrong start position or length—indexes garbage bytes and every lookup fails or matches wrong rows.
12345678FILE STATTAB TABLE INSTREAM ARG 1 1 A DESC 3 15 A A ACTIVE I INACTIVE P PENDING S SUSPENDED ENDTABLE
Single-character status codes index alphabetically: A, I, P, S. WITH STATUS must be one-byte alphanumeric matching ARG layout.
| Table source | When indexed | Notes |
|---|---|---|
| INSTREAM | Compile time | Rows embedded in source; index ships in load module |
| External sequential | JOB initiation | Load reads maintenance file once; index built before first SEARCH |
| Re-Search same run | No rebuild | Index persists for job duration; table data static during run |
Index structure assumes monotonic ascending ARG. Maintenance teams must sort before load. Instream authors must type rows in order. Validation utilities can read a maintenance file and compare each ARG to the prior row, flagging inversions before production JCL runs. One inversion near the middle of a ten-thousand-row table can make half of valid keys unreachable to binary search—a failure mode that looks like bad input data instead of bad index data.
Business keys often combine region, branch, and product code. TABLE allows one ARG field spanning the concatenated bytes—not three separate SEARCH calls on three ARG columns.
1234567891011121314DEFINE COMP-KEY W 9 A FILE PRODTAB TABLE INSTREAM ARG 1 9 A DESC 11 30 A EAST01ABC WIDGET STANDARD EAST01XYZ WIDGET PREMIUM WEST02ABC GADGET STANDARD ENDTABLE MOVE REGION TO COMP-KEY POS 1 MOVE BRANCH TO COMP-KEY POS 3 MOVE PROD TO COMP-KEY POS 6 SEARCH PRODTAB WITH COMP-KEY GIVING PROD-DESC
Composite ARG sorts lexicographically on the full nine bytes. EAST01ABC precedes EAST01XYZ; WEST02ABC follows all EAST keys. WITH field must match nine-byte layout exactly. Padding rules apply—shorter branch codes need consistent spaces or zeros in COMP-KEY construction.
Numeric ARG indexes by numeric value. Alphanumeric indexes by character collating sequence. Choose ARG type to match how input keys are stored. Department 417 as numeric ARG sorts before 903; as alphanumeric '417' and '903' still sort correctly but '0417' and '417' differ. Index compare uses declared length—truncated keys on input never match padded table ARG.
123FILE ZIPTABLE TABLE 5000 ARG 1 5 N DESC 7 20 A
FILE TABLE 5000 reserves memory for five thousand rows at initiation. The index contains at most that many entries. If maintenance delivers six thousand zips, the last thousand are dropped at load—SEARCH returns NOT FOUND for those keys with no diagnostic unless you compare load counts. Size max-entries above current row count with growth headroom; document peak historical counts.
Each indexed row consumes memory for ARG, DESC, and internal structure. Large DESC fields multiply footprint: ten thousand rows with two-hundred-byte descriptions differ materially from ten thousand rows with twenty-byte descriptions. Indexing does not spill to disk mid-job—entire table must fit available region. Programs with many large external tables can face storage abends at initiation before first SEARCH.
Easytrieve does not support online reindex during a run. To change table content for external tables, replace maintenance file and rerun JOB—initiation rebuilds index. INSTREAM changes require recompile. Operations schedule reference file regeneration; developers recompile when instream codes change. There is no REINDEX verb.
| Feature | Easytrieve TABLE | Db2 / SQL FILE |
|---|---|---|
| Key definition | Single ARG layout | Primary key, multiple indexes |
| Maintenance | Sort file or edit INSTREAM | SQL INSERT UPDATE DELETE |
| Lookup statement | SEARCH | SQL SELECT |
| Scale | Memory-bound thousands | Large shared tables |
Table indexing is putting flashcards in alphabetical order by the word on the front. The word on the front is ARG; the answer on the back is DESC. Easytrieve stacks the cards in order once so finding a word is fast. If two cards have the same front word or the stack is out of order, the fast-finding trick breaks.
1. The searchable index for TABLE files is built on:
2. TABLE supports how many ARG fields per table?
3. max-entries on FILE TABLE reserves:
4. Composite key indexing uses:
5. INSTREAM table indexing occurs at: