By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
INSERT 0 9
parent_id | path | jsondata |
---|---|---|
null | {comments,4} | {"children": [], "username": "Mike Tyson", "comment_id": "i", "comment_body": "more cookies", "comment_likes": 1} |
null | {comments,2} | {"children": [], "username": "Mike Tyson", "comment_id": "e", "comment_body": "cookies", "comment_likes": 864} |
null | {comments,3} | {"children": [], "username": "Mike Tyson", "comment_id": "f", "comment_body": "bar", "comment_likes": 44} |
null | {comments,1} | {"children": [], "username": "Mike Tyson", "comment_id": "a", "comment_body": "foo", "comment_likes": 1} |
{a} | {comments,1,children,1} | {"children": [], "username": "Mike Tyson", "comment_id": "b", "comment_body": "foofoo", "comment_likes": 232} |
{a} | {comments,1,children,2} | {"children": [], "username": "Mike Tyson", "comment_id": "d", "comment_body": "fooFOO", "comment_likes": 53} |
{a,b} | {comments,1,children,1,children,1} | {"children": [], "username": "Mike Tyson", "comment_id": "c", "comment_body": "foofoofoo", "comment_likes": 23232} |
{f} | {comments,3,children,3} | {"children": [], "username": "Mike Tyson", "comment_id": "g", "comment_body": "barbar", "comment_likes": 54} |
{f} | {comments,3,children,4} | {"children": [], "username": "Mike Tyson", "comment_id": "h", "comment_body": "barBAR", "comment_likes": 222} |
SELECT 9
CREATE FUNCTION
jsonb_pretty |
---|
{ "comments": [ { "children": [ ], "username": "Mike Tyson", "comment_id": "i", "comment_body": "more cookies", "comment_likes": 1 }, { "children": [ { "children": [ ], "username": "Mike Tyson", "comment_id": "b", "comment_body": "foofoo", "comment_likes": 232 }, { "children": [ { "children": [ ], "username": "Mike Tyson", "comment_id": "c", "comment_body": "foofoofoo", "comment_likes": 23232 } ], "username": "Mike Tyson", "comment_id": "d", "comment_body": "fooFOO", "comment_likes": 53 } ], "username": "Mike Tyson", "comment_id": "a", "comment_body": "foo", "comment_likes": 1 }, { "children": [ ], "username": "Mike Tyson", "comment_id": "e", "comment_body": "cookies", "comment_likes": 864 }, { "children": [ { "children": [ ], "username": "Mike Tyson", "comment_id": "g", "comment_body": "barbar", "comment_likes": 54 }, { "children": [ ], "username": "Mike Tyson", "comment_id": "h", "comment_body": "barBAR", "comment_likes": 222 } ], "username": "Mike Tyson", "comment_id": "f", "comment_body": "bar", "comment_likes": 44 } ] } |
SELECT 1