On Nov 22, 5:52 am, Ciaran Archer <[email protected]> wrote:
> Hi there
>
> We've been evaluating the use of Sequel with SQL Server, and as poart
> of this we've been benchmarking Sequel against AR.
>
> We're using JRuby, and Torquebox as our application server for all
> tests. We are using Sinatra as our web framework and Apache Bench to
> run the tests. A SQL Server 2008 R2 instance is being used for the
> tests.
>
> Our benchmark test is very simple, return all rows in a table and
> print them to the standard output. The test table has 72 rows.
>
> AR BENCHMARK RESULTS
>
> Requests per second:    182.08 [#/sec] (mean)
> Time per request:       54.922 [ms] (mean)
>
> SEQUEL BENCHMARK RESULTS
>
> Requests per second:    8.72 [#/sec] (mean)
> Time per request:       1146.993 [ms] (mean)
>
> I've extracted the relevant Sequel code, here:https://gist.github.com/1385695
>
> I am trying to understand why Sequel seems to be doing so poorly and
> I'm hoping someone can tell me where I might be introducing an issue,
> or where I might be able to improve things.

One area where ActiveRecord can perform better than Sequel is where
you are selecting fields you don't need.  This is because Sequel does
typecasting on retrieval, while ActiveRecord does typecasting on
access. You appear to only be using the firstname field in the query,
so you can try:

  def self.get_all
    dataset.select(:firstname).filter("clientid > 0")
  end

Since you are also using JDBC, you can try turning off type conversion
in the Sequel jdbc driver:

  @sia_db.convert_types = false

You can also try the master branch, which has significant speedups for
typecasting in the jdbc driver.

If I had to guess, I would guess there are date fields in the table
that you are retrieving but not accessing.  Ruby's Date class (pre
1.9.3 stdlib, and JRuby is either 1.8.7 or 1.9.2 stdlib) is
exceptionally slow, and it could cause the difference in performance
that you are seeing.

In general, if you want to see _why_ something is slow, you need to
profile the code.  For MRI, you can use ruby-prof to do this.  I know
there are also profilers for JRuby, but I'm not familiar with them.

Jeremy

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

Reply via email to