Add jsonb_each and sort/hash tests
authorMaciek Sakrejda <[email protected]>
Fri, 7 Mar 2014 01:35:38 +0000 (17:35 -0800)
committerMaciek Sakrejda <[email protected]>
Fri, 7 Mar 2014 01:35:38 +0000 (17:35 -0800)
src/test/regress/expected/jsonb.out
src/test/regress/sql/jsonb.sql

index cb92ad9bb37dbf803cabcfc3fb4264b323024452..f8666e9b9e48e04fb0464e2676616af1113d9738 100644 (file)
@@ -1036,3 +1036,69 @@ select count(*) from testjsonb where j ?& ARRAY['public','disabled'];
     42
 (1 row)
 
+RESET enable_seqscan;
+select count(*) from (select (jsonb_each(j)).key from testjsonb) as wow;
+ count 
+-------
+  4783
+(1 row)
+
+select key, count(*) from (select (jsonb_each(j)).key from testjsonb) as wow group by key order by count desc, key;
+    key    | count 
+-----------+-------
+ line      |   884
+ query     |   207
+ pos       |   203
+ node      |   202
+ space     |   197
+ status    |   195
+ public    |   194
+ title     |   190
+ wait      |   190
+ org       |   189
+ user      |   189
+ coauthors |   188
+ disabled  |   185
+ indexed   |   184
+ cleaned   |   180
+ bad       |   179
+ date      |   179
+ world     |   176
+ state     |   172
+ subtitle  |   169
+ auth      |   168
+ abstract  |   161
+ age       |     2
+(23 rows)
+
+-- sort/hash
+select count(distinct j) from testjsonb;
+ count 
+-------
+   886
+(1 row)
+
+set enable_hashagg = false;
+select count(*) from (select j from (select * from testjsonb union all select * from testjsonb) js group by j) js2;
+ count 
+-------
+   886
+(1 row)
+
+set enable_hashagg = true;
+set enable_sort = false;
+select count(*) from (select j from (select * from testjsonb union all select * from testjsonb) js group by j) js2;
+ count 
+-------
+   886
+(1 row)
+
+select distinct * from (values (jsonb '{}' || ''),('{}')) v(j);
+ j  
+----
+ {}
+(1 row)
+
+set enable_sort = true;
+RESET enable_hashagg;
+RESET enable_sort;
index e7c4b2d2b21b30c6636ab659257c016cc5da720d..408a29b0bb0c8fcb9469d8d0dbd0ec21f24791d6 100644 (file)
@@ -279,3 +279,21 @@ select count(*) from testjsonb where j ? 'public';
 select count(*) from testjsonb where j ?| ARRAY['public','disabled'];
 select count(*) from testjsonb where j ?& ARRAY['public','disabled'];
 
+
+RESET enable_seqscan;
+
+select count(*) from (select (jsonb_each(j)).key from testjsonb) as wow;
+select key, count(*) from (select (jsonb_each(j)).key from testjsonb) as wow group by key order by count desc, key;
+
+-- sort/hash
+select count(distinct j) from testjsonb;
+set enable_hashagg = false;
+select count(*) from (select j from (select * from testjsonb union all select * from testjsonb) js group by j) js2;
+set enable_hashagg = true;
+set enable_sort = false;
+select count(*) from (select j from (select * from testjsonb union all select * from testjsonb) js group by j) js2;
+select distinct * from (values (jsonb '{}' || ''),('{}')) v(j);
+set enable_sort = true;
+
+RESET enable_hashagg;
+RESET enable_sort;