Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6018787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:19:31+00:00 2026-05-23T03:19:31+00:00

The following query takes 25 seconds with 2 table joins. The first posts table

  • 0

The following query takes 25 seconds with 2 table joins. The first posts table has 150,00 rows, topics table has 50,000 rows. Anyone know how I can speed this up.

SELECT SQL_NO_CACHE
  post_search.post_id,
  topic_search.topic_id,
  topic_search.topic_title,
  topic_search.topic_last_post_time,
  MATCH(post_search.post_text,topic_search.topic_title) AGAINST('search_terms' IN BOOLEAN MODE) AS score
FROM bb_posts_fulltext_search post_search
LEFT JOIN bb_topics_fulltext_search topic_search
  ON post_search.topic_id = topic_search.topic_id
WHERE MATCH(post_search.post_text,topic_search.topic_title) AGAINST('search_terms' IN BOOLEAN MODE)
GROUP BY topic_search.topic_id
ORDER BY score DESC
LIMIT 0,6

DESCRIBE

mysql> DESCRIBE bb_posts_fulltext_search;
+-----------+------------+------+-----+---------+-------+
| Field     | Type       | Null | Key | Default | Extra |
+-----------+------------+------+-----+---------+-------+
| post_id   | bigint(20) | NO   | PRI | NULL    |       |
| post_text | longtext   | YES  | MUL | NULL    |       |
| topic_id  | bigint(20) | YES  | MUL | NULL    |       |
+-----------+------------+------+-----+---------+-------+

DESCRIBE

mysql> DESCRIBE bb_topics_fulltext_search
    -> ;
+----------------------+--------------+------+-----+---------+-------+
| Field                | Type         | Null | Key | Default | Extra |
+----------------------+--------------+------+-----+---------+-------+
| topic_id             | int(11)      | NO   | PRI | NULL    |       |
| topic_title          | varchar(255) | YES  | MUL | NULL    |       |
| topic_posts          | bigint(20)   | YES  |     | NULL    |       |
| topic_poster_name    | varchar(40)  | YES  |     | NULL    |       |
| topic_last_post_id   | bigint(20)   | YES  |     | NULL    |       |
| forum_id             | int(11)      | YES  |     | NULL    |       |
| parent_group_id      | int(11)      | YES  |     | NULL    |       |
| child_group_id       | int(11)      | YES  |     | NULL    |       |
| topic_last_post_time | datetime     | YES  | MUL | NULL    |       |
+----------------------+--------------+------+-----+---------+-------+

EXPLAIN

+----+-------------+--------------+--------+---------------+---------+---------+----------------------------------+--------+---------------------------------+
| id | select_type | table        | type   | possible_keys | key     | key_len | ref                              | rows   | Extra                           |
+----+-------------+--------------+--------+---------------+---------+---------+----------------------------------+--------+---------------------------------+
|  1 | SIMPLE      | post_search  | ALL    | NULL          | NULL    | NULL    | NULL                             | 158972 | Using temporary; Using filesort |
|  1 | SIMPLE      | topic_search | eq_ref | PRIMARY       | PRIMARY | 4       | wordpress.post_search.topic_id   |      1 | Using where                     |
+----+-------------+--------------+--------+---------------+---------+---------+----------------------------------+--------+---------------------------------+

UPDATE: Indexes

+--------------------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table                    | Non_unique | Key_name  | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------------------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| bb_posts_fulltext_search |          0 | PRIMARY   |            1 | post_id     | A         |      158972 |     NULL | NULL   |      | BTREE      |         |               |
| bb_posts_fulltext_search |          1 | topic_id  |            1 | topic_id    | A         |       52990 |     NULL | NULL   | YES  | BTREE      |         |               |
| bb_posts_fulltext_search |          1 | post_text |            1 | post_text   | NULL      |           1 |     NULL | NULL   | YES  | FULLTEXT   |         |               |
+--------------------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

CREATE 1

