Managing datafiles

This section describes how to manage datafiles: create, list and delete datafiles, renaming, moving, resizing and defragmenting datafiles.

A datafile is identified by:

Datafile name and file name

The datafile name and its file name are two different things: the file name is simply the operating system file name, as in /var/tmp/foo.dat and the name is an identifier known by EyeDB that can be used to identify the datafile as in FOO.

Creating, listing and deleting datafiles

Creating a datafile is done using the eyedbadmin command:

eyedbadmin
datafile create [options] {database} {datafile}

Options are:

  • --filedir=directory

    datafile directory

  • --name=name

    datafile name (see Note)

  • --size=size

    datafile size in Mbytes

  • --slotsize=slotsize

    the allocation slot size in bytes

  • --physical

    to specify that this datafile will contain physical Oids (see Chapter 6, Database tuning)

Command arguments are:

  • {database}

    the database to which the datafile will be attached

  • {datafile}

    the datafile name (.dat file name extension is recommended)

Example 5.1. eyedbadmin datafile create

	    ## create a datafile
	    eyedbadmin datafile create test3 data1.dat
	    ## create a datafile with a name
	    eyedbadmin datafile create --name=DATA2 test3 data2.dat
	    ## create a datafile with a size of 30 Gb and a directory
	    eyedbadmin datafile create --filedir=/var/tmp --size=30000 test3 data3.dat
	    ## list the database
	    eyedbadmin database list --datafiles test3
	    test3.dat
	    data1.dat
	    data2.dat
	    /var/tmp/data3.dat
	  

The list of the datafiles associated with a database can be obtained using the eyedbadmin command:

eyedbadmin
datafile list [options] {database} {[{datafile_id} | {datafile_name}]...}

Options are:

  • --all

    list all informations about datafile

  • --stats

    list only statistics on datafile

Command arguments are:

  • {database}

    the database to which the datafile belongs

  • {[{datafile_id} | {datafile_name}]...}

    the datafiles to be listed, that can be specified either by its id or by its name

Example 5.2. eyedbadmin datafile list

	    ## List
	    eyedbadmin datafile list --all test3
	    Datafile #0
	    Name      DEFAULT
	    Dataspace #0 DEFAULT
	    File      test3.dat
	    Maxsize   2147483648b, ~2097152Kb, ~2048Mb, ~2Gb
	    Slotsize  16
	    Oid Type  Logical

	    Object Number        2561
	    Total Busy Size      8439065b, ~8241Kb, ~8Mb
	    Average Size         3295b, ~3Kb

	    ... output deleted

	    Datafile #1
	    Name      <unnamed>
	    File      data1.dat
	    Maxsize   2147483648b, ~2097152Kb, ~2048Mb, ~2Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted

	    Datafile #2
	    Name      DATA2
	    File      data2.dat
	    Maxsize   2147483648b, ~2097152Kb, ~2048Mb, ~2Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted

	    Datafile #3
	    Name      <unnamed>
	    File      /var/tmp/data3.dat
	    Maxsize   31457280000b, ~30720000Kb, ~30000Mb, ~29Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted
	  

Deleting a datafile is done using the eyedbadmin command:

eyedbadmin
datafile delete {[{datafile_id} | {datafile_name}]}

Command arguments are:

  • {database}

    the database to which the datafile belongs

  • {[{datafile_id} | {datafile_name}]}

    the datafile to be deleted, that can be specified either by its id or by its name

Example 5.3. eyedbadmin datafile delete

	    ## Delete datafile by id
	    eyedbadmin datafile delete test3 1
	    ## Delete datafile by name
	    eyedbadmin datafile delete test3 DATA2
	    ## List
	    eyedbadmin datafile list test3
	    Datafile #0
	    Name      DEFAULT
	    Dataspace #0 DEFAULT
	    File      test3.dat
	    Maxsize   2147483648b, ~2097152Kb, ~2048Mb, ~2Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted

	    Datafile #3
	    Name      <unnamed>
	    File      /var/tmp/data3.dat
	    Maxsize   31457280000b, ~30720000Kb, ~30000Mb, ~29Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted
	  

Renaming and moving datafiles

