Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Jon Nelson
On Wed, Apr 4, 2012 at 12:51 PM, Thomas Kellerer wrote: > Jon Nelson wrote on 04.04.2012 19:47: > >>> What about a set-returning function that builds the query dynamically and >>> wrapping that into a view? >>> >>> That way the view would never change and client would still have the >>> perspectiv

Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Thomas Kellerer
Jon Nelson wrote on 04.04.2012 19:47: What about a set-returning function that builds the query dynamically and wrapping that into a view? That way the view would never change and client would still have the perspective of a view/table Your function could pick up the changes automatically e.g.

Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Merlin Moncure
On Wed, Apr 4, 2012 at 12:47 PM, Jon Nelson wrote: > On Wed, Apr 4, 2012 at 11:22 AM, Thomas Kellerer wrote: >> Jon Nelson wrote on 04.04.2012 15:50: >> >>> I need to have something table-like from the client's perspective for >>> a bunch of reasons. >>> For now, assume that I want to keep using

Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Jon Nelson
On Wed, Apr 4, 2012 at 11:22 AM, Thomas Kellerer wrote: > Jon Nelson wrote on 04.04.2012 15:50: > >> I need to have something table-like from the client's perspective for >> a bunch of reasons. >> For now, assume that I want to keep using the view and that I'd like >> to find better ways to addres

Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Thomas Kellerer
Jon Nelson wrote on 04.04.2012 15:50: I need to have something table-like from the client's perspective for a bunch of reasons. For now, assume that I want to keep using the view and that I'd like to find better ways to address my concerns. What about a set-returning function that builds the qu

Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Jon Nelson
On Wed, Apr 4, 2012 at 10:43 AM, Tom Lane wrote: > Jon Nelson writes: >> On Wed, Apr 4, 2012 at 9:01 AM, Tom Lane wrote: >>> Why aren't you using a standard partitioned table, cf >>> http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html > >> Because I'm adding "scalar" (constant-value)

Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Tom Lane
Jon Nelson writes: > On Wed, Apr 4, 2012 at 9:01 AM, Tom Lane wrote: >> Why aren't you using a standard partitioned table, cf >> http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html > Because I'm adding "scalar" (constant-value) columns to the view like this: > SELECT * from tableA, D

Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Jon Nelson
On Wed, Apr 4, 2012 at 9:01 AM, Tom Lane wrote: > > Why aren't you using a standard partitioned table, cf > http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html Because I'm adding "scalar" (constant-value) columns to the view like this: SELECT * from tableA, DATE 'date string here' as

Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Tom Lane
Jon Nelson writes: > I need to have something table-like from the client's perspective for > a bunch of reasons. > For now, assume that I want to keep using the view and that I'd like > to find better ways to address my concerns. Why aren't you using a standard partitioned table, cf http://www.po

Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Merlin Moncure
On Wed, Apr 4, 2012 at 8:50 AM, Jon Nelson wrote: > > I need to have something table-like from the client's perspective for > a bunch of reasons. > For now, assume that I want to keep using the view and that I'd like > to find better ways to address my concerns. hence my question upthread: "how s

Re: [GENERAL] views, queries, and locks

2012-04-04 Thread Jon Nelson
On Tue, Apr 3, 2012 at 8:58 PM, Scott Marlowe wrote: > On Tue, Apr 3, 2012 at 7:21 PM, Jon Nelson wrote: >> On Tue, Apr 3, 2012 at 2:45 PM, Thomas Kellerer wrote: >>> Jon Nelson wrote on 03.04.2012 20:41: >>> Close, but not quite. It's not rotation but every N minutes a newly-built tab

Re: [GENERAL] views, queries, and locks

2012-04-03 Thread Scott Marlowe
On Tue, Apr 3, 2012 at 7:21 PM, Jon Nelson wrote: > On Tue, Apr 3, 2012 at 2:45 PM, Thomas Kellerer wrote: >> Jon Nelson wrote on 03.04.2012 20:41: >> >>> Close, but not quite. It's not rotation but every N minutes a >>> newly-built table appears. I'd like that table to appear as part of >>> the

Re: [GENERAL] views, queries, and locks

