Re: [SQL] Referential integrity broken (8.0.3), sub-select help

2006-03-22 Thread Patrick JACQUOT
[EMAIL PROTECTED] wrote: Hello, I've got 2 tables, url (U), and bookmark (B), with bookmark pointing to url via FK. Somehow I ended up with some rows in B referencing non-existent rows in U. This sounds super strange and dangerous to me, and it's not clear to me how/why PG let this happen.

[SQL] COPY tablename FROM and null values

2006-03-22 Thread ivan marchesini
Dear users, I'm working on a Postgres 7.4 server I have a .txt file, containing some tabular data, where data are delimited by TABs. there are 3 columns: column1 int4, column2 float8, column3 float8 the problem is that column3 contains also null values (i.e. sometimes is empty) so when I try

Re: [SQL] COPY tablename FROM and null values

2006-03-22 Thread Achilleus Mantzios
O ivan marchesini έγραψε στις Mar 22, 2006 : Dear users, I'm working on a Postgres 7.4 server I have a .txt file, containing some tabular data, where data are delimited by TABs. there are 3 columns: column1 int4, column2 float8, column3 float8 the problem is that column3 contains

Re: [SQL] COPY tablename FROM and null values

2006-03-22 Thread Luckys
On 3/22/06, Achilleus Mantzios [EMAIL PROTECTED] wrote: O ivan marchesini έγραψε στις Mar 22, 2006 : Dear users, I'm working on a Postgres 7.4 server I have a .txt file, containing some tabular data, where data are delimited by TABs. there are 3 columns: column1 int4, column2 float8, column3

Re: [SQL] Using a parameter in Interval

2006-03-22 Thread Davidson, Robert
That worked perfectly - thanks! CREATE OR REPLACE FUNCTION Testing(TrailingWeeks int) RETURNS date AS $$ BEGIN RETURN current_date - (TrailingWeeks || ' weeks')::INTERVAL; END; $$ LANGUAGE plpgsql; select * from testing(1); -Original Message- From: [EMAIL PROTECTED]

Re: [SQL] COPY tablename FROM and null values

2006-03-22 Thread Tom Lane
ivan marchesini [EMAIL PROTECTED] writes: I have a .txt file, containing some tabular data, where data are delimited by TABs. there are 3 columns: column1 int4, column2 float8, column3 float8 the problem is that column3 contains also null values (i.e. sometimes is empty) This should work,

[SQL] How to optimize this query?

2006-03-22 Thread Maciej Piekielniak
Hello pgsql-sql, I have postgresql 8.1.3 and database with about 2,7GB (90% large objects). When I execute this query postgresql calculate this 2min 50sec. How can I optimize this query? select towar.id_towar,towar.key2,towar.nazwa,0 as min,0 as

Re: [SQL] How to optimize this query?

2006-03-22 Thread Markus Bertheau
Send an EXPLAIN ANALYZE of the query along with the description of the involved tables. Also hardware information (RAM, disks, CPU), what other applications are running on that box and the parameter values in postgresql.conf that you changed from the defaults would be interesting. Markus

Re: [SQL] How to optimize this query?

2006-03-22 Thread Maciej Piekielniak
Hello Markus, Wednesday, March 22, 2006, 6:58:44 PM, you wrote: MB Send an EXPLAIN ANALYZE of the query along with the description of the MB involved tables. Also hardware information (RAM, disks, CPU), what MB other applications are running on that box and the parameter values in MB

Re: [SQL] How to optimize this query?

2006-03-22 Thread Markus Bertheau
That's an explain. We need explain analyze. 2006/3/23, Maciej Piekielniak [EMAIL PROTECTED]: Hello Markus, Wednesday, March 22, 2006, 6:58:44 PM, you wrote: MB Send an EXPLAIN ANALYZE of the query along with the description of the MB involved tables. Also hardware information (RAM, disks,

Re: [SQL] How to optimize this query?

2006-03-22 Thread Markus Bertheau
In the meantime, try this: SELECT towar.id_towar, towar.key2, towar.nazwa, 0 AS min, 0 AS max, towar.ilosc_jed, towar.ilosc_nom, towar.ilosc_paczkowa, dostawcy.id_dostawcy, jednostka_miary.jednostka, 0.0 AS

Re: [SQL] How to optimize this query?

2006-03-22 Thread Maciej Piekielniak
Hello Markus, Wednesday, March 22, 2006, 7:32:11 PM, you wrote: MB foo.z_zamowien, MB ) AS foo ON (foo.id_towar = towar.id_towar) foo? -- Best regards, Maciejmailto:[EMAIL PROTECTED] ---(end of

Re: [SQL] How to optimize this query?

2006-03-22 Thread Maciej Piekielniak
Hello Markus, ERROR: column foo.z_zamowien must appear in the GROUP BY clause or be used in an aggregate function -- Best regards, Maciejmailto:[EMAIL PROTECTED] ---(end of broadcast)--- TIP 5: don't forget to

Re: [SQL] How to optimize this query?

2006-03-22 Thread Maciej Piekielniak
Hello Markus, Sorry, I try this: SELECT towar.id_towar, towar.key2, towar.nazwa, 0 AS min, 0 AS max, towar.ilosc_jed, towar.ilosc_nom, towar.ilosc_paczkowa, dostawcy.id_dostawcy, jednostka_miary.jednostka, 0.0

Re: [SQL] How to optimize this query?

2006-03-22 Thread Jeffrey Melloy
Maciej Piekielniak wrote: Hello Markus, Oryginal query return 7881 rows , your query only 729 rows. But it's faster! ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if

[SQL] Function Parameters in GROUP BY clause cause errors

2006-03-22 Thread Davidson, Robert
Title: Function Parameters in GROUP BY clause cause errors When I use a parameter in a query which aggregates it fails with a GROUP BY error. What syntax can I use to avoid this error? CREATE TABLE test (email_creation_datetime timestamp); INSERT INTO test VALUES ('2006-03-20 09:00');

[SQL] Custom type

2006-03-22 Thread Daniel Caune
Hi, How can I enter description for my custom types? \dT provides information such as schema, name, and description for all the registered types and custom types. I would like to provide a description for each custom type I create. Thanks, -- Daniel CAUNE Ubisoft Online Technology (514) 4090

Re: [SQL] Custom type

2006-03-22 Thread Terry Lee Tucker
On Wednesday 22 March 2006 03:25 pm, Daniel Caune saith: Hi, How can I enter description for my custom types? \dT provides information such as schema, name, and description for all the registered types and custom types. I would like to provide a description for each custom type I create.

Re: [SQL] Custom type

2006-03-22 Thread Bryce Nesbitt
Terry Lee Tucker wrote: rnd=# \h comment Command: COMMENT Description: define or change the comment of an object ..I believe this is what you need. Cool! That's a great feature. Though it would be even nicer if the comment showed when you \d a table:: stage=# comment on table

Re: [SQL] Custom type

2006-03-22 Thread Daniel Caune
Hi, How can I enter description for my custom types? \dT provides information such as schema, name, and description for all the registered types and custom types. I would like to provide a description for each custom type I create. Thanks, -- Daniel CAUNE Ubisoft

Re: [SQL] Function Parameters in GROUP BY clause cause errors

2006-03-22 Thread Tom Lane
Davidson, Robert [EMAIL PROTECTED] writes: ERROR: column em.email_creation_datetime must appear in the GROUP BY = clause or be used in an aggregate function CONTEXT: SQL statement select to_char(to_timestamp(EXTRACT(HOUR FROM = em.email_creation_datetime) || ':' || (EXTRACT(MINUTE FROM =

[SQL] OUT parameter

2006-03-22 Thread Daniel Caune
Hi, Is there any suggestion against using OUT parameter for local calculation such as using a local variable? CREATE OR REPLACE FUNCTION foo(a IN int, b1 OUT int, b2 OUT int) AS $$ BEGIN FOR (...) LOOP b1 = (...); b2 =

Re: [SQL] OUT parameter

2006-03-22 Thread Owen Jacobson
Daniel Caune wrote: Is there any suggestion against using OUT parameter for local calculation such as using a local variable? CREATE OR REPLACE FUNCTION foo(a IN int, b1 OUT int, b2 OUT int) AS $$ BEGIN FOR (...) LOOP

Re: [SQL] Function Parameters in GROUP BY clause cause errors

2006-03-22 Thread Christian Paul B. Cosinas
Title: Function Parameters in GROUP BY clause cause errors Just Put aggregate function to the fields you selected. Like this: select to_char(to_timestamp(EXTRACT(HOUR FROM max(em.email_creation_datetime)) || ':' || (EXTRACT(MINUTE FROM max(em.email_creation_datetime))::integer/30) *

Re: [SQL] OUT parameter

2006-03-22 Thread Tom Lane
Daniel Caune wrote: Is there any suggestion against using OUT parameter for local calculation such as using a local variable? In plpgsql (at least in the current implementation) an OUT parameter is pretty much just a local variable, and so there's no efficiency argument against using it as a

Re: [SQL] Function Parameters in GROUP BY clause cause errors

2006-03-22 Thread Tom Lane
I wrote: Hmm, this seems like a plpgsql deficiency. It feels it can generate a separate parameter symbol ($n) for each occurrence of each variable it passes into a SQL query. But for this query to be legal, the two instances of IntervalMinutes have to be represented by the *same* parameter