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 wrote: > From: Alban Hertroys > Subject: Re: [GENERAL] Slow connection once the PC is network connected > To: "Yan Cheng CHEOK" > Cc: pgsql-general@postgresql.org > Date: Tuesday, October 26, 2010, 6:01 PM > On 26 Oct 2010,

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

[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 Osvaldo Kussama
2010/10/31 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 ? > SELECT current_setting('server_version') AS Contents; Osvaldo -- Sent via pgsq

[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: h

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 going

[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, '

[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 th

Re: [GENERAL] max_fsm_pages increase

2010-10-31 Thread Scott Marlowe
On Sun, Oct 31, 2010 at 2:43 AM, AI Rumman 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 bad affect? No, y

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] 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 true

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 INSER

Re: [GENERAL] NOT IN (NULL) ?

2010-10-31 Thread Tom Lane
"Paul" 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 is

Re: [GENERAL] NOT IN (NULL) ?

2010-10-31 Thread Pavel Stehule
2010/10/31 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 inst

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 (NUL

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 -- Sen

Re: [GENERAL] NOT IN (NULL) ?

2010-10-31 Thread Tom Lane
"Paul" 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 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] 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 o

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Pavel Stehule
2010/10/31 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) > You must not ignore errors in SQL - it's not T-SQL :) Pav

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Pavel Stehule
2010/10/31 Alexander Farber : > 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 transaction in PostgreSQL

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 (pgsql-general@pos

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 sub

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 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 ;) http://www.postgresql.org/docs/current/static/plpgsql-control-struct

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Pavel Stehule
2010/10/31 Dmitriy Igrishin : > 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 >> >> Hello >> >> 2010/10/31 Dmitriy Igrishin : >> > Hey Alexander, Pavel >> >

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 > Hello > > 2010/10/31 Dmitriy Igrishin : > > Hey Alexander, Pavel > > > > The solution like below should works IMO, but it does not. > > insert into pref_users(id, first_

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Pavel Stehule
Hello 2010/10/31 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 p

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, l

Re: [GENERAL] Implementing replace function

2010-10-31 Thread Pavel Stehule
2010/10/31 Alexander Farber : > Thanks Pavel, but I have an SQL procedure and not plpgsql? it's not possible in sql. But plpgsql is same level like stored procedures language from mysql. > > On Sun, Oct 31, 2010 at 9:34 AM, Pavel Stehule > wrote: >>> But how can I detect that the UPDATE has fai

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 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 > near to end of p

Re: [GENERAL] max_fsm_pages increase

2010-10-31 Thread Pavel Stehule
Hello 2010/10/31 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? I takes a little more memo

[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] Implementing replace function

2010-10-31 Thread Pavel Stehule
Hello 2010/10/31 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? > see: http://www.postgresql.org/docs/8.4/interactive/pl

[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 key