Questions tagged [postgresql]

All versions of PostgreSQL. Add an additional version-specific tag like [postgresql-13] if that context is relevant.

PostgreSQL is a powerful, open source ACID compliant MVCC database system with a proven architecture that has earned a strong reputation for standards-compliance, reliability, data integrity, and extensibility.

PostgreSQL runs on all major operating systems and supports most of the major features of SQL:2016 including foreign keys, transactions, and window functions, views and materialized views, triggers, and CTEs (including recursive CTEs).
Functions and procedures can be written in multiple languages including C, PL/pgSQL, Python, Perl, TCL, and numerous other languages including Java, Lua, R, sh, and v8 ECMAScript/JavaScript.

Types

PostgreSQL supports most of the standard SQL types including:

Indexes

PostgreSQL supports multicolumn, unique, full, partial and functional indexes, and combinations thereof. Index types include B-tree, Hash, GiST, SP-GiST, GIN and BRIN.

Replication and High Availability

PostgreSQL supports both logical replication, and WAL-shipping.

Extensions

A multitude of extensions provides additional capabilities. Notably, the spatial extension PostGIS is the best in the industry. See also

License

PostgreSQL is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.

16860 questions
161
votes
4 answers

How to list all constraints of a table in PostgreSQL?

How to list all constraints (Primary key, check, unique mutual exclusive, ..) of a table in PostgreSQL?
Thirumal
  • 2,398
  • 3
  • 13
  • 24
65
votes
3 answers

Can't rename columns in PostgreSQL views with CREATE OR REPLACE

In PostreSQL 8.3, I'm trying to create a view which will look just like an existing table but have different column names. This works CREATE OR REPLACE VIEW gfam.nice_builds AS SELECT (family_tree.family_tree_id) as x, …
Aleksandr Levchuk
  • 1,187
  • 1
  • 9
  • 11
64
votes
4 answers

Does running pg_dump on live db produce consistent backups?

I have a 3GB database that is constantly modified and I need to make backups without stopping the server (Postgres 8.3). My pg_dump runs for 5 minutes. What if the data is modified during the process? Do I get consistent backups? I don't want to…
Roman
  • 789
  • 1
  • 6
  • 7
59
votes
6 answers

Getting last modification date of a PostgreSQL database table

I'm trying to get when my table was modified by checking its file modification date as it is described in this answer. But the result is not always correct. The file modification date updates in several minute after I update my table. Is it correct…
hank
  • 889
  • 1
  • 8
  • 11
53
votes
5 answers

How to efficiently copy millions of rows from one table to another in Postgresql?

I have two database tables. One contains hundreds of millions of records. Lets call that one history. The other one is calculated on daily basis and I want to copy all of its records into the history one. What I did was to run: INSERT INTO history…
Milovan Zogovic
  • 1,423
  • 3
  • 15
  • 20
53
votes
6 answers

Troubleshooting high CPU usage from postgres and postmaster services?

I'm using an open source (RHEL 6.2) based machine running SIEM software. When I run the top command, I see postgres and postmaster both with 96% CPU usage. Is there a way to pin-point or see what causing these service to stack up?
asadz
  • 635
  • 1
  • 5
  • 6
50
votes
1 answer

Is there a maximum length constraint for a postgres query?

The app we are building might execute quite a big insert queries. Is there limit that my postgres query can have only a certain number of characters?
Kannan Ramamoorthy
  • 647
  • 2
  • 7
  • 8
46
votes
1 answer

What does IDLE state denotes in a row of pg_stat_activity?

Can someone resolve my below doubts about pg_stat_activity in terms of postgres 9.5? Can some let me know what does the state IDLE denotes in the row of pg_stat_activity? Is it like it checks all the open connections to postgres and if the…
tuk
  • 1,203
  • 1
  • 13
  • 21
45
votes
4 answers

Force PostgreSQL clients to use SSL?

I have configured ssl = on in postgresql.conf (and installed a certificate etcetera). Does this ensure that all clients will always connect over SSL? (I.e. does ssl = on it make it impossible to connect without SSL encryption?) Are there other ways…
KajMagnus
  • 1,209
  • 2
  • 14
  • 21
44
votes
4 answers

Can listen_addresses really be set to a list?

I have a VM with IP address 192.168.0.192 running postgreSQL. If I specify listen_addresses = '*' then I can connect from another VM at 192.168.0.191 and from localhost. But I can't seem to use a list to tell postgreSQL to use those two addresses. …
zabouti
  • 543
  • 1
  • 4
  • 4
41
votes
4 answers

How do I find out how far along my PostgreSQL query is?

I have a pretty decent idea of how many rows my SELECT...INTO query will actually process (e.g. I know how many will materialize). I understand Postgres won't tell me percentage completeness, is there a way (buried deep in logs, system tables, or…
Mark Elliot
  • 511
  • 1
  • 4
  • 5
39
votes
5 answers

Set names to attributes when creating JSON with row_to_json

Is it possible to rename default f1, f2, f3... names when using row_to_json function for only some columns? I can do row_to_json(customers) returning {"id_customer":2,"first_name":"bla","last_name":"second_bla"} But if I want only names without…
boobiq
  • 807
  • 3
  • 9
  • 13
35
votes
6 answers

PostgreSQL: How to create full copy of database schema in same database?

How I can copy my public schema into the same database with full table structure, data, functions, fk, pk and etc. My version of Postgres is 8.4 P.S. I need to copy schema NOT database
sigra
  • 453
  • 1
  • 4
  • 5
34
votes
2 answers

Superuser is not permitted to login

I created a superuser portal with the following command create role portal with superuser password 'portal' When I tried to login into postgres with portal user I am getting the following error in rails. FATAL: role "portal" is not permitted to…
Antony
  • 443
  • 1
  • 4
  • 5
34
votes
1 answer

What is the meaning of n_live_tup and n_dead_tup in pg_stat_user_tables

What is the meaning of n_live_tup and n_dead_tup in pg_stat_user_tables or pgstattuple?
Majid Azimi
  • 2,261
  • 3
  • 23
  • 24
1
2 3
99 100