0% found this document useful (0 votes)
5 views

1. Index Internals

The document outlines a test taken on Oracle database concepts, with a score of 73.33%. It includes questions and answers related to storage space occupied by table data versus index entries, the purpose of checking index columns, analyzing index statistics, and managing stale statistics. The document emphasizes the importance of accurate statistics for query performance and provides correct answers along with explanations for various scenarios in Oracle database management.

Uploaded by

Harinadh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

1. Index Internals

The document outlines a test taken on Oracle database concepts, with a score of 73.33%. It includes questions and answers related to storage space occupied by table data versus index entries, the purpose of checking index columns, analyzing index statistics, and managing stale statistics. The document emphasizes the importance of accurate statistics for query performance and provides correct answers along with explanations for various scenarios in Oracle database management.

Uploaded by

Harinadh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

You completed this test on 05/08/2024, 18:10


Your score is 73.33%

CORRECT

What typically occupies more storage space in an Oracle database: the table data or
the index entries?

 A) Table data

B) Index entries

Correct Answer:A Table data Explanation: Generally, table data occupies more
storage space in an Oracle database compared to index entries. This is because the
table contains all the actual data rows and associated columns, whereas the index
contains only key columns and pointers to the corresponding rows in the table.
Incorrect Answers
B) While index entries are essential for e!cient data retrieval, they typically
occupy less storage space compared to the actual table data. Index entries
consist of keys and pointers, which are smaller in size compared to entire rows
of data.

CORRECT

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 1 of 17
:
1.

Real World Scenario: You’re working with an e-commerce database that stores product
information. A developer reports slow query performance for a search query on product
names.

Question: How can you determine which columns have indexes on them for the
products table?

A. Query the USER_INDEXES view.

 B. Check the USER_IND_COLUMNS view.

C. Examine the USER_TAB_COLUMNS view.

Correct Answer: B . Check the USER_IND_COLUMNS view. This view provides


information about the columns included in each index.
Incorrect Answers
: A) Querying USER_INDEXES gives information about indexes but not the
speci"c columns. C) USER_TAB_COLUMNS provides details about table columns
but not index-related information.

CORRECT

USER_INDEXES gives information about indexes but not specific columns. (True /False)

 TRUE

FALSE

Correct Answer: TRUE. USER_IND_COLUMNS provides details about the


columns included in indexes.

CORRECT

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 2 of 17
:
Real World Scenario: You’re optimizing a reporting query that retrieves sales data from a
large table.

Question: What is the primary purpose of checking index columns for a query?

A. To ensure data consistency

 B. The primary purpose of checking index columns is to improve query performance by


leveraging indexed data.

Correct Answer: B .

CORRECT

USER_IND_COLUMNS provides details about the columns included in indexes and also position
of the column in a composite Index.

 True

False

In a Composite index, In some oracle versions, where condition should have


leading column , else that composite index will not used by optimizer . In such
cases , position of a column in a composite index plays important role

CORRECT

What typically occupies more storage space in an Oracle database: the table data or
the index entries?

 A) Table data

B) Index entries

Correct Answer:A Table data Explanation: Generally, table data occupies more
storage space in an Oracle database compared to index entries. This is

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 3 of 17
:
because the table contains all the actual data rows and associated columns,
whereas the index contains only key columns and pointers to the
corresponding rows in the table.
Incorrect Answers
B) While index entries are essential for e!cient data retrieval, they typically
occupy less storage space compared to the actual table data. Index entries
consist of keys and pointers, which are smaller in size compared to entire rows
of data.

CORRECT

You want to "nd more information on indexes , not sure which data dictionary to be used .
Which of the below query do you use?

 A. select * from all_views where view_name like 'USER%IND%';

B. select * from tab;

Correct Answer is A. There are so many data dictionary views to get required
information on indexes, If we cannot remember , then we can use this query.

CORRECT

Which type of latest optimizer is commonly used in Oracle databases for query optimization
(used in latest versions)?

