While using JSON data store in GemFire, number of pdx types proliferates
search cancel

While using JSON data store in GemFire, number of pdx types proliferates

book

Article ID: 294332

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

While using JSON data, if you put fields in different order in various documents that should be following a common schema, the PDX registry will become confused and will treat each document as a unique PDX type in the registry. And the number of PDX types increases drastically. Unfortunately this proliferation of PDX types can cause problems, eventually bloating the PDX registry so large as to cause the system to slow down significantly. 


Environment

Product Version: 9.3

Resolution

If you treat your JSON objects as if they were conforming to a common schema, always place the fields in the same order and always provide all the fields and set fields to appropriate null values as necessary you will not generate as many permutations of PDX types. This will guarantee that there will only be one PDX type created for all of the objects that match that schema.

Example : 
Given an example like this:

{
    "name":"John",
    "age":30,
    "car":"Ford"
}

If George DOESN’T HAVE a car do this:

{
    "name":"George",
    "age":24,
    "car":null
}

rather than this:

{
    "name":"George",
    "age":24
}

And most importantly, keep the fields ordered the same. In other words don’t do this:

{
    "name":"John",
    "age":30,
    "car":"Ford"
}
{
    "age":24,
    "name":"George",
    "car":null
}


For further info, please refer 

https://gemfire.docs.pivotal.io/98/geode/developing/data_serialization/jsonformatter_pdxinstances.html