It’s been a while since I made several changes to the initial Oracle implementation in Icinga IDOUtils. Code has been split, first start of using prepared statements and binded params with ocilib and some other changes to the code.
In the last few weeks I have been investigating a lot on how to implement more improvements and optimize the critical path of data input from Icinga Core.
I want to start with IDOUtils Oracle, more information on other improvements for Icinga and IDOUtils will follow :)
Oracle implementation splits up into several parts taken care of:
- Rewrite all queries to prepared statements and bind params at runtime
- Add dynamic procedures for DELETE statements
- Drop autoincrement emulation by one sequence and insert triggers
- Add sequences for each table and use INSERT INTO … (id, …) VALUES (seq_name.nextval, …)
- Add RETURNING id INTO :id for INSERT statements to save one round trip
- MERGE does not support returning INTO, added SELECT seq_name.currval query instead for fetching last inserted id
- Rewrite selecting cached objects from DB
The rewritten queries are divided as follows:
- 1x SELECT latest data time as is (called only at startup)
- dynamic procedure for DELETE on table by instance_id called at startup for cleaning config/status
- dynamic procedure for DELETE on tably by instance_id, field compared to time called during periodic cleanup
- all other queries are prepared with their own statement handler
- 4x DELETE
- 52x MERGE
- 9x INSERT
- 9x UPDATE
- 5x SELECT
This summarizes into about 8000 lines (+) and 2000 lines (-) of code modifications :-)
Furthermore I have been thinking on how to provide an upgrade path for all existing IDOUtils Oracle users. Importing data using the newly applied sequences might lead into errors regarding currval of each sequence. A basic upgrade procedure has been provided already – if you want to try, get the latest GIT master.
Stay tuned for more interesting stories to tell :)
… and watch out for Icinga 1.0.1 and fresh IDOUtils Oracle!