Permalink
Browse files

Significant (98.87%) improvement in the speed up Vehicles#Current dat…

…abase queries. 1046ms -> 1ms
  • Loading branch information...
bamnet committed Dec 4, 2010
1 parent f086222 commit 52aad0d3d02db88be51654879af468e9663d2bd7
Showing with 12 additions and 1 deletion.
  1. +9 −0 db/migrate/20101204232129_add_vehicle_timestamp_index_to_updates.rb
  2. +3 −1 db/schema.rb
@@ -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
View
@@ -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
@@ -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

0 comments on commit 52aad0d

Please sign in to comment.