Re: [GENERAL] Hard upgrade (everything)

2014-02-25 Thread Frank Broniewski
Hi everybody, I just wanted to let you know my notes I took during the upgrade process from Postgresql 9.1 to 9.3 and Postgis 1.5 to 2.1. Maybe someone finds them useful. I'm running the cluster on FreeBSD 9.2 so all commands apply to FreeBSD of course, but it should be fairly easy to translate

[GENERAL] execute query from inside C function

2014-02-25 Thread James Harper
I've googled the docs but I can't seem to make a link as to how to execute database queries from inside a C function. I'm used to having a PGconn and using the API around that, but how do I do that from inside a C function (and a bit later on, a language handler?) Thanks James -- Sent via

Re: [GENERAL] execute query from inside C function

2014-02-25 Thread Pavel Stehule
Hello you should to use a SPI API http://www.postgresql.org/docs/9.3/static/spi.html http://www.postgresql.org/docs/9.3/static/spi-spi-exec.html Regards Pavel Stehule 2014-02-25 13:22 GMT+01:00 James Harper james.har...@bendigoit.com.au: I've googled the docs but I can't seem to make a

Re: [GENERAL] execute query from inside C function

2014-02-25 Thread James Harper
Hello you should to use a SPI API http://www.postgresql.org/docs/9.3/static/spi.html http://www.postgresql.org/docs/9.3/static/spi-spi-exec.html Yep just found it. I obviously didn't google hard enough. Thanks James -- Sent via pgsql-general mailing list

Re: [GENERAL] execute query from inside C function

2014-02-25 Thread Pavel Stehule
2014-02-25 13:36 GMT+01:00 James Harper james.har...@bendigoit.com.au: Hello you should to use a SPI API http://www.postgresql.org/docs/9.3/static/spi.html http://www.postgresql.org/docs/9.3/static/spi-spi-exec.html Yep just found it. I obviously didn't google hard enough. It

[GENERAL] JSON vs Text + Regexp Index Searching

2014-02-25 Thread Eliot Gable
I am working on a project for which I require some assistance. Any input would be appreciated. We have a table with millions of records and dozens of columns. On some systems, it takes up 10GB of disk space, and it runs on a single disk which is rather slow (7200 RPM). We typically don't do any

Re: [GENERAL] JSON vs Text + Regexp Index Searching

2014-02-25 Thread Merlin Moncure
On Tue, Feb 25, 2014 at 9:08 AM, Eliot Gable egable+pgsql-gene...@gmail.com wrote: If we wanted to put an index on a JSON data type column whose values was a simple array of IDs, what would the index look like, and how would we construct the query to make use of it? For 9.0, your only option

Re: [GENERAL] JSON vs Text + Regexp Index Searching

2014-02-25 Thread David Johnston
Eliot Gable-4 wrote I advocated creating a separate mapping table which maps the ID of these records to the other ID we are searching for and performing a JOIN on the two tables with appropriate foreign key relationships and indices. However, I was ask to instead put the list into a single

Re: [GENERAL] JSON vs Text + Regexp Index Searching

2014-02-25 Thread David Johnston
David Johnston wrote Eliot Gable-4 wrote I advocated creating a separate mapping table which maps the ID of these records to the other ID we are searching for and performing a JOIN on the two tables with appropriate foreign key relationships and indices. However, I was ask to instead put

Re: [GENERAL] Adding a non-null column without noticeable downtime

2014-02-25 Thread Zev Benjamin
To be clear, this is with PostgreSQL 9.1. Also, if there is some other way of doing this, I'd be interested in other methodologies as well. Zev On 02/24/2014 10:41 PM, Zev Benjamin wrote: Hi all, I'm sure this has been answered somewhere, but I was not able to find anything in the list

Re: [GENERAL] Adding a non-null column without noticeable downtime

2014-02-25 Thread Sameer Kumar
I think index should help. Why don't you try it out and check the explain plan of it? If you are planning to break it down as below: 1. ALTER TABLE foo ADD COLUMN bar boolean; 2. UPDATE foo SET bar = False; -- Done in batches 3. ALTER TABLE foo ALTER COLUMN bar SET DEFAULT False; 4. ALTER TABLE

[GENERAL] cannot delete corrupted rows after DB corruption: tuple concurrently updated

2014-02-25 Thread john gale
We ran into an open file limit on the DB host (Mac OS X 10.9.0, Postgres 9.3.2) and caused the familiar ERROR: unexpected chunk number 0 (expected 1) for toast value 155900302 in pg_toast_16822 when selecting data. Previously when we've run into this kind of corruption we could find the

Re: [GENERAL] Adding a non-null column without noticeable downtime

2014-02-25 Thread Zev Benjamin
EXPLAIN does not appear to work on ALTER TABLE statements: = EXPLAIN ALTER TABLE foo ALTER COLUMN bar SET NOT NULL; ERROR: syntax error at or near ALTER LINE 1: explain ALTER TABLE foo ALTER COLUMN bar SET NOT NULL; ^ Zev On 02/25/2014 01:56 PM, Sameer Kumar wrote: I think

