Calculate the Cost and Determine the Final Access Plan

With the access plan for each permutation established (see Calculate the Table Order Permutations), the Query Processor can begin calculating the cost of each access plan. The cost is the demand the access plan will place on system resources - the access plan with the highest cost is the least efficient and the access plan with the lowest cost is the most efficient (and will be used by the Query Processor for your query).

As part of its calculation for the costs, the Query Processor considers the type of table being searched and the type of access path being used (Scan, Non-Unique Lookup, or Unique Lookup):

Table Type

Scan Cost

Non-Unique Lookup Cost

Unique Lookup Cost

Object

Database item count/100

Average number of items per group

Or:

Number of items in search map

1

Aggregate

Aggregate count/100

1

1

Alarm Condition

Number of items that can have alarms/33

1

1

Event Journal

Total number of records

Average number of records per database item

1

Point Historic

-

Average number of records per database point

1

Processed Historic

-

Average number of records per database point

1

Forecast Historic

-

100

1

Data Grid

Number of rows in Data Grid

-

1

Data Table

Number of rows in Data Table

Number of rows in Data Table

1

When considering the cost and Final Access Plan, you need to be aware that:

When the cost of each access plan has been calculated, the Query Processor chooses the access plan with the lowest cost as the Final Access Plan (the access plan that will be used to retrieve the values requested in your Query). If there are multiple access plans with the same lowest cost, the Query Processor will use the first access plan that it calculated with that cost. For example, if there are 4 access plans that have the lowest cost of 1, the Query Processor will use the first access plan that it calculated (out of those 4 permutations).

The cost of each access plan and details of the Final Access Plan can be found in the database log file (see Display a Server Log File in the Geo SCADA Expert Guide to Server Administration).

When the Query Processor has chosen the appropriate access path for the Final Access Plan, it begins the SQL Query Execution Process (see SQL Execution).

You can use the Query Processor section of the Geo SCADA Expert Server Status Tool to ascertain information about the latest, largest, and longest SQL queries. This includes information such as the time taken to parse and verify (validate) a query, along with the type of optimization used, and the number of rows that the query returns.


Disclaimer

Geo SCADA Expert 2022