Querying a database view - performance?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2015 10:01 AM
Hi,
Does querying a database view cause a performance issue? I have created a view by joining a table and wanted to query (GlideRecord) that view instead of querying the two table separately in two while loops (loop inside a loop).
Can anyone help me.
Thank you,
Sudipta
Harish MurikinatiShiva Sai prasadAshish SharmaCHHAVI SHAHBrad Tilton (Cloud Sherpas)Jim Coyne
- Labels:
-
Analytics and Reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2015 06:15 AM
Hi Goswami,
Are you thinking of a performance issue relating to say to your query taking longer?
Or thinking of a possible impact on the instance for users?
The scenario you mention does not seem likely to cause a performance issue, in any case.
If querying the two tables separately in two while loops (loop inside a loop) does not cause a performance issue, then pulling the same data back via a view should not cause a performance issue either.
Here are some factors you could consider
1) Evidently you should specify fields to return if either of the two tables has a large number of fields, or if you want just to pull back the data you need.
Database Views - ServiceNow Wiki
..
Specify Fields to Return
2) Avoid Left joins which cause the left-hand table in the database view to display all records, even if the join condition does not find a matching record on the right-hand table.
3) Database Views - ServiceNow Wiki Overview
1. Overview
..
Note: In general, as the number of tables that are included in the view and the number of records that those tables contain increases, the accumulated impact on performance grows. In addition, to optimize the performance of the database view ensure that the 'where' clauses that are defined in the database view are based on indexed fields.
On final point, the above advice depends on an analysis of factors which may affect the performance.
Actually testing the results of querying the database view you created, will give you the confidence you need to actually deploy it (or not) depending on results.
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2015 11:01 PM
Hi Goswami.
Also, I should mention perhaps it is likely that creating a database view rather than querying the two table separately in two while loops while be faster, perhaps a lot faster.
Did you try this out? What was your experience?
Best Regards
Tony