In most cases, insertion into a GIN index is slow due to the likelihood of many keys being inserted for each value. So, for bulk insertions into a table it is advisable to to drop the GIN index and recreate it after finishing bulk insertion.
The primary goal of developing GIN indices was support for highly scalable, full-text search in PostgreSQL and there are often situations when a full-text search returns a very large set of results. Since reading tuples from the disk and sorting them could take a lot of time, this is unacceptable for production. (Note that the index search itself is very fast.)
Such queries usually contain very frequent words, so the results are not
very helpful. To facilitate execution of such queries
GIN has a configurable soft upper limit of the size
of the returned set, determined by the
gin_fuzzy_search_limit
GUC variable. It is set to 0 by
default (no limit).
If a non-zero search limit is set, then the returned set is a subset of the whole result set, chosen at random.
“Soft” means that the actual number of returned results could slightly differ from the specified limit, depending on the query and the quality of the system's random number generator.