美文网首页
What's the difference between At

What's the difference between At

作者: 光剑书架上的书 | 来源:发表于2022-03-21 01:42 被阅读0次

    问题: ClickHouse 数据库引擎,默认的到底是 Atomic 还是 Ordinary?

    I found this comment in source file: src/Databases/DatabaseAtomic.h

    
    /// All tables in DatabaseAtomic have persistent UUID and store data in
    /// /clickhouse_path/store/xxx/xxxyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy/
    /// where xxxyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy is UUID of the table.
    /// RENAMEs are performed without changing UUID and moving table data.
    /// Tables in Atomic databases can be accessed by UUID through DatabaseCatalog.
    /// On DROP TABLE no data is removed, DatabaseAtomic just marks table as dropped
    /// by moving metadata to /clickhouse_path/metadata_dropped/ and notifies DatabaseCatalog.
    /// Running queries still may use dropped table. Table will be actually removed when it's not in use.
    /// Allows to execute RENAME and DROP without IStorage-level RWLocks
    class DatabaseAtomic : public DatabaseOrdinary
    {
    public:
        DatabaseAtomic(String name_, String metadata_path_, UUID uuid, const String & logger_name, ContextPtr context_);
        DatabaseAtomic(String name_, String metadata_path_, UUID uuid, ContextPtr context_);
    
        String getEngineName() const override { return "Atomic"; }
        UUID getUUID() const override { return db_uuid; }
    
    

    ClickHouse 官网文档说:

    默认情况下,ClickHouse使用Atomic数据库引擎。

    源代码中说:

    
    /** Default engine of databases.
      * It stores tables list in filesystem using list of .sql files,
      *  that contain declaration of table represented by SQL ATTACH TABLE query.
      */
    class DatabaseOrdinary : public DatabaseOnDisk
    {
    public:
        DatabaseOrdinary(const String & name_, const String & metadata_path_, ContextPtr context);
        DatabaseOrdinary(
            const String & name_, const String & metadata_path_, const String & data_path_,
            const String & logger, ContextPtr context_);
    
        String getEngineName() const override { return "Ordinary"; }
    

    Answer

    Atomic Database Engine

    In version 20.5 ClickHouse first introduced database engine=Atomic.

    Since version 20.10 it is a default database engine (before engine=Ordinary was used).

    Those 2 database engine differs in a way how they store data on a filesystem, and engine Atomic allows to resolve some of the issues existed in engine=Ordinary.

    engine=Atomic supports

    non-blocking drop table / rename table
    tables delete (&detach) async (wait for selects finish but invisible for new selects)
    atomic drop table (all files / folders removed)
    atomic table swap (table swap by “EXCHANGE TABLES t1 AND t2;”)
    rename dictionary / rename database
    unique automatic UUID paths in FS and ZK for Replicated

    https://kb.altinity.com/engines/altinity-kb-atomic-database-engine/

    相关文章

      网友评论

          本文标题:What's the difference between At

          本文链接:https://www.haomeiwen.com/subject/kadzdrtx.html