From 1f7e64ba6256a87750bc92c3f6ff02e0754b3dca Mon Sep 17 00:00:00 2001 From: Taimoor Zaeem Date: Mon, 8 Dec 2025 13:19:55 +0500 Subject: [PATCH] fix: out of memory errors for large number of tables - Closes #4462 - Closes #4463 Signed-off-by: Taimoor Zaeem --- CHANGELOG.md | 5 +++++ src/PostgREST/Error.hs | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc5ed5f257..fcbf30d577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. From versio ## Unreleased +### Fixed + +- Fix out of memory errors for large number of tables by @taimoorzaeem in #4523 + + Disables the table not found error `hint` generation for more than 4000 tables + ## [14.1] - 2025-11-05 ## Fixed diff --git a/src/PostgREST/Error.hs b/src/PostgREST/Error.hs index 39217610cf..fe680be929 100644 --- a/src/PostgREST/Error.hs +++ b/src/PostgREST/Error.hs @@ -428,9 +428,12 @@ noRpcHint schema procName params allProcs overloadedProcs = -- | -- Do a fuzzy search in all tables in the same schema and return closest result +-- We have a upper limit for hint generation as 4000 tables to avoid memory +-- and performance issues. tableNotFoundHint :: Text -> Text -> [Table] -> Maybe Text tableNotFoundHint schema tblName tblList - = fmap (\tbl -> "Perhaps you meant the table '" <> schema <> "." <> tbl <> "'") perhapsTable + | length tblList <= 4000 = fmap (\tbl -> "Perhaps you meant the table '" <> schema <> "." <> tbl <> "'") perhapsTable + | otherwise = Nothing where perhapsTable = Fuzzy.getOne fuzzyTableSet tblName fuzzyTableSet = Fuzzy.fromList [ tableName tbl | tbl <- tblList, tableSchema tbl == schema]