This happens in under a second. Various factors and algorithms are used to generate the best possible search result or a search result page from the indexed data. Google always tries to answer the search query in the best possible way. This also applies to advertisements in Google search. The focus is always on the user and his search intention.