[GENERAL] Curious why planner can't handle NOT IN

2013-05-03 Thread Yang Zhang
I have an `account` table with 5.3M rows, with primary key `id` of type `text` (and 600+ columns if that matters). I'm trying to create a `newaccount` table with the same schema but 600k newly imported rows, then insert all the old rows for which `id` isn't already in the set of newly updated

[GENERAL] SPI_execute_with_args call

2013-05-03 Thread Yuriy Rusinov
Hello, colleagues ! I have to write random number generator state into database table Table structure is table rand_state { id serial not null primary key, state_rand bytea }; In C-function I do size_t nr_ins = strlen (insert into rand_state (state_rand) values ($1);); char * r_sql =

Re: [GENERAL] SPI_execute_with_args call

2013-05-03 Thread Gavin Flower
On 03/05/13 21:19, Yuriy Rusinov wrote: Hello, colleagues ! I have to write random number generator state into database table Table structure is table rand_state { id serial not null primary key, state_rand bytea }; In C-function I do size_t nr_ins = strlen (insert into rand_state

Re: [GENERAL] SPI_execute_with_args call

2013-05-03 Thread Yuriy Rusinov
I'm sorry ! But if I commented SPI_execute_with_args call, then all others works without bugs. On Fri, May 3, 2013 at 2:31 PM, Gavin Flower gavinflo...@archidevsys.co.nzwrote: On 03/05/13 21:19, Yuriy Rusinov wrote: Hello, colleagues ! I have to write random number generator state into

Re: [GENERAL] Curious why planner can't handle NOT IN

2013-05-03 Thread Tom Lane
Yang Zhang yanghates...@gmail.com writes: The most obvious query doesn't work so hot due to repeated execution of the subplan: = explain insert into newaccount select * from account where id not in (select id from account); Yeah. Try using a NOT EXISTS instead. This isn't a big deal as

Re: [GENERAL] SPI_execute_with_args call

2013-05-03 Thread Tom Lane
Yuriy Rusinov yrusi...@gmail.com writes: In C-function I do size_t nr_ins = strlen (insert into rand_state (state_rand) values ($1);); char * r_sql = (char *) palloc (nr_ins + 1); strncpy (r_sql, insert into rand_state (state_rand) values ($1);, nr_ins); This is a hard, error-prone, and

Re: [GENERAL] Curious why planner can't handle NOT IN

2013-05-03 Thread pradeep singh
On May 3, 2013 12:15 PM, Yang Zhang yanghates...@gmail.com wrote: I have an `account` table with 5.3M rows, with primary key `id` of type `text` (and 600+ columns if that matters). I'm trying to create a `newaccount` table with the same schema but 600k newly imported rows, then insert all

Re: [GENERAL] SPI_execute_with_args call

2013-05-03 Thread Yuriy Rusinov
Thanks a lot, I have corrected and bug was fixed. On Fri, May 3, 2013 at 6:42 PM, Tom Lane t...@sss.pgh.pa.us wrote: Yuriy Rusinov yrusi...@gmail.com writes: In C-function I do size_t nr_ins = strlen (insert into rand_state (state_rand) values ($1);); char * r_sql = (char *) palloc

[GENERAL] How to INSERT INTO one table from another table, WHERE

2013-05-03 Thread Kirk Wythers
I am trying to insert data from 2 columns in tableB (colX and colY) into the same two columns of tableB, with a join like where clause. Is this possible? For example: INSERT INTO tableA (colX, colY) (SELECT colX, colY FROM tableB WHERE tableA.blockname = tableB.block_name AND

Re: [GENERAL] How to INSERT INTO one table from another table, WHERE

2013-05-03 Thread Igor Neyman
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- ow...@postgresql.org] On Behalf Of Kirk Wythers Sent: Friday, May 03, 2013 1:51 PM To: POSTGRES Subject: [GENERAL] How to INSERT INTO one table from another table, WHERE I am trying to insert data

[GENERAL] Unlogged indexes

2013-05-03 Thread Yang Zhang
Guessing the answer's no, but is there any way to construct indexes such that I can safely put them on (faster) volatile storage? (Just to be clear, I'm asking about indexes for *logged* tables.) -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your

Re: [GENERAL] Unlogged indexes

2013-05-03 Thread Thom Brown
On 3 May 2013 21:06, Yang Zhang yanghates...@gmail.com wrote: Guessing the answer's no, but is there any way to construct indexes such that I can safely put them on (faster) volatile storage? (Just to be clear, I'm asking about indexes for *logged* tables.) Yes: CREATE INDEX ... TABLESPACE

Re: [GENERAL] Unlogged indexes

2013-05-03 Thread Yang Zhang
Yeah, I know that indexes for unlogged tables are unlogged. I was just wondering if you could do this for logged tables. (Safely, such that on crash recovery WAL replay won't throw up, these can be omitted from base backups, etc.) On Fri, May 3, 2013 at 1:46 PM, Thom Brown t...@linux.com wrote:

[GENERAL] How to monitor recovery on Windows?

2013-05-03 Thread Doug Gorley
This weekend, we're planning to move a production cluster to a new server. Rather than a full dump-and-restore, I want to use a base backup from last night, have the server replay the WAL files up to the time we shutdown the old server, and go from there. Both servers are Windows. I've never

Re: [GENERAL] Simple, free PG GUI/query tool wanted

2013-05-03 Thread mark_r
You can use free tool - Valentina Studio http://www.valentina-db.com/en/valentina-studio-overview 14 Feb 2013 in the 5.0 version added support of PostgreSQL, as well as mySQL/mariaDB, SQLite. It is FREE. Works on Mac, Win and Linux. Includes not only db management but powerfull reports that work