Replication

Planning for Transactional Replication

Transactional replication requires planning in the following areas:

Transaction Log Space

For each database that will be published in transactional replication, ensure that the transaction log has enough space allocated. The transaction log of a published database may require more space than the log of an identical, unpublished database. This is because the log records may not be purged until they have been moved to the distribution database.

If the distribution database is unavailable, or if the Log Reader Agent is not running, the transaction log of a publication database continues to grow. The log cannot be truncated past the oldest published transaction that has not been passed into the distribution database (unless replication is turned off completely for that database). It is recommended that you set the transaction log file to autogrow so that the log can accommodate these circumstances.

Disk Space for the Distribution Database

If you plan to create transactional publications and make the snapshot files available to Subscribers immediately, allow enough disk space for the distribution database to store all of the transactions after the last snapshot. Although making the snapshot available to Subscribers immediately improves the speed with which new Subscribers have access to the publication, the option does require a larger disk storage area for the distribution database. It also means that a new snapshot will be generated each time the Snapshot Agent runs. If the option is not used, and if anonymous subscriptions are not allowed, a new snapshot needs to be generated only if there is a new subscription.

The distribution database begins collecting transactions immediately and continues to store them until the second time the Snapshot Agent is run (either scheduled or run manually). After the second time the Snapshot Agent is run, the cleanup task begins to clean up and reduce the size of the distribution database by deleting the rows from the first snapshot. Thus, if you use the default schedule of once a day for running the Snapshot Agent, you must have enough disk space to store all the transactions that occur in one day.

Similarly, if you plan to create transactional publications and allow anonymous subscriptions to a publication, you must allow enough disk space for the distribution database to store all of the transactions since the last snapshot. Allowing anonymous subscriptions also means that a new snapshot will be generated every time the Snapshot Agent runs.

An alternative to allocating more disk space in both of these situations is to run the Snapshot Agent more frequently than once a day (the default) so fewer commands must be retained in the distribution database. However, generating a snapshot can be resource-intensive and can affect performance temporarily. Reducing the distribution retention period (in Publisher and Distributor Properties) can also help maintain fewer commands because the Distribution Clean Up Agent is controlled by the distribution retention period and will remove replicated transactions from the distribution database.

Primary Keys

All published tables in transactional replication must contain a declared primary key. Existing tables can be prepared for publishing by adding a declared primary key using the Transact-SQL statement ALTER TABLE.

text and image Data Types in Transactional Replication

The process of replicating text and image data types in a transactional publication is subject to the following considerations:

An important consideration when sizing Subscriber databases is that the text pointer for replicated text and image columns must be initialized on Subscriber tables, even when they are not initialized on the Publisher. Consequently, each text and image column added to the Subscriber table by the distribution task will consume at least 43 bytes of database storage even if the contents are empty.