Browse Source

lib/srdb1/schema: Updated indices for presence tables based on results of latest performance testing

- By Hugh Waite @ Crocodile RCS Ltd and Peter Dunkley @ Crocodile RCS Ltd
Peter Dunkley 13 years ago
parent
commit
2b62b73f8d

+ 4 - 1
lib/srdb1/schema/pr_active_watchers.xml

@@ -216,18 +216,21 @@
     <index>
         <name>active_watchers_pres</name>
         <colref linkend="presentity_uri"/>
+        <colref linkend="event"/>
         <description>This index is needed only if you use DB_ONLY mode.</description>
     </index>
 
     <index>
         <name>updated_idx</name>
         <colref linkend="updated"/>
+        <description>This index is needed only if you use DB_ONLY mode. If possible use a partial index WHERE (updated &lt;&gt;(-1))</description>
     </index>
 
     <index>
         <name>updated_winfo_idx</name>
         <colref linkend="updated_winfo"/>
-	<colref linkend="presentity_uri"/>
+        <colref linkend="presentity_uri"/>
+        <description>This index is needed only if you use DB_ONLY mode. If possible use a partial index WHERE (updated_winfo &lt;&gt;(-1))</description>
     </index>
 
 </table>

+ 3 - 24
lib/srdb1/schema/pr_pua.xml

@@ -167,39 +167,18 @@
 
     <index>
         <name>dialog1_idx</name>
-        <colref linkend="call_id"/>
-        <colref linkend="from_tag"/>
-        <colref linkend="to_tag"/>
-    </index>
-
-    <index>
-        <name>dialog2_idx</name>
         <colref linkend="pres_id"/>
         <colref linkend="pres_uri"/>
     </index>
 
-    <index>
-        <name>tmp_dlg1_idx</name>
-        <colref linkend="call_id"/>
-        <colref linkend="from_tag"/>
-    </index>
-
-    <index>
-        <name>tmp_dlg2_idx</name>
-        <colref linkend="pres_id"/>
-        <colref linkend="pres_uri"/>
+   <index>
+        <name>dialog2_idx</name>
         <colref linkend="call_id"/>
         <colref linkend="from_tag"/>
     </index>
 
     <index>
-        <name>tmp_record1_idx</name>
+        <name>record_idx</name>
         <colref linkend="pres_id"/>
     </index>
-
-    <index>
-        <name>tmp_record2_idx</name>
-        <colref linkend="pres_id"/>
-        <colref linkend="etag"/>
-    </index>
 </table>

+ 1 - 0
lib/srdb1/schema/rls_presentity.xml

@@ -96,6 +96,7 @@
     <index>
         <name>updated_idx</name>
         <colref linkend="updated"/>
+        <description>If possible use a partial index WHERE (updated &lt;&gt;(-1))</description>
     </index>
 
     <index>

+ 1 - 6
lib/srdb1/schema/rls_watchers.xml

@@ -202,12 +202,6 @@
         <unique/>
     </index>
 
-    <index>
-        <name>rls_watchers_delete</name>
-        <colref linkend="callid"/>
-        <colref linkend="to_tag"/>
-    </index>
-
     <index>
         <name>rls_watchers_update</name>
         <colref linkend="watcher_username"/>
@@ -223,5 +217,6 @@
     <index>
         <name>updated_idx</name>
         <colref linkend="updated"/>
+        <description>This index is needed only if you use DB_ONLY mode. If possible use a partial index WHERE (updated &lt;&gt;(-1))</description>
     </index>
 </table>

+ 4 - 7
utils/kamctl/db_sqlite/presence-create.sql

@@ -46,7 +46,7 @@ CREATE TABLE active_watchers (
 );
 
 CREATE INDEX active_watchers_active_watchers_expires ON active_watchers (expires);
-CREATE INDEX active_watchers_active_watchers_pres ON active_watchers (presentity_uri);
+CREATE INDEX active_watchers_active_watchers_pres ON active_watchers (presentity_uri, event);
 CREATE INDEX active_watchers_updated_idx ON active_watchers (updated);
 CREATE INDEX active_watchers_updated_winfo_idx ON active_watchers (updated_winfo, presentity_uri);
 
