SlideShare a Scribd company logo
JSON caveats
Oracle 12.1
Agenda
1. JSON in relational storage
2. RDMS Configuration
3. Storage
4. Ingestion
5. Retrieval
6. Search
7. Maintenance
8. Fast search
9. Summary
10. Q&A session
JSON in RDBMS
Why
• Consistency (integrity, transaction ACIDity) for storing JSON documents
• Denormalization of complex objects
What
• Logs with responses/requests received/sent during software interaction
• Configuration data, key/value user preferences
• Unstructured or semi-structured complex objects
and please forget about any analytics by JSON fields 
DB configuration
• Install JSON fixes on regular base
• Retain scripts to check old issues – new fixes restores them often
• These patches MUST be installed
1. Patch 20080249: JSON Patch Bundle 1
2. Patch 20885778: JSON Patch Bundle 2
3. Patch 24836374: JSON Patch Bundle 3
Oracle thinks JSON is stable now so no more dedicated JSON Bundle patches!
Fixes are inside ordinal database proactive bundle patches (Doc ID 1937782.1).
Table structure
UCS2
10000
Table structure
BLOB for JSON benefits:
• Twice less space consumption
• less I/O due less space
• No implicit character-set conversion if the database
character set is not AL32UTF8
RFC 4627
Table structure
Constraint works fine but JAVA still fails 
Table structure
Ingestion
• Oracle treats JSON as string – no tailored object type
• Insert works fine
• No option to update a piece of JSON
Ingestion
Ingestion
N, run
with json
strict
with json
lax
with json lax and unique
names without constraints
1 115 121 132 83
2 119 117 142 80
3 119 115 132 91
4 115 110 136 90
5 117 125 138 92
6 122 117 135 90
7 116 117 134 88
8 127 120 142 81
9 115 125 152 80
10 118 114 147 83
AVG 118,3 118,1 139 85,8
Ingestion
Ingestion
N, run
with json
strict with json lax
with json lax and unique
names
without
constraints with cache
1 115 121 132 83 78
2 119 117 142 80 78
3 119 115 132 91 84
4 115 110 136 90 75
5 117 125 138 92 78
6 122 117 135 90 75
7 116 117 134 88 75
8 127 120 142 81 78
9 115 125 152 80 77
10 118 114 147 83 77
AVG 118,3 118,1 139 85,8 77,5
Retrieval
• Extract 1 row with raw JSON data and pass it to application server as is
• Issue SQL statement which extracts 1 row from table and parses it via Oracle
JSON feature
• Create a view which encapsulates JSON treatment and extract a row from the view
Retrieval
Nothing changes
Retrieval
Bad approach – each json_value function parses JSON
again!
The same for .notation!
Retrieval
Storage logic could be encapsulated inside virtual columns
Retrieval
Retrieval
Retrieval
Retrieval
Retrieval
Views
1. Often become non mergable so performance degrades
2. If 2 or more json_table are used exception doesn’t occur but results could be
wrong in aggregate functions. no_merge hint helps sometimes.
3. ORA-600 and ORA-7445 No Data to be read from socket arise in arbitrary
places
4. Count(distinct <field>) fails with ORA-7445 No Data to be read from socket.
Could be fixed by removing group by, adding row_number() over (partition by
<group by fields>) rn and filtering out records where rn <> 1
Search
Search
Search
Separate indexes should be
created for .notation?
Search
Search
Query rewrite
Search
Use index side effect – create JSON validation
ORA-01722: invalid number
Validator 
Search
Multiple columns indexing
Search
Search
Search
Search
Search
. notation is not supported
again!
Search
= 0
2 different tokens
All Oracle text reserved words -
https://docs.oracle.com/database/121/CCREF/cqspcl.htm#CCREF2091
= 1
Search
Search
Search
filter
Anchor Inside one
object
Ingestion
= 0
= 1
Ingestion
= 0
= 1
Ingestion
Execution time: ~125 seconds
Ingestion
Execution time: ~7 seconds
Refresh job execution time: ~4 seconds
Ingestion
Execution time: ~8 seconds
Ingestion
= 0
= 0
= 0
= 0
= 1
TRANSACTIONAL doesn’t work for sections! Only for tokens!
Ingestion
Ingestion
Execution time: ~6 seconds
Maintenance
Pos/prefix columns with JSON data via _JSON like INVOICE_JSON before.
• Create daily checks
1. If you need control JSON format (strict/lax) use dba_tab_columns and
all_json_columns views to check JSON constrains
2. If you need insert performance check dba_lobs to check cache attribute
• Check CONTEXT indexes are in proper state
Maintenance
Provide regular indexes optimization
1. Collect fragmented indexes (estimated row fragmentation)
2. Collect indexes with many deleted rows (estimated garbage size)
3. Run ctx_ddl.optimize_index in FULL mode (SERIAL or PARALLEL)
Conclusion
• JSON is always tradeoff between performance/data treatment convenience/integrity
• Indexing strategy should be checked very careful you use 2 notations especially
• JSON treatment is acceptable in row-per-row scenario
• JSON features are still non-stable
• Oracle fails with JSON more 2 Mb very often
• Current implementation doesn’t look like “document-stored” DB
• Tailored search solutions bring better performance
and we are waiting Oracle 12.2 
Q&A
THANK YOU.
WE ARE HIRING!
Alexander Tokarev
Senior Developer
Ad

