Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClickHouse Database Schema #1

Open
includenull opened this issue Nov 21, 2024 · 0 comments
Open

ClickHouse Database Schema #1

includenull opened this issue Nov 21, 2024 · 0 comments
Assignees
Labels

Comments

@includenull
Copy link
Member

Proposed schema for ClickHouse database

Tables

blocks

CREATE TABLE IF NOT EXISTS blocks (
    id UInt32,
    block_hash String,
    parent_hash String,
    block_timestamp DateTime,
    producer String,
    tx_count UInt32,
    ax_count UInt32
) ENGINE = MergeTree()
ORDER BY id;

transactions

CREATE TABLE IF NOT EXISTS transactions (
    tx_id String,
    block_num UInt32,
    block_timestamp DateTime,
    sequence UInt64,
    block_position UInt32,
    ax_count UInt64,
    cpu_usage_us UInt32,
    net_usage UInt64,
) ENGINE = MergeTree()
ORDER BY sequence;

actions

CREATE TABLE IF NOT EXISTS actions (
    id UInt64,
    block_num UInt32,
    block_timestamp DateTime,
    tx_id String,
    action_ordinal UInt8,
    creator_action_ordinal UInt8,
    receipt_receiver String,
    receipt_act_digest String,
    receipt_global_sequence UInt64,
    receipt_recv_sequence UInt64,
    receipt_auth_sequence Array(Tuple(String, UInt64)),
    receipt_code_sequence UInt32,
    receipt_abi_sequence UInt32,
    account String,
    name String,
    receiver String,
    first_receiver UInt8,
    data JSON,
    authorization Array(Tuple(String, String)),
    console Nullable(String),
    except Nullable(String),
    error Nullable(UInt64),
    return Nullable(String)
) ENGINE = MergeTree()
ORDER BY id;

Considerations

  • Is there a better way to store the data for an action? Currently using JSON but would like to explore faster options.
  • Is there a better way to store the authorizations for an action? Currently using Array(Tuple(String, String)).
@includenull includenull self-assigned this Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant