3월의 할인 혜택은 다음과 같습니다. 인덱스 어드바이저 서비스 2월에 마지막으로 새로 고친 후 발견된 일부 버그를 수정한 후 N1QL용 인덱스 어드바이저 서비스를 계속 개선할 계획입니다(무슨 일이죠?). 일반적으로 다음 유지 관리 릴리스에서 볼 수 있는 Index Advisor의 수정 사항을 이제 매월 사용할 수 있습니다.
누구를 위한 서비스인가요? 언제 사용해야 하나요?
https://index-advisor.couchbase.com/
반복해서 말씀드리지만,
이 서비스는 DBA, 개발자, 아키텍트가 쿼리 성능을 최적화하고 SLA를 충족하는 데 도움이 되는 인덱스 권장 사항을 제공합니다.
이 서비스는 다음과 같은 경우에 유용합니다:
- 읽지 않으려면 인덱스 생성 규칙를 살펴보고, 이를 이해하고, 구현하여 쿼리/질문/워크로드에 적합한 인덱스를 찾아보세요.
- 아직 최신 Couchbase 6.5 서버를 다운로드하고 싶지 않습니다.
- 사용 중입니다. 구형 카우치베이스 버전(버전 5.5,6.0) 쿼리에 적합한 인덱스를 만드는 데 도움이 필요합니다.
- 인덱스에 대한 조언을 생성하고 싶습니다. 버킷을 만들지 않고 또는 스키마 또는 데이터를 업로드합니다.
새로운 기능은 무엇인가요?
카우치베이스 서버 6.5 서버를 다운로드하고 쿼리 워크벤치에서 인덱스 어드바이저를 사용할 수 있는 경우에도, 이 인덱스 어드바이저는 최신 버전(보기 좋은 UI는 없지만 다음과 같은 결함이 수정된 버전)입니다.
1.TTL을 지원하는 인덱스 어드바이저(meta().expiration & meta.cas)
이 개선 사항으로 다음과 같은 쿼리는
|
1 2 3 4 5 |
ADVISE SELECT META().id, META().expiration FROM `travel-sample` WHERE META().expiration = 0 ORDER BY META().id LIMIT 2; |
를 제공하던
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<span style="color: #ff0000">{ "results": [ { "#operator": "Advise", "advice": { "#operator": "IndexAdvice", "adviseinfo": { "recommended_indexes": "No index recommendation at this time: no keyspace found." } }, "query": "SELECT name, META().id\nFROM `travel-sample`\nWHERE META().id > \"g\"\nLIMIT 2;" } ] }</span> |
이제
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<span style="color: #339966">{ "results": [ { "#operator": "Advise", "advice": { "#operator": "IndexAdvice", "adviseinfo": { "recommended_indexes": { "covering_indexes": [ { "index_statement": "CREATE INDEX adv_meta_self_expiration ON `travel-sample`(meta(self).`expiration`)", "keyspace_alias": "travel-sample" } ], "indexes": [ { "index_statement": "CREATE INDEX adv_meta_self_expiration ON `travel-sample`(meta(self).`expiration`)", "keyspace_alias": "travel-sample", "recommending_rule": "Index keys follow order of predicate types: 2. equality/null/missing." } ] } } }, "query": "SELECT META().id, META().expiration\nFROM `travel-sample`\nWHERE META().expiration = 0\nORDER BY META().id\nLIMIT 2;" } </span> <span style="color: #339966">] }</span> |
또는
|
1 2 3 4 5 |
ADVISE SELECT name, META().cas FROM `travel-sample` WHERE type="hotel" ORDER BY META().cas DESC LIMIT 2; |
를 제공했습니다:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<span style="color: #ff0000">{ "results": [ { "#operator": "Advise", "advice": { "#operator": "IndexAdvice", "adviseinfo": { "recommended_indexes": { "indexes": [ { "index_statement": "CREATE INDEX adv_type ON `travel-sample`(`type`)", "keyspace_alias": "travel-sample", "recommending_rule": "Index keys follow order of predicate types: 2. equality/null/missing." } ] } } }, "query": "SELECT name, META().cas FROM `travel-sample` WHERE type=\"hotel\" ORDER BY META().cas DESC LIMIT 2;" } ] }</span> |
이제
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<span style="color: #339966">{ "results": [ { "#operator": "Advise", "advice": { "#operator": "IndexAdvice", "adviseinfo": { "recommended_indexes": { "covering_indexes": [ { "index_property": "ORDER pushdown, LIMIT pushdown", "index_statement": "CREATE INDEX adv_type_meta_self_casDESC_name ON `travel-sample`(`type`,meta(self).`cas` DESC,`name`)", "keyspace_alias": "travel-sample" } ], "indexes": [ { "index_statement": "CREATE INDEX adv_type ON `travel-sample`(`type`)", "keyspace_alias": "travel-sample", "recommending_rule": "Index keys follow order of predicate types: 2. equality/null/missing." } ] } } }, "query": "SELECT name, META().cas\nFROM `travel-sample`\nWHERE type=\"hotel\"\nORDER BY META().cas DESC\nLIMIT 2;" } ] }</span> |
2. 함수 및 배열 술어에 대한 인덱스 키의 순서를 조정하도록 조언합니다.
이 결함으로 인해 이전에 적용했던 규칙이 약간 변경되었습니다:
- 기능 인덱스 키의 규칙을 삭제합니다.
- Add rule “like” in the same position for scenario ” a like “%adv%”.This rule is applicable only when the pattern is of the type “%x”.If it is of the type “x%” the rule does not apply.
- 기능 술어의 인덱스 키는 EQ/in/LE/LT의 순서를 따릅니다.
다음과 같은 쿼리입니다:
|
1 |
advise select * from shellTest where length(a21) <= 3 and c21 = 3 and c22 > 30 |
제공에 사용
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<span style="color: #ff0000">"results": [ { "#operator": "Advise", "advice": { "#operator": "IndexAdvice", "adviseinfo": { "recommended_indexes": { "indexes": [ { "index_statement": "CREATE INDEX adv_c21_c22_length_a21 ON `shellTest`(`c21`,`c22`,length((`a21`)))", "keyspace_alias": "shellTest", "recommending_rule": "Index keys follow order of predicate types: 2. equality/null/missing, 5. less than/between/greater than, 9. function index." } ] } } }, "query": "update shellTest set type=\"left\" where length(a21) < 3 and c21 = 3 and c22 > 30</span> |
이제
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<span style="color: #339966">{ "results": [ { "#operator": "Advise", "advice": { "#operator": "IndexAdvice", "adviseinfo": { "recommended_indexes": { "indexes": [ { "index_statement": "CREATE INDEX adv_c21_length_a21_c22 ON `shellTest`(`c21`,length((`a21`)),`c22`)", "keyspace_alias": "shellTest", "recommending_rule": "Index keys follow order of predicate types: 2. equality/null/missing, 4. not less than/between/not greater than, 5. less than/between/greater than." } ] }</span> <span style="color: #339966">} }, "query": "update shellTest set type=\"left\" where length(a21) <= 3 and c21 = 3 and c22 > 30" } ] } ]</span> |
3. 배열 인덱스 키의 순서를 SATISFIES 조건에서 조정합니다.
- 배열 술어를 SATISFIES 조건의 순서대로 넣습니다.
- SATISFIES의 결합 해제: 공통 용어 가져오기 -> 우선 순위가 가장 낮은 용어 선택 -> (EQ<IN<LE<LT<IS NOT NULL< LIKE)
- 만족스러운 결합의 경우: 우선순위가 가장 낮은 것을 선택합니다.
#2 및 #3 수정 후 새 규칙:
1: 중첩되지 않은 배열의 선행 배열 인덱스입니다,
2: 같음/없음/누락,
3: in,
4: 이하/중간/초과하지 않음,
5: 다음보다 작거나 큼,
6: 선행 키로 파생된 조인 필터,
7: null/누락되지 않음/값이 없습니다,
8: 좋아요,
9: 비정적 조인 술어,
10:부분 지수의 경우 맛,
|
1 2 3 4 |
advise SELECT META(p).id, ARRAY_DISTINCT(IFMISSING(rooms[*].num,[])) FROM shellTest AS p WHERE (guestCode = IFNULL($guestCode, '') OR guestCode = '') AND checkinTime BETWEEN $startTime AND $endTime |
제공에 사용
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<span style="color: #ff0000">"results": [ { "#operator": "Advise", "advice": { "#operator": "IndexAdvice", "adviseinfo": { "recommended_indexes": { "covering_indexes": [ { "index_statement": "CREATE INDEX adv_guestCode_checkinTime_DISTINCT_rooms_level_size_num_array_di1747996179 ON `shellTest`(`guestCode`,`checkinTime`,DISTINCT ARRAY [`s`.`level`, `s`.`size`, `s`.`num`] FOR s in `rooms` END,array_distinct(ifmissing((array_star((`rooms`)).`num`), [])))", "keyspace_alias": "shellTest_p" } ], "indexes": [ { "index_statement": "CREATE INDEX adv_guestCode_checkinTime_DISTINCT_rooms_level_size_num ON `shellTest`(`guestCode`,`checkinTime`,DISTINCT ARRAY [`s`.`level`, `s`.`size`, `s`.`num`] FOR s in `rooms` END)", "keyspace_alias": "shellTest_p", "recommending_rule": "Index keys follow order of predicate types: 1. Common leading key for disjunction (2. equality/null/missing, 4. not less than/between/not greater than, 6. array predicate)." } ] } } }, "query": "SELECT META(p).id, ARRAY_DISTINCT(IFMISSING(rooms[*].num,[])) FROM shellTest AS p WHERE (guestCode = IFNULL($guestCode, '') OR guestCode = '') AND (checkinTime BETWEEN $startTime AND $endTime) AND (ANY s IN rooms SATISFIES [s.level,s.size, s.num] = [$level, $size, $num] END)" </span> |
이제 제공합니다:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<span style="color: #339966">results": [ { "#operator": "Advise", "advice": { "#operator": "IndexAdvice", "adviseinfo": { "recommended_indexes": { "covering_indexes": [ { "index_statement": "CREATE INDEX adv_guestCode_checkinTime_array_distinct_ifmissing_array_star_rooms_num ON `shellTest`(`guestCode`,`checkinTime`,array_distinct(ifmissing((array_star((`rooms`)).`num`), [])))", "keyspace_alias": "shellTest_p" } ], "indexes": [ { "index_statement": "CREATE INDEX adv_guestCode_checkinTime ON `shellTest`(`guestCode`,`checkinTime`)", "keyspace_alias": "shellTest_p", "recommending_rule": "Index keys follow order of predicate types: 1. Common leading key for disjunction (2. equality/null/missing, 4. not less than/between/not greater than)." } ] } } }</span> |
사용해 보시고 인덱스 어드바이저 서비스에서 추천하는 인덱스에 문제가 있는 경우 이 블로그에 댓글로 추가할 수 있습니다.
인덱스 어드바이저 기능에 대해 자세히 알아보세요:
https://www.couchbase.com/blog/index-advisor-service/
https://www.couchbase.com/blog/index-advisor-service-for-couchbase-n1qlfeb-refresh/
https://www.couchbase.com/blog/n1ql-index-advisor-improve-query-performance-and-productivity/
https://www.couchbase.com/blog/index-advisor-for-query-workload/
https://docs.couchbase.com/server/6.5/n1ql/n1ql-language-reference/advise.html
https://docs.couchbase.com/server/6.5/n1ql/n1ql-language-reference/advisor.html
https://docs.couchbase.com/server/6.5/tools/query-workbench.html#index-advisor