Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package BDScripts;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.ArrayList;
- import java.util.List;
- import DBClasses.Client;
- import DBClasses.Device;
- public class IndexChecker
- {
- private int counterS, counterE ;
- private Connection myConn;
- public IndexChecker ()
- {
- try {
- myConn = DriverManager.getConnection("jdbc:mysql://localhost:3307/serwispusty", "root", "servroot");
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public void checkIndexesModel ()
- {
- long startnoInd, endnoInd, startInd, endInd, resnoInd, resInd, res;
- ResultSet resultsInd, resultsnoInd;
- try
- {
- Statement keysStatement0 = myConn.createStatement();
- Statement keysStatement1 = myConn.createStatement();
- Statement selectStatement1 = myConn.createStatement();
- Statement selectStatement2 = myConn.createStatement();
- //
- startnoInd = System.nanoTime(); //System.currentTimeMillis();
- resultsnoInd = selectStatement2.executeQuery("select * from serwispusty.urzadzenie where Model = 'B6726'"); //("select * from serwispusty.urzadzenie where Model like 'B%'");
- while (resultsnoInd.next())
- {
- ;
- }
- endnoInd = System.nanoTime(); //System.currentTimeMillis();
- res = endnoInd - startnoInd;
- //
- keysStatement0.executeUpdate("create index by_model on serwispusty.urzadzenie (Model)");
- startInd = System.nanoTime(); //System.currentTimeMillis();
- resultsInd = selectStatement2.executeQuery("select * from serwispusty.urzadzenie where Model = 'B6726'");
- while (resultsInd.next())
- {
- ;
- }
- endInd = System.nanoTime(); //System.currentTimeMillis();
- keysStatement1.executeUpdate("ALTER TABLE serwispusty.urzadzenie DROP INDEX by_model");
- startnoInd = System.nanoTime(); //System.currentTimeMillis();
- resultsnoInd = selectStatement2.executeQuery("select * from serwispusty.urzadzenie where Model = 'B6726'");
- while (resultsnoInd.next())
- {
- ;
- }
- endnoInd = System.nanoTime(); //System.currentTimeMillis();
- resnoInd = endnoInd - startnoInd;
- resInd = endInd - startInd;
- System.out.println("Czas bez ind: " + resnoInd);
- System.out.println("Czas z ind : " + resInd);
- System.out.println("spr : " + res);
- }
- catch ( Exception e)
- {
- System.out.println("Blad");
- }
- }
- public static void main(String[] args)
- {
- IndexChecker obj = new IndexChecker();
- System.out.println("Czasy sprawdzenia modelu");
- obj.checkIndexesModel();
- System.out.println("///////////////////////////////////////////////");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement