[Mapserver-dev] Re: [Mapserver-users] Mapscript drawQuery() on
big PostGIS layers doesn't work properly ?
Paul Ramsey
pramsey at refractions.net
Wed Oct 15 14:55:04 EDT 2003
It is entirely possible that I am speaking out of my ass. Dave does what
you describe for WhichShapes and NextShape (yay!)
It is the msPOSTGISLayerGetShape function which does random access on
records, and for which we need to keep unique identifiers around.
It only appears to be called in a few contexts:
mapdraw.c: status = msLayerGetShape(layer, &shape,
layer->resultcache->results[i].tileindex,
layer->resultcache->results[i].shapeindex);
mapgml.c: status = msLayerGetShape(lp, &shape,
lp->resultcache->results[j].tileindex,
lp->resultcache->results[j].shapeindex);
mapgml.c: status = msLayerGetShape(lp, &shape,
mapquery.c: status = msLayerGetShape(lp, &shape, tileindex, shapeindex);
mapquery.c: status = msLayerGetShape(slp, &selectshape,
slp->resultcache->results[i].tileindex,
slp->resultcache->results[i].shapeindex);
mapswf.c: msLayerGetShape(layer, &shape, -1, shapeidx);
maptemplate.c: status = msLayerGetShape(lp,
&(msObj->ResultShape), lp->resultcache->results[0].tileindex,
lp->resultcache->results[0].shapeindex);
maptemplate.c: status = msLayerGetShape(lp, &(msObj->ResultShape),
lp->resultcache->results[j].tileindex,
lp->resultcache->results[j].shapeindex);
mapwms.c: if (msLayerGetShape(lp, &shape,
lp->resultcache->results[j].tileindex,
lp->resultcache->results[j].shapeindex) != MS_SUCCESS)
I am trying to talk back through the code to see if these calls iterate,
but if they do, that would be ... slow.
P.
Daniel Morissette wrote:
> Paul Ramsey wrote:
>
>> David Blasby wrote:
>>
>>> Whats happening is that postgresql is using the spatial index (which
>>> presumably returns the entire layer), then does a sequencial scan to
>>> find the rows with the "filter" attributes.
>>
>>
>>
>> Incidentally, it is worth pointing out that the currect behavior for
>> query functionality is almost painfully unsuited to database backends.
>> The shapefile heritage really shows through in the query workflow,
>> which if I am not mistaken is "tell me the record numbers of all
>> records of interest (that match the criteria)", "give me record 1",
>> "give me record 2", etc. To emulate this, we do exactly as asked. Give
>> the list of record numbers (unique ids in our case) and then perform
>> repeated queries -- the opposite of efficient, given the capabilities
>> of the backend. Obviously it would be preferable to turn the query
>> into a single resultset and then scroll through it, once.
>>
>
> I may be wrong since it was a while since I played in that part of
> MapServer, but I think it should be possible for the postgis driver to
> do what you suggest. If I remember correctly that's more or less the
> way the OGR driver works. When a layer is drawn or a query is done, the
> following happens:
>
> msLayerWhichShapes() is called to initialize the query. In the case of
> shapefiles this means retrieving the list of shapeIds, but in the case
> of PostGIS it could be just performing the query to the DB. I believe
> that's what msPOSTGISLayerWhichShapes() does today.
>
> Then msLayerNextShape() is called until there are no more shapes to
> read. The postgis implementation of this could simply scroll through
> the resultset that was created in msLayerWhichShapes().
>
> Daniel
--
__
/
| Paul Ramsey
| Refractions Research
| Email: pramsey at refractions.net
| Phone: (250) 885-0632
\_
More information about the mapserver-dev
mailing list