dex statistics are not available in these catalog views,
we additionally have to call the DBCC-command
SHOW
STATISTICS. SHOW STATISTICS requires
an index name or the name of a statistics group as
target. Regarding statistics a statistics group in SQL
Server is similar to an index. A column can be part
of multiple statistics groups and a statistics group
can contain multiple columns but detailed information
and a histogram is only available for the first column
in a statistics group or index. So, we have to query
the catalog views to get the names of all statistics
groups and indexes where the given column is in the
first place. When this query returns multiple occur-
rences, we choose the latest, i.e., the one that has been
updated last. Then we can call SHOW
STATISTICS
with the name of this statistics group or index.
To avoid the execution of a query but to get the
associated cost and cardinality estimate, we must set
SHOWPLAN ALL ON. Afterwards, when we send
a SQL statement to the database, it returns the query
plan including some additional information in a tabu-
lar format as result set. We read the cardinality esti-
mate and the cost estimate contained in the first return
row and set SHOWPLAN
ALL back to OFF.
Indexes can be identified by their name and the
name and schema of the associated table. This is due
to the fact, that in SQL Server an index is tightly cou-
pled with the associated table. Hence, the same name
can be used for multiple indexes as long as they are
not associated with the same table.
To get access to the full functionality of the Statis-
tics API, the account used by the application to con-
nect to the database must own the server-role sysad-
min or the database-role db
owner.
5 CONCLUSION AND FUTURE
WORK
In this paper we proposed a DBMS-independent
JAVA interface that provides read access as well as
write access to statistics stored in databases on dif-
ferent relational DBMSs. This interface provides not
just a set of methods but also a set of data structures to
store the retrieved data in a DBMS-independent for-
mat. It can be viewed as an extension and unifica-
tion of existing interfaces used for statistics retrieval
or costing of statements.
In the future, the Statistics API can be enriched by
additional statistics or meta data elements as needed.
Extension to handle multidimensional histograms are
also possible. Further points for improvements are
already given in the text. Although relational DBMSs
dominate, an extension of our approach to other than
relational backend DBMSs and data stores is another
valuable next step.
REFERENCES
Ellis, J., Ho, L., and Fisher, M. (2001). JDBC(TM) 3.0
Specification, Final Release. Sun Microsystems, Inc.
Ewen, S., Ortega-Binderberger, M., and Markl, V. (2005).
A learning optimizer for a federated database manage-
ment system. In Proc. BTW, Karlsruhe, Germany.
IBM (2004a). IBM DB2 Information Integrator, Wrapper
Developer’s Guide, Version 8.2. IBM Corp.
IBM (2004b). IBM DB2 Universal Database, Administra-
tion Guide: Performance, Version 8.2. IBM Corp.
IBM (2004c). IBM DB2 Universal Database, SQL Refer-
ence Volume 1, Version 8.2. IBM Corp.
Ioannidis, Y. (2003). The History of Histograms (abridged).
In Proc. VLDB, Berlin, Germany.
Kraft, T., Schwarz, H., Rantzau, R., and Mitschang, B.
(2003). Coarse-Grained Optimization: Techniques for
Rewriting SQL Statement Sequences. In Proc. VLDB,
Berlin, Germany.
Lu, H., Ooi, B. C., and Goh, C. H. (1993). Multidatabase
Query Optimization: Issues and Solutions. In Proc.
RIDE-IMS, Vienna, Austria.
Melton, J., Michels, J.-E., Josifovski, V., Kulkarni, K. G.,
and Schwarz, P. M. (2002). SQL/MED - A Status Re-
port. SIGMOD Record, 31(3):81–89.
Melton, J., Michels, J.-E., Josifovski, V., Kulkarni, K. G.,
Schwarz, P. M., and Zeidenstein, K. (2001). SQL
and Management of External Data. SIGMOD Record,
30(1):70–77.
Microsoft (2006). SQL Server 2005 Books Online -
Transact-SQL Reference. http://msdn2.microsoft.com/
en-us/library/ms189826.aspx. Microsoft Corp.
Oracle (2003a). Oracle Database Performance Tuning
Guide, 10g Release 1 (10.1). Oracle Corp.
Oracle (2003b). Oracle Database Reference, 10g Release 1
(10.1). Oracle Corp.
Oracle (2003c). PL/SQL Packages and Types Reference,
10g Release 1 (10.1). Oracle Corp.
Oracle (2006). Ask Tom. http://asktom.oracle.com/. Oracle
Corp.
Roth, M. T., Arya, M., Haas, L. M., Carey, M. J., Cody,
W. F., Fagin, R., Schwarz, P. M., Thomas II, J., and
Wimmers, E. L. (1996). The Garlic Project. In Proc.
SIGMOD, Montreal, Quebec, Canada.
Roth, M. T., Ozcan, F., and Haas, L. M. (1999). Cost Mod-
els DO Matter: Providing Cost Information for Di-
verse Data Sources in a Federated System. In Proc.
VLDB, Edinburgh, Scotland, UK.
Selinger, P., Astrahan, M., Chamberlin, D., Lorie, R., and
Price, T. (1979). Access Path Selection in a Relational
Database Management System. In Proc. SIGMOD,
Boston, Massachusetts, USA.
ICEIS 2007 - International Conference on Enterprise Information Systems
12