2012-04-03 Thread Jon Nelson
On Tue, Apr 3, 2012 at 2:45 PM, Thomas Kellerer wrote: > Jon Nelson wrote on 03.04.2012 20:41: > >> Close, but not quite. It's not rotation but every N minutes a >> newly-built table appears. I'd like that table to appear as part of >> the view as soon as possible. > > > Can't you use table inheri

Re: [GENERAL] views, queries, and locks

2012-04-03 Thread Scott Marlowe
On Tue, Apr 3, 2012 at 1:45 PM, Thomas Kellerer wrote: > Jon Nelson wrote on 03.04.2012 20:41: > >> Close, but not quite. It's not rotation but every N minutes a >> newly-built table appears. I'd like that table to appear as part of >> the view as soon as possible. > > > Can't you use table inheri

Re: [GENERAL] views, queries, and locks

2012-04-03 Thread Thomas Kellerer
Jon Nelson wrote on 03.04.2012 20:41: Close, but not quite. It's not rotation but every N minutes a newly-built table appears. I'd like that table to appear as part of the view as soon as possible. Can't you use table inheritance for that? -- Sent via pgsql-general mailing list (pgsql-gener

Re: [GENERAL] views, queries, and locks

2012-04-03 Thread Merlin Moncure
On Tue, Apr 3, 2012 at 1:41 PM, Jon Nelson wrote: > On Tue, Apr 3, 2012 at 1:36 PM, Merlin Moncure wrote: >> Generally speaking, in SQL, locks are held until the transaction >> commits; there are tons of reasons why things have to work that way. >> Anyways, I'm betting your requirement to have to

Re: [GENERAL] views, queries, and locks

2012-04-03 Thread Jon Nelson
On Tue, Apr 3, 2012 at 1:36 PM, Merlin Moncure wrote: > On Tue, Apr 3, 2012 at 12:30 PM, Jon Nelson wrote: >> On Tue, Apr 3, 2012 at 12:16 PM, Merlin Moncure wrote: >>> On Tue, Apr 3, 2012 at 12:01 PM, Jon Nelson >>> wrote: I have a situation that I'd like some help resolving. Using

Re: [GENERAL] views, queries, and locks

2012-04-03 Thread Merlin Moncure
On Tue, Apr 3, 2012 at 12:30 PM, Jon Nelson wrote: > On Tue, Apr 3, 2012 at 12:16 PM, Merlin Moncure wrote: >> On Tue, Apr 3, 2012 at 12:01 PM, Jon Nelson >> wrote: >>> I have a situation that I'd like some help resolving. >>> Using PostgreSQL 8.4. on Linux, I have three things >>> coming toget

Re: [GENERAL] views, queries, and locks

2012-04-03 Thread Thomas Kellerer
Jon Nelson wrote on 03.04.2012 19:01: I also update this view with CREATE OR REPLACE VIEW every 15-30 minutes That is a highly questionable approach. What real problem are you trying to solve with that? Maybe there is a better solution that does not require changing the view. -- Sent via p

Re: [GENERAL] views, queries, and locks

2012-04-03 Thread Jon Nelson
On Tue, Apr 3, 2012 at 12:16 PM, Merlin Moncure wrote: > On Tue, Apr 3, 2012 at 12:01 PM, Jon Nelson wrote: >> I have a situation that I'd like some help resolving. >> Using PostgreSQL 8.4. on Linux, I have three things >> coming together that cause me pain. I have a VIEW used by a bunch of >> qu

Re: [GENERAL] views, queries, and locks

2012-04-03 Thread Merlin Moncure
On Tue, Apr 3, 2012 at 12:01 PM, Jon Nelson wrote: > I have a situation that I'd like some help resolving. > Using PostgreSQL 8.4. on Linux, I have three things > coming together that cause me pain. I have a VIEW used by a bunch of > queries. Usually, these queries are fairly short (subsecond) but

[GENERAL] views, queries, and locks

2012-04-03 Thread Jon Nelson
I have a situation that I'd like some help resolving. Using PostgreSQL 8.4. on Linux, I have three things coming together that cause me pain. I have a VIEW used by a bunch of queries. Usually, these queries are fairly short (subsecond) but sometimes they can be very long (days). I also update this