-
Notifications
You must be signed in to change notification settings - Fork 5
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
MTG-979 Fix collection verification check for API requests #329
base: new-main
Are you sure you want to change the base?
Conversation
@@ -303,7 +303,8 @@ fn add_filter_clause<'a>( | |||
} | |||
|
|||
if !options.show_unverified_collections { | |||
query_builder.push(" AND assets_v3.ast_is_collection_verified = true"); | |||
// if there is no collection for asset it doesn't mean that it's unverified |
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.
But it also doesn't mean that it's verified 🙃
But as I understood other providers have such logic, so there just thoughts out loud
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.
The point in that change was that if there is no collection for an asset we cannot filter it by collection_verified
field because there is no such field for asset at all.
Added new index as well for this PR - |
Tested on BD with 3639661 assets. There were 622453 asset with collection_verified null, 2375833 assets with collection_verified true and 641375 assets with collection_verified false. results with old indexes req: response:
after few launches execution time becomes 756.960 ms old request: response:
request without collection: response:
The worst time I received here during tests was 2000 ms results with new index added new index which was added: req: response:
req: response:
The worst time I received here was 1500 ms. Result here is worse than on same req before because there was set |
Please rebase on new-main. |
Are we trying to do a universal filter, or is the request in the comment that was analized is the primary use case? For a universal filter the index created doesn't seem to be a good choice, it's indexing the bool value filtering it by itself, so just keeping a separate list of values that are true of null. While this would be valid in some cases, for example, when you have only 10% of records matching the filter, in a general case when roughly half the records are filtered, postgres will internally tend to use a full scan just because using the index is not efficient. But given already have the following index:
you could change the query condition to
to
|
postgre-client/src/load_client.rs
Outdated
@@ -231,6 +232,7 @@ impl PgClient { | |||
("assets_v3_specification_asset_class", "assets_v3 (ast_specification_asset_class) WHERE ast_specification_asset_class IS NOT NULL AND ast_specification_asset_class <> 'unknown'::specification_asset_class"), | |||
("assets_v3_specification_version", "assets_v3 (ast_specification_version) WHERE ast_specification_version <> 'v1'::specification_versions"), | |||
("assets_v3_supply", "assets_v3(ast_supply) WHERE ast_supply IS NOT NULL"), | |||
("assets_v3_is_collection_verified", "assets_v3(ast_is_collection_verified) WHERE ast_is_collection_verified IS NULL OR ast_is_collection_verified = TRUE"), |
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.
we've dropped the migration that's adding a new index. Is it needed here?
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.
👍
What
This PR fixes collection verification check during keys selecting from the Postgre.
Also it adds one more new test case with selecting different type of assets with and without collections.