Skip to content
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

Reduce update queries if pk is uuid #147

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

alpaca-tc
Copy link
Contributor

When the column of bitemporal_id_key is uuid, the uuid can be generated and specified before insertion into the DB. In this case, there is no need to update bitemporal_id_key in after_create, so the update query can be reduced by one query.

Note that for types other than uuid, it is not possible to specify the next pk before inserting it into the DB, so the current logic is maintained.

@auto-assign auto-assign bot requested review from mkmn and wata727 August 16, 2023 12:05
When the column of bitemporal_id_key is uuid, the uuid can be generated and specified before insertion into the DB.
In this case, there is no need to update bitemporal_id_key in after_create, so the update query can be reduced by one query.

Note that for types other than uuid, it is not possible to specify the next pk before inserting it into the DB, so the current logic is maintained.
@alpaca-tc alpaca-tc force-pushed the assign-bitemporal-id-before-after-create branch from bdf1536 to d9d4f16 Compare August 16, 2023 12:16
"name" => [nil, "Tom"]
),
previously_force_updated?: false
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we test here that the swapped_id is equal to the bitemporal_id?

Copy link
Contributor

@wata727 wata727 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like issuing ids implicitly is beyond the responsibility of this gem, but it's not a bad idea if it improves performance in many cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants