Happy, or even better, Merry #MapInfoMonday to you all!
A final Tip & Trick before the Holidays. This time I'll give you a few tips on how you can analyze potential performance issues when loading a workspace into MapInfo Pro.
Potential issues
A workspace is a plain text file containing a set of MapBasic statements that open tables, run queries, create maps, configure layers, create layouts, and open browsers windows. Basically. A workspace stores your current session in MapInfo Pro into a file which makes it possible for you to later restore this session.
Some of the typical issues that we see users run into when they experience MapInfo Pro takes an unexpectedly long time opening a workspace are:
- Printer Settings: Workspaces can contain references to printers and paper sizes. If a referenced printer has been removed from the network, MapInfo Pro might spend some time trying to locate that printer.
- Queries: If you save your workspace after having executed a number of queries and the resulting query tables still are open in MapInfo Pro, these query statements will be maintained in the workspace if possible.
- Access to data: If the data referenced by the workspace is located on a network drive with slow access times, MapInfo Pro can take a while to access this data. The same goes for live access to database tables.
- Generating preview for raster files: When opening raster files of a format supported by MapInfo Raster, the raster engine will generate a set of cache files (typically .pprc and .ghx files) for better performance. If the raster files live in a read-only folder, these cache files are created in your temp folder every time you open the files, slowing down the process.
- Map rendering: very complex maps can take a while to render, and having many map windows will take longer to get rendered than fewer map windows.
The list above is just to give you some idea of where MapInfo Pro could be spending time when loading a workspace. The could also be other causes for potential slowness. In most cases, you will not be seeing any issues.
The easy fixes
The quick fix here is to start turning off using some of the settings from the workspace. Here there is one setting that quickly can tell you if the problem lies with your printers.
The startup preference, found on the backstage via the Pro tab, Options, lets you set MapInfo Pro up to ignoring Printer Settings in workspaces.
If you are seeing a longer load time for your workspaces, try to disable this option in the Startup Preferences dialog: Restore Printer Information from Workspace.
If this solves the issues, you should open the workspace and change the printers used for your windows, and save the workspace again with these new printers.
If unchecking this option doesn't improve the load time, you might want to analyze where MapInfo Pro is spending the time. I will show you how you can do this below.
Analyzing Workspace Load Time
As I mentioned before, a workspace holds a number of MapBasic statements. This also means that you can add additional MapBasic statements to the workspace that can help you identify where the additional time is being spent.
The idea is to add a number of statements to the workspace file that prints out a bit of information as MapInfo Pro reads through the workspace file. It is printed with a timestamp to the Message window and will give you an idea of where the time is spent.
The MapBasic statement looks a bit like this:
Print Time(24) + " Opening tables..."
It contains three parts:
- Print: a MapBasic statement that tells MapInfo Pro to write something into the Message window.
- Time(24): a MapBasic function that creates a timestamp like "13:01:24" using the current time
- + " Opening tables...": A variable string that tells you afterward what's going on in the workspace. You will modify this part to the different parts of the workspace.
As you will be modifying the workspace, I will suggest that you create a copy of the workspace using Windows File Explorer and that you use this copy for the analysis. In this way, your original workspace will be left intact.
You can open the workspace file in your favorite text editor and make the adjustments here.
Here are some lines from a workspace file:
!Workspace
!Version 1900
!Charset UTF-8
Open Table "Addresses" As Addresses Interactive
Open Table "Nature Conservation Areas" As Nature_Conservation_Areas Interactive
Open Table "Nature Conservation Areas Proposals" As Nature_Conservation_Areas_Prop Interactive
Open Table "Planning Zones" As Planning_Zones Interactive
Open Table "Planning Zones Proposal" As Planning_Zones_Proposal Interactive
Open Table "Parcels" As Parcels Interactive
Open Table "DTK Skærmkort.TAB" As DTK_Skærmkort Interactive
Open Table "Streets" As Streets Interactive
Select * from Parcels as "p" where p . ESR_EJDNR = 8400005654 into Query3
Select p . * , CartesianBuffer ( p . Obj , 32 , 10 , "m" ) object from Parcels as "p" where p . ESR_EJDNR = 8400005654 into Query4
Select p . * , CartesianBuffer ( p . Obj , 32 , 10 , "m" ) object from Parcels as "p" where p . ESR_EJDNR = 8400005654 into Query5
Select p . ESR_EJDNR , aggregatebuffer ( p . Obj , 32 , 10 , "m" ) from Parcels as "p" where p . ESR_EJDNR = 8400005654 into Query6 group by p . ESR_EJDNR
Map From Addresses,Streets,Query6,Nature_Conservation_Areas_Prop
,Nature_Conservation_Areas,Planning_Zones_Proposal,Planning_Zones,Parcels,DTK_Skærmkort
Position (0.75,2.45833) Units "in"
Width 9.89167 Units "in" Height 4.45833 Units "in"
Set Window FrontWindow() ScrollBars Off Autoscroll On Enhanced On Smooth Text Antialias Image High Vector Antialias
Set Map
CoordSys Earth Projection 8, 115, "m", 9, 0, 0.9996, 500000, 0
Center (547766.2685,6303441.682)
Zoom 1564.794702 Units "m"
Preserve Zoom Display Zoom
Distance Units "m" Area Units "hectare" XY Units "m"
Distance Type Cartesian
Set Map
Layer 1
Display Global
Global Pen (1,2,22015) Brush (1,16777215,16777215) Symbol (32,14708736,4,"MapInfo Symbols",0,0) Line (2,2,22015) Font ("Arial",0,8,8421504)
Selectable Off
Override Add "Layer Display Override" Zoom (0, 5000) Units "m" Enable On
Override Add "Layer Display Override" Zoom (5000, 50000) Units "m" Enable On
Symbol (35,8421504,4,"MapInfo Symbols",0,0)
Label Line Arrow Position Center Font ("Arial",256,7,0,16777215) Pen (1,2,0)
With StreetBuildingIdentifier
Parallel On Auto On Overlap Off Duplicates On Offset 2
Visibility Zoom (0, 5000) Units "m"
Layer 2
Display Graphic ...
In the example below, you can see that I have inserted a couple of statements that help me analyze how long time MapInfo Pro is using to load the individual parts of the workspace:
!Workspace
!Version 1900
!Charset UTF-8
Print Time(24) + " Opening tables..."
Open Table "Addresses" As Addresses Interactive
Open Table "Nature Conservation Areas" As Nature_Conservation_Areas Interactive
Open Table "Nature Conservation Areas Proposals" As Nature_Conservation_Areas_Prop Interactive
Open Table "Planning Zones" As Planning_Zones Interactive
Open Table "Planning Zones Proposal" As Planning_Zones_Proposal Interactive
Open Table "Parcels" As Parcels Interactive
Open Table "DTK Skærmkort.TAB" As DTK_Skærmkort Interactive
Open Table "Streets" As Streets Interactive
Print Time(24) + " Running Queries..."
Select * from Parcels as "p" where p . ESR_EJDNR = 8400005654 into Query3
Select p . * , CartesianBuffer ( p . Obj , 32 , 10 , "m" ) object from Parcels as "p" where p . ESR_EJDNR = 8400005654 into Query4
Select p . * , CartesianBuffer ( p . Obj , 32 , 10 , "m" ) object from Parcels as "p" where p . ESR_EJDNR = 8400005654 into Query5
Select p . ESR_EJDNR , aggregatebuffer ( p . Obj , 32 , 10 , "m" ) from Parcels as "p" where p . ESR_EJDNR = 8400005654 into Query6 group by p . ESR_EJDNR
Print Time(24) + " Creating a map..."
Map From Addresses,Streets,Query6,Nature_Conservation_Areas_Prop
,Nature_Conservation_Areas,Planning_Zones_Proposal,Planning_Zones,Parcels,DTK_Skærmkort
Position (0.75,2.45833) Units "in"
Width 9.89167 Units "in" Height 4.45833 Units "in"
Set Window FrontWindow() ScrollBars Off Autoscroll On Enhanced On Smooth Text Antialias Image High Vector Antialias
Print Time(24) + " Configuring the map..."
Set Map
CoordSys Earth Projection 8, 115, "m", 9, 0, 0.9996, 500000, 0
Center (547766.2685,6303441.682)
Zoom 1564.794702 Units "m"
Preserve Zoom Display Zoom
Distance Units "m" Area Units "hectare" XY Units "m"
Distance Type Cartesian
Print Time(24) + " Configuring the layers..."
Set Map
Layer 1
Display Global
Global Pen (1,2,22015) Brush (1,16777215,16777215) Symbol (32,14708736,4,"MapInfo Symbols",0,0) Line (2,2,22015) Font ("Arial",0,8,8421504)
Selectable Off
Override Add "Layer Display Override" Zoom (0, 5000) Units "m" Enable On
Override Add "Layer Display Override" Zoom (5000, 50000) Units "m" Enable On
Symbol (35,8421504,4,"MapInfo Symbols",0,0)
Label Line Arrow Position Center Font ("Arial",256,7,0,16777215) Pen (1,2,0)
With StreetBuildingIdentifier
Parallel On Auto On Overlap Off Duplicates On Offset 2
Visibility Zoom (0, 5000) Units "m"
Layer 2
Display Graphic ...
Finally, you should also add a statement at the end of the workspace so that you can see the total load time.
Save the changes to the workspace file in your text editor, and load the workspace file in MapInfo Pro.
As the workspace file is being loaded, you should see text appear in the Message window similar to what you can see below.
In my example, you can see it took MapInfo Pro one second to load the workspace. It can take a bit longer before all the windows have been rendered to the screen.
As you work your way through the analysis, it can be necessary to add more statements. If you for example learn that MapInfo Pro is taking a long time opening the tables, you might want to add more statements between the individual tables to figure what specific table(s) is/are the main problem.
Please note that you can't insert these additional lines anywhere in the workspace. You need to make sure they aren't inserted in the middle of an existing statement as that will break the workspace. As a rule of thumb only add statements before a line that hasn't been indented.
I hope this gives you a few ideas on how to pin down potential performance issues you might have when loading workspaces into MapInfo Pro.
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
------------------------------