This is normal behavior in SQL databases.
The first time you run it, it has to come up with an execution plan, so that takes the longest.
After that, the first time you run it with one set of parameters, it has to find that data, but it saves the results in memory. So, when you run the exact same thing again, it runs very fast.
The whole idea is that, as the database is used more and more, it stores the most important and common data and the most important and common queries, so that they run very fast.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon