Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 918eee0

Browse files
committed
Collect and use histograms of lower and upper bounds for range types.
This enables selectivity estimation of the <<, >>, &<, &> and && operators, as well as the normal inequality operators: <, <=, >=, >. "range @> element" is also supported, but the range-variant @> and <@ operators are not, because they cannot be sensibly estimated with lower and upper bound histograms alone. We would need to make some assumption about the lengths of the ranges for that. Alexander's patch included a separate histogram of lengths for that, but I left that out of the patch for simplicity. Hopefully that will be added as a followup patch. The fraction of empty ranges is also calculated and used in estimation. Alexander Korotkov, heavily modified by me.
1 parent 6bb0b08 commit 918eee0

File tree

9 files changed

+881
-32
lines changed

9 files changed

+881
-32
lines changed

src/backend/utils/adt/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ OBJS = acl.o arrayfuncs.o array_selfuncs.o array_typanalyze.o \
3030
tsginidx.o tsgistidx.o tsquery.o tsquery_cleanup.o tsquery_gist.o \
3131
tsquery_op.o tsquery_rewrite.o tsquery_util.o tsrank.o \
3232
tsvector.o tsvector_op.o tsvector_parser.o \
33-
txid.o uuid.o windowfuncs.o xml.o rangetypes_spgist.o
33+
txid.o uuid.o windowfuncs.o xml.o rangetypes_spgist.o \
34+
rangetypes_typanalyze.o rangetypes_selfuncs.o
3435

3536
like.o: like.c like_match.c
3637

src/backend/utils/adt/rangetypes.c

-17
Original file line numberDiff line numberDiff line change
@@ -1228,23 +1228,6 @@ hash_range(PG_FUNCTION_ARGS)
12281228
PG_RETURN_INT32(result);
12291229
}
12301230

1231-
/* ANALYZE support */
1232-
1233-
/* typanalyze function for range datatypes */
1234-
Datum
1235-
range_typanalyze(PG_FUNCTION_ARGS)
1236-
{
1237-
/*
1238-
* For the moment, just punt and don't analyze range columns. If we get
1239-
* close to release without having a better answer, we could consider
1240-
* letting std_typanalyze do what it can ... but those stats are probably
1241-
* next door to useless for most activity with range columns, so it's not
1242-
* clear it's worth gathering them.
1243-
*/
1244-
PG_RETURN_BOOL(false);
1245-
}
1246-
1247-
12481231
/*
12491232
*----------------------------------------------------------
12501233
* CANONICAL FUNCTIONS

0 commit comments

Comments
 (0)