Re: [SQL] separating improperly grouped page views

2007-06-17 Thread Jeff Frost
On Mon, 18 Jun 2007, Tom Lane wrote: Jeff Frost <[EMAIL PROTECTED]> writes: [ umpteen million iterations of: ] -> Limit (cost=0.00..367.09 rows=1 width=8) -> Index Scan Backward using page_view_stamp_idx on page_view pv2 (cost=0.00..158215.86 rows=431 widt

Re: [SQL] separating improperly grouped page views

2007-06-17 Thread Tom Lane
Jeff Frost <[EMAIL PROTECTED]> writes: > [ umpteen million iterations of: ] > -> Limit (cost=0.00..367.09 rows=1 width=8) > -> Index Scan Backward using page_view_stamp_idx on > page_view pv2 (cost=0.00..158215.86 rows=431 width=8) >

[SQL] separating improperly grouped page views

2007-06-17 Thread Jeff Frost
It seems a user visit cookie's expiration has been improperly set and so the tables which represent a user's clickstream through the website are grouped improperly. I'd like to run a set-wise query to regroup them based on periods of inactivity greather than 1 hour. So, what we want to do is a

Re: [SQL] joining a table whose name is stored in the primary record

2007-06-17 Thread Andrew Sullivan
On Sun, Jun 17, 2007 at 04:39:51AM -0400, John Gunther wrote: > functions and using subqueries without success. I think I need someone > to point me in the right conceptual direction. Well, the right SQL-esque conceptual direction is not to have different tables at all. That's not a very normal-

Re: [SQL] joining a table whose name is stored in the primary record

2007-06-17 Thread Andreas Kretschmer
John Gunther <[EMAIL PROTECTED]> schrieb: > I've tried everything I can think of here to join records when the join > table varies and is named in the primary record, but to no avail. Here's an > example with all non-essentials stripped out. > > I have 3 tables: > > create table zip ( > id se

[SQL] joining a table whose name is stored in the primary record

2007-06-17 Thread John Gunther
I've tried everything I can think of here to join records when the join table varies and is named in the primary record, but to no avail. Here's an example with all non-essentials stripped out. I have 3 tables: create table zip ( id serial primary key, name text, parent_tbl text, parent_id in