So we have a system that uses two columns as the unique ID the userid as well as the a date. We have to keep every record that has ever been associated with a particular subject so there are no deleted records. So one subject can have 50 records. The database designer created views to get the latest row for a subject. Database is really not that huge in terms of record count we are roughly at 750000 records.
The view is written for every table very similar to:
Select Username,
UserID
From users
where USerID = 000
and UserUpdatedDate = (
Select MAX(UserUpdatedDate)
FROM
users a
WHERE a.USerID = UserID
)
We are seeing a major slowness, any suggestions would be welcomed?
We are rewriting some queries using temp tables, it seems to be quicker. Is this a good thing or bad in long haul