[GENERAL] Evil Nested Loops

2009-06-02 Thread Ow Mun Heng
What can I do about this plan? HashAggregate (cost=8035443.21..8035445.17 rows=157 width=24) -> Nested Loop (cost=37680.95..7890528.72 rows=28982898 width=24) < suspect Join Filter: ((a.test_run_start_date_time >= date.start_time) AND (a.test_run_start_date_time <= date.end_ti

Re: [GENERAL] timestamp no fractional seconds

2009-06-02 Thread Scott Bailey
Grzegorz Jaśkiewicz wrote: what difference does the (0) make than ? is timestamp() a function than ?/ The (0) is setting the precision. Telling it to store 0 places for the fractional second. Much like setting scale and precision with numeric(6,2) Scott -- Sent via pgsql-general mailing list

Re: [GENERAL] ubuntu 9.04 and auto-start

2009-06-02 Thread Scott Marlowe
In ubuntu it'll have a version number as well since you can have >1 version installed, so... update-rc.d postgresql-8.3 defaults On Tue, Jun 2, 2009 at 5:22 PM, John Cheng wrote: > > The same way you add any other service in Ubuntu :) > > To add a service, use > > update-rc.d defaults > > In yo

Re: [GENERAL] warm standby with WAL shipping

2009-06-02 Thread Joshua D. Drake
On Tue, 2009-06-02 at 19:44 -0400, Geoffrey wrote: > > > pg_standby it self isn't a solution for warm standby. It is a component > > thereof. Also don't use SCP. Use rsync. Take a look at walmgr or > > PITRTools it will make your life easier. > > I still don't understand why the pg_standby code

Re: [GENERAL] warm standby with WAL shipping

2009-06-02 Thread Geoffrey
Joshua D. Drake wrote: On Tue, 2009-06-02 at 15:21 -0400, Geoffrey wrote: My problem is, I never see a *.history file, thus my script sits in a loop looking for it. I see the WAL files showing up on the archive server, but I don't see a *.history file. What am I missing? pg_standby it sel

Re: [GENERAL] ubuntu 9.04 and auto-start

2009-06-02 Thread John Cheng
The same way you add any other service in Ubuntu :) To add a service, use update-rc.d defaults In your case, it sounds like your servicename is postgresql, so you'd have update-rc.d postgresql defaults Try this URL: http://ubuntu.wordpress.com/2005/09/07/adding-a-startup-script-to-be-run-at

Re: [GENERAL] Change view definition - do not have to drop it

2009-06-02 Thread Brent Wood
I believe Postgres only checks the output types & column names for each column in the view. If, as you suggest, you convert these in your view to a standard appropriate datatype, you could then recreate the view with different input column datatypes: eg: in the countries_simpl table, cat is a

Re: [GENERAL] catalog view use to find DATABASE, LANGUAGE, TABLESPACE, SCHEMA, SEQUENCE privileges granted to user or role

2009-06-02 Thread Tom Lane
"Louis Lam" writes: > Thank you very much for the quick response. That was very helpful. I > was able to find the privilege on pg_language, pg_database and > pg_tablespace. I am looking for privileges granted to SCHEMA and > SEQUENCE. Do you by any change know what view or table I can queries

Re: [GENERAL] catalog view use to find DATABASE, LANGUAGE, TABLESPACE, SCHEMA, SEQUENCE privileges granted to user or role

2009-06-02 Thread Louis Lam
Hi Tom, Thank you very much for the quick response. That was very helpful. I was able to find the privilege on pg_language, pg_database and pg_tablespace. I am looking for privileges granted to SCHEMA and SEQUENCE. Do you by any change know what view or table I can queries to get privileges gr

Re: [GENERAL] Really out of memory?

2009-06-02 Thread Ben Chobot
On Tue, 2 Jun 2009, Martijn van Oosterhout wrote: It's got nothing to do with how much swap is in use. It's preventing you from allocating memory that *hypothetically* might not be available if every byte of allocated memory were actually used. For example, on my desktop I have 1GB of RAM of wh

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Tom Lane
Douglas Alan writes: > Hey, while I have you on the line, might you be so kind as to explain why > this query is so slow? Shouldn't it just fetch the first row in the table? > > explain analyze select * from maindb_astobject limit 1; Yeah ... >> QUERY >> PLAN >> >>

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Alvaro Herrera
Douglas Alan escribió: > Hey, while I have you on the line, might you be so kind as to explain why > this query is so slow? Shouldn't it just fetch the first row in the table? > What could be faster than that? > > explain analyze select * from maindb_astobject limit 1; > > > >

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Douglas Alan
On Tue, Jun 2, 2009 at 9:52 AM, Tom Lane wrote: > > delete from pg_statistic > where (starelid, staattnum) in > (select attrelid, attnum from pg_attribute > where attrelid = 'my_relation'::regclass and attname = 'my_attribute'); > > regclass knows about schemas and search paths, so stuff like

Re: [GENERAL] Really out of memory?

2009-06-02 Thread Martijn van Oosterhout
On Tue, Jun 02, 2009 at 11:45:11AM -0700, Ben Chobot wrote: > On Tue, 2 Jun 2009, Martijn van Oosterhout wrote: > >> On Tue, Jun 02, 2009 at 11:10:04AM -0700, Ben Chobot wrote: > >>> May 31 02:59:40 sfmelwss postgres[30103]: [1-1] ERROR: out of memory >>> May 31 02:59:40 sfmelwss postgres[30103]:

Re: [GENERAL] warm standby with WAL shipping

2009-06-02 Thread Geoffrey
Joshua D. Drake wrote: On Tue, 2009-06-02 at 15:21 -0400, Geoffrey wrote: My problem is, I never see a *.history file, thus my script sits in a loop looking for it. I see the WAL files showing up on the archive server, but I don't see a *.history file. What am I missing? pg_standby it sel

Re: [GENERAL] Really out of memory?

2009-06-02 Thread Tom Lane
Ben Chobot writes: > On Tue, 2 Jun 2009, Tom Lane wrote: >> You don't have /proc//limits ? > Nope. I'd like to believe I would consider that "obviously relevant." :) Next best thing I can think of is to stick "ulimit -a >/tmp/mylimits" into the postgres initscript and restart. If the initscript

Re: [GENERAL] warm standby with WAL shipping

2009-06-02 Thread Geoffrey
Geoffrey wrote: Joshua D. Drake wrote: On Tue, 2009-06-02 at 15:21 -0400, Geoffrey wrote: My problem is, I never see a *.history file, thus my script sits in a loop looking for it. I see the WAL files showing up on the archive server, but I don't see a *.history file. What am I missing?

Re: [GENERAL] loops

2009-06-02 Thread Merlin Moncure
On Tue, Jun 2, 2009 at 12:24 PM, John R Pierce wrote: > Esneiker wrote: >> >> Hello, can anybody tell me how to do loops in postgres? >> > > SQL, the query language, has no such control structures.  SQL is a > 'declarative' language rather than a procedural one. > > pl/pgsql stored procedures do,

Re: [GENERAL] Really out of memory?

2009-06-02 Thread Ben Chobot
On Tue, 2 Jun 2009, Tom Lane wrote: Is there a way to see what the limits are for a given pid? I don't see anything obviously relevant in /proc// You don't have /proc//limits ? Nope. I'd like to believe I would consider that "obviously relevant." :) This server is running 2.6.20-1.2962.

Re: [GENERAL] Really out of memory?

2009-06-02 Thread Tom Lane
Ben Chobot writes: >> hey, is any ULIMIT in effect for the postgres process? > Not that I can tell. There's nothing special in /etc/init.d/postgresql or > /etc/sysconfig/pgsql/postgresql, and ulimit -a shows: That tells you the limits for your interactive shell, but a daemon might be started und

Re: [GENERAL] catalog view use to find DATABASE, LANGUAGE, TABLESPACE, SCHEMA, SEQUENCE privileges granted to user or role

2009-06-02 Thread Tom Lane
"Louis Lam" writes: > In PostgreSQL, there are some grant privileges like grant on SEQUENCE, > DATABASE, LANGUAGE, SCHEMA and DATABASE. I grant and revoke these > privleges on my PostgreSQL on Windows and Linux OS. But once it is > granted, how do I find out what user and role are granted with t

