From 75b2612aeec995ecfafe2db7e4c23c4365b91d74 Mon Sep 17 00:00:00 2001 From: bjrambo Date: Tue, 26 Jul 2016 23:31:39 +0900 Subject: [PATCH] Add composite index to speed up getNotifyList query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 모듈내의 인덱스랑 스키마에 적용된 각종 오타 수정완료 By @kijin --- ncenterlite.class.php | 26 ++++++++++++++++++++------ schemas/ncenterlite_notify.xml | 32 ++++++++++++++++---------------- schemas/ncenterlite_user_set.xml | 2 +- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/ncenterlite.class.php b/ncenterlite.class.php index 0a42f5b..8d1e317 100644 --- a/ncenterlite.class.php +++ b/ncenterlite.class.php @@ -124,12 +124,19 @@ function checkUpdate() return true; } - if(!$oDB->isIndexExists('ncenterlite_notify', 'idx_notify')) + if(!$oDB->isIndexExists('ncenterlite_notify', 'idx_target_member_srl')) { return true; } - if(!$oDB->isIndexExists('ncenterlite_notify', 'idx_target_member_srl')) + // Composite index to speed up getNotifyList + if(!$oDB->isIndexExists('ncenterlite_notify', 'idx_member_srl_and_readed')) + { + return true; + } + + // PK duplicate + if($oDB->isIndexExists('ncenterlite_notify', 'idx_notify')) { return true; } @@ -202,14 +209,21 @@ function moduleUpdate() $oDB->addIndex('ncenterlite_notify', 'idx_target_p_srl', array('target_p_srl')); } - if(!$oDB->isIndexExists('ncenterlite_notify', 'idx_notify')) + if(!$oDB->isIndexExists('ncenterlite_notify', 'idx_target_member_srl')) { - $oDB->addIndex('ncenterlite_notify', 'idx_notify', array('notify')); + $oDB->addIndex('ncenterlite_notify', 'idx_target_member_srl', array('target_member_srl')); } - if(!$oDB->isIndexExists('ncenterlite_notify', 'idx_target_member_srl')) + // Composite index to speed up getNotifyList + if(!$oDB->isIndexExists('ncenterlite_notify', 'idx_member_srl_and_readed')) { - $oDB->addIndex('ncenterlite_notify', 'idx_target_member_srl', array('target_member_srl')); + $oDB->addIndex('ncenterlite_notify', 'idx_member_srl_and_readed', array('member_srl', 'readed')); + } + + // PK duplicate + if($oDB->isIndexExists('ncenterlite_notify', 'idx_notify')) + { + $oDB->dropIndex('ncenterlite_notify', 'idx_notify'); } return new Object(0, 'success_updated'); diff --git a/schemas/ncenterlite_notify.xml b/schemas/ncenterlite_notify.xml index b779822..6a0d9ef 100644 --- a/schemas/ncenterlite_notify.xml +++ b/schemas/ncenterlite_notify.xml @@ -1,24 +1,24 @@ - + - - - - - - + + + + + + - + - - - - + + + + - - - - + + + +
diff --git a/schemas/ncenterlite_user_set.xml b/schemas/ncenterlite_user_set.xml index 0562ed1..6143f16 100644 --- a/schemas/ncenterlite_user_set.xml +++ b/schemas/ncenterlite_user_set.xml @@ -1,5 +1,5 @@ - +