{"id":2009,"date":"2024-06-28T09:53:09","date_gmt":"2024-06-28T09:53:09","guid":{"rendered":"https:\/\/www.w3computing.com\/articles\/?p=2009"},"modified":"2024-06-28T09:53:13","modified_gmt":"2024-06-28T09:53:13","slug":"how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql","status":"publish","type":"post","link":"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/","title":{"rendered":"How to Perform Online Schema Changes with pt-online-schema-change in MySQL"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Performing schema changes on a live MySQL database can be a challenging task, especially when dealing with large tables or high-traffic environments. Traditional methods of altering tables can lead to significant downtime, locking issues, and potential data loss. This is where <code>pt-online-schema-change<\/code>, a tool from the Percona Toolkit, comes into play. It allows for non-blocking schema changes, enabling you to alter your tables without significant downtime.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we will explore how to use <code>pt-online-schema-change<\/code> to perform online schema changes in MySQL. This guide is intended for users who are familiar with MySQL and have some experience with database administration but may not have used <code>pt-online-schema-change<\/code> before.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before we begin, ensure you have the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A MySQL database with administrative access.<\/li>\n\n\n\n<li>Basic knowledge of MySQL command-line operations.<\/li>\n\n\n\n<li>A backup of your database. While <code>pt-online-schema-change<\/code> is designed to minimize risk, having a backup is always a good practice.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding pt-online-schema-change<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>pt-online-schema-change<\/code> is part of the Percona Toolkit, a collection of advanced command-line tools for MySQL and MariaDB. The tool works by creating a shadow copy of the table to be altered, applying the changes to the shadow table, and then swapping the original table with the altered table. This process ensures minimal disruption to database operations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Key features include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Non-blocking operation:<\/strong> Changes are applied without locking the entire table.<\/li>\n\n\n\n<li><strong>Data integrity:<\/strong> Ensures data consistency throughout the operation.<\/li>\n\n\n\n<li><strong>Customizable:<\/strong> Supports various options to control the behavior of the schema change.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Percona Toolkit<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To install Percona Toolkit, you can use your package manager of choice. Below are the installation steps for different operating systems.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">On Ubuntu\/Debian<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">sudo apt-get update\nsudo apt-get install percona-toolkit<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">On CentOS\/RHEL<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">sudo yum install percona-toolkit<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">On macOS<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">brew install percona-toolkit<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Alternatively, you can download and compile it from the source if you prefer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Usage of pt-online-schema-change<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The basic syntax of <code>pt-online-schema-change<\/code> is as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"SCHEMA CHANGE\" D=database,t=table<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li><code>--execute<\/code>: Executes the schema change. Without this option, the tool will run in dry-run mode.<\/li>\n\n\n\n<li><code>--alter<\/code>: Specifies the schema change to be applied.<\/li>\n\n\n\n<li><code>D=database,t=table<\/code>: Specifies the database and table to be altered.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s start with a simple example where we add a new column to a table.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"ADD COLUMN new_col INT\" D=mydb,t=mytable<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This command adds a new column <code>new_col<\/code> to the <code>mytable<\/code> table in the <code>mydb<\/code> database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Performing Schema Changes<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Adding Columns<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To add a column, use the <code>ADD COLUMN<\/code> clause in the <code>--alter<\/code> option.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"ADD COLUMN age INT\" D=mydb,t=users<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Modifying Columns<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To modify an existing column, use the <code>MODIFY COLUMN<\/code> clause.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"MODIFY COLUMN age BIGINT\" D=mydb,t=users<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Dropping Columns<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To drop a column, use the <code>DROP COLUMN<\/code> clause.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"DROP COLUMN age\" D=mydb,t=users<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Adding Indexes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To add an index, use the <code>ADD INDEX<\/code> clause.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"ADD INDEX idx_age (age)\" D=mydb,t=users<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Dropping Indexes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To drop an index, use the <code>DROP INDEX<\/code> clause.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"DROP INDEX idx_age\" D=mydb,t=users<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Advanced Usage<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Chunk Size Management<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>pt-online-schema-change<\/code> processes the table in chunks to minimize locking. The default chunk size is 1000 rows. You can adjust this using the <code>--chunk-size<\/code> option.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"ADD COLUMN age INT\" D=mydb,t=users --chunk-size 2000<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Throttle Options<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To control the tool&#8217;s impact on your server, use the <code>--max-load<\/code> and <code>--critical-load<\/code> options. These options specify the maximum permissible load on the server before the tool pauses.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"ADD COLUMN age INT\" D=mydb,t=users --max-load Threads_running=25 --critical-load Threads_running=50<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Specifying Where Clauses<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can limit the rows to be processed using the <code>--where<\/code> option.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"ADD COLUMN age INT\" D=mydb,t=users --where \"age IS NULL\"<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Handling Foreign Keys<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When dealing with foreign keys, use the <code>--alter-foreign-keys-method<\/code> option to specify how foreign keys should be handled. The default method is <code>auto<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"ADD COLUMN age INT\" D=mydb,t=users --alter-foreign-keys-method auto<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Custom Triggers<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can create custom triggers to perform specific actions during the schema change.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"ADD COLUMN age INT\" D=mydb,t=users --before-trigger \"CREATE TRIGGER...\"<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Monitoring and Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Monitoring Progress<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>pt-online-schema-change<\/code> provides progress output by default. You can also monitor progress by querying the <code>information_schema<\/code> tables.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">SELECT * FROM information_schema.innodb_trx WHERE TIME_TO_SEC(TIMEDIFF(NOW(), trx_started)) &gt; 60;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Handling Errors<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If an error occurs, <code>pt-online-schema-change<\/code> will stop and provide an error message. Review the message to diagnose the issue.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Cleaning Up<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If the tool is interrupted, it may leave behind temporary tables. You can clean these up using the <code>--cleanup<\/code> option.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"Shell Session\" data-shcb-language-slug=\"shell\"><span><code class=\"hljs language-shell\">pt-online-schema-change --execute --alter \"ADD COLUMN age INT\" D=mydb,t=users --cleanup<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Shell Session<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">shell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Best Practices<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Test in a staging environment:<\/strong> Always test schema changes in a staging environment before applying them to production.<\/li>\n\n\n\n<li><strong>Monitor server load:<\/strong> Use the <code>--max-load<\/code> and <code>--critical-load<\/code> options to prevent the tool from overwhelming your server.<\/li>\n\n\n\n<li><strong>Backup your data:<\/strong> Ensure you have a recent backup of your data before performing schema changes.<\/li>\n\n\n\n<li><strong>Read the documentation:<\/strong> Familiarize yourself with the <a href=\"https:\/\/www.percona.com\/doc\/percona-toolkit\/LATEST\/pt-online-schema-change.html\">official documentation<\/a> for detailed information and advanced options.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>pt-online-schema-change<\/code> is a powerful tool for performing online schema changes in MySQL. By following this tutorial, you should now be equipped to use <code>pt-online-schema-change<\/code> to alter your database schemas with minimal downtime and disruption. Remember to always test your changes in a staging environment and monitor your server load during the process. With these best practices, you can confidently perform schema changes on your live databases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For more information, refer to the official <a href=\"https:\/\/www.percona.com\/doc\/percona-toolkit\/LATEST\/pt-online-schema-change.html\">Percona Toolkit documentation<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Performing schema changes on a live MySQL database can be a challenging task, especially when dealing with large tables or high-traffic environments. Traditional methods of altering tables can lead to significant downtime, locking issues, and potential data loss. This is where pt-online-schema-change, a tool from the Percona Toolkit, comes into play. It allows for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[14,24],"tags":[],"class_list":["post-2009","post","type-post","status-publish","format-standard","category-database-development","category-mysql","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Online Schema Changes with pt-online-schema-change in MySQL<\/title>\n<meta name=\"description\" content=\"pt-online-schema-change is part of the Percona Toolkit, a collection of advanced command-line tools for MySQL and MariaDB.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Online Schema Changes with pt-online-schema-change in MySQL\" \/>\n<meta property=\"og:description\" content=\"pt-online-schema-change is part of the Percona Toolkit, a collection of advanced command-line tools for MySQL and MariaDB.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-28T09:53:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-28T09:53:13+00:00\" \/>\n<meta name=\"author\" content=\"w3compadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"w3compadmin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\\\/\"},\"author\":{\"name\":\"w3compadmin\",\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/#\\\/schema\\\/person\\\/a550b3e20d78bb4f79b7c6b7b53f0561\"},\"headline\":\"How to Perform Online Schema Changes with pt-online-schema-change in MySQL\",\"datePublished\":\"2024-06-28T09:53:09+00:00\",\"dateModified\":\"2024-06-28T09:53:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\\\/\"},\"wordCount\":720,\"articleSection\":[\"Database Development\",\"MySQL\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\\\/\",\"url\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\\\/\",\"name\":\"Online Schema Changes with pt-online-schema-change in MySQL\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/#website\"},\"datePublished\":\"2024-06-28T09:53:09+00:00\",\"dateModified\":\"2024-06-28T09:53:13+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/#\\\/schema\\\/person\\\/a550b3e20d78bb4f79b7c6b7b53f0561\"},\"description\":\"pt-online-schema-change is part of the Percona Toolkit, a collection of advanced command-line tools for MySQL and MariaDB.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Articles Home\",\"item\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Database Development\",\"item\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/database-development\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MySQL\",\"item\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/database-development\\\/mysql\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to Perform Online Schema Changes with pt-online-schema-change in MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/#website\",\"url\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/\",\"name\":\"Developer Articles Hub\",\"description\":\"\",\"alternateName\":\"Developer Articles\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/#\\\/schema\\\/person\\\/a550b3e20d78bb4f79b7c6b7b53f0561\",\"name\":\"w3compadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/wp-content\\\/litespeed\\\/avatar\\\/bd481d404e42caa2763662a3bfe825f8.jpg?ver=1780141266\",\"url\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/wp-content\\\/litespeed\\\/avatar\\\/bd481d404e42caa2763662a3bfe825f8.jpg?ver=1780141266\",\"contentUrl\":\"https:\\\/\\\/www.w3computing.com\\\/articles\\\/wp-content\\\/litespeed\\\/avatar\\\/bd481d404e42caa2763662a3bfe825f8.jpg?ver=1780141266\",\"caption\":\"w3compadmin\"},\"sameAs\":[\"http:\\\/\\\/w3computing.com\\\/articles\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Online Schema Changes with pt-online-schema-change in MySQL","description":"pt-online-schema-change is part of the Percona Toolkit, a collection of advanced command-line tools for MySQL and MariaDB.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/","og_locale":"en_US","og_type":"article","og_title":"Online Schema Changes with pt-online-schema-change in MySQL","og_description":"pt-online-schema-change is part of the Percona Toolkit, a collection of advanced command-line tools for MySQL and MariaDB.","og_url":"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/","article_published_time":"2024-06-28T09:53:09+00:00","article_modified_time":"2024-06-28T09:53:13+00:00","author":"w3compadmin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"w3compadmin","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/#article","isPartOf":{"@id":"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/"},"author":{"name":"w3compadmin","@id":"https:\/\/www.w3computing.com\/articles\/#\/schema\/person\/a550b3e20d78bb4f79b7c6b7b53f0561"},"headline":"How to Perform Online Schema Changes with pt-online-schema-change in MySQL","datePublished":"2024-06-28T09:53:09+00:00","dateModified":"2024-06-28T09:53:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/"},"wordCount":720,"articleSection":["Database Development","MySQL"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/","url":"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/","name":"Online Schema Changes with pt-online-schema-change in MySQL","isPartOf":{"@id":"https:\/\/www.w3computing.com\/articles\/#website"},"datePublished":"2024-06-28T09:53:09+00:00","dateModified":"2024-06-28T09:53:13+00:00","author":{"@id":"https:\/\/www.w3computing.com\/articles\/#\/schema\/person\/a550b3e20d78bb4f79b7c6b7b53f0561"},"description":"pt-online-schema-change is part of the Percona Toolkit, a collection of advanced command-line tools for MySQL and MariaDB.","breadcrumb":{"@id":"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.w3computing.com\/articles\/how-to-perform-online-schema-changes-with-pt-online-schema-change-in-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Articles Home","item":"https:\/\/www.w3computing.com\/articles\/"},{"@type":"ListItem","position":2,"name":"Database Development","item":"https:\/\/www.w3computing.com\/articles\/database-development\/"},{"@type":"ListItem","position":3,"name":"MySQL","item":"https:\/\/www.w3computing.com\/articles\/database-development\/mysql\/"},{"@type":"ListItem","position":4,"name":"How to Perform Online Schema Changes with pt-online-schema-change in MySQL"}]},{"@type":"WebSite","@id":"https:\/\/www.w3computing.com\/articles\/#website","url":"https:\/\/www.w3computing.com\/articles\/","name":"Developer Articles Hub","description":"","alternateName":"Developer Articles","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.w3computing.com\/articles\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.w3computing.com\/articles\/#\/schema\/person\/a550b3e20d78bb4f79b7c6b7b53f0561","name":"w3compadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.w3computing.com\/articles\/wp-content\/litespeed\/avatar\/bd481d404e42caa2763662a3bfe825f8.jpg?ver=1780141266","url":"https:\/\/www.w3computing.com\/articles\/wp-content\/litespeed\/avatar\/bd481d404e42caa2763662a3bfe825f8.jpg?ver=1780141266","contentUrl":"https:\/\/www.w3computing.com\/articles\/wp-content\/litespeed\/avatar\/bd481d404e42caa2763662a3bfe825f8.jpg?ver=1780141266","caption":"w3compadmin"},"sameAs":["http:\/\/w3computing.com\/articles"]}]}},"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"w3compadmin","author_link":"https:\/\/www.w3computing.com\/articles\/author\/w3compadmin\/"},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.w3computing.com\/articles\/wp-json\/wp\/v2\/posts\/2009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.w3computing.com\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.w3computing.com\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.w3computing.com\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.w3computing.com\/articles\/wp-json\/wp\/v2\/comments?post=2009"}],"version-history":[{"count":1,"href":"https:\/\/www.w3computing.com\/articles\/wp-json\/wp\/v2\/posts\/2009\/revisions"}],"predecessor-version":[{"id":2012,"href":"https:\/\/www.w3computing.com\/articles\/wp-json\/wp\/v2\/posts\/2009\/revisions\/2012"}],"wp:attachment":[{"href":"https:\/\/www.w3computing.com\/articles\/wp-json\/wp\/v2\/media?parent=2009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.w3computing.com\/articles\/wp-json\/wp\/v2\/categories?post=2009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.w3computing.com\/articles\/wp-json\/wp\/v2\/tags?post=2009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}