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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:15:03+00:00 2026-05-15T19:15:03+00:00

Using EXPLAIN for the query below shows SELECT cha.cid AS cid, cha.data AS dl

  • 0

Using EXPLAIN for the query below shows

SELECT cha.cid AS cid,
       cha.data AS dl
FROM cha, c_users
WHERE uid = 808
AND cha.cid = c_users.cid;
  1. it does a full scan on cha table
  2. uses the multi column index(cid,uid) from c_users.

Why doesn’t it not use the primary key index from cha and rather does a full table scan. Is there a better way to optimise the query/table.

Edit:
cha.cid is my primary key. Added after the comment below.

  • 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-15T19:15:04+00:00Added an answer on May 15, 2026 at 7:15 pm

    In a normal BTREE, and an index on (cid,uid), a scan will be needed if you don’t specify cid and only search for uid. An index on (uid,cid) (notice the order) would / could help.

    This is by no means a guarantee it will be used, MySQL can guess that a full scan might be quicker (continuous read) if a certain index / join most likely will require a certain large percentage of the index to be used, and other reasons. You can check with FORCE INDEX if using the key compared to a scan is actually any quicker or not (disable query cache on a testserver before testing this).

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

Sidebar

Related Questions

A query (see below) that extracts climate data from weather stations within a given
I am using indexing for mysql tables. My query was like this EXPLAIN SELECT
I expected either index to be used for my SELECT DISTINCT query below: CREATE
I am using 'explain' to view why my query is hitting every single row
This simple query: SELECT trip_id from stop_times WHERE stop_id = 345 Takes about 80ms,
I have this MySQL query that I'd like to optimize: SELECT min(`topic_id`) FROM `gallery_topics`
I know the below query isn't valid, but I'm just using it as an
If it's harder to explain using words, let's look at an example I have
Can anyone explain why using comments like this in css cause really weird effects
Could someone explain why both tests using the latest versions of Moq and Rhino.Mocks

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.