A) Rule-Based Optimizer (RBO)

 B)Cost-Based Optimizer (CBO)

Cost based optimizer is used by latest oracle versions. "Rule based " optimizer
is used by older versions like 7.x

CORRECT

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 4 of 17
:
What is the purpose of analyzing index statistics in Oracle?

A) To optimize memory usage for index structures.

 B) To improve query performance by ensuring accurate statistics.

C) To reduce disk space consumption for index segments.

Correct Answer (B): Analyzing index statistics helps the optimizer make
informed decisions about query execution plans. Accurate statistics ensure
that the optimizer chooses the most e!cient access paths for queries.

CORRECT

True /False

Disabling and Rebuilding Indexes:

During data loading or heavy operations, you can temporarily disable indexes to
improve performance. Once the data load is complete, you can rebuild the indexes
using below commands.
-- Disable the index (for data loading)
ALTER INDEX my_table_idx01 DISABLE;
-- Perform your data loading process
-- Rebuild the index
ALTER INDEX my_table_idx01 REBUILD;

Explanation:

Disabling the index makes it unusable during the data load, preventing
unnecessary maintenance overhead.
Rebuilding the index ensures it’s optimized for the newly loaded data.

FALSE

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 5 of 17
:
 TRUE

TRUE

CORRECT

Question: What is the syntax of the ANALYZE INDEX command in Oracle?

 A) ANALYZE INDEX [schema.]index_name [PARTITION (partition_name)] { COMPUTE


STATISTICS | ESTIMATE STATISTICS [SAMPLE integer ROWS | PERCENT] | DELETE STATISTICS |
VALIDATE STRUCTURE }

B) ANALYZE INDEX [schema.]index_name [PARTITION (partition_name)] { COMPUTE STATISTICS


| ESTIMATE STATISTICS [SAMPLE integer PERCENT | ROWS] | DELETE STATISTICS | VALIDATE
STRUCTURE }

Explanation: Correct Answer:A ): This is the correct syntax of the ANALYZE


INDEX command, which can be used to collect or delete statistics, or validate
the structure of an index1.
Incorrect Answers
: This is incorrect because the order of the SAMPLE clause options is reversed.
It should be SAMPLE integer ROWS | PERCENT, not SAMPLE integer PERCENT |
ROWS1.

INCORRECT

Question: What is the di#erence between COMPUTE STATISTICS and ESTIMATE STATISTICS
options in the ANALYZE INDEX command?

 A) COMPUTE STATISTICS collects detailed statistics for the index, while ESTIMATE STATISTICS
provides an estimated statistical summary based on a sample of rows or percentage of the index.

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 6 of 17
:
B) COMPUTE STATISTICS collects detailed statistics for the index, while ESTIMATE
STATISTICS provides an estimated statistical summary based on a sample of blocks or
percentage of the index.

Correct Answer (B): This is the correct answer, as the ESTIMATE STATISTICS
option uses a sample of blocks or percentage of the index to estimate the
statistics, not rows

CORRECT

ANALYZE INDEX scott.emp_I;

Which of the following completes the command?

COMPUTE STATISTICS : Collects detailed statistics for the index.


ESTIMATE STATISTICS : Provides an estimated statistical summary.
DELETE STATISTICS : Removes existing statistics for the index.
VALIDATE STRUCTURE : Validates the index’s structure without collecting
statistics (https://www.complexsql.com/gather-stats-in-oracle-schematables-and-
indexes/)

 All of the above

None of the Above

INCORRECT

Di#erent ways of analyzing statistics in oracle

Analyze Command

 DBMS_STATS Package

Both ways . But DBMS_STATS is recommended by oracle.

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 7 of 17
:
CORRECT

To update statistics for an index, you can use the DBMS_STATS package.

Example:

SQL

EXEC DBMS_STATS.GATHER_TABLE_STATS ('my_schema', 'my_table');

Explanation:

The GATHER_TABLE_STATS procedure collects statistics for the speci"ed table


(including all its indexes).

