|Developer(s)||PostgreSQL Global Development Group|
|Stable release||8.4.3 /|
PostgreSQL, often simply Postgres, is an object-relational database management system (ORDBMS). It is released under an MIT-style license and is thus free and open source software. As with many other open source programs, PostgreSQL is not controlled by any single company, but has a global community of developers and companies to develop it.
Functions allow blocks of code to be executed by the server. Although these blocks can be written in SQL, the lack of basic programming operations which existed prior to version 8.4, such as branching and looping, has driven the adoption of other languages inside of functions. Some of the languages can even execute inside of triggers. Functions in PostgreSQL can be written in the following languages:
- A built-in language called PL/pgSQL resembles Oracle's procedural language PL/SQL.
- Scripting languages are supported through PL/Lua, PL/LOLCODE, PL/Perl, plPHP, PL/Python, PL/Ruby, PL/sh, PL/Tcl and PL/Scheme.
- Compiled languages C, C++, Java (via PL/Java)
- The statistical language R through PL/R.
PostgreSQL supports row-returning functions, where the output of the function is a set of values which can be treated much like a table within queries. Custom aggregates and window functions can also be defined.
Functions can be defined to execute with the privileges of either the caller or the user who defined the function. Functions are sometimes referred to as stored procedures, although there is a slight technical distinction between the two.
PostgreSQL includes built-in support for B+-tree, hash table, GiST and GiN indexes. In addition, user-defined index methods can be created, although this is quite an involved process. Indexes in PostgreSQL also support the following features:
- Expression indexes can be created with an index of the result of an expression or function, instead of simply the value of a column.
- Partial indexes, which only index part of a table, can be created by adding a
WHEREclause to the end of the
CREATE INDEXstatement. This allows a smaller index to be created.
- The planner is capable of using multiple indexes together to satisfy complex queries, using temporary in-memory bitmap index operations.
Triggers are events triggered by the action of SQL DML statements. For example, an INSERT statement might activate a trigger that checked if the values of the statement were valid. Most triggers are only activated by either INSERT or UPDATE statements.
Database triggers are fully supported and can be attached to tables but not to views. Views can have rules, though. Multiple triggers are fired in alphabetical order. In addition to calling functions written in the native PL/PgSQL, triggers can also invoke functions written in other languages like PL/Perl.
PostgreSQL manages concurrency through a system known as Multi-Version Concurrency Control (MVCC), which gives each user a "snapshot" of the database, allowing changes to be made without being visible to other users until a transaction is committed. This largely eliminates the need for read locks, and ensures the database maintains the ACID principles in an efficient manner.
Rules allow the "query tree" of an incoming query to be rewritten. One common usage is to implement views, including updatable views. Rules, or more properly, "Query Re-Write Rules", are attached to a table/class and "Re-Write" the incoming DML (select, insert, update, and/or delete) into 1 or more queries that either replace the original DML statement or execute in addition to it. Query Re-Write occurs after DML statement parsing, but, before query planning.
A wide variety of native data types are supported, including:
- Variable length arrays (including text and composite types) up to 1GB in total storage size.
- Arbitrary precision numerics
- Geometric primitives
- IPv4 and IPv6 addresses
- CIDR blocks and MAC addresses
- XML supporting Xpath queries (as of 8.3)
- UUID (as of 8.3)
In addition, users can create their own data types which can usually be made fully indexable via PostgreSQL's GiST infrastructure. Examples of these are the geographic information system (GIS) data types from the PostGIS project for PostgreSQL.
New types of almost all objects inside the database can be created, including:
- Data types
- Functions, including aggregate functions
- Operators (existing ones can be overloaded)
- Procedural languages
Tables can be set to inherit their characteristics from a "parent" table. Data in child tables will appear to exist in the parent tables, unless data is selected from the parent table using the ONLY keyword, i.e. select * from ONLY PARENT_TABLE. Adding a column in the parent table will cause that column to appear in the child table.
Inheritance can be used to implement table partitioning, using either triggers or rules to direct inserts to the parent table into the proper child tables.
This feature is not fully supported yet—in particular, table constraints are not currently inheritable. As of the 8.4 release, all check constraints and not-null constraints on a parent table are automatically inherited by its children. Other types of constraints (unique, primary key, and foreign key constraints) are not inherited.
Inheritance provides a way to map the features of generalization hierarchies depicted in Entity Relationship Diagrams (ERD) directly into the PostgreSQL database.
- Referential integrity constraints including foreign key constraints, column constraints, and row checks
- Views. Although views are by default not updateable, they can be made so by creating "insert", "update", and/or "delete" Query Re-Write Rules on the view.
- Inner, outer (full, left and right), and cross joins
- Correlated sub-queries 
- Supports most of the major features of SQL:2008 standard 
- Encrypted connections via SSL
- Binary and textual large-object storage
- Online backup
- Point-in-time recovery
- Two-phase commit
- TOAST (The Oversized-Attribute Storage Technique) is used to transparently store large table attributes (such as big MIME attachments or XML messages) in a separate area, with automatic compression.
- Regular expressions 
- Common table expressions
- Embedded SQL is implemented using preprocessor. SQL code is first written embedded into C code. Then code is run through ECPG preprocessor, which replaces SQL with calls to code library. Then code can be compiled using C compiler. Embedding works also with C++ but it does not recognize all C++ constructs.
- Performance wizard - included with any Postgres download from EnterpriseDB. Source code also available.
- MySQL migration wizard - included with any Postgres download from EnterpriseDB. Source code also available.
- Geographic objects via PostGIS. GPL.
- Shortest-Path-Algorithms with pgRouting using PostGIS. GPL.
- Full text search via Tsearch2 and OpenFTS. (As of version 8.3, Tsearch2 is included in core PostgreSQL)
- Some synchronous multi-master derivatives or extensions exist, including
- Several asynchronous master/slave replication packages, including
- There are proxy (middleware) tools that enable replication, failover or load management and balancing for PostgreSQL:
A number of companies offer proprietary tools for PostgreSQL. They often consist of a universal core that is adapted for various specific database products. These tools mostly share the administration features with the open source tools but offer improvements in data modeling, importing, exporting or reporting.
- Wikipedia contributors, "PostgreSQL", Wikipedia, The Free Encyclopedia, http://en.wikipedia.org/wiki/PostgreSQL Accessed May 10, 2010
- "PostgreSQL licence approved by OSI". 2010-02-18. http://www.crynwr.com/cgi-bin/ezmlm-cgi?17:mmp:969. Retrieved 2010-02-18.
- "OSI PostgreSQL licence". 2010-02-20. http://www.opensource.org/licenses/postgresql. Retrieved 2010-02-20.
- What is PostgreSQL?
- Command prompt's Mammoth replicator page lists replicator's availability as "open source"
- Douglas, Korry (August 5, 2005). PostgreSQL (Second ed.). Sams. 664. ISBN 0672327562. http://www.informit.com/store/product.aspx?isbn=0672327562.
- Gilmore, W. Jason; Treat, Robert (February 27, 2006). Beginning PHP and PostgreSQL 8: From Novice to Professional. Apress. 896. ISBN 1590595475. http://www.apress.com/book/view/1590595475.
- Matthew, Neil; Stones, Richard (April 6, 2005). Beginning Databases with PostgreSQL (Second ed.). Apress. 664. ISBN 1590594789. http://www.apress.com/book/view/9781590594780.
- Worsley, John C.; Drake, Joshua D. (January 2002). Practical PostgreSQL. O'Reilly Media. 636. ISBN 1565928466. http://oreilly.com/catalog/9781565928466/.
- PostgreSQL website
- Professional technical support for PostgreSQL
- PostgreSQL installation tutorial
- PostgreSQL getting started tutorial
- Database Journal articles on PostgreSQL
- Linux Productivity Magazine: a complete issue on PostgreSQL
- PostgreSQL Guide
- PostgreSQL gotchas, documented but counterintuitive behavior
- Test_PGC, Example embedded SQL/C program for PostgreSQL showing database operations and SQLSTATE testing.
- PostgreSQL Performance Tuning