At 06:25 PM 5/13/2002, you wrote:
>Hi,
>
>         I have the following query and everytime i try to run it, it 
> returns an
>error "Mysql server has gone away". Is it beacause the query is very slow?
>If so, how can i speed it up?
>
>Query ->
>SELECT a.idemail, a.fklastresp
>FROM wmkt_email a, wmkt_client b, wmkt_maillist_client c
>WHERE bActive AND b.fkemail NOT IN (1, 2 <- about 130.000 values -> )
>AND c.fkmaillist IN (2) AND a.idemail=b.fkemail AND c.fkclient=b.idclient
>ORDER BY fklastresp LIMIT 5000

Edilson.

You have 130,000 values in your IN clause?? Holey moley!! (Can I say 
that?<g>) It is going to take ages just to parse the sql statement.
You're going to have to find a better way to exclude those 130,000 values. 
If they are not consecutive numbers, or fall within ranges, try putting 
them into a table and do a left join on it to exclude them.

Mike



>Tables structures ->
>--------------------------------------------------------
>Table,Create Table
>wmkt_email,CREATE TABLE `wmkt_email` (
>   `idemail` int(11) NOT NULL auto_increment,
>   `email` varchar(255) NOT NULL default '',
>   `fklastresp` int(11) NOT NULL default '0',
>   PRIMARY KEY  (`idemail`),
>   UNIQUE KEY `ixEmail` (`email`)
>) TYPE=MyISAM
>
>--------------------------------------------------------
>Table,Create Table
>wmkt_client,CREATE TABLE `wmkt_client` (
>   `idclient` int(11) NOT NULL auto_increment,
>   `realname` varchar(80) NOT NULL default '',
>   `fkemail` int(11) NOT NULL default '0',
>   `dtInsert` datetime default NULL,
>   `dtLastUp` datetime default NULL,
>   `fkuser` int(11) NOT NULL default '1',
>   PRIMARY KEY  (`idclient`),
>   KEY `ixFkemail` (`fkemail`)
>) TYPE=MyISAM
>
>---------------------------------------------------------
>Table,Create Table
>wmkt_maillist_client,CREATE TABLE `wmkt_maillist_client` (
>   `fkmaillist` int(11) NOT NULL default '0',
>   `fkclient` int(11) NOT NULL default '0',
>   `dtInsert` datetime default NULL,
>   `bActive` tinyint(4) NOT NULL default '1',
>   KEY `ixEmailList` (`fkmaillist`,`fkclient`)
>) TYPE=MyISAM
>
>
>Thank u very much,
>Edilson.
>
>
>---------------------------------------------------------------------
>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 <[EMAIL PROTECTED]>
>To unsubscribe, e-mail <[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
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 <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to