-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#44 Sampling tasks from user data #115
Conversation
@@ -31,3 +31,5 @@ class Post(SQLModel, table=True): | |||
) | |||
payload_type: str = Field(nullable=False, max_length=200) | |||
payload: PayloadContainer = Field(sa_column=sa.Column(payload_column_type(PayloadContainer), nullable=True)) | |||
depth: int = Field(sa_column=sa.Column(sa.Integer, default=0, server_default=sa.text("0"), nullable=False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need all these attributes?
it seems like sqlmodel might do the right thing with depth: int = 0
without any field definition at all, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was an issue adding default boolean value (ack, done), the value did not propagate properly to existing rows. Solution was to specify server_default, so I did it the same way to other columns.
LGTM, but I'll leave the review to @andreaskoepf bc more familiar with this code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thoughts:
- depth and children_count are incrementally calculated, e.g. we must from now on not directly delete elements from post without going through python code that updates the parent element.
- regarding sampling &
order by random()
I have read different reports about its performance online (some say it "performs a full table scan and also ordering. Therefore this method is not preferred for tables with large number of rows because of performance reasons." ..) Postgres also supports TABLESAMPLE, which is probably faster.
In general we will need very soon a more sophisticated sampling function that takes a weights into account.
linking #44 |
Tasks are now sampled randomly from user-uploaded data.
resolves #44