mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Create a "sort support" interface API for faster sorting.
This patch creates an API whereby a btree index opclass can optionally provide non-SQL-callable support functions for sorting. In the initial patch, we only use this to provide a directly-callable comparator function, which can be invoked with a bit less overhead than the traditional SQL-callable comparator. While that should be of value in itself, the real reason for doing this is to provide a datatype-extensible framework for more aggressive optimizations, as in Peter Geoghegan's recent work. Robert Haas and Tom Lane
This commit is contained in:
@ -1830,6 +1830,25 @@ timestamp_cmp(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(timestamp_cmp_internal(dt1, dt2));
|
||||
}
|
||||
|
||||
/* note: this is used for timestamptz also */
|
||||
static int
|
||||
timestamp_fastcmp(Datum x, Datum y, SortSupport ssup)
|
||||
{
|
||||
Timestamp a = DatumGetTimestamp(x);
|
||||
Timestamp b = DatumGetTimestamp(y);
|
||||
|
||||
return timestamp_cmp_internal(a, b);
|
||||
}
|
||||
|
||||
Datum
|
||||
timestamp_sortsupport(PG_FUNCTION_ARGS)
|
||||
{
|
||||
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
|
||||
|
||||
ssup->comparator = timestamp_fastcmp;
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
Datum
|
||||
timestamp_hash(PG_FUNCTION_ARGS)
|
||||
{
|
||||
|
Reference in New Issue
Block a user