Skip to content

Instantly share code, notes, and snippets.

@gregblake
Created August 11, 2017 04:20
Show Gist options
  • Save gregblake/38bfb9dd76498767b2fe7f8b626aff7d to your computer and use it in GitHub Desktop.
Save gregblake/38bfb9dd76498767b2fe7f8b626aff7d to your computer and use it in GitHub Desktop.
Media Library v2: sql query on index action
[read] SQL (1.1ms) SELECT `documents`.`id` AS t0_r0, `documents`.`name` AS t0_r1, `documents`.`active` AS t0_r2, `documents`.`created_by` AS t0_r3, `documents`.`roles_count` AS t0_r4, `documents`.`created_at` AS t0_r5, `documents`.`updated_at` AS t0_r6, `documents`.`territories_count` AS t0_r7, `documents`.`published_date_start` AS t0_r8, `documents`.`published_date_end` AS t0_r9, `documents`.`thumbnail_file_name` AS t0_r10, `documents`.`thumbnail_file_size` AS t0_r11, `documents`.`thumbnail_content_type` AS t0_r12, `documents`.`viewing_mode` AS t0_r13, `document_versions`.`id` AS t1_r0, `document_versions`.`document_id` AS t1_r1, `document_versions`.`attachment_file_size` AS t1_r2, `document_versions`.`thumbnail_file_size` AS t1_r3, `document_versions`.`version` AS t1_r4, `document_versions`.`created_by` AS t1_r5, `document_versions`.`updated_by` AS t1_r6, `document_versions`.`attachment_file_name` AS t1_r7, `document_versions`.`attachment_content_type` AS t1_r8, `document_versions`.`thumbnail_file_name` AS t1_r9, `document_versions`.`thumbnail_content_type` AS t1_r10, `document_versions`.`active` AS t1_r11, `document_versions`.`created_at` AS t1_r12, `document_versions`.`updated_at` AS t1_r13, `document_versions`.`release_notes` AS t1_r14, `document_versions`.`page_count` AS t1_r15, `document_versions`.`job_id` AS t1_r16 FROM `documents` LEFT OUTER JOIN `document_versions` ON `document_versions`.`document_id` = `documents`.`id` WHERE (documents.active = 1 OR ((published_date_start IS NOT NULL AND published_date_start <= '2017-08-11') AND (published_date_end > '2017-08-11' OR published_date_end IS NULL))) GROUP BY documents.id ORDER BY document_versions.created_at DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment