What is the best way to query cmdb_ci table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 05:23 AM
Hi,
We have this integration where we want to crosscheck input CI and put it on the affected CI on the incident table.
However we don't know the table name.
And I believe it is not best practice to do a direct GlideRecord query on cmdb_ci table as this might cause performance issue.
What would be the best way to query cmdb_ci table given we don't know which child table from cmdb_ci to query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 05:28 AM - edited 10-10-2024 05:29 AM
Hello @Tadz
Use addEncodedQuery()
Use setLimit(1), if you need only one record.
Use Indexing and composite indexing on the table "cmdb_ci" for the field by which you are searching (querying in the table), by this you will not face any performance issue.
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 05:38 AM
What is it that you get in? Is it just the name of the CI? It could be problematic, because of uniqueness (I have seen CMDB's where some services had the same name as applications, server names being the same, because their uniqueness is defined on serial number, etc.)
Next: how do you get it in? Is it a staging table and a transform map or are you writing to the table directly? Often there already is a reference qualifier in place on the cmdb_ci field (like only operational ci's). If you use that query to prefilter the cmdb_ci table, you already have some performance gained.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark