Skip to content
Advertisement

Tag: postgresql

PostgreSQL verify an empty array on json

I have the following row on select I have to Identify empty jsons, then manually add a value to it (eg row 1 and 3 ), I tried the following : But the “is null” verification fails for this type of data (array of json), how to identify ‘[]’ values in this case? Note: I only have select permission on

How to sum rows in groups of 3?

I have a table that looks like this: I need a query that returns the summed amount of rows grouped by every 3 consequent IDs. The result should be: In my table, you can assume IDs are always consequent. So there can’t be a 10 without existing a 9 too. But the same ID can also show up multiple times

Select row where latest quarter and year In POSTGRESQL

I need help with my issue here . I need to select rows where quarter and year are latest . Here is example of my table Risk Master table named HD_Risk_Master:- Another table that join with HD_Risk_Master table named HD_Case_Resolution 1:M Expected Result My result of query , no HDS-OP3 and HDS-OP4 in my query which i realised the max

Idempotent record creation: is it better to use a unique constraint or check for existence before inserting a record?

I’ve recently been wondering what’s generally the best approach for ensuring that the creation of database records is idempotent. The two approaches I can think of are: Checking whether a record already exists before executing an INSERT Using a unique constraint on the relevant columns to insure two records with the same values cannot exist This seems like an example

Why is this Index Scan so slow?

From what I can see, the index is not entirely loaded up in memory, and that’s what causing it to be slow? Am I correct? obs: I changed the “Output” section a little bit for privacy concerns Answer The index scan is fast (1.774 milliseconds on average). The execution is so slow because the index scan is executed 46257 times.

Advertisement