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 number of SQL queries when slug history is maintained #844

Closed
wants to merge 1 commit into from
Closed

Reduce number of SQL queries when slug history is maintained #844

wants to merge 1 commit into from

Conversation

bogdan
Copy link

@bogdan bogdan commented Nov 2, 2017

  • Used inverse_of to load Slug#sluggable from memory instead of DB:
  • Don't perform history maintainance for new records.
 SQL (0.3ms)  INSERT INTO `sites` (`name`, `url`, `created_at`, `updated_at`, `cached_slug`, `technical_contact_email`, `customer_service_email`, `account_id`) VALUES ('Company 1', 'http://merchant.com', '2017-11-02 13:15:40', '2017-11-02 13:15:40', 'company-1', 'technical_contact@email.com', 'customer_service@merchant.com', 1448)
- FriendlyId::Slug Load (0.4ms)  SELECT  `friendly_id_slugs`.* FROM `friendly_id_slugs` WHERE `friendly_id_slugs`.`sluggable_id` = 1031 AND `friendly_id_slugs`.`sluggable_type` = 'Site' ORDER BY `friendly_id_slugs`.id DESC LIMIT 1
- SQL (0.4ms)  DELETE FROM `friendly_id_slugs` WHERE `friendly_id_slugs`.`sluggable_id` = 1031 AND `friendly_id_slugs`.`sluggable_type` = 'Site' AND `friendly_id_slugs`.`slug` = 'company-1'
-Site Load (0.4ms)  SELECT  `sites`.* FROM `sites` WHERE `sites`.`id` = 1031 LIMIT 1
 SQL (0.6ms)  INSERT INTO `friendly_id_slugs` (`slug`, `sluggable_id`, `sluggable_type`, `created_at`) VALUES ('company-1', 1031, 'Site',

Used inverse_of to load Slug#sluggable from memory instead of DB
Don't perform history maintainance for new records
@bogdan
Copy link
Author

bogdan commented Jun 14, 2018

Any feedback here?

@stale
Copy link

stale bot commented Dec 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 11, 2019
@stale stale bot closed this Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant