mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-07 08:05:25 +02:00
Merge pull request #1766 from bantu/ticket/11621
[ticket/11621] Improve MySQL fulltext search indexes
This commit is contained in:
commit
1769135eaf
@ -24,6 +24,7 @@ class alpha1 extends \phpbb\db\migration\migration
|
||||
'\phpbb\db\migration\data\v310\config_db_text',
|
||||
'\phpbb\db\migration\data\v310\forgot_password',
|
||||
'\phpbb\db\migration\data\v310\mod_rewrite',
|
||||
'\phpbb\db\migration\data\v310\mysql_fulltext_drop',
|
||||
'\phpbb\db\migration\data\v310\namespaces',
|
||||
'\phpbb\db\migration\data\v310\notifications_cron',
|
||||
'\phpbb\db\migration\data\v310\notification_options_reconvert',
|
||||
|
47
phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php
Normal file
47
phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v310;
|
||||
|
||||
class mysql_fulltext_drop extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
// This migration is irrelevant for all non-MySQL DBMSes.
|
||||
return strpos($this->db->sql_layer, 'mysql') === false;
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v310\dev',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
/*
|
||||
* Drop FULLTEXT indexes related to MySQL fulltext search.
|
||||
* Doing so is equivalent to dropping the search index from the ACP.
|
||||
* Possibly time-consuming recreation of the search index (i.e.
|
||||
* FULLTEXT indexes) is left as a task to the admin to not
|
||||
* unnecessarily stall the upgrade process. The new search index will
|
||||
* then require about 40% less table space (also see PHPBB3-11621).
|
||||
*/
|
||||
return array(
|
||||
'drop_keys' => array(
|
||||
$this->table_prefix . 'posts' => array(
|
||||
'post_subject',
|
||||
'post_text',
|
||||
'post_content',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -781,7 +781,7 @@ class fulltext_mysql extends \phpbb\search\base
|
||||
$alter[] = 'ADD FULLTEXT (post_subject)';
|
||||
}
|
||||
|
||||
if (!isset($this->stats['post_text']))
|
||||
if (!isset($this->stats['post_content']))
|
||||
{
|
||||
if ($this->db->sql_layer == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
|
||||
{
|
||||
@ -791,12 +791,8 @@ class fulltext_mysql extends \phpbb\search\base
|
||||
{
|
||||
$alter[] = 'MODIFY post_text mediumtext NOT NULL';
|
||||
}
|
||||
$alter[] = 'ADD FULLTEXT (post_text)';
|
||||
}
|
||||
|
||||
if (!isset($this->stats['post_content']))
|
||||
{
|
||||
$alter[] = 'ADD FULLTEXT post_content (post_subject, post_text)';
|
||||
$alter[] = 'ADD FULLTEXT post_content (post_text, post_subject)';
|
||||
}
|
||||
|
||||
if (sizeof($alter))
|
||||
@ -834,11 +830,6 @@ class fulltext_mysql extends \phpbb\search\base
|
||||
$alter[] = 'DROP INDEX post_subject';
|
||||
}
|
||||
|
||||
if (isset($this->stats['post_text']))
|
||||
{
|
||||
$alter[] = 'DROP INDEX post_text';
|
||||
}
|
||||
|
||||
if (isset($this->stats['post_content']))
|
||||
{
|
||||
$alter[] = 'DROP INDEX post_content';
|
||||
@ -864,7 +855,7 @@ class fulltext_mysql extends \phpbb\search\base
|
||||
$this->get_stats();
|
||||
}
|
||||
|
||||
return (isset($this->stats['post_text']) && isset($this->stats['post_subject']) && isset($this->stats['post_content'])) ? true : false;
|
||||
return isset($this->stats['post_subject']) && isset($this->stats['post_content']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -904,11 +895,7 @@ class fulltext_mysql extends \phpbb\search\base
|
||||
|
||||
if ($index_type == 'FULLTEXT')
|
||||
{
|
||||
if ($row['Key_name'] == 'post_text')
|
||||
{
|
||||
$this->stats['post_text'] = $row;
|
||||
}
|
||||
else if ($row['Key_name'] == 'post_subject')
|
||||
if ($row['Key_name'] == 'post_subject')
|
||||
{
|
||||
$this->stats['post_subject'] = $row;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user