this_is_a_hack.patch

application/octet-stream

Filename: this_is_a_hack.patch
Type: application/octet-stream
Part: 0
Message: Re: [BUGS] BUG #11500: PRIMARY KEY index not being used

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/optimizer/util/pathnode.c 12 0
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
index b0da28150d3..cd3922fbf03 100644
--- a/src/backend/optimizer/util/pathnode.c
+++ b/src/backend/optimizer/util/pathnode.c
@@ -562,6 +562,18 @@ add_path(RelOptInfo *parent_rel, Path *new_path)
 									remove_old = true;	/* new dominates old */
 								else if (new_path->rows > old_path->rows)
 									accept_new = false; /* old dominates new */
+								else if (IsA(new_path, IndexPath) && IsA(old_path, IndexPath) &&
+										((IndexPath *) new_path)->indexinfo->unique == true &&
+										((IndexPath *) old_path)->indexinfo->unique == false)
+								{
+									remove_old = true;
+								}
+								else if (IsA(new_path, IndexPath) && IsA(old_path, IndexPath) &&
+										((IndexPath *) new_path)->indexinfo->unique == false &&
+										((IndexPath *) old_path)->indexinfo->unique == true)
+								{
+									accept_new = false;
+								}
 								else if (compare_path_costs_fuzzily(new_path,
 																	old_path,
 																	1.0000000001) == COSTS_BETTER1)