educative.io

Performing an intersection won’t be efficient

How efficient would this query be? We have estimated 500M places to be stored in our service. Since we have two separate indexes, each index can return a huge list of places and performing an intersection on those two lists won’t be efficient. Another way to look at this problem is that there could be too many locations between ‘X-D’ and ‘X+D’, and similarly between ‘Y-D’ and ‘Y+D’. If we can somehow shorten these lists, it can improve the performance of our query.
can’t we create a composite index composed of longitude and latitude. that way, we don’t need to worry about intersection of the lists not being efficient.

Hi @Dewey_Munoz

Yes, your approach also seems fine. But when we have this much data, there will be a compromisation whether on time or space. And again, yes, you can follow your approach :slight_smile: