Re: [GENERAL] Unhandled exception in PGAdmin when opening 16-million-record table

2010-10-31 Thread Guillaume Lelarge
Le 29/10/2010 14:46, Guillaume Lelarge a écrit : Le 29/10/2010 13:52, Rob Richardson a écrit : A customer was reviewing the database that supports the application we have provided. One of the tables is very simple, but has over 16 million records. Here is the table's definition: CREATE

[GENERAL] Implementing replace function

2010-10-31 Thread Alexander Farber
Hello Postgres users, to mimic the MySQL-REPLACE statement I need to try to UPDATE a record and if that fails - INSERT it. But how can I detect that the UPDATE has failed in my SQL procedure? begin transaction; create table pref_users ( id varchar(32) primary

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Pavel Stehule
Hello 2010/10/31 Alexander Farber alexander.far...@gmail.com: Hello Postgres users, to mimic the MySQL-REPLACE statement I need to try to UPDATE a record and if that fails - INSERT it. But how can I detect that the UPDATE has failed in my SQL procedure? see:

[GENERAL] max_fsm_pages increase

2010-10-31 Thread AI Rumman
I using Postgresql 8.1 and during vacuum at night time, I am getting the following log: number of page slots needed (2520048) exceeds max_fsm_pages (356656) Do I need to increase max_fsm_pages to 2520048? Does it have any bad affect?

Re: [GENERAL] max_fsm_pages increase

2010-10-31 Thread Pavel Stehule
Hello 2010/10/31 AI Rumman rumman...@gmail.com: I using Postgresql 8.1 and during vacuum at night time, I am getting the following log: number of page slots needed (2520048) exceeds max_fsm_pages (356656) Do I need to increase max_fsm_pages to 2520048? Does it have any bad affect? I takes a

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Alexander Farber
Thanks Pavel, but I have an SQL procedure and not plpgsql? On Sun, Oct 31, 2010 at 9:34 AM, Pavel Stehule pavel.steh...@gmail.com wrote: But how can I detect that the UPDATE has failed in my SQL procedure? see: http://www.postgresql.org/docs/8.4/interactive/plpgsql-control-structures.html

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Dmitriy Igrishin
Hey Alexander, Pavel The solution like below should works IMO, but it does not. insert into pref_users(id, first_name, last_name, female, avatar, city, last_ip) select $1, $2, $3, $4, $5, $6, $7 where not exists (update pref_users set first_name = $2,

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Pavel Stehule
Hello 2010/10/31 Dmitriy Igrishin dmit...@gmail.com: Hey Alexander, Pavel The solution like below should works IMO, but it does not.   insert into pref_users(id, first_name, last_name,     female, avatar, city, last_ip)     select $1, $2, $3, $4, $5, $6, $7   where not exists

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Dmitriy Igrishin
Okay, Pavel, will wait for 9.1 :-) It is a common case - insert new row if it cannot be updated. 2010/10/31 Pavel Stehule pavel.steh...@gmail.com Hello 2010/10/31 Dmitriy Igrishin dmit...@gmail.com: Hey Alexander, Pavel The solution like below should works IMO, but it does not.

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Pavel Stehule
2010/10/31 Dmitriy Igrishin dmit...@gmail.com: Okay, Pavel, will wait for 9.1 :-) It is a common case - insert new row if it cannot be updated. you can find (probably) MERGE statement in 9.1. Pavel 2010/10/31 Pavel Stehule pavel.steh...@gmail.com Hello 2010/10/31 Dmitriy Igrishin

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Thomas Kellerer
Alexander Farber wrote on 31.10.2010 09:22: Hello Postgres users, to mimic the MySQL-REPLACE statement I need to try to UPDATE a record and if that fails - INSERT it. There is actually an example of this in the PG manual ;)

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Alexander Farber
Thanks for all the comments. Do I need to use BEGIN/COMMIT in my plpgsql-function for UPSERT or are functions atomic? Regards Alex -- 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] Implementing replace function

2010-10-31 Thread Alexander Farber
And would a pure SQL-function solution to call an INSERT followed by an UPDATE in its body and ignoring the error? (don't know how ignore it best though, so that I don't ignore other critical errors) -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Alexander Farber
[corrected typo, sorry] And wouldn't a pure SQL-function solution be: to call an INSERT followed by an UPDATE in its body and ignoring the error? (don't know how ignore that error best though, so that I don't ignore other critical errors) -- Sent via pgsql-general mailing list

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Pavel Stehule
2010/10/31 Alexander Farber alexander.far...@gmail.com: Thanks for all the comments. Do I need to use BEGIN/COMMIT in my plpgsql-function for UPSERT or are functions atomic? If you use a code from documentation, then you don't need explicit transaction - every SQL run inside outer implicit

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Pavel Stehule
2010/10/31 Alexander Farber alexander.far...@gmail.com: And would a pure SQL-function solution to call an INSERT followed by an UPDATE in its body and ignoring the error? (don't know how ignore it best though, so that I don't ignore other critical errors) You must not ignore errors in SQL -

Re: [GENERAL] large xml database

2010-10-31 Thread Andy Colson
On 10/30/2010 4:48 PM, Viktor Bojović wrote: Hi, i have very big XML documment which is larger than 50GB and want to import it into databse, and transform it to relational schema. When splitting this documment to smaller independent xml documments i get ~11.1mil XML documents. I have spent lots

[GENERAL] NOT IN (NULL) ?

2010-10-31 Thread Paul
Please, help me. Why the condition SELECT 5 NOT IN (NULL) returns NULL, but not FALSE (as I thought)? -- Paul -- 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] NOT IN (NULL) ?

2010-10-31 Thread Tom Lane
Paul maga...@mail.ru writes: Why the condition SELECT 5 NOT IN (NULL) returns NULL, but not FALSE (as I thought)? Because the SQL standard says so. If you think of NULL as meaning unknown, it makes some intuitive sense: it's unknown whether that unknown value is equal to 5.

Re: [GENERAL] NOT IN (NULL) ?

2010-10-31 Thread Raymond O'Donnell
On 31/10/2010 16:37, Paul wrote: Please, help me. Why the condition SELECT 5 NOT IN (NULL) returns NULL, but not FALSE (as I thought)? Because NULL basically means don't know - so you don't know whether 5 is there or not. Ray. -- Raymond O'Donnell :: Galway :: Ireland r...@iol.ie -- Sent

Re: [GENERAL] NOT IN (NULL) ?

2010-10-31 Thread Paul
Tom, Sunday, October 31, 2010, 9:42:27 PM, you wrote: TL Because the SQL standard says so. But there is not such thing in PostgreSQL as empty set as IN () that must be false, because nothing element may be found in empty set. And I thought that instead of IN () I could use IN (NULL),

Re: [GENERAL] NOT IN (NULL) ?

2010-10-31 Thread Pavel Stehule
2010/10/31 Paul maga...@mail.ru: Tom, Sunday, October 31, 2010, 9:42:27 PM, you wrote: TL Because the SQL standard says so. But  there  is  not  such  thing  in PostgreSQL as empty set as IN () that must be false, because nothing element may be found in empty set. And  I  thought that

Re: [GENERAL] NOT IN (NULL) ?

2010-10-31 Thread Tom Lane
Paul maga...@mail.ru writes: But there is not such thing in PostgreSQL as empty set as IN () that must be false, because nothing element may be found in empty set. And I thought that instead of IN () I could use IN (NULL), but I was failed and result was NULL and not FALSE. :( NULL

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Alexander Farber
I've created a function now (below) and can call it as well, but how can I see it at the psql prompt? Is there a \d command for that or should I dump the database to see my declarations? And is my function atomic? I.e. can't it happen, that FOUND is not true, but then another session calls a

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Rob Sargent
\df *update* Alexander Farber wrote: I've created a function now (below) and can call it as well, but how can I see it at the psql prompt? Is there a \d command for that or should I dump the database to see my declarations? And is my function atomic? I.e. can't it happen, that FOUND is not

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Raymond O'Donnell
On 31/10/2010 17:28, Alexander Farber wrote: I've created a function now (below) and can call it as well, but how can I see it at the psql prompt? Is there a \d command for that or should I dump the database to see my declarations? You can do \df public.*, assuming that your function is in the

Re: [GENERAL] max_fsm_pages increase

2010-10-31 Thread Scott Marlowe
On Sun, Oct 31, 2010 at 2:43 AM, AI Rumman rumman...@gmail.com wrote: I using Postgresql 8.1 and during vacuum at night time, I am getting the following log: number of page slots needed (2520048) exceeds max_fsm_pages (356656) Do I need to increase max_fsm_pages to 2520048? Does it have any

[GENERAL] difference functions

2010-10-31 Thread Mark Rostron
This post is just to record an example of how to use the new window fn's in 8.4 to perform difference-between-row calculations. To demonstrate, we create a table with 30 rows of data, two columns, one of which contains the sequence 1..30, the other contains mod(c1,10). So the table looks like

[GENERAL] Sorting rows by a column and storing a row number

2010-10-31 Thread Alexander Farber
Hello, I have a card game for each I'd like to introduce weekly tournaments. I'm going to save the score (virtual money) won by each player into: create table pref_money ( id varchar(32) references pref_users, yw char(7) default to_char(current_timestamp,

Re: [GENERAL] Sorting rows by a column and storing a row number

2010-10-31 Thread Darren Duncan
Use the Postgres window functions like rank(); this is what they're for. http://www.postgresql.org/docs/8.4/interactive/queries-table-expressions.html#QUERIES-WINDOW -- Darren Duncan Alexander Farber wrote: Hello, I have a card game for each I'd like to introduce weekly tournaments. I'm

[GENERAL] How to determine server version inside select statement

2010-10-31 Thread Andrus
I tried SELECT (SHOW server_version) AS Contents but got ERROR: syntax error at or near server_version at character 14 how to get server version inside select statement ? Andrus. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:

Re: [GENERAL] How to determine server version inside select statement

2010-10-31 Thread Osvaldo Kussama
2010/10/31 Andrus kobrule...@hot.ee: I tried SELECT (SHOW server_version) AS Contents but got ERROR:  syntax error at or near server_version at character 14 how to get server version inside select statement ? SELECT current_setting('server_version') AS Contents; Osvaldo -- Sent via

[GENERAL] avoiding nested loops when joining on partitioned tables

2010-10-31 Thread Peter Neal
Hi, I have two tables (A and B), which are partitioned (A1, A2... B1, B2...) for easy deletion of old records. They are linked by a bigint column id, which is defined as a foreign key in each B partition referencing the corresponding A partition. Many rows in B1 can reference a single row in A1.

Re: [GENERAL] How to determine server version inside select statement

2010-10-31 Thread Alban Hertroys
On 31 Oct 2010, at 22:56, Andrus wrote: I tried SELECT (SHOW server_version) AS Contents postgres= select version(); version

Re: [GENERAL] Slow connection once the PC is network connected

2010-10-31 Thread Yan Cheng CHEOK
Thanks. That's work pretty well. --- On Tue, 10/26/10, Alban Hertroys dal...@solfertje.student.utwente.nl wrote: From: Alban Hertroys dal...@solfertje.student.utwente.nl Subject: Re: [GENERAL] Slow connection once the PC is network connected To: Yan Cheng CHEOK ycch...@yahoo.com Cc: