@@ -808,39 +808,20 @@ For example, to exclude comments from your structure dump, add this to an initia
808
808
ActiveRecord ::Tasks ::DatabaseTasks .structure_dump_flags = [" --no-comments" ]
809
809
```
810
810
811
- Explain options to give deeper insight into Query Performance
812
- --------------
813
-
814
- ### Buffer
815
-
816
- The Buffer option that comes with PostgreSQL's ` Explain ` command gives one
817
- insights with regard to the data it is reading or writing when performing a
818
- query operation and which of that data comes from cache or another source like
819
- disk.
811
+ Explain
812
+ -------
820
813
821
- The buffer option is intended to give you one or more hints into what
822
- specifically within the query your executing could be a potential cause of
823
- slowness and thereby has room for further improvement.
824
-
825
-
826
- An example Active Record query that uses ` explain ` with the ` buffers ` option:
814
+ Along with the standard [ ` explain ` ] [ explain-options ] options, the PostgreSQL adapter supports [ ` buffers ` ] [ explain-analayze-buffers ] .
827
815
828
816
``` ruby
829
817
Company .where(id: owning_companies_ids).explain(:analyze , :buffers )
818
+ # => EXPLAIN (ANALYZE, BUFFERS) SELECT "companies".* FROM "companies"
819
+ # ...
820
+ # Seq Scan on companies (cost=0.00..2.21 rows=3 width=64)
821
+ # ...
830
822
```
831
823
832
- Output of above query:
824
+ See their documentation for more details.
833
825
834
- ``` sql
835
- => EXPLAIN (ANALYZE, BUFFERS) SELECT " companies" .* FROM " companies"
836
- WHERE " companies" ." id" IN ($1 , $2 , $3 ) [[" id" , 365 ], [" id" , 364 ], [" id" , 360 ]]
837
- QUERY PLAN
838
- -- -----------------------------------------------------------------------------
839
- Seq Scan on companies (cost= 0 .00 ..2 .21 rows= 3 width= 64 )
840
- (actual time = 0 .009 ..0 .012 rows= 3 loops= 1 )
841
- Filter: (id = ANY (' {365,364,360}' ::bigint []))
842
- Rows Removed by Filter: 10
843
- Buffers: shared hit= 1
844
- Planning Time : 0 .023 ms
845
- Execution Time : 0 .011 ms
846
- ```
826
+ [ explain-options ] : active_record_querying.html#explain-options
827
+ [ explain-analayze-buffers ] : https://www.postgresql.org/docs/current/sql-explain.html
0 commit comments