Do not use index without limit or if limit + offset > expected tuples

This commit is contained in:
Andrew Kane
2024-01-20 15:16:30 -08:00
parent 042ddfdc8a
commit 63c4af0454
23 changed files with 177 additions and 45 deletions

View File

@@ -83,8 +83,11 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
List *qinfos;
#endif
/* Never use index without order */
if (path->indexorderbys == NULL)
/*
* Never use index without order or limit, or if limit + offset >
* ef_search
*/
if (path->indexorderbys == NULL || root->limit_tuples < 0 || root->limit_tuples > hnsw_ef_search)
{
*indexStartupCost = DBL_MAX;
*indexTotalCost = DBL_MAX;