How you would go about creating a materialised view for an existing SQL view, which joins quite a lot of tables (combination of inner / left and right joins) to produce it's output?
We have an existing view in our cache application that takes around 4 hours to produce it's output (it joins around 20/30 different tables and outputs about 300 fields). 4 hours is after having undertaken performance optimisations like adding indexes and tuning tables. Our application has a very high throughput of data.
I am working on creating a materialised version of my aforementioned view and wondering if I have to add data indexes to each of the 20 tables or if there is better way?
Will appreciate any code you might be able to share.
We did consider swizzling but don't think that applies in this case since since we are inserting child records using ChildRelationship.Insert(childObj) as opposed to swizzling them into memory that they need to be unswizzled later.
@Wolf Koelling, I have been researching this because we encountered <Store> errors when processing data stored within a parent child relationship. <Store> errors occurred because of child data being loaded into memory. This breached default memory allocated to a cache process of 262,144 Kbytes (262 MB).
We initially increased cache process memory using $ZSTORAGE to get rid of <Store> errors and kept doing this till we had increased it to 2048,000 Kbytes (2 GB)! We will be refactoring our code to use one-many relationship instead, as soon as possible.
My take away from this is that it's better to stay away from parent-child relationships and use one-many relationships by default.
This greatly helps my understanding. It would be nice if this information formed part of the documentation for Cache itself and could be elaborated upon.
Essentially to use SELECT, function must implement Table-Valued Function (TVF) interface. Is there any specific documentation relative to TVF you are able to point me towards please?
Your recommended approach, though hugely appreciated, won't work for me I'm afraid.
In answer to your questions:
I am making my call from object script, as part of an already built component within a financial cache application that explicitly uses a SELECT statement
Changing this component to use CALL instead of a SELECT is not possible due to dependencies and legacy code.
Essentially question I am asking is why some stored procedures can only be called via CALL and why can some be called by both CALL and SELECT (such as in the case of class queries)?
I get a feeling this has something to do with SQL-Invokable-Routine (SIR) - see @Dan Pasco comment here but there is almost nothing in the documentation or any code for me to go further on.
Alternative approach: %SQL.CustomResultSet is icing on the cake which is not covered by Intersystems documentation. It really should be. This is exactly what I needed for my current project. Thanks.
Fantastic help. Thank for sharing this. I didn't know you could use ##Expression in basic class queries. Studio does complain about it though but works just fine at run time!
Thanks John. Appreciate your team's effort in getting us to this stage. We will upgrade and start testing it out.
LUT and HL7 need to be on the roadmap at some point. Our code is currently fragmented and not entirely committed to GIT. Changes to these files need to be manually tracked which defeats the purpose of having a source control system.
@Andreas, are we on track for Atelier 1.3 release late August or has this moved?
Atelier is starting to become critical to our way of working and we are hoping it will address some critical issues such as 1.2's inability to export HL7 schemas and lookup tables.
Can anyone provide an update on Atelier 1.3 release date? It is scheduled for release this month.
There are quite a few issues we are hoping it would fix hopefully around DTL errors and inability of 1.2 to export HL7 schemas and lookup tables to commit in GIT
go to post
Cheers Marc. I'll have a look.
go to post
Thanks Ben. IRIS upgrade cannot become a dependency for S3 write. We will ensure we revisit these connectors post upgrade.
go to post
Thank you Eduard. I'll have a look. Appreciate response.
go to post
Hi Robert,
Thanks for this article.
How you would go about creating a materialised view for an existing SQL view, which joins quite a lot of tables (combination of inner / left and right joins) to produce it's output?
We have an existing view in our cache application that takes around 4 hours to produce it's output (it joins around 20/30 different tables and outputs about 300 fields). 4 hours is after having undertaken performance optimisations like adding indexes and tuning tables. Our application has a very high throughput of data.
I am working on creating a materialised version of my aforementioned view and wondering if I have to add data indexes to each of the 20 tables or if there is better way?
Will appreciate any code you might be able to share.
Regards
go to post
Apologies for the delay in responding but just to say, appreciate your response. This is exactly how we fixed it.
go to post
We did consider swizzling but don't think that applies in this case since since we are inserting child records using ChildRelationship.Insert(childObj) as opposed to swizzling them into memory that they need to be unswizzled later.
go to post
@Wolf Koelling, I have been researching this because we encountered <Store> errors when processing data stored within a parent child relationship. <Store> errors occurred because of child data being loaded into memory. This breached default memory allocated to a cache process of 262,144 Kbytes (262 MB).
We initially increased cache process memory using $ZSTORAGE to get rid of <Store> errors and kept doing this till we had increased it to 2048,000 Kbytes (2 GB)! We will be refactoring our code to use one-many relationship instead, as soon as possible.
My take away from this is that it's better to stay away from parent-child relationships and use one-many relationships by default.
go to post
Thanks very much @Dan Pasco. Very useful responses.
go to post
and I guess for those that don't want to dig deeper, an easier approach to using SELECT * FROM..., is to use custom class queries.
go to post
Hi @Dan Pasco
This greatly helps my understanding. It would be nice if this information formed part of the documentation for Cache itself and could be elaborated upon.
Essentially to use SELECT, function must implement Table-Valued Function (TVF) interface. Is there any specific documentation relative to TVF you are able to point me towards please?
go to post
Thanks for your response @Kevin Chan
go to post
Thanks @Benjamin De Boe
I believe we are on a high enough version which should cater for this.
go to post
Hi Rupert,
I hope you are well and enjoying robotics.
Thanks for coming back to me.
Your recommended approach, though hugely appreciated, won't work for me I'm afraid.
In answer to your questions:
Essentially question I am asking is why some stored procedures can only be called via CALL and why can some be called by both CALL and SELECT (such as in the case of class queries)?
I get a feeling this has something to do with SQL-Invokable-Routine (SIR) - see @Dan Pasco comment here but there is almost nothing in the documentation or any code for me to go further on.
go to post
Your request object needs to extend %XML.Adaptor for it to be visible in management portal's content section.
See: https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?K...
"Optionally include %XML.Adaptor as a superclass so that the properties defined in the referenced class can be displayed in the Management Portal. "
go to post
Fantastic post @Eduard Lebedyuk
Alternative approach: %SQL.CustomResultSet is icing on the cake which is not covered by Intersystems documentation. It really should be. This is exactly what I needed for my current project. Thanks.
go to post
Fantastic help. Thank for sharing this. I didn't know you could use ##Expression in basic class queries. Studio does complain about it though but works just fine at run time!
go to post
It seems that views in cache need to start with a "SELECT ..." therefore to get around this, I did the following which works:
Class DC.NewClass1 [ ClassType = view, ViewQuery = {
SELECT '', As A, '' As B WHERE 1=2
UNION
SELECT A,B FROM DC.ClosedFuturesProc(65257,65286) --'2019-09-01','2019-09-30'
} ]
{ Parameter READONLY = 1; }
go to post
Thanks John. Appreciate your team's effort in getting us to this stage. We will upgrade and start testing it out.
LUT and HL7 need to be on the roadmap at some point. Our code is currently fragmented and not entirely committed to GIT. Changes to these files need to be manually tracked which defeats the purpose of having a source control system.
Thanks again.
go to post
@Andreas, are we on track for Atelier 1.3 release late August or has this moved?
Atelier is starting to become critical to our way of working and we are hoping it will address some critical issues such as 1.2's inability to export HL7 schemas and lookup tables.
Please provide an update?
go to post
Can anyone provide an update on Atelier 1.3 release date? It is scheduled for release this month.
There are quite a few issues we are hoping it would fix hopefully around DTL errors and inability of 1.2 to export HL7 schemas and lookup tables to commit in GIT