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

  • Home
  • SEARCH
  • 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 7562483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:25:11+00:00 2026-05-30T13:25:11+00:00

In my system Users can add/edit/view Customers . I would like to add a

  • 0

In my system Users can add/edit/view Customers. I would like to add a feature allowing the user to see “Recently Viewed Customers”. This would show them the last 20 customers which they have seen (which includes add/edit).

Users will view customers very often as they skip between different web pages and this needs to be very efficient. I would like to persist this across sessions so it needs to be saved to the database. There are about 16,000 users and 600,000 customers.

Here is what I’m thinking as the design.

Create a new table:

  • Columns are (UserId, CustomerId, DateViewed)
  • Primary key is (UserId, CustomerId)
  • Index-organised
  • Separate indxes on foreign keys UserId and CustomerId
  • DateViewed column only exists to allow ordering of the records

Create a PL/SQL procedure that with parameters of UserId and CustomerId responsible for storing that the user viewed the customer. In the PL/SQL procedure I would:

  • Use MERGE to insert or update a row with the given UserId and CustomerId setting DateViewed to SYSDATE
  • If a row was inserted by the merge, then use an analytic query to delete any rows with a row_number() > 20

The “Recently Viewed Customers” page then becomes a basic join between this new table and the customer table, ordered by DateViewed and limited to 20 records just in case. No need to include DateViewed in any index as it’s only a 20 row sort.

Say, once a month, delete any records with DateViewed is older than a year. This would be a full scan. Cascade deletes from Customer and User to the new table.

Does anyone have suggestions for improvement or other ideas that are worth profiling?

(The other idea I had was to denormalise into a table with 20 columns for the different CustomerIds and shuffle values down from CustomerId1 -> CustomerId2 -> CustomerId3. This would require different updates depending on where the CustomerId already appeared in the list.)

  • 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-30T13:25:13+00:00Added an answer on May 30, 2026 at 1:25 pm

    I believe you’ve thought through the problem pretty thoroughly.

    One thing I would suggest you try is deferring pruning the 21st (and later) most recently viewed customer(s) for a user. If you did this you’d have to include a TOP 20 in your selection query.

    There will be some time required to complete the pruning operation (whether it’s done with each new view or later). There will also be some incremental time involved in picking the top 20 from from a list of more than 20.

    Depending on exactly how frequently a customer add/edit/view is done, it may be that pruning each time a record is inserted is more expensive than sorting and selecting the TOP 20. You could perform the pruning as a scheduled background task, say once per hour or even once per day.

    It is also possible, depending on the actual usage, that performance is not and issue and you should instead be optimizing for maintainability, in which case you should do the simplest thing with the least code.


    Regarding your other idea (20 denormalized columns): This is not recommended!

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

Sidebar

Related Questions

I need to create a wall system just like Facebook's (users can post messages,
I'm looking content management system that would have features similar to stackoverflow: Users can
I have a system whereby a user can view categories that they've subscribed to
I'm working on a system were a user can edit existing objects (Filter domain
I have a system where registered users can vote up/vote down comments for a
I am developing a system with Java EE and JPA where users can make
My system is base on driving permit application. Where users can apply for different
I have make a messaging system in which user can send messages to each
I'm interested in creating a system where the user can define the steps in
How can I access the name of the system user (which eclipse also uses

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.