Re: [GENERAL] Join Bad Performance on different data types

2014-03-03 Thread Pavel Stehule
Hello PostgreSQL doesn't use index when types on left and right part are not equal. Probably you lost some index - you can see a difference in EXPLAIN SELECT ... Regards Pavel 2014-03-04 7:57 GMT+01:00 Adarsh Sharma : > Hi, > > Today i need to change datatype of one of my tables from *bigint

Re: [GENERAL] Join Bad Performance on different data types

2014-03-03 Thread Sameer Kumar
On Tue, Mar 4, 2014 at 2:57 PM, Adarsh Sharma wrote: > I tried creating simple and gin indexes on the column(t_ids) but still not > helping. Anyone has any idea or faced this before. Postgresql version is > 9.2. > have you done a vacuum analyze or analyze after this step? You might have to disa

[GENERAL] Join Bad Performance on different data types

2014-03-03 Thread Adarsh Sharma
Hi, Today i need to change datatype of one of my tables from *bigint to bigint[] *due to application requirements. But One of my query hangs after this change :- select DISTINCT glt.id || ':' || gtt.name as id_type, glt.name, latitude, longitude, radius, latitude || ',' || longitude as latlon fro

Re: [GENERAL] How to recovery failed master after failover

2014-03-03 Thread Tatsuo Ishii
>I am evaluating the HA solution of PostgreSQL 9.3. > 1. Pacemaker resource agent for PostgreSQL + PostgreSQL sync stream > replication > 2. PG-Pool + PostgreSQL sync stream replication >According to my understanding, above two solution must be done same > things to recover

[GENERAL] How to recovery failed master after failover

2014-03-03 Thread snowbird
Hi, I am evaluating the HA solution of PostgreSQL 9.3. 1. Pacemaker resource agent for PostgreSQL + PostgreSQL sync stream replication 2. PG-Pool + PostgreSQL sync stream replication According to my understanding, above two solution must be done same things to recovery faile

Re: [GENERAL] multiple results from a function

2014-03-03 Thread James Harper
> > James Harper wrote on 03.03.2014 21:10: > > I'm working on an application to accept TDS (Microsoft SQL Server) > > connections and proxy them to postgres. MSSQL does things a little > > differently, for instance in addition to a functions it has stored > > procedures that can contain multiple

Re: [GENERAL] multiple results from a function

2014-03-03 Thread Thomas Kellerer
James Harper wrote on 03.03.2014 21:10: I'm working on an application to accept TDS (Microsoft SQL Server) connections and proxy them to postgres. MSSQL does things a little differently, for instance in addition to a functions it has stored procedures that can contain multiple select statement th

Re: [GENERAL] multiple results from a function

2014-03-03 Thread James Harper
> > I'm building against 9.3 at the moment, and my code is external to the > > postgres process and using libpq connections, but I noticed that 9.4 allows > > dynamic backend worker processes which would allow my code to run server > > side and spawn a process for each TDS connection. > > Hm, inte

Re: [GENERAL] Efficiently delete rows not referenced by a foreign key

2014-03-03 Thread David Johnston
Evan Martin wrote > Hi All, > > I have a database schema where if row is deleted from one table the rows > it references in another table should also be deleted, unless still > referenced by something else. > > Eg. Table A has foreign key to table B. When I delete a row from A I > also want to

Re: [GENERAL] multiple results from a function

2014-03-03 Thread Merlin Moncure
On Mon, Mar 3, 2014 at 2:10 PM, James Harper wrote: >> >> On Thu, Feb 27, 2014 at 6:23 PM, James Harper >> wrote: >> > I see that I can use PQgetResult to get results from an async query, and >> > this >> allows for multiple results, presumably when the query is like "SELECT 123, >> 456; SELECT

[GENERAL] Efficiently delete rows not referenced by a foreign key

2014-03-03 Thread Evan Martin
Hi All, I have a database schema where if row is deleted from one table the rows it references in another table should also be deleted, unless still referenced by something else. Eg. Table A has foreign key to table B. When I delete a row from A I also want to delete the referenced row in B,

Re: [GENERAL] multiple results from a function

2014-03-03 Thread James Harper
> > On Thu, Feb 27, 2014 at 6:23 PM, James Harper > wrote: > > I see that I can use PQgetResult to get results from an async query, and > > this > allows for multiple results, presumably when the query is like "SELECT 123, > 456; SELECT 'ABC', 'DEF';". Is there a way for a C function, using SPI,

Re: [GENERAL] Multiple Schema in One DB

2014-03-03 Thread Brent Wood
We use this script as a proxy for psql, the user can run this followed by the schema's they want in the search path on the command line & the PGOPTIONS value sets it up for them... schema=`echo $@|sed 's/, /,/g'|tr " " ","|sed 's/,,/,/g'` #echo $schema export PGOPTIONS="-c search_path=$schema,pu

Re: [GENERAL] Role Inheritance Without Explicit Naming?

2014-03-03 Thread Adrian Klaver
On 03/02/2014 08:48 PM, François Beausoleil wrote: Hi all, I have four roles involved: meetphil - the database owner, should not login mpwebui - the role the web application logs in as, should have very limited privileges, but should be able to SET ROLE to a user that has the correct privileg

[GENERAL] execute table query in backend

2014-03-03 Thread Anh Pham
Hi, I am trying to extend the server backend by writing a new module. Basically, it tries to retrieve tuples from a specific table using some predefined qualifications (equivalent to "SELECT FROM WHERE" client sql statement ). Is there any quick or efficient way to do this? Many thanks :)

Re: [GENERAL] Why is varchar_pattern_ops needed?

2014-03-03 Thread Tom Lane
Albe Laurenz writes: > Is there anything that "varchar_pattern_ops" is needed for that > "text_pattern_ops" cannot provide? Lack of surprise? If you're creating a pattern index on a varchar column, you'd likely expect to need to mention varchar_pattern_ops. The idea that varchar is an alias fo

Re: [GENERAL] multiple results from a function

2014-03-03 Thread Merlin Moncure
On Thu, Feb 27, 2014 at 6:23 PM, James Harper wrote: > I see that I can use PQgetResult to get results from an async query, and this > allows for multiple results, presumably when the query is like "SELECT 123, > 456; SELECT 'ABC', 'DEF';". Is there a way for a C function, using SPI, to > send

Re: [GENERAL] 'tuple concurrently updated' error when granting permissions

2014-03-03 Thread Jason Daly
Thanks Tom et al, I appreciate the explanation. I am certainly more appreciative of what is going on behind the scenes now when I see 'tuple concurrently updated' errors. I couldn't initially find a way to grant select on all present *and future*tables in a schema, which is why we took the approac

Re: [GENERAL] Statistically significant poll results

2014-03-03 Thread Vincent Veyron
On Sun, 2 Mar 2014 15:28:31 +0100 Vincent Veyron wrote: > > http://www.databasefriends.co/2014/03/favorite-relational-database.html > I forgot to mention that this was posted on reddit : http://www.reddit.com/r/programming/comments/1zc5aw/favorite_relational_database_poll_results/ -- Sent

[GENERAL] Why is varchar_pattern_ops needed?

2014-03-03 Thread Albe Laurenz
I understand the difference between "*_ops" and "*_pattern_ops". But look at the following: CREATE TABLE test (v varchar(30)); CREATE INDEX test_v_ind ON test (v varchar_pattern_ops); CREATE INDEX test_t_ind ON test (v text_pattern_ops); SET enable_seqscan = off; EXPLAIN VERBOSE SELECT * FROM t