Commit Graph

23 Commits

Author SHA1 Message Date
Mike Bayer 4550983e0c Performance fixes for new result set
A few small mistakes led to huge callcounts.   Additionally,
the warn-on-get behavior which is attempting to warn for
deprecated access in SQLAlchemy 2.0 is very expensive; it's not clear
if its feasible to have this warning or to somehow alter how it
works.

Fixes: #5340
Change-Id: I73bdd2d7b6f1b25cc0222accabd585cf761a5af4
2020-05-21 14:16:03 -04:00
Mike Bayer a9b62055bf Try to measure new style caching in the ORM, take two
Supercedes: If78fbb557c6f2cae637799c3fec2cbc5ac248aaf

Trying to see if by making the cache key memoized, we
still can have the older "identity" form of caching
which is the cheapest of all, at the same time as the
newer "cache key each time" version that is not nearly
as cheap; but still much cheaper than no caching at all.

Also needed is a per-execution update of _keymap when
we invoke from a cached select, so that Column objects
that are anonymous or otherwise adapted will match up.
this is analogous to the adaption of bound parameters
from the cache key.

Adds test coverage for the keymap / construct_params()
 changes related to caching.  Also hones performance
to a large extent for statement construction and
cache key generation.

Also includes a new memoized attribute
approach that vastly simplifies the previous approach
of "group_expirable_memoized_property" and finally
integrates cleanly with _clone(), _generate(), etc.
no more hardcoding of attributes is needed, as well
as that most _reset_memoization() calls are no longer
needed as the reset is inherent in a _generate() call;
this also has dramatic performance improvements.

Change-Id: I95c560ffcbfa30b26644999412fb6a385125f663
2020-04-01 16:12:23 -04:00
Mike Bayer 190e0139e8 Enable F841
This is a very useful assertion which prevents unused variables
from being set up allows code to be more readable and sometimes
even more efficient.  test suites seem to be where the most
problems are and there do not seem to be documentation examples
that are using this, or at least the linter is not taking effect
within rst blocks.

Change-Id: I2b3341d8dd14da34879d8425838e66a4b9f8e27d
2019-06-20 13:50:41 -04:00
Matt Schuchhardt 203de6946e Fix large_resultsets performance example field name
Fixed bug in large_resultsets example case where a re-named "id" variable
due to code reformatting caused the test to fail.  Pull request courtesy
Matt Schuchhardt.

Fixes: #4528
Closes: #4529
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4529
Pull-request-sha: 8f52f10422

Change-Id: Iaca6fd06ec0ede8ff1745d627708ba492a2114c8
2019-03-06 10:34:17 -05:00
Mike Bayer 1e278de4cc Post black reformatting
Applied on top of a pure run of black -l 79 in
I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9,  this set of changes
resolves all remaining flake8 conditions for those codes
we have enabled in setup.cfg.

Included are resolutions for all remaining flake8 issues
including shadowed builtins, long lines, import order, unused
imports, duplicate imports, and docstring issues.

Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
2019-01-06 18:23:11 -05:00
Mike Bayer 1e1a38e780 Run black -l 79 against all source files
This is a straight reformat run using black as is, with no edits
applied at all.

The black run will format code consistently, however in
some cases that are prevalent in SQLAlchemy code it produces
too-long lines.   The too-long lines will be resolved in the
following commit that will resolve all remaining flake8 issues
including shadowed builtins, long lines, import order, unused
imports, duplicate imports, and docstring issues.

Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
2019-01-06 17:34:50 +00:00
Patrick 4a3205df84 Docstring Fix
Change the docstring in short_selects example to match the code
2016-03-30 21:45:40 +01:00
Mike Bayer e3b46bd624 - Added a new extension suite :mod:sqlalchemy.ext.baked. This
simple but unusual system allows for a dramatic savings in Python
overhead for the construction and processing of orm :class:`.Query`
objects, from query construction up through rendering of a string
SQL statement.
fixes #3054
2015-03-11 20:31:11 -04:00
Mike Bayer 611d88d234 - add a callers option 2015-03-09 15:19:49 -04:00
Mike Bayer 9afe585f45 - pick around gaining modest dings in callcounts here and there 2015-03-09 14:36:23 -04:00
Mike Bayer a421106c9d - random performance whacking vs. 0.9, in particular we have to watch
for the slots-based __getattr__ thing getting hit
2015-03-08 15:32:21 -04:00
Mike Bayer a92f6662b4 - add this for testing 2015-03-08 14:43:42 -04:00
Mike Bayer 3f1477e2ec - A new series of :class:.Session methods which provide hooks
directly into the unit of work's facility for emitting INSERT
and UPDATE statements has been created.  When used correctly,
this expert-oriented system can allow ORM-mappings to be used
to generate bulk insert and update statements batched into
executemany groups, allowing the statements to proceed at
speeds that rival direct use of the Core.
fixes #3100
2014-12-08 01:10:30 -05:00
Mike Bayer 0c19d765dc bulk_updates 2014-11-06 17:31:14 -05:00
Mike Bayer b9d430af75 - add differentiating examples of list() vs. iteration 2014-09-16 11:57:03 -04:00
Mike Bayer fa7c8f8811 - try to finish up the performance example for now 2014-09-06 13:01:21 -04:00
Mike Bayer d2c05c36a5 - add a test that shows query caching. 2014-09-04 20:55:38 -04:00
Mike Bayer eb81531275 tweak 2014-09-03 20:30:52 -04:00
Mike Bayer cbef6a7d58 refine 2014-09-03 20:07:08 -04:00
Mike Bayer 84d4651f3d Merge branch 'master' into ticket_3100 2014-09-03 19:44:40 -04:00
Mike Bayer 2c081f9a4a - large resultsets 2014-09-03 19:30:38 -04:00
Mike Bayer 07d061a17b - wip 2014-09-03 14:49:26 -04:00
Mike Bayer 9494ca00d4 - lets start exampling this stuff 2014-09-02 19:46:55 -04:00