Is it faster to use a complex boolean to restrict the ResultSet at the end of MySQL or at the end of Java?

Let's say I have a really big table filled with a lot of data (let's say enough to not fit comfortably in memory), and I want to analyze a subset of the rows.

This usually happens faster:

SELECT (column1, column2, ... , columnN) FROM table WHERE (some complicated boolean clause);

and then use a ResultSet, or it can be done faster:

SELECT (column1, column2, ... , columnN) FROM table;

and then iterate over the ResultSet, taking different strings based on the java version of your logical condition?

I think it comes down to whether the Java iterator / Boolean evaluator is faster than the MySQL logical evaluator.

+3
source share
4 answers

.

  • , .
  • - , . , .
+13

, , Java-/ , MySQL boolean .

. , ( ). - , 99% . , .

+4

, . . , , . , , , . , , , Java, .

+3

. . , , , , .

This is a bit like asking if data should be loaded into Excel first, and datawad can be stored in memory more than Excel.

+1
source

Source: https://habr.com/ru/post/1742614/


All Articles