« first day (11 days earlier)    last day (14 days later) » 

12:13 PM
Ok I'm going to test it out now
 
 
2 hours later…
2:00 PM
Ok
It works
Look it over
/* Tables */

CREATE TABLE `emails` (
 `group_id` bigint(20) NOT NULL,
 `email` varchar(500) NOT NULL,
 UNIQUE KEY `group_id` (`group_id`,`email`) USING BTREE,
 CONSTRAINT `emails_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `entities` (`group_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1

CREATE TABLE `hashes` (
 `group_id` bigint(20) NOT NULL,
 `hash` varchar(128) NOT NULL,
 `repeat_count` int(11) NOT NULL DEFAULT '0',
 UNIQUE KEY `hash` (`hash`),
 KEY `group_id` (`group_id`),
 CONSTRAINT `hashes_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `entities` (`group_id`) ON DELETE 
So look it over, see you see any glaring issues. If you do, let me know. Then you can update your answer on my question to that and I'll accept it as correct/give you the bounty. Also, link back to this discussion to show how we arrived at this solution.
 
mnv
2:31 PM
great
 
see any issues?
does it make sense logically?
 
mnv
I has added this solution as new answer, because it looks similar, but here is something new: `entity_lookup`. I save my old answer, because I has tested it. New solution looks correct. But my questions:
1. Why you use `INSERT IGNORE INTO entity_lookup` instead of `INSERT INTO entity_lookup SELECT DISTINCT`. Is it really faster?
2. What about temporary table `entity_lookup` instead of physical table?
 
1. I'm not sure, which one do you think is faster?
2. It takes longer I think to create a temporary table than it does to insert into a myisam table
 
mnv
2:48 PM
1. I dont know, should be tested
 

« first day (11 days earlier)    last day (14 days later) »