public static void addQuery(Type type, String sql, Duration time) {
        // Do nothing if we didn't receive a sql statement
        if (sql == null || sql.isEmpty()) {
            return;
        }

        // Do nothing if profiling has stopped.
        if (startTime == null || (endTime != null && endTime.isAfter(startTime))) {
            return;
        }

        // clean up sql to insert spaces after every ','
        sql = reformatQuery(sql);

        // remove values from query
        sql = removeQueryValues(sql);

        ProfiledConnectionEntry entry;
        switch (type) {
            case select:
                selectCount++;
                totalSelectTime = totalSelectTime.plus(time);
                entry = selectQueries.get(sql);
                if (entry == null) {
                    entry = new ProfiledConnectionEntry(sql);
                    selectQueries.put(sql, entry);
                }
                break;
            case update:
                updateCount++;
                totalUpdateTime = totalUpdateTime.plus(time);
                entry = updateQueries.get(sql);
                if (entry == null) {
                    entry = new ProfiledConnectionEntry(sql);
                    updateQueries.put(sql, entry);
                }
                break;
            case insert:
                insertCount++;
                totalInsertTime = totalInsertTime.plus(time);
                entry = insertQueries.get(sql);
                if (entry == null) {
                    entry = new ProfiledConnectionEntry(sql);
                    insertQueries.put(sql, entry);
                }
                break;
            case delete:
                deleteCount++;
                totalDeleteTime = totalDeleteTime.plus(time);
                entry = deleteQueries.get(sql);
                if (entry == null) {
                    entry = new ProfiledConnectionEntry(sql);
                    deleteQueries.put(sql, entry);
                }
                break;
            default:
                throw new IllegalArgumentException("Invalid type");
        }

        entry.count++;
        entry.totalTime = entry.totalTime.plus(time);
    }
Adds a query.

@param type the type of the query.
@param sql the insert sql string.
@param time the length of time the query took in milliseconds
xmppserver/src/main/java/org/jivesoftware/database/ProfiledConnection.java