DROP TABLE IF EXISTS `wordpress`.`bb_posts_fulltext_search`;
CREATE TABLE  `wordpress`.`bb_posts_fulltext_search` (
  `post_id` bigint(20) NOT NULL,
  `post_text` longtext,
  `topic_id` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`post_id`),
  KEY `topic_id` (`topic_id`),
  FULLTEXT KEY `post_text` (`post_text`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE 2

DROP TABLE IF EXISTS `wordpress`.`bb_topics_fulltext_search`;
CREATE TABLE  `wordpress`.`bb_topics_fulltext_search` (
  `topic_id` int(11) NOT NULL,
  `topic_title` varchar(255) DEFAULT NULL,
  `topic_posts` bigint(20) DEFAULT NULL,
  `topic_poster_name` varchar(40) DEFAULT NULL,
  `topic_last_post_id` bigint(20) DEFAULT NULL,
  `forum_id` int(11) DEFAULT NULL,
  `parent_group_id` int(11) DEFAULT NULL,
  `child_group_id` int(11) DEFAULT NULL,
  `topic_last_post_time` datetime DEFAULT NULL,
  PRIMARY KEY (`topic_id`),
  KEY `topic_last_post_time` (`topic_last_post_time`),
  FULLTEXT KEY `topic_title` (`topic_title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

SOLUTION:
http://forums.mysql.com/read.php?115,418955,418955#msg-418955

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:19:32+00:00Added an answer on May 23, 2026 at 3:19 am

    The OP has found an answer here, just in case the link disappears, below is the text in that link:

    DROP TABLE IF EXISTS `wordpress`.`bb_posts_fulltext_search`;
    CREATE TABLE `wordpress`.`bb_posts_fulltext_search` (
    `post_id` int(10) unsigned NOT NULL,
    `post_text` longtext,
    `topic_id` int(10) unsigned NOT NULL DEFAULT '0',
    PRIMARY KEY (`post_id`,`topic_id`) USING BTREE,
    FULLTEXT KEY `post_text` (`post_text`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    
    DROP TABLE IF EXISTS `wordpress`.`bb_topics_fulltext_search`;
    CREATE TABLE `wordpress`.`bb_topics_fulltext_search` (
    `topic_id` int(11) NOT NULL,
    `topic_title` varchar(255) DEFAULT NULL,
    `topic_posts` bigint(20) DEFAULT NULL,
    `topic_poster_name` varchar(40) DEFAULT NULL,
    `topic_last_post_id` bigint(20) DEFAULT NULL,
    `forum_id` int(11) DEFAULT NULL,
    `parent_group_id` int(11) DEFAULT NULL,
    `child_group_id` int(11) DEFAULT NULL,
    `topic_last_post_time` datetime DEFAULT NULL,
    PRIMARY KEY (`topic_id`),
    KEY `topic_last_post_time` (`topic_last_post_time`),
    FULLTEXT KEY `topic_title` (`topic_title`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    
    SELECT
      topic_search.topic_id,
      topic_search.topic_title,
      topic_search.topic_posts,
      topic_search.topic_title,
      topic_search.topic_poster_name,
      topic_search.topic_last_post_id,
      topic_search.topic_last_post_time,
      MATCH(post_search.post_text,topic_search.topic_title) 
        AGAINST('searchterms' IN BOOLEAN MODE) AS score
    FROM bb_posts_fulltext_search as post_search
    LEFT JOIN bb_topics_fulltext_search as topic_search
      ON post_search.topic_id = topic_search.topic_id
    WHERE 
      MATCH(post_search.post_text,topic_search.topic_title) 
        AGAINST('searchterms' IN BOOLEAN MODE)
    GROUP BY topic_search.topic_id
    ORDER BY score DESC
    LIMIT 0,6 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following problem: Table with 1000 000 Records If i use the following query with
I have an SQL query that takes the following form: UPDATE foo SET flag=true
I have the following query: select column_name, count(column_name) from table group by column_name having
I've got the following query to determine how many votes a story has received:
I have an sql query with inner joins of four tables that takes more
I am trying to use the following query on a table with ~200k records
The following query returns strange results for me: SELECT `Statistics`.`StatisticID`, COUNT(`Votes`.`StatisticID`) AS `Score`, COUNT(`Views`.`StatisticID`)
The following query does what I'd like it to do, however, I have no
The following query will display all Dewey Decimal numbers that have been duplicated in
Using the following query and results, I'm looking for the most recent entry where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.