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

Flowchart shows am_scancost pointing to am_open, which points to am_beginscan, which points to am_getnext. If the am_getnext returns MI_ROWS, the scan executes am_getnext again. If am_getnext returns MI_NO_MORE_RESULTS, the scan continues to am_endscan, which points to am_close.