Closed apraditya closed 2 years ago
@apraditya As this is >2.5y old, have you managed to resolve the issue?
In general, I don’t think this is an issue with PublicActivity itself but rather an issue with PostgreSQL. The reason I say that is because your query doesn’t use the parameters
text/jsonb. So there’s something else going on unless you changed some indices along the way. Take a look at https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-STATISTICS. This could be the culprit of your performance problem.
I’m going to close this issue for now as this is more about PostgreSQL than PublicActivity. However, I’d be interested to hear back in case the vacuum helps or if you’ve identified any other issues with jsonb
. So feel free to re-open the issue.
I'm considering to change parameters type to jsonb. Here's what I did:
parameters_json
with type jsonb, convert all parameters to that column and set AR callback to copyparameters
toparameters_json
before saving the record.parameters
column & renameparameters_json
toparameters
.I don't see any issues after deploying the first step. However, on the 2nd step, the performance gets slower by 6 times. For example, on the following simple query:
running it on a PostgreSQL client, normally it takes 0.22s, after dropping & renaming the column, it takes 1.45s.
Currently I have 18M records in the table. Appreciate any suggestion, help or thoughts.