Re: [GENERAL] Function returning 2 columns evaluated twice when both columns are needed

2009-10-18 Thread Gerhard Wiesinger
On Sun, 18 Oct 2009, Tom Lane wrote: Gerhard Wiesinger writes: Since getSums() is a cursor and is complex and takes long time getSums should only be evaluated once. Is there a better solution available to get both columns from the function in the select? You need a sub-select, along the line

[GENERAL] unsubscribe

2009-10-18 Thread ddh
unsubscribe

Re: [GENERAL] Catalog help

2009-10-18 Thread Scott Ribe
> Well, you can't. Each database has it's own pg_class (and other) > catalog table and tables in any given database are not visible from > others. Ah well of course, that's the answer to my question. Only the entries for the tables in the database to which I am currently connected are visible, so

Re: [GENERAL] Catalog help

2009-10-18 Thread Erik Jones
On Oct 18, 2009, at 5:02 PM, Scott Ribe wrote: I've figured out how to use the catalogs to get from table name to name of file(s) on disk, and also the toast files. But what I don't see is how to handle the case where a cluster contains multiple databases with tables of the same name--I fa

[GENERAL] Catalog help

2009-10-18 Thread Scott Ribe
I've figured out how to use the catalogs to get from table name to name of file(s) on disk, and also the toast files. But what I don't see is how to handle the case where a cluster contains multiple databases with tables of the same name--I fail to follow the oid keys somewhere along the way. I do

Re: [GENERAL] db not dumping properly, or at least not restoring

2009-10-18 Thread Brent Wood
Hi Kirk, How's it going? You can use pg_dump on the local host to access a db on a remote host, & as the output is just SQL, pipe this directly intp a psql command, thus replicating/migrating a database. One note, if you are doing this with a PostGIS db, I find it works better to create an em

Re: [GENERAL] Function returning 2 columns evaluated twice when both columns are needed

2009-10-18 Thread Tom Lane
Gerhard Wiesinger writes: > Since getSums() is a cursor and is complex and takes long time getSums > should only be evaluated once. Is there a better solution available to > get both columns from the function in the select? You need a sub-select, along the lines of SELECT cur_date, (gs).su

[GENERAL] Function returning 2 columns evaluated twice when both columns are needed

2009-10-18 Thread Gerhard Wiesinger
Hello, I'm having a problem with the following: CREATE TYPE Sums AS (sum_m1 double precision, sum_m2 double precision); CREATE TYPE date_m1_m2 AS (cur_date date, sum_m1 double precision, sum_m2 double precision); CREATE OR REPLACE FUNCTION getSums(IN start_ts timestamp with time zone, IN stop

Re: [GENERAL] Delete fails with out of memory

2009-10-18 Thread Simon Riggs
On Sat, 2009-10-17 at 20:02 -0700, yuliada wrote: > I have a large database and I'm trying to execute delete on a table which > has some related tables. The query fails with following error: > ERROR: out of memory > DETAIL: Failed on request of size 1048576. > > I'm new to postgresql and I'm cu

Re: [GENERAL] How ad an increasing index to a query result?

2009-10-18 Thread Raymond O'Donnell
On 18/10/2009 11:30, Alban Hertroys wrote: > Short of enumerating those results in your application, the easiest > approach is probably to wrap your query in a join with generate_series > like so: > > SELECT a, s.b > FROM ( > SELECT a > FROM table1 > ORDER BY a DESC LIMIT 5 > ) AS t1,

Re: [GENERAL] Determining dead/unused space in a table?

2009-10-18 Thread Tom Lane
David Spadea writes: > I'm looking to do some reporting on tablespace usage, and wanted to be able > to determine how much of the space a table physically occupies is actually > in use. contrib/pgstattuple can help you with this. regards, tom lane -- Sent via pgsql-gene

[GENERAL] Determining dead/unused space in a table?

2009-10-18 Thread David Spadea
Hi all, I'm looking to do some reporting on tablespace usage, and wanted to be able to determine how much of the space a table physically occupies is actually in use. 1. I know I can get n_live_tup and n_dead_tup from pg_stat_all_tables, but I don't think that really answers the question entirely

Re: [GENERAL] How ad an increasing index to a query result?

2009-10-18 Thread Thom Brown
2009/10/14 Josip : > Hello, > > Could somebody please try to help me with this problem? > So, let’s say that I have the query: > > CREATE SEQUENCE c START 1; > > SELECT a, nextval('c') as b > FROM table1 > ORDER BY a DESC LIMIT 5; > > I.e., I want to pick the 5 largest entries from table1 and show

Re: [GENERAL] How ad an increasing index to a query result?

2009-10-18 Thread Alban Hertroys
On 14 Oct 2009, at 19:05, Josip wrote: Hello, Could somebody please try to help me with this problem? I.e., I want to pick the 5 largest entries from table1 and show them alongside a new index column that tells the position of the entry. For example: a | b 82 | 5 79 | 4 34 | 3 12

Re: [GENERAL] Delete fails with out of memory

2009-10-18 Thread Filip Rembiałkowski
2009/10/18 yuliada > > Hello > > I have a large database and I'm trying to execute delete on a table which > has some related tables. The query fails with following error: > ERROR: out of memory > DETAIL: Failed on request of size 1048576. > > I'm new to postgresql and I'm currently trying to f