databaseclickhouse

What is the Store folder in ClickHouse?


What is the Store folder in ClickHouse?
There is a folder called Store in ClickHouse and it has a very large size.
I only have one database and its size is 1 gig, but the Store folder is almost 8 gig.
Can this folder be deleted?
There is little information on the Internet about this folder.
store folder disk size

the size of my database: database size query


Solution

  • This is where the ClickHouse data is actually stored in recent ClickHouse versions. The /data directory contains symlinks to the /store sub directory where the data is for each table is actually kept. So deleting that directory entirely will lose all of your data.

    In most cases if you drop tables or whole databases from ClickHouse, the corresponding /store directory is also deleted. However, in some situations (crashes, etc.) these directories can get out sync.

    If that happens you can selectively delete /store subdirectories if you are confident they contain data that ClickHouse no longer knows about. You can tell what /store directories ClickHouse is using by looking at the symlinks in the /data directory. You can find the specific symlink associated with a table in /data/<database_name>/<table_name>

    For example, on my local machine the system database is using three symlinks in store:

    m1 geoff@GeoffMac: ~/chrun ls -la data/system
    total 0
    drwx------   5 geoff  staff   160 Jan  3 05:26 .
    drwx------  49 geoff  staff  1568 Jan  6 18:34 ..
    lrwxr-x---   1 geoff  staff    66 Jan  3 05:26 metric_log -> /Users/geoff/chrun/store/57f/57fbc8e9-14ed-4cbc-9c9d-28ae69ff196f/
    lrwxr-x---   1 geoff  staff    66 Jan  3 05:26 query_log -> /Users/geoff/chrun/store/d13/d13002dd-92c1-49b2-8dac-16ae1a63efef/
    lrwxr-x---   1 geoff  staff    66 Jan  3 05:26 session_log -> /Users/geoff/chrun/store/6dd/6dd443b3-44cf-4254-8767-ed8fd2933102/
    

    By checking your /data symlinks again the /store directory you should be able to determine what /store directories aren't being used. (Someone could write a script for this)