
ACID which stands for Atomicity, consistency, isolation, and durability are four critical properties of relational database. I think any engineer working with a relational database like postgres, mysql, sqlserver oracle, should understand these properties.
In this course, we will go through the four properties and explain why each is critical to build and use a relational database successfully.
In this video we will demonstrate Atomicity, Isolation, Consistency and Durability on Postgres, fully practical example.
This lecture details the inner working of database systems with regards to storage. It is a must watch to understand the difference between tables, pages, IO, rows, indexes and data files.
In this lecture I will discuss the difference between Primary Key and a Secondary Key and how it can affect your performance.
Lots of you asked me how to create a table with millions of rows in postgres, here are the details
In this video, I explain the benefits of Bitmap Index Scan and how it differs from Index scan and table sequential scan.
If you create an index on a large production table in postgres, the operations blocks writes in order to make sure to pull all the field entries to the index. However most of the time you can't afford to block writes on an active production database table. Postgres new feature which allows create index concurrently allows writes and reads to go in the expense of cpu/memory, time and chance for the index to be invalid. A small price to pay for fast production writes! https://www.postgresql.org/docs/9.1/sql-createindex.html#SQL-CREATEINDEX-CONCURRENTLY
B-tree is a self-balancing tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time. However, most contents explain this data structure from a theoretical point of view, in this lecture I’d like to shed some light on the practical considerations of B-Tree and B+Trees in real production database systems such as Postgres and MySQL.
Link to the original paper https://infolab.usc.edu/csci585/Spring2010/den_ar/indexing.pdf
Assume you have a table that is partitioned on the customer_id field serial 32bit, and you want to partition by range, how do you create all the necessary partitions? this is what I discuss in this video
Source Code
https://github.com/hnasr/javascript_playground/tree/master/automate_partitions
In this lecture we explain the difference between exclusive (write locks) and shared locks (read locks)
In this video, I demonstrate how is it possible to get double booking in database-backed web applications and how to prevent double booking and race conditions with row-level locks.
Source Code https://github.com/hnasr/javascript_playground/tree/master/booking-system
In this video I’ll explain why you should avoid using SQL offset when implementing any kind of paging. I’ll explain what offset does, why is it slow and what is the alternative for better performance This video is inspired by Use the index luke, i’ll have a link to the blog and slides to learn more. Let say you have a web application with an API that supports paging, you user want to request 10 news articles in page 10, this is performed via a simple GET request as shown here The API server receives the GET request and builds the SQL in order to send it to the database hopefully a pool of connections exist here. Page 10 translates to offset 100 assuming each page has 10 records and now the database is ready to execute the query against the table. Offset by design means fetch and drop the first x number of rows, so in this case the database will fetch the first 110 rows and physically drop the first 100 leaving the limit of 10 which the user will get. As the offset increase, the database is doing more work which makes this operation extremely expensive. Furthermore, the problem with offset is you might accidentally read duplicate records. consider the user now want to read page 11 and meanwhile someone inserted a new row in the table, row 111 will be read twice Let us jump and test this against postgres
Use the Index Luke Blog https://use-the-index-luke.com/no-offset
Slides in this video https://payhip.com/b/B6o1
Connection pooling is a pattern of creating a pool of available connections (usually TCP) and allow multiple clients to share the same pool of connections. This pattern is usually used when connection establishment and tearing down is costly, and the server has a limited number of connections. In this video we will learn how to use connection pooling in NodeJs when working with a Postgres Database, we will learn how to spin up a pool of database connections and use stateless pool queries and transactional queries begin/end, and finally, we will
Node JS Source Code used in this lecture here https://github.com/hnasr/javascript_playground/tree/master/postgresnode-pool
Scripts and commands
docker run --name pgmaster -v /Users/HusseinNasser/postgres/v/master_data:/var/lib/postgresql/data -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
docker run --name pgstandby -v /Users/HusseinNasser/postgres/v/standby_data:/var/lib/postgresql/data -p 5433:5432 -e POSTGRES_PASSWORD=postgres -d postgres
In standby node update postgresql.conf
primary_conninfo = 'application_name=standby host=husseinmac port=5432 user=postgres password=postgres’
add file standby.signal
touch standby.signal
In master update postgresql.conf
first 1 (standby1)
select * from pg_stat_replication
Scripts and commands
docker run --name pgmaster -v /Users/HusseinNasser/postgres/v/master_data:/var/lib/postgresql/data -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
docker run --name pgstandby -v /Users/HusseinNasser/postgres/v/standby_data:/var/lib/postgresql/data -p 5433:5432 -e POSTGRES_PASSWORD=postgres -d postgres
In standby node update postgresql.conf
primary_conninfo = 'application_name=standby host=husseinmac port=5432 user=postgres password=postgres’
add file standby.signal
touch standby.signal
In master update postgresql.conf
first 1 (standby1)
select * from pg_stat_replication
If using the hostname doesn't work, use the IP address of the container itself. You can get the local IP address of the container by running docker inspect container name
We got through a practical system design exercises, this lecture is two parts. Part 1 is all about backend engineering and scaling and Part 2 focuses on database design.
데이터베이스 엔지니어링 은 매우 흥미로운 소프트웨어 엔지니어링 분야입니다.
데이터베이스 엔지니어링 에 대해 배우고 싶다면 이 강의에 잘 오셨습니다. 저는 데이터베이스 엔지니어링 의 기본 개념을 다루기 위해 이 강의를 엄선하여 준비하였습니다.
이 과정은 SQL 이나 프로그래밍 언어 를 가르치지 않지만, 데이터베이스 엔지니어링 에 적용할 수 있는 기술과 패턴을 가르칩니다.
여러분은 인덱싱 (Indexing), 파티셔닝 (Partitioning), 샤딩 (Sharding), 복제 (Replication), B-트리 (B-trees)에 대한 심층적인 인덱싱, 동시성 제어 (Concurrency Control), 데이터베이스 엔진과 보안(Database Engines and Security) 및 그 외 다양한 데이터베이스 엔지니어링 개념을 학습합니다!
저는 데이터베이스 엔지니어링 의 기초를 배움으로써 어렵고 힘든 문제를 직접 해결할 수 있는 힘을 갖출 수 있다고 생각합니다.
저는 항상 엔지니어링 을 수학에 비교합니다. 수학에서는 특정한 공식이나 방정식을 암기하지는 않아도, 기초적인 원리를 알면 주어진 어떤 문제든 해결할 수 있습니다. 데이터베이스 엔지니어링 도 수학과 비슷합니다. MongoDB 가 MySQL 보다 좋다고 말할 수 없고 Postgres 가 Oracle 보다 우수하다고 말할 수 없습니다. 대신에 여러분은 여러 사용 사례를 이해하고 각 데이터베이스 플랫폼이 어떤 장단점을 가지고 있는지를 이해함으로써 최적의 결정을 내릴 수 있게 될 것입니다.
이 강의에서는 또한 OS와 통신하는 가장 낮은 데이터베이스 인터페이스인 데이터베이스 엔진에 대해 다룹니다.
데이터베이스 엔진 또는 스토리지 엔진 또는 임베디드 데이터베이스 라고도 불리는 데이터베이스 엔진은 데이터베이스 관리 소프트웨어가 데이터를 디스크에 저장하고 CRUD (생성, 갱신, 삭제) 작업을 수행하는 데 사용하는 소프트웨어 라이브러리입니다. 임베디드는 하나의 소프트웨어의 모든 것을 네트워크 클라이언트 서버로 옮기는 것을 뜻합니다. 이 강의에서는 몇 가지 인기있는 데이터베이스 엔진을 알아보고 그들 간의 차이를 설명한 후 데이터베이스를 생성하고 엔진을 변경하여 각 엔진의 다른 기능을 보여드리고자 합니다.
그럼 즐겁게 수강하시기 바랍니다!
- Hussein 드림