DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Cloud Migration: How To Overcome Fears and Capitalize on Opportunities
  • Modern Data Backup Strategies for Safeguarding Your Information
  • Performance Optimization Strategies in Highly Scalable Systems
  • A Guide to Data-Driven Design and Architecture

Trending

  • Writing Reusable SQL Queries for Your Application With DbVisualizer Scripts
  • How to Migrate Vector Data from PostgreSQL to MyScale
  • An Introduction to Build Servers and Continuous Integration
  • Memory Management in Java: An Introduction
  1. DZone
  2. Data Engineering
  3. Data
  4. The Importance of a Data Format: Part 1 — Current State Problems

The Importance of a Data Format: Part 1 — Current State Problems

JSON is a really simple format. It's very easy to work with it, interchange it, read it, etc. However, JSON also has a few major issues. Read on to learn more.

Oren Eini user avatar by
Oren Eini
·
Jan. 11, 16 · Analysis
Like (2)
Save
Tweet
Share
3.13K Views

Join the DZone community and get the full member experience.

Join For Free

JSON is a really simple format. It's very easy to work with it, interchange it, read it, etc. Here is the full JSON format definition:

object = {} | { members }
members = pair | pair , members
pair = string : value
array = [] | [ elements ]
elements = value | value , elements
value = string | number | object | array | true | false | null

So far, so good. But, JSON also has a few major issues. In particular, JSON requires you to read and parse the entire document (at least until the part you actually care about) before you can do something with it. Reading JSON documents into memory and actually working with them means loading and parsing the whole thing, and typically requires the use of dictionaries to get fast access to the data. Let us look at this typical document:

{
  "firstName": "John",
  "lastName": "Smith",
  "address": {
  "state": "NY",
  "postalCode": "10021-3100"
},
"children": [{"firstName": "Alice"}]
}

How would this look in memory after parsing?

Dictionary (root)
firstName –> John
lastName –> Smith
address –> Dictionary
state –> NY
postalCode –> 10021-3100
children –> array
[0] –> Dictionary
firstName –> Alice

So, that is three dictionaries and an array (even assuming we ignore all the strings). Using Newtonsoft.Json, the above document takes 3,840 bytes in managed memory (measured using ObjSize in WinDBG). The size of the document is 126 bytes as text. The reason for the different sizes is dictionaries. Here is 320 bytes allocation:

new Dictionary<string,Object>{ {“test”, “tube”} };

And, as you can see, this adds up fast. For a database that mostly deals with JSON data, this is a pretty important factor. Controlling memory is a very important aspect of the work of a database. And, JSON is really inefficient in this regard. For example, imagine that we want to index documents by the names of the children. That is going to force us to parse the entire document, incurring a high penalty in both CPU and memory. We need a better internal format for the data.

In my next post, I’ll go into details on this format and what constraints we are working under.

Data (computing)

Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Cloud Migration: How To Overcome Fears and Capitalize on Opportunities
  • Modern Data Backup Strategies for Safeguarding Your Information
  • Performance Optimization Strategies in Highly Scalable Systems
  • A Guide to Data-Driven Design and Architecture

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: