Is it faster to use a complicated boolean to limit a ResultSet at the MySQL end or at the Java end?

Posted by javanix on Stack Overflow See other posts from Stack Overflow or by javanix
Published on 2010-04-24T21:59:33Z Indexed on 2010/04/24 22:03 UTC
Read the original article Hit count: 215

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about java

Related posts about mysql