Contoh yang buruk :
SELECT Count(*) FROM pengawas p LEFT JOIN (SELECT * FROM pengawas_periode WHERE periode_id = '2') AS pp ON pp.pengawas_id = p.id LEFT JOIN lencana_pengawas lp ON p.ingin_lencana_pengawas = lp.id LEFT JOIN panlok ON p.panlok_id = panlok.id WHERE 1 = 1 AND p.fc_no_identitas IS NOT NULL AND p.foto IS NOT NULL AND pp.pengawas_id IS NULL AND ( ( Lower(p.nama) LIKE '%a%' OR Lower(lp.singkatan) = 'a' ) OR p.no_identitas = 'a' ) AND p.is_aktif = 1 AND ( p.instansi = '77' OR p.instansi IN( 'Instansi A', 'Instansi B' ) ) AND ( p.ingin_lencana_pengawas = '22' OR p.ingin_lencana_pengawas = '3' ) OR p.id = 'a' ORDER BY p.angkatan ASC, p.created_at ASC;
SELECT Count(*) FROM pengawas p LEFT JOIN pengawas_periode pp ON p.id = pp.pengawas_id AND pp.periode_id = 2 LEFT JOIN lencana_pengawas lp ON p.ingin_lencana_pengawas = lp.id LEFT JOIN panlok ON p.panlok_id = panlok.id WHERE 1 = 1 AND pp.pengawas_id IS NULL AND p.fc_no_identitas IS NOT NULL AND p.foto IS NOT NULL AND ( ( Lower(p.nama) LIKE '%a%' OR Lower(lp.singkatan) = 'a' ) OR p.no_identitas = 'a' ) AND p.is_aktif = 1 AND ( p.instansi = '77' OR p.instansi IN( 'Instansi A', 'Instansi B' ) ) AND ( p.ingin_lencana_pengawas = '22' OR p.ingin_lencana_pengawas = '3' ) OR p.id = 'a' ORDER BY p.angkatan ASC, p.created_at ASC
No comments:
Post a Comment