Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6547649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:51:23+00:00 2026-05-25T11:51:23+00:00

To help explain my question I’ll explain a little bit of the problem. We

  • 0

To help explain my question I’ll explain a little bit of the problem. We have a database of customers, including a history of their addresses (i.e. every address update inserts a new row into the address table and we have views that pull the latest information for reporting on screen and printed reports).

User requirement for a new search is that we show their current address (if we have one on file) on search results to determine that they are indeed finding the correct client.

We have reached a performance hit by running a left join to a view in our returned search results, so this is where the question comes in.

Our first thought was to store a copy of the latest address for display only purposes in our customer table, but we were concerned at how to keep this data updated. We wondered if a computed column could be built on a scalar function to query our view and have it persisted, or if triggers were our only option.

Am I barking up the wrong tree entirely by looking at ways of getting around this slowness, should I be investigating addressing the database tuning in some way to optimize the search instead?

Thanks in advance,
Wesley

edit: query is as shown:

Select 
    Clients.ClientID,
    Clients.LastName,
    Clients.FirstName,
    Clients.PreferredName,
    PrimaryDeliveryCity as City,
    PrimaryDeliveryPostalCode as PostalCode,
    DateOfBirth,
    ClientNumber
FROM 
    Clients LEFT JOIN v_LatestClientAddressHistoryRecord 
    ON Clients.ClientID = v_LatestClientAddressHistoryRecord.ClientID
WHERE
    ClientNumber like @ClientNumber + '%'

Indeed the query does have %, however not on the joined table.

Clients has 50,000 records, view has similar but slightly less, base address table has 200,000

Edit #2:

SELECT ClientAddressHistoryRecords.*
FROM
dbo.ClientAddressHistoryRecords INNER JOIN dbo.v_LatestClientAddressHistoryRecordID 
ON dbo.ClientAddressHistoryRecords.ClientID = dbo.v_LatestClientAddressHistoryRecordID.ClientID 
AND
dbo.ClientAddressHistoryRecords.ClientAddressHistoryRecordID = dbo.v_LatestClientAddressHistoryRecordID.MaxClientAddressHistoryRecordID

and the v_LatestClientAddressHistoryRecordID view

SELECT     MAX(ClientConsentHistoryRecordID) AS MaxClientConsentHistoryRecordID, ClientID
FROM         dbo.ClientConsentHistoryRecords
GROUP BY ClientID
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:51:23+00:00Added an answer on May 25, 2026 at 11:51 am

    Another approach would be an INSTEAD OF TRIGGER that inserts all inserts/updates into a history table (each as its own row), and merges all inserts/updates into an active table (with the only row for a customer being the most current row). Now you point your active queries at the active table, and if you need the history, you write that query to go fetch it from the archive table. Yes, you have two copies of the active rows, but assuming the speed issue is due to there being a large % of old addresses sticking around, this might be ok.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So let me explain my problem a little better now (please reopen this question).
To help better explain my Question, here is what i have: I am using
The question is a bit difficult to explain, but I will try. I have
I have a query with regards to pointers, can someone help explain the following
maybe I will not correct explain a problem, maybe somebody help me explain this
It is very difficult for me to explain this particular problem/question so please bear
I will explain my problem statement with the following illustration. I have 4 machines,
I'll start with an example and hopefully it will help explain my question. Say
I have a question related to strings and pointers. Please explain only with C/C++
i have a question about EF4 and want to explain it by an example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.