recentpopularlog in

activerecord

« earlier   
westonganger/spreadsheet_architect: Spreadsheet Architect is a library that allows you to create XLSX, ODS, or CSV spreadsheets super easily from ActiveRecord relations, plain Ruby objects, or tabular data
Spreadsheet Architect is a library that allows you to create XLSX, ODS, or CSV spreadsheets super easily from ActiveRecord relations, plain Ruby objects, or tabular data
csv  rails  ruby  xls  ods  spreadsheet  activerecord  relations 
2 days ago by pioneerskies
How to generate ActiveRecord insert SQL (Example)
A protip by lankz about ruby, rails, activerecord, and arel.
rails  activerecord 
8 days ago by aghecht
Summary of API misuses
Summary of API misuses
Our static checker in powerstation finds all API misuses in source code by pattern matching and suggests a more efficient API to replace with. Common API misuse patterns are summarized in our paper. More specifically, the API misuses detected in this checker includes:

any?, to be replaced with (=>) exists?
where.first? => find_by
* => *.except(order)
each.update => update_all
.count => size
.map => .pluck
pluck.sum => sum
.pluck + pluck => SQL UNION
if exists? find else create end => find_or_create_by
We list how many times such misuses happen in the applications we studied, and each instance of misuse. The list can be found here.
ActiveRecord  RubyOnRails  Performance 
10 days ago by cnk
How not to structure your database-backed web applications: a study of performance bugs in the wild | the morning paper
The authors study all 40 of the problematic actions and manually fix 39 of the (the other one spends its time on file-system actions). This leads to 64 fixes being applied.

Many fixes are very effective. About a quarter of them achieve more than 5x speedup, and more than 60% of them achieve more than 2x speedup. Every type of fix has at least one case where it achieves more than 2x speedup.

40 of the 64 fixes alter neither the display nor the functionality of the original application, achieving an average speed-up of 2.2x (maximum 9.2x).

Per a recent comment from Steve Powell, it’s actually quite confusing to talk about a ‘2x speed-up’ when you’re talking about the time something takes! I guess we could interpret this as either 2x requests-per-second (that’s a speed metric) , or that an action takes on average half the time it used to (a ‘/2’ latency reduction?). With a single thread of execution, they both amount to the same thing.



The average server time is reduced form 3.57 seconds to 0.49 seconds, and the end-to-end page load times from 4.17 seconds to 0.69 seconds. More than 78% of fixes require fewer than 5 lines of code.

In other words, by writing code that contains the anti-patterns discussed earlier, developers degrade the performance of their applications by about 6x.

The authors wrote a static analyser (you can find it here) that looks for some of the simple API misuse patterns and ran it on the latest versions of the 12 ORM applications. There are still plenty of incidences! (Some of these in actions that weren’t identified as worse performing actions during profiling of course).
RubyOnRails  ActiveRecord  Performance  Tuning 
10 days ago by cnk
ActiveRecord's where.not and nil
The takeaway: When using where.not, be explicit if you want NULL values.
rails  activerecord  tips 
25 days ago by junya
Rails Migrations with Zero Downtime - via @codeship | via @codeship
オンラインでやって大丈夫かどうかのチートシートがついている。
activerecord  rails  migration  postgresql 
25 days ago by morygonzalez

Copy this bookmark:





to read