[GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Ilya I. Ashchepkov
Hi. Is spaces is necessary in text presentation of JSONB? In my data resulting text contains ~12% of spaces. I'm developing web application, and want to get json-string from pg and send it to browser without repacking. -- С уважением, Ащепков Илья koc...@gmail.com

[GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Ilya I. Ashchepkov
Hi. Is spaces is nessesary in text presentation of JSONB? In my data resulting text contains ~12% of spaces. I'm developing web application, and want to get json-string from pg and send it to browser without repacking. -- С уважением, Ащепков Илья koc...@gmail.com

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread John R Pierce
On 9/24/2014 12:23 AM, Ilya I. Ashchepkov wrote: Is spaces is necessary in text presentation of JSONB? In my data resulting text contains ~12% of spaces. can you show us an example of this? -- john r pierce 37N 122W somewhere on the middle of the left

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Ilya I. Ashchepkov
I'm sorry about sending email several times. I haven't understand, was it sent by gmail or not. On Wed, Sep 24, 2014 at 2:30 PM, John R Pierce pie...@hogranch.com wrote: On 9/24/2014 12:23 AM, Ilya I. Ashchepkov wrote: Is spaces is necessary in text presentation of JSONB? In my data

[GENERAL] Synchronous replication + pgPool: not all transactions immediately visible on standby

2014-09-24 Thread Thomas Kellerer
Hello, we have a setup with Postgres 9.3.4 running on Ubuntu (don't know the exact version) using streaming replication with a hot standby and pgPool 3.3.3 as a loadbalancer in front of the two Postgres servers. While running automated tests we noticed that despite the fact that replication

Re: [GENERAL] pg_dump: [archiver] -C and -c are incompatible options

2014-09-24 Thread Tom Lane
David G Johnston david.g.johns...@gmail.com writes: Tom Lane-2 wrote Like it says, you should not use both the -C and -c command-line options to pg_dump. I'm not sure how that translates to what you're doing in pgAdmin3, but presumably you're selecting some incompatible options there. You

[GENERAL] Custom type literal conversion

2014-09-24 Thread Chris Bandy
I would like to create a new type for version strings that sorts numerically. The composite type below was quick to write and does not require superuser privileges. However, it doesn't respond to type casts the way I'd like. Is there a way to implement this type's literal conversion without

Re: [GENERAL] Custom type literal conversion

2014-09-24 Thread hubert depesz lubaczewski
On Wed, Sep 24, 2014 at 2:45 PM, Chris Bandy bandy.ch...@gmail.com wrote: I would like to create a new type for version strings that sorts numerically. The composite type below was quick to write and does not require superuser privileges. However, it doesn't respond to type casts the way I'd

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Merlin Moncure
On Wed, Sep 24, 2014 at 2:44 AM, Ilya I. Ashchepkov koc...@gmail.com wrote: I'm sorry about sending email several times. I haven't understand, was it sent by gmail or not. On Wed, Sep 24, 2014 at 2:30 PM, John R Pierce pie...@hogranch.com wrote: On 9/24/2014 12:23 AM, Ilya I. Ashchepkov

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Adrian Klaver
On 09/24/2014 12:44 AM, Ilya I. Ashchepkov wrote: I'm sorry about sending email several times. I haven't understand, was it sent by gmail or not. On Wed, Sep 24, 2014 at 2:30 PM, John R Pierce pie...@hogranch.com mailto:pie...@hogranch.com wrote: On 9/24/2014 12:23 AM, Ilya I. Ashchepkov

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Seref Arikan
This is interesting. Most binary encoding methods I use produce smaller files than the text files for the same content. Having read your mail, I've realized that I have no reason to accept the same from the jsonb. I did a quick google search to see if it is wrong to expect binary encoding to

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Adrian Klaver
On 09/24/2014 07:22 AM, Seref Arikan wrote: This is interesting. Most binary encoding methods I use produce smaller files than the text files for the same content. Having read your mail, I've realized that I have no reason to accept the same from the jsonb. I did a quick google search to see if

[GENERAL] How to clone CURRENT_DATE to SYSDATE ?

2014-09-24 Thread Emanuel Araújo
Hi, I need to clone function CURRENT_DATE to SYSDATE in my PostgreSQL. Does anybody know how to do that it ? -- *Atenciosamente,Emanuel Araújo* *Linux Certified, DBA PostgreSQL*

[GENERAL] readonly user

2014-09-24 Thread Stefan Carl
Dear List, i work with a PostgreSQL/PostGIS-database (version 9.1.14/1.5.3) to manage geodata and other data. Now i want to create a login-role, that only enable readonly rights for the data. I easy find hints to the GRANT-command and i created a login-role readonly and modify the

[GENERAL] Question about row_number() ordering semantics

2014-09-24 Thread Fred Jonsson
Hey everyone, As I was playing around with `row_number()`s for cursor-based pagination, I came across some ordering behavior that I didn't expect. In particular, when I order in a way where multiple rows compete for the same position in the result set (i.e., rows that are equivalent in terms of

Re: [GENERAL] [ADMIN] readonly user

2014-09-24 Thread Geoff Winkless
On 24 September 2014 15:45, Stefan Carl stefancar...@web.de wrote: ALTER DEFAULT PRIVILEGES FOR ddl_user IN SCHEMA public GRANT SELECT ON TABLES TO readonly; ALTER DEFAULT PRIVILEGES FOR ddl_user IN SCHEMA public GRANT SELECT ON SEQUENCES TO readonly; ALTER DEFAULT PRIVILEGES FOR ddl_user

[GENERAL] Why can't I select un-grouped columns when grouping by a (non-primary) unique key?

2014-09-24 Thread Daniel Lenski
If I include the primary key of a table in my GROUP BY clause, PG 9.3 allows me to refer to other columns of that table without explicit GROUP BY: CREATE TABLE A (id SERIAL PRIMARY KEY, name TEXT UNIQUE NOT NULL, document JSON); -- this works fine SELECT A.document FROM A

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Ilya I. Ashchepkov
IMHO, prettification is useful only for debugging. It would be nice to have a session variable for the debug output with spaces, new lines and indentation. On Wed, Sep 24, 2014 at 8:44 PM, Merlin Moncure mmonc...@gmail.com wrote: On Wed, Sep 24, 2014 at 2:44 AM, Ilya I. Ashchepkov

Re: [GENERAL] Question about row_number() ordering semantics

2014-09-24 Thread Tom Lane
Fred Jonsson f...@pyth.net writes: As I was playing around with `row_number()`s for cursor-based pagination, I came across some ordering behavior that I didn't expect. In particular, when I order in a way where multiple rows compete for the same position in the result set (i.e., rows that are

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Ilya I. Ashchepkov
With the same data: # create cast (jsonb as bytea) without function; # select sum(length(data::text))::float/sum(octet_length((data::jsonb)::bytea)) from data.packets; ?column? --- 0.630663654967513 and 0.554666142734544 without spaces On Wed, Sep 24, 2014 at 9:22 PM,

Re: [GENERAL] deadlock of lock-waits (on transaction and on tuple) using same update statement

2014-09-24 Thread Bill Moran
On Tue, 23 Sep 2014 20:00:27 +0200 Andrej Vanek andrej.vanek...@gmail.com wrote: Hi, My application runs many concurrent sessions with the same transaction code starting with an update statement. I would expect locking and serialization of those transactions. But I get unexpected

Re: [GENERAL] Why can't I select un-grouped columns when grouping by a (non-primary) unique key?

2014-09-24 Thread Alberto Cabello Sánchez
On Wed, 24 Sep 2014 09:04:21 -0700 Daniel Lenski dlen...@gmail.com wrote: If I include the primary key of a table in my GROUP BY clause, PG 9.3 allows me to refer to other columns of that table without explicit GROUP BY: Why doesn't the same thing work with a non-NULL unique constraint? At

Re: [GENERAL] Why can't I select un-grouped columns when grouping by a (non-primary) unique key?

2014-09-24 Thread Geoff Montee
On Wed, Sep 24, 2014 at 1:37 PM, Alberto Cabello Sánchez albe...@unex.es wrote: On Wed, 24 Sep 2014 09:04:21 -0700 Daniel Lenski dlen...@gmail.com wrote: If I include the primary key of a table in my GROUP BY clause, PG 9.3 allows me to refer to other columns of that table without explicit

[GENERAL] Transaction completion timing

2014-09-24 Thread Steve Dodd
Say we have two transactions run sequentially: T1 writes some data, and T2 reads the written data. There is a non-zero time delay between the apparent T1 commit, and the subsequent T2 query. Is there any guarantee that the data written in T1 will be visible to the query in T2? We have a

Re: [GENERAL] Transaction completion timing

2014-09-24 Thread Tom Lane
Steve Dodd st...@streetcontxt.com writes: Say we have two transactions run sequentially: T1 writes some data, and T2 reads the written data. There is a non-zero time delay between the apparent T1 commit, and the subsequent T2 query. Is there any guarantee that the data written in T1 will be

Re: [GENERAL] Why can't I select un-grouped columns when grouping by a (non-primary) unique key?

2014-09-24 Thread Daniel Lenski
On Wed, Sep 24, 2014 at 10:46 AM, Geoff Montee geoff.mon...@gmail.com wrote: I believe this blog post contains better examples of the feature he's referring to: http://www.depesz.com/2010/08/08/waiting-for-9-1-recognize-functional-dependency-on-primary-keys/ For example: SELECT p.id,

Re: [GENERAL] Why can't I select un-grouped columns when grouping by a (non-primary) unique key?

2014-09-24 Thread Daniel Lenski
On Wed, Sep 24, 2014 at 10:37 AM, Alberto Cabello Sánchez albe...@unex.es wrote: At first sight, primary key means no grouping at all, as there are no duplicated A.primary_key values: SELECT A.document FROM A GROUP BY A.primary_key is the same as SELECT A.document FROM A

Re: [GENERAL] Why can't I select un-grouped columns when grouping by a (non-primary) unique key?

2014-09-24 Thread Tom Lane
Daniel Lenski dlen...@gmail.com writes: Now that I understand PG's current behavior, it doesn't seem like a huge limitation... but I'm curious about what is preventing the UNIQUE NOT NULL constraints from being allowed as well. Is there something different about the internal representation of

Re: [GENERAL] Custom type literal conversion

2014-09-24 Thread Chris Bandy
On Wed, Sep 24, 2014 at 8:40 AM, hubert depesz lubaczewski dep...@gmail.com wrote: On Wed, Sep 24, 2014 at 2:45 PM, Chris Bandy bandy.ch...@gmail.com wrote: I would like to create a new type for version strings that sorts numerically. The composite type below was quick to write and does not

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Oleg Bartunov
Check slides 17-20 of http://www.sai.msu.su/~megera/postgres/talks/hstore-dublin-2013.pdf to understand, what 'binary format' means. The slides describes binary storage for nested hstore, not jsonb, but you'll get the idea. On Wed, Sep 24, 2014 at 6:22 PM, Seref Arikan serefari...@gmail.com

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread John R Pierce
On 9/24/2014 7:22 AM, Seref Arikan wrote: This is interesting. Most binary encoding methods I use produce smaller files than the text files for the same content. '1' vs INTEGER 1 ... 1 byte vs 4 bytes. now add metadata necessary to represent the original json structure. -- john r pierce

Re: [GENERAL] How to clone CURRENT_DATE to SYSDATE ?

2014-09-24 Thread Adrian Klaver
On 09/24/2014 07:39 AM, Emanuel Araújo wrote: Hi, I need to clone function CURRENT_DATE to SYSDATE in my PostgreSQL. Does anybody know how to do that it ? Not sure what you want? A clone is an exact replica so cloning CURRENT_DATE would create another CURRENT_DATE. My guess is that this

Re: [GENERAL] Transaction completion timing

2014-09-24 Thread Steve Dodd
You could very well be right. We are using JPA under Hibernate, using container managed transactions. So T1 and T2 above are actually container managed transactions, each running in response to REST API requests. They should be bound 1:1 with underlying PostgreSQL transactions, but perhaps

Re: [GENERAL] JSONB spaces in text presentation

2014-09-24 Thread Seref Arikan
Thanks Oleg, I'll check the slides. On Wed, Sep 24, 2014 at 8:07 PM, Oleg Bartunov obartu...@gmail.com wrote: Check slides 17-20 of http://www.sai.msu.su/~megera/postgres/talks/hstore-dublin-2013.pdf to understand, what 'binary format' means. The slides describes binary storage for nested

[GENERAL] spgist index not getting used

2014-09-24 Thread Paul Ramsey
Hi all, I continue to bang along towards a binding of the spgist api from a run-time extension (postgis, in this case). To avoid complication, I am actually not doing any postgis code at this point, just copying the internal point quadtree implementation and seeing if I can get it to turn over.

Re: [GENERAL] spgist index not getting used

2014-09-24 Thread Peter Geoghegan
On Wed, Sep 24, 2014 at 2:01 PM, Paul Ramsey pram...@cleverelephant.ca wrote: If I build an index on the same table using the internal quad-tree ops, and use their operator, I do get an index scan. What about when enable_seqscan = off? -- Regards, Peter Geoghegan -- Sent via pgsql-general

Re: [GENERAL] Synchronous replication + pgPool: not all transactions immediately visible on standby

2014-09-24 Thread Tatsuo Ishii
I think your problem is not relevant to pgpool-II. PostgreSQL's synchronous replication is actually not synchronous (it's confusing but the naming was developer's decision). Primary server sends the committed transaction's WAL record to standby and wait for it is written to the standby's WAL file

Re: [GENERAL] spgist index not getting used

2014-09-24 Thread Paul Ramsey
Still no go. I actually tried a bunch of different selectivity functions too, and the planner correctly used them to estimate the number of potential returned functions, but in no case did the index actually kick in, no matter how selective I made the operator appear.  P. --

Re: [GENERAL] spgist index not getting used

2014-09-24 Thread Tom Lane
Paul Ramsey pram...@cleverelephant.ca writes: My C implementation is here  https://github.com/pramsey/postgis/blob/spgist/postgis/gserialized_spgist_2d.c My SQL binding calls are here  https://github.com/pramsey/postgis/blob/spgist/postgis/gserialized_spgist_2d.sql Thanks to help from

Re: [GENERAL] spgist index not getting used

2014-09-24 Thread Paul Ramsey
Yep, that was a typo (or, rather, an unpushed commit). And yep, the lack of a commutator was the problem.  Thanks so much, it’s a huge relief to see it turning over properly :) now, onwards to actually doing the PostGIS implementation. (On an semi-related note, if the spgist example had been