Mysql 쿼리에 대해 질문을 하고 계산

0

질문

이 쿼리*,내가 목록을 정렬한 행서"mytableabc"에 의해,위도,경도,다양한 criterias,...에서 가까운 또는 점수의/나열 자료와 난 생각의 좋은/빠른 충분!?

select 
round((6371 * acos(cos(radians('40.123456')) * cos(radians(latitude)) * cos(radians(longtitude) - radians('29.123456')) + sin(radians(latitude)) * sin(radians('40.123456')))), (2)) as distance, 
    (match(colone,coltwo) against('searchkeywordabc' in boolean mode)) as score, 
id,colone,coltwo,latitude,longtitude,colthree 
        from mytableabc 
        where (colone='sampleforsomething') 
            and (match(colone,coltwo) against('searchkeywordabc' in boolean mode))
                having distance <= 5 order by distance asc limit 0,50

--문제

에서 다른 라인 및 파일에만 필요한 총 count(id)의 반환 요소와 같은 criterias... 를 추가하려고 하산(id),하지만 그게 올바른 총 계산 및 또한 목록은 선, 그냥 숫(일반적으로 수 쿼리지)데이터 라인

select 
    count(id), 
round((6371 * acos(cos(radians('40.123456')) * cos(radians(latitude)) * cos(radians(longtitude) - radians('29.123456')) + sin(radians(latitude)) * sin(radians('40.123456')))), (2)) as distance, 
        (match(colone,coltwo) against('searchkeywordabc' in boolean mode)) as score, 
    id,colone,coltwo,latitude,longtitude,colthree 
            from mytableabc 
            where (colone='sampleforsomething') 
                and (match(colone,coltwo) against('searchkeywordabc' in boolean mode))
                    having distance <= 5 order by distance asc limit 0,50

-또한 이 쿼리지 않고 거리/위도/하면 기준은 좋은 작품을 반환,유 총...그러나 나는 필요 거리를 추가하는 쿼리를 이 쿼리

select count(id) from mytableabc where (colone='sampleforsomething') and (match(colone,coltwo) against('searchkeywordabc' in boolean mode))

나는 sql 전문가 네 당신이 볼로 하나가 필요합니다. 감사합니다.

geolocation mariadb mysql php
2021-11-17 21:58:00
1

최고의 응답

0

계획:

이동 distance 체크 WHERE 절입니다. 이에 대한 필요성을 제거 HAVING 필터링하면서 더 많은,그래서 COUNT 지 않을 팽창된다.

select  count(*)
    from  mytableabc
    where  (colone='sampleforsomething')
      and  (match(colone,coltwo) against('searchkeywordabc' in boolean mode))
      AND  (6371 * acos(cos(radians('40.123456')) * 
        cos(radians(latitude)) * cos(radians(longtitude) -
        radians('29.123456')) + sin(radians(latitude)) *
        sin(radians('40.123456')))) < 5;

내가 기대 FULLTEXT index 사용되는 첫째,다른 두 시험(= 그리고 거리)의 확인에 대한 모든 행에서 반환된 FT 검색합니다.

Plan B:

를 계속 사용 HAVING지만,하위. (이것은 아마 느립니다.)

2021-11-18 04:19:40

나는 분석/준 및 계획을 선택합니다. 감사에 대한 빠른 답변
evet

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................