queryByAttributes - speed

Zhonghai Wang zhonghaiw at GMAIL.COM
Tue Feb 27 09:59:58 EST 2007


Hi,

there is one way that may help you to speed them up. You can create another
intermidiate table in Oracle or PostGIS, which contains the indexed column
and the attribute column you are going to use for your queries in the
MapInfo table, use this table to convert the query attributes into the index
values in your MapInfo table, then you will get something you want.

Apparently, the best solution is what Bart has said. My suggestion is only
one possibility to solve your problem.

Regards

Zhonghai

On 2/27/07, Bart van den Eijnden (OSGIS) <bartvde at osgis.nl> wrote:
>
> Hi,
>
> I don't believe the Mapinfo attribute indexes are used by Mapserver/OGR.
> This is not implemented.
>
> So if you need performance, store your data in e.g. PostGIS instead if
> possible.
>
> Best regards,
> Bart
>
> --
> Bart van den Eijnden
> OSGIS, Open Source GIS
> http://www.osgis.nl
>
>
> --------- Oorspronkelijk bericht --------
> Van: Jeppe Lund Andersen <JXA at COWI.DK>
> Naar: MAPSERVER-USERS at LISTS.UMN.EDU <MAPSERVER-USERS at LISTS.UMN.EDU>
> Onderwerp: [UMN_MAPSERVER-USERS] queryByAttributes - speed
> Datum: 27/02/07 09:34
>
> > Hello all
> >
> > Iam running php mapscript on a windows 2003 server and when Iam using
> > queryByAttributes, but it take some time to perform the search.
> > It takes between 7-8 sek for this linie
> >
> > $Qry = @$Layer-&gt;queryByAttributes($ID_navn, '(' . $Search_Str .')',
> > $ResultType);
> >
> > The file iam using is a mapinfo file which has cadastral information.
> > there are 156612 records in the file and the coln iam searching in has
> > been index via mapifno.
> > the field is a text field
> >
> > Am I doing something wrong ?
> >
> > Jeppe
> >
> > here is the funktion that load the map and perform the search
> >
> > function FindExtendForMatrikel()
> > {
> >       global $GISREF_LAYER_NAME, $MAP_PATH_NAME, $MAP_FILE_NAME,
> > $MATRIKEL_ID_NAME;;
> >       global $xmin, $ymin, $xmax, $ymax;
> >       global $MATRIKEL_LAYER_NAME, $starttid, $kort;
> >       $Shape_matr = array();
> >
> >       $Result = mssql_query (&quot;select * from kort WHERE name =
> '&quot;.
> > $MATRIKEL_LAYER_NAME . &quot;'&quot;);
> >       while ($row = mssql_fetch_array($Result))
> >       {
> >               $Map = ms_newMapObj($MAP_FILE_NAME);
> >               $Layer = ms_newLayerObj($Map);
> >               $Layer-&gt;set('name', &quot;MatrikelSearchLayer&quot;);
> >               $Layer-&gt;set(&quot;connection&quot;,
> $row['MS_CONNECTION']);
> >               $Layer-&gt;set(&quot;connectiontype&quot;, MS_OGR);
> >               $Layer-&gt;set('status', MS_OFF);
> >               $Layer-&gt;set('type', MS_LAYER_POLYGON);
> >               $Layer-&gt;setProjection($row['MS_PROJECTION']);
> >               $Class = ms_newClassObj($Layer);
> >               $Class-&gt;set('name', &quot;Matrikler&quot;);
> >               $Class-&gt;set('template', 'void');
> >       }
> >
> >       foreach ($kort-&gt;objekter as $value)
> >       {
> >               if ($value-&gt;ObjType() == &quot;Matrikel&quot;)
> >               {
> >
> >                       $ID_value = $value-&gt;id;
> >                       $Layer =
> > $Map-&gt;getLayerByName(&quot;MatrikelSearchLayer&quot;);
> >                       //$ID_value = &quot;78065110g&quot;;
> >                       $ID_navn = $MATRIKEL_ID_NAME;
> >                       $ResultType = MS_MULTIPLE;
> >
> >                       $Search_Str = &quot;&quot;;
> >                       $matr_array = split(',', $ID_value);
> >
> >                       foreach ($matr_array as $matr)
> >                       {
> >                               if ($Search_Str != &quot;&quot;) {
> >                                       $Search_Str .= &quot; OR &quot;;
> >                               }
> >                               $Search_Str .= &quot; '[$ID_navn]' =
> '$matr'
> > &quot;;
> >                       }
> >
> >                       $Qry = @$Layer-&gt;queryByAttributes($ID_navn, '('
> > .. $Search_Str .')', $ResultType);
> >                       $QryRes = $Layer-&gt;getNumResults();
> >                       if ($QryRes == 0 ) { $kort-&gt;matrikelsogning =
> > NULL;}
> >
> >                       for ($I = 0; $I &lt; $QryRes; $I++)
> >                       {
> >                               $Res = $Layer-&gt;getResult($I);
> >                               $Layer-&gt;open();
> >                               $Shape_matr[] =
> > $Layer-&gt;getShape($Res-&gt;tileindex, $Res-&gt;shapeindex);
> >                               $Layer-&gt;close();
> >
> >                       }
> >               }
> >       }
> >
> > }
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20070227/70d15515/attachment.html


More information about the mapserver-users mailing list