Hi,
As recently discussed on pgsql-bugs[1], substring() does unnecessarywork that can easily be deleted. Here's a patch to try that.
[1] https://stream.boxwatch.ru/message-id/flat/19406-9867fddddd724fca%40postgresql.org