By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE tb_kse(id_no INT, ss_no INT )
create index IDX_KSE_NO_01 on tb_kse(ss_no);
Records: 0 Duplicates: 0 Warnings: 0
create index IDX_KSE_NO_02 on tb_kse(id_no);
Records: 0 Duplicates: 0 Warnings: 0
explain
SELECT *
FROM tb_kse WHERE ss_no = 10
UNION ALL
SELECT *
FROM tb_kse
WHERE ss_no IS NULL AND id_no = 10;
id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | PRIMARY | tb_kse | null | ref | IDX_KSE_NO_01 | IDX_KSE_NO_01 | 5 | const | 1 | 100.00 | null |
2 | UNION | tb_kse | null | ref | IDX_KSE_NO_01,IDX_KSE_NO_02 | IDX_KSE_NO_01 | 5 | const | 1 | 100.00 | Using index condition; Using where |