- Yury and Elvis built asyncpg, an asynchronous Python client library for Postgres to improve performance and pull binary data directly out of Postgres before starting EdgeDB. (see 1M rows/s from Postgres to Python | EdgeDB Blog)
- EdgeQL has no
NULL. Everything is a set, so an empty set is equivalent toNULL.NULLis a real problem in SQL, behaving very unpredictably
- Can cast easily into JSON
- The design principles of EdgeDB (Elvis refers to them as “the three pillars”): ergonomics, performance, and correctness. Correctness trumps all, and the other two are balanced.
- EdgeDB is open source
- Instance credentials get written to
~/Library/Application Support/edgedb/credentials/<instance-name>.jsonwhen you runedgedb instance init - “Free shapes” are arbitrary “objects” defined in a query, not tied to a type in the schema
- Convenient way to execute several expressions at once
- Examples:
SELECT {
empty_set := <str>{},
users := (SELECT User),
blog_posts := (SELECT BlogPost),
number_of_users := count((SELECT User)),
nested_shape := { nesting_level := 2 }
}
WITH
skip := <int64>$skip,
remaining_users := (SELECT User ORDER BY .id OFFSET skip),
page_results := (SELECT remaining_users LIMIT 10)
SELECT {
page_results := page_results { id, name },
next_offset := skip + count(page_results),
has_more := count(remaining_users) > 10
};
- Transactions intelligently retry by default; connections are always pooled with a number of connections defined by a server hint (as of RC2)
- Can emulate old behavior with options
- Set pool size to 1
- Set retry attempts to 1
- Can emulate old behavior with options
- Yury wrote the Python spec for coroutines with async and await syntax
- Need was discovered while designing a hypothetical EdgeDB client in Python and noting that the verbose syntax required could be dramatically improved.
- Wrote uvloop to replace the built-in asyncio event loop for improved performance
- Building a production database in ten years or less | EdgeDB Blog has a timeline of events leading up to the launch of EdgeDB 1.0
Graph-relational
- Graph-relational database is not the same as EdgeDB. EdgeDB is just the first implementation of the paradigm.
- graph-relational extends relational with three concepts: object identity, links, and cardinality
- Relational concepts mapped to graph-relational | Relational | Graph-relational | |------------------------|--------------------| | Table (“relation”) | Object type | | Column (“attribute”) | Property or link | | Row (“tuple”) | Object |
Object identity
- All objects have unique immutable identifier
- Does not need to be declared
- required, read-only property
idwith exclusive constraint - auto-assigned UUID upon insertion
Is EdgeDB an ORM?
From Yury’s 1.0 launch blog post:
If Postgres is already a database, and EdgeDB is built on top of Postgres, then is EdgeDB an ORM (object-relational mapper)?
We don’t think so. It has its own formally-defined query language, EdgeQL, which matches SQL in power and surpasses it in clarity and brevity. It’s language-agnostic, whereas most ORMs are libraries written for a particular language. It has its own type system, standard library, binary protocol, client libraries in multiple languages, CLI, workflows, and conventions. By any definition, EdgeDB is a database unto itself.
The post-SQL era — Yury Selivanov | EdgeDB Day - YouTube
- is composable, unlike SQL
- “plays nice” with programming languages
ORMs
Yury spends a lot of time talking about ORMs, so this must be perceived as a “competitor” to EdgeDB.
- ORM = object relational mapper
- ORMs reflect the fact that developers generally don’t want to interact directly with the database
- ORMs sacrifice performance for composability
- Non-trivial cases still require hand-written SQL
- Not hand-writing SQL means you lose performance of the underlying database
EdgeDB answer to ORMs
- Eliminates layers of abstraction
- No mental overhead, so no need for ORM
- graph database- stores nodes and relationships between nodes instead of tables
- EdgeDB “turns your data into a graph while retaining relational fundamentals”
- EdgeQL “looks like a child of SQL and GraphQL”
- Computations like SQL
- Select nested data like GraphQL
- Great to build data APIs with
Cloud/Serverless
- Relational databases generally not ready for cloud/serverless
- EdgeDB handles “several orders of magnitude more connections” than typical SQL databases
- client libraries recover from network errors and replay failed transactions
- minimize number of round trips
Features
- supports GraphQL directly
- first-class transactions
- open-source
EdgeQL: The big ideas — Elvis Pranskevichus | EdgeDB Day - YouTube
- object-relational impedance mismatch- Object-oriented paradigm used by programmers is incompatible with the relational paradigm used in RDBMS
- Queries in SQL become verbose quickly
- EdgeQL query in a tweet, SQL in a Medium post
- ORMs like Prisma lack a way to compute arbitrary expressions in queries
- Must perform a separate query and manually join results
- EdgeQL can perform computation in query
- Prisma performs three queries to get the results
- Graph-relational = relational + object identity + links + everything is a set
