PostgreSQL
Tags: webdev, programming, database
Published: 2024-04-08 13:52:36


 
![Elephant Coding](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/msamhnvc7dmv91172v5p.png)

####**What is PostgreSQL?**
"A powerful, open source object-relational database system that uses and extends the SQUL language combined with many features that safely store and scale the most complicated data workloads. PostgreSQL runs on all major operating systems, has been ACID-compliant since 2011, and has powerful add-ons such as the popular PostGIS geospatial database extender."

####**Why use PostgreSQL?**
- "Comes with many features aimed to help developers build fault-tolerant environments, and help you manage your data no matter how big or small the dataset." 
- "You can define your own own data types, build custom functions, even write code from different programming languages without recompiling your database!"
- "Tries to confirm with the SQL standard where such conformance does not contradict traditional features or could lead to poor architectural decisions."
 
![Datatypes of PostgreSQL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8c0jvo1nr4kr3jn13kzo.png)

![Features for PostgreSQL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ikl2xtfngsl0gdji81p.png)


####**Features Found in PostgreSQL**
###### - **Data Types**
- - Primitives: Integer, Numeric, String, Boolean
- Structured: Date/Time, Array, Range / Multirange, UUID
- Document: JSON/JSONB, XML, Key-value (Hstore)
- Geometry: Point, Line, Circle, Polygon
- Customizations: Composite, Custom Types

###### - **Data Integrity**
- - UNIQUE, NOT NULL
- Primary Keys
- Foreign Keys
- Exclusion Constraints
- Explicit Locks, Advisory Locks

###### - **Concurrency, Performance**
- - Indexing: B-tree, Multicolumn, Expressions, Partial
- Advanced Indexing: GiST, SP-Gist, KNN Gist, GIN, BRIN, Covering indexes, Bloom filters
- Sophisticated query planner / optimizer, index-only scans, multicolumn statistics
- Transactions, Nested Transactions (via savepoints)
- Multi-Version concurrency Control (MVCC)
- Parallelization of read queries and building B-tree indexes
- Table partitioning
- All transaction isolation levels defined in the SQL standard, including Serializable
- Just-in-time (JIT) compilation of expressions

###### - **Reliability, Disaster Recovery**
- - - Write-ahead Logging (WAL)
    - Replication: Asynchronous, Synchronous, Logical
    - Point-in-time-recovery (PITR), active standbys
    - Tablespaces

###### - **Security**
  - Authentication: GSSAPI, SSPI, LDAP, SCRAM-SHA-256, Certificate, and more
- Robust access-control system
- Column and row-level security
- Multi-factor authentication with certificates and an additional method

###### - **Extensibility**
- - Stored functions and procedures
- Procedural Languages: PL/pgSQL, Perl, Python, and Tcl. There are other languages available through extensions, e.g. Java, JavaScript (V8), R, Lua, and Rust
- SQL/JSON constructors and path expressions
- Foreign data wrappers: connect to other databases or streams with a standard SQL interface
- Customizable storage interface for tables
- Many extensions that provide additional functionality, including PostGIS

###### - **Internationalism, Text Search**
- - Support for international character sets, e.g. through ICU collations
- Case-insensitive and accent-insensitive collations
- Full-text search

####**History**
- "The origins of PostgreSQL date back to 1986 as part of the POSTGRES project at the University of California at Berkeley and has more than 35 years of active development on the core platform."
- "Derived from the POSTGRES package, with decades of development behind it, it's now the most advanced open-source database available anywhere."
- "The POSTGRES project was sponsored by the Defense Advanced Research Projects Agency(DARPA), the Army Research Office(ARO), the National Science Foundation (NSF), and ESL Federal Credit Union."  

<u>**Has been used to implement many different research and production applications.**</u>
- Financial analysis system
- A jet engine**
- Performance monitoring package
- An asteroid tracking database
- Medical information database
- Several geographic information systems

####**General Outlook**
"PostgreSQL has been proven to be highly scalable both in the sheer quantity of data it can manage and in the number of concurrent users it can accommodate."