SlideShare a Scribd company logo
1 of 150
JSON treatment challenges
FROM ORACLE 12.1 TO 18C
“
”
Oracle Database provides all of the benefits of
SQL and relational databases to JSON data, which
you store and manipulate in the same ways and
with the same confidence as any other type of
database data.
Oracle JSON developer guide
Disclaimer: The contents of this presentation are for informal guidance and discussion purposes only.
Agenda
 JSON in RDBMS
 Configuration
 Storage
 Ingestion
 Retrieval
 Generation
 Maintenance
 Q&A
JSON in RDBMS
Why
 Consistency (integrity, transaction ACIDity)
 complex objects denormalization
What
 Logs
 Configuration data, key/value user preferences
 Unstructured/semi-structured objects
Please forget about JSON-based analytics
DB configuration
 JSON patches on regular base
 sql scripts to check old issues
DB configuration 12.1
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
Proactive bundle patches with JSON fixes - Doc ID 1937782.1
DB configuration 12.2
 Convince DBA to install latest Database Release Update with JSON fixes -
Doc ID 2285557.1
DB configuration 18C
Do not care!
Oracle 18C
RFC 4627 JSON requirements
Encoding
JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.
JSON storage
JSON storage
10000
JSON storage
CLOB = UCS2 => Size = characters count * 2 bytes!
JSON constraints
JAVA processing fails!
JSON constraints
Constraint works fine but JAVA still fails 
JSON constraints
JSON constraints
JSON constraints
JSON constraints
JSON ingestion performance
N, run
with json strict
unique names,
seconds
with json strict,
seconds
with json lax,
seconds
without
seconds
1 132 115 121 83
2 142 119 117 80
3 132 119 115 91
4 136 115 110 90
5 138 117 125 92
6 135 122 117 90
7 134 116 117 88
8 142 127 120 81
9 152 115 125 80
10 147 118 114 83
AVG,
seconds 139 118,3 118,1 85,8
2x performance degradation!
JSON storage
JSON storage
JSON ingestion performance
N, run
with json strict
and unique
names, seconds
with json
seconds
With json strict
and cache,
seconds
with json lax,
seconds
without
seconds
without
constraints
and with
cache
1 132 115 110 121 83 78
2 142 119 110 117 80 78
3 132 119 106 115 91 84
4 136 115 111 110 90 75
5 138 117 109 125 92 78
6 135 122 108 117 90 75
7 134 116 102 117 88 75
8 142 127 105 120 81 78
9 152 115 105 125 80 77
10 147 118 110 114 83 77
AVG,
seconds 139 118 107 118 85 77
Storage recommendations
Data types
 Small values up to 4000 characters – VARCHAR2
 More than 4000 - BLOB
BLOB
 2x less space consumption
 2x less I/O due less space
 No implicit character-set conversion if the database character set is not AL32UTF8
Constraints
 JSON STRICT without unique keys
Columns settings
 CACHE=YES
JSON limitations
 Path length - 4000 bytes
 In-memory JSON length – 32767 bytes max
 sql json functions return value length – 32Kb max
Ingestion
 JSON = string
 Insert works fine
 Update = full rewrite
JSON update
Ingestion nuances
Ingestion nuances
Ingestion nuances
Ingestion nuances
JSON is mentioned nowhere!!!
Ingestion nuances
Ingestion nuances
IS JSON on source = no direct path! Oracle 18 behave the same!
Ingestion nuances
No answer!
Loading from files
Loading from files
Loading from files
Single row only 
Loading from files
Retrieval
 Parse on application server
 SQL Oracle JSON features parsing
 Virtual columns
 Oracle JSON features parsing in views
.Notation
.Notation 18c
.Notation
12.1
12.2
Virtual columns
Virtual columns
Switch Adaptive Optimization off
or
Patch 24563796: WRONG RESULT IN COLUMN VALUE IN 12C should be applied!
Retrieval JSON_TABLE
Retrieval JSON_TABLE 18c
Retrieval
Retrieval
Each JSON_VALUE reparses JSON!
Visible on documents more 4000 characters
In Oracle 12.2 it works fine!
Retrieval Common issues
 Views often become non mergeable
 ORA-600 and ORA-7445 No Data to be read from socket
 COUNT(distinct) = ORA-7445 No Data to be read from socket
 2 or more json_table = wrong results in aggregates
Remediation
 dbms_utility.expand_sql_text + sql plan
 use single json_table
 /*+ NO_MERGE*/ hint
 /*+ NO_QUERY_TRANSFORMATION*/ hint
 materialize JSON - materialize hint
 materialize JSON - by CTAS
 apex_json package + json-to-xml tranformation
Retrieval
Retrieval
Retrieval
Retrieval
Retrieval
Retrieval
Materialize failure
12.1 12.2
Retrieval
Materialized views 12.1
Use 12.2 and later….
Real-time materialized views 12.2
Doesn’t work nowhere 
Real-time materialized views 12.2
18c and later…
Materialized views 18c
No commit!!!
JSON search
JSON search
JSON search
JSON search
JSON search
JSON Validation
ORA-01722: invalid number
Validator 
Multiple field indexes
Multiple field indexes
Multiple field indexes
Multiple field indexes
JSON search
JSON search
12.1
12.2
JSON search
JSON search
JSON search
JSON search
JSON search
JSON search
. notation is not supported again 12.1, 12.2, 18c!
Search quiz 1
= 0
= 1
Search quiz 1
= 1
= 1
Search quiz 1
Search quiz 2
Search quiz 2
Search quiz 2
Search quiz 2
Search quiz 2
Who stolen titles?!
Search quiz 2
Never do when troubleshoot JSON!!!
Search quiz 2
Search quiz 2
Search quiz 2
Search quiz 2
Search quiz 3
Task: find json with value = ‘640’ in class type ‘Country’.
Search quiz 3
Search quiz 3
Search quiz 3
5 steps
Index is used
Search expressions
Filter Anchor
Inside one object
Search quiz 3
3 steps
Search expressions 18c
abs()
boolean()
booleanOnly()
ceiling()
date()
double()
floor()
length()
lower()
number()
numberOnly()
size()
string()
stringOnly()
timestamp()
type()
upper()
Ingestion
Ingestion
= 0
= 1
Ingestion
Ingestion
= 0
= 1
Ingestion
Execution time: ~100 seconds
Ingestion
Ingestion
Ingestion
Execution time: ~10 seconds
Refresh job execution time: ~4 seconds
Ingestion
Ingestion
Execution time: ~8 seconds
Ingestion
= 0
= 0
= 0
= 0
Ingestion
= 1
TRANSACTIONAL doesn’t work with JSON!
Ingestion
$G table recommendations
 Pin $G table in KEEP pool
 Setup stage_itab_max_row – 12.2 only
