I'm starting to do some tuning on Sloan's upgraded OACS5.1 + .LRN 2.1 pre-release system.
One of the slower queries is dbqd.calendar.www.views.select_items. For the calendar "day view" it takes about 1.6 seconds. We've got roughly 36,000 rows in cal_items and > 10,000 in each of the six tables that are joined.
I've experimented a little bit with creating indexes but haven't really thought deeply about it yet.
If you happened to have tuned this query, or have ideas about how to tune it, I'd appreciate hearing about it.
Here's the query for reference:
select to_char(start_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_start_date,
to_char(end_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_end_date,
to_number(to_char(start_date,'HH24'),'90') as start_hour,
to_number(to_char(end_date,'HH24'),'90') as end_hour,
to_number(to_char(end_date,'MI'),'90') as end_minutes,
nvl(e.name, a.name) as name,
nvl(e.status_summary, a.status_summary) as status_summary,
e.event_id as item_id,
(select type from cal_item_types where item_type_id= ci.item_type_id) as item_type,
cals.calendar_id,
cals.calendar_name
from acs_activities a,
acs_events e,
timespans s,
time_intervals t,
cal_items ci,
calendars cals
where e.timespan_id = s.timespan_id
and s.interval_id = t.interval_id
and e.activity_id = a.activity_id
and start_date between
to_date(:current_date,'YYYY-MM-DD')
and (to_date(:current_date,'YYYY-MM-DD') + (24 - 1/3600)/24)
and ci.cal_item_id = e.event_id
and cals.calendar_id = ci.on_which_calendar
and e.event_id = ci.cal_item_id
and (to_char(start_date, 'HH24:MI') <> '00:00' or to_char(end_date, 'HH24:MI') <> '00:00')
and on_which_calendar in (long list of integers) and (cals.private_p='f' or (cals.private_p='t' and cals.owner_id= :user_id))
order by to_char(start_date,'HH24')