{"Entry":{"collection":"opclass","key":"class-gin-jsonb_ops","name":"gin/jsonb_ops (class)","aliases":["jsonb_ops","gin/jsonb_ops"],"metadata":{"aliases":["jsonb_ops","gin/jsonb_ops"],"category":"GIN classes","content_hash":"cb75a84ebb54a5cd8244c3c0c593322f1c7ece618d4588d9d3163845d49bea26","derived_content_hash":"18a803fa39e82023e70a064b58293e8ef36294ce8f8513ff7ab73625b0bed080","imported_at":"2026-09-30T00:40:38.54082+08:00","name":"gin/jsonb_ops (class)","name_zh":"","slug":"class-gin-jsonb_ops","summary":"GIN operator class for jsonb; member of jsonb_ops."}},"Definition":{"Collection":"opclass","Key":"class-gin-jsonb_ops","SourceDatabase":"center","Version":"18","SourceTable":"operator_class","SourceKey":"class-gin-jsonb_ops","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"aliases":["jsonb_ops","gin/jsonb_ops"],"class":{"default":"t","family":"jsonb_ops","input_type":"jsonb","key_type":"text","method":"gin","name":"jsonb_ops"},"classes":[{"default":"t","family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","input_type":"jsonb","key_type":"text","method":"gin","name":"jsonb_ops","slug":"class-gin-jsonb_ops","source_oid":""}],"comparison_data":{"attributes":{"default":"t","family":"jsonb_ops","input_type":"jsonb","key_type":"text","method":"gin","name":"jsonb_ops"},"classes":[{"default":"t","family":"jsonb_ops","input_type":"jsonb","key_type":"text","method":"gin","name":"jsonb_ops"}],"kind":"class","operators":[{"family":"jsonb_ops","left_type":"jsonb","method":"gin","operator":"?|(jsonb,_text)","purpose":"search","right_type":"_text","sort_family":"","strategy":"10"},{"family":"jsonb_ops","left_type":"jsonb","method":"gin","operator":"?\u0026(jsonb,_text)","purpose":"search","right_type":"_text","sort_family":"","strategy":"11"},{"family":"jsonb_ops","left_type":"jsonb","method":"gin","operator":"@\u003e(jsonb,jsonb)","purpose":"search","right_type":"jsonb","sort_family":"","strategy":"7"},{"family":"jsonb_ops","left_type":"jsonb","method":"gin","operator":"@?(jsonb,jsonpath)","purpose":"search","right_type":"jsonpath","sort_family":"","strategy":"15"},{"family":"jsonb_ops","left_type":"jsonb","method":"gin","operator":"@@(jsonb,jsonpath)","purpose":"search","right_type":"jsonpath","sort_family":"","strategy":"16"},{"family":"jsonb_ops","left_type":"jsonb","method":"gin","operator":"?(jsonb,text)","purpose":"search","right_type":"text","sort_family":"","strategy":"9"}],"support_functions":[{"family":"jsonb_ops","function":"gin_compare_jsonb(text,text)","left_type":"jsonb","method":"gin","number":"1","result_type":"int4","right_type":"jsonb"},{"family":"jsonb_ops","function":"gin_extract_jsonb(jsonb,internal,internal)","left_type":"jsonb","method":"gin","number":"2","result_type":"internal","right_type":"jsonb"},{"family":"jsonb_ops","function":"gin_extract_jsonb_query(jsonb,internal,int2,internal,internal,internal,internal)","left_type":"jsonb","method":"gin","number":"3","result_type":"internal","right_type":"jsonb"},{"family":"jsonb_ops","function":"gin_consistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal,internal)","left_type":"jsonb","method":"gin","number":"4","result_type":"bool","right_type":"jsonb"},{"family":"jsonb_ops","function":"gin_triconsistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal)","left_type":"jsonb","method":"gin","number":"6","result_type":"char","right_type":"jsonb"}]},"comparison_hash":"936524c55bfb0a8f6e5c074061dfc6bb18482e960e32f5edf582c7408be1b66d","description":["GIN operator class for jsonb; member of jsonb_ops."],"description_zh":"jsonb_ops 是 gin 的运算符类。","description_zh_html":"\u003cp\u003ejsonb_ops 是 gin 的运算符类。\u003c/p\u003e\u003cdl\u003e\u003cdt\u003e名称\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003ejsonb_ops\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e运算符族\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003ejsonb_ops\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e索引访问方法\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003egin\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e默认类\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003e是\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e存储键类型\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e输入类型\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/dd\u003e\u003c/dl\u003e\u003ch3\u003e策略运算符\u003c/h3\u003e\u003ctable\u003e\u003cthead\u003e\u003ctr\u003e\u003cth\u003e策略编号\u003c/th\u003e\u003cth\u003e用途\u003c/th\u003e\u003cth\u003e运算符\u003c/th\u003e\u003cth\u003e左操作数类型\u003c/th\u003e\u003cth\u003e右操作数类型\u003c/th\u003e\u003cth\u003e排序运算符族\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e7\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e搜索\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e@\u0026gt;(jsonb,jsonb)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e9\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e搜索\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e?(jsonb,text)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e10\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e搜索\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e?|(jsonb,_text)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e_text\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e11\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e搜索\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e?\u0026amp;(jsonb,_text)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e_text\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e15\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e搜索\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e@?(jsonb,jsonpath)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonpath\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e16\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e搜索\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e@@(jsonb,jsonpath)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonpath\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003ch3\u003e支持函数\u003c/h3\u003e\u003ctable\u003e\u003cthead\u003e\u003ctr\u003e\u003cth\u003e支持函数编号\u003c/th\u003e\u003cth\u003e实现函数\u003c/th\u003e\u003cth\u003e左操作数类型\u003c/th\u003e\u003cth\u003e右操作数类型\u003c/th\u003e\u003cth\u003e结果类型\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e1\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003egin_compare_jsonb(text,text)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003eint4\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e2\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003egin_extract_jsonb(jsonb,internal,internal)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003einternal\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e3\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003egin_extract_jsonb_query(jsonb,internal,int2,internal,internal,internal,internal)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003einternal\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e4\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003egin_consistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal,internal)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ebool\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e6\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003egin_triconsistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal)\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003ejsonb\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003echar\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003ch3\u003e同版本中文手册节选\u003c/h3\u003e\u003cp\u003e\n   一个索引定义可以为索引的每一列指定一个\u003cem class=\"firstterm\"\u003e操作符类\u003c/em\u003e。\n\u003c/p\u003e\u003cp\u003e\n   操作符类标识该索引在该列上要使用哪些操作符。例如，类型 \u003ccode class=\"type\"\u003eint4\u003c/code\u003e 上的一个 B-树索引会使用 \u003ccode class=\"literal\"\u003eint4_ops\u003c/code\u003e 类；这个操作符类包含对 \u003ccode class=\"type\"\u003eint4\u003c/code\u003e 值进行比较所需的函数。实践中，列数据类型的默认操作符类通常已经足够。之所以存在操作符类，主要是因为对某些数据类型来说，可能存在多种有意义的索引行为。例如，我们可能希望按绝对值排序一种复数数据类型，也可能希望按实部排序。我们可以通过为该数据类型定义两个操作符类，并在创建索引时选择合适的那个来做到这一点。操作符类决定了基础排序顺序（之后还可以通过添加排序选项 \u003ccode class=\"literal\"\u003eCOLLATE\u003c/code\u003e、\u003ccode class=\"literal\"\u003eASC\u003c/code\u003e/\u003ccode class=\"literal\"\u003eDESC\u003c/code\u003e 和/或 \u003ccode class=\"literal\"\u003eNULLS FIRST\u003c/code\u003e/\u003ccode class=\"literal\"\u003eNULLS LAST\u003c/code\u003e 来修改）。\n  \u003c/p\u003e\u003cp\u003e\n   除了默认操作符类之外，还有一些内置操作符类：\n\n   \u003c/p\u003e\u003cp\u003e\n    下面的查询会显示所有已定义的操作符类：\n\n\u003c/p\u003e\u003cp\u003e\u003ca href=\"/zh/docs/18/indexes-opclass.html\"\u003e查看完整中文手册与上下文\u003c/a\u003e。\u003c/p\u003e","facts":[{"label":"Object kind","value":"Operator class"},{"label":"Index AM","value":"GIN"},{"label":"Input type","value":"jsonb"},{"label":"Stored key type","value":"text"},{"label":"Default class","value":"yes"}],"facts_zh":[{"label":"对象种类","value":"操作符类"},{"label":"索引访问方法","value":"GIN"},{"label":"输入类型","value":"jsonb"},{"label":"存储键类型","value":"text"},{"label":"默认操作符类","value":"是"}],"operators":[{"description":"contains","family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","left_type":"jsonb","method":"gin","operator":"@\u003e(jsonb,jsonb)","operator_slug":"op-403e-jsonb-jsonb","purpose":"search","result_type":"bool","right_type":"jsonb","sort_family":"","sort_family_slug":"","strategy":"7"},{"description":"key exists","family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","left_type":"jsonb","method":"gin","operator":"?(jsonb,text)","operator_slug":"op-3f-jsonb-text","purpose":"search","result_type":"bool","right_type":"text","sort_family":"","sort_family_slug":"","strategy":"9"},{"description":"any key exists","family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","left_type":"jsonb","method":"gin","operator":"?|(jsonb,_text)","operator_slug":"op-3f7c-jsonb-_text","purpose":"search","result_type":"bool","right_type":"_text","sort_family":"","sort_family_slug":"","strategy":"10"},{"description":"all keys exist","family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","left_type":"jsonb","method":"gin","operator":"?\u0026(jsonb,_text)","operator_slug":"op-3f26-jsonb-_text","purpose":"search","result_type":"bool","right_type":"_text","sort_family":"","sort_family_slug":"","strategy":"11"},{"description":"jsonpath exists","family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","left_type":"jsonb","method":"gin","operator":"@?(jsonb,jsonpath)","operator_slug":"op-403f-jsonb-jsonpath","purpose":"search","result_type":"bool","right_type":"jsonpath","sort_family":"","sort_family_slug":"","strategy":"15"},{"description":"jsonpath match","family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","left_type":"jsonb","method":"gin","operator":"@@(jsonb,jsonpath)","operator_slug":"op-4040-jsonb-jsonpath","purpose":"search","result_type":"bool","right_type":"jsonpath","sort_family":"","sort_family_slug":"","strategy":"16"}],"related":[{"label":"GIN Index AM","url":"/wiki/indexam/gin/?v=18"},{"label":"jsonb_ops family","url":"/wiki/opclass/family-gin-jsonb_ops/?v=18"},{"label":"jsonb data type","url":"/wiki/type/jsonb/?v=18"},{"label":"text data type","url":"/wiki/type/text/?v=18"}],"release":{"catalog_fingerprint":"deec62e0f0c649d9d0d058ddd0b16bf41afffd569c3fd73949ff0971ce5cabd6","channel":"stable","label":"18.6","major":"18","manual_fingerprint":"fefce9e478eb2afe5e17e869492bbedc67dce23d317f0a5257240113d6496ebc","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[{"paragraphs":["An index definition can specify an operator class for each column of an index.","The operator class identifies the operators to be used by the index for that column. For example, a B-tree index on the type int4 would use the int4_ops class; this operator class includes comparison functions for values of type int4 . In practice the default operator class for the column's data type is usually sufficient. The main reason for having operator classes is that for some data types, there could be more than one meaningful index behavior. For example, we might want to sort a complex-number data type either by absolute value or by real part. We could do this by defining two operator classes for the data type and then selecting the proper class when making an index. The operator class determines the basic sort ordering (which can then be modified by adding sort options COLLATE , ASC / DESC and/or NULLS FIRST / NULLS LAST ).","There are also some built-in operator classes besides the default ones:"],"title":"Operator classes and families"},{"paragraphs":["For these operators, a GIN index extracts clauses of the form accessors_chain == constant out of the jsonpath pattern, and does the index search based on the keys and values mentioned in these clauses. The accessors chain may include . key , [*] , and [ index ] accessors. The jsonb_ops operator class also supports .* and .** accessors, but the jsonb_path_ops operator class does not.","Although the jsonb_path_ops operator class supports only queries with the @\u003e , @? and @@ operators, it has notable performance advantages over the default operator class jsonb_ops . A jsonb_path_ops index is usually much smaller than a jsonb_ops index over the same data, and the specificity of searches is better, particularly when queries contain keys that appear frequently in the data. Therefore search operations typically perform better than with the default operator class.","The technical difference between a jsonb_ops and a jsonb_path_ops GIN index is that the former creates independent index items for each key and value in the data, while the latter creates index items only for each value in the data. [7] Basically, each jsonb_path_ops index item is a hash of the value and the key(s) leading to it; for example to index {\"foo\": {\"bar\": \"baz\"}} , a single index item would be created incorporating all three of foo , bar , and baz into the hash value. Thus a containment query looking for this structure would result in an extremely specific index search; but there is no way at all to find out whether foo appears as a key. On the other hand, a jsonb_ops index would create three index items representing foo , bar , and baz separately; then to do the containment query, it would look for rows containing all three of these items. While GIN indexes can perform such an AND search fairly efficiently, it will still be less specific and slower than the equivalent jsonb_path_ops search, especially if there are a very large number of rows containing any single one of the three index items."],"title":"Specific manual guidance"}],"sections_zh":[{"paragraphs":["一个索引定义可以为索引的每一列指定一个 操作符类 。","操作符类标识该索引在该列上要使用哪些操作符。例如，类型 int4 上的一个 B-树索引会使用 int4_ops 类；这个操作符类包含对 int4 值进行比较所需的函数。实践中，列数据类型的默认操作符类通常已经足够。之所以存在操作符类，主要是因为对某些数据类型来说，可能存在多种有意义的索引行为。例如，我们可能希望按绝对值排序一种复数数据类型，也可能希望按实部排序。我们可以通过为该数据类型定义两个操作符类，并在创建索引时选择合适的那个来做到这一点。操作符类决定了基础排序顺序（之后还可以通过添加排序选项 COLLATE 、 ASC / DESC 和/或 NULLS FIRST / NULLS LAST 来修改）。","除了默认操作符类之外，还有一些内置操作符类："],"title":"操作符类与家族"},{"paragraphs":["对于这些运算符，GIN 索引会从 jsonpath 模式中提取 accessors_chain == constant 形式的子句，并根据其中提到的键和值进行索引搜索。访问器链可以包含 . key、[*] 和 [ index ] 访问器。jsonb_ops 运算符类还支持 .* 和 .** 访问器，而 jsonb_path_ops 运算符类不支持。","虽然 jsonb_path_ops 操作符类只支持带有 @\u003e 、 @? 和 @@ 操作符的查询，但相较于默认操作符类 jsonb_ops ，它具有显著的性能优势。 jsonb_path_ops 索引通常比相同数据上的 jsonb_ops 索引小得多，而且搜索也更有针对性，尤其是在查询中包含数据里频繁出现的键时。因此，搜索操作通常比使用默认操作符类时性能更佳。","jsonb_ops 与 jsonb_path_ops GIN 索引之间的技术差异在于，前者会为数据中的每个键和值分别创建独立的索引项，而后者只会为数据中的每个值创建索引项。 [7] 基本上，每个 jsonb_path_ops 索引项都是该值连同通向该值的键一起计算出的 hash。例如，要索引 {\"foo\": {\"bar\": \"baz\"}} ，会创建一个单独的索引项，其 hash 值中同时纳入 foo 、 bar 和 baz 这三者。因此，查找这一结构的包含查询会得到一次非常精确的索引搜索；但完全没有办法据此找出 foo 是否作为键出现。另一方面， jsonb_ops 索引会分别创建三个索引项来表示 foo 、 bar 和 baz ；然后为了执行包含查询，它会查找包含这三个项的行。尽管 GIN 索引可以相当高效地执行这种 AND 搜索，但它仍然会比等效的 jsonb_path_ops 搜索更不精确、也更慢，尤其是在包含这三个索引项中任意一个的行数非常多时。"],"title":"专题手册说明"}],"signature":"gin/jsonb_ops","source_oid":"","sources":[{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18 English manual: indexes-opclass.html","path":"indexes-opclass.html","sha256":"07de06abf3a2aff2a891a2789def434d9b76705e54d45ca5338dc13451ae2962","url":"/docs/18/indexes-opclass.html"},{"label":"PostgreSQL 18 English manual: catalog-pg-opclass.html","path":"catalog-pg-opclass.html","sha256":"6f131a502f81b813d447e746fc39ee28e5bdfb3ce8e8baea36a71ad0fde78c40","url":"/docs/18/catalog-pg-opclass.html"},{"label":"PostgreSQL 18 English manual: catalog-pg-amop.html","path":"catalog-pg-amop.html","sha256":"e65b90ee78eaf4b4da97ce5b08b972cee2e2660b882ec107be22eca47201f7d1","url":"/docs/18/catalog-pg-amop.html"},{"label":"PostgreSQL 18 English manual: catalog-pg-amproc.html","path":"catalog-pg-amproc.html","sha256":"0a09afbde0ba8da9899bf770b86d8301bee116057b16ebe7db0e4a7fca2e91c6","url":"/docs/18/catalog-pg-amproc.html"},{"label":"PostgreSQL 18 English manual: datatype-json.html","path":"datatype-json.html","sha256":"650162a05b660146b500a205d523374d00aee117a6a6240d30262be51b6e33e5","url":"/docs/18/datatype-json.html"}],"support_functions":[{"family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","function":"gin_compare_jsonb(text,text)","left_type":"jsonb","method":"gin","number":"1","result_type":"int4","right_type":"jsonb"},{"family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","function":"gin_extract_jsonb(jsonb,internal,internal)","left_type":"jsonb","method":"gin","number":"2","result_type":"internal","right_type":"jsonb"},{"family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","function":"gin_extract_jsonb_query(jsonb,internal,int2,internal,internal,internal,internal)","left_type":"jsonb","method":"gin","number":"3","result_type":"internal","right_type":"jsonb"},{"family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","function":"gin_consistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal,internal)","left_type":"jsonb","method":"gin","number":"4","result_type":"bool","right_type":"jsonb"},{"family":"jsonb_ops","family_slug":"family-gin-jsonb_ops","function":"gin_triconsistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal)","left_type":"jsonb","method":"gin","number":"6","result_type":"char","right_type":"jsonb"}],"tables":[{"columns":[{"key":"operator","label":"Operator overload"},{"key":"strategy","label":"Strategy"},{"key":"purpose","label":"Purpose"},{"key":"sort_family","label":"Ordering family"},{"key":"scope","label":"Membership scope"},{"key":"description","label":"Source description"}],"key":"operators","rows":[{"description":"contains","operator":{"text":"@\u003e(jsonb,jsonb)","url":"/wiki/operator/op-403e-jsonb-jsonb/?v=18"},"purpose":"search","scope":"Class input pair","sort_family":"","strategy":"7"},{"description":"key exists","operator":{"text":"?(jsonb,text)","url":"/wiki/operator/op-3f-jsonb-text/?v=18"},"purpose":"search","scope":"Family member","sort_family":"","strategy":"9"},{"description":"any key exists","operator":{"text":"?|(jsonb,_text)","url":"/wiki/operator/op-3f7c-jsonb-_text/?v=18"},"purpose":"search","scope":"Family member","sort_family":"","strategy":"10"},{"description":"all keys exist","operator":{"text":"?\u0026(jsonb,_text)","url":"/wiki/operator/op-3f26-jsonb-_text/?v=18"},"purpose":"search","scope":"Family member","sort_family":"","strategy":"11"},{"description":"jsonpath exists","operator":{"text":"@?(jsonb,jsonpath)","url":"/wiki/operator/op-403f-jsonb-jsonpath/?v=18"},"purpose":"search","scope":"Family member","sort_family":"","strategy":"15"},{"description":"jsonpath match","operator":{"text":"@@(jsonb,jsonpath)","url":"/wiki/operator/op-4040-jsonb-jsonpath/?v=18"},"purpose":"search","scope":"Family member","sort_family":"","strategy":"16"}],"title":"Family operator strategies"},{"columns":[{"key":"number","label":"Support number"},{"key":"left_type","label":"Left type"},{"key":"right_type","label":"Right type"},{"key":"function","label":"Function signature"},{"key":"result_type","label":"Result type"}],"key":"support-functions","rows":[{"function":"gin_compare_jsonb(text,text)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"1","result_type":"int4","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_extract_jsonb(jsonb,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"2","result_type":"internal","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_extract_jsonb_query(jsonb,internal,int2,internal,internal,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"3","result_type":"internal","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_consistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"4","result_type":"bool","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_triconsistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"6","result_type":"char","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}}],"title":"Family support functions"},{"columns":[{"key":"class","label":"Class"},{"key":"input_type","label":"Input type"},{"key":"key_type","label":"Key type"},{"key":"default","label":"Default"}],"key":"classes","rows":[{"class":{"text":"jsonb_ops","url":"/wiki/opclass/class-gin-jsonb_ops/?v=18"},"default":"yes","input_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"key_type":{"text":"text","url":"/wiki/type/text/?v=18"}}],"title":"Classes in this family"}],"tables_zh":[{"columns":[{"key":"operator","label":"操作符重载"},{"key":"strategy","label":"策略"},{"key":"purpose","label":"用途"},{"key":"sort_family","label":"排序家族"},{"key":"scope","label":"成员范围"},{"key":"description","label":"源码说明"}],"key":"operators","rows":[{"description":"包含","operator":{"text":"@\u003e(jsonb,jsonb)","url":"/wiki/operator/op-403e-jsonb-jsonb/?v=18"},"purpose":"搜索","scope":"操作符类输入类型对","sort_family":"","strategy":"7"},{"description":"键存在","operator":{"text":"?(jsonb,text)","url":"/wiki/operator/op-3f-jsonb-text/?v=18"},"purpose":"搜索","scope":"家族成员","sort_family":"","strategy":"9"},{"description":"任一键存在","operator":{"text":"?|(jsonb,_text)","url":"/wiki/operator/op-3f7c-jsonb-_text/?v=18"},"purpose":"搜索","scope":"家族成员","sort_family":"","strategy":"10"},{"description":"所有键均存在","operator":{"text":"?\u0026(jsonb,_text)","url":"/wiki/operator/op-3f26-jsonb-_text/?v=18"},"purpose":"搜索","scope":"家族成员","sort_family":"","strategy":"11"},{"description":"jsonpath 存在性检查","operator":{"text":"@?(jsonb,jsonpath)","url":"/wiki/operator/op-403f-jsonb-jsonpath/?v=18"},"purpose":"搜索","scope":"家族成员","sort_family":"","strategy":"15"},{"description":"jsonpath 匹配","operator":{"text":"@@(jsonb,jsonpath)","url":"/wiki/operator/op-4040-jsonb-jsonpath/?v=18"},"purpose":"搜索","scope":"家族成员","sort_family":"","strategy":"16"}],"title":"家族中的操作符策略"},{"columns":[{"key":"number","label":"支持函数编号"},{"key":"left_type","label":"左侧类型"},{"key":"right_type","label":"右侧类型"},{"key":"function","label":"函数签名"},{"key":"result_type","label":"返回类型"}],"key":"support-functions","rows":[{"function":"gin_compare_jsonb(text,text)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"1","result_type":"int4","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_extract_jsonb(jsonb,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"2","result_type":"internal","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_extract_jsonb_query(jsonb,internal,int2,internal,internal,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"3","result_type":"internal","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_consistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"4","result_type":"bool","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_triconsistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"6","result_type":"char","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}}],"title":"家族支持函数"},{"columns":[{"key":"class","label":"操作符类"},{"key":"input_type","label":"输入类型"},{"key":"key_type","label":"键类型"},{"key":"default","label":"默认值"}],"key":"classes","rows":[{"class":{"text":"jsonb_ops","url":"/wiki/opclass/class-gin-jsonb_ops/?v=18"},"default":"是","input_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"key_type":{"text":"text","url":"/wiki/type/text/?v=18"}}],"title":"本家族的操作符类"}],"zh_from":{"authored_translation":"source-derived-structured-summary","body_sha256":"d83f6842fee5d8bc7c320773e626c24b914684f96258420473dc010104283a37","kind":"same-version-chinese-manual-with-source-derived-structured-summary","manual":{"anchor":"","build_id":107,"extraction":"concept-introduction","fragment_sha256":"dad5545190ebde655fce48dfc13cd02d2863166fac7cf0c2b28b059c9e419ae4","locale":"zh-Hans","page_key":"indexes-opclass.html","source_hash":"cce6c9b1d4fbb418823aa7be2585facae45f45a5f75c43bd26170c1383c2a4b5","source_revision":"unknown:rendered-translation-baseline","translated_from_revision":null,"translation_revision":"git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b","url":"/zh/docs/18/indexes-opclass.html","version":"18"},"runtime_rerun":false,"source_facts_revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}},"ManualEvidence":{"release":{"catalog_fingerprint":"deec62e0f0c649d9d0d058ddd0b16bf41afffd569c3fd73949ff0971ce5cabd6","channel":"stable","label":"18.6","major":"18","manual_fingerprint":"fefce9e478eb2afe5e17e869492bbedc67dce23d317f0a5257240113d6496ebc","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18 English manual: indexes-opclass.html","path":"indexes-opclass.html","sha256":"07de06abf3a2aff2a891a2789def434d9b76705e54d45ca5338dc13451ae2962","url":"/docs/18/indexes-opclass.html"},{"label":"PostgreSQL 18 English manual: catalog-pg-opclass.html","path":"catalog-pg-opclass.html","sha256":"6f131a502f81b813d447e746fc39ee28e5bdfb3ce8e8baea36a71ad0fde78c40","url":"/docs/18/catalog-pg-opclass.html"},{"label":"PostgreSQL 18 English manual: catalog-pg-amop.html","path":"catalog-pg-amop.html","sha256":"e65b90ee78eaf4b4da97ce5b08b972cee2e2660b882ec107be22eca47201f7d1","url":"/docs/18/catalog-pg-amop.html"},{"label":"PostgreSQL 18 English manual: catalog-pg-amproc.html","path":"catalog-pg-amproc.html","sha256":"0a09afbde0ba8da9899bf770b86d8301bee116057b16ebe7db0e4a7fca2e91c6","url":"/docs/18/catalog-pg-amproc.html"},{"label":"PostgreSQL 18 English manual: datatype-json.html","path":"datatype-json.html","sha256":"650162a05b660146b500a205d523374d00aee117a6a6240d30262be51b6e33e5","url":"/docs/18/datatype-json.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"opclass","Key":"class-gin-jsonb_ops","SourceDatabase":"center","Version":"18","Locale":"en","Title":"gin/jsonb_ops (class)","Summary":"GIN operator class for jsonb; member of jsonb_ops.","BodyHTML":"\u003cp\u003eGIN operator class for jsonb; member of jsonb_ops.\u003c/p\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"85be7ee3df471446213dd064718e0a1dc212d2c4b9fa4014abf42fd4ebe19e9f","Payload":{"description":["GIN operator class for jsonb; member of jsonb_ops."],"related":[{"label":"GIN Index AM","url":"/wiki/indexam/gin/?v=18"},{"label":"jsonb_ops family","url":"/wiki/opclass/family-gin-jsonb_ops/?v=18"},{"label":"jsonb data type","url":"/wiki/type/jsonb/?v=18"},{"label":"text data type","url":"/wiki/type/text/?v=18"}],"sections":[{"paragraphs":["An index definition can specify an operator class for each column of an index.","The operator class identifies the operators to be used by the index for that column. For example, a B-tree index on the type int4 would use the int4_ops class; this operator class includes comparison functions for values of type int4 . In practice the default operator class for the column's data type is usually sufficient. The main reason for having operator classes is that for some data types, there could be more than one meaningful index behavior. For example, we might want to sort a complex-number data type either by absolute value or by real part. We could do this by defining two operator classes for the data type and then selecting the proper class when making an index. The operator class determines the basic sort ordering (which can then be modified by adding sort options COLLATE , ASC / DESC and/or NULLS FIRST / NULLS LAST ).","There are also some built-in operator classes besides the default ones:"],"title":"Operator classes and families"},{"paragraphs":["For these operators, a GIN index extracts clauses of the form accessors_chain == constant out of the jsonpath pattern, and does the index search based on the keys and values mentioned in these clauses. The accessors chain may include . key , [*] , and [ index ] accessors. The jsonb_ops operator class also supports .* and .** accessors, but the jsonb_path_ops operator class does not.","Although the jsonb_path_ops operator class supports only queries with the @\u003e , @? and @@ operators, it has notable performance advantages over the default operator class jsonb_ops . A jsonb_path_ops index is usually much smaller than a jsonb_ops index over the same data, and the specificity of searches is better, particularly when queries contain keys that appear frequently in the data. Therefore search operations typically perform better than with the default operator class.","The technical difference between a jsonb_ops and a jsonb_path_ops GIN index is that the former creates independent index items for each key and value in the data, while the latter creates index items only for each value in the data. [7] Basically, each jsonb_path_ops index item is a hash of the value and the key(s) leading to it; for example to index {\"foo\": {\"bar\": \"baz\"}} , a single index item would be created incorporating all three of foo , bar , and baz into the hash value. Thus a containment query looking for this structure would result in an extremely specific index search; but there is no way at all to find out whether foo appears as a key. On the other hand, a jsonb_ops index would create three index items representing foo , bar , and baz separately; then to do the containment query, it would look for rows containing all three of these items. While GIN indexes can perform such an AND search fairly efficiently, it will still be less specific and slower than the equivalent jsonb_path_ops search, especially if there are a very large number of rows containing any single one of the three index items."],"title":"Specific manual guidance"}],"tables":[{"columns":[{"key":"operator","label":"Operator overload"},{"key":"strategy","label":"Strategy"},{"key":"purpose","label":"Purpose"},{"key":"sort_family","label":"Ordering family"},{"key":"scope","label":"Membership scope"},{"key":"description","label":"Source description"}],"key":"operators","rows":[{"description":"contains","operator":{"text":"@\u003e(jsonb,jsonb)","url":"/wiki/operator/op-403e-jsonb-jsonb/?v=18"},"purpose":"search","scope":"Class input pair","sort_family":"","strategy":"7"},{"description":"key exists","operator":{"text":"?(jsonb,text)","url":"/wiki/operator/op-3f-jsonb-text/?v=18"},"purpose":"search","scope":"Family member","sort_family":"","strategy":"9"},{"description":"any key exists","operator":{"text":"?|(jsonb,_text)","url":"/wiki/operator/op-3f7c-jsonb-_text/?v=18"},"purpose":"search","scope":"Family member","sort_family":"","strategy":"10"},{"description":"all keys exist","operator":{"text":"?\u0026(jsonb,_text)","url":"/wiki/operator/op-3f26-jsonb-_text/?v=18"},"purpose":"search","scope":"Family member","sort_family":"","strategy":"11"},{"description":"jsonpath exists","operator":{"text":"@?(jsonb,jsonpath)","url":"/wiki/operator/op-403f-jsonb-jsonpath/?v=18"},"purpose":"search","scope":"Family member","sort_family":"","strategy":"15"},{"description":"jsonpath match","operator":{"text":"@@(jsonb,jsonpath)","url":"/wiki/operator/op-4040-jsonb-jsonpath/?v=18"},"purpose":"search","scope":"Family member","sort_family":"","strategy":"16"}],"title":"Family operator strategies"},{"columns":[{"key":"number","label":"Support number"},{"key":"left_type","label":"Left type"},{"key":"right_type","label":"Right type"},{"key":"function","label":"Function signature"},{"key":"result_type","label":"Result type"}],"key":"support-functions","rows":[{"function":"gin_compare_jsonb(text,text)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"1","result_type":"int4","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_extract_jsonb(jsonb,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"2","result_type":"internal","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_extract_jsonb_query(jsonb,internal,int2,internal,internal,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"3","result_type":"internal","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_consistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"4","result_type":"bool","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}},{"function":"gin_triconsistent_jsonb(internal,int2,jsonb,int4,internal,internal,internal)","left_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"number":"6","result_type":"char","right_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"}}],"title":"Family support functions"},{"columns":[{"key":"class","label":"Class"},{"key":"input_type","label":"Input type"},{"key":"key_type","label":"Key type"},{"key":"default","label":"Default"}],"key":"classes","rows":[{"class":{"text":"jsonb_ops","url":"/wiki/opclass/class-gin-jsonb_ops/?v=18"},"default":"yes","input_type":{"text":"jsonb","url":"/wiki/type/jsonb/?v=18"},"key_type":{"text":"text","url":"/wiki/type/text/?v=18"}}],"title":"Classes in this family"}]}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
