Re: [GENERAL] Question about SELECT statements with subselects

2017-09-22 Thread Albe Laurenz
Miloslav Semler wrote: > I found strange behavior with subselects and I am not able to explain > it. I have several tables in schema: > > tramecky, mt_hodnoty, plata_kusy > > in these tables, id is always primary key (serial), table_id is always > foreign key to table. When I run this query: > >

Re: [GENERAL] libpq confusion

2017-09-22 Thread Thomas Delrue
On Wednesday, September 20, 2017 1:47:05 PM EDT Igor Korot wrote: >Thx. >So it is referring to the command not a "command returning no data". ;-) assuming create table t (c int); select c from t; - PQresultStatus(result) == PGRES_TUPLES_OK - PQntuples(result) == number or

[GENERAL] Question about SELECT statements with subselects

2017-09-22 Thread Miloslav Semler
Hello, I found strange behavior with subselects and I am not able to explain it. I have several tables in schema: tramecky, mt_hodnoty, plata_kusy in these tables, id is always primary key (serial), table_id is always foreign key to table. When I run this query: select tramecky.id FROM a.t

Re: [GENERAL] Question about SELECT statements with subselects

2017-09-22 Thread Miloslav Semler
Thank you very much. You have been right. Adding tramecky_id IS NOT NULL solved the problem. Cheers, Miloslav Dne 22.9.2017 v 09:32 Albe Laurenz napsal(a): Miloslav Semler wrote: I found strange behavior with subselects and I am not able to explain it. I have several tables in schema: tramec

[GENERAL] Re: Dynamic use of RAISE with USING to generate and catch non-hardcoded custom exceptions

2017-09-22 Thread mike davis
>This works for me: > >DO $$ >DECLARE > v_msg TEXT := 'SOMETHING IS WRONG'; > v_sqlstate TEXT := 'E0001'; >BEGIN > RAISE EXCEPTION USING message = v_msg, errcode = v_sqlstate; >EXCEPTION > WHEN SQLSTATE 'E0001' THEN > RAISE NOTICE '%','Error E0001 raised - going to do something about it'; >

Re: [GENERAL] Performance appending to an array column

2017-09-22 Thread Imre Samu
>I also tried cstore_fdw for this, but my queries >(building a 2-D histogram) were taking 4+ seconds, >compared to 500ms using arrays. > ... > but maybe I could write my own extension Have you checked the new TimescaleDB extension? [ https://github.com/timescale/timescaledb ] "TimescaleDB is pack

Re: [GENERAL] Insert large number of records

2017-09-22 Thread Alban Hertroys
On 20 September 2017 at 22:55, Job wrote: > One further question: within a query launched on the MASTER table where i > need to scan every table, for exaple to search rows locatd in more partitions. > In there a way to improve "parallel scans" between more table at the same > time or not? > I no

Re: [GENERAL] a JOIN to a VIEW seems slow

2017-09-22 Thread Merlin Moncure
On Thu, Sep 21, 2017 at 12:02 PM, Frank Millman wrote: > On Thu, Sep 21, 2017 at 3:54 PM, Merlin Moncure wrote: >> >> > On Thu, Sep 21, 2017 at 1:51 AM, Frank Millman >> > wrote: >> > >> >> I did not get any response to this, but I am still persevering, and feel >> >> that I am getting closer. In

Re: [GENERAL] VM-Ware Backup of VM safe?

2017-09-22 Thread Klaus P. Pieper
> -Ursprüngliche Nachricht- > Von: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] Im Auftrag von George Neuner > Gesendet: Donnerstag, 21. September 2017 18:35 > > I can't speak for all VM managers, but Vmware's standard static snapshots > *do* capture bot

Re: [GENERAL] a JOIN to a VIEW seems slow

