0

so this is a more of a logical question.

I'm having trouble deciding on what I will use on implementing limit, let's say for example ticket limit where I have 2 plans, one is standard which have 100 ticket limit, and premium which have 500 ticket limit.

Which of these two is better for implementing such logic? I have 2 ideas:

A. Just count the number of unique tickets in the database for a specific user, and if it reached 100 or 500, implement a method that will restrict further ticket opening.

B. Create a table, which will have the user ID, and a column which will have an upper limit of 100 or 500 depending on the plan availed of the user. Then, each opening of ticket, will subtract from the upper limit in the table. And if the record reached 0, implement a method which will restrict further opening of ticket.

Or if you have any other ideas, I will be glad to have it

1 Answer 1

0

Let's analyze how much effort COUNT(*) will take...

For those numbers, either way will probably work. Counting 500 rows is likely to take only a fraction of a second. If you don't need to do that a million times a day, you probably won't run out of performance.

Either approach requires performing some form of test every time the user takes a ticket, so this does not seem to be a limiting factor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.