You’re looking for a file, and you know that you just saved it.
You know where you hoped this file was saved, but you just don’t see it. So you try searching your computer, and end up really frustrated. This paper is due in ten minutes, and your computer is taking its sweet time searching. And you know you have the right filename because you just saved it. So you ask your friend Google where Word saves temporary files, just in case your computer did something weird.
And in the blink of an eye, Google gives you an ordered list of relevant results. Google’s computers looked through trillions of Web pages, ranked their relevance to your specific problem, and listed them in order for you.
Meanwhile, your computer keeps spinning away, taking thousands of times longer to search a database a million times smaller than Google’s. So how does Google do it?
You might assume that Google’s computers are just faster than yours, and that’s probably true. But computing power isn’t the main reason for Google’s impressive speed. Instead, it comes down to their famous algorithm. An algorithm is just any kind of procedure that you follow in order to accomplish something. And with Google or any other search engine, the algorithm is what turns your search into pages of results. The algorithm can work so fast because the search engine doesn’t actually look through those trillions of pages in that split-second between your search and the results showing up on your screen. That would take way too much time, and this isn’t the dial-up era anymore. We want our results now.
Search engines don’t look through all those pages when you search because they already did. A search engine’s computers are constantly crawling the Web. They follow links from site to site, creating gigantic lists of which pages have which words, how many times those words appear on each page, how important those pages are to the rest of the internet, and all kinds of stuff like that.
The exact way a search engine decides which results to show you is generally a secret, since they want to stop sites from gaming the system so they’re higher in the search results. But it all depends on how these gigantic lists are sorted and combined into what’s called an index, which is a lot like the index you’d find in the back of a book. When you search, the search engine’s computers just check the index, find the entries that are most relevant, and then send them back to you in the right order. This might sound more complicated than searching the pages themselves each time, but think about how much easier it is to find something in the book’s index than it is to flip and skim through every page to find what you’re looking for. The index is faster because whoever made it did all the work for you by putting the book’s topics in a nice, orderly list.
And their hard work is worth it, because the index lets you find whatever you want way faster than you could’ve otherwise. Google’s computers also put a ton of time and effort into making the index, but all that effort’s worth it. The index dramatically speeds up each of the roughly forty thousand searches that Google answers every single second.
So why doesn’t your home computer or laptop make an index if it’s easier to search through than files themselves? Well, some modern computers do, which lets them search for files pretty quickly. And those that don’t can generally make an index if you ask nicely. Or, really, if you change the right setting. But some people tell their computers not to bother making an index, because making and maintaining an index takes time and computer power that can slow a computer down. If you search without an index, your computer pretty much has to go through each of those files to see if it has what you’re looking for, which is why searching a computer can be so painfully slow sometimes. And that’s why you’re watching your ten minutes tick away as your computer asks each and every song you own if it’s your term paper.