Re: GiST rtree logic is not right

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: GiST rtree logic is not right
Date: 2005-06-23 14:04:07
Message-ID: 4575.1119535447@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Oleg Bartunov <oleg(at)sai(dot)msu(dot)su> writes:
> something is broken in HEAD. I recall it worked in STABLE, here is what I have

No, actually it is broken in 8.0 too. The difference is that 8.0
defaults to not using an indexscan for this query. In 8.0 I see:

regression=# set enable_seqscan TO 1;
SET
regression=# explain select count(*) from gist_emp4000 where home_base << '(35565,5404),(35546,5360)';
QUERY PLAN
---------------------------------------------------------------------
Aggregate (cost=65.53..65.53 rows=1 width=0)
-> Seq Scan on gist_emp4000 (cost=0.00..64.75 rows=310 width=0)
Filter: (home_base << '(35565,5404),(35546,5360)'::box)
(3 rows)

regression=# select count(*) from gist_emp4000 where home_base << '(35565,5404),(35546,5360)';
count
-------
2214
(1 row)

regression=# set enable_seqscan TO 0;
SET
regression=# explain select count(*) from gist_emp4000 where home_base << '(35565,5404),(35546,5360)';
QUERY PLAN
----------------------------------------------------------------------------------------
Aggregate (cost=112.96..112.96 rows=1 width=0)
-> Index Scan using grect2ind on gist_emp4000 (cost=0.00..112.18 rows=310 width=0)
Index Cond: (home_base << '(35565,5404),(35546,5360)'::box)
(3 rows)

regression=# select count(*) from gist_emp4000 where home_base << '(35565,5404),(35546,5360)';
count
-------
2144
(1 row)

In CVS tip the default plan is:

regression=# explain select count(*) from gist_emp4000 where home_base << '(35565,5404),(35546,5360)';
QUERY PLAN
--------------------------------------------------------------------------------
Aggregate (cost=35.74..35.74 rows=1 width=0)
-> Bitmap Heap Scan on gist_emp4000 (cost=5.08..34.96 rows=310 width=0)
Recheck Cond: (home_base << '(35565,5404),(35546,5360)'::box)
-> Bitmap Index Scan on grect2ind (cost=0.00..5.08 rows=310 width=0)
Index Cond: (home_base << '(35565,5404),(35546,5360)'::box)
(5 rows)

regression=# select count(*) from gist_emp4000 where home_base << '(35565,5404),(35546,5360)';
count
-------
2144
(1 row)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-06-23 14:08:26 Re: GiST rtree logic is not right
Previous Message Dave Cramer 2005-06-23 12:42:31 HEAD initdb failing on OSX