JSON datatype in postgreSQL

Introduction PostgreSQL provides us with a datatype to store JSON data. This datatype can be helpful in lots of situations giving us a way to store some dynamic data. Further PostgreSQL provides us with two types for storing JSON data json jsonb They both take almost identical set of inputs but the major difference is that in the efficiency. The json data type stores the exact copy of the input text which the processing functions must reparse on each execution....

August 11, 2022 · 5 min · 915 words · Rajkumar Gosavi

Using Constants in PostgreSQL queries

Introduction Imagine we have a long query which has a lots of conditions, and many of the conditions has some kind of comparisions with literals instead of some other record value. Example: SELECT * FROM users u where (u.name='some name' or u.age=12 or u.email='qwe@qwe.qwe'); For example sake we are taking the name, age and email as constants. Imagine these literal values used multiple times in the query. We will have very untidy query....

November 30, 2021 · 2 min · 268 words · Rajkumar Gosavi