From d81e5307b7b99af6169aaead81d6ff087c03a578 Mon Sep 17 00:00:00 2001
From: Peter Geoghegan <pg@heroku.com>
Date: Tue, 2 Sep 2014 18:55:05 -0700
Subject: [PATCH 5/5] Re-enable optimization on Darwin

Continue to limit the optimization to platforms with 8 byte Datums,
though.
---
 src/backend/utils/adt/varlena.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 062035f..a753510 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -1752,23 +1752,14 @@ btsortsupport_worker(SortSupport ssup, Oid collid)
 	/*
 	 * On platforms where the abbreviated key for text optimization might have
 	 * bad worst case performance it is avoided entirely.  In order to ever
-	 * apply the optimization we require:
-	 *
-	 * 	* That the platform's strxfrm() meets a certain standard for
-	 * 	representing as much information as possible in leading bytes.
-	 *
-	 *	* That there are a full 8 bytes of storage per Datum on the platform,
-	 *	since we pack bytes into that representation.  Having only 4 bytes
-	 *	could make worse case performance drastically more likely.
+	 * apply the optimization we require that there are a full 8 bytes of
+	 * storage per Datum on the platform, since we pack bytes into that
+	 * representation.  Having only 4 bytes could make worse case performance
+	 * drastically more likely.
 	 *
 	 * The standard applied for strxfrm() is that a significant amount of
 	 * entropy from the original string must be concentrated at the beginning
-	 * of returned blobs.  The Mac OS X implementation is known to produce
-	 * blobs with very little entropy;  it produces printable blobs with a
-	 * series of 24-bit weights, each one encoded into four bytes.  Multiple
-	 * "levels" of weights are separated by a weight of 0.  Typically only two
-	 * ASCII characters are represented in the first eight bytes.  Therefore,
-	 * the optimization is specially disabled.
+	 * of returned blobs.
 	 *
 	 * Any reasonable implementation will pack primary weights into the start
 	 * of returned blobs.  The canonical algorithm's implementation is
@@ -1802,7 +1793,7 @@ btsortsupport_worker(SortSupport ssup, Oid collid)
 	 * There is no reason to not at least perform fmgr elision on platforms
 	 * where abbreviation isn't expected to be profitable, though.
 	 */
-#if defined(__darwin__) || SIZEOF_DATUM != 8
+#if SIZEOF_DATUM != 8
 	ssup->type = sortKeyOther;
 #endif
 
-- 
1.9.1