Replace 'my_schema' and 'my_table' with the actual schema and table names.

False

 TRUE

CORRECT

What are stale statistics in oracle indexes?

 A) Statistics that are outdated and do not re!ect the current state of the index.

B) Statistics that are corrupted and do not match the index structure.

C) Statistics that are missing and do not exist for the index.

D) Statistics that are invalid and do not comply with the optimizer rules.

Correct Answer:A: Stale statistics are statistics that are outdated and do not
re$ect the current state of the index. This can happen when the index
undergoes signi"cant changes, such as inserts, updates, deletes, or splits.
Incorrect Answers
(B) Incorrect. Statistics that are corrupted and do not match the index
structure are not stale, but invalid. This can happen due to bugs or errors in
the statistics collection process. Incorrect. Statistics that are missing and do

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 8 of 17
:
not exist for the index are not stale, but absent. This can happen when the
index is newly created or the statistics are explicitly deleted3. (D) Incorrect.
Statistics that are invalid and do not comply with the optimizer rules are not
stale, but inconsistent. This can happen when the statistics are manually
modi"ed or manipulated.

CORRECT

How can you tell if an index has stale statistics in Oracle?

 A) By checking the STALE_STATS column in the DBA_TAB_STATISTICS view.

B) By checking the LAST_ANALYZED column in the DBA_INDEXES view.

C) By checking the STATTYPE_LOCKED column in the DBA_IND_STATISTICS view.

D) By checking the USER_STATS column in the DBA_INDEXES view.

Correct Answer:A : By checking the STALE_STATS column in the


DBA_TAB_STATISTICS view, you can see if Oracle thinks the statistics on an
index are stale. If the column returns “YES”, Oracle believes that it’s time to re-
gather stats.
Incorrect Answers:
(B) Incorrect. By checking the LAST_ANALYZED column in the DBA_INDEXES
view, you can see when the statistics on an index were last collected. However,
this does not necessarily indicate if the statistics are stale or not, as the index
may have changed since then. © Incorrect. By checking the STATTYPE_LOCKED
column in the DBA_IND_STATISTICS view, you can see if the statistics on an
index are locked or not. If the column is not NULL, the statistics are locked and
cannot be modi"ed or refreshed. (D) Incorrect. By checking the USER_STATS
column in the DBA_INDEXES view, you can see if the statistics on an index are
user-de"ned or not. If the column is “YES”, the statistics are user-de"ned and
may not be accurate or consistent. Remember that stale statistics can a#ect

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 9 of 17
:
the performance of queries that use the index, as the optimizer may choose
suboptimal execution plans. Therefore, it is important to keep the statistics
up-to-date and accurate

INCORRECT

How can you prevent statistics from becoming stale on an index that is frequently
updated?

 A) By locking the statistics on the index using the DBMS_STATS.LOCK_TABLE_STATS procedure.

B) By setting the STALE_PERCENT parameter to a lower value using the


DBMS_STATS.SET_TABLE_PREFS procedure.

C) By enabling the monitoring of the index using the ALTER INDEX … MONITORING USAGE
statement.

D) By scheduling a job to gather statistics on the index periodically using the


DBMS_SCHEDULER.CREATE_JOB procedure.

Correct Answer:D ): By scheduling a job to gather statistics on the index


periodically, you can ensure that the statistics are always up-to-date and
re$ect the current state of the index. You can use the
DBMS_SCHEDULER.CREATE_JOB procedure to create a job that runs the
DBMS_STATS.GATHER_INDEX_STATS procedure at regular intervals1.
Incorrect Answers:
(A) Incorrect. By locking the statistics on the index, you can prevent them from
being modi"ed or refreshed by any user or process. This can be useful when
you have manually de"ned or imported statistics that you want to preserve,
but it does not prevent them from becoming stale due to changes in the index.
(B) Incorrect. By setting the STALE_PERCENT parameter to a lower value, you
can change the threshold that Oracle uses to determine if the statistics on a
table or index are stale. However, this does not automatically trigger the
statistics collection; you still need to enable the automatic statistics gathering

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 10 of 17
:
job or run it manually. Incorrect. By enabling the monitoring of the index, you
can track how often the index is used by queries. This can help you identify
unused or rarely used indexes that can be dropped or made invisible.
However, this does not a#ect the statistics on the index or their freshness.

