0

"A GIN index stores a set of (key, posting list) pairs, where a posting list is a set of row IDs in which the key occurs. " https://www.postgresql.org/docs/current/gin-intro.html

How can I access this list of (key,posting list)?

Yorai Levi
  • 473
  • 5
  • 17
  • Why do you think you need that? What problem are you trying to solve with that information? –  Jun 24 '22 at 05:58
  • 2
    The [pageinspect](https://www.postgresql.org/docs/current/pageinspect.html#id-1.11.7.32.8) module is probably your best chance –  Jun 24 '22 at 06:06
  • @a_horse_with_no_name I literally need this kind of info. a mapping from bag of words to rows that contain them – Yorai Levi Jun 24 '22 at 06:07
  • @YoraiLevi If you want to access `(key,posting list)` meaning you access all the distinct base lexemes. That is a lot. If you just want to query certain lexemes being contained in which row, you can just use GIN index tsvector_ops. – jian Jun 24 '22 at 06:17
  • @Mark I need everything – Yorai Levi Jun 24 '22 at 06:32
  • 1
    @YoraiLevi I've made a [demo](https://dbfiddle.uk/?rdbms=postgres_14&fiddle=051815cf24494f2fbb59fbc6b5f77933). Let me know if that is what you want. – jian Jun 24 '22 at 07:00
  • Simply perform the corresponding SQL query, and you get your result. – Laurenz Albe Jun 24 '22 at 07:05
  • Thanks @Mark that's almost it. I don't want the lexemes for each single line(yet) I need them aggregated. It's simple to do from the query demo you gave but it's going to compute it again where I hoped to reuse the index for that – Yorai Levi Jun 24 '22 at 17:02
  • https://stackoverflow.com/questions/43822114/how-to-select-data-from-a-postgresql-index hopefully by 2030 it will be easier – Yorai Levi Jun 24 '22 at 17:44

0 Answers0