select ra.value, ra.ra_id, q.id as q_id, q.qid , q.parent, q.q, q.type, p.qid as pqid, if($ifstatement,'1','0') as selection , r.rpid from r, ra, q left join q p on q.parent = p.id where r.id = ra.ra_id and r.q in (3,4,5) and ra.q = q.id order by ra.ra_id ASC,selection desc; #### my $bm= DEBUG_Benchmark->new(); $bm->bmStart(); $sth = $dbh->prepare("select ra.value, ra.ra_id, q.id as q_id, q.qid , q.parent, q.q, q.type, p.qid as pqid, if($ifstatement,'1','0') as selection , r.rpid from r, ra, q left join q p on q.parent = p.id where r.id = ra.ra_id and r.q in (3,4,5) and ra.q = q.id order by ra.ra_id ASC,selection desc"); $sth->execute(); $bm->bmStop(); print $bm->getBmResult(); #### value ra_id q_id qid parent q(4,5,6)type pqid selection rpid 1 5501 1918917 34 0 4 6 NULL 1 ed94d62745f52f83cc6225c46cd1f012 1 5501 1918918 33 0 4 6 NULL 1 ed94d62745f52f83cc6225c46cd1f012 4 5501 1918915 32 0 4 6 NULL 1 ed94d62745f52f83cc6225c46cd1f012 2 5501 1918940 31 0 4 6 NULL 1 ed94d62745f52f83cc6225c46cd1f012 6 5501 1918916 30 0 4 6 NULL 1 ed94d62745f52f83cc6225c46cd1f012 ... #### uml: Command line: *** Benchmark *** : Execute: 4.636518 seconds From Apache : *** Benchmark *** : Execute: 12.584603 seconds life: Command line: *** Benchmark *** : Execute: 3.079879 seconds From Apache : *** Benchmark *** : Execute: 3.066677 seconds