Database systems normally have a query processor that can articulate a query in a range of semantically equivalent query plans that will produce the same end result. However, not all such query plans will perform as efficiently as others. The DBMS has a query optimiser that estimates the cost of the various options for query plans and selects the one that is estimated to be most efficient.
However, the query optimiser may select an inefficient plan, or the database may be lacking the indexes needed to execute that query efficiently and the query performance may suffer as a result. When this happens the query may take unacceptably long times to execute, or take up a lot of resources on the server, slowing down other processing. These inefficiencies can be extreme.
When this happens it may be necessary to manually intervene. A developer or DBA can hint or re-write the query so the optimiser chooses an efficient query plan, or add an index to the database that the DBMS can use to process the query efficiently.