Skip to content

Commit 59501ce

Browse files
authored
Merge pull request rails#52893 from boddhisattva/add_docs_explain_with_buffer_option_in_postgres
Add info on how to use the buffers option in Postgres [ci skip]
2 parents ed72523 + fedb779 commit 59501ce

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

guides/source/active_record_postgresql.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,3 +808,21 @@ For example, to exclude comments from your structure dump, add this to an initia
808808
```ruby
809809
ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = ["--no-comments"]
810810
```
811+
812+
Explain
813+
-------
814+
815+
Along with the standard [`explain`][explain-options] options, the PostgreSQL adapter supports [`buffers`][explain-analayze-buffers].
816+
817+
```ruby
818+
Company.where(id: owning_companies_ids).explain(:analyze, :buffers)
819+
#=> EXPLAIN (ANALYZE, BUFFERS) SELECT "companies".* FROM "companies"
820+
# ...
821+
# Seq Scan on companies (cost=0.00..2.21 rows=3 width=64)
822+
# ...
823+
```
824+
825+
See their documentation for more details.
826+
827+
[explain-options]: active_record_querying.html#explain-options
828+
[explain-analayze-buffers]: https://www.postgresql.org/docs/current/sql-explain.html

0 commit comments

Comments
 (0)