CREATE TABLE triples ( subject int(10) NOT NULL default '0', predicate int(10) NOT NULL default '0', object int(10) NOT NULL default '0', assertid text NOT NULL, personid text NOT NULL, isresource tinyint(1) NOT NULL default '0' ); CREATE TABLE resources ( keyhash int(10) NOT NULL default '0', value text not NULL ); ALTER TABLE resources ADD PRIMARY KEY (keyhash); ALTER TABLE triples ADD KEY (subject); ALTER TABLE triples ADD KEY (predicate); ALTER TABLE triples ADD KEY (object); EXPLAIN SELECT DISTINCT b1.value AS dd, b2.value AS mbox, b4.value AS uri, b5.value AS thumb, b7.value AS name FROM triples a1, a2, a3, a4, a5, a6, a7, resources b1, b2, b4, b5, b7 WHERE a1.predicate = '116868652' AND a2.predicate = '116868652' AND a3.predicate = '1547507681' AND a3.object = '1145937192' AND a4.predicate = '1547507681' AND a5.predicate = '1577895888' AND a6.predicate = '-1848367484' AND a7.predicate = '-221079518' AND a1.subject=a3.subject AND a1.object=a2.object AND a2.object=a6.subject AND a6.subject=a7.subject AND a2.subject=a4.subject AND a4.subject=a5.subject AND b1.keyhash=a7.object AND b2.keyhash=a4.object AND b4.keyhash=a7.subject AND b5.keyhash=a6.object AND b7.keyhash=a5.object ; table type possible_keys key key_len ref rows Extra a3 ref subject,predicate,object object 4 const 215 where used; Using temporary a1 ref subject,predicate,object subject 4 a3.subject 12 where used a2 ref subject,predicate,object object 4 a1.object 12 where used a4 ref subject,predicate,object subject 4 a2.subject 12 where used a5 ref subject,predicate,object subject 4 a4.subject 12 where used a6 ref subject,predicate,object subject 4 a2.object 12 where used b2 eq_ref PRIMARY PRIMARY 4 a4.object 1 b5 eq_ref PRIMARY PRIMARY 4 a6.object 1 a7 ref subject,predicate,object subject 4 a6.subject 12 where used b4 eq_ref PRIMARY PRIMARY 4 a7.subject 1 b1 eq_ref PRIMARY PRIMARY 4 a7.object 1 b7 eq_ref PRIMARY PRIMARY 4 a5.object 1