"bughunter@ru" <a.********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
For example - very large table with a lot indexes and updates work very
slow. I'd like found unused or rarely used indexes. How? Yes, for
static I found all sql in packages and, after analyse, drop/recreate
some indexes. But for dynamic I have no idea. Only drop all and monitor
RR :-) Inhumanely, IMHO
Dynamic SQL is, in effect, SQL that is generated live at the moment the
query is being run. For instance, if you go to a command line and write a
SELECT, INSERT, UPDATE, or DELETE statement, then press Enter, you are doing
dynamic SQL.
I don't see how you can possibly anticipate which indexes dynamic queries
will need before you've written them.
If you have somehow kept a large proportion of the dynamic SQL that you and
your users have written in the past, you might be able to analyze it and see
patterns that would tell you what indexes are likely to be used by those
queries, assuming that the queries written in the future are similar to the
ones written in the past. But dynamic SQL queries are often not saved and,
even if they are, future queries might differ substantially from queries in
the past. After all, if a dynamic query starts getting used heavily, it is
probably a good candidate to be made into static SQL, perhaps in an
application or stored procedure. Therefore, the most popular dynamic queries
probably become static queries over time and then dynamic queries will do
different things than they did when the database was newer.
It may be best to handle this problem reactively, i.e. drop all indexes that
aren't heavily used by your static queries and then wait for the users to
start screaming about dynamic queries that are suddenly much slower. Those
queries will give you big clues about where you need additional indexes - or
where dynamic queries should be made static by putting them in applications
or stored procedures.
Just my two cents worth....
Rhino