Searching an arraylist of size 25000 (using contains method) or queryig a database table of the same size, which is faster?
We have to validate a field entered by the user, we can cache the master data for that field in application scope in an arraylist and use contains function to look for the validity of user entered data. Or fire an SQL (Oracle database) to check if the data exist. caching 25000 records in Tomcat server is it advisable? is the contains function faster than SQL considering the network round trip required for a database call?