I have two tables in Django:
Item
column_name | data_type
-------------+-----------
id | integer
price | integer
User
column_name | data_type
-------------+-----------
id | integer
amount | integer
Item's price rarely changes while user's amount might change once a day or more frequently.
Ordering in Django need be done be like below.
- Show items whose price is less than or equal current user's amount (affordable) - order by item price high to low
- Then rest of the items (unaffordable) - order by item price high to low
I need to show items in this order with pagination.
We have around 200k items and around 100k users. Around 100 items are added per day.
All these need to be updated whenever an item/user changes/added/removed.
Django models:
from django.db import models
class Item(models.Model):
id = models.AutoField()
price = models.IntegerField()
class User(models.Model):
id = models.AutoField()
amount = models.IntegerField()
I thought of creating an extra column but that will has to change for each call for all items. Has anyone built something like this?
Should I use some other DB tool? I am open to suggestions.
Thanks