Commit 2a0a512
Add source filter and indexed hash prefix to cert tag batch query (#27847)
* Add source filter and use indexed hash prefix in cert tag batch query
The certification tag batch query (TagUsageDAO.getCertTagsInternalBatch)
was hitting ~12 seconds per call on instances with deep classification
hierarchies — fired ~5,800 times per Data Insights run, contributing
~19 hrs of cumulative DB time per DI run.
Two missing index-friendly predicates caused the slowness:
1. No `source = ?` filter — couldn't use idx_tag_usage_target_exact
(source, targetFQNHash, state) INCLUDE (tagFQN, labelType) whose
covering INCLUDE has tagFQN.
2. `tagFQN LIKE 'Certification.%'` on the raw column — there's no
LIKE-friendly index on raw tagFQN, only on tagfqn_lower text_pattern_ops
and tagFQNHash. The LIKE always ran as a post-filter on every row the
IN clause returned.
Fix:
- Add `source = :source` filter (Certifications are always Classification
source = 0).
- Switch `tagFQN LIKE :tagFQNPrefix` → `tagFQNHash LIKE :tagFQNHashPrefix`,
with the hash prefix pre-computed via FullyQualifiedName.buildHash so the
query hits the indexed hash column.
Same SQL on MySQL and Postgres — no @ConnectionAwareSqlQuery split needed.
Also a correctness improvement: the `source = 0` filter excludes glossary
terms (source = 1) that happen to have FQNs starting with "Certification.".
Previously such glossary terms could be incorrectly returned as
certifications; now they're excluded as expected.
Test:
- Added test_certBatch_bulkFetchReturnsCorrectCertsPerEntity in
TagResourceIT — exercises the bulk fetch path with three schemas
(cert-tagged / untagged / non-cert-tagged) and asserts each gets
the right certification (or null) in the listed response. Locks in
source-filter correctness and prevents future regressions where a
non-cert tag could leak into the certification field.
* Fix duplicate schema names in cert batch test, trim verbose comments
* Update EntityRepositoryCertificationTest mocks for new getCertTagsInternalBatch signature
* fix check style
(cherry picked from commit 4a2f42f)1 parent cc454b3 commit 2a0a512
4 files changed
Lines changed: 126 additions & 14 deletions
File tree
- openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests
- openmetadata-service/src
- main/java/org/openmetadata/service/jdbi3
- test/java/org/openmetadata/service/jdbi3
Lines changed: 98 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1444 | 1444 | | |
1445 | 1445 | | |
1446 | 1446 | | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
1447 | 1545 | | |
1448 | 1546 | | |
1449 | 1547 | | |
| |||
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4963 | 4963 | | |
4964 | 4964 | | |
4965 | 4965 | | |
4966 | | - | |
4967 | | - | |
| 4966 | + | |
| 4967 | + | |
| 4968 | + | |
4968 | 4969 | | |
4969 | 4970 | | |
4970 | 4971 | | |
| 4972 | + | |
4971 | 4973 | | |
4972 | | - | |
| 4974 | + | |
4973 | 4975 | | |
4974 | 4976 | | |
4975 | 4977 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3722 | 3722 | | |
3723 | 3723 | | |
3724 | 3724 | | |
3725 | | - | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
3726 | 3728 | | |
3727 | 3729 | | |
3728 | 3730 | | |
| |||
7792 | 7794 | | |
7793 | 7795 | | |
7794 | 7796 | | |
7795 | | - | |
| 7797 | + | |
| 7798 | + | |
| 7799 | + | |
| 7800 | + | |
| 7801 | + | |
| 7802 | + | |
7796 | 7803 | | |
7797 | 7804 | | |
7798 | 7805 | | |
| |||
Lines changed: 14 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
209 | | - | |
| 210 | + | |
210 | 211 | | |
211 | 212 | | |
212 | 213 | | |
| |||
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
230 | | - | |
| 231 | + | |
| 232 | + | |
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
| |||
282 | 284 | | |
283 | 285 | | |
284 | 286 | | |
285 | | - | |
| 287 | + | |
| 288 | + | |
286 | 289 | | |
287 | 290 | | |
288 | 291 | | |
| |||
393 | 396 | | |
394 | 397 | | |
395 | 398 | | |
396 | | - | |
| 399 | + | |
| 400 | + | |
397 | 401 | | |
398 | 402 | | |
399 | 403 | | |
| |||
415 | 419 | | |
416 | 420 | | |
417 | 421 | | |
418 | | - | |
| 422 | + | |
419 | 423 | | |
420 | 424 | | |
421 | 425 | | |
| |||
433 | 437 | | |
434 | 438 | | |
435 | 439 | | |
436 | | - | |
| 440 | + | |
437 | 441 | | |
438 | 442 | | |
439 | 443 | | |
| |||
568 | 572 | | |
569 | 573 | | |
570 | 574 | | |
571 | | - | |
| 575 | + | |
| 576 | + | |
572 | 577 | | |
573 | 578 | | |
574 | 579 | | |
| |||
0 commit comments