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

Extract lat/long from point type column

In my table I have a column “location” that is a POINT. I tried this: SELECT ST_X(location), ST_Y(location) FROM locations; But I still get the error message: ERROR: function st_x(point) does not exist

View Article


How to run recurring tasks on a Postgresql database without a cron-like tool?

I would like to call a stored procedure on a regular basis. On Oracle, I would create a job for this. I have found that Postgresql can mimic this well by using an external tool (cron etc) and PgAgent....

View Article


How do I determine if a column is defined as a serial data type instead of an...

So I’m currently creating some SQL to read through the postgres (9.1) catalogs to build table definitions. However, I am encountering a problem with SERIAL/BIGSERIAL data types. Example: CREATE TABLE...

View Article

PostgreSQL 9.1.4 will not install service scripts

Same setup as before, but with a different install command. PostgreSQL refuses to install its service scripts into /etc/init.d/; in fact, I can’t find them anywhere (find / -regex ".*postgres.*")...

View Article

Measure the size of a PostgreSQL table row

I have a PostgreSQL table. select * is very slow whereas select id is nice and quick. I think it may be that the size of the row is very large and it’s taking a while to transport, or it may be some...

View Article


Install the Pgadmin3 shapefile importer plugin on a Mac(10.8)?

I’m new to GIS related things and I’m setting up a Postgre/Postgis database for geospatial queries. I’d like to import various shapefiles into the database and I found that Pgadmin3 has a shapefile...

View Article

Why do psql queries take longer when inserting many rows. Why is it non linear

So if I insert a single row into a postgres database it takes 18 ms. If I do this in a loop like this: INSERT INTO contacts (numbers) SELECT distinct array[ (random() * 99999999)::integer, (random() *...

View Article

How to keep an unique counter per row with PostgreSQL?

I need to keep an unique (per-row) revision number in a document_revisions table, where the revision number is scoped to a document, so it’s not unique to the whole table, only to the related document....

View Article


pg_timezone_names view is empty – can be recreated?

For some strange reason pg_timezone_names view is empty. Is there a way to recreate it?

View Article


Foreign Key to Multicolumn Primary Key?

I have three connected table in my design. Basic logic is when a category deleted, also delete records in category_product table which has deleted category’s id in its cat_id column. But when I tried...

View Article

Postgres – Schema information within Trigger?

Background : (Multi-tenant design;separate schema per customer, all table structures identical;Data-warehouse / non-OLTP system here; Postgres 9.2.x). Reviewing patterns for the following problem: I...

View Article

Have aggregate function group results in one row

I have a table that has the following columns: debit credit payment_method class Now I will perform this query: select sum(debit - credit), payment_method, class from my_table group by payment_method,...

View Article

What are the privileges required to execute a trigger function in PostgreSQL...

What are the privileges required to execute a trigger function in PostgreSQL 8.4? It seems that the privileges set to a role does not matter to execute a trigger function. I think I have seen some day...

View Article


When postgresql sequences get out of sync?

For the third time it has happened to me that a sequence has been set to an initial value (zero or one, not sure) while in the table, there are around 1500 records. When it happens, new rows cannot be...

View Article

Find nearest neighbours faster in PostGIS

I currently have a query that calculates the number of useful amenities within a certain radius of each town, using OSM data: create table places as select town.name, place, town.way, ( select count(*)...

View Article


Help with Postgres 9.1 data import (is 4x expected data size, 4x slower than...

I have 25 billion <int, int, float> rows that I’m trying to import into Postgres, and after 77% of the data being imported, the Postgres data folder is taking up 840GB, about 4x the storage...

View Article

How to create fault tolerant databases? [closed]

I have a local application running on a LAN. Sometimes a database gets shutdown. In such a scenario how can I keep the application working? Can I have two concurrent databases so that one picks up the...

View Article


PostgreSQL, How to keep only one schema?

I don’t want some users be available to create schemas, and only use the public schema. I’d like to remove the permission of creating schemas, but I can’t found anything on PotsgreSQL 9.1...

View Article

Recovering a dropped table in PostgreSQL

I have : CREATE TABLE ketoan_vn.Customers ( CustomerId character varying(10) NOT NULL, CustomerName character varying(150), CONSTRAINT Customers_PK_CustomerID PRIMARY KEY (CustomerId) ); I inserted 2...

View Article

How to dive into the PostgreSQL's optimizer and trace each step it takes to...

Just like the MEMO structure in SQL Server which is kind of a “paper trail” of steps the optimizer takes in optimizing the query. Does PostgreSQL have the similar structure which records steps the...

View Article
Browsing all 1138 articles
Browse latest View live