One nice property of SQL is that the result of every result generating statement is a table itself which we again can query. This property is used in TSQLQueryTableModel to allow the user to limit, filter and sort the result of the query from the table control. It does this by adding these options to an outer query which selects from an inner query which equals the provided query. This approach is easy to implement and guaranteed to work for every type of query.
Class TOldSQLQueryTableModel was developed to counteract the problem of MySQL that it is not always able to properly optimize queries with the subqueries that are constructed in the above approach. The approach of the old query table model was to optimize the query by removing the need of a subquery entirely and add restrictions and sort columns to original query instead. Although being much faster in the case of MySQL this approach was not implemented in such a way that it guaranteed to return the correct result for all types of queries. For instance, when the original query already had a LIMIT clause, the old query table model did not work well. Furthermore, the MySQL subquery limitations are encountered not only in table models but during the execution of other queries as well.
We should phase out the TOldSQLQueryTableModel in favor of TSQLQueryTableModel. In most of the cases this means we can drop the "Old" part from the class name wherever the class is used and then we are ready. However, we should test whether this introduces performance problems which should be addressed immediately. If this is the case we should solve the performance problems by adding optimization rules to TMySQL which should detect and rewrite the ill performing query. Please note that this optimizer has not yet been written. We first need to address how big the performance problem is as recent announcements show that MySQL has gained some extra optimizations in the area of subqueries. MySQL 5.1 should be better than 5.0 and MySQL 5.4 should even be better than 5.1.