postgresql

Migrating SQL Server 2008 DB to Postgres

I would like to migrate a SQL Server 2008 database to Postgres. Is there a painless way to do this? are there any tools that will scan through the schema and stored procedures to flag compatibility problems? ...

The "Model" in .Net MVC

How do data frameworks such as Linq 2 SQL, ADO.Net Data Entities and DataSets relate to the "Model" as defined by .Net MVC. The reason I ask is I'm trying to learn the ins and outs of the .Net framework without relying on many of the tools that make it easy and hide the workings from you. The "model" I'm building in my exploratory app ...

SQL: How to refer subexpression from WHERE in SELECT?

Hi, all! I have Postgresql and query SELECT complex_expression() FROM t WHERE complex_expression() != ''; Is there a way to write complex_expression() only once in query and then refer to it? Thanx in advance ...

How to use (install) dblink in postgresql ?

I am used to Oracle and to create a dblink in my schema and then access to a remote database like this : mytable@myremotedb, is there anyway do to the same with PostgreSQL ? Right now I am using dblink like this : SELECT logindate FROM dblink('host=dev.toto.com user=toto pass...

Sorting rows by count of a many-to-many associated record

I know there are a lot of other SO entries that seem like this one, but I haven't found one that actually answers my question so hopefully one of you can either answer it or point me to another SO question that is related. Basically, I have the following query that returns Venues that have any CheckIns that contain the searched Keyword ...

How to execute PostgreSQL funcion from VBA code?

How to execute funcion named Test1 that is stored in PostgreSQL from VBA code? For example. We have function definition as follow: CREATE OR REPLACE FUNCTION "public"."Test1" ( ) RETURNS bit AS $body$ BEGIN INSERT INTO test ("name") VALUES ('1'); RETURN 1; END; $body$ LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOK...

PostgreSql + btrim function is not working properly

Here, I have probleming in trim the value in postgresql. Please have a look. Ruby code :: if(this.modelName=="ClientOffice") { this.params="model_name="+this.modelName+"&action_name="+this.actionName+"& find_condition=btrim(clients_corporate_billings.id,' ') %3D btrim('"+validString('populateValue0','text')+"',' ') & ob...

Postgresql compare 2 querys for optimization

I just created a couple of queries that bring the same data but in a different. the first one uses a sub query and the second one uses a self join strategy. checking the documentation, i found the ANALYZE and EXPLAIN commands, Now i'm trying to understand which query is better. this is the result of EXPLAIN ANALYZE for each query. Hope s...

Throttling i/o in postgres's pg_dump?

So we have a production database that is 32GB on a machine with 16GB of RAM. Thanks to caching this is usually not a problem at all. But whenever I start a pg_dump of the database, queries from the app servers start queueing up, and after a few minutes the queue runs away and our app grinds to a halt. I'll be the first to acknowledge th...

Using a DISTINCT clause to filter data but still pull other fields that are not DISTINCT

I am trying to write a query in Postgresql that pulls a set of ordered data and filters it by a distinct field. I also need to pull several other fields from the same table row, but they need to be left out of the distinct evaluation. example: SELECT DISTINCT(user_id) user_id, created_at FROM creations ORDER BY crea...

How to discover what a Postgresql table's usage is?

Our team is working on a Postgresql database with lots of tables and views, without any referential constraints. The project is undocumented and there appears to be a great number of unused/temporary/duplicate tables/views dirtying the schema. We need to discover what database objects have real value and are actually used and accessed. ...

django-fts: How to create indexes for psql

Hi, I am investigating how the http://code.google.com/p/django-fts/ application works. I am trying to setup psql FTS to work with the application, but can't understand how to create index correctly. Don't understand how to create the GIN index as it was specified in doc. My model is following: class Product(fts.SearchableModel): ...

Auto Increment in FLuent Nhibernate and PostgreSQL

Hai, I`m Newbie in Fluent Nhibernate.. I have postgreSql Database and what i want is generated id with auto increment.. i have no see feature auto increment in Postgres and i was understand that for use auto increment in postgreSql i must create sequence.. there is other way beside sequence? if create sequence is the only way, can You ...

glassfish connection pool additionnal delay while re-creating after idle timeout

Hi, We are currently deploying some applications on a glassfish 3.0.1 using a postgres database through postgresql-9.0-801.jdbc4.jar Our actual configuration regarding the connexion pool is : Idle Timeout : 120 seconds Max Wait Time : 60000 millisecondes Initial and Mimimum Pool Size : 1 Maximum Pool Size : 1 Pool Resize Quantity : 1 ...

Ignore Postgresql batch insert errors

Assume this simple SQL query: INSERT INTO table (col1,col2) VALUES (val1,val2),(val3,val4),(val5,val6); Lets say val3 is invalid value for col1. This would cause psql to abort whole INSERT command - it would not insert (val1,val2) nor (val5,val6) either. Is it possible to make postgresql ignore this error so it does not insert (val3...

What is the equivalent of PL/SQL %NOTFOUND in PL/pgSQL ?

Everything's in the title. I am Looping on a cursor and would like to have the EXIT WHEN curs%NOTFOUND when there is no more row, what is the equivalent of %NOTFOUND under PostgreSQL ? Edit Or the other cursors attributes %ISOPEN, %EMPTY, etc... ...

PostgreSQL+table partitioning: inefficient max() and min()

Hi, I have a huge partitioned table stored at a PostgreSQL table. Each child table has an index and a check constraint on its id, e.g. (irrelevant deatils removed for clarity): Master table: points Column | Type | Modifiers ---------------+-----------------------------+----------------------...

Finding the hash value of a row in postgresql

Hi, Is there a way to get the hash code of a row in postgresql? I need to export some data only if there is some changes in the data after the last export, the last exported data rows can be stored in a table, the when the again I need to export the data I can get the hash values of all the data and export only those rows who has a d...

How to pass a record as parameter for PL/pgSQL function ?

I keep looking for this answer online but I cannot find it. I am trying to pass one record over a PL/pgSQL function. I tried it in two ways. Fist way : CREATE OR REPLACE FUNCTION translateToReadableDate(mRecord dim_date%ROWTYPE) RETURNS void AS $$ That is the ouput : psql:requestExample.sql:21: ERROR: syntax error at or near "%" L...

Grant EXECUTE to many PostGIS functions

Hello. I have a Web Application which is based on MapServer, which uses PostGIS as underlying database extension. Now I want to have a dedicated database role which is used for MapServer, cause I don't want to access the database via the postgres superuser. This role should only have SELECT permission on public tables (which is easy to...