On May 14, 8:25 pm, "Mislav Marohnić" <[EMAIL PROTECTED]> wrote: > So, every query ever issued will become a prepared statement. Isn't this > going to lead to unnecessary overhead? I mean, there are *a lot* of various > SELECT statements generated by even a simple Rails application. Does it > really make sense to prepare every one of them? Having backends cache the > execution plan for rare SELECTs can possibly have undesirable overhead. > Also, how will ActiveRecord know how to reuse these statements? For example: > > a = Author.find(1) > post = Author.posts.first > post.author > > The first and the last query are different to AR, yet they take a same shape > ("SELECT * FROM authors WHERE authors.id = ?") and can both be represented > by a single prepared statement. With your solution, will AR know how to > reuse the prepared statement in different places, or will it try to prepare > it twice?
The current implementation immediately removes prepared statements after using them once, so they will be reparsed twice. Right now I'm trying to make it actually work and getting the framework in place. Optimization can be done later (and I'm fairly confident that it can be optimized). In the future I can add caching. The cache will have a limited size, and items can be removed based on least-recently-used or some other criteria, similar to how CPU caches work. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---