Prepared Statement vs. Stored Procedure

John picture John · Oct 13, 2008 · Viewed 21.3k times · Source

If you are using php5 and mysql5, is there a substantial advantage to using stored procs over prepared statements? ( i read somewhere you may not get substantial performance gains from mysql5 stored proc)

Answer

Toby Hede picture Toby Hede · Oct 13, 2008

They are not really the same thing - with stored procedures, your database logic resides inside the database. Prepared statements basically avoid re-parsing queries if they are called multiple times - the performance benefit can vary greatly.

The choice to use one or the other is really dependent on your specific situation. I don't really use stored procs anymore as I like having all of my logic in one place.