In college, I was told prepared statements usually don't yield any better performance. But then I wonder why they ever invented.
I would like to see the opinion of someone with a better argument than "hear say". Cheers, Paulo Köch On Wed, Nov 12, 2008 at 00:06, Hongli Lai <[EMAIL PROTECTED]> wrote: > > Hi. > > I've just read the InfoQ interview about Sequel. This paragraph caught > my attention: > > "7) Prepared Statements/Bound Variables: Sequel allows the use of real > database prepared statements and bound variables on some databases, > with emulated support available on all other databases. Prepared > statements can be significantly faster than regular queries depending > on the database being used." > > I'm wondering what exactly the benefits are of "real" database > prepared statements. I know that there's some kind of unwritten rule > that prepared statements are faster than regular queries. Indeed, > almost every single person that I've asked thinks that way, if said > person knows what prepared statements are. However, there seems to be > a total lack of real evidence that prepared statements are faster. > > Almost 2 years ago, I was working on support for prepared statements > in ActiveRecord. I eventually abandoned the effort, and one of the > reasons why I did that was because of lack of real advantages. I had > expected performance improvements, but someone on the Rails mailing > list told me that it could in fact be slower because it would involve > more roundtrips to the database server. And indeed, I measured a > slight (about 5%) overhead in my initial naive implementation, when > running the ActiveRecord unit tests. > Later on I implemented a cache which caches the prepared statements, > and expires statements based on the least-recently-used algorithm. I > managed to make the test suite just as fast as before, but not any > faster, even if I increase the cache's size. I wrote a simple test > program which performs many database insertions, and the version using > prepared statements is only 1% faster than the version without > prepared statements. > > I've searched the internet for evidence that prepared statements are > faster, but I could not find any evidence other than people claiming > that it is so. No benchmarks, no scientific papers, no numbers, > nothing. > > So after reading the InfoQ interview I'm wondering whether you (the > Sequel developers) have any evidence. Do you have any benchmarks? > Under what conditions are prepared statements faster? And if they're > faster, by how much? > > Regards, > Hongli > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
