I must check approximately 1000 numbers against 1000 other numbers.
I loaded both and compared them server-side:
foreach( $numbers1 as $n1 ) {
foreach( $numbers2 as $n2 ) {
if( $n1 == $n2 ) {
doBla();
}
}
}
This took a long time, so I tried to do the same comparison client side using two hidden
div
elements. Then compared them using JavaScript. It still takes 45 seconds to load the page (using hidden div
elements).
I do not need to load the numbers that are not the same.
Is there a faster algorithm? I am thinking of comparing them database side and just load the error numbers, then do an Ajax call for the remaining non-error numbers. But is a MySQL database fast enough?
Thank you, it would help me out very much.