Why optimize

Optimizing data reduces the time the system is ready to perform search after the web page loads. This is accomplished by reducing the amount of <location> data entered into the system at startup. Optimization is recommended for systems containing 200 to 1000 records.

 
How it works

Partial location data is entered into the system using the batch method, similar to the description in the last section 3.4.2. Only the fields needed to perform a search are installed at startup. For example: The system is to be configured to search by city and state only; then only the id, city, and state attributes are set using a partial batch of locations.

To optimize data, the <locations_batch> tag contains one additional source attribute. The source attribute value contains the name of the XML data file containing full <location> data. Full location data is only loaded after a search is performed and restricted to the found set.

Figure 3.4.3a below shows how the source attribute is used. The file named locations_MA.xml will contain all the attributes for <location>s with id 9,10,11, and 12. The file containing full data was configured using individual <location> tags as described in section 3.4.1. Note that the format attribute value has been reduced to only specify the id, city, and state_code.

<locations_batch format="id:city:state_code" source="locations_MA.xml" ><![CDATA[


|9:Shattuckville:MA|
|10:Wendell Depot:MA|
|11:Pepperell:MA|
|12:North Brookfield:MA|


]]></locations_batch>

Fig 3.4.3a Example optimized location batch

The above example would not allow searching by distance from a zip code since the data does not include the latitude and longitude coordinates. Adding the lat and lon in the format attribute and the corresponding coordinates in the data would enable distance searches.

 
Data management

The file containing optimized data would contain many <locations_batch> tags, one for each unique source file. Grouping method is a personal choice. Setting up one file containing full location data per state is one possible method. Such organization would allow better file/data management when updating information.

Optimizing data requires special attention when updating records. For example: A city name was entered with a letter missing. The file containing full <location> data was corrected. One must also correct data in the file containing <locations_batch> where the same city name resides.

 
Optimized locations XML file
The XML file containing optimized locations will be quite small. Most applications would result in a file smaller than 125 kilobytes, typically under 50 kilobytes for 1000 records. Name this single file locations_opt.xml and place it in the locations folder.
 
Configuring the startup XML file
Only the file containing optimized locations is set to load at startup. One line of code is required in the startup XML file as shown in figure 3.4.3b below.

<loadlocations source="locations_opt.xml" />

Fig 3.4.3b Loading of optimized locations
 
MT1207 Application <locations_batch>
AttributeValues / Range Default 1 Notes
format text   2
source text   3
Notes
  1. Default value persists if attribute is omitted from tag.
  2. Colon delimited list of attribute names. The id attribute must be first.
  3. Name of file containing full location data. Specifying source enables optimization.
Table 3.4.3c Tag Reference