I have a table(table1) consists of 5 columns in this order
date | x | y | z | t ... | 10.24 | 12.01 | 6 | 7 ... | 42 | 18 | 12 | 1
and .... This table has 5 million records
I have another table(table2) like table1 structure but it has only 10 rows I want to find the closest path in table1. I use this method to calculate distance between two points
sqrt(pow(table2.x-table1.x,2) + pow(table2.y-table1.y,2) + pow(table2.z-table1.z,2) + pow(table2.t-table1.t,2))
what is the fastest way to find the nearest ones in table1. data of the table2 changes every 10 minutes