From 1a4314c31bfac01c40a03a062054d9cf35badaf7 Mon Sep 17 00:00:00 2001 From: ncabatoff Date: Fri, 10 May 2019 13:26:01 -0400 Subject: [PATCH] Since the two branches of the UNION produce disjoint sets, do a UNION ALL (#6546) This obviates the need for a sort/eliminate duplicates step, giving a performance boost in some key distributions with large datasets. --- physical/postgresql/postgresql.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physical/postgresql/postgresql.go b/physical/postgresql/postgresql.go index 79d68d4c77..013eae624c 100644 --- a/physical/postgresql/postgresql.go +++ b/physical/postgresql/postgresql.go @@ -157,7 +157,7 @@ func NewPostgreSQLBackend(conf map[string]string, logger log.Logger) (physical.B get_query: "SELECT value FROM " + quoted_table + " WHERE path = $1 AND key = $2", delete_query: "DELETE FROM " + quoted_table + " WHERE path = $1 AND key = $2", list_query: "SELECT key FROM " + quoted_table + " WHERE path = $1" + - " UNION SELECT DISTINCT substring(substr(path, length($1)+1) from '^.*?/') FROM " + quoted_table + + " UNION ALL SELECT DISTINCT substring(substr(path, length($1)+1) from '^.*?/') FROM " + quoted_table + " WHERE parent_path LIKE $1 || '%'", haGetLockValueQuery: // only read non expired data