Sorry, but you say " this functionality is not implemented" ?
Here is the piece of testcase demonstrating the above piece of statement you quoted - which confirms that it uses index for expression (json_value) projected from JSON_TABLE clause.
but it is not working only for JSON_EXISTS condition, when projected using JSON_TABLE.
Is that only "json_exists" functionality is not implemented? Kindly advice.
drop table twitter_data1 purge;
create table twitter_data( twit clob
constraint twitter1data_chk
check( twit is json) );
declare
l_sql long;
begin
l_sql := q'# {
"user": {
"notifications": null,
"profile_use_background_image": true,
"statuses_count": 351,
"profile_background_color": "C0DEED",
"followers_count": 48,
"profile_image_url": "http://a1.twimg.com/profile_images/455128973/gCsVUnofNqqyd6tdOGevROvko1_500_normal.jpg",
"listed_count": 0,
"profile_background_image_url": "http://a3.twimg.com/a/1300479984/images/themes/theme1/bg.png",
"description": "watcha doin in my waters?",
"screen_name": "OldGREG85",
"default_profile": true,
"verified": false,
"time_zone": "Hawaii",
"profile_text_color": "333333",
"is_translator": false,
"profile_sidebar_fill_color": "DDEEF6",
"location": "Texas",
"id_str": "##x1##",
"default_profile_image": false,
"profile_background_tile": false,
"lang": "en",
"friends_count": 81,
"protected": false,
"favourites_count": 0,
"created_at": "Tue Oct 06 01:13:17 +0000 2009",
"profile_link_color": "0084B4",
"name": "GG",
"show_all_inline_media": false,
"follow_request_sent": null,
"geo_enabled": false,
"profile_sidebar_border_color": "C0DEED",
"url": "##x2##",
"id": 80177619,
"contributors_enabled": false,
"following": null,
"utc_offset": -36000
},
"id": 54691802283900930,
"coordinates": null,
"geo": null
} #';
insert into twitter_data( twit )
select replace( replace( l_sql, '"##x1##"', object_id ), '"##x2##"', '"'||substr( object_name,1,10)||'"' )
from all_objects
where rownum <=1000;
commit;
end;
/
exec dbms_stats.gather_table_stats(user,'twitter_data',no_invalidate=>false);
demo@PDB1> create index user_id_idx
2 on twitter_data(
3 json_value( twit, '$.user.id_str'
4 returning number
5 error on error
6 null on empty) );
Index created.
demo@PDB1> set autotrace traceonly explain
demo@PDB1> select *
2 from twitter_data
3 where json_value( twit ,'$.user.id_str' returning number) =5;
Execution Plan
----------------------------------------------------------
Plan hash value: 2813084340
----------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 10 | 1150 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID BATCHED| TWITTER_DATA | 10 | 1150 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | USER_ID_IDX | 4 | | 1 (0)| 00:00:01 |
----------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access(JSON_VALUE("TWIT" FORMAT JSON , '$.user.id_str' RETURNING NUMBER ERROR ON
ERROR NULL ON EMPTY)=5)
demo@PDB1> select twitter_data.*
2 from twitter_data ,
3 json_table( twit, '$.user'
4 columns(
5 id_str_val number path '$.id_str' )) t2
6 where t2.id_str_val =5;
Execution Plan
----------------------------------------------------------
Plan hash value: 3095621313
-----------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 81680 | 9173K| 275 (1)| 00:00:01 |
| 1 | NESTED LOOPS | | 81680 | 9173K| 275 (1)| 00:00:01 |
| 2 | TABLE ACCESS BY INDEX ROWID BATCHED| TWITTER_DATA | 10 | 1150 | 2 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | USER_ID_IDX | 4 | | 1 (0)| 00:00:01 |
| 4 | JSONTABLE EVALUATION | | | | | |
-----------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access(JSON_VALUE("TWIT" FORMAT JSON , '$.user.id_str' RETURNING NUMBER ERROR ON
ERROR NULL ON EMPTY)=5)