Delete data

Updated at:

This topic describes how to purge a database and concurrently delete data based on point labels, edge labels, point IDs, or edge IDs.

Purge the database

To purge the database, see Purge instance data.

Warning

This operation purges all data from the instance. You must confirm the operation before you proceed. If you want to delete only a portion of the data, see the Deletion script section.

Deletion script

You can run the following script to concurrently delete data based on point labels, edge labels, point IDs, or edge IDs.

  1. Download and unzip the deletion script.

    wget https://github.com/aliyun/alibabacloud-gdb-tools/archive/refs/heads/master.zip
    unzip master.zip
    pip install -r requirements.txt --user
  2. Examples

    • Delete all points with the label Player using 32 concurrent threads.

      python GdbDataRemover.py --host ${gdb_end_point} --port ${gdb_port} --username ${gdb_user} --password ${gdb_pwd} --label player --threadCnt 32
    • Batch delete points based on the IDs in an input file. The batch size is 128.

      python GdbDataRemover.py --host ${gdb_end_point} --port ${gdb_port} --username ${gdb_user} --password ${gdb_pwd} --threadCnt 32 --batch 128 input1.txt [input2.txt]

      The input file input1.txt contains a list of point IDs, with one ID per line.

    • Batch delete edges based on the IDs in an input file. The batch size is 128.

      python GdbDataRemover.py --host ${gdb_end_point} --port ${gdb_port} --username ${gdb_user} --password ${gdb_pwd} --threadCnt 32 --edge --batch 128 input1.txt [input2.txt]

      The input file input1.txt contains a list of edge IDs, with one ID per line.

    Note
    • ${gdb_end_point}: Replace this with the endpoint of the Graph Database (GDB) instance. This can be a private or public endpoint.

    • ${gdb_port}: Replace this with the port number that corresponds to the endpoint of the GDB instance. This can be a private or public port.

    • ${gdb_user}: Replace this with the account name for the GDB instance.

    • ${gdb_pwd}: Replace this with the account password for the GDB instance.

Limit the number of items to delete

Graph Database (GDB) supports transactions with atomicity, consistency, isolation, and durability (ACID). However, the dataset for each modification must be 8 MB or smaller. If you do not use the provided script, you must manually limit the amount of data that you delete in each operation.

Example:

  • Recommended method: Limit the amount of data deleted in each operation to 1024 bytes.

    String dsl ="g.V().limit(1024).drop()";
    ResultSet results = client.submit(dsl);
  • Standard method

    String dsl ="g.V().drop()";
    ResultSet results = client.submit(dsl);