From 25f33cb5fc58b175aba6c4e07035025ac277c24b Mon Sep 17 00:00:00 2001 From: ssube Date: Fri, 29 Nov 2019 00:20:33 -0600 Subject: [PATCH] feat(schema): drop name column and eliminate extended storage from samples table (#15) --- postgres/client.go | 4 ++-- schema/tables.sql | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/postgres/client.go b/postgres/client.go index 0cfce2d..a18d1fd 100644 --- a/postgres/client.go +++ b/postgres/client.go @@ -305,7 +305,7 @@ func (c *Client) WriteLabel(m *model.Metric, stmt *sql.Stmt, t time.Time) (writt } func (c *Client) WriteSamples(samples model.Samples) error { - txn, stmt, err := c.PrepareStmt(pq.CopyIn("metric_samples", "time", "name", "value", "lid")) + txn, stmt, err := c.PrepareStmt(pq.CopyIn("metric_samples", "time", "lid", "value")) if err != nil { level.Error(c.logger).Log("msg", "error preparing sample statement", "err", err) return err @@ -373,7 +373,7 @@ func (c *Client) WriteSample(s *model.Sample, txn *sql.Tx, stmt *sql.Stmt) (writ } level.Debug(c.logger).Log("name", name, "time", t, "value", v, "labels", lid) - _, err = stmt.Exec(t, name, v, lid) + _, err = stmt.Exec(t, lid, v) if err != nil { level.Error(c.logger).Log("msg", "error in single sample execution", "err", err) // this is the only error case that is actually fatal for the transaction and must return err diff --git a/schema/tables.sql b/schema/tables.sql index 554874e..25e3ea1 100644 --- a/schema/tables.sql +++ b/schema/tables.sql @@ -43,7 +43,6 @@ WHERE -- samples CREATE TABLE IF NOT EXISTS metric_samples ( "time" TIMESTAMP NOT NULL, -- sample time - "name" TEXT NOT NULL, -- metric name "lid" uuid NOT NULL, -- metric lid "value" double precision NOT NULL -- value );