
uwe at kiewel-online
Apr 14, 2008, 12:33 PM
Post #5 of 5
(259 views)
Permalink
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul J Stevens schrieb: > Uwe Kiewel wrote: >> Hi Paul, >> >> Paul J Stevens schrieb: >>> Uwe, >>> please run that query through an 'ANALYZE' command. > > I meant 'DESCRIBE ...' > > > looks normal: mysql> describe SELECT 'a',COUNT(*) FROM dbmail_messages WHERE mailbox_idnr=121 AND (status < 2) UNION SELECT 'b',COUNT(*) FROM dbmail_messages WHERE mailbox_idnr=121 AND (status < 2) AND seen_flag=1 UNION SELECT 'c',COUNT(*) FROM dbmail_messages WHERE mailbox_idnr=121 AND (status < 2) AND recent_flag=1; +----+--------------+-----------------+------+----------------------------------------------------------------+--------------------+---------+-------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+--------------+-----------------+------+----------------------------------------------------------------+--------------------+---------+-------+------+-------------+ | 1 | PRIMARY | dbmail_messages | ref | mailbox_idnr_index,status_index,mailbox_status | mailbox_idnr_index | 8 | const | 2 | Using where | | 2 | UNION | dbmail_messages | ref | mailbox_idnr_index,seen_flag_index,status_index,mailbox_status | mailbox_idnr_index | 8 | const | 2 | Using where | | 3 | UNION | dbmail_messages | ref | mailbox_idnr_index,status_index,mailbox_status | mailbox_idnr_index | 8 | const | 2 | Using where | | NULL | UNION RESULT | <union1,2,3> | ALL | NULL | NULL | NULL | NULL | NULL | | +----+--------------+-----------------+------+----------------------------------------------------------------+--------------------+---------+-------+------+-------------+ 4 rows in set (0.02 sec) another format of the output might be better readable: mysql> explain SELECT 'a',COUNT(*) FROM dbmail_messages WHERE mailbox_idnr=121 AND (status < 2) UNION SELECT 'b',COUNT(*) FROM dbmail_messages WHERE mailbox_idnr=121 AND (status < 2) AND seen_flag=1 UNION SELECT 'c',COUNT(*) FROM dbmail_messages WHERE mailbox_idnr=121 AND (status < 2) AND recent_flag=1\G *************************** 1. row *************************** id: 1 select_type: PRIMARY table: dbmail_messages type: ref possible_keys: mailbox_idnr_index,status_index,mailbox_status key: mailbox_idnr_index key_len: 8 ref: const rows: 2 Extra: Using where *************************** 2. row *************************** id: 2 select_type: UNION table: dbmail_messages type: ref possible_keys: mailbox_idnr_index,seen_flag_index,status_index,mailbox_status key: mailbox_idnr_index key_len: 8 ref: const rows: 2 Extra: Using where *************************** 3. row *************************** id: 3 select_type: UNION table: dbmail_messages type: ref possible_keys: mailbox_idnr_index,status_index,mailbox_status key: mailbox_idnr_index key_len: 8 ref: const rows: 2 Extra: Using where *************************** 4. row *************************** id: NULL select_type: UNION RESULT table: <union1,2,3> type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: NULL Extra: 4 rows in set (0.00 sec) Thanks, Uwe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQEVAwUBSAOxeds3frmum9swAQJeZAf9FBFvWTt0x73S9ln3D19KFlEuq5GB5Lg4 htuIo6E4lK9fevjnin/yMytN2hoo4/a4a+gPwb9JSajhhrAvs/f7Mm1R0nM6kWkt ZMoQg7rHjpL1LUIyGiAUnw5JNUEbXof2hUuvBza9EaLt2m+ledluXvXM/HUklYo0 I0eet1w1e7RN0S8kCogf//CQnSjNZwkGhd5mJN3KaxCVdtUiVFcuy1F8bGRn7/BA w7eEIWK3u18BMUveBzr6XDSHwb9XcBdo3sR9TYaK0Lto9za/GMX/NJ0lNHTnPBUk ty9aDtW8tDnFYUvSjRzM/fNuP7q5WqwdtYDPEZ2VARV0VsE0h3D8PA== =qyTr -----END PGP SIGNATURE----- _______________________________________________ DBmail mailing list DBmail[at]dbmail.org https://mailman.fastxs.nl/mailman/listinfo/dbmail
|