Opened 16 years ago

Closed 14 years ago

#2605 closed enhancement (fixed)

Mapserver WFS should send maxfeatures to the spatial database

Reported by: bartvde Owned by: assefa
Priority: normal Milestone: 6.0 release
Component: WFS Server Version: unspecified
Severity: normal Keywords:
Cc: pramsey, sdlime, assefa, dmorissette

Description

Mapserver WFS should send the maxfeatures from the WFS request to the underlying spatial database. Now it will retrieve all the rows matching, and get rid of the additional rows, which is quite inefficient for certain situations.

Attachments (2)

limitpg.patch (4.1 KB ) - added by pramsey 16 years ago.
Patch for PostGIS
bug2605.zip (1.6 KB ) - added by assefa 14 years ago.

Download all attachments as: .zip

Change History (21)

by pramsey, 16 years ago

Attachment: limitpg.patch added

Patch for PostGIS

comment:1 by dmorissette, 16 years ago

FYI there is also ticket #2424 about more general support for MAXFEATURES in MapServer (and not just with WMS/WFS) that could benefit from this fix.

comment:2 by dmorissette, 16 years ago

Milestone: 5.2 release

comment:3 by dmorissette, 16 years ago

Milestone: 5.2 release5.4 release
Owner: changed from mapserverbugs to dmorissette

comment:4 by dmorissette, 15 years ago

Cc: pramsey sdlime added
Milestone: 5.4 release6.0 release

Paul, Steve, do the changes to the query stuff done at the Code Sprint help this in anyway? Would one of you want to take ownership of this ticket?

comment:5 by pramsey, 15 years ago

In trunk PostGIS should be respecting maxfeatures now. The sprint change should not alter this logic at all.

comment:6 by pramsey, 15 years ago

In Oracle it should also be pretty easy,

// Oracle
select col from tbl where rownum<=20;

comment:7 by dmorissette, 15 years ago

Cc: assefa added

Thanks for the info. From a quick browse of the code it seems that to enable this we'd need to update mapwfs.c to set layer->maxfeatures before calling the query.

comment:8 by pramsey, 15 years ago

Right, and I guess the key is to not over-ride maxfeatures if it's already set in the map file.

comment:9 by dmorissette, 15 years ago

Or if maxfeatures is already set then we override it only if the value from the WFS request is lower than the value set in the mapfile?

comment:10 by pramsey, 15 years ago

Yes, that seems a reasonable interpretation of user intent.

comment:11 by bartvde, 15 years ago

For Oracle this is an interesting article:

http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html

select *
  from 
(select * 
   from t 
  order by unindexed_column)
 where ROWNUM < :N;

comment:12 by assefa, 15 years ago

Cc: dmorissette added
Owner: changed from dmorissette to assefa

I will look into this one after the 5.6 release.

by assefa, 14 years ago

Attachment: bug2605.zip added

comment:13 by assefa, 14 years ago

Added a patch against trunk to set the maxfeatures on the layer object if available in the wfs request. Postgis already uses the maxfeatures to limit the search. Added support for the oracle driver.

comment:14 by bartvde, 14 years ago

Assefa, did you read the stuff in:

http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html

?

If I understand your patch correctly, it won't work correctly as yet, but I could be wrong.

comment:15 by assefa, 14 years ago

Bart,

From what I can see rownum<=N should allow to select the first N random records. From the tests I have done (oracle11) by setting the layer's maxfeatures in the map file or from wfs request, this is what is happening.

Is it possible to give it a try?

comment:16 by bartvde, 14 years ago

Assefa, but did you try combining it with another filter? My experience is that you will get far less records than the maxfeatures, since the rownum is applied too soon, even if the database has more records that match the filter.

comment:17 by assefa, 14 years ago

This is what I used to test the case with a filter:

FILTER " OGR_FID > 10" #I have 28 features in my layer

DATA "ORA_GEOMETRY FROM POPPLACE_MSAUTOTEST USING VERSION 10g"

if I do not set the MAXFEATURES on the layer, I get 18 records. IfvI set the maxfeatures to 10 , query looks something like this and returns 10 features:

SELECT rownum, OGR_FID, AREA, PERIMETER, POPPLACE_, POPPLACE_I, UNIQUE_KEY, NAME, NAME_E, NAME_F, UNIQUE_K_1, UNIQUE_K_2, REG_CODE, NTS50, LAT, LON, SGC_CODE, CAPITAL, POP_RANGE, ORA_GEOMETRY FROM POPPLACE_MSAUTOTEST WHERE OGR_FID > 10 AND ROWNUM<=10 AND SDO_FILTER( ORA_GEOMETRY, MDSYS.SDO_GEOMETRY(2003, :srid, NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),:ordinates ),'querytype=window') = 'TRUE'

Are there any particular tests I should add to see if there are problems?

comment:18 by assefa, 14 years ago

patch committed in r9593

comment:19 by bartvde, 14 years ago

Resolution: fixed
Status: newclosed

Tested for Oracle and it works fine.

Note: See TracTickets for help on using tickets.