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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:42:48+00:00 2026-06-02T07:42:48+00:00

Just curious if it’s possible to make this query any faster? or if there

  • 0

Just curious if it’s possible to make this query any faster? or if there is any other similar queries that would work better?

SELECT id,source FROM posts
WHERE id = ANY(SELECT image_id FROM `post_tags` WHERE tag_id = (SELECT id FROM `tags` WHERE tag = _utf8 '$TAG' collate utf8_bin))
  AND posts.exists = 'n'
ORDER BY posts.ratecount DESC
LIMIT 0,100

Without using the:

  AND posts.exists = 'n'
ORDER BY posts.ratecount
DESC LIMIT 0,100

It speeds up to query to usable levels, but somewhat need this for what I’m doing.

  • Tags table has unique index for both ‘tag’ and ‘id’.
  • Tags has 83K rows.
  • Post_tags has unique index for ‘image_id’, ‘tag_id’. Also normal index for each.
  • Post_tags has 471K rows.
  • Posts has unique index for ‘id’. Also normal index for ‘exists’ and ‘ratecount’.
  • Posts table has about 1.1M rows.
  • 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-02T07:42:50+00:00Added an answer on June 2, 2026 at 7:42 am

    Managed to get it working using a JOIN as someone suggested.

    SELECT * FROM posts
    LEFT JOIN post_tags ON post_tags.image_id = posts.id
    JOIN tags ON post_tags.tag_id = tags.id
    WHERE tags.tag = _utf8 '$tag' collate utf8_bin
      AND posts.exists = 'n'
    ORDER BY posts.ratecount DESC
    LIMIT 0,100
    

    Reduced time taken from 22s > 0.26s.

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

Sidebar

Related Questions

Just curious how you would comment this line of code: string customerNm = customerNm.EndsWith(s)
Just curious if this is the way to do this, just want to make
Just curious. Tried to google this, but found nothing. I remember earlier there was
Just curious to know what the best practice would be for something like this:
Just curious about which of these would be faster? $('ul.dropdown a').first().click(function(event) { event.stopPropagation(); return
Just curious about what would be the django way of achieving the following :
Just curious here: is it possible to invoke a Windows Blue Screen of Death
Just curious if there is anyway to display an objects retain count using NSLog.
Just curious (maybe this is an implementation detail so you may not know) but
Just curious to see if there is a lua way to ping a server

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.