Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: DBMail: users

crazy slow query

 

 

DBMail users RSS feed   Index | Next | Previous | View Threaded


uwe at kiewel-online

Apr 12, 2008, 8:06 AM

Post #1 of 5 (308 views)
Permalink
crazy slow query

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have a crazy slow query. I think it is *not* a slow query. Look at the
time stamp. But, I cannot imagine, why it happened...

Uwe


Apr 12 17:00:53 vm-host postfix-mx/smtpd[13917]: disconnect from
n77.bullet.mail.sp1.yahoo.com[98.136.44.45]

Apr 12 18:16:16 vm-host dbmail/imap4d[13320]: Warning:[db]
dbmodule.c,db_query(+151): slow query [.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] took [4398] seconds

[root[at]vm-host ~]# date
Sat Apr 12 17:03:21 CEST 2008
[root[at]vm-host ~]#
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEVAwUBSADQC9s3frmum9swAQLR/gf8CFvbxSiuN35Eavhb8Z+9SN6j8bsixUiN
2qU2GPV4R2Wbf3K9I/aL5FQ897fcEnl7OW3TDRH9gZHeq5mMr7d4BBxE4vC0fomK
YYSFFAnkwofqYMvjdlyVQgrnbEQkmb98J0jO/8diZiLt9OEbiqN0BaOmZUWG9sHb
uX/FxgAaPZKx5KDcJDQlvxcLOVGyDflYKLHDAzTbDdyuG9kKILP/UXDMWA3BSKNV
NjXuh0+Xbofc7Np9TJaHRG3taNPcbQnyH/uS0MxER8SioBPAvTPPEmyvJ3PY/EtO
hSpxGofBxlUGRnarEwn7QBNtmCha4Jn/DfVL/El6uw2tDoMjGfsj7w==
=B2Sj
-----END PGP SIGNATURE-----
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


paul at nfg

Apr 13, 2008, 3:28 AM

Post #2 of 5 (284 views)
Permalink
Re: crazy slow query [In reply to]

Uwe,

please run that query through an 'ANALYZE' command.


Uwe Kiewel wrote:
> Hi,
>
> I have a crazy slow query. I think it is *not* a slow query. Look at the
> time stamp. But, I cannot imagine, why it happened...
>
> Uwe
>
>
> Apr 12 17:00:53 vm-host postfix-mx/smtpd[13917]: disconnect from
> n77.bullet.mail.sp1.yahoo.com[98.136.44.45]
>
> Apr 12 18:16:16 vm-host dbmail/imap4d[13320]: Warning:[db]
> dbmodule.c,db_query(+151): slow query [.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] took [4398] seconds
>
> [root[at]vm-host ~]# date
> Sat Apr 12 17:03:21 CEST 2008
> [root[at]vm-host ~]#
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail

--
________________________________________________________________
Paul Stevens paul at nfg.nl
NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
The Netherlands________________________________http://www.nfg.nl
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


uwe at kiewel-online

Apr 13, 2008, 5:29 AM

Post #3 of 5 (282 views)
Permalink
Re: crazy slow query [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Paul,

Paul J Stevens schrieb:
> Uwe,
>
> please run that query through an 'ANALYZE' command.

do you really mean 'ANALYZE'? IMHO I can 'ANALYZE' a table, not a query...

Uwe
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEVAwUBSAH8xNs3frmum9swAQLOgQf/fkMOjnkjz5b2UOv3fhft43YobSlUeUI8
PYwwJaYxaw4fW1Hcf5WchEhlaMTSzLZmx6NytkYtsB7BqbVyGg9ng3/sHBeYRqYO
MzsAk91V6UerDyekNGPJEisRMu+/kwda0UimXfiyHrJVsHnbhugfi4n44x4bo5kg
k2irMJ8+M0dhVKaABhztLMQnFnMItnKFDqsBDQ7qyN/AlDfYAXDTjHTF8+pWiil7
wrE9zsUojxS2nEXZP7GOgKT6vPNRG2k/RO1gPM759s8fcqh3MZ/RftQScKYliyQP
bCK4QK0uMlER9Rn0gmwcDDlPvF2UFM/YPFE8VexbtXOGYoWfVZaaPQ==
=deI5
-----END PGP SIGNATURE-----
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


paul at nfg

Apr 13, 2008, 6:55 AM

Post #4 of 5 (282 views)
Permalink
Re: crazy slow query [In reply to]

Uwe Kiewel wrote:
> Hi Paul,
>
> Paul J Stevens schrieb:
>> Uwe,
>
>> please run that query through an 'ANALYZE' command.

I meant 'DESCRIBE ...'



--
________________________________________________________________
Paul Stevens paul at nfg.nl
NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
The Netherlands________________________________http://www.nfg.nl
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


uwe at kiewel-online

Apr 14, 2008, 12:33 PM

Post #5 of 5 (275 views)
Permalink
Re: crazy slow query [In reply to]

-----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

DBMail users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.