IBM Support

How do you calculate the size of a geometry (in bytes)?

Question & Answer


Question

How do you calculate the size of a geometry (in bytes)?

Answer

You can use the SQL function LENGTH to determine the total size of a geometry. This function takes a value of any spatial type as input parameters, and returns the number of bytes that are required to store that value.

The following sample query determines the number of bytes of all geometries stored in the column spatialCol in the table spatialTable.

    SELECT LENGTH(spatialCol) AS size
    FROM spatialTable
This query returns the following result:
    SIZE
    -----------
    222
    230
    240

3 record(s) selected.

The result of the LENGTH function can be used as any other numerical value in a SQL statement. For example, the following query uses the aggregate function AVG() to determine the average size of all the geometries in the column spatialCol.
    SELECT AVG(LENGTH(spatialCol)) AS avg
    FROM spatialTable


    AVG
    -----------
            230

  1 record(s) selected.

[{"Product":{"code":"SSYUVL","label":"Db2 Spatial Extender for Linux, UNIX and Windows"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Performance","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF033","label":"Windows"},{"code":"PF027","label":"Solaris"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"}],"Version":"9.1;9.5;9.7;10.1","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
16 June 2018

UID

swg21079722