[GENERAL] Explain returns extremely high cost

2006-08-15 Thread Andrii Vasyliev
Hi! I have a database just recreated from scratch with SQL script. (My PostgreSQL version is 8.1.3). All of the tables are pretty empty, but that's what I've got with explain: EXPLAIN SELECT * FROM account; QUERY PLAN

[GENERAL] Excluding a table from pg_dump

2006-08-15 Thread Kari Lavikka
Hi, I think there has been some talk about this missing feature since 2001, but anyway.. I have a database which contains about 500M rows and the nightly dump takes about six hours. Size of the compressed dump is ~30GB. The biggest tables are: relname| reltuples

Re: [GENERAL] Explain returns extremely high cost

2006-08-15 Thread Martijn van Oosterhout
On Tue, Aug 15, 2006 at 10:14:49AM +0300, Andrii Vasyliev wrote: > Hi! > > I have a database just recreated from scratch with SQL script. > (My PostgreSQL version is 8.1.3). > All of the tables are pretty empty, but that's what I've got with explain: > > EXPLAIN SELECT * FROM account; >

[GENERAL] Partial indexes Vs standard indexes : Insert performance

2006-08-15 Thread MaXX
Hi, I just want to verify if I'm understanding this correctly: I have a table in which I store log from my firewall. For the protocol column (3 distinct values: TCP ~82%, UDP ~17%, ICMP ~1%, the table contains 1.7M rows), I use a partial index to find ICMP packets faster. In my understanding

Re: [GENERAL] Connection string

2006-08-15 Thread Michael Fuhr
On Sun, Aug 13, 2006 at 10:30:24AM +0200, Michael Meskes wrote: > On Fri, Aug 11, 2006 at 04:40:36PM -0600, Michael Fuhr wrote: > > Will you take care of it or should I submit a patch? I've noticed > > I you have the time to write the patch I woul dappreciate it. I'll submit a patch. However, i

Re: [GENERAL] Excluding a table from pg_dump

2006-08-15 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > The database contains several schemas and excluding "comment_archive" by > moving it to different schema doesn't sound very convenient. pg_dump > doesn't have an option to dump multiple schemas at once. > > Are there any working "-X" patches for pg

Re: [GENERAL] Connection string

2006-08-15 Thread Michael Meskes
On Tue, Aug 15, 2006 at 05:59:23AM -0600, Michael Fuhr wrote: > I'll submit a patch. However, in the case of string literals not > working, is that a documentation bug or a code bug? Are they > supposed to work? You shoudl be able to use a string constant or a char * variable as database name. T

Re: [GENERAL] Excluding a table from pg_dump

2006-08-15 Thread Ron St-Pierre
Greg Sabino Mullane wrote: The database contains several schemas and excluding "comment_archive" by moving it to different schema doesn't sound very convenient. pg_dump doesn't have an option to dump multiple schemas at once. Are there any working "-X" patches for pg_dump or does anyone have oth

[GENERAL] Using SETOF functions in SQL

2006-08-15 Thread Pavel Velikhov
Hi!  Is it possible to use a function that returns SETOF and doesn't take constant parameters?I have a function 'connections(id1 bigint, id2 bigint) returns setof text' that I use to list all paths from id1 to id2. However, I haven't figured out a way to call the function with non-constant function

[GENERAL]

2006-08-15 Thread Max
Hello all. I'm working on a kind of permissions management and I would like to add restrictions on SELECT statements depending on certain fields of a row. tablename : id, perm_field1, .. .. perm_field2, data_field1, data_field2, ... Do you know if it is possible to write such things : SEL

Re: [GENERAL] Using SETOF functions in SQL

2006-08-15 Thread Jeff Davis
On Tue, 2006-08-15 at 12:38 +0100, Pavel Velikhov wrote: > SELECT t1.node, t2.node, path FROM t1,t2, connections(t1.id, t2.id) as > path > > I get the notorious: ERROR: subquery in FROM may not refer to other > relations of same query level > The FROM list must be a list of relations, but in t

Re: [GENERAL] Connection string

2006-08-15 Thread Harpreet Dhaliwal
Hi Micheal,sudde2nly a problem has cropped up in my connection.Its kind of strange.ECPGdegug(1, stderr) says[9852]: connect: cold not open database dbxyz on 192.168.0.123 port 5432 for user jsb in line 16 could not connect to server: No route to host Is the server running on host "192.168.

[GENERAL] Unable to Start PostgreSQL 8.1.4 on Windows XP

2006-08-15 Thread Ludwig Isaac Lim
Hi: I installed PostgreSQL 8.1.0 on my computer running on Windows XP Service Pack 2 last April. It works fine (I don't use the database everyday though). Today, after being unable to connect to the server, I realized there must be something wrong. Looking at the logs I found out that there we

Re: [GENERAL] Connection string

2006-08-15 Thread Harpreet Dhaliwal
in my previous mail both the ip addressed should be read as 192.168.0.123thanksharpreetOn 8/15/06, Harpreet Dhaliwal < [EMAIL PROTECTED]> wrote:Hi Micheal,sudde2nly a problem has cropped up in my connection. Its kind of strange.ECPGdegug(1, stderr) says[9852]: connect: cold not open database db

Re: [GENERAL] Partial indexes Vs standard indexes : Insert

2006-08-15 Thread Jeff Davis
On Tue, 2006-08-15 at 13:13 +0200, MaXX wrote: > Hi, > > I just want to verify if I'm understanding this correctly: > > I have a table in which I store log from my firewall. > For the protocol column (3 distinct values: TCP ~82%, UDP ~17%, ICMP > ~1%, the table contains 1.7M rows), I use a parti

Re: [GENERAL]

2006-08-15 Thread Jeff Davis
On Tue, 2006-08-15 at 18:05 +0200, Max wrote: > Do you know if it is possible to write such things : > > SELECT * FROM tablename WHERE permission(some parameters) == TRUE; > > with the function 'permission' returning TRUE or FALSE after a check > on different perm_fields of the current row. Y

Re: [GENERAL] Unable to Start PostgreSQL 8.1.4 on Windows XP

2006-08-15 Thread Thomas Kellerer
Ludwig Isaac Lim wrote on 15.08.2006 18:05: Searching the web using google gives me the following information about error 1063: Error code 1063: ERROR_FAILED_SERVICE_CONTROLLER_CONNECT - The service process could not connect to the service controller. (from http://user.tninet.se/~tdf275m/wincode2

Re: [GENERAL]

2006-08-15 Thread Max
Thx. But I know how to write procedure and function, but my problem is to know how to access the current row fields during a SELECT inside a function: So, in a function, can I write : /* ... */ permission (/* ... */) /* ... */ IF (ROW.perm_field1 = 1) statement IF (some_operation(RO

Re: [GENERAL] Connection string

2006-08-15 Thread Harpreet Dhaliwal
Its doneservice iptables stop did the trickfirewall was running on my DB serverforgot to stop itThanks~HarpreetOn 8/15/06, Michael Fuhr <[EMAIL PROTECTED]> wrote:On Sun, Aug 13, 2006 at 10:30:24AM +0200, Michael Meskes wrote: > On Fri, Aug 11, 2006 at 04:40:36PM -0600, Michael Fuhr wrote:> > Will

Re: [GENERAL] Partial indexes Vs standard indexes : Insert performance

2006-08-15 Thread Gregory Stark
MaXX <[EMAIL PROTECTED]> writes: > In my understanding, a partial index is only touched when a matching row is > inserted/updated/deleted (index constraint is true), so if I create a partial > index for each protocol, I will slow down my machine as if I had created a > single "normal" index, but

Re: [GENERAL] wal files on temporary tables

2006-08-15 Thread marcelo Cortez
Tom thanks for to respond quickly, see below > marcelo Cortez <[EMAIL PROTECTED]> writes: > > Then i've created "normal" tables but the wal > file > > generated by this tables grows and grows. > > The WAL files shouldn't grow indefinitely unless > you've got some > fairly serious problem tha

Re: [GENERAL] Unable to Start PostgreSQL 8.1.4 on Windows XP

2006-08-15 Thread Ludwig Isaac Lim
Hi Thomas : --- Thomas Kellerer <[EMAIL PROTECTED]> wrote: > Ludwig Isaac Lim wrote on 15.08.2006 18:05: > > Searching the web using google gives me the following > > information about error 1063: > > Error code 1063: > ERROR_FAILED_SERVICE_CONTROLLER_CONNECT - > I had a similar issue several we

Re: [GENERAL]

2006-08-15 Thread Jeff Davis
On Tue, 2006-08-15 at 18:46 +0200, Max wrote: > Thx. > But I know how to write procedure and function, but my problem is to > know how to access the current row fields during a SELECT inside a > function: > > So, in a function, can I write : > > /* ... */ permission (/* ... */) > /* ... */ >

[GENERAL] plpgsql dynamic queries and optional arguments

2006-08-15 Thread Curtis Scheer
I have a table that I would like to be able to retrieve information out of based on a combination of multiple columns and I would like to be able to do this through a plpgsql stored procedure. Right now I have multiple stored procedures that I am calling based on the values parameter values

[GENERAL] REFERENCE problem with parent_table

2006-08-15 Thread gustavo halperin
 Hello I need many tables of type "id" and "name", see below:       CREATE TABLE id_names (       id    smallint    CONSTRAINT the_id PRIMARY KEY NOT NULL,       name    text    CONSTRAINT the_name UNIQUE     ) WITH OIDS; therefore I created these tables with the "LIKE"

Re: [GENERAL] REFERENCE problem with parent_table

2006-08-15 Thread Richard Broersma Jr
> I need many tables of type "id" and "name", see below: > / CREATE TABLE id_names ( > idsmallintCONSTRAINT the_id PRIMARY KEY NOT NULL, > nametextCONSTRAINT the_name UNIQUE > ) WITH OIDS;/ > therefore I created these tables with the "LI

Re: [GENERAL] REFERENCE problem with parent_table

2006-08-15 Thread gustavo halperin
Richard Broersma Jr wrote: I need many tables of type "id" and "name", see below: / CREATE TABLE id_names ( idsmallintCONSTRAINT the_id PRIMARY KEY NOT NULL, nametextCONSTRAINT the_name UNIQUE ) WITH OIDS;/ therefore I created these tab

Re: [GENERAL] REFERENCE problem with parent_table

2006-08-15 Thread Stephan Szabo
On Tue, 15 Aug 2006, gustavo halperin wrote: > Hello > > I need many tables of type "id" and "name", see below: > / CREATE TABLE id_names ( > idsmallintCONSTRAINT the_id PRIMARY KEY NOT NULL, > nametextCONSTRAINT the_name UNIQUE > ) WIT

Re: [GENERAL] REFERENCE problem with parent_table

2006-08-15 Thread Richard Broersma Jr
> > it looks like the syntax here is a little off from what is defined by: > > http://www.postgresql.org/docs/8.1/interactive/sql-createtable.html > > > > CREATE TABLE like_id_1 ( idsmallint like id_names, > > name text like id_name ) with oids ; > > > Are you s

Re: [GENERAL]

2006-08-15 Thread Tom Lane
Jeff Davis <[EMAIL PROTECTED]> writes: > What you want to do is pass each "perm_field" as a parameter. I think the OP is hoping for some sort of magic action-at-a-distance behavior whereby his function can access stuff that wasn't passed to it. Doesn't exist though ... reg

Re: [GENERAL] Partial indexes Vs standard indexes : Insert performance

2006-08-15 Thread Tom Lane
Gregory Stark <[EMAIL PROTECTED]> writes: > But if you're just looking up a single record I wouldn't expect it to be much > faster to look it up in the smaller partial index than in the larger index. > Indexes find records in log(n) time and log() grows awfully slowly. Yeah. Given the proportions

[GENERAL] trigger speed

2006-08-15 Thread Joseph Shraibman
I have a trigger that updates a count table, based on status. The count table looks like this: key status count a1 300 a2 400 b1 100 b2 200 The problem is that for large updates when I do "UPDATE table SET status = 1 WHERE status = 2 and key =

[GENERAL] Changing the data directory Ubuntu

2006-08-15 Thread shaun . ricci
Hello, I have done a good deal of investigation and cannot seem to find a straight answer. Is there way to change the default data directory? I am using Ubuntu Dapper LTS. I have a seperate hard drive (and partition) that I want to keep my data on in case of a problem with the OS. Any help wo

Re: [GENERAL] Changing the data directory Ubuntu

2006-08-15 Thread Thomas F. O'Connell
On Aug 15, 2006, at 1:19 PM, [EMAIL PROTECTED] wrote: Hello, I have done a good deal of investigation and cannot seem to find a straight answer. Is there way to change the default data directory? I am using Ubuntu Dapper LTS. I have a seperate hard drive (and partition) that I want to keep

Re: [GENERAL] Changing the data directory Ubuntu

2006-08-15 Thread John Purser
On 15 Aug 2006 11:19:39 -0700 [EMAIL PROTECTED] wrote: > Hello, > > I have done a good deal of investigation and cannot seem to find a > straight answer. Is there way to change the default data directory? > I am using Ubuntu Dapper LTS. I have a seperate hard drive (and > partition) that I wa

[GENERAL] CONSTRAINT REFERENCE betwen array to single

2006-08-15 Thread gustavo halperin
Hello I have a table with an array of smallint that I want reference to a column of smallint, see below: /database=# CREATE TABLE id_names ( id smallint CONSTRAINT the_id PRIMARY KEY NOT NULL, database(# name text CONSTRAINT the_name UNIQUE ) WITH OIDS; NOTICE: CREATE TABLE / PRIMAR

Re: [GENERAL] plpgsql dynamic queries and optional arguments

2006-08-15 Thread Harvey, Allan AC
Curtis, Here is an example function that uses dynamic sql. I use it under 7.4.5 Hope this helps. Allan -- Function to delete old data out of the point tables. -- tablename is a column in the points table that holds the name -- of the table in which this points data is stored. create or replace

[GENERAL] How to add days to date

2006-08-15 Thread Alejandro Michelin Salomon \( Adinet \)
Hi: I have problem trying to add same days to a date. I have this select : SELECT '2006-08-01' + FP.carencia + ( FP.prazo * ( MFP.parcela - 1 )) AS vencimento FROM fi_mov_formas_pagamento MFP LEFT OUTER JOIN fi_formas_pagamento FP ON ( MFP.idformapagamento = FP.idformapagamento AND MFP

Re: [GENERAL] How to add days to date

2006-08-15 Thread Michael Fuhr
On Tue, Aug 15, 2006 at 10:10:27PM -0300, Alejandro Michelin Salomon ( Adinet ) wrote: > EX : > '2006-08-01' + 30 + ( 7 * ( 3 - 1 )) ==> '2006-08-01' + 44 > > All my trys fails. The error message hints at what's wrong: test=> SELECT '2006-08-01' + 30 + (7 * (3 - 1)); ERROR: invalid input synta

Re: [GENERAL] Connection string

2006-08-15 Thread Michael Fuhr
On Tue, Aug 15, 2006 at 03:56:03PM +0200, Michael Meskes wrote: > On Tue, Aug 15, 2006 at 05:59:23AM -0600, Michael Fuhr wrote: > > I'll submit a patch. However, in the case of string literals not > > working, is that a documentation bug or a code bug? Are they > > supposed to work? > > You shou

[GENERAL] DB insert Error

2006-08-15 Thread Jasbinder Bali
Hi, I'm using ECPG and trying to do follwoing insert in one of the talbes.    insert into raw_email ( id  , raw_email  ) values ( 1 , :ch);   ch is an array and defined as follows:    EXEC SQL BEGIN DECLARE SECTION;    char ch[MSG_LEN];EXEC SQL END DECLARE SECTION;  contents of array ch is actually

Re: [GENERAL] DB insert Error

2006-08-15 Thread Michael Fuhr
On Tue, Aug 15, 2006 at 11:55:58PM -0400, Jasbinder Bali wrote: > I'm using ECPG and trying to do follwoing insert in one of the talbes. > > insert into raw_email ( id , raw_email ) values ( 1 , :ch); > > ch is an array and defined as follows: > > EXEC SQL BEGIN DECLARE SECTION; >char ch[M

Re: [GENERAL] DB insert Error

2006-08-15 Thread Jasbinder Bali
table definition of raw_email table is as follows   CREATE TABLE raw_email ( idint4 NOT NULL, raw_email  varchar[], parsed_flag bool NOT NULL DEFAULT false, CONSTRAINT  pk_rawemail PRIMARY KEY (id)) WITHOUT OIDS;   i have very much declared raw_email field as varchar and n

[GENERAL] how to use variable for select query in pl/pgsql

2006-08-15 Thread aBBISh
hello everybody, i want use a variable to denote a table name in select query. for example: DECLARE table_message_data varchar; record_message_data record; BEGIN table_message_data := prefix || 'message_data'; select into record_message_data * from table_message_data

Re: [GENERAL] DB insert Error

2006-08-15 Thread Michael Fuhr
On Wed, Aug 16, 2006 at 12:38:42AM -0400, Jasbinder Bali wrote: > table definition of raw_email table is as follows > > CREATE TABLE raw_email ( > idint4 NOT NULL, > raw_email varchar[], > parsed_flag bool NOT NULL DEFAULT false, > CONSTRAINT pk_rawemail PRIMARY KEY (id)

Re: [GENERAL] how to use variable for select query in pl/pgsql

2006-08-15 Thread Michael Fuhr
On Wed, Aug 16, 2006 at 12:43:07PM +0800, aBBISh wrote: > i want use a variable to denote a table name in select query. See "Executing Dynamic Commands" in the PL/pgSQL documentation: http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN -- Mich

Re: [GENERAL] DB insert Error

2006-08-15 Thread Jasbinder Bali
This is how the array is formed in my C code ---  FILE   *fp;   while(!feof(fp))  {ch[i]=fgetc(fp);   if(ch[i]=='\n') lines++;   i++;  }    ch[i-1]='\0';    fclose(fp);---

[GENERAL] Trigger (Calling a Procedure)

2006-08-15 Thread Harpreet Dhaliwal
Hi,I'm trying to create a trigger with the following definition:CREATE TRIGGER insert_price_change AFTER INSERT OR DELETE OR UPDATE ON raw_email  FOR EACH ROW EXECUTE PROCEDURE add_one(1);Procedure / Function add_one has the following definition CREATE FUNCTION add_one(integer) RETURNS integer

Re: [GENERAL] DB insert Error

2006-08-15 Thread Michael Fuhr
On Wed, Aug 16, 2006 at 01:20:08AM -0400, Jasbinder Bali wrote: > This is how the array is formed in my C code > --- > FILE *fp; > > while(!feof(fp)) > {ch[i]=fgetc(fp); > if(ch[i]=='\n') lines++;

Re: [GENERAL] DB insert Error

2006-08-15 Thread Jasbinder Bali
I changed the datatype from varchar[] to varchar ECPGdebug(1,stderr) says [2998]: ECPGexecute line 97 Ok: INSERT 0 1  Its not inserting any record even though sqlcode is 0.   ~Jas  On 8/16/06, Michael Fuhr <[EMAIL PROTECTED]> wrote: On Wed, Aug 16, 2006 at 01:20:08AM -0400, Jasbinder Bali wrote:>

Re: [GENERAL] DB insert Error

2006-08-15 Thread Jasbinder Bali
Also, My insert statement is   EXEC SQL INSERT INTO raw_email (id,raw_email) VALUES (1,:ch);    On 8/16/06, Michael Fuhr <[EMAIL PROTECTED]> wrote: On Wed, Aug 16, 2006 at 01:20:08AM -0400, Jasbinder Bali wrote:> This is how the array is formed in my C code > --

Re: [GENERAL] Trigger (Calling a Procedure)

2006-08-15 Thread Michael Fuhr
On Wed, Aug 16, 2006 at 01:35:47AM -0400, Harpreet Dhaliwal wrote: > I'm trying to create a trigger with the following definition: > > CREATE TRIGGER insert_price_change AFTER INSERT OR DELETE OR UPDATE ON > raw_email > FOR EACH ROW EXECUTE PROCEDURE add_one(1); > > Procedure / Function add_one

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-15 Thread Michael Fuhr
On Wed, Aug 16, 2006 at 01:46:30AM -0400, Jasbinder Bali wrote: > I changed the datatype from varchar[] to varchar > ECPGdebug(1,stderr) says > [2998]: ECPGexecute line 97 Ok: INSERT 0 1 > > Its not inserting any record even though sqlcode is 0. Are you committing the transaction? See the bottom

Re: [GENERAL] Trigger (Calling a Procedure)

2006-08-15 Thread Harpreet Dhaliwal
I got your point. however, my requirement is something like this. The trigger shold start another function (a stored procedure) after any event is fired.   how do I accomplish this goal?   Harpreet  On 8/16/06, Michael Fuhr <[EMAIL PROTECTED]> wrote: On Wed, Aug 16, 2006 at 01:35:47AM -0400, Harpr

Re: [NOVICE] [GENERAL] DB insert Error

2006-08-15 Thread Harpreet Dhaliwal
Its actually something like the trigger should start a C function after insert and the C function has the ECPG code for some more inserts. Its similar to the way we dynamically load a shared library while executing a stored procedure, as in , executing a fucntion in C file using stored procedure/ f

Re: [GENERAL] Trigger (Calling a Procedure)

2006-08-15 Thread Harpreet Dhaliwal
Its actually something like the trigger should start a C function after insert and the C function has the ECPG code for some more inserts. Its similar to the way we dynamically load a shared library while executing a stored procedure, as in , executing a fucntion in C file using stored procedure/