Re: [GENERAL] JSON vs Text + Regexp Index Searching

2014-02-25 Thread Eliot Gable
On Tue, Feb 25, 2014 at 11:17 AM, David Johnston pol...@yahoo.com wrote: David Johnston wrote Eliot Gable-4 wrote I advocated creating a separate mapping table which maps the ID of these records to the other ID we are searching for and performing a JOIN on the two tables with

Re: [GENERAL] JSON vs Text + Regexp Index Searching

2014-02-25 Thread Eliot Gable
On Tue, Feb 25, 2014 at 3:13 PM, Eliot Gable egable+pgsql-gene...@gmail.com wrote: On Tue, Feb 25, 2014 at 11:17 AM, David Johnston pol...@yahoo.com wrote: David Johnston wrote Eliot Gable-4 wrote I advocated creating a separate mapping table which maps the ID of these records to the

[GENERAL] Josh's Comments on Hstore / Jsonb

2014-02-25 Thread john.tiger
Somehow my comments didn't go thru on the soup blog but wanted to throw in more support for this patch Josh, you are so right on the money. An ACID compliant db that serves JSON is great. Sorry I didn't make SCALE this year to hear the PG talks and stop by and say hi. Maybe at Open West ?

Re: [GENERAL] Josh's Comments on Hstore / Jsonb

2014-02-25 Thread Merlin Moncure
On Tue, Feb 25, 2014 at 3:43 PM, john.tiger john.tigernas...@gmail.com wrote: Somehow my comments didn't go thru on the soup blog but wanted to throw in more support for this patch Josh, you are so right on the money. An ACID compliant db that serves JSON is great. Sorry I didn't make SCALE

[GENERAL] How can I use the crosstab() function?

2014-02-25 Thread Rob Richardson
Hello! I am trying to use the crosstab() function in PostgreSQL 9.0 under Windows 7. My table has three columns: a timestamp, a tag name and a tag value. I am trying to generate a table that has one column for every distinct value in the tag name field. Each row of the crosstab table will

Re: [GENERAL] How can I use the crosstab() function?

2014-02-25 Thread Thom Brown
On 25 February 2014 23:30, Rob Richardson rdrichard...@rad-con.com wrote: Hello! I am trying to use the crosstab() function in PostgreSQL 9.0 under Windows 7. My table has three columns: a timestamp, a tag name and a tag value. I am trying to generate a table that has one column for

[GENERAL] why does documentation use END CASE when that doesn't work

2014-02-25 Thread Susan Cassidy
The documentation says: CASE search-expression WHEN expression [, expression [ ... ]] THEN statements [ WHEN expression [, expression [ ... ]] THEN statements ... ] [ ELSE statements ] END CASE; And it repeats the END CASE phrase in other examples. However, that

Re: [GENERAL] why does documentation use END CASE when that doesn't work

2014-02-25 Thread Tom Lane
Susan Cassidy susan.cass...@decisionsciencescorp.com writes: The documentation says: CASE search-expression WHEN expression [, expression [ ... ]] THEN statements [ WHEN expression [, expression [ ... ]] THEN statements ... ] [ ELSE statements ] END CASE;

Re: [GENERAL] why does documentation use END CASE when that doesn't work

2014-02-25 Thread Jov
plpgsql case use end case,while sql case use end,they are different language jov 在 2014-2-26 上午8:32,Susan Cassidy susan.cass...@decisionsciencescorp.com 写道: The documentation says: CASE search-expression WHEN expression [, expression [ ... ]] THEN statements [ WHEN expression

Re: [GENERAL] Adding a non-null column without noticeable downtime

2014-02-25 Thread Sergey Konoplev
On Mon, Feb 24, 2014 at 7:41 PM, Zev Benjamin zev-pg...@strangersgate.com wrote: [...] ALTER TABLE foo ADD COLUMN bar boolean; UPDATE foo SET bar = False; -- Done in batches ALTER TABLE foo ALTER COLUMN bar SET DEFAULT False; ALTER TABLE foo ALTER COLUMN bar SET NOT NULL; You should set

Re: [GENERAL] Adding a non-null column without noticeable downtime

2014-02-25 Thread Vik Fearing
On 02/25/2014 04:41 AM, Zev Benjamin wrote: I'm conceptually trying to do ALTER TABLE foo ADD COLUMN bar boolean NOT NULL DEFAULT False; without taking any noticeable downtime. I know I can divide the query up like so: ALTER TABLE foo ADD COLUMN bar boolean; UPDATE foo SET bar = False; --

Re: [GENERAL] cannot delete corrupted rows after DB corruption: tuple concurrently updated

2014-02-25 Thread john gale
Does anybody have any ideas about this. We restarted the postmaster and the issue persists. So previously in 9.0.4 where we could clean corruption, it seems in 9.3.2 we can no longer clean corruption.o I'm assuming this because our data insert environment has not changed, so we shouldn't be