[Sqlalchemy-tickets] Issue #4330: Should JSON type default to 'jsonb' on Postgres? (zzzeek/sqlalche
Brought to you by:
zzzeek
From: Mark A. <iss...@bi...> - 2018-09-06 14:05:58
|
New issue 4330: Should JSON type default to 'jsonb' on Postgres? https://bitbucket.org/zzzeek/sqlalchemy/issues/4330/should-json-type-default-to-jsonb-on Mark Amery: https://www.postgresql.org/docs/current/static/datatype-json.html recommends using jsonb over json for most use cases, since its performance is superior. (The json type just stores the input as text, which has to be parsed in order to do any queries, and keys within the json can't be indexed. jsonb stores a proper structured representation of the given JSON that can be indexed for faster querying.) This guidance seems obviously good to me. For that reason, wouldn't it make sense for sqlalchemy.types.JSON to translate to jsonb on Postgres instead of json? Besides the "jsonb is just plain better in almost all cases" argument, it also seems relevant that PostgreSQL's "jsonb" type is a closer match behaviourally to MySQL's "JSON" type than PostgreSQL's "json" type is. Since SQLAlchemy translates sqlalchemy.types.JSON to "JSON" on MySQL, this perhaps means that translating to "jsonb" on Postgres is more portable? |