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].
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.

Reply via email to