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 1086335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:48:01+00:00 2026-05-16T22:48:01+00:00

I would like to know if it is possible to simplify the following process:

  • 0

I would like to know if it is possible to simplify the following process: I want to mark a game for shipping to a customer based on the following criteria: (If you are familiar with Netflix, it’s the equivalent of their movie queue.)

  1. How many games they have at home.
  2. How many games have they received in total for their billing month.

I have a table that stores customer choices (their games queue) called wishlists. I’m using the following query to automatically rank their choices for newly inserted records (rank determines the priority of shipping):

schema (id, memberId, gameId, rank, markedForShipment, shippedOn, returnedOn)

        INSERT INTO wishlists (memberId, gameId, rank, markedForShipment)
        SELECT  @memberId, @gameId, COALESCE(MAX(rank), 0) + 1, 0, null, null
        FROM    wishlists
        WHERE   wishlists.memberId = @memberId

I would like to automatically populate “markedForShipment” with either a 0 or a 1 based on two criteria: 1. How many games a member has already received this month, and 2. how many games a member currently has at home

At the moment I am doing the following AFTER each insert:

  1. Grab the plan limits from a plans table (shipmentsPerMonthLimit and gamesAtHomeLimit).

  2. Find out how many shipments (shipmentCount) a member has had this month

        SELECT COUNT(shippedOn) AS shipmentCount
        FROM wishlists
        INNER JOIN members ON wishlists.memberId = members.id
        WHERE wishlists.memberId = @memberId
        AND wishlists.shippedOn >= members.billingCycleStart
        AND wishlists.shippedOn < DATE_ADD(members.billingCycleStart, INTERVAL 1 MONTH)
    
  3. Find out how many gamesAtHome a member has

        SELECT COUNT(shippedOn) AS gamesAtHome
        FROM wishlists
        WHERE memberId = @memberId AND shippedOn IS NOT NULL AND returnedOn IS NULL
    
  4. Find out how many queued shipments (markedForShippment) a member has

        SELECT COUNT(markedForShippment) AS queuedShipments
        FROM wishlists
        WHERE memberId = @memberId AND markedForShipping = 1
    
  5. Check to see if the game is inventory.

If all the following is true I update the newly inserted record by setting markedForShipping to 1.

gamesAtHome is < than gamesAtHomeLimit
shipmentCount is < than shipmentsPerMonthLimit
queuedShipments is < gamesAtHomeLimit

How can I improve this process? Can I simplify it? I ask these questions bearing in mind that performance is probably the most important factor.
4.

  • 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-16T22:48:02+00:00Added an answer on May 16, 2026 at 10:48 pm

    Looks pretty efficient to me (I suppose you use indices and foreign keys). My advise would be not to optimize unless you really have performance issues.

    The only way I see to optimize this would be to introduce redundancy. For instance, you could add “shippingLimitReached” and “gamesAtHomeLimitReached” to the members table. If many users reach their limits (and probably users with a long wishlist will), you can save some SELECTs.

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

Sidebar

Related Questions

I would like to know if it is possible to determine if a function
I would like to know if it is possible, To extract the userid from
I would like to know if it is possible, to select certain columns from
I would like to know whether it is possible to force LWP::UserAgent to accept
I would like to know if it is possible to copy/move files to a
I would like to know if it's possible to call a inline function with
I would like to know if its possible to add a space inside the
I would like to know whether its possible to open Open word 2003 (doc)
I would like to know if its possible to call a non-const member function
I would like to know if its possible, by using JSF, to make somethings

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.