-
Notifications
You must be signed in to change notification settings - Fork 7
Performance investigation #7278
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
Changes from 11 commits
dadd0f2
05ce482
06adf7c
807508a
2aefaaf
ab5a4eb
23b1e5c
354d7b3
b4851d1
7244f40
ec02df8
9555b5f
1b86b02
b8b5421
8626e95
85b4d5d
8a83922
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| description: Improve performance for very large models | ||
| issue-nr: 7262 | ||
| change-type: minor | ||
| destination-branches: [master, iso7] | ||
| sections: | ||
| minor-improvement: "{{description}}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4621,6 +4621,40 @@ def convert_or_ignore(rvid): | |||||
| ) | ||||||
| return out | ||||||
|
|
||||||
| @classmethod | ||||||
| async def set_deployed_multi( | ||||||
| cls, | ||||||
| environment: uuid.UUID, | ||||||
| resource_ids: Sequence[m.ResourceIdStr], | ||||||
| version: int, | ||||||
| connection: Optional[asyncpg.connection.Connection] = None, | ||||||
| ) -> None: | ||||||
| query = "UPDATE resource SET status='deployed' WHERE environment=$1 AND model=$2 AND resource_id =ANY($3) " | ||||||
| async with cls.get_connection(connection) as connection: | ||||||
| await connection.execute(query, environment, version, resource_ids) | ||||||
|
|
||||||
| @classmethod | ||||||
| async def get_resource_ids_with_status( | ||||||
| cls, | ||||||
| environment: uuid.UUID, | ||||||
| resource_version_ids: list[m.ResourceIdStr], | ||||||
| version: int, | ||||||
| statuses: Sequence[const.ResourceState], | ||||||
| lock: Optional[RowLockMode] = None, | ||||||
| connection: Optional[asyncpg.connection.Connection] = None, | ||||||
| ) -> list[m.ResourceIdStr]: | ||||||
| query = ( | ||||||
| "SELECT resource_id as resource_id FROM resource WHERE " | ||||||
| "environment=$1 AND model=$2 AND status = ANY($3) and resource_id =ANY($4) " | ||||||
| ) | ||||||
| if lock: | ||||||
| query += lock.value | ||||||
| async with cls.get_connection(connection) as connection: | ||||||
| return [ | ||||||
| m.ResourceIdStr(cast(str, r["resource_id"])) | ||||||
sanderr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| for r in await connection.fetch(query, environment, version, statuses, resource_version_ids) | ||||||
| ] | ||||||
|
|
||||||
| @classmethod | ||||||
| async def get_undeployable(cls, environment: uuid.UUID, version: int) -> list["Resource"]: | ||||||
| """ | ||||||
|
|
@@ -4796,27 +4830,38 @@ async def get_resources_for_version_raw_with_persistent_state( | |||||
| version: int, | ||||||
| projection: Optional[list[str]], | ||||||
| projection_presistent: Optional[list[str]], | ||||||
| project_attributes: Optional[list[str]] = None, | ||||||
|
||||||
| project_attributes: Optional[list[str]] = None, | |
| project_attributes: Optional[Sequence[LiteralString]] = None, |
See typing.LiteralString docs. I think we should use this ideally because we bake it into the query itself, which is not safe with any user input. Ideally we'd do the same for the other lists but I'll leave that decision up to you.
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.
Mypy doesn't support it python/mypy#12554
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.
Oh, shame
Uh oh!
There was an error while loading. Please reload this page.