I've been using the activerecord adapter for sqlite (without rails), and when I try to insert anything it seems to be too slow. For instance when I do ~250 inserts it could easily take more than 5 minutes! My schema is the following:
create_table :courses do |t|
t.string :title
t.integer :ethmmy_id
end
add_index :courses, :ethmmy_id
create_table :announcements do |t|
t.string :title
t.string :author
t.string :body
t.string :uhash
t.belongs_to :courses
t.timestamps null: false
end
add_index :announcements, :courses_id
The ActiveRecord models I use are the following:
class Course < ActiveRecord::Base
validates :ethmmy_id, uniqueness: true
has_many :announcements
end
class Announcement < ActiveRecord::Base
validates :uhash, uniqueness: true
belongs_to :course
end
I've tried modifying the PRAGMAS like setting the journal in memory or setting synchronous I/O off but there doesn't seem to be much of a difference. The data is fetched from a web crawler but that is not the bottleneck, as the crawler is pretty fast by itself.
Aucun commentaire:
Enregistrer un commentaire