Thank you for your reply, here are the results:
mysql> explain extended select DB_ID,TB_ID
-> from
-> (
-> select db.ID as DB_ID, tb.ID as TB_ID
-> from sec_databases db, sec_tables tb join (
-> select TABLE_SCHEMA, TABLE_NAME
-> from information_schema.tables
-> where table_schema <> 'information_schema'
-> ) nms
-> where nms.TABLE_SCHEMA = db.DATABASENAME and
-> nms.TABLE_NAME = tb.TABLENAME
-> UNION ALL
-> select DB_ID,TB_ID
-> from sec_db_tb
-> ) tmp
-> group by DB_ID, TB_ID
-> having count(*) = 1;
+----+--------------+------------+--------+---------------+---------
+---------+------+------+----------
+-----------------------------------------------------+
| id | select_type | table | type | possible_keys | key |
key_len | ref | rows | filtered |
Extra |
+----+--------------+------------+--------+---------------+---------
+---------+------+------+----------
+-----------------------------------------------------+
| 1 | PRIMARY | <derived2> | system | NULL | NULL |
NULL | NULL | 0 | 0.00 | const row not
found |
| 2 | DERIVED | NULL | NULL | NULL | NULL |
NULL | NULL | NULL | NULL | no matching row in const
table |
| 3 | DERIVED | tables | ALL | NULL | NULL |
NULL | NULL | NULL | NULL | Using where; Skip_open_table;
Scanned all databases |
| 4 | UNION | sec_db_tb | index | NULL | PRIMARY |
12 | NULL | 1 | 100.00 | Using
index |
| NULL | UNION RESULT | <union2,4> | ALL | NULL | NULL
| NULL | NULL | NULL | NULL
| |
+----+--------------+------------+--------+---------------+---------
+---------+------+------+----------
+-----------------------------------------------------+
5 rows in set, 1 warning (0.01 sec)
mysql> show warnings;
| Level | Code |
Message
| Note | 1003 | select NULL AS `DB_ID`,NULL AS `TB_ID` from (select
`securich`.`db`.`ID` AS `DB_ID`,`securich`.`tb`.`ID` AS `TB_ID` from
`securich`.`sec_databases` `db` join `securich`.`sec_tables` `tb` join
(select `tables`.`TABLE_SCHEMA` AS
`TABLE_SCHEMA`,`tables`.`TABLE_NAME` AS `TABLE_NAME` from
`information_schema`.`tables` where (`tables`.`TABLE_SCHEMA` <>
'information_schema')) `nms` where ((NULL =
convert(`securich`.`db`.`DATABASENAME` using utf8)) and (NULL =
convert(`securich`.`tb`.`TABLENAME` using utf8))) union all select
`securich`.`sec_db_tb`.`DB_ID` AS
`DB_ID`,`securich`.`sec_db_tb`.`TB_ID` AS `TB_ID` from
`securich`.`sec_db_tb`) `tmp` group by NULL,NULL having (count(0) = 1)
|
1 row in set (0.00 sec)
cheers,
Paolo.