Recommended

PPTX
Oracle JSON internals advanced edition
Alexander Tokarev
 
PPTX
Oracle JSON treatment evolution - from 12.1 to 18 AOUG-2018
Alexander Tokarev
 
PPTX
Oracle result cache highload 2017
Alexander Tokarev
 
PPTX
Oracle Result Cache deep dive
Alexander Tokarev
 
PPTX
Apache Solr for begginers
Alexander Tokarev
 
PPTX
P9 speed of-light faceted search via oracle in-memory option by alexander tok...
Alexander Tokarev
 
PPTX
Row Level Security in databases advanced edition
Alexander Tokarev
 
PPTX
Row level security in enterprise applications
Alexander Tokarev
 
PPT
Oracle High Availabiltity for application developers
Alexander Tokarev
 
PPTX
Sql killedserver
ColdFusionConference
 
PDF
Scaling MySQL Strategies for Developers
Jonathan Levin
 
PDF
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Dave Stokes
 
PDF
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
Dave Stokes
 
PDF
MySQL Replication Update - DEbconf 2020 presentation
Dave Stokes
 
PDF
Migration from mysql to elasticsearch
Ryosuke Nakamura
 
PPTX
Confoo 2021 - MySQL Indexes & Histograms
Dave Stokes
 
PDF
Introduction to Mongodb execution plan and optimizer
Mydbops
 
PPTX
cPanel now supports MySQL 8.0 - My Top Seven Features
Dave Stokes
 
PDF
MySQL 8.0 Operational Changes
Dave Stokes
 
PDF
PostgreSQL Advanced Queries
Nur Hidayat
 
PDF
Datacon LA - MySQL without the SQL - Oh my!
Dave Stokes
 
PPTX
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
Dave Stokes
 
PDF
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
Hemant Kumar Singh
 
PDF
Advanced MySQL Query Optimizations
Dave Stokes
 
PDF
Json within a relational database
Dave Stokes
 
PDF
Introduction into MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
PDF
Oracle 12.2 sharding learning more
Leyi (Kamus) Zhang
 
PPTX
MySQL Indexing - Best practices for MySQL 5.6
MYXPLAIN
 
PPTX
BGOUG15: JSON support in MySQL 5.7
Georgi Kodinov
 
PDF
UKOUG Tech14 - Getting Started With JSON in the Database
Marco Gralike
 

More Related Content

What's hot (20)

PPT
Oracle High Availabiltity for application developers
Alexander Tokarev
 
PPTX
Sql killedserver
ColdFusionConference
 
