Pull to refresh
104.16

PostgreSQL *

Object-relational database management system (ORDBMS) with an emphasis on extensibility and standards compliance

Show first
Rating limit
Level of difficulty

«Divide and Conquer» for OpenStreetMap world inside PostgreSQL

Level of difficulty Medium
Reading time 28 min
Views 815
Open source *PostgreSQL *Java *OpenStreetMap *
Translation

I will continue the story "How to put the whole world into a regular laptop: PostgreSQL and OpenStreetMap" with secrets about OpenStreetMap geodata, on which many companies have built their business, but not everyone shares the details... Well, today we will open crucial details.

The OSM database in PosgreSQL after loading from the dump takes up more than 587 GB. This is already a large database by the standards of a DBMS, and one huge table for each type of object will not work. For manageability, such data must be partitioned, it's good that PostgreSQL supports declarative data partitioning. It remains only to figure out how to split geographical data. After searching and comparing, the H3 hierarchical hexagonal geospatial indexing system came to rescue. All this was implemented in my openstreetmap_h3 project for fast processing and loading of the world dump into the PostGIS database.

I considered following options from geopartitioning systems...

Read more
Rating 0
Comments 0

How to put the whole world into a regular laptop: PostgreSQL and OpenStreetMap

Level of difficulty Easy
Reading time 12 min
Views 892
Open source *PostgreSQL *Java *OpenStreetMap *
Translation

When a person used to say that he controls the whole world, he was usually placed in the next room with Napoleon Bonaparte. I hope that these times are in the past and everyone can analyze the geodata of the entire Earth and get answers to their global questions in minutes and seconds. I published Openstreetmap_h3 - my project, which allows you to perform geoanalytics on data from OpenStreetMap in PostGIS or in any query engine that can work with Apache Arrow / Parquet.

First of all, I say hello to the haters and skeptics. What I developed is really unique and solves the problem of transforming and analyzing geodata using the usual and familiar tools available to every analyst and data science specialist without bigdata, GPGPU, FPGA. What looks easy to use and code now is my personal project where I have invested my vacations, weekends, sleepless nights and a lot of personal time over the past 3 years. Maybe I will share the background of the project and the rake that I went through, but first I will still describe the end result.

Read more
Total votes 8: ↑8 and ↓0 +8
Comments 0

Roads and building density in North America. 100GB geodata processing OSM data in PostgreSQL

Reading time 15 min
Views 798
Open source *PostgreSQL *OpenStreetMap *
Translation

Today I will discover America to you based on OpenStreetMap data in PostgreSQL15/PostGIS and my project openstreetmap_h3. Let's run the query and compare its execution time on the Citus column store in PostgreSQL and on the standard 100GB database partitioned by H3 geoindex.

We will find the top15 buildable locations in North America and the total length of roads, as well as their type and surface. I will not overload the publication with program logs, let's focus on the data! You can easily repeat all requests yourself on your laptop/computer.

Read more
Rating 0
Comments 0

Database selection cheat sheet: SQL or NoSQL?

Reading time 9 min
Views 2.5K
PostgreSQL *Java *SQL *NoSQL *Go *

This is a series of articles dedicated to the optimal choice between different systems on a real project or an architectural interview.

This topic seemed relevant to me because such tasks can be encountered both at work and at an interview for System Design Interview and you will have to choose between these two types of DBMS. I plunged into this issue and will tell you what and how. What is better in each case, what are the advantages and disadvantages of these systems and which one to choose, I will show with several examples at the end of the article.

SQL or NoSQL?

Read more
Total votes 1: ↑1 and ↓0 +1
Comments 0

PostgreSQL 16: Part 3 or CommitFest 2022-11

Reading time 10 min
Views 912
Postgres Professional corporate blog PostgreSQL *SQL *
Translation

image


We continue to follow the news of the upcoming PostgreSQL 16. The third CommitFest concluded in early December. Let's look at the results.


If you missed the previous CommitFests, check out our reviews: 2022-07, 2022-09.


Here are the patches I want to talk about:


