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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:39:30+00:00 2026-05-27T21:39:30+00:00

Schema: CREATE TABLE IF NOT EXISTS `tx_hep_homes_attributes_mm` ( `uid_local` int(11) NOT NULL DEFAULT ‘0’,

  • 0

Schema:

CREATE TABLE IF NOT EXISTS `tx_hep_homes_attributes_mm` (
  `uid_local` int(11) NOT NULL DEFAULT '0',
  `uid_foreign` int(11) NOT NULL DEFAULT '0',
  `tablenames` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `sorting` int(11) NOT NULL DEFAULT '0',
  KEY `uid_local` (`uid_local`),
  KEY `uid_foreign` (`uid_foreign`),
  KEY `uid_local_foreign` (`uid_local`,`uid_foreign`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Sample input:

INSERT INTO `tx_hep_homes_attributes_mm` (`uid_local`, `uid_foreign`, `tablenames`, `sorting`) VALUES
(2, 4, '', 3),
(2, 1, '', 2),
(2, 2, '', 1),
(1, 2, '', 5),
(1, 3, '', 4),
(1, 4, '', 3),
(1, 7, '', 2),
(1, 8, '', 1);

Query:

SELECT amm.uid_local, 
       amm.uid_foreign 
FROM   tx_hep_homes_attributes_mm amm 
       JOIN (SELECT 1 AS att_id 
             UNION 
             SELECT 4 AS att_id 
             UNION 
             SELECT 13 AS att_id 
             UNION 
             SELECT 22 AS att_id 
             UNION 
             SELECT 12 AS att_id)d1 
         ON d1.att_id = amm.uid_foreign 
       JOIN (SELECT 1 AS home_id 
             UNION 
             SELECT 2 AS home_id)d2 
         ON d2.home_id = amm.uid_local 
ORDER  BY uid_local 

produces:

+------+---------------+-------------------+-------+------------------------------------------+--------------------+----------+-------------+-------+---------------------------------+
| id   | select_type   |      table        | type  |              possible_keys               |        key         | key_len  |    ref      | rows  |              Extra              |
+------+---------------+-------------------+-------+------------------------------------------+--------------------+----------+-------------+-------+---------------------------------+
| 1    | PRIMARY       | <derived7>        | ALL   | NULL                                     | NULL               | NULL     | NULL        | 2     | Using temporary; Using filesort |
| 1    | PRIMARY       | amm               | ref   | uid_local,uid_foreign,uid_local_foreign  | uid_local_foreign  | 4        | d2.home_id  | 1     | Using where; Using index        |
| 1    | PRIMARY       | <derived2>        | ALL   | NULL                                     | NULL               | NULL     | NULL        | 5     | Using where; Using join buffer  |
| 7    | DERIVED       | NULL              | NULL  | NULL                                     | NULL               | NULL     | NULL        | NULL  | No tables used                  |
| 8    | UNION         | NULL              | NULL  | NULL                                     | NULL               | NULL     | NULL        | NULL  | No tables used                  |
| NULL | UNION RESULT  | <union7,8>        | ALL   | NULL                                     | NULL               | NULL     | NULL        | NULL  |                                 |
| 2    | DERIVED       | NULL              | NULL  | NULL                                     | NULL               | NULL     | NULL        | NULL  | No tables used                  |
| 3    | UNION         | NULL              | NULL  | NULL                                     | NULL               | NULL     | NULL        | NULL  | No tables used                  |
| 4    | UNION         | NULL              | NULL  | NULL                                     | NULL               | NULL     | NULL        | NULL  | No tables used                  |
| 5    | UNION         | NULL              | NULL  | NULL                                     | NULL               | NULL     | NULL        | NULL  | No tables used                  |
| 6    | UNION         | NULL              | NULL  | NULL                                     | NULL               | NULL     | NULL        | NULL  | No tables used                  |
| NULL | UNION RESULT  | <union2,3,4,5,6>  | ALL   | NULL                                     | NULL               | NULL     | NULL        | NULL  |                                 |
+------+---------------+-------------------+-------+------------------------------------------+--------------------+----------+-------------+-------+---------------------------------+

As you see uses where, uses file sort, although it should resolve from the composite index.

  • 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-27T21:39:31+00:00Added an answer on May 27, 2026 at 9:39 pm

    If tx_hep_homes_attributes_mm is only the 9 rows shown here then I would expect the index to be ignored as all the data will be in a cache and using an index will cost more.

    Indicies are used mainly when the amount of data selected by index is much less than the number of rows in the table. Here 75% of the rows are in the result.

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

Sidebar

Related Questions

Here's the Schema in mysql: CREATE TABLE IF NOT EXISTS `labs_test`.`games` ( `game_id` INT
CREATE TABLE IF NOT EXISTS `mydb`.`MATCHES` ( `idMatch` INT NOT NULL , `idChampionship` INT
For some reason, this MySQL fails: CREATE SCHEMA IF NOT EXISTS `partB` DEFAULT CHARACTER
We have a database with a very simple schema: CREATE TABLE IF NOT EXISTS
Say I have a table like so: CREATE TABLE big_table (UUID varchar(32) not null,
I have the following table schema; CREATE TABLE `db1`.`sms_queue` ( `Id` INTEGER UNSIGNED NOT
Test case schema and data follow as: create table tmp ( vals varchar(8), mask
This is the master table structure: CREATE TABLE IF NOT EXISTS `gf_film` ( `film_id`
I've a table [File] that has the following schema CREATE TABLE [dbo].[File] ( [FileID]
I have a table in PostgreSQL where the schema looks like this: CREATE TABLE

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.