INCORRECT

How can you fix the performance issues caused by stale statistics on an index?

A) By using the DBMS_STATS.GATHER_INDEX_STATS procedure to collect fresh statistics on


the index.

 B) By using the DBMS_STATS.EXPORT_INDEX_STATS and DBMS_STATS.IMPORT_INDEX_STATS


procedures to export and import statistics from another index.

C) By using the DBMS_STATS.COPY_TABLE_STATS and DBMS_STATS.COPY_INDEX_STATS


procedures to copy statistics from another table and index with similar data distribution.

D) By using the DBMS_STATS.SET_INDEX_STATS and DBMS_STATS.GET_INDEX_STATS procedures


to manually modify and view the statistics on the index.

Correct Answer:A : By using the DBMS_STATS.GATHER_INDEX_STATS procedure,


you can collect fresh statistics on the index that re$ect the current state of the
index. This can help the optimizer choose optimal execution plans for queries
that use the index.
Incorrect Answers:
(B) Incorrect. By using the DBMS_STATS.EXPORT_INDEX_STATS and
DBMS_STATS.IMPORT_INDEX_STATS procedures, you can export and import
statistics from another index. However, this is not a recommended way to "x
stale statistics, as the statistics may not be accurate or consistent for the
target index. Incorrect. By using the DBMS_STATS.COPY_TABLE_STATS and
DBMS_STATS.COPY_INDEX_STATS procedures, you can copy statistics from
another table and index with similar data distribution. However, this is not a
recommended way to "x stale statistics, as the statistics may not be accurate

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 11 of 17
:
or consistent for the target table and index. (D) Incorrect. By using the
DBMS_STATS.SET_INDEX_STATS and DBMS_STATS.GET_INDEX_STATS procedures,
you can manually modify and view the statistics on the index. However, this is
not a recommended way to "x stale statistics, as the statistics may not be
accurate or consistent for the index.

INCORRECT

Question: How can you enable the monitoring of an index to track its usage by
queries?

A) By using the ALTER INDEX … MONITORING USAGE statement.

B) By using the DBMS_STATS.SET_INDEX_PREFS procedure.

C) By using the ALTER INDEX … MONITORING STATISTICS statement.

 D) By using the DBMS_STATS.GATHER_INDEX_STATS procedure.

Correct Answer:A : By using the ALTER INDEX … MONITORING USAGE


statement, you can enable the monitoring of an index to track how often it is
used by queries. This can help you identify unused or rarely used indexes that
can be dropped or made invisible1.
Incorrect Answers:
(B) Incorrect. By using the DBMS_STATS.SET_INDEX_PREFS procedure, you can
set the preferences for gathering statistics on an index, such as the sampling
percentage or the stale percentage. Incorrect. There is no such statement as
ALTER INDEX … MONITORING STATISTICS. The correct statement is ALTER
INDEX … MONITORING USAGE. (D) Incorrect. By using the
DBMS_STATS.GATHER_INDEX_STATS procedure, you can collect statistics on an
index, such as the number of leaf blocks or the clustering factor.

INCORRECT

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 12 of 17
:
How can you check if an index is being used by any query or not?

 A) By querying the V$INDEX_USAGE view.

B) By querying the V$SQL_PLAN view.

C) By querying the V$INDEX_STATS view.

D) By querying the V$SQL_PLAN_STATISTICS view.

