Search code examples
graph-databasesmemgraphdb

Memgraph is an in-memory database. Does that mean that data is lost when I shutdown the computer?


Memgraph is an in-memory database. Does that mean that data is lost when I shut down the computer?

Do I need to use GQLAlchemy library as an on-disk storage solution to ensure data persistence?


Solution

  • The data is not lost when you shutdown your computer.

    Memgraph uses two mechanisms to ensure data durability:

    • write-ahead logs (WAL)
    • periodic snapshots

    Snapshots are taken periodically during the entire runtime of Memgraph based on the time defined with the --storage-snapshot-interval-sec configuration flag. The whole data storage is written to the disk when a snapshot is triggered. Write-ahead logs save all database modifications that happened to a file.

    If you want to generate a snapshot for the current database state instantly, use the following query:

    CREATE SNAPSHOT;
    

    If you are using Docker, check how to specify volumes for data persistence.


    Therefore, you don't need to use GQLAlchemy to insure data persistence. GQLAlchemy library provides an on-disk storage solution for large properties not used in graph algorithms. This is useful when nodes or relationships have metadata that doesn’t need to be used in any of the graph algorithms that need to be carried out in Memgraph, but can be fetched after. You can check out the how-to guide to learn how to use an SQL database to store node properties seamlessly as if they were being stored in Memgraph.