@@ -106,10 +106,7 @@ CREATE TABLE pua (
 );
 
 CREATE INDEX pua_expires_idx ON pua (expires);
-CREATE INDEX pua_dialog1_idx ON pua (call_id, from_tag, to_tag);
-CREATE INDEX pua_dialog2_idx ON pua (pres_id, pres_uri);
-CREATE INDEX pua_tmp_dlg1_idx ON pua (call_id, from_tag);
-CREATE INDEX pua_tmp_dlg2_idx ON pua (pres_id, pres_uri, call_id, from_tag);
-CREATE INDEX pua_tmp_record1_idx ON pua (pres_id);
-CREATE INDEX pua_tmp_record2_idx ON pua (pres_id, etag);
+CREATE INDEX pua_dialog1_idx ON pua (pres_id, pres_uri);
+CREATE INDEX pua_dialog2_idx ON pua (call_id, from_tag);
+CREATE INDEX pua_record_idx ON pua (pres_id);
 

+ 0 - 1
utils/kamctl/db_sqlite/rls-create.sql

@@ -45,7 +45,6 @@ CREATE TABLE rls_watchers (
     CONSTRAINT rls_watchers_rls_watcher_idx UNIQUE (callid, to_tag, from_tag)
 );
 
-CREATE INDEX rls_watchers_rls_watchers_delete ON rls_watchers (callid, to_tag);
 CREATE INDEX rls_watchers_rls_watchers_update ON rls_watchers (watcher_username, watcher_domain, event);
 CREATE INDEX rls_watchers_rls_watchers_expires ON rls_watchers (expires);
 CREATE INDEX rls_watchers_updated_idx ON rls_watchers (updated);

+ 4 - 7
utils/kamctl/mysql/presence-create.sql

@@ -46,7 +46,7 @@ CREATE TABLE active_watchers (
 ) ENGINE=MyISAM;
 
 CREATE INDEX active_watchers_expires ON active_watchers (expires);
-CREATE INDEX active_watchers_pres ON active_watchers (presentity_uri);
+CREATE INDEX active_watchers_pres ON active_watchers (presentity_uri, event);
 CREATE INDEX updated_idx ON active_watchers (updated);
 CREATE INDEX updated_winfo_idx ON active_watchers (updated_winfo, presentity_uri);
 
@@ -106,10 +106,7 @@ CREATE TABLE pua (
 ) ENGINE=MyISAM;
 
 CREATE INDEX expires_idx ON pua (expires);
-CREATE INDEX dialog1_idx ON pua (call_id, from_tag, to_tag);
-CREATE INDEX dialog2_idx ON pua (pres_id, pres_uri);
-CREATE INDEX tmp_dlg1_idx ON pua (call_id, from_tag);
-CREATE INDEX tmp_dlg2_idx ON pua (pres_id, pres_uri, call_id, from_tag);
-CREATE INDEX tmp_record1_idx ON pua (pres_id);
-CREATE INDEX tmp_record2_idx ON pua (pres_id, etag);
+CREATE INDEX dialog1_idx ON pua (pres_id, pres_uri);
+CREATE INDEX dialog2_idx ON pua (call_id, from_tag);
+CREATE INDEX record_idx ON pua (pres_id);
 

+ 0 - 1
utils/kamctl/mysql/rls-create.sql

@@ -45,7 +45,6 @@ CREATE TABLE rls_watchers (
     CONSTRAINT rls_watcher_idx UNIQUE (callid, to_tag, from_tag)
 ) ENGINE=MyISAM;
 
-CREATE INDEX rls_watchers_delete ON rls_watchers (callid, to_tag);
 CREATE INDEX rls_watchers_update ON rls_watchers (watcher_username, watcher_domain, event);
 CREATE INDEX rls_watchers_expires ON rls_watchers (expires);
 CREATE INDEX updated_idx ON rls_watchers (updated);

+ 4 - 7
utils/kamctl/oracle/presence-create.sql

@@ -62,7 +62,7 @@ END active_watchers_tr;
 BEGIN map2users('active_watchers'); END;
 /
 CREATE INDEX ORA_active_watchers_expires  ON active_watchers (expires);
