@@ -0,0 +1,2266 @@
+/*%0A * Copyright (C) 2004 EBI, GRL%0A * %0A * This library is free software; you can redistribute it and/or modify it under the terms of the%0A * GNU Lesser General Public License as published by the Free Software Foundation; either version%0A * 2.1 of the License, or (at your option) any later version.%0A * %0A * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without%0A * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU%0A * Lesser General Public License for more details.%0A * %0A * You should have received a copy of the GNU Lesser General Public License along with this library;%0A * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA%0A * 02111-1307 USA%0A */%0A%0Apackage org.ensembl.healthcheck.testcase.generic;%0A%0Aimport java.sql.Connection;%0A%0Aimport org.ensembl.healthcheck.DatabaseRegistryEntry;%0Aimport org.ensembl.healthcheck.ReportManager;%0Aimport org.ensembl.healthcheck.Species;%0Aimport org.ensembl.healthcheck.testcase.Priority;%0Aimport org.ensembl.healthcheck.testcase.SingleDatabaseTestCase;%0Aimport org.ensembl.healthcheck.util.DBUtils;%0A%0A/**%0A * Check whether tables need to be analysed.%0A */%0Apublic class AnalyseTables extends SingleDatabaseTestCase %7B%0A%0A%09/**%0A%09 * Creates a new instance of AnalyseTables%0A%09 */%0A%09public AnalyseTables() %7B%0A%0A%09%09addToGroup(%22release%22);%0A%09%09setDescription(%22Check whether tables need to be analysed.%22);%0A%09%09setPriority(Priority.AMBER);%0A%09%09setEffect(%22Causes indices not to be used, making queries slow or unresponsive.%22);%0A%09%09setFix(%22Run ANALYSE TABLE x.%22);%0A%09%09setTeamResponsible(%22ReleaseCoordinator%22);%0A%09%09%0A%09%7D%0A%0A%09/**%0A%09 * Run the test.%0A%09 * %0A%09 */%0A%09public boolean run(DatabaseRegistryEntry dbre) %7B%0A%0A%09%09boolean result = true;%0A%0A%09%09Connection con = dbre.getConnection();%0A%09%09%0A%09%09String%5B%5D tables = DBUtils.getTableNames(con);%0A%0A%09%09for (int i = 0; i %3C tables.length; i++) %7B%0A%0A%09%09%09String table = tables%5Bi%5D;%0A%09%09%09%0A%09%09%09int results = getRowCount(con, %22 SHOW INDEX FROM %22 + table + %22 WHERE CARDINALITY IS NULL%22);%0A%09%09%09%0A%09%09%09if (results %3E 0) %7B%0A%09%09%09%09ReportManager.problem(this, con, table + %22 needs to be analysed%22);%0A%09%09%09%09result = false;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09return result;%0A%0A%09%7D // run%0A%0A%09// -----------------------------------------------------------------------%0A%0A%7D // AnalyseTables%0A%0A

Check whether tables need to be analysed to improve index performance.