From: Sebastian Harl Date: Thu, 25 Oct 2012 10:37:02 +0000 (+0200) Subject: collectd_insert.sql: Added view 'collectd'. X-Git-Tag: collectd-5.2.0~13^2~13 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ad0244784f7a9bb3a4ebbb992401a16b0c75a1b6;p=collectd.git collectd_insert.sql: Added view 'collectd'. This view provides a join of the 'identifiers' and 'values' tables plus an additional column with the serialized collectd identifier. --- diff --git a/contrib/postgresql/collectd_insert.sql b/contrib/postgresql/collectd_insert.sql index e20b0bf1..7ccd909a 100644 --- a/contrib/postgresql/collectd_insert.sql +++ b/contrib/postgresql/collectd_insert.sql @@ -90,6 +90,26 @@ CREATE TABLE "values" ( value double precision NOT NULL ); +CREATE OR REPLACE VIEW collectd + AS SELECT host, plugin, plugin_inst, type, type_inst, + host + || '/' || plugin + || CASE + WHEN plugin_inst IS NOT NULL THEN '-' + ELSE '' + END + || coalesce(plugin_inst, '') + || '/' || type + || CASE + WHEN type_inst IS NOT NULL THEN '-' + ELSE '' + END + || coalesce(plugin_inst, '') AS identifier, + tstamp, name, value + FROM identifiers + JOIN values + ON values.id = identifiers.id; + -- partition "values" by day (or week, month, ...) -- create the child tables for today and the next 'days' days: