It’s a well-known fact, that although the database performance is great, and each query is executed in milliseconds, the overall application response time may be slow, making the users wait for a response for extended periods of time. The problem is not the database, but the way the application de...
It’s a well-known fact, that although the database performance is great, and each query is executed in milliseconds, the overall application response time may be slow, making the users wait for a response for extended periods of time. The problem is not the database, but the way the application developers communicate with the database - using Object-Relational Mappers (ORM).
The only way to change this behavior is to provide application developers with a tool, which is as easy to use, as an ORM, but which will allow escaping the common ORM pitfalls. That’s why we developed NORM – No-ORM Framework. To facilitate the adoption of the No-ORM approach, we developed a set of generators of user-defined types and functions. The input data is presented in a form of annotated JSON schema, which makes them easy to use by both database and application developers.
Size: 3.1 MB
Language: en
Added: Jun 26, 2024
Slides: 24 pages
Slide Content
ORM is Bad - But is There an Alternative? Henrietta Dombrovskaya Database Architect DRW (YOUR LOGO)
Hettie Dombrovskaya ( She/Her ) Database Architect DRW Working with databases for over 40 years (people do not live that long!) I love working with app developers! Local organizer of Chicago PostgreSQL User Group Author of PostgreSQL Query Optimization There is no “work-life balance” - it’s called “work-life integration”!
ORM Quizz What is ORM? Object Relational Mapper Why developers use ORM? To abstract from database specifics Why ORM is good? Rapid development Why ORM is bad? Inefficient data access patterns
Application Model Database Model ORM Flat Tables JDBC (Object-Relational) (Object-Oriented) 2023 hDBn
The result: World Wide Wait!
Why Waiting Is Bad? Amazon: 0.1 sec increase response time - 1% sales loss. 50 % visitors abandon the site, which is not loaded within 3 sec 79% visitors will never return again
Introducing NORM The goal of is to reduce the number of round trips
NORM – No ORM Transfer Mapping Mapping Database Model (Object-Relational) JDBC Tex t Text Transfer model (JSON) Transfer Application Model (Object-Oriented)
CONTRACT Both sides (an application and a database) convert internal representations into complex hierarchical object Contract establishes object structure implemented on both sides Now, for any application endpoint it takes one database call to transfer data to and from database App DB
Are You Kidding Me?!
We focused on: Formalizing contracts (mapping) Generating all database-level objects: Types Search functions (reads) DML functions (writes)
MongoDB-style Search { "booking_hierarchy":{ "departure_airport_code":"ORD", "arrival_city":{"$like":"NEW%"}, "last_name":"Smith"} } SQL: booking_id IN ( select booking_id from postgres_air.booking_leg where flight_id IN ( select flight_id from postgres_air.flight where arrival_airport IN ( select airport_code from postgres_air.airport where city LIKE ('NEW%'::text) ) AND departure_airport = ('ORD'::bpchar) ) ) AND booking_id IN ( select booking_id from postgres_air.passenger where last_name = (Smith::text) )
Why not storing JSON? Single hierarchy The search is slow Storage overhead No strong type check
Additional Considerations How this is different from other ORMs? “Thinking sets” Mapping complex objects Doing DB work inside DB On the application side: Details may vary (no need for converting to text, etc.) ActiveRecord requires additional work, because it reads the DB catalog directly