Filtering tables from Azure Database for MySQL read replica servers

Published Dec 16 2021 10:54 AM 1,152 Views
Microsoft

In certain scenarios, users may want to limit the tables that are replicated to a read replica server to improve performance and save costs. For example, many reporting/analytics workloads require only subset of the tables rather than the entire database schema(s). Similarly, a database schema for a web application often includes audit or logging tables designed to capture user behavior and to accommodate audit and compliance requirements. These tables have heavy write activities and often account for 80-90% of the instance size. While the tables are essential to ensuring that the application meets compliance requirements, they aren’t required for read-only functionality. In these examples there’s no need to replicate anything other than the required tables to meet the business requirements.

 

However, when you set up an Azure Database for MySQL read replica, all the tables from your primary instance are copied to the read replicas by default. While the Azure Database for MySQL service doesn’t support filtering a table or a database schema from a read replica, it does support the replicate_wild_ignore_table parameter, a native MySQL capability, which can prevent one or more tables from being included in MySQL replication.

 

To accomplish this goal, we simply need to:

  1. Set up MySQL Data-in replication, which allows you to synchronize data between two Azure Database for MySQL instances using the binary log (binlog) file position-based or GTID-based replication that is native to MySQL.
  2. Limit the tables replicated to the secondary replica instance via the Azure Portal or the Azure CLI.
  3. Provision the required Azure Database for MySQL read replica from the secondary instance.

The rest of this blog post discusses how best to leverage the replicate_wild_ignore_table parameter and MySQL replication to prevent one or more tables from being replicated to the Azure Database for MySQL read replica.

 

Note: This blog post applies to both Single Server and Flexible Server.

 

Reference architecture using Azure DB for MySQL read replica

 

With Azure Database for MySQL, the appropriate reference architecture to offload the read-only workload is shown in Figure-1 below.

 

Fig1a.png

 

In this architecture, myrw-1 is the source instance of Azure Database for MySQL, and it supports all Data Manipulation Language (DML) activities. This instance has four Azure Database for MySQL read replica servers (myrr-1, etc.) available for offloading read-only workloads, and by default, each of the read replica servers has a compute and storage configuration that is identical to the source instance.

 

In this example, the source instance is in East US2, with read replica servers in East US and Central US. Each read replica server is updated asynchronously using the MySQL engine's native binary log (binlog)-based replication technology.

 

Note: Flexible Server doesn’t currently support cross-region read replicas or replication on a High Availability (HA) configuration. As a result, Flexible Server read replicas would be located in the same region as the primary instance. Cross-region read replicas and support for replication on an HA Flexible Server are on the product roadmap for future delivery.

 

Set up MySQL Data-in replication

 

First, we need to set up MySQL Data-in replication for the primary instance, myrw-1. In so doing, we’ll create the secondary instance, myrw-2, as shown in Figure 2 below.

 

Fig2a.png

 

Note: For more information, see How to configure Azure Database for MySQL Data-in Replication.

 

Limit tables replicated to the secondary instance

 

Next, we need to limit the tables that are replicated from the myrw-1 instance to the myrw-2 instance. Let’s assume that the myrw-1 instance has two databases (Sales and Album), and that each database includes some tables that are required by the application or for read-only operations and some that aren’t, as listed in the following table:

 

Database

Required tables

Tables that aren’t required

Sales

City, Country, CountryLanguage

SalesAudit, SalesLog, ComplianceLog

Album

Album, Track

TrackAudit, TrackLog, ComplianceLog

 

As you can see, read operations don’t require the SalesAudit, SalesLog, and ComplianceLog tables in Sales database. Similarly, the TrackAudit, TrackLog, ComplianceLog tables in the Album database aren’t required.

 

To filter these tables from replication to the myrw-2 instance, use the replicate_wild_ignore_table parameter, which by default has the following value:

 

mysql.%,information_schema.%,performance_schema.%,sys.%

 

To skip these tables during replication, either specify each table separately or use “%” pattern matching via the Azure Portal or the Azure CLI.

 

Filter tables via the Azure portal

 

In the Azure portal, on the Server Parameters blade under Settings, update the default value of the replicate_wild_ignore_table parameter by appending the default value with the tables that you want to exclude from replication, as shown below:

 

mysql.%,information_schema.%,performance_schema.%,sys.%,Sales.SalesAudit,Sales.SalesLog,Sales.ComplianceLog,Album.TrackAudit,Album.TrackLog,Album.ComplianceLog

 

