When loading a dump of a database that had a segregated log and data segment, SAP ASE rearranges the physical layout of the target database to ensure physical separation of the log and data segments.
To avoid data and log fragments on the same device, SAP ASE versions 15.7 SP100 and later rearrange the physical layout of the database to accommodate for the log and data distribution in the database dump:
The %s segment in the target database '%.*s' is too small (%d MB) to accommodate the %s segment from the dumped database (%d MB). The target database will be rearranged not to mix up data and log
Example of physical database rearrangement on loading
Using the same create database command used earlier, the following example shows the results when there is insufficient space to accommodate the data segment when loading a database:
load database target_db from '/dumps/source_db.dmp' go Msg 3185, Level 16, State 2: Line 1: The data segment in the target database 'target_db' is too small (10 MB) to accommodate the data segment from the dumped database (14 MB).
Because the data segment in the source database is 14 MB and only 10 MB in the target database, the space must be increased before loading the database:
1> alter database target_db on dev1=4 2> go Extending database by 1024 pages (4.0 megabytes) on disk dev1
Now load the database:
1> load database target_db from '/dumps/source_db.dmp' 2> go 1> select dbid, segmap, lstart, size, vdevno, vstart, location 2> from master..sysusages where dbid=b_id("target_db") 3> go
The sysusages rows for the target database shows how SAP ASE now handles loading a database during which physical rearrangement has occurred. SAP ASE has placed the data segment (with a segmap of 3) on the device with vdevno = 1, and the log segment (with a segmap of 4), on the device with a vdevno = 2. This means that the log and data segments are now on separate devices.
dbid segmap lstart size vdevno vstart location ---- -------- ------ ------ ------- ------ --------- 7 3 0 1536 1 3072 0 7 4 1536 768 2 1536 0 7 3 2304 1024 1 6144 0 7 3 3328 1024 1 8192 0 7 4 4352 1792 2 3072 0
The rearrangement of these pages and segments has left the same logical ordering, but a different physical layout. All pages in vdevno = 1 are data pages and all pages in vdevno = 2 are now log pages. The new pages from 4352 to 6143 that did not exist in source_db, because they have been created in vdevno = 2 which is the device holding the log, have become log pages as well.
In versions earlier than 15.7 SP100, to move a database (the source database) to new devices on your system or to rebuild a database on the old devices, you needed to first create the new database (the target database), then load a dump of the source database onto the target database. SAP ASE would preserve the logical structure of the source database when it was loaded onto the target database. That is, every database page in a fragment of the source database occupies the same logical space in the target database, irrespective of the physical location of the fragment in the target database to which it is copied. This can result in parts of the data segment and the log segment being physically located on the same device. In order to prevent this, you needed to create a target database that was identical to the source database by:
Example
The following example demonstrates how loading a dump onto a database created with fragments of different sizes, or fragments in a different order than in the source database, increases the number of fragments, and places data and log on the same device. This example is based on an SAP ASE installation using a 4K bytes page size
Creating source_db
The source database, source_db, was created as follows:
1> create database source_db 2> on dev1 = 6 3> log on dev2 = 3 4> goLater, two more data fragments on different devices were added to the database:
1> alter database source_db 2> on dev3 = 4, 3> dev4 = 4 4> go
A select from sysusages shows four fragments for source_db:
select dbid, segmap, lstart, size, vdevno, vstart, location from master..sysusages where dbid=db_id("source_db") go
dbid segmap lstart size vdevno vstart location ---- -------- ------ ------ ------- ------ --------- 4 3 0 1536 1 0 0 4 4 1536 768 2 0 0 4 3 2304 1024 3 0 0 4 3 3328 1024 4 0 0 (4 rows affected)
Creating target_db
target_db is created differently than source_db. The database is created in a single command on all of the devices at once instead of being altered onto the devices later and with a different size:
1> create database target_db 2> on dev1 = 10 3> log on dev2=10 6> go
1> select dbid, segmap, lstart, size, vdevno, vstart, location 2> from master..sysusages where dbid=db_id("target_db") 3> go
dbid segmap lstart size vdevno vstart location ---- -------- ------ ------ ------- ------ --------- 7 3 0 2560 1 3072 0 7 4 2560 2560 2 1536 0
Loading the dump from source_db onto target_db
The database source_db is dumped and loaded onto target_db:
1> load database target_db from "/dumps/source_db.dmp" 2> go
SAP ASE keeps the logical distribution of pages from the dump when they are copied to the target, which results in the following:
1> select dbid, segmap, lstart, size, vdevno, vstart, location 2> from master..sysusages where dbid=b_id("target_db") 3> go
dbid segmap lstart size vdevno vstart location ---- -------- ------ ------ ------- ------ --------- 7 3 0 1536 1 3072 0 7 4 1536 768 1 6144 0 7 3 2304 256 1 7680 0 7 3 2560 1792 2 1536 0 7 3 4352 768 2 5120 0
Results of example
Loading the dump of source_db onto target_db caused the following undesirable results:
dbid segmap lstart size vdevno vstart location ---- -------- ------ ------ ------- ------ --------- 7 3 0 1536 1 3072 0 7 4 1536 768 1 6144 0 7 3 2304 256 1 7680 0 7 3 2560 1792 2 1536 0 7 3 4352 768 2 5120 0
You can see from the above, a log fragment is on device vdevno = 1. However, there are two data fragments, (the first and third row) that are also on vdevno = 1. Meaning that the log segment is on the same device as the data segment.