Merge pull request #4263 from coopdevs/index-frequent-spree-orders-query

Index spree_orders on various columns
This commit is contained in:
Pau Pérez Fabregat
2019-09-19 10:12:54 +02:00
committed by GitHub
3 changed files with 16 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
class AddLongCompoundIndexOnSpreeOrders < ActiveRecord::Migration
def change
add_index(
:spree_orders,
[:completed_at, :user_id, :created_by_id, :created_at],
name: 'spree_orders_completed_at_user_id_created_by_id_created_at_idx'
)
end
end

View File

@@ -0,0 +1,5 @@
class DropCompletedAtIndexOnSpreeOrders < ActiveRecord::Migration
def change
remove_index :spree_orders, :completed_at
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20190913023137) do
ActiveRecord::Schema.define(:version => 20190916110029) do
create_table "adjustment_metadata", :force => true do |t|
t.integer "adjustment_id"
@@ -576,7 +576,7 @@ ActiveRecord::Schema.define(:version => 20190913023137) do
t.integer "created_by_id"
end
add_index "spree_orders", ["completed_at"], :name => "index_spree_orders_on_completed_at"
add_index "spree_orders", ["completed_at", "user_id", "created_by_id", "created_at"], :name => "spree_orders_completed_at_user_id_created_by_id_created_at_idx"
add_index "spree_orders", ["customer_id"], :name => "index_spree_orders_on_customer_id"
add_index "spree_orders", ["number"], :name => "index_orders_on_number"