mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
Use simple query without JOIN in admin comment list, to improve query speed with millions of comments
This commit is contained in:
parent
584b370769
commit
d14e2dd3fd
2 changed files with 71 additions and 1 deletions
|
|
@ -960,6 +960,15 @@ class CommentModel extends Comment
|
|||
return $output;
|
||||
}
|
||||
|
||||
// Use simple query without JOIN if there are no document-related conditions.
|
||||
if ($query_id === 'comment.getTotalCommentList')
|
||||
{
|
||||
if (!$args->s_module_srl && !$args->exclude_module_srl && !$args->document_statusList)
|
||||
{
|
||||
$query_id = 'comment.getTotalCommentListWithoutJoin';
|
||||
}
|
||||
}
|
||||
|
||||
// If an alternate output is set, use it instead of running the default queries
|
||||
if (isset($args->use_alternate_output) && $args->use_alternate_output instanceof BaseObject)
|
||||
{
|
||||
|
|
@ -977,9 +986,40 @@ class CommentModel extends Comment
|
|||
return $output;
|
||||
}
|
||||
|
||||
// Fill in document-related fields if a simple query was used.
|
||||
if ($query_id === 'comment.getTotalCommentListWithoutJoin')
|
||||
{
|
||||
$document_srl_list = [];
|
||||
foreach ($output->data as $val)
|
||||
{
|
||||
$document_srl_list[$val->document_srl] = true;
|
||||
}
|
||||
if (count($document_srl_list))
|
||||
{
|
||||
$document_list = DocumentModel::getDocuments(array_keys($document_srl_list), false, false, [
|
||||
'document_srl', 'module_srl', 'member_srl', 'user_id', 'user_name', 'nick_name', 'title',
|
||||
]);
|
||||
foreach ($document_list as $val)
|
||||
{
|
||||
$document_srl_list[$val->document_srl] = $val;
|
||||
}
|
||||
foreach ($output->data as $val)
|
||||
{
|
||||
if (isset($document_srl_list[$val->document_srl]))
|
||||
{
|
||||
$val->module_srl = $document_srl_list[$val->document_srl]->get('module_srl');
|
||||
$val->document_member_srl = $document_srl_list[$val->document_srl]->get('member_srl');
|
||||
$val->document_user_id = $document_srl_list[$val->document_srl]->get('user_id');
|
||||
$val->document_user_name = $document_srl_list[$val->document_srl]->get('user_name');
|
||||
$val->document_nick_name = $document_srl_list[$val->document_srl]->get('nick_name');
|
||||
$val->document_title = $document_srl_list[$val->document_srl]->get('title');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($output->data as $key => $val)
|
||||
{
|
||||
unset($_oComment);
|
||||
$_oComment = new CommentItem(0);
|
||||
$_oComment->setAttribute($val);
|
||||
$output->data[$key] = $_oComment;
|
||||
|
|
|
|||
30
modules/comment/queries/getTotalCommentListWithoutJoin.xml
Normal file
30
modules/comment/queries/getTotalCommentListWithoutJoin.xml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<query id="getTotalCommentListWithoutJoin" action="select">
|
||||
<tables>
|
||||
<table name="comments" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="is_secret" var="s_is_secret" pipe="and" />
|
||||
<condition operation="equal" column="status" var="s_is_published" pipe="and" />
|
||||
<condition operation="in" column="status" var="statusList" pipe="and" />
|
||||
<condition operation="in" column="member_srl" var="s_member_srl" pipe="and" />
|
||||
<group pipe="and">
|
||||
<condition operation="search" column="content" var="s_content" pipe="or" />
|
||||
<condition operation="like_prefix" column="user_name" var="s_user_name" pipe="or" />
|
||||
<condition operation="like_prefix" column="nick_name" var="s_nick_name" pipe="or" />
|
||||
<condition operation="like" column="email_address" var="s_email_address" pipe="or" />
|
||||
<condition operation="like" column="homepage" var="s_homepage" pipe="or" />
|
||||
<condition operation="like_prefix" column="regdate" var="s_regdate" pipe="or" />
|
||||
<condition operation="like_prefix" column="last_update" var="s_last_upate" pipe="or" />
|
||||
<condition operation="like_prefix" column="ipaddress" var="s_ipaddress" pipe="or" />
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="sort_index" default="list_order" order="asc" />
|
||||
<list_count var="list_count" default="20" />
|
||||
<page_count var="page_count" default="10" />
|
||||
<page var="page" default="1" />
|
||||
</navigation>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue