InnoDB Crash

2010-10-12 Thread Willy Mularto
Hi List,
Last night accidentally one of my InnoDB table crash. And cause client can not 
connect to MySQL, it always said cannot connect to socket, even the daemon is 
launched. I tried to set innodb_force_recovery from 0 to 6 and only number 3 
bring back the connection. After that I dump the data and drop the table. I 
recreate it as MyISAM and inject the dumped data. After that I stop MySQL and 
remove innodb_force_recovery and restart. And clients start complaining can not 
connect. Then I enable innodb_force_recovery again. I tried to create a new 
InnoDB table test and MySQL complaint cannot create the table due to the engine 
type is not supported. The question is how to solve this problem? How to bring 
back InnoDB to my server without reinstall the OS or MySQL itself? I have also 
tried to drop the database and remove the data folder from mysql data dir and 
recreate the database but still no luck. Thanks for any help.


 
sangprabv
sangpr...@gmail.com
http://www.petitiononline.com/froyo/



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Can this be done with a single query?

2010-10-12 Thread Paul Halliday
I have 2 tables: events and mappings.

what I want to do is something like:

SELECT DISTINCT(src_ip) FROM event WHERE timestamp BETWEEN '2010-10-11
00:00:00' AND '2010-10-12 00:00:00' AND INET_NTOA(src_ip) NOT LIKE
'10.%.%.%' AND INET_NTOA(src_ip) NOT LIKE '172.16.%.%' AND INET_NTOA(src_ip)
NOT LIKE '192.168.%.%';

but, within that somewhere also check to see if src_ip exists in mappings.
If it does, do not return it.

Is this possible?

Thanks.
-- 
Paul Halliday
Ideation | Individualization | Learner | Achiever | Analytical
http://www.pintumbler.org


Re: Can this be done with a single query?

2010-10-12 Thread Nathan Sullivan
Paul,

I think you could accomplish this by adding a subquery to your where clause, 
like:

AND NOT EXISTS (SELECT * FROM mappings m where m.src_ip=src_ip)


Hope that helps.


Nathan


On Tue, Oct 12, 2010 at 03:19:36AM -0700, Paul Halliday wrote:
 I have 2 tables: events and mappings.
 
 what I want to do is something like:
 
 SELECT DISTINCT(src_ip) FROM event WHERE timestamp BETWEEN '2010-10-11
 00:00:00' AND '2010-10-12 00:00:00' AND INET_NTOA(src_ip) NOT LIKE
 '10.%.%.%' AND INET_NTOA(src_ip) NOT LIKE '172.16.%.%' AND INET_NTOA(src_ip)
 NOT LIKE '192.168.%.%';
 
 but, within that somewhere also check to see if src_ip exists in mappings.
 If it does, do not return it.
 
 Is this possible?
 
 Thanks.
 -- 
 Paul Halliday
 Ideation | Individualization | Learner | Achiever | Analytical
 http://www.pintumbler.org

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Can this be done with a single query?

2010-10-12 Thread Johnny Withers
I would try:

SELECT DISTINCT(e.src_ip)
FROM event AS e
LEFT JOIN mappings AS m ON e.src_ip=m.src_ip
WHERE e.timestamp BETWEEN '2010-10-11 00:00:00' AND '2010-10-12 00:00:00'
AND INET_NTOA(e.src_ip) NOT LIKE '10.%.%.%'
AND INET_NTOA(e.src_ip) NOT LIKE '172.16.%.%'
AND INET_NTOA(e.src_ip) NOT LIKE '192.168.%.%'
AND m.src_ip IS NULL
;

I would also modify the where clause to use:

AND src_ip NOT BETWEEN INET_ATON('10.0.0.0') AND INET_ATON(10.255.255.255)
AND src_ip NOT BETWEEN INET_ATON('172.16.0.0') AND INET_ATON(172.16.255.255)
AND src_ip NOT BETWEEN INET_ATON('192.168.0.0') AND
INET_ATON(192.168.255.255)

instead of

AND INET_NTOA(src_ip) NOT LIKE '10.%.%.%'
AND INET_NTOA(src_ip) NOT LIKE '172.16.%.%'
AND INET_NTOA(src_ip) NOT LIKE '192.168.%.%

You should also ensure there is an index on src_ip in events and mappings
tables.

Using the INET_NTOA() function on the src_ip column will prevent index usage
during the query.

-JW


On Tue, Oct 12, 2010 at 5:19 AM, Paul Halliday paul.halli...@gmail.comwrote:

 I have 2 tables: events and mappings.

 what I want to do is something like:

 SELECT DISTINCT(src_ip) FROM event WHERE timestamp BETWEEN '2010-10-11
 00:00:00' AND '2010-10-12 00:00:00' AND INET_NTOA(src_ip) NOT LIKE
 '10.%.%.%' AND INET_NTOA(src_ip) NOT LIKE '172.16.%.%' AND
 INET_NTOA(src_ip)
 NOT LIKE '192.168.%.%';

 but, within that somewhere also check to see if src_ip exists in mappings.
 If it does, do not return it.

 Is this possible?

 Thanks.
 --
 Paul Halliday
 Ideation | Individualization | Learner | Achiever | Analytical
 http://www.pintumbler.org




-- 
-
Johnny Withers
601.209.4985
joh...@pixelated.net


Re: InnoDB Crash

2010-10-12 Thread Suresh Kuna
Hey Willy - Install the new binaries and start mysql with new binary as
basedir and see whether innodb has enabled or not. Check the error log why
the innodb is getting disabled, make a copy of it here too.

On Tue, Oct 12, 2010 at 2:57 PM, Willy Mularto sangpr...@gmail.com wrote:

 Hi List,
 Last night accidentally one of my InnoDB table crash. And cause client can
 not connect to MySQL, it always said cannot connect to socket, even the
 daemon is launched. I tried to set innodb_force_recovery from 0 to 6 and
 only number 3 bring back the connection. After that I dump the data and drop
 the table. I recreate it as MyISAM and inject the dumped data. After that I
 stop MySQL and remove innodb_force_recovery and restart. And clients start
 complaining can not connect. Then I enable innodb_force_recovery again. I
 tried to create a new InnoDB table test and MySQL complaint cannot create
 the table due to the engine type is not supported. The question is how to
 solve this problem? How to bring back InnoDB to my server without reinstall
 the OS or MySQL itself? I have also tried to drop the database and remove
 the data folder from mysql data dir and recreate the database but still no
 luck. Thanks for any help.



 sangprabv
 sangpr...@gmail.com
 http://www.petitiononline.com/froyo/



 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:
 http://lists.mysql.com/mysql?unsub=sureshkumar...@gmail.com




-- 
Thanks
Suresh Kuna
MySQL DBA


Re: Can this be done with a single query?

2010-10-12 Thread Paul Halliday
On Tue, Oct 12, 2010 at 11:14 AM, Johnny Withers joh...@pixelated.netwrote:

 I would try:

 SELECT DISTINCT(e.src_ip)
 FROM event AS e
 LEFT JOIN mappings AS m ON e.src_ip=m.src_ip
 WHERE e.timestamp BETWEEN '2010-10-11 00:00:00' AND '2010-10-12 00:00:00'
  AND INET_NTOA(e.src_ip) NOT LIKE '10.%.%.%'
 AND INET_NTOA(e.src_ip) NOT LIKE '172.16.%.%'
 AND INET_NTOA(e.src_ip) NOT LIKE '192.168.%.%'
 AND m.src_ip IS NULL
 ;

 I would also modify the where clause to use:

 AND src_ip NOT BETWEEN INET_ATON('10.0.0.0') AND INET_ATON(10.255.255.255)
 AND src_ip NOT BETWEEN INET_ATON('172.16.0.0') AND
 INET_ATON(172.16.255.255)
 AND src_ip NOT BETWEEN INET_ATON('192.168.0.0') AND
 INET_ATON(192.168.255.255)

 instead of

 AND INET_NTOA(src_ip) NOT LIKE '10.%.%.%'
 AND INET_NTOA(src_ip) NOT LIKE '172.16.%.%'
 AND INET_NTOA(src_ip) NOT LIKE '192.168.%.%

 You should also ensure there is an index on src_ip in events and mappings
 tables.

 Using the INET_NTOA() function on the src_ip column will prevent index
 usage during the query.


This and the suggestion by Nathan both work.

Thanks for the help!


Backing up the InnoDB tables

2010-10-12 Thread Tompkins Neil
Hi

On a shared MySQL server with access just to my own database, what is the
recommend backup methods and strategies for the InnoDB tables ?

Cheers
Neil


Can this query be done w/o adding another column?

2010-10-12 Thread Paul Halliday
Geez, really taking advantage of the list today :). This one is a little
more complicated, well, in my head anyway.

Same tables as before, event and mappings. Mappings is just IP to Country
info. I want to be able to join both a src and dst but the problem is the
mappings table just has one ip column.

My initial query looks like this:

SELECT COUNT(signature) as count, MAX(timestamp) AS maxTime,
INET_NTOA(src_ip), INET_NTOA(dst_ip), signature, signature_id, ip_proto FROM
event WHERE timestamp BETWEEN 2010-10-12 00:00:00 AND 2010-10-13
00:00:00 GROUP BY src_ip, dst_ip, signature,ip_proto ORDER BY maxTime DESC;

Which would return something like this:

2 | 2010-10-12 16:34:17 | 10.1.2.3 | 173.193.202.69 | ET P2P Vuze BT UDP
Connection | 2010144 | 17

Now I want to add the country info into the mix. I have made it this far:

SELECT COUNT(signature) as count, MAX(timestamp) AS maxTime,
INET_NTOA(src_ip), mappings.cc, INET_NTOA(dst_ip), mappings.cc, signature,
signature_id, ip_proto FROM event INNER JOIN mappings ON event.src_ip =
mappings.ip OR event.dst_ip = mappings.ip WHERE timestamp BETWEEN
2010-10-12 03:00:00 AND 2010-10-13 03:00:00 GROUP BY src_ip, dst_ip,
signature,ip_proto ORDER BY maxTime DESC LIMIT 10;

gives me:
2 | 2010-10-12 16:34:17 | 10.1.2.3 | US | 173.193.202.69 | US | ET P2P Vuze
BT UDP Connection | 2010144 | 17

which obviously isn't right ;) but is close. I was just going to change the
columns in the mappings table to have src_ip and dst_ip just duplicating the
ip column but I have a nagging feeling that that probably isn't necessary.

Thanks.

-- 
Paul Halliday
Ideation | Individualization | Learner | Achiever | Analytical
http://www.pintumbler.org


RE: Can this be done with a single query?

2010-10-12 Thread Travis Ard
You may get better performance from your query, and be able to make better
use of indexes if you use integer comparisons for your IP address
expressions instead of converting to strings with pattern matching.  You
might consider something like the following:


SELECT DISTINCT(e.src_ip) 
FROM event e
left outer join mappings m on mappings.src_ip = e.src_ip
WHERE e.timestamp BETWEEN '2010-10-11 00:00:00' AND '2010-10-12 00:00:00' 
AND e.src_ip NOT BETWEEN 167772160 AND 184549375
AND e.src_ip NOT BETWEEN 2886729728 AND 2886795263
AND e.src_ip NOT BETWEEN 3232235520 AND 3232301055
AND m.src_ip IS NULL;

-Travis


-Original Message-
From: Paul Halliday [mailto:paul.halli...@gmail.com] 
Sent: Tuesday, October 12, 2010 10:08 AM
To: Johnny Withers
Cc: mysql@lists.mysql.com
Subject: Re: Can this be done with a single query?

On Tue, Oct 12, 2010 at 11:14 AM, Johnny Withers
joh...@pixelated.netwrote:

 I would try:

 SELECT DISTINCT(e.src_ip)
 FROM event AS e
 LEFT JOIN mappings AS m ON e.src_ip=m.src_ip
 WHERE e.timestamp BETWEEN '2010-10-11 00:00:00' AND '2010-10-12 00:00:00'
  AND INET_NTOA(e.src_ip) NOT LIKE '10.%.%.%'
 AND INET_NTOA(e.src_ip) NOT LIKE '172.16.%.%'
 AND INET_NTOA(e.src_ip) NOT LIKE '192.168.%.%'
 AND m.src_ip IS NULL
 ;

 I would also modify the where clause to use:

 AND src_ip NOT BETWEEN INET_ATON('10.0.0.0') AND INET_ATON(10.255.255.255)
 AND src_ip NOT BETWEEN INET_ATON('172.16.0.0') AND
 INET_ATON(172.16.255.255)
 AND src_ip NOT BETWEEN INET_ATON('192.168.0.0') AND
 INET_ATON(192.168.255.255)

 instead of

 AND INET_NTOA(src_ip) NOT LIKE '10.%.%.%'
 AND INET_NTOA(src_ip) NOT LIKE '172.16.%.%'
 AND INET_NTOA(src_ip) NOT LIKE '192.168.%.%

 You should also ensure there is an index on src_ip in events and mappings
 tables.

 Using the INET_NTOA() function on the src_ip column will prevent index
 usage during the query.


This and the suggestion by Nathan both work.

Thanks for the help!


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: Can this query be done w/o adding another column?

2010-10-12 Thread Travis Ard
You could join your mappings table twice, once on src_ip and again on
dst_ip:

SELECT COUNT(signature) AS count,
   MAX(timestamp) AS maxTime,
   INET_NTOA(src_ip),
   m.cc as src_cc,
   INET_NTOA(dst_ip),
   m2.cc as dst_cc,
   signature,
   signature_id,
   ip_proto
FROM event
INNER JOIN mappings m ON event.src_ip = mappings.ip
INNER JOIN mappings m2 ON event.dst_ip = mappings.ip
WHERE timestamp BETWEEN 2010-10-12 03:00:00 AND 2010-10-13 03:00:00
GROUP BY INET_NTOA(src_ip), m.cc, INET_NTOA(dst_ip), m2.cc, signature,
signature_id, ip_proto
ORDER BY maxTime DESC
LIMIT 10;

-Travis

-Original Message-
From: Paul Halliday [mailto:paul.halli...@gmail.com] 
Sent: Tuesday, October 12, 2010 10:49 AM
To: mysql@lists.mysql.com
Subject: Can this query be done w/o adding another column?

Geez, really taking advantage of the list today :). This one is a little
more complicated, well, in my head anyway.

Same tables as before, event and mappings. Mappings is just IP to Country
info. I want to be able to join both a src and dst but the problem is the
mappings table just has one ip column.

My initial query looks like this:

SELECT COUNT(signature) as count, MAX(timestamp) AS maxTime,
INET_NTOA(src_ip), INET_NTOA(dst_ip), signature, signature_id, ip_proto FROM
event WHERE timestamp BETWEEN 2010-10-12 00:00:00 AND 2010-10-13
00:00:00 GROUP BY src_ip, dst_ip, signature,ip_proto ORDER BY maxTime DESC;

Which would return something like this:

2 | 2010-10-12 16:34:17 | 10.1.2.3 | 173.193.202.69 | ET P2P Vuze BT UDP
Connection | 2010144 | 17

Now I want to add the country info into the mix. I have made it this far:

SELECT COUNT(signature) as count, MAX(timestamp) AS maxTime,
INET_NTOA(src_ip), mappings.cc, INET_NTOA(dst_ip), mappings.cc, signature,
signature_id, ip_proto FROM event INNER JOIN mappings ON event.src_ip =
mappings.ip OR event.dst_ip = mappings.ip WHERE timestamp BETWEEN
2010-10-12 03:00:00 AND 2010-10-13 03:00:00 GROUP BY src_ip, dst_ip,
signature,ip_proto ORDER BY maxTime DESC LIMIT 10;

gives me:
2 | 2010-10-12 16:34:17 | 10.1.2.3 | US | 173.193.202.69 | US | ET P2P Vuze
BT UDP Connection | 2010144 | 17

which obviously isn't right ;) but is close. I was just going to change the
columns in the mappings table to have src_ip and dst_ip just duplicating the
ip column but I have a nagging feeling that that probably isn't necessary.

Thanks.

-- 
Paul Halliday
Ideation | Individualization | Learner | Achiever | Analytical
http://www.pintumbler.org


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Can this query be done w/o adding another column?

2010-10-12 Thread Paul Halliday
On Tue, Oct 12, 2010 at 1:59 PM, Travis Ard travis_...@hotmail.com wrote:

 You could join your mappings table twice, once on src_ip and again on
 dst_ip:

 SELECT COUNT(signature) AS count,
MAX(timestamp) AS maxTime,
   INET_NTOA(src_ip),
m.cc as src_cc,
   INET_NTOA(dst_ip),
   m2.cc as dst_cc,
signature,
   signature_id,
   ip_proto
 FROM event
 INNER JOIN mappings m ON event.src_ip = mappings.ip
 INNER JOIN mappings m2 ON event.dst_ip = mappings.ip
 WHERE timestamp BETWEEN 2010-10-12 03:00:00 AND 2010-10-13 03:00:00
 GROUP BY INET_NTOA(src_ip), m.cc, INET_NTOA(dst_ip), m2.cc, signature,
 signature_id, ip_proto
 ORDER BY maxTime DESC
 LIMIT 10;

 -Travis


I get an error: ERROR 1054 (42S22): Unknown column 'mappings.ip' in 'on
clause'


Re: MySQL sock file is missing: server doesn't start

2010-10-12 Thread spacemarc
2010/10/11 Sabika M sabika.makhd...@gmail.com:
 are the permissions on that directory correct? The .sock file is created at
 start up by mysql
mysqld doesn't start because are missing /var/run/mysqld dir and
/var/run/mysqld/mysqld.sock file. Dir and file are created on mysqld
boot, i presume. It's cyclic!

2010/10/12 partha sarathy par...@mafiree.com:
 once mysqld gets started then only we can see the sock file and use the same 
 to
 connect to mysql prompt.
 check your error log... some error message will be there. make it correct
 otherwise reply the error msg.

101012 20:21:29 [Note] Plugin 'FEDERATED' is disabled.
101012 20:21:30  InnoDB: Started; log sequence number 0 44263
101012 20:21:30 [ERROR] Can't start server : Bind on unix socket: No
such file or directory
101012 20:21:30 [ERROR] Do you already have another mysqld server
running on socket: /var/run/mysqld/mysqld.sock ?
101012 20:21:30 [ERROR] Aborting
101012 20:21:30  InnoDB: Starting shutdown...
101012 20:21:31  InnoDB: Shutdown completed; log sequence number 0 44263
101012 20:21:31 [Note] mysqld: Shutdown complete


2010/10/12 Michael Dykman mdyk...@gmail.com:
 More often than not, this is a file permission issue.  Does the MySQL
 user have permission to create a socket in /var/run/mysqld ?try

 ls -ld /var/run/mysqld
 ls -l /var/run/mysqld

 and make sure everything is owned by the MySQL user.

now, i have created the /var/run/mysqld dir and change the own to mysql user:
sudo chown mysql:mysql mysqld
The ls -ld output is:
drwxr-xr-x 2 mysql mysql 40 2010-10-12 20:31 /var/run/mysqld

The result is still 2002 error!

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: Can this query be done w/o adding another column?

2010-10-12 Thread Travis Ard
Sorry, try changing the column mappings.ip to use the table aliases (m.ip
and m2.ip).

 

-Travis

 

From: Paul Halliday [mailto:paul.halli...@gmail.com] 
Sent: Tuesday, October 12, 2010 11:37 AM
To: Travis Ard
Cc: mysql@lists.mysql.com
Subject: Re: Can this query be done w/o adding another column?

 

On Tue, Oct 12, 2010 at 1:59 PM, Travis Ard travis_...@hotmail.com wrote:

You could join your mappings table twice, once on src_ip and again on
dst_ip:

SELECT COUNT(signature) AS count,

  MAX(timestamp) AS maxTime,
  INET_NTOA(src_ip),

  m.cc as src_cc,
  INET_NTOA(dst_ip),
  m2.cc as dst_cc,

  signature,
  signature_id,
  ip_proto
FROM event

INNER JOIN mappings m ON event.src_ip = mappings.ip
INNER JOIN mappings m2 ON event.dst_ip = mappings.ip

WHERE timestamp BETWEEN 2010-10-12 03:00:00 AND 2010-10-13 03:00:00

GROUP BY INET_NTOA(src_ip), m.cc, INET_NTOA(dst_ip), m2.cc, signature,
signature_id, ip_proto

ORDER BY maxTime DESC
LIMIT 10;

-Travis

 

 
I get an error: ERROR 1054 (42S22): Unknown column 'mappings.ip' in 'on
clause'



Re: InnoDB Crash

2010-10-12 Thread Willy Mularto
I got the solution. I stop the ib* files in MySQL datadir and start the server. 
Now everything is back to normal. Thanks.




sangprabv
sangpr...@gmail.com
http://www.petitiononline.com/froyo/


On Oct 12, 2010, at 11:00 PM, Suresh Kuna wrote:

 Hey Willy - Install the new binaries and start mysql with new binary as 
 basedir and see whether innodb has enabled or not. Check the error log why 
 the innodb is getting disabled, make a copy of it here too.
 
 On Tue, Oct 12, 2010 at 2:57 PM, Willy Mularto sangpr...@gmail.com wrote:
 Hi List,
 Last night accidentally one of my InnoDB table crash. And cause client can 
 not connect to MySQL, it always said cannot connect to socket, even the 
 daemon is launched. I tried to set innodb_force_recovery from 0 to 6 and only 
 number 3 bring back the connection. After that I dump the data and drop the 
 table. I recreate it as MyISAM and inject the dumped data. After that I stop 
 MySQL and remove innodb_force_recovery and restart. And clients start 
 complaining can not connect. Then I enable innodb_force_recovery again. I 
 tried to create a new InnoDB table test and MySQL complaint cannot create the 
 table due to the engine type is not supported. The question is how to solve 
 this problem? How to bring back InnoDB to my server without reinstall the OS 
 or MySQL itself? I have also tried to drop the database and remove the data 
 folder from mysql data dir and recreate the database but still no luck. 
 Thanks for any help.
 
 
 
 sangprabv
 sangpr...@gmail.com
 http://www.petitiononline.com/froyo/
 
 
 
 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql?unsub=sureshkumar...@gmail.com
 
 
 
 
 -- 
 Thanks
 Suresh Kuna
 MySQL DBA