PDF
Scaling MySQL Strategies for Developers
Jonathan Levin
 
PDF
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Dave Stokes
 
PDF
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
Dave Stokes
 
PDF
MySQL Replication Update - DEbconf 2020 presentation
Dave Stokes
 
PDF
Migration from mysql to elasticsearch
Ryosuke Nakamura
 
PPTX
Confoo 2021 - MySQL Indexes & Histograms
Dave Stokes
 
PDF
Introduction to Mongodb execution plan and optimizer
Mydbops
 
PPTX
cPanel now supports MySQL 8.0 - My Top Seven Features
Dave Stokes
 
PDF
MySQL 8.0 Operational Changes
Dave Stokes
 
PDF
PostgreSQL Advanced Queries
Nur Hidayat
 
PDF
Datacon LA - MySQL without the SQL - Oh my!
Dave Stokes
 
PPTX
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
Dave Stokes
 
PDF
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
Hemant Kumar Singh
 
PDF
Advanced MySQL Query Optimizations
Dave Stokes
 
PDF
Json within a relational database
Dave Stokes
 
PDF
Introduction into MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
PDF
Oracle 12.2 sharding learning more
Leyi (Kamus) Zhang
 
PPTX
MySQL Indexing - Best practices for MySQL 5.6
MYXPLAIN
 
Oracle High Availabiltity for application developers
Alexander Tokarev
 
Sql killedserver
ColdFusionConference
 
Scaling MySQL Strategies for Developers
Jonathan Levin
 
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Dave Stokes
 
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
Dave Stokes
 
MySQL Replication Update - DEbconf 2020 presentation
Dave Stokes
 
Migration from mysql to elasticsearch
Ryosuke Nakamura
 
Confoo 2021 - MySQL Indexes & Histograms
Dave Stokes
 
Introduction to Mongodb execution plan and optimizer
Mydbops
 
cPanel now supports MySQL 8.0 - My Top Seven Features
Dave Stokes
 
MySQL 8.0 Operational Changes
Dave Stokes
 
PostgreSQL Advanced Queries
Nur Hidayat
 
Datacon LA - MySQL without the SQL - Oh my!
Dave Stokes
 
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
Dave Stokes
 
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
Hemant Kumar Singh
 
Advanced MySQL Query Optimizations
Dave Stokes
 
Json within a relational database
Dave Stokes
 
Introduction into MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
Oracle 12.2 sharding learning more
Leyi (Kamus) Zhang
 
MySQL Indexing - Best practices for MySQL 5.6
MYXPLAIN
 

Similar to Oracle json caveats (20)

PPTX
BGOUG15: JSON support in MySQL 5.7
Georgi Kodinov
 
PDF
UKOUG Tech14 - Getting Started With JSON in the Database
Marco Gralike
 
PPTX
Starting with JSON Path Expressions in Oracle 12.1.0.2
Marco Gralike
 
PDF
Native JSON Support in SQL2016
Ivo Andreev
 
PPTX
Oracle Database - JSON and the In-Memory Database
Marco Gralike
 
PPTX
Everything That Is Really Useful in Oracle Database 12c for Application Devel...
Lucas Jellema
 
PDF
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
Tammy Bednar
 
PPTX
Php forum2015 tomas_final
Bertrand Matthelie
 
PPTX
Singpore Oracle Sessions III - What is truly useful in Oracle Database 12c fo...
Lucas Jellema
 
PPTX
JSON-SQLServer2016.pptx dgsdgdsgdsgdsgsdgdsgdsg
zmulani8
 
PPTX
MySQL Rises with JSON Support
Okcan Yasin Saygılı
 
PPTX
SQL Server 2016 JSON
Davide Mauri
 
PDF
JSON Support in DB2 for z/OS
Jane Man
 
PPTX
Azure SQL & SQL Server 2016 JSON
Davide Mauri
 
PDF
Store non-structured data in JSON column types and enhancements of JSON
Alireza Kamrani
 
