Hello Jeremy, I'm using Sequel to send direct SQL queries. I don't use the SQL generation facilities that much. My queries are multi-line pure SQL queries with lots of joins, window functions and such (I do reporting). I'm using Sequel as a nicer layer for database connection and some models. My queries also take multi-seconds to minutes to execute. That's just me though.
Awesome work on Sequel. François Beausoleil http://blog.teksol.info/ Le mercredi 14 mars 2012 à 16:13, Jeremy Evans a écrit : > Profiling Sequel's performance on simple queries has shown that Sequel can > spend more time building the SQL than the database does on executing it. > There are a couple of likely reasons for this: > > * Ruby is slow (relative to the database) > * Sequel's SQL generation code is very modular (lots of method calls) > > I can't do anything about the former, but the latter can be dealt with a > fairly simple optimization, just manually inlining the method calls. I have a > patch that does that for the PostgreSQL adapter: http://pastie.org/3595976 > > I'm leaning toward not applying this patch. I suspect it will increase > maintenance burden in the future, and while the gains for pure SQL generation > of simple queries are substantial (~40% increase in my testing of simple > queries on 1.9.3), I'm only seeing single-digit increases (7-10%) in > performance for common cases that access the database (#all/#first). Also, > these increases are best-case scenarios, using very simple queries with a > very optimized adapter (pg with sequel_pg). Anyone who wants faster SQL > generation for simple queries would be better off using one of the following: > > * A placeholder string: DB["SELECT * FROM table WHERE column = ?", value] > (150% faster SQL generation) > * A placeholder array: DB.dataset.with_sql(['SELECT * FROM table WHERE column > = '], value) (260% faster SQL generation) > * A prepared statement: ps = DB[:table].where(:column=>:$c).prepare(:select, > :some_name); ps.call(:c=>value) (skips SQL generation completely when called) > > That being said, I'm still open to applying this patch depending on the > response from the community. Any thoughts about whether this patch should be > applied? > > Jeremy > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/sequel-talk/-/Prn7T3gPemEJ. > To post to this group, send email to [email protected] > (mailto:[email protected]). > To unsubscribe from this group, send email to > [email protected] > (mailto:[email protected]). > For more options, visit this group at > http://groups.google.com/group/sequel-talk?hl=en. -- 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.