Alternately, you can use “%” pattern matching in the parameter value to avoid specifying the SalesLog and ComplianceLog tables in the Sales database and the TrackLog and ComplianceLog tables in the Album database, schema as all these tables ending with “Log”. In this case, the parameter value would be:

 

mysql.%,information_schema.%,performance_schema.%,sys.%,Sales.SalesAudit,Sales.%Log,Album.TrackAudit,Album.%Log

 

Filter tables via the Azure CLI

 

You can also use the Azure CLI to update the replicate_wild_ignore_table parameter. Below are the CLI commands that you can use to list and update the replicate_wild_ignore_table parameter in Azure Database for MySQL Server.

 

To show the current value of the replicate_wild_ignore_table parameter, run the following command:

 

Single Server

Flexible Server

az mysql server configuration show -g <resource-group> -s <server-name> -n replicate_wild_ignore_table --query value

az mysql flexible-server parameter show -g <resource-group> -s <server-name> -n replicate_wild_ignore_table --query value

 

To update the value of the replicate_wild_ignore_table parameter, run the following command:

 

Single Server

Flexible Server

az mysql server configuration set -g <resource-group> -s <server-name> -n replicate_wild_ignore_table --value <new-value>

az mysql flexible-server parameter set -g <resource-group> -s <server-name> -n replicate_wild_ignore_table --value <new-value>

 

Restart the Azure Database for MySQL instance by running the following command:

 

Single Server

Flexible Server

az mysql server restart -g <resource-group> -n <server-name>

az mysql flexible-server restart -g <resource-group> -n <server-name>

 

Provision read replicas from the secondary instance

 

The secondary instance, myrw-2, now includes only the tables that are required for read-only operations; the remaining tables have been excluded from replication to the secondary instance. You can now use the myrw-2 instance to provision the Azure Database for MySQL read replicas via the Azure Portal or Azure CLI, which will offload the read-only workload, as shown in Figure 3 below.

 

Fig3a.png

 

Finally, remember that the Azure Database for MySQL read replicas will by default have identical Compute and storage configuration as primary instance. If, after filtering the tables, your read replica instance is significantly smaller than the primary instance, then you can consider reducing the Compute size to reduce cost. It’s recommended to monitor the replication_lag_in_seconds metric regularly to ensure that the replication lag between the primary and read replica isn’t impacted because of the reduced Compute size.

 

Conclusion

 

Using the steps discussed above, you can easily filter tables that aren’t required for your read-only operations from replication. This configuration will help improve replication performance and potentially provide an option for reducing costs by lowering the Compute requirement for your read-replicas.

 

If you have any feedback or questions, please leave a comment below or email our team at AskAzureDBforMySQL@service.microsoft.com.

 

Thank you!

