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 6716635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:45:25+00:00 2026-05-26T08:45:25+00:00

This query on my site is taking a very long time to execute. I

  • 0

This query on my site is taking a very long time to execute. I have a blog and a forum on my site that I have loosely integrated so every forum account has an account on the blog and vice versa. However the user_id’s in each table aren’t correlated so I have been joining them by username.

SELECT *
FROM comments AS c
INNER JOIN articles AS a ON c.article_id = a.article_id
INNER JOIN user_profiles AS p ON c.user_id = p.user_id
INNER JOIN blog_users AS b ON c.user_id = b.user_id
INNER JOIN forum_users AS f ON b.username = f.username
WHERE a.article_id =  :article_id
ORDER BY c.comment_id DESC 
LIMIT 0 , 30

When I used explain on the query I saw that the last join was examining every single row in the forum_users table to come up with the result which is over 1,000,000 rows. The username columns for both tables are indexed and all tables are InnoDB. As a workaround, I’m storing each user’s forum user_id in the blog_users table, and vice versa so I can join directly on the user_id which has the query running much quicker but I would like to avoid having to do this if possible. Is there a way I could rework the query so the username join is more efficient?

  • 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-26T08:45:25+00:00Added an answer on May 26, 2026 at 8:45 am

    Are the table and column character sets the same? For example, blog_users in utf8 and forum_users in latin1? If they aren’t the same, mysql won’t use the indexes. You can change the character set with, for example:

    ALTER TABLE blog_users CONVERT TO CHARACTER SET utf8

    If this is the problem, read the docs carefully before doing this. It can change the content of the columns. http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This query that I have is returning therapists whose 'therapistTable.activated' is equal to false
I have this rather complex query that grabs data from three tables, and now
I have noticed that my site in Cakephp is very very slow. I have
In my method, I have this query: var query = _db.STEWARDSHIP .OrderBy(r => r.SITE.SITE_NAME)
This query is related to this one I asked yesterday. I have a radio
i found this site: here its very well described why it works and why
Trying to get this query to work in MS Access. Update Network.Location=Enclave.Location Where Enclave.Site=No
i have this query: select eid from event where creator = 100000956216009 Return this
I have this query: SELECT p.text,se.name,s.sub_name,SUM((p.volume / (SELECT SUM(p.volume) FROM phrase p WHERE p.volume
Consider this query: SELECT table1.id, table1.review, table1.time, table2.author, table2.title FROM table1, table2 WHERE table1.id

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.