summaryrefslogtreecommitdiff
path: root/SQL
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-02-23 08:13:02 +0000
committeralecpl <alec@alec.pl>2011-02-23 08:13:02 +0000
commit3a5476d150419b46847dd922935f368c969519c1 (patch)
tree145ed6817352cb843c1ea7467eed24e81091418f /SQL
parent5744bfa54de0baacbf788bc30aacce3cd1089b9c (diff)
- Add index on contactgroupmembers.contact_id column.
Improves performance and fixes problem with contactgroupmembers table creation on MySQL 4.x
Diffstat (limited to 'SQL')
-rw-r--r--SQL/mssql.initial.sql2
-rw-r--r--SQL/mssql.upgrade.sql2
-rw-r--r--SQL/mysql.initial.sql3
-rw-r--r--SQL/mysql.update.sql2
-rw-r--r--SQL/postgres.initial.sql2
-rw-r--r--SQL/postgres.update.sql3
-rw-r--r--SQL/sqlite.initial.sql2
-rw-r--r--SQL/sqlite.update.sql1
8 files changed, 14 insertions, 3 deletions
diff --git a/SQL/mssql.initial.sql b/SQL/mssql.initial.sql
index 4e31c07d0..4aa6fc9f7 100644
--- a/SQL/mssql.initial.sql
+++ b/SQL/mssql.initial.sql
@@ -195,6 +195,8 @@ ALTER TABLE [dbo].[contactgroupmembers] ADD
CONSTRAINT [DF_contactgroupmembers_created] DEFAULT (getdate()) FOR [created]
GO
+CREATE INDEX [IX_contactgroupmembers_contact_id] ON [dbo].[contactgroupmembers]([contact_id]) ON [PRIMARY]
+GO
ALTER TABLE [dbo].[identities] ADD
CONSTRAINT [DF_identities_user] DEFAULT ('0') FOR [user_id],
diff --git a/SQL/mssql.upgrade.sql b/SQL/mssql.upgrade.sql
index 3d067924c..8534afdd3 100644
--- a/SQL/mssql.upgrade.sql
+++ b/SQL/mssql.upgrade.sql
@@ -101,3 +101,5 @@ GO
ALTER TABLE [dbo].[contacts] ADD [words] [text] COLLATE Latin1_General_CI_AI NULL
GO
+CREATE INDEX [IX_contactgroupmembers_contact_id] ON [dbo].[contactgroupmembers]([contact_id]) ON [PRIMARY]
+GO
diff --git a/SQL/mysql.initial.sql b/SQL/mysql.initial.sql
index accf212d4..8e2e61c9e 100644
--- a/SQL/mysql.initial.sql
+++ b/SQL/mysql.initial.sql
@@ -117,7 +117,8 @@ CREATE TABLE `contactgroupmembers` (
CONSTRAINT `contactgroup_id_fk_contactgroups` FOREIGN KEY (`contactgroup_id`)
REFERENCES `contactgroups`(`contactgroup_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `contact_id_fk_contacts` FOREIGN KEY (`contact_id`)
- REFERENCES `contacts`(`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE
+ REFERENCES `contacts`(`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ INDEX `contactgroupmembers_contact_index` (`contact_id`)
) /*!40000 ENGINE=INNODB */;
diff --git a/SQL/mysql.update.sql b/SQL/mysql.update.sql
index f6c8d7869..d30f037c6 100644
--- a/SQL/mysql.update.sql
+++ b/SQL/mysql.update.sql
@@ -136,3 +136,5 @@ TRUNCATE TABLE `messages`;
-- Updates from version 0.5.*
ALTER TABLE `contacts` ADD `words` TEXT NULL AFTER `vcard`;
+ALTER TABLE `contactgroupmembers` ADD INDEX `contactgroupmembers_contact_index` (`contact_id`);
+ \ No newline at end of file
diff --git a/SQL/postgres.initial.sql b/SQL/postgres.initial.sql
index f52ebd572..b273bcb0b 100644
--- a/SQL/postgres.initial.sql
+++ b/SQL/postgres.initial.sql
@@ -157,6 +157,8 @@ CREATE TABLE contactgroupmembers (
PRIMARY KEY (contactgroup_id, contact_id)
);
+CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id);
+
--
-- Sequence "cache_ids"
-- Name: cache_ids; Type: SEQUENCE; Schema: public; Owner: postgres
diff --git a/SQL/postgres.update.sql b/SQL/postgres.update.sql
index 6c3838868..e3eb581f9 100644
--- a/SQL/postgres.update.sql
+++ b/SQL/postgres.update.sql
@@ -90,8 +90,7 @@ ALTER TABLE contacts ALTER email TYPE varchar(255);
TRUNCATE messages;
-
-- Updates from version 0.5.x
ALTER TABLE contacts ADD words TEXT NULL;
-
+CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id);
diff --git a/SQL/sqlite.initial.sql b/SQL/sqlite.initial.sql
index 3aacccb95..d2885e968 100644
--- a/SQL/sqlite.initial.sql
+++ b/SQL/sqlite.initial.sql
@@ -56,6 +56,8 @@ CREATE TABLE contactgroupmembers (
PRIMARY KEY (contactgroup_id, contact_id)
);
+CREATE INDEX ix_contactgroupmembers_contact_id ON contactgroupmembers (contact_id);
+
-- --------------------------------------------------------
diff --git a/SQL/sqlite.update.sql b/SQL/sqlite.update.sql
index 46373d8b0..7b5464c64 100644
--- a/SQL/sqlite.update.sql
+++ b/SQL/sqlite.update.sql
@@ -221,3 +221,4 @@ CREATE INDEX ix_contacts_user_id ON contacts(user_id, email);
DROP TABLE contacts_tmp;
DELETE FROM messages;
+CREATE INDEX ix_contactgroupmembers_contact_id ON contactgroupmembers (contact_id);