Skip to content

Commit

Permalink
perf: add index on created_at_unixtimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
shaojunda committed Dec 18, 2020
1 parent 2e73fcc commit 41d4749
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/models/daily_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ def liquidity
# nodes_count :integer
# locked_capacity :decimal(30, )
#
# Indexes
#
# index_daily_statistics_on_created_at_unixtimestamp (created_at_unixtimestamp)
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIndexOnCreatedAtUnixtimestampToDailyStatistics < ActiveRecord::Migration[6.0]
def change
add_index :daily_statistics, :created_at_unixtimestamp, order: { created_at_unixtimestamp: "DESC NULLS LAST" }
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_10_29_140549) do
ActiveRecord::Schema.define(version: 2020_12_18_065319) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -237,6 +237,7 @@
t.jsonb "nodes_distribution"
t.integer "nodes_count"
t.decimal "locked_capacity", precision: 30
t.index ["created_at_unixtimestamp"], name: "index_daily_statistics_on_created_at_unixtimestamp", order: "DESC NULLS LAST"
end

create_table "dao_contracts", force: :cascade do |t|
Expand Down

0 comments on commit 41d4749

Please sign in to comment.