SlideShare a Scribd company logo
1
X y
- Queries too slow
- Schemas change
- Complex relationships
- 3NF, BCNF…
- Nest SELECT, JOIN
- 1-n, 1-1, n-n
- Migration
- Synchonize
- Huge records
- …
SQLite problems
REALM
khacpv@gmail.com

15/05/2016
no-sqlite for mobile
Who am I?
3
Realm is
SQL
SELECT user.name, user.email
FROM user
INNER JOIN shop ON user.id = shop.userid

INNER JOIN city ON user.cityid = city.id
WHERE user.name = 'the flash'
No-SQL
Realm.getA().getC().getF();
A
B C
D E F
G
X
Z
y
4
Realm is
SQLite
SELECT user.name, user.email
FROM user
INNER JOIN shop ON user.id = shop.userid

INNER JOIN city ON user.cityid = city.id
WHERE user.name = 'khac'
No-SQLite
Realm.getA().getC().getF();
A
B C
D E F
G
X
Z
y
5
YOUR 

logo?
6
How: fastest?
7
Galaxy S4
8
Zenfone 5
9
Why: fastest?
10
Speed force
• Memory-mapped files
• C++ core
• B+ trees
• Column-oriented
• Bit-packing
Minimize I/O overhead

Cross-platform

Faster reads and writes

Queries > writes (no-sql)

Smaller file size
11
benchmark vs SQLite
http://static.realm.io/downloads/java/android-benchmark.zip 12
Architecture
Realm Object Store API
Realm Internal API
JNI
Realm Core
13
Method count
• Realm: ~1750
• Model class: +2x no. of fields
• Proxy class: + 2x no. of fields + 11
• Total: "it depends" (~2000)
Picasso: ~600

GSON: ~950

RxJava: ~3500
Retrofit: ~494
Support Lib: ~12300

OrmLite: ~2400
14
How: code?
15
get Realm
16
web:
version:
support:
contributors:
last release:
https://realm.io
0.90.1
xamarin, java, obj-c, swift, react-native
52+ (java)
7 days ago (13/05/2016)
classpath "io.realm:realm-gradle-plugin:0.90.1"
apply plugin: 'realm-android'
ProGuard!
Realtime
17
update realtime
Types fields
18
@Required
@Ignore
@RealmClass
@Index
@PrimaryKey
boolean
byte, short,int,long -> long
float
double
String
Date
byte[]
final
transient
volatile
Relationships
19
n…1
n…n
Queries
20
• equalTo
• greaterThan
• between
• contains
• beginWith
• beginGroup
• or
• not
• isEmpty
• distinct
• sum/ count
• min/ max/ average
• findAll/ findFirst
• sort
• …
Insert / Update
21
Delete
22
Configuration
23
1. Encrypt with key (AES-256)
2. Migration strategy
3. In memory mode
4. Default instance
5. isAutoRefresh() & waitForChange()
6. Create from JSON
https://nelenkov.blogspot.dk/2012/05/storing-application-secrets-in-androids.html
https://developer.android.com/training/articles/keystore.html
Thread
Realm
Realm
object
Realm
Results
Threads
24
RealmObject
A B C
Not yet Polymorphism
Debug
25
Crashlytics
Limitations
26
1. Class names: <= 57 letters*
2. Field names: <= 63 letters
3. Nest transactions -> not supported!
4. String & byte[] < 16Mb
*Realm auto append class_ at begin of class name
References
• https://realm.io/news/introducing-realm
• https://realm.io/users/chatwork
• https://github.com/realm
• http://www.slideshare.net/ChristianMelchior/realm-building-a-
mobile-database
• http://www.slideshare.net/dalinaum/realm-java
• https://en.wikipedia.org/wiki/Zero-copy
• https://en.wikipedia.org/wiki/Data_structure_alignment
27
Q & A
28
• Why do you choose Realm?
• Faster 5~10 times, especialy in write data
• Combine with ActiveAndroid
• Which data should be stored in Realm?
• The data need to be writen many times, ex: total
chats.
• Should remove ActiveAndroid to only play with Realm.
• Yes, it’s doesn’t complicated but ActiveAndroid has
value too.
• Easy to synchronize with data from server
• Yes, no problem
• Use for both Android & Ios?
• Yes
29
ChatWork
Ryutaro Miyashita
https://realm.io/users/chatwork/
30
Appendix
B+ Tree
31https://en.wikipedia.org/wiki/B%2B_tree
The primary value of a B+ tree is in storing data for
efficient retrieval in a block-oriented storage context in
particular, filesystems. (NTFS, EXT4, SQLite, Oracle …
Column Oriented
32http://arxiv.org/pdf/1105.4252.pdf
Memory-mapped
33
Memory-mapped I/O uses the same address bus to
address both memory and I/O devices
CPU
RAM
Hard Disk
I/O
https://en.wikipedia.org/wiki/Memory-mapped_file
http://www.slideshare.net/jpountz/how-does-lucene-store-your-data
http://lemire.me/blog/2012/03/06/how-fast-is-bit-packing/
Bit-packing
34
• Efficient technique to store blocks of small ints
• Supports random access
• Special case: bits per value = 1 is a bit set
• Say you want to store
• 5 30 1 1 10 12
• Raw data: 6 * 32 = 192 bits
• Packed : 6 * 5 = 30 bits (84% size reduction!)
0000 0000 0000 0000 0000 0000 0000 0101 = 5
0000 0000 0000 0000 0000 0000 0001 1110 = 30
0000 0000 0000 0000 0000 0000 0000 0001 = 1
0000 0000 0000 0000 0000 0000 0000 0001 = 1
0000 0000 0000 0000 0000 0000 0000 1010 = 10
0000 0000 0000 0000 0000 0000 0000 1100 = 12

More Related Content

What's hot

pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
Command Prompt., Inc
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
Command Prompt., Inc
 
Introduction to Sharding
Introduction to ShardingIntroduction to Sharding
Introduction to Sharding
MongoDB
 
Zabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructureZabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructure
Arvids Godjuks
 

What's hot (20)

Redshift performance tuning
Redshift performance tuningRedshift performance tuning
Redshift performance tuning
 
Integração do Zabbix com Testes Automatizados
Integração do Zabbix com Testes AutomatizadosIntegração do Zabbix com Testes Automatizados
Integração do Zabbix com Testes Automatizados
 
[WEBINAR] 10 cosas que debes saber sobre Active Directory.
[WEBINAR] 10 cosas que debes saber sobre Active Directory.[WEBINAR] 10 cosas que debes saber sobre Active Directory.
[WEBINAR] 10 cosas que debes saber sobre Active Directory.
 
How to Ingest 16 Billion Records Per Day into your Hadoop Environment
How to Ingest 16 Billion Records Per Day into your Hadoop EnvironmentHow to Ingest 16 Billion Records Per Day into your Hadoop Environment
How to Ingest 16 Billion Records Per Day into your Hadoop Environment
 
Redis and it's data types
Redis and it's data typesRedis and it's data types
Redis and it's data types
 
MySQL Transactions
MySQL TransactionsMySQL Transactions
MySQL Transactions
 
Zabbix monitoring in 5 pictures
Zabbix monitoring in 5 pictures  Zabbix monitoring in 5 pictures
Zabbix monitoring in 5 pictures
 
Zabbix
ZabbixZabbix
Zabbix
 
Active Directory
Active DirectoryActive Directory
Active Directory
 
Row-level security and Dynamic Data Masking
Row-level security and Dynamic Data MaskingRow-level security and Dynamic Data Masking
Row-level security and Dynamic Data Masking
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
Zabbix Monitoring Platform
Zabbix Monitoring Platform Zabbix Monitoring Platform
Zabbix Monitoring Platform
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
Exadata Cloud Service Overview(v2)
Exadata Cloud Service Overview(v2) Exadata Cloud Service Overview(v2)
Exadata Cloud Service Overview(v2)
 
Introduction to Sharding
Introduction to ShardingIntroduction to Sharding
Introduction to Sharding
 
Apache Iceberg: An Architectural Look Under the Covers
Apache Iceberg: An Architectural Look Under the CoversApache Iceberg: An Architectural Look Under the Covers
Apache Iceberg: An Architectural Look Under the Covers
 
Winning Strategies for Converting and Migrating Master Data to SAP BusinessOb...
Winning Strategies for Converting and Migrating Master Data to SAP BusinessOb...Winning Strategies for Converting and Migrating Master Data to SAP BusinessOb...
Winning Strategies for Converting and Migrating Master Data to SAP BusinessOb...
 
Webinar: Working with Graph Data in MongoDB
Webinar: Working with Graph Data in MongoDBWebinar: Working with Graph Data in MongoDB
Webinar: Working with Graph Data in MongoDB
 
Engage 2020 - HCL Notes V11 Performance Boost
Engage 2020 - HCL Notes V11 Performance BoostEngage 2020 - HCL Notes V11 Performance Boost
Engage 2020 - HCL Notes V11 Performance Boost
 
Zabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructureZabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructure
 

Similar to Realm Presentation

Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 

Similar to Realm Presentation (20)

Your backend architecture is what matters slideshare
Your backend architecture is what matters slideshareYour backend architecture is what matters slideshare
Your backend architecture is what matters slideshare
 
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
 
Building production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackBuilding production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stack
 
Mini-Training: Redis
Mini-Training: RedisMini-Training: Redis
Mini-Training: Redis
 
Node azure
Node azureNode azure
Node azure
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
OrientDB for real & Web App development
OrientDB for real & Web App developmentOrientDB for real & Web App development
OrientDB for real & Web App development
 
Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling Twitter
 
Remix
RemixRemix
Remix
 
Deploying and Managing PowerPivot for SharePoint
Deploying and Managing PowerPivot for SharePointDeploying and Managing PowerPivot for SharePoint
Deploying and Managing PowerPivot for SharePoint
 
Graph Database Use Cases - StampedeCon 2015
Graph Database Use Cases - StampedeCon 2015Graph Database Use Cases - StampedeCon 2015
Graph Database Use Cases - StampedeCon 2015
 
Graph database Use Cases
Graph database Use CasesGraph database Use Cases
Graph database Use Cases
 
Hotsos 2012
Hotsos 2012Hotsos 2012
Hotsos 2012
 
Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB
 
Exploring Relay land
Exploring Relay landExploring Relay land
Exploring Relay land
 
Five Database Mistakes and how to fix them -- Confoo Vancouver
Five Database Mistakes and how to fix them -- Confoo VancouverFive Database Mistakes and how to fix them -- Confoo Vancouver
Five Database Mistakes and how to fix them -- Confoo Vancouver
 
Sql and Go
Sql and GoSql and Go
Sql and Go
 
Master tuning
Master   tuningMaster   tuning
Master tuning
 
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevMigration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
 
JavaOne_2010
JavaOne_2010JavaOne_2010
JavaOne_2010
 

Recently uploaded

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 

Realm Presentation