Ingestion
Standard tables: 5 seconds
$G KEEP pool: 2 seconds
Merge job: 2 seconds
Ingestion with Text Index
3 sessions simultaneously
Sequential processing on DR$INDEXNAME$R! table!
Ingestion with Text Index
Sequential processing on DR$INDEXNAME$R! table!
Split count – 20 000 000 record!
Ingestion with Text Index
Semi-parallel processing on DR$INDEXNAME$R! table!
3x time less locks!
3 rows
Ingestion with Text Index Oracle 12.1
Ingestion with Text Index Oracle 12.1
JSON search Autowarming
Fast search KEEP pool
1. Allocate KEEP pool memory area using DB_KEEP_CACHE_SIZE
2. Pin in KEEP pool properly all:
 DR$ tables
 DR$ indexes
 LOB segments of DR$ tables
3. Set CACHE for DR$ tables
4. Load data in KEEP pool once by stored procedure or do nothing – keep pool will be
populated by itself during queries
5. Be happy with 5x performance boost
Until server reboot 
Extra fast search
Never do it!
Changes will be lost after rebuild!
Extra fast search
Repeat the same for indexes using i_index_clause!
Extra fast search
Extra fast search
Ultra-fast search InMemory option
 Oracle 12.2
 Extended data types should be enabled
 IMMEMORY_EXPRESSIONS_USAGE=ENABLE
 IMMEMORY_VIRTUAL_COLUMNS=ENABLE
 IS JSON check constraint is a must
 The whole table should be marked as INMEMORY
JSON storage InMemory option
 Stores JSON in binary OSON format (32 Kb max)
 Tries to create in-memory virtual columns
 Doesn’t affect json_textcontains operator
Use JSON-based InMemory materialized views instead !
Generation 12.1
Generation 12.1
Generation 12.2 – 18c
Generation 12.2 – 18c
Generation 12.2 – 18c
Generation Big JSONs
Generation
Generation Plain JSON
N, run Concatenation Function UDF function JSON_OBJECT
1 0,156 0,39 0,375 0,187
2 0,188 0,343 0,39 0,203
3 0,156 0,36 0,391 0,203
4 0,171 0,359 0,359 0,188
5 0,156 0,359 0,359 0,219
6 0,172 0,36 0,343 0,204
7 0,188 0,344 0,344 0,204
8 0,156 0,344 0,36 0,188
9 0,172 0,391 0,359 0,203
10 0,172 0,36 0,359 0,188
AVG, seconds 0,17 0,38 0,36 0,20
Overhead, percent
% 15,10
Generation Nested JSON
N, run Concatenation Function UDF function XMLAGG JSON_OBJECT
1 0,328 0,5 0,49 6,047 0,171
2 0,328 0,525 0,52 5,98 0,156
3 0,344 0,526 0,52 5,340 0,156
4 0,344 0,598 0,51 6,015 0,188
5 0,344 0,56 0,55 6,000 0,141
6 0,328 0,65 0,65 6,102 0,156
7 0,344 0,599 0,6 5,894 0,203
8 0,382 0,6 0,6 5,25 0,172
9 0,328 0,687 0,54 5,998 0,156
10 0,328 0,642 0,53 5,97 0,156
AVG, seconds 0,34 0,59 0,55 5,82 0,17
Profit, percent 51,29
Data structure maintenance
 Do not base any checks on DBA_JSON_COLUMNS view!
 Posfix/prefix columns with JSON data via _JSON like INVOICE_JSON
 Create daily checks:
 JSON format (strict/lax)
 Field type (clob/blob/varchar2)
 CACHE option
DBA_JSON_COLUMNS Quiz
NO JSON there!
DBA_JSON_COLUMNS Quiz
The behavior is consistent between 12.1, 12. 2 and 18C!
No data at all!
Data structure maintenance
Data structure maintenance
Data structure maintenance
1. Gather index statistics via CTX_REPORT.INDEX_STAT
2. Collect fragmented indexes - estimated row fragmentation.
3. Collect indexes with many deleted rows - estimated garbage size
4. Run ctx_ddl.optimize_index in FULL mode: SERIAL or PARALLEL
5. Oracle 18C Automatic Background Index Maintenance doesn’t optimize the index
Index optimization
No optimization = up to 10x search performance degradation!
Index optimization
Index optimization
Maintenance
 Check index statuses
 Rebuild the index
Maintenance for STAGE_ITAB option
12.1-12.2
 Enable AUTO_OPTIMIZE option
12.2-18
 If you under 12.2 proper parallelism should be setup via stage_itab_max_parallel
 If you under 12.2 setup how often optimization starts via stage_itab_max_rows
18
 Disable AUTO_OPTIMIZE option
 Use preference stage_itab_auto_opt
Maintenance for STAGE_ITAB option
12.1-12.2
Conclusion
 JSON = tradeoff
 row-per-row scenario is safe
 knowledge of Oracle Text is required
 .notation isn’t production ready
 Only Oracle 18 looks mature
 Dedicated JSON search solutions are faster than Oracle
THANK YOU FOR YOUR TIME!
Alexander Tokarev
Database expert
DataArt
shtock@mail.ru
https://github.com/shtock
https://www.linkedin.com/in/alexander-tokarev-14bab230

More Related Content

What's hot

Data Management vs Data Strategy
Data Management vs Data StrategyData Management vs Data Strategy
Data Management vs Data StrategyDATAVERSITY
 
Denodo Data Virtualization Platform architecture: Data Discovery and Data Gov...
Denodo Data Virtualization Platform architecture: Data Discovery and Data Gov...Denodo Data Virtualization Platform architecture: Data Discovery and Data Gov...
Denodo Data Virtualization Platform architecture: Data Discovery and Data Gov...Denodo
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyJean-François Gagné
 
Distributed SQL Databases Deconstructed
Distributed SQL Databases DeconstructedDistributed SQL Databases Deconstructed
Distributed SQL Databases DeconstructedYugabyte
 
Data Modeling Best Practices - Business & Technical Approaches
Data Modeling Best Practices - Business & Technical ApproachesData Modeling Best Practices - Business & Technical Approaches
Data Modeling Best Practices - Business & Technical ApproachesDATAVERSITY
 
Tuning and Debugging in Apache Spark
Tuning and Debugging in Apache SparkTuning and Debugging in Apache Spark
Tuning and Debugging in Apache SparkPatrick Wendell
 
Introducing the eDB360 Tool
Introducing the eDB360 ToolIntroducing the eDB360 Tool
Introducing the eDB360 ToolCarlos Sierra
 
The Business Glossary, Data Dictionary, Data Catalog Trifecta
The Business Glossary, Data Dictionary, Data Catalog TrifectaThe Business Glossary, Data Dictionary, Data Catalog Trifecta
The Business Glossary, Data Dictionary, Data Catalog Trifectageorgefirican
 
Best practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability TutorialBest practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability TutorialColin Charles
 
From Key-Value to Multi-Model - RedisConf19
From Key-Value to Multi-Model - RedisConf19From Key-Value to Multi-Model - RedisConf19
From Key-Value to Multi-Model - RedisConf19Guy Korland
 
Introduction to Data Engineering
Introduction to Data EngineeringIntroduction to Data Engineering
Introduction to Data EngineeringDurga Gadiraju
 
Oracle Transparent Data Encryption (TDE) 12c
Oracle Transparent Data Encryption (TDE) 12cOracle Transparent Data Encryption (TDE) 12c
Oracle Transparent Data Encryption (TDE) 12cNabeel Yoosuf
 
AWS big-data-demystified #1.1 | Big Data Architecture Lessons Learned | English
AWS big-data-demystified #1.1  | Big Data Architecture Lessons Learned | EnglishAWS big-data-demystified #1.1  | Big Data Architecture Lessons Learned | English
AWS big-data-demystified #1.1 | Big Data Architecture Lessons Learned | EnglishOmid Vahdaty
 
6 3 tier architecture php
6 3 tier architecture php6 3 tier architecture php
6 3 tier architecture phpcefour
 
Necessity of Data Lakes in the Financial Services Sector
Necessity of Data Lakes in the Financial Services SectorNecessity of Data Lakes in the Financial Services Sector
Necessity of Data Lakes in the Financial Services SectorDataWorks Summit
 
Developing Customer Portal with Oracle APEX - A Case Study
Developing Customer Portal with Oracle APEX - A Case StudyDeveloping Customer Portal with Oracle APEX - A Case Study
Developing Customer Portal with Oracle APEX - A Case StudyToronto-Oracle-Users-Group
 
Cloud Data Warehouses
Cloud Data WarehousesCloud Data Warehouses
Cloud Data WarehousesAsis Mohanty
 
Slides: Relational to NoSQL Migration
Slides: Relational to NoSQL MigrationSlides: Relational to NoSQL Migration
Slides: Relational to NoSQL MigrationDATAVERSITY
 
Data Architecture - The Foundation for Enterprise Architecture and Governance
Data Architecture - The Foundation for Enterprise Architecture and GovernanceData Architecture - The Foundation for Enterprise Architecture and Governance
Data Architecture - The Foundation for Enterprise Architecture and GovernanceDATAVERSITY
 

What's hot (20)

Data Management vs Data Strategy
Data Management vs Data StrategyData Management vs Data Strategy
Data Management vs Data Strategy
 
Denodo Data Virtualization Platform architecture: Data Discovery and Data Gov...
Denodo Data Virtualization Platform architecture: Data Discovery and Data Gov...Denodo Data Virtualization Platform architecture: Data Discovery and Data Gov...
Denodo Data Virtualization Platform architecture: Data Discovery and Data Gov...
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash Safety
 
Distributed SQL Databases Deconstructed
Distributed SQL Databases DeconstructedDistributed SQL Databases Deconstructed
Distributed SQL Databases Deconstructed
 
Data Modeling Best Practices - Business & Technical Approaches
Data Modeling Best Practices - Business & Technical ApproachesData Modeling Best Practices - Business & Technical Approaches
Data Modeling Best Practices - Business & Technical Approaches
 
Tuning and Debugging in Apache Spark
Tuning and Debugging in Apache SparkTuning and Debugging in Apache Spark
Tuning and Debugging in Apache Spark
 
Introducing the eDB360 Tool
Introducing the eDB360 ToolIntroducing the eDB360 Tool
Introducing the eDB360 Tool
 
Reliable and Scalable Data Ingestion at Airbnb
Reliable and Scalable Data Ingestion at AirbnbReliable and Scalable Data Ingestion at Airbnb
Reliable and Scalable Data Ingestion at Airbnb
 
The Business Glossary, Data Dictionary, Data Catalog Trifecta
The Business Glossary, Data Dictionary, Data Catalog TrifectaThe Business Glossary, Data Dictionary, Data Catalog Trifecta
The Business Glossary, Data Dictionary, Data Catalog Trifecta
 
Best practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability TutorialBest practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability Tutorial
 
