CREATE TABLE mybox_tbl as ( select box(p,p) 
from (select point(random(), random()) p 
from generate_series(1,1000000)) x);


CREATE INDEX mybox_tbl_gist_index ON mybox_tbl USING gist (box);

SET enable_seqscan TO true;
SET enable_bitmapscan TO true;
SET enable_indexscan TO true;
SET enable_indexonlyscan TO false;

vacuum analyze mybox_tbl;
EXPLAIN ANALYZE
select box from mybox_tbl where box && box(point(0.5,0.5), point(0.6,0.6));
select box from mybox_tbl where box && box(point(0.5,0.5), point(0.6,0.6));

SET enable_seqscan TO false;
SET enable_bitmapscan TO false;
SET enable_indexscan TO false;
SET enable_indexonlyscan TO true;

vacuum analyze mybox_tbl;
EXPLAIN ANALYZE
select box from mybox_tbl where box && box(point(0.5,0.5), point(0.6,0.6));
select box from mybox_tbl where box && box(point(0.5,0.5), point(0.6,0.6));

RESET enable_seqscan;
RESET enable_bitmapscan;
RESET enable_indexscan;
RESET enable_indexonlyscan;


DROP INDEX mybox_tbl_gist_index;
DROP TABLE mybox_tbl;