Skip to content

Gather Avatars image type distribution

We want to understand distribution by the image types (png/jpg/..) of the Avatars we store.

Unfortunately, we don't store an extension in a separate, indexed column, so it would require parsing a path filed, which is slow.

So, I think of something like running this type of query:

SELECT COUNT(*) AS count_all, regexp_matches("uploads"."path", '\.(\w+)$') 
AS uploads_path FROM "uploads" 
WHERE "uploads"."uploader" = 'AvatarUploader' 
GROUP BY uploads_path  

Please tell me if there is a better way to retrieve that in our data schema.

(#database-lab plan: https://gitlab.slack.com/archives/CLJMDRD8C/p1597076638458900)

@abrandl assigning to you, thanks for helping!

cc @mkaeppler @nmilojevic1 - we discussed it. I think it would be most beneficial to static approach even.

Edited by Aleksei Lipniagov