Re: [HACKERS] Bringing text abbreviation debug output under the control of trace_sort

2015-04-07 Thread Robert Haas
On Sun, Apr 5, 2015 at 3:59 PM, Peter Geoghegan p...@heroku.com wrote:
 Attached patch makes trace_sort control abbreviation debug output for
 the text opclass, which makes it consistent with the numeric opclass.
 This seems better than relying on someone going to the trouble of
 building Postgres themselves to debug cases where abbreviation is the
 wrong thing, which we're not 100% sure will not occur. It also allows
 wider analysis of where abbreviation helps the most and the least in
 production, which is surely a good thing.

 I have added this to the next commitfest, but I suggest that it be
 quickly committed to the master branch as a maintenance commit.

Done.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Bringing text abbreviation debug output under the control of trace_sort

2015-04-07 Thread Peter Geoghegan
On Tue, Apr 7, 2015 at 7:46 PM, Robert Haas robertmh...@gmail.com wrote:
 Done.

Thank you.


-- 
Peter Geoghegan


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] Bringing text abbreviation debug output under the control of trace_sort

2015-04-05 Thread Peter Geoghegan
Attached patch makes trace_sort control abbreviation debug output for
the text opclass, which makes it consistent with the numeric opclass.
This seems better than relying on someone going to the trouble of
building Postgres themselves to debug cases where abbreviation is the
wrong thing, which we're not 100% sure will not occur. It also allows
wider analysis of where abbreviation helps the most and the least in
production, which is surely a good thing.

I have added this to the next commitfest, but I suggest that it be
quickly committed to the master branch as a maintenance commit.
-- 
Peter Geoghegan
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index d874a1a..18cbdd0 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -34,9 +34,6 @@
 #include utils/pg_locale.h
 #include utils/sortsupport.h
 
-#ifdef DEBUG_ABBREV_KEYS
-#define DEBUG_elog_output	DEBUG1
-#endif
 
 /* GUC variable */
 int			bytea_output = BYTEA_OUTPUT_HEX;
@@ -2149,11 +2146,13 @@ bttext_abbrev_abort(int memtupcount, SortSupport ssup)
 	 * time there are differences within full key strings not captured in
 	 * abbreviations.
 	 */
-#ifdef DEBUG_ABBREV_KEYS
+#ifdef TRACE_SORT
+	if (trace_sort)
 	{
 		double norm_abbrev_card = abbrev_distinct / (double) memtupcount;
 
-		elog(DEBUG_elog_output, abbrev_distinct after %d: %f (key_distinct: %f, norm_abbrev_card: %f, prop_card: %f),
+		elog(LOG, bttext_abbrev: abbrev_distinct after %d: %f 
+			 (key_distinct: %f, norm_abbrev_card: %f, prop_card: %f),
 			 memtupcount, abbrev_distinct, key_distinct, norm_abbrev_card,
 			 tss-prop_card);
 	}
@@ -2219,11 +2218,11 @@ bttext_abbrev_abort(int memtupcount, SortSupport ssup)
 	 * of moderately high to high abbreviated cardinality.  There is little to
 	 * lose but much to gain, which our strategy reflects.
 	 */
-#ifdef DEBUG_ABBREV_KEYS
-	elog(DEBUG_elog_output, would have aborted abbreviation due to worst-case at %d. abbrev_distinct: %f, key_distinct: %f, prop_card: %f,
-		 memtupcount, abbrev_distinct, key_distinct, tss-prop_card);
-	/* Actually abort only when debugging is disabled */
-	return false;
+#ifdef TRACE_SORT
+	if (trace_sort)
+		elog(LOG, bttext_abbrev: aborted abbreviation at %d 
+			 (abbrev_distinct: %f, key_distinct: %f, prop_card: %f),
+			 memtupcount, abbrev_distinct, key_distinct, tss-prop_card);
 #endif
 
 	return true;

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers