Skip to main content

Overview

Determine how long it will take to migrate the database by checking the size of each table.

SELECT
table_name AS `Table`,
ROUND(data_length / 1024 / 1024, 2) AS `Data Size (MB)`,
ROUND(index_length / 1024 / 1024, 2) AS `Index Size (MB)`,
ROUND((data_length + index_length) / 1024 / 1024, 2) AS `Total Size (MB)`
FROM
information_schema.tables
WHERE
table_schema = 'jod-v2-prod'
ORDER BY
`Total Size (MB)` DESC;

Database Size​

SELECT
table_name AS `Table`,
ROUND(data_length / 1024 / 1024, 2) AS `Data Size (MB)`,
ROUND(index_length / 1024 / 1024, 2) AS `Index Size (MB)`,
ROUND((data_length + index_length) / 1024 / 1024, 2) AS `Total Size (MB)`
DatabaseSize (MB)
information_schema0.20
jod-v1-prod9440.69
jod-v2-demo14.78
jod-v2-prod1209306.53
mysql13.19
performance_schema0.00
sys0.02
TOTAL1218775.41

Table Sizes​

Top 4 tables by size:

TableData Size (MB)Index Size (MB)Total Size (MB)
notifications_20240325786200.00139757.86925957.86
notifications242404.0027080.95269484.95
audits9147.002815.9111962.91
jod_jobs548.9871.56620.55

Data in the tables (except jod_jobs) are not used by the system or reporting.

  • We can migrate only the schema (without row data)

Total Migration Size 1,209,306.53 - 925,957.86 - 269,484.95 - 11,962.91 = 1,900.81 MB (approx. 1.9 GB) to migrate.

Small enough to use mysqldump in an EC2 instance with access to the rds instances:

  • rds-jod-prod
  • jodgig-qa
  • jodgig

The dump and load into QA took about 15 minutes.

rds-jod.prod.jod-v2-prod tables by size

As of 31 Oct 2024, 12pm GMT +7:

TableData Size (MB)Index Size (MB)Total Size (MB)
notifications_20240325786200.00139757.86925957.86
notifications242404.0027080.95269484.95
audits9147.002815.9111962.91
jod_jobs548.9871.56620.55
email_sms_notifications150.67117.19267.86
failed_jobs242.581.52244.09
slot_user85.6959.06144.75
job_user83.6653.95137.61
oauth_access_tokens55.5037.8093.30
users68.6322.8191.44
payments53.5929.5883.17
billings34.5636.9171.47
slots29.559.5239.06
qr_code_slot_users12.5217.5830.09
jod_job_certificates13.554.5218.06
user_badges7.525.5213.03
applicant_experiences6.523.9810.50
wishlists3.524.808.31
company_badge_assignments1.522.894.41
partner_events2.521.504.02
slot_user_badges1.521.943.45
job_templates2.520.132.64
friends1.520.421.94
company_role_permissions1.520.311.83
credits1.520.271.78
user_settings1.520.231.75
files1.520.001.52
eber_points_logs0.340.380.72
locations0.520.170.69
user_certificates0.500.140.64
job_batches0.270.000.27
account_suspensions0.190.000.19
slot_user_transaction_logs0.090.060.16
track_incidents0.110.050.16
role_permissions0.080.050.13
ct_reposts0.110.000.11
user_unsuspension_request0.090.000.09
companies0.080.000.08
notification_templates0.080.000.08
payment_adjustment_approvals0.050.030.08
permissions0.060.000.06
migrations0.050.000.05
user_company0.020.030.05
oauth_clients0.020.020.03
address0.020.020.03
role_features0.020.020.03
configurations0.020.020.03
oauth_auth_codes0.020.020.03
jobs0.020.020.03
versions0.020.020.03
features0.020.020.03
feature_permissions0.020.020.03
user_roles0.020.020.03
password_resets0.020.020.03
banks0.020.020.03
menus0.020.020.03
menu_roles0.020.020.03
settings0.020.020.03
oauth_refresh_tokens0.020.020.03
job_template_certificates0.020.020.03
reason_templates0.020.000.02
feature_modules0.020.000.02
certificates0.020.000.02
job_types0.020.000.02
educational_institutes0.020.000.02
badges0.020.000.02
roles0.020.000.02
oauth_personal_access_clients0.020.000.02

Stored procedures, events and TRIGGERS​

Database contains stored procedures, events and triggers.

Determine if we need to migrate them by checking if there is any data in them.

We only had a COUNT_MIGRATE stored procedure, so we can ignore tha

  • the rest returned 0 rows

Commands​

Stored procedures:

SELECT ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE, DATA_TYPE, CREATED, LAST_ALTERED
FROM information_schema.ROUTINES
WHERE ROUTINE_SCHEMA = 'jod-v2-prod';

Columns with blob, varbinary, binary data types:

SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'jod-v2-prod'
AND DATA_TYPE IN ('blob', 'varbinary', 'binary');

Triggers:

SELECT TRIGGER_SCHEMA, TRIGGER_NAME, EVENT_MANIPULATION, EVENT_OBJECT_TABLE, ACTION_STATEMENT, ACTION_TIMING, CREATED
FROM information_schema.TRIGGERS
WHERE TRIGGER_SCHEMA = 'jod-v2-prod';

Events:

SELECT EVENT_SCHEMA, EVENT_NAME, EVENT_DEFINITION, STATUS, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STARTS, ENDS, LAST_EXECUTED
FROM information_schema.EVENTS
WHERE EVENT_SCHEMA = 'your_database_name';