The engineering team at Bubble encountered a challenge with slow custom-sorted searches on large tables, even with a b-tree index on the column used for sorting. They noticed that Postgres's ability to use indexes for sort operations is limited by its need to know the exact order of entries in the index will satisfy the requested sort order. The team solved this problem by performing a preliminary search to find the 10th highest score, using an inequality constraint to filter results based on this value. This approach allows them to take advantage of Postgres's indexing capabilities while still achieving performance comparable to a highly-specific index tailored for that particular search.