The SELECT...WHERE statement interface

The following figure shows the order in which the database server executes purpose functions for a SELECT statement with a WHERE clause.
Figure 1: Processing a SELECT statement scan

This flowchart shows am_scancost pointing to am_open, which points to am_beginscan, which points to am_getnext, which either returns MI_ROWS and re-executes, or returns MI_NO_MORE_RESULTS.