Re: [GENERAL] warm standby with WAL shipping

2009-06-02 Thread Geoffrey
Joshua D. Drake wrote: On Tue, 2009-06-02 at 15:21 -0400, Geoffrey wrote: My problem is, I never see a *.history file, thus my script sits in a loop looking for it. I see the WAL files showing up on the archive server, but I don't see a *.history file. What am I missing? pg_standby it sel

Re: [GENERAL] Really out of memory?

2009-06-02 Thread Ben Chobot
On Tue, 2 Jun 2009, Tom Lane wrote: It's possible you are running out of 32-bit address space in the backend process, but what seems more likely is that the per-process ulimit is unreasonably small. I only have 1GB in the machine, and another 1GB of swap, so running out of 32-bit address spac

[GENERAL] lc_messages 8.3.7

2009-06-02 Thread pribram pribram
Hi, Postgresql 8.2.13 on Windows (it's correct, "Leden" is the Czech translation of "January"): postgres=# SET lc_messages=en;select to_char('2006/01/01'::timestamp, 'TMMonth'); SET to_char - January postgres=# SET lc_messages=cs;select to_char('2006/01/01'::timestamp, 'TMMonth'); S

[GENERAL] lc_messages on 8.3.7

2009-06-02 Thread pribram pribram
Hi, Postgresql 8.2.13 on Windows (it's correct, "Leden" is the Czech translation of "January"): postgres=# SET lc_messages=en;select to_char('2006/01/01'::timestamp, 'TMMonth'); SET to_char - January postgres=# SET lc_messages=cs;select to_char('2006/01/01'::timestamp, 'TMMonth'); S

Re: [GENERAL] Change view definition - do not have to drop it

2009-06-02 Thread Emi Lu
Now I need update view1 definition to create or replace view view1 as select col1, col2 from new_table; However, col1 in new_table is not bpchar. This gives me headache! There are tens of dependent views based on view1, so I cannot just drop view1 and recreate it. How I can redefine view1

Re: [GENERAL] Really out of memory?

2009-06-02 Thread Ben Chobot
On Tue, 2 Jun 2009, John R Pierce wrote: Ben Chobot wrote: May 31 02:59:40 sfmelwss postgres[30103]: [1-1] ERROR: out of memory May 31 02:59:40 sfmelwss postgres[30103]: [1-2] DETAIL: Failed on request of size 16777212. Thats a 16MB request is that your work_mem size or something by any

Re: [GENERAL] warm standby with WAL shipping

2009-06-02 Thread Joshua D. Drake
On Tue, 2009-06-02 at 15:21 -0400, Geoffrey wrote: > My problem is, I never see a *.history file, thus my script sits in a > loop looking for it. I see the WAL files showing up on the archive > server, but I don't see a *.history file. > > What am I missing? pg_standby it self isn't a solutio

[GENERAL] warm standby with WAL shipping

2009-06-02 Thread Geoffrey
I'm trying to set up a warm standby via WAL shipping. I'm digging through the source of pg_standby.c to determine the proper method. Since we are using scp to access the archive files, pg_standby doesn't provide a solution to our problem. From reading the comments in pg_standby.c, I see: 'Ch

[GENERAL] catalog view use to find DATABASE, LANGUAGE, TABLESPACE, SCHEMA, SEQUENCE privileges granted to user or role

2009-06-02 Thread Louis Lam
Hi, In PostgreSQL, there are some grant privileges like grant on SEQUENCE, DATABASE, LANGUAGE, SCHEMA and DATABASE. I grant and revoke these privleges on my PostgreSQL on Windows and Linux OS. But once it is granted, how do I find out what user and role are granted with these privileges?

Re: [GENERAL] Schema, databse, or tables in different system folder

2009-06-02 Thread Chris Browne
"Carlos Oliva" writes: > Is there a way to create a database or a table of a database in its own > folder? We are looking for ways to backup the sytem files of the database > to tape and one to exclude some tables from this backup. We can selectively > backup folders of the file system so we

Re: [GENERAL] Warm standby: 1 to N

2009-06-02 Thread Bruce Momjian
Yaroslav Tykhiy wrote: > Hi All, > > Let's consider the following case: WAL segments from a master have > been shipped to N warm standby servers, and now the master fails. > Using this or that mechanism, one of the warm standbys takes over and > becomes the new master. Now the question is what

Re: [GENERAL] Change view definition - do not have to drop it

2009-06-02 Thread Tom Lane
Emi Lu writes: > Now I need update view1 definition to > create or replace view view1 as select col1, col2 from new_table; > However, col1 in new_table is not bpchar. This gives me headache! There > are tens of dependent views based on view1, so I cannot just drop view1 > and recreate it. > Ho

Re: [GENERAL] Really out of memory?

2009-06-02 Thread Tom Lane
Ben Chobot writes: > May 31 02:59:40 sfmelwss postgres[30103]: [1-1] ERROR: out of memory > May 31 02:59:40 sfmelwss postgres[30103]: [1-2] DETAIL: Failed on request of > size 16777212. So the kernel isn't letting PG have any more memory. > That seems pretty self-explainitory. But I'm not so

Re: [GENERAL] Really out of memory?

2009-06-02 Thread Ben Chobot
On Tue, 2 Jun 2009, Martijn van Oosterhout wrote: On Tue, Jun 02, 2009 at 11:10:04AM -0700, Ben Chobot wrote: May 31 02:59:40 sfmelwss postgres[30103]: [1-1] ERROR: out of memory May 31 02:59:40 sfmelwss postgres[30103]: [1-2] DETAIL: Failed on request of size 16777212. Add even more swa

Re: [GENERAL] Really out of memory?

2009-06-02 Thread John R Pierce
Ben Chobot wrote: May 31 02:59:40 sfmelwss postgres[30103]: [1-1] ERROR: out of memory May 31 02:59:40 sfmelwss postgres[30103]: [1-2] DETAIL: Failed on request of size 16777212. Thats a 16MB request is that your work_mem size or something by any chance? 02:30:01 AM kbmemfree kbmemused %

Re: [GENERAL] Really out of memory?

2009-06-02 Thread Martijn van Oosterhout
On Tue, Jun 02, 2009 at 11:10:04AM -0700, Ben Chobot wrote: > I have a linux postgres server in the field. Its version is: > > PostgreSQL 8.2.4 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.1.1 > 20070105 (Red Hat 4.1.1-51) > > (aka postgresql-8.2.4-1PGDG) > > A few days ago, its log start

[GENERAL] Change view definition - do not have to drop it

2009-06-02 Thread Emi Lu
Original view1 (col1 bpchar, col2 varchar). Now I need update view1 definition to create or replace view view1 as select col1, col2 from new_table; However, col1 in new_table is not bpchar. This gives me headache! There are tens of dependent views based on view1, so I cannot just drop view1 an

Re: [GENERAL] Schema, databse, or tables in different system folder

2009-06-02 Thread Chris Browne
"Carlos Oliva" writes: > Is there a way to create a database or a table of a database in its own > folder? We are looking for ways to backup the sytem files of the database > to tape and one to exclude some tables from this backup. We can selectively > backup folders of the file system so we

[GENERAL] Really out of memory?

2009-06-02 Thread Ben Chobot
I have a linux postgres server in the field. Its version is: PostgreSQL 8.2.4 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.1.1 20070105 (Red Hat 4.1.1-51) (aka postgresql-8.2.4-1PGDG) A few days ago, its log started showing this: May 31 02:59:40 sfmelwss postgres[30103]: [1-1] ERROR:

Re: [GENERAL] Forcing the use of one index instead other.

2009-06-02 Thread Tom Lane
"Edmundo Robles L." writes: > I have two index with a same field into them like this: > create index numberfail on Events (numberfail); > and > create index failtype on Events (numberfail,eventtype); > then i ran explain analyze and always took the numberfail index but i wish the failtyp

Re: [GENERAL] Forcing the use of one index instead other.

2009-06-02 Thread Ries van Twisk
You could remove the index numberfail. PG can use the index failtype in the case you just need a where clause on numberfail also Ries Hello there! I have two index with a same field into them like this: create index numberfail on Events (numberfail); and create index failtype on

Re: [GENERAL] timestamp no fractional seconds

2009-06-02 Thread Grzegorz Jaśkiewicz
what difference does the (0) make than ? is timestamp() a function than ?/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] timestamp no fractional seconds

2009-06-02 Thread Tom Lane
=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= writes: > what difference does the (0) make than ? is timestamp() a function than ?/ No, it's a type. See http://www.postgresql.org/docs/8.3/static/datatype-datetime.html regards, tom lane -- Sent via pgsql-general mailing list (pgs

[GENERAL] Forcing the use of one index instead other.

2009-06-02 Thread Edmundo Robles L.
Hello there! I have two index with a same field into them like this: create index numberfail on Events (numberfail); and create index failtype on Events (numberfail,eventtype); then i ran explain analyze and always took the numberfail index but i wish the failtype index; this is

Re: [GENERAL] timestamp no fractional seconds

2009-06-02 Thread Tom Lane
Brandon Metcalf writes: > I suppose my question really boils down to how do I cast the timestamp > with no fractional seconds part? For example, if I have a table where > I haven't put a limit on the fractional seconds part, how would I > select the timestamp without fractional seconds? Cast to

Re: [GENERAL] timestamp no fractional seconds

2009-06-02 Thread Brandon Metcalf
p == pavel.steh...@gmail.com writes: p> Hello p> use timestamp(0) p> timestamp[0] means array of timestamps Of course. I was reading the documentation wrong and taking the [] as literal instead of it meaning an optional parameter as it always does. Thanks. -- Brandon -- Sent via pgsql

Re: [GENERAL] timestamp no fractional seconds

2009-06-02 Thread Pavel Stehule
2009/6/2 Brandon Metcalf : > b == bran...@geronimoalloys.com writes: > >  b> I need to create a table with two columns of type timestamp but I >  b> don't want to store any fractional part of the seconds field.  So, >  b> I created a table with: > >  b>   CREATE TABLE timeclock ( >  b>       timecl

Re: [GENERAL] timestamp no fractional seconds

2009-06-02 Thread Brandon Metcalf
b == bran...@geronimoalloys.com writes: b> I need to create a table with two columns of type timestamp but I b> don't want to store any fractional part of the seconds field. So, b> I created a table with: b> CREATE TABLE timeclock ( b> timeclock_id SERIAL, b> employee_id I

Re: [GENERAL] timestamp no fractional seconds

2009-06-02 Thread Pavel Stehule
Hello use timestamp(0) timestamp[0] means array of timestamps regards Pavel Stehule 2009/6/2 Brandon Metcalf : > I need to create a table with two columns of type timestamp but I > don't want to store any fractional part of the seconds field.  So, > I created a table with: > >  CREATE TABLE tim

Re: [GENERAL] timestamp no fractional seconds

2009-06-02 Thread hubert depesz lubaczewski
On Tue, Jun 02, 2009 at 11:26:05AM -0500, Brandon Metcalf wrote: > Am I creating the table correctly? If so, how do I insert or update > rows? timestamp[] is array of timestamps. there is no way to make timestamps "without subsecond data". you can add trigger to remove unneeded parts of the dat

[GENERAL] timestamp no fractional seconds

2009-06-02 Thread Brandon Metcalf
I need to create a table with two columns of type timestamp but I don't want to store any fractional part of the seconds field. So, I created a table with: CREATE TABLE timeclock ( timeclock_id SERIAL, employee_id INTEGER, clockin TIMESTAMP[0]NOT NULL, clock

Re: [GENERAL] loops

2009-06-02 Thread John R Pierce
Esneiker wrote: Hello, can anybody tell me how to do loops in postgres? SQL, the query language, has no such control structures. SQL is a 'declarative' language rather than a procedural one. pl/pgsql stored procedures do, however, as they embed SQL in a procedural context. depesz posted

Re: [GENERAL] loops

2009-06-02 Thread hubert depesz lubaczewski
On Tue, Jun 02, 2009 at 11:32:03AM -0400, Esneiker wrote: > Hello, can anybody tell me how to do loops in postgres? As usually, the fine manual: http://www.postgresql.org/docs/current/interactive/plpgsql-control-structures.html Best regards, depesz -- Linkedin: http://www.linkedin.com/in/depe

[GENERAL] loops

2009-06-02 Thread Esneiker
Hello, can anybody tell me how to do loops in postgres? Thanks. Ing. Esneiker Enriquez Cabrera. Excelencia en Software. Desoft S.A. en Ciego de Ávila. Joaquín de Agüero Esq. Calle 2. Ciego de Ávila. Cuba. email: eenriq...@cav.desoft.cu

Re: [GENERAL] is generate_series_timestamp() exposed on public api ?

2009-06-02 Thread Grzegorz Jaśkiewicz
foo, nevermind - it is there on 8.4, but wasn't on 8.3 ;) -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Schema, databse, or tables in different system folder

2009-06-02 Thread A. Kretschmer
In response to Carlos Oliva : > Is there a way to create a database or a table of a database in its own Database or table? > folder? We are looking for ways to backup the sytem files of the database > to tape and one to exclude some tables from this backup. We can selectively > backup folde

Re: [GENERAL] Schema, databse, or tables in different system folder

2009-06-02 Thread Grzegorz Jaśkiewicz
yes, it is called tablespace. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] is generate_series_timestamp() exposed on public api ?

