Is it faster to use a complicated boolean to limit a ResultSet at the MySQL end or at the Java end?
- by javanix
Lets say I have a really big table filled with lots of data (say, enough not to fit comfortably in memory), and I want to analyze a subset of the rows.
Is it generally faster to do:
SELECT (column1, column2, ... , columnN) FROM table WHERE (some complicated boolean clause);
and then use the ResultSet, or is it faster to do:
SELECT (column1, column2, ... , columnN) FROM table;
and then iterate over the ResultSet, accepting different rows based on a java version of your boolean condition?
I think it comes down to whether the Java iterator/boolean evaluator is faster than the MySQL boolean evaluator.