jointakahe / takahe

An ActivityPub/Fediverse server
BSD 3-Clause "New" or "Revised" License
1.1k stars 84 forks source link

nodeinfo reveals metadata based on domain requested #628

Closed alphatownsman closed 11 months ago

alphatownsman commented 11 months ago

nodeName is not supported by Mastodon but other major implementations like Pleroma, Misskey and their forks all have it.

andrewgodwin commented 11 months ago

So this code looks correct, but the problem is that changing the query will have a nasty impact on performance if landed as-is - local has an index on it, but I do not think domain does. I'll run the queries on takahe.social's db when I get a chance to see what the difference is.

andrewgodwin commented 11 months ago

I might suggest adding local into the filter query too, so the db can use that to grab the initial rows and then the scan for domain values is a lot cheaper?

alphatownsman commented 11 months ago

Thanks. very good point. I somehow had a wrong assumption that foreign key implies index but i just checked psql doc and I'm clearly wrong!

just add local=True to query. let me know anything else needed.

adding index for domain will be handy, given we will have to batch delete post from a domain when blocking an instance, but I assume that can have its own pr.

TkTech commented 11 months ago

Thanks. very good point. I somehow had a wrong assumption that foreign key implies index but i just checked psql doc and I'm clearly wrong!

No, you're correct, but that's a behaviour of Django's ForeignKey and not something postgres is doing.

A database index is automatically created on the ForeignKey. You can disable this by setting db_index to False. You may want to avoid the overhead of an index if you are creating a foreign key for consistency rather than joins, or if you will be creating an alternative index like a partial or multiple column index.

alphatownsman commented 11 months ago

Thank you! Guess that's where my vague memory was from 😂

Given having that local in query does little to no harm anyway, I'll just leave it as is.