Kaynağa Gözat

added indexes on the virtual alias tables

When you're hosting a couple of hundred aliases, you will benefit.
It seems safer to create the index and deal with the slight overhead
for just a couple of records, as opposed to not having these
indexes and deal with serious performance issues if you have
lots of aliases on the machine.
Joost Baaij 11 yıl önce
ebeveyn
işleme
b5bf654181
1 değiştirilmiş dosya ile 6 ekleme ve 0 silme
  1. 6
    0
      roles/mailserver/templates/mailserver.sql.j2

+ 6
- 0
roles/mailserver/templates/mailserver.sql.j2 Dosyayı Görüntüle

@@ -10,6 +10,8 @@ CREATE TABLE IF NOT EXISTS `virtual_domains` (
10 10
 	PRIMARY KEY (`id`)
11 11
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
12 12
 
13
+CREATE UNIQUE INDEX name_idx ON virtual_domains (name);
14
+
13 15
 CREATE TABLE IF NOT EXISTS `virtual_users` (
14 16
 	`id` int(11) NOT NULL auto_increment,
15 17
 	`domain_id` int(11) NOT NULL,
@@ -20,6 +22,8 @@ CREATE TABLE IF NOT EXISTS `virtual_users` (
20 22
 	FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE
21 23
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
22 24
 
25
+CREATE UNIQUE INDEX email_idx ON virtual_users (email);
26
+
23 27
 CREATE TABLE IF NOT EXISTS `virtual_aliases` (
24 28
 	`id` int(11) NOT NULL auto_increment,
25 29
 	`domain_id` int(11) NOT NULL,
@@ -29,6 +33,8 @@ CREATE TABLE IF NOT EXISTS `virtual_aliases` (
29 33
 	FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE
30 34
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31 35
 
36
+CREATE INDEX source_idx ON virtual_aliases (source);
37
+
32 38
 {% for virtual_domain in mail_virtual_domains %}
33 39
 INSERT INTO {{ mail_mysql_database }}.`virtual_domains` (`id`, `name`)
34 40
         VALUES ('{{ virtual_domain.pk_id }}', '{{ virtual_domain.name }}');

Loading…
İptal
Kaydet