#activerecord on #mysql— Iterating over large tables with conditions
▻https://hackernoon.com/activerecord-on-mysql-iterating-over-large-tables-with-conditions-453bd8
In this article, I’m going to demonstrate performance differences between two ways of iterating over the records in a MySQL database table with millions of records. In a high volume analytics system, tables with millions of records are quite common and iterating over the full table or a subset of these tables becomes often necessary — whether it’s to perform computations, run a migration, or create parallelized background jobs on the records. At AirPR, we have many database tables with 100s of millions of records, and it becomes important to write efficient code for iterations because there is often an order of magnitude difference between a good and not-so-good approach.Find Each MethodThe standard approach provided natively by ActiveRecord is the find_eachmethod.For the purposes of this (...)