Skip to content

collectd: Improve database schema #333

@amotl

Description

@amotl

Pitch

@coderabbitai's review at #330 (review) yielded this recommendation.

63-76: Align table types with arrays and avoid TIMESTAMPTZ ambiguity.

CrateDB handles TIMESTAMP in UTC; storing arrays as arrays eases querying (unnest/ANY). Also keep the generated monthly partition.

 CREATE TABLE doc.collectd_data (
-   p_time timestamp with time zone,
-   p_host TEXT,
-   p_plugin TEXT,
-   p_plugin_instance TEXT,
-   p_type TEXT,
-   p_type_instance TEXT,
-   p_value_names TEXT,
-   p_type_names TEXT,
-   p_values TEXT,
-   month GENERATED ALWAYS AS date_trunc('month',p_time)
+   p_time TIMESTAMP,
+   p_host TEXT,
+   p_plugin TEXT,
+   p_plugin_instance TEXT,
+   p_type TEXT,
+   p_type_instance TEXT,
+   p_value_names ARRAY(TEXT),
+   p_type_names ARRAY(TEXT),
+   p_values ARRAY(DOUBLE PRECISION),
+   month GENERATED ALWAYS AS date_trunc('month', p_time)
 ) PARTITIONED BY (month);

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions