On Wed, 2 Jun 2004, Joel VanderWerf wrote: > Sven Schott wrote: >> Pstore is a bit too simple as I need something that handles multiple >> clients and I don't really want to write a transaction engine(I'm hardly >> qualified), so MySQL(or Post) would be my first choice. I just really >> wanted to know if using the MySQL ruby libraries would be faster or >> slower than the File ruby library. How well would ruby handle passing >> binary data to MySQL? How fast would it be? Should I just stick to file >> operations? > > As an alternative to PStore, there is my FSDB library[1]. Like PStore, > it's pure ruby. But instead of putting everything in one file, it makes > multiple files look like a database, of sorts. Also, it's thread and > process safe and has simple transactions. It allows multiple back-end > formats for objects: strings (binary or ascii), marshal, yaml, etc. > > I don't expect it will be as fast as as a true database, but it is > convenient to be able to access your "database" as a normal file tree. > > [1] http://redshift.sourceforge.net/fsdb-0.4 i was just checking this out today joel - very cool. marshal aint that slow for medium sized data sets: ~ > ruby pstore_test.rb 8192 schema @ 0.0243198871612549 insert @ 0.0122055444226135 select @ 0.0250020936364308 ~ > ruby sqlite_test.rb 8192 schema @ 0.0509798526763916 insert @ 0.0439234171062708 select @ 0.000174661865457892 ~ > cat pstore_test.rb # # builtin # require 'pstore' n = (n or ARGV.shift).to_i # # connect # db = PStore.new 'pstore.db' # # schema # a = Time.now db.transaction do db['table'] = [] db['pk_index'] = {} end b = Time.now puts "schema @ #{ b.to_f - a.to_f }" # # insert # a = Time.now n.times do |i| db.transaction do table = db['table'] table << [] db['pk_index'][i] = table.size - 1 db['table'] = table end end b = Time.now puts "insert @ #{ (b.to_f - a.to_f) / n }" # # select # a = Time.now n.times do |i| magic = rand n table, pk_index = db.transaction{[db['table'], db['pk_index']]} tuple = table[pk_index[magic]] end b = Time.now puts "select @ #{ (b.to_f - a.to_f) / n }" ~ > cat sqlite_test.rb # # raa # require 'sqlite' n = (n or ARGV.shift).to_i # # connect # db = SQLite::Database.new 'sqlite.db', 0 # # schema # schema = <<-sql create table foo(bar, primary key (bar)); sql a = Time.now db.execute schema b = Time.now puts "schema @ #{ b.to_f - a.to_f }" # # insert # a = Time.now n.times do |i| sql = <<-sql insert into foo values ('#{ i }'); sql db.execute sql end b = Time.now puts "insert @ #{ (b.to_f - a.to_f) / n }" # # select # a = Time.now n.times do |i| magic = rand n sql = <<-sql select * from foo where bar = '#{ magic }' sql db.execute sql end b = Time.now puts "select @ #{ (b.to_f - a.to_f) / n }" i realize the test is neither accurate nor complete - but interesting nonetheless. -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; and a weed grows, even though we do | not love it. --Dogen ===============================================================================