Re: [GENERAL] How do I calculate the sum of a field filtered by multiple windows defined by another field?

2015-03-15 Thread Robert James
Version 9.2.4 On 3/15/15, David G. Johnston wrote: > On Sunday, March 15, 2015, Robert James wrote: > >> How do I calculate the sum of a field filtered by multiple windows >> defined by another field? >> >> I have table event with fields event_date, num_events, site_id. I can >> easily use aggre

Re: [GENERAL] Preserving formatting and comments in a VIEW definition

2015-03-15 Thread Tom Lane
Robert James writes: > When I save a VIEW, Postgres seems to convert it to a different > format, functionally equivalent but unrecognizable (whitespace, > comments, adds lots of casts, etc.) > Is there any simple way to preserve my original code? The usual suggestion is to keep your SQL code in

[GENERAL] Preserving formatting and comments in a VIEW definition

2015-03-15 Thread Robert James
When I save a VIEW, Postgres seems to convert it to a different format, functionally equivalent but unrecognizable (whitespace, comments, adds lots of casts, etc.) Is there any simple way to preserve my original code? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make

Re: [GENERAL] How do I calculate the sum of a field filtered by multiple windows defined by another field?

2015-03-15 Thread David G. Johnston
On Sunday, March 15, 2015, Robert James wrote: > How do I calculate the sum of a field filtered by multiple windows > defined by another field? > > I have table event with fields event_date, num_events, site_id. I can > easily use aggregate SQL to do SELECT SUM(num_events) GROUP BY > site_id. > >

Re: [GENERAL] regclass and format('%I')

2015-03-15 Thread David G. Johnston
On Sunday, March 15, 2015, Tom Lane wrote: > "David G. Johnston" > writes: > > ​IOW, as long as the output string matches: ^"(?:"{2})*"$ I do not see > how > > it is possible ​for format to lay in a value at %I that is any more > > insecure than the current behavior. If the input string already

Re: [GENERAL] regclass and format('%I')

2015-03-15 Thread Tom Lane
"David G. Johnston" writes: > ​IOW, as long as the output string matches: ^"(?:"{2})*"$ I do not see how > it is possible ​for format to lay in a value at %I that is any more > insecure than the current behavior. If the input string already matches > that pattern then it could be output as-is

Re: [GENERAL] is there a relationship between indexes and temporary file creation?

2015-03-15 Thread Seref Arikan
Thanks Tom, I'll give it a try, the whole setup is synthetic anyway, should not be too much of a trouble Best regards Seref On Sun, Mar 15, 2015 at 3:16 PM, Tom Lane wrote: > Seref Arikan writes: > > Another idea that popped into my head is to consider table partitioning. > Am > > I correct t

Re: [GENERAL] is there a relationship between indexes and temporary file creation?

2015-03-15 Thread Tom Lane
Seref Arikan writes: > Another idea that popped into my head is to consider table partitioning. Am > I correct to assume that (inevitable) joins could benefit from partitions > when sub query criteria constraints results to a particular partition? That's too vague to answer really. My suspicion

[GENERAL] How do I calculate the sum of a field filtered by multiple windows defined by another field?

2015-03-15 Thread Robert James
How do I calculate the sum of a field filtered by multiple windows defined by another field? I have table event with fields event_date, num_events, site_id. I can easily use aggregate SQL to do SELECT SUM(num_events) GROUP BY site_id. But I also have another table site with fields site_id, target

Re: [GENERAL] is there a relationship between indexes and temporary file creation?

2015-03-15 Thread Seref Arikan
Thanks Tom, This is helpful. I'm unable to share the queries but your reasoning helps nonetheless. Another idea that popped into my head is to consider table partitioning. Am I correct to assume that (inevitable) joins could benefit from partitions when sub query criteria constraints results to a