Re: [GENERAL] JSONB performance enhancement for 9.6

2016-02-08 Thread Álvaro Hernández Tortosa
On 20/01/16 13:32, Bill Moran wrote: On Tue, 19 Jan 2016 23:53:19 -0300 Alvaro Herrera wrote: Bill Moran wrote: As far as a current solution: my solution would be to decompose the JSON into an optimized table. I.e.: CREATE TABLE store1 ( id SERIAL PRIMARY KEY, data JSONB ); CREATE TA

Re: [GENERAL] JSONB performance enhancement for 9.6

2016-02-08 Thread Tom Smith
Using JSON/JSONB type in postgresql is usually due to the use case that the keys (top level included) can not be predefined. this is the major difference between NoSQL/Document and RDBMS. Why would TOAST have to be used? Can some speciailly structured "raw" files be used outside current databa

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes wrote: > Am 08.02.2016 um 21:50 schrieb Vitaly Burovoy: >> On 2/8/16, Johannes wrote: >>> Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: Hmm. Could you clarify why you don't want to pass id from the first query to the second one: select col1 from t1 where t

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Am 08.02.2016 um 21:50 schrieb Vitaly Burovoy: > On 2/8/16, Johannes wrote: >> Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: >>> On 2/8/16, Johannes wrote: Am 08.02.2016 um 20:15 schrieb David G. Johnston: > On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: > >> Hi, >> >>>

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Alban Hertroys wrote: > >> On 08 Feb 2016, at 20:05, Johannes wrote: >> >> select id, col1, col2, ... from t0 where id = (select max(id) from t0 >> where col1 = value1 and col2 = value2 and …); >> >> select col1 from t1 where t0_id = (select max(id) from t0 where col1 = >> value1 and c

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes wrote: > Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: >> On 2/8/16, Johannes wrote: >>> Am 08.02.2016 um 20:15 schrieb David G. Johnston: On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: > Hi, > > is there a best practice to share data between two sele

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Alban Hertroys
> On 08 Feb 2016, at 20:05, Johannes wrote: > > select id, col1, col2, ... from t0 where id = (select max(id) from t0 > where col1 = value1 and col2 = value2 and …); > select col1 from t1 where t0_id = (select max(id) from t0 where col1 = > value1 and col2 = value2 and …); select t0.id, t0.co

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Am 08.02.2016 um 21:33 schrieb Vitaly Burovoy: > On 2/8/16, Johannes wrote: >> >> Am 08.02.2016 um 20:32 schrieb Vitaly Burovoy: >>> On 2/8/16, Adrian Klaver wrote: Based on rough guess of the above, without seeing actual table schemas: select id, t0.col1, t1.col1, col2, ... from

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes wrote: > > Am 08.02.2016 um 20:32 schrieb Vitaly Burovoy: >> On 2/8/16, Adrian Klaver wrote: >>> Based on rough guess of the above, without seeing actual table schemas: >>> >>> select id, t0.col1, t1.col1, col2, ... from t0 JOIN t1 ON t0.id = >>> t1.t0_id where id = (select ma

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: > On 2/8/16, Johannes wrote: >> Am 08.02.2016 um 20:15 schrieb David G. Johnston: >>> On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: >>> Hi, is there a best practice to share data between two select statements? Imaging fo

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Am 08.02.2016 um 20:32 schrieb Vitaly Burovoy: > On 2/8/16, Adrian Klaver wrote: >> On 02/08/2016 11:05 AM, Johannes wrote: >>> Imaging following situation: I want to receive two result sets from two >>> tables, referring to a specific id from table t0 AND I try not to query >>> for that specifi

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes wrote: > Am 08.02.2016 um 20:15 schrieb David G. Johnston: >> On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: >> >>> Hi, >>> >>> is there a best practice to share data between two select statements? >>> >>> Imaging following situation: I want to receive two result sets from t

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Am 08.02.2016 um 20:15 schrieb David G. Johnston: > On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: > >> Hi, >> >> is there a best practice to share data between two select statements? >> >> Imaging following situation: I want to receive two result sets from two >> tables, referring to a specifi

Re: [GENERAL] Trouble installing postgresql server on Amazon Linux

2016-02-08 Thread John R Pierce
On 2/7/2016 1:35 PM, Augori wrote: ... In fact, it seems like both of them must be the wrong repos? So I need to remove these? # rpm -e pgdg-93-redhat.repo error: package pgdg-93-redhat.repo is not installed # rpm -e pgdg-93-ami201503.repo error: package pgdg-93-ami201503.repo is not installed

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, tra...@traviswellman.com wrote: > Not an expert, but I would try a temporary unlogged table. Note: temporary tables are always unlogged. Please, 1. Don't top post. 2. Use "Reply to all" to be sure an author of an original letter gets your answer even if he hasn't subscribed to the lis

Re: [GENERAL] Let's Do the CoC Right

2016-02-08 Thread Tom Lane
Chris Travers writes: > Core has spoken that they will create one. I them that it will maintain > the general political neutrality of the community (and again for the > record, I don't see the topless dancer conference issue as one that > compromised that political neutrality either). So as far

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Adrian Klaver wrote: > On 02/08/2016 11:05 AM, Johannes wrote: >> Imaging following situation: I want to receive two result sets from two >> tables, referring to a specific id from table t0 AND I try not to query >> for that specific id a second time. > >> Table t0 returns 1 row and tab

Re: [GENERAL] Let's Do the CoC Right

2016-02-08 Thread Chris Travers
I was hoping to let this thread lie. However because I think there is a need for people to sit back and wait for the draft to be circulated, there are a couple more thoughts that are important to add. I am working on one more blog post on the topic but will not further participate in this discus

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes wrote: > Hi, > > is there a best practice to share data between two select statements? > > Imaging following situation: I want to receive two result sets from two > tables, referring to a specific id from table t0 AND I try not to query > for that specific id a second time. > >

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Adrian Klaver
On 02/08/2016 11:05 AM, Johannes wrote: Hi, is there a best practice to share data between two select statements? A join: http://www.postgresql.org/docs/9.4/interactive/sql-select.html Search for: join_type Imaging following situation: I want to receive two result sets from two tables, re

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread travis
Not an expert, but I would try a temporary unlogged table. Sent from my android device. -Original Message- From: Johannes To: pgsql-general@postgresql.org Sent: Mon, 08 Feb 2016 11:07 Subject: [GENERAL] execute same query only one time? Hi, is there a best practice to share data betwee

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread David G. Johnston
On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: > Hi, > > is there a best practice to share data between two select statements? > > Imaging following situation: I want to receive two result sets from two > tables, referring to a specific id from table t0 AND I try not to query > for that specifi

[GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Hi, is there a best practice to share data between two select statements? Imaging following situation: I want to receive two result sets from two tables, referring to a specific id from table t0 AND I try not to query for that specific id a second time. Table t0 returns 1 row and table t1 return

[GENERAL] COALESCE requires NULL from scalar subquery has a type

2016-02-08 Thread Geoff Winkless
Hi Not an important question, but a niggle. CREATE TABLE gwtest (id INT PRIMARY KEY); INSERT INTO gwtest VALUES (1),(2),(3); SELECT COALESCE((SELECT 'Yes' FROM gwtest WHERE id=4), 'No') AS valid; gives an error failed to find conversion function from unknown to text I can work around this with

[GENERAL] Reminder: PgDay @ LFNW CFP is closing on the 10th

2016-02-08 Thread Joshua D. Drake
Hello, As a reminder the PgDay @ LFNW CFP is closing on the 10th. This is a great 2000 person non-profit conference that takes place at a local college in Bellingham, WA. We are still looking for talks! Bring your ideas. Sincerely, JD -- Command Prompt, Inc. http://the.pos

Re: [GENERAL] four template0 databases after vacuum

2016-02-08 Thread Adrian Klaver
On 02/08/2016 04:16 AM, Kazuaki Fujikura wrote: Thank you for your comments. First, I think I need to tell you our database situation - 3 physical databases (installed in different servers. 1master, 2 slave servers.) For future reference the above are generally called database clusters or in

Re: [GENERAL] Trouble installing postgresql server on Amazon Linux

2016-02-08 Thread Adrian Klaver
On 02/07/2016 01:35 PM, Augori wrote: Thanks for the reply. Yes, it seems that you're right about having multiple pgdg93 repos,. # yum repolist Loaded plugins: priorities, update-motd, upgrade-helper Repository pgdg93 is listed more than once in the configuration Repository pgdg93-source is li

Re: [GENERAL] FDW and transaction management

2016-02-08 Thread Michael Holzman
On Mon, Feb 8, 2016 at 6:25 PM, Adrian Klaver wrote: > What is the correct state of the subject? > > The documentation. > > If you look a bottom of Wiki page you will find: > > This page was last modified on 6 March 2012, at 11:11 > > -- > Adrian Klaver > Thanks -- Regards, Michael Holzman

Re: [GENERAL] FDW and transaction management

2016-02-08 Thread Adrian Klaver
On 02/07/2016 10:24 PM, Michael Holzman wrote: Greetings, I am trying to understand the subject. I see in the documentation (http://www.postgresql.org/docs/current/static/postgres-fdw.html) that F.31.3. Transaction Management During a query that references any remote tables on a foreign s

Re: [GENERAL] fast refresh materialized view

2016-02-08 Thread Nguyễn Trần Quốc Vinh
Thank you very much. We did n't think about that. We would like to choose APACHE LICENSE. We apologize for late reply. We would like to get discussion of the experts. Thanks and best regards, TS. Nguyễn Trần Quốc Vinh --- Chủ nhiệm khoa Tin học Trường

Re: [GENERAL] COALESCE requires NULL from scalar subquery has a type

2016-02-08 Thread David G. Johnston
On Mon, Feb 8, 2016 at 8:25 AM, Geoff Winkless wrote: > On 8 February 2016 at 14:49, Tom Lane wrote: > > Yup. The output column type of the sub-SELECT is determined without > > reference to its context, so there's nothing causing the unknown-type > > literal to get assigned a definite type. > >

Re: [GENERAL] Very slow DELETEs with foreign keys

2016-02-08 Thread Tom Lane
Thom Brown writes: > Yeah, there's no index on contacts.country, and that would certainly > make the query acceptably quick, but I'm asking whether the > non-indexed scenario is going about things the most efficient way, > given what it has available to it. [ shrug... ] If you're up for nuking t

Re: [GENERAL] COALESCE requires NULL from scalar subquery has a type

2016-02-08 Thread Geoff Winkless
On 8 February 2016 at 14:49, Tom Lane wrote: > Yup. The output column type of the sub-SELECT is determined without > reference to its context, so there's nothing causing the unknown-type > literal to get assigned a definite type. Mm. I can follow that, although it makes me unhappy that casting t

Re: [GENERAL] Very slow DELETEs with foreign keys

2016-02-08 Thread Thom Brown
On 8 February 2016 at 14:52, Tom Lane wrote: > Thom Brown writes: >> I've just noticed a general delete performance issue while testing a >> patch, and this can be recreated on all recent major versions. > >> I have 2 tables: > >> CREATE TABLE countries ( >> country text PRIMARY KEY, >> c

Re: [GENERAL] COALESCE requires NULL from scalar subquery has a type

2016-02-08 Thread Tom Lane
Geoff Winkless writes: > SELECT COALESCE((SELECT 'Yes' FROM gwtest WHERE id=4), 'No') AS valid; > gives an error > I'm guessing this is because Postgres can't deduce the type of the > string column from the source when the result isn't returned. Oddly, > it also seems to cope when I do: > SELECT

Re: [GENERAL] Very slow DELETEs with foreign keys

2016-02-08 Thread Tom Lane
Thom Brown writes: > I've just noticed a general delete performance issue while testing a > patch, and this can be recreated on all recent major versions. > I have 2 tables: > CREATE TABLE countries ( > country text PRIMARY KEY, > continent text > ); > CREATE TABLE contacts ( > id s

[GENERAL] Very slow DELETEs with foreign keys

2016-02-08 Thread Thom Brown
Hi, I've just noticed a general delete performance issue while testing a patch, and this can be recreated on all recent major versions. I have 2 tables: CREATE TABLE countries ( country text PRIMARY KEY, continent text ); CREATE TABLE contacts ( id serial PRIMARY KEY, first_name

[GENERAL] COALESCE requires NULL from scalar subquery has a type

2016-02-08 Thread Geoff Winkless
Hi Not an important question, but a niggle. CREATE TABLE gwtest (id INT PRIMARY KEY); INSERT INTO gwtest VALUES (1),(2),(3); SELECT COALESCE((SELECT 'Yes' FROM gwtest WHERE id=4), 'No') AS valid; gives an error failed to find conversion function from unknown to text I can work around this with

Re: [GENERAL] four template0 databases after vacuum

2016-02-08 Thread Kazuaki Fujikura
Thank you for your comments. First, I think I need to tell you our database situation - 3 physical databases (installed in different servers. 1master, 2 slave servers.) - more than logical 1100 databases in each servers [Karsten and Melvin] It shows 0 records in template0 with the query you pro

Re: [GENERAL] Is PRIMARY KEY the same as UNIQUE NOT NULL?

2016-02-08 Thread Geoff Winkless
On 7 February 2016 at 21:04, Tom Lane wrote: > Geoff Winkless writes: >> On 31 January 2016 at 19:53, David G. Johnston >> wrote: >>> A PRIMARY KEY enforces a UNIQUE, NOT NULL constraint and additionally allows > >> I would just remove the whole paragraph. A primary key does what it >> does, a u

Re: [GENERAL] Code of Conduct plan

2016-02-08 Thread benjamin barber
The Code of Conducts basically amount to a "code of wrongthink". This can be best described when some of their advocates, like for example in the Node project make respositories called "mansplain" and "misandry", or when speakers at OSCON are caught with mugs reading "male tears" and using the "#ki

Re: [GENERAL] Let's Do the CoC Right

2016-02-08 Thread Gavin Flower
On 24/01/16 13:48, Regina Obe wrote: This is mostly in response to David's recent comments. I should say David, you are really beginning to make me feel unsafe. By unsafe I mean my mental safety of being able to speak truthfully without fear of being kicked out of a community I love. I do not t

Re: [GENERAL] log_min_duration question

2016-02-08 Thread Joshua Berkus
- Original Message - > From the 9.5 docs: > > log_min_duration_statement (integer) > > Causes the duration of each completed statement to be logged if the > statement ran for at least the specified number of > milliseconds. Setting this to zero prints all statement > durations

[GENERAL] log_min_duration question

2016-02-08 Thread Harald Fuchs
>From the 9.5 docs: log_min_duration_statement (integer) Causes the duration of each completed statement to be logged if the statement ran for at least the specified number of milliseconds. Setting this to zero prints all statement durations. Minus-one (the default) disables logging sta