Re:The surprising impact of medium-size texts on PostgreSQL ...
by throwayws on Tuesday October 20, 2020 @01:17PM
(#24839954)
This sounds like an interesting optimization possibility. Do you know will this be patched?
Re:The surprising impact of medium-size texts on PostgreSQL ...
by jerrysievert on Tuesday October 20, 2020 @09:44PM
(#24844098)
the funny thing is that pg shouldn't need to do a detoasting to be able to query as long as it's jsonb, it's a pretty straightforward iteration - we do the same thing when converting from jsonb to v8 in plv8.
Re:The surprising impact of medium-size texts on PostgreSQL ...
by Tomis02 on Wednesday October 21, 2020 @12:46AM
(#24844808)
How come? As far as I know if the jsonb data was toasted (too big to fit in 2kb), then in order to query anything back from inside the jsonb you have to de-toast it, by definition.
Re:The surprising impact of medium-size texts on PostgreSQL ...
by rolls-reus on Tuesday October 20, 2020 @01:32PM
(#24840131)
How do you find out that the optimiser inlined the subquery? Is this visible in the explain output?
Re:The surprising impact of medium-size texts on PostgreSQL ...
by malisper on Tuesday October 20, 2020 @01:47PM
(#24840308)
IIRC, EXPLAIN VERBOSE will show you the columns being selected by each step of the plan. The inlining showed up there.
Re:The surprising impact of medium-size texts on PostgreSQL ...
by jerrysievert on Tuesday October 20, 2020 @11:41PM
(#24844555)
or better yet: EXPLAIN ANALYZE VERBOSE - that will give you a little bit better picture.
My first attempt to fix this was to read the field in one query and use a subselect to pull out the individual fields. This attempt was thwarted by the Postgres optimizer which inlined the subquery and still resulted in deTOASTing the field multiple times.
After a discussion with the Postgres IRC, RhodiumToad pointed out that if I add OFFSET 0 to the end of the subquery, that will prevent Postgres from inlining it. After retrying that, I saw an order of magnitude improvement due to eliminating the redundant work.