-
Notifications
You must be signed in to change notification settings - Fork 897
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
Optimize insert query loading #15404
Conversation
@miq-bot add_label enhancement |
Add Returning clause if the IC has dependees
Use INSERT query result if possible. If we are sure that all ids of inserted records are in the result, we can use it and spare time loading the records back from the db.
b3be700
to
b4330a8
Compare
Checked commits Ladas/manageiq@74c72f8~...b4330a8 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/models/manager_refresh/save_collection/saver/sql_helper.rb
|
# we test if the number of results matches the expected batch size. Then if the counts do not match, the only | ||
# safe option is to query all the data from the DB, using the unique_indexes. The batch size will also not match | ||
# for every remainders(a last batch in a stream of batches) | ||
if !supports_remote_data_timestamp?(all_attribute_keys) || result.count == batch_size |
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.
@Ladas is it possible the count could be the same as the batch size but still not return the "correct" ids?
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.
it should not be, we check for uniqueness at least like on 2 places
Optimize insert query loading, using a Returning clause properly. This way we can spare another query for loading back the data. We need to load back the inserted data, to get their primary keys.