Opened 6 years ago

Closed 6 years ago

#4286 closed defect (invalid)

Problem for generating statistics for 3D geometries

Reported by: ezimanyi Owned by: pramsey
Priority: medium Milestone: PostGIS 2.5.2
Component: postgis Version: 2.4.x
Keywords: Cc:

Description

Statistics for 3D geometries are not collected. The problem can be reproduced with the following script.


CREATE OR REPLACE FUNCTION random_float(low float, high float)

RETURNS float AS $$

BEGIN

RETURN random()* (high-low + 1) + low;

END; $$ LANGUAGE 'plpgsql' STRICT;

CREATE OR REPLACE FUNCTION random_geompoint(lowx float, highx float,

lowy float, highy float) RETURNS geometry AS $$

BEGIN

RETURN st_point(random_float(lowx, highx), random_float(lowy, highy));

END; $$ LANGUAGE 'plpgsql' STRICT;

CREATE OR REPLACE FUNCTION random_geompoint3D(lowx float, highx float,

lowy float, highy float, lowz float, highz float) RETURNS geometry AS $$

BEGIN

RETURN st_makepoint(random_float(lowx, highx), random_float(lowy, highy), random_float(lowz, highz));

END; $$ LANGUAGE 'plpgsql' STRICT;


drop table if exists test_point; create table test_point ( pt geometry(Point) );

insert into test_point select random_geompoint(1, 1000, 1, 1000) from generate_series(1,100);

vacuum analyze test_point;

select stanumbers1, stanumbers2 from pg_statistic where starelid = (select relfilenode from pg_class where relname = 'test_point');

— "{2,4,4,0,0,31.6331,0.643264,0,0,997.588,1005.19,0,0,100,100,100,100,16,100,3,8,4,9,5,7,6,7,6,4,8,2,8,7,12,4}"; — "{2,4,4,0,0,31.6331,0.643264,0,0,997.588,1005.19,0,0,100,100,100,100,16,100,3,8,4,9,5,7,6,7,6,4,8,2,8,7,12,4}"


drop table if exists test_point3D; create table test_point3D ( pt geometry(PointZ) );

insert into test_point3D select random_geompoint3D(1, 1000, 1, 1000, 1, 1000) from generate_series(1,100);

select st_astext(pt) from test_point3D;

vacuum analyze test_point3D;

select stanumbers1, stanumbers2 from pg_statistic where starelid = (select relfilenode from pg_class where relname = 'test_point3D');

— EMPTY


Change History (2)

comment:1 by pramsey, 6 years ago

I'm afraid you now owe me a beer, I went to the debugger and spent a few hours on this and it all works. The problem is your test.

select stanumbers1, stanumbers2 from pg_statistic where starelid = (select relfilenode from pg_class where relname = 'test_point3d');

Note the case of 'test_point3d'

comment:2 by pramsey, 6 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.