A datafile has a name (see Note); changing this name is done using the eyedbadmin command:

eyedbadmin
datafile rename {database} {[{datafile_id} | {datafile_name}]} {new_name}

Example 5.4. eyedbadmin datafile rename

	    ## Rename datafile
	    eyedbadmin datafile rename test3 3 DATA3
	    ## List
	    eyedbadmin datafile list test3
	    Datafile #0
	    Name      DEFAULT
	    Dataspace #0 DEFAULT
	    File      test3.dat
	    Maxsize   2147483648b, ~2097152Kb, ~2048Mb, ~2Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted

	    Datafile #3
	    Name      DATA3
	    File      /var/tmp/data3.dat
	    Maxsize   31457280000b, ~30720000Kb, ~30000Mb, ~29Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted
	  

Moving a datafile is done using the eyedbadmin command:

eyedbadmin
datafile move [options] {database} {[{datafile_id} | {datafile_name}]} {new_datafile}

Options are:

  • --filedir=directory

    datafile directory

Command arguments are:

  • {database}

    the database to which the datafile belongs

  • {[{datafile_id} | {datafile_name}]}

    the datafile to be moved, that can be specified either by its id or by its name

  • {datafile}

    the new datafile file name (.dat file name extension is recommended)

Example 5.5. eyedbadmin datafile move

	    ## Create destination directory
	    mkdir /var/tmp/test3
	    ## Move datafile
	    eyedbadmin datafile move --filedir=/var/tmp/test3 test3 DATA3 newdata3.dat
	    ## List
	    eyedbadmin datafile list test3
	    Datafile #0
	    Name      DEFAULT
	    Dataspace #0 DEFAULT
	    File      test3.dat
	    Maxsize   2147483648b, ~2097152Kb, ~2048Mb, ~2Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted

	    Datafile #3
	    Name      DATA3
	    File      /var/tmp/test3/newdata3.dat
	    Maxsize   31457280000b, ~30720000Kb, ~30000Mb, ~29Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted
	  

Resizing and defragmenting datafiles

Datafile size is set at creation time; once created, the size of a datafile can be changed using the eyedbadmin command:

eyedbadmin
datafile resize {database} {[{datafile_id} | {datafile_name}]} {new_size}

Command arguments are:

  • {database}

    the database to which the datafile belongs

  • {[{datafile_id} | {datafile_name}]}

    the datafile to be resized, that can be specified either by its id or by its name

  • {new_size}

    the new datafile size, in Mbytes

Example 5.6. eyedbadmin datafile resize

	    ## List
	    eyedbadmin datafile list test3 DATA3
	    Datafile #3
	    Name      DATA3
	    File      /var/tmp/test3/newdata3.dat
	    Maxsize   31457280000b, ~30720000Kb, ~30000Mb, ~29Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted
	    ## Set new size to 40Gb
	    eyedbadmin datafile resize test3 DATA3 40000
	    ## List
	    eyedbadmin datafile list test3 DATA3
	    Datafile #3
	    Name      DATA3
	    File      /var/tmp/test3/newdata3.dat
	    Maxsize   41943040000b, ~40960000Kb, ~40000Mb, ~39Gb
	    Slotsize  16
	    Oid Type  Logical

	    ... output deleted
	  

Datafiles can become fragmented because of object deletion; the allocator used inside datafile is a bitmap allocator for better efficiency, but as a consequence there can be holes in the datafile that can impact performance. Defragmenting can be done using the eyedbadmin command:

eyedbadmin
datafile defragment {database} {[{datafile_id} | {datafile_name}]}

Command arguments are:

  • {database}

    the database to which the datafile belongs

  • {[{datafile_id} | {datafile_name}]}

    the datafile to be defragmented, that can be specified either by its id or by its name

Example 5.7. eyedbadmin datafile defragment

	    ## datafile can be given by their id
	    eyedbadmin datafile defragment test3 0
	    ## datafile can also be given by their name
	    eyedbadmin datafile defragment test3 DEFAULT
	    ## giving a non-existing datafile
	    eyedbadmin datafile defragment test3 42
	    eyedb error: datafile #42 not found in database test3