Skip to content

Commit

Permalink
Add composite index to speed up getNotifyList query
Browse files Browse the repository at this point in the history
모듈내의 인덱스랑 스키마에 적용된 각종 오타 수정완료 By @kijin
  • Loading branch information
bjrambo committed Jul 26, 2016
1 parent c2e8f29 commit 75b2612
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
26 changes: 20 additions & 6 deletions ncenterlite.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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');
Expand Down
32 changes: 16 additions & 16 deletions schemas/ncenterlite_notify.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<table name="ncenterlite_notify">
<column name="notify" type="char" size="32" notnull="notnull" primary_key="primary_key" breif="메시지 ID" />
<column name="notify" type="char" size="32" notnull="notnull" primary_key="primary_key" brief="메시지 ID" />

<column name="srl" type="number" size="11" notnull="notnull" index="idx_srl" breif="이벤트 대상의 상위 srl" />
<column name="target_srl" type="number" size="11" notnull="notnull" index="idx_target_srl" breif="이벤트 대상 srl(문서/댓글)" />
<column name="target_p_srl" type="number" size="11" notnull="notnull" index="idx_target_p_srl" breif="이벤트 대상 srl(문서/댓글) 대댓글의 경우 앞전 댓글" />
<column name="type" type="char" size="1" notnull="notnull" breif="이벤트 대상 타입" />
<column name="target_type" type="char" size="1" notnull="notnull" breif="이벤트 타입" />
<column name="notify_type" type="number" breif="이벤트 타입 SRL" />
<column name="srl" type="number" size="11" notnull="notnull" index="idx_srl" brief="이벤트 대상의 상위 srl" />
<column name="target_srl" type="number" size="11" notnull="notnull" index="idx_target_srl" brief="이벤트 대상 srl(문서/댓글)" />
<column name="target_p_srl" type="number" size="11" notnull="notnull" index="idx_target_p_srl" brief="이벤트 대상 srl(문서/댓글) 대댓글의 경우 앞전 댓글" />
<column name="type" type="char" size="1" notnull="notnull" brief="이벤트 대상 타입" />
<column name="target_type" type="char" size="1" notnull="notnull" brief="이벤트 타입" />
<column name="notify_type" type="number" brief="이벤트 타입 SRL" />

<column name="member_srl" type="number" size="11" notnull="notnull" index="idx_member_srl" breif="receiver" />
<column name="member_srl" type="number" size="11" notnull="notnull" index="idx_member_srl" brief="receiver" />

<column name="target_member_srl" type="number" size="11" notnull="notnull" index="idx_target_member_srl" breif="sender" />
<column name="target_nick_name" type="varchar" size="50" notnull="notnull" breif="sender" />
<column name="target_user_id" type="varchar" size="50" notnull="notnull" breif="sender" />
<column name="target_email_address" type="varchar" size="50" notnull="notnull" breif="sender" />
<column name="target_member_srl" type="number" size="11" notnull="notnull" index="idx_target_member_srl" brief="sender" />
<column name="target_nick_name" type="varchar" size="50" notnull="notnull" brief="sender" />
<column name="target_user_id" type="varchar" size="50" notnull="notnull" brief="sender" />
<column name="target_email_address" type="varchar" size="50" notnull="notnull" brief="sender" />

<column name="target_browser" type="varchar" size="50" breif="브라우저 제목" />
<column name="target_summary" type="varchar" size="50" breif="메시지 요약문" />
<column name="target_body" type="varchar" size="255" breif="커스텀 알림 제목" />
<column name="target_url" type="varchar" size="255" notnull="notnull" breif="링크 목적지 주소" />
<column name="target_browser" type="varchar" size="50" brief="브라우저 제목" />
<column name="target_summary" type="varchar" size="50" brief="메시지 요약문" />
<column name="target_body" type="varchar" size="255" brief="커스텀 알림 제목" />
<column name="target_url" type="varchar" size="255" notnull="notnull" brief="링크 목적지 주소" />
<column name="readed" type="char" size="1" default="N" notnull="notnull" index="idx_readed" />
<column name="regdate" type="date" index="idx_regdate" />
</table>
2 changes: 1 addition & 1 deletion schemas/ncenterlite_user_set.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<table name="ncenterlite_user_set">
<column name="member_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" breif="member_srl 고유맴버 번호" />
<column name="member_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" brief="member_srl 고유맴버 번호" />
<column name="comment_notify" type="char" size="1" notnull="notnull" />
<column name="mention_notify" type="char" size="1" notnull="notnull" />
<column name="message_notify" type="char" size="1" notnull="notnull" />
Expand Down

0 comments on commit 75b2612

Please sign in to comment.