6074: Speed up db query by using octet_length() instead of length(). closes #6223
authorTom Clegg <tom@curoverse.com>
Wed, 3 Jun 2015 19:39:01 +0000 (15:39 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 3 Jun 2015 19:39:01 +0000 (15:39 -0400)
services/api/app/controllers/application_controller.rb

index 6810d91d4cd6c235751365b1e6d1856a5f6a19b8..e6a02b1e12c67a795cbaa877cc997d7e406f1795 100644 (file)
@@ -302,7 +302,7 @@ class ApplicationController < ActionController::Base
     model_class.transaction do
       limit_query = @objects.
         select("(%s) as read_length" %
-               limit_columns.map { |s| "length(#{s})" }.join(" + "))
+               limit_columns.map { |s| "octet_length(#{s})" }.join(" + "))
       new_limit = 0
       read_total = 0
       limit_query.find_each do |record|