From Key-Value to Multi-Model - RedisConf19
From Key-Value to Multi-Model - RedisConf19From Key-Value to Multi-Model - RedisConf19
From Key-Value to Multi-Model - RedisConf19
 
Introduction to Data Engineering
Introduction to Data EngineeringIntroduction to Data Engineering
Introduction to Data Engineering
 
Oracle Transparent Data Encryption (TDE) 12c
Oracle Transparent Data Encryption (TDE) 12cOracle Transparent Data Encryption (TDE) 12c
Oracle Transparent Data Encryption (TDE) 12c
 
AWS big-data-demystified #1.1 | Big Data Architecture Lessons Learned | English
AWS big-data-demystified #1.1  | Big Data Architecture Lessons Learned | EnglishAWS big-data-demystified #1.1  | Big Data Architecture Lessons Learned | English
AWS big-data-demystified #1.1 | Big Data Architecture Lessons Learned | English
 
6 3 tier architecture php
6 3 tier architecture php6 3 tier architecture php
6 3 tier architecture php
 
Necessity of Data Lakes in the Financial Services Sector
Necessity of Data Lakes in the Financial Services SectorNecessity of Data Lakes in the Financial Services Sector
Necessity of Data Lakes in the Financial Services Sector
 
Developing Customer Portal with Oracle APEX - A Case Study
Developing Customer Portal with Oracle APEX - A Case StudyDeveloping Customer Portal with Oracle APEX - A Case Study
Developing Customer Portal with Oracle APEX - A Case Study
 
Cloud Data Warehouses
Cloud Data WarehousesCloud Data Warehouses
Cloud Data Warehouses
 
Slides: Relational to NoSQL Migration
Slides: Relational to NoSQL MigrationSlides: Relational to NoSQL Migration
Slides: Relational to NoSQL Migration
 
Data Architecture - The Foundation for Enterprise Architecture and Governance
Data Architecture - The Foundation for Enterprise Architecture and GovernanceData Architecture - The Foundation for Enterprise Architecture and Governance
Data Architecture - The Foundation for Enterprise Architecture and Governance
 

Similar to Oracle JSON treatment evolution - from 12.1 to 18 AOUG-2018

Oracle JSON internals advanced edition
Oracle JSON internals advanced editionOracle JSON internals advanced edition
Oracle JSON internals advanced editionAlexander Tokarev
 
Sql server scalability fundamentals
Sql server scalability fundamentalsSql server scalability fundamentals
Sql server scalability fundamentalsChris Adkin
 
JSON in Oracle 18c and 19c
JSON in Oracle 18c and 19cJSON in Oracle 18c and 19c
JSON in Oracle 18c and 19cstewashton
 
Going Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21cGoing Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21cJim Czuprynski
 
SPL_ALL_EN.pptx
SPL_ALL_EN.pptxSPL_ALL_EN.pptx
SPL_ALL_EN.pptx政宏 张
 
An introduction to column store indexes and batch mode
An introduction to column store indexes and batch modeAn introduction to column store indexes and batch mode
An introduction to column store indexes and batch modeChris Adkin
 
Performance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsPerformance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsSerge Smetana
 
SequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational DatabaseSequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational Databasewangzhonnew
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performancerudib
 
12c Database new features
12c Database new features12c Database new features
12c Database new featuresSandeep Redkar
 
SQL Server It Just Runs Faster
SQL Server It Just Runs FasterSQL Server It Just Runs Faster
SQL Server It Just Runs FasterBob Ward
 
Introduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big DataIntroduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big DataGruter
 
XML features in DB2 11 for z/OS
XML features in DB2 11 for z/OSXML features in DB2 11 for z/OS
XML features in DB2 11 for z/OSJane Man
 
Code4Lib 2007: MyResearch Portal
Code4Lib 2007: MyResearch PortalCode4Lib 2007: MyResearch Portal
Code4Lib 2007: MyResearch Portaleby
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Alex Zaballa
 
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New FeaturesAmazon Web Services
 
Codeone18 jdk-incremental-dev6074
Codeone18 jdk-incremental-dev6074Codeone18 jdk-incremental-dev6074
Codeone18 jdk-incremental-dev6074Paul Sandoz
 
MySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMorgan Tocker
 

Similar to Oracle JSON treatment evolution - from 12.1 to 18 AOUG-2018 (20)

Oracle json caveats
Oracle json caveatsOracle json caveats
Oracle json caveats
 
Oracle JSON internals advanced edition
Oracle JSON internals advanced editionOracle JSON internals advanced edition
Oracle JSON internals advanced edition
 
Sql server scalability fundamentals
Sql server scalability fundamentalsSql server scalability fundamentals
Sql server scalability fundamentals
 
JSON in Oracle 18c and 19c
JSON in Oracle 18c and 19cJSON in Oracle 18c and 19c
JSON in Oracle 18c and 19c
 
Going Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21cGoing Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21c
 
SPL_ALL_EN.pptx
SPL_ALL_EN.pptxSPL_ALL_EN.pptx
SPL_ALL_EN.pptx
 
An introduction to column store indexes and batch mode
An introduction to column store indexes and batch modeAn introduction to column store indexes and batch mode
An introduction to column store indexes and batch mode
 
Performance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsPerformance Optimization of Rails Applications
Performance Optimization of Rails Applications
 
SequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational DatabaseSequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational Database
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performance
 
12c Database new features
12c Database new features12c Database new features
12c Database new features
 
SQL Server It Just Runs Faster
SQL Server It Just Runs FasterSQL Server It Just Runs Faster
SQL Server It Just Runs Faster
 
Introduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big DataIntroduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big Data
 
XML features in DB2 11 for z/OS
XML features in DB2 11 for z/OSXML features in DB2 11 for z/OS
XML features in DB2 11 for z/OS
 
Code4Lib 2007: MyResearch Portal
Code4Lib 2007: MyResearch PortalCode4Lib 2007: MyResearch Portal
Code4Lib 2007: MyResearch Portal
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
 
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
 
Codeone18 jdk-incremental-dev6074
Codeone18 jdk-incremental-dev6074Codeone18 jdk-incremental-dev6074
Codeone18 jdk-incremental-dev6074
 
MySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics Improvements
 
11g R2
11g R211g R2
11g R2
 

More from Alexander Tokarev

Open Policy Agent for governance as a code
Open Policy Agent for governance as a code Open Policy Agent for governance as a code
Open Policy Agent for governance as a code Alexander Tokarev
 
Relational databases for BigData
Relational databases for BigDataRelational databases for BigData
Relational databases for BigDataAlexander Tokarev
 
P9 speed of-light faceted search via oracle in-memory option by alexander tok...
P9 speed of-light faceted search via oracle in-memory option by alexander tok...P9 speed of-light faceted search via oracle in-memory option by alexander tok...
P9 speed of-light faceted search via oracle in-memory option by alexander tok...Alexander Tokarev
 
Row Level Security in databases advanced edition
Row Level Security in databases advanced editionRow Level Security in databases advanced edition
Row Level Security in databases advanced editionAlexander Tokarev
 
Row level security in enterprise applications
Row level security in enterprise applicationsRow level security in enterprise applications
Row level security in enterprise applicationsAlexander Tokarev
 
Inmemory BI based on opensource stack
Inmemory BI based on opensource stackInmemory BI based on opensource stack
Inmemory BI based on opensource stackAlexander Tokarev
 
Oracle InMemory hardcore edition
Oracle InMemory hardcore editionOracle InMemory hardcore edition
Oracle InMemory hardcore editionAlexander Tokarev
 
Tagging search solution design Advanced edition
Tagging search solution design Advanced editionTagging search solution design Advanced edition
Tagging search solution design Advanced editionAlexander Tokarev
 
Faceted search with Oracle InMemory option
Faceted search with Oracle InMemory optionFaceted search with Oracle InMemory option
Faceted search with Oracle InMemory optionAlexander Tokarev
 
Tagging search solution design
Tagging search solution designTagging search solution design
Tagging search solution designAlexander Tokarev
 
Oracle Result Cache deep dive
Oracle Result Cache deep diveOracle Result Cache deep dive
Oracle Result Cache deep diveAlexander Tokarev
 
Oracle result cache highload 2017
Oracle result cache highload 2017Oracle result cache highload 2017
Oracle result cache highload 2017Alexander Tokarev
 

More from Alexander Tokarev (20)

Rate limits and all about
Rate limits and all aboutRate limits and all about
Rate limits and all about
 
rnd teams.pptx
rnd teams.pptxrnd teams.pptx
rnd teams.pptx
 
FinOps for private cloud
FinOps for private cloudFinOps for private cloud
FinOps for private cloud
 
Graph ql and enterprise
Graph ql and enterpriseGraph ql and enterprise
Graph ql and enterprise
 
FinOps introduction
FinOps introductionFinOps introduction
FinOps introduction
 
Open Policy Agent for governance as a code
Open Policy Agent for governance as a code Open Policy Agent for governance as a code
Open Policy Agent for governance as a code
 
Relational databases for BigData
Relational databases for BigDataRelational databases for BigData
Relational databases for BigData
 
Cloud DWH deep dive
Cloud DWH deep diveCloud DWH deep dive
Cloud DWH deep dive
 
Cloud dwh
Cloud dwhCloud dwh
Cloud dwh
 
P9 speed of-light faceted search via oracle in-memory option by alexander tok...
P9 speed of-light faceted search via oracle in-memory option by alexander tok...P9 speed of-light faceted search via oracle in-memory option by alexander tok...
P9 speed of-light faceted search via oracle in-memory option by alexander tok...
 
Row Level Security in databases advanced edition
Row Level Security in databases advanced editionRow Level Security in databases advanced edition
Row Level Security in databases advanced edition
 
Row level security in enterprise applications
Row level security in enterprise applicationsRow level security in enterprise applications
Row level security in enterprise applications
 
Inmemory BI based on opensource stack
Inmemory BI based on opensource stackInmemory BI based on opensource stack
Inmemory BI based on opensource stack
 
Oracle InMemory hardcore edition
Oracle InMemory hardcore editionOracle InMemory hardcore edition
Oracle InMemory hardcore edition
 
Tagging search solution design Advanced edition
Tagging search solution design Advanced editionTagging search solution design Advanced edition
Tagging search solution design Advanced edition
 
Faceted search with Oracle InMemory option
Faceted search with Oracle InMemory optionFaceted search with Oracle InMemory option
Faceted search with Oracle InMemory option
 
Tagging search solution design
Tagging search solution designTagging search solution design
Tagging search solution design
 
Oracle Result Cache deep dive
Oracle Result Cache deep diveOracle Result Cache deep dive
Oracle Result Cache deep dive
 
Oracle result cache highload 2017
Oracle result cache highload 2017Oracle result cache highload 2017
Oracle result cache highload 2017
 
Apache Solr for begginers
Apache Solr for begginersApache Solr for begginers
Apache Solr for begginers
 

Recently uploaded

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 

Recently uploaded (20)

Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 

Oracle JSON treatment evolution - from 12.1 to 18 AOUG-2018

