aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/explain.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* [Active Record] require => require_relativeAkira Matsuda2017-10-211-1/+1
| | | | This basically reverts 9d4f79d3d394edb74fa2192e5d9ad7b09ce50c6d
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-1/+1
|\
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| | |
| * | Make ActiveRecord frozen string literal friendly.Pat Allan2017-06-201-1/+1
| |/
* / [Active Record] require => require_relativeAkira Matsuda2017-07-011-1/+1
|/
* We're not calling hooks here since 9e4c41c903e8e58721f2c41776a8c60ddba7a0a9Akira Matsuda2016-11-251-1/+0
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-2/+2
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Fix explain logging with bindsRyuta Kamizono2016-07-201-9/+20
| | | | `binds` is an array of a query attribute since Active Record 5.0.
* Fixed typo in commentSteve2014-07-191-1/+1
|
* let EXPLAIN use a thread locals registry [John J. Wang & Xavier Noria]Xavier Noria2013-04-161-7/+8
| | | | Closes #10198.
* fix typos in AR. lots of them.Vipul A M2013-03-191-1/+1
|
* Remove unused return value, because collecting_queries_for_explain isn't ↵kennyj2013-03-061-1/+2
| | | | public API.
* remove AR auto-explain (config.auto_explain_threshold_in_seconds)Yves Senn2013-02-241-52/+1
| | | | | | | | | | We discussed that the auto explain feature is rarely used. This PR removes only the automatic explain. You can still display the explain output for any given relation using `ActiveRecord::Relation#explain`. As a side-effect this should also fix the connection problem during asset compilation (#9385). The auto explain initializer in the `ActiveRecord::Railtie` forced a connection.
* Don't run explain on slow queries for database adapters that don't support itBlake Smith2012-11-261-6/+7
|
* Remove ActiveRecord::ModelJon Leighton2012-10-261-5/+3
| | | | | | | | | | In the end I think the pain of implementing this seamlessly was not worth the gain provided. The intention was that it would allow plain ruby objects that might not live in your main application to be subclassed and have persistence mixed in. But I've decided that the benefit of doing that is not worth the amount of complexity that the implementation introduced.
* Revert "Get rid of the ActiveRecord::Model::DeprecationProxy thing."Jeremy Kemper2012-10-201-1/+1
| | | | This reverts commit 83846838252397b3781eed165ca301e05db39293.
* Get rid of the ActiveRecord::Model::DeprecationProxy thing.Jon Leighton2012-10-191-1/+1
| | | | | | | | | | | | | | | | | I think it's going to be too much pain to try to transition the :active_record load hook from executing against Base to executing against Model. For example, after Model is included in Base, and modules included in Model will no longer get added to the ancestors of Base. So plugins which wish to be compatible with both Model and Base should use the :active_record_model load hook which executes *before* Base gets loaded. In general, ActiveRecord::Model is an advanced feature at the moment and probably most people will continue to inherit from ActiveRecord::Base for the time being.
* load active_support/core_ext/class/attribute in active_support/railsXavier Noria2012-08-021-1/+0
|
* Simplify AR configuration code.Jon Leighton2012-06-151-5/+6
| | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* minor comment revisionXavier Noria2012-06-011-1/+1
|
* improve readability of AR explain resultAkira Matsuda2012-06-011-1/+7
|
* More using <tt>x</tt> instead of +x+ when the latter renders improperly.Mark Rushakoff2012-04-271-1/+1
|
* disable automatic explain if there is no logger [closes #4671]Xavier Noria2012-01-261-0/+2
|
* Support configuration on ActiveRecord::Model.Jon Leighton2011-12-281-3/+5
| | | | | | | | | | | | | | | The problem: We need to be able to specify configuration in a way that can be inherited to models that include ActiveRecord::Model. So it is no longer sufficient to put 'top level' config on ActiveRecord::Base, but we do want configuration specified on ActiveRecord::Base and descendants to continue to work. So we need something like class_attribute that can be defined on a module but that is inherited when ActiveRecord::Model is included. The solution: added ActiveModel::Configuration module which provides a config_attribute macro. It's a bit specific hence I am not putting this in Active Support or making it a 'public API' at present.
* auto_explain_threshold_in_seconds should be a global config option so it can ↵Jon Leighton2011-12-241-8/+3
| | | | be shared between AR::Base and AR::Model
* AS::Concern is not really needed for AR::ExplainXavier Noria2011-12-161-71/+69
|
* Split out most of the AR::Base code into separate modules :cake:Jon Leighton2011-12-151-61/+74
|
* moves some auto explain logic to the subscriber [José Valim & Xavier Noria]Xavier Noria2011-12-041-17/+0
|
* implements a much faster auto EXPLAIN, closes #3843 [José Valim & Xavier Noria]Xavier Noria2011-12-041-47/+40
| | | | | | | | | | | | | | | | | | | | | | | | | This commit vastly reduces the impact of auto explain logging when enabled, while keeping a negligible cost when disabled. The first implementation was based on the idea of subscribing to "sql.active_record" when needed, and unsubscribing once done. This is the idea behind AR::Relation#explain. Subscribe, collect, unsubscribe. But with the current implementation of notifications unsubscribing is costly, because it wipes an internal cache and that puts a penalty on the next event. So we are switching to an approach where a long-running subscriber is listening. Instead of collecting the queries with a closure in a dedicated subscriber, now we setup a thread local. If the feature is disabled by setting the threshold to nil, the subscriber will call a method that does nothing. That's totally cheap.
* removes the convenience instance version of AR::Base.silence_auto_explainXavier Noria2011-12-031-88/+78
| | | | | | | Rationale: As discussed with José and Jon, this convenience shortcut is not clearly justified and it could let the user thing the disabled EXPLAINs are related to the model instance rather than being globally disabled.
* yield > block.callXavier Noria2011-12-021-3/+3
|
* two small details from the previous patchXavier Noria2011-12-021-1/+1
|
* implements AR::Base(.|#)silence_auto_explainXavier Noria2011-12-021-60/+90
|
* revises some details in the previous explain patchXavier Noria2011-12-021-2/+2
|
* implements automatic EXPLAIN logging for slow queriesXavier Noria2011-12-021-0/+76