https://github.com/postgres/postgres/blob/master/contrib/cube/sql/cube.sql
Last active
October 23, 2020 11:01
-
-
Save duyleekun/ea1b035afb32e78f7a04ec7be0bf0047 to your computer and use it in GitHub Desktop.
postgres cube test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To increase the limit of CUBE_MAX_DIM DIMM | |
# Run inside docker | |
export PG_VER=13.0 | |
apt-get install -y unzip gcc make zlib1g-dev libreadline-dev postgresql-server-dev-${PG_VER%.*} bison flex wget | |
wget https://ftp.postgresql.org/pub/source/v${PG_VER}/postgresql-${PG_VER}.tar.bz2 --quiet -O postgresql.tar.bz2 | |
tar xvf postgresql.tar.bz2 | |
cd postgresql-${PG_VER} | |
./configure | |
cd contrib/cube | |
sed -i 's/#define CUBE_MAX_DIM (100)/#define CUBE_MAX_DIM (500)/' cubedata.h | |
make USE_PGXS=1 | |
sudo make USE_PGXS=1 install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create database duy; | |
create extension cube; | |
create table duytest | |
( | |
id serial | |
constraint duytest_pk | |
primary key, | |
cu cube not null | |
); | |
create index duytest_gist on duytest using gist(cu); | |
insert into duytest (cu) values (cube('(1,2,3)') ); | |
insert into duytest (cu) values (cube('(1,2,4)') ); | |
insert into duytest (cu) values (cube('(1,2,5)') ); | |
explain analyse select * from duytest order by cu <-> cube(array[1,2,9]) limit 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment