menggunakan left join untuk menggantikan not in

Untuk query menggunakan NOT IN koq hasil querynya lama banget ya sampek 10 detik ,, bhe bhe bhe ga berhees dhek rhemek cong !

Q> query yang 10 detik

SELECT * FROM temp_sp WHERE no_temp NOT IN (SELECT no_temp FROM sp WHERE no_temp IS NOT NULL )

Q> query yang 1 detik

SELECT a.* FROM temp_sp a
LEFT JOIN sp b on a.no_temp = b.no_temp
where b.no_temp is null

) Note ::
Dalam pengetesan query menggunakan database yang sama
jumlah row tabel temp_sp : 400
jumlah row tabel sp : 166,119

Published by

saifiahmada

Begin a big Process with a bit trying

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s