2009-06-02 Thread Grzegorz Jaśkiewicz
I found this function in src/backend/utils/adt/timestamp.c called generate_series_timestamp(timestamp, timestamp, interval). It might be useful sometimes, but doesn't look like it is exposed to public api. Anyone knows anything ? -- GJ -- Sent via pgsql-general mailing list (pgsql-general@postg

Re: [GENERAL] Accessing pg_controldata information from SQL

2009-06-02 Thread Bruce Momjian
Massa, Harald Armin wrote: > Hello, > > is there any way to acess the pg_controldata information via SQL? > > (running pg_controldata via shell needs file access to the postgresql data > dictionary, which is usually not given) Some of the settings have read-only variables that appear in SHOW ALL

[GENERAL] Schema, databse, or tables in different system folder

2009-06-02 Thread Carlos Oliva
Is there a way to create a database or a table of a database in its own folder? We are looking for ways to backup the sytem files of the database to tape and one to exclude some tables from this backup. We can selectively backup folders of the file system so we figure that if we can create a

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Tom Lane
Douglas Alan writes: > delete from pg_statistic s > where exists ( select 1 > from pg_class as c, pg_attribute as a > where a.attrelid = c.relfilenode > and s.starelid = c.relfilenode > and s.staattnum = a.attnum > and c.relname = 'maindb_astobject' > and attname = 'survey_id' > ); Use c.oid, not

