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 ArticleStoring 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 ArticleRename 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 ArticlePostgres 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 ArticleRetrieving 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 ArticleCombine 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 ArticleCan 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 Articlepg_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 ArticleRecovery 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 ArticleCreate 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 ArticleAdd 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 ArticleReferential 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 Articleinvalid 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 ArticleArcMap 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 Articledisplay 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 ArticleNeed 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 ArticleAdding 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 ArticleCOMMIT 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 ArticlePostgreSQL – 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 ArticleExecution 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