4 ms·
No it is exactly the same query as if it were a separate table/collection. You can just say fetch from User.Profile instead of Profile. If you need to fetch ac
by taligent 14y ago
No it is exactly the same query as if it were a separate table/collection. You can just say fetch from User.Profile instead of Profile.
If you need to fetch across users then you will need an index in order to have decent performance. But the point is that in MY use case this never, ever happens so I made that tradeoff. Much faster "fetch everything about this user by id" in exchange for much slower "fetch me all profiles for all users".
- swah 14y agoYes, I was trying to understand if, for your use case, storing JSON properties for each user in a SQL text column would give the same result.
- tomjakubowski 14y agoor this case could have the best of both worlds and use an HSTORE column - which can be queried by field - in PostgreSQL.
- taligent 14y agoYou could but then you're really trying to jam a JSON style modal into a relational database. You CAN do it. But the tools and query language will make it much harder to work with. Not to mention lack of indexes on individual fields.
- jeffdavis 14y agoPeople avoid introducing new data stores because it adds complexity and it's harder to do queries across data sets. Jamming different data models together in one system is a very viable strategy. Postgres supports functional indexes, so indexing individual fields within a JSON document is already possible. If it's not easy now it will be easy soon. Remember XML databases? They became extremely marginalized when relational systems started adding basic support.