-CREATE INDEX ORA_active_watchers_pres  ON active_watchers (presentity_uri);
+CREATE INDEX ORA_active_watchers_pres  ON active_watchers (presentity_uri, event);
 CREATE INDEX active_watchers_updated_idx  ON active_watchers (updated);
 CREATE INDEX ORA_updated_winfo_idx  ON active_watchers (updated_winfo, presentity_uri);
 
@@ -146,10 +146,7 @@ END pua_tr;
 BEGIN map2users('pua'); END;
 /
 CREATE INDEX pua_expires_idx  ON pua (expires);
-CREATE INDEX pua_dialog1_idx  ON pua (call_id, from_tag, to_tag);
-CREATE INDEX pua_dialog2_idx  ON pua (pres_id, pres_uri);
-CREATE INDEX pua_tmp_dlg1_idx  ON pua (call_id, from_tag);
-CREATE INDEX pua_tmp_dlg2_idx  ON pua (pres_id, pres_uri, call_id, from_tag);
-CREATE INDEX pua_tmp_record1_idx  ON pua (pres_id);
-CREATE INDEX pua_tmp_record2_idx  ON pua (pres_id, etag);
+CREATE INDEX pua_dialog1_idx  ON pua (pres_id, pres_uri);
+CREATE INDEX pua_dialog2_idx  ON pua (call_id, from_tag);
+CREATE INDEX pua_record_idx  ON pua (pres_id);
 

+ 0 - 1
utils/kamctl/oracle/rls-create.sql

@@ -61,7 +61,6 @@ END rls_watchers_tr;
 /
 BEGIN map2users('rls_watchers'); END;
 /
-CREATE INDEX ORA_rls_watchers_delete  ON rls_watchers (callid, to_tag);
 CREATE INDEX ORA_rls_watchers_update  ON rls_watchers (watcher_username, watcher_domain, event);
 CREATE INDEX ORA_rls_watchers_expires  ON rls_watchers (expires);
 CREATE INDEX rls_watchers_updated_idx  ON rls_watchers (updated);

+ 4 - 7
utils/kamctl/postgres/presence-create.sql

@@ -46,7 +46,7 @@ CREATE TABLE active_watchers (
 );
 
 CREATE INDEX active_watchers_active_watchers_expires ON active_watchers (expires);
-CREATE INDEX active_watchers_active_watchers_pres ON active_watchers (presentity_uri);
+CREATE INDEX active_watchers_active_watchers_pres ON active_watchers (presentity_uri, event);
 CREATE INDEX active_watchers_updated_idx ON active_watchers (updated);
 CREATE INDEX active_watchers_updated_winfo_idx ON active_watchers (updated_winfo, presentity_uri);
 
@@ -106,10 +106,7 @@ CREATE TABLE pua (
 );
 
 CREATE INDEX pua_expires_idx ON pua (expires);
-CREATE INDEX pua_dialog1_idx ON pua (call_id, from_tag, to_tag);
-CREATE INDEX pua_dialog2_idx ON pua (pres_id, pres_uri);
-CREATE INDEX pua_tmp_dlg1_idx ON pua (call_id, from_tag);
-CREATE INDEX pua_tmp_dlg2_idx ON pua (pres_id, pres_uri, call_id, from_tag);
-CREATE INDEX pua_tmp_record1_idx ON pua (pres_id);
-CREATE INDEX pua_tmp_record2_idx ON pua (pres_id, etag);
+CREATE INDEX pua_dialog1_idx ON pua (pres_id, pres_uri);
+CREATE INDEX pua_dialog2_idx ON pua (call_id, from_tag);
+CREATE INDEX pua_record_idx ON pua (pres_id);
 

+ 0 - 1
utils/kamctl/postgres/rls-create.sql

@@ -45,7 +45,6 @@ CREATE TABLE rls_watchers (
     CONSTRAINT rls_watchers_rls_watcher_idx UNIQUE (callid, to_tag, from_tag)
 );
 
-CREATE INDEX rls_watchers_rls_watchers_delete ON rls_watchers (callid, to_tag);
 CREATE INDEX rls_watchers_rls_watchers_update ON rls_watchers (watcher_username, watcher_domain, event);
 CREATE INDEX rls_watchers_rls_watchers_expires ON rls_watchers (expires);
 CREATE INDEX rls_watchers_updated_idx ON rls_watchers (updated);