This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 59535 - Running statistics when viewing oracle tables.
Summary: Running statistics when viewing oracle tables.
Status: CLOSED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords:
: 88097 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-02 10:05 UTC by turbomillenium
Modified: 2007-01-03 16:16 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description turbomillenium 2005-06-02 10:05:36 UTC
When connecting and viewing table structures using the oracle classes12.jar,
the database explorer runs oracle statistics on these tables. 

This has direct consequences in regards to the execution plan that the oracle 
optimiser uses when executing sql statements. This should definitely not be the 
default behaviour as this is a oracle DBA type role, rather than a developer 
role.

Currently if the oracle database being used is running a rule based optimiser 
for executing sql statements, than statistics are being generated for the 
tables being viewed, and can seriously impact query perfomance as the table 
being analysed will be based on a cost based optimiser. Because of this any sql 
statements being executed will be forced to run using the cost based optimiser.
Comment 1 Andrei Badea 2005-08-19 12:53:55 UTC
I'm not aware of anything in the database explorer causing the statistics to be
generated. The database explorer only connnects to the database, asks for
DatabaseMetaData and calls methods on it for retrieving the database structure.
But I'm not an Oracle expert. Do you know what exactly causes it? 
Comment 2 Martin Schovanek 2005-08-19 15:07:16 UTC
It is definitely no P1 by Bug Priority Guidelines, see:
http://qa.netbeans.org/processes/bug_priority_guidelines.html

I expect that it is default behaviour of oracle driver, do you have a idea how
to change it?
Comment 3 neald 2005-08-19 15:47:17 UTC
I am not an expert either.  I captured the SQL being sent to the database.  The
first call is "analyze table XYZ compute statistics".  That will cause the
database to update it's statistics.  Not only is that a bad thing to do from
netbeans (it's a DBA activity), it is a very slow process, and it makes it seem
that either 1) netbeans is hanging (if you do have the privileges to run
statistics) or 2) netbeans is broken (if you do not have the privileges to run
statistics).  The solution is to remove any reference to compute statistics from
the code.  I do not know of any database platform where the "compute statistics"
call would be acceptable.

It is P1 based on at least the following items from the guidelines:
# Severe regression in performance of a feature
# Very bad UI responsiveness of a feature making the feature unusable

Displaying a table's indices -- or viewing any information about a table --
takes 10-15 minutes on many tables (and they are not that large).

If someone were to point me to the location of the code for showing the table's
indices or the initial view a table's information, I would be happy to try to
find the cause of the problem. 

Comment 4 Andrei Badea 2005-08-19 18:44:52 UTC
I agree that NetBeans should in no way explicitly cause the statistics to be
created. However, I don't believe NetBeans does it. I looked at the code and
there's no place where the "analyze table" command is sent to the database.
Really look the driver is the culprit, but I will investigate more.

In the mean time, do you think you could try to connect with another driver?
Comment 5 turbomillenium 2005-08-21 06:18:11 UTC
Hi all,

Im using with Netbeans the standard driver which was issued by Oracle.
I am using this to connect to an Oracle database.
Comment 6 Andrei Badea 2005-09-14 08:46:49 UTC
As I said in a previous post, nothing in NetBeans explicitly executes the
ANALYZE TABLE statement. However, I grepped the classes in classes12.zip for
this string and it is contained in the oracle.jdbc.OracleDatabaseMetaData class.
Probably the driver needs to analyze the table this in order to retrieve the
columns CARDINALITY and PAGES in the ResultSet returned by DMD.getIndexInfo(). 

This is not a defect in NetBeans, so closing. If you have any idea how to
workaround the driver behavior, file a new ENHANCEMENT issue.
Comment 7 Martin Schovanek 2005-09-16 09:35:46 UTC
Additional user information:
----------------------------

....
I believe the problem is here:

ResultSet rs = dmd.getIndexInfo(drvSpec.getCatalog(), drvSpec.getSchema(),
table, false, false);

The last parameter is 'approximate' - when true, result is allowed to
reflect approximate or out of data values; when false, results are requested
to be accurate

Because the parm is set to false, Oracle (and some other databases, I would
surmise) runs update statistics to gather the accurate data.  Setting the
parm to true will cause Oracle to respond with the results from the last run
of statistics.
....
Comment 8 Andrei Badea 2005-10-05 10:12:06 UTC
Fixed by retrieving the indexes using aproximate = true.

Checking in org/netbeans/modules/db/explorer/actions/AddToIndexAction.java;
/cvs/db/src/org/netbeans/modules/db/explorer/actions/AddToIndexAction.java,v 
<--  AddToIndexAction.java
new revision: 1.28; previous revision: 1.27
done
Checking in org/netbeans/modules/db/explorer/dlg/AddTableColumnDialog.java;
/cvs/db/src/org/netbeans/modules/db/explorer/dlg/AddTableColumnDialog.java,v 
<--  AddTableColumnDialog.java
new revision: 1.35; previous revision: 1.34
done
Checking in org/netbeans/modules/db/explorer/infos/IndexListNodeInfo.java;
/cvs/db/src/org/netbeans/modules/db/explorer/infos/IndexListNodeInfo.java,v  <--
 IndexListNodeInfo.java
new revision: 1.30; previous revision: 1.29
done
Checking in org/netbeans/modules/db/explorer/infos/IndexNodeInfo.java;
/cvs/db/src/org/netbeans/modules/db/explorer/infos/IndexNodeInfo.java,v  <-- 
IndexNodeInfo.java
new revision: 1.33; previous revision: 1.32
done
Checking in org/netbeans/modules/db/explorer/infos/TableNodeInfo.java;
/cvs/db/src/org/netbeans/modules/db/explorer/infos/TableNodeInfo.java,v  <-- 
TableNodeInfo.java
new revision: 1.40; previous revision: 1.39
done
Checking in org/netbeans/modules/db/explorer/nodes/IndexNode.java;
/cvs/db/src/org/netbeans/modules/db/explorer/nodes/IndexNode.java,v  <-- 
IndexNode.java
new revision: 1.25; previous revision: 1.24
done
Comment 9 Martin Schovanek 2005-11-18 17:42:20 UTC
VERIFIED
Comment 10 Andrei Badea 2007-01-03 16:16:17 UTC
*** Issue 88097 has been marked as a duplicate of this issue. ***