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

Does ST_Intersection work in 3D?

I am using “ST_Intersection” between two 3D lines which I believe do not intersect, but the result gives me their intersection. SELECT ST_ASText(ST_Intersection( ST_GeomFromText('LINESTRING( 1 1 1, 5 5...

View Article


How to speed up select distinct?

I have a simple select distinct on some time series data: SELECT DISTINCT user_id FROM events WHERE project_id = 6 AND time > '2015-01-11 8:00:00' AND time < '2015-02-10 8:00:00'; And it takes...

View Article


Good encryption performance

I’m converting a sql server database to postgresql 9.4. I’m stuck on something that is really really slow. I use copy to bulk insert 200 files of 5000 lines each into 200 tables (one file per table)....

View Article

Compare only day / month / year portion of a timestamp field

I am creating a view for a certain table, where rows have timestamp fields (planned_ts). The view needs to be sorted according to these timestamps, but since the application is only interested by the...

View Article

Group by transformed column

I have a database with creations and orders, and a bunch of tables linking them. I want to extract, for each month, the number of ordered creations, and the sum of amount for these orders, but for a...

View Article


Create/copy new superuser from an existing one

I have a superuser for a PostgreSQL database, let’s call him userX. How can I make a new superuser (let’s call him userY) with all the same permissions, access, etc…? Basically, I want a clone of...

View Article

noobie to streaming replication in postgres 9.2

I’ve been asked to reverse engineer an app that uses postgresql in the back end. I can see that there is some database replica tion going on… based on my reading, I *think it’s called streaming...

View Article

Tuning PostgreSQL for minimum reliability and bulk updates

I’m using PostgreSQL to host some data that comes from external source, the normal operation of the database is read-only with periodic updates. Updates though are kinda huge e.g. in a 50 million row...

View Article


How to create Spatial Reference System in QGIS?

I have some Attribute and the coordinate and the coordinate reference system. I want to create a DBmanagamet form my spatial data. To do that I want to create one table with name Spa_ref_sys, but I...

View Article


PostgreSQL and MONEY data type for currency values

For a project, I created a table with a column price MONEY NOT NULL column. And I thought it would handle decimals properly, unlike a floating number (i.e. IEEE rounding issues), but I end up having...

View Article

How do completely empty columns in a large table affect performance?

I have 400 million rows in a Postgres db, and the table has 18 columns: id serial NOT NULL, a integer, b integer, c integer, d smallint, e timestamp without time zone, f smallint, g timestamp without...

View Article

How do I use pg_dump and pg_restore to move a large database to another machine?

I’m a bit unclear on how to use the pg_dump/pg_restore duo to move a large-ish database. Here is the command I use to dump the database (the host and username are taken from environmental variables):...

View Article

How do I change the PostgreSQL data directory in the OpenGeo Suite 4.5?

I am using OpenGeo Suite and I would like to move the PostgreSQL databases files to a different drive than my operating system. The default location installed by OpenGeo Suite is in the “C:ProgramData”...

View Article


Copy table with separate sequences for serial columns

While creating a column management tool I came across the need to quickly replicate tables in PostgreSQL so I would not test new tools with non-test tables. To effectively test the new column tool that...

View Article

Working with Materialized View

I have a materialised view which takes around 57 second to be created and I’m using Postgresql 9.4. When I do an insert into a table, a trigger will call a trigger function which will do a REFRESH...

View Article


Postgres pg_basebackup reports directory exists but is not empty

I have postgreSQL 9.4.1 installed on a Win 2012 Server. I am looking to setup replication between this and another server of the same spec. So I am following guidance on preparing the master database...

View Article

How can I create a bool column for a view based on the result of a statement?

I’m using PostgreSQL as my database. CREATE TABLE groups ( id SERIAL NOT NULL, name TEXT NOT NULL, PRIMARY KEY (id), UNIQUE (name) ); CREATE TABLE users ( id SERIAL NOT NULL, group INT NOT NULL, name...

View Article


Image may be NSFW.
Clik here to view.

Get products of category plus all child categories till leaf nodes

We have a hierarchy which looks this: Now the problem is that most products are only connected with 1 category, which is most of the time the lowest level. I am trying to get ALL products below a given...

View Article

Match multiple components of a subquery CTE in PostgreSQL

I’ve got an app that grants access to users in varying different ways, and I’m attempting to write a query that determines access in all the different ways, but is readable, by breaking the access out...

View Article

can one database participate in bdr master to master, as well as a master to...

This might seem like a silly question but I have to ask. Let’s say we have databaseA in POP1. We need to replicate over to POP2 and POP3. But within each each POP, we also have databaseB that is a...

View Article
Browsing all 1138 articles
Browse latest View live