diff --git a/src/jrd/optimizer/Optimizer.cpp b/src/jrd/optimizer/Optimizer.cpp index afec33c3e83..7d6cf5d02f8 100644 --- a/src/jrd/optimizer/Optimizer.cpp +++ b/src/jrd/optimizer/Optimizer.cpp @@ -1508,7 +1508,7 @@ SortedStream* Optimizer::generateSort(const StreamList& streams, const auto* dbb = tdbb->getDatabase(); const auto threshold = dbb->dbb_config->getInlineSortThreshold(); - refetchFlag = (totalLength > threshold); + refetchFlag = (totalLength > MIN(threshold, MAX_SORT_RECORD / 2)); } // Check for persistent fields to be excluded from the sort. diff --git a/src/jrd/val.h b/src/jrd/val.h index 86da74647ba..a65baf9c92e 100644 --- a/src/jrd/val.h +++ b/src/jrd/val.h @@ -49,7 +49,7 @@ class VaryingString : public pool_alloc_rpt UCHAR str_data[2]; // one byte for ALLOC and one for the NULL }; -inline constexpr ULONG MAX_RECORD_SIZE = 65535; +inline constexpr ULONG MAX_RECORD_SIZE = 1048576; // 1 MB -- just to protect from possible misuse namespace Jrd {