0

친구의 최근 위치 게시물을 찾고 사용자 프로필 데이터와 장소 정보를 얻기 위해 일련의 쿼리를 실행하고 있습니다. 내가 이것을 할 수 있었던 유일한 방법은 800ms 범위를 벤치 마크하는 것으로 보이는 쿼리가 아니라 매우 빠릅니다. 쿼리는 내가 정말 끊은 첫 번째 쿼리는 "친구 하나"입니다입니다 생각이페이스 북 멀티 쿼리의 속도를 높이거나 최적화하는 방법은 없습니까?

{ 
    "posts": "select id,app_id,author_uid,post_id,message,post_id,tagged_uids,page_id,timestamp from location_post where author_uid in (select uid2 from #friends) and timestamp < 1393537146 order by timestamp desc limit 3", 
    "placenames": "select name from page where page_id in (select page_id from #posts)", 
    "friends": "select uid2 from friend where uid1 = me()", 
    "usernames": "select name,uid,pic from user where uid in (select author_uid from #posts)" 
} 

처럼 보이는이 모든 친구를 조회 한 후 최근 게시물을 찾기 위해이를 사용하므로.

모든 최적화 조언 또는 다른 전략을 높이십시오. 이 단지 같은 존재 참조 있기 때문에

+0

--- "나는 정말 끊은 첫 번째 쿼리입니다 생각"당신이 추측을 확인하기 위해 해당 쿼리를 제거하려고 시도 했습니까? – zerkms

+0

제거 할 수 없으며 나머지는 실패합니다. 그들은 서로 독립적이지 않습니다. – Brian

+0

오케이. 첫 번째 만 실행하려 했습니까? 그럼 두 번째 건? – zerkms

답변

0

당신은 적어도 게시물 쿼리 내부의 친구 쿼리를 래핑 수 :

{ 
    "posts": "select id,app_id,author_uid,post_id,message,post_id,tagged_uids,page_id,timestamp from location_post where author_uid in (select uid2 from friend where uid1 = me()) and timestamp < 1393537146 order by timestamp desc limit 3", 
    "placenames": "select name from page where page_id in (select page_id from #posts)", 
    "usernames": "select name,uid,pic from user where uid in (select author_uid from #posts)" 
}