Editor's Notes

  1. Hello, guys. My name is Alex and we are going to discuss JSON processing today. Just a small survey who has oracle json features in production? Have you ever faced with strange json parsing results? Perfect. It means the presentation will help you.
  2. There are a lot of blogs which state that json is extremely powerful and seamlessly integrated inside the Oracle database. Nevertheless the best part of their experience is based on checking New features section of Oracle JSON guide manual. Today I’ll share pure production experience, challenges and how we addressed them implementing various projects with Oracle database full of JSON treatment. It is our experience but we suspect you will face same issues as we did.
  3. Let’s start from the ground up. We discuss what for do we need JSON in a database, how to configure it, store and process. We will touch JSON maintenance which is crucial for stable database performance. For sure I’ll answer your question in Q&A session. Actually, json treatment and performance tuning are extremely volumetric so I’m going to implement sort of master class full of technical details further. So, let’s start
  4. Because all operation are consistent and there is a wiliness to denormalize complex objects. Which are these objects we’re talking about. Logs, configuration, complex structured or semistructured objects are the best candidates to be stored in JSON. And do not think about analytics on pure JSON data
  5. If you would like to have stable json processing install json fixes Do regression because json issues resurrects often
  6. If you’re under 12.1 3 patches must be installed otherwise JSON processing doesn’t work in predictable fashion at all. Otherwise consider the document with latest JSON patches.
  7. If you’re under 12.2 json fixes could be found in release updates
  8. And we could not care about patches in 18c for now at least
  9. Rfc 4627 dictates how JSON should be encoded.
  10. In order to check how it affects database efficiency let’s create 3 tables with varchar, clob and blob fields and populate all of them
  11. And populate the tables by 10000 equal jsons
  12. As we could see clob storage occupies 2x more space. It happens because clobs are stored in ucs2 so 2 bytes for 1 character is required so it is recommended to store blob whenever it is possible. That’s about disk space.
  13. Let’s discuss constraints. Assume we have a JSON which fails during processing by JAVA application.
  14. Let’s add IS JSON constraint to ensure JSON is valid. Inserts with bad JSON fails so the previous json is valid What’s the reason of java failure?
  15. If we check JSON in a json validator we see figure don’t have leading values so json isn’t valid actually but Oracle tells it is valid. Where is the truth?
  16. The answer could be found in the documentation. Default Oracle check is LAX which isn’t severe for json data type If you want be completely sure that your JSON is valid use JSON STRICT clause explicitly.
  17. Let’s try to enable constraint with more and more severe limitations in order to get how they influence on ingestion performance.
  18. And measure what time is required to add 10000 different records in a table with BLOB field
  19. So it is clearly seen json constraints could introduce twice overhead in a worst case for ingestion performance. Could we make our insert statements faster? Yes, we could.
  20. In order to get how we should look into user_lob view. What is bad here?
  21. Exactly. If we would like fast inserts we need use YES value to not bypass the buffer cache.
  22. If we summarize CACHE brings 10% of performance profit.
  23. We recommend you our configuration for JSON storage. It provides decent performance and reliable json in-database validation We use both blob and varchar2 Because blob doesn’t consume much space and is rather fast We use json strict constraints and cache option set to Yes
  24. There is a lot of JSON limitations in Oracle but we could neglect them. They are mostly about maximum JSON field name length, json path length and levels of array nesting. There is only one annoying limitation – sql json functions can’t return more than 32 kbytes. Moreover you have to enable extended varchar2 datatype explicitly to achieve it.
  25. What’s about ingestion? Oracle treats json as string so insert works fine but is very complicated to update data inside of json documents. We use 12.1 now so we use JAVA to update data inside of JSON even for data migration scripts. It is much faster that PL/SQL hand-made JSON parsing and piece-by-piece updates.
  26. As I told we could change json only in plsql. We could do it rather simple. Create an object from textual representation, upsert new fields and remove some useless. Once we do it we deserialeze JSON into a string again for further usage.
  27. Let’s simulate ETL-loading pipeline which transfers JSON data In order to do it we create source table with json check constraint and populate by random data
  28. Let’s populate a target table from the source one. We have APPEND hint and we see direct path insert which is fine.
  29. Let’s add a json constraint into destination table Once we add it our direct path insert goes nuts Json checks are complicated enough so it is more or less clear but it isn’t mentioned in the documentation at all
  30. Let’s make the case more complicated
  31. Let’s drop the constrain which screws up direct path insert and assume that we need an arbitrary WHERE clause for our insert into the destination table Let’s have a look into the plan. The direct path insert hasn’t returned back even though we dropped the constraint. Why WHERE clause kill direct path insert?
  32. hat we need to do is to drop IS JSON constraint in a SOURCE table. The main point here that if you have IS JSON constraints they could kill direct path insert in arbitrary moment of time.
  33. Why? Actually no ideas. Even tracing for direct path decision didn’t give any results.
  34. If we want to load a json data from a file we should do some action before like create directory and create the file. Let it be a file with 2 rows in accordance with the documentation.
  35. Let’s select data from our file using BFILENAME clause. The construction looks extremely simple but how many records do you expect to see? You will see only one recor Why?
  36. I did some tests and let me share so conlclusion I came up with. the result is the json_table treats the file as a huge single json so the file should look like an array of json objects Once you use such format our query returns 2 rows as expected
  37. There are many options for json retrieval and parsing Extract 1 row with raw JSON data and pass it to application server as is Parse by oracle feature Use virtual columns Parse in a view which hide complexity of parsing The first one is valid before oracle 12 so let’s stick to others one
  38. Oracle has simplified syntax for json. We could select id of menu. Looks very simple but doesn’t work. .notation works only if check constraints are defined. When we have them in place the parsing works perferct.
  39. 18c doesn’t require constraint but treat as json must be added before
  40. .notation can’t works with arrays in 12.1 but is in a good shape in 12.2
  41. It is possible to use virtual columns for json retrieval. You could use embedded sql functions or your own plsql functions.
  42. But if you would like to play with them on production you should disable adaptive optimization of install the patch which fixes virtual columns issues
  43. Json_table feature permits to parse very complex JSON structure in a way close to XMLTABLE.
  44. Oracle 18c permits even do not care about verbose json path expressions but use .notation as well
  45. When you deal with messages from integration buses you could get rather strange JSONs which could be not parsable. I would recommend always use single quotes for your json path otherwise you have to face with reserved word issues overtime
  46. I wouldn’t recommend you to use many json_value or json_exist or json_query functions in one query because each of them parses JSON once again. If you have small documents it doesn’t bring any disturbance but once you have documens more 4 Kb it is annoying so try to use json_table from the beginning. Oracle 12.2 has an optimizer transformation which tries to rewrite many json functions call to a single json_table function
  47. Frankly speaking JSON_TABLE is full of issues because of LATERAL internals so if you work with json extensively you probably noticed that: Json statement tends to make sql non-mergeable which leads to performance detioration Arbitrary ora-600 and No data to be read from socket Bad count distinct processing And even wrong mixed results if there are more than 2 json_table in one query What is good in case of ora-600 and no data read oracle creates core dump and incedent file with stack trace which we could investigate and open SR.
  48. Let me suggest you remediation steps ordered by their power Identify issue by expand_sql_text and sql_plan access and filter predicates first Try to use one json_table for the query When results are mixed use no-_merge or no_query_transformation hints. The latest one fixes the best part of issues for queries with joins Materialize json parsing by materialize hint or by create table as select. The hint works more or less fine starting from oracle 12.2 Use apex_json package which transforms data to xml that is error-prone enough
  49. It could give you a glue how Oraclre rewrote the query.
  50. We could see here that Oracle added extra erroneous condition into JSON_TEXTCONTAINT function
  51. Always pay attention to full text search access predicates – it happens often they are not relevant to actual search condition
  52. We could simulate DISTINCT clause via analytical function so the query doesn’t fail with No data to be read from the socket error.
  53. It is clear how to use no_merge
  54. Or no_query_transformation hints
  55. As I told materialize doesn’t work in 12.1 but provides even in-memory cursors for JSON during temporary table materialization
  56. And the worst case – transform json to XML via apex_json and parse xml
  57. Json parsing complexity could be hidden in materialized views nevertheless when we try to create fast refresh matviews in Oracle 12.1 we will face the issue even though materialized view log is created properly
  58. When we try to play with ON DEMAND views to no depend from commit statements and do not deal with stale results we have An error. It doesn’t work neither 12.2 nor 18c
  59. Oracle introduced new materialized view type ON STATEMENT which doesn’t requires mat view logs, are not depended from COMMIT clause but they do not work with JSON either
  60. Oracle 18c fixed issues and we needn’t any commits to see fresh data
  61. If you need fast search you need indexes. Please be careful with JSON FILTER clause. Indexes should use it. When you create ordinal indexes please be careful with index expressions. They should be equal to expressions in filter clause.
  62. Once we have it indexes work fine
  63. A small question – which of indexes will be used by .notation? Exactly – it neglects indexes.
  64. If we try to create the index as is we will face the error but once we add an alias in the index we have it working fine. Does it mean that we should create a separated set of indexes do deal with .notation?
  65. We could make it working even with ordinal indexes but we have to use error or error clause. It is bad actualy because it kills schema-less features of json.
  66. But it could be sort of validation. If we created error on error index and try to insert some data which doesn’t fit it we get an oracle exception which is free JSON validator
  67. If we need index many fields it works but as you see the syntax is over-verbose as for create index
  68. As well as for queries
  69. So we should consider virtual columns indexing
  70. So we should consider virtual columns indexing But don’t forget about patch for virtual columns I mentioned before please
  71. So let’s try to gess which of indexes will be used for JSON table. The answer is no indexes will be used – JSON table works with ordinal indexes in very reluctant fashion. In accordance with the manual it should work with ERROR ON ERROR indexes but it doesn’t work mostly.
  72. In order to provide ad-hoc queries oracle suggests using context indexes with JSON section. Oracle 12.2 hides it via new syntax but they are equal internally
  73. They are mostly used with json_textcontains function which rewrites json path to ordinal oracle contains function internaly
  74. They work perfect for json_value
  75. Json_exists
  76. Morevover multi-columns search works fine
  77. And even json_table works properly
  78. There is only one exception. Which one? Exactly. .notation is not supported
  79. It seems that it is a little bit boring part so let’s have a quiz We have a json from rs 485 devices. If we try to identify these JSONs we see that they can’t be found. When we search by keywords we find these records successfully
  80. If we look into index table with tokens we will see that the protocol consists from 2 tokens so we need to tell Oracle index we should treat protocol name as whole word or just escape underscore mark
  81. There is a bunch of reserved words and characters you should be aware if you deal with Oracle indexes and json
  82. Let’s imagine we have json about cartoons with 3 sentences and a full text index based on it
  83. When we search by a whole sentence we find it succesfuly
  84. When we search Mr Jerry cartoons we find all sentences
  85. The same is for Ms Jerry
  86. The reason that there is no title in the token tables
  87. Let’s try to figure it out. We need to extract index DDL first. But do not use get_ddl for full text search indexes
  88. Use ctx_report.create_index_script instead. You will see a stoplist which is a set of word to not be parsed. All titles are there.
  89. In order to fix we should drop the index, create empty stoplist and use it in index create script
  90. So we see that we find the whole sentence, Mr Jerry and Ms Jerry in proper single rows
  91. Moreover we see titles in token list
  92. I think it is the latest quiz for search. You need to find records where we have class type Country and 640 in a single json object so only first json should be found
  93. Let’s try to solve by an obvious way – it doesn’t work because works with JSON as a string rather than object collection
  94. If we use json_table we could parse json as a row so filter works fine
  95. But is requires 5 steps. What is good – index is used
  96. In order to solve such issues Oracle introduced JSON search expressions which permit filtering on different objects level.
  97. For json search expression 3 steps is enough
  98. Oracle 12-18 permits to add functions call after JSON path expression now. The best part of them is for data conversion only but some of them could be very usefull and permit to implement less verbose code. For instance array size could be calculated without significant efforts.
  99. Let’s investigate how search indexes affect ingestion performance and their transaction scope
  100. If we search data just after insert statement we will fine nothing so we have to call sync procedure manualy
  101. Let’s setup the index as refresh on commit
  102. It works perfect but brings some performance overhead Let’s measure which one.
  103. It takes 100 second to insert 10000 records. Try to guess which operation will be in the most time consuming here? Actually no. If we have a look into awr report we will see a stored procedure which is invoked after commit statement in a shadow mode.
  104. We could setup index update schedule. For instance 1 hour.
  105. It is implemented as simple job which could be found in index and scheduler metadata.
  106. So it takes 10 second to load data and 5 to refresh the index
  107. There is an option which permits to use context indexes in transaction scope
  108. Insert works fast but let’s try to search
  109. None of search doesn’t work.
  110. But if you use simple CONTAINS without JSON features it starts working. It works 2 times slower but it works. So if you need transactional access for your json data you should invent something by yourself.
  111. If we would like to have even faster insert we should use stage_itab option. It create $G table which is separated from main index tables
  112. It should be kept in KEEP pool in accordance with Oracle recommendations If you have 12.2 you could control the size of the table to not consume all keep pool size. When given boundaries are reached data is moved to $I table
  113. ITAB works very fast, 5 seconds without any tweak 2 seconds after keep pool And a merge job from G to I table works for 2 seconds
  114. If your application inserts data in many threads you will face with concurrency due of user locks
  115. It happens that Oracle locks exclusively a table for reverse index lookup which consists from 1 row by default. A new row is added if it exceeds 20 000 000 records.
  116. In order to not have such huge locks SMALL_R_ROW property should be enable. It is an instruction to Oracle split rows after 35000 records exceeded. When we enable such option we receive 3 times less locks usually.
  117. If we try to do it in 12.1 we get an exception because it isn’t documented
  118. In order to use small_r_row in 12.1 please set the event before index script
  119. When you have full text search indexes and have a look into AWR report top statements by executions it is very likely you see statements to have all tokens in buffer cache. Oracle has an internal algorithm how to warm cache but it isn’t enough to provide very fast search.
  120. One of the options is to put full text search index tables in keep pool. You need allocate keep pool memory Pin DR tables, indexes and lob segment Set CACHE for DR tables and populate keep pool It gives 5 times performance boost usualy
  121. Never try to pin DR$ tables via ALTER commands otherwise settings will disappear after index rebuild.
  122. Keep pool settings should be setup via properties _TABLE_CLAUSE for all you DR tables
  123. If we do it via properties keep pool settings are intact after rebuild
  124. If you would like implement a loading stored procedure the example is on the slide Please pay attention on the first command. If we don’t use it Oracle bypasses shared pool via direct path read. Don’t forget to load BLOB data, otherwise they will be out of keep pool. In order to preload data into keep pool I would recommend create a generic stored procedure which does a set of actions mentioned on slides
  125. You could put your JSON in memory by doing setup steps above
  126. Which encourage Oracle to store JSON in binary format. but what we’ve seen it works good when virtual columns are created and materialized into in-memory virtual columns. We haven’t seen a significant benefit of array parsing by In-Memory engine. We would recommend use JSON-based materialized views instead.
  127. In oracle 12.1 we had to populate JSON by sqll. For plain structures concatenation is used and listadd for nested strucures
  128. You could use plsql functions which do concatenation as well
  129. Oracle 12.2 and later significantly simplified JSON generation introducing dedicated functions
  130. Oracle 12.2 and later significantly simplified JSON generation introducing dedicated functions Why do I have rownum <= 5? If I don’t it will fail with Even if you enable extended data types you are not permitted to return json more than 32Kb
  131. It isn’t fixed in Oracle 18 as well. Returning CLOB clause doesn’t work.
  132. There is only 1 workaround – dirty games with XML and manual concatenation
  133. The most interesting question for me is what is faster – concatenation or embedded functions. In order to measure it let’s collect full fetch time for all cases
  134. So when we create plain json an overhead from embedded json functions is about 15%
  135. When we create nested json embedded functions are extremely efficient but if we need big json xmlagg approach works rather slow.
  136. As I told before we need some housekeeping. Do not base in on DBA_JSON_COLUMNS. It could contains not all JSON columns or brings extra data That’s why just prefix your json fields. Create daily checks for strict/lax constraints Field types And CACHE option
  137. Let me show what I meant when talked about DBA_JSON_COLUMN. We add a constrain with AND condition. As we see from the view it has 2 columns and one of them isn’t connected with JSON at all
  138. The other case is OR condition. We’ve just lost all JSON columns here
  139. Check for CLOB is rather simple
  140. As well as for IS JSON STRICT
  141. And CACHE option
  142. Context indexes become fragmented overtime. Why? Unfortunately we have no time discussing it but we should have them less fragmented to provide fast search. Oracle 18 manuals tell it provides Automatic Background Index Maintenance but actually you have to do run optimize_index in you own You need to identify fragmentation and garbage volume before. If they are too big run OPTIMIZE_INDEX either on serial or parallel modes
  143. Please pay attention that fragmentation is in percent and you have get rid of percent sign via regexp, but garbage size in megabytes so you have to combine total index size with garbage size via regexp parsing as well.
  144. Serial optimization makes indexes less fragmented but parallel is faster
  145. Check indexes on JSON fields after index create/rebuild, TRUNCATE or huge data loading. They may to become corrupted sometimes
  146. If you use STAGE_ITAB option you should care about maintenance either Autooptimize works by unknown alghorithm in Oracle 12.1 and works when it needn’t at all 12.2 has sort of threshold 18 – haven’t understood does it provide merge of G or merge of I and G and I optimization
  147. Auto_optimize procedure creates a job which runs either by unknown algorithm in 12.1 or after reaching threshold in 12.2 Default threshold = 1 million and 16 parallels which is bad actually. It depends on your workload but based on our json which are more or less structured 10000 records looks better
  148. JSON is always tradeoff between performance/data treatment convenience/integrity JSON treatment is mostly acceptable in row-per-row scenario JSON search requires perfect knowledge of Oracle Text nuances 2 JSON notations in one project could lead to a mess Only Oracle 18 looks mature in terms of JSON treatment Dedicated JSON search solutions are much faster than Oracle
  149. So, thank you for your time. I’m ready answer your questions. Follow my Linkedin – I’ll share masterclass schedule there