I have a Postgres table with more than 25M records, there I have a jsonb column called info.
sample json format:
{
"username1":{"name":"somename","age":22,"gender":"male"},
"fathername":{"name":"somename","age":22,"gender":"male"}
}
I am going to find number of records that match the 'user%' key value.
Here is my query
select count(1) from tablename where info::text like '%user%';
this query is working and I am getting result for it, but it is taking long time to execute this query in 25M records.
Is there any way that I can optimize this query or any alternate method to achieve it? Please help.
Thanks in advance!