.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
-.\" $Header: /cvsroot/pgsql/src/man/Attic/create_operator.l,v 1.1 1996/11/14 10:15:58 scrappy Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/create_operator.l,v 1.2 1996/11/30 04:56:18 momjian Exp $
.TH "CREATE OPERATOR" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
create operator \(em define a new user operator
is a sequence of up to sixteen punctuation characters. The following
characters are valid for single-character operator names:
.nf
+
+.ce 1
~ ! @ # % ^ & ` ?
+
.fi
If the operator name is more than one character long, it may consist
of any combination of the above characters or the following additional
characters:
.nf
+
+.ce 1
| $ : + - * / < > =
+
.fi
+The operator "!=" is mapped to "<>" on input, and they are
+therefore equivalent.
.PP
At least one of
.IR leftarg
exists, as well as an area not equal, !==. Hence, the query optimizer
could freely convert:
.nf
+
+.ce 1
"0,0,1,1"::box >>> MYBOXES.description
+
.fi
to
.nf
+
+.ce 1
MYBOXES.description <<< "0,0,1,1"::box
+
.fi
This allows the execution code to always use the latter representation
and simplifies the query optimizer somewhat.
.PP
The negator operator allows the query optimizer to convert
.nf
-not MYBOXES.description === "0,0,1,1"::box
+
+.ce 1
+NOT MYBOXES.description === "0,0,1,1"::box
+
.fi
to
.nf
+
+.ce 1
MYBOXES.description !== "0,0,1,1"::box
+
.fi
If a commutator operator name is supplied, Postgres searches for it in
the catalog. If it is found and it does not yet have a commutator
strategy is applicable. For example, a hash-join algorithm is usable
for a clause of the form:
.nf
+
+.ce 1
MYBOXES.description === MYBOXES2.description
+
.fi
but not for a clause of the form:
.nf
+
+.ce 1
MYBOXES.description <<< MYBOXES2.description.
+
.fi
The
.BR hashes
the optimizer must sort both relations using the operator, <<<. On
the other hand, merge-sort is not usable with the clause:
.nf
+
+.ce 1
MYBOXES.description <<< MYBOXES2.description
+
.fi
If other join strategies are found to be practical, Postgres will change
the optimizer and run-time system to use them and will require
The last two pieces of the specification are present so the query
optimizer can estimate result sizes. If a clause of the form:
.nf
+
+.ce 1
MYBOXES.description <<< "0,0,1,1"::box
+
.fi
is present in the qualification, then Postgres may have to estimate the
fraction of the instances in MYBOXES that satisfy the clause. The
.IR "define function" (l))
which accepts one argument of the correct data type and returns a
floating point number. The query optimizer simply calls this
-function, passing the parameter
-.nf
-"0,0,1,1"
-.fi
+function, passing the parameter "0,0,1,1"
and multiplies the result by the relation size to get the desired
expected number of instances.
.PP
.PP
The difference between the function
.nf
+
+.ce 1
my_procedure_1 (MYBOXES.description, "0,0,1,1"::box)
+
.fi
and the operator
.nf
+
+.ce 1
MYBOXES.description === "0,0,1,1"::box
+
.fi
is that Postgres attempts to optimize operators and can decide to use an
index to restrict the search space when operators are involved.