-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn when caching is disabled / document
This patch adds new warnings for all elements that don't indicate their caching behavior, including user-defined ClauseElement subclasses and third party dialects. it additionally adds new documentation to discuss an apparent performance degradation in 1.4 when caching is disabled as a result in the significant expense incurred by ORM lazy loaders, which in 1.3 used BakedQuery so were actually cached. As a result of adding the warnings, a fair degree of lesser used SQL expression objects identified that they did not define caching behavior so would have been producing ``[no key]``, including PostgreSQL constructs ``hstore`` and ``array``. These have been amended to use inherit cache where appropriate. "on conflict" constructs in PostgreSQL, MySQL, SQLite still explicitly don't generate a cache key at this time. The change also adds a test for all constructs via assert_compile() to assert they will not generate cache warnings. Fixes: #7394 Change-Id: I85958affbb99bfad0f5efa21bc8f2a95e7e46981
- Loading branch information
Showing
45 changed files
with
979 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.. change:: | ||
:tags: bug, sql | ||
:tickets: 7394 | ||
|
||
Custom SQL elements, third party dialects, custom or third party datatypes | ||
will all generate consistent warnings when they do not clearly opt in or | ||
out of SQL statement caching, which is achieved by setting the appropriate | ||
attributes on each type of class. The warning links to documentation | ||
sections which indicate the appropriate approach for each type of object in | ||
order for caching to be enabled. | ||
|
||
.. change:: | ||
:tags: bug, sql | ||
:tickets: 7394 | ||
|
||
Fixed missing caching directives for a few lesser used classes in SQL Core | ||
which would cause ``[no key]`` to be logged for elements which made use of | ||
these. | ||
|
||
.. change:: | ||
:tags: bug, postgresql | ||
:tickets: 7394 | ||
|
||
Fixed missing caching directives for :class:`_postgresql.hstore` and | ||
:class:`_postgresql.array` constructs which would cause ``[no key]`` | ||
to be logged for these elements. | ||
|
||
.. change:: | ||
:tags: bug, orm | ||
:tickets: 7394 | ||
|
||
User defined ORM options, such as those illustrated in the dogpile.caching | ||
example which subclass :class:`_orm.UserDefinedOption`, by definition are | ||
handled on every statement execution and do not need to be considered as | ||
part of the cache key for the statement. Caching of the base | ||
:class:`.ExecutableOption` class has been modified so that it is no longer | ||
a :class:`.HasCacheKey` subclass directly, so that the presence of user | ||
defined option objects will not have the unwanted side effect of disabling | ||
statement caching. Only ORM specific loader and criteria options, which are | ||
all internal to SQLAlchemy, now participate within the caching system. | ||
|
||
.. change:: | ||
:tags: bug, orm | ||
:tickets: 7394 | ||
|
||
Fixed issue where mappings that made use of :func:`_orm.synonym` and | ||
potentially other kinds of "proxy" attributes would not in all cases | ||
successfully generate a cache key for their SQL statements, leading to | ||
degraded performance for those statements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.. _core_foundation_toplevel: | ||
|
||
================================================= | ||
SQL Expression Language Foundational Constructs | ||
================================================= | ||
|
||
Base classes and mixins that are used to compose SQL Expression Language | ||
elements. | ||
|
||
.. currentmodule:: sqlalchemy.sql.expression | ||
|
||
.. autoclass:: CacheKey | ||
:members: | ||
|
||
.. autoclass:: ClauseElement | ||
:members: | ||
:inherited-members: | ||
|
||
|
||
.. autoclass:: sqlalchemy.sql.base.DialectKWArgs | ||
:members: | ||
|
||
|
||
.. autoclass:: sqlalchemy.sql.traversals.HasCacheKey | ||
:members: | ||
|
||
.. autoclass:: LambdaElement | ||
:members: | ||
|
||
.. autoclass:: StatementLambdaElement | ||
:members: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.