John Paul Lamontre said this is not an easy question. He writes:
First, run SQL under
(without any parameter).
You will have a complete description of the SQL optimiser process. Inspect in detail each message, checking for a missing index or other requirements of SQL.
If second runs are quicker, SQL has probably delayed the destruction of a temporary index.
I have encountered thie problem sometimes, but was unable to find an explanation.