From bb274508d67863d06933bb1bb1631e0fad2a9a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rge=20N=C3=A6ss?= Date: Thu, 19 Sep 2013 11:26:41 +0200 Subject: [PATCH] Index fingerprints on identities --- db/development_structure.sql | 25 ++++++++++++------- .../20130919084945_add_fingerprints_index.rb | 9 +++++++ 2 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20130919084945_add_fingerprints_index.rb diff --git a/db/development_structure.sql b/db/development_structure.sql index 77fb4a9..8ecc662 100644 --- a/db/development_structure.sql +++ b/db/development_structure.sql @@ -3,7 +3,7 @@ -- SET statement_timeout = 0; -SET client_encoding = 'SQL_ASCII'; +SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; @@ -87,8 +87,8 @@ CREATE TABLE accounts ( image_url text, email text, synced_at timestamp without time zone, - created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + created_at timestamp without time zone, + updated_at timestamp without time zone ); @@ -277,8 +277,8 @@ CREATE TABLE identities ( realm_id integer NOT NULL, primary_account_id integer, god boolean DEFAULT false, - created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL, + created_at timestamp without time zone, + updated_at timestamp without time zone, last_seen_on date, fingerprints tsvector, tags tsvector @@ -385,8 +385,8 @@ CREATE TABLE realms ( title text, label text NOT NULL, service_keys text, - created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL, + created_at timestamp without time zone, + updated_at timestamp without time zone, primary_domain_id integer ); @@ -427,8 +427,8 @@ CREATE TABLE sessions ( id integer NOT NULL, identity_id integer, key text, - created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + created_at timestamp without time zone, + updated_at timestamp without time zone ); @@ -701,6 +701,13 @@ CREATE UNIQUE INDEX index_domains_on_name ON domains USING btree (name); CREATE INDEX index_domains_on_realm_id ON domains USING btree (realm_id); +-- +-- Name: index_fingerprints_on_identities; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_fingerprints_on_identities ON identities USING gist (fingerprints); + + -- -- Name: index_group_subtrees_on_group_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- diff --git a/db/migrate/20130919084945_add_fingerprints_index.rb b/db/migrate/20130919084945_add_fingerprints_index.rb new file mode 100644 index 0000000..13d0cd3 --- /dev/null +++ b/db/migrate/20130919084945_add_fingerprints_index.rb @@ -0,0 +1,9 @@ +class AddFingerprintsIndex < ActiveRecord::Migration + def self.up + execute "create index index_fingerprints_on_identities on identities using gist(fingerprints)" + end + + def self.down + execute "drop index index_fingerprints_on_identities" + end +end