Impossible to Install PG gem on my mac with Mavericks

If you want to avoid using MacPorts, you can download the Postgres App and place it into the Application directory. Then, specify the location of newly downloaded pg_config: gem install pg — –with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config If you run in to missing headers problem, try specifying the include directory of the app: gem install pg — –with-pg-include=”/Applications/Postgres.app/Contents/Versions/latest/include/”

How to increase the max connections in postgres?

Just increasing max_connections is bad idea. You need to increase shared_buffers and kernel.shmmax as well. Considerations max_connections determines the maximum number of concurrent connections to the database server. The default is typically 100 connections. Before increasing your connection count you might need to scale up your deployment. But before that, you should consider whether you … Read more

What are the pros and cons of performing calculations in sql vs. in your application

It depends on a lot of factors – but most crucially: complexity of calculations (prefer doing complex crunching on an app-server, since that scales out; rather than a db server, which scales up) volume of data (if you need to access/aggregate a lot of data, doing it at the db server will save bandwidth, and … Read more

psql: could not connect to server: No such file or directory (Mac OS X)

WARNING: If you delete postmaster.pid without making sure there are really no postgres processes running you, could permanently corrupt your database. (PostgreSQL should delete it automatically if the postmaster has exited.). SOLUTION: This fixed the issue–I deleted this file, and then everything worked! /usr/local/var/postgres/postmaster.pid — and here is how I figured out why this needed … Read more

Getting all Buildings in range of 5 miles from specified coordinates

Why are you storing x,y in separated columns? I strongly suggest you to store them as geometry or geography to avoid unnecessary casting overhead in query time. That being said, you can compute and check distances in miles using ST_DWithin or ST_Distance: (Test data) CREATE TABLE building (name text, long numeric, lat numeric); INSERT INTO … Read more