PDF
Json in Postgres - the Roadmap
EDB
 
PDF
MySQL 5.7 + JSON
Morgan Tocker
 
PDF
JSON Processing in the Database using PostgreSQL 9.4 :: Data Wranglers DC :: ...
Ryan B Harvey, CSDP, CSM
 
PDF
Agile Database Development with JSON
Chris Saxon
 
PPTX
What_to_expect_from_oracle_database_12c
Maria Colgan
 
BGOUG15: JSON support in MySQL 5.7
Georgi Kodinov
 
UKOUG Tech14 - Getting Started With JSON in the Database
Marco Gralike
 
Starting with JSON Path Expressions in Oracle 12.1.0.2
Marco Gralike
 
Native JSON Support in SQL2016
Ivo Andreev
 
Oracle Database - JSON and the In-Memory Database
Marco Gralike
 
Everything That Is Really Useful in Oracle Database 12c for Application Devel...
Lucas Jellema
 
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
Tammy Bednar
 
Php forum2015 tomas_final
Bertrand Matthelie
 
Singpore Oracle Sessions III - What is truly useful in Oracle Database 12c fo...
Lucas Jellema
 
JSON-SQLServer2016.pptx dgsdgdsgdsgdsgsdgdsgdsg
zmulani8
 
MySQL Rises with JSON Support
Okcan Yasin Saygılı
 
SQL Server 2016 JSON
Davide Mauri
 
JSON Support in DB2 for z/OS
Jane Man
 
Azure SQL & SQL Server 2016 JSON
Davide Mauri
 
Store non-structured data in JSON column types and enhancements of JSON
Alireza Kamrani
 
Json in Postgres - the Roadmap
EDB
 
MySQL 5.7 + JSON
Morgan Tocker
 
JSON Processing in the Database using PostgreSQL 9.4 :: Data Wranglers DC :: ...
Ryan B Harvey, CSDP, CSM
 
Agile Database Development with JSON
Chris Saxon
 
What_to_expect_from_oracle_database_12c
Maria Colgan
 
Ad

More from Alexander Tokarev (15)

PPTX
Rate limits and all about
Alexander Tokarev
 
PPTX
rnd teams.pptx
Alexander Tokarev
 
PPTX
FinOps for private cloud
Alexander Tokarev
 
PPTX
Graph ql and enterprise
Alexander Tokarev
 
PPTX
FinOps introduction
Alexander Tokarev
 
PPTX
Open Policy Agent for governance as a code
Alexander Tokarev
 
PPTX
Relational databases for BigData
Alexander Tokarev
 
PPTX
Cloud DWH deep dive
Alexander Tokarev
 
PPTX
Cloud dwh
Alexander Tokarev
 
PPTX
Inmemory BI based on opensource stack
Alexander Tokarev
 
PPTX
Oracle InMemory hardcore edition
Alexander Tokarev
 
PPTX
Tagging search solution design Advanced edition
Alexander Tokarev
 
PPTX
Faceted search with Oracle InMemory option
Alexander Tokarev
 
PPTX
Tagging search solution design
Alexander Tokarev
 
PPTX
Data structures for cloud tag storage
Alexander Tokarev
 
Rate limits and all about
Alexander Tokarev
 
rnd teams.pptx
Alexander Tokarev
 
FinOps for private cloud
Alexander Tokarev
 
Graph ql and enterprise
Alexander Tokarev
 
FinOps introduction
Alexander Tokarev
 
Open Policy Agent for governance as a code
Alexander Tokarev
 
Relational databases for BigData
Alexander Tokarev
 
Cloud DWH deep dive
Alexander Tokarev
 
Inmemory BI based on opensource stack
Alexander Tokarev
 
Oracle InMemory hardcore edition
Alexander Tokarev
 
Tagging search solution design Advanced edition
Alexander Tokarev
 
Faceted search with Oracle InMemory option
Alexander Tokarev
 
Tagging search solution design
Alexander Tokarev
 
