PostgreSQL is an open-source, Relational Database Management System (RDBMS) available for many platforms including Linux, UNIX, MS Windows and Mac OS X. Please mention your PostgreSQL version when asking questions. Always include the "sql" tag and possibly the "plpgsql" tag if applicable.
10
votes
3answers
339 views
Finding person with most medals in Olympics database
I have an Olympics database from each Olympic year and I want to find the person that has won the most medals. The main problem is that I'm basically querying the same sub-query twice in ...
5
votes
2answers
81 views
How to properly call an “upsert” using parameterized raw SQL to Postgresql in ActiveRecord?
I need to call an upsert to my Category table in PostgreSQL. My current solution uses the exec_query API in ActiveRecord, using ...
2
votes
2answers
65 views
4
votes
2answers
100 views
SQL query where id=… or id=… or id=… etc
I haven't had much experience with postgresql (none) and I am wondering/hoping that there is a better way for me to do this query.
...
6
votes
1answer
165 views
Help optimizing this query with multiple where exists
In the application I'm building, the user is able to define 'types' where each 'type' has a set of 'attributes'.
The user is able to create instances of products by defining a value for each ...
2
votes
1answer
146 views
Faster way to update/create of a large amount of records?
In our Rails 3.2.13 app (Ruby 2.0.0 + Postgres on Heroku), we are often retreiving a large amount of Order data from an API, and then we need to update or create each order in our database, as well as ...
1
vote
1answer
116 views
Importing Markdown Files - Code Efficiency?
I'm building a rails app that, among other things, imports text markdown files as blog posts. The idea is that the truth is in the markdown files, so any time those are edited, created, or deleted, ...
1
vote
1answer
50 views
Automating the install of postgresql from Shell
When my debian server deploys it can run a shell script so I wanted to make one to install postgreSQL, create a role, create two databases and then import a schema into one.
Can anyone please look ...
0
votes
1answer
66 views
please help to simplify my method (taxonomy) (propel ORM)
I'm working on a simple blogsystem (for learning purposes, not to reinvent the wheel). In this system the user can add existing or new tags to a blogpost. I wrote a method to achieve this, but it's ...
0
votes
0answers
50 views
2
votes
1answer
75 views
Postgres 9.x Joining on Overlaping Date & Time Range
I have several tables that have a TIMESTAMP WITH TIME ZONE column along with some additional information. I need to be able to join these tables such that all of ...
2
votes
1answer
73 views
Summing different tables values limiting the results
I have two tables (a and b) which have both one date field of type ...
5
votes
1answer
503 views
Generic method for database calls
Background
Breaking from MVC, I've implemented the following architecture:
POST/GET ➤ PHP ➤ Database Calls ➤ XML ➤ XSLT ➤ HTML
All database interactions are ...
3
votes
1answer
926 views
Get all recursive dependencies of a single database object
I've written a SELECT statement that creates a List of all objects that depend on a single object, so that if I wanted to DROP that object I could DROP all referenced objects first without using ...
1
vote
2answers
157 views
First Database Schema - How did I do?
I would really like some advice from any DB gurus who have a few minutes free. After doing some reading and playing with sqlfiddle over the weekend I have constructed this postgresql schema and it is ...
3
votes
2answers
549 views
PostgreSQL simple query with repeated function calls
I have PostgreSQL 9.1.1 running in a shared hosting environment and I'm running this query:
...
1
vote
2answers
121 views
simplify and improve performance of getting data
I am working on a little browsergame project written in PHP and using PostgreSQL as DBMS. Now I'm not really lucky with the process started after a userlogin was succesful.
Some info:
there are 3 ...
3
votes
0answers
55 views
Low performance of PL/pgSQL function
I have a PL/pgSQL function which is unstable. This is source:
...
9
votes
2answers
3k views
Node.js password salting/hashing
In view of the recent LinkedIn breach, would anyone care to review my data access routines relating to user access?
This is a standard node.js module, accessing a Postgres database.
...
6
votes
3answers
1k views
SQL: Search for a keyword in several columns of a table
I want to perform a search in several columns of a table. I use the following query:
...
6
votes
2answers
751 views
SQL: Extracting nodes from a graph database
I guess I'm one of these people who are more at home in C#,C++, Python, etc; and only use SQL to do simple INSERTs and SELECTs, so apologies if this is too simple. I'm also new to Postgres and ...