Skip to content

Instantly share code, notes, and snippets.

@suzukimilanpaak
Last active January 17, 2018 06:48
Show Gist options
  • Save suzukimilanpaak/2494954aee2ee184c35e5ffe5209f667 to your computer and use it in GitHub Desktop.
Save suzukimilanpaak/2494954aee2ee184c35e5ffe5209f667 to your computer and use it in GitHub Desktop.
県を一つ指定して検索した場合
/search?category_id=7&prefecture_ids%5B%5D=12&occupation_id=54
mysql> explain
-> SELECT DISTINCT `job_offers`.`id`, `job_offers`.`status` AS alias_0, `job_offers`.`created_at` AS alias_1
-> FROM
-> `job_offers` LEFT OUTER JOIN `occupations` ON `occupations`.`id` = `job_offers`.`occupation_id` LEFT OUTER JOIN `job_offer_appeals` ON `job_offer_appeals`.`job_offer_id` = `job_offers`.`id` LEFT OUTER JOIN `appeals` ON `appeals`.`id` = `job_offer_appeals`.`appeal_id` AND `appeals`.`type` IN ('Appeal::JobAppeal') LEFT OUTER JOIN `job_offer_skills` ON `job_offer_skills`.`job_offer_id` = `job_offers`.`id` LEFT OUTER JOIN `skills` ON `skills`.`id` = `job_offer_skills`.`skill_id` LEFT OUTER JOIN `display_skills` ON `display_skills`.`id` = `skills`.`display_skill_id`
-> WHERE
-> `job_offers`.`office_location_prefecture_id` = 12
-> AND `job_offers`.`occupation_id` = 54
-> AND `job_offers`.`public` = 1
-> ORDER BY
-> `job_offers`.`status` DESC, `job_offers`.`created_at` DESC LIMIT 10 OFFSET 0
-> \G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: job_offers
type: ALL
possible_keys: index_job_offers_on_occupation_id,index_job_offers_on_public_and_status_and_created_at,index_job_offers_on_public_and_status_and_max_unit_price,idx
key: NULL
key_len: NULL
ref: NULL
rows: 4090
Extra: Using where; Using temporary; Using filesort
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: occupations
type: const
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: const
rows: 1
Extra: Using index; Distinct
*************************** 3. row ***************************
id: 1
select_type: SIMPLE
table: job_offer_appeals
type: ref
possible_keys: index_job_offer_appeals_on_job_offer_id_and_appeal_id,index_job_offer_appeals_on_job_offer_id
key: index_job_offer_appeals_on_job_offer_id_and_appeal_id
key_len: 4
ref: crowdtech_dev.job_offers.id
rows: 1
Extra: Using index; Distinct
*************************** 4. row ***************************
id: 1
select_type: SIMPLE
table: appeals
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: crowdtech_dev.job_offer_appeals.appeal_id
rows: 1
Extra: Using where; Distinct
*************************** 5. row ***************************
id: 1
select_type: SIMPLE
table: job_offer_skills
type: ref
possible_keys: index_job_offer_skills_on_job_offer_id_and_priority_order,index_job_offer_skills_on_job_offer_id_and_skill_id,index_job_offer_skills_on_job_offer_id
key: index_job_offer_skills_on_job_offer_id_and_priority_order
key_len: 5
ref: crowdtech_dev.job_offers.id
rows: 1
Extra: Distinct
*************************** 6. row ***************************
id: 1
select_type: SIMPLE
table: skills
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: crowdtech_dev.job_offer_skills.skill_id
rows: 1
Extra: Distinct
*************************** 7. row ***************************
id: 1
select_type: SIMPLE
table: display_skills
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: crowdtech_dev.skills.display_skill_id
rows: 1
Extra: Using index; Distinct
7 rows in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment