I'm not sure I understand a prepared statement as it relates to speed or efficiency. I read that a prepared statement is compiled on the database server and can be use over and over.
But, say I have a webpage. It does one query. Next person pulls up the page, same query, just different parameters for that user.
On the second hit to the webpage, is the prepared statement looking on the dbms to see if that particular query already exists on the database server? I don't understand what it means to say the statement is compiled and can be run "over and over." It doesn't prepare it each run of the page?
Also, this is not about sql injection. That's one part I do understand as it relates to compiling.
Thanks.
edit: I have searched, but I cannot find the answer. I am only led to this question.
edit: Based on the comments below, given my scenario, I cannot see any efficiency benefit. Security yes. The whole compiled thing. No. Does anyone have a scenario they can give as an example that does meet the efficiency question?