Icon View Incident Report

Serious Serious
Reported By: Hedley Muscroft
Reported On: 2/14/2009
For: Version 2.02 Build 7
# 2924 Using Views in Joins in a SELECT Statement Results in Very Slow Performance

I seem to be hitting quite a lot of performance issues when JOINing to VIEWs in my queries in ElevateDB.

See below for an example of a SELECT statement that takes a very long time to execute.

select inv.id,
invoicenum,
datetime,
inv.discpercent,
discamount,
nettotal, 
taxtotal,
total,
printed,
inv.per_id as recipient_per_id,
rtrim(recipper.lastname || ', ' || 
coalesce(recipper.firstname,'') || ' ' ||
coalesce(recipper.title,'')) as _recipient,
inv.clinic_id,
clinic.name as _clinicname,
inv.staff_id,
staff.knownas as _staffmember,
inv.room_id,
room.name as _roomname,
inv.apptype_id,
apptype.name as _apptype,
inv.patient_per_id,
rtrim(patper.lastname || ', ' || 
coalesce(patper.firstname,'') || ' ' ||
coalesce(patper.title,'')) as _patient,
patper.code, patper.insuranceref, (coalesce(clinic.prefix, '') || 
cast(inv.invoicenum as varchar(20))) as _invoiceref,
coalesce(view_invamtalloc.amtalloc, 0) as amtpaid,
case
 when (inv.total = 0) or
      (view_invamtalloc.amtalloc >= inv.total) then 'Paid In Full'
 when (view_invamtalloc.amtalloc > 0) and
      (view_invamtalloc.amtalloc < inv.total) then 'Part Paid'
 else 'Unpaid'
end as _status
from inv
inner join per as recipper on (inv.per_id = recipper.id)
inner join clinic on (inv.clinic_id = clinic.id)
left join staff on (inv.staff_id = staff.id)
left join room on (inv.room_id = room.id)
left join apptype on (inv.apptype_id = apptype.id)
left join per as patper on (inv.patient_per_id = patper.id)
left join view_invamtalloc on (inv.id = view_invamtalloc.inv_id)

View definition:

create view view_invamtalloc AS
select inv_id, per_id, sum(amount) as amtalloc
from alloc
where (inv_id is not null)
group by inv_id, per_id;



Comments Comments
The problem was related to the type of result set that is returned for views vs. the raw table opens that are performed on the base tables for purposes of usage in queries.


Resolution Resolution
Fixed Problem on 2/16/2009 in version 2.02 build 8


Products Affected Products Affected
ElevateDB Additional Software and Utilities
ElevateDB DAC Client-Server
ElevateDB DAC Client-Server with Source
ElevateDB DAC Standard
ElevateDB DAC Standard with Source
ElevateDB DAC Trial
ElevateDB LCL Standard with Source
ElevateDB VCL Client-Server
ElevateDB VCL Client-Server with Source
ElevateDB VCL Standard
ElevateDB VCL Standard with Source
ElevateDB VCL Trial

Image