From 46a1d7f0b2e998edb6d8b8a1a9fb7eebe8581b8a Mon Sep 17 00:00:00 2001 From: Pablo Alonso Date: Fri, 5 Apr 2024 23:59:53 +0200 Subject: [PATCH] Update active_record_querying.md --- guides/source/active_record_querying.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 1a3e408259c37..f7b6830d18231 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -2610,13 +2610,13 @@ Running EXPLAIN You can run [`explain`][] on a relation. EXPLAIN output varies for each database. -For example, running +For example, running: ```ruby Customer.where(id: 1).joins(:orders).explain ``` -may yield +may yield this for MySQL and MariaDB: ```sql EXPLAIN SELECT `customers`.* FROM `customers` INNER JOIN `orders` ON `orders`.`customer_id` = `customers`.`id` WHERE `customers`.`id` = 1 @@ -2636,11 +2636,9 @@ EXPLAIN SELECT `customers`.* FROM `customers` INNER JOIN `orders` ON `orders`.`c 2 rows in set (0.00 sec) ``` -under MySQL and MariaDB. - Active Record performs a pretty printing that emulates that of the corresponding database shell. So, the same query running with the -PostgreSQL adapter would yield instead +PostgreSQL adapter would yield instead: ```sql EXPLAIN SELECT "customers".* FROM "customers" INNER JOIN "orders" ON "orders"."customer_id" = "customers"."id" WHERE "customers"."id" = $1 [["id", 1]] @@ -2658,7 +2656,7 @@ EXPLAIN SELECT "customers".* FROM "customers" INNER JOIN "orders" ON "orders"."c Eager loading may trigger more than one query under the hood, and some queries may need the results of previous ones. Because of that, `explain` actually -executes the query, and then asks for the query plans. For example, +executes the query, and then asks for the query plans. For example, running: ```ruby Customer.where(id: 1).includes(:orders).explain