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

How to modelling a union type in PostgreSQL

We have the generic idea of a rule with specific implementation details stored in their own table. We currently have the following schema: Rule * id * name * ruleAId * ruleBId * .... * ruleNId *...

View Article


Is it possible to backup my ubuntu postgresql database by copying the...

A developer working on my server has fiddled with some settings and knocked my postgresql database offline. I’ve been messing with it for an hour and am considering just reinstalling postgresql fresh...

View Article


Why do we need partitions in PostgresSQL? (or any other RDBMS)

So, I am trying to teach myself partitions in PostgreSQL. I understand that a database can become slow when a table hits millions+ of lines and indexes don’t fit into memory anymore. One thing that...

View Article

List all columns and rows of PostgreSQL table with a view limit

I am currently using select * from items; to show my table during development however I am finding it a bit messy now as some the strings I am adding to the table are 1,000+ chars long. Is there a...

View Article

Postgres tablespace on mounted usb

I’ve got postgres 9.1 running on raspbian installed with apt-get. I’ve got NTFS usb HDD mounted in /mnt/usb. What I’d like to achieve is to create a tablespace pointing to /mnt/usb/postgres so I...

View Article


Normalization of library book table with multiple authors

I have a database structure with two tables: The first one is called Author, has two columns (AuthID, AuthName) and its Primary Key is (PK_AuthID). The second one is called Book and has three columns...

View Article

SQL social connections query

Given the following 2 tables: Profiles --------- id, name Connections ----------- id1, id2, status where status is (for the sake of the example) either ‘pending’, or ‘active’. What I’m trying to do is...

View Article

Image may be NSFW.
Clik here to view.

Postgresql performance issues when issuing many small inserts and updates one...

I have a production web server with postgresql database. My server gets data from another server every hour on the hour. The other server wakes up and sends many requests to my server, each result in...

View Article


Heroku Postgres Follower

I’m currently looking at creating a follower db of a live production database. The follower will be used for analytics purposes only. And will not be inserting any data – if it did then it would be by...

View Article


ST_Split and looping problems PostGIS

I am a total PostGIS noob, and am having trouble understanding the finer points of SQL syntax. I am trying to take a large set of line data and clip it with a polygon. I then want to create a new table...

View Article

psql with '-c' option or '-f' option is not terminating properly

When I run a command such psql -d database -c 'select * from table' or psql -d database -f sqlcommands psql does not terminate cleanly. Interestingly piping the the contents of the file instead of...

View Article

Install PostgreSQL using source code or using apt-get?

I want to install PostgreSQL on a server that runs Ubuntu 14.04.2 LTS. I understand that I have two options: 1) Install PostgreSQL using the source code distribution e.g.,...

View Article

Postgresql query history hacking

I believe that PostgreSQL can log slow or unsuccessful queries. Probably I can set also PostgreSQL to log all queries executed. Contrarily, I am interested to know if there is a way that a malicious...

View Article


Simple join in postgresql [closed]

I have a simple join query below : select jobs.location_id from companies, jobs where jobs.company_id = companies.id and companies.name = 'name'; it doesn’t seem to get the job location of company has...

View Article

Last occurance of time relative to now()

What’s the most elegant way to ask Postgres for the last 4:05pm relative to now()? I have been writing a fairly elaborate CASE with date_trunc‘s and my guess is it can be accomplished in a much cleaner...

View Article


Forcing FK constraint to validated in system catalog

I have a big table (~60gigs, 35mill+ rows) that I need to add a FK to. Adding a FK directly to the table causes a validation which runs for about 30secs that I want avoid as it’s a 30sec access...

View Article

Postgres privileges: psql dp – what is about the plus-sign

I used psql-command “dp” to find out the given grants. Versions on test-server: PostgreSQL 9.1.15 on armv7l-unknown-linux-gnueabi, compiled by gcc (Debian 4.6.3-14) 4.6.3, 32-bit Out of the...

View Article


Is there a workaround for the lack of foreign keys constraint to a...

I have a big table A (~30 million lines) at the core of my model. Another table B has a foreign key referencing A. I would like to partition A using the well-known inheritance hack. Is there a...

View Article

Return type of JOINing stored procedure – PostgreSQL

Is it possible to express return type of stored procedure that returns joined tables using table type of one of joined tables? My stored procedure looks like this: CREATE or REPLACE FUNCTION...

View Article

Find number of points within certain radius of a set of points

I have two tables. One is a list of stores (with lat/long). The other is a list of customer addresses (with lat/long). What I want is a query that will return the number of customers within a certain...

View Article
Browsing all 1138 articles
Browse latest View live