Re: [GENERAL] newbie table design question

2009-06-02 Thread Merlin Moncure
2009/6/1 Andrew Smith : > 2009/6/2 björn lundin >> >> > CREATE TABLE "DataImport" >> > ( >> >   "DataImportID" serial NOT NULL PRIMARY KEY, >> >   "Time" timestamp without time zone NOT NULL, >> >   "ID_ABC" integer NOT NULL, >> >   "ID_DEF" integer NOT NULL, >> >   "ID_HIJ" integer NOT NULL, >> >

Re: [GENERAL] newbie table design question

2009-06-02 Thread Grzegorz Jaśkiewicz
On Tue, Jun 2, 2009 at 2:27 PM, Merlin Moncure wrote: > _IF_ arrays fit your requirements, they are an extremely compact and > efficient way to store your data.  The requirements are exact..you > can't update or extract a single piece of data out of a block > efficiently.  While indexing techniqu

Re: [GENERAL] Query timeout in dbcp

2009-06-02 Thread Martin Gainty
http://pgtclng.projects.postgresql.org/pgtcldocs-20070115/pgtcl-example-asyncevent.html an asynchronous callback that is called after specified number of secs and cancels the query re-posting to postgres users list for more clarification Martin Gainty __

Re: [GENERAL] newbie table design question

2009-06-02 Thread Merlin Moncure
On Mon, Jun 1, 2009 at 8:41 AM, Sam Mason wrote: > On Mon, Jun 01, 2009 at 06:53:30AM -0500, Chris Spotts wrote: >> I just finished doing something very close to this - not quite once per >> minute, but close.  I started off with an array of integers and after about >> a month of it, I'm having to

Re: [GENERAL] Foreign Key question

2009-06-02 Thread Bill Moran
In response to Dave Clarke : > > I have a table that I'm trying to refactor and I'm by no means a SQL > expert (apologies if I'm posting to the wrong group). The table in > question has a column that allows NULLs. I want to move that column > into a separate table and set up a FK reference back to

[GENERAL] New install Error : FATAL: could not create lock file "postmaster.pid"

2009-06-02 Thread Václav Kyselý
Hi, I have problem with Postgre SQL 8.3.7 (beta the same). I have at event log : "%t FATAL: could not create lock file "postmaster.pid": Permission denied" At PgAdmin I cannot Connect to database : it writing "false ..." - My systém Windows XP Pro SP3 - i have admin privilegs on systém - I try

[GENERAL] Issue with Inheritance and Partitioning and grants

2009-06-02 Thread Maxim Boguk
I have one large table Partitioned via timestamp on monthly parts. And i use Inheritance on it. So structure look like: Parent table: entity_log ... And lots child tables like: entity_log_2002_01 ... Check constraints: "chk_entity_log_2002_01" CHECK (ctime >= '2002-01-01 00:00:00'::timestamp

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Isak Hansen
On Mon, Jun 1, 2009 at 8:20 PM, Douglas Alan wrote: > I'd like to manually alter the statistics for a column, as for the column in > question the statistics are causing Postgres to do the wrong thing for my > purposes. (I.e., a Seq Scan, rather than an Index Scan.)  If someone can > tell me how to

Re: [GENERAL] Foreign Key question

2009-06-02 Thread Daniel Schuchardt
Hi Dave, that makes sense. You should read the documentation about FK. They can be 1:n, 1:1, n:1. Normally i would make a unique field in each table to avoid complex PK/FK. Eg a serial column. Dave Clarke schrieb: Hello I have a table that I'm trying to refactor and I'm by no means a SQL ex

Re: [GENERAL] Order by parameter inside pgsql function ignored

2009-06-02 Thread A. Kretschmer
In response to Anton Marchenkov : > Hi! > > I'm trying to use the order by parameter inside a function, but it is > ignored. Any ideas why? And how can I sort by external parameters inside > pgsql function? You an use dynamic SQL with EXECUTE, for instance: create or replace function my_order

Re: [GENERAL] Order by parameter inside pgsql function ignored

2009-06-02 Thread Leif B. Kristensen
On Tuesday 2. June 2009, Anton Marchenkov wrote: >CREATE OR REPLACE FUNCTION "public"."test_order_by" (sort_key varchar) >RETURNS SETOF "customers"."customers_with_mark_deleted" AS >$body$ >DECLARE > rec RECORD; >BEGIN > FOR rec IN SELECT * FROM customers.customers_with_mark_deleted c >

Re: [GENERAL] Order by parameter inside pgsql function ignored

2009-06-02 Thread Leif B. Kristensen
On Tuesday 2. June 2009, Anton Marchenkov wrote: >Hi! > >I'm trying to use the order by parameter inside a function, but it is >ignored. Any ideas why? And how can I sort by external parameters > inside pgsql function? What's the problem with SELECT * FROM foo(myvar) ORDER BY sort_key ASC ? If

[GENERAL] Order by parameter inside pgsql function ignored

2009-06-02 Thread Anton Marchenkov
Hi! I'm trying to use the order by parameter inside a function, but it is ignored. Any ideas why? And how can I sort by external parameters inside pgsql function? CREATE OR REPLACE FUNCTION "public"."test_order_by" (sort_key varchar) RETURNS SETOF "customers"."customers_with_mark_deleted" AS

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Douglas Alan
If you want something done right, I guess you have to do it yourself! Here's the answer to my question. It works great! Or so it seems to: delete from pg_statistic s where exists ( select 1 from pg_class as c, pg_attribute as a where a.attrelid = c.relfilenode and s.starelid = c.relfilenode and