<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #15744 # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. ## Testing - [x] Added/updated automated tests - [ ] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [x] QA'd all new/changed functionality manually Manually inserted 10k hosts and random emails associated to them. Response times were always below 200ms locally. We already have covering indexes so we don't need a migration. https://github.com/user-attachments/assets/721db4f1-f3c9-4ede-ba62-499ac30c4a02 SQL used: ```sql -- Seed 10k hosts for performance testing email search. -- Requires: SET cte_max_recursion_depth = 10000; -- -- Distribution (by osquery_host_id suffix): -- 1-2500: Chrome profile email only -- 2501-5000: IdP email only -- 5001-7500: Both Chrome profile and IdP emails -- 7501-10000: No email association -- Generate 10k hosts using a recursive CTE INSERT INTO hosts (osquery_host_id, node_key, hostname, uuid, platform, detail_updated_at, label_updated_at, policy_updated_at) WITH RECURSIVE seq AS ( SELECT 1 AS n UNION ALL SELECT n + 1 FROM seq WHERE n < 10000 ) SELECT CONCAT('perf-osq-', n), CONCAT('perf-nk-', n), CONCAT('perf-host-', n), CONCAT('perf-uuid-', n), 'darwin', NOW(), '2000-01-01 00:00:00', '2000-01-01 00:00:00' FROM seq; -- Populate display names so that hosts are visible in the UI. INSERT INTO host_display_names (host_id, display_name) SELECT id, hostname FROM hosts WHERE osquery_host_id LIKE 'perf-osq-%'; -- 1-2500: Chrome profile email only INSERT INTO host_emails (host_id, email, source) SELECT id, CONCAT('chrome-', id, '@example.com'), 'google_chrome_profiles' FROM hosts WHERE osquery_host_id LIKE 'perf-osq-%' AND CAST(SUBSTRING(osquery_host_id, 10) AS UNSIGNED) BETWEEN 1 AND 2500; -- 2501-5000: IdP email only INSERT INTO host_emails (host_id, email, source) SELECT id, CONCAT('idp-', id, '@example.com'), 'mdm_idp_accounts' FROM hosts WHERE osquery_host_id LIKE 'perf-osq-%' AND CAST(SUBSTRING(osquery_host_id, 10) AS UNSIGNED) BETWEEN 2501 AND 5000; -- 5001-7500: Both Chrome profile and IdP emails INSERT INTO host_emails (host_id, email, source) SELECT id, CONCAT('chrome-', id, '@example.com'), 'google_chrome_profiles' FROM hosts WHERE osquery_host_id LIKE 'perf-osq-%' AND CAST(SUBSTRING(osquery_host_id, 10) AS UNSIGNED) BETWEEN 5001 AND 7500; INSERT INTO host_emails (host_id, email, source) SELECT id, CONCAT('idp-', id, '@example.com'), 'mdm_idp_accounts' FROM hosts WHERE osquery_host_id LIKE 'perf-osq-%' AND CAST(SUBSTRING(osquery_host_id, 10) AS UNSIGNED) BETWEEN 5001 AND 7500; -- 7501-10000: no emails (nothing to insert) -- Cleanup: -- DELETE FROM host_emails WHERE host_id IN (SELECT id FROM hosts WHERE osquery_host_id LIKE 'perf-osq-%'); -- DELETE FROM host_display_names WHERE host_id IN (SELECT id FROM hosts WHERE osquery_host_id LIKE 'perf-osq-%'); -- DELETE FROM hosts WHERE osquery_host_id LIKE 'perf-osq-%'; ```
2 lines
114 B
Plaintext
2 lines
114 B
Plaintext
* Improved host search to always match against host email addresses, not only when the query looks like an email.
|