-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[b/341297017] Add used-space-details, db-objects SQLs (#432)
Add used-space-details and db-objects for databases supporting PDBs.
- Loading branch information
Showing
4 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
dumper/app/src/main/resources/oracle-stats/native/db-objects-synonym-public.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- Copyright 2022-2024 Google LLC | ||
-- Copyright 2013-2021 CompilerWorks | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
SELECT | ||
B.con_id "ConId", | ||
'PUBLIC' "Owner", | ||
'SYNONYM' "ObjectType", | ||
B.editionable "Editionable", | ||
-- This looks similar to filtering with WHERE and using count() instead of sum(). | ||
-- | ||
-- It is not similar. DB will see the LIKE inside a WHERE predicate and decide to | ||
-- replace a HASH JOIN with NESTED LOOPS. The JOIN arguments have >10k rows each, | ||
-- so performance-wise the nested loop would be terrible. | ||
sum( | ||
CASE WHEN B.object_name LIKE '/%' THEN 0 | ||
WHEN B.object_name LIKE 'BIN$%' THEN 0 | ||
ELSE 1 END | ||
) "Count" | ||
FROM ( | ||
SELECT | ||
A.con_id, | ||
A.editionable, | ||
A.object_name, | ||
A.owner | ||
FROM cdb_objects A | ||
WHERE A.object_type = 'SYNONYM' | ||
AND A.owner = 'PUBLIC' | ||
) B | ||
LEFT JOIN ( | ||
SELECT | ||
C.synonym_name, | ||
C.con_id, | ||
C.table_owner | ||
FROM cdb_synonyms C | ||
WHERE C.owner = 'PUBLIC' | ||
AND C.table_owner IS NOT NULL | ||
) D ON B.object_name = D.synonym_name | ||
AND B.con_id = D.con_id | ||
WHERE D.table_owner IS NULL | ||
AND B.owner = 'PUBLIC' | ||
GROUP BY B.con_id, B.editionable |
63 changes: 63 additions & 0 deletions
63
dumper/app/src/main/resources/oracle-stats/native/db-objects.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
-- Copyright 2022-2024 Google LLC | ||
-- Copyright 2013-2021 CompilerWorks | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
SELECT | ||
A.con_id "ConId", | ||
A.owner "Owner", | ||
A.object_type "ObjectType", | ||
A.editionable "Editionable", | ||
count(1) "Count" | ||
FROM cdb_objects A | ||
WHERE A.owner NOT LIKE '%SYS' | ||
AND A.object_name NOT LIKE 'BIN$%' | ||
GROUP BY | ||
A.con_id, | ||
A.owner, | ||
A.object_type, | ||
A.editionable | ||
UNION ALL ( | ||
SELECT | ||
B.con_id "ConId", | ||
'SYS' "Owner", | ||
'DIRECTORY' "ObjectType", | ||
B.editionable "Editionable", | ||
count(1) "Count" | ||
FROM cdb_objects B | ||
WHERE B.owner = 'SYS' | ||
AND B.object_type = 'DIRECTORY' | ||
AND B.object_name NOT LIKE 'BIN$%' | ||
GROUP BY | ||
B.con_id, | ||
B.owner, | ||
B.object_type, | ||
B.editionable | ||
) | ||
UNION ALL ( | ||
SELECT | ||
C.con_id "ConId", | ||
C.owner "Owner", | ||
C.object_type "ObjectType", | ||
C.editionable "Editionable", | ||
count(1) "Count" | ||
FROM cdb_objects C | ||
WHERE C.owner NOT LIKE '%SYS' | ||
AND C.owner <> 'PUBLIC' | ||
AND C.object_type = 'SYNONYM' | ||
AND C.object_name NOT LIKE 'BIN$%' | ||
GROUP BY | ||
C.con_id, | ||
C.owner, | ||
C.editionable, | ||
C.object_type | ||
) |
21 changes: 21 additions & 0 deletions
21
dumper/app/src/main/resources/oracle-stats/native/used-space-details.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Copyright 2022-2024 Google LLC | ||
-- Copyright 2013-2021 CompilerWorks | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
SELECT A.con_id "ConId", | ||
A.owner "Owner", | ||
A.segment_type "SegmentType", | ||
SUM(bytes) "Bytes" | ||
FROM cdb_segments A | ||
WHERE A.owner NOT LIKE '%SYS' | ||
GROUP BY A.con_id, A.owner, A.segment_type |