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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:59:12+00:00 2026-06-06T01:59:12+00:00

At first, i have to say that this topic is very common topic. I

  • 0

At first, i have to say that this topic is very common topic. I have studied all related topics but i can not find out the answer.
I have three tables. Messages table has 300.000, tags table has 1 million and message_tag table has about 10 million rows. message_tag.message_id and message_tag.tag_id columns have indexes. My purpose is select messages which linked a spesified tag. However query times are too long. There is not any query time shorter than 20 seconds. On the other hand sometimes query does not give even a result due to long query times. Table structures and my query are below. How can i handle this problem? I am open all suggestions. Even i can recreate tables with a new schema. Database is MySql, Storage motor is MyIsam. .

table name: messages
columns :
id (int)
message (vharchar)
message_poster (vharchar)

table name: tags
id (int)
tag (vharchar)

table name : message_tag
columns :
message_id (int)
tag_id (int)

My query:

SELECT                    messages.message_poster,
                          messages.message
                     FROM tags, messages, message_tag 
                     WHERE message_tag.tag_id=191
                     AND messages.id= message_tag.message_id
  • 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-06-06T01:59:13+00:00Added an answer on June 6, 2026 at 1:59 am

    And here is an example of why I don’t like using , notation.

    You don’t relate message_tag to tags. Instead, you join EVERY message tag to every other row.

    This is what you have…

    SELECT
      messages.message_poster,
      messages.message
    FROM
      messages
    INNER JOIN
      message_tag
        ON messages.id= message_tag.message_id
    CROSS JOIN
      tags
    WHERE
      message_tag.tag_id=191
    

    This is what you should have…

    SELECT
      messages.message_poster,
      messages.message
    FROM
      messages
    INNER JOIN
      message_tag
        ON messages.id = message_tag.message_id
    INNER JOIN
      tags
        ON tags.id     = message_tag.tag_id
    WHERE
      message_tag.tag_id = 191
    

    (Or, just don’t JOIN on tags at all, you’re not using it in this case. Though I appreciate that this may be a simplified version of the actual query.)

    It’s much harder to mess that up with ANSI-92 notation.

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

Sidebar

Related Questions

First, let me just say that I have searched for information on this topic;
I have a question, but let me first say that this is being performed
First of all, I have to say that I'm going to talk about System.ComponentModel.Component
First of all i want to say that i have searched each and every
Let's say I have some code that is ordered, but the ordering is not
Note first of all that this question is not tagged winforms or wpf or
First of all I must say that this may seem like a lot of
First of all let me say that this questions is slightly connected to another
First off I should say that I don't have any experience in working with
Let's say I have a form that collects a first name and a last

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.