Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > dynamic events ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 3539 of 3797
Post > Topic >>

dynamic events categorization

by vindex+lists-pgsql-sql@[EMAIL PROTECTED] (Louis-David Mitterrand) Jun 24, 2008 at 10:43 AM

Hello,

I'm looking for a more efficient way of dynamically categorizing some
events. The following view definition looks into each event's latest
event_date object (a theater play can have several, a book only one) to
tell whether the event is current, past or future:

	SELECT s.id_event_subtype, s.subtype, t.id_event_type, t.type,
	e.id_event, e.created_by, e.created_on, e.modified_by, e.modified_on,
	e.id_image, e.show_name, e.length, d.id_date,
	d.start_date, d.end_date, d.low_price, d.high_price, d.id_location,
	d.showtime,
			CASE
				WHEN d.start_date <= 'now'::text::date AND 
				CASE
					WHEN t.type = 'movie'::text THEN d.start_date >= ('now'::text::date -
21)
					WHEN t.type = 'book'::text THEN e.created_on >= ('now'::text::date -
28)
					ELSE d.end_date >= 'now'::text::date OR d.end_date IS NULL
				END THEN '0_current'::text
				WHEN d.start_date > 'now'::text::date THEN '1_future'::text
				WHEN d.start_date IS NOT NULL THEN '2_past'::text
				ELSE ''::text
			END AS timing
	FROM event e
	NATURAL JOIN event_type2 t
	LEFT JOIN event_subtype2 s USING (id_event_subtype)
	LEFT JOIN show_date d USING (id_event);

This view is widely used in my application, including as a basis for
further views, as I almost always need to know the 'timing' category of
an event (past, current, future). But I have nagging doubts about its
efficiency. It also seems pretty slow in its current form.

Any suggestion on how to improve it (including schema modifications) are
more than welcome.

Thanks,

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 3 Posts in Topic:
dynamic events categorization
vindex+lists-pgsql-sql@[E  2008-06-24 10:43:54 
Re: dynamic events categorization
M.Mamin@[EMAIL PROTECTED]  2008-06-26 17:06:14 
Re: dynamic events categorization
vindex+lists-pgsql-sql@[E  2008-06-27 17:11:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 11:17:36 CST 2008.