In addition to what Hamid mentioned, Indexes are constantly improved from one version to another as Oak version is upgraded with every AEM upgrade. Also, there are new optimizations introduced at oak level that are not available for older versions of oak.
That said, try the following to find more details:
- First, find the query that is slow
- Use the explain query tool to check which index is used for that query on both 6.2 and 6.4
- It might be that different indexes are used for the same query in 6.2/6.4 Or the index definition has been optimized in 6.4
In general having relevant index will improve the query performance. If there is any query that traverse among a large number of nodes then certainly the performance will negatively be affected. Now I am not sure which query you are referring to as being faster in AEM 6.4 but having better indexing can be a potential reason.