From fe51243cad5b6caefb76c71d6325a288203817ec Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 1 Jun 2015 09:51:36 +0500 Subject: [PATCH] speed up maintainer queries --- ...601043133_add_order_index_to_build_list_packages.rb | 10 ++++++++++ db/schema.rb | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20150601043133_add_order_index_to_build_list_packages.rb diff --git a/db/migrate/20150601043133_add_order_index_to_build_list_packages.rb b/db/migrate/20150601043133_add_order_index_to_build_list_packages.rb new file mode 100644 index 000000000..6907c6fdf --- /dev/null +++ b/db/migrate/20150601043133_add_order_index_to_build_list_packages.rb @@ -0,0 +1,10 @@ +class AddOrderIndexToBuildListPackages < ActiveRecord::Migration + def up + add_index :build_list_packages, name: :build_list_packages_ordering, + expression: "lower(build_list_packages.name) ASC, length(build_list_packages.name) ASC" + end + + def down + remove_index :build_list_packages, name: :build_list_packages_ordering, if_exists: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 6f34e3bfc..594de1336 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150529034800) do +ActiveRecord::Schema.define(version: 20150601043133) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -102,6 +102,7 @@ ActiveRecord::Schema.define(version: 20150529034800) do t.string "sha1" t.integer "epoch" t.text "dependent_packages" + t.index :name => "build_list_packages_ordering", :expression => "lower((name)::text), length((name)::text)" t.index ["actual", "platform_id"], :name => "index_build_list_packages_on_actual_and_platform_id" t.index ["build_list_id"], :name => "index_build_list_packages_on_build_list_id" t.index ["name", "project_id"], :name => "index_build_list_packages_on_name_and_project_id"