Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: release_13_0_10 ] [ release_13_0_30 ] [ release_13_0_40 ] [ release_13_1_0 ]

001 -- Hello emacs, please make this buffer -*- sql -*-
002 -- Andre DOS ANJOS <Andre.dos.Anjos@cern.ch>
003 
004 -- $Author: stelzer $
005 -- $Revision: 1.5 $
006 -- $Date: 2007/05/10 10:07:59 $
007 
008 -- Creates a set of views that are useful for HLT (jobOption) configuration, 
009 -- using INNER JOINS statements. Because the selects are very long, do *not*
010 -- pin it down using a specific masterkey. If you make changes here, observe 
011 -- the following:
012 
013 -- 1. DISTINCT keyword on selects, as well as other sorting, uniq'ing utilities
014 --    require the SQL server to fetch the whole table sometimes, so let it for
015 --    your last call.
016 
017 -- 2. Do *never* jump from N-to-N relationship table to another N-to-N relation
018 --    ship table since the SQL server cannot find the index between the connected
019 --    tables this way. Try to go from table to table in single direct steps.
020 
021 -- 3. If you are working with ORACLE, remember to make indexes out of the foreign
022 --    keys of your tables, otherwise these views might be quite slow.
023 
024 -- Generates a view where we get all trigger elements associated with a given
025 -- master key. This view is only used to gather the algorithms that are part
026 -- of a run so the component query can be made easier. It is not necessary for
027 -- normal JO calculations
028 -- OPTIMIZATION STATUS: queries to a fixed HMT_ID gives a constant access time,
029 -- independent of the size of the tables involved. Queries without a HMT_ID will
030 -- issue a full scan on HLT_MASTER_TABLE, for MySQL5
031 CREATE OR REPLACE VIEW HLT_MK_TO_TE_VIEW (HMT_ID, HTE_ID) AS
032   SELECT HLT_MASTER_TABLE.HMT_ID, HLT_TRIGGER_ELEMENT.HTE_ID
033   FROM HLT_MASTER_TABLE, -- Defines the trigger-menu to use
034        HLT_TM_TO_TC, -- trigger-menu  -> trigger-chain
035        HLT_TC_TO_TS, -- trigger-chain -> trigger-signature
036        HLT_TS_TO_TE, -- trigger-signature  -> trigger-element
037        HLT_TRIGGER_ELEMENT
038   WHERE HLT_MASTER_TABLE.HMT_TRIGGER_MENU_ID IS NOT NULL AND
039         HLT_MASTER_TABLE.HMT_TRIGGER_MENU_ID = 
040           HLT_TM_TO_TC.HTM2TC_TRIGGER_MENU_ID AND
041         HLT_TM_TO_TC.HTM2TC_TRIGGER_CHAIN_ID = 
042           HLT_TC_TO_TS.HTC2TS_TRIGGER_CHAIN_ID AND
043         HLT_TC_TO_TS.HTC2TS_TRIGGER_SIGNATURE_ID = 
044           HLT_TS_TO_TE.HTS2TE_TRIGGER_SIGNATURE_ID AND
045         HLT_TS_TO_TE.HTS2TE_TRIGGER_ELEMENT_ID =
046           HLT_TRIGGER_ELEMENT.HTE_ID;
047 
048 
049 -- Chooses the setup from the chains in a master key
050 CREATE OR REPLACE VIEW HLT_MK_TO_ST_VIEW1 (HMT_ID, HST_ID) AS
051   SELECT HLT_MASTER_TABLE.HMT_ID, HLT_SETUP.HST_ID
052   FROM HLT_MASTER_TABLE,
053        HLT_TM_TO_TC,
054        HLT_TRIGGER_CHAIN,
055        HLT_SETUP 
056   WHERE HLT_MASTER_TABLE.HMT_TRIGGER_MENU_ID IS NOT NULL AND
057         HLT_MASTER_TABLE.HMT_TRIGGER_MENU_ID = HLT_TM_TO_TC.HTM2TC_TRIGGER_MENU_ID AND
058         HLT_TM_TO_TC.HTM2TC_TRIGGER_CHAIN_ID = HLT_TRIGGER_CHAIN.HTC_ID AND
059         HLT_TRIGGER_CHAIN.HTC_SETUP_ID = HLT_SETUP.HST_ID;
060 
061 -- Chooses the setup from the forced setup entry in the master table
062 -- OPTIMIZATION STATUS: queries to a fixed HMT_ID gives a constant access time,
063 -- independent of the size of the tables involved. Queries without a HMT_ID will
064 -- issue a full scan on HLT_MASTER_TABLE, for MySQL5
065 CREATE OR REPLACE VIEW HLT_MK_TO_ST_VIEW2 (HMT_ID, HST_ID) AS
066   SELECT HLT_MASTER_TABLE.HMT_ID, HLT_SETUP.HST_ID
067   FROM HLT_MASTER_TABLE, -- mastertable
068        HLT_SETUP
069   WHERE HLT_MASTER_TABLE.HMT_FORCED_SETUP_ID = HLT_SETUP.HST_ID;
070 
071 -- This partial view gets all masterkeys and relations to the setups in one shot
072 -- but you have to pay the price for derivation in SQL (otherwise it should be 
073 -- be relatively fast if you pin down the masterkey).
074 -- OPTIMIZATION STATUS: queries to a fixed HMT_ID gives an access time 
075 -- proportional to the full scan of the dependent views, so it depends on the 
076 -- size of the dependent views. Full scans on HLT_TM_TO_TC and _twice_ on 
077 -- HLT_MASTER_TABLE also happen.
078 CREATE OR REPLACE VIEW HLT_MK_TO_ST_VIEW (HMT_ID, HST_ID) AS
079   SELECT * FROM HLT_MK_TO_ST_VIEW1
080   UNION
081   SELECT * FROM HLT_MK_TO_ST_VIEW2;
082 
083 -- This is a comparison view that replaces the UNION statement above and the
084 -- two other tables in a single select statement for the two paths binded by
085 -- an OR clause. This table should *not* be used normally. It is just a proof
086 -- that, despite MySQL5 might sound to optimize it better in the overall case
087 -- it doesn't help too much, the query takes longer to complete than the UNION
088 -- query above. In my machine, this one takes a constant timing of 1.8 seconds
089 -- against 0.20 seconds of the UNION query.
090 CREATE OR REPLACE VIEW HLT_MK_TO_ST_VIEW3 (HMT_ID, HST_ID) AS
091   SELECT HLT_MASTER_TABLE.HMT_ID, HLT_SETUP.HST_ID
092   FROM HLT_MASTER_TABLE, -- Defines the trigger-menu to use
093        HLT_TRIGGER_MENU, -- trigger menus
094        HLT_TM_TO_TC, -- trigger-menu  -> trigger-chain
095        HLT_TRIGGER_CHAIN, -- trigger chains
096        HLT_SETUP -- trigger setup 
097   WHERE (HLT_MASTER_TABLE.HMT_TRIGGER_MENU_ID IS NOT NULL AND
098         HLT_MASTER_TABLE.HMT_TRIGGER_MENU_ID = HLT_TRIGGER_MENU.HTM_ID AND
099         HLT_TRIGGER_MENU.HTM_ID = HLT_TM_TO_TC.HTM2TC_TRIGGER_MENU_ID AND
100         HLT_TM_TO_TC.HTM2TC_TRIGGER_CHAIN_ID = HLT_TRIGGER_CHAIN.HTC_ID AND
101         HLT_TRIGGER_CHAIN.HTC_SETUP_ID = HLT_SETUP.HST_ID) OR
102         (HLT_MASTER_TABLE.HMT_FORCED_SETUP_ID = HLT_SETUP.HST_ID);
103 
104 
105 
106 -- This partial view shows the components from the relationship between
107 -- the master table and the trigger elements
108 -- OPTIMIZATION STATUS: queries with a fixed HMT_ID takes an amount of time
109 -- which is independent of the table sizes involved. Queries without a master
110 -- key require a full scan on HLT_MASTER_TABLE and HLT_TM_TO_TC for MySQL5.
111 CREATE OR REPLACE VIEW HLT_MK_TO_CP_VIEW1 (HMT_ID, HCP_ID) AS
112   SELECT HLT_MK_TO_TE_VIEW.HMT_ID, HLT_COMPONENT.HCP_ID
113   FROM HLT_MK_TO_TE_VIEW,
114        HLT_TE_TO_CP,
115        HLT_COMPONENT
116   WHERE HLT_MK_TO_TE_VIEW.HTE_ID = HLT_TE_TO_CP.HTE2CP_TRIGGER_ELEMENT_ID AND
117         HLT_TE_TO_CP.HTE2CP_COMPONENT_ID = HLT_COMPONENT.HCP_ID;
118 
119 -- This partial view shows the components derived from the setups that need to
120 -- be run.
121 -- OPTIMIZATION STATUS: Queries without a fixed HMT_ID take a full scan on
122 -- HLT_TM_TO_TC, twice on HLT_MASTER_TABLE and once on the HLT_MK_TO_ST_VIEW,
123 -- which can be costly (depends on the DB sizes). Queries with a fixed master
124 -- key don't change too much the scenario. This view requires careful thinking
125 -- for optimization in the long term since it depends on a view that is based
126 -- on a UNION statement (too difficult for the optimizer to digest). Despite
127 -- all this, for the time being (17/Feb/2006), this view is still quite 
128 -- performant, taking something like 0.18 seconds in my machine (pcuw32).
129 CREATE OR REPLACE VIEW HLT_MK_TO_CP_VIEW2 (HMT_ID, HCP_ID) AS
130   SELECT HLT_MK_TO_ST_VIEW.HMT_ID, HLT_COMPONENT.HCP_ID
131   FROM HLT_MK_TO_ST_VIEW,
132        HLT_ST_TO_CP,
133        HLT_COMPONENT
134   WHERE HLT_MK_TO_ST_VIEW.HST_ID = HLT_ST_TO_CP.HST2CP_SETUP_ID AND
135         HLT_ST_TO_CP.HST2CP_COMPONENT_ID = HLT_COMPONENT.HCP_ID;
136 
137 -- Binds together all possible components that need to run for a masterkey
138 -- OPTIMIZATION STATUS: Queries with or without a masterkey are dependent
139 -- on results of HLT_MK_TO_CP_VIEW1 (optimal) and HLT_MK_TO_CP_VIEW2,
140 -- which is not very optimized. So, if you fix the master key or not, that
141 -- won't matter too much here. This needs work w.r.t. the previous views
142 -- it depends on and because of potential other views as well, since it 
143 -- introduces a UNION. For the time being, it executes in something like
144 -- 0.25 seconds on my machine.
145 CREATE OR REPLACE VIEW HLT_MK_TO_CP_VIEW (HMT_ID, HCP_ID) AS
146   SELECT * FROM HLT_MK_TO_CP_VIEW1
147   UNION
148   SELECT * FROM HLT_MK_TO_CP_VIEW2;
149 
150 -- Generates a view where we get all services/tools/converters/algorithms from
151 -- a master key. We use the component view above to get all possible setups
152 -- involved in a run. The sources are also checked for consistency between what
153 -- is available in the release pointed by the master table.
154 -- OPTIMIZATION STATUS: This one is interesting! If you fix a master-key, at
155 -- least for MySQL 5 (5.0.18 running now), you get a slower performance!
156 -- Probably because it has to conduct so many full scans on derived tables, I
157 -- really don't know. MySQL5's optimizer claims it again needs to perform full
158 -- scan on 2 derived tables (oh my!) and a couple of times in HLT_MASTER_TABLE
159 -- and HLT_TM_TO_TC. I do understand full scans on HLT_MASTER_TABLE, but not on
160 -- the HLT_TM_TO_TC... Anyways, the query takes like 0.25 seconds w/o a master
161 -- key and around 0.25 seconds w/o a key.
162 -- One important observation: There are missing indexes for the jump between 
163 -- HCP_NAME and HSO_NAME. This might speed up this query.
164 --     CREATE OR REPLACE VIEW HLT_MK_TO_SO_VIEW (HMT_ID, HCP_ID,
165 --                                               HCP_NAME, HCP_ALIAS, HCP_TOPALG,
166 --                                               HSO_GAUDI_TYPE, HSO_ID) AS
167 --       SELECT HLT_MASTER_TABLE.HMT_ID, 
168 --              HLT_COMPONENT.HCP_ID, 
169 --              HLT_COMPONENT.HCP_NAME,
170 --              HLT_COMPONENT.HCP_ALIAS, 
171 --              HLT_COMPONENT.HCP_TOPALG, 
172 --              HLT_SOURCE.HSO_GAUDI_TYPE, 
173 --              HLT_SOURCE.HSO_ID
174 --       FROM HLT_MASTER_TABLE,
175 --            HLT_MK_TO_CP_VIEW, -- components(s) for a master key
176 --            HLT_COMPONENT, -- component table
177 --            HLT_RE_TO_DL,  -- release -> dll
178 --            HLT_DLL, -- dlls available in the release
179 --            HLT_SO_TO_DL,  -- dll -> source
180 --            HLT_SOURCE     -- source table
181 --       WHERE HLT_MASTER_TABLE.HMT_ID = HLT_MK_TO_CP_VIEW.HMT_ID AND -- fix master key
182 --             HLT_MK_TO_CP_VIEW.HCP_ID = HLT_COMPONENT.HCP_ID AND -- components that run
183 --             HLT_MASTER_TABLE.HMT_RELEASE_ID = HLT_RE_TO_DL.HRE2DL_RELEASE_ID AND
184 --             HLT_RE_TO_DL.HRE2DL_DLL_ID = HLT_DLL.HDL_ID AND
185 --             HLT_DLL.HDL_ID = HLT_SO_TO_DL.HSO2DL_DLL_ID AND
186 --             HLT_SO_TO_DL.HSO2DL_SOURCE_ID = HLT_SOURCE.HSO_ID AND
187 --             HLT_SOURCE.HSO_NAME = HLT_COMPONENT.HCP_NAME;
188 
189 -- These are the forced DLL's that I have to force loading. This only depends
190 -- on the setups used. This is only a partial view of required DLL's to run.
191 -- [Joerg 17.06.2006: in case the release part of the HLT db is not loaded, this table
192 -- contains all dll's that are needed to run this setup]
193 -- OPTIMIZATION STATUS: MySQL5's optimizer claims it needs to do a full scan on
194 -- the dependent view, plus a full scan on the HLT_FORCE_DLL table, another at
195 -- HLT_TM_TO_TC and twice on HLT_MASTER_TABLE. The other queries are cross
196 -- references which are easily digested by the optimizer. Takes like 0.20
197 -- seconds on my machine with today's (17/Feb/2006) DB load.
198 
199 
200 -- CREATE OR REPLACE VIEW HLT_MK_TO_FD_VIEW (HMT_ID, HDL_NAME) AS
201 --   SELECT HLT_MK_TO_ST_VIEW.HMT_ID, 
202 --          HLT_FORCE_DLL.HFD_DLL_NAME
203 -- 
204 --   FROM HLT_MK_TO_ST_VIEW, -- Defines the setups needed
205 --        HLT_FD_TO_ST, -- dll's <-> setup's
206 --        HLT_FORCE_DLL -- Defines the forced DLL identifiers
207 --   WHERE HLT_MK_TO_ST_VIEW.HST_ID = HLT_FD_TO_ST.HFD2ST_SETUP_ID AND
208 --         HLT_FD_TO_ST.HFD2ST_FORCE_DLL_ID = HLT_FORCE_DLL.HFD_ID;
209  
210 
211 
212 CREATE OR REPLACE VIEW HLT_MK_TO_FD_VIEW (HMT_ID, HDL_NAME) AS
213   SELECT HLT_MK_TO_ST_VIEW.HMT_ID, 
214          HLT_FORCE_DLL.HFD_DLL_NAME
215 
216   FROM HLT_MK_TO_ST_VIEW, -- Defines the setups needed
217        HLT_FORCE_DLL -- Defines the forced DLL identifiers
218   WHERE HLT_MK_TO_ST_VIEW.HST_ID = HLT_FORCE_DLL.hfd_setup_id;
219 
220 
221 -- Generates a partial view with the required DLL's for components
222 -- OPTIMIZATION STATUS: This is a big query! Two full scans on devirations and
223 -- other generally bad stuff. It is much faster than before, but it may get
224 -- stuck as we get more data in the DB.
225 -- WARNING: we may need an index to do this faster here (HCP_NAME ->
226 -- HSO_NAME mapping)
227 --     CREATE OR REPLACE VIEW HLT_MK_TO_CD_VIEW (HMT_ID, HDL_NAME) AS
228 --       SELECT HLT_MK_TO_CP_VIEW.HMT_ID, HLT_DLL.HDL_NAME
229 --       FROM HLT_MK_TO_CP_VIEW,
230 --            HLT_COMPONENT,
231 --            HLT_SOURCE,
232 --            HLT_SO_TO_DL, -- source -> dll mappings
233 --            HLT_DLL
234 --       WHERE HLT_MK_TO_CP_VIEW.HCP_ID = HLT_COMPONENT.HCP_ID AND
235 --             HLT_COMPONENT.HCP_NAME = HLT_SOURCE.HSO_NAME AND
236 --             HLT_SOURCE.HSO_ID = HLT_SO_TO_DL.HSO2DL_SOURCE_ID AND
237 --             HLT_SO_TO_DL.HSO2DL_DLL_ID = HLT_DLL.HDL_ID;
238         
239 -- A combined view from the two views above
240 -- OPTIMIZATION STATUS: This is even bigger than the query before! Three or
241 -- four full scan on derived tables + HLT_SO_TO_DL, HLT_MASTER_TABLE three or
242 -- four times and so on. The problem is upstairs and this still adds a union
243 -- clause to the following views. Takes like 0.45 seconds now, with the present
244 -- DB load (17/Feb/2006).
245 --     CREATE OR REPLACE VIEW HLT_MK_TO_DL_VIEW1 (HMT_ID, HDL_NAME) AS
246 --       SELECT * FROM HLT_MK_TO_FD_VIEW
247 --       UNION
248 --       SELECT * FROM HLT_MK_TO_CD_VIEW;
249 
250 -- A combined view of all DLL's needed for a given master key
251 -- OPTIMIZATION STATUS: 55 joins are executed for this one... No need to say
252 -- is one of the slowest views. Still, taking 0.65 seconds on my machine 
253 -- (pcuw32) with the present DB load (17/Feb/2006).
254 --     CREATE OR REPLACE VIEW HLT_MK_TO_DL_VIEW (HMT_ID, HDL_NAME, HDL_CMT_VERSION) AS
255 --       SELECT HLT_MASTER_TABLE.HMT_ID, HLT_DLL.HDL_NAME, HLT_DLL.HDL_CMT_VERSION
256 --       FROM HLT_MASTER_TABLE, -- unified master-key entry
257 --            HLT_MK_TO_DL_VIEW1,
258 --            HLT_RE_TO_DL,  -- release -> dll
259 --            HLT_DLL -- DLL specifications
260 --       WHERE HLT_MASTER_TABLE.HMT_ID = HLT_MK_TO_DL_VIEW1.HMT_ID AND
261 --      HLT_MASTER_TABLE.HMT_RELEASE_ID = HLT_RE_TO_DL.HRE2DL_RELEASE_ID AND
262 --             HLT_RE_TO_DL.HRE2DL_DLL_ID = HLT_DLL.HDL_ID AND
263 --             HLT_DLL.HDL_NAME = HLT_MK_TO_DL_VIEW1.HDL_NAME;
264 
265 -- Generates a view with the required parameters to run services. This is
266 -- extracted from the list of components that will run and are available with 
267 -- correlating sources in the chosen release.
268 -- OPTIMIZATION STATUS: I originally thought this was one of the worst views,
269 -- bound to be the slowest, but I'm wrong! It is not so bad... Could be
270 -- optimized though, if the dependent views are better written. Currently
271 -- (17/Feb/2006), taking 0.25 seconds to execute in my machine (pcuw32). 
272 -- MySQL5 has to perform 32 queries to get this done. Full scans being executed
273 -- on HLT_MASTER_TABLE and HLT_TM_TO_TC, several times.
274 CREATE OR REPLACE VIEW HLT_MK_TO_PA_VIEW (HMT_ID, HCP_ALIAS, HPA_NAME, 
275                                           HPA_OP, HPA_VALUE) AS
276   SELECT HLT_MK_TO_CP_VIEW.HMT_ID, 
277          HLT_COMPONENT.HCP_ALIAS, 
278          HLT_PARAMETER.HPA_NAME, 
279          HLT_PARAMETER.HPA_OP, 
280          HLT_PARAMETER.HPA_VALUE
281   FROM HLT_MK_TO_CP_VIEW, -- get components that will run
282        HLT_COMPONENT, -- the components
283        HLT_CP_TO_PA, -- component -> parameter
284        HLT_PARAMETER -- parameter specifications
285   WHERE HLT_MK_TO_CP_VIEW.HCP_ID = HLT_CP_TO_PA.HCP2PA_COMPONENT_ID AND
286         HLT_MK_TO_CP_VIEW.HCP_ID = HLT_COMPONENT.HCP_ID AND
287         HLT_CP_TO_PA.HCP2PA_PARAMETER_ID = HLT_PARAMETER.HPA_ID;
288 
289 
290 
291 -- These three views allow to access the parameters of all componenents in a job
292 -- for a given hlt_master_id and hlt_triggerlevel
293 CREATE OR REPLACE VIEW HLT_MK_TL_TO_ST_VIEW (HMT_ID, HTC_L2EF, HST_ID) AS
294   SELECT DISTINCT HLT_MASTER_TABLE.HMT_ID, HLT_TRIGGER_CHAIN.HTC_L2_OR_EF, HLT_SETUP.HST_ID
295   FROM HLT_MASTER_TABLE,
296        HLT_TM_TO_TC,
297        HLT_TRIGGER_CHAIN,
298        HLT_SETUP 
299   WHERE HLT_MASTER_TABLE.HMT_TRIGGER_MENU_ID IS NOT NULL AND
300         HLT_MASTER_TABLE.HMT_TRIGGER_MENU_ID = HLT_TM_TO_TC.HTM2TC_TRIGGER_MENU_ID AND
301         HLT_TM_TO_TC.HTM2TC_TRIGGER_CHAIN_ID = HLT_TRIGGER_CHAIN.HTC_ID AND
302         HLT_TRIGGER_CHAIN.HTC_SETUP_ID = HLT_SETUP.HST_ID;
303 
304 
305 CREATE OR REPLACE VIEW HLT_MK_TL_TO_CP_VIEW (HMT_ID, HTC_L2EF, HCP_ID) AS
306   SELECT HLT_MK_TL_TO_ST_VIEW.HMT_ID, HLT_MK_TL_TO_ST_VIEW.HTC_L2EF, HLT_COMPONENT.HCP_ID
307   FROM HLT_MK_TL_TO_ST_VIEW,
308        HLT_ST_TO_CP,
309        HLT_COMPONENT
310   WHERE HLT_MK_TL_TO_ST_VIEW.HST_ID = HLT_ST_TO_CP.HST2CP_SETUP_ID AND
311         HLT_ST_TO_CP.HST2CP_COMPONENT_ID = HLT_COMPONENT.HCP_ID;
312 
313 
314 CREATE OR REPLACE VIEW HLT_MK_TL_TO_PA_VIEW (HMT_ID, HTC_L2EF, HCP_ALIAS, HPA_NAME, 
315                                           HPA_OP, HPA_VALUE) AS
316   SELECT HLT_MK_TL_TO_CP_VIEW.HMT_ID,
317          HLT_MK_TL_TO_CP_VIEW.HTC_L2EF,
318          HLT_COMPONENT.HCP_ALIAS, 
319          HLT_PARAMETER.HPA_NAME, 
320          HLT_PARAMETER.HPA_OP, 
321          HLT_PARAMETER.HPA_VALUE
322   FROM HLT_MK_TL_TO_CP_VIEW, -- get components that will run
323        HLT_COMPONENT, -- the components
324        HLT_CP_TO_PA, -- component -> parameter
325        HLT_PARAMETER -- parameter specifications
326   WHERE HLT_MK_TL_TO_CP_VIEW.HCP_ID = HLT_CP_TO_PA.HCP2PA_COMPONENT_ID AND
327         HLT_MK_TL_TO_CP_VIEW.HCP_ID = HLT_COMPONENT.HCP_ID AND
328         HLT_CP_TO_PA.HCP2PA_PARAMETER_ID = HLT_PARAMETER.HPA_ID;

source navigation ] diff markup ] identifier search ] general search ]

This page was automatically generated by the LXR engine. Valid HTML 4.01!