Data structures for cloud tag storage
Alexander Tokarev
 
Ad

Recently uploaded (20)

DOCX
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
PDF
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
PPTX
arctitecture application system design os dsa
za241967
 
PDF
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
PDF
Complete WordPress Programming Guidance Book
Shabista Imam
 
PDF
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
DOCX
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
PPTX
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
 
PDF
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
PPTX
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
PDF
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
PDF
A Guide to Telemedicine Software Development.pdf
Olivero Bozzelli
 
PPTX
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
PDF
University Campus Navigation for All - Peak of Data & AI
Safe Software
 
PDF
Which Hiring Management Tools Offer the Best ROI?
HireME
 
PDF
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
PPTX
Top Time Tracking Solutions for Accountants
oliviareed320
 
PDF
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
PDF
Best Software Development at Best Prices
softechies7
 
PPTX
declaration of Variables and constants.pptx
meemee7378
 
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
arctitecture application system design os dsa
za241967
 
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Complete WordPress Programming Guidance Book
Shabista Imam
 
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
 
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
A Guide to Telemedicine Software Development.pdf
Olivero Bozzelli
 
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
University Campus Navigation for All - Peak of Data & AI
Safe Software
 
Which Hiring Management Tools Offer the Best ROI?
HireME
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Top Time Tracking Solutions for Accountants
oliviareed320
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
Best Software Development at Best Prices
softechies7
 
declaration of Variables and constants.pptx
meemee7378
 

Oracle json caveats

  • 2. Agenda 1. JSON in relational storage 2. RDMS Configuration 3. Storage 4. Ingestion 5. Retrieval 6. Search 7. Maintenance 8. Fast search 9. Summary 10. Q&A session
  • 3. JSON in RDBMS Why • Consistency (integrity, transaction ACIDity) for storing JSON documents • Denormalization of complex objects What • Logs with responses/requests received/sent during software interaction • Configuration data, key/value user preferences • Unstructured or semi-structured complex objects and please forget about any analytics by JSON fields 
  • 4. DB configuration • Install JSON fixes on regular base • Retain scripts to check old issues – new fixes restores them often • These patches MUST be installed 1. Patch 20080249: JSON Patch Bundle 1 2. Patch 20885778: JSON Patch Bundle 2 3. Patch 24836374: JSON Patch Bundle 3 Oracle thinks JSON is stable now so no more dedicated JSON Bundle patches! Fixes are inside ordinal database proactive bundle patches (Doc ID 1937782.1).
  • 6. Table structure BLOB for JSON benefits: • Twice less space consumption • less I/O due less space • No implicit character-set conversion if the database character set is not AL32UTF8 RFC 4627
  • 7. Table structure Constraint works fine but JAVA still fails 
  • 9. Ingestion • Oracle treats JSON as string – no tailored object type • Insert works fine • No option to update a piece of JSON
  • 11. Ingestion N, run with json strict with json lax with json lax and unique names without constraints 1 115 121 132 83 2 119 117 142 80 3 119 115 132 91 4 115 110 136 90 5 117 125 138 92 6 122 117 135 90 7 116 117 134 88 8 127 120 142 81 9 115 125 152 80 10 118 114 147 83 AVG 118,3 118,1 139 85,8
  • 13. Ingestion N, run with json strict with json lax with json lax and unique names without constraints with cache 1 115 121 132 83 78 2 119 117 142 80 78 3 119 115 132 91 84 4 115 110 136 90 75 5 117 125 138 92 78 6 122 117 135 90 75 7 116 117 134 88 75 8 127 120 142 81 78 9 115 125 152 80 77 10 118 114 147 83 77 AVG 118,3 118,1 139 85,8 77,5
  • 14. Retrieval • Extract 1 row with raw JSON data and pass it to application server as is • Issue SQL statement which extracts 1 row from table and parses it via Oracle JSON feature • Create a view which encapsulates JSON treatment and extract a row from the view
  • 16. Retrieval Bad approach – each json_value function parses JSON again! The same for .notation!
  • 17. Retrieval Storage logic could be encapsulated inside virtual columns
  • 22. Retrieval Views 1. Often become non mergable so performance degrades 2. If 2 or more json_table are used exception doesn’t occur but results could be wrong in aggregate functions. no_merge hint helps sometimes. 3. ORA-600 and ORA-7445 No Data to be read from socket arise in arbitrary places 4. Count(distinct <field>) fails with ORA-7445 No Data to be read from socket. Could be fixed by removing group by, adding row_number() over (partition by <group by fields>) rn and filtering out records where rn <> 1
  • 25. Search Separate indexes should be created for .notation?
  • 28. Search Use index side effect – create JSON validation ORA-01722: invalid number Validator 
  • 34. Search . notation is not supported again!
  • 35. Search = 0 2 different tokens All Oracle text reserved words - https://docs.oracle.com/database/121/CCREF/cqspcl.htm#CCREF2091 = 1
  • 42. Ingestion Execution time: ~7 seconds Refresh job execution time: ~4 seconds
  • 44. Ingestion = 0 = 0 = 0 = 0 = 1 TRANSACTIONAL doesn’t work for sections! Only for tokens!
  • 47. Maintenance Pos/prefix columns with JSON data via _JSON like INVOICE_JSON before. • Create daily checks 1. If you need control JSON format (strict/lax) use dba_tab_columns and all_json_columns views to check JSON constrains 2. If you need insert performance check dba_lobs to check cache attribute • Check CONTEXT indexes are in proper state
  • 48. Maintenance Provide regular indexes optimization 1. Collect fragmented indexes (estimated row fragmentation) 2. Collect indexes with many deleted rows (estimated garbage size) 3. Run ctx_ddl.optimize_index in FULL mode (SERIAL or PARALLEL)
  • 49. Conclusion • JSON is always tradeoff between performance/data treatment convenience/integrity • Indexing strategy should be checked very careful you use 2 notations especially • JSON treatment is acceptable in row-per-row scenario • JSON features are still non-stable • Oracle fails with JSON more 2 Mb very often • Current implementation doesn’t look like “document-stored” DB • Tailored search solutions bring better performance and we are waiting Oracle 12.2 
  • 50. Q&A
  • 51. THANK YOU. WE ARE HIRING! Alexander Tokarev Senior Developer

