Skip to content
This repository has been archived by the owner on Sep 5, 2021. It is now read-only.

Commit

Permalink
Significant (98.87%) improvement in the speed up Vehicles#Current dat…
Browse files Browse the repository at this point in the history
…abase queries. 1046ms -> 1ms
  • Loading branch information
bamnet committed Dec 4, 2010
1 parent f086222 commit 52aad0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
@@ -0,0 +1,9 @@
class AddVehicleTimestampIndexToUpdates < ActiveRecord::Migration
def self.up
add_index :updates, [:vehicle_id, :timestamp]
end

def self.down
remove_index :updates, [:vehicle_id, :timestamp]
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20101108204713) do
ActiveRecord::Schema.define(:version => 20101204232129) do

create_table "coords", :force => true do |t|
t.decimal "latitude", :precision => 15, :scale => 10, :default => 0.0
Expand Down Expand Up @@ -81,6 +81,8 @@
t.datetime "updated_at"
end

add_index "updates", ["vehicle_id", "timestamp"], :name => "index_updates_on_vehicle_id_and_timestamp"

create_table "users", :force => true do |t|
t.string "username"
t.integer "sign_in_count", :default => 0
Expand Down

0 comments on commit 52aad0d

Please sign in to comment.