Take Out The Papers And The Trash

How to clean and clear large tables in MySQL

From time to time our data team gets requests for advice on how to perform cleanup operations against large database tables. Typically, these originate in a ticket requesting information about how the disk is being used or why a specific table is performing poorly.

Somewhat less often, we are asked us to explain why a cleanup attempt has failed or why it has caused downtime for an application. Managing these types of operations with minimal or no downtime can be a challenge given the way a database like MySQL performs these tasks.

The most common form of table cleanup operation we are asked about is for the sessions table. Even though these are not really recommended practice(https://guides.rubyonrails.org/action_controller_overview.html#session) they are still quite common to see. Depending on your application workload and use cases these tables can grow very quickly in size; often including older records that are never going to be used again. Even though the data payload in each row is relatively small, it's not uncommon to find sessions tables that are 10 or 20 GB in size—often larger than the rest of the database combined.

The "Standard" Solution

While there is no automatic session cleanup built into a rails app it happens to be really easy to write a rake task that handles this cleanup for you. In fact, it's so easy that it's often overlooked until the table has reached the size where it is difficult to manage .

Read More

Do we still need RVM Gemsets?

RVM or Ruby Version Manager allows you to install and manage Ruby environments. Similar tools are Rbenv and chruby. I previously wrote about installing these on a Mac here.

Read More

Top 5 reasons Not to miss Rails Conf

Every year, there is a gathering of developers, looking toward the future of a framework that nearly 15 years ago brought Ruby to the web. That gathering is Rails Conf, and the 2018 edition is in Pittsburgh, Pennsylvania!

Read More

Rails Encrypted Credentials Use AES 128-bit Key

Rails 5.2 introduces Credentials which replaces Secrets and Encrypted Secrets from previous Rails versions. I have previously written about Credentials for those of you wanting to know more.

Read More

New Feature on Rails 5.2: Redis Cache Store

Redis Cache Store is a new feature on Rails 5.2 although support for caching in Rails has been around for some time. A few cache stores already exist like MemCacheStore, FileStore, and MemoryStore. You can also use a custom store so no doubt some people are already using Redis as a cache store.

Read More

Application Load Balancer vs Classic Load Balancer

Engine Yard announced support of AWS Application Load Balancer last December.

Read More
Subscribe to our Blog