Abstract
Informix Dynamic Server (IDS) stores smart large objects in sbspaces separate to dbspaces containing tables. Typically, all will be stored in the default sbspace configured in parameter SBSPACENAME. It is therefore challenging to determine which of your columns of type BLOB (binary large object) or CLOB (character large object) are taking up the most room.
This article provides and describes a stored procedure to list the total size for each smart large object column.
Content
Firstly, did you know that smart large objects are not logged by default? See Storage characteristics of sbspaces. Unless you have a good reason otherwise, always create sbspaces as in the following example:
The alternate create sbspace with log SQL API method returns “ERROR” with no further explanation on my test system (see DT463888 in Conclusions):
Use this two-stage process instead:
You can check existing sbspaces with:
It would otherwise show “LO_NOLOG”.
You can “Turn logging on or off for an sbspace“, though that only changes the default for new objects. See also our article on “Mass updates and moving smart blobs“.
There is no built-in way to get the size of a smart object:
A solution was given in the IBM Informix Community forum here:
Is there a way to check the sbspace usage by table?
As pointed out by Art Kagel, the SQL Packages Extension DataBlade provided with IDS contains a suitable function “dbms_lob_getlength”. Install it in your preferred database with this SQL:
Note that the documentation on the DBMS_LOB package wrongly lists the function name as “dbms_lob.get_length” (see Conclusions).
We can then use that in our procedure which you should create in the same database as the DataBlade:
You can then run the report across all databases in your instance simply with:
On my test system, that produces:
| dbsname | tabname | colname | coltype | sbspace | nrows | blobs | bytes |
|---|---|---|---|---|---|---|---|
| test | clobs | contents | clob | sbspace3 | 4 | 4 | 1834 |
| test | smart_blob_test | data | blob | sbspace | 2 | 2 | 16313 |
| test | smart_blob_test_copy | data | blob | sbspace | 2 | 2 | 16313 |
| test | smart_clob_test | data | clob | sbspace | 2 | 2 | 16313 |
| test | smart_clob_test_copy | data | clob | sbspace | 2 | 2 | 16313 |
You can wrap that in a view which might be easier to use:
You can then select sub-totals, etc. The above and example usage are in comments at the top of the procedure.
Conclusion
The results of the procedure provided in this article will be a good indicator of the relative usage per smart large object column.
TS021500062 has been raised with IBM for the create sbspace with log defect and SQL Packages Extension documentation fault:
- DT463888: execute function task(“create unencrypted sbspace” or “create sbspace with log) is failing, sometimes with an assertion.
- Documentation: Function names are not correct in the “SQL Package Extension” page of Informix extensions and Datablade Modules
RFE INFX-I-699 has been raised for a new configuration parameter SPSPACELOGGING to make sbspaces logged by default.
Disclaimer
Suggestions above are provided “as is” without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement.
Contact Us
If you have any questions or would like to find out more about this topic, please contact us.