Clear ORM
Search…
Benchmark

How fast is Clear?

Initial bootstrapping

Clear magic is built on compile time. Therefore, the impact on loading time is very limited. Clear can be used for example into web function (lambda function, google cloud function) application without any problem.
The only overhead is the connection to the database; Clear allocate by default 5 connections to PostgreSQL. In the case of mono-fiber web-function projects, you may want to reduce the connection pool to 1 only:
1
Clear::SQL.init("postgres://[email protected]/example_db", connection_pool_size: 1)
Copied!
Another good performance improvement would be to connect through PGBouncer instead of directly to the database.

Query and fetching benchmark

Here is a simple benchmark comparing the different layers of Clear and how they impact the performance, over a 100k row very simple table:
1
With Model: With attributes and cursor 7.4 (135.09ms) (± 6.44%) 116409530 B/op 5.64× slower
2
With Model: With cursor 8.61 (116.08ms) (± 2.82%) 97209247 B/op 4.84× slower
3
With Model: With attributes 13.78 ( 72.59ms) (± 3.61%) 83101520 B/op 3.03× slower
4
With Model: Simple load 100k 16.41 ( 60.94ms) (± 3.22%) 63901872 B/op 2.54× slower
5
Hash from SQL only 30.21 ( 33.1ms) (± 5.18%) 22354496 B/op 1.38× slower
6
Using: Model::Collection#pluck 41.74 ( 23.96ms) (± 8.35%) 25337128 B/op fastest
Copied!

Against the competition

While being a bit outdated, a benchmark of the competition has been done here.
Clear stands in the middle of the crowd, being slightly slower than some other ORM over select methods.
More noticeably, Clear performs 5 to 8x faster than Ruby's ActiveRecord !
Last modified 2yr ago