News for hackers. Stuff that matters.
Re:PostgreSQL 9.6 Released by kuschku on Thursday September 29, 2016 @03:31PM (#12608106)
> What happens if you search for a term that matches a lot of rows? This is the case where ts_rank is very expensive. I'd be curious to look at the explain of such a low-selectivity query.

That’s actually quite unproblematic, if you have the tsvector as its own column (not just as index).

It’s far more problematic to actually load that data from disk.

Re:PostgreSQL 9.6 Released by ngrilly on Thursday September 29, 2016 @03:54PM (#12608281)
> That’s actually quite unproblematic, if you have the tsvector as its own column (not just as index).

Yes, it works, but it is slow because the tsvector is usually big enough to be stored in a TOAST table, and this produces a lot of random access reads.

This is why there is a project of storing additional information in the GIN (term positions) in order for the index to contain all necessary information for the ranking:

https://wiki.postgresql.org/images/2/25/Full-text_search_in_...

Re:PostgreSQL 9.6 Released by kuschku on Thursday September 29, 2016 @04:03PM (#12608334)
> usually big enough to be stored in a TOAST table

Ah, luckily, in my case, that can’t happen – each row’s message contains one IRC message, so at most 512 bytes. That also automatically ensures we’ll never run into TOAST issues.

Re:PostgreSQL 9.6 Released by ngrilly on Thursday September 29, 2016 @06:23PM (#12609304)
Now I understand why you didn't suffer from the slow ranking issue. In my test case, text is longer and triggers the TOAST management code.
Re:PostgreSQL 9.6 Released by kuschku on Thursday September 29, 2016 @06:25PM (#12609317)
Yeah, if your vectors are in TOAST, you really have a huge issue with ranking. There’s no simple way to get around that, except with customized solutions like Lucene/Solr/ES