public int queryExeCount(String filterMd5, String filterExeName, long filterArch,
		long filterCompilerName, boolean includeFakes) throws SQLException {

		if (StringUtils.isAnyBlank(filterMd5)) {
			filterMd5 = null;
		}
		if (StringUtils.isAnyBlank(filterExeName)) {
			filterExeName = null;
		}

		StringBuilder buffer = new StringBuilder();
		buffer.append("SELECT ALL COUNT(*) FROM ");
		buffer.append(TABLE_NAME);
		buffer.append(" ");
		if (filterMd5 != null || filterExeName != null || filterArch != 0 ||
			filterCompilerName != 0 || !includeFakes) {
			buffer.append("WHERE (");
			boolean needAnd = false;
			if (!includeFakes) {
				buffer.append("md5 NOT ILIKE 'bbbbbbbbaaaaaaaa%' ");
				needAnd = true;
			}
			if (filterMd5 != null) {
				if (needAnd) {
					buffer.append("AND ");
				}
				if (filterMd5.length() == 32) {	// A complete md5 value
					buffer.append("md5 = ? ");
				}
				else {						// A partial md5 prefix
					buffer.append("md5 ILIKE ? ");
					filterMd5 = filterMd5 + '%';	// match anything at the end	
				}
				needAnd = true;
			}
			if (filterExeName != null) {
				if (needAnd) {
					buffer.append("AND ");
				}
				buffer.append("name_exec ILIKE ? ");
				filterExeName = '%' + filterExeName + '%';
				needAnd = true;
			}
			if (filterArch != 0) {
				if (needAnd) {
					buffer.append("AND ");
				}
				buffer.append("architecture = ? ");
				needAnd = true;
			}
			if (filterCompilerName != 0) {
				if (needAnd) {
					buffer.append("AND ");
				}
				buffer.append("name_compiler = ? ");
			}
			buffer.append(')');
		}

		int pos = 1;
		String query = buffer.toString();
		try (PreparedStatement selectExeCountStatement = db.prepareStatement(query)) {
			if (filterMd5 != null) {
				selectExeCountStatement.setString(pos++, filterMd5);
			}
			if (filterExeName != null) {
				selectExeCountStatement.setString(pos++, filterExeName);
			}
			if (filterArch != 0) {
				selectExeCountStatement.setInt(pos++, (int) filterArch);
			}
			if (filterCompilerName != 0) {
				selectExeCountStatement.setInt(pos++, (int) filterCompilerName);
			}

			try (ResultSet rs = selectExeCountStatement.executeQuery()) {
				rs.next();
				int count = rs.getInt(1);
				return count;
			}
			catch (Exception e) {
				return 0;
			}
		}
	}
Returns a count of all records in the database matching the filter criteria.

@param filterMd5 md5 must contain this
@param filterExeName exe name must contain this
@param filterArch if non-zero, force matching architecture id
@param filterCompilerName if non-zero, force matching compiler id
@param includeFakes if true, include MD5s that start with 'bbbbbbbbaaaaaaa'
@return total number of records in the database
@throws SQLException when preparing or executing the query
Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/ExeTable.java