meson: a new source code build system
Documentation: a new chapter on transaction processing
psql: \d+ indicates foreign partitions in a partitioned table
psql: extended query protocol support
Predicate locks on materialized views
Tracking last scan time of indexes and tables
pg_buffercache: a new function pg_buffercache_summary
walsender displays the database name in the process status
Reducing the WAL overhead of freezing tuples
Reduced power consumption when idle
postgres_fdw: batch mode for COPY
Modernizing the GUC infrastructure
Hash index build optimization
MAINTAIN ― a new privilege for table maintenance
SET ROLE: better role change management
Support for file inclusion directives in pg_hba.conf and pg_ident.conf
Regular expressions support in pg_hba.conf

Read more →
Total votes 1: ↑1 and ↓0 +1
Comments 1

PostgreSQL 16: Part 2 or CommitFest 2022-09

Reading time 13 min
Views 901
Postgres Professional corporate blog PostgreSQL *SQL *
Translation


It's official! PostgreSQL 15 is out, and the community is abuzz discussing all the new features of the fresh release.


Meanwhile, the October CommitFest for PostgreSQL 16 had come and gone, with its own notable additions to the code.


If you missed the July CommitFest, our previous article will get you up to speed in no time.


Here are the patches I want to talk about:


SYSTEM_USER function
Frozen pages/tuples information in autovacuum's server log
pg_stat_get_backend_idset returns the actual backend ID
Improved performance of ORDER BY / DISTINCT aggregates
Faster bulk-loading into partitioned tables
Optimized lookups in snapshots
Bidirectional logical replication
pg_auth_members: pg_auth_members: role membership granting management
pg_auth_members: role membership and privilege inheritance
pg_receivewal and pg_recvlogical can now handle SIGTERM

Read more →
Total votes 1: ↑1 and ↓0 +1
Comments 0

Queries in PostgreSQL. Nested Loop

Reading time 17 min
Views 1.1K
Postgres Professional corporate blog PostgreSQL *SQL *
Translation

So far we've discussed query execution stagesstatistics, and the two basic data access methods: Sequential scan and Index scan.

The next item on the list is join methods. This article will remind you what logical join types are out there, and then discuss one of three physical join methods, the Nested loop join. Additionally, we will check out the row memoization feature introduced in PostgreSQL 14.

Read more
Total votes 4: ↑4 and ↓0 +4
Comments 0

Queries in PostgreSQL. Sort and merge

Reading time 19 min
Views 962
Postgres Professional corporate blog PostgreSQL *SQL *
Translation


In the previous articles, we have covered query execution stages, statistics, sequential and index scan, and two of the three join methods: nested loop and hash join.


This last article of the series will cover the merge algorithm and sorting. I will also demonstrate how the three join methods compare against each other.

Read more →
Total votes 3: ↑3 and ↓0 +3
Comments 0

Queries in PostgreSQL. Sequential Scan

Reading time 15 min
Views 1.8K
Postgres Professional corporate blog PostgreSQL *SQL *
Translation

Queries in PostgreSQL. Sequential scan


In previous articles we discussed how the system plans a query execution and how it collects statistics to select the best plan. The following articles, starting with this one, will focus on what a plan actually is, what it consists of, and how it is executed.


In this article, I will demonstrate how the planner calculates execution costs. I will also discuss access methods and how they affect these costs, and use the sequential scan method as an illustration. Lastly, I will talk about parallel execution in PostgreSQL, how it works, and when to use it.


I will use several seemingly complicated math formulas later in the article. You don't have to memorize any of them to get to the bottom of how the planner works; they are merely there to show where I get my numbers from.

Read more →
Total votes 3: ↑3 and ↓0 +3
Comments 0

Queries in PostgreSQL. Statistics

Reading time 18 min
Views 3.5K
Postgres Professional corporate blog PostgreSQL *SQL *
Translation

In the last article we reviewed the stages of query execution. Before we move on to plan node operations (data access and join methods), let's discuss the bread and butter of the cost optimizer: statistics.

Dive in to learn what types of statistics PostgreSQL collects when planning queries, and how they improve query cost assessment and execution times.

Read more
Total votes 4: ↑3 and ↓1 +2
Comments 0

Queries in PostgreSQL. Query execution stages

Reading time 15 min
Views 3.4K
Postgres Professional corporate blog PostgreSQL *SQL *
Translation

Hello! I'm kicking off another article series about the internals of PostgreSQL. This one will focus on query planning and execution mechanics.

