mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Support ORDER BY ... NULLS FIRST/LAST, and add ASC/DESC/NULLS FIRST/NULLS LAST
per-column options for btree indexes. The planner's support for this is still pretty rudimentary; it does not yet know how to plan mergejoins with nondefault ordering options. The documentation is pretty rudimentary, too. I'll work on improving that stuff later. Note incompatible change from prior behavior: ORDER BY ... USING will now be rejected if the operator is not a less-than or greater-than member of some btree opclass. This prevents less-than-sane behavior if an operator that doesn't actually define a proper sort ordering is selected.
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.218 2007/01/05 22:19:42 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.219 2007/01/09 02:14:14 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -5101,7 +5101,7 @@ btcostestimate(PG_FUNCTION_ARGS)
|
||||
|
||||
if (get_attstatsslot(tuple, InvalidOid, 0,
|
||||
STATISTIC_KIND_CORRELATION,
|
||||
index->ordering[0],
|
||||
index->fwdsortop[0],
|
||||
NULL, NULL, &numbers, &nnumbers))
|
||||
{
|
||||
double varCorrelation;
|
||||
@ -5116,6 +5116,23 @@ btcostestimate(PG_FUNCTION_ARGS)
|
||||
|
||||
free_attstatsslot(InvalidOid, NULL, 0, numbers, nnumbers);
|
||||
}
|
||||
else if (get_attstatsslot(tuple, InvalidOid, 0,
|
||||
STATISTIC_KIND_CORRELATION,
|
||||
index->revsortop[0],
|
||||
NULL, NULL, &numbers, &nnumbers))
|
||||
{
|
||||
double varCorrelation;
|
||||
|
||||
Assert(nnumbers == 1);
|
||||
varCorrelation = numbers[0];
|
||||
|
||||
if (index->ncolumns > 1)
|
||||
*indexCorrelation = - varCorrelation * 0.75;
|
||||
else
|
||||
*indexCorrelation = - varCorrelation;
|
||||
|
||||
free_attstatsslot(InvalidOid, NULL, 0, numbers, nnumbers);
|
||||
}
|
||||
ReleaseSysCache(tuple);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user