The document presents a novel query optimization algorithm called 'sub-join' specifically designed for flash-based databases, addressing the shortcomings of traditional join algorithms in relational database management systems (RDBMS). It emphasizes the advantages of flash memory, particularly its fast random read capabilities, and details the method and performance evaluation of the sub-join algorithm compared to conventional indexed nested-loop joins. Experimental results indicate that sub-join significantly enhances performance in flash memory environments.