Quantcast
Channel: Question and Answer » postgresql
Browsing all 1138 articles
Browse latest View live

How to avoid duplications using a function

I am using this function in a bulk insert to avoid duplication of url paths. CREATE OR REPLACE FUNCTION "univ"."gc_landing"(IN _name text, OUT landing_id int4) RETURNS "int4" AS $BODY$ DECLARE...

View Article


Storing historical data in DB vs on disk

I’ve been pondering on alternative solutions to speed up data retrieval from my DB. I currently have a relatively large database, about 1 billion rows and growing. We expect the DB to grow linearly...

View Article


Rename the constraint of a possibly referenced primary key in PostgreSQL

Is it safe to use this command just like that, even though the table might be referenced from other tables as foreign key? ALTER INDEX foo_pkey RENAME TO pk__foo__id; I have just tried it and it seems...

View Article

Postgres Won't Start – incomplete startup packet

I have an issue that is preventing a Postgres server from starting. The server fell over after it ran out of disk space, how ever this has now been resolved although now Postgres will not start. It...

View Article

Retrieving latest record using DISTINCT ON is slow [duplicate]

This question already has an answer here: How do I efficiently get “the most recent corresponding row”? 6 answers

View Article


Combine multiple similar queries into one

I need to calculate a weighted average using the following table. I have to calculate this number for metric_1 up to metric_10. All the metric columns have a value from 1 to 5....

View Article

Can bdr only replicate one database per server?

I have installed the new BDR-Solution with PostgreSQL 9.4 and it works like a charm. My Problem: I want to add more databases to the replication but every time if I added the other database and...

View Article

pg_stat_activity – is it possible to decompose a stored procedure further?

I got a long running query in pg_stat_activity: datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start |...

View Article


Image may be NSFW.
Clik here to view.

Recovery when failover

1/ Description: I have 2 Centos machine: master, slave (streaming replication). Both of them are built on PostgreSQL 9.3 (image below) and configured failover event (failover PG 9.3 document). Last WAL...

View Article


Create and update PostgreSQL view from Drupal view

Do you know about any way to automatically create and update PostgreSQL view from Drupal view? The reason is, that there are some applications, which can use DB view, but not Drupal one, such as QGIS...

View Article

Add fields to view from select (transpose fields)

I’ve got a table with following structure: CREATE TABLE test ( id integer, field character varying, value character varying ); field value ------ ----- field1 value1 field2 value2 field3 value3 ... ......

View Article

Referential integrity after disable/enable trigger all

I wonder how to check referential integrity on a table after disabling and reenabling foreign key constraints. For example : postgres=# CREATE TABLE main(id serial, id_delta integer, PRIMARY KEY (id));...

View Article

invalid memory alloc request size on simple query with array_agg on Postgres 9.3

Postgresql 9.3 – Debian 7 54gb RAM 8 cores (On google compute engine) I have a huge table called search_token (~50M rows) and I’m trying to execute a very simple query that is: select...

View Article


ArcMap 10.1, the identify tool does not show feature attributes on a query...

I’m developing an ArcGIS 10.1 desktop map editing application using ArcEngine and ArcObjects. I’m using a PostgreSQL database. After a direct database connection (using a query layer), I displayed the...

View Article

display thematic map using openlayers

iam displaying map from mapfile(mapserver) in c# using openlayers mapfile is connected to postgres it is working well but now i want to diaplay thematic map using the postgrs database using openlayers...

View Article


Need help on transferring data from a PostgreSQL database to a future (to be...

(English isn’t my native language) I’m doing an internship for school and my task is to theoretically describe the best way to transfer the data from their current database (PostgreSQL) that they have...

View Article

Adding column to Postgres table fails

I have a Postgres (8.4.20) table that I’m supposed to add columns to, but it seems to have some problems that I have difficulties to debug: I’m attempting what I thought was a simple ALTER TABLE… on...

View Article


COMMIT after EXPLAIN ANALYZE of a read-only query

In PostgreSQL, what effect could produce issuing a COMMIT after executing an EXPLAIN ANALYZE with a read-only query?

View Article

PostgreSQL – partial dump of large orbjects (pg_largeobject table)

Context : Our web-app is like a collaboration platform where you can share files, appointments, survey and so on. An instance of this web-app is divided in communities, each one is independent to each...

View Article

Execution plan of query inside pl/pgsql function

Briefly, we have a pl/pgsql function which collects some intermediate data in several temporary tables (“on commit drop”) and then returns REFCURSOR which joins those temporary tables with some static...

View Article
Browsing all 1138 articles
Browse latest View live