SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Table with status column that looks up history table based on date


Table with status column that looks up history table based on date

Author
Message
agibson83
agibson83
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 2
I have a Users table with a CurrentStatus column which is a computed column that runs a UDF passing in the UserID and getdate(). The UDF queries a UserHistory table which contains ID, UserID, StartDate, EndDate, StatusID and returns StatusID for the user on the date passed in. I can then use this StatusID to lookup the StatusName on the Statuses table.

This functionality is required for a web based system where user status can be changed in the past, present or future. The functionality works great however on the website list pages where i get all 2500 users out of the database and i need the StatusName column in the returned recordset, it has massive performance problems.

I am trying to avoid doing server side paging if possible. Does anyone have experience with a similar sort of setup?
Steve Jones
Steve Jones
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: Administrators
Points: 63592 Visits: 19115
You'd have to provide more information about the code here if you want help.

There are performance problems with functions at times, so you want to minimize them in large data sets.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search