Each query is optimized by the database engine before execution. This means that the engine tries to find the fastest plan to execute the query.
There are several factors affecting the execution time. For example:
- presence of relevant indexes
- statistics used by the optimizer
- the number of permutations calculated during the optimization
- workload when the query is executed
- presence of the desired data blocks in the memory
- workload on the network when returning results and so on.
So what you should do is to investigate the plans of different queries. To star, have a look at the documentation at:
Obtaining Query Execution Plan Information[
^]