Correct Answer:B : By querying the V$SQL_PLAN view, you can see the
execution plan of any SQL statement in the shared pool, including the indexes
used by the statement. You can "lter the view by the index name or the object
ID to see if the index is being used by any query or not.
Incorrect Answers:
(A) Incorrect. There is no such view as V$INDEX_USAGE. The correct view is
V$OBJECT_USAGE, which shows the usage information of indexes that are
being monitored. Incorrect. There is no such view as V$INDEX_STATS. The
correct view is V$INDEXES, which shows the information about all indexes in
the database, such as the index type, status, or uniqueness5. (D) Incorrect. By
querying the V$SQL_PLAN_STATISTICS view, you can see the runtime statistics
of any SQL statement in the shared pool, such as the number of rows
processed, the bu#er gets, or the CPU time. Remember that monitoring and
checking the usage of indexes can help you improve the performance of
queries that use the index, as well as identify and eliminate unnecessary
indexes.

INCORRECT

Match the Following

Index Rebuild ONLINE (During this the exclusive lock will be applied
on the table, which will impact DDL and
DMLS.)ALTER INDEX
SCHEMA_NAME.INDEX_NAME

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 13 of 17
:
REBUILD;Alternatively we can drop and recreate
the index . (DML and DDLS operations will
work as usual, without any impact)

Index REbuild OFFLINE DML and DDLS operations will work as usual,
without any impact ((During this the exclusive
lock will be applied on the table, which will
impact DDL and DMLS.)ALTER INDEX
SCHEMA_NAME.INDEX_NAME
REBUILD;Alternatively we can drop and
recreate the index .)

ALTER INDEX SCHEMA_NAME.INDEX_NAME REBUILD ONLINE;

INCORRECT

How can we improve the speed of index creation on large table?

Create index , generates a lot of redo and these logs are of no use. So we can create the
create the index with nologgin as below.

create index TEST_INDX_object on test(object_name) nologging parallel 12;

A.create index TEST_INDX_object on test(object_name) parallel 12;

 B. we can add nologging parameter in create index statment. create index


TEST_INDX_object on test(object_name) nologging parallel 12;

C .None of the Above

D. A, B Both

CORRECT

Rowid is pseudocolumn, which contains below information.ROWID is used to get the exact
location of a row in the database.It is the fasterst way to locating a row.

When we create index, the rowids and the column_values are stored in the leaf block of the
index.

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 14 of 17
:
1. object_id
2. block number
3. position of the row in the block
4. datafile number in which the row resides.(i.e relative file number)

 A. TRUE

B. FALSE

CORRECT

Moving a table, makes the index Unusable

 A. TRUE

B. FALSE

When we move the table , the rows moved to a di#erent location and gets a
new rowid. But Index still points to the old rowids. So we need to rebuild the
index, which will make the index entries to use new set of rowids for the table
row. Di#erent reasons for index unusable is dropping table partition/truncate
partition.

CORRECT

Can I create two indexes on a same column in oracle?

A. In any version it is not possible.

 B. Prior to 12c, it was not allowed to have two indexes on same column. However from
12c onwards , we can create two indexes on same column, but the index_type should be
di#erent. i.e if i have already btree index on a column, then other index should be a bitmap.

CORRECT

We want to find the list of unused index in a database.

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 15 of 17
:
How can I do that?

A. No need to do any thing. Oracle will monitor by default

 B. We can alter the index with MONITORING USAGE clause. After the respective index
usage will be tracked.

CORRECT

Match the Following

Index Shrinking will release the free space to database

Index Coalescing combines adjacent leaf blocks into a single


block and put the new free leaf blocks in the
free list of index segment, Which can be used
by index in future. But
it will not release the free space to database.

CORRECT

Match index scan and wait event.

Normal Index Scan db $le sequential read (wait event in AWR)

Index Fast Full Scan db $le scattered read (wait event in AWR)

CORRECT

Coalasce is always prefered over index rebuild,

Because, index rebuild need twice the size to complete the activity. Also it will generate lot
of redo during the activity and there might be impact on CPU usage.

 A. TRUE

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 16 of 17
:
B. FALSE

https://dbvidya.talentlms.com/unit/viewtestsurvey/id:3198,mode:test 05/08/24, 6 19 PM
Page 17 of 17
:

You might also like