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://www.postgresql.org/message-id/flat/19406-9867fddddd724fca%40postgresql.org