README.rdoc in swift-0.6.1 vs README.rdoc in swift-0.7.0
- old
+ new
@@ -7,15 +7,21 @@
A rational rudimentary object relational mapper.
== Dependencies
* ruby >= 1.9.1
-* dbic++ >= 0.1.6
-* mysql >= 5.0.17 or postgresql >= 8.4
+* dbic++ >= 0.4.0 (http://github.com/deepfryed/dbicpp)
+* mysql >= 5.0.17 or postgresql >= 8.4 or db2 >= 9.7.2
-dbic++ can be found here http://github.com/deepfryed/dbicpp
+== Caveats
+=== DB2
+* The server needs to be running under DB2_COMPATIBILITY_VECTOR=77FF if you want to use the ORM
+ features of swift.
+* DB2 asynchronous operations are highly experimental at this point due to inherent limitations of the
+ underlying api. It is more an academic exercise and is not ready for real-world use.
+
== Features
* Multiple databases.
* Prepared statements.
* Bind values.
@@ -69,11 +75,11 @@
class User < Swift::Scheme
store :users
attribute :id, Swift::Type::Integer, serial: true, key: true
attribute :name, Swift::Type::String
attribute :email, Swift::Type::String
- attribute :updated_at, Swift::Type::DateTime
+ attribute :updated_at, Swift::Type::Time
end # User
Swift.db do |db|
db.migrate! User
@@ -167,11 +173,11 @@
User.first(':name = ?', 'James Arthurton')
User.first(':name = ?', 'James Arthurton') # Gets same object reference
=== Bulk inserts
-Swift comes with adapter level support for bulk inserts for MySQL and PostgreSQL. This
+Swift comes with adapter level support for bulk inserts for MySQL, PostgreSQL and DB2. This
is usually very fast (~5-10x faster) than regular prepared insert statements for larger
sets of data.
MySQL adapter - Overrides the MySQL C API and implements its own _infile_ handlers. This
means currently you *cannot* execute the following SQL using Swift
@@ -189,22 +195,24 @@
File.open('/tmp/users.tab') do |file|
count = db.write('users', %w{name email balance}, file)
end
end
-You are not just limited to files - you can stream data from anywhere into MySQL and
-PostgreSQL directly without creating temporary files.
+You are not just limited to files - you can stream data from anywhere into your database without
+creating temporary files.
== Performance
Swift prefers performance when it doesn't compromise the Ruby-ish interface. It's unfair to compare Swift to DataMapper
and ActiveRecord which suffer under the weight of support for many more databases and legacy/alternative Ruby
implementations. That said obviously if Swift were slower it would be redundant so benchmark code does exist in
http://github.com/shanna/swift/tree/master/benchmarks
=== Benchmarks
+==== ORM
+
The following bechmarks were run on a machine with 4G ram, 5200rpm sata drive,
Intel Core2Duo P8700 2.53GHz and stock PostgreSQL 8.4.1.
* 10,000 rows are created once.
* All the rows are selected once.
@@ -212,33 +220,63 @@
* Memory footprint(rss) shows how much memory the benchmark used with GC disabled.
This gives an idea of total memory use and indirectly an idea of the number of
objects allocated and the pressure on Ruby GC if it were running. When GC is enabled,
the actual memory consumption might be much lower than the numbers below.
- ./benchmarks/simple.rb -r 10000 -n 1
- benchmark sys user total real rss
- dm #create 0.390000 3.950000 4.340000 5.771812 244.32m
- dm #select 0.150000 1.760000 1.910000 2.035583 128.97m
- dm #update 0.690000 7.880000 8.570000 11.295239 603.30m
+ ./simple.rb -n1 -r10000 -s ar -s dm -s sequel -s swift
- ar #create 0.930000 6.620000 7.550000 10.002911 367.82m
- ar #select 0.050000 0.310000 0.360000 0.417127 38.82m
- ar #update 0.770000 6.180000 6.950000 9.711788 361.93m
+ benchmark sys user total real rss
+ ar #create 0.800000 6.620000 7.420000 9.898821 369.44m
+ ar #select 0.020000 0.300000 0.320000 0.372809 38.83m
+ ar #update 0.770000 6.550000 7.320000 10.02434 361.92m
- swift #create 0.180000 0.820000 1.000000 1.968757 27.35m
- swift #select 0.010000 0.070000 0.080000 0.130234 9.85m
- swift #update 0.250000 0.610000 0.860000 1.996165 29.35m
- swift #write 0.000000 0.100000 0.100000 0.167199 6.23m
+ dm #create 0.110000 3.590000 3.700000 4.847609 248.74m
+ dm #select 0.120000 1.840000 1.960000 2.029552 128.98m
+ dm #update 0.400000 7.750000 8.150000 9.741249 599.52m
+ sequel #create 0.770000 3.910000 4.680000 7.432611 263.59m
+ sequel #select 0.020000 0.080000 0.100000 0.147321 9.82m
+ sequel #update 0.730000 3.910000 4.640000 7.594949 259.18m
+
+ swift #create 0.210000 0.850000 1.060000 2.618661 32.72m
+ swift #select 0.000000 0.080000 0.080000 0.132245 9.91m
+ swift #update 0.270000 0.650000 0.920000 2.204108 37.48m
+
+ -- bulk insert api --
+ swift #write 0.000000 0.080000 0.080000 0.151146 7.29m
+
+
+==== Adapter
+
+The adapter level SELECT benchmarks without using ORM.
+
+* Same dataset as above.
+* All rows are selected 5 times.
+* The pg benchmark uses pg_typecast gem to provide typecasting support
+ for pg gem and also makes the benchmarks more fair.
+
+===== PostgreSQL
+
+ benchmark sys user total real rss
+ do #select 0.060000 1.070000 1.130000 1.370092 99.83m
+ pg #select 0.030000 0.270000 0.300000 0.584091 46.13m
+ swift #select 0.020000 0.290000 0.310000 0.571635 39.08m
+
+===== MySQL
+
+ benchmark sys user total real rss
+ do #select 0.030000 1.070000 1.100000 1.200177 99.26m
+ mysql2 #select 0.060000 0.450000 0.510000 0.609236 76.44m
+ swift #select 0.050000 0.170000 0.220000 0.334932 33.61m
+
== TODO
-* Tests.
-* Extension performance. Remove all repeated rb_intern() calls etc.
+* More tests.
+* Make db2 async api more stable.
* Assertions for dumb stuff.
* Abstract interface for other adapters? Move dbic++ to Swift::DBI::(Adapter, Pool, Result, Statment etc.)
== Contributing
Go nuts! There is no style guide and I do not care if you write tests or comment code. If you write something neat just
send a pull request, tweet, email or yell it at me line by line in person.
-