Skip to content

Considerable performance impact when running migrations #33

Description

@bschrag620

In my current project at work, we noticed a considerable increase in the time for our rails db:migrate command to run that seems to be related to pp_sql. To test this, update the gem to not be required if an ENV_VAR was set.

# Gemfile

group :development do
  gem "pp_sql", require: !ENV["PP_SQL_OPT_OUT"]
end

# development.rb
Rails.application.configure do
  ...
  unless ENV["PP_SQL_OPT_OUT"]
    PpSql.rewrite_to_sql_method = false  
  end
  ...
end

I then used a bash script to time the 2 options:

#!/bin/bash

echo "Running without PP_SQL_OPT_OUT..."
time1=$( { time rails db:migrate; } 2>&1 | grep real | awk '{print $2}' )

echo "Running with PP_SQL_OPT_OUT=1..."
time2=$( { time PP_SQL_OPT_OUT=1 rails db:migrate; } 2>&1 | grep real | awk '{print $2}' )

echo "Results:"
echo "With pp_sql formatting logs: $time1"
echo "Without pp_sql formatting logsr:    $time2"

The following is the result:

Running without PP_SQL_OPT_OUT...
Running with PP_SQL_OPT_OUT=1...
Results:
With pp_sql formatting logs: 0m42.109s
Without pp_sql formatting logsr:    0m10.283s

There's a 4x increase in the amount of time it takes to run rails db:migrate. Any thoughts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions