반응형
ORDER BY RAND() Maria가 아닌 랜덤 행을 가져옵니다.DB
랜덤 행을 선택해야 하는 큰 sql 쿼리를 받았는데 테이블이 크기 때문에 rand()로 주문하는 데 시간이 오래 걸립니다.
$getdata = $this->db->query("
SELECT DISTINCT property.id,property.unid,property.imported,property.userid,
CONCAT(user.firstname) as username,property.url,
IFNULL(user.thumbpic,'temp/misc/noimage.png') as profilepic,
property.bedrooms,property.beds,type.meta_val as type,property.accommodates,property.price,
IFNULL((select thumbimg from tblpropertyimages where pid=property.id limit 1),'temp/misc/noimage.png') as image,
property.name as propertyname,(select sum(rating) from tblreviews where pid=property.id) as totalrating,
(select count(id) from tblreviews where pid=property.id) as countratings,
location.name as cityname from tblproperty as property join tbluser as user on property.userid=user.id
join tblcommon as type on property.type=type.id
left join tblpropertyamenities as p_amenities on property.id=p_amenities.pid
join tbllocation as location on location.id=property.city
WHERE property.status='Active' and user.status='Active'
$home $q limit $limit offset $start");
이 특정 쿼리에 대해 랜덤 행을 선택하는 데 가장 적합한 솔루션은 무엇입니까?
상세한 요건에 따라서는, 보다 고속의 어프로치가 몇개인가 있습니다.아무것도 완벽하지 않지만, 각각의 어프로치가 「충분히 좋다」라고 말할 수 있습니다.
언급URL : https://stackoverflow.com/questions/42330867/get-random-rows-but-not-with-order-by-rand-mariadb
반응형
'itsource' 카테고리의 다른 글
MySQL 외부 키를 사용하여 테이블을 만드는 중 오류 없음: 150 (0) | 2022.09.17 |
---|---|
내 항아리의 명세서 읽기 (0) | 2022.09.17 |
Tensorflow 디버깅 정보 비활성화 (0) | 2022.09.17 |
Github 페이지의 VueJS 앱 공백 페이지 (0) | 2022.09.17 |
PHP가 숫자 문자열에서 쉼표 제거 (0) | 2022.09.17 |