* Table Join 소요시간 (MySQL)
inner join이 self join보다 빠름 : 테이블의 내부검색시(테이블 1개를 2개로 간주)
select a.customized_id, a.value, a.custom_field_id from
(select customized_id, value, custom_field_id from custom_values as a where (custom_field_id = 17 and value = 'AMAT')) as a
inner join
(select customized_id, value, custom_field_id from custom_values as b where (custom_field_id = 1 and value = 'ETCH')) as b
/* 0 rows affected, 38 rows found. Duration for 1 query: 0.016 sec. */
select a.customized_id from custom_values a, custom_values b
where
(a.custom_field_id = 17 and a.value = 'AMAT')
and (b.custom_field_id = 1 and b.value = 'ETCH')
and a.customized_id = b.customized_id
/* 0 rows affected, 38 rows found. Duration for 1 query: 0.124 sec. */
'Programming > Database' 카테고리의 다른 글
MySQL inner join 예제 (0) | 2012.09.07 |
---|---|
MySQL error code (1) | 2012.08.28 |
[펌] MySQL 튜닝 18 가지 (0) | 2012.08.09 |