Subject: Question on R-trees

From: [email-masked]
Date: Thu, 15 Dec 1994 10:22:34 -0500

Hi,

Got a couple of questions on R-trees on Postgres:

Suppose I have a relation and index defined as :

create rel1 (code = int4, bound = box)\g
define index rel1ind on rel1 using rtree (bound box_ops)\g

(1) Does it mean that everytime I query using the box operation (like <<, &<
    etc.) the Rtree will be used to access the tuples? Can I force the
    system to use the Rtree?

(2) Will the output be ordered in anyway beacuase of the use of the index?
    I try to run a couple of querys and the output is ordered as the order
    of inputting them. Is it supposed to be that way?

(3) (A dumb question), for the box datatype, is a box constant specified
    by : "(xlow, ylow, xhigh, yhigh)"::box ?

Thanks a lot

David Lin

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "[email-masked]".
   If this fails, send mail to "[email-masked]" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
              URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres/

---

From: Mike Olson <[email-masked]>
Date: Thu, 15 Dec 94 08:52:08 -0800

>     etc.) the Rtree will be used to access the tuples? Can I force the

the query optimizer decides whether or not to use the index, based on
the expected size of the result set.  if the table is very small, then
using the index will be purely overhead, since you'll likely have to
touch every page in both the index and the base table.

if the table's large, then in general, postgres will (correctly) choose
to use the index.

>     of inputting them. Is it supposed to be that way?

rtrees return data in an order that makes no sense to the user.  it
depends on the input order, the spatial distribution of boxes, and
the query rectangle.  don't try to figure it out.

>     by : "(xlow, ylow, xhigh, yhigh)"::box ?

yes.

> Thanks a lot

no problem, it was kind of fun.
					mike