In the first article we will split the query execution process into stages and discuss what exactly happens at each stage.

Read more
Total votes 4: ↑4 and ↓0 +4
Comments 1

Just for Fun: PVS-Studio Team Came Up With Monitoring Quality of Some Open Source Projects

Reading time 5 min
Views 987
PVS-Studio corporate blog Open source *PostgreSQL *C++ *

Static code analysis is a crucial component of all modern projects. Its proper application is even more important. We decided to set up a regular check of some open source projects to see the effect of the analyzer's frequent running. We use the PVS-Studio analyzer to check projects. As for viewing the outcome, the choice fell on SonarQube. As a result, our subscribers will learn about new interesting bugs in the newly written code. We hope you'll have fun.

Читать далее
Rating 0
Comments 1

Development of “YaRyadom” (“I’mNear”) application under the control of Vk Mini Apps. Part 1 .Net Core

Reading time 8 min
Views 756
PostgreSQL *.NET *API *C# *
Translation
Application is developed in order to help people find their peers who share similar interests and to be able to spend some time doing what you like. The project is currently on the stage of beta-testing in the social network “VKontakte”. Right now I am in the process of fixing bugs and adding everything that is missing. I felt like I could use a bit of destruction and decided to write a little about the development. While I was writing, I decided to divide the text into different parts. Here we are going to pay more attention to backend nuances which I faced, and to everything that a user does not see.
Read more →
Rating 0
Comments 0

Patroni cluster (with Zookeeper) in a docker swarm on a local machine

Reading time 20 min
Views 6.1K
PostgreSQL *Development Management *DevOps *
Tutorial

There probably is no way one who stores some crucial data (and well, in particular, using SQL databases) can possibly dodge from thoughts of building some kind of safe cluster, distant guardian to protect consistency and availability at all times. Even if the main server with your precious database gets knocked out deadly - the show must go on, right? This basically means the database must still be available and data be up-to-date with the one on the failed server.

As you might have noticed, there are dozens of ways to go and Patroni is just one of them. There is plenty of articles providing a more or less detailed comparison of the options available, so I assume I'm free to skip the part of luring you into Patroni's side. Let's start off from the point where among others you are already leaning towards Patroni and are willing to try that out in a more or less real-case setup.

I am not a DevOps engineer originally so when the need for the high-availability cluster arose and I went on I would catch every single bump on the road. Hope this tutorial will help you out to get the job done with ease! If you don't want any more explanations, jump right in. Otherwise, you might want to read some more notes on the setup I went on with.

Read more
Rating 0
Comments 1

Locks in PostgreSQL: 4. Locks in memory

Reading time 10 min
Views 13K
Postgres Professional corporate blog PostgreSQL *SQL *
Translation
To remind you, we've already talked about relation-level locks, row-level locks, locks on other objects (including predicate locks) and interrelationships of different types of locks.

The following discussion of locks in RAM finishes this series of articles. We will consider spinlocks, lightweight locks and buffer pins, as well as events monitoring tools and sampling.


Read more →
Rating 0
Comments 0

Locks in PostgreSQL: 3. Other locks

Reading time 14 min
Views 6.8K
Postgres Professional corporate blog PostgreSQL *SQL *
Translation
We've already discussed some object-level locks (specifically, relation-level locks), as well as row-level locks with their connection to object-level locks and also explored wait queues, which are not always fair.

We have a hodgepodge this time. We'll start with deadlocks (actually, I planned to discuss them last time, but that article was excessively long in itself), then briefly review object-level locks left and finally discuss predicate locks.

Deadlocks


When using locks, we can confront a deadlock. It occurs when one transaction tries to acquire a resource that is already in use by another transaction, while the second transaction tries to acquire a resource that is in use by the first. The figure on the left below illustrates this: solid-line arrows indicate acquired resources, while dashed-line arrows show attempts to acquire a resource that is already in use.

To visualize a deadlock, it is convenient to build the wait-for graph. To do this, we remove specific resources, leave only transactions and indicate which transaction waits for which other. If a graph contains a cycle (from a vertex, we can get to itself in a walk along arrows), this is a deadlock.


Read more →
Total votes 6: ↑6 and ↓0 +6
Comments 0

Authors' contribution