Hello Steven,
I am trying to draw a decission about what I should do now based on your explanations.
Regarding questions 1a-d)
>> That is not to say there won't be indexes on the internal materialzation target table, it's just they will be created based upon the view pk, unique, and index metadata.
>> Pk, Unique Key, and Indexes on the view will result in the creation of an index on the materialization target table and are fully utilized in planning decisions.
>> If you are asking about that metadata on Teiid views, then no as that metadata will influence neither costing, nor will it be preserved after view removal. If you are asking about that metadata on a Teiid foreign table, then yes it will be consulted.
From your comments my understanding is yes, PK,Unique Key and Indexes are used and it makes sense for me to specify them at least on foreign table definitions. What is not clear to me is, if I should specify them on a View on top of a foreign table as well, or if Teiid can optimally perform with the definitions on the foreign table alone. I do not want to write unnecessary lines of code.
Example:
I have the following two definitions in my ddl file:
CREATE FOREIGN TABLE UserDefinedProducts (
fkProduct long NOT NULL OPTIONS(NAMEINSOURCE '"fkProduct"', NATIVE_TYPE 'BIGINT'),
fkProfile long NOT NULL OPTIONS(NAMEINSOURCE '"fkProfile"', NATIVE_TYPE 'BIGINT'),
idCode long OPTIONS(NAMEINSOURCE '"idCode"', NATIVE_TYPE 'BIGINT'),
product_name string(48) OPTIONS(NAMEINSOURCE '"product_name"', NATIVE_TYPE 'VARCHAR'),
CONSTRAINT "PRIMARY" PRIMARY KEY(fkProduct, fkProfile),
CONSTRAINT fkUserDefinedProductToProduct FOREIGN KEY(fkProduct) REFERENCES Products(idProduct),
CONSTRAINT fKUserDefinedProductToAccount FOREIGN KEY(fkProfile) REFERENCES Account(idProfile),
CONSTRAINT fkProfile_fkProduct_idCode_InProducts_UNIQUE UNIQUE(fkProduct, fkProfile, idCode),
CONSTRAINT idCodeInUserDefinedProducts_idx INDEX(idCode),
CONSTRAINT fKUserDefinedProductToAccount_idx INDEX(fkProfile)
) OPTIONS(NAMEINSOURCE '"UserDefinedProducts"', UPDATABLE 'TRUE', CARDINALITY '4');
CREATE View UserDefinedProductsOfAllUsers (
fkProduct long NOT NULL,
fkProfile long NOT NULL,
idCode long,
product_name string(48) NOT NULL,
CONSTRAINT "PRIMARY" PRIMARY KEY(fkProduct, fkProfile),
CONSTRAINT fkUserDefinedProductToProduct FOREIGN KEY(fkProduct) REFERENCES Products(idProduct),
CONSTRAINT fKUserDefinedProductToAccount FOREIGN KEY(fkProfile) REFERENCES Account(idProfile),
CONSTRAINT idCodeInUserDefinedProducts_idx INDEX(idCode),
CONSTRAINT fKUserDefinedProductToAccount_idx INDEX(fkProfile)
) OPTIONS(MATERIALIZED 'TRUE', "teiid_rel:ALLOW_MATVIEW_MANAGEMENT" 'true', "teiid_rel:MATVIEW_UPDATABLE" 'true', "teiid_rel:MATVIEW_TTL" '1000') --// TTL is in miliseconds
AS
SELECT p.fkProduct as fkProduct, p.fkProfile as fkProfile, p.idCode as idCode, p.product_name as product_name
FROM UserDefinedProducts p;
Now my question is, should I explicitly specify the CONSTRAINTS marked as red on the View UserDefinedProductsOfAllUsers like I did in this example, or does this have no benefit for Teiid as this is already implicitly known to Teiid via the foreign table definition. Hence, I can simply omit the red lines of code. What I observed is, that I at least need to specify the PRIMARY KEY line as the view is not exported to the odata layer otherwise.
———————————
Regarding question 2:
>> [TEIID-5754] Schema visibility issues - JBoss Issue Tracker addresses any issues with visibility that were apparent. Primarily it's a doc issue - the property should be "VISIBLE FALSE".
In response to your first reply I had added TEIID-5752. So if I understand you correct, Teiid 5754 already address and solved the issue? Hence TEIID-5752 could be closed?
What does this now mean regarding the correct usage of the feature.? Once Teiid 12.2.1 is available, how can I use this feature to hide parts of my table? My understanding is that setting VISIBLE FALSE on the schema will set all foreign tables and Views in this schema to invisible. Hence the strategy would be that I have to define all foreign source tables which shall become invisible in a Schema A, set this schema to invisible, and create a second Schema B which now is a visible one, and defines viewson the source tables of Schema A to make parts of their data visible / accessible on the odata layer. Is my assumption and the sketched strategy correct?
———————————
Regarding question 4:
<< If your updates are flowing through teiid, then use the use of write through will keep everything in sync. For internal materialization this will require the multiple Teiid instances to use cluster communication as each member will maintain it's own copy of the table.
Ok, here is what I have planned. Once my basic app is finally running, I would like to switch from a single Teiid Wildfly instance to multiple independently running Teiid Thorntail instances to realize horizontal scaling of my backend. My current assumption was, that these instances do not require cluster communication. My plan for updatable materialized tables was to use write through on them and configure each Thorntail instance to refresh the materialized table once all 10 seconds. My thinking was, that the updated data are directly written to the underlaying database and the data in the other Thorntail instances would be at max stale for 10 seconds (till periodic refresh happens). Hence, I would not require cluster communication between the Thorntail instances. Is my thinking correct or would I still require cluster communication between the instances for other topics I have not thought about yet?