|
/* |
|
GET ANCESTORS ORM: |
|
- Similar to the one above, using a subquery to ease ORM integration. |
|
- Current: 0,268 sec. |
|
- New: 0,00055 sec. |
|
*/ |
|
|
|
SELECT `object` . `class_name` , |
|
`object` . `created_at` , |
|
`object` . `updated_at` , |
|
`object` . `id` , |
|
`object` . `serial_number` , |
|
`information_object` . `id` , |
|
`information_object` . `identifier` , |
|
`information_object` . `oai_local_identifier` , |
|
`information_object` . `level_of_description_id` , |
|
`information_object` . `collection_type_id` , |
|
`information_object` . `repository_id` , |
|
`information_object` . `parent_id` , |
|
`information_object` . `description_status_id` , |
|
`information_object` . `description_detail_id` , |
|
`information_object` . `description_identifier` , |
|
`information_object` . `source_standard` , |
|
`information_object` . `display_standard_id` , |
|
`information_object` . `lft` , |
|
`information_object` . `rgt` , |
|
`information_object` . `source_culture` |
|
FROM `object` , `information_object` |
|
WHERE `information_object` . `id` IN ( |
|
WITH RECURSIVE cte AS |
|
( |
|
SELECT io1.id, io1.parent_id FROM information_object io1 WHERE io1.id=771558 |
|
UNION ALL |
|
SELECT io2.id, io2.parent_id FROM information_object io2 JOIN cte ON cte.parent_id=io2.id |
|
) |
|
SELECT id FROM cte |
|
) |
|
AND `information_object` . `id` = `object` . `id` |
|
ORDER BY `information_object` . `lft` asc; |
|
|
|
|
|
/* CURRENT QUERY */ |
|
|
|
SELECT `object` . `class_name` , |
|
`object` . `created_at` , |
|
`object` . `updated_at` , |
|
`object` . `id` , |
|
`object` . `serial_number` , |
|
`information_object` . `id` , |
|
`information_object` . `identifier` , |
|
`information_object` . `oai_local_identifier` , |
|
`information_object` . `level_of_description_id` , |
|
`information_object` . `collection_type_id` , |
|
`information_object` . `repository_id` , |
|
`information_object` . `parent_id` , |
|
`information_object` . `description_status_id` , |
|
`information_object` . `description_detail_id` , |
|
`information_object` . `description_identifier` , |
|
`information_object` . `source_standard` , |
|
`information_object` . `display_standard_id` , |
|
`information_object` . `lft` , |
|
`information_object` . `rgt` , |
|
`information_object` . `source_culture` |
|
FROM `object` , `information_object` |
|
WHERE `information_object` . `lft` <= 1393556 |
|
AND `information_object` . `rgt` >= 1393557 |
|
AND `information_object` . `id` = `object` . `id` |
|
ORDER BY `information_object` . `lft` asc; |