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

  • Home
  • SEARCH
  • 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 7923737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:24:52+00:00 2026-06-03T17:24:52+00:00

I have a news section. Articles are tagged and stored in 3 tables: posts:

  • 0

I have a news section. Articles are tagged and stored in 3 tables:

posts:

posts_id,title,body

tags:

tags_id,name

posts_tags:

posts_id,tags_id

The problem at the moment is that the front page of the news section displays previews of the first 10 articles. Each preview displays the tag lists. Displaying the tag lists means I have to query again for each post to get a list of the tags.

So for example, the 10 previews requires, 1 query(gets 10 posts from posts)+10 queries(1 for each post on tags and posts_tags to get tag lists). 11 queries to load a page seems like it could eventually be a bottleneck.

Should I forgo tagging previews? Would PIVOT result in the same amount of queries?

  • 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-03T17:24:54+00:00Added an answer on June 3, 2026 at 5:24 pm

    You can use a “join” to keep it all in one query. However: these kind of queries can get very “expensive”, escpecially if you are going to do some kind of grouping. So i would recommend to experiment with subselects. For example:

    SELECT (
        SELECT GROUP_CONCAT(name)
        FROM   tags, posts_tags
        WHERE  posts_tags.posts_id = posts.posts_id
        AND    tags.tags_id = posts_tags.tags_id
    ) FROM posts LIMIT 10
    

    With such kind of subselects you can normally get much better results than doing a normal join and grouping.

    Caching is of course still a good idea …

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

Sidebar

Related Questions

I have SEF urls like /sitename/section/12-news-title and number 12 is id of the news.
I have a news section that shows posts only with a category of news.
I have tables named news and tags_news. Given a news id I have to
I have a mysql question. I have a news section on my website, and
All of this is code is here: http://jsfiddle.net/yrgK8/ I have a news section which
I'm not sure how to go about this. I have a news section on
I have a sidebar with latest news and random blog posts etc <nav id=sidebar>
I want to have a news section to my page in a placeholder which
I have a news section where I can post some news. -> Thumbnail ,
I have a freelance project where I have to build a news articles based

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.