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

Create index on payload.service_md5 of measturements table #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class AddIndexToPayloadServiceMd5OnMeasurements < ActiveRecord::Migration[5.0]
def up
execute(<<-SQL.strip_heredoc)
CREATE INDEX measurements_payload_service_md5_index ON measurements USING BTREE ((payload->>'service_md5'))
SQL
end

def down
execute('DROP INDEX IF EXISTS measurements_payload_service_md5_index')
end
end
21 changes: 18 additions & 3 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- PostgreSQL database dump
--

-- Dumped from database version 9.6.1
-- Dumped by pg_dump version 9.6.1
-- Dumped from database version 9.6.5
-- Dumped by pg_dump version 9.6.5

SET statement_timeout = 0;
SET lock_timeout = 0;
Expand Down Expand Up @@ -232,6 +232,20 @@ ALTER TABLE ONLY schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);


--
-- Name: measurements_payload_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX measurements_payload_idx ON measurements USING gin (payload);


--
-- Name: measurements_payload_service_md5_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX measurements_payload_service_md5_index ON measurements USING btree (((payload ->> 'service_md5'::text)));


--
-- Name: measurements update_measurements_updated_at; Type: TRIGGER; Schema: public; Owner: -
--
Expand All @@ -257,6 +271,7 @@ INSERT INTO schema_migrations (version) VALUES
('20170210151154'),
('20170212033722'),
('20170314184402'),
('20170328122726');
('20170328122726'),
('20171015140634');