Commit Graph

26386 Commits

Author SHA1 Message Date
Xavier Noria
cfeac38e2b implements a much faster auto EXPLAIN, closes #3843 [José Valim & Xavier Noria]
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.
2011-12-04 11:52:12 -08:00
Xavier Noria
5dfdc69ef9 Merge pull request #3848 from arunagw/sqlite3_bump
SQlite3 Bump
2011-12-04 01:56:50 -08:00
Arun Agrawal
ac4763f5c0 SQlite3 Bump 2011-12-04 10:27:44 +05:30
Jon Leighton
e9b6659c4c Add missing require 2011-12-03 20:39:49 +00:00
Jon Leighton
3f23c049c2 Enable postgres on the CI ❤️ 🍺 2011-12-03 20:09:43 +00:00
Jon Leighton
51c2ef0b81 Avoid postgres 9.X syntax 2011-12-03 20:06:46 +00:00
Jon Leighton
9c172b2931 Fix #3837.
We also need to time zone convert time zone aware attributes when
accessed via read_attribute, not only when via direct access.
2011-12-03 16:46:46 +00:00
Xavier Noria
de24ed9f2d removes the convenience instance version of AR::Base.silence_auto_explain
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.
2011-12-03 14:26:34 +01:00
Jon Leighton
a02691ce09 Merge pull request #3820 from jaylevitt/nested_loading_through_assoc
reintroduce patch from #726 to handle nested eager loading via associations
2011-12-03 04:01:14 -08:00
Jon Leighton
2e902d52eb Merge pull request #3833 from kennyj/fix_3678-3
Use show create table (fix 3678: third time).
2011-12-03 03:36:00 -08:00
José Valim
75981a9208 Merge pull request #3842 from arunagw/app_gen_test
App Generator test
2011-12-03 02:45:22 -08:00
Arun Agrawal
c4f18683d9 Simplifying test in app/generator 2011-12-03 16:12:02 +05:30
José Valim
2ab2077235 Fix failing cascade exception. 2011-12-03 11:38:25 +01:00
Jon Jensen
0e17cf17eb Restore performance of ERB::Util.html_escape
Revert html_escape to do a single gsub again, but add the "n" flag (no
language, i.e. not multi-byte) to protect against XSS via invalid utf8

