Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Query causes MySQL to "Lose connection"

0 views
Skip to first unread message

Jason Rhinelander

unread,
Feb 15, 2002, 11:28:02 PM2/15/02
to

I'm having a problem with a MySQL query - when I run it, I get "ERROR 2013:
Lost connection to MySQL server during query"

Here is the query:

SELECT forum_id_fk, COUNT(*) FROM gforum_Post WHERE (
( forum_id_fk = 21 AND post_time > 1008613409 ) OR
( forum_id_fk = 22 AND post_time > 1012588917 ) OR
( forum_id_fk = 23 AND post_time > 1012250410 ) OR
( forum_id_fk = 24 AND post_time > 1012073390 ) OR
( forum_id_fk = 25 AND post_time > 1012435676 )
)
GROUP BY forum_id_fk;

You can take the GROUP BY and COUNT(*) off, it doesn't seem to have any
effect.

gforum_Post has about 180,000 rows.

What make this even more bizarre is that the following query does NOT cause
the error:

SELECT forum_id_fk, COUNT(*) FROM gforum_Post WHERE (
( forum_id_fk = 22 AND post_time > 1012588917 ) OR
( forum_id_fk = 23 AND post_time > 1012250410 ) OR
( forum_id_fk = 24 AND post_time > 1012073390 ) OR
( forum_id_fk = 25 AND post_time > 1012435676 )
)
GROUP BY forum_id_fk;


If I do a logical negation of the whole thing, it works successfully, but
isn't using any indices and so becomes too slow.

An EXPLAIN of the working query gives (split in half to keep it from
wrapping in this e-mail):

+-------------+-------+-----------------------+-------
| table | type | possible_keys | key
+-------------+-------+-----------------------+-------
| gforum_Post | range | p_fn,p_fmn,p_mn,p_mfu | p_fmn
+-------------+-------+-----------------------+-------

+---------+------+------+-------------------------+
| key_len | ref | rows | Extra |
+---------+------+------+-------------------------+
| 8 | NULL | 636 | where used; Using index |
+---------+------+------+-------------------------+

Attempting to EXPLAIN the first query causes the same "Lost connection" as
actually running the query.

Can anyone shed some light on why this might be happening, and what I could
do to get around it?

-- Jason Rhinelander
-- Gossamer Threads, Inc.


---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <mysql-thr...@lists.mysql.com>
To unsubscribe, e-mail <mysql-unsubscribe-mysql=freebsd.csie...@lists.mysql.com>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

0 new messages