2017-09-22 Thread Frank Millman
Merlin Moncure wrote: On Thu, Sep 21, 2017 at 12:02 PM, Frank Millman wrote: > > SELECT q.cust_row_id, > SUM(CASE WHEN q.tran_date > '2015-08-31' THEN q.balance ELSE 0 END > ) AS "balance_curr AS [DECTEXT]", > SUM(CASE WHEN q.tran_date <= '2015-08-31' AND q.tran_date > '2015-07-31' > THEN q.b

Re: [GENERAL] VM-Ware Backup of VM safe?

2017-09-22 Thread George Neuner
On Fri, 22 Sep 2017 16:14:23 +0200, "Klaus P. Pieper" wrote: >I am aware that VSS is purely Windows, and your comment about VSS aware >application is true. Backup programs / VM managers like Data Protection >Manager trigger these applications to put the files into a safe state >prior to the snaps

[GENERAL] shared_buffers smaller than max_wal_size

2017-09-22 Thread Vladimir Mihailenco
Hi, I wonder what is the point of setting max WAL size bigger than shared buffers, e.g. shared_buffers = 512mb max_wal_size = 2gb As I understand a checkpoint happens after 2gb of data were modified (writter to WAL), but shared buffers can contain at most 512mb of dirty pages to be flushed to th

[GENERAL] errors on COMMIT and transaction states

2017-09-22 Thread Andrei Matei
Hello all, I've got a question about the state in which a session/transaction finds itself in case a COMMIT statement fails. I hope this is a good mailing list to ask it on. Is it true that a failed COMMIT behaves just like a ROLLBACK statement would have if it was issues in its stead? In other wo

Re: [GENERAL] Multicolumn Index on OR conditions

2017-09-22 Thread legrand legrand
No You should try with 2 single column indexes and may be rewrite your query with a Union All syntax -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: h

[GENERAL] Is float8 a reference type?

2017-09-22 Thread Paul A Jungwirth
The docs say that a Datum can be 4 bytes or 8 depending on the machine: https://www.postgresql.org/docs/9.5/static/sql-createtype.html Is a Datum always 8 bytes for 64-bit architectures? And if so, can my C extension skip a loop like this when compiling there, and just do a memcpy (or even a cas

Re: [GENERAL] Is float8 a reference type?

2017-09-22 Thread Paul A Jungwirth
On Fri, Sep 22, 2017 at 7:52 PM, Paul A Jungwirth wrote: > Is a Datum always 8 bytes for 64-bit architectures? Never mind, I found this in `pg_config.h`: /* float8, int8, and related values are passed by value if 'true', by reference if 'false' */ #define FLOAT8PASSBYVAL true Pau

Re: [GENERAL] Is float8 a reference type?

2017-09-22 Thread Pavel Stehule
2017-09-23 4:52 GMT+02:00 Paul A Jungwirth : > The docs say that a Datum can be 4 bytes or 8 depending on the machine: > > https://www.postgresql.org/docs/9.5/static/sql-createtype.html > > Is a Datum always 8 bytes for 64-bit architectures? > > And if so, can my C extension skip a loop like this

Re: [GENERAL] Is float8 a reference type?

2017-09-22 Thread Paul A Jungwirth
On Fri, Sep 22, 2017 at 8:05 PM, Pavel Stehule wrote: > yes, it is 8 bytes on 64-bit. Thanks! > I don't think so it is good idea to write 64bit only extensions. I agree, but how about this?: if (FLOAT8PASSBYVAL) { datums = (Datum *)floats; } else { datums = palloc0(arrlen *

Re: [GENERAL] Is float8 a reference type?

2017-09-22 Thread Pavel Stehule
2017-09-23 5:10 GMT+02:00 Paul A Jungwirth : > On Fri, Sep 22, 2017 at 8:05 PM, Pavel Stehule > wrote: > > yes, it is 8 bytes on 64-bit. > > Thanks! > > > I don't think so it is good idea to write 64bit only extensions. > > I agree, but how about this?: > > if (FLOAT8PASSBYVAL) { > datu

Re: [GENERAL] Is float8 a reference type?

2017-09-22 Thread Tom Lane
Paul A Jungwirth writes: > On Fri, Sep 22, 2017 at 8:05 PM, Pavel Stehule > wrote: >> I don't think so it is good idea to write 64bit only extensions. > I agree, but how about this?: "Premature optimization is the root of all evil". Do you have good reason to think that it's worth your time t

[GENERAL] Why can't the database owner create schemas and how can I enable that?

2017-09-22 Thread Tim Uckun
I am setting up a database for an app. So I create a user without superuser but with login priveleges I then create a database and set it's owner to that user like this... dropdb --if-exists api_development dropuser --if-exists api_user createuser api_user -P -d createdb api_development -O api_u

[GENERAL] shared_buffers smaller than max_wal_size

2017-09-22 Thread Vladimir Mihailenco
Hi, I wonder what is the point of setting max WAL size bigger than shared buffers, e.g. shared_buffers = 512mb max_wal_size = 2gb As I understand a checkpoint happens after 2gb of data were modified (writter to WAL), but shared buffers can contain at most 512mb of dirty pages to be flushed to th

Re: [GENERAL] Why can't the database owner create schemas and how can I enable that?

2017-09-22 Thread John R Pierce
On 9/22/2017 10:29 PM, Tim Uckun wrote: I am setting up a database for an app. So I create a user without superuser but with login priveleges I then create a database and set it's owner to that user like this... dropdb --if-exists api_development dropuser --if-exists api_user createuser api_u