Re: [GENERAL] is there a way to deliver an array over column from a query window?

2013-04-26 Thread Rafał Pietrak
W dniu 04/26/2013 12:25 AM, Merlin Moncure pisze: On Thu, Apr 25, 2013 at 1:30 PM, Rafał Pietrak wrote: [--] No, I don't (manual: http://www.postgresql.org/docs/9.1/static/tutorial-window.html, have just one word "distinct" on that page, and it's not in the above context).

[GENERAL] Checking for changes in other tables

2013-04-26 Thread CR Lender
I have two tables with countries and persons living in those countries: create table countries ( codechar(2) not null primary key, eu boolean not null ); insert into countries values ('AR', false), ('BE', true), ('CH', f

Re: [GENERAL] Checking for changes in other tables

2013-04-26 Thread Misa Simic
two triggers?. one on eu_loans... and one on persons (if valid eu_loan - cant move...) 2013/4/26 CR Lender > I have two tables with countries and persons living in those countries: > > create table countries ( > codechar(2) not null primary key, > eu bo

Re: [GENERAL] Checking for changes in other tables

2013-04-26 Thread D'Arcy J.M. Cain
On Fri, 26 Apr 2013 11:01:28 +0200 CR Lender wrote: > I have two tables with countries and persons living in those > countries: > > create table countries ( > codechar(2) not null primary key, Isn't this redundant? Primary keys are always NOT NULL. > Enter a third table

Re: [GENERAL] Checking for changes in other tables

2013-04-26 Thread CR Lender
On 2013-04-26 12:17, D'Arcy J.M. Cain wrote: > On Fri, 26 Apr 2013 11:01:28 +0200 > CR Lender wrote: >> create table countries ( >> codechar(2) not null primary key, > > Isn't this redundant? Primary keys are always NOT NULL. Yes, I forgot to remove the NOT NULL when I

Re: [GENERAL] is there a way to deliver an array over column from a query window?

2013-04-26 Thread Merlin Moncure
On Fri, Apr 26, 2013 at 3:15 AM, Rafał Pietrak wrote: > W dniu 04/26/2013 12:25 AM, Merlin Moncure pisze: > >> On Thu, Apr 25, 2013 at 1:30 PM, Rafał Pietrak >> wrote: > > [--] > >>> >>> No, I don't (manual: >>> http://www.postgresql.org/docs/9.1/static/tutorial-window.html, h

Re: [GENERAL] Checking for changes in other tables

2013-04-26 Thread Richard Poole
On Fri, Apr 26, 2013 at 11:01:28AM +0200, CR Lender wrote: > Is there any way to ensure that all donors and recipients in eu_loans > are in the EU, without altering the countries and persons tables? One way to do this would be to add countries to the eu_loans table so it looks like this: create

[GENERAL] UPDATE using 3 medium-sized tables causes runaway hash table and fills disk

2013-04-26 Thread Rowan Collins
Hi All, I've come upon some very strange behaviour with an UPDATE query which causes Postgres to consume all the disk space on the server for no apparent reason. Basically, I'm trying to run an UPDATE involving three medium-sized tables (~60k rows each), which generates a query plan with thr

Re: [GENERAL] is there a way to deliver an array over column from a query window?

2013-04-26 Thread Rafał Pietrak
W dniu 04/26/2013 12:25 AM, Merlin Moncure pisze: [--] select array_agg(v order by v desc) from generate_series(1,3) v; also, 'distinct' select array_agg(distinct v order by v desc) from (select generate_series(1,3) v union all select generate_series(1,3)) q; [

[GENERAL] UPDATE using 3 medium-sized tables causes runaway hash table and fills disk

2013-04-26 Thread Rowan Collins
Hi All, I've come upon some very strange behaviour with an UPDATE query which causes Postgres to consume all the disk space on the server for no apparent reason. Basically, I'm trying to run an UPDATE involving three medium-sized tables (~60k rows each), which generates a query plan with thr

[GENERAL] Table containing only valid table names

2013-04-26 Thread Michael Graham
Hi all, I'm trying to create a table that contains only valid table names. I'm currently using reglass for the field type which works fine for when you are adding to the table (i.e. you can't add invalid tablesnames to the table). But it is still possible to leave the table in an invalid sta

Re: [GENERAL] Checking for changes in other tables

2013-04-26 Thread Richard Huxton
On 26/04/13 10:01, CR Lender wrote: I can add a trigger on eu_loans to check if Diane and Betty both live in the EU. The problem is how to prevent one of them from moving to a non-EU country (if they do, the loan has to be cancelled first). They are however allowed to move to other EU countries.

Re: [GENERAL] Table containing only valid table names

2013-04-26 Thread Richard Huxton
On 26/04/13 16:09, Michael Graham wrote: I'm pretty sure I can't do what I need as postgres doesn't support triggers on DDL but maybe I'm wrong. If you're still in development and not live, it'll be worth checking out 9.3 http://www.postgresql.org/docs/devel/static/event-triggers.html -- R

Re: [GENERAL] apt.postgresql.org broken dependency?

2013-04-26 Thread Richard Huxton
On 25/04/13 18:01, Martín Marqués wrote: Just tried upgrading and added the apt-postgresql.org repo to my Debian server (on testing now) and I got some backages like barman retained because some dependencies couldn't be satisfied. Los siguientes paquetes tienen dependencias incumplidas: barman

Re: [GENERAL] is there a way to deliver an array over column from a query window?

2013-04-26 Thread Tom Lane
=?ISO-8859-2?Q?Rafa=B3_Pietrak?= writes: > array_agg(distinct v order by v) -- works in postgres, but actually I need: > array_agg(distinct v order by v,x) -- which doesn't. (ERROR: > expressions must appear in argument list), Why do you think you need that? AFAICS, the extra order-by colum

Re: [GENERAL] Table containing only valid table names

2013-04-26 Thread salah jubeh
Hello, You can have the list of table names  from pg_class  such as SELECT c.relname as "Name" , FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r') AND n.nspname NOT IN  ('pg_toast', 'pg_catalog', 'information_schema') ; So, if you

[GENERAL] NOTIFY channel

2013-04-26 Thread Perry Smith
Hi, I'm curious what the design assumptions of the LISTEN / NOTIFY are. For example, would it work to have a thousand LISTEN channels open at the same time or would that be abusing the assumptions that were made? In short, I'm trying to understand if I need a few central LISTEN / NOTIFY chann

Re: [GENERAL] NOTIFY channel

2013-04-26 Thread Merlin Moncure
On Fri, Apr 26, 2013 at 11:30 AM, Perry Smith wrote: > Hi, > > I'm curious what the design assumptions of the LISTEN / NOTIFY are. For > example, would it work to have a thousand LISTEN channels open at the same > time or would that be abusing the assumptions that were made? In short, I'm > t

Re: [GENERAL] is there a way to deliver an array over column from a query window?

2013-04-26 Thread Rafał Pietrak
W dniu 04/26/2013 05:25 PM, Tom Lane pisze: =?ISO-8859-2?Q?Rafa=B3_Pietrak?= writes: array_agg(distinct v order by v) -- works in postgres, but actually I need: array_agg(distinct v order by v,x) -- which doesn't. (ERROR: expressions must appear in argument list), Why do you think you need

Re: [GENERAL] NOTIFY channel

2013-04-26 Thread Tom Lane
Perry Smith writes: > I'm curious what the design assumptions of the LISTEN / NOTIFY are. For > example, would it work to have a thousand LISTEN channels open at the same > time or would that be abusing the assumptions that were made? In short, I'm > trying to understand if I need a few centr

Re: [GENERAL] How to find current row number relative to window frame

2013-04-26 Thread Tom Lane
Art Ruszkowski writes: > I have a user defined aggregate function and in Sfunc I need to > reference current row number relative to window frame. Ideallly I would like > to have following construct: > select my_aggregate(x,current_row_number_relative_to window) over > (order by y rows between n

[GENERAL] Where to set search_path

2013-04-26 Thread Jeff Janes
I've have an application which uses the public schema for all of its relations. I want to change the name of the schema (in preparation to merging the database into that of another application, which also uses the public schema for its tables). I could qualify all of the tables and sequence with

Re: [GENERAL] NOTIFY channel

2013-04-26 Thread Misa Simic
" 2) notify does not work with pgbouncer (yet), although I have in the past had a private pgbouncer with functioning notify. " Is there a plan to make it work? Actually - stupid question - probably not important... But good to know... Listen connection doesn't need to work via pgbouncer... Tha

Re: [GENERAL] is there a way to deliver an array over column from a query window?

2013-04-26 Thread Misa Simic
SELECT DISTINCT a, b, c, array_agg(d) OVER (PARTITION BY c ) FROM ( SELECT a, b, c, d FROM testy where e <> 'email' and c='1035049' ORDER BY a, b, c, e ) t Doesnt give u desired result? On Friday, April 26, 2013, Rafał Pietrak wrote: > W dniu 04/26/2013 05:25 PM, Tom Lane pisze: > >> =

Re: [GENERAL] Where to set search_path

2013-04-26 Thread David Johnston
Jeff Janes wrote > I've have an application which uses the public schema for all of its > relations. > > I want to change the name of the schema (in preparation to merging the > database into that of another application, which also uses the public > schema for its tables). > > I could qualify all

Re: [GENERAL] is there a way to deliver an array over column from a query window?

2013-04-26 Thread Rafał Pietrak
W dniu 04/26/2013 09:54 PM, Misa Simic pisze: SELECT DISTINCT a, b, c, array_agg(d) OVER (PARTITION BY c ) FROM ( SELECT a, b, c, d FROM testy where e <> 'email' and c='1035049' ORDER BY a, b, c, e ) t Doesnt give u desired result? Hmm... actualy, it looks like it does. I wouldn't th

[GENERAL] Optimizing bulk update performance

2013-04-26 Thread Yang Zhang
It currently takes up to 24h for us to run a large set of UPDATE statements on a database, which are of the form: UPDATE table SET field1 = constant1, field2 = constant2, ... WHERE id = constid (We're just overwriting fields of objects identified by ID.) The tables have handfuls of indi

Re: [GENERAL] Optimizing bulk update performance

2013-04-26 Thread Gavin Flower
On 27/04/13 12:14, Yang Zhang wrote: It currently takes up to 24h for us to run a large set of UPDATE statements on a database, which are of the form: UPDATE table SET field1 = constant1, field2 = constant2, ... WHERE id = constid (We're just overwriting fields of objects identified

Re: [GENERAL] Optimizing bulk update performance

2013-04-26 Thread Yang Zhang
We're using Postgresql 9.1.9 on Ubuntu 12.04 on EBS volumes on m1.xlarge instances, which have: 15 GiB memory 8 EC2 Compute Units (4 virtual cores with 2 EC2 Compute Units each) 64-bit platform (Yes, we're moving to EBS Optimized instances + Provisioned IOPS volumes, but prelim. benchmarks sugges

[GENERAL] Basic question on recovery and disk snapshotting

2013-04-26 Thread Yang Zhang
We're running on EBS volumes on EC2. We're interested in leveraging EBS snapshotting for backups. However, does this mean we'd need to ensure our pg_xlog is on the same EBS volume as our data? (I believe) the usual reasoning for separating pg_xlog onto a separate volume is for performance. Howe

Re: [GENERAL] Optimizing bulk update performance

2013-04-26 Thread Gavin Flower
Please do not top post, the convention in these list are to add stuff at the end, apart from comments interspersed to make use of appropriate context! On 27/04/13 13:35, Yang Zhang wrote: We're using Postgresql 9.1.9 on Ubuntu 12.04 on EBS volumes on m1.xlarge instances, which have: 15 GiB me

Re: [GENERAL] Optimizing bulk update performance

2013-04-26 Thread Yang Zhang
On Fri, Apr 26, 2013 at 7:01 PM, Gavin Flower wrote: > Please do not top post, the convention in these list are to add stuff at the > end, apart from comments interspersed to make use of appropriate context! Noted, thanks. Anyway, any performance hints are greatly appreciated. > > > On 27/04/13

Re: [GENERAL] Optimizing bulk update performance

2013-04-26 Thread Tom Lane
Yang Zhang writes: > It currently takes up to 24h for us to run a large set of UPDATE > statements on a database, which are of the form: > UPDATE table SET field1 = constant1, field2 = constant2, ... WHERE > id = constid > (We're just overwriting fields of objects identified by ID.) Fo