Answer the question
In order to leave comments, you need to log in
Most efficient redundancy algorithm?
There are, say, models of the following form:
class Car(models.Model):
vin = models.Charfield(max_length=64)
class Order(models.Model):
car = models.ForeignKey(Car)
start_date = models.DatetimeField()
end_date = models.DatetimeField()
Answer the question
In order to leave comments, you need to log in
start_date and end_date - in daterange + index
or hang a functional index (daterange(start_date, end_date))
select * from car_orders where start_end_range && daterange('2018-01-01', '2018-01-02')
Start by finding a free car at a specific point in time
Type
Car.objects.exclude(Q(order__end_date__gte=datetime.now())&Q(order__start_date__lte=datetime.now()))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question