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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:24:42+00:00 2026-05-18T01:24:42+00:00

My query seems to be very similar to example from http://dev.mysql.md/doc/refman/5.1/en/in-subquery-optimization.html , but unfortunately

  • 0

My query seems to be very similar to example from http://dev.mysql.md/doc/refman/5.1/en/in-subquery-optimization.html, but unfortunately receipts from this manual don’t work for me.

When I run them separately, both inner and outer queries use indexes, but when I run the whole query, outer query scans the whole table…

mysql> explain select smsId FROM SMSDelivery WHERE smsId IN (SELECT smsId FROM SMS WHERE phoneNumber=’123456′ OR fromUser=’5678p’ OR toUser=’5124p’) \G

  *************************** 1. row ***************************
           id: 1
  select_type: PRIMARY
  table: SMSDelivery
  type: index
  possible_keys: NULL
  key: FK75C784D70BE5EC9
  key_len: 4
  ref: NULL
  rows: 1337017
  Extra: Using where; Using index

*************************** 2. row ***************************
     id: 2
    select_type: DEPENDENT SUBQUERY
    table: SMS
     type: unique_subquery
    possible_keys: PRIMARY,phoneNumber,fromUser,toUser
    key: PRIMARY
     key_len: 4
     ref: func
     rows: 1
     Extra: Using where
    2 rows in set (0.00 sec)
  • 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-18T01:24:43+00:00Added an answer on May 18, 2026 at 1:24 am

    can you try this:

    EXPLAIN
    SELECT
     sd.* 
    FROM 
     SMSDelivery sd
    INNER JOIN
    (
     SELECT smsId FROM SMS WHERE phoneNumber='123456' OR fromUser='5678p' OR toUser='5124p'
    ) s ON sd.smsId = s.smsId;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble setting up a query, it seems very simple but I
I have the following xpath query which seems to be working but I just
I'm stuck with a certain query, it seems to be simple but it seems
My question is very similar to this question but a bit more specific. My
I have a very similar problem, but i cant seem to figure it out,
I found a question that was very similar to this one, but using features
It seems that every time I want to perform a db query, I have
It seems to be fairly accepted that including the schema owner in the query
We're using Stored Procedures for every query to the DB. This seems incredibly un-
Looking for some help with optimising the query below. Seems to be two bottlenecks

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.