You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 7, 2019. It is now read-only.
When using as_of() it using OR operator into query to add current record into result.
>>>print MyMode.objects.as_of(timezone.now()).query
SELECT `mymodel`.`id`, `mymodel`.`identity`, `mymodel`.`version_start_date`, `mymodel`.`version_end_date`, `mymodel`.`version_birth_date` FROM `mymodel` WHERE ((`mymodel`.`version_end_date` > 2018-03-20 14:30:18 OR `mymodel`.`version_end_date` IS NULL) AND `mymodel`.`version_start_date` <= 2018-03-20 14:30:18)
If set version_end_date default value to datetime.max (or other hard-to-reach value) it is possible to avoid using OR. This will lead to a decrease of query cost.
SELECT `mymodel`.`id`, `mymodel`.`identity`, `mymodel`.`version_start_date`, `mymodel`.`version_end_date`, `mymodel`.`version_birth_date` FROM `mymodel` WHERE (`mymodel`.`version_end_date` > 2018-03-20 14:30:18 AND `mymodel`.`version_start_date` <= 2018-03-20 14:30:18)
The text was updated successfully, but these errors were encountered:
Hey @tbazadaykin, thanks for coming up with this. I see a bit of a trade-off in identifying current versions - but this may be less of a problem than it seems, if the column is properly indexed.
I will not have time to go deeper into this during the upcoming couple of weeks, but will try to get back to this point sometime later.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When using
as_of()
it usingOR
operator into query to add current record into result.If set
version_end_date
default value todatetime.max
(or other hard-to-reach value) it is possible to avoid usingOR
. This will lead to a decrease of query cost.The text was updated successfully, but these errors were encountered: