Try OpenEdge Now
skip to main content
Database Essentials
Database Design : Defining indexes : Indexing basics : How indexes work
 
How indexes work
A database index works like a book index. To look up a topic, you scan the book index, locate the topic, and turn to the pages where the information resides. The index itself does not contain the information; it only contains page numbers that direct you to the pages where the information resides. Without an index, you would have to search the entire book, scanning each page sequentially.
Similarly, if you ask for specific data from a database, the database engine uses an index to find the data. An index contains two pieces of information—the index key and a row pointer that points to the corresponding row in the main table. The following figure illustrates this using the Order table from the Sports 2000 database.
Figure 9. Indexing the Order table
Index table entries are always sorted in numerical, alphabetical, or chronological order. Using the pointers, the system can then access data rows directly, and in the sort order specified by the index.
Every table should have at least one index, the primary index. When you create the first index on any table, OpenEdge assumes it is the primary index and sets the Primary flag accordingly. In the above figure, the Order-Num index is the primary index.