drop table _tmpXX ; \timing create table _tmpXX as select * from ( select *, (select healpixid from idt_match as m where m.transitid=o.transitid) as x from idt_photoobservation_small as o offset 0 ) as y where x%16=XX order by x;