Skip to content

Commit

Permalink
pg_stats.sql: reduce gauges/counters indices
Browse files Browse the repository at this point in the history
  • Loading branch information
astro committed Feb 1, 2015
1 parent a6c51c0 commit 22f7069
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions pg_stats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ CREATE TABLE gauges (
"info_hash" BYTEA,
"value" BIGINT DEFAULT 1
);
CREATE INDEX gauges_kind_info_hash_time ON gauges ("kind","info_hash","time");
CREATE INDEX gauges_kind_info_hash_time3600 ON gauges ("kind","info_hash",align_timestamp("time", 3600));
CREATE INDEX gauges_kind_info_hash_time21600 ON gauges ("kind","info_hash",align_timestamp("time", 21600));
CREATE INDEX gauges_kind_info_hash_time86400 ON gauges ("kind","info_hash",align_timestamp("time", 86400));
CREATE INDEX gauges_kind_info_hash_time604800 ON gauges ("kind","info_hash",align_timestamp("time", 604800));
CREATE INDEX gauges_kind_info_hash_time_value ON gauges ("kind","info_hash","time","value");

CREATE OR REPLACE FUNCTION set_gauge(
"e_kind" TEXT,
Expand Down Expand Up @@ -76,11 +72,7 @@ CREATE TABLE counters (
"value" BIGINT NOT NULL
);

CREATE INDEX counters_kind_info_hash_time ON counters ("kind","info_hash","time");
CREATE INDEX counters_kind_info_hash_time3600 ON counters ("kind","info_hash",align_timestamp("time", 3600));
CREATE INDEX counters_kind_info_hash_time21600 ON counters ("kind","info_hash",align_timestamp("time", 21600));
CREATE INDEX counters_kind_info_hash_time86400 ON counters ("kind","info_hash",align_timestamp("time", 86400));
CREATE INDEX counters_kind_info_hash_time604800 ON counters ("kind","info_hash",align_timestamp("time", 604800));
CREATE INDEX counters_kind_info_hash_time_value ON counters ("kind","info_hash","time","value");

CREATE INDEX counters_get
ON counters ("info_hash", "time")
Expand All @@ -94,6 +86,7 @@ CREATE OR REPLACE FUNCTION add_counter(
) RETURNS void AS $$
DECLARE
period_length BIGINT := 600;
-- TODO: reuse align_timestamp()
period TIMESTAMP := TO_TIMESTAMP(
FLOOR(
EXTRACT(EPOCH FROM NOW())
Expand Down

0 comments on commit 22f7069

Please sign in to comment.