3 ms·
I'm new to postgres and having trouble visualizing the recursive query you're describing. Would you be willing to share an example query (or something that illu
by chrisshroba 6y ago
I'm new to postgres and having trouble visualizing the recursive query you're describing. Would you be willing to share an example query (or something that illustrates the point on fake data)?
- koeng 6y agoThe query that I have working is an abomination (it works though, https://github.com/Koeng101/poly/blob/polyStore_v0.1/store/construct.go#L244-L332 https://github.com/Koeng101/poly/blob/polyStore_v0.1/store/c...) The basic idea is that I am using SQL to back a suffix array (https://en.wikipedia.org/wiki/Suffix_array https://en.wikipedia.org/wiki/Suffix_array). The suffix array has all suffixes of a string (for "bats", it would have ["bat", "at", "t"] sorted in alphabetical order ["at", "bat", "t"] except storing the index of the suffix [1, 0, 2]. To search for a string, you go halfway in the suffix array and check if the suffix is lexicographically equal to, larger than, or smaller than your input. If it is not equal to, halve in the right direction. If the string is there, eventually you'll hit it.