question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SQLAlchemy ``cache_ok`` bit

See original GitHub issue

While working with an RDS database, I received this warning, and the performance has deteriorated, from the local version, drastically:
.....lib/python3.8/site-packages/ax/storage/sqa_store/load.py:229: SAWarning: TypeDecorator JSONEncodedText() will not produce a cache key because the ``cache_ok`` attribute is not set to True. This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions. Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf) Any idea on how I can address it?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
danielcohenlivecommented, Mar 25, 2022

😬 Okay, this seems like a bit of a pain for you. I do see a problem in that the dict passed to JSONEncodedText is not hashable, but I’m also seeing it hashes the arguments to __init__(), not process_bind_param() which I’m confused about, so I’m running some tests to see if anything breaks.

0reactions
alxfedcommented, Jul 22, 2022

Unfortunately it happens in 0.2.5.1 too, but on line 232 now /storage/sqa_store/load.py:232: SAWarning: TypeDecorator JSONEncodedText() will not produce a cache key because the ``cache_ok`` attribute is not set to True. This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions. Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf) .one_or_none() SQLAlchemy==1.4.39 python ==3.10.5

Apparently the cache_ok = True line in JSONEncodedObject doesn’t cut it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance - SQLAlchemy 1.4 Documentation
SQLAlchemy as of version 1.4 includes a SQL compilation caching facility which will allow Core and ORM SQL constructs to cache their stringified...
Read more >
how can I stop the [UtcDateTime cache_ok ]warn? When I run ...
This is due to change in SQLAlchemy 1.4 (see release notes). If you get this warning it means that you did not install...
Read more >
Do you really need Redis? How to get away with just ...
I've personally done a fair bit of migration from formal queue systems into an RDBMS. You simply get a ... If it's “just...
Read more >
How to use st.cache with sqlalchemy.orm objects - Streamlit
I am writing an app for data exploration. The app uses sqlalchemy to query data from a database. Some of the queries can...
Read more >
How Should I Set Up Aiomysq Pool Cache - ADocLib
In the use of sqlalchemy when , Need to use aiomysql.sa.createengine Function ... A new class-level attribute TypeDecorator.cacheok may be set which will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found