RE: Can this be done with a single query?

2010-10-12 Thread Daevid Vincent
Absolutely was just going to suggest this Travis.

Another option and this is untested, but is to use HAVING and an alias.
Something to this effect...

SELECT INET_NTOA(e.src_ip) AS source_ip
WHERE e.timestamp BETWEEN '2010-10-11 00:00:00' AND '2010-10-12 00:00:00'
HAVING source_ip BETWEEN '10.0.0.0' and '10.255.255.255'

But yeah, Travis suggestion is cleaner and more efficient.

 -Original Message-
 From: Travis Ard [mailto:travis_...@hotmail.com] 
 Sent: Tuesday, October 12, 2010 9:51 AM
 To: 'Paul Halliday'
 Cc: mysql@lists.mysql.com
 Subject: RE: Can this be done with a single query?
 
 You may get better performance from your query, and be able 
 to make better
 use of indexes if you use integer comparisons for your IP address
 expressions instead of converting to strings with pattern 
 matching.  You
 might consider something like the following:
 
 
 SELECT DISTINCT(e.src_ip) 
 FROM event e
 left outer join mappings m on mappings.src_ip = e.src_ip
 WHERE e.timestamp BETWEEN '2010-10-11 00:00:00' AND 
 '2010-10-12 00:00:00' 
 AND e.src_ip NOT BETWEEN 167772160 AND 184549375
 AND e.src_ip NOT BETWEEN 2886729728 AND 2886795263
 AND e.src_ip NOT BETWEEN 3232235520 AND 3232301055
 AND m.src_ip IS NULL;
 
 -Travis
 
 
 -Original Message-
 From: Paul Halliday [mailto:paul.halli...@gmail.com] 
 Sent: Tuesday, October 12, 2010 10:08 AM
 To: Johnny Withers
 Cc: mysql@lists.mysql.com
 Subject: Re: Can this be done with a single query?
 
 On Tue, Oct 12, 2010 at 11:14 AM, Johnny Withers
 joh...@pixelated.netwrote:
 
  I would try:
 
  SELECT DISTINCT(e.src_ip)
  FROM event AS e
  LEFT JOIN mappings AS m ON e.src_ip=m.src_ip
  WHERE e.timestamp BETWEEN '2010-10-11 00:00:00' AND 
 '2010-10-12 00:00:00'
   AND INET_NTOA(e.src_ip) NOT LIKE '10.%.%.%'
  AND INET_NTOA(e.src_ip) NOT LIKE '172.16.%.%'
  AND INET_NTOA(e.src_ip) NOT LIKE '192.168.%.%'
  AND m.src_ip IS NULL
  ;
 
  I would also modify the where clause to use:
 
  AND src_ip NOT BETWEEN INET_ATON('10.0.0.0') AND 
 INET_ATON(10.255.255.255)
  AND src_ip NOT BETWEEN INET_ATON('172.16.0.0') AND
  INET_ATON(172.16.255.255)
  AND src_ip NOT BETWEEN INET_ATON('192.168.0.0') AND
  INET_ATON(192.168.255.255)
 
  instead of
 
  AND INET_NTOA(src_ip) NOT LIKE '10.%.%.%'
  AND INET_NTOA(src_ip) NOT LIKE '172.16.%.%'
  AND INET_NTOA(src_ip) NOT LIKE '192.168.%.%
 
  You should also ensure there is an index on src_ip in 
 events and mappings
  tables.
 
  Using the INET_NTOA() function on the src_ip column will 
 prevent index
  usage during the query.
 
 
 This and the suggestion by Nathan both work.
 
 Thanks for the help!
 
 
 -- 
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:
 http://lists.mysql.com/mysql?unsub=dae...@daevid.com
 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org