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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:01:08+00:00 2026-05-14T05:01:08+00:00

Setup: mysql> create table t(a integer unsigned,b integer unsigned); mysql> insert into t(a,b) values

  • 0

Setup:

mysql> create table t(a integer unsigned,b integer unsigned);
mysql> insert into t(a,b) values (1,2),(1,3),(2,4);
mysql> create index i_t_a on t(a);
mysql> create index i_t_b on t(b);
mysql> explain select * from t where a=1 or b=4;
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
|  1 | SIMPLE      | t     | ALL  | i_t_a,i_t_b   | NULL | NULL    | NULL |    3 | Using where |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+

Is there something I’m missing?

Update

mysql> explain select * from t where a=1 or b=4;
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
|  1 | SIMPLE      | t     | ALL  | i_t_a,i_t_b   | NULL | NULL    | NULL | 1863 | Using where |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+

Version:

mysql> select version();
+----------------------+
| version()            |
+----------------------+
| 5.1.36-community-log |
+----------------------+

Has anyone ever successfully make index merge work for MySQL?

I’ll be glad to see successful stories here:)

  • 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-14T05:01:08+00:00Added an answer on May 14, 2026 at 5:01 am

    Long back:

    show indexes from lesssong;

    Table, Non_unique, Key_name, Seq_in_index, Column_name, Collation, Cardinality, Sub_part, Packed, Null, Index_type, Comment
    'lesssong', 0, 'PRIMARY', 1, 'S_ID', 'A', 50000, , '', '', 'BTREE', ''
    'lesssong', 1, 'idx_s_name', 1, 'S_NAME', 'A', 25000, 10, '', '', 'BTREE', ''
    'lesssong', 1, 'idx_S_ARID', 1, 'S_ARID', 'A', 1315, , '', '', 'BTREE', ''
    'lesssong', 1, 'idxFTS', 1, 'S_NAME', '', 1, , '', '', 'FULLTEXT', ''
    

    Count = 50000

    explain select * from lesssong where s_name=’kv’ or s_arid=4

    1, 'SIMPLE', 'lesssong', 'index_merge', 'idx_s_name,idx_S_ARID,idxFTS', 'idx_s_name,idx_S_ARID', '12,4', '', 2, 'Using sort_union(idx_s_name,idx_S_ARID); Using where'
    

    Structure:

    'S_ID', 'int(10) unsigned', 'NO', 'PRI', '', 'auto_increment'
    'S_ALID', 'int(10) unsigned', 'NO', '', '', ''
    'S_ARID', 'int(10) unsigned', 'NO', 'MUL', '', ''
    'S_NAME', 'varchar(100)', 'NO', 'MUL', '', ''
    'S_LYRIC', 'text', 'NO', '', '', ''
    'S_WRITER', 'varchar(45)', 'NO', '', '', ''
    'S_LINK', 'varchar(255)', 'NO', '', '', ''
    

    Even for you structure I got it work for me:

    I added random 100 values:

    insert into t(a,b) select ceil(rand()*5),ceil(rand()*30)
    

    explain select * from t where a=1 or b=4;

    id, select_type, table, type, possible_keys, key, key_len, ref, rows, Extra
    1, 'SIMPLE', 't', 'index_merge', 'i_t_a,i_t_b', 'i_t_a,i_t_b', '5,5', '', 32, 'Using union(i_t_a,i_t_b); Using where'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

setup: mysql> create table main(id integer unsigned); mysql> create table test1(id integer unsigned,body text);
Set up(MySQL): create table inRelation( party1 integer unsigned NOT NULL, party2 integer unsigned NOT
setup: mysql> create table bank(bank_id integer, bank_name varchar(255)); Query OK, 0 rows affected (0.27
setup: mysql> create table product_stock( product_id integer, qty integer, branch_id integer); Query OK, 0
setup: mysql> create table product_stock( product_id integer, qty integer); Query OK, 0 rows affected
How can I import a mysql database dump file (contains insert and create table
Why does Mysql optimizer choose the secondary index when doing a 'select * from
Assume the following in MySQL: CREATE TABLE users ( id integer auto_increment primary key,
I have a MySQL table with following setup: CREATE TABLE IF NOT EXISTS `coords`
setup: create table product_stock(product_id integer, qty integer, branch_id integer); create table product(product_id integer, product_name

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.