Editor's Notes

  • #2: One of our projects uses JSON extensively so we have a lot of stuff to share with you . We found quite a few JSON caveats you whether may or not face with in Oracle 12.1. We will cover the best part of issues you could face with starting from a decision to use JSON in Oracle to daily maintenance and will try to advice how to process JSON efficiently. Please pay attention some advices will be useless in Oracle 12.2 especially related to search.
  • #3: We will try to go through full JSON field lifecycle. Please pay attention some of principles being mentioned will not be connected to JSON but without them good DB performance will be impossible. I divided retrieval and search which look similar but the difference will be clear further. Sometimes we will return to plan point because of additional workarounds.
  • #4: Let’s discuss what for do we need JSON in RDBMS These objects is something like tags, questionnaires, documents with many levels of nesting which requires huge number of relational tables. Key idea – avoid extra joins.
  • #5: Please don’t forget about Support – check latest JSON fixes. Without installed patches there a tons of errors: ora-600, no read data from the socket, 2 json_tables don’t work in different session, FORMAT JSON should be mentioned in case of BLOB fields.
  • #6: Let’s decide how we would like to store our JSON. Which table is better? DB encoding is Oracle-recommended AL32UTF8 Let’s add 10000 records in each table and check space consumption. Universal Coded Character Set - ucs
  • #7: So final structure recommended by Oracle is
  • #8: We created a table with BLOB, put but JAVA side failed with number conversion. Let’s add is json constraint to ensure no wrong data in our table.
  • #9: Let’s check in any online JSON validator Why Oracle passes invalid JSON? Is it actually invalid? 50/50 Oracle default is Lax. If you need to be completely sure for any JSON parser use STRICT.
  • #10: If we use . Notation it fails so have to rewrite all json which leads to huge I/O in case of JSON + sophisticated PL/SQL processing in case of JSON more 4000 bytes. If we need update JSON we create small Java utilities which run in our CI tool. It works faster that sql/plsql in Java bulk processing especially.
  • #11: We created perfect looking json table structure and started to ingest our data. Let’s measure just time, without context switches and e.t.c. otherwise we have no time to check all stuff during the presentation. We will use rather simple script. It is slow and let’s omit BULK. Even if we add it the performance is low. At least I state it is low. What the reason? How to defeat it? Let’s remove our constraints we just created to see which one contributes more
  • #12: We have decent speed but it is still an issue. Is it possible to get more? Any ideas? Without bulk, pure sql and obvious stuff?
  • #13: Let me give you a glue What Oracle documentation says about it?
  • #14: So ingestion is twice faster with CACHE and without constraints Frankly speaking we don’t switch off constraint but having known our data we use CACHE for best part of our BLOB intended for JSON. I hope you all have tests of your database structure so add something like it there and discuss with your developers why they didn’t set cache for the particular BLOB
  • #15: Retrieval – extract information from JSON There are many options. The first way is common way before Oracle 12 and it works fine. Let’s consider others 2.
  • #16: The simplest option – use . Notation. Let’s check. Doesn’t work. Let’s add an alias. Doesn’t work as well. Let’s add a check and it works now
  • #17: Let’s try to work with json_value and complex structures .notation doesn’t work with arrays in Oracle 12.1 but does work in Oracle 12.2
  • #19: JSON table looks very promising. Single parsing, a little verbose syntax, arrays work perfect so sounds cool! Isn’t it?
  • #20: Let’s have a look into other example which seems very straighforward We have 2 json_table which takes a lot of effort from CPU We got the result but what’s the price – 2 parse and unreadable sql!
  • #21: Let’s make it simpler – json_table works for the same line so could be used in a such manner We have 2 json_table which takes a lot of effort from CPU
  • #22: So it is the proper way and 1 sql call
  • #23: It is rather hard to show issues with view without showing production data but we collected all issues
  • #24: For sure if there is no index we have full scans which is bad actually. Let’s create the index. Plan is the same. The reason is filter condition
  • #25: So we have to create indexes completely equal to filter conditions and we have them in the plan
  • #26: Let’s check .notation – we should ensure the index is used so we see that it is done internally via JSON_QUERY rather than JSON value so we need to create separate set of indexes.
  • #27: Let’s do it Let’s run and see what we get. What do you think? Exception!!! Once we add the alias the index works fine I hope you knows how these indexes work inside – they are virtual columns where extended statistic is gather but it is another story
  • #28: Nevertheless it is possible to have only 1 index. Once we have it we could use . notation but we make json field more rigid.
  • #29: Creating indexes we could maintain sort of json schema
  • #30: There are 2 options for multiple column indexing. The straightforward and not. Queries are a little bit ugly
  • #31: Let’s try more appropriate way. As we seen for indexes they work using virtual columns. Let’s use the same approach. Once we add columns index them as the ordinal ones.
  • #32: Let’s start the latest case. Which index will be used? What should we do? Let’s move to the next slide.
  • #33: Let’s create an index without dropping others indexes and check all our queries.
  • #34: Even json table as well as others statements and multi-column queries work properly.
  • #35: It sounds very good to be in our slides but for sure there are caveats.
  • #36: How many rows do you expect to see? Let’s have a look into the plan. The plan has CONTAIN which is Oracle Text operator and _ is a placeholder. Moreover _ is a letter delimiter in default lexert that’s why the second query returns 2 row. There is 2 tokens in reverted index. So we should instruct Oracle text to search by whole phrase. The behavior changes from patch to patch. So Oracle full text indexes are rather tricky. There are quite a few of nuances like bitmap index conversion, filter by indexes but it is out of current scope.
  • #37: Let’s play with indexes and json where there is a lot of nested elements. We need to find value = ‘640’ in class type ‘Country’. Please pay attention we have 2 of them.
  • #38: Let’s try to find data by equal queries. All of them return 2 records which looks like or. Oracle textcontains deals with tokens as we know so if it finds a token in a document it is happy. There is no way to fix a a JSON object boundaries. Let’s try to use JSON table. It works. But could we make the search faster?
  • #39: And we have a good plan which limits by tokens and next filter by expression. Moreover we don’t waste time for JSON_TABLE so it is faster from I/O and CPU prospectives
  • #40: Let’s check how data ingestion works with FTS indexes Let’s add a new record. How many record will we see? Zero! Why? JSON indexes are fts so need be refreshed separately. Once we did it we see a record.
  • #41: How to address the issue? Let’s have a look into the dictionary. Let’s fix it. We need to issue replace_metadata mentioning REPLACE METADATA once again. Let’s repeat the query and will see new sync type. I deleted the record with ID 8888888 and repeated insert from previous page. How many records do we get? So the conclusion is if you need to use context indexes after you inserted data you need something else but we discuss it further.
  • #42: Let’s check the performance and run our well know script with intermediary commit. Execution time is huge comparing first execution (about 2 seconds) with json strict and unique identifiers. So the question: which command takes the best part of time if we have a look into database logs? No, it will be other which is invoked before each commit implicitly.
  • #43: Let’s defer index update without inventing a wheel like hand-made job procedures. If we have a look in details it is done by job but the profit is when you drop the index it will be dropped automatically + refresh metadata are in the index itself. One place. So we run the script, it works slowly but definitely better even in conjunction with refresh time.
  • #44: But what to do if we need an access indexed data transactionaly? Oracle does provide something for it. Let’s test. In order to do it drop the index and don’t forget FORCE option otherwise Oracle fails and could live orphan CTXSYS dictionary records. So let’s check how TRANSACTIONAL works. It takes information from Oracle Text staging tables before they come in the reverted index actually but it slow the queries down for sure. Usualy they work 2 times slower when decent volume of data is out of sync. It is instruction how to process CONTAINTS rather than SYNC. We still need it. Please pay attention – there is no COMMIT inside.
  • #45: Let’s ensure we get our records via full text search commands without committing them. Let’s commit records. Nothing helps. But Oracle can’t lie. The conclusion – if you need transactional data access for json data you should invent something by yourself.
  • #46: Transactional option doesn’t work but we would like to have faster insert. Oracle 12 has new feature which works in terms of internals like TRANSACTIONAL i.e. deals with staging tables but with the new ones. In terms of update of the reverted index it works in async mode. It is name STAGE_ITAB. Let’s have a look in details. The first command instructs Oracle a new temporary table should be created with $G prefix equal to inverted index. The next assigns the storage to the new index and creates a job which moves data to the index. What is interesting the job is without a schedule – is invoked taking into account the DB workload. 3rd states data from staging should be moved to reverted index in async mode. Let’s have a look into the dictionary
  • #47: Let’s check how it works using our famous statement. It sounds good regarding we could query after commit without additional sync. For sure we still out of transaction context but still…
  • #49: Context indexes become fragmented. Why? Unfortunately we have no time discussing it but we should have them less fragmented to provide fast search. Serial optimization makes indexes less fragmented but parallel is faster
  • #50: For sure it is our experience but inside DataArt we will use these guidelines further You already seen that proper json reinforced by constraints works slow but without constraints .notation doesn’t work for instance. The safest JSON treatment – extract one row, use json features as json_table, json_exist and etc Oracle json isn’t’ still stable even all patches are installed. ---- We try to use Solr or Elastic even if we have delays. Search speed SLA is more strict that SLA to see fresh data
  • #52: I would like to tell thank you for you time and questions once again. We are going to tell about JSON during DataArt IT talk series so follow us in VK/Facebook and welcome to our team.