%3CLINGO-SUB%20id%3D%22lingo-sub-3039561%22%20slang%3D%22en-US%22%3EFiltering%20tables%20from%20Azure%20Database%20for%20MySQL%20read%20replica%20servers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3039561%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20certain%20scenarios%2C%20users%20may%20want%20to%20limit%20the%20tables%20that%20are%20replicated%20to%20a%20read%20replica%20server%20to%20improve%20performance%20and%20save%20costs.%20For%20example%2C%20many%20reporting%2Fanalytics%20workloads%20require%20only%20subset%20of%20the%20tables%20rather%20than%20the%20entire%20database%20schema(s).%20Similarly%2C%20a%20database%20schema%20for%20a%20web%20application%20often%20includes%20audit%20or%20logging%20tables%20designed%20to%20capture%20user%20behavior%20and%20to%20accommodate%20audit%20and%20compliance%20requirements.%20These%20tables%20have%20heavy%20write%20activities%20and%20often%20account%20for%2080-90%25%20of%20the%20instance%20size.%20While%20the%20tables%20are%20essential%20to%20ensuring%20that%20the%20application%20meets%20compliance%20requirements%2C%20they%20aren%E2%80%99t%20required%20for%20read-only%20functionality.%20In%20these%20examples%20there%E2%80%99s%20no%20need%20to%20replicate%20anything%20other%20than%20the%20required%20tables%20to%20meet%20the%20business%20requirements.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20when%20you%20set%20up%20an%20Azure%20Database%20for%20MySQL%20read%20replica%2C%20all%20the%20tables%20from%20your%20primary%20instance%20are%20copied%20to%20the%20read%20replicas%20by%20default.%20While%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmysql%2Foverview%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Database%20for%20MySQL%3C%2FA%3E%20service%20doesn%E2%80%99t%20support%20filtering%20a%20table%20or%20a%20database%20schema%20from%20a%20read%20replica%2C%20it%20does%20support%20the%20%3CA%20href%3D%22https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Freplication-options-replica.html%23option_mysqld_replicate-wild-ignore-table%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ereplicate_wild_ignore_table%3C%2FA%3E%20parameter%2C%20a%20native%20MySQL%20capability%2C%20which%20can%20prevent%20one%20or%20more%20tables%20from%20being%20included%20in%20MySQL%20replication.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20accomplish%20this%20goal%2C%20we%20simply%20need%20to%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ESet%20up%20MySQL%20Data-in%20replication%2C%20which%20allows%20you%20to%20synchronize%20data%20between%20two%20Azure%20Database%20for%20MySQL%20instances%20using%20the%20binary%20log%20(binlog)%20file%20position-based%20or%20GTID-based%20replication%20that%20is%20native%20to%20MySQL.%3C%2FLI%3E%0A%3CLI%3ELimit%20the%20tables%20replicated%20to%20the%20secondary%20replica%20instance%20via%20the%20Azure%20Portal%20or%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Fservice-page%2Fazure%2520database%2520for%2520mysql%3Fview%3Dazure-cli-latest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20CLI%3C%2FA%3E.%3C%2FLI%3E%0A%3CLI%3EProvision%20the%20required%20Azure%20Database%20for%20MySQL%20read%20replica%20from%20the%20secondary%20instance.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EThe%20rest%20of%20this%20blog%20post%20discusses%20how%20best%20to%20leverage%20the%20replicate_wild_ignore_table%20parameter%20and%20MySQL%20replication%20to%20prevent%20one%20or%20more%20tables%20from%20being%20replicated%20to%20the%20Azure%20Database%20for%20MySQL%20read%20replica.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%20style%3D%22height%3A%2030px%3B%20border-style%3A%20none%3B%20width%3A%20100%25%3B%22%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%20height%3D%2230px%22%3E%3CSTRONG%3ENote%3C%2FSTRONG%3E%3A%20This%20blog%20post%20applies%20to%20both%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmysql%2Fsingle-server-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESingle%20Server%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmysql%2Fflexible-server%2Foverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EFlexible%20Server%3C%2FA%3E.%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-332955501%22%20id%3D%22toc-hId-336502584%22%3EReference%20architecture%20using%20Azure%20DB%20for%20MySQL%20read%20replica%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20Azure%20Database%20for%20MySQL%2C%20the%20appropriate%20reference%20architecture%20to%20offload%20the%20read-only%20workload%20is%20shown%20in%20Figure-1%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Fig1a.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F334429iB83FFA400E82E5C4%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Fig1a.png%22%20alt%3D%22Fig1a.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20architecture%2C%20%3CSTRONG%3Emyrw-1%3C%2FSTRONG%3E%20is%20the%20source%20instance%20of%20Azure%20Database%20for%20MySQL%2C%20and%20it%20supports%20all%20Data%20Manipulation%20Language%20(DML)%20activities.%20This%20instance%20has%20four%20Azure%20Database%20for%20MySQL%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmysql%2Fconcepts-read-replicas%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eread%20replica%3C%2FA%3E%20servers%20(%3CSTRONG%3Emyrr-1%3C%2FSTRONG%3E%2C%20etc.)%20available%20for%20offloading%20read-only%20workloads%2C%20and%20by%20default%2C%20each%20of%20the%20read%20replica%20servers%20has%20a%20compute%20and%20storage%20configuration%20that%20is%20identical%20to%20the%20source%20instance.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20example%2C%20the%20source%20instance%20is%20in%20East%20US2%2C%20with%20read%20replica%20servers%20in%20East%20US%20and%20Central%20US.%20Each%20read%20replica%20server%20is%20updated%20asynchronously%20using%20the%20MySQL%20engine's%20native%20binary%20log%20(binlog)-based%20replication%20technology.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%3E%3CSTRONG%3ENote%3C%2FSTRONG%3E%3A%20Flexible%20Server%20doesn%E2%80%99t%20currently%20support%20cross-region%20read%20replicas%20or%20replication%20on%20a%20High%20Availability%20(HA)%20configuration.%20As%20a%20result%2C%20Flexible%20Server%20read%20replicas%20would%20be%20located%20in%20the%20same%20region%20as%20the%20primary%20instance.%20Cross-region%20read%20replicas%20and%20support%20for%20replication%20on%20an%20HA%20Flexible%20Server%20are%20on%20the%20product%20roadmap%20for%20future%20delivery.%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1474498962%22%20id%3D%22toc-hId--1470951879%22%3ESet%20up%20MySQL%20Data-in%20replication%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%2C%20we%20need%20to%20set%20up%20MySQL%20Data-in%20replication%20for%20the%20primary%20instance%2C%20%3CSTRONG%3Emyrw-1%3C%2FSTRONG%3E.%20In%20so%20doing%2C%20we%E2%80%99ll%20create%20the%20secondary%20instance%2C%20%3CSTRONG%3Emyrw-2%3C%2FSTRONG%3E%2C%20as%20shown%20in%20Figure%202%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Fig2a.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F334430i435169E90B5BB63D%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Fig2a.png%22%20alt%3D%22Fig2a.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%3E%3CSTRONG%20style%3D%22font-family%3A%20inherit%3B%22%3ENote%3C%2FSTRONG%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E%3A%20For%20more%20information%2C%20see%20%3C%2FSPAN%3E%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmysql%2Fhowto-data-in-replication%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHow%20to%20configure%20Azure%20Database%20for%20MySQL%20Data-in%20Replication%3C%2FA%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3E.%3C%2FSPAN%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1013013871%22%20id%3D%22toc-hId-1016560954%22%3ELimit%20tables%20replicated%20to%20the%20secondary%20instance%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENext%2C%20we%20need%20to%20limit%20the%20tables%20that%20are%20replicated%20from%20the%20%3CSTRONG%3Emyrw-1%3C%2FSTRONG%3E%20instance%20to%20the%20%3CSTRONG%3Emyrw-2%3C%2FSTRONG%3E%20instance.%20Let%E2%80%99s%20assume%20that%20the%20%3CSTRONG%3Emyrw-1%3C%2FSTRONG%3E%20instance%20has%20two%20databases%20(%3CSTRONG%3ESales%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EAlbum%3C%2FSTRONG%3E)%2C%20and%20that%20each%20database%20includes%20some%20tables%20that%20are%20required%20by%20the%20application%20or%20for%20read-only%20operations%20and%20some%20that%20aren%E2%80%99t%2C%20as%20listed%20in%20the%20following%20table%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2272%22%3E%3CP%3E%3CSTRONG%3EDatabase%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22300%22%3E%3CP%3E%3CSTRONG%3ERequired%20tables%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22300%22%3E%3CP%3E%3CSTRONG%3ETables%20that%20aren%E2%80%99t%20required%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2272%22%3E%3CP%3E%3CSTRONG%3ESales%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22300%22%3E%3CP%3ECity%2C%20Country%2C%20CountryLanguage%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22300%22%3E%3CP%3ESalesAudit%2C%20SalesLog%2C%20ComplianceLog%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%2272%22%3E%3CP%3E%3CSTRONG%3EAlbum%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22300%22%3E%3CP%3EAlbum%2C%20Track%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22300%22%3E%3CP%3ETrackAudit%2C%20TrackLog%2C%20ComplianceLog%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20see%2C%20%3CEM%3Eread%3C%2FEM%3E%20operations%20don%E2%80%99t%20require%20the%20%3CSTRONG%3ESalesAudit%3C%2FSTRONG%3E%2C%20%3CSTRONG%3ESalesLog%3C%2FSTRONG%3E%2C%20and%20%3CSTRONG%3EComplianceLog%3C%2FSTRONG%3E%20tables%20in%3CSTRONG%3E%20Sales%20%3C%2FSTRONG%3Edatabase.%20Similarly%2C%20the%20%3CSTRONG%3ETrackAudit%3C%2FSTRONG%3E%2C%20%3CSTRONG%3ETrackLog%3C%2FSTRONG%3E%2C%20%3CSTRONG%3EComplianceLog%3C%2FSTRONG%3E%20tables%20in%20the%20%3CSTRONG%3EAlbum%3C%2FSTRONG%3E%20database%20aren%E2%80%99t%20required.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20filter%20these%20tables%20from%20replication%20to%20the%20%3CSTRONG%3Emyrw-2%3C%2FSTRONG%3E%20instance%2C%20use%20the%20replicate_wild_ignore_table%20parameter%2C%20which%20by%20default%20has%20the%20following%20value%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CFONT%20color%3D%22%230000FF%22%3Emysql.%25%2Cinformation_schema.%25%2Cperformance_schema.%25%2Csys.%25%3C%2FFONT%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20skip%20these%20tables%20during%20replication%2C%20either%20specify%20each%20table%20separately%20or%20use%20%E2%80%9C%25%E2%80%9D%20pattern%20matching%20via%20the%20Azure%20Portal%20or%20the%20Azure%20CLI.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--93376014%22%20id%3D%22toc-hId--89828931%22%3EFilter%20tables%20via%20the%20Azure%20portal%3C%2FH4%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20Azure%20portal%2C%20on%20the%20%3CSTRONG%3EServer%20Parameters%3C%2FSTRONG%3E%20blade%20under%20%3CSTRONG%3ESettings%3C%2FSTRONG%3E%2C%20update%20the%20default%20value%20of%20the%20replicate_wild_ignore_table%20parameter%20by%20appending%20the%20default%20value%20with%20the%20tables%20that%20you%20want%20to%20exclude%20from%20replication%2C%20as%20shown%20below%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CFONT%20color%3D%22%230000FF%22%3Emysql.%25%2Cinformation_schema.%25%2Cperformance_schema.%25%2Csys.%25%2C%3C%2FFONT%3E%3CFONT%20color%3D%22%23FF0000%22%3ESales.SalesAudit%2CSales.SalesLog%2CSales.ComplianceLog%2CAlbum.TrackAudit%2CAlbum.TrackLog%2CAlbum.ComplianceLog%3C%2FFONT%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlternately%2C%20you%20can%20use%20%E2%80%9C%25%E2%80%9D%20pattern%20matching%20in%20the%20parameter%20value%20to%20avoid%20specifying%20the%20%3CSTRONG%3ESalesLog%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EComplianceLog%3C%2FSTRONG%3E%20tables%20in%20the%20%3CSTRONG%3ESales%3C%2FSTRONG%3E%20database%20and%20the%20%3CSTRONG%3ETrackLog%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EComplianceLog%3C%2FSTRONG%3E%20tables%20in%20the%20%3CSTRONG%3EAlbum%3C%2FSTRONG%3E%20database%2C%20schema%20as%20all%20these%20tables%20ending%20with%20%E2%80%9CLog%E2%80%9D.%20In%20this%20case%2C%20the%20parameter%20value%20would%20be%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CFONT%20color%3D%22%230000FF%22%3Emysql.%25%2Cinformation_schema.%25%2Cperformance_schema.%25%2Csys.%25%2C%3C%2FFONT%3E%3CFONT%20color%3D%22%23FF0000%22%3ESales.SalesAudit%2CSales.%25Log%2CAlbum.TrackAudit%2CAlbum.%25Log%3C%2FFONT%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--1900830477%22%20id%3D%22toc-hId--1897283394%22%3EFilter%20tables%20via%20the%20Azure%20CLI%3C%2FH4%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20use%20the%20Azure%20CLI%20to%20update%20the%20replicate_wild_ignore_table%20parameter.%26nbsp%3BBelow%20are%20the%20CLI%20commands%20that%20you%20can%20use%20to%20list%20and%20update%20the%20replicate_wild_ignore_table%20parameter%20in%20Azure%20Database%20for%20MySQL%20Server.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20show%20the%20current%20value%20of%20the%20replicate_wild_ignore_table%20parameter%2C%20run%20the%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3E%3CSTRONG%3ESingle%20Server%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3E%3CSTRONG%3EFlexible%20Server%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3Eaz%20mysql%20server%20configuration%20show%20-g%20%3CRESOURCE-GROUP%3E%20-s%20%3CSERVER-NAME%3E%20-n%20replicate_wild_ignore_table%20--query%20value%3C%2FSERVER-NAME%3E%3C%2FRESOURCE-GROUP%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3Eaz%20mysql%20flexible-server%20parameter%20show%20-g%20%3CRESOURCE-GROUP%3E%20-s%20%3CSERVER-NAME%3E%20-n%20replicate_wild_ignore_table%20--query%20value%3C%2FSERVER-NAME%3E%3C%2FRESOURCE-GROUP%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20update%20the%20value%20of%20the%20replicate_wild_ignore_table%20parameter%2C%20run%20the%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3E%3CSTRONG%3ESingle%20Server%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3E%3CSTRONG%3EFlexible%20Server%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3Eaz%20mysql%20server%20configuration%20set%20-g%20%3CRESOURCE-GROUP%3E%20-s%20%3CSERVER-NAME%3E%20-n%20replicate_wild_ignore_table%20--value%20%3CNEW-VALUE%3E%3C%2FNEW-VALUE%3E%3C%2FSERVER-NAME%3E%3C%2FRESOURCE-GROUP%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3Eaz%20mysql%20flexible-server%20parameter%20set%20-g%20%3CRESOURCE-GROUP%3E%20-s%20%3CSERVER-NAME%3E%20-n%20replicate_wild_ignore_table%20--value%20%3CNEW-VALUE%3E%3C%2FNEW-VALUE%3E%3C%2FSERVER-NAME%3E%3C%2FRESOURCE-GROUP%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERestart%20the%20Azure%20Database%20for%20MySQL%20instance%20by%20running%20the%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3E%3CSTRONG%3ESingle%20Server%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3E%3CSTRONG%3EFlexible%20Server%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3Eaz%20mysql%20server%20restart%20-g%20%3CRESOURCE-GROUP%3E%20-n%20%3CSERVER-NAME%3E%3C%2FSERVER-NAME%3E%3C%2FRESOURCE-GROUP%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22336%22%3E%3CP%3Eaz%20mysql%20flexible-server%20restart%20-g%20%3CRESOURCE-GROUP%3E%20-n%20%3CSERVER-NAME%3E%3C%2FSERVER-NAME%3E%3C%2FRESOURCE-GROUP%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--114382222%22%20id%3D%22toc-hId--110835139%22%3EProvision%20read%20replicas%20from%20the%20secondary%20instance%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20secondary%20instance%2C%20%3CSTRONG%3Emyrw-2%3C%2FSTRONG%3E%2C%20now%20includes%20only%20the%20tables%20that%20are%20required%20for%20read-only%20operations%3B%20the%20remaining%20tables%20have%20been%20excluded%20from%20replication%20to%20the%20secondary%20instance.%20You%20can%20now%20use%20the%20%3CSTRONG%3Emyrw-2%3C%2FSTRONG%3E%20instance%20to%20provision%20the%20Azure%20Database%20for%20MySQL%20read%20replicas%20via%20the%20Azure%20Portal%20or%20Azure%20CLI%2C%20which%20will%20offload%20the%20read-only%20workload%2C%20as%20shown%20in%20Figure%203%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Fig3a.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F334432iD18CB0ECDEEC61A2%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Fig3a.png%22%20alt%3D%22Fig3a.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFinally%2C%20remember%20that%20the%20Azure%20Database%20for%20MySQL%20read%20replicas%20will%20by%20default%20have%20identical%20Compute%20and%20storage%20configuration%20as%20primary%20instance.%20If%2C%20after%20filtering%20the%20tables%2C%20your%20read%20replica%20instance%20is%20significantly%20smaller%20than%20the%20primary%20instance%2C%20then%20you%20can%20consider%20reducing%20the%20Compute%20size%20to%20reduce%20cost.%20It%E2%80%99s%20recommended%20to%20monitor%20the%20replication_lag_in_seconds%20metric%20regularly%20to%20ensure%20that%20the%20replication%20lag%20between%20the%20primary%20and%20read%20replica%20isn%E2%80%99t%20impacted%20because%20of%20the%20reduced%20Compute%20size.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1921836685%22%20id%3D%22toc-hId--1918289602%22%3EConclusion%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUsing%20the%20steps%20discussed%20above%2C%20you%20can%20easily%20filter%20tables%20that%20aren%E2%80%99t%20required%20for%20your%20read-only%20operations%20from%20replication.%20This%20configuration%20will%20help%20improve%20replication%20performance%20and%20potentially%20provide%20an%20option%20for%20reducing%20costs%20by%20lowering%20the%20Compute%20requirement%20for%20your%20read-replicas.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20any%20feedback%20or%20questions%2C%20please%20leave%20a%20comment%20below%20or%20email%20our%20team%20at%20%3CA%20href%3D%22mailto%3AAskAzureDBforMySQL%40service.microsoft.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EAskAzureDBforMySQL%40service.microsoft.com%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-3039561%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Teaser2.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F334442i358E9F0073BDF873%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Teaser2.png%22%20alt%3D%22Teaser2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3EThis%20blog%20post%20discusses%20how%20best%20to%20leverage%20the%20replicate_wild_ignore_table%20parameter%20and%20MySQL%20replication%20to%20prevent%20one%20or%20more%20tables%20from%20being%20replicated%20to%20an%20Azure%20Database%20for%20MySQL%20read%20replica.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Version history
Last update:
‎Dec 16 2021 11:08 AM
Updated by: