Sequel vs Active Record ORM Benchmark on PostgreSQL
- Categories:
- benchmark
Benchmark Machine
- OSX Yosemite version 10.10.5
- MacBook Pro (Mid 2010)
- Processor 2.66 GHz Intel Core i7
- 8GB 1067 MHz DDR3
- Storage: SSD
Rbenv, Ruby and PostgreSQL version:
- Rbenv 0.4.0-148-g5b9e4f0
- Ruby 2.2.2p95
- PostgreSQL 9.4.1 with default configuration
I use simple_orm_benchmark as benchmarking tool.
Active Record 4.1.10 vs Sequel 4.22.0
activerecord-postgresql,sequel-postgresql,Benchmark
3.797079,0.289459,Eager Loading Query Per Association With 1-1 Records: 640 objects 22 times-No Transaction
4.301958,0.288102,Eager Loading Query Per Association With 1-1 Records: 640 objects 22 times-Transaction
1.359212,0.167307,Eager Loading Query Per Association With 1-32 Records: 1024 objects 22 times-No Transaction
1.472812,0.172438,Eager Loading Query Per Association With 1-32 Records: 1024 objects 22 times-Transaction
0.876188,0.139245,Eager Loading Query Per Association With 1-32-32 Records: 2048 objects 9 times-No Transaction
0.896743,0.146838,Eager Loading Query Per Association With 1-32-32 Records: 2048 objects 9 times-Transaction
4.708626,0.391683,Eager Loading Single Query With 1-1 Records: 640 objects 22 times-No Transaction
4.587593,0.377062,Eager Loading Single Query With 1-1 Records: 640 objects 22 times-Transaction
1.773245,0.377837,Eager Loading Single Query With 1-32 Records: 1024 objects 22 times-No Transaction
1.738072,0.369713,Eager Loading Single Query With 1-32 Records: 1024 objects 22 times-Transaction
1.413392,0.767108,Eager Loading Single Query With 1-32-32 Records: 2048 objects 1 time-No Transaction
1.283107,0.750355,Eager Loading Single Query With 1-32-32 Records: 2048 objects 1 time-Transaction
2.758472,2.155154,Heavy Threading with 32 threads-No Transaction
0.597441,0.264672,Lazy Loading With 1-1 Records: 640 objects 1 time-No Transaction
0.596161,0.253702,Lazy Loading With 1-1 Records: 640 objects 1 time-Transaction
1.189394,0.322589,Lazy Loading With 1-32 Records: 1024 objects 16 times-No Transaction
1.087375,0.318084,Lazy Loading With 1-32 Records: 1024 objects 16 times-Transaction
0.582010,0.421863,Light Threading with 6 threads-No Transaction
1.559292,0.832258,Model Object And Associated Object Creation: 640 objects-No Transaction
1.073548,0.424554,Model Object And Associated Object Creation: 640 objects-Transaction
1.878293,0.964404,Model Object Creation: 1600 objects-No Transaction
1.180933,0.467102,Model Object Creation: 1600 objects-Transaction
2.329239,1.767813,Model Object Destruction: 3200 objects-No Transaction
1.405677,0.751915,Model Object Destruction: 3200 objects-Transaction
4.863034,1.987028,Model Object Select Hash: 320 objects 32 times-No Transaction
4.528117,1.814798,Model Object Select Hash: 320 objects 32 times-Transaction
3.904008,1.792130,Model Object Select PK: 320 objects 32 times-No Transaction
3.874856,1.685732,Model Object Select PK: 320 objects 32 times-Transaction
1.961619,0.932147,Model Object Select and Save: 1600 objects-No Transaction
1.513534,0.385108,Model Object Select and Save: 1600 objects-Transaction
1.996105,0.258897,Model Object Select: 3200 objects 32 times-No Transaction
1.968377,0.271433,Model Object Select: 3200 objects 32 times-Transaction
1.996668,1.173830,Model Object and Associated Object Destruction: 800 objects-No Transaction
1.319295,0.682365,Model Object and Associated Object Destruction: 800 objects-Transaction
Active Record 4.2.4 vs Sequel 4.26.0
activerecord-postgresql,sequel-postgresql,Benchmark
4.305316,0.307019,Eager Loading Query Per Association With 1-1 Records: 640 objects 22 times-No Transaction
4.281943,0.335119,Eager Loading Query Per Association With 1-1 Records: 640 objects 22 times-Transaction
1.229413,0.185485,Eager Loading Query Per Association With 1-32 Records: 1024 objects 22 times-No Transaction
1.226506,0.200746,Eager Loading Query Per Association With 1-32 Records: 1024 objects 22 times-Transaction
0.900579,0.146086,Eager Loading Query Per Association With 1-32-32 Records: 2048 objects 9 times-No Transaction
0.951023,0.146339,Eager Loading Query Per Association With 1-32-32 Records: 2048 objects 9 times-Transaction
4.925186,0.391609,Eager Loading Single Query With 1-1 Records: 640 objects 22 times-No Transaction
4.936297,0.420436,Eager Loading Single Query With 1-1 Records: 640 objects 22 times-Transaction
1.871573,0.417916,Eager Loading Single Query With 1-32 Records: 1024 objects 22 times-No Transaction
1.834014,0.406317,Eager Loading Single Query With 1-32 Records: 1024 objects 22 times-Transaction
1.405914,0.769988,Eager Loading Single Query With 1-32-32 Records: 2048 objects 1 time-No Transaction
0.964567,0.766396,Eager Loading Single Query With 1-32-32 Records: 2048 objects 1 time-Transaction
2.891799,2.085380,Heavy Threading with 32 threads-No Transaction
0.555199,0.265492,Lazy Loading With 1-1 Records: 640 objects 1 time-No Transaction
0.556650,0.276605,Lazy Loading With 1-1 Records: 640 objects 1 time-Transaction
1.033306,0.348341,Lazy Loading With 1-32 Records: 1024 objects 16 times-No Transaction
0.994400,0.318828,Lazy Loading With 1-32 Records: 1024 objects 16 times-Transaction
0.628959,0.412763,Light Threading with 6 threads-No Transaction
1.692002,0.907158,Model Object And Associated Object Creation: 640 objects-No Transaction
1.152138,0.449708,Model Object And Associated Object Creation: 640 objects-Transaction
1.834905,0.988383,Model Object Creation: 1600 objects-No Transaction
1.203676,0.470106,Model Object Creation: 1600 objects-Transaction
2.254071,2.033704,Model Object Destruction: 3200 objects-No Transaction
1.129794,0.865704,Model Object Destruction: 3200 objects-Transaction
2.426885,2.162950,Model Object Select Hash: 320 objects 32 times-No Transaction
2.350779,1.937255,Model Object Select Hash: 320 objects 32 times-Transaction
2.283536,1.929124,Model Object Select PK: 320 objects 32 times-No Transaction
2.198589,1.788150,Model Object Select PK: 320 objects 32 times-Transaction
1.882493,0.940933,Model Object Select and Save: 1600 objects-No Transaction
1.276082,0.394599,Model Object Select and Save: 1600 objects-Transaction
1.489740,0.308673,Model Object Select: 3200 objects 32 times-No Transaction
1.478039,0.377845,Model Object Select: 3200 objects 32 times-Transaction
1.833602,1.250165,Model Object and Associated Object Destruction: 800 objects-No Transaction
1.211799,0.802087,Model Object and Associated Object Destruction: 800 objects-Transaction
Gist: https://gist.github.com/kuntoaji/e66ed4fac8b9e578e9fa
Conclusion
Based on benchmark result with simple_orm_benchmark tool, Sequel has better performance than Active Record on every test cases. The biggest difference occurs in Eager Loading Query Per Association With 1-1 Records and Eager Loading Single Query With 1-1 Records with or without Transaction test cases. I still do not know why. I need to explore more about Sequel.
- Tags:
- #active record
- #sequel
Sponsored Links
- Register to Digital Ocean cloud with this link and get $200 credit
- Looking for cheap CDN? Bunny is the answer
- Alternative Cloud besides AWS and Digital Ocean