Signed-off-by: José Valim <jose.valim@gmail.com>
2011-12-03 10:36:52 +01:00
Vijay Dev
9ac6310bd9 fix a typo in query guide 2011-12-03 03:08:18 +05:30
Xavier Noria
3a967806ad yield > block.call 2011-12-02 11:44:04 -08:00
Xavier Noria
15dab0d2f5 two small details from the previous patch 2011-12-02 11:29:35 -08:00
Xavier Noria
0be5adaedf implements AR::Base(.|#)silence_auto_explain 2011-12-02 11:16:26 -08:00
Vijay Dev
36c014193e fix typo in railties changelog 2011-12-03 00:23:58 +05:30
Vijay Dev
ee45823072 revises Enumerable#pluck in AS guide 2011-12-02 23:53:21 +05:30
Vijay Dev
baa93a1c2e Merge branch 'master' of github.com:lifo/docrails 2011-12-02 23:43:52 +05:30
Vijay Dev
f402ef5766 rephrase doc on explain threshold 2011-12-02 23:41:50 +05:30
Arun Agrawal
3d550e5174 Added doc about pluck for active_support core ext 2011-12-02 23:15:08 +05:30
Xavier Noria
31a3124f05 Merge pull request #3832 from arunagw/indentation
indentation fix warning
2011-12-02 09:29:26 -08:00
Arun Agrawal
9a59475d4a indentation fix warning 2011-12-02 22:55:15 +05:30
kennyj
f3470b08c9 Use show create table. 2011-12-03 02:21:56 +09:00
Xavier Noria
36cc1f78eb revises some details in the previous explain patch 2011-12-02 09:19:13 -08:00
Jon Leighton
9acb340e88 Revert "Roflscaling!" (for now)
This reverts commit f6b5046305.

Fear not, the roflscale will return when I have a bit more time and
figure out a better way to do it. (In particular, a way that doesn't
break the build.)
2011-12-02 13:23:31 +00:00
Xavier Noria
0306f82e0c implements automatic EXPLAIN logging for slow queries 2011-12-02 04:35:43 -08:00
David Heinemeier Hansson
4d20de8a50 Added Enumerable#pluck to wrap the common pattern of collect(&:method) *DHH* 2011-12-02 13:00:56 +01:00
José Valim
76a3ec7f6e Try to play nice with plugins doing monkey patches. 2011-12-02 09:57:43 +01:00
Arun Agrawal
9f623e2109 [Docs] Information about ActionDispatch::DebugExceptions in rake task 2011-12-02 08:45:11 +05:30
Arun Agrawal
330db28018 Adding information about ActionDispatch::DebugExceptions 2011-12-02 08:44:32 +05:30
Jon Leighton
6bff6439b1 Fewer string allocations in attribute method 2011-12-01 23:41:51 +00:00
Jon Leighton
f6b5046305 Roflscaling!
Don't prefix the name with attribute_. Avoids a string allocation on
read_attribute, which is a bit faster.
2011-12-01 23:41:51 +00:00
Jon Leighton
9ead4130de Create method with known identifier then alias into place.
This means we never have to rely on define_method (which is slower and
uses more memory), even when we have attributes containing characters
that are not allowed in standard method names.

(I am mainly changing this because the duplication annoys me, though.)
2011-12-01 23:41:51 +00:00
Jon Leighton
bd920eae82 Remove some unnecessary code etc 2011-12-01 23:41:51 +00:00
Jon Leighton
e9fb6d04bd Add test for read_attribute(:id) with non-standard PK.
Also make it actually work.

It slows down all read_attribute accesses to map 'id' to whatever the PK
actually is, inside read_attribute. So instead make sure the necessary
methods are defined and that they redirect wherever they need to go.
2011-12-01 23:41:51 +00:00
Jon Leighton
f1a534af98 Remove the need for type_cast_attribute.
This is good because it reduces duplication.
2011-12-01 23:41:51 +00:00
Jon Leighton
47b97a739d Fix up test altering global state that was causing me grief 2011-12-01 23:41:51 +00:00
Jon Leighton
3a40d38619 Get rid of the underscore versions of attribute methods!
This makes me happy!
2011-12-01 23:41:51 +00:00
Jon Leighton
3dcb127109 Don't rely on underscore-prefixed attribute methods.
Define singleton methods on the attributes module instead. This reduces
method pollution on the actual model classes. It also seems to make
something faster, I am unsure why! O_o
2011-12-01 23:41:51 +00:00
Jon Leighton
365e10b8dc Remove unnecessary *args 2011-12-01 23:41:51 +00:00
Richard Hulse
d72a85c022 [docs] removed last-modifed line from examples
This is no longer best-practice.

ref:
http://stackoverflow.com/questions/8344186/rails-3-1-on-apache-pagespeed-says-specify-cache-validator-when-using-asset-p/8348385#8348385
2011-12-02 10:44:34 +13:00
José Valim
07f90f6bec Merge branch 'exceptions' with the following features:
* A Railtie API for registering new exceptions and their respective status code (check Active Record railtie for an example)

* Extraction of ShowExceptions middleware logging and debugging features into a middleware called DebugExceptions

Conflicts:
	actionpack/CHANGELOG.md
2011-12-01 21:18:47 +01:00
José Valim
6a4606d3a6 Remove unnecessary test setup. 2011-12-01 21:17:11 +01:00
José Valim
f9edc079e0 Split and improve show and debug exceptions middlewares. 2011-12-01 21:15:42 +01:00
José Valim
750bb5c865 Split ShowExceptions responsibilities in two middlewares. 2011-12-01 20:46:18 +01:00
David Heinemeier Hansson
83d29a283c Revert "Added ActiveRecord::Base#last_modified to work with the new fresh_when/stale? conditional get methods from Action Pack"
Needless indirection with no added value.

This reverts commit 535853e83b.
2011-12-01 20:45:47 +01:00
José Valim
956ecff833 Add a deprecation to old show exceptions API (even though it was not public). 2011-12-01 20:16:12 +01:00