Label | Explanation | Data Type |
Input Workspace |
The file geodatabase to be compacted. | Workspace |
Derived Output
Label | Explanation | Data Type |
Updated Input Workspace | The updated input workspace. | Workspace |
Compacts a file geodatabase. Compacting rearranges how the geodatabase is stored on disk, often reducing its size and improving performance.
If data entry, deletion, or general editing is frequently performed on a database, the database should be regularly compacted to ensure optimal performance.
If a database is open in ArcGIS Pro for editing, it cannot be compacted. To compact the database, remove any layers with a source table or feature class in that database from the Table Of Contents.
File geodatabases are stored as binary files on a disk drive. As data is added, removed, or edited, these files become fragmented, decreasing overall database performance. The Compact tool is used to rearrange how the database is stored on disk by defragmenting these binary files, reducing the database's size on disk and improving database performance.
Label | Explanation | Data Type |
Input Workspace |
The file geodatabase to be compacted. | Workspace |
Label | Explanation | Data Type |
Updated Input Workspace | The updated input workspace. | Workspace |
arcpy.management.Compact(in_workspace)
Name | Explanation | Data Type |
in_workspace |
The file geodatabase to be compacted. | Workspace |
Name | Explanation | Data Type |
out_workspace | The updated input workspace. | Workspace |
The following Python window script demonstrates how to use the Compact function in immediate mode.
import arcpy
arcpy.Compact_management("c:/landuse.gdb")
The following stand-alone script is a simple example of how to use the Compact function in a scripting environment.
# Name: Compact_Example.py
# Description: compact a file geodatabase
# Import the system modules
import arcpy
# Set local variables
gdbWorkspace = "C:/data/data.